Changeset 255141 in webkit


Ignore:
Timestamp:
Jan 27, 2020, 4:01:21 AM (6 years ago)
Author:
graouts@webkit.org
Message:

[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:
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r255138 r255141  
     12020-01-26  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Update all DocumentTimeline objects when updating animations
     4        https://bugs.webkit.org/show_bug.cgi?id=206819
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Mark a single new WPT progression.
     9
     10        * web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-replacement-expected.txt:
     11
    1122020-01-27  Rob Buis  <rbuis@igalia.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/timing-model/timelines/update-and-send-events-replacement-expected.txt

    r255076 r255141  
    3939PASS Does NOT remove an animation after making a redundant change to another animation's effect's properties
    4040PASS Does NOT remove an animation after making a redundant change to its effect's properties
    41 FAIL Updates ALL timelines before checking for replacement assert_equals: expected "removed" but got "active"
     41PASS Updates ALL timelines before checking for replacement
    4242PASS Dispatches remove events after finish events
    4343PASS Fires remove event before requestAnimationFrame
  • trunk/Source/WebCore/ChangeLog

    r255136 r255141  
     12020-01-26  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Update all DocumentTimeline objects when updating animations
     4        https://bugs.webkit.org/show_bug.cgi?id=206819
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Developers can create additional DocumentTimeline objects in JavaScript using that class's constructor, and an animation can be
     9        assigned to that timeline after its creation. Until now we would only update an timeline created by a Document when that document's
     10        animations were updated. Now we keep track of all DocumentTimeline objects that are created for a given Document as a vector of weak
     11        references, and we update all of them when updating a document's animations.
     12
     13        * animation/DocumentTimeline.cpp:
     14        (WebCore::DocumentTimeline::DocumentTimeline):
     15        (WebCore::DocumentTimeline::~DocumentTimeline):
     16        * animation/DocumentTimeline.h:
     17        * dom/Document.cpp:
     18        (WebCore::Document::updateAnimationsAndSendEvents):
     19        (WebCore::Document::addTimeline):
     20        (WebCore::Document::removeTimeline):
     21        * dom/Document.h:
     22
    1232020-01-26  Darin Adler  <darin@apple.com>
    224
  • trunk/Source/WebCore/animation/DocumentTimeline.cpp

    r255131 r255141  
    6363    , m_originTime(originTime)
    6464{
     65    if (m_document)
     66        m_document->addTimeline(*this);
    6567    if (m_document && m_document->page() && !m_document->page()->isVisible())
    6668        suspendAnimations();
    6769}
    6870
    69 DocumentTimeline::~DocumentTimeline() = default;
     71DocumentTimeline::~DocumentTimeline()
     72{
     73    if (m_document)
     74        m_document->removeTimeline(*this);
     75}
    7076
    7177void DocumentTimeline::detachFromDocument()
  • trunk/Source/WebCore/animation/DocumentTimeline.h

    r255131 r255141  
    3232#include <wtf/Markable.h>
    3333#include <wtf/Ref.h>
     34#include <wtf/WeakPtr.h>
    3435
    3536namespace WebCore {
     
    3839class RenderElement;
    3940
    40 class DocumentTimeline final : public AnimationTimeline
     41class DocumentTimeline final : public AnimationTimeline, public CanMakeWeakPtr<DocumentTimeline>
    4142{
    4243public:
  • trunk/Source/WebCore/dom/Document.cpp

    r255131 r255141  
    63536353void Document::updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp)
    63546354{
    6355     if (m_timeline)
    6356         m_timeline->updateAnimationsAndSendEvents(timestamp);
     6355    ASSERT(!m_timelines.hasNullReferences());
     6356    // We need to copy m_timelines before iterating over its members since calling updateAnimationsAndSendEvents() may mutate m_timelines.
     6357    Vector<RefPtr<DocumentTimeline>> timelines;
     6358    for (auto& timeline : m_timelines)
     6359        timelines.append(&timeline);
     6360    for (auto& timeline : timelines)
     6361        timeline->updateAnimationsAndSendEvents(timestamp);
    63576362}
    63586363
     
    80398044}
    80408045
     8046void Document::addTimeline(DocumentTimeline& timeline)
     8047{
     8048    m_timelines.add(timeline);
     8049}
     8050
     8051void Document::removeTimeline(DocumentTimeline& timeline)
     8052{
     8053    m_timelines.remove(timeline);
     8054}
     8055
    80418056DocumentTimeline& Document::timeline()
    80428057{
  • trunk/Source/WebCore/dom/Document.h

    r254785 r255141  
    14721472    WEBCORE_EXPORT void setConsoleMessageListener(RefPtr<StringCallback>&&); // For testing.
    14731473
     1474    void addTimeline(DocumentTimeline&);
     1475    void removeTimeline(DocumentTimeline&);
    14741476    WEBCORE_EXPORT DocumentTimeline& timeline();
    14751477    DocumentTimeline* existingTimeline() const { return m_timeline.get(); }
     
    20382040
    20392041    RefPtr<DocumentTimeline> m_timeline;
     2042    WeakHashSet<DocumentTimeline> m_timelines;
     2043
    20402044    DocumentIdentifier m_identifier;
    20412045
Note: See TracChangeset for help on using the changeset viewer.