Move animation and transition functions from RenderBoxModelObject to RenderElement
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Mar 2019 21:25:37 +0000 (21:25 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Mar 2019 21:25:37 +0000 (21:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195903

Reviewed by Simon Fraser.

Transitions and animations do not require RenderBoxModelObject. Move these functions to RenderElement and override them at RenderLayerModelObject to support
composition related callbacks.

* page/animation/AnimationBase.cpp:
(WebCore::AnimationBase::compositedRenderer const):
* page/animation/AnimationBase.h:
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::startTransition): Deleted.
(WebCore::RenderBoxModelObject::transitionPaused): Deleted.
(WebCore::RenderBoxModelObject::transitionFinished): Deleted.
(WebCore::RenderBoxModelObject::startAnimation): Deleted.
(WebCore::RenderBoxModelObject::animationPaused): Deleted.
(WebCore::RenderBoxModelObject::animationSeeked): Deleted.
(WebCore::RenderBoxModelObject::animationFinished): Deleted.
(WebCore::RenderBoxModelObject::suspendAnimations): Deleted.
* rendering/RenderBoxModelObject.h:
* rendering/RenderElement.cpp:
(WebCore::RenderElement::startTransition):
(WebCore::RenderElement::transitionPaused):
(WebCore::RenderElement::transitionFinished):
(WebCore::RenderElement::startAnimation):
(WebCore::RenderElement::animationPaused):
(WebCore::RenderElement::animationSeeked):
(WebCore::RenderElement::animationFinished):
(WebCore::RenderElement::suspendAnimations):
* rendering/RenderElement.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243103 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/animation/AnimationBase.cpp
Source/WebCore/page/animation/AnimationBase.h
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderBoxModelObject.h
Source/WebCore/rendering/RenderElement.h
Source/WebCore/rendering/RenderLayerModelObject.cpp
Source/WebCore/rendering/RenderLayerModelObject.h

index 48a7a1e..c34f3c8 100644 (file)
@@ -1,3 +1,37 @@
+2019-03-18  Zalan Bujtas  <zalan@apple.com>
+
+        Move animation and transition functions from RenderBoxModelObject to RenderElement
+        https://bugs.webkit.org/show_bug.cgi?id=195903
+
+        Reviewed by Simon Fraser.
+
+        Transitions and animations do not require RenderBoxModelObject. Move these functions to RenderElement and override them at RenderLayerModelObject to support
+        composition related callbacks.
+
+        * page/animation/AnimationBase.cpp:
+        (WebCore::AnimationBase::compositedRenderer const):
+        * page/animation/AnimationBase.h:
+        * rendering/RenderBoxModelObject.cpp:
+        (WebCore::RenderBoxModelObject::startTransition): Deleted.
+        (WebCore::RenderBoxModelObject::transitionPaused): Deleted.
+        (WebCore::RenderBoxModelObject::transitionFinished): Deleted.
+        (WebCore::RenderBoxModelObject::startAnimation): Deleted.
+        (WebCore::RenderBoxModelObject::animationPaused): Deleted.
+        (WebCore::RenderBoxModelObject::animationSeeked): Deleted.
+        (WebCore::RenderBoxModelObject::animationFinished): Deleted.
+        (WebCore::RenderBoxModelObject::suspendAnimations): Deleted.
+        * rendering/RenderBoxModelObject.h:
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::startTransition):
+        (WebCore::RenderElement::transitionPaused):
+        (WebCore::RenderElement::transitionFinished):
+        (WebCore::RenderElement::startAnimation):
+        (WebCore::RenderElement::animationPaused):
+        (WebCore::RenderElement::animationSeeked):
+        (WebCore::RenderElement::animationFinished):
+        (WebCore::RenderElement::suspendAnimations):
+        * rendering/RenderElement.h:
+
 2019-03-18  Antti Koivisto  <antti@apple.com>
 
         Try to fix Windows build.
index 8a3b3b9..5e7173d 100644 (file)
@@ -69,12 +69,12 @@ RenderElement* AnimationBase::renderer() const
     return m_element ? m_element->renderer() : nullptr;
 }
 
-RenderBoxModelObject* AnimationBase::compositedRenderer() const
+RenderLayerModelObject* AnimationBase::compositedRenderer() const
 {
     auto* renderer = this->renderer();
     if (!renderer || !renderer->isComposited())
         return nullptr;
-    return downcast<RenderBoxModelObject>(renderer);
+    return downcast<RenderLayerModelObject>(renderer);
 }
 
 void AnimationBase::clear()
index df5eeb1..cd31743 100644 (file)
@@ -39,7 +39,7 @@ class CompositeAnimation;
 class Element;
 class FloatRect;
 class LayoutRect;
-class RenderBoxModelObject;
+class RenderLayerModelObject;
 class RenderElement;
 class RenderStyle;
 class TimingFunction;
@@ -62,7 +62,7 @@ public:
     Element* element() const { return m_element.get(); }
     const RenderStyle& currentStyle() const override;
     RenderElement* renderer() const override;
-    RenderBoxModelObject* compositedRenderer() const;
+    RenderLayerModelObject* compositedRenderer() const;
     void clear();
 
     double duration() const;
index 2437476..a8429bb 100644 (file)
@@ -161,62 +161,6 @@ bool RenderBoxModelObject::hasAcceleratedCompositing() const
     return view().compositor().hasAcceleratedCompositing();
 }
 
-bool RenderBoxModelObject::startTransition(double timeOffset, CSSPropertyID propertyId, const RenderStyle* fromStyle, const RenderStyle* toStyle)
-{
-    ASSERT(hasLayer());
-    ASSERT(isComposited());
-    return layer()->backing()->startTransition(timeOffset, propertyId, fromStyle, toStyle);
-}
-
-void RenderBoxModelObject::transitionPaused(double timeOffset, CSSPropertyID propertyId)
-{
-    ASSERT(hasLayer());
-    ASSERT(isComposited());
-    layer()->backing()->transitionPaused(timeOffset, propertyId);
-}
-
-void RenderBoxModelObject::transitionFinished(CSSPropertyID propertyId)
-{
-    ASSERT(hasLayer());
-    ASSERT(isComposited());
-    layer()->backing()->transitionFinished(propertyId);
-}
-
-bool RenderBoxModelObject::startAnimation(double timeOffset, const Animation* animation, const KeyframeList& keyframes)
-{
-    ASSERT(hasLayer());
-    ASSERT(isComposited());
-    return layer()->backing()->startAnimation(timeOffset, animation, keyframes);
-}
-
-void RenderBoxModelObject::animationPaused(double timeOffset, const String& name)
-{
-    ASSERT(hasLayer());
-    ASSERT(isComposited());
-    layer()->backing()->animationPaused(timeOffset, name);
-}
-
-void RenderBoxModelObject::animationSeeked(double timeOffset, const String& name)
-{
-    ASSERT(hasLayer());
-    ASSERT(isComposited());
-    layer()->backing()->animationSeeked(timeOffset, name);
-}
-
-void RenderBoxModelObject::animationFinished(const String& name)
-{
-    ASSERT(hasLayer());
-    ASSERT(isComposited());
-    layer()->backing()->animationFinished(name);
-}
-
-void RenderBoxModelObject::suspendAnimations(MonotonicTime time)
-{
-    ASSERT(hasLayer());
-    ASSERT(isComposited());
-    layer()->backing()->suspendAnimations(time);
-}
-
 RenderBoxModelObject::RenderBoxModelObject(Element& element, RenderStyle&& style, BaseTypeFlags baseTypeFlags)
     : RenderLayerModelObject(element, WTFMove(style), baseTypeFlags | RenderBoxModelObjectFlag)
 {
index 86f4b80..1d3b7ad 100644 (file)
@@ -60,7 +60,6 @@ enum ContentChangeType {
 class BorderEdge;
 class ImageBuffer;
 class InlineFlowBox;
-class KeyframeList;
 class RenderTextFragment;
 class StickyPositionViewportConstraints;
 
@@ -223,17 +222,6 @@ public:
     void contentChanged(ContentChangeType);
     bool hasAcceleratedCompositing() const;
 
-    bool startTransition(double, CSSPropertyID, const RenderStyle* fromStyle, const RenderStyle* toStyle);
-    void transitionPaused(double timeOffset, CSSPropertyID);
-    void transitionFinished(CSSPropertyID);
-
-    bool startAnimation(double timeOffset, const Animation*, const KeyframeList& keyframes);
-    void animationPaused(double timeOffset, const String& name);
-    void animationSeeked(double timeOffset, const String& name);
-    void animationFinished(const String& name);
-
-    void suspendAnimations(MonotonicTime = MonotonicTime());
-
     RenderBoxModelObject* continuation() const;
     WEBCORE_EXPORT RenderInline* inlineContinuation() const;
     
index d46dd33..dae56d3 100644 (file)
@@ -28,6 +28,7 @@
 namespace WebCore {
 
 class ControlStates;
+class KeyframeList;
 class RenderBlock;
 class RenderTreeBuilder;
 
@@ -221,6 +222,17 @@ public:
     RenderObject* attachRendererInternal(RenderPtr<RenderObject> child, RenderObject* beforeChild);
     RenderPtr<RenderObject> detachRendererInternal(RenderObject&);
 
+    virtual bool startTransition(double /* timeOffset */, CSSPropertyID, const RenderStyle* /* fromStyle */, const RenderStyle* /* toStyle */) { return false; }
+    virtual void transitionPaused(double /* timeOffset */, CSSPropertyID) { }
+    virtual void transitionFinished(CSSPropertyID) { }
+
+    virtual bool startAnimation(double /* timeOffset */, const Animation*, const KeyframeList&) { return false; }
+    virtual void animationPaused(double /* timeOffset */, const String& /* name */) { }
+    virtual void animationSeeked(double /* timeOffset */, const String& /* name */) { }
+    virtual void animationFinished(const String& /* name */) { }
+
+    virtual void suspendAnimations(MonotonicTime = MonotonicTime()) { }
+
 protected:
     enum BaseTypeFlag {
         RenderLayerModelObjectFlag  = 1 << 0,
index 0ce0bb4..fe2ed9a 100644 (file)
@@ -283,5 +283,61 @@ void RenderLayerModelObject::computeRepaintLayoutRects(const RenderLayerModelObj
         setRepaintLayoutRects(RepaintLayoutRects(*this, repaintContainer, geometryMap));
 }
 
+bool RenderLayerModelObject::startTransition(double timeOffset, CSSPropertyID propertyId, const RenderStyle* fromStyle, const RenderStyle* toStyle)
+{
+    ASSERT(hasLayer());
+    ASSERT(isComposited());
+    return layer()->backing()->startTransition(timeOffset, propertyId, fromStyle, toStyle);
+}
+
+void RenderLayerModelObject::transitionPaused(double timeOffset, CSSPropertyID propertyId)
+{
+    ASSERT(hasLayer());
+    ASSERT(isComposited());
+    layer()->backing()->transitionPaused(timeOffset, propertyId);
+}
+
+void RenderLayerModelObject::transitionFinished(CSSPropertyID propertyId)
+{
+    ASSERT(hasLayer());
+    ASSERT(isComposited());
+    layer()->backing()->transitionFinished(propertyId);
+}
+
+bool RenderLayerModelObject::startAnimation(double timeOffset, const Animation* animation, const KeyframeList& keyframes)
+{
+    ASSERT(hasLayer());
+    ASSERT(isComposited());
+    return layer()->backing()->startAnimation(timeOffset, animation, keyframes);
+}
+
+void RenderLayerModelObject::animationPaused(double timeOffset, const String& name)
+{
+    ASSERT(hasLayer());
+    ASSERT(isComposited());
+    layer()->backing()->animationPaused(timeOffset, name);
+}
+
+void RenderLayerModelObject::animationSeeked(double timeOffset, const String& name)
+{
+    ASSERT(hasLayer());
+    ASSERT(isComposited());
+    layer()->backing()->animationSeeked(timeOffset, name);
+}
+
+void RenderLayerModelObject::animationFinished(const String& name)
+{
+    ASSERT(hasLayer());
+    ASSERT(isComposited());
+    layer()->backing()->animationFinished(name);
+}
+
+void RenderLayerModelObject::suspendAnimations(MonotonicTime time)
+{
+    ASSERT(hasLayer());
+    ASSERT(isComposited());
+    layer()->backing()->suspendAnimations(time);
+}
+
 } // namespace WebCore
 
index e605a48..a6b2a66 100644 (file)
@@ -26,6 +26,7 @@
 
 namespace WebCore {
 
+class KeyframeList;
 class RenderLayer;
 
 struct RepaintLayoutRects {
@@ -68,6 +69,17 @@ public:
     void setRepaintLayoutRects(const RepaintLayoutRects&);
     void clearRepaintLayoutRects();
 
+    bool startTransition(double timeOffset, CSSPropertyID, const RenderStyle* fromStyle, const RenderStyle* toStyle) override;
+    void transitionPaused(double timeOffset, CSSPropertyID) override;
+    void transitionFinished(CSSPropertyID) override;
+
+    bool startAnimation(double timeOffset, const Animation*, const KeyframeList& keyframes) override;
+    void animationPaused(double timeOffset, const String& name) override;
+    void animationSeeked(double timeOffset, const String& name) override;
+    void animationFinished(const String& name) override;
+
+    void suspendAnimations(MonotonicTime = MonotonicTime()) override;
+
 protected:
     RenderLayerModelObject(Element&, RenderStyle&&, BaseTypeFlags);
     RenderLayerModelObject(Document&, RenderStyle&&, BaseTypeFlags);