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)) | 61 if (!usesDeprecatedSVGUseTreeEventRules(referenceNode)) |
pdr.
2014/06/02 14:09:06
I thought we could remove all svg-specific logic h
| |
63 return referenceNode; | 62 return referenceNode; |
64 | 63 |
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(); | 64 Node& rootNode = referenceNode->treeScope().rootNode(); |
68 Element* shadowHostElement = rootNode.isShadowRoot() ? toShadowRoot(rootNode ).host() : 0; | 65 Element* shadowHostElement = rootNode.isShadowRoot() ? toShadowRoot(rootNode ).host() : 0; |
69 // At this time, SVG nodes are not supported in non-<use> shadow trees. | 66 if (isSVGUseElement(shadowHostElement)) |
70 if (!isSVGUseElement(shadowHostElement)) | 67 return shadowHostElement; |
71 return referenceNode; | |
72 SVGUseElement& useElement = toSVGUseElement(*shadowHostElement); | |
73 if (SVGElementInstance* instance = useElement.instanceForShadowTreeElement(r eferenceNode)) | |
74 return instance; | |
75 | 68 |
76 return referenceNode; | 69 return referenceNode; |
77 } | 70 } |
78 | 71 |
79 static inline bool inTheSameScope(ShadowRoot* shadowRoot, EventTarget* target) | 72 static inline bool inTheSameScope(ShadowRoot* shadowRoot, EventTarget* target) |
80 { | 73 { |
81 return target->toNode() && target->toNode()->treeScope().rootNode() == shado wRoot; | 74 return target->toNode() && target->toNode()->treeScope().rootNode() == shado wRoot; |
82 } | 75 } |
83 | 76 |
84 static inline EventDispatchBehavior determineDispatchBehavior(Event* event, Shad owRoot* shadowRoot, EventTarget* target) | 77 static inline EventDispatchBehavior determineDispatchBehavior(Event* event, Shad owRoot* shadowRoot, EventTarget* target) |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
379 } | 372 } |
380 #endif | 373 #endif |
381 | 374 |
382 void EventPath::trace(Visitor* visitor) | 375 void EventPath::trace(Visitor* visitor) |
383 { | 376 { |
384 visitor->trace(m_nodeEventContexts); | 377 visitor->trace(m_nodeEventContexts); |
385 visitor->trace(m_event); | 378 visitor->trace(m_event); |
386 } | 379 } |
387 | 380 |
388 } // namespace | 381 } // namespace |
OLD | NEW |