Title: [223825] trunk
Revision
223825
Author
[email protected]
Date
2017-10-22 14:31:24 -0700 (Sun, 22 Oct 2017)

Log Message

[Web Animations] Add animations to the timeline
https://bugs.webkit.org/show_bug.cgi?id=178643

Patch by Antoine Quint <[email protected]> on 2017-10-22
Reviewed by Dean Jackson.

Source/WebCore:

If a timeline is provided as a parameter to the Animation constructor,
add it to the timeline, and remove it when the object is destroyed.

We also start the basic mechanism to dump the contents of a timeline
as text for testing purposes, currently only logging the number of
animations in a timeline and just logging the class name for animation
themselves.

Test: webanimations/animation-creation-addition.html

* animation/AnimationTimeline.cpp:
(WebCore::AnimationTimeline::description):
* animation/AnimationTimeline.h:
* animation/AnimationTimeline.idl:
* animation/WebAnimation.cpp:
(WebCore::WebAnimation::create):
(WebCore::WebAnimation::~WebAnimation):
(WebCore::WebAnimation::description):
* animation/WebAnimation.h:
* testing/Internals.cpp:
(WebCore::Internals::timelineDescription):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Add a new test that checks that animations created with a timeline
are added to the provided timeline.

* webanimations/animation-creation-addition-expected.txt: Added.
* webanimations/animation-creation-addition.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (223824 => 223825)


--- trunk/LayoutTests/ChangeLog	2017-10-22 18:28:16 UTC (rev 223824)
+++ trunk/LayoutTests/ChangeLog	2017-10-22 21:31:24 UTC (rev 223825)
@@ -1,3 +1,16 @@
+2017-10-22  Antoine Quint  <[email protected]>
+
+        [Web Animations] Add animations to the timeline
+        https://bugs.webkit.org/show_bug.cgi?id=178643
+
+        Reviewed by Dean Jackson.
+
+        Add a new test that checks that animations created with a timeline
+        are added to the provided timeline.
+
+        * webanimations/animation-creation-addition-expected.txt: Added.
+        * webanimations/animation-creation-addition.html: Added.
+
 2017-10-21  Dean Jackson  <[email protected]>
 
         createImageBitmap with basic HTMLImageElement

Added: trunk/LayoutTests/webanimations/animation-creation-addition-expected.txt (0 => 223825)


--- trunk/LayoutTests/webanimations/animation-creation-addition-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/webanimations/animation-creation-addition-expected.txt	2017-10-22 21:31:24 UTC (rev 223825)
@@ -0,0 +1,13 @@
+Constructing an Animation with a timeline should add the animation to the timeline.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+DocumentTimeline with 2 animations:
+  1. Animation
+  2. Animation
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/webanimations/animation-creation-addition.html (0 => 223825)


--- trunk/LayoutTests/webanimations/animation-creation-addition.html	                        (rev 0)
+++ trunk/LayoutTests/webanimations/animation-creation-addition.html	2017-10-22 21:31:24 UTC (rev 223825)
@@ -0,0 +1,12 @@
+<script src=""
+<script>
+
+description("Constructing an Animation with a timeline should add the animation to the timeline.");
+
+new Animation(document.timeline);
+new Animation();
+new Animation(document.timeline);
+debug(internals.timelineDescription(document.timeline));
+
+</script>
+<script src=""
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (223824 => 223825)


--- trunk/Source/WebCore/ChangeLog	2017-10-22 18:28:16 UTC (rev 223824)
+++ trunk/Source/WebCore/ChangeLog	2017-10-22 21:31:24 UTC (rev 223825)
@@ -1,3 +1,34 @@
+2017-10-22  Antoine Quint  <[email protected]>
+
+        [Web Animations] Add animations to the timeline
+        https://bugs.webkit.org/show_bug.cgi?id=178643
+
+        Reviewed by Dean Jackson.
+
+        If a timeline is provided as a parameter to the Animation constructor,
+        add it to the timeline, and remove it when the object is destroyed.
+
+        We also start the basic mechanism to dump the contents of a timeline
+        as text for testing purposes, currently only logging the number of
+        animations in a timeline and just logging the class name for animation
+        themselves.
+
+        Test: webanimations/animation-creation-addition.html
+
+        * animation/AnimationTimeline.cpp:
+        (WebCore::AnimationTimeline::description):
+        * animation/AnimationTimeline.h:
+        * animation/AnimationTimeline.idl:
+        * animation/WebAnimation.cpp:
+        (WebCore::WebAnimation::create):
+        (WebCore::WebAnimation::~WebAnimation):
+        (WebCore::WebAnimation::description):
+        * animation/WebAnimation.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::timelineDescription):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2017-10-21  Zalan Bujtas  <[email protected]>
 
         [FrameView::layout cleanup] Drop allowSubtree parameter

Modified: trunk/Source/WebCore/animation/AnimationTimeline.cpp (223824 => 223825)


--- trunk/Source/WebCore/animation/AnimationTimeline.cpp	2017-10-22 18:28:16 UTC (rev 223824)
+++ trunk/Source/WebCore/animation/AnimationTimeline.cpp	2017-10-22 21:31:24 UTC (rev 223825)
@@ -28,6 +28,8 @@
 #include "AnimationTimeline.h"
 
 #include "DocumentTimeline.h"
+#include <wtf/text/TextStream.h>
+#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
@@ -50,4 +52,19 @@
     m_animations.remove(WTFMove(animation));
 }
 
+String AnimationTimeline::description()
+{
+    TextStream stream;
+    int count = 1;
+    stream << (m_classType == DocumentTimelineClass ? "DocumentTimeline" : "AnimationTimeline") << " with " << m_animations.size() << " animations:";
+    stream << "\n";
+    for (const auto& animation : m_animations) {
+        writeIndent(stream, 1);
+        stream << count << ". " << animation->description();
+        stream << "\n";
+        count++;
+    }
+    return stream.release();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/animation/AnimationTimeline.h (223824 => 223825)


--- trunk/Source/WebCore/animation/AnimationTimeline.h	2017-10-22 18:28:16 UTC (rev 223824)
+++ trunk/Source/WebCore/animation/AnimationTimeline.h	2017-10-22 21:31:24 UTC (rev 223825)
@@ -27,6 +27,7 @@
 #pragma once
 
 #include "WebAnimation.h"
+#include <wtf/Forward.h>
 #include <wtf/HashSet.h>
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
@@ -40,6 +41,7 @@
     bool isDocumentTimeline() const { return m_classType == DocumentTimelineClass; }
     void addAnimation(Ref<WebAnimation>&&);
     void removeAnimation(Ref<WebAnimation>&&);
+    WEBCORE_EXPORT String description();
 
     virtual ~AnimationTimeline();
 

Modified: trunk/Source/WebCore/animation/AnimationTimeline.idl (223824 => 223825)


--- trunk/Source/WebCore/animation/AnimationTimeline.idl	2017-10-22 18:28:16 UTC (rev 223824)
+++ trunk/Source/WebCore/animation/AnimationTimeline.idl	2017-10-22 21:31:24 UTC (rev 223825)
@@ -25,6 +25,7 @@
 
 [
     EnabledAtRuntime=WebAnimations,
+    ExportMacro=WEBCORE_EXPORT,
     CustomToJSObject
 ] interface AnimationTimeline {
 };

Modified: trunk/Source/WebCore/animation/WebAnimation.cpp (223824 => 223825)


--- trunk/Source/WebCore/animation/WebAnimation.cpp	2017-10-22 18:28:16 UTC (rev 223824)
+++ trunk/Source/WebCore/animation/WebAnimation.cpp	2017-10-22 21:31:24 UTC (rev 223825)
@@ -25,6 +25,7 @@
 
 #include "config.h"
 #include "WebAnimation.h"
+#include <wtf/text/WTFString.h>
 
 #include "AnimationTimeline.h"
 
@@ -32,7 +33,12 @@
 
 Ref<WebAnimation> WebAnimation::create(AnimationTimeline* timeline)
 {
-    return adoptRef(*new WebAnimation(timeline));
+    auto result = adoptRef(*new WebAnimation(timeline));
+
+    if (timeline)
+        timeline->addAnimation(result.copyRef());
+    
+    return result;
 }
 
 WebAnimation::WebAnimation(AnimationTimeline* timeline)
@@ -42,6 +48,13 @@
 
 WebAnimation::~WebAnimation()
 {
+    if (m_timeline)
+        m_timeline->removeAnimation(*this);
 }
 
+String WebAnimation::description()
+{
+    return "Animation";
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/animation/WebAnimation.h (223824 => 223825)


--- trunk/Source/WebCore/animation/WebAnimation.h	2017-10-22 18:28:16 UTC (rev 223824)
+++ trunk/Source/WebCore/animation/WebAnimation.h	2017-10-22 21:31:24 UTC (rev 223825)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include <wtf/Forward.h>
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
@@ -39,6 +40,7 @@
     ~WebAnimation();
 
     AnimationTimeline* timeline() const { return m_timeline.get(); }
+    String description();
 
 private:
     WebAnimation(AnimationTimeline*);

Modified: trunk/Source/WebCore/testing/Internals.cpp (223824 => 223825)


--- trunk/Source/WebCore/testing/Internals.cpp	2017-10-22 18:28:16 UTC (rev 223824)
+++ trunk/Source/WebCore/testing/Internals.cpp	2017-10-22 21:31:24 UTC (rev 223825)
@@ -4245,4 +4245,9 @@
 }
 #endif
 
+String Internals::timelineDescription(AnimationTimeline& timeline)
+{
+    return timeline.description();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/testing/Internals.h (223824 => 223825)


--- trunk/Source/WebCore/testing/Internals.h	2017-10-22 18:28:16 UTC (rev 223824)
+++ trunk/Source/WebCore/testing/Internals.h	2017-10-22 21:31:24 UTC (rev 223825)
@@ -42,6 +42,7 @@
 
 namespace WebCore {
 
+class AnimationTimeline;
 class AudioContext;
 class CacheStorageConnection;
 class DOMRect;
@@ -617,6 +618,8 @@
 
     bool hasServiceWorkerRegisteredForOrigin(const String&);
 
+    String timelineDescription(AnimationTimeline&);
+
 private:
     explicit Internals(Document&);
     Document* contextDocument() const;

Modified: trunk/Source/WebCore/testing/Internals.idl (223824 => 223825)


--- trunk/Source/WebCore/testing/Internals.idl	2017-10-22 18:28:16 UTC (rev 223824)
+++ trunk/Source/WebCore/testing/Internals.idl	2017-10-22 21:31:24 UTC (rev 223825)
@@ -560,4 +560,6 @@
     [Conditional=SERVICE_WORKER] ExtendableEvent createTrustedExtendableEvent();
 
     boolean hasServiceWorkerRegisteredForOrigin(DOMString origin);
+
+    [EnabledAtRuntime=WebAnimations] DOMString timelineDescription(AnimationTimeline timeline);
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to