Changeset 222104 in webkit


Ignore:
Timestamp:
Sep 15, 2017 12:54:01 PM (7 years ago)
Author:
Ryan Haddad
Message:

Unreviewed, rolling out r222040.

The LayoutTest added with this change is a flaky image failure
on mac-wk1 debug bots.

Reverted changeset:

"Computing animated style should not require renderers"
https://bugs.webkit.org/show_bug.cgi?id=171926
http://trac.webkit.org/changeset/222040

Location:
trunk
Files:
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r222102 r222104  
     12017-09-15  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r222040.
     4
     5        The LayoutTest added with this change is a flaky image failure
     6        on mac-wk1 debug bots.
     7
     8        Reverted changeset:
     9
     10        "Computing animated style should not require renderers"
     11        https://bugs.webkit.org/show_bug.cgi?id=171926
     12        http://trac.webkit.org/changeset/222040
     13
    1142017-09-15  Matt Baker  <mattbaker@apple.com>
    215
  • trunk/LayoutTests/transitions/transition-display-property.html

    r222040 r222104  
    66<script>
    77var test = document.querySelector("test");
     8var count = 0;
     9function testUntilComplete()
     10{
     11    if (test.offsetWidth == 10 || ++count == 10)
     12        testRunner.notifyDone();
     13    else
     14        setTimeout(testUntilComplete, 0.1);
     15}
    816
    917if (window.testRunner) {
    1018    testRunner.waitUntilDone();
    11     test.ontransitionend = () => testRunner.notifyDone();
     19    testUntilComplete();
    1220}
    1321test.offsetWidth;
  • trunk/Source/WebCore/ChangeLog

    r222103 r222104  
     12017-09-15  Ryan Haddad  <ryanhaddad@apple.com>
     2
     3        Unreviewed, rolling out r222040.
     4
     5        The LayoutTest added with this change is a flaky image failure
     6        on mac-wk1 debug bots.
     7
     8        Reverted changeset:
     9
     10        "Computing animated style should not require renderers"
     11        https://bugs.webkit.org/show_bug.cgi?id=171926
     12        http://trac.webkit.org/changeset/222040
     13
    1142017-09-15  Tim Horton  <timothy_horton@apple.com>
    215
  • trunk/Source/WebCore/page/animation/CSSAnimationController.cpp

    r222040 r222104  
    638638}
    639639
    640 AnimationUpdate CSSAnimationController::updateAnimations(Element& element, const RenderStyle& newStyle, const RenderStyle* oldStyle)
    641 {
    642     bool hasOrHadAnimations = (oldStyle && oldStyle->hasAnimationsOrTransitions()) || newStyle.hasAnimationsOrTransitions();
    643     if (!hasOrHadAnimations)
    644         return { };
     640bool CSSAnimationController::updateAnimations(Element& element, const RenderStyle& newStyle, std::unique_ptr<RenderStyle>& animatedStyle)
     641{
     642    auto* renderer = element.renderer();
     643    auto* oldStyle = (renderer && renderer->hasInitializedStyle()) ? &renderer->style() : nullptr;
     644    if ((!oldStyle || (!oldStyle->animations() && !oldStyle->transitions())) && (!newStyle.animations() && !newStyle.transitions()))
     645        return false;
    645646
    646647    if (element.document().pageCacheState() != Document::NotInPageCache)
    647         return { };
     648        return false;
    648649
    649650    // Don't run transitions when printing.
    650651    if (element.document().renderView()->printing())
    651         return { };
     652        return false;
    652653
    653654    // Fetch our current set of implicit animations from a hashtable. We then compare them
     
    657658
    658659    CompositeAnimation& compositeAnimation = m_data->ensureCompositeAnimation(element);
    659     auto update = compositeAnimation.animate(element, oldStyle, newStyle);
    660 
    661     auto* renderer = element.renderer();
     660    bool animationStateChanged = compositeAnimation.animate(element, oldStyle, newStyle, animatedStyle);
     661
    662662    if ((renderer && renderer->parent()) || newStyle.animations() || (oldStyle && oldStyle->animations())) {
    663663        auto& frameView = *element.document().view();
     
    668668    }
    669669
    670     return update;
     670    return animationStateChanged;
    671671}
    672672
  • trunk/Source/WebCore/page/animation/CSSAnimationController.h

    r222040 r222104  
    3131#include "AnimationBase.h"
    3232#include "CSSPropertyNames.h"
    33 #include "RenderStyle.h"
    3433#include <wtf/Forward.h>
    3534
     
    4241class LayoutRect;
    4342class RenderElement;
    44 
    45 struct AnimationUpdate {
    46 #if !COMPILER_SUPPORTS(NSDMI_FOR_AGGREGATES)
    47     AnimationUpdate() = default;
    48     AnimationUpdate(std::unique_ptr<RenderStyle> style, bool stateChanged)
    49         : style(WTFMove(style))
    50         , stateChanged(stateChanged)
    51     { }
    52 #endif
    53     std::unique_ptr<RenderStyle> style;
    54     bool stateChanged { false };
    55 };
     43class RenderStyle;
    5644
    5745class CSSAnimationController {
     
    6250
    6351    void cancelAnimations(Element&);
    64     AnimationUpdate updateAnimations(Element&, const RenderStyle& newStyle, const RenderStyle* oldStyle);
     52    bool updateAnimations(Element&, const RenderStyle& newStyle, std::unique_ptr<RenderStyle>& animatedStyle);
    6553    std::unique_ptr<RenderStyle> animatedStyleForRenderer(RenderElement&);
    6654
  • trunk/Source/WebCore/page/animation/CompositeAnimation.cpp

    r222040 r222104  
    288288}
    289289
    290 AnimationUpdate CompositeAnimation::animate(Element& element, const RenderStyle* currentStyle, const RenderStyle& targetStyle)
     290bool CompositeAnimation::animate(Element& element, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& blendedStyle)
    291291{
    292292    // We don't do any transitions if we don't have a currentStyle (on startup).
     
    298298    bool forceStackingContext = false;
    299299
    300     std::unique_ptr<RenderStyle> animatedStyle;
    301 
    302300    if (currentStyle) {
    303301        // Now that we have transition objects ready, let them know about the new goal state.  We want them
     
    306304        for (auto& transition : m_transitions.values()) {
    307305            bool didBlendStyle = false;
    308             if (transition->animate(*this, targetStyle, animatedStyle, didBlendStyle))
     306            if (transition->animate(*this, targetStyle, blendedStyle, didBlendStyle))
    309307                animationStateChanged = true;
    310308
     
    313311        }
    314312
    315         if (animatedStyle && checkForStackingContext) {
     313        if (blendedStyle && checkForStackingContext) {
    316314            // Note that this is similar to code in StyleResolver::adjustRenderStyle() but only needs to consult
    317315            // animatable properties that can trigger stacking context.
    318             if (animatedStyle->opacity() < 1.0f
    319                 || animatedStyle->hasTransformRelatedProperty()
    320                 || animatedStyle->hasMask()
    321                 || animatedStyle->clipPath()
    322                 || animatedStyle->boxReflect()
    323                 || animatedStyle->hasFilter()
     316            if (blendedStyle->opacity() < 1.0f
     317                || blendedStyle->hasTransformRelatedProperty()
     318                || blendedStyle->hasMask()
     319                || blendedStyle->clipPath()
     320                || blendedStyle->boxReflect()
     321                || blendedStyle->hasFilter()
    324322#if ENABLE(FILTERS_LEVEL_2)
    325                 || animatedStyle->hasBackdropFilter()
     323                || blendedStyle->hasBackdropFilter()
    326324#endif
    327325                )
     
    336334        if (keyframeAnim) {
    337335            bool didBlendStyle = false;
    338             if (keyframeAnim->animate(*this, targetStyle, animatedStyle, didBlendStyle))
     336            if (keyframeAnim->animate(*this, targetStyle, blendedStyle, didBlendStyle))
    339337                animationStateChanged = true;
    340338
     
    348346    // the user agent must act as if the will-change property ([css-will-change-1]) on the element additionally
    349347    // includes all the properties animated by the animation.
    350     if (forceStackingContext && animatedStyle) {
    351         if (animatedStyle->hasAutoZIndex())
    352             animatedStyle->setZIndex(0);
    353     }
    354 
    355     return { WTFMove(animatedStyle), animationStateChanged };
     348    if (forceStackingContext && blendedStyle) {
     349        if (blendedStyle->hasAutoZIndex())
     350            blendedStyle->setZIndex(0);
     351    }
     352
     353    return animationStateChanged;
    356354}
    357355
  • trunk/Source/WebCore/page/animation/CompositeAnimation.h

    r222040 r222104  
    2929#pragma once
    3030
    31 #include "CSSAnimationController.h"
    3231#include "ImplicitAnimation.h"
    3332#include "KeyframeAnimation.h"
     
    5655    void clearElement();
    5756
    58     AnimationUpdate animate(Element&, const RenderStyle* currentStyle, const RenderStyle& targetStyle);
     57    bool animate(Element&, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& blendedStyle);
    5958    std::unique_ptr<RenderStyle> getAnimatedStyle() const;
    6059    bool computeExtentOfTransformAnimation(LayoutRect&) const;
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r222040 r222104  
    2727
    2828#include "AXObjectCache.h"
     29#include "CSSAnimationController.h"
    2930#include "ContentData.h"
    3031#include "CursorList.h"
     
    102103    , m_ancestorLineBoxDirty(false)
    103104    , m_hasInitializedStyle(false)
     105    , m_hasInitialAnimatedStyle(false)
    104106    , m_renderInlineAlwaysCreatesLineBoxes(false)
    105107    , m_renderBoxNeedsLazyRepaint(false)
     
    11031105        view().frameView().removeSlowRepaintObject(this);
    11041106
     1107    if (element())
     1108        animation().cancelAnimations(*element());
     1109
    11051110    destroyLeftoverChildren();
    11061111
  • trunk/Source/WebCore/rendering/RenderElement.h

    r222040 r222104  
    132132    void setStyleInternal(RenderStyle&& style) { m_style = WTFMove(style); }
    133133
     134    bool hasInitialAnimatedStyle() const { return m_hasInitialAnimatedStyle; }
     135    void setHasInitialAnimatedStyle(bool b) { m_hasInitialAnimatedStyle = b; }
     136
    134137    // Repaint only if our old bounds and new bounds are different. The caller may pass in newBounds and newOutlineBox if they are known.
    135138    bool repaintAfterLayoutIfNeeded(const RenderLayerModelObject* repaintContainer, const LayoutRect& oldBounds, const LayoutRect& oldOutlineBox, const LayoutRect* newBoundsPtr = nullptr, const LayoutRect* newOutlineBoxPtr = nullptr);
     
    327330    unsigned m_ancestorLineBoxDirty : 1;
    328331    unsigned m_hasInitializedStyle : 1;
     332    unsigned m_hasInitialAnimatedStyle : 1;
    329333
    330334    unsigned m_renderInlineAlwaysCreatesLineBoxes : 1;
  • trunk/Source/WebCore/style/RenderTreeUpdater.cpp

    r222040 r222104  
    308308            renderTreePosition().invalidateNextSibling();
    309309        }
    310 
    311         // display:none cancels animations.
    312         auto teardownType = update.style->display() == NONE ? TeardownType::RendererUpdateCancelingAnimations : TeardownType::RendererUpdate;
    313         tearDownRenderers(element, teardownType);
     310        tearDownRenderers(element, TeardownType::KeepHoverAndActive);
    314311    }
    315312
     
    399396
    400397    element.setRenderer(newRenderer);
     398
     399    auto& initialStyle = newRenderer->style();
     400    std::unique_ptr<RenderStyle> animatedStyle;
     401    newRenderer->animation().updateAnimations(element, initialStyle, animatedStyle);
     402    if (animatedStyle) {
     403        newRenderer->setStyleInternal(WTFMove(*animatedStyle));
     404        newRenderer->setHasInitialAnimatedStyle(true);
     405    }
    401406
    402407    newRenderer->initializeStyle();
     
    521526}
    522527
    523 void RenderTreeUpdater::tearDownRenderers(Element& root)
    524 {
    525     tearDownRenderers(root, TeardownType::Full);
    526 }
    527 
    528528void RenderTreeUpdater::tearDownRenderers(Element& root, TeardownType teardownType)
    529529{
     
    538538    };
    539539
    540     auto& animationController = root.document().frame()->animation();
    541 
    542540    auto pop = [&] (unsigned depth) {
    543541        while (teardownStack.size() > depth) {
    544542            auto& element = *teardownStack.takeLast();
    545543
    546             if (teardownType == TeardownType::Full || teardownType == TeardownType::RendererUpdateCancelingAnimations)
    547                 animationController.cancelAnimations(element);
    548 
    549             if (teardownType == TeardownType::Full)
     544            if (teardownType != TeardownType::KeepHoverAndActive)
    550545                element.clearHoverAndActiveStatusBeforeDetachingRenderer();
    551 
    552546            element.clearStyleDerivedDataBeforeDetachingRenderer();
    553547
  • trunk/Source/WebCore/style/RenderTreeUpdater.h

    r222040 r222104  
    4848    void commit(std::unique_ptr<const Style::Update>);
    4949
    50     static void tearDownRenderers(Element&);
     50    enum class TeardownType { Normal, KeepHoverAndActive };
     51    static void tearDownRenderers(Element&, TeardownType = TeardownType::Normal);
    5152    static void tearDownRenderer(Text&);
    5253
     
    8384    void popParentsToDepth(unsigned depth);
    8485
    85     enum class TeardownType { Full, RendererUpdate, RendererUpdateCancelingAnimations };
    86     static void tearDownRenderers(Element&, TeardownType);
    87 
    8886    RenderView& renderView();
    8987
  • trunk/Source/WebCore/style/StyleTreeResolver.cpp

    r222040 r222104  
    242242ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr<RenderStyle> newStyle, Element& element, Change parentChange)
    243243{
    244     auto& animationController = element.document().frame()->animation();
    245 
    246     auto* oldStyle = renderOrDisplayContentsStyle(element);
    247     auto animationUpdate = animationController.updateAnimations(element, *newStyle, oldStyle);
    248 
    249     if (animationUpdate.style)
    250         newStyle = WTFMove(animationUpdate.style);
    251 
    252     auto change = oldStyle ? determineChange(*oldStyle, *newStyle) : Detach;
    253 
    254244    auto validity = element.styleValidity();
    255     if (validity >= Validity::SubtreeInvalid)
    256         change = std::max(change, validity == Validity::SubtreeAndRenderersInvalid ? Detach : Force);
    257     if (parentChange >= Force)
    258         change = std::max(change, parentChange);
    259 
    260     bool shouldRecompositeLayer = element.styleResolutionShouldRecompositeLayer() || animationUpdate.stateChanged;
    261 
    262     return { WTFMove(newStyle), change, shouldRecompositeLayer };
     245    bool recompositeLayer = element.styleResolutionShouldRecompositeLayer();
     246
     247    auto makeUpdate = [&] (std::unique_ptr<RenderStyle> style, Change change) {
     248        if (validity >= Validity::SubtreeInvalid)
     249            change = std::max(change, validity == Validity::SubtreeAndRenderersInvalid ? Detach : Force);
     250        if (parentChange >= Force)
     251            change = std::max(change, parentChange);
     252        return ElementUpdate { WTFMove(style), change, recompositeLayer };
     253    };
     254
     255    auto* renderer = element.renderer();
     256
     257    bool shouldReconstruct = validity >= Validity::SubtreeAndRenderersInvalid || parentChange == Detach;
     258    if (shouldReconstruct)
     259        return makeUpdate(WTFMove(newStyle), Detach);
     260
     261    if (!renderer) {
     262        auto change = Detach;
     263        if (auto* oldStyle = renderOrDisplayContentsStyle(element))
     264            change = determineChange(*oldStyle, *newStyle);
     265        return makeUpdate(WTFMove(newStyle), change);
     266    }
     267
     268    std::unique_ptr<RenderStyle> animatedStyle;
     269    if (element.document().frame()->animation().updateAnimations(element, *newStyle, animatedStyle))
     270        recompositeLayer = true;
     271
     272    if (animatedStyle) {
     273        auto change = determineChange(renderer->style(), *animatedStyle);
     274        if (renderer->hasInitialAnimatedStyle()) {
     275            renderer->setHasInitialAnimatedStyle(false);
     276            // When we initialize a newly created renderer with initial animated style we don't inherit it to descendants.
     277            // The first animation frame needs to correct this.
     278            // FIXME: We should compute animated style correctly during initial style resolution when we don't have renderers yet.
     279            //        https://bugs.webkit.org/show_bug.cgi?id=171926
     280            change = std::max(change, Inherit);
     281        }
     282        // If animation forces render tree reconstruction pass the original style. The animation will be applied on renderer construction.
     283        // FIXME: We should always use the animated style here.
     284        auto style = change == Detach ? WTFMove(newStyle) : WTFMove(animatedStyle);
     285        return makeUpdate(WTFMove(style), change);
     286    }
     287
     288    auto change = determineChange(renderer->style(), *newStyle);
     289    return makeUpdate(WTFMove(newStyle), change);
    263290}
    264291
Note: See TracChangeset for help on using the changeset viewer.