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 21 matching lines...) Expand all Loading... |
32 #include "SVGNames.h" | 32 #include "SVGNames.h" |
33 #include "core/dom/FullscreenElementStack.h" | 33 #include "core/dom/FullscreenElementStack.h" |
34 #include "core/dom/Touch.h" | 34 #include "core/dom/Touch.h" |
35 #include "core/dom/TouchList.h" | 35 #include "core/dom/TouchList.h" |
36 #include "core/dom/shadow/InsertionPoint.h" | 36 #include "core/dom/shadow/InsertionPoint.h" |
37 #include "core/dom/shadow/ShadowRoot.h" | 37 #include "core/dom/shadow/ShadowRoot.h" |
38 #include "core/events/FocusEvent.h" | 38 #include "core/events/FocusEvent.h" |
39 #include "core/events/MouseEvent.h" | 39 #include "core/events/MouseEvent.h" |
40 #include "core/events/TouchEvent.h" | 40 #include "core/events/TouchEvent.h" |
41 #include "core/events/TouchEventContext.h" | 41 #include "core/events/TouchEventContext.h" |
42 #include "core/svg/SVGElementInstance.h" | |
43 #include "core/svg/SVGUseElement.h" | 42 #include "core/svg/SVGUseElement.h" |
44 | 43 |
45 namespace WebCore { | 44 namespace WebCore { |
46 | 45 |
47 // SVG1.1 specified that the <use> instance tree would expose the target | 46 // SVG1.1 specified that the <use> instance tree would expose the target |
48 // element for events. This has been deprecated and will be removed. | 47 // element for events. This has been deprecated and will be removed. |
49 // See: crbug.com/313438 | 48 // See: crbug.com/313438 |
50 static bool usesDeprecatedSVGUseTreeEventRules(Node* node) | 49 static bool usesDeprecatedSVGUseTreeEventRules(Node* node) |
51 { | 50 { |
52 return node->isSVGElement() && toSVGElement(node)->inUseShadowTree(); | 51 return node->isSVGElement() && toSVGElement(node)->inUseShadowTree(); |
53 } | 52 } |
54 | 53 |
55 EventTarget* EventPath::eventTargetRespectingTargetRules(Node* referenceNode) | 54 EventTarget* EventPath::eventTargetRespectingTargetRules(Node* referenceNode) |
56 { | 55 { |
57 ASSERT(referenceNode); | 56 ASSERT(referenceNode); |
58 | 57 |
59 if (referenceNode->isPseudoElement()) | 58 if (referenceNode->isPseudoElement()) |
60 return referenceNode->parentNode(); | 59 return referenceNode->parentNode(); |
61 | 60 |
62 if (!usesDeprecatedSVGUseTreeEventRules(referenceNode)) | |
63 return referenceNode; | |
64 | |
65 // Spec: The event handling for the non-exposed tree works as if the referen
ced element had been textually included | |
66 // as a deeply cloned child of the 'use' element, except that events are dis
patched to the SVGElementInstance objects. | |
67 Node& rootNode = referenceNode->treeScope().rootNode(); | |
68 Element* shadowHostElement = rootNode.isShadowRoot() ? toShadowRoot(rootNode
).host() : 0; | |
69 // At this time, SVG nodes are not supported in non-<use> shadow trees. | |
70 if (!isSVGUseElement(shadowHostElement)) | |
71 return referenceNode; | |
72 SVGUseElement& useElement = toSVGUseElement(*shadowHostElement); | |
73 if (SVGElementInstance* instance = useElement.instanceForShadowTreeElement(r
eferenceNode)) | |
74 return instance; | |
75 | |
76 return referenceNode; | 61 return referenceNode; |
77 } | 62 } |
78 | 63 |
79 static inline bool inTheSameScope(ShadowRoot* shadowRoot, EventTarget* target) | 64 static inline bool inTheSameScope(ShadowRoot* shadowRoot, EventTarget* target) |
80 { | 65 { |
81 return target->toNode() && target->toNode()->treeScope().rootNode() == shado
wRoot; | 66 return target->toNode() && target->toNode()->treeScope().rootNode() == shado
wRoot; |
82 } | 67 } |
83 | 68 |
84 static inline EventDispatchBehavior determineDispatchBehavior(Event* event, Shad
owRoot* shadowRoot, EventTarget* target) | 69 static inline EventDispatchBehavior determineDispatchBehavior(Event* event, Shad
owRoot* shadowRoot, EventTarget* target) |
85 { | 70 { |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 } | 364 } |
380 #endif | 365 #endif |
381 | 366 |
382 void EventPath::trace(Visitor* visitor) | 367 void EventPath::trace(Visitor* visitor) |
383 { | 368 { |
384 visitor->trace(m_nodeEventContexts); | 369 visitor->trace(m_nodeEventContexts); |
385 visitor->trace(m_event); | 370 visitor->trace(m_event); |
386 } | 371 } |
387 | 372 |
388 } // namespace | 373 } // namespace |
OLD | NEW |