Title: [289178] trunk/Source/WebCore
Revision
289178
Author
[email protected]
Date
2022-02-06 12:42:34 -0800 (Sun, 06 Feb 2022)

Log Message

[web-animations] DocumentTimeline::computeExtentOfAnimation() should be defined on Styleable
https://bugs.webkit.org/show_bug.cgi?id=236204

Reviewed by Dean Jackson.

There is no need to go through the DocumentTimeline to compute the animated
bounds for a renderer. Styleable is a more appropriate place for this.

* animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::computeExtentOfAnimation const): Deleted.
* animation/DocumentTimeline.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects const):
* style/Styleable.cpp:
(WebCore::Styleable::computeAnimationExtent const):
* style/Styleable.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (289177 => 289178)


--- trunk/Source/WebCore/ChangeLog	2022-02-06 20:37:53 UTC (rev 289177)
+++ trunk/Source/WebCore/ChangeLog	2022-02-06 20:42:34 UTC (rev 289178)
@@ -1,3 +1,22 @@
+2022-02-06  Antoine Quint  <[email protected]>
+
+        [web-animations] DocumentTimeline::computeExtentOfAnimation() should be defined on Styleable
+        https://bugs.webkit.org/show_bug.cgi?id=236204
+
+        Reviewed by Dean Jackson.
+
+        There is no need to go through the DocumentTimeline to compute the animated
+        bounds for a renderer. Styleable is a more appropriate place for this.
+
+        * animation/DocumentTimeline.cpp:
+        (WebCore::DocumentTimeline::computeExtentOfAnimation const): Deleted.
+        * animation/DocumentTimeline.h:
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::calculateClipRects const):
+        * style/Styleable.cpp:
+        (WebCore::Styleable::computeAnimationExtent const):
+        * style/Styleable.h:
+
 2022-02-06  Alan Bujtas  <[email protected]>
 
         [LFC][IFC] Introduce LineBoxBuilder::setBaselineAndLayoutBounds/layoutBoundsMetricsForInlineBox

Modified: trunk/Source/WebCore/animation/DocumentTimeline.cpp (289177 => 289178)


--- trunk/Source/WebCore/animation/DocumentTimeline.cpp	2022-02-06 20:37:53 UTC (rev 289177)
+++ trunk/Source/WebCore/animation/DocumentTimeline.cpp	2022-02-06 20:42:34 UTC (rev 289178)
@@ -336,32 +336,6 @@
         m_tickScheduleTimer.startOneShot(scheduleDelay);
 }
 
-bool DocumentTimeline::computeExtentOfAnimation(RenderElement& renderer, LayoutRect& bounds) const
-{
-    auto styleable = Styleable::fromRenderer(renderer);
-    if (!styleable)
-        return false;
-
-    auto* animations = styleable->animations();
-    if (!animations)
-        return false;
-
-    KeyframeEffect* matchingEffect = nullptr;
-    for (const auto& animation : *animations) {
-        auto* effect = animation->effect();
-        if (is<KeyframeEffect>(effect)) {
-            auto* keyframeEffect = downcast<KeyframeEffect>(effect);
-            if (keyframeEffect->animatedProperties().contains(CSSPropertyTransform))
-                matchingEffect = downcast<KeyframeEffect>(effect);
-        }
-    }
-
-    if (matchingEffect)
-        return matchingEffect->computeExtentOfTransformAnimation(bounds);
-
-    return true;
-}
-
 bool DocumentTimeline::isRunningAcceleratedAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property) const
 {
     auto styleable = Styleable::fromRenderer(renderer);

Modified: trunk/Source/WebCore/animation/DocumentTimeline.h (289177 => 289178)


--- trunk/Source/WebCore/animation/DocumentTimeline.h	2022-02-06 20:37:53 UTC (rev 289177)
+++ trunk/Source/WebCore/animation/DocumentTimeline.h	2022-02-06 20:42:34 UTC (rev 289178)
@@ -60,10 +60,6 @@
     void removeAnimation(WebAnimation&) override;
     void transitionDidComplete(RefPtr<CSSTransition>);
 
-    // If possible, compute the visual extent of any transform animation on the given renderer
-    // using the given rect, returning the result in the rect. Return false if there is some
-    // transform animation but we were unable to cheaply compute its effect on the extent.
-    bool computeExtentOfAnimation(RenderElement&, LayoutRect&) const;
     bool isRunningAcceleratedAnimationOnRenderer(RenderElement&, CSSPropertyID) const;
     void animationAcceleratedRunningStateDidChange(WebAnimation&);
     bool runningAnimationsForRendererAreAllAccelerated(const RenderBoxModelObject&) const;

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (289177 => 289178)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2022-02-06 20:37:53 UTC (rev 289177)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2022-02-06 20:42:34 UTC (rev 289178)
@@ -130,6 +130,7 @@
 #include "SourceGraphic.h"
 #include "StyleProperties.h"
 #include "StyleResolver.h"
+#include "Styleable.h"
 #include "TransformationMatrix.h"
 #include "TranslateTransformOperation.h"
 #include "WheelEventTestMonitor.h"
@@ -4882,8 +4883,8 @@
     bounds = calculateLayerBounds(this, LayoutSize(), boundsFlags);
     
     LayoutRect animatedBounds = bounds;
-    if (auto* timeline = renderer().documentTimeline()) {
-        if (timeline->computeExtentOfAnimation(renderer(), animatedBounds)) {
+    if (auto styleable = Styleable::fromRenderer(renderer())) {
+        if (styleable->computeAnimationExtent(animatedBounds)) {
             bounds = animatedBounds;
             return true;
         }

Modified: trunk/Source/WebCore/style/Styleable.cpp (289177 => 289178)


--- trunk/Source/WebCore/style/Styleable.cpp	2022-02-06 20:37:53 UTC (rev 289177)
+++ trunk/Source/WebCore/style/Styleable.cpp	2022-02-06 20:42:34 UTC (rev 289178)
@@ -127,6 +127,28 @@
     return animatedStyle;
 }
 
+bool Styleable::computeAnimationExtent(LayoutRect& bounds) const
+{
+    auto* animations = this->animations();
+    if (!animations)
+        return false;
+
+    KeyframeEffect* matchingEffect = nullptr;
+    for (const auto& animation : *animations) {
+        auto* effect = animation->effect();
+        if (is<KeyframeEffect>(effect)) {
+            auto* keyframeEffect = downcast<KeyframeEffect>(effect);
+            if (keyframeEffect->animatedProperties().contains(CSSPropertyTransform))
+                matchingEffect = downcast<KeyframeEffect>(effect);
+        }
+    }
+
+    if (matchingEffect)
+        return matchingEffect->computeExtentOfTransformAnimation(bounds);
+
+    return true;
+}
+
 void Styleable::animationWasAdded(WebAnimation& animation) const
 {
     ensureAnimations().add(&animation);

Modified: trunk/Source/WebCore/style/Styleable.h (289177 => 289178)


--- trunk/Source/WebCore/style/Styleable.h	2022-02-06 20:37:53 UTC (rev 289177)
+++ trunk/Source/WebCore/style/Styleable.h	2022-02-06 20:42:34 UTC (rev 289178)
@@ -72,6 +72,11 @@
 
     std::unique_ptr<RenderStyle> computeAnimatedStyle() const;
 
+    // If possible, compute the visual extent of any transform animation using the given rect,
+    // returning the result in the rect. Return false if there is some transform animation but
+    // we were unable to cheaply compute its effect on the extent.
+    bool computeAnimationExtent(LayoutRect&) const;
+
     KeyframeEffectStack* keyframeEffectStack() const
     {
         return element.keyframeEffectStack(pseudoId);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to