| 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 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return StayInsideShadowDOM; | 73 return StayInsideShadowDOM; |
| 74 | 74 |
| 75 return RetargetEvent; | 75 return RetargetEvent; |
| 76 } | 76 } |
| 77 | 77 |
| 78 void EventRetargeter::calculateEventPath(Node* node, Event* event, EventPath& ev
entPath) | 78 void EventRetargeter::calculateEventPath(Node* node, Event* event, EventPath& ev
entPath) |
| 79 { | 79 { |
| 80 bool inDocument = node->inDocument(); | 80 bool inDocument = node->inDocument(); |
| 81 bool isSVGElement = node->isSVGElement(); | 81 bool isSVGElement = node->isSVGElement(); |
| 82 bool isMouseOrFocusEvent = event->isMouseEvent() || event->isFocusEvent(); | 82 bool isMouseOrFocusEvent = event->isMouseEvent() || event->isFocusEvent(); |
| 83 #if ENABLE(TOUCH_EVENTS) |
| 83 bool isTouchEvent = event->isTouchEvent(); | 84 bool isTouchEvent = event->isTouchEvent(); |
| 85 #endif |
| 84 Vector<EventTarget*, 32> targetStack; | 86 Vector<EventTarget*, 32> targetStack; |
| 85 for (EventPathWalker walker(node); walker.node(); walker.moveToParent()) { | 87 for (EventPathWalker walker(node); walker.node(); walker.moveToParent()) { |
| 86 Node* node = walker.node(); | 88 Node* node = walker.node(); |
| 87 if (targetStack.isEmpty()) | 89 if (targetStack.isEmpty()) |
| 88 targetStack.append(eventTargetRespectingTargetRules(node)); | 90 targetStack.append(eventTargetRespectingTargetRules(node)); |
| 89 else if (walker.isVisitingInsertionPointInReprojection()) | 91 else if (walker.isVisitingInsertionPointInReprojection()) |
| 90 targetStack.append(targetStack.last()); | 92 targetStack.append(targetStack.last()); |
| 91 if (isMouseOrFocusEvent) | 93 if (isMouseOrFocusEvent) |
| 92 eventPath.append(adoptPtr(new MouseOrFocusEventContext(node, eventTa
rgetRespectingTargetRules(node), targetStack.last()))); | 94 eventPath.append(adoptPtr(new MouseOrFocusEventContext(node, eventTa
rgetRespectingTargetRules(node), targetStack.last()))); |
| 95 #if ENABLE(TOUCH_EVENTS) |
| 93 else if (isTouchEvent) | 96 else if (isTouchEvent) |
| 94 eventPath.append(adoptPtr(new TouchEventContext(node, eventTargetRes
pectingTargetRules(node), targetStack.last()))); | 97 eventPath.append(adoptPtr(new TouchEventContext(node, eventTargetRes
pectingTargetRules(node), targetStack.last()))); |
| 98 #endif |
| 95 else | 99 else |
| 96 eventPath.append(adoptPtr(new EventContext(node, eventTargetRespecti
ngTargetRules(node), targetStack.last()))); | 100 eventPath.append(adoptPtr(new EventContext(node, eventTargetRespecti
ngTargetRules(node), targetStack.last()))); |
| 97 if (!inDocument) | 101 if (!inDocument) |
| 98 return; | 102 return; |
| 99 if (!node->isShadowRoot()) | 103 if (!node->isShadowRoot()) |
| 100 continue; | 104 continue; |
| 101 if (determineDispatchBehavior(event, toShadowRoot(node), targetStack.las
t()) == StayInsideShadowDOM) | 105 if (determineDispatchBehavior(event, toShadowRoot(node), targetStack.las
t()) == StayInsideShadowDOM) |
| 102 return; | 106 return; |
| 103 if (!isSVGElement) { | 107 if (!isSVGElement) { |
| 104 ASSERT(!targetStack.isEmpty()); | 108 ASSERT(!targetStack.isEmpty()); |
| 105 targetStack.removeLast(); | 109 targetStack.removeLast(); |
| 106 } | 110 } |
| 107 } | 111 } |
| 108 } | 112 } |
| 109 | 113 |
| 110 void EventRetargeter::adjustForMouseEvent(Node* node, const MouseEvent& mouseEve
nt, EventPath& eventPath) | 114 void EventRetargeter::adjustForMouseEvent(Node* node, const MouseEvent& mouseEve
nt, EventPath& eventPath) |
| 111 { | 115 { |
| 112 adjustForRelatedTarget(node, mouseEvent.relatedTarget(), eventPath); | 116 adjustForRelatedTarget(node, mouseEvent.relatedTarget(), eventPath); |
| 113 } | 117 } |
| 114 | 118 |
| 115 void EventRetargeter::adjustForFocusEvent(Node* node, const FocusEvent& focusEve
nt, EventPath& eventPath) | 119 void EventRetargeter::adjustForFocusEvent(Node* node, const FocusEvent& focusEve
nt, EventPath& eventPath) |
| 116 { | 120 { |
| 117 adjustForRelatedTarget(node, focusEvent.relatedTarget(), eventPath); | 121 adjustForRelatedTarget(node, focusEvent.relatedTarget(), eventPath); |
| 118 } | 122 } |
| 119 | 123 |
| 124 #if ENABLE(TOUCH_EVENTS) |
| 120 void EventRetargeter::adjustForTouchEvent(Node* node, const TouchEvent& touchEve
nt, EventPath& eventPath) | 125 void EventRetargeter::adjustForTouchEvent(Node* node, const TouchEvent& touchEve
nt, EventPath& eventPath) |
| 121 { | 126 { |
| 122 size_t eventPathSize = eventPath.size(); | 127 size_t eventPathSize = eventPath.size(); |
| 123 | 128 |
| 124 EventPathTouchLists eventPathTouches(eventPathSize); | 129 EventPathTouchLists eventPathTouches(eventPathSize); |
| 125 EventPathTouchLists eventPathTargetTouches(eventPathSize); | 130 EventPathTouchLists eventPathTargetTouches(eventPathSize); |
| 126 EventPathTouchLists eventPathChangedTouches(eventPathSize); | 131 EventPathTouchLists eventPathChangedTouches(eventPathSize); |
| 127 | 132 |
| 128 for (size_t i = 0; i < eventPathSize; ++i) { | 133 for (size_t i = 0; i < eventPathSize; ++i) { |
| 129 ASSERT(eventPath[i]->isTouchEventContext()); | 134 ASSERT(eventPath[i]->isTouchEventContext()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 146 ASSERT(eventPathTouchLists.size() == eventPathSize); | 151 ASSERT(eventPathTouchLists.size() == eventPathSize); |
| 147 for (size_t i = 0; i < touchList->length(); ++i) { | 152 for (size_t i = 0; i < touchList->length(); ++i) { |
| 148 const Touch& touch = *touchList->item(i); | 153 const Touch& touch = *touchList->item(i); |
| 149 AdjustedNodes adjustedNodes; | 154 AdjustedNodes adjustedNodes; |
| 150 calculateAdjustedNodes(node, touch.target()->toNode(), DoesNotStopAtBoun
dary, const_cast<EventPath&>(eventPath), adjustedNodes); | 155 calculateAdjustedNodes(node, touch.target()->toNode(), DoesNotStopAtBoun
dary, const_cast<EventPath&>(eventPath), adjustedNodes); |
| 151 ASSERT(adjustedNodes.size() == eventPathSize); | 156 ASSERT(adjustedNodes.size() == eventPathSize); |
| 152 for (size_t j = 0; j < eventPathSize; ++j) | 157 for (size_t j = 0; j < eventPathSize; ++j) |
| 153 eventPathTouchLists[j]->append(touch.cloneWithNewTarget(adjustedNode
s[j].get())); | 158 eventPathTouchLists[j]->append(touch.cloneWithNewTarget(adjustedNode
s[j].get())); |
| 154 } | 159 } |
| 155 } | 160 } |
| 161 #endif |
| 156 | 162 |
| 157 void EventRetargeter::adjustForRelatedTarget(const Node* node, EventTarget* rela
tedTarget, EventPath& eventPath) | 163 void EventRetargeter::adjustForRelatedTarget(const Node* node, EventTarget* rela
tedTarget, EventPath& eventPath) |
| 158 { | 164 { |
| 159 if (!node) | 165 if (!node) |
| 160 return; | 166 return; |
| 161 if (!relatedTarget) | 167 if (!relatedTarget) |
| 162 return; | 168 return; |
| 163 Node* relatedNode = relatedTarget->toNode(); | 169 Node* relatedNode = relatedTarget->toNode(); |
| 164 if (!relatedNode) | 170 if (!relatedNode) |
| 165 return; | 171 return; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 break; | 249 break; |
| 244 } | 250 } |
| 245 scope = scope->parentTreeScope(); | 251 scope = scope->parentTreeScope(); |
| 246 } | 252 } |
| 247 for (Vector<TreeScope*, 32>::iterator iter = parentTreeScopes.begin(); iter
< parentTreeScopes.end(); ++iter) | 253 for (Vector<TreeScope*, 32>::iterator iter = parentTreeScopes.begin(); iter
< parentTreeScopes.end(); ++iter) |
| 248 relatedNodeMap.add(*iter, relatedNode); | 254 relatedNodeMap.add(*iter, relatedNode); |
| 249 return relatedNode; | 255 return relatedNode; |
| 250 } | 256 } |
| 251 | 257 |
| 252 } | 258 } |
| OLD | NEW |