Skip to content

[css-anchor-position-1] Fix intrinsic layout of anchor-positioned element after visibility change#35418

Merged
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
Scony:281728-css-fix-anchor-position-layout
Oct 20, 2024
Merged

[css-anchor-position-1] Fix intrinsic layout of anchor-positioned element after visibility change#35418
webkit-commit-queue merged 1 commit intoWebKit:mainfrom
Scony:281728-css-fix-anchor-position-layout

Conversation

@Scony
Copy link
Copy Markdown
Contributor

@Scony Scony commented Oct 18, 2024

8a01164

[css-anchor-position-1] Fix intrinsic layout of anchor-positioned element after visibility change
https://bugs.webkit.org/show_bug.cgi?id=281728

Reviewed by Antti Koivisto.

Since style resolution is not being done in one pass when anchoring is used, block elements hold its children resolution until resolving anchors is done.
In that case - when it finally happens - the resolution of block element children is not enforced (as it would be during 1st pass) and the children are
not willing to "force update" and create renderers in the process. The net outcome is that children of elements that became visible again, are not rendered.

This change fixes the above issue by extending one of the conditions that leads to creation of renderers when the resolution is deferred due to anchoring.

* LayoutTests/TestExpectations:
* Source/WebCore/style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::determineResolutionType):

Canonical link: https://commits.webkit.org/285486@main

5aa9afe

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🧪 bindings ✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ✅ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🧪 mac-wk1 ✅ 🛠 wpe-cairo
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 ✅ 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ✅ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@Scony Scony self-assigned this Oct 18, 2024
@Scony Scony added the CSS Cascading Style Sheets implementation label Oct 18, 2024
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Oct 18, 2024
@Scony Scony requested a review from anttijk October 18, 2024 11:31
@Scony Scony removed the merging-blocked Applied to prevent a change from being merged label Oct 18, 2024
Copy link
Copy Markdown
Contributor

@anttijk anttijk Oct 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix seems logically correct (if we don't have a style we need to compute it). Can you tell why this hasn't caused trouble elsewhere and why it does cause trouble with anchor positioning?

You can just write

if (!existingStyle || existingStyle->hasExplicitlyInheritedProperties())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

As for why it does work without anchor positioning - in that scenarios the resolution of children of element that became visible again is being done altogether always. In that case, in WebCore::Style::TreeResolver::computeDescendantsToResolve() we're hitting case Change::Renderer: that forces full resolution (yields DescendantsToResolve::All). Moreover, further down the road in TreeResolver::determineResolutionType() we have combinedValidity equal to WebCore::Style::Validity::SubtreeInvalid (for entire subtree) that leads to full resolution of all subtree elements. With anchor-positioning, if the element that become visible again is anchor positioned, at the point when update.change resolves to Change::Renderer only the original element creates renderer - it's children have to wait for anchor-positioning resolution. When it finally is done (few passes after) the update.change resolves to DescendantsToResolve::ChildrenWithExplicitInherit which then leads to no resolution in TreeResolver::determineResolutionType() as such corner-case was never happening before. The fix proposed in this PR just handles such unhanded case.

@Scony Scony force-pushed the 281728-css-fix-anchor-position-layout branch from c01441f to 5aa9afe Compare October 20, 2024 14:03
@Scony Scony added the merge-queue Applied to send a pull request to merge-queue label Oct 20, 2024
…ment after visibility change

https://bugs.webkit.org/show_bug.cgi?id=281728

Reviewed by Antti Koivisto.

Since style resolution is not being done in one pass when anchoring is used, block elements hold its children resolution until resolving anchors is done.
In that case - when it finally happens - the resolution of block element children is not enforced (as it would be during 1st pass) and the children are
not willing to "force update" and create renderers in the process. The net outcome is that children of elements that became visible again, are not rendered.

This change fixes the above issue by extending one of the conditions that leads to creation of renderers when the resolution is deferred due to anchoring.

* LayoutTests/TestExpectations:
* Source/WebCore/style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::determineResolutionType):

Canonical link: https://commits.webkit.org/285486@main
@webkit-commit-queue webkit-commit-queue force-pushed the 281728-css-fix-anchor-position-layout branch from 5aa9afe to 8a01164 Compare October 20, 2024 18:46
@webkit-commit-queue
Copy link
Copy Markdown
Collaborator

Committed 285486@main (8a01164): https://commits.webkit.org/285486@main

Reviewed commits have been landed. Closing PR #35418 and removing active labels.

@webkit-commit-queue webkit-commit-queue merged commit 8a01164 into WebKit:main Oct 20, 2024
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Oct 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CSS Cascading Style Sheets implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants