Source/WebCore:
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Feb 2015 15:22:57 +0000 (15:22 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 1 Feb 2015 15:22:57 +0000 (15:22 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179467 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/gtk/svg/custom/use-instanceRoot-event-bubbling-expected.png [deleted file]
LayoutTests/platform/gtk/svg/custom/use-instanceRoot-modifications-expected.png [deleted file]
LayoutTests/platform/gtk/svg/custom/use-instanceRoot-modifications-expected.txt [deleted file]
LayoutTests/platform/ios-sim-deprecated/svg/custom/use-instanceRoot-modifications-expected.txt [deleted file]
LayoutTests/platform/ios-simulator/svg/custom/use-instanceRoot-modifications-expected.txt [deleted file]
LayoutTests/platform/mac-mountainlion/svg/custom/use-instanceRoot-modifications-expected.txt [deleted file]
LayoutTests/platform/mac/svg/custom/use-instanceRoot-event-bubbling-expected.png [deleted file]
LayoutTests/platform/mac/svg/custom/use-instanceRoot-modifications-expected.png [deleted file]
LayoutTests/platform/mac/svg/custom/use-instanceRoot-modifications-expected.txt [deleted file]
LayoutTests/svg/custom/resources/use-instanceRoot-event-bubbling.js
LayoutTests/svg/custom/use-event-retargeting-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/use-event-retargeting.html [new file with mode: 0644]
LayoutTests/svg/custom/use-instanceRoot-event-bubbling-expected.txt
LayoutTests/svg/custom/use-instanceRoot-event-bubbling.xhtml
LayoutTests/svg/custom/use-instanceRoot-modifications.svg [deleted file]
LayoutTests/svg/custom/use-instanceRoot-with-use-removed-expected.txt [deleted file]
LayoutTests/svg/custom/use-instanceRoot-with-use-removed.svg [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/dom/EventDispatcher.cpp

index fa2843109f4dd09285cb4e9103bc5965f9420d73..6615188be4b68a35e4d32525d18c40f2da66d55b 100644 (file)
@@ -1,3 +1,36 @@
+2015-01-31  Darin Adler  <darin@apple.com>
+
+        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.
+
 2015-02-01  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         Unreviewd EFL gardening. Add new failing tests related to W3C SVG 1.1.
diff --git a/LayoutTests/platform/gtk/svg/custom/use-instanceRoot-event-bubbling-expected.png b/LayoutTests/platform/gtk/svg/custom/use-instanceRoot-event-bubbling-expected.png
deleted file mode 100644 (file)
index c5ea4a6..0000000
Binary files a/LayoutTests/platform/gtk/svg/custom/use-instanceRoot-event-bubbling-expected.png and /dev/null differ
diff --git a/LayoutTests/platform/gtk/svg/custom/use-instanceRoot-modifications-expected.png b/LayoutTests/platform/gtk/svg/custom/use-instanceRoot-modifications-expected.png
deleted file mode 100644 (file)
index c433f51..0000000
Binary files a/LayoutTests/platform/gtk/svg/custom/use-instanceRoot-modifications-expected.png and /dev/null differ
diff --git a/LayoutTests/platform/gtk/svg/custom/use-instanceRoot-modifications-expected.txt b/LayoutTests/platform/gtk/svg/custom/use-instanceRoot-modifications-expected.txt
deleted file mode 100644 (file)
index d3d3eb8..0000000
+++ /dev/null
@@ -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."
diff --git a/LayoutTests/platform/ios-sim-deprecated/svg/custom/use-instanceRoot-modifications-expected.txt b/LayoutTests/platform/ios-sim-deprecated/svg/custom/use-instanceRoot-modifications-expected.txt
deleted file mode 100644 (file)
index ddf8d17..0000000
+++ /dev/null
@@ -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."
diff --git a/LayoutTests/platform/ios-simulator/svg/custom/use-instanceRoot-modifications-expected.txt b/LayoutTests/platform/ios-simulator/svg/custom/use-instanceRoot-modifications-expected.txt
deleted file mode 100644 (file)
index ddf8d17..0000000
+++ /dev/null
@@ -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."
diff --git a/LayoutTests/platform/mac-mountainlion/svg/custom/use-instanceRoot-modifications-expected.txt b/LayoutTests/platform/mac-mountainlion/svg/custom/use-instanceRoot-modifications-expected.txt
deleted file mode 100644 (file)
index eedecb5..0000000
+++ /dev/null
@@ -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."
diff --git a/LayoutTests/platform/mac/svg/custom/use-instanceRoot-event-bubbling-expected.png b/LayoutTests/platform/mac/svg/custom/use-instanceRoot-event-bubbling-expected.png
deleted file mode 100644 (file)
index 4e583c0..0000000
Binary files a/LayoutTests/platform/mac/svg/custom/use-instanceRoot-event-bubbling-expected.png and /dev/null differ
diff --git a/LayoutTests/platform/mac/svg/custom/use-instanceRoot-modifications-expected.png b/LayoutTests/platform/mac/svg/custom/use-instanceRoot-modifications-expected.png
deleted file mode 100644 (file)
index 16891fd..0000000
Binary files a/LayoutTests/platform/mac/svg/custom/use-instanceRoot-modifications-expected.png and /dev/null differ
diff --git a/LayoutTests/platform/mac/svg/custom/use-instanceRoot-modifications-expected.txt b/LayoutTests/platform/mac/svg/custom/use-instanceRoot-modifications-expected.txt
deleted file mode 100644 (file)
index 852c7aa..0000000
+++ /dev/null
@@ -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."
index c08fe9414583b862240f9ced78dc556da5df0bba..b9358951565430117107b9d00d20517e39efa738 100644 (file)
@@ -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 log(message) {
 }
 
 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 eventHandler(evt, label) {
 
 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 @@ function nextTest()
     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 @@ defs.appendChild(rectContainer);
 
 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.id = "use";
 use.href.baseVal = "#rectParent";
 useContainer.appendChild(use);
 
-function repaintTest() {
-    if (window.testRunner)
-        testRunner.waitUntilDone();
-    nextTest();
-}
+nextTest();
diff --git a/LayoutTests/svg/custom/use-event-retargeting-expected.txt b/LayoutTests/svg/custom/use-event-retargeting-expected.txt
new file mode 100644 (file)
index 0000000..77fdc2d
--- /dev/null
@@ -0,0 +1,3 @@
+PASS - [object SVGUseElement] was clicked.
+PASS - [object HTMLDivElement] was clicked.
+
diff --git a/LayoutTests/svg/custom/use-event-retargeting.html b/LayoutTests/svg/custom/use-event-retargeting.html
new file mode 100644 (file)
index 0000000..b7d25c2
--- /dev/null
@@ -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="#blue-rectangle"></use>
+        </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>
index ec6b5c518ec69a79bcc6e7c4af3ef570d2a96ff7..48fab3764102f2ffa78165165d275c32e8ecf324 100644 (file)
@@ -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
 
index 96a85209d824d34a5fa42f6cd05be57d376eee71..e2c935051ac9f05d54d711c0e8333435a838a777 100644 (file)
@@ -1,12 +1,11 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
 <script>window.enablePixelTesting = true;</script>
-<script src="../../resources/js-test-pre.js"></script>
-<script src="../../fast/repaint/resources/repaint.js"></script>
+<script src="../../resources/js-test-pre.js"/>
 </head>
-<body onload="runRepaintTest()">
-<p id="description"></p>
-<div id="console"></div>
-<script src="resources/use-instanceRoot-event-bubbling.js"></script>
+<body>
+<p id="description"/>
+<div id="console"/>
+<script src="resources/use-instanceRoot-event-bubbling.js"/>
 </body>
 </html>
diff --git a/LayoutTests/svg/custom/use-instanceRoot-modifications.svg b/LayoutTests/svg/custom/use-instanceRoot-modifications.svg
deleted file mode 100644 (file)
index 1c664d0..0000000
+++ /dev/null
@@ -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="#g"/>
-<use x="125" y="25" xlink:href="#g"/>
-
-<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>
diff --git a/LayoutTests/svg/custom/use-instanceRoot-with-use-removed-expected.txt b/LayoutTests/svg/custom/use-instanceRoot-with-use-removed-expected.txt
deleted file mode 100644 (file)
index c333423..0000000
+++ /dev/null
@@ -1 +0,0 @@
-PASS: Successfully removed use element.
diff --git a/LayoutTests/svg/custom/use-instanceRoot-with-use-removed.svg b/LayoutTests/svg/custom/use-instanceRoot-with-use-removed.svg
deleted file mode 100644 (file)
index e8614e6..0000000
+++ /dev/null
@@ -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="#g1" id="use1" />
-<text x="20" y="20" fill="green" id="t1"></text>
-</svg>
index 9925b3d0c5130f0d9abb336f837f28972f3ade17..f8dc02ffa6ba450d21458a6f6ccddc52deb2e64e 100644 (file)
@@ -1,3 +1,17 @@
+2015-01-31  Darin Adler  <darin@apple.com>
+
+        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-01  Zan Dobersek  <zdobersek@igalia.com>
 
         [TexMap] Optimize TextureMapperLayer::removeAllChildren()
index d8ee19f7f4f9ed4b35f2ab9c8d917f6c3536a590..76c5e730863ae4b23961df3ea3baecd0f3de19f7 100644 (file)
@@ -206,24 +206,15 @@ private:
 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;
-
-    // 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;
+    // 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;
+    }
 
     return referenceNode;
 }