[Web Animations] Move the logic of Document::getAnimations() to DocumentTimeline
authorgraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 28 Oct 2018 07:53:07 +0000 (07:53 +0000)
committergraouts@webkit.org <graouts@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 28 Oct 2018 07:53:07 +0000 (07:53 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190994

Reviewed by Dean Jackson.

It would be cleaner to have the logic of document.getAnimations() on the DocumentTimeline instead of the Document, keep more
animation-related code compartmentalized in the animation directory. No change in behavior, so no test update.

* animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::getAnimations const):
* animation/DocumentTimeline.h:
* dom/Document.cpp:
(WebCore::Document::getAnimations):

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

Source/WebCore/ChangeLog
Source/WebCore/animation/DocumentTimeline.cpp
Source/WebCore/animation/DocumentTimeline.h
Source/WebCore/dom/Document.cpp

index 9b9463c..70fc425 100644 (file)
@@ -1,5 +1,21 @@
 2018-10-27  Antoine Quint  <graouts@apple.com>
 
+        [Web Animations] Move the logic of Document::getAnimations() to DocumentTimeline
+        https://bugs.webkit.org/show_bug.cgi?id=190994
+
+        Reviewed by Dean Jackson.
+
+        It would be cleaner to have the logic of document.getAnimations() on the DocumentTimeline instead of the Document, keep more
+        animation-related code compartmentalized in the animation directory. No change in behavior, so no test update.
+
+        * animation/DocumentTimeline.cpp:
+        (WebCore::DocumentTimeline::getAnimations const):
+        * animation/DocumentTimeline.h:
+        * dom/Document.cpp:
+        (WebCore::Document::getAnimations):
+
+2018-10-27  Antoine Quint  <graouts@apple.com>
+
         [Web Animations] Move bindings methods requiring style flush from CSSAnimation to DeclarativeAnimation
         https://bugs.webkit.org/show_bug.cgi?id=190996
 
index 687b9f2..5bf10ba 100644 (file)
@@ -83,6 +83,23 @@ void DocumentTimeline::detachFromDocument()
     m_document = nullptr;
 }
 
+Vector<RefPtr<WebAnimation>> DocumentTimeline::getAnimations() const
+{
+    ASSERT(m_document);
+
+    // FIXME: Filter and order the list as specified (webkit.org/b/179535).
+    Vector<RefPtr<WebAnimation>> animations;
+    for (const auto& animation : this->animations()) {
+        if (animation->canBeListed() && is<KeyframeEffectReadOnly>(animation->effect())) {
+            if (auto* target = downcast<KeyframeEffectReadOnly>(animation->effect())->target()) {
+                if (target->isDescendantOf(*m_document))
+                    animations.append(animation);
+            }
+        }
+    }
+    return animations;
+}
+
 void DocumentTimeline::updateThrottlingState()
 {
     m_needsUpdateAnimationSchedule = false;
index e6a6c29..193adaf 100644 (file)
@@ -43,6 +43,8 @@ public:
     static Ref<DocumentTimeline> create(Document&, DocumentTimelineOptions&&);
     ~DocumentTimeline();
 
+    Vector<RefPtr<WebAnimation>> getAnimations() const;
+
     Document* document() const { return m_document.get(); }
 
     std::optional<Seconds> currentTime() override;
index 7b4808b..9f9c8a2 100644 (file)
@@ -8204,24 +8204,13 @@ DocumentTimeline& Document::timeline()
 
 Vector<RefPtr<WebAnimation>> Document::getAnimations()
 {
-    // FIXME: Filter and order the list as specified (webkit.org/b/179535).
-
     // For the list of animations to be current, we need to account for any pending CSS changes,
     // such as updates to CSS Animations and CSS Transitions.
     updateStyleIfNeeded();
 
-    Vector<RefPtr<WebAnimation>> animations;
-    if (m_timeline) {
-        for (auto& animation : m_timeline->animations()) {
-            if (animation->canBeListed() && is<KeyframeEffectReadOnly>(animation->effect())) {
-                if (auto* target = downcast<KeyframeEffectReadOnly>(animation->effect())->target()) {
-                    if (target->isDescendantOf(this))
-                        animations.append(animation);
-                }
-            }
-        }
-    }
-    return animations;
+    if (m_timeline)
+        return m_timeline->getAnimations();
+    return { };
 }
 
 #if ENABLE(ATTACHMENT_ELEMENT)