Changeset 179785 in webkit


Ignore:
Timestamp:
Feb 7, 2015 3:17:26 PM (9 years ago)
Author:
Darin Adler
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.

Location:
trunk
Files:
2 added
12 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r179777 r179785  
     12015-02-07  Darin Adler  <darin@apple.com>
     2
     3        Stop dispatching events with SVGElementInstance objects as their targets
     4        https://bugs.webkit.org/show_bug.cgi?id=141108
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Many tests are no longer relevant once we aren't doing this any more.
     9
     10        * platform/gtk/svg/custom/use-instanceRoot-event-bubbling-expected.png: Removed.
     11        * platform/gtk/svg/custom/use-instanceRoot-modifications-expected.png: Removed.
     12        * platform/gtk/svg/custom/use-instanceRoot-modifications-expected.txt: Removed.
     13        * platform/ios-sim-deprecated/svg/custom/use-instanceRoot-modifications-expected.txt: Removed.
     14        * platform/ios-simulator/svg/custom/use-instanceRoot-modifications-expected.txt: Removed.
     15        * platform/mac-mountainlion/svg/custom/use-instanceRoot-modifications-expected.txt: Removed.
     16        * platform/mac/svg/custom/use-instanceRoot-event-bubbling-expected.png: Removed.
     17        * platform/mac/svg/custom/use-instanceRoot-modifications-expected.png: Removed.
     18        * platform/mac/svg/custom/use-instanceRoot-modifications-expected.txt: Removed.
     19        * svg/custom/use-instanceRoot-modifications.svg: Removed.
     20        * svg/custom/use-instanceRoot-with-use-removed-expected.txt: Removed.
     21        * svg/custom/use-instanceRoot-with-use-removed.svg: Removed.
     22
     23        * svg/custom/resources/use-instanceRoot-event-bubbling.js: Updated this test to expect
     24        the events to be dispatched with the SVGUseElement as the target. I talked this over with
     25        Sam Weinig and we decided this is good behavior for now, and it almost matches what the
     26        spec says. Might be worth refining later.
     27        * svg/custom/use-instanceRoot-event-bubbling-expected.txt: Updated expected results.
     28        * svg/custom/use-instanceRoot-event-bubbling.xhtml: Tweaked the test a little. It still
     29        could use improvement; it's like half a "repaint test", which is strange.
     30
     31        * svg/custom/use-event-retargeting-expected.txt: Added. Got this test from Blink.
     32        * svg/custom/use-event-retargeting.html: Added. Ditto.
     33
     34        * svg/custom/use-events-crash.svg: Added some more events, a second click, so that we
     35        don't hang with the context menu up when running this. Also converted line endings to
     36        use LF instead of CRLF.
     37
    1382015-02-07  Alexey Proskuryakov  <ap@apple.com>
    239
  • trunk/LayoutTests/svg/custom/resources/use-instanceRoot-event-bubbling.js

    r179471 r179785  
    1 description("Tests wheter SVG event bubbling works accross shadow trees.");
     1description("Tests whether SVG event bubbling works across shadow trees.");
    22
    3 if (window.testRunner)
     3if (window.testRunner) {
    44    testRunner.waitUntilDone();
     5    testRunner.dumpAsText();
     6}
    57
    68var svgNS = "http://www.w3.org/2000/svg";
     
    1921
    2022function eventHandler(evt, label) {
    21     var targetId = evt.target.correspondingElement ? evt.target.correspondingElement.id : evt.target.id;
    22     var curTargetId = evt.currentTarget.correspondingElement ? evt.currentTarget.correspondingElement.id : evt.currentTarget.id;
     23    var targetId = evt.target.id;
     24    var curTargetId = evt.currentTarget.id;
    2325
    2426    var phaseString = "";
     
    4244function finishTest()
    4345{
    44     successfullyParsed = true;
    45 
    4646    document.getElementById("rectParent").setAttribute("fill", "green");
    47     shouldBeTrue("successfullyParsed");
    4847    debug('<br /><span class="pass">TEST COMPLETE</span>');
    4948
     
    6059    case 1:
    6160        rect.onclick = function(evt) { eventHandler(evt, 1); };
    62         expected[0] = "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rect)";
     61        expected[0] = "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)";
    6362        testListeners();
    6463        break;
    6564    case 2:
    6665        rectContainer.addEventListener("click", function(evt) { eventHandler(evt, 2) }, false);
    67         expected[1] = "[EventHandler 2] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rectParent)";   
     66        expected[1] = "[EventHandler 2] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)";
    6867        testListeners();
    6968        break;
    7069    case 3:
    7170        use.setAttribute("onclick", "eventHandler(evt, 3)");
    72         expected[2] = "[EventHandler 3] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGUseElement] (id: use)";
     71        expected[2] = "[EventHandler 3] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)";
    7372        testListeners();
    7473        break;
    7574    case 4:
    7675        useContainer.onclick = function(evt) { eventHandler(evt, 4) };
    77         expected[3] = "[EventHandler 4] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGGElement] (id: useParent)";
     76        expected[3] = "[EventHandler 4] type: click phase: BUBBLING target: [object SVGUseElement] (id: use) currentTarget: [object SVGGElement] (id: useParent)";
    7877        testListeners();
    7978        break;
     
    107106var rect = document.createElementNS(svgNS, "rect");
    108107rect.id = "rect";
    109 rect.style.fill = "red";
     108rect.style.fill = "blue";
    110109rect.width.baseVal.value = 100;
    111110rect.height.baseVal.value = 100;
     
    122121useContainer.appendChild(use);
    123122
    124 function repaintTest() {
    125     if (window.testRunner)
    126         testRunner.waitUntilDone();
    127     nextTest();
    128 }
     123nextTest();
  • trunk/LayoutTests/svg/custom/use-events-crash.svg

    r19571 r179785  
    99        eventSender.mouseMoveTo(370, 45);
    1010        eventSender.contextClick();
     11        eventSender.mouseUp();
     12        eventSender.mouseDown();
     13        eventSender.mouseUp();
    1114    }
    1215}
  • trunk/LayoutTests/svg/custom/use-instanceRoot-event-bubbling-expected.txt

    r179471 r179785  
    1 Tests wheter SVG event bubbling works accross shadow trees.
     1Tests whether SVG event bubbling works across shadow trees.
    22
    33On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
    44
    55
    6 PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rect)"
    7 PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rect)"
    8 PASS msg is "[EventHandler 2] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rectParent)"
    9 PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rect)"
    10 PASS msg is "[EventHandler 2] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rectParent)"
    11 PASS msg is "[EventHandler 3] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGUseElement] (id: use)"
    12 PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rect)"
    13 PASS msg is "[EventHandler 2] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGElementInstance] (id: rectParent)"
    14 PASS msg is "[EventHandler 3] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGUseElement] (id: use)"
    15 PASS msg is "[EventHandler 4] type: click phase: BUBBLING target: [object SVGElementInstance] (id: rect) currentTarget: [object SVGGElement] (id: useParent)"
    16 PASS successfullyParsed is true
     6PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
     7PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
     8PASS msg is "[EventHandler 2] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
     9PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
     10PASS msg is "[EventHandler 2] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
     11PASS msg is "[EventHandler 3] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
     12PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
     13PASS msg is "[EventHandler 2] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
     14PASS msg is "[EventHandler 3] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"
     15PASS msg is "[EventHandler 4] type: click phase: BUBBLING target: [object SVGUseElement] (id: use) currentTarget: [object SVGGElement] (id: useParent)"
    1716
    1817TEST COMPLETE
  • trunk/LayoutTests/svg/custom/use-instanceRoot-event-bubbling.xhtml

    r179471 r179785  
    22<head>
    33<script>window.enablePixelTesting = true;</script>
    4 <script src="../../resources/js-test-pre.js"></script>
    5 <script src="../../fast/repaint/resources/repaint.js"></script>
     4<script src="../../resources/js-test-pre.js"/>
    65</head>
    7 <body onload="runRepaintTest()">
    8 <p id="description"></p>
    9 <div id="console"></div>
    10 <script src="resources/use-instanceRoot-event-bubbling.js"></script>
     6<body>
     7<p id="description"/>
     8<div id="console"/>
     9<script src="resources/use-instanceRoot-event-bubbling.js"/>
    1110</body>
    1211</html>
  • trunk/Source/WebCore/ChangeLog

    r179784 r179785  
     12015-02-07  Darin Adler  <darin@apple.com>
     2
     3        Stop dispatching events to with SVGElementInstance objects as their targets
     4        https://bugs.webkit.org/show_bug.cgi?id=141108
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Test: svg/custom/use-event-retargeting.html
     9
     10        * dom/EventDispatcher.cpp:
     11        (WebCore::eventTargetRespectingTargetRules): Replaced the code that retargeted
     12        events at SVGElementInstance objects with code that retargets them at the use
     13        element instead. Also wrote the code in a simpler way.
     14
    1152015-02-07  Jer Noble  <jer.noble@apple.com>
    216
  • trunk/Source/WebCore/dom/EventDispatcher.cpp

    r179471 r179785  
    207207{
    208208    if (is<PseudoElement>(referenceNode)) {
    209         EventTarget* hostElement = downcast<PseudoElement>(referenceNode).hostElement();
    210         ASSERT(hostElement);
    211         return *hostElement;
    212     }
    213 
    214     if (!referenceNode.isSVGElement() || !referenceNode.isInShadowTree())
    215         return referenceNode;
    216 
    217     // Spec: The event handling for the non-exposed tree works as if the referenced element had been textually included
    218     // as a deeply cloned child of the 'use' element, except that events are dispatched to the SVGElementInstance objects
    219     auto& rootNode = referenceNode.treeScope().rootNode();
    220     Element* shadowHostElement = is<ShadowRoot>(rootNode) ? downcast<ShadowRoot>(rootNode).hostElement() : nullptr;
    221     // At this time, SVG nodes are not supported in non-<use> shadow trees.
    222     if (!shadowHostElement || !shadowHostElement->hasTagName(SVGNames::useTag))
    223         return referenceNode;
    224     SVGUseElement& useElement = downcast<SVGUseElement>(*shadowHostElement);
    225     if (SVGElementInstance* instance = useElement.instanceForShadowTreeElement(&referenceNode))
    226         return *instance;
     209        ASSERT(downcast<PseudoElement>(referenceNode).hostElement());
     210        return *downcast<PseudoElement>(referenceNode).hostElement();
     211    }
     212
     213    // Events sent to elements inside an SVG use element's shadow tree go to the use element.
     214    if (is<SVGElement>(referenceNode)) {
     215        if (auto* useElement = downcast<SVGElement>(referenceNode).correspondingUseElement())
     216            return *useElement;
     217    }
    227218
    228219    return referenceNode;
Note: See TracChangeset for help on using the changeset viewer.