Title: [191494] trunk
Revision
191494
Author
[email protected]
Date
2015-10-23 01:39:01 -0700 (Fri, 23 Oct 2015)

Log Message

Support for SVG `beginEvent` event and `onbegin` attribute
https://bugs.webkit.org/show_bug.cgi?id=150442

Patch by Antoine Quint <[email protected]> on 2015-10-23
Reviewed by Dean Jackson.

Source/WebCore:

Add support for the SVG `beginEvent` event, which is fired as an SVG timing element enters its active interval.
Also add support for the SVG `onbegin` attribute which allows the definition of a JS event listener declaratively
for the SVG `beginEvent` event.

Tests: svg/animations/begin-event-attribute.svg
       svg/animations/begin-event-script.svg
       svg/animations/begin-event-syncbase.svg

* dom/EventNames.h:
* svg/animation/SVGSMILElement.cpp:
(WebCore::smilBeginEventSender):
(WebCore::smilEndEventSender):
(WebCore::SVGSMILElement::~SVGSMILElement):
(WebCore::SVGSMILElement::parseAttribute):
(WebCore::SVGSMILElement::progress):
(WebCore::SVGSMILElement::dispatchPendingEvent):
* svg/svgattrs.in:

LayoutTests:

* svg/animations/begin-event-attribute-expected.svg: Added.
* svg/animations/begin-event-attribute.svg: Added.

Test for the newly supported `onbegin` attribute.

* svg/animations/begin-event-script-expected.svg: Added.
* svg/animations/begin-event-script.svg: Added.

Test for the newly supported `beginEvent` event handled via `addEventListener()`.

* svg/animations/begin-event-syncbase-expected.svg: Added.
* svg/animations/begin-event-syncbase.svg: Added.

Test for the newly supported `beginEvent` event used as a syncbase value in a
timing attribute.

* svg/animations/end-event-attribute-expected.svg:
* svg/animations/end-event-attribute.svg:
* svg/animations/end-event-script-expected.svg:
* svg/animations/end-event-script.svg:
* svg/animations/end-event-syncbase-expected.svg:
* svg/animations/end-event-syncbase.svg:

Cleaned up tests previously added to remove unnecessary XLink namespace, DOCTYPE and
processing instruction to match new tests.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (191493 => 191494)


--- trunk/LayoutTests/ChangeLog	2015-10-23 08:10:24 UTC (rev 191493)
+++ trunk/LayoutTests/ChangeLog	2015-10-23 08:39:01 UTC (rev 191494)
@@ -1,3 +1,36 @@
+2015-10-23  Antoine Quint  <[email protected]>
+
+        Support for SVG `beginEvent` event and `onbegin` attribute
+        https://bugs.webkit.org/show_bug.cgi?id=150442
+
+        Reviewed by Dean Jackson.
+
+        * svg/animations/begin-event-attribute-expected.svg: Added.
+        * svg/animations/begin-event-attribute.svg: Added.
+
+        Test for the newly supported `onbegin` attribute.
+
+        * svg/animations/begin-event-script-expected.svg: Added.
+        * svg/animations/begin-event-script.svg: Added.
+
+        Test for the newly supported `beginEvent` event handled via `addEventListener()`.
+
+        * svg/animations/begin-event-syncbase-expected.svg: Added.
+        * svg/animations/begin-event-syncbase.svg: Added.
+
+        Test for the newly supported `beginEvent` event used as a syncbase value in a
+        timing attribute.
+
+        * svg/animations/end-event-attribute-expected.svg:
+        * svg/animations/end-event-attribute.svg:
+        * svg/animations/end-event-script-expected.svg:
+        * svg/animations/end-event-script.svg:
+        * svg/animations/end-event-syncbase-expected.svg:
+        * svg/animations/end-event-syncbase.svg:
+
+        Cleaned up tests previously added to remove unnecessary XLink namespace, DOCTYPE and
+        processing instruction to match new tests.
+
 2015-10-23  Hyemi Shin  <[email protected]>
 
         ConvolverNode.buffer must have same sample rate as the AudioContext

Added: trunk/LayoutTests/svg/animations/begin-event-attribute-expected.svg (0 => 191494)


--- trunk/LayoutTests/svg/animations/begin-event-attribute-expected.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/begin-event-attribute-expected.svg	2015-10-23 08:39:01 UTC (rev 191494)
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+    <rect x="0" y="0" width="50" height="50" fill="green" />
+</svg>
\ No newline at end of file

Added: trunk/LayoutTests/svg/animations/begin-event-attribute.svg (0 => 191494)


--- trunk/LayoutTests/svg/animations/begin-event-attribute.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/begin-event-attribute.svg	2015-10-23 08:39:01 UTC (rev 191494)
@@ -0,0 +1,19 @@
+<svg _onload_="loaded()" xmlns="http://www.w3.org/2000/svg">
+<rect id="rect" x="0" y="0" width="50" height="50" fill="red">
+    <animate id="anim" attributeName="visibility" to="visible" begin="1s" end="2s" _onbegin_="handleBeginEvent()" />
+</rect>
+<script>
+    if (window.testRunner)
+        testRunner.waitUntilDone();
+
+    function handleBeginEvent(event) {
+        document.getElementById("rect").setAttribute("fill", "green");
+        testRunner.notifyDone();
+    }
+
+    function loaded() {
+        document.documentElement.setCurrentTime(1);
+    }
+
+</script>
+</svg>
\ No newline at end of file

Added: trunk/LayoutTests/svg/animations/begin-event-script-expected.svg (0 => 191494)


--- trunk/LayoutTests/svg/animations/begin-event-script-expected.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/begin-event-script-expected.svg	2015-10-23 08:39:01 UTC (rev 191494)
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg">
+    <rect x="0" y="0" width="50" height="50" fill="green" />
+</svg>
\ No newline at end of file

Added: trunk/LayoutTests/svg/animations/begin-event-script.svg (0 => 191494)


--- trunk/LayoutTests/svg/animations/begin-event-script.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/begin-event-script.svg	2015-10-23 08:39:01 UTC (rev 191494)
@@ -0,0 +1,19 @@
+<svg _onload_="loaded()" xmlns="http://www.w3.org/2000/svg">
+<rect id="rect" x="0" y="0" width="50" height="50" fill="red">
+    <animate id="anim" attributeName="visibility" to="visible" begin="1s" end="2s" />
+</rect>
+<script>
+    if (window.testRunner)
+        testRunner.waitUntilDone();
+
+    function loaded() {
+        document.getElementById("anim").addEventListener("beginEvent", function(event) {
+            document.getElementById("rect").setAttribute("fill", "green");
+            testRunner.notifyDone();
+        });
+
+        document.documentElement.setCurrentTime(1);
+    }
+
+</script>
+</svg>
\ No newline at end of file

Added: trunk/LayoutTests/svg/animations/begin-event-syncbase-expected.svg (0 => 191494)


--- trunk/LayoutTests/svg/animations/begin-event-syncbase-expected.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/begin-event-syncbase-expected.svg	2015-10-23 08:39:01 UTC (rev 191494)
@@ -0,0 +1,3 @@
+<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>
\ No newline at end of file

Added: trunk/LayoutTests/svg/animations/begin-event-syncbase.svg (0 => 191494)


--- trunk/LayoutTests/svg/animations/begin-event-syncbase.svg	                        (rev 0)
+++ trunk/LayoutTests/svg/animations/begin-event-syncbase.svg	2015-10-23 08:39:01 UTC (rev 191494)
@@ -0,0 +1,17 @@
+<svg _onload_="loaded()" xmlns="http://www.w3.org/2000/svg">
+<rect x="0" y="0" width="50" height="50" fill="red">
+    <animate id="anim" attributeName="visibility" to="visible" begin="1s" end="2s" />
+    <set attributeName="fill" to="green" begin="anim.beginEvent" />
+</rect>
+<script>
+    if (window.testRunner)
+        testRunner.waitUntilDone();
+
+    function loaded() {
+        document.documentElement.setCurrentTime(1);
+
+        if (window.testRunner)
+            setTimeout(function() {testRunner.notifyDone();}, 100);
+    }
+</script>
+</svg>
\ No newline at end of file

Modified: trunk/LayoutTests/svg/animations/end-event-attribute-expected.svg (191493 => 191494)


--- trunk/LayoutTests/svg/animations/end-event-attribute-expected.svg	2015-10-23 08:10:24 UTC (rev 191493)
+++ trunk/LayoutTests/svg/animations/end-event-attribute-expected.svg	2015-10-23 08:39:01 UTC (rev 191494)
@@ -1,5 +1,3 @@
-<?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">
+<svg xmlns="http://www.w3.org/2000/svg">
     <rect x="0" y="0" width="50" height="50" fill="green" />
 </svg>
\ No newline at end of file

Modified: trunk/LayoutTests/svg/animations/end-event-attribute.svg (191493 => 191494)


--- trunk/LayoutTests/svg/animations/end-event-attribute.svg	2015-10-23 08:10:24 UTC (rev 191493)
+++ trunk/LayoutTests/svg/animations/end-event-attribute.svg	2015-10-23 08:39:01 UTC (rev 191494)
@@ -1,6 +1,4 @@
-<?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">
+<svg _onload_="loaded()" xmlns="http://www.w3.org/2000/svg">
 <rect id="rect" x="0" y="0" width="50" height="50" fill="red">
     <animate id="anim" attributeName="visibility" to="visible" begin="0s" end="2s" _onend_="handleEndEvent()" />
 </rect>

Modified: trunk/LayoutTests/svg/animations/end-event-script-expected.svg (191493 => 191494)


--- trunk/LayoutTests/svg/animations/end-event-script-expected.svg	2015-10-23 08:10:24 UTC (rev 191493)
+++ trunk/LayoutTests/svg/animations/end-event-script-expected.svg	2015-10-23 08:39:01 UTC (rev 191494)
@@ -1,5 +1,3 @@
-<?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">
+<svg xmlns="http://www.w3.org/2000/svg">
     <rect x="0" y="0" width="50" height="50" fill="green" />
 </svg>
\ No newline at end of file

Modified: trunk/LayoutTests/svg/animations/end-event-script.svg (191493 => 191494)


--- trunk/LayoutTests/svg/animations/end-event-script.svg	2015-10-23 08:10:24 UTC (rev 191493)
+++ trunk/LayoutTests/svg/animations/end-event-script.svg	2015-10-23 08:39:01 UTC (rev 191494)
@@ -1,6 +1,4 @@
-<?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">
+<svg _onload_="loaded()" xmlns="http://www.w3.org/2000/svg">
 <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>

Modified: trunk/LayoutTests/svg/animations/end-event-syncbase-expected.svg (191493 => 191494)


--- trunk/LayoutTests/svg/animations/end-event-syncbase-expected.svg	2015-10-23 08:10:24 UTC (rev 191493)
+++ trunk/LayoutTests/svg/animations/end-event-syncbase-expected.svg	2015-10-23 08:39:01 UTC (rev 191494)
@@ -1,5 +1,3 @@
-<?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">
+<svg xmlns="http://www.w3.org/2000/svg">
     <rect x="0" y="0" width="50" height="50" fill="green" />
 </svg>
\ No newline at end of file

Modified: trunk/LayoutTests/svg/animations/end-event-syncbase.svg (191493 => 191494)


--- trunk/LayoutTests/svg/animations/end-event-syncbase.svg	2015-10-23 08:10:24 UTC (rev 191493)
+++ trunk/LayoutTests/svg/animations/end-event-syncbase.svg	2015-10-23 08:39:01 UTC (rev 191494)
@@ -1,6 +1,4 @@
-<?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">
+<svg _onload_="loaded()" xmlns="http://www.w3.org/2000/svg">
 <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" />

Modified: trunk/Source/WebCore/ChangeLog (191493 => 191494)


--- trunk/Source/WebCore/ChangeLog	2015-10-23 08:10:24 UTC (rev 191493)
+++ trunk/Source/WebCore/ChangeLog	2015-10-23 08:39:01 UTC (rev 191494)
@@ -1,3 +1,28 @@
+2015-10-23  Antoine Quint  <[email protected]>
+
+        Support for SVG `beginEvent` event and `onbegin` attribute
+        https://bugs.webkit.org/show_bug.cgi?id=150442
+
+        Reviewed by Dean Jackson.
+
+        Add support for the SVG `beginEvent` event, which is fired as an SVG timing element enters its active interval.
+        Also add support for the SVG `onbegin` attribute which allows the definition of a JS event listener declaratively
+        for the SVG `beginEvent` event.
+
+        Tests: svg/animations/begin-event-attribute.svg
+               svg/animations/begin-event-script.svg
+               svg/animations/begin-event-syncbase.svg
+
+        * dom/EventNames.h:
+        * svg/animation/SVGSMILElement.cpp:
+        (WebCore::smilBeginEventSender):
+        (WebCore::smilEndEventSender):
+        (WebCore::SVGSMILElement::~SVGSMILElement):
+        (WebCore::SVGSMILElement::parseAttribute):
+        (WebCore::SVGSMILElement::progress):
+        (WebCore::SVGSMILElement::dispatchPendingEvent):
+        * svg/svgattrs.in:
+
 2015-10-23  Hyemi Shin  <[email protected]>
 
         ConvolverNode.buffer must have same sample-rate as the AudioContext 

Modified: trunk/Source/WebCore/dom/EventNames.h (191493 => 191494)


--- trunk/Source/WebCore/dom/EventNames.h	2015-10-23 08:10:24 UTC (rev 191493)
+++ trunk/Source/WebCore/dom/EventNames.h	2015-10-23 08:39:01 UTC (rev 191494)
@@ -58,6 +58,7 @@
     macro(beforeload) \
     macro(beforepaste) \
     macro(beforeunload) \
+    macro(beginEvent) \
     macro(blocked) \
     macro(blur) \
     macro(boundary) \

Modified: trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp (191493 => 191494)


--- trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp	2015-10-23 08:10:24 UTC (rev 191493)
+++ trunk/Source/WebCore/svg/animation/SVGSMILElement.cpp	2015-10-23 08:39:01 UTC (rev 191494)
@@ -47,9 +47,15 @@
 
 namespace WebCore {
 
+static SMILEventSender& smilBeginEventSender()
+{
+    static NeverDestroyed<SMILEventSender> sender(eventNames().beginEventEvent);
+    return sender;
+}
+
 static SMILEventSender& smilEndEventSender()
 {
-    static NeverDestroyed<SMILEventSender> sender("endEvent");
+    static NeverDestroyed<SMILEventSender> sender(eventNames().endEventEvent);
     return sender;
 }
 
@@ -142,6 +148,7 @@
 SVGSMILElement::~SVGSMILElement()
 {
     clearResourceReferences();
+    smilBeginEventSender().cancelEvent(*this);
     smilEndEventSender().cancelEvent(*this);
     disconnectConditions();
     if (m_timeContainer && m_targetElement && hasValidAttributeName())
@@ -480,9 +487,11 @@
         parseBeginOrEnd(value.string(), End);
         if (inDocument())
             connectConditions();
-    } else if (name == SVGNames::onendAttr) {
+    } else if (name == SVGNames::onendAttr)
         setAttributeEventListener(eventNames().endEventEvent, name, value);
-    } else
+    else if (name == SVGNames::onbeginAttr)
+        setAttributeEventListener(eventNames().beginEventEvent, name, value);
+    else
         SVGElement::parseAttribute(name, value);
 }
 
@@ -1118,7 +1127,8 @@
         endedActiveInterval();
         if (m_activeState != Frozen)
             clearAnimatedType(m_targetElement);
-    }
+    } else if (oldActiveState != Active && m_activeState == Active)
+        smilBeginEventSender().dispatchEventSoon(*this);
 
     // Triggering all the pending events if the animation timeline is changed.
     if (seekToTime) {
@@ -1203,7 +1213,7 @@
 
 void SVGSMILElement::dispatchPendingEvent(SMILEventSender* eventSender)
 {
-    ASSERT(eventSender == &smilEndEventSender());
+    ASSERT(eventSender == &smilBeginEventSender() || eventSender == &smilEndEventSender());
     const AtomicString& eventType = eventSender->eventType();
     dispatchEvent(Event::create(eventType, false, false));
 }

Modified: trunk/Source/WebCore/svg/svgattrs.in (191493 => 191494)


--- trunk/Source/WebCore/svg/svgattrs.in	2015-10-23 08:10:24 UTC (rev 191493)
+++ trunk/Source/WebCore/svg/svgattrs.in	2015-10-23 08:39:01 UTC (rev 191494)
@@ -128,6 +128,7 @@
 name
 numOctaves
 offset
+onbegin
 onend
 onzoom
 opacity
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to