Title: [289212] trunk/Source/WebCore
- Revision
- 289212
- Author
- [email protected]
- Date
- 2022-02-07 06:06:06 -0800 (Mon, 07 Feb 2022)
Log Message
Refactor DocumentTimeline::isRunningAcceleratedAnimationOnRenderer() into a Styleable method
https://bugs.webkit.org/show_bug.cgi?id=236224
Reviewed by Dean Jackson.
This method has nothing to do with DocumentTimeline, so let's instead expose it on Styleable.
While we're at it, since it's only ever called with CSSPropertyTransform as a parameter, let's
make it specific to that property.
Next, we'll make that method account for other transform-related properties in bug 236019.
* animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::isRunningAcceleratedAnimationOnRenderer const): Deleted.
* animation/DocumentTimeline.h:
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::currentTransform const):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateGeometry):
* style/Styleable.cpp:
(WebCore::Styleable::isRunningAcceleratedTransformAnimation const):
* style/Styleable.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (289211 => 289212)
--- trunk/Source/WebCore/ChangeLog 2022-02-07 13:57:38 UTC (rev 289211)
+++ trunk/Source/WebCore/ChangeLog 2022-02-07 14:06:06 UTC (rev 289212)
@@ -1,5 +1,29 @@
2022-02-07 Antoine Quint <[email protected]>
+ Refactor DocumentTimeline::isRunningAcceleratedAnimationOnRenderer() into a Styleable method
+ https://bugs.webkit.org/show_bug.cgi?id=236224
+
+ Reviewed by Dean Jackson.
+
+ This method has nothing to do with DocumentTimeline, so let's instead expose it on Styleable.
+ While we're at it, since it's only ever called with CSSPropertyTransform as a parameter, let's
+ make it specific to that property.
+
+ Next, we'll make that method account for other transform-related properties in bug 236019.
+
+ * animation/DocumentTimeline.cpp:
+ (WebCore::DocumentTimeline::isRunningAcceleratedAnimationOnRenderer const): Deleted.
+ * animation/DocumentTimeline.h:
+ * rendering/RenderLayer.cpp:
+ (WebCore::RenderLayer::currentTransform const):
+ * rendering/RenderLayerBacking.cpp:
+ (WebCore::RenderLayerBacking::updateGeometry):
+ * style/Styleable.cpp:
+ (WebCore::Styleable::isRunningAcceleratedTransformAnimation const):
+ * style/Styleable.h:
+
+2022-02-07 Antoine Quint <[email protected]>
+
[Web Animations] Starting a transform animation with a 1ms delay doesn't run it accelerated
https://bugs.webkit.org/show_bug.cgi?id=236080
<rdar://problem/88432373>
Modified: trunk/Source/WebCore/animation/DocumentTimeline.cpp (289211 => 289212)
--- trunk/Source/WebCore/animation/DocumentTimeline.cpp 2022-02-07 13:57:38 UTC (rev 289211)
+++ trunk/Source/WebCore/animation/DocumentTimeline.cpp 2022-02-07 14:06:06 UTC (rev 289212)
@@ -336,31 +336,6 @@
m_tickScheduleTimer.startOneShot(scheduleDelay);
}
-bool DocumentTimeline::isRunningAcceleratedAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property) const
-{
- auto styleable = Styleable::fromRenderer(renderer);
- if (!styleable)
- return false;
-
- auto* animations = styleable->animations();
- if (!animations)
- return false;
-
- for (const auto& animation : *animations) {
- auto playState = animation->playState();
- if (playState != WebAnimation::PlayState::Running && playState != WebAnimation::PlayState::Paused)
- continue;
- auto* effect = animation->effect();
- if (is<KeyframeEffect>(effect)) {
- auto* keyframeEffect = downcast<KeyframeEffect>(effect);
- if (keyframeEffect->isCurrentlyAffectingProperty(property, KeyframeEffect::Accelerated::Yes))
- return true;
- }
- }
-
- return false;
-}
-
void DocumentTimeline::animationAcceleratedRunningStateDidChange(WebAnimation& animation)
{
m_acceleratedAnimationsPendingRunningStateChange.add(&animation);
Modified: trunk/Source/WebCore/animation/DocumentTimeline.h (289211 => 289212)
--- trunk/Source/WebCore/animation/DocumentTimeline.h 2022-02-07 13:57:38 UTC (rev 289211)
+++ trunk/Source/WebCore/animation/DocumentTimeline.h 2022-02-07 14:06:06 UTC (rev 289212)
@@ -60,7 +60,6 @@
void removeAnimation(WebAnimation&) override;
void transitionDidComplete(RefPtr<CSSTransition>);
- bool isRunningAcceleratedAnimationOnRenderer(RenderElement&, CSSPropertyID) const;
void animationAcceleratedRunningStateDidChange(WebAnimation&);
bool runningAnimationsForRendererAreAllAccelerated(const RenderBoxModelObject&) const;
void detachFromDocument();
Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (289211 => 289212)
--- trunk/Source/WebCore/rendering/RenderLayer.cpp 2022-02-07 13:57:38 UTC (rev 289211)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp 2022-02-07 14:06:06 UTC (rev 289212)
@@ -1354,8 +1354,8 @@
auto& renderBox = downcast<RenderBox>(renderer());
- if (auto* timeline = renderer().documentTimeline()) {
- if (timeline->isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyTransform)) {
+ if (auto styleable = Styleable::fromRenderer(renderer())) {
+ if (styleable->isRunningAcceleratedTransformAnimation()) {
TransformationMatrix currTransform;
std::unique_ptr<RenderStyle> style = renderer().animatedStyle();
FloatRect pixelSnappedBorderRect = snapRectToDevicePixels(renderBox.referenceBox(transformBoxToCSSBoxType(style->transformBox())), renderBox.document().deviceScaleFactor());
Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (289211 => 289212)
--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2022-02-07 13:57:38 UTC (rev 289211)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp 2022-02-07 14:06:06 UTC (rev 289212)
@@ -72,6 +72,7 @@
#include "ScrollingCoordinator.h"
#include "Settings.h"
#include "StyleResolver.h"
+#include "Styleable.h"
#include "TiledBacking.h"
#include <wtf/SystemTracing.h>
#include <wtf/text/TextStream.h>
@@ -1293,8 +1294,8 @@
const auto deviceScaleFactor = this->deviceScaleFactor();
bool isRunningAcceleratedTransformAnimation = false;
- if (auto* timeline = renderer().documentTimeline())
- isRunningAcceleratedTransformAnimation = timeline->isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyTransform);
+ if (auto styleable = Styleable::fromRenderer(renderer()))
+ isRunningAcceleratedTransformAnimation = styleable->isRunningAcceleratedTransformAnimation();
updateTransform(style);
updateOpacity(style);
Modified: trunk/Source/WebCore/style/Styleable.cpp (289211 => 289212)
--- trunk/Source/WebCore/style/Styleable.cpp 2022-02-07 13:57:38 UTC (rev 289211)
+++ trunk/Source/WebCore/style/Styleable.cpp 2022-02-07 14:06:06 UTC (rev 289212)
@@ -149,6 +149,20 @@
return true;
}
+bool Styleable::isRunningAcceleratedTransformAnimation() const
+{
+ auto* effectStack = keyframeEffectStack();
+ if (!effectStack)
+ return false;
+
+ for (const auto& effect : effectStack->sortedEffects()) {
+ if (effect->isCurrentlyAffectingProperty(CSSPropertyTransform, KeyframeEffect::Accelerated::Yes))
+ return true;
+ }
+
+ return false;
+}
+
void Styleable::animationWasAdded(WebAnimation& animation) const
{
ensureAnimations().add(&animation);
Modified: trunk/Source/WebCore/style/Styleable.h (289211 => 289212)
--- trunk/Source/WebCore/style/Styleable.h 2022-02-07 13:57:38 UTC (rev 289211)
+++ trunk/Source/WebCore/style/Styleable.h 2022-02-07 14:06:06 UTC (rev 289212)
@@ -77,6 +77,8 @@
// we were unable to cheaply compute its effect on the extent.
bool computeAnimationExtent(LayoutRect&) const;
+ bool isRunningAcceleratedTransformAnimation() const;
+
KeyframeEffectStack* keyframeEffectStack() const
{
return element.keyframeEffectStack(pseudoId);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes