Changeset 289455 in webkit


Ignore:
Timestamp:
Feb 8, 2022, 10:39:34 PM (4 years ago)
Author:
graouts@webkit.org
Message:

Move DocumentTimeline::runningAnimationsForRendererAreAllAccelerated() to Styleable
https://bugs.webkit.org/show_bug.cgi?id=236239

Reviewed by Dean Jackson.

This method has nothing to do with DocumentTimeline and everything to do with Styleable and its associated
effect stack. This also allows us to remove WebAnimation::isRunningAccelerated() since we don't need to go
through the animation as we iterate over keyframe effects directly.

This refactor surfaced an issue with Styleable::fromRenderer() where in the ::marker case we would fail
to correctly obtain the parent RenderListItem, we now recurse through parents until we find one instead
of stopping at the first ancestor with an element.

  • animation/DocumentTimeline.cpp:

(WebCore::DocumentTimeline::runningAnimationsForRendererAreAllAccelerated const): Deleted.

  • animation/DocumentTimeline.h:
  • animation/WebAnimation.cpp:

(WebCore::WebAnimation::isRunningAccelerated const): Deleted.

  • animation/WebAnimation.h:
  • rendering/RenderBoxModelObject.cpp:

(WebCore::RenderBoxModelObject::hasRunningAcceleratedAnimations const):

  • style/Styleable.cpp:

(WebCore::Styleable::fromRenderer):
(WebCore::Styleable::runningAnimationsAreAllAccelerated const):

  • style/Styleable.h:
Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r289454 r289455  
     12022-02-08  Antoine Quint  <graouts@webkit.org>
     2
     3        Move DocumentTimeline::runningAnimationsForRendererAreAllAccelerated() to Styleable
     4        https://bugs.webkit.org/show_bug.cgi?id=236239
     5
     6        Reviewed by Dean Jackson.
     7
     8        This method has nothing to do with DocumentTimeline and everything to do with Styleable and its associated
     9        effect stack. This also allows us to remove WebAnimation::isRunningAccelerated() since we don't need to go
     10        through the animation as we iterate over keyframe effects directly.
     11
     12        This refactor surfaced an issue with Styleable::fromRenderer() where in the ::marker case we would fail
     13        to correctly obtain the parent RenderListItem, we now recurse through parents until we find one instead
     14        of stopping at the first ancestor with an element.
     15
     16        * animation/DocumentTimeline.cpp:
     17        (WebCore::DocumentTimeline::runningAnimationsForRendererAreAllAccelerated const): Deleted.
     18        * animation/DocumentTimeline.h:
     19        * animation/WebAnimation.cpp:
     20        (WebCore::WebAnimation::isRunningAccelerated const): Deleted.
     21        * animation/WebAnimation.h:
     22        * rendering/RenderBoxModelObject.cpp:
     23        (WebCore::RenderBoxModelObject::hasRunningAcceleratedAnimations const):
     24        * style/Styleable.cpp:
     25        (WebCore::Styleable::fromRenderer):
     26        (WebCore::Styleable::runningAnimationsAreAllAccelerated const):
     27        * style/Styleable.h:
     28
    1292022-02-08  Antoine Quint  <graouts@webkit.org>
    230
  • trunk/Source/WebCore/animation/DocumentTimeline.cpp

    r289357 r289455  
    387387}
    388388
    389 bool DocumentTimeline::runningAnimationsForRendererAreAllAccelerated(const RenderBoxModelObject& renderer) const
    390 {
    391     auto styleable = Styleable::fromRenderer(renderer);
    392     if (!styleable)
    393         return false;
    394 
    395     auto* animations = styleable->animations();
    396     if (!animations || animations->isEmpty())
    397         return false;
    398 
    399     for (const auto& animation : *animations) {
    400         if (!animation->isRunningAccelerated())
    401             return false;
    402     }
    403 
    404     return true;
    405 }
    406 
    407389void DocumentTimeline::enqueueAnimationEvent(AnimationEventBase& event)
    408390{
  • trunk/Source/WebCore/animation/DocumentTimeline.h

    r289357 r289455  
    6262
    6363    void animationAcceleratedRunningStateDidChange(WebAnimation&);
    64     bool runningAnimationsForRendererAreAllAccelerated(const RenderBoxModelObject&) const;
    6564    void detachFromDocument();
    6665
  • trunk/Source/WebCore/animation/WebAnimation.cpp

    r289453 r289455  
    12531253}
    12541254
    1255 bool WebAnimation::isRunningAccelerated() const
    1256 {
    1257     return is<KeyframeEffect>(m_effect) && downcast<KeyframeEffect>(*m_effect).isRunningAccelerated();
    1258 }
    1259 
    12601255bool WebAnimation::needsTick() const
    12611256{
  • trunk/Source/WebCore/animation/WebAnimation.h

    r289357 r289455  
    135135    void willChangeRenderer();
    136136
    137     bool isRunningAccelerated() const;
    138137    bool isRelevant() const { return m_isRelevant; }
    139138    void updateRelevance();
  • trunk/Source/WebCore/rendering/RenderBoxModelObject.cpp

    r289357 r289455  
    3232#include "ColorBlending.h"
    3333#include "Document.h"
    34 #include "DocumentTimeline.h"
    3534#include "FloatRoundedRect.h"
    3635#include "Frame.h"
     
    6160#include "ScrollingConstraints.h"
    6261#include "Settings.h"
     62#include "Styleable.h"
    6363#include "TextBoxPainter.h"
    6464#include "TransformState.h"
     
    27002700bool RenderBoxModelObject::hasRunningAcceleratedAnimations() const
    27012701{
    2702     if (auto* node = element()) {
    2703         if (auto* timeline = node->document().existingTimeline())
    2704             return timeline->runningAnimationsForRendererAreAllAccelerated(*this);
    2705     }
     2702    if (auto styleable = Styleable::fromRenderer(*this))
     2703        return styleable->runningAnimationsAreAllAccelerated();
    27062704    return false;
    27072705}
  • trunk/Source/WebCore/style/Styleable.cpp

    r289357 r289455  
    6161        }
    6262        break;
    63     case PseudoId::Marker:
    64         if (auto* ancestor = renderer.parent()) {
    65             while (ancestor && !ancestor->element())
    66                 ancestor = ancestor->parent();
    67             ASSERT(is<RenderListItem>(ancestor));
    68             ASSERT(downcast<RenderListItem>(ancestor)->markerRenderer() == &renderer);
    69             return Styleable(*ancestor->element(), PseudoId::Marker);
     63    case PseudoId::Marker: {
     64        auto* ancestor = renderer.parent();
     65        while (ancestor) {
     66            if (is<RenderListItem>(ancestor) && ancestor->element() && downcast<RenderListItem>(ancestor)->markerRenderer() == &renderer)
     67                return Styleable(*ancestor->element(), PseudoId::Marker);
     68            ancestor = ancestor->parent();
    7069        }
    7170        break;
     71    }
    7272    case PseudoId::After:
    7373    case PseudoId::Before:
     
    162162
    163163    return false;
     164}
     165
     166bool Styleable::runningAnimationsAreAllAccelerated() const
     167{
     168    auto* effectStack = keyframeEffectStack();
     169    if (!effectStack || !effectStack->hasEffects())
     170        return false;
     171
     172    for (const auto& effect : effectStack->sortedEffects()) {
     173        if (!effect->isRunningAccelerated())
     174            return false;
     175    }
     176
     177    return true;
    164178}
    165179
  • trunk/Source/WebCore/style/Styleable.h

    r289357 r289455  
    7979
    8080    bool isRunningAcceleratedTransformAnimation() const;
     81
     82    bool runningAnimationsAreAllAccelerated() const;
    8183
    8284    KeyframeEffectStack* keyframeEffectStack() const
Note: See TracChangeset for help on using the changeset viewer.