From 0baeff68329c84d6315ba9a7ccb1f3352d5ca2f6 Mon Sep 17 00:00:00 2001 From: "commit-queue@webkit.org" Date: Sun, 22 Oct 2017 21:31:24 +0000 Subject: [PATCH] [Web Animations] Add animations to the timeline https://bugs.webkit.org/show_bug.cgi?id=178643 Patch by Antoine Quint 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. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223825 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 13 +++++++++ .../animation-creation-addition-expected.txt | 13 +++++++++ .../webanimations/animation-creation-addition.html | 12 +++++++++ Source/WebCore/ChangeLog | 31 ++++++++++++++++++++++ Source/WebCore/animation/AnimationTimeline.cpp | 17 ++++++++++++ Source/WebCore/animation/AnimationTimeline.h | 2 ++ Source/WebCore/animation/AnimationTimeline.idl | 1 + Source/WebCore/animation/WebAnimation.cpp | 15 ++++++++++- Source/WebCore/animation/WebAnimation.h | 2 ++ Source/WebCore/testing/Internals.cpp | 5 ++++ Source/WebCore/testing/Internals.h | 3 +++ Source/WebCore/testing/Internals.idl | 2 ++ 12 files changed, 115 insertions(+), 1 deletion(-) create mode 100644 LayoutTests/webanimations/animation-creation-addition-expected.txt create mode 100644 LayoutTests/webanimations/animation-creation-addition.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 13e201f..b7a5997 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,16 @@ +2017-10-22 Antoine Quint + + [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 createImageBitmap with basic HTMLImageElement diff --git a/LayoutTests/webanimations/animation-creation-addition-expected.txt b/LayoutTests/webanimations/animation-creation-addition-expected.txt new file mode 100644 index 0000000..21cd248 --- /dev/null +++ b/LayoutTests/webanimations/animation-creation-addition-expected.txt @@ -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 + diff --git a/LayoutTests/webanimations/animation-creation-addition.html b/LayoutTests/webanimations/animation-creation-addition.html new file mode 100644 index 0000000..b3be178 --- /dev/null +++ b/LayoutTests/webanimations/animation-creation-addition.html @@ -0,0 +1,12 @@ + + + \ No newline at end of file diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index cbf1640..0f91122 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,34 @@ +2017-10-22 Antoine Quint + + [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 [FrameView::layout cleanup] Drop allowSubtree parameter diff --git a/Source/WebCore/animation/AnimationTimeline.cpp b/Source/WebCore/animation/AnimationTimeline.cpp index 1f15fb3..655739a 100644 --- a/Source/WebCore/animation/AnimationTimeline.cpp +++ b/Source/WebCore/animation/AnimationTimeline.cpp @@ -28,6 +28,8 @@ #include "AnimationTimeline.h" #include "DocumentTimeline.h" +#include +#include namespace WebCore { @@ -50,4 +52,19 @@ void AnimationTimeline::removeAnimation(Ref&& animation) 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 diff --git a/Source/WebCore/animation/AnimationTimeline.h b/Source/WebCore/animation/AnimationTimeline.h index 893f8a1..4a48a1d 100644 --- a/Source/WebCore/animation/AnimationTimeline.h +++ b/Source/WebCore/animation/AnimationTimeline.h @@ -27,6 +27,7 @@ #pragma once #include "WebAnimation.h" +#include #include #include #include @@ -40,6 +41,7 @@ public: bool isDocumentTimeline() const { return m_classType == DocumentTimelineClass; } void addAnimation(Ref&&); void removeAnimation(Ref&&); + WEBCORE_EXPORT String description(); virtual ~AnimationTimeline(); diff --git a/Source/WebCore/animation/AnimationTimeline.idl b/Source/WebCore/animation/AnimationTimeline.idl index f4f6c51..ee8ed06 100644 --- a/Source/WebCore/animation/AnimationTimeline.idl +++ b/Source/WebCore/animation/AnimationTimeline.idl @@ -25,6 +25,7 @@ [ EnabledAtRuntime=WebAnimations, + ExportMacro=WEBCORE_EXPORT, CustomToJSObject ] interface AnimationTimeline { }; diff --git a/Source/WebCore/animation/WebAnimation.cpp b/Source/WebCore/animation/WebAnimation.cpp index 7df36be..969d842 100644 --- a/Source/WebCore/animation/WebAnimation.cpp +++ b/Source/WebCore/animation/WebAnimation.cpp @@ -25,6 +25,7 @@ #include "config.h" #include "WebAnimation.h" +#include #include "AnimationTimeline.h" @@ -32,7 +33,12 @@ namespace WebCore { Ref 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(AnimationTimeline* timeline) WebAnimation::~WebAnimation() { + if (m_timeline) + m_timeline->removeAnimation(*this); +} + +String WebAnimation::description() +{ + return "Animation"; } } // namespace WebCore diff --git a/Source/WebCore/animation/WebAnimation.h b/Source/WebCore/animation/WebAnimation.h index 5b91dde..e7d8bf8 100644 --- a/Source/WebCore/animation/WebAnimation.h +++ b/Source/WebCore/animation/WebAnimation.h @@ -25,6 +25,7 @@ #pragma once +#include #include #include #include @@ -39,6 +40,7 @@ public: ~WebAnimation(); AnimationTimeline* timeline() const { return m_timeline.get(); } + String description(); private: WebAnimation(AnimationTimeline*); diff --git a/Source/WebCore/testing/Internals.cpp b/Source/WebCore/testing/Internals.cpp index 87c0561..39929b8 100644 --- a/Source/WebCore/testing/Internals.cpp +++ b/Source/WebCore/testing/Internals.cpp @@ -4245,4 +4245,9 @@ Ref Internals::createTrustedExtendableEvent() } #endif +String Internals::timelineDescription(AnimationTimeline& timeline) +{ + return timeline.description(); +} + } // namespace WebCore diff --git a/Source/WebCore/testing/Internals.h b/Source/WebCore/testing/Internals.h index 17b8c68..f05e6e5 100644 --- a/Source/WebCore/testing/Internals.h +++ b/Source/WebCore/testing/Internals.h @@ -42,6 +42,7 @@ namespace WebCore { +class AnimationTimeline; class AudioContext; class CacheStorageConnection; class DOMRect; @@ -617,6 +618,8 @@ public: bool hasServiceWorkerRegisteredForOrigin(const String&); + String timelineDescription(AnimationTimeline&); + private: explicit Internals(Document&); Document* contextDocument() const; diff --git a/Source/WebCore/testing/Internals.idl b/Source/WebCore/testing/Internals.idl index de87ae9..52aaf0f 100644 --- a/Source/WebCore/testing/Internals.idl +++ b/Source/WebCore/testing/Internals.idl @@ -560,4 +560,6 @@ enum EventThrottlingBehavior { [Conditional=SERVICE_WORKER] ExtendableEvent createTrustedExtendableEvent(); boolean hasServiceWorkerRegisteredForOrigin(DOMString origin); + + [EnabledAtRuntime=WebAnimations] DOMString timelineDescription(AnimationTimeline timeline); }; -- 1.8.3.1