Chromium Code Reviews| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 return referenceNode->parentNode(); | 51 return referenceNode->parentNode(); |
| 52 | 52 |
| 53 return referenceNode; | 53 return referenceNode; |
| 54 } | 54 } |
| 55 | 55 |
| 56 static inline bool inTheSameScope(ShadowRoot* shadowRoot, EventTarget* target) | 56 static inline bool inTheSameScope(ShadowRoot* shadowRoot, EventTarget* target) |
| 57 { | 57 { |
| 58 return target->toNode() && target->toNode()->treeScope().rootNode() == shado wRoot; | 58 return target->toNode() && target->toNode()->treeScope().rootNode() == shado wRoot; |
| 59 } | 59 } |
| 60 | 60 |
| 61 static inline EventDispatchBehavior determineDispatchBehavior(Event* event, Shad owRoot* shadowRoot, EventTarget* target) | 61 static inline EventDispatchBehavior determineDispatchBehavior(Event* event, Node * current, EventTarget* target) |
| 62 { | 62 { |
| 63 ShadowRoot* shadowRoot = current->containingShadowRoot(); | |
| 64 if (!shadowRoot) | |
| 65 return RetargetEvent; | |
| 63 // WebKit never allowed selectstart event to cross the the shadow DOM bounda ry. | 66 // WebKit never allowed selectstart event to cross the the shadow DOM bounda ry. |
| 64 // Changing this breaks existing sites. | 67 // Changing this breaks existing sites. |
| 65 // See https://bugs.webkit.org/show_bug.cgi?id=52195 for details. | 68 // See https://bugs.webkit.org/show_bug.cgi?id=52195 for details. |
| 66 const AtomicString eventType = event->type(); | 69 const AtomicString eventType = event->type(); |
| 67 if (inTheSameScope(shadowRoot, target) | 70 if (inTheSameScope(shadowRoot, target) |
| 68 && (eventType == EventTypeNames::abort | 71 && (eventType == EventTypeNames::abort |
| 69 || eventType == EventTypeNames::change | 72 || eventType == EventTypeNames::change |
| 70 || eventType == EventTypeNames::error | 73 || eventType == EventTypeNames::error |
| 71 || eventType == EventTypeNames::load | 74 || eventType == EventTypeNames::load |
| 72 || eventType == EventTypeNames::reset | 75 || eventType == EventTypeNames::reset |
| 73 || eventType == EventTypeNames::resize | 76 || eventType == EventTypeNames::resize |
| 74 || eventType == EventTypeNames::scroll | 77 || eventType == EventTypeNames::scroll |
| 75 || eventType == EventTypeNames::select | 78 || eventType == EventTypeNames::select |
| 76 || eventType == EventTypeNames::selectstart)) | 79 || eventType == EventTypeNames::selectstart)) |
| 77 return StayInsideShadowDOM; | 80 return StayInsideShadowDOM; |
| 78 | 81 |
| 82 if (current->keepEventInShadowDOM(event)) | |
| 83 return StayInsideShadowDOM; | |
| 84 | |
| 79 return RetargetEvent; | 85 return RetargetEvent; |
| 80 } | 86 } |
| 81 | 87 |
| 82 EventPath::EventPath(Event* event) | 88 EventPath::EventPath(Event* event) |
| 83 : m_node(nullptr) | 89 : m_node(nullptr) |
| 84 , m_event(event) | 90 , m_event(event) |
| 85 { | 91 { |
| 86 } | 92 } |
| 87 | 93 |
| 88 EventPath::EventPath(Node* node) | 94 EventPath::EventPath(Node* node) |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 111 void EventPath::calculatePath() | 117 void EventPath::calculatePath() |
| 112 { | 118 { |
| 113 ASSERT(m_node); | 119 ASSERT(m_node); |
| 114 ASSERT(m_nodeEventContexts.isEmpty()); | 120 ASSERT(m_nodeEventContexts.isEmpty()); |
| 115 m_node->document().updateDistributionForNodeIfNeeded(const_cast<Node*>(m_nod e.get())); | 121 m_node->document().updateDistributionForNodeIfNeeded(const_cast<Node*>(m_nod e.get())); |
| 116 | 122 |
| 117 Node* current = m_node; | 123 Node* current = m_node; |
| 118 addNodeEventContext(current); | 124 addNodeEventContext(current); |
| 119 if (!m_node->inDocument()) | 125 if (!m_node->inDocument()) |
| 120 return; | 126 return; |
| 127 bool stopAtShadowRoot = false; | |
| 121 while (current) { | 128 while (current) { |
| 122 if (current->isShadowRoot() && m_event && determineDispatchBehavior(m_ev ent, toShadowRoot(current), m_node) == StayInsideShadowDOM) | 129 if (m_event && determineDispatchBehavior(m_event, current, m_node) == St ayInsideShadowDOM) |
|
hayato
2014/07/30 03:19:11
After the patch, determineDispatchBehavior will be
aberent
2014/07/31 10:52:47
See discussion on main review thread.
| |
| 130 stopAtShadowRoot = true; | |
| 131 if (current->isShadowRoot() && stopAtShadowRoot) | |
| 123 break; | 132 break; |
| 124 WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> insertionPoints; | 133 WillBeHeapVector<RawPtrWillBeMember<InsertionPoint>, 8> insertionPoints; |
| 125 collectDestinationInsertionPoints(*current, insertionPoints); | 134 collectDestinationInsertionPoints(*current, insertionPoints); |
| 126 if (!insertionPoints.isEmpty()) { | 135 if (!insertionPoints.isEmpty()) { |
| 127 for (size_t i = 0; i < insertionPoints.size(); ++i) { | 136 for (size_t i = 0; i < insertionPoints.size(); ++i) { |
| 128 InsertionPoint* insertionPoint = insertionPoints[i]; | 137 InsertionPoint* insertionPoint = insertionPoints[i]; |
| 129 if (insertionPoint->isShadowInsertionPoint()) { | 138 if (insertionPoint->isShadowInsertionPoint()) { |
| 130 ShadowRoot* containingShadowRoot = insertionPoint->containin gShadowRoot(); | 139 ShadowRoot* containingShadowRoot = insertionPoint->containin gShadowRoot(); |
| 131 ASSERT(containingShadowRoot); | 140 ASSERT(containingShadowRoot); |
| 132 if (!containingShadowRoot->isOldest()) | 141 if (!containingShadowRoot->isOldest()) |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 348 | 357 |
| 349 void EventPath::trace(Visitor* visitor) | 358 void EventPath::trace(Visitor* visitor) |
| 350 { | 359 { |
| 351 visitor->trace(m_nodeEventContexts); | 360 visitor->trace(m_nodeEventContexts); |
| 352 visitor->trace(m_node); | 361 visitor->trace(m_node); |
| 353 visitor->trace(m_event); | 362 visitor->trace(m_event); |
| 354 visitor->trace(m_treeScopeEventContexts); | 363 visitor->trace(m_treeScopeEventContexts); |
| 355 } | 364 } |
| 356 | 365 |
| 357 } // namespace | 366 } // namespace |
| OLD | NEW |