<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[190890] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/190890">190890</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2015-10-12 14:48:32 -0700 (Mon, 12 Oct 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[SVG] Handle endEvent for svg animations
https://bugs.webkit.org/show_bug.cgi?id=121587
Patch by Antoine Quint <graouts@apple.com> 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.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoresvganimationSMILTimeContainercpp">trunk/Source/WebCore/svg/animation/SMILTimeContainer.cpp</a></li>
<li><a href="#trunkSourceWebCoresvganimationSVGSMILElementcpp">trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp</a></li>
<li><a href="#trunkSourceWebCoresvganimationSVGSMILElementh">trunk/Source/WebCore/svg/animation/SVGSMILElement.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestssvganimationsendeventdeclarativeexpectedsvg">trunk/LayoutTests/svg/animations/end-event-declarative-expected.svg</a></li>
<li><a href="#trunkLayoutTestssvganimationsendeventdeclarativesvg">trunk/LayoutTests/svg/animations/end-event-declarative.svg</a></li>
<li><a href="#trunkLayoutTestssvganimationsendeventscriptexpectedsvg">trunk/LayoutTests/svg/animations/end-event-script-expected.svg</a></li>
<li><a href="#trunkLayoutTestssvganimationsendeventscriptsvg">trunk/LayoutTests/svg/animations/end-event-script.svg</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (190889 => 190890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-10-12 21:31:28 UTC (rev 190889)
+++ trunk/LayoutTests/ChangeLog        2015-10-12 21:48:32 UTC (rev 190890)
</span><span class="lines">@@ -1,3 +1,17 @@
</span><ins>+2015-10-12 Antoine Quint <graouts@apple.com>
+
+ [SVG] Handle endEvent for svg animations
+ https://bugs.webkit.org/show_bug.cgi?id=121587
+
+ Reviewed by Dean Jackson.
+
+ 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.
+
</ins><span class="cx"> 2015-10-12 Brady Eidson <beidson@apple.com>
</span><span class="cx">
</span><span class="cx"> Modern IDB: Start version change transaction for connections to new database.
</span></span></pre></div>
<a id="trunkLayoutTestssvganimationsendeventdeclarativeexpectedsvg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/animations/end-event-declarative-expected.svg (0 => 190890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/animations/end-event-declarative-expected.svg         (rev 0)
+++ trunk/LayoutTests/svg/animations/end-event-declarative-expected.svg        2015-10-12 21:48:32 UTC (rev 190890)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <rect x="0" y="0" width="50" height="50" fill="green" />
+</svg>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestssvganimationsendeventdeclarativesvg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/animations/end-event-declarative.svg (0 => 190890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/animations/end-event-declarative.svg         (rev 0)
+++ trunk/LayoutTests/svg/animations/end-event-declarative.svg        2015-10-12 21:48:32 UTC (rev 190890)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg onload="loaded()" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<rect x="0" y="0" width="50" height="50" fill="red">
+ <animate id="anim" attributeName="visibility" to="visible" begin="0s" end="2s" />
+ <set attributeName="fill" to="green" begin="anim.endEvent" />
+</rect>
+<script>
+ if (window.testRunner)
+ testRunner.waitUntilDone();
+
+ function loaded() {
+ document.documentElement.setCurrentTime(2);
+
+ if (window.testRunner)
+ setTimeout(function() {testRunner.notifyDone();}, 100);
+ }
+</script>
+</svg>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestssvganimationsendeventscriptexpectedsvg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/animations/end-event-script-expected.svg (0 => 190890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/animations/end-event-script-expected.svg         (rev 0)
+++ trunk/LayoutTests/svg/animations/end-event-script-expected.svg        2015-10-12 21:48:32 UTC (rev 190890)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+ <rect x="0" y="0" width="50" height="50" fill="green" />
+</svg>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkLayoutTestssvganimationsendeventscriptsvg"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/svg/animations/end-event-script.svg (0 => 190890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/svg/animations/end-event-script.svg         (rev 0)
+++ trunk/LayoutTests/svg/animations/end-event-script.svg        2015-10-12 21:48:32 UTC (rev 190890)
</span><span class="lines">@@ -0,0 +1,21 @@
</span><ins>+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1 Tiny//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11-tiny.dtd">
+<svg onload="loaded()" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+<rect id="rect" x="0" y="0" width="50" height="50" fill="red">
+ <animate id="anim" attributeName="visibility" to="visible" begin="0s" end="2s" />
+</rect>
+<script>
+ if (window.testRunner)
+ testRunner.waitUntilDone();
+
+ function loaded() {
+ document.getElementById("anim").addEventListener("endEvent", function(event) {
+ document.getElementById("rect").setAttribute("fill", "green");
+ testRunner.notifyDone();
+ });
+
+ document.documentElement.setCurrentTime(2);
+ }
+
+</script>
+</svg>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (190889 => 190890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-10-12 21:31:28 UTC (rev 190889)
+++ trunk/Source/WebCore/ChangeLog        2015-10-12 21:48:32 UTC (rev 190890)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2015-10-12 Antoine Quint <graouts@apple.com>
+
+ [SVG] Handle endEvent for svg animations
+ https://bugs.webkit.org/show_bug.cgi?id=121587
+
+ Reviewed by Dean Jackson.
+
+ 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):
+
</ins><span class="cx"> 2015-10-12 Per Arne Vollan <peavo@outlook.com>
</span><span class="cx">
</span><span class="cx"> [Curl] Increase limit of parallel network requests.
</span></span></pre></div>
<a id="trunkSourceWebCoresvganimationSMILTimeContainercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/animation/SMILTimeContainer.cpp (190889 => 190890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/animation/SMILTimeContainer.cpp        2015-10-12 21:31:28 UTC (rev 190889)
+++ trunk/Source/WebCore/svg/animation/SMILTimeContainer.cpp        2015-10-12 21:48:32 UTC (rev 190890)
</span><span class="lines">@@ -264,6 +264,14 @@
</span><span class="cx"> AnimationsVector animationsToApply;
</span><span class="cx"> for (auto& it : m_scheduledAnimations) {
</span><span class="cx"> AnimationsVector* scheduled = it.value.get();
</span><ins>+ for (auto* animation : *scheduled) {
+ if (!animation->hasConditionsConnected())
+ animation->connectConditions();
+ }
+ }
+
+ for (auto& it : m_scheduledAnimations) {
+ AnimationsVector* scheduled = it.value.get();
</ins><span class="cx">
</span><span class="cx"> // Sort according to priority. Elements with later begin time have higher priority.
</span><span class="cx"> // In case of a tie, document order decides.
</span></span></pre></div>
<a id="trunkSourceWebCoresvganimationSVGSMILElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp (190889 => 190890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp        2015-10-12 21:31:28 UTC (rev 190889)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp        2015-10-12 21:48:32 UTC (rev 190890)
</span><span class="lines">@@ -30,6 +30,7 @@
</span><span class="cx"> #include "Document.h"
</span><span class="cx"> #include "Event.h"
</span><span class="cx"> #include "EventListener.h"
</span><ins>+#include "EventSender.h"
</ins><span class="cx"> #include "FloatConversion.h"
</span><span class="cx"> #include "FrameView.h"
</span><span class="cx"> #include "HTMLNames.h"
</span><span class="lines">@@ -45,7 +46,13 @@
</span><span class="cx"> #include <wtf/Vector.h>
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><del>-
</del><ins>+
+static SMILEventSender& smilEndEventSender()
+{
+ static NeverDestroyed<SMILEventSender> sender("endEvent");
+ return sender;
+}
+
</ins><span class="cx"> // This is used for duration type time values that can't be negative.
</span><span class="cx"> static const double invalidCachedTime = -1.;
</span><span class="cx">
</span><span class="lines">@@ -135,6 +142,7 @@
</span><span class="cx"> SVGSMILElement::~SVGSMILElement()
</span><span class="cx"> {
</span><span class="cx"> clearResourceReferences();
</span><ins>+ smilEndEventSender().cancelEvent(*this);
</ins><span class="cx"> disconnectConditions();
</span><span class="cx"> if (m_timeContainer && m_targetElement && hasValidAttributeName())
</span><span class="cx"> m_timeContainer->unschedule(this, m_targetElement, m_attributeName);
</span><span class="lines">@@ -1048,9 +1056,6 @@
</span><span class="cx"> ASSERT(m_timeContainer);
</span><span class="cx"> ASSERT(m_isWaitingForFirstInterval || m_intervalBegin.isFinite());
</span><span class="cx">
</span><del>- if (!m_conditionsConnected)
- connectConditions();
-
</del><span class="cx"> if (!m_intervalBegin.isFinite()) {
</span><span class="cx"> ASSERT(m_activeState == Inactive);
</span><span class="cx"> m_nextProgressTime = SMILTime::unresolved();
</span><span class="lines">@@ -1107,11 +1112,18 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (oldActiveState == Active && m_activeState != Active) {
</span><ins>+ smilEndEventSender().dispatchEventSoon(*this);
</ins><span class="cx"> endedActiveInterval();
</span><span class="cx"> if (m_activeState != Frozen)
</span><span class="cx"> clearAnimatedType(m_targetElement);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ // Triggering all the pending events if the animation timeline is changed.
+ if (seekToTime) {
+ if (m_activeState == Inactive || m_activeState == Frozen)
+ smilEndEventSender().dispatchEventSoon(*this);
+ }
+
</ins><span class="cx"> m_nextProgressTime = calculateNextProgressTime(elapsed);
</span><span class="cx"> return animationIsContributing;
</span><span class="cx"> }
</span><span class="lines">@@ -1187,4 +1199,11 @@
</span><span class="cx"> clearTimesWithDynamicOrigins(m_endTimes);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void SVGSMILElement::dispatchPendingEvent(SMILEventSender* eventSender)
+{
+ ASSERT(eventSender == &smilEndEventSender());
+ const AtomicString& eventType = eventSender->eventType();
+ dispatchEvent(Event::create(eventType, false, false));
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoresvganimationSVGSMILElementh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.h (190889 => 190890)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/svg/animation/SVGSMILElement.h        2015-10-12 21:31:28 UTC (rev 190889)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.h        2015-10-12 21:48:32 UTC (rev 190890)
</span><span class="lines">@@ -33,6 +33,11 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><ins>+class SVGSMILElement;
+
+template<typename T> class EventSender;
+typedef EventSender<SVGSMILElement> SMILEventSender;
+
</ins><span class="cx"> class ConditionEventListener;
</span><span class="cx"> class SMILTimeContainer;
</span><span class="cx">
</span><span class="lines">@@ -107,6 +112,11 @@
</span><span class="cx"> virtual void clearAnimatedType(SVGElement* targetElement) = 0;
</span><span class="cx"> virtual void applyResultsToTarget() = 0;
</span><span class="cx">
</span><ins>+ void connectConditions();
+ bool hasConditionsConnected() const { return m_conditionsConnected; }
+
+ void dispatchPendingEvent(SMILEventSender*);
+
</ins><span class="cx"> protected:
</span><span class="cx"> void addBeginTime(SMILTime eventTime, SMILTime endTime, SMILTimeWithOrigin::Origin = SMILTimeWithOrigin::ParserOrigin);
</span><span class="cx"> void addEndTime(SMILTime eventTime, SMILTime endTime, SMILTimeWithOrigin::Origin = SMILTimeWithOrigin::ParserOrigin);
</span><span class="lines">@@ -168,7 +178,6 @@
</span><span class="cx"> void parseBeginOrEnd(const String&, BeginOrEnd beginOrEnd);
</span><span class="cx"> Element* eventBaseFor(const Condition&);
</span><span class="cx">
</span><del>- void connectConditions();
</del><span class="cx"> void disconnectConditions();
</span><span class="cx">
</span><span class="cx"> // Event base timing
</span></span></pre>
</div>
</div>
</body>
</html>