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

Changeset 239985 in webkit


Ignore:
Timestamp:
Jan 15, 2019, 8:24:57 AM (8 years ago)
Author:
Simon Fraser
Message:

Simplify isRunningAnimationOnRenderer()
​https://bugs.webkit.org/show_bug.cgi?id=193435

Reviewed by Darin Adler.

All callers of CSSAnimationController::isRunningAnimationOnRenderer() pass AnimationBase::Running | AnimationBase::Paused,
so we can remove the parameter and just hardcode this behavior.

This will simplify a later patch that needs to consider state changes between running and not running.

No behavior change.

  • page/animation/AnimationBase.h:

(WebCore::AnimationBase::isAnimatingProperty const):

  • page/animation/CSSAnimationController.cpp:

(WebCore::CSSAnimationControllerPrivate::isRunningAnimationOnRenderer const):
(WebCore::CSSAnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer const):
(WebCore::CSSAnimationControllerPrivate::computeExtentOfAnimation const):
(WebCore::CSSAnimationController::isRunningAnimationOnRenderer const):
(WebCore::CSSAnimationController::isRunningAcceleratedAnimationOnRenderer const):

  • page/animation/CSSAnimationController.h:
  • page/animation/CSSAnimationControllerPrivate.h:
  • page/animation/CompositeAnimation.cpp:

(WebCore::CompositeAnimation::isAnimatingProperty const):

  • page/animation/CompositeAnimation.h:
  • rendering/RenderLayer.cpp:

(WebCore::RenderLayer::currentTransform const):

  • rendering/RenderLayerBacking.cpp:

(WebCore::RenderLayerBacking::updateGeometry):

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::requiresCompositingForAnimation const):
(WebCore::RenderLayerCompositor::isRunningTransformAnimation const):

Location:
trunk/Source/WebCore
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r239984 r239985  
     12019-01-15  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Simplify isRunningAnimationOnRenderer()
     4        https://bugs.webkit.org/show_bug.cgi?id=193435
     5
     6        Reviewed by Darin Adler.
     7
     8        All callers of CSSAnimationController::isRunningAnimationOnRenderer() pass AnimationBase::Running | AnimationBase::Paused,
     9        so we can remove the parameter and just hardcode this behavior.
     10       
     11        This will simplify a later patch that needs to consider state changes between running and not running.
     12       
     13        No behavior change.
     14
     15        * page/animation/AnimationBase.h:
     16        (WebCore::AnimationBase::isAnimatingProperty const):
     17        * page/animation/CSSAnimationController.cpp:
     18        (WebCore::CSSAnimationControllerPrivate::isRunningAnimationOnRenderer const):
     19        (WebCore::CSSAnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer const):
     20        (WebCore::CSSAnimationControllerPrivate::computeExtentOfAnimation const):
     21        (WebCore::CSSAnimationController::isRunningAnimationOnRenderer const):
     22        (WebCore::CSSAnimationController::isRunningAcceleratedAnimationOnRenderer const):
     23        * page/animation/CSSAnimationController.h:
     24        * page/animation/CSSAnimationControllerPrivate.h:
     25        * page/animation/CompositeAnimation.cpp:
     26        (WebCore::CompositeAnimation::isAnimatingProperty const):
     27        * page/animation/CompositeAnimation.h:
     28        * rendering/RenderLayer.cpp:
     29        (WebCore::RenderLayer::currentTransform const):
     30        * rendering/RenderLayerBacking.cpp:
     31        (WebCore::RenderLayerBacking::updateGeometry):
     32        * rendering/RenderLayerCompositor.cpp:
     33        (WebCore::RenderLayerCompositor::requiresCompositingForAnimation const):
     34        (WebCore::RenderLayerCompositor::isRunningTransformAnimation const):
     35
    1362019-01-15  Antti Koivisto  <antti@apple.com>
    237
  • trunk/Source/WebCore/page/animation/AnimationBase.h

    r239427 r239985  
    156156    virtual bool affectsProperty(CSSPropertyID /*property*/) const { return false; }
    157157
    158     enum RunningStates {
    159         Delaying = 1 << 0,
    160         Paused = 1 << 1,
    161         Running = 1 << 2,
    162     };
    163     typedef unsigned RunningState;
    164     bool isAnimatingProperty(CSSPropertyID property, bool acceleratedOnly, RunningState runningState) const
     158    bool isAnimatingProperty(CSSPropertyID property, bool acceleratedOnly) const
    165159    {
    166160        if (acceleratedOnly && !m_isAccelerated)
    … …  
    170164            return false;
    171165
    172         if ((runningState & Delaying) && preActive())
     166        if (inPausedState())
    173167            return true;
    174168
    175         if ((runningState & Paused) && inPausedState())
    176             return true;
    177 
    178         if ((runningState & Running) && !inPausedState() && (m_animationState >= AnimationState::StartWaitStyleAvailable && m_animationState < AnimationState::Done))
     169        if (m_animationState >= AnimationState::StartWaitStyleAvailable && m_animationState < AnimationState::Done)
    179170            return true;
    180171
  • trunk/Source/WebCore/page/animation/CSSAnimationController.cpp

    r239965 r239985  
    291291}
    292292
    293 bool CSSAnimationControllerPrivate::isRunningAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const
     293bool CSSAnimationControllerPrivate::isRunningAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property) const
    294294{
    295295    if (!renderer.element())
    … …  
    298298    if (!animation)
    299299        return false;
    300     return animation->isAnimatingProperty(property, false, runningState);
    301 }
    302 
    303 bool CSSAnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const
     300    return animation->isAnimatingProperty(property, false);
     301}
     302
     303bool CSSAnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property) const
    304304{
    305305    if (!renderer.element())
    … …  
    308308    if (!animation)
    309309        return false;
    310     return animation->isAnimatingProperty(property, true, runningState);
     310    return animation->isAnimatingProperty(property, true);
    311311}
    312312
    … …  
    490490        return true;
    491491
    492     if (!animation->isAnimatingProperty(CSSPropertyTransform, false, AnimationBase::Running | AnimationBase::Paused))
     492    if (!animation->isAnimatingProperty(CSSPropertyTransform, false))
    493493        return true;
    494494
    … …  
    694694}
    695695
    696 bool CSSAnimationController::isRunningAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const
     696bool CSSAnimationController::isRunningAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property) const
    697697{
    698698    if (!renderer.style().hasAnimationsOrTransitions())
    699699        return false;
    700     return m_data->isRunningAnimationOnRenderer(renderer, property, runningState);
    701 }
    702 
    703 bool CSSAnimationController::isRunningAcceleratedAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const
     700    return m_data->isRunningAnimationOnRenderer(renderer, property);
     701}
     702
     703bool CSSAnimationController::isRunningAcceleratedAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property) const
    704704{
    705705    if (!renderer.style().hasAnimationsOrTransitions())
    706706        return false;
    707     return m_data->isRunningAcceleratedAnimationOnRenderer(renderer, property, runningState);
     707    return m_data->isRunningAcceleratedAnimationOnRenderer(renderer, property);
    708708}
    709709
  • trunk/Source/WebCore/page/animation/CSSAnimationController.h

    r236750 r239985  
    7070    WEBCORE_EXPORT unsigned numberOfActiveAnimations(Document*) const; // To be used only for testing
    7171   
    72     bool isRunningAnimationOnRenderer(RenderElement&, CSSPropertyID, AnimationBase::RunningState) const;
    73     bool isRunningAcceleratedAnimationOnRenderer(RenderElement&, CSSPropertyID, AnimationBase::RunningState) const;
     72    // "Running" here means the animation is running or paused.
     73    bool isRunningAnimationOnRenderer(RenderElement&, CSSPropertyID) const;
     74    bool isRunningAcceleratedAnimationOnRenderer(RenderElement&, CSSPropertyID) const;
    7475
    7576    WEBCORE_EXPORT bool isSuspended() const;
  • trunk/Source/WebCore/page/animation/CSSAnimationControllerPrivate.h

    r239427 r239985  
    7777    void detachFromDocument(Document*);
    7878
    79     bool isRunningAnimationOnRenderer(RenderElement&, CSSPropertyID, AnimationBase::RunningState) const;
    80     bool isRunningAcceleratedAnimationOnRenderer(RenderElement&, CSSPropertyID, AnimationBase::RunningState) const;
     79    bool isRunningAnimationOnRenderer(RenderElement&, CSSPropertyID) const;
     80    bool isRunningAcceleratedAnimationOnRenderer(RenderElement&, CSSPropertyID) const;
    8181
    8282    bool pauseAnimationAtTime(Element&, const AtomicString& name, double t);
  • trunk/Source/WebCore/page/animation/CompositeAnimation.cpp

    r239427 r239985  
    511511}
    512512
    513 bool CompositeAnimation::isAnimatingProperty(CSSPropertyID property, bool acceleratedOnly, AnimationBase::RunningState runningState) const
     513bool CompositeAnimation::isAnimatingProperty(CSSPropertyID property, bool acceleratedOnly) const
    514514{
    515515    if (!m_keyframeAnimations.isEmpty()) {
    516516        m_keyframeAnimations.checkConsistency();
    517517        for (auto& animation : m_keyframeAnimations.values()) {
    518             if (animation->isAnimatingProperty(property, acceleratedOnly, runningState))
     518            if (animation->isAnimatingProperty(property, acceleratedOnly))
    519519                return true;
    520520        }
    … …  
    523523    if (!m_transitions.isEmpty()) {
    524524        for (auto& transition : m_transitions.values()) {
    525             if (transition->isAnimatingProperty(property, acceleratedOnly, runningState))
     525            if (transition->isAnimatingProperty(property, acceleratedOnly))
    526526                return true;
    527527        }
  • trunk/Source/WebCore/page/animation/CompositeAnimation.h

    r239427 r239985  
    7070    bool hasAnimations() const  { return !m_transitions.isEmpty() || !m_keyframeAnimations.isEmpty(); }
    7171
    72     bool isAnimatingProperty(CSSPropertyID, bool acceleratedOnly, AnimationBase::RunningState) const;
     72    bool isAnimatingProperty(CSSPropertyID, bool acceleratedOnly) const;
    7373
    7474    KeyframeAnimation* animationForProperty(CSSPropertyID) const;
  • trunk/Source/WebCore/rendering/RenderLayer.cpp

    r239965 r239985  
    12061206        }
    12071207    } else {
    1208         if (renderer().animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyTransform, AnimationBase::Running | AnimationBase::Paused)) {
     1208        if (renderer().animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyTransform)) {
    12091209            TransformationMatrix currTransform;
    12101210            FloatRect pixelSnappedBorderRect = snapRectToDevicePixels(box->borderBoxRect(), box->document().deviceScaleFactor());
  • trunk/Source/WebCore/rendering/RenderLayerBacking.cpp

    r239576 r239985  
    991991        }
    992992    } else {
    993         isRunningAcceleratedTransformAnimation = renderer().animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyTransform, AnimationBase::Running | AnimationBase::Paused);
    994         isRunningAcceleratedOpacityAnimation = renderer().animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyOpacity, AnimationBase::Running | AnimationBase::Paused);
     993        isRunningAcceleratedTransformAnimation = renderer().animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyTransform);
     994        isRunningAcceleratedOpacityAnimation = renderer().animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyOpacity);
    995995    }
    996996
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r239658 r239985  
    24402440        return false;
    24412441
    2442     const AnimationBase::RunningState activeAnimationState = AnimationBase::Running | AnimationBase::Paused;
    24432442    auto& animController = renderer.animation();
    2444     return (animController.isRunningAnimationOnRenderer(renderer, CSSPropertyOpacity, activeAnimationState)
     2443    return (animController.isRunningAnimationOnRenderer(renderer, CSSPropertyOpacity)
    24452444        && (usesCompositing() || (m_compositingTriggers & ChromeClient::AnimatedOpacityTrigger)))
    2446         || animController.isRunningAnimationOnRenderer(renderer, CSSPropertyFilter, activeAnimationState)
     2445        || animController.isRunningAnimationOnRenderer(renderer, CSSPropertyFilter)
    24472446#if ENABLE(FILTERS_LEVEL_2)
    2448         || animController.isRunningAnimationOnRenderer(renderer, CSSPropertyWebkitBackdropFilter, activeAnimationState)
    2449 #endif
    2450         || animController.isRunningAnimationOnRenderer(renderer, CSSPropertyTransform, activeAnimationState);
     2447        || animController.isRunningAnimationOnRenderer(renderer, CSSPropertyWebkitBackdropFilter)
     2448#endif
     2449        || animController.isRunningAnimationOnRenderer(renderer, CSSPropertyTransform);
    24512450}
    24522451
    … …  
    28572856        return false;
    28582857    }
    2859     return renderer.animation().isRunningAnimationOnRenderer(renderer, CSSPropertyTransform, AnimationBase::Running | AnimationBase::Paused);
     2858    return renderer.animation().isRunningAnimationOnRenderer(renderer, CSSPropertyTransform);
    28602859}
    28612860
Note: See TracChangeset for help on using the changeset viewer.