| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Neither the name of Google Inc. nor the names of its | 10 * * Neither the name of Google Inc. nor the names of its |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 #include "core/dom/shadow/ShadowRoot.h" | 36 #include "core/dom/shadow/ShadowRoot.h" |
| 37 #include "core/events/FocusEvent.h" | 37 #include "core/events/FocusEvent.h" |
| 38 #include "core/events/MouseEvent.h" | 38 #include "core/events/MouseEvent.h" |
| 39 #include "core/events/TouchEvent.h" | 39 #include "core/events/TouchEvent.h" |
| 40 #include "core/events/TouchEventContext.h" | 40 #include "core/events/TouchEventContext.h" |
| 41 #include "core/svg/SVGUseElement.h" | 41 #include "core/svg/SVGUseElement.h" |
| 42 #include "platform/RuntimeEnabledFeatures.h" | 42 #include "platform/RuntimeEnabledFeatures.h" |
| 43 | 43 |
| 44 namespace WebCore { | 44 namespace WebCore { |
| 45 | 45 |
| 46 // SVG1.1 specified that the <use> instance tree would expose the target | |
| 47 // element for events. This has been deprecated and will be removed. | |
| 48 // See: crbug.com/313438 | |
| 49 static bool usesDeprecatedSVGUseTreeEventRules(Node* node) | |
| 50 { | |
| 51 return node->isSVGElement() && toSVGElement(node)->inUseShadowTree(); | |
| 52 } | |
| 53 | |
| 54 EventTarget* EventPath::eventTargetRespectingTargetRules(Node* referenceNode) | 46 EventTarget* EventPath::eventTargetRespectingTargetRules(Node* referenceNode) |
| 55 { | 47 { |
| 56 ASSERT(referenceNode); | 48 ASSERT(referenceNode); |
| 57 | 49 |
| 58 if (referenceNode->isPseudoElement()) | 50 if (referenceNode->isPseudoElement()) |
| 59 return referenceNode->parentNode(); | 51 return referenceNode->parentNode(); |
| 60 | 52 |
| 61 return referenceNode; | 53 return referenceNode; |
| 62 } | 54 } |
| 63 | 55 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 93 } |
| 102 | 94 |
| 103 void EventPath::resetWith(Node* node) | 95 void EventPath::resetWith(Node* node) |
| 104 { | 96 { |
| 105 ASSERT(node); | 97 ASSERT(node); |
| 106 m_node = node; | 98 m_node = node; |
| 107 m_nodeEventContexts.clear(); | 99 m_nodeEventContexts.clear(); |
| 108 m_treeScopeEventContexts.clear(); | 100 m_treeScopeEventContexts.clear(); |
| 109 calculatePath(); | 101 calculatePath(); |
| 110 calculateAdjustedTargets(); | 102 calculateAdjustedTargets(); |
| 111 if (!usesDeprecatedSVGUseTreeEventRules(node)) | 103 calculateTreeScopePrePostOrderNumbers(); |
| 112 calculateTreeScopePrePostOrderNumbers(); | |
| 113 } | 104 } |
| 114 | 105 |
| 115 void EventPath::addNodeEventContext(Node* node) | 106 void EventPath::addNodeEventContext(Node* node) |
| 116 { | 107 { |
| 117 m_nodeEventContexts.append(NodeEventContext(node, eventTargetRespectingTarge
tRules(node))); | 108 m_nodeEventContexts.append(NodeEventContext(node, eventTargetRespectingTarge
tRules(node))); |
| 118 } | 109 } |
| 119 | 110 |
| 120 void EventPath::calculatePath() | 111 void EventPath::calculatePath() |
| 121 { | 112 { |
| 122 ASSERT(m_node); | 113 ASSERT(m_node); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 } | 195 } |
| 205 } else if (!treeScopeEventContext->target() && currentTarget) { | 196 } else if (!treeScopeEventContext->target() && currentTarget) { |
| 206 treeScopeEventContext->setTarget(eventTargetRespectingTargetRules(curren
tTarget)); | 197 treeScopeEventContext->setTarget(eventTargetRespectingTargetRules(curren
tTarget)); |
| 207 } | 198 } |
| 208 return treeScopeEventContext; | 199 return treeScopeEventContext; |
| 209 } | 200 } |
| 210 | 201 |
| 211 void EventPath::calculateAdjustedTargets() | 202 void EventPath::calculateAdjustedTargets() |
| 212 { | 203 { |
| 213 const TreeScope* lastTreeScope = 0; | 204 const TreeScope* lastTreeScope = 0; |
| 214 bool useDeprecatedSVGUseTreeEventRules = usesDeprecatedSVGUseTreeEventRules(
at(0).node()); | |
| 215 | 205 |
| 216 TreeScopeEventContextMap treeScopeEventContextMap; | 206 TreeScopeEventContextMap treeScopeEventContextMap; |
| 217 TreeScopeEventContext* lastTreeScopeEventContext = 0; | 207 TreeScopeEventContext* lastTreeScopeEventContext = 0; |
| 218 | 208 |
| 219 for (size_t i = 0; i < size(); ++i) { | 209 for (size_t i = 0; i < size(); ++i) { |
| 220 Node* currentNode = at(i).node(); | 210 Node* currentNode = at(i).node(); |
| 221 TreeScope& currentTreeScope = currentNode->treeScope(); | 211 TreeScope& currentTreeScope = currentNode->treeScope(); |
| 222 if (lastTreeScope != ¤tTreeScope) { | 212 if (lastTreeScope != ¤tTreeScope) { |
| 223 if (!useDeprecatedSVGUseTreeEventRules) { | 213 lastTreeScopeEventContext = ensureTreeScopeEventContext(currentNode,
¤tTreeScope, treeScopeEventContextMap); |
| 224 lastTreeScopeEventContext = ensureTreeScopeEventContext(currentN
ode, ¤tTreeScope, treeScopeEventContextMap); | |
| 225 } else { | |
| 226 TreeScopeEventContextMap::AddResult addResult = treeScopeEventCo
ntextMap.add(¤tTreeScope, TreeScopeEventContext::create(currentTreeScope))
; | |
| 227 lastTreeScopeEventContext = addResult.storedValue->value.get(); | |
| 228 if (addResult.isNewEntry) { | |
| 229 // Don't adjust an event target for SVG. | |
| 230 lastTreeScopeEventContext->setTarget(eventTargetRespectingTa
rgetRules(at(0).node())); | |
| 231 } | |
| 232 } | |
| 233 } | 214 } |
| 234 ASSERT(lastTreeScopeEventContext); | 215 ASSERT(lastTreeScopeEventContext); |
| 235 at(i).setTreeScopeEventContext(lastTreeScopeEventContext); | 216 at(i).setTreeScopeEventContext(lastTreeScopeEventContext); |
| 236 lastTreeScope = ¤tTreeScope; | 217 lastTreeScope = ¤tTreeScope; |
| 237 } | 218 } |
| 238 m_treeScopeEventContexts.appendRange(treeScopeEventContextMap.values().begin
(), treeScopeEventContextMap.values().end()); | 219 m_treeScopeEventContexts.appendRange(treeScopeEventContextMap.values().begin
(), treeScopeEventContextMap.values().end()); |
| 239 } | 220 } |
| 240 | 221 |
| 241 void EventPath::buildRelatedNodeMap(const Node* relatedNode, RelatedTargetMap& r
elatedTargetMap) | 222 void EventPath::buildRelatedNodeMap(const Node* relatedNode, RelatedTargetMap& r
elatedTargetMap) |
| 242 { | 223 { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 } | 345 } |
| 365 #endif | 346 #endif |
| 366 | 347 |
| 367 void EventPath::trace(Visitor* visitor) | 348 void EventPath::trace(Visitor* visitor) |
| 368 { | 349 { |
| 369 visitor->trace(m_nodeEventContexts); | 350 visitor->trace(m_nodeEventContexts); |
| 370 visitor->trace(m_event); | 351 visitor->trace(m_event); |
| 371 } | 352 } |
| 372 | 353 |
| 373 } // namespace | 354 } // namespace |
| OLD | NEW |