Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 87540245e4490d299da57a929766347d430c40c9
https://github.com/WebKit/WebKit/commit/87540245e4490d299da57a929766347d430c40c9
Author: Kiet Ho <[email protected]>
Date: 2025-08-14 (Thu, 14 Aug 2025)
Changed paths:
M LayoutTests/TestExpectations
M
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/base-style-invalidation-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-basic-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-basic.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-change-fallbacks-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-change-fallbacks.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-change-try-rule-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-change-try-rule.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-iframe-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-iframe.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-intermediate-ignored-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-intermediate-ignored.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-pseudo-element-basic-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-pseudo-element-basic.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-pseudo-element-fallbacks-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-pseudo-element-fallbacks.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/position-try-transition-basic.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/position-try-transition-flip.html
M
LayoutTests/imported/w3c/web-platform-tests/css/css-transitions/after-change-style-inherited-try-fallback-expected.txt
M Source/WebCore/rendering/style/RenderStyle.cpp
M Source/WebCore/rendering/style/RenderStyle.h
M Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp
M Source/WebCore/rendering/style/StyleRareNonInheritedData.h
M Source/WebCore/style/StyleTreeResolver.cpp
M Source/WebCore/style/StyleTreeResolver.h
Log Message:
-----------
[css-anchor-position-1] Implement remembering last-successful position option
for layout stability
rdar://154352444
https://bugs.webkit.org/show_bug.cgi?id=295009
Reviewed by Antti Koivisto.
Previously, when an element's style is resolved, the position-try fallback
options are re-tried from scratch. This can lead to layout instability, where
an element jumps around as soon as the style changes and another fallback
wins out. To remedy this, when trying fallback options, we remember the
successful fallback, and in the next style resolution, try that fallback
first before other options.
[1]: https://github.com/w3c/csswg-drafts/issues/12577
* LayoutTests/TestExpectations:
- Add expectation for
imported/w3c/web-platform-tests/css/css-anchor-position/anchor-position-non-anchored-fallback.html,
might be a test error, see [1]
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/base-style-invalidation-expected.txt:
- Adjust expectation. Might be a test error, see [1]
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-basic-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-basic.html:
- Update test to account for shifting anchor-positioned element for safety.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-change-fallbacks-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-change-fallbacks.html:
- Update test to account for shifting anchor-positioned element for safety.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-change-try-rule-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-change-try-rule.html:
- Update test to account for shifting anchor-positioned element for safety.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-iframe-expected.txt:
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-iframe.html:
- Update test to account for shifting anchor-positioned element for safety.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-intermediate-ignored-expected.txt
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-intermediate-ignored.html
- Update test to account for shifting anchor-positioned element for safety.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-pseudo-element-basic-expected.txt:
Copied from
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-basic-expected.txt.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-pseudo-element-basic.html:
Copied from
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-basic.html.
- Add a test to test last-successful fallback behavior on pseudo-element
anchor-positioned elements.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-pseudo-element-fallbacks-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-pseudo-element-fallbacks.html:
Copied from
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/last-successful-change-fallbacks.html.
- Add a test to test last-successful fallback behavior on pseudo-element
anchor-positioned elements.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/position-try-transition-basic.html:
- Fix a bug where the test doesn't explicitly un-apply position-try.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-anchor-position/position-try-transition-flip.html:
- Fix a bug where the test doesn't explicitly un-apply position-try.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-transitions/after-change-style-inherited-try-fallback-expected.txt:
* Source/WebCore/rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::lastSuccessfulPositionTryFallbackIndex const):
(WebCore::RenderStyle::setLastSuccessfulPositionTryFallbackIndex):
* Source/WebCore/rendering/style/RenderStyle.h:
- Add methods to set/get lastSuccessfulPositionTryFallbackIndex
* Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
(WebCore::StyleRareNonInheritedData::operator== const):
(WebCore::StyleRareNonInheritedData::dumpDifferences const):
* Source/WebCore/rendering/style/StyleRareNonInheritedData.h:
- Add RenderStyle::lastSuccessfulPositionTryFallbackIndex to store the index
of the last successful fallback.
* Source/WebCore/style/StyleTreeResolver.h:
- Each option is now a PositionOption, which includes the resulting style,
and the index of the applied fallback.
- Remove PositionOptions::originalStyle. Instead, the original style is
stored
as an option in ::optionStyles at index 0.
* Source/WebCore/style/StyleTreeResolver.cpp:
(WebCore::Style::lastSuccessfulPositionTryFallbackIndex):
- Add method to get the last successful fallback index from the old style.
There're extra logic to only preserve the last successful fallback if
position-try-fallbacks/-order don't change between styles.
(WebCore::Style::TreeResolver::styleForStyleable):
- Don't pass existingStyle to tryChoosePositionOption, it's not needed
anymore.
- Propagate lastSuccessfulPositionTryFallbackIndex from old to new style.
(WebCore::Style::TreeResolver::resolvePseudoElement):
- Don't pass existingStyle to tryChoosePositionOption, it's not needed
anymore.
- Propagate lastSuccessfulPositionTryFallbackIndex from old to new style.
(WebCore::Style::TreeResolver::generatePositionOptionsIfNeeded):
- Treat the "original style" (style without fallbacks applied) as a
fallback option
and insert it into PositionOptions::optionStyles.
- When generating styles, pair it with the index of the fallback in the
position-try-fallbacks list
(WebCore::Style::TreeResolver::PositionOptions::originalStyle const):
- Add convenience method to get the original style.
(WebCore::Style::TreeResolver::PositionOptions::currentOption const):
- Add convenience method to get the current style option, with the style's
lastSuccessfulPositionTryFallbackIndex set to the option's index.
(WebCore::Style::TreeResolver::sortPositionOptionsIfNeeded):
- As index 0 is the original style, change the logic to only sort options
from index 1.
- If there's a last-successful fallback (in
PositionOptions::usedFallbackIndex),
left-rotate the options array after sort to make the last-successful
fallback the
first option.
(WebCore::Style::TreeResolver::tryChoosePositionOption):
- Change logic to accomodate the fact that the original style is at index 0.
- On first try, immediately apply the first option.
Canonical link: https://commits.webkit.org/298718@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes