⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 271435 in webkit


Ignore:
Timestamp:
Jan 13, 2021, 2:11:25 AM (6 years ago)
Author:
graouts@webkit.org
Message:

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.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r271431 r271435  
     12021-01-12  Antoine Quint  <graouts@webkit.org>
     2
     3        REGRESSION (r267571): black line appears upon navigating back from apple.com shopping bag
     4        https://bugs.webkit.org/show_bug.cgi?id=220550
     5        <rdar://problem/72459816>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Add a test that checks that adding a pseudo-element for an existing host element does not use
     10        the host element's style to consider starting a transition.
     11
     12        * webanimations/no-transition-on-after-pseudo-element-upon-creation-expected.html: Added.
     13        * webanimations/no-transition-on-after-pseudo-element-upon-creation.html: Added.
     14
    1152021-01-12  Lauro Moura  <lmoura@igalia.com>
    216
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r271434 r271435  
     12021-01-12  Antoine Quint  <graouts@webkit.org>
     2
     3        REGRESSION (r267571): black line appears upon navigating back from apple.com shopping bag
     4        https://bugs.webkit.org/show_bug.cgi?id=220550
     5        <rdar://problem/72459816>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Mark two additional PASS results for ::marker tests.
     10
     11        * web-platform-tests/css/css-pseudo/parsing/marker-supported-properties-in-animation-expected.txt:
     12
    1132021-01-13  Youenn Fablet  <youenn@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/parsing/marker-supported-properties-in-animation-expected.txt

    r269813 r271435  
    3030PASS Animation of list-style-type in ::marker
    3131FAIL Animation of line-height in ::marker assert_equals: expected "normal" but got "35px"
    32 FAIL Transition of font in ::marker assert_in_array: value "italic small-caps 500 expanded 15px/35px Ahem" not in array ["italic small-caps 500 expanded 15px Ahem", "italic small-caps 500 expanded 15px/normal Ahem"]
     32PASS Transition of font in ::marker
    3333PASS Transition of font-family in ::marker
    3434PASS Transition of font-feature-settings in ::marker
     
    5959PASS Transition of list-style-position in ::marker
    6060PASS Transition of list-style-type in ::marker
    61 FAIL Transition of line-height in ::marker assert_equals: expected "normal" but got "35px"
     61PASS Transition of line-height in ::marker
    6262target
  • trunk/Source/WebCore/ChangeLog

    r271433 r271435  
     12021-01-12  Antoine Quint  <graouts@webkit.org>
     2
     3        REGRESSION (r267571): black line appears upon navigating back from apple.com shopping bag
     4        https://bugs.webkit.org/show_bug.cgi?id=220550
     5        <rdar://problem/72459816>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Test: webanimations/no-transition-on-after-pseudo-element-upon-creation.html
     10
     11        In r267571, we refactored the code to use Styleable instead of Element in pseudo-element resolution code. While there
     12        should have been no behavior change, there was a change in Style::TreeResolver::createAnimatedElementUpdate() that
     13        mistakenly introduced one.
     14
     15        In order to get the "before" style to be used to consider CSS Transitions, we used to simply call Element::renderOrDisplayContentsStyle()
     16        on the element provided to createAnimatedElementUpdate(), which would be either an Element or a PseudoElement in the
     17        case of ::before and ::after. When we switched to using Styleable, we made a change where we'd call renderOrDisplayContentsStyle()
     18        on the Styleable's element, if it didn't a pseudo-element, or try to get the matching PseudoElement in the case of
     19        ::before and ::after. However, if we got a nullptr RenderStyle in the PseudoElement case, we'd fall back to using the
     20        style from the host element.
     21
     22        This yielded this regression on apple.com where a transition is started on an ::after pseudo-element which has an
     23        "opacity: 0" style and a "transition" style set for "opacity". The host element is created first, and later the
     24        ::after pseudo-element added. While it should not consider starting a transition in this case since upon creation
     25        there is no existing style to work with, it did start a transition since it would use the host element's style
     26        and see "opacity: 1" to start a transition.
     27
     28        In this patch, we address the FIXME we'd left behind in TreeResolver::createAnimatedElementUpdate() and make
     29        Element::renderOrDisplayContentsStyle() take in a PseudoId, defaulting to PseudoId::None. In case we have a
     30        pseudo-element, we first try to call renderOrDisplayContentsStyle() on the matching PseudoElement if it exists,
     31        or we return the existing computed style for this pseudo-element.
     32
     33        If there is no existing computed style, we return nullptr, which means that in the apple.com scenario, no transition
     34        is started because we correctly don't have a "before" style to work within upon creation of the ::after pseudo-element.
     35
     36        * dom/Element.cpp:
     37        (WebCore::beforeOrAfterPseudoElement):
     38        (WebCore::Element::renderOrDisplayContentsStyle const):
     39        * dom/Element.h:
     40        * style/StyleTreeResolver.cpp:
     41        (WebCore::Style::TreeResolver::createAnimatedElementUpdate):
     42
    1432021-01-12  Cathie Chen  <cathiechen@igalia.com>
    244
  • trunk/Source/WebCore/dom/Element.cpp

    r271382 r271435  
    32943294}
    32953295
    3296 static PseudoElement* beforeOrAfterPseudoElement(Element& host, PseudoId pseudoElementSpecifier)
     3296static PseudoElement* beforeOrAfterPseudoElement(const Element& host, PseudoId pseudoElementSpecifier)
    32973297{
    32983298    switch (pseudoElementSpecifier) {
     
    33163316}
    33173317
    3318 const RenderStyle* Element::renderOrDisplayContentsStyle() const
    3319 {
     3318const RenderStyle* Element::renderOrDisplayContentsStyle(PseudoId pseudoId) const
     3319{
     3320    if (pseudoId != PseudoId::None) {
     3321        if (auto* pseudoElement = beforeOrAfterPseudoElement(*this, pseudoId))
     3322            return pseudoElement->renderOrDisplayContentsStyle();
     3323
     3324        if (auto* computedStyle = existingComputedStyle()) {
     3325            if (auto* cachedPseudoStyle = computedStyle->getCachedPseudoStyle(pseudoId))
     3326                return cachedPseudoStyle;
     3327        }
     3328
     3329        return nullptr;
     3330    }
     3331
    33203332    if (auto* style = renderStyle())
    33213333        return style;
  • trunk/Source/WebCore/dom/Element.h

    r270297 r271435  
    553553
    554554    const RenderStyle* existingComputedStyle() const;
    555     WEBCORE_EXPORT const RenderStyle* renderOrDisplayContentsStyle() const;
     555    WEBCORE_EXPORT const RenderStyle* renderOrDisplayContentsStyle(PseudoId = PseudoId::None) const;
    556556
    557557    void clearBeforePseudoElement();
  • trunk/Source/WebCore/style/StyleTreeResolver.cpp

    r270837 r271435  
    317317{
    318318    auto& element = styleable.element;
    319 
    320     // FIXME: Ideally we could just call Element::renderOrDisplayContentsStyle() with a PseudoId
    321     // and get the style for any PseudoId, not just PseudoId::Before or PseudoId::After.
    322     auto* pseudoElement = [styleable]() -> PseudoElement* {
    323         switch (styleable.pseudoId) {
    324         case PseudoId::Before:
    325             return styleable.element.beforePseudoElement();
    326         case PseudoId::After:
    327             return styleable.element.afterPseudoElement();
    328         default:
    329             return nullptr;
    330         }
    331     }();
    332     auto* oldStyle = pseudoElement ? pseudoElement->renderOrDisplayContentsStyle() : element.renderOrDisplayContentsStyle();
     319    auto* oldStyle = element.renderOrDisplayContentsStyle(styleable.pseudoId);
    333320
    334321    OptionSet<AnimationImpact> animationImpact;
Note: See TracChangeset for help on using the changeset viewer.