haikuwebkit/LayoutTests/webanimations/no-transition-on-after-pseu...

32 lines
883 B
HTML
Raw Permalink Normal View History

REGRESSION (r267571): black line appears upon navigating back from apple.com shopping bag https://bugs.webkit.org/show_bug.cgi?id=220550 <rdar://problem/72459816> Reviewed by Antti Koivisto. LayoutTests/imported/w3c: Mark two additional PASS results for ::marker tests. * web-platform-tests/css/css-pseudo/parsing/marker-supported-properties-in-animation-expected.txt: Source/WebCore: Test: webanimations/no-transition-on-after-pseudo-element-upon-creation.html In r267571, we refactored the code to use Styleable instead of Element in pseudo-element resolution code. While there should have been no behavior change, there was a change in Style::TreeResolver::createAnimatedElementUpdate() that mistakenly introduced one. In order to get the "before" style to be used to consider CSS Transitions, we used to simply call Element::renderOrDisplayContentsStyle() on the element provided to createAnimatedElementUpdate(), which would be either an Element or a PseudoElement in the case of ::before and ::after. When we switched to using Styleable, we made a change where we'd call renderOrDisplayContentsStyle() on the Styleable's element, if it didn't a pseudo-element, or try to get the matching PseudoElement in the case of ::before and ::after. However, if we got a nullptr RenderStyle in the PseudoElement case, we'd fall back to using the style from the host element. This yielded this regression on apple.com where a transition is started on an ::after pseudo-element which has an "opacity: 0" style and a "transition" style set for "opacity". The host element is created first, and later the ::after pseudo-element added. While it should not consider starting a transition in this case since upon creation there is no existing style to work with, it did start a transition since it would use the host element's style and see "opacity: 1" to start a transition. In this patch, we address the FIXME we'd left behind in TreeResolver::createAnimatedElementUpdate() and make Element::renderOrDisplayContentsStyle() take in a PseudoId, defaulting to PseudoId::None. In case we have a pseudo-element, we first try to call renderOrDisplayContentsStyle() on the matching PseudoElement if it exists, or we return the existing computed style for this pseudo-element. If there is no existing computed style, we return nullptr, which means that in the apple.com scenario, no transition is started because we correctly don't have a "before" style to work within upon creation of the ::after pseudo-element. * dom/Element.cpp: (WebCore::beforeOrAfterPseudoElement): (WebCore::Element::renderOrDisplayContentsStyle const): * dom/Element.h: * style/StyleTreeResolver.cpp: (WebCore::Style::TreeResolver::createAnimatedElementUpdate): LayoutTests: Add a test that checks that adding a pseudo-element for an existing host element does not use the host element's style to consider starting a transition. * webanimations/no-transition-on-after-pseudo-element-upon-creation-expected.html: Added. * webanimations/no-transition-on-after-pseudo-element-upon-creation.html: Added. Canonical link: https://commits.webkit.org/232995@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271435 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-01-13 10:11:25 +00:00
<body>
<style>
div {
width: 100px;
height: 100px;
background-color: green;
}
div.after::after {
content: "";
display: block;
width: 100px;
height: 100px;
opacity: 0;
background-color: red;
transition: opacity 60s;
}
</style>
<script>
// Adding the "after" class on the next frame will yield the ::after pseudo-element.
// This should not yield a CSS Transition since there was no previous pseudo-element
// style to animate from, although there was a bug in WebKit introduced in r267571
// where we would use the host element's current style to consider whether we should
// run a CSS Transition here.
const element = document.body.appendChild(document.createElement("div"));
requestAnimationFrame(() => element.classList.add("after"));
</script>
</body>