Commit ceea60e0 authored by ed@opera.com's avatar ed@opera.com

[SVG2] The exposed event target should be the <use> element.

Spec:
https://svgwg.org/svg2-draft/struct.html#UseElement

BUG=382872, 313438

Review URL: https://codereview.chromium.org/323343004

git-svn-id: svn://svn.chromium.org/blink/trunk@176090 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e291bbc7
...@@ -1074,3 +1074,5 @@ crbug.com/383596 fast/js/reserved-words-as-property.html [ Failure ] ...@@ -1074,3 +1074,5 @@ crbug.com/383596 fast/js/reserved-words-as-property.html [ Failure ]
crbug.com/383596 inspector-protocol/runtime/runtime-getProperties.html [ Failure ] crbug.com/383596 inspector-protocol/runtime/runtime-getProperties.html [ Failure ]
crbug.com/383596 inspector/console/console-eval-scoped.html [ Failure ] crbug.com/383596 inspector/console/console-eval-scoped.html [ Failure ]
crbug.com/383596 inspector/console/console-object-preview-accessors.html [ Failure ] crbug.com/383596 inspector/console/console-object-preview-accessors.html [ Failure ]
crbug.com/382872 svg/custom/use-instanceRoot-event-bubbling.xhtml [ NeedsRebaseline ]
...@@ -56,12 +56,12 @@ function nextTest() ...@@ -56,12 +56,12 @@ function nextTest()
switch (counter) { switch (counter) {
case 1: case 1:
rect.onclick = function(evt) { eventHandler(evt, 1); }; rect.onclick = function(evt) { eventHandler(evt, 1); };
expected[0] = "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"; expected[0] = "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGRectElement] (id: rect) currentTarget: [object SVGRectElement] (id: rect)";
testListeners(); testListeners();
break; break;
case 2: case 2:
rectContainer.addEventListener("click", function(evt) { eventHandler(evt, 2) }, false); rectContainer.addEventListener("click", function(evt) { eventHandler(evt, 2) }, false);
expected[1] = "[EventHandler 2] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use)"; expected[1] = "[EventHandler 2] type: click phase: BUBBLING target: [object SVGRectElement] (id: rect) currentTarget: [object SVGGElement] (id: rectParent)";
testListeners(); testListeners();
break; break;
case 3: case 3:
...@@ -103,7 +103,7 @@ defs.appendChild(rectContainer); ...@@ -103,7 +103,7 @@ defs.appendChild(rectContainer);
var rect = document.createElementNS(svgNS, "rect"); var rect = document.createElementNS(svgNS, "rect");
rect.id = "rect"; rect.id = "rect";
rect.style.fill = "red"; rect.style.fill = "blue";
rect.width.baseVal.value = 100; rect.width.baseVal.value = 100;
rect.height.baseVal.value = 100; rect.height.baseVal.value = 100;
rectContainer.appendChild(rect); rectContainer.appendChild(rect);
......
PASS - [object SVGUseElement] was clicked.
PASS - [object HTMLDivElement] was clicked.
<!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,expectedElm)
{
expected = expectedElm;
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>
...@@ -6,16 +6,16 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE ...@@ -6,16 +6,16 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
FAIL msg should be [EventHandler 1] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use). Was [EventHandler 1] type: click phase: AT_TARGET target: [object SVGRectElement] (id: rect) currentTarget: [object SVGRectElement] (id: rect). PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGRectElement] (id: rect) currentTarget: [object SVGRectElement] (id: rect)"
FAIL msg should be [EventHandler 1] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use). Was [EventHandler 1] type: click phase: AT_TARGET target: [object SVGRectElement] (id: rect) currentTarget: [object SVGRectElement] (id: rect). PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGRectElement] (id: rect) currentTarget: [object SVGRectElement] (id: rect)"
FAIL msg should be [EventHandler 2] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use). Was [EventHandler 2] type: click phase: BUBBLING target: [object SVGRectElement] (id: rect) currentTarget: [object SVGGElement] (id: rectParent). PASS msg is "[EventHandler 2] type: click phase: BUBBLING target: [object SVGRectElement] (id: rect) currentTarget: [object SVGGElement] (id: rectParent)"
FAIL msg should be [EventHandler 1] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use). Was [EventHandler 1] type: click phase: AT_TARGET target: [object SVGRectElement] (id: rect) currentTarget: [object SVGRectElement] (id: rect). PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGRectElement] (id: rect) currentTarget: [object SVGRectElement] (id: rect)"
FAIL msg should be [EventHandler 2] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use). Was [EventHandler 2] type: click phase: BUBBLING target: [object SVGRectElement] (id: rect) currentTarget: [object SVGGElement] (id: rectParent). PASS msg is "[EventHandler 2] type: click phase: BUBBLING target: [object SVGRectElement] (id: rect) currentTarget: [object SVGGElement] (id: rectParent)"
FAIL msg should be [EventHandler 3] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use). Was [EventHandler 3] type: click phase: BUBBLING target: [object SVGRectElement] (id: rect) 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)"
FAIL msg should be [EventHandler 1] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use). Was [EventHandler 1] type: click phase: AT_TARGET target: [object SVGRectElement] (id: rect) currentTarget: [object SVGRectElement] (id: rect). PASS msg is "[EventHandler 1] type: click phase: AT_TARGET target: [object SVGRectElement] (id: rect) currentTarget: [object SVGRectElement] (id: rect)"
FAIL msg should be [EventHandler 2] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use). Was [EventHandler 2] type: click phase: BUBBLING target: [object SVGRectElement] (id: rect) currentTarget: [object SVGGElement] (id: rectParent). PASS msg is "[EventHandler 2] type: click phase: BUBBLING target: [object SVGRectElement] (id: rect) currentTarget: [object SVGGElement] (id: rectParent)"
FAIL msg should be [EventHandler 3] type: click phase: AT_TARGET target: [object SVGUseElement] (id: use) currentTarget: [object SVGUseElement] (id: use). Was [EventHandler 3] type: click phase: BUBBLING target: [object SVGRectElement] (id: rect) 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)"
FAIL msg should be [EventHandler 4] type: click phase: BUBBLING target: [object SVGUseElement] (id: use) currentTarget: [object SVGGElement] (id: useParent). Was [EventHandler 4] type: click phase: BUBBLING target: [object SVGRectElement] (id: rect) currentTarget: [object SVGGElement] (id: useParent). PASS msg is "[EventHandler 4] type: click phase: BUBBLING target: [object SVGUseElement] (id: use) currentTarget: [object SVGGElement] (id: useParent)"
PASS successfullyParsed is true PASS successfullyParsed is true
TEST COMPLETE TEST COMPLETE
......
...@@ -43,14 +43,6 @@ ...@@ -43,14 +43,6 @@
namespace WebCore { namespace WebCore {
// SVG1.1 specified that the <use> instance tree would expose the target
// element for events. This has been deprecated and will be removed.
// See: crbug.com/313438
static bool usesDeprecatedSVGUseTreeEventRules(Node* node)
{
return node->isSVGElement() && toSVGElement(node)->inUseShadowTree();
}
EventTarget* EventPath::eventTargetRespectingTargetRules(Node* referenceNode) EventTarget* EventPath::eventTargetRespectingTargetRules(Node* referenceNode)
{ {
ASSERT(referenceNode); ASSERT(referenceNode);
...@@ -108,8 +100,7 @@ void EventPath::resetWith(Node* node) ...@@ -108,8 +100,7 @@ void EventPath::resetWith(Node* node)
m_treeScopeEventContexts.clear(); m_treeScopeEventContexts.clear();
calculatePath(); calculatePath();
calculateAdjustedTargets(); calculateAdjustedTargets();
if (!usesDeprecatedSVGUseTreeEventRules(node)) calculateTreeScopePrePostOrderNumbers();
calculateTreeScopePrePostOrderNumbers();
} }
void EventPath::addNodeEventContext(Node* node) void EventPath::addNodeEventContext(Node* node)
...@@ -211,7 +202,6 @@ TreeScopeEventContext* EventPath::ensureTreeScopeEventContext(Node* currentTarge ...@@ -211,7 +202,6 @@ TreeScopeEventContext* EventPath::ensureTreeScopeEventContext(Node* currentTarge
void EventPath::calculateAdjustedTargets() void EventPath::calculateAdjustedTargets()
{ {
const TreeScope* lastTreeScope = 0; const TreeScope* lastTreeScope = 0;
bool useDeprecatedSVGUseTreeEventRules = usesDeprecatedSVGUseTreeEventRules(at(0).node());
TreeScopeEventContextMap treeScopeEventContextMap; TreeScopeEventContextMap treeScopeEventContextMap;
TreeScopeEventContext* lastTreeScopeEventContext = 0; TreeScopeEventContext* lastTreeScopeEventContext = 0;
...@@ -220,16 +210,7 @@ void EventPath::calculateAdjustedTargets() ...@@ -220,16 +210,7 @@ void EventPath::calculateAdjustedTargets()
Node* currentNode = at(i).node(); Node* currentNode = at(i).node();
TreeScope& currentTreeScope = currentNode->treeScope(); TreeScope& currentTreeScope = currentNode->treeScope();
if (lastTreeScope != &currentTreeScope) { if (lastTreeScope != &currentTreeScope) {
if (!useDeprecatedSVGUseTreeEventRules) { lastTreeScopeEventContext = ensureTreeScopeEventContext(currentNode, &currentTreeScope, treeScopeEventContextMap);
lastTreeScopeEventContext = ensureTreeScopeEventContext(currentNode, &currentTreeScope, treeScopeEventContextMap);
} else {
TreeScopeEventContextMap::AddResult addResult = treeScopeEventContextMap.add(&currentTreeScope, TreeScopeEventContext::create(currentTreeScope));
lastTreeScopeEventContext = addResult.storedValue->value.get();
if (addResult.isNewEntry) {
// Don't adjust an event target for SVG.
lastTreeScopeEventContext->setTarget(eventTargetRespectingTargetRules(at(0).node()));
}
}
} }
ASSERT(lastTreeScopeEventContext); ASSERT(lastTreeScopeEventContext);
at(i).setTreeScopeEventContext(lastTreeScopeEventContext); at(i).setTreeScopeEventContext(lastTreeScopeEventContext);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment