Changeset 275277 in webkit


Ignore:
Timestamp:
Mar 31, 2021 5:16:18 AM (16 months ago)
Author:
Antti Koivisto
Message:

Animated pseudo element style resolved against wrong parent style
https://bugs.webkit.org/show_bug.cgi?id=223990
rdar://74997361

Reviewed by Antoine Quint.
Source/WebCore:

In createAnimatedElementUpdate we get the parent and parent box styles from the parent stack.
This is wrong for pseudo elements. Their parent style should the host style which is not pushed to the stack.

This matters in style adjuster which may apply wrong adjustments as a result.

Test: fast/animation/pseudo-element-style-adjuster.html

  • style/StyleTreeResolver.cpp:

(WebCore::Style::TreeResolver::resolveElement):
(WebCore::Style::TreeResolver::resolvePseudoStyle):
(WebCore::Style::TreeResolver::createAnimatedElementUpdate):

Make static and provide the parent and parent box styles as parameters.

  • style/StyleTreeResolver.h:

LayoutTests:

  • fast/animation/pseudo-element-style-adjuster-expected.html: Added.
  • fast/animation/pseudo-element-style-adjuster.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r275276 r275277  
     12021-03-31  Antti Koivisto  <antti@apple.com>
     2
     3        Animated pseudo element style resolved against wrong parent style
     4        https://bugs.webkit.org/show_bug.cgi?id=223990
     5        rdar://74997361
     6
     7        Reviewed by Antoine Quint.
     8
     9        * fast/animation/pseudo-element-style-adjuster-expected.html: Added.
     10        * fast/animation/pseudo-element-style-adjuster.html: Added.
     11
    1122021-03-31  Youenn Fablet  <youenn@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r275276 r275277  
     12021-03-31  Antti Koivisto  <antti@apple.com>
     2
     3        Animated pseudo element style resolved against wrong parent style
     4        https://bugs.webkit.org/show_bug.cgi?id=223990
     5        rdar://74997361
     6
     7        Reviewed by Antoine Quint.
     8       
     9        In createAnimatedElementUpdate we get the parent and parent box styles from the parent stack.
     10        This is wrong for pseudo elements. Their parent style should the host style which is not pushed to the stack.
     11       
     12        This matters in style adjuster which may apply wrong adjustments as a result.
     13
     14        Test: fast/animation/pseudo-element-style-adjuster.html
     15
     16        * style/StyleTreeResolver.cpp:
     17        (WebCore::Style::TreeResolver::resolveElement):
     18        (WebCore::Style::TreeResolver::resolvePseudoStyle):
     19        (WebCore::Style::TreeResolver::createAnimatedElementUpdate):
     20       
     21        Make static and provide the parent and parent box styles as parameters.
     22       
     23        * style/StyleTreeResolver.h:
     24
    1252021-03-31  Youenn Fablet  <youenn@apple.com>
    226
  • trunk/Source/WebCore/style/StyleTreeResolver.cpp

    r273621 r275277  
    223223    }
    224224
    225     auto update = createAnimatedElementUpdate(WTFMove(newStyle), styleable, parent().change);
     225    auto update = createAnimatedElementUpdate(WTFMove(newStyle), styleable, parent().change, parent().style, parentBoxStyle());
    226226    auto descendantsToResolve = computeDescendantsToResolve(update.change, element.styleValidity(), parent().descendantsToResolve);
    227227
     
    279279    if (!elementUpdate.style->hasPseudoStyle(pseudoId))
    280280        return { };
    281 
    282     auto pseudoStyle = scope().resolver.pseudoStyleForElement(element, { pseudoId }, *elementUpdate.style, parentBoxStyleForPseudo(elementUpdate), &scope().selectorFilter);
     281   
     282    auto& parentStyle = *elementUpdate.style;
     283    auto* parentBoxStyle = parentBoxStyleForPseudo(elementUpdate);
     284   
     285    auto pseudoStyle = scope().resolver.pseudoStyleForElement(element, { pseudoId }, parentStyle, parentBoxStyle, &scope().selectorFilter);
    283286    if (!pseudoStyle)
    284287        return { };
     
    288291        return { };
    289292
    290     return createAnimatedElementUpdate(WTFMove(pseudoStyle), { element, pseudoId }, elementUpdate.change);
     293    return createAnimatedElementUpdate(WTFMove(pseudoStyle), { element, pseudoId }, elementUpdate.change, parentStyle, parentBoxStyle);
    291294}
    292295
     
    317320}
    318321
    319 ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr<RenderStyle> newStyle, const Styleable& styleable, Change parentChange)
     322ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr<RenderStyle> newStyle, const Styleable& styleable, Change parentChange, const RenderStyle& parentStyle, const RenderStyle* parentBoxStyle)
    320323{
    321324    auto& element = styleable.element;
     325    auto& document = element.document();
    322326    auto* oldStyle = element.renderOrDisplayContentsStyle(styleable.pseudoId);
    323327
     
    327331    // on the document timeline. Note that we get timeline() on the Document here because we need a timeline created
    328332    // in case no Web Animations have been created through the JS API.
    329     if (element.document().backForwardCacheState() == Document::NotInBackForwardCache && !element.document().renderView()->printing()) {
     333    if (document.backForwardCacheState() == Document::NotInBackForwardCache && !document.renderView()->printing()) {
    330334        if (oldStyle && (oldStyle->hasTransitions() || newStyle->hasTransitions()))
    331             m_document.timeline().updateCSSTransitionsForStyleable(styleable, *oldStyle, *newStyle);
     335            document.timeline().updateCSSTransitionsForStyleable(styleable, *oldStyle, *newStyle);
    332336
    333337        // The order in which CSS Transitions and CSS Animations are updated matters since CSS Transitions define the after-change style
     
    335339        // such that when CSS Transitions are updated the CSS Animations data is the same as during the previous style change event.
    336340        if ((oldStyle && oldStyle->hasAnimations()) || newStyle->hasAnimations())
    337             m_document.timeline().updateCSSAnimationsForStyleable(styleable, oldStyle, *newStyle, &parent().style);
     341            document.timeline().updateCSSAnimationsForStyleable(styleable, oldStyle, *newStyle, &parentStyle);
    338342    }
    339343
     
    346350        // Apply all keyframe effects to the new style.
    347351        auto animatedStyle = RenderStyle::clonePtr(*newStyle);
    348         animationImpact = styleable.applyKeyframeEffects(*animatedStyle, *previousLastStyleChangeEventStyle, &parent().style);
     352        animationImpact = styleable.applyKeyframeEffects(*animatedStyle, *previousLastStyleChangeEventStyle, &parentStyle);
    349353        newStyle = WTFMove(animatedStyle);
    350354
    351         Adjuster adjuster(m_document, parent().style, parentBoxStyle(), styleable.pseudoId == PseudoId::None ? &element : nullptr);
     355        Adjuster adjuster(document, parentStyle, parentBoxStyle, styleable.pseudoId == PseudoId::None ? &element : nullptr);
    352356        adjuster.adjustAnimatedStyle(*newStyle, animationImpact);
    353357    } else
  • trunk/Source/WebCore/style/StyleTreeResolver.h

    r273621 r275277  
    6262    ElementUpdates resolveElement(Element&);
    6363
    64     ElementUpdate createAnimatedElementUpdate(std::unique_ptr<RenderStyle>, const Styleable&, Change);
     64    static ElementUpdate createAnimatedElementUpdate(std::unique_ptr<RenderStyle>, const Styleable&, Change, const RenderStyle& parentStyle, const RenderStyle* parentBoxStyle);
    6565    Optional<ElementUpdate> resolvePseudoStyle(Element&, const ElementUpdate&, PseudoId);
    6666
Note: See TracChangeset for help on using the changeset viewer.