Changeset 190890 in webkit


Ignore:
Timestamp:
Oct 12, 2015 2:48:32 PM (9 years ago)
Author:
commit-queue@webkit.org
Message:

[SVG] Handle endEvent for svg animations
https://bugs.webkit.org/show_bug.cgi?id=121587

Patch by Antoine Quint <Antoine Quint> on 2015-10-12
Reviewed by Dean Jackson.

Source/WebCore:

Add support for the "endEvent" SVG event triggered when an animation completes, as
specified in http://www.w3.org/TR/SMIL3/smil-timing.html#q135. This event doesn't
bubble and can't be canceled. Added test coverage for the event through the DOM
Events API as well as the declarative SMIL Animation syntax.

Adapted from a Chromium patch by pavan.e@samsung.com
https://chromium.googlesource.com/chromium/blink/+/4d415ca0268231aa80e3552fe21bf3480a6978f8

Tests: svg/animations/end-event-declarative-expected.svg

svg/animations/end-event-declarative.svg
svg/animations/end-event-script-expected.svg
svg/animations/end-event-script.svg

  • svg/animation/SMILTimeContainer.cpp:

(WebCore::SMILTimeContainer::updateAnimations):

  • svg/animation/SVGSMILElement.cpp:

(WebCore::smilEndEventSender):
(WebCore::SVGSMILElement::~SVGSMILElement):
(WebCore::SVGSMILElement::progress):
(WebCore::SVGSMILElement::dispatchPendingEvent):

  • svg/animation/SVGSMILElement.h:

(WebCore::SVGSMILElement::hasConditionsConnected):

LayoutTests:

Tests for the "endEvent" event for SVG animations.

  • svg/animations/end-event-declarative-expected.svg: Added.
  • svg/animations/end-event-declarative.svg: Added.
  • svg/animations/end-event-script-expected.svg: Added.
  • svg/animations/end-event-script.svg: Added.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r190884 r190890  
     12015-10-12  Antoine Quint  <graouts@apple.com>
     2
     3        [SVG] Handle endEvent for svg animations
     4        https://bugs.webkit.org/show_bug.cgi?id=121587
     5
     6        Reviewed by Dean Jackson.
     7
     8        Tests for the "endEvent" event for SVG animations.
     9
     10        * svg/animations/end-event-declarative-expected.svg: Added.
     11        * svg/animations/end-event-declarative.svg: Added.
     12        * svg/animations/end-event-script-expected.svg: Added.
     13        * svg/animations/end-event-script.svg: Added.
     14
    1152015-10-12  Brady Eidson  <beidson@apple.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r190887 r190890  
     12015-10-12  Antoine Quint  <graouts@apple.com>
     2
     3        [SVG] Handle endEvent for svg animations
     4        https://bugs.webkit.org/show_bug.cgi?id=121587
     5
     6        Reviewed by Dean Jackson.
     7
     8        Add support for the "endEvent" SVG event triggered when an animation completes, as
     9        specified in http://www.w3.org/TR/SMIL3/smil-timing.html#q135. This event doesn't
     10        bubble and can't be canceled. Added test coverage for the event through the DOM
     11        Events API as well as the declarative SMIL Animation syntax.
     12
     13        Adapted from a Chromium patch by pavan.e@samsung.com
     14        https://chromium.googlesource.com/chromium/blink/+/4d415ca0268231aa80e3552fe21bf3480a6978f8
     15
     16        Tests: svg/animations/end-event-declarative-expected.svg
     17               svg/animations/end-event-declarative.svg
     18               svg/animations/end-event-script-expected.svg
     19               svg/animations/end-event-script.svg
     20
     21        * svg/animation/SMILTimeContainer.cpp:
     22        (WebCore::SMILTimeContainer::updateAnimations):
     23        * svg/animation/SVGSMILElement.cpp:
     24        (WebCore::smilEndEventSender):
     25        (WebCore::SVGSMILElement::~SVGSMILElement):
     26        (WebCore::SVGSMILElement::progress):
     27        (WebCore::SVGSMILElement::dispatchPendingEvent):
     28        * svg/animation/SVGSMILElement.h:
     29        (WebCore::SVGSMILElement::hasConditionsConnected):
     30
    1312015-10-12  Per Arne Vollan  <peavo@outlook.com>
    232
  • trunk/Source/WebCore/svg/animation/SMILTimeContainer.cpp

    r184852 r190890  
    265265    for (auto& it : m_scheduledAnimations) {
    266266        AnimationsVector* scheduled = it.value.get();
     267        for (auto* animation : *scheduled) {
     268            if (!animation->hasConditionsConnected())
     269                animation->connectConditions();
     270        }
     271    }
     272   
     273    for (auto& it : m_scheduledAnimations) {
     274        AnimationsVector* scheduled = it.value.get();
    267275
    268276        // Sort according to priority. Elements with later begin time have higher priority.
  • trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp

    r185813 r190890  
    3131#include "Event.h"
    3232#include "EventListener.h"
     33#include "EventSender.h"
    3334#include "FloatConversion.h"
    3435#include "FrameView.h"
     
    4647
    4748namespace WebCore {
    48    
     49
     50static SMILEventSender& smilEndEventSender()
     51{
     52    static NeverDestroyed<SMILEventSender> sender("endEvent");
     53    return sender;
     54}
     55
    4956// This is used for duration type time values that can't be negative.
    5057static const double invalidCachedTime = -1.;
     
    136143{
    137144    clearResourceReferences();
     145    smilEndEventSender().cancelEvent(*this);
    138146    disconnectConditions();
    139147    if (m_timeContainer && m_targetElement && hasValidAttributeName())
     
    10491057    ASSERT(m_isWaitingForFirstInterval || m_intervalBegin.isFinite());
    10501058
    1051     if (!m_conditionsConnected)
    1052         connectConditions();
    1053 
    10541059    if (!m_intervalBegin.isFinite()) {
    10551060        ASSERT(m_activeState == Inactive);
     
    11081113
    11091114    if (oldActiveState == Active && m_activeState != Active) {
     1115        smilEndEventSender().dispatchEventSoon(*this);
    11101116        endedActiveInterval();
    11111117        if (m_activeState != Frozen)
    11121118            clearAnimatedType(m_targetElement);
     1119    }
     1120
     1121    // Triggering all the pending events if the animation timeline is changed.
     1122    if (seekToTime) {
     1123        if (m_activeState == Inactive || m_activeState == Frozen)
     1124            smilEndEventSender().dispatchEventSoon(*this);
    11131125    }
    11141126
     
    11881200}
    11891201
    1190 }
     1202void SVGSMILElement::dispatchPendingEvent(SMILEventSender* eventSender)
     1203{
     1204    ASSERT(eventSender == &smilEndEventSender());
     1205    const AtomicString& eventType = eventSender->eventType();
     1206    dispatchEvent(Event::create(eventType, false, false));
     1207}
     1208
     1209}
  • trunk/Source/WebCore/svg/animation/SVGSMILElement.h

    r185813 r190890  
    3434namespace WebCore {
    3535
     36class SVGSMILElement;
     37
     38template<typename T> class EventSender;
     39typedef EventSender<SVGSMILElement> SMILEventSender;
     40
    3641class ConditionEventListener;
    3742class SMILTimeContainer;
     
    107112    virtual void clearAnimatedType(SVGElement* targetElement) = 0;
    108113    virtual void applyResultsToTarget() = 0;
     114
     115    void connectConditions();
     116    bool hasConditionsConnected() const { return m_conditionsConnected; }
     117   
     118    void dispatchPendingEvent(SMILEventSender*);
    109119
    110120protected:
     
    169179    Element* eventBaseFor(const Condition&);
    170180
    171     void connectConditions();
    172181    void disconnectConditions();
    173182
Note: See TracChangeset for help on using the changeset viewer.