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)
{
ASSERT(referenceNode);
if (referenceNode->isPseudoElement())
return referenceNode->parentNode();
- if (!referenceNode->isSVGElement() || !referenceNode->isInShadowTree())
+ if (!usesDeprecatedSVGUseTreeEventRules(referenceNode))
return referenceNode;
// Spec: The event handling for the non-exposed tree works as if the referenced element had been textually included
EventPath::EventPath(Node* node)
: m_node(node)
- , m_event(0)
+ , m_event(nullptr)
{
resetWith(node);
}
m_treeScopeEventContexts.clear();
calculatePath();
calculateAdjustedTargets();
- if (!node->isSVGElement())
+ if (!usesDeprecatedSVGUseTreeEventRules(node))
calculateTreeScopePrePostOrderNumbers();
}
{
if (!treeScope)
return 0;
- TreeScopeEventContextMap::AddResult addResult = treeScopeEventContextMap.add(treeScope, TreeScopeEventContext::create(*treeScope));
- TreeScopeEventContext* treeScopeEventContext = addResult.storedValue->value.get();
- if (addResult.isNewEntry) {
+ TreeScopeEventContext* treeScopeEventContext;
+ bool isNewEntry;
+ {
+ TreeScopeEventContextMap::AddResult addResult = treeScopeEventContextMap.add(treeScope, nullptr);
+ if ((isNewEntry = addResult.isNewEntry))
+ addResult.storedValue->value = TreeScopeEventContext::create(*treeScope);
+ treeScopeEventContext = addResult.storedValue->value.get();
+ }
+ if (isNewEntry) {
TreeScopeEventContext* parentTreeScopeEventContext = ensureTreeScopeEventContext(0, treeScope->olderShadowRootOrParentTreeScope(), treeScopeEventContextMap);
if (parentTreeScopeEventContext && parentTreeScopeEventContext->target()) {
treeScopeEventContext->setTarget(parentTreeScopeEventContext->target());
void EventPath::calculateAdjustedTargets()
{
const TreeScope* lastTreeScope = 0;
- bool isSVGElement = at(0).node()->isSVGElement();
+ bool useDeprecatedSVGUseTreeEventRules = usesDeprecatedSVGUseTreeEventRules(at(0).node());
TreeScopeEventContextMap treeScopeEventContextMap;
TreeScopeEventContext* lastTreeScopeEventContext = 0;
Node* currentNode = at(i).node();
TreeScope& currentTreeScope = currentNode->treeScope();
if (lastTreeScope != ¤tTreeScope) {
- if (!isSVGElement) {
+ if (!useDeprecatedSVGUseTreeEventRules) {
lastTreeScopeEventContext = ensureTreeScopeEventContext(currentNode, ¤tTreeScope, treeScopeEventContextMap);
} else {
TreeScopeEventContextMap::AddResult addResult = treeScopeEventContextMap.add(¤tTreeScope, TreeScopeEventContext::create(currentTreeScope));
}
#endif
+void EventPath::trace(Visitor* visitor)
+{
+ visitor->trace(m_event);
+}
+
} // namespace