- Revision
- 255835
- Author
- [email protected]
- Date
- 2020-02-05 11:35:05 -0800 (Wed, 05 Feb 2020)
Log Message
Cherry-pick r255141. rdar://problem/59195660
[Web Animations] Update all DocumentTimeline objects when updating animations
https://bugs.webkit.org/show_bug.cgi?id=206819
Reviewed by Antti Koivisto.
LayoutTests/imported/w3c:
Mark a single new WPT progression.
* web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-replacement-expected.txt:
Source/WebCore:
Developers can create additional DocumentTimeline objects in _javascript_ using that class's constructor, and an animation can be
assigned to that timeline after its creation. Until now we would only update an timeline created by a Document when that document's
animations were updated. Now we keep track of all DocumentTimeline objects that are created for a given Document as a vector of weak
references, and we update all of them when updating a document's animations.
* animation/DocumentTimeline.cpp:
(WebCore::DocumentTimeline::DocumentTimeline):
(WebCore::DocumentTimeline::~DocumentTimeline):
* animation/DocumentTimeline.h:
* dom/Document.cpp:
(WebCore::Document::updateAnimationsAndSendEvents):
(WebCore::Document::addTimeline):
(WebCore::Document::removeTimeline):
* dom/Document.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255141 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Modified Paths
Diff
Modified: branches/safari-609.1.16-branch/LayoutTests/imported/w3c/ChangeLog (255834 => 255835)
--- branches/safari-609.1.16-branch/LayoutTests/imported/w3c/ChangeLog 2020-02-05 19:31:56 UTC (rev 255834)
+++ branches/safari-609.1.16-branch/LayoutTests/imported/w3c/ChangeLog 2020-02-05 19:35:05 UTC (rev 255835)
@@ -1,3 +1,48 @@
+2020-02-05 Alan Coon <[email protected]>
+
+ Cherry-pick r255141. rdar://problem/59195660
+
+ [Web Animations] Update all DocumentTimeline objects when updating animations
+ https://bugs.webkit.org/show_bug.cgi?id=206819
+
+ Reviewed by Antti Koivisto.
+
+ LayoutTests/imported/w3c:
+
+ Mark a single new WPT progression.
+
+ * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-replacement-expected.txt:
+
+ Source/WebCore:
+
+ Developers can create additional DocumentTimeline objects in _javascript_ using that class's constructor, and an animation can be
+ assigned to that timeline after its creation. Until now we would only update an timeline created by a Document when that document's
+ animations were updated. Now we keep track of all DocumentTimeline objects that are created for a given Document as a vector of weak
+ references, and we update all of them when updating a document's animations.
+
+ * animation/DocumentTimeline.cpp:
+ (WebCore::DocumentTimeline::DocumentTimeline):
+ (WebCore::DocumentTimeline::~DocumentTimeline):
+ * animation/DocumentTimeline.h:
+ * dom/Document.cpp:
+ (WebCore::Document::updateAnimationsAndSendEvents):
+ (WebCore::Document::addTimeline):
+ (WebCore::Document::removeTimeline):
+ * dom/Document.h:
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255141 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-01-26 Antoine Quint <[email protected]>
+
+ [Web Animations] Update all DocumentTimeline objects when updating animations
+ https://bugs.webkit.org/show_bug.cgi?id=206819
+
+ Reviewed by Antti Koivisto.
+
+ Mark a single new WPT progression.
+
+ * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-replacement-expected.txt:
+
2020-01-27 Russell Epstein <[email protected]>
Cherry-pick r255076. rdar://problem/58920206
Modified: branches/safari-609.1.16-branch/LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-replacement-expected.txt (255834 => 255835)
--- branches/safari-609.1.16-branch/LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-replacement-expected.txt 2020-02-05 19:31:56 UTC (rev 255834)
+++ branches/safari-609.1.16-branch/LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-replacement-expected.txt 2020-02-05 19:35:05 UTC (rev 255835)
@@ -38,7 +38,7 @@
PASS Does NOT remove an animation after making a redundant change to its timeline
PASS Does NOT remove an animation after making a redundant change to another animation's effect's properties
PASS Does NOT remove an animation after making a redundant change to its effect's properties
-FAIL Updates ALL timelines before checking for replacement assert_equals: expected "removed" but got "active"
+PASS Updates ALL timelines before checking for replacement
PASS Dispatches remove events after finish events
PASS Fires remove event before requestAnimationFrame
PASS Queues all remove events before running them
Modified: branches/safari-609.1.16-branch/Source/WebCore/ChangeLog (255834 => 255835)
--- branches/safari-609.1.16-branch/Source/WebCore/ChangeLog 2020-02-05 19:31:56 UTC (rev 255834)
+++ branches/safari-609.1.16-branch/Source/WebCore/ChangeLog 2020-02-05 19:35:05 UTC (rev 255835)
@@ -1,3 +1,59 @@
+2020-02-05 Alan Coon <[email protected]>
+
+ Cherry-pick r255141. rdar://problem/59195660
+
+ [Web Animations] Update all DocumentTimeline objects when updating animations
+ https://bugs.webkit.org/show_bug.cgi?id=206819
+
+ Reviewed by Antti Koivisto.
+
+ LayoutTests/imported/w3c:
+
+ Mark a single new WPT progression.
+
+ * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-replacement-expected.txt:
+
+ Source/WebCore:
+
+ Developers can create additional DocumentTimeline objects in _javascript_ using that class's constructor, and an animation can be
+ assigned to that timeline after its creation. Until now we would only update an timeline created by a Document when that document's
+ animations were updated. Now we keep track of all DocumentTimeline objects that are created for a given Document as a vector of weak
+ references, and we update all of them when updating a document's animations.
+
+ * animation/DocumentTimeline.cpp:
+ (WebCore::DocumentTimeline::DocumentTimeline):
+ (WebCore::DocumentTimeline::~DocumentTimeline):
+ * animation/DocumentTimeline.h:
+ * dom/Document.cpp:
+ (WebCore::Document::updateAnimationsAndSendEvents):
+ (WebCore::Document::addTimeline):
+ (WebCore::Document::removeTimeline):
+ * dom/Document.h:
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@255141 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2020-01-26 Antoine Quint <[email protected]>
+
+ [Web Animations] Update all DocumentTimeline objects when updating animations
+ https://bugs.webkit.org/show_bug.cgi?id=206819
+
+ Reviewed by Antti Koivisto.
+
+ Developers can create additional DocumentTimeline objects in _javascript_ using that class's constructor, and an animation can be
+ assigned to that timeline after its creation. Until now we would only update an timeline created by a Document when that document's
+ animations were updated. Now we keep track of all DocumentTimeline objects that are created for a given Document as a vector of weak
+ references, and we update all of them when updating a document's animations.
+
+ * animation/DocumentTimeline.cpp:
+ (WebCore::DocumentTimeline::DocumentTimeline):
+ (WebCore::DocumentTimeline::~DocumentTimeline):
+ * animation/DocumentTimeline.h:
+ * dom/Document.cpp:
+ (WebCore::Document::updateAnimationsAndSendEvents):
+ (WebCore::Document::addTimeline):
+ (WebCore::Document::removeTimeline):
+ * dom/Document.h:
+
2020-01-27 Russell Epstein <[email protected]>
Cherry-pick r255128. rdar://problem/58921492
Modified: branches/safari-609.1.16-branch/Source/WebCore/animation/DocumentTimeline.cpp (255834 => 255835)
--- branches/safari-609.1.16-branch/Source/WebCore/animation/DocumentTimeline.cpp 2020-02-05 19:31:56 UTC (rev 255834)
+++ branches/safari-609.1.16-branch/Source/WebCore/animation/DocumentTimeline.cpp 2020-02-05 19:35:05 UTC (rev 255835)
@@ -65,11 +65,17 @@
, m_document(&document)
, m_originTime(originTime)
{
+ if (m_document)
+ m_document->addTimeline(*this);
if (m_document && m_document->page() && !m_document->page()->isVisible())
suspendAnimations();
}
-DocumentTimeline::~DocumentTimeline() = default;
+DocumentTimeline::~DocumentTimeline()
+{
+ if (m_document)
+ m_document->removeTimeline(*this);
+}
void DocumentTimeline::detachFromDocument()
{
Modified: branches/safari-609.1.16-branch/Source/WebCore/animation/DocumentTimeline.h (255834 => 255835)
--- branches/safari-609.1.16-branch/Source/WebCore/animation/DocumentTimeline.h 2020-02-05 19:31:56 UTC (rev 255834)
+++ branches/safari-609.1.16-branch/Source/WebCore/animation/DocumentTimeline.h 2020-02-05 19:35:05 UTC (rev 255835)
@@ -31,6 +31,7 @@
#include "Timer.h"
#include <wtf/Markable.h>
#include <wtf/Ref.h>
+#include <wtf/WeakPtr.h>
namespace WebCore {
@@ -37,7 +38,7 @@
class AnimationPlaybackEvent;
class RenderElement;
-class DocumentTimeline final : public AnimationTimeline
+class DocumentTimeline final : public AnimationTimeline, public CanMakeWeakPtr<DocumentTimeline>
{
public:
static Ref<DocumentTimeline> create(Document&);
Modified: branches/safari-609.1.16-branch/Source/WebCore/dom/Document.cpp (255834 => 255835)
--- branches/safari-609.1.16-branch/Source/WebCore/dom/Document.cpp 2020-02-05 19:31:56 UTC (rev 255834)
+++ branches/safari-609.1.16-branch/Source/WebCore/dom/Document.cpp 2020-02-05 19:35:05 UTC (rev 255835)
@@ -6321,8 +6321,13 @@
void Document::updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp)
{
- if (m_timeline)
- m_timeline->updateAnimationsAndSendEvents(timestamp);
+ ASSERT(!m_timelines.hasNullReferences());
+ // We need to copy m_timelines before iterating over its members since calling updateAnimationsAndSendEvents() may mutate m_timelines.
+ Vector<RefPtr<DocumentTimeline>> timelines;
+ for (auto& timeline : m_timelines)
+ timelines.append(&timeline);
+ for (auto& timeline : timelines)
+ timeline->updateAnimationsAndSendEvents(timestamp);
}
void Document::serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp)
@@ -8010,6 +8015,16 @@
m_consoleMessageListener = listener;
}
+void Document::addTimeline(DocumentTimeline& timeline)
+{
+ m_timelines.add(timeline);
+}
+
+void Document::removeTimeline(DocumentTimeline& timeline)
+{
+ m_timelines.remove(timeline);
+}
+
DocumentTimeline& Document::timeline()
{
if (!m_timeline)
Modified: branches/safari-609.1.16-branch/Source/WebCore/dom/Document.h (255834 => 255835)
--- branches/safari-609.1.16-branch/Source/WebCore/dom/Document.h 2020-02-05 19:31:56 UTC (rev 255834)
+++ branches/safari-609.1.16-branch/Source/WebCore/dom/Document.h 2020-02-05 19:35:05 UTC (rev 255835)
@@ -1473,6 +1473,8 @@
WEBCORE_EXPORT void setConsoleMessageListener(RefPtr<StringCallback>&&); // For testing.
+ void addTimeline(DocumentTimeline&);
+ void removeTimeline(DocumentTimeline&);
WEBCORE_EXPORT DocumentTimeline& timeline();
DocumentTimeline* existingTimeline() const { return m_timeline.get(); }
Vector<RefPtr<WebAnimation>> getAnimations();
@@ -2038,6 +2040,8 @@
static bool hasEverCreatedAnAXObjectCache;
RefPtr<DocumentTimeline> m_timeline;
+ WeakHashSet<DocumentTimeline> m_timelines;
+
DocumentIdentifier m_identifier;
RefPtr<WindowEventLoop> m_eventLoop;