Changeset 216591 in webkit


Ignore:
Timestamp:
May 10, 2017 9:50:56 AM (7 years ago)
Author:
Antti Koivisto
Message:

REGRESSION (r207372) Visibility property is not inherited when used in an animation
https://bugs.webkit.org/show_bug.cgi?id=171883
<rdar://problem/32086550>

Reviewed by Simon Fraser.

Source/WebCore:

The problem here is that our animation code is tied to renderers. We don't have renderers during
the initial style resolution so animations are not applied yet. When constructing renderers we set
their style to the initial animated style but this step can't implement inheritance.

Normally this is invisible as the first animation frame will immediately inherit the style correctly.
However in this case the animation is discrete and the first frame is the same as the initial state.
With r207372 we optimize the descendant style change away.

This patch fixes the problem by tracking that the renderer has initial animated style and inheriting
it to descendants during next style resolution even if it doesn't change.

Test: animations/animation-initial-inheritance.html

  • rendering/RenderElement.cpp:

(WebCore::RenderElement::RenderElement):

  • rendering/RenderElement.h:

(WebCore::RenderElement::hasInitialAnimatedStyle):
(WebCore::RenderElement::setHasInitialAnimatedStyle):

  • style/RenderTreeUpdater.cpp:

(WebCore::RenderTreeUpdater::createRenderer):

Set a bit on renderer indicating it has initial animated style.

  • style/StyleTreeResolver.cpp:

(WebCore::Style::TreeResolver::createAnimatedElementUpdate):

Return at least 'Inherit' for style change when updating renderer with initial animated style.

LayoutTests:

  • animations/animation-initial-inheritance-expected.html: Added.
  • animations/animation-initial-inheritance.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r216588 r216591  
     12017-05-10  Antti Koivisto  <antti@apple.com>
     2
     3        REGRESSION (r207372) Visibility property is not inherited when used in an animation
     4        https://bugs.webkit.org/show_bug.cgi?id=171883
     5        <rdar://problem/32086550>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * animations/animation-initial-inheritance-expected.html: Added.
     10        * animations/animation-initial-inheritance.html: Added.
     11
    1122017-05-10  Per Arne Vollan  <pvollan@apple.com>
    213
  • trunk/Source/WebCore/ChangeLog

    r216586 r216591  
     12017-05-10  Antti Koivisto  <antti@apple.com>
     2
     3        REGRESSION (r207372) Visibility property is not inherited when used in an animation
     4        https://bugs.webkit.org/show_bug.cgi?id=171883
     5        <rdar://problem/32086550>
     6
     7        Reviewed by Simon Fraser.
     8
     9        The problem here is that our animation code is tied to renderers. We don't have renderers during
     10        the initial style resolution so animations are not applied yet. When constructing renderers we set
     11        their style to the initial animated style but this step can't implement inheritance.
     12
     13        Normally this is invisible as the first animation frame will immediately inherit the style correctly.
     14        However in this case the animation is discrete and the first frame is the same as the initial state.
     15        With r207372 we optimize the descendant style change away.
     16
     17        This patch fixes the problem by tracking that the renderer has initial animated style and inheriting
     18        it to descendants during next style resolution even if it doesn't change.
     19
     20        Test: animations/animation-initial-inheritance.html
     21
     22        * rendering/RenderElement.cpp:
     23        (WebCore::RenderElement::RenderElement):
     24        * rendering/RenderElement.h:
     25        (WebCore::RenderElement::hasInitialAnimatedStyle):
     26        (WebCore::RenderElement::setHasInitialAnimatedStyle):
     27        * style/RenderTreeUpdater.cpp:
     28        (WebCore::RenderTreeUpdater::createRenderer):
     29
     30            Set a bit on renderer indicating it has initial animated style.
     31
     32        * style/StyleTreeResolver.cpp:
     33        (WebCore::Style::TreeResolver::createAnimatedElementUpdate):
     34
     35            Return at least 'Inherit' for style change when updating renderer with initial animated style.
     36
    1372017-05-10  Myles C. Maxfield  <mmaxfield@apple.com>
    238
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r216549 r216591  
    103103    , m_ancestorLineBoxDirty(false)
    104104    , m_hasInitializedStyle(false)
     105    , m_hasInitialAnimatedStyle(false)
    105106    , m_renderInlineAlwaysCreatesLineBoxes(false)
    106107    , m_renderBoxNeedsLazyRepaint(false)
  • trunk/Source/WebCore/rendering/RenderElement.h

    r216549 r216591  
    134134    void setStyleInternal(RenderStyle&& style) { m_style = WTFMove(style); }
    135135
     136    bool hasInitialAnimatedStyle() const { return m_hasInitialAnimatedStyle; }
     137    void setHasInitialAnimatedStyle(bool b) { m_hasInitialAnimatedStyle = b; }
     138
    136139    // Repaint only if our old bounds and new bounds are different. The caller may pass in newBounds and newOutlineBox if they are known.
    137140    bool repaintAfterLayoutIfNeeded(const RenderLayerModelObject* repaintContainer, const LayoutRect& oldBounds, const LayoutRect& oldOutlineBox, const LayoutRect* newBoundsPtr = nullptr, const LayoutRect* newOutlineBoxPtr = nullptr);
     
    330333    unsigned m_ancestorLineBoxDirty : 1;
    331334    unsigned m_hasInitializedStyle : 1;
     335    unsigned m_hasInitialAnimatedStyle : 1;
    332336
    333337    unsigned m_renderInlineAlwaysCreatesLineBoxes : 1;
  • trunk/Source/WebCore/style/RenderTreeUpdater.cpp

    r214501 r216591  
    354354    std::unique_ptr<RenderStyle> animatedStyle;
    355355    newRenderer->animation().updateAnimations(*newRenderer, initialStyle, animatedStyle);
    356     if (animatedStyle)
     356    if (animatedStyle) {
    357357        newRenderer->setStyleInternal(WTFMove(*animatedStyle));
     358        newRenderer->setHasInitialAnimatedStyle(true);
     359    }
    358360
    359361    newRenderer->initializeStyle();
  • trunk/Source/WebCore/style/StyleTreeResolver.cpp

    r214435 r216591  
    259259    if (animatedStyle) {
    260260        auto change = determineChange(renderer->style(), *animatedStyle);
     261        if (renderer->hasInitialAnimatedStyle()) {
     262            renderer->setHasInitialAnimatedStyle(false);
     263            // When we initialize a newly created renderer with initial animated style we don't inherit it to descendants.
     264            // The first animation frame needs to correct this.
     265            // FIXME: We should compute animated style correctly during initial style resolution when we don't have renderers yet.
     266            //        https://bugs.webkit.org/show_bug.cgi?id=171926
     267            change = std::max(change, Inherit);
     268        }
    261269        // If animation forces render tree reconstruction pass the original style. The animation will be applied on renderer construction.
    262270        // FIXME: We should always use the animated style here.
Note: See TracChangeset for help on using the changeset viewer.