Make more of the CSS animation system internals element based
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Sep 2017 18:20:12 +0000 (18:20 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Sep 2017 18:20:12 +0000 (18:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=176832

Reviewed by Zalan Bujtas.

CSS animations animate element style. Continue moving away from renderers in the animation code.

Also do some general modernization.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::computeRenderStyleForProperty):
* page/animation/AnimationBase.cpp:
(WebCore::AnimationBase::AnimationBase):
* page/animation/AnimationBase.h:
* page/animation/CSSAnimationController.cpp:
(WebCore::CSSAnimationControllerPrivate::ensureCompositeAnimation):
(WebCore::CSSAnimationControllerPrivate::clear):
(WebCore::CSSAnimationControllerPrivate::updateAnimations):
(WebCore::CSSAnimationControllerPrivate::updateAnimationTimerForElement):
(WebCore::CSSAnimationControllerPrivate::isRunningAnimationOnRenderer const):
(WebCore::CSSAnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer const):
(WebCore::CSSAnimationControllerPrivate::pauseAnimationAtTime):
(WebCore::CSSAnimationControllerPrivate::pauseTransitionAtTime):
(WebCore::CSSAnimationControllerPrivate::animatedStyleForElement):
(WebCore::CSSAnimationControllerPrivate::computeExtentOfAnimation const):
(WebCore::CSSAnimationController::cancelAnimations):
(WebCore::CSSAnimationController::updateAnimations):
(WebCore::CSSAnimationController::animatedStyleForRenderer):
(WebCore::CSSAnimationController::computeExtentOfAnimation const):
(WebCore::CSSAnimationController::pauseAnimationAtTime):
(WebCore::CSSAnimationController::pauseTransitionAtTime):
(WebCore::CSSAnimationControllerPrivate::updateAnimationTimerForRenderer): Deleted.
(WebCore::CSSAnimationControllerPrivate::getAnimatedStyleForRenderer): Deleted.
(WebCore::CSSAnimationController::getAnimatedStyleForRenderer): Deleted.
* page/animation/CSSAnimationController.h:
* page/animation/CSSAnimationControllerPrivate.h:
* page/animation/CompositeAnimation.cpp:
(WebCore::CompositeAnimation::~CompositeAnimation):
(WebCore::CompositeAnimation::clearElement):
(WebCore::CompositeAnimation::updateTransitions):
(WebCore::CompositeAnimation::updateKeyframeAnimations):
(WebCore::CompositeAnimation::animate):
(WebCore::CompositeAnimation::clearRenderer): Deleted.
* page/animation/CompositeAnimation.h:
* page/animation/ImplicitAnimation.cpp:
(WebCore::ImplicitAnimation::ImplicitAnimation):
(WebCore::ImplicitAnimation::animate):
* page/animation/ImplicitAnimation.h:
(WebCore::ImplicitAnimation::create):
* page/animation/KeyframeAnimation.cpp:
(WebCore::KeyframeAnimation::KeyframeAnimation):
(WebCore::KeyframeAnimation::animate):
* page/animation/KeyframeAnimation.h:
* rendering/RenderElement.cpp:
(WebCore::RenderElement::willBeDestroyed):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::currentTransform const):
* style/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::createRenderer):
* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::createAnimatedElementUpdate):
* testing/Internals.cpp:
(WebCore::Internals::pauseAnimationAtTimeOnElement):
(WebCore::Internals::pauseAnimationAtTimeOnPseudoElement):
(WebCore::Internals::pauseTransitionAtTimeOnElement):
(WebCore::Internals::pauseTransitionAtTimeOnPseudoElement):

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

19 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/page/animation/AnimationBase.cpp
Source/WebCore/page/animation/AnimationBase.h
Source/WebCore/page/animation/CSSAnimationController.cpp
Source/WebCore/page/animation/CSSAnimationController.h
Source/WebCore/page/animation/CSSAnimationControllerPrivate.h
Source/WebCore/page/animation/CompositeAnimation.cpp
Source/WebCore/page/animation/CompositeAnimation.h
Source/WebCore/page/animation/ImplicitAnimation.cpp
Source/WebCore/page/animation/ImplicitAnimation.h
Source/WebCore/page/animation/KeyframeAnimation.cpp
Source/WebCore/page/animation/KeyframeAnimation.h
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/style/RenderTreeUpdater.cpp
Source/WebCore/style/StyleTreeResolver.cpp
Source/WebCore/testing/Internals.cpp
Source/WebKitLegacy/win/WebFrame.cpp

index 9e293b4..36d2d26 100644 (file)
@@ -1,3 +1,72 @@
+2017-09-13  Antti Koivisto  <antti@apple.com>
+
+        Make more of the CSS animation system internals element based
+        https://bugs.webkit.org/show_bug.cgi?id=176832
+
+        Reviewed by Zalan Bujtas.
+
+        CSS animations animate element style. Continue moving away from renderers in the animation code.
+
+        Also do some general modernization.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::computeRenderStyleForProperty):
+        * page/animation/AnimationBase.cpp:
+        (WebCore::AnimationBase::AnimationBase):
+        * page/animation/AnimationBase.h:
+        * page/animation/CSSAnimationController.cpp:
+        (WebCore::CSSAnimationControllerPrivate::ensureCompositeAnimation):
+        (WebCore::CSSAnimationControllerPrivate::clear):
+        (WebCore::CSSAnimationControllerPrivate::updateAnimations):
+        (WebCore::CSSAnimationControllerPrivate::updateAnimationTimerForElement):
+        (WebCore::CSSAnimationControllerPrivate::isRunningAnimationOnRenderer const):
+        (WebCore::CSSAnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer const):
+        (WebCore::CSSAnimationControllerPrivate::pauseAnimationAtTime):
+        (WebCore::CSSAnimationControllerPrivate::pauseTransitionAtTime):
+        (WebCore::CSSAnimationControllerPrivate::animatedStyleForElement):
+        (WebCore::CSSAnimationControllerPrivate::computeExtentOfAnimation const):
+        (WebCore::CSSAnimationController::cancelAnimations):
+        (WebCore::CSSAnimationController::updateAnimations):
+        (WebCore::CSSAnimationController::animatedStyleForRenderer):
+        (WebCore::CSSAnimationController::computeExtentOfAnimation const):
+        (WebCore::CSSAnimationController::pauseAnimationAtTime):
+        (WebCore::CSSAnimationController::pauseTransitionAtTime):
+        (WebCore::CSSAnimationControllerPrivate::updateAnimationTimerForRenderer): Deleted.
+        (WebCore::CSSAnimationControllerPrivate::getAnimatedStyleForRenderer): Deleted.
+        (WebCore::CSSAnimationController::getAnimatedStyleForRenderer): Deleted.
+        * page/animation/CSSAnimationController.h:
+        * page/animation/CSSAnimationControllerPrivate.h:
+        * page/animation/CompositeAnimation.cpp:
+        (WebCore::CompositeAnimation::~CompositeAnimation):
+        (WebCore::CompositeAnimation::clearElement):
+        (WebCore::CompositeAnimation::updateTransitions):
+        (WebCore::CompositeAnimation::updateKeyframeAnimations):
+        (WebCore::CompositeAnimation::animate):
+        (WebCore::CompositeAnimation::clearRenderer): Deleted.
+        * page/animation/CompositeAnimation.h:
+        * page/animation/ImplicitAnimation.cpp:
+        (WebCore::ImplicitAnimation::ImplicitAnimation):
+        (WebCore::ImplicitAnimation::animate):
+        * page/animation/ImplicitAnimation.h:
+        (WebCore::ImplicitAnimation::create):
+        * page/animation/KeyframeAnimation.cpp:
+        (WebCore::KeyframeAnimation::KeyframeAnimation):
+        (WebCore::KeyframeAnimation::animate):
+        * page/animation/KeyframeAnimation.h:
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::willBeDestroyed):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::currentTransform const):
+        * style/RenderTreeUpdater.cpp:
+        (WebCore::RenderTreeUpdater::createRenderer):
+        * style/StyleTreeResolver.cpp:
+        (WebCore::Style::TreeResolver::createAnimatedElementUpdate):
+        * testing/Internals.cpp:
+        (WebCore::Internals::pauseAnimationAtTimeOnElement):
+        (WebCore::Internals::pauseAnimationAtTimeOnPseudoElement):
+        (WebCore::Internals::pauseTransitionAtTimeOnElement):
+        (WebCore::Internals::pauseTransitionAtTimeOnPseudoElement):
+
 2017-09-13  Daniel Bates  <dabates@apple.com>
 
         Make history.pushState()/replaceState() more closely aligned to the HTML standard
index 01f2428..2c22806 100644 (file)
@@ -2477,7 +2477,7 @@ static inline const RenderStyle* computeRenderStyleForProperty(Element& element,
     auto* renderer = element.renderer();
 
     if (renderer && renderer->isComposited() && CSSAnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
-        ownedStyle = renderer->animation().getAnimatedStyleForRenderer(*renderer);
+        ownedStyle = renderer->animation().animatedStyleForRenderer(*renderer);
         if (pseudoElementSpecifier && !element.isPseudoElement()) {
             // FIXME: This cached pseudo style will only exist if the animation has been run at least once.
             return ownedStyle->getCachedPseudoStyle(pseudoElementSpecifier);
index fc463c2..10eba0c 100644 (file)
@@ -76,12 +76,11 @@ static inline double solveSpringFunction(double mass, double stiffness, double d
     return solver.solve(t * duration);
 }
 
-AnimationBase::AnimationBase(const Animation& animation, RenderElement* renderer, CompositeAnimation* compositeAnimation)
-    : m_element(renderer->element())
-    , m_compositeAnimation(compositeAnimation)
+AnimationBase::AnimationBase(const Animation& animation, Element& element, CompositeAnimation& compositeAnimation)
+    : m_element(&element)
+    , m_compositeAnimation(&compositeAnimation)
     , m_animation(const_cast<Animation&>(animation))
 {
-    ASSERT(m_element);
     // Compute the total duration
     if (m_animation->iterationCount() > 0)
         m_totalDuration = m_animation->duration() * m_animation->iterationCount();
index 6c5c7f0..373922d 100644 (file)
@@ -48,7 +48,7 @@ class AnimationBase : public RefCounted<AnimationBase> {
     friend class CSSPropertyAnimation;
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    AnimationBase(const Animation& transition, RenderElement*, CompositeAnimation*);
+    AnimationBase(const Animation& transition, Element&, CompositeAnimation&);
     virtual ~AnimationBase() { }
 
     RenderElement* renderer() const;
@@ -134,8 +134,6 @@ public:
 
     double progress(double scale = 1, double offset = 0, const TimingFunction* = nullptr) const;
 
-    // Returns true if the animation state changed.
-    virtual bool animate(CompositeAnimation&, RenderElement*, const RenderStyle* /*currentStyle*/, const RenderStyle& /*targetStyle*/, std::unique_ptr<RenderStyle>& /*animatedStyle*/, bool& didBlendStyle) = 0;
     virtual void getAnimatedStyle(std::unique_ptr<RenderStyle>& /*animatedStyle*/) = 0;
 
     virtual bool computeExtentOfTransformAnimation(LayoutRect&) const = 0;
index 72a4d04..eb67fd6 100644 (file)
@@ -83,34 +83,32 @@ CSSAnimationControllerPrivate::~CSSAnimationControllerPrivate()
 {
 }
 
-CompositeAnimation& CSSAnimationControllerPrivate::ensureCompositeAnimation(RenderElement& renderer)
+CompositeAnimation& CSSAnimationControllerPrivate::ensureCompositeAnimation(Element& element)
 {
-    auto result = m_compositeAnimations.ensure(&renderer, [&] {
+    auto result = m_compositeAnimations.ensure(&element, [&] {
         return CompositeAnimation::create(*this);
     });
 
-    if (animationsAreSuspendedForDocument(&renderer.document()))
+    if (animationsAreSuspendedForDocument(&element.document()))
         result.iterator->value->suspendAnimations();
 
     return *result.iterator->value;
 }
 
-bool CSSAnimationControllerPrivate::clear(RenderElement& renderer)
+bool CSSAnimationControllerPrivate::clear(Element& element)
 {
-    auto it = m_compositeAnimations.find(&renderer);
+    auto it = m_compositeAnimations.find(&element);
     if (it == m_compositeAnimations.end())
         return false;
 
-    LOG(Animations, "CSSAnimationControllerPrivate %p clear: %p", this, &renderer);
+    LOG(Animations, "CSSAnimationControllerPrivate %p clear: %p", this, &element);
 
-    Element* element = renderer.element();
-
-    m_eventsToDispatch.removeAllMatching([element] (const EventToDispatch& info) {
-        return info.element.ptr() == element;
+    m_eventsToDispatch.removeAllMatching([&] (const EventToDispatch& info) {
+        return info.element.ptr() == &element;
     });
 
-    m_elementChangesToDispatch.removeAllMatching([element](auto& currentElement) {
-        return currentElement.ptr() == element;
+    m_elementChangesToDispatch.removeAllMatching([&](auto& currentElement) {
+        return currentElement.ptr() == &element;
     });
     
     // Return false if we didn't do anything OR we are suspended (so we don't try to
@@ -118,7 +116,7 @@ bool CSSAnimationControllerPrivate::clear(RenderElement& renderer)
     // FIXME: The code below does the opposite of what the comment above says regarding suspended state.
     auto& animation = *it->value;
     bool result = animation.isSuspended();
-    animation.clearRenderer();
+    animation.clearElement();
 
     m_compositeAnimations.remove(it);
 
@@ -140,10 +138,9 @@ std::optional<Seconds> CSSAnimationControllerPrivate::updateAnimations(SetChange
             if (timeToNextService && timeToNextService.value() == 0_s) {
                 if (callSetChanged != CallSetChanged)
                     break;
-                Element* element = compositeAnimation.key->element();
-                ASSERT(element);
-                ASSERT(element->document().pageCacheState() == Document::NotInPageCache);
-                element->invalidateStyleAndLayerComposition();
+                Element& element = *compositeAnimation.key;
+                ASSERT(element.document().pageCacheState() == Document::NotInPageCache);
+                element.invalidateStyleAndLayerComposition();
                 calledSetChanged = true;
             }
         }
@@ -155,11 +152,11 @@ std::optional<Seconds> CSSAnimationControllerPrivate::updateAnimations(SetChange
     return timeToNextService;
 }
 
-void CSSAnimationControllerPrivate::updateAnimationTimerForRenderer(RenderElement& renderer)
+void CSSAnimationControllerPrivate::updateAnimationTimerForElement(Element& element)
 {
     std::optional<Seconds> timeToNextService;
 
-    const CompositeAnimation* compositeAnimation = m_compositeAnimations.get(&renderer);
+    const CompositeAnimation* compositeAnimation = m_compositeAnimations.get(&element);
     if (!compositeAnimation->isSuspended() && compositeAnimation->hasAnimations())
         timeToNextService = compositeAnimation->timeToNextService();
 
@@ -289,7 +286,9 @@ void CSSAnimationControllerPrivate::animationTimerFired()
 
 bool CSSAnimationControllerPrivate::isRunningAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const
 {
-    auto* animation = m_compositeAnimations.get(&renderer);
+    if (!renderer.element())
+        return false;
+    auto* animation = m_compositeAnimations.get(renderer.element());
     if (!animation)
         return false;
     return animation->isAnimatingProperty(property, false, runningState);
@@ -297,7 +296,9 @@ bool CSSAnimationControllerPrivate::isRunningAnimationOnRenderer(RenderElement&
 
 bool CSSAnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const
 {
-    auto* animation = m_compositeAnimations.get(&renderer);
+    if (!renderer.element())
+        return false;
+    auto* animation = m_compositeAnimations.get(renderer.element());
     if (!animation)
         return false;
     return animation->isAnimatingProperty(property, true, runningState);
@@ -402,14 +403,11 @@ void CSSAnimationControllerPrivate::setAllowsNewAnimationsWhileSuspended(bool al
     m_allowsNewAnimationsWhileSuspended = allowed;
 }
 
-bool CSSAnimationControllerPrivate::pauseAnimationAtTime(RenderElement* renderer, const AtomicString& name, double t)
+bool CSSAnimationControllerPrivate::pauseAnimationAtTime(Element& element, const AtomicString& name, double t)
 {
-    if (!renderer)
-        return false;
-
-    CompositeAnimation& compositeAnimation = ensureCompositeAnimation(*renderer);
+    CompositeAnimation& compositeAnimation = ensureCompositeAnimation(element);
     if (compositeAnimation.pauseAnimationAtTime(name, t)) {
-        renderer->element()->invalidateStyleAndLayerComposition();
+        element.invalidateStyleAndLayerComposition();
         startUpdateStyleIfNeededDispatcher();
         return true;
     }
@@ -417,14 +415,11 @@ bool CSSAnimationControllerPrivate::pauseAnimationAtTime(RenderElement* renderer
     return false;
 }
 
-bool CSSAnimationControllerPrivate::pauseTransitionAtTime(RenderElement* renderer, const String& property, double t)
+bool CSSAnimationControllerPrivate::pauseTransitionAtTime(Element& element, const String& property, double t)
 {
-    if (!renderer)
-        return false;
-
-    CompositeAnimation& compositeAnimation = ensureCompositeAnimation(*renderer);
+    CompositeAnimation& compositeAnimation = ensureCompositeAnimation(element);
     if (compositeAnimation.pauseTransitionAtTime(cssPropertyID(property), t)) {
-        renderer->element()->invalidateStyleAndLayerComposition();
+        element.invalidateStyleAndLayerComposition();
         startUpdateStyleIfNeededDispatcher();
         return true;
     }
@@ -467,24 +462,24 @@ void CSSAnimationControllerPrivate::receivedStartTimeResponse(double time)
     startTimeResponse(time);
 }
 
-std::unique_ptr<RenderStyle> CSSAnimationControllerPrivate::getAnimatedStyleForRenderer(RenderElement& renderer)
+std::unique_ptr<RenderStyle> CSSAnimationControllerPrivate::animatedStyleForElement(Element& element)
 {
-    auto* animation = m_compositeAnimations.get(&renderer);
+    auto* animation = m_compositeAnimations.get(&element);
     if (!animation)
-        return RenderStyle::clonePtr(renderer.style());
+        return nullptr;
 
     AnimationPrivateUpdateBlock animationUpdateBlock(*this);
 
-    std::unique_ptr<RenderStyle> animatingStyle = animation->getAnimatedStyle();
+    auto animatingStyle = animation->getAnimatedStyle();
     if (!animatingStyle)
-        animatingStyle = RenderStyle::clonePtr(renderer.style());
+        return nullptr;
     
     return animatingStyle;
 }
 
-bool CSSAnimationControllerPrivate::computeExtentOfAnimation(RenderElement& renderer, LayoutRect& bounds) const
+bool CSSAnimationControllerPrivate::computeExtentOfAnimation(Element& element, LayoutRect& bounds) const
 {
-    auto* animation = m_compositeAnimations.get(&renderer);
+    auto* animation = m_compositeAnimations.get(&element);
     if (!animation)
         return true;
 
@@ -631,29 +626,29 @@ CSSAnimationController::~CSSAnimationController()
 {
 }
 
-void CSSAnimationController::cancelAnimations(RenderElement& renderer)
+void CSSAnimationController::cancelAnimations(Element& element)
 {
-    if (!m_data->clear(renderer))
+    if (!m_data->clear(element))
         return;
 
-    Element* element = renderer.element();
-    if (!element || element->document().renderTreeBeingDestroyed())
+    if (element.document().renderTreeBeingDestroyed())
         return;
-    ASSERT(element->document().pageCacheState() == Document::NotInPageCache);
-    element->invalidateStyleAndLayerComposition();
+    ASSERT(element.document().pageCacheState() == Document::NotInPageCache);
+    element.invalidateStyleAndLayerComposition();
 }
 
-bool CSSAnimationController::updateAnimations(RenderElement& renderer, const RenderStyle& newStyle, std::unique_ptr<RenderStyle>& animatedStyle)
+bool CSSAnimationController::updateAnimations(Element& element, const RenderStyle& newStyle, std::unique_ptr<RenderStyle>& animatedStyle)
 {
-    auto* oldStyle = renderer.hasInitializedStyle() ? &renderer.style() : nullptr;
+    auto* renderer = element.renderer();
+    auto* oldStyle = (renderer && renderer->hasInitializedStyle()) ? &renderer->style() : nullptr;
     if ((!oldStyle || (!oldStyle->animations() && !oldStyle->transitions())) && (!newStyle.animations() && !newStyle.transitions()))
         return false;
 
-    if (renderer.document().pageCacheState() != Document::NotInPageCache)
+    if (element.document().pageCacheState() != Document::NotInPageCache)
         return false;
 
     // Don't run transitions when printing.
-    if (renderer.view().printing())
+    if (element.document().renderView()->printing())
         return false;
 
     // Fetch our current set of implicit animations from a hashtable. We then compare them
@@ -661,37 +656,41 @@ bool CSSAnimationController::updateAnimations(RenderElement& renderer, const Ren
     // have changed, we reset the animation. We then do a blend to get new values and we return
     // a new style.
 
-    // We don't support anonymous pseudo elements like :first-line or :first-letter.
-    ASSERT(renderer.element());
+    CompositeAnimation& compositeAnimation = m_data->ensureCompositeAnimation(element);
+    bool animationStateChanged = compositeAnimation.animate(element, oldStyle, newStyle, animatedStyle);
 
-    CompositeAnimation& rendererAnimations = m_data->ensureCompositeAnimation(renderer);
-    bool animationStateChanged = rendererAnimations.animate(renderer, oldStyle, newStyle, animatedStyle);
-
-    if (renderer.parent() || newStyle.animations() || (oldStyle && oldStyle->animations())) {
-        auto& frameView = renderer.view().frameView();
-        if (rendererAnimations.hasAnimationThatDependsOnLayout())
+    if ((renderer && renderer->parent()) || newStyle.animations() || (oldStyle && oldStyle->animations())) {
+        auto& frameView = *element.document().view();
+        if (compositeAnimation.hasAnimationThatDependsOnLayout())
             m_data->setRequiresLayout();
-        m_data->updateAnimationTimerForRenderer(renderer);
+        m_data->updateAnimationTimerForElement(element);
         frameView.scheduleAnimation();
     }
 
     return animationStateChanged;
 }
 
-std::unique_ptr<RenderStyle> CSSAnimationController::getAnimatedStyleForRenderer(RenderElement& renderer)
+std::unique_ptr<RenderStyle> CSSAnimationController::animatedStyleForRenderer(RenderElement& renderer)
 {
-    if (!renderer.style().hasAnimationsOrTransitions())
-        return RenderStyle::clonePtr(renderer.style());
+    std::unique_ptr<RenderStyle> result;
+
+    if (renderer.style().hasAnimationsOrTransitions() && renderer.element())
+        result = m_data->animatedStyleForElement(*renderer.element());
 
-    return m_data->getAnimatedStyleForRenderer(renderer);
+    if (!result)
+        result = RenderStyle::clonePtr(renderer.style());
+
+    return result;
 }
 
 bool CSSAnimationController::computeExtentOfAnimation(RenderElement& renderer, LayoutRect& bounds) const
 {
+    if (!renderer.element())
+        return true;
     if (!renderer.style().hasAnimationsOrTransitions())
         return true;
 
-    return m_data->computeExtentOfAnimation(renderer, bounds);
+    return m_data->computeExtentOfAnimation(*renderer.element(), bounds);
 }
 
 void CSSAnimationController::notifyAnimationStarted(RenderElement& renderer, double startTime)
@@ -703,10 +702,10 @@ void CSSAnimationController::notifyAnimationStarted(RenderElement& renderer, dou
     m_data->receivedStartTimeResponse(startTime);
 }
 
-bool CSSAnimationController::pauseAnimationAtTime(RenderElement* renderer, const AtomicString& name, double t)
+bool CSSAnimationController::pauseAnimationAtTime(Element& element, const AtomicString& name, double t)
 {
     AnimationUpdateBlock animationUpdateBlock(this);
-    return m_data->pauseAnimationAtTime(renderer, name, t);
+    return m_data->pauseAnimationAtTime(element, name, t);
 }
 
 unsigned CSSAnimationController::numberOfActiveAnimations(Document* document) const
@@ -714,10 +713,10 @@ unsigned CSSAnimationController::numberOfActiveAnimations(Document* document) co
     return m_data->numberOfActiveAnimations(document);
 }
 
-bool CSSAnimationController::pauseTransitionAtTime(RenderElement* renderer, const String& property, double t)
+bool CSSAnimationController::pauseTransitionAtTime(Element& element, const String& property, double t)
 {
     AnimationUpdateBlock animationUpdateBlock(this);
-    return m_data->pauseTransitionAtTime(renderer, property, t);
+    return m_data->pauseTransitionAtTime(element, property, t);
 }
 
 bool CSSAnimationController::isRunningAnimationOnRenderer(RenderElement& renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const
index 1a179ac..8647a23 100644 (file)
@@ -48,9 +48,9 @@ public:
     explicit CSSAnimationController(Frame&);
     ~CSSAnimationController();
 
-    void cancelAnimations(RenderElement&);
-    bool updateAnimations(RenderElement&, const RenderStyle& newStyle, std::unique_ptr<RenderStyle>& animatedStyle);
-    std::unique_ptr<RenderStyle> getAnimatedStyleForRenderer(RenderElement&);
+    void cancelAnimations(Element&);
+    bool updateAnimations(Element&, const RenderStyle& newStyle, std::unique_ptr<RenderStyle>& animatedStyle);
+    std::unique_ptr<RenderStyle> animatedStyleForRenderer(RenderElement&);
 
     // 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
@@ -60,8 +60,8 @@ public:
     // This is called when an accelerated animation or transition has actually started to animate.
     void notifyAnimationStarted(RenderElement&, double startTime);
 
-    WEBCORE_EXPORT bool pauseAnimationAtTime(RenderElement*, const AtomicString& name, double t); // To be used only for testing
-    WEBCORE_EXPORT bool pauseTransitionAtTime(RenderElement*, const String& property, double t); // To be used only for testing
+    WEBCORE_EXPORT bool pauseAnimationAtTime(Element&, const AtomicString& name, double t); // To be used only for testing
+    WEBCORE_EXPORT bool pauseTransitionAtTime(Element&, const String& property, double t); // To be used only for testing
     WEBCORE_EXPORT unsigned numberOfActiveAnimations(Document*) const; // To be used only for testing
     
     bool isRunningAnimationOnRenderer(RenderElement&, CSSPropertyID, AnimationBase::RunningState) const;
index 15a4f72..d74df04 100644 (file)
@@ -52,8 +52,8 @@ public:
     std::optional<Seconds> updateAnimations(SetChanged callSetChanged = DoNotCallSetChanged);
     void updateAnimationTimer(SetChanged callSetChanged = DoNotCallSetChanged);
 
-    CompositeAnimation& ensureCompositeAnimation(RenderElement&);
-    bool clear(RenderElement&);
+    CompositeAnimation& ensureCompositeAnimation(Element&);
+    bool clear(Element&);
 
     void updateStyleIfNeededDispatcherFired();
     void startUpdateStyleIfNeededDispatcher();
@@ -79,13 +79,13 @@ public:
     bool isRunningAnimationOnRenderer(RenderElement&, CSSPropertyID, AnimationBase::RunningState) const;
     bool isRunningAcceleratedAnimationOnRenderer(RenderElement&, CSSPropertyID, AnimationBase::RunningState) const;
 
-    bool pauseAnimationAtTime(RenderElement*, const AtomicString& name, double t);
-    bool pauseTransitionAtTime(RenderElement*, const String& property, double t);
+    bool pauseAnimationAtTime(Element&, const AtomicString& name, double t);
+    bool pauseTransitionAtTime(Element&, const String& property, double t);
     unsigned numberOfActiveAnimations(Document*) const;
 
-    std::unique_ptr<RenderStyle> getAnimatedStyleForRenderer(RenderElement&);
+    std::unique_ptr<RenderStyle> animatedStyleForElement(Element&);
 
-    bool computeExtentOfAnimation(RenderElement&, LayoutRect&) const;
+    bool computeExtentOfAnimation(Element&, LayoutRect&) const;
 
     double beginAnimationUpdateTime();
     
@@ -101,7 +101,7 @@ public:
 
     void animationWillBeRemoved(AnimationBase*);
 
-    void updateAnimationTimerForRenderer(RenderElement&);
+    void updateAnimationTimerForElement(Element&);
 
     bool allowsNewAnimationsWhileSuspended() const { return m_allowsNewAnimationsWhileSuspended; }
     void setAllowsNewAnimationsWhileSuspended(bool);
@@ -124,7 +124,7 @@ private:
     void fireEventsAndUpdateStyle();
     void startTimeResponse(double t);
 
-    HashMap<RenderElement*, RefPtr<CompositeAnimation>> m_compositeAnimations;
+    HashMap<Element*, RefPtr<CompositeAnimation>> m_compositeAnimations;
     Timer m_animationTimer;
     Timer m_updateStyleIfNeededDispatcher;
     Frame& m_frame;
index d8e1b2d..c195133 100644 (file)
@@ -53,12 +53,12 @@ CompositeAnimation::~CompositeAnimation()
     // Toss the refs to all animations, but make sure we remove them from
     // any waiting lists first.
 
-    clearRenderer();
+    clearElement();
     m_transitions.clear();
     m_keyframeAnimations.clear();
 }
 
-void CompositeAnimation::clearRenderer()
+void CompositeAnimation::clearElement()
 {
     if (!m_transitions.isEmpty()) {
         // Clear the renderers from all running animations, in case we are in the middle of
@@ -77,10 +77,10 @@ void CompositeAnimation::clearRenderer()
     }
 }
 
-void CompositeAnimation::updateTransitions(RenderElement* renderer, const RenderStyle* currentStyle, const RenderStyle* targetStyle)
+void CompositeAnimation::updateTransitions(Element& element, const RenderStyle* currentStyle, const RenderStyle& targetStyle)
 {
     // If currentStyle is null or there are no old or new transitions, just skip it
-    if (!currentStyle || (!targetStyle->transitions() && m_transitions.isEmpty()))
+    if (!currentStyle || (!targetStyle.transitions() && m_transitions.isEmpty()))
         return;
 
     // Mark all existing transitions as no longer active. We will mark the still active ones
@@ -91,9 +91,9 @@ void CompositeAnimation::updateTransitions(RenderElement* renderer, const Render
     std::unique_ptr<RenderStyle> modifiedCurrentStyle;
     
     // Check to see if we need to update the active transitions
-    if (targetStyle->transitions()) {
-        for (size_t i = 0; i < targetStyle->transitions()->size(); ++i) {
-            auto& animation = targetStyle->transitions()->animation(i);
+    if (targetStyle.transitions()) {
+        for (size_t i = 0; i < targetStyle.transitions()->size(); ++i) {
+            auto& animation = targetStyle.transitions()->animation(i);
             bool isActiveTransition = animation.duration() || animation.delay() > 0;
 
             Animation::AnimationMode mode = animation.animationMode();
@@ -143,7 +143,7 @@ void CompositeAnimation::updateTransitions(RenderElement* renderer, const Render
                     // you have both an explicit transition-property and 'all' in the same
                     // list. In this case, the latter one overrides the earlier one, so we
                     // behave as though this is a running animation being replaced.
-                    if (!implAnim->isTargetPropertyEqual(prop, targetStyle)) {
+                    if (!implAnim->isTargetPropertyEqual(prop, &targetStyle)) {
                         // For accelerated animations we need to return a new RenderStyle with the _current_ value
                         // of the property, so that restarted transitions use the correct starting point.
                         if (CSSPropertyAnimation::animationOfPropertyIsAccelerated(prop) && implAnim->isAccelerated()) {
@@ -159,7 +159,7 @@ void CompositeAnimation::updateTransitions(RenderElement* renderer, const Render
                     }
                 } else {
                     // We need to start a transition if it is active and the properties don't match
-                    equal = !isActiveTransition || CSSPropertyAnimation::propertiesEqual(prop, fromStyle, targetStyle);
+                    equal = !isActiveTransition || CSSPropertyAnimation::propertiesEqual(prop, fromStyle, &targetStyle);
                 }
 
                 // We can be in this loop with an inactive transition (!isActiveTransition). We need
@@ -168,11 +168,11 @@ void CompositeAnimation::updateTransitions(RenderElement* renderer, const Render
                 // <https://bugs.webkit.org/show_bug.cgi?id=24787>
                 if (!equal && isActiveTransition) {
                     // Add the new transition
-                    auto implicitAnimation = ImplicitAnimation::create(animation, prop, renderer, this, modifiedCurrentStyle ? modifiedCurrentStyle.get() : fromStyle);
+                    auto implicitAnimation = ImplicitAnimation::create(animation, prop, element, *this, modifiedCurrentStyle ? *modifiedCurrentStyle : *fromStyle);
                     if (m_suspended && implicitAnimation->hasStyle())
                         implicitAnimation->updatePlayState(AnimPlayStatePaused);
 
-                    LOG(Animations, "Created ImplicitAnimation %p on renderer %p for property %s duration %.2f delay %.2f", implicitAnimation.ptr(), renderer, getPropertyName(prop), animation.duration(), animation.delay());
+                    LOG(Animations, "Created ImplicitAnimation %p on element %p for property %s duration %.2f delay %.2f", implicitAnimation.ptr(), &element, getPropertyName(prop), animation.duration(), animation.delay());
                     m_transitions.set(prop, WTFMove(implicitAnimation));
                 }
 
@@ -189,7 +189,7 @@ void CompositeAnimation::updateTransitions(RenderElement* renderer, const Render
         if (!transition->active()) {
             animationController().animationWillBeRemoved(transition.get());
             toBeRemoved.append(transition->animatingProperty());
-            LOG(Animations, "Removing ImplicitAnimation %p from renderer %p for property %s", transition.get(), renderer, getPropertyName(transition->animatingProperty()));
+            LOG(Animations, "Removing ImplicitAnimation %p from element %p for property %s", transition.get(), &element, getPropertyName(transition->animatingProperty()));
         }
     }
 
@@ -198,15 +198,15 @@ void CompositeAnimation::updateTransitions(RenderElement* renderer, const Render
         m_transitions.remove(propertyToRemove);
 }
 
-void CompositeAnimation::updateKeyframeAnimations(RenderElement* renderer, const RenderStyle* currentStyle, const RenderStyle* targetStyle)
+void CompositeAnimation::updateKeyframeAnimations(Element& element, const RenderStyle* currentStyle, const RenderStyle& targetStyle)
 {
     // Nothing to do if we don't have any animations, and didn't have any before
-    if (m_keyframeAnimations.isEmpty() && !targetStyle->hasAnimations())
+    if (m_keyframeAnimations.isEmpty() && !targetStyle.hasAnimations())
         return;
 
     m_keyframeAnimations.checkConsistency();
     
-    if (currentStyle && currentStyle->hasAnimations() && targetStyle->hasAnimations() && *(currentStyle->animations()) == *(targetStyle->animations()))
+    if (currentStyle && currentStyle->hasAnimations() && targetStyle.hasAnimations() && *(currentStyle->animations()) == *(targetStyle.animations()))
         return;
 
 #if ENABLE(CSS_ANIMATIONS_LEVEL_2)
@@ -221,10 +221,10 @@ void CompositeAnimation::updateKeyframeAnimations(RenderElement* renderer, const
     static NeverDestroyed<const AtomicString> none("none", AtomicString::ConstructFromLiteral);
     
     // Now mark any still active animations as active and add any new animations.
-    if (targetStyle->animations()) {
-        int numAnims = targetStyle->animations()->size();
+    if (targetStyle.animations()) {
+        int numAnims = targetStyle.animations()->size();
         for (int i = 0; i < numAnims; ++i) {
-            auto& animation = targetStyle->animations()->animation(i);
+            auto& animation = targetStyle.animations()->animation(i);
             AtomicString animationName(animation.name());
 
             if (!animation.isValidAnimation())
@@ -249,8 +249,8 @@ void CompositeAnimation::updateKeyframeAnimations(RenderElement* renderer, const
                 // Set the saved animation to this new one, just in case the play state has changed.
                 keyframeAnim->setAnimation(animation);
             } else if ((animation.duration() || animation.delay()) && animation.iterationCount() && animationName != none) {
-                keyframeAnim = KeyframeAnimation::create(animation, renderer, this, targetStyle);
-                LOG(Animations, "Creating KeyframeAnimation %p on renderer %p with keyframes %s, duration %.2f, delay %.2f, iterations %.2f", keyframeAnim.get(), renderer, animation.name().utf8().data(), animation.duration(), animation.delay(), animation.iterationCount());
+                keyframeAnim = KeyframeAnimation::create(animation, element, *this, targetStyle);
+                LOG(Animations, "Creating KeyframeAnimation %p on element %p with keyframes %s, duration %.2f, delay %.2f, iterations %.2f", keyframeAnim.get(), &element, animation.name().utf8().data(), animation.duration(), animation.delay(), animation.iterationCount());
 
                 if (m_suspended) {
                     keyframeAnim->updatePlayState(AnimPlayStatePaused);
@@ -280,18 +280,18 @@ void CompositeAnimation::updateKeyframeAnimations(RenderElement* renderer, const
         if (!newAnimations.contains(animation->name().impl())) {
             animationController().animationWillBeRemoved(animation.get());
             animation->clear();
-            LOG(Animations, "Removing KeyframeAnimation %p from renderer %p", animation.get(), renderer);
+            LOG(Animations, "Removing KeyframeAnimation %p from element %p", animation.get(), &element);
         }
     }
     
     std::swap(newAnimations, m_keyframeAnimations);
 }
 
-bool CompositeAnimation::animate(RenderElement& renderer, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& blendedStyle)
+bool CompositeAnimation::animate(Element& element, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& blendedStyle)
 {
     // We don't do any transitions if we don't have a currentStyle (on startup).
-    updateTransitions(&renderer, currentStyle, &targetStyle);
-    updateKeyframeAnimations(&renderer, currentStyle, &targetStyle);
+    updateTransitions(element, currentStyle, targetStyle);
+    updateKeyframeAnimations(element, currentStyle, targetStyle);
     m_keyframeAnimations.checkConsistency();
 
     bool animationStateChanged = false;
@@ -303,7 +303,7 @@ bool CompositeAnimation::animate(RenderElement& renderer, const RenderStyle* cur
         bool checkForStackingContext = false;
         for (auto& transition : m_transitions.values()) {
             bool didBlendStyle = false;
-            if (transition->animate(*this, &renderer, currentStyle, targetStyle, blendedStyle, didBlendStyle))
+            if (transition->animate(*this, targetStyle, blendedStyle, didBlendStyle))
                 animationStateChanged = true;
 
             if (didBlendStyle)
@@ -333,7 +333,7 @@ bool CompositeAnimation::animate(RenderElement& renderer, const RenderStyle* cur
         RefPtr<KeyframeAnimation> keyframeAnim = m_keyframeAnimations.get(name);
         if (keyframeAnim) {
             bool didBlendStyle = false;
-            if (keyframeAnim->animate(*this, &renderer, currentStyle, targetStyle, blendedStyle, didBlendStyle))
+            if (keyframeAnim->animate(*this, targetStyle, blendedStyle, didBlendStyle))
                 animationStateChanged = true;
 
             forceStackingContext |= didBlendStyle && keyframeAnim->triggersStackingContext();
index b84bc8f..b20f00e 100644 (file)
@@ -52,9 +52,9 @@ public:
 
     ~CompositeAnimation();
     
-    void clearRenderer();
+    void clearElement();
 
-    bool animate(RenderElement&, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& blendedStyle);
+    bool animate(Element&, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& blendedStyle);
     std::unique_ptr<RenderStyle> getAnimatedStyle() const;
     bool computeExtentOfTransformAnimation(LayoutRect&) const;
 
@@ -88,8 +88,8 @@ public:
 private:
     CompositeAnimation(CSSAnimationControllerPrivate&);
 
-    void updateTransitions(RenderElement*, const RenderStyle* currentStyle, const RenderStyle* targetStyle);
-    void updateKeyframeAnimations(RenderElement*, const RenderStyle* currentStyle, const RenderStyle* targetStyle);
+    void updateTransitions(Element&, const RenderStyle* currentStyle, const RenderStyle& targetStyle);
+    void updateKeyframeAnimations(Element&, const RenderStyle* currentStyle, const RenderStyle& targetStyle);
     
     typedef HashMap<int, RefPtr<ImplicitAnimation>> CSSPropertyTransitionsMap;
     typedef HashMap<AtomicStringImpl*, RefPtr<KeyframeAnimation>> AnimationNameMap;
index 9f6deeb..bbd68db 100644 (file)
@@ -40,9 +40,9 @@
 
 namespace WebCore {
 
-ImplicitAnimation::ImplicitAnimation(const Animation& transition, CSSPropertyID animatingProperty, RenderElement* renderer, CompositeAnimation* compAnim, const RenderStyle* fromStyle)
-    : AnimationBase(transition, renderer, compAnim)
-    , m_fromStyle(RenderStyle::clonePtr(*fromStyle))
+ImplicitAnimation::ImplicitAnimation(const Animation& transition, CSSPropertyID animatingProperty, Element& element, CompositeAnimation& compositeAnimation, const RenderStyle& fromStyle)
+    : AnimationBase(transition, element, compositeAnimation)
+    , m_fromStyle(RenderStyle::clonePtr(fromStyle))
     , m_transitionProperty(transition.property())
     , m_animatingProperty(animatingProperty)
 {
@@ -61,7 +61,7 @@ bool ImplicitAnimation::shouldSendEventForListener(Document::ListenerType inList
     return m_element->document().hasListenerType(inListenerType);
 }
 
-bool ImplicitAnimation::animate(CompositeAnimation& compositeAnimation, RenderElement*, const RenderStyle*, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle)
+bool ImplicitAnimation::animate(CompositeAnimation& compositeAnimation, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle)
 {
     // If we get this far and the animation is done, it means we are cleaning up a just finished animation.
     // So just return. Everything is already all cleaned up.
index 0f061c5..a419d49 100644 (file)
@@ -40,9 +40,9 @@ class RenderElement;
 // for a single RenderElement.
 class ImplicitAnimation : public AnimationBase {
 public:
-    static Ref<ImplicitAnimation> create(const Animation& animation, CSSPropertyID animatingProperty, RenderElement* renderer, CompositeAnimation* compositeAnimation, const RenderStyle* fromStyle)
+    static Ref<ImplicitAnimation> create(const Animation& animation, CSSPropertyID animatingProperty, Element& element, CompositeAnimation& compositeAnimation, const RenderStyle& fromStyle)
     {
-        return adoptRef(*new ImplicitAnimation(animation, animatingProperty, renderer, compositeAnimation, fromStyle));
+        return adoptRef(*new ImplicitAnimation(animation, animatingProperty, element, compositeAnimation, fromStyle));
     };
     
     CSSPropertyID transitionProperty() const { return m_transitionProperty; }
@@ -53,7 +53,7 @@ public:
     void pauseAnimation(double timeOffset) override;
     void endAnimation() override;
 
-    bool animate(CompositeAnimation&, RenderElement*, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle) override;
+    bool animate(CompositeAnimation&, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle);
     void getAnimatedStyle(std::unique_ptr<RenderStyle>& animatedStyle) override;
     void reset(const RenderStyle& to, CompositeAnimation&);
 
@@ -86,7 +86,7 @@ protected:
 #endif
 
 private:
-    ImplicitAnimation(const Animation&, CSSPropertyID, RenderElement*, CompositeAnimation*, const RenderStyle*);
+    ImplicitAnimation(const Animation&, CSSPropertyID, Element&, CompositeAnimation&, const RenderStyle&);
     virtual ~ImplicitAnimation();
 
     // The two styles that we are blending.
index bef2803..538ca24 100644 (file)
 
 namespace WebCore {
 
-KeyframeAnimation::KeyframeAnimation(const Animation& animation, RenderElement* renderer, CompositeAnimation* compositeAnimation, const RenderStyle* unanimatedStyle)
-    : AnimationBase(animation, renderer, compositeAnimation)
+KeyframeAnimation::KeyframeAnimation(const Animation& animation, Element& element, CompositeAnimation& compositeAnimation, const RenderStyle& unanimatedStyle)
+    : AnimationBase(animation, element, compositeAnimation)
     , m_keyframes(animation.name())
-    , m_unanimatedStyle(RenderStyle::clonePtr(*unanimatedStyle))
+    , m_unanimatedStyle(RenderStyle::clonePtr(unanimatedStyle))
 {
     resolveKeyframeStyles();
 
@@ -154,7 +154,7 @@ void KeyframeAnimation::fetchIntervalEndpointsForProperty(CSSPropertyID property
     prog = progress(scale, offset, prevKeyframe.timingFunction(name()));
 }
 
-bool KeyframeAnimation::animate(CompositeAnimation& compositeAnimation, RenderElement*, const RenderStyle*, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle)
+bool KeyframeAnimation::animate(CompositeAnimation& compositeAnimation, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle)
 {
     // Fire the start timeout if needed
     fireAnimationEventsIfNeeded();
index 06db899..e3e4ee1 100644 (file)
@@ -39,12 +39,12 @@ class RenderStyle;
 // A KeyframeAnimation tracks the state of an explicit animation for a single RenderElement.
 class KeyframeAnimation final : public AnimationBase {
 public:
-    static Ref<KeyframeAnimation> create(const Animation& animation, RenderElement* renderer, CompositeAnimation* compositeAnimation, const RenderStyle* unanimatedStyle)
+    static Ref<KeyframeAnimation> create(const Animation& animation, Element& element, CompositeAnimation& compositeAnimation, const RenderStyle& unanimatedStyle)
     {
-        return adoptRef(*new KeyframeAnimation(animation, renderer, compositeAnimation, unanimatedStyle));
+        return adoptRef(*new KeyframeAnimation(animation, element, compositeAnimation, unanimatedStyle));
     }
 
-    bool animate(CompositeAnimation&, RenderElement*, const RenderStyle* currentStyle, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle) override;
+    bool animate(CompositeAnimation&, const RenderStyle& targetStyle, std::unique_ptr<RenderStyle>& animatedStyle, bool& didBlendStyle);
     void getAnimatedStyle(std::unique_ptr<RenderStyle>&) override;
 
     bool computeExtentOfTransformAnimation(LayoutRect&) const override;
@@ -93,7 +93,7 @@ protected:
 #endif
 
 private:
-    KeyframeAnimation(const Animation&, RenderElement*, CompositeAnimation*, const RenderStyle* unanimatedStyle);
+    KeyframeAnimation(const Animation&, Element&, CompositeAnimation&, const RenderStyle& unanimatedStyle);
     virtual ~KeyframeAnimation();
     
     // Get the styles for the given property surrounding the current animation time and the progress between them.
index 1bec90e..b2a6b07 100644 (file)
@@ -1104,7 +1104,8 @@ void RenderElement::willBeDestroyed()
     if (m_style.hasFixedBackgroundImage() && !settings().fixedBackgroundsPaintRelativeToDocument())
         view().frameView().removeSlowRepaintObject(this);
 
-    animation().cancelAnimations(*this);
+    if (element())
+        animation().cancelAnimations(*element());
 
     destroyLeftoverChildren();
 
index d35ba45..2e47400 100644 (file)
@@ -1005,7 +1005,7 @@ TransformationMatrix RenderLayer::currentTransform(RenderStyle::ApplyTransformOr
     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().getAnimatedStyleForRenderer(renderer());
+        std::unique_ptr<RenderStyle> style = renderer().animation().animatedStyleForRenderer(renderer());
         style->applyTransform(currTransform, pixelSnappedBorderRect, applyOrigin);
         makeMatrixRenderable(currTransform, canRender3DTransforms());
         return currTransform;
index 04db1b4..f662a00 100644 (file)
@@ -398,7 +398,7 @@ void RenderTreeUpdater::createRenderer(Element& element, RenderStyle&& style)
 
     auto& initialStyle = newRenderer->style();
     std::unique_ptr<RenderStyle> animatedStyle;
-    newRenderer->animation().updateAnimations(*newRenderer, initialStyle, animatedStyle);
+    newRenderer->animation().updateAnimations(element, initialStyle, animatedStyle);
     if (animatedStyle) {
         newRenderer->setStyleInternal(WTFMove(*animatedStyle));
         newRenderer->setHasInitialAnimatedStyle(true);
index 1f2ab82..8c0c577 100644 (file)
@@ -266,7 +266,7 @@ ElementUpdate TreeResolver::createAnimatedElementUpdate(std::unique_ptr<RenderSt
     }
 
     std::unique_ptr<RenderStyle> animatedStyle;
-    if (element.document().frame()->animation().updateAnimations(*renderer, *newStyle, animatedStyle))
+    if (element.document().frame()->animation().updateAnimations(element, *newStyle, animatedStyle))
         recompositeLayer = true;
 
     if (animatedStyle) {
index ea68815..8a31be5 100644 (file)
@@ -907,7 +907,7 @@ ExceptionOr<bool> Internals::pauseAnimationAtTimeOnElement(const String& animati
 {
     if (pauseTime < 0)
         return Exception { InvalidAccessError };
-    return frame()->animation().pauseAnimationAtTime(element.renderer(), AtomicString(animationName), pauseTime);
+    return frame()->animation().pauseAnimationAtTime(element, AtomicString(animationName), pauseTime);
 }
 
 ExceptionOr<bool> Internals::pauseAnimationAtTimeOnPseudoElement(const String& animationName, double pauseTime, Element& element, const String& pseudoId)
@@ -922,14 +922,14 @@ ExceptionOr<bool> Internals::pauseAnimationAtTimeOnPseudoElement(const String& a
     if (!pseudoElement)
         return Exception { InvalidAccessError };
 
-    return frame()->animation().pauseAnimationAtTime(pseudoElement->renderer(), AtomicString(animationName), pauseTime);
+    return frame()->animation().pauseAnimationAtTime(*pseudoElement, AtomicString(animationName), pauseTime);
 }
 
 ExceptionOr<bool> Internals::pauseTransitionAtTimeOnElement(const String& propertyName, double pauseTime, Element& element)
 {
     if (pauseTime < 0)
         return Exception { InvalidAccessError };
-    return frame()->animation().pauseTransitionAtTime(element.renderer(), propertyName, pauseTime);
+    return frame()->animation().pauseTransitionAtTime(element, propertyName, pauseTime);
 }
 
 ExceptionOr<bool> Internals::pauseTransitionAtTimeOnPseudoElement(const String& property, double pauseTime, Element& element, const String& pseudoId)
@@ -944,7 +944,7 @@ ExceptionOr<bool> Internals::pauseTransitionAtTimeOnPseudoElement(const String&
     if (!pseudoElement)
         return Exception { InvalidAccessError };
 
-    return frame()->animation().pauseTransitionAtTime(pseudoElement->renderer(), property, pauseTime);
+    return frame()->animation().pauseTransitionAtTime(*pseudoElement, property, pauseTime);
 }
 
 ExceptionOr<String> Internals::elementRenderTreeAsText(Element& element)
index 8353083..619f33a 100644 (file)
@@ -1171,7 +1171,7 @@ HRESULT WebFrame::pauseAnimation(_In_ BSTR animationName, _In_opt_ IDOMNode* nod
     if (!domNode)
         return E_FAIL;
 
-    *animationWasRunning = frame->animation().pauseAnimationAtTime(downcast<RenderElement>(domNode->node()->renderer()), String(animationName, SysStringLen(animationName)), secondsFromNow);
+    *animationWasRunning = frame->animation().pauseAnimationAtTime(downcast<Element>(*domNode->node()), String(animationName, SysStringLen(animationName)), secondsFromNow);
     return S_OK;
 }
 
@@ -1190,7 +1190,7 @@ HRESULT WebFrame::pauseTransition(_In_ BSTR propertyName, _In_opt_ IDOMNode* nod
     if (!domNode)
         return E_FAIL;
 
-    *transitionWasRunning = frame->animation().pauseTransitionAtTime(downcast<RenderElement>(domNode->node()->renderer()), String(propertyName, SysStringLen(propertyName)), secondsFromNow);
+    *transitionWasRunning = frame->animation().pauseTransitionAtTime(downcast<Element>(*domNode->node()), String(propertyName, SysStringLen(propertyName)), secondsFromNow);
     return S_OK;
 }