Title: [230578] trunk
Revision
230578
Author
grao...@webkit.org
Date
2018-04-12 09:34:42 -0700 (Thu, 12 Apr 2018)

Log Message

[Web Animations] Ensure elements overlapping with elements animating also get composited
https://bugs.webkit.org/show_bug.cgi?id=184539

Reviewed by Jon Lee.

Source/WebCore:

A number of compositing tests failed because we didn't call into the Web Animations engine while various calls
on RenderLayer and RenderLayerBacking were made. We bring the functionality over from CSSAnimationController to
DocumentTimeline and KeyframeAnimation to KeyframeEffectReadOnly.

* animation/AnimationTimeline.cpp:
(WebCore::AnimationTimeline::animationsForElement const): Update this method's signature to be const since it
should be callable by other const method.
(WebCore::AnimationTimeline::animationsForElement): Deleted.
* animation/AnimationTimeline.h:
* animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::computeExtentOfAnimation const): Adapt this method from CSSAnimationController.
(WebCore::DocumentTimeline::isRunningAnimationOnRenderer const): Adapt this method from CSSAnimationController.
(WebCore::DocumentTimeline::isRunningAcceleratedAnimationOnRenderer const): Adapt this method from CSSAnimationController.
* animation/DocumentTimeline.h:
* animation/KeyframeEffectReadOnly.cpp:
(WebCore::KeyframeEffectReadOnly::computeExtentOfTransformAnimation const): Bring this method over from KeyframeAnimation.
(WebCore::containsRotation): Bring this method over from KeyframeAnimation.
(WebCore::KeyframeEffectReadOnly::computeTransformedExtentViaTransformList const): Bring this method over from KeyframeAnimation.
(WebCore::KeyframeEffectReadOnly::computeTransformedExtentViaMatrix const): Bring this method over from KeyframeAnimation.
* animation/KeyframeEffectReadOnly.h:
(WebCore::KeyframeEffectReadOnly::animatedProperties const): DocumentTimeline::computeExtentOfAnimation() needs to get a list
of all animated properties to see if a transform is animated, so we now expose such a list.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::currentTransform const): Update this method to call into DocumentTimeline if the CSS Animations
and CSS Transitions as Web Animations flag is on.
(WebCore::RenderLayer::calculateClipRects const): Update this method to call into DocumentTimeline if the CSS Animations
and CSS Transitions as Web Animations flag is on.
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateGeometry): Update this method to call into DocumentTimeline if the CSS Animations
and CSS Transitions as Web Animations flag is on.
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::isRunningTransformAnimation const): Update this method to call into DocumentTimeline
if the CSS Animations and CSS Transitions as Web Animations flag is on.
* rendering/RenderObject.h:
(WebCore::RenderObject::documentTimeline const):

LayoutTests:

Opt more tests in the CSS Animations and CSS Transitions as Web Animations runtime flag since they now pass.

* compositing/backing/backface-visibility-flip.html:
* compositing/layer-creation/overlap-animation-clipping.html:
* compositing/layer-creation/overlap-animation-container.html:
* compositing/layer-creation/overlap-animation.html:
* compositing/layer-creation/translate-animation-overlap.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (230577 => 230578)


--- trunk/LayoutTests/ChangeLog	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/LayoutTests/ChangeLog	2018-04-12 16:34:42 UTC (rev 230578)
@@ -1,3 +1,18 @@
+2018-04-12  Antoine Quint  <grao...@apple.com>
+
+        [Web Animations] Ensure elements overlapping with elements animating also get composited
+        https://bugs.webkit.org/show_bug.cgi?id=184539
+
+        Reviewed by Jon Lee.
+
+        Opt more tests in the CSS Animations and CSS Transitions as Web Animations runtime flag since they now pass.
+
+        * compositing/backing/backface-visibility-flip.html:
+        * compositing/layer-creation/overlap-animation-clipping.html:
+        * compositing/layer-creation/overlap-animation-container.html:
+        * compositing/layer-creation/overlap-animation.html:
+        * compositing/layer-creation/translate-animation-overlap.html:
+
 2018-04-11  Antoine Quint  <grao...@apple.com>
 
         [Web Animations] Enable seeking for hardware animations

Modified: trunk/LayoutTests/compositing/backing/backface-visibility-flip.html (230577 => 230578)


--- trunk/LayoutTests/compositing/backing/backface-visibility-flip.html	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/LayoutTests/compositing/backing/backface-visibility-flip.html	2018-04-12 16:34:42 UTC (rev 230578)
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
 
 <html>
 <head>

Modified: trunk/LayoutTests/compositing/layer-creation/overlap-animation-clipping.html (230577 => 230578)


--- trunk/LayoutTests/compositing/layer-creation/overlap-animation-clipping.html	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/LayoutTests/compositing/layer-creation/overlap-animation-clipping.html	2018-04-12 16:34:42 UTC (rev 230578)
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
 
 <html>
 <head>

Modified: trunk/LayoutTests/compositing/layer-creation/overlap-animation-container.html (230577 => 230578)


--- trunk/LayoutTests/compositing/layer-creation/overlap-animation-container.html	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/LayoutTests/compositing/layer-creation/overlap-animation-container.html	2018-04-12 16:34:42 UTC (rev 230578)
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
 
 <html>
 <head>

Modified: trunk/LayoutTests/compositing/layer-creation/overlap-animation.html (230577 => 230578)


--- trunk/LayoutTests/compositing/layer-creation/overlap-animation.html	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/LayoutTests/compositing/layer-creation/overlap-animation.html	2018-04-12 16:34:42 UTC (rev 230578)
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
 
 <html>
 <head>

Modified: trunk/LayoutTests/compositing/layer-creation/translate-animation-overlap.html (230577 => 230578)


--- trunk/LayoutTests/compositing/layer-creation/translate-animation-overlap.html	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/LayoutTests/compositing/layer-creation/translate-animation-overlap.html	2018-04-12 16:34:42 UTC (rev 230578)
@@ -1,4 +1,4 @@
-<!DOCTYPE html>
+<!DOCTYPE html><!-- webkit-test-runner [ enableCSSAnimationsAndCSSTransitionsBackedByWebAnimations=true ] -->
 
 <html>
 <head>

Modified: trunk/Source/WebCore/ChangeLog (230577 => 230578)


--- trunk/Source/WebCore/ChangeLog	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/Source/WebCore/ChangeLog	2018-04-12 16:34:42 UTC (rev 230578)
@@ -1,3 +1,46 @@
+2018-04-12  Antoine Quint  <grao...@apple.com>
+
+        [Web Animations] Ensure elements overlapping with elements animating also get composited
+        https://bugs.webkit.org/show_bug.cgi?id=184539
+
+        Reviewed by Jon Lee.
+
+        A number of compositing tests failed because we didn't call into the Web Animations engine while various calls
+        on RenderLayer and RenderLayerBacking were made. We bring the functionality over from CSSAnimationController to
+        DocumentTimeline and KeyframeAnimation to KeyframeEffectReadOnly.
+
+        * animation/AnimationTimeline.cpp:
+        (WebCore::AnimationTimeline::animationsForElement const): Update this method's signature to be const since it
+        should be callable by other const method.
+        (WebCore::AnimationTimeline::animationsForElement): Deleted.
+        * animation/AnimationTimeline.h:
+        * animation/DocumentTimeline.cpp:
+        (WebCore::DocumentTimeline::computeExtentOfAnimation const): Adapt this method from CSSAnimationController.
+        (WebCore::DocumentTimeline::isRunningAnimationOnRenderer const): Adapt this method from CSSAnimationController.
+        (WebCore::DocumentTimeline::isRunningAcceleratedAnimationOnRenderer const): Adapt this method from CSSAnimationController.
+        * animation/DocumentTimeline.h:
+        * animation/KeyframeEffectReadOnly.cpp:
+        (WebCore::KeyframeEffectReadOnly::computeExtentOfTransformAnimation const): Bring this method over from KeyframeAnimation.
+        (WebCore::containsRotation): Bring this method over from KeyframeAnimation.
+        (WebCore::KeyframeEffectReadOnly::computeTransformedExtentViaTransformList const): Bring this method over from KeyframeAnimation.
+        (WebCore::KeyframeEffectReadOnly::computeTransformedExtentViaMatrix const): Bring this method over from KeyframeAnimation.
+        * animation/KeyframeEffectReadOnly.h:
+        (WebCore::KeyframeEffectReadOnly::animatedProperties const): DocumentTimeline::computeExtentOfAnimation() needs to get a list
+        of all animated properties to see if a transform is animated, so we now expose such a list.
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::currentTransform const): Update this method to call into DocumentTimeline if the CSS Animations
+        and CSS Transitions as Web Animations flag is on.
+        (WebCore::RenderLayer::calculateClipRects const): Update this method to call into DocumentTimeline if the CSS Animations
+        and CSS Transitions as Web Animations flag is on.
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateGeometry): Update this method to call into DocumentTimeline if the CSS Animations
+        and CSS Transitions as Web Animations flag is on.
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::isRunningTransformAnimation const): Update this method to call into DocumentTimeline
+        if the CSS Animations and CSS Transitions as Web Animations flag is on.
+        * rendering/RenderObject.h:
+        (WebCore::RenderObject::documentTimeline const):
+
 2018-04-11  Antoine Quint  <grao...@apple.com>
 
         [Web Animations] Enable seeking for hardware animations

Modified: trunk/Source/WebCore/animation/AnimationTimeline.cpp (230577 => 230578)


--- trunk/Source/WebCore/animation/AnimationTimeline.cpp	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/Source/WebCore/animation/AnimationTimeline.cpp	2018-04-12 16:34:42 UTC (rev 230578)
@@ -115,7 +115,7 @@
         map.remove(iterator);
 }
 
-Vector<RefPtr<WebAnimation>> AnimationTimeline::animationsForElement(Element& element)
+Vector<RefPtr<WebAnimation>> AnimationTimeline::animationsForElement(Element& element) const
 {
     Vector<RefPtr<WebAnimation>> animations;
     if (m_elementToCSSAnimationsMap.contains(&element))

Modified: trunk/Source/WebCore/animation/AnimationTimeline.h (230577 => 230578)


--- trunk/Source/WebCore/animation/AnimationTimeline.h	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/Source/WebCore/animation/AnimationTimeline.h	2018-04-12 16:34:42 UTC (rev 230578)
@@ -58,7 +58,7 @@
     virtual void timingModelDidChange() { };
 
     const ListHashSet<RefPtr<WebAnimation>>& animations() const { return m_animations; }
-    Vector<RefPtr<WebAnimation>> animationsForElement(Element&);
+    Vector<RefPtr<WebAnimation>> animationsForElement(Element&) const;
     void cancelAnimationsForElement(Element&);
     void animationWasAddedToElement(WebAnimation&, Element&);
     void animationWasRemovedFromElement(WebAnimation&, Element&);

Modified: trunk/Source/WebCore/animation/DocumentTimeline.cpp (230577 => 230578)


--- trunk/Source/WebCore/animation/DocumentTimeline.cpp	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/Source/WebCore/animation/DocumentTimeline.cpp	2018-04-12 16:34:42 UTC (rev 230578)
@@ -190,6 +190,64 @@
     timingModelDidChange();
 }
 
+bool DocumentTimeline::computeExtentOfAnimation(RenderElement& renderer, LayoutRect& bounds) const
+{
+    if (!renderer.element())
+        return true;
+
+    KeyframeEffectReadOnly* matchingEffect;
+    for (const auto& animation : animationsForElement(*renderer.element())) {
+        auto* effect = animation->effect();
+        if (is<KeyframeEffectReadOnly>(effect)) {
+            auto* keyframeEffect = downcast<KeyframeEffectReadOnly>(effect);
+            if (keyframeEffect->animatedProperties().contains(CSSPropertyTransform))
+                matchingEffect = downcast<KeyframeEffectReadOnly>(effect);
+        }
+    }
+
+    if (matchingEffect)
+        return matchingEffect->computeExtentOfTransformAnimation(bounds);
+
+    return true;
+}
+
+bool DocumentTimeline::isRunningAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property) const
+{
+    if (!renderer.element())
+        return false;
+
+    for (const auto& animation : animationsForElement(*renderer.element())) {
+        auto playState = animation->playState();
+        if (playState != WebAnimation::PlayState::Running && playState != WebAnimation::PlayState::Paused)
+            continue;
+        auto* effect = animation->effect();
+        if (is<KeyframeEffectReadOnly>(effect) && downcast<KeyframeEffectReadOnly>(effect)->animatedProperties().contains(property))
+            return true;
+    }
+
+    return false;
+}
+
+bool DocumentTimeline::isRunningAcceleratedAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property) const
+{
+    if (!renderer.element())
+        return false;
+
+    for (const auto& animation : animationsForElement(*renderer.element())) {
+        auto playState = animation->playState();
+        if (playState != WebAnimation::PlayState::Running && playState != WebAnimation::PlayState::Paused)
+            continue;
+        auto* effect = animation->effect();
+        if (is<KeyframeEffectReadOnly>(effect)) {
+            auto* keyframeEffect = downcast<KeyframeEffectReadOnly>(effect);
+            if (keyframeEffect->isRunningAccelerated() && keyframeEffect->animatedProperties().contains(property))
+                return true;
+        }
+    }
+
+    return false;
+}
+
 std::unique_ptr<RenderStyle> DocumentTimeline::animatedStyleForRenderer(RenderElement& renderer)
 {
     std::unique_ptr<RenderStyle> result;

Modified: trunk/Source/WebCore/animation/DocumentTimeline.h (230577 => 230578)


--- trunk/Source/WebCore/animation/DocumentTimeline.h	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/Source/WebCore/animation/DocumentTimeline.h	2018-04-12 16:34:42 UTC (rev 230578)
@@ -57,7 +57,13 @@
     void timingModelDidChange() override;
     void windowScreenDidChange(PlatformDisplayID);
 
+    // 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;
     std::unique_ptr<RenderStyle> animatedStyleForRenderer(RenderElement& renderer);
+    bool isRunningAnimationOnRenderer(RenderElement&, CSSPropertyID) const;
+    bool isRunningAcceleratedAnimationOnRenderer(RenderElement&, CSSPropertyID) const;
     void animationAcceleratedRunningStateDidChange(WebAnimation&);
     void applyPendingAcceleratedAnimations();
     bool runningAnimationsForElementAreAllAccelerated(Element&);

Modified: trunk/Source/WebCore/animation/KeyframeEffectReadOnly.cpp (230577 => 230578)


--- trunk/Source/WebCore/animation/KeyframeEffectReadOnly.cpp	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/Source/WebCore/animation/KeyframeEffectReadOnly.cpp	2018-04-12 16:34:42 UTC (rev 230578)
@@ -37,6 +37,7 @@
 #include "CSSTransition.h"
 #include "Element.h"
 #include "FontCascade.h"
+#include "GeometryUtilities.h"
 #include "JSCompositeOperation.h"
 #include "JSKeyframeEffectReadOnly.h"
 #include "RenderBoxModelObject.h"
@@ -1257,4 +1258,108 @@
     return RenderStyle::defaultStyle();
 }
 
+bool KeyframeEffectReadOnly::computeExtentOfTransformAnimation(LayoutRect& bounds) const
+{
+    ASSERT(m_blendingKeyframes.containsProperty(CSSPropertyTransform));
+
+    if (!is<RenderBox>(renderer()))
+        return true; // Non-boxes don't get transformed;
+
+    RenderBox& box = downcast<RenderBox>(*renderer());
+    FloatRect rendererBox = snapRectToDevicePixels(box.borderBoxRect(), box.document().deviceScaleFactor());
+
+    FloatRect cumulativeBounds = bounds;
+
+    for (const auto& keyframe : m_blendingKeyframes.keyframes()) {
+        // FIXME: maybe for declarative animations we always say it's true for the first and last keyframe.
+        if (!keyframe.containsProperty(CSSPropertyTransform))
+            continue;
+
+        LayoutRect keyframeBounds = bounds;
+
+        bool canCompute;
+        if (transformFunctionListsMatch())
+            canCompute = computeTransformedExtentViaTransformList(rendererBox, *keyframe.style(), keyframeBounds);
+        else
+            canCompute = computeTransformedExtentViaMatrix(rendererBox, *keyframe.style(), keyframeBounds);
+
+        if (!canCompute)
+            return false;
+
+        cumulativeBounds.unite(keyframeBounds);
+    }
+
+    bounds = LayoutRect(cumulativeBounds);
+    return true;
+}
+
+static bool containsRotation(const Vector<RefPtr<TransformOperation>>& operations)
+{
+    for (const auto& operation : operations) {
+        if (operation->type() == TransformOperation::ROTATE)
+            return true;
+    }
+    return false;
+}
+
+bool KeyframeEffectReadOnly::computeTransformedExtentViaTransformList(const FloatRect& rendererBox, const RenderStyle& style, LayoutRect& bounds) const
+{
+    FloatRect floatBounds = bounds;
+    FloatPoint transformOrigin;
+
+    bool applyTransformOrigin = containsRotation(style.transform().operations()) || style.transform().affectedByTransformOrigin();
+    if (applyTransformOrigin) {
+        transformOrigin.setX(rendererBox.x() + floatValueForLength(style.transformOriginX(), rendererBox.width()));
+        transformOrigin.setY(rendererBox.y() + floatValueForLength(style.transformOriginY(), rendererBox.height()));
+        // Ignore transformOriginZ because we'll bail if we encounter any 3D transforms.
+
+        floatBounds.moveBy(-transformOrigin);
+    }
+
+    for (const auto& operation : style.transform().operations()) {
+        if (operation->type() == TransformOperation::ROTATE) {
+            // For now, just treat this as a full rotation. This could take angle into account to reduce inflation.
+            floatBounds = boundsOfRotatingRect(floatBounds);
+        } else {
+            TransformationMatrix transform;
+            operation->apply(transform, rendererBox.size());
+            if (!transform.isAffine())
+                return false;
+
+            if (operation->type() == TransformOperation::MATRIX || operation->type() == TransformOperation::MATRIX_3D) {
+                TransformationMatrix::Decomposed2Type toDecomp;
+                transform.decompose2(toDecomp);
+                // Any rotation prevents us from using a simple start/end rect union.
+                if (toDecomp.angle)
+                    return false;
+            }
+
+            floatBounds = transform.mapRect(floatBounds);
+        }
+    }
+
+    if (applyTransformOrigin)
+        floatBounds.moveBy(transformOrigin);
+
+    bounds = LayoutRect(floatBounds);
+    return true;
+}
+
+bool KeyframeEffectReadOnly::computeTransformedExtentViaMatrix(const FloatRect& rendererBox, const RenderStyle& style, LayoutRect& bounds) const
+{
+    TransformationMatrix transform;
+    style.applyTransform(transform, rendererBox, RenderStyle::IncludeTransformOrigin);
+    if (!transform.isAffine())
+        return false;
+
+    TransformationMatrix::Decomposed2Type fromDecomp;
+    transform.decompose2(fromDecomp);
+    // Any rotation prevents us from using a simple start/end rect union.
+    if (fromDecomp.angle)
+        return false;
+
+    bounds = LayoutRect(transform.mapRect(bounds));
+    return true;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/animation/KeyframeEffectReadOnly.h (230577 => 230578)


--- trunk/Source/WebCore/animation/KeyframeEffectReadOnly.h	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/Source/WebCore/animation/KeyframeEffectReadOnly.h	2018-04-12 16:34:42 UTC (rev 230578)
@@ -116,7 +116,12 @@
     void computeCSSTransitionBlendingKeyframes(const RenderStyle* oldStyle, const RenderStyle& newStyle);
     bool stylesWouldYieldNewCSSTransitionsBlendingKeyframes(const RenderStyle& oldStyle, const RenderStyle& newStyle) const;
     bool hasBlendingKeyframes() const { return m_blendingKeyframes.size(); }
+    const HashSet<CSSPropertyID>& animatedProperties() const { return m_blendingKeyframes.properties(); }
 
+    bool computeExtentOfTransformAnimation(LayoutRect&) const;
+    bool computeTransformedExtentViaTransformList(const FloatRect&, const RenderStyle&, LayoutRect&) const;
+    bool computeTransformedExtentViaMatrix(const FloatRect&, const RenderStyle&, LayoutRect&) const;
+
 protected:
     void copyPropertiesFromSource(Ref<KeyframeEffectReadOnly>&&);
     ExceptionOr<void> processKeyframes(JSC::ExecState&, JSC::Strong<JSC::JSObject>&&);

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (230577 => 230578)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2018-04-12 16:34:42 UTC (rev 230578)
@@ -53,6 +53,7 @@
 #include "Document.h"
 #include "DocumentEventQueue.h"
 #include "DocumentMarkerController.h"
+#include "DocumentTimeline.h"
 #include "Element.h"
 #include "EventHandler.h"
 #include "FEColorMatrix.h"
@@ -107,6 +108,7 @@
 #include "RenderTheme.h"
 #include "RenderTreeAsText.h"
 #include "RenderView.h"
+#include "RuntimeEnabledFeatures.h"
 #include "SVGNames.h"
 #include "ScaleTransformOperation.h"
 #include "ScriptDisallowedScope.h"
@@ -999,15 +1001,29 @@
     
     RenderBox* box = renderBox();
 
-    if (renderer().animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyTransform, AnimationBase::Running | AnimationBase::Paused)) {
-        TransformationMatrix currTransform;
-        FloatRect pixelSnappedBorderRect = snapRectToDevicePixels(box->borderBoxRect(), box->document().deviceScaleFactor());
-        std::unique_ptr<RenderStyle> style = renderer().animation().animatedStyleForRenderer(renderer());
-        style->applyTransform(currTransform, pixelSnappedBorderRect, applyOrigin);
-        makeMatrixRenderable(currTransform, canRender3DTransforms());
-        return currTransform;
+    if (RuntimeEnabledFeatures::sharedFeatures().cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled()) {
+        if (auto* timeline = renderer().documentTimeline()) {
+            if (timeline->isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyTransform)) {
+                TransformationMatrix currTransform;
+                FloatRect pixelSnappedBorderRect = snapRectToDevicePixels(box->borderBoxRect(), box->document().deviceScaleFactor());
+                std::unique_ptr<RenderStyle> style = timeline->animatedStyleForRenderer(renderer());
+                style->applyTransform(currTransform, pixelSnappedBorderRect, applyOrigin);
+                makeMatrixRenderable(currTransform, canRender3DTransforms());
+                return currTransform;
+            }
+        }
+    } else {
+        if (renderer().animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyTransform, AnimationBase::Running | AnimationBase::Paused)) {
+            TransformationMatrix currTransform;
+            FloatRect pixelSnappedBorderRect = snapRectToDevicePixels(box->borderBoxRect(), box->document().deviceScaleFactor());
+            std::unique_ptr<RenderStyle> style = renderer().animation().animatedStyleForRenderer(renderer());
+            style->applyTransform(currTransform, pixelSnappedBorderRect, applyOrigin);
+            makeMatrixRenderable(currTransform, canRender3DTransforms());
+            return currTransform;
+        }
     }
 
+
     // m_transform includes transform-origin, so we need to recompute the transform here.
     if (applyOrigin == RenderStyle::ExcludeTransformOrigin) {
         TransformationMatrix currTransform;
@@ -5775,9 +5791,18 @@
     bounds = calculateLayerBounds(this, LayoutSize(), boundsFlags);
     
     LayoutRect animatedBounds = bounds;
-    if (renderer().animation().computeExtentOfAnimation(renderer(), animatedBounds)) {
-        bounds = animatedBounds;
-        return true;
+    if (RuntimeEnabledFeatures::sharedFeatures().cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled()) {
+        if (auto* timeline = renderer().documentTimeline()) {
+            if (timeline->computeExtentOfAnimation(renderer(), animatedBounds)) {
+                bounds = animatedBounds;
+                return true;
+            }
+        }
+    } else {
+        if (renderer().animation().computeExtentOfAnimation(renderer(), animatedBounds)) {
+            bounds = animatedBounds;
+            return true;
+        }
     }
     
     return false;

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (230577 => 230578)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2018-04-12 16:34:42 UTC (rev 230578)
@@ -33,6 +33,7 @@
 #include "CSSPropertyNames.h"
 #include "CachedImage.h"
 #include "Chrome.h"
+#include "DocumentTimeline.h"
 #include "FilterEffectRenderer.h"
 #include "Frame.h"
 #include "FrameView.h"
@@ -61,6 +62,7 @@
 #include "RenderMedia.h"
 #include "RenderVideo.h"
 #include "RenderView.h"
+#include "RuntimeEnabledFeatures.h"
 #include "ScrollingCoordinator.h"
 #include "Settings.h"
 #include "StyleResolver.h"
@@ -948,8 +950,17 @@
 
     const RenderStyle& style = renderer().style();
 
-    bool isRunningAcceleratedTransformAnimation = renderer().animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyTransform, AnimationBase::Running | AnimationBase::Paused);
-    bool isRunningAcceleratedOpacityAnimation = renderer().animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyOpacity, AnimationBase::Running | AnimationBase::Paused);
+    bool isRunningAcceleratedTransformAnimation = false;
+    bool isRunningAcceleratedOpacityAnimation = false;
+    if (RuntimeEnabledFeatures::sharedFeatures().cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled()) {
+        if (auto* timeline = renderer().documentTimeline()) {
+            isRunningAcceleratedTransformAnimation = timeline->isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyTransform);
+            isRunningAcceleratedOpacityAnimation = timeline->isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyOpacity);
+        }
+    } else {
+        isRunningAcceleratedTransformAnimation = renderer().animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyTransform, AnimationBase::Running | AnimationBase::Paused);
+        isRunningAcceleratedOpacityAnimation = renderer().animation().isRunningAcceleratedAnimationOnRenderer(renderer(), CSSPropertyOpacity, AnimationBase::Running | AnimationBase::Paused);
+    }
 
     // Set transform property, if it is not animating. We have to do this here because the transform
     // is affected by the layer dimensions.

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (230577 => 230578)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2018-04-12 16:34:42 UTC (rev 230578)
@@ -2719,6 +2719,13 @@
     if (!(m_compositingTriggers & ChromeClient::AnimationTrigger))
         return false;
 
+    if (RuntimeEnabledFeatures::sharedFeatures().cssAnimationsAndCSSTransitionsBackedByWebAnimationsEnabled()) {
+        if (auto* element = renderer.element()) {
+            if (auto* timeline = element->document().existingTimeline())
+                return timeline->isRunningAnimationOnRenderer(renderer, CSSPropertyTransform);
+        }
+        return false;
+    }
     return renderer.animation().isRunningAnimationOnRenderer(renderer, CSSPropertyTransform, AnimationBase::Running | AnimationBase::Paused);
 }
 

Modified: trunk/Source/WebCore/rendering/RenderObject.h (230577 => 230578)


--- trunk/Source/WebCore/rendering/RenderObject.h	2018-04-12 16:11:22 UTC (rev 230577)
+++ trunk/Source/WebCore/rendering/RenderObject.h	2018-04-12 16:34:42 UTC (rev 230578)
@@ -46,6 +46,7 @@
 class Color;
 class Cursor;
 class Document;
+class DocumentTimeline;
 class HitTestLocation;
 class HitTestRequest;
 class HitTestResult;
@@ -754,6 +755,7 @@
     virtual void imageChanged(WrappedImagePtr, const IntRect* = nullptr) { }
 
     CSSAnimationController& animation() const;
+    DocumentTimeline* documentTimeline() const;
 
     // Map points and quads through elements, potentially via 3d transforms. You should never need to call these directly; use
     // localToAbsolute/absoluteToLocal methods instead.
@@ -1004,6 +1006,11 @@
     return frame().animation();
 }
 
+inline DocumentTimeline* RenderObject::documentTimeline() const
+{
+    return document().existingTimeline();
+}
+
 inline bool RenderObject::renderTreeBeingDestroyed() const
 {
     return document().renderTreeBeingDestroyed();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to