Title: [179785] trunk
Revision
179785
Author
[email protected]
Date
2015-02-07 15:17:26 -0800 (Sat, 07 Feb 2015)

Log Message

Source/WebCore:
Stop dispatching events to with SVGElementInstance objects as their targets
https://bugs.webkit.org/show_bug.cgi?id=141108

Reviewed by Anders Carlsson.

Test: svg/custom/use-event-retargeting.html

* dom/EventDispatcher.cpp:
(WebCore::eventTargetRespectingTargetRules): Replaced the code that retargeted
events at SVGElementInstance objects with code that retargets them at the use
element instead. Also wrote the code in a simpler way.

LayoutTests:
Stop dispatching events with SVGElementInstance objects as their targets
https://bugs.webkit.org/show_bug.cgi?id=141108

Reviewed by Anders Carlsson.

Many tests are no longer relevant once we aren't doing this any more.

* platform/gtk/svg/custom/use-instanceRoot-event-bubbling-expected.png: Removed.
* platform/gtk/svg/custom/use-instanceRoot-modifications-expected.png: Removed.
* platform/gtk/svg/custom/use-instanceRoot-modifications-expected.txt: Removed.
* platform/ios-sim-deprecated/svg/custom/use-instanceRoot-modifications-expected.txt: Removed.
* platform/ios-simulator/svg/custom/use-instanceRoot-modifications-expected.txt: Removed.
* platform/mac-mountainlion/svg/custom/use-instanceRoot-modifications-expected.txt: Removed.
* platform/mac/svg/custom/use-instanceRoot-event-bubbling-expected.png: Removed.
* platform/mac/svg/custom/use-instanceRoot-modifications-expected.png: Removed.
* platform/mac/svg/custom/use-instanceRoot-modifications-expected.txt: Removed.
* svg/custom/use-instanceRoot-modifications.svg: Removed.
* svg/custom/use-instanceRoot-with-use-removed-expected.txt: Removed.
* svg/custom/use-instanceRoot-with-use-removed.svg: Removed.

* svg/custom/resources/use-instanceRoot-event-bubbling.js: Updated this test to expect
the events to be dispatched with the SVGUseElement as the target. I talked this over with
Sam Weinig and we decided this is good behavior for now, and it almost matches what the
spec says. Might be worth refining later.
* svg/custom/use-instanceRoot-event-bubbling-expected.txt: Updated expected results.
* svg/custom/use-instanceRoot-event-bubbling.xhtml: Tweaked the test a little. It still
could use improvement; it's like half a "repaint test", which is strange.

* svg/custom/use-event-retargeting-expected.txt: Added. Got this test from Blink.
* svg/custom/use-event-retargeting.html: Added. Ditto.

* svg/custom/use-events-crash.svg: Added some more events, a second click, so that we
don't hang with the context menu up when running this. Also converted line endings to
use LF instead of CRLF.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (179784 => 179785)


--- trunk/LayoutTests/ChangeLog	2015-02-07 22:48:36 UTC (rev 179784)
+++ trunk/LayoutTests/ChangeLog	2015-02-07 23:17:26 UTC (rev 179785)
@@ -1,3 +1,40 @@
+2015-02-07  Darin Adler  <[email protected]>
+
+        Stop dispatching events with SVGElementInstance objects as their targets
+        https://bugs.webkit.org/show_bug.cgi?id=141108
+
+        Reviewed by Anders Carlsson.
+
+        Many tests are no longer relevant once we aren't doing this any more.
+
+        * platform/gtk/svg/custom/use-instanceRoot-event-bubbling-expected.png: Removed.
+        * platform/gtk/svg/custom/use-instanceRoot-modifications-expected.png: Removed.
+        * platform/gtk/svg/custom/use-instanceRoot-modifications-expected.txt: Removed.
+        * platform/ios-sim-deprecated/svg/custom/use-instanceRoot-modifications-expected.txt: Removed.
+        * platform/ios-simulator/svg/custom/use-instanceRoot-modifications-expected.txt: Removed.
+        * platform/mac-mountainlion/svg/custom/use-instanceRoot-modifications-expected.txt: Removed.
+        * platform/mac/svg/custom/use-instanceRoot-event-bubbling-expected.png: Removed.
+        * platform/mac/svg/custom/use-instanceRoot-modifications-expected.png: Removed.
+        * platform/mac/svg/custom/use-instanceRoot-modifications-expected.txt: Removed.
+        * svg/custom/use-instanceRoot-modifications.svg: Removed.
+        * svg/custom/use-instanceRoot-with-use-removed-expected.txt: Removed.
+        * svg/custom/use-instanceRoot-with-use-removed.svg: Removed.
+
+        * svg/custom/resources/use-instanceRoot-event-bubbling.js: Updated this test to expect
+        the events to be dispatched with the SVGUseElement as the target. I talked this over with
+        Sam Weinig and we decided this is good behavior for now, and it almost matches what the
+        spec says. Might be worth refining later.
+        * svg/custom/use-instanceRoot-event-bubbling-expected.txt: Updated expected results.
+        * svg/custom/use-instanceRoot-event-bubbling.xhtml: Tweaked the test a little. It still
+        could use improvement; it's like half a "repaint test", which is strange.
+
+        * svg/custom/use-event-retargeting-expected.txt: Added. Got this test from Blink.
+        * svg/custom/use-event-retargeting.html: Added. Ditto.
+
+        * svg/custom/use-events-crash.svg: Added some more events, a second click, so that we
+        don't hang with the context menu up when running this. Also converted line endings to
+        use LF instead of CRLF.
+
 2015-02-07  Alexey Proskuryakov  <[email protected]>
 
         REGRESSION (OS X 10.10.2): http/tests/media/video-query-url.html frequently times out

Deleted: trunk/LayoutTests/platform/gtk/svg/custom/use-instanceRoot-event-bubbling-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/gtk/svg/custom/use-instanceRoot-modifications-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/gtk/svg/custom/use-instanceRoot-modifications-expected.txt (179784 => 179785)


--- trunk/LayoutTests/platform/gtk/svg/custom/use-instanceRoot-modifications-expected.txt	2015-02-07 22:48:36 UTC (rev 179784)
+++ trunk/LayoutTests/platform/gtk/svg/custom/use-instanceRoot-modifications-expected.txt	2015-02-07 23:17:26 UTC (rev 179785)
@@ -1,19 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderSVGRoot {svg} at (45,40) size 330x107
-    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
-      RenderSVGContainer {g} at (0,0) size 125x30
-        RenderSVGRect {rect} at (0,0) size 125x25 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-        RenderSVGEllipse {circle} at (40,0) size 40x30 [opacity=0.80] [fill={[type=SOLID] [color=#008000]}] [cx=30.00] [cy=5.00] [r=10.00]
-    RenderSVGContainer {use} at (45,40) size 130x40 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
-      RenderSVGContainer {g} at (45,40) size 130x40
-        RenderSVGRect {rect} at (45,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-        RenderSVGEllipse {circle} at (90,40) size 40x40 [opacity=0.80] [fill={[type=SOLID] [color=#008000]}] [cx=30.00] [cy=5.00] [r=10.00]
-    RenderSVGContainer {use} at (245,40) size 130x40 [transform={m=((1.00,0.00)(0.00,1.00)) t=(125.00,25.00)}]
-      RenderSVGContainer {g} at (245,40) size 130x40
-        RenderSVGRect {rect} at (245,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-        RenderSVGEllipse {circle} at (290,40) size 40x40 [opacity=0.80] [fill={[type=SOLID] [color=#008000]}] [cx=30.00] [cy=5.00] [r=10.00]
-    RenderSVGText {text} at (70,55) size 78x19 contains 1 chunk(s)
-      RenderSVGInlineText {#text} at (0,0) size 78x18
-        chunk 1 text run 1 at (70.00,70.00) startOffset 0 endOffset 12 width 77.50: "Test passed."

Deleted: trunk/LayoutTests/platform/ios-sim-deprecated/svg/custom/use-instanceRoot-modifications-expected.txt (179784 => 179785)


--- trunk/LayoutTests/platform/ios-sim-deprecated/svg/custom/use-instanceRoot-modifications-expected.txt	2015-02-07 22:48:36 UTC (rev 179784)
+++ trunk/LayoutTests/platform/ios-sim-deprecated/svg/custom/use-instanceRoot-modifications-expected.txt	2015-02-07 23:17:26 UTC (rev 179785)
@@ -1,19 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderSVGRoot {svg} at (45,40) size 330x107
-    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
-      RenderSVGContainer {g} at (0,0) size 125x30
-        RenderSVGRect {rect} at (0,0) size 125x25 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-        RenderSVGEllipse {circle} at (40,0) size 40x30 [opacity=0.80] [fill={[type=SOLID] [color=#008000]}] [cx=30.00] [cy=5.00] [r=10.00]
-    RenderSVGContainer {use} at (45,40) size 130x40 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
-      RenderSVGContainer {g} at (45,40) size 130x40
-        RenderSVGRect {rect} at (45,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-        RenderSVGEllipse {circle} at (90,40) size 40x40 [opacity=0.80] [fill={[type=SOLID] [color=#008000]}] [cx=30.00] [cy=5.00] [r=10.00]
-    RenderSVGContainer {use} at (245,40) size 130x40 [transform={m=((1.00,0.00)(0.00,1.00)) t=(125.00,25.00)}]
-      RenderSVGContainer {g} at (245,40) size 130x40
-        RenderSVGRect {rect} at (245,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-        RenderSVGEllipse {circle} at (290,40) size 40x40 [opacity=0.80] [fill={[type=SOLID] [color=#008000]}] [cx=30.00] [cy=5.00] [r=10.00]
-    RenderSVGText {text} at (70,55) size 79x19 contains 1 chunk(s)
-      RenderSVGInlineText {#text} at (0,0) size 79x18
-        chunk 1 text run 1 at (70.00,70.00) startOffset 0 endOffset 12 width 78.20: "Test passed."

Deleted: trunk/LayoutTests/platform/ios-simulator/svg/custom/use-instanceRoot-modifications-expected.txt (179784 => 179785)


--- trunk/LayoutTests/platform/ios-simulator/svg/custom/use-instanceRoot-modifications-expected.txt	2015-02-07 22:48:36 UTC (rev 179784)
+++ trunk/LayoutTests/platform/ios-simulator/svg/custom/use-instanceRoot-modifications-expected.txt	2015-02-07 23:17:26 UTC (rev 179785)
@@ -1,19 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderSVGRoot {svg} at (45,40) size 330x107
-    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
-      RenderSVGContainer {g} at (0,0) size 125x30
-        RenderSVGRect {rect} at (0,0) size 125x25 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-        RenderSVGEllipse {circle} at (40,0) size 40x30 [opacity=0.80] [fill={[type=SOLID] [color=#008000]}] [cx=30.00] [cy=5.00] [r=10.00]
-    RenderSVGContainer {use} at (45,40) size 130x40 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
-      RenderSVGContainer {g} at (45,40) size 130x40
-        RenderSVGRect {rect} at (45,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-        RenderSVGEllipse {circle} at (90,40) size 40x40 [opacity=0.80] [fill={[type=SOLID] [color=#008000]}] [cx=30.00] [cy=5.00] [r=10.00]
-    RenderSVGContainer {use} at (245,40) size 130x40 [transform={m=((1.00,0.00)(0.00,1.00)) t=(125.00,25.00)}]
-      RenderSVGContainer {g} at (245,40) size 130x40
-        RenderSVGRect {rect} at (245,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-        RenderSVGEllipse {circle} at (290,40) size 40x40 [opacity=0.80] [fill={[type=SOLID] [color=#008000]}] [cx=30.00] [cy=5.00] [r=10.00]
-    RenderSVGText {text} at (70,55) size 79x19 contains 1 chunk(s)
-      RenderSVGInlineText {#text} at (0,0) size 79x18
-        chunk 1 text run 1 at (70.00,70.00) startOffset 0 endOffset 12 width 78.20: "Test passed."

Deleted: trunk/LayoutTests/platform/mac/svg/custom/use-instanceRoot-event-bubbling-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/mac/svg/custom/use-instanceRoot-modifications-expected.png


(Binary files differ)

Deleted: trunk/LayoutTests/platform/mac/svg/custom/use-instanceRoot-modifications-expected.txt (179784 => 179785)


--- trunk/LayoutTests/platform/mac/svg/custom/use-instanceRoot-modifications-expected.txt	2015-02-07 22:48:36 UTC (rev 179784)
+++ trunk/LayoutTests/platform/mac/svg/custom/use-instanceRoot-modifications-expected.txt	2015-02-07 23:17:26 UTC (rev 179785)
@@ -1,19 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderSVGRoot {svg} at (45,40) size 330x108
-    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
-      RenderSVGContainer {g} at (0,0) size 125x30
-        RenderSVGRect {rect} at (0,0) size 125x25 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-        RenderSVGEllipse {circle} at (40,0) size 40x30 [opacity=0.80] [fill={[type=SOLID] [color=#008000]}] [cx=30.00] [cy=5.00] [r=10.00]
-    RenderSVGContainer {use} at (45,40) size 130x40 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
-      RenderSVGContainer {g} at (45,40) size 130x40
-        RenderSVGRect {rect} at (45,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-        RenderSVGEllipse {circle} at (90,40) size 40x40 [opacity=0.80] [fill={[type=SOLID] [color=#008000]}] [cx=30.00] [cy=5.00] [r=10.00]
-    RenderSVGContainer {use} at (245,40) size 130x40 [transform={m=((1.00,0.00)(0.00,1.00)) t=(125.00,25.00)}]
-      RenderSVGContainer {g} at (245,40) size 130x40
-        RenderSVGRect {rect} at (245,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-        RenderSVGEllipse {circle} at (290,40) size 40x40 [opacity=0.80] [fill={[type=SOLID] [color=#008000]}] [cx=30.00] [cy=5.00] [r=10.00]
-    RenderSVGText {text} at (70,55) size 79x19 contains 1 chunk(s)
-      RenderSVGInlineText {#text} at (0,0) size 79x19
-        chunk 1 text run 1 at (70.00,70.00) startOffset 0 endOffset 12 width 78.20: "Test passed."

Deleted: trunk/LayoutTests/platform/mac-mountainlion/svg/custom/use-instanceRoot-modifications-expected.txt (179784 => 179785)


--- trunk/LayoutTests/platform/mac-mountainlion/svg/custom/use-instanceRoot-modifications-expected.txt	2015-02-07 22:48:36 UTC (rev 179784)
+++ trunk/LayoutTests/platform/mac-mountainlion/svg/custom/use-instanceRoot-modifications-expected.txt	2015-02-07 23:17:26 UTC (rev 179785)
@@ -1,19 +0,0 @@
-layer at (0,0) size 800x600
-  RenderView at (0,0) size 800x600
-layer at (0,0) size 800x600
-  RenderSVGRoot {svg} at (45,40) size 330x108
-    RenderSVGHiddenContainer {defs} at (0,0) size 0x0
-      RenderSVGContainer {g} at (0,0) size 125x30
-        RenderSVGRect {rect} at (0,0) size 125x25 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-        RenderSVGEllipse {circle} at (40,0) size 40x30 [opacity=0.80] [fill={[type=SOLID] [color=#008000]}] [cx=30.00] [cy=5.00] [r=10.00]
-    RenderSVGContainer {use} at (45,40) size 130x40 [transform={m=((1.00,0.00)(0.00,1.00)) t=(25.00,25.00)}]
-      RenderSVGContainer {g} at (45,40) size 130x40
-        RenderSVGRect {rect} at (45,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-        RenderSVGEllipse {circle} at (90,40) size 40x40 [opacity=0.80] [fill={[type=SOLID] [color=#008000]}] [cx=30.00] [cy=5.00] [r=10.00]
-    RenderSVGContainer {use} at (245,40) size 130x40 [transform={m=((1.00,0.00)(0.00,1.00)) t=(125.00,25.00)}]
-      RenderSVGContainer {g} at (245,40) size 130x40
-        RenderSVGRect {rect} at (245,45) size 130x30 [stroke={[type=SOLID] [color=#000080] [stroke width=5.00]}] [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=60.00] [height=10.00]
-        RenderSVGEllipse {circle} at (290,40) size 40x40 [opacity=0.80] [fill={[type=SOLID] [color=#008000]}] [cx=30.00] [cy=5.00] [r=10.00]
-    RenderSVGText {text} at (70,55) size 78x19 contains 1 chunk(s)
-      RenderSVGInlineText {#text} at (0,0) size 78x19
-        chunk 1 text run 1 at (70.00,70.00) startOffset 0 endOffset 12 width 77.50: "Test passed."

Modified: trunk/LayoutTests/svg/custom/resources/use-instanceRoot-event-bubbling.js (179784 => 179785)


--- trunk/LayoutTests/svg/custom/resources/use-instanceRoot-event-bubbling.js	2015-02-07 22:48:36 UTC (rev 179784)
+++ trunk/LayoutTests/svg/custom/resources/use-instanceRoot-event-bubbling.js	2015-02-07 23:17:26 UTC (rev 179785)
@@ -1,7 +1,9 @@
-description("Tests wheter SVG event bubbling works accross shadow trees.");
+description("Tests whether SVG event bubbling works across shadow trees.");
 
-if (window.testRunner)
+if (window.testRunner) {
     testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+}
 
 var svgNS = "http://www.w3.org/2000/svg";
 var xhtmlNS = "http://www.w3.org/1999/xhtml";
@@ -18,8 +20,8 @@
 }
 
 function eventHandler(evt, label) {
-    var targetId = evt.target.correspondingElement ? evt.target.correspondingElement.id : evt.target.id;
-    var curTargetId = evt.currentTarget.correspondingElement ? evt.currentTarget.correspondingElement.id : evt.currentTarget.id;
+    var targetId = evt.target.id;
+    var curTargetId = evt.currentTarget.id;
 
     var phaseString = "";
     switch (evt.eventPhase) {
@@ -41,10 +43,7 @@
 
 function finishTest()
 {
-    successfullyParsed = true;
-
     document.getElementById("rectParent").setAttribute("fill", "green");
-    shouldBeTrue("successfullyParsed");
     debug('<br /><span class="pass">TEST COMPLETE</span>');
 
     if (window.testRunner)
@@ -59,22 +58,22 @@
     switch (counter) {
     case 1:
         rect._onclick_ = function(evt) { eventHandler(evt, 1); };
-        expected[0] = "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rect)";
+        expected[0] = "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)";
         testListeners();
         break;
     case 2:
         rectContainer.addEventListener("click", function(evt) { eventHandler(evt, 2) }, false);
-        expected[1] = "[EventHandler 2] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rectParent)";    
+        expected[1] = "[EventHandler 2] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)";
         testListeners();
         break;
     case 3:
         use.setAttribute("onclick", "eventHandler(evt, 3)");
-        expected[2] = "[EventHandler 3] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGUseElement] (id: use)";
+        expected[2] = "[EventHandler 3] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)";
         testListeners();
         break;
     case 4:
         useContainer._onclick_ = function(evt) { eventHandler(evt, 4) };
-        expected[3] = "[EventHandler 4] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGGElement] (id: useParent)";
+        expected[3] = "[EventHandler 4] type: click phase: BUBBLING target: [object SVGUseElement] (id: use) currentTarget: [object SVGGElement] (id: useParent)";
         testListeners();
         break;
     }
@@ -106,7 +105,7 @@
 
 var rect = document.createElementNS(svgNS, "rect");
 rect.id = "rect";
-rect.style.fill = "red";
+rect.style.fill = "blue";
 rect.width.baseVal.value = 100;
 rect.height.baseVal.value = 100;
 rectContainer.appendChild(rect);
@@ -121,8 +120,4 @@
 use.href.baseVal = "#rectParent";
 useContainer.appendChild(use);
 
-function repaintTest() {
-    if (window.testRunner)
-        testRunner.waitUntilDone();
-    nextTest();
-}
+nextTest();

Added: trunk/LayoutTests/svg/custom/use-event-retargeting-expected.txt (0 => 179785)


--- trunk/LayoutTests/svg/custom/use-event-retargeting-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/use-event-retargeting-expected.txt	2015-02-07 23:17:26 UTC (rev 179785)
@@ -0,0 +1,3 @@
+PASS - [object SVGUseElement] was clicked.
+PASS - [object HTMLDivElement] was clicked.
+
Property changes on: trunk/LayoutTests/svg/custom/use-event-retargeting-expected.txt
___________________________________________________________________

Added: svn:eol-style

Added: trunk/LayoutTests/svg/custom/use-event-retargeting.html (0 => 179785)


--- trunk/LayoutTests/svg/custom/use-event-retargeting.html	                        (rev 0)
+++ trunk/LayoutTests/svg/custom/use-event-retargeting.html	2015-02-07 23:17:26 UTC (rev 179785)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<head>
+    <style>
+        * { margin: 0; padding: 0; }
+        svg { width: 200px; height: 100px; }
+        a div { width: 200px; height: 100px; background-color: yellow; }
+    </style>
+</head>
+<body>
+    <a href="" class="icon-link">
+        <svg>
+            <defs>
+                <rect id="blue-rectangle" width="200" height="100" style="fill:#00f;" />
+            </defs>
+            <use xlink:href=""
+        </svg>
+        <div></div>
+    </a>
+
+    <div class="log"></div>
+
+    <script>
+        var expected = null;
+
+        if (window.testRunner)
+            testRunner.dumpAsText();
+
+        function clickAt(x, y, expectedElement)
+        {
+            expected = expectedElement;
+            if (window.eventSender) {
+                eventSender.mouseMoveTo(x, y);
+                eventSender.mouseDown();
+                eventSender.mouseUp();
+            }
+            expected = null;
+        }
+
+        document.querySelector("a").addEventListener("click", function(event) {
+            var result = "";
+            if (event.target == expected)
+                result = "PASS - " + event.target + " was clicked.";
+            else
+                result = "FAIL - expected " + expected + " but got " + event.target + ".";
+            document.querySelector('.log').innerHTML += result + '<br />';
+            event.preventDefault();
+        }, false);
+
+        clickAt(50, 50, document.querySelector("use"));
+        clickAt(50, 130, document.querySelector("a div"));
+    </script>
+</body>
Property changes on: trunk/LayoutTests/svg/custom/use-event-retargeting.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:eol-style

Modified: trunk/LayoutTests/svg/custom/use-events-crash.svg (179784 => 179785)


--- trunk/LayoutTests/svg/custom/use-events-crash.svg	2015-02-07 22:48:36 UTC (rev 179784)
+++ trunk/LayoutTests/svg/custom/use-events-crash.svg	2015-02-07 23:17:26 UTC (rev 179785)
@@ -1,35 +1,38 @@
-<?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" version="1.1" baseProfile="tiny" id="svg-root" width="480" height="360" viewBox="0 0 480 360" _onload_="test()">
-<script>
-function test()
-{
-    if (window.eventSender) {
-	eventSender.mouseMoveTo(370, 45);
-	eventSender.contextClick();
-    }
-}
-
-</script>
-
-    <g id="test-body-content">
-        <defs>
-            <g fill="red" stroke="yellow" stroke-width="3">
-                <rect id="usedRect" width="40" height="40"/>
-            </g>
-        </defs>
-        <g>
-            <g id="labels" transform="translate(330, 40)" font-size="12" text-anchor="end">
-                <text>Right-clicking on green box using a debug build</text>
-            </g>
-            <g id="labels" transform="translate(330, 54)" font-size="12" text-anchor="end">
-                <text>should not cause an assert (Bugzilla Bug 12580)</text>
-            </g>
-        </g>
-        <g transform="translate(350, 25)">
-            <use xlink:href="" fill="#0F0"/>
-        </g>
-    </g>
-
-</svg>
+<?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" version="1.1" baseProfile="tiny" id="svg-root" width="480" height="360" viewBox="0 0 480 360" _onload_="test()">
+<script>
+function test()
+{
+    if (window.eventSender) {
+	eventSender.mouseMoveTo(370, 45);
+	eventSender.contextClick();
+        eventSender.mouseUp();
+        eventSender.mouseDown();
+        eventSender.mouseUp();
+    }
+}
+
+</script>
+
+    <g id="test-body-content">
+        <defs>
+            <g fill="red" stroke="yellow" stroke-width="3">
+                <rect id="usedRect" width="40" height="40"/>
+            </g>
+        </defs>
+        <g>
+            <g id="labels" transform="translate(330, 40)" font-size="12" text-anchor="end">
+                <text>Right-clicking on green box using a debug build</text>
+            </g>
+            <g id="labels" transform="translate(330, 54)" font-size="12" text-anchor="end">
+                <text>should not cause an assert (Bugzilla Bug 12580)</text>
+            </g>
+        </g>
+        <g transform="translate(350, 25)">
+            <use xlink:href="" fill="#0F0"/>
+        </g>
+    </g>
+
+</svg>

Modified: trunk/LayoutTests/svg/custom/use-instanceRoot-event-bubbling-expected.txt (179784 => 179785)


--- trunk/LayoutTests/svg/custom/use-instanceRoot-event-bubbling-expected.txt	2015-02-07 22:48:36 UTC (rev 179784)
+++ trunk/LayoutTests/svg/custom/use-instanceRoot-event-bubbling-expected.txt	2015-02-07 23:17:26 UTC (rev 179785)
@@ -1,19 +1,18 @@
-Tests wheter SVG event bubbling works accross shadow trees.
+Tests whether SVG event bubbling works across shadow trees.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rect)"
-PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rect)"
-PASS msg is "[EventHandler 2] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rectParent)"
-PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rect)"
-PASS msg is "[EventHandler 2] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rectParent)"
-PASS msg is "[EventHandler 3] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGUseElement] (id: use)"
-PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rect)"
-PASS msg is "[EventHandler 2] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rectParent)"
-PASS msg is "[EventHandler 3] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGUseElement] (id: use)"
-PASS msg is "[EventHandler 4] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGGElement] (id: useParent)"
-PASS successfullyParsed is true
+PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
+PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
+PASS msg is "[EventHandler 2] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
+PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
+PASS msg is "[EventHandler 2] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
+PASS msg is "[EventHandler 3] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
+PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
+PASS msg is "[EventHandler 2] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
+PASS msg is "[EventHandler 3] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
+PASS msg is "[EventHandler 4] type: click phase: BUBBLING target: [object SVGUseElement] (id: use) currentTarget: [object SVGGElement] (id: useParent)"
 
 TEST COMPLETE
 

Modified: trunk/LayoutTests/svg/custom/use-instanceRoot-event-bubbling.xhtml (179784 => 179785)


--- trunk/LayoutTests/svg/custom/use-instanceRoot-event-bubbling.xhtml	2015-02-07 22:48:36 UTC (rev 179784)
+++ trunk/LayoutTests/svg/custom/use-instanceRoot-event-bubbling.xhtml	2015-02-07 23:17:26 UTC (rev 179785)
@@ -1,12 +1,11 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <script>window.enablePixelTesting = true;</script>
-<script src=""
-<script src=""
+<script src=""
 </head>
-<body _onload_="runRepaintTest()">
-<p id="description"></p>
-<div id="console"></div>
-<script src=""
+<body>
+<p id="description"/>
+<div id="console"/>
+<script src=""
 </body>
 </html>

Deleted: trunk/LayoutTests/svg/custom/use-instanceRoot-modifications.svg (179784 => 179785)


--- trunk/LayoutTests/svg/custom/use-instanceRoot-modifications.svg	2015-02-07 22:48:36 UTC (rev 179784)
+++ trunk/LayoutTests/svg/custom/use-instanceRoot-modifications.svg	2015-02-07 23:17:26 UTC (rev 179785)
@@ -1,38 +0,0 @@
-<?xml version="1.0" standalone="no"?>
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
-<svg viewBox="0 0 400 300" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
-<defs>
-    <g id="g">
-        <rect id="rect" stroke-width="5px" fill="red" stroke="navy" width="60" height="10"/>
-        <circle id="circle" opacity="0.5" fill="green" cx="30" cy="5" r="10"/>
-    </g>
-</defs>
-
-<use x="25" y="25" xlink:href=""
-<use x="125" y="25" xlink:href=""
-
-<text id="text" x="70" y="70">Test failed.</text>
-
-<script>
-function runInstanceRootTest() {
-    var useElement = document.getElementsByTagName("use")[1];
-    var element = document.getElementById("g");
-
-    // element.firstChild is a #text node! the next sibling gives the rect
-    var rect = element.firstChild.nextSibling;
-    if (rect != document.getElementById("rect"))
-        return;
-
-    // rect.nextSibling is a #text node! the next sibling gives the circle
-    var circle = rect.nextSibling.nextSibling;
-    if (circle != document.getElementById("circle"))
-        return;
-
-    rect.setAttribute("fill", "green");
-    circle.setAttribute("opacity", "0.8");
-
-    document.getElementById("text").firstChild.nodeValue = "Test passed.";
-}
-runInstanceRootTest();
-</script>
-</svg>

Deleted: trunk/LayoutTests/svg/custom/use-instanceRoot-with-use-removed-expected.txt (179784 => 179785)


--- trunk/LayoutTests/svg/custom/use-instanceRoot-with-use-removed-expected.txt	2015-02-07 22:48:36 UTC (rev 179784)
+++ trunk/LayoutTests/svg/custom/use-instanceRoot-with-use-removed-expected.txt	2015-02-07 23:17:26 UTC (rev 179785)
@@ -1 +0,0 @@
-PASS: Successfully removed use element.

Deleted: trunk/LayoutTests/svg/custom/use-instanceRoot-with-use-removed.svg (179784 => 179785)


--- trunk/LayoutTests/svg/custom/use-instanceRoot-with-use-removed.svg	2015-02-07 22:48:36 UTC (rev 179784)
+++ trunk/LayoutTests/svg/custom/use-instanceRoot-with-use-removed.svg	2015-02-07 23:17:26 UTC (rev 179785)
@@ -1,31 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
-<script>
-<![CDATA[
-if (window.testRunner) {
-    testRunner.dumpAsText();
-    testRunner.waitUntilDone();
-    gc = function(){window.GCController.collect()};
-} else if (!window.gc)
-    gc = function(){};
-
-window._onload_ = function(){
-    if (location.hash != "#2") {
-        if (location.hash)
-            location.hash = "#" + (parseInt(location.hash.slice(1)) + 1).toString();
-        else
-            location.hash = "#1";
-        document.getElementById("use1").parentElement.removeChild(document.getElementById("use1"));
-        gc();
-        setTimeout(function(){location.reload()},0);
-    } else {
-        document.getElementById("t1").appendChild(document.createTextNode("PASS: Successfully removed use element."));
-        if (window.testRunner)
-            testRunner.notifyDone();
-    }
-}
-//]]>
-</script>
-<g id="g1" />
-<use xlink:href="" id="use1" />
-<text x="20" y="20" fill="green" id="t1"></text>
-</svg>

Modified: trunk/Source/WebCore/ChangeLog (179784 => 179785)


--- trunk/Source/WebCore/ChangeLog	2015-02-07 22:48:36 UTC (rev 179784)
+++ trunk/Source/WebCore/ChangeLog	2015-02-07 23:17:26 UTC (rev 179785)
@@ -1,3 +1,17 @@
+2015-02-07  Darin Adler  <[email protected]>
+
+        Stop dispatching events to with SVGElementInstance objects as their targets
+        https://bugs.webkit.org/show_bug.cgi?id=141108
+
+        Reviewed by Anders Carlsson.
+
+        Test: svg/custom/use-event-retargeting.html
+
+        * dom/EventDispatcher.cpp:
+        (WebCore::eventTargetRespectingTargetRules): Replaced the code that retargeted
+        events at SVGElementInstance objects with code that retargets them at the use
+        element instead. Also wrote the code in a simpler way.
+
 2015-02-07  Jer Noble  <[email protected]>
 
         [Mac] Set -contentsScale on AVPlayerLayer to allow AVPlayer to select the appropriate HLS variant.

Modified: trunk/Source/WebCore/dom/EventDispatcher.cpp (179784 => 179785)


--- trunk/Source/WebCore/dom/EventDispatcher.cpp	2015-02-07 22:48:36 UTC (rev 179784)
+++ trunk/Source/WebCore/dom/EventDispatcher.cpp	2015-02-07 23:17:26 UTC (rev 179785)
@@ -206,25 +206,16 @@
 inline EventTarget& eventTargetRespectingTargetRules(Node& referenceNode)
 {
     if (is<PseudoElement>(referenceNode)) {
-        EventTarget* hostElement = downcast<PseudoElement>(referenceNode).hostElement();
-        ASSERT(hostElement);
-        return *hostElement;
+        ASSERT(downcast<PseudoElement>(referenceNode).hostElement());
+        return *downcast<PseudoElement>(referenceNode).hostElement();
     }
 
-    if (!referenceNode.isSVGElement() || !referenceNode.isInShadowTree())
-        return referenceNode;
+    // Events sent to elements inside an SVG use element's shadow tree go to the use element.
+    if (is<SVGElement>(referenceNode)) {
+        if (auto* useElement = downcast<SVGElement>(referenceNode).correspondingUseElement())
+            return *useElement;
+    }
 
-    // Spec: The event handling for the non-exposed tree works as if the referenced element had been textually included
-    // as a deeply cloned child of the 'use' element, except that events are dispatched to the SVGElementInstance objects
-    auto& rootNode = referenceNode.treeScope().rootNode();
-    Element* shadowHostElement = is<ShadowRoot>(rootNode) ? downcast<ShadowRoot>(rootNode).hostElement() : nullptr;
-    // At this time, SVG nodes are not supported in non-<use> shadow trees.
-    if (!shadowHostElement || !shadowHostElement->hasTagName(SVGNames::useTag))
-        return referenceNode;
-    SVGUseElement& useElement = downcast<SVGUseElement>(*shadowHostElement);
-    if (SVGElementInstance* instance = useElement.instanceForShadowTreeElement(&referenceNode))
-        return *instance;
-
     return referenceNode;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to