Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(787)

Side by Side Diff: Source/core/dom/EventRetargeter.cpp

Issue 14296003: Remove TOUCH_EVENTS and TOUCH_EVENT_TRACKING compile-time flags. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/EventRetargeter.h ('k') | Source/core/dom/Node.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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)
84 bool isTouchEvent = event->isTouchEvent(); 83 bool isTouchEvent = event->isTouchEvent();
85 #endif
86 Vector<EventTarget*, 32> targetStack; 84 Vector<EventTarget*, 32> targetStack;
87 for (EventPathWalker walker(node); walker.node(); walker.moveToParent()) { 85 for (EventPathWalker walker(node); walker.node(); walker.moveToParent()) {
88 Node* node = walker.node(); 86 Node* node = walker.node();
89 if (targetStack.isEmpty()) 87 if (targetStack.isEmpty())
90 targetStack.append(eventTargetRespectingTargetRules(node)); 88 targetStack.append(eventTargetRespectingTargetRules(node));
91 else if (walker.isVisitingInsertionPointInReprojection()) 89 else if (walker.isVisitingInsertionPointInReprojection())
92 targetStack.append(targetStack.last()); 90 targetStack.append(targetStack.last());
93 if (isMouseOrFocusEvent) 91 if (isMouseOrFocusEvent)
94 eventPath.append(adoptPtr(new MouseOrFocusEventContext(node, eventTa rgetRespectingTargetRules(node), targetStack.last()))); 92 eventPath.append(adoptPtr(new MouseOrFocusEventContext(node, eventTa rgetRespectingTargetRules(node), targetStack.last())));
95 #if ENABLE(TOUCH_EVENTS)
96 else if (isTouchEvent) 93 else if (isTouchEvent)
97 eventPath.append(adoptPtr(new TouchEventContext(node, eventTargetRes pectingTargetRules(node), targetStack.last()))); 94 eventPath.append(adoptPtr(new TouchEventContext(node, eventTargetRes pectingTargetRules(node), targetStack.last())));
98 #endif
99 else 95 else
100 eventPath.append(adoptPtr(new EventContext(node, eventTargetRespecti ngTargetRules(node), targetStack.last()))); 96 eventPath.append(adoptPtr(new EventContext(node, eventTargetRespecti ngTargetRules(node), targetStack.last())));
101 if (!inDocument) 97 if (!inDocument)
102 return; 98 return;
103 if (!node->isShadowRoot()) 99 if (!node->isShadowRoot())
104 continue; 100 continue;
105 if (determineDispatchBehavior(event, toShadowRoot(node), targetStack.las t()) == StayInsideShadowDOM) 101 if (determineDispatchBehavior(event, toShadowRoot(node), targetStack.las t()) == StayInsideShadowDOM)
106 return; 102 return;
107 if (!isSVGElement) { 103 if (!isSVGElement) {
108 ASSERT(!targetStack.isEmpty()); 104 ASSERT(!targetStack.isEmpty());
109 targetStack.removeLast(); 105 targetStack.removeLast();
110 } 106 }
111 } 107 }
112 } 108 }
113 109
114 void EventRetargeter::adjustForMouseEvent(Node* node, const MouseEvent& mouseEve nt, EventPath& eventPath) 110 void EventRetargeter::adjustForMouseEvent(Node* node, const MouseEvent& mouseEve nt, EventPath& eventPath)
115 { 111 {
116 adjustForRelatedTarget(node, mouseEvent.relatedTarget(), eventPath); 112 adjustForRelatedTarget(node, mouseEvent.relatedTarget(), eventPath);
117 } 113 }
118 114
119 void EventRetargeter::adjustForFocusEvent(Node* node, const FocusEvent& focusEve nt, EventPath& eventPath) 115 void EventRetargeter::adjustForFocusEvent(Node* node, const FocusEvent& focusEve nt, EventPath& eventPath)
120 { 116 {
121 adjustForRelatedTarget(node, focusEvent.relatedTarget(), eventPath); 117 adjustForRelatedTarget(node, focusEvent.relatedTarget(), eventPath);
122 } 118 }
123 119
124 #if ENABLE(TOUCH_EVENTS)
125 void EventRetargeter::adjustForTouchEvent(Node* node, const TouchEvent& touchEve nt, EventPath& eventPath) 120 void EventRetargeter::adjustForTouchEvent(Node* node, const TouchEvent& touchEve nt, EventPath& eventPath)
126 { 121 {
127 size_t eventPathSize = eventPath.size(); 122 size_t eventPathSize = eventPath.size();
128 123
129 EventPathTouchLists eventPathTouches(eventPathSize); 124 EventPathTouchLists eventPathTouches(eventPathSize);
130 EventPathTouchLists eventPathTargetTouches(eventPathSize); 125 EventPathTouchLists eventPathTargetTouches(eventPathSize);
131 EventPathTouchLists eventPathChangedTouches(eventPathSize); 126 EventPathTouchLists eventPathChangedTouches(eventPathSize);
132 127
133 for (size_t i = 0; i < eventPathSize; ++i) { 128 for (size_t i = 0; i < eventPathSize; ++i) {
134 ASSERT(eventPath[i]->isTouchEventContext()); 129 ASSERT(eventPath[i]->isTouchEventContext());
(...skipping 16 matching lines...) Expand all
151 ASSERT(eventPathTouchLists.size() == eventPathSize); 146 ASSERT(eventPathTouchLists.size() == eventPathSize);
152 for (size_t i = 0; i < touchList->length(); ++i) { 147 for (size_t i = 0; i < touchList->length(); ++i) {
153 const Touch& touch = *touchList->item(i); 148 const Touch& touch = *touchList->item(i);
154 AdjustedNodes adjustedNodes; 149 AdjustedNodes adjustedNodes;
155 calculateAdjustedNodes(node, touch.target()->toNode(), DoesNotStopAtBoun dary, const_cast<EventPath&>(eventPath), adjustedNodes); 150 calculateAdjustedNodes(node, touch.target()->toNode(), DoesNotStopAtBoun dary, const_cast<EventPath&>(eventPath), adjustedNodes);
156 ASSERT(adjustedNodes.size() == eventPathSize); 151 ASSERT(adjustedNodes.size() == eventPathSize);
157 for (size_t j = 0; j < eventPathSize; ++j) 152 for (size_t j = 0; j < eventPathSize; ++j)
158 eventPathTouchLists[j]->append(touch.cloneWithNewTarget(adjustedNode s[j].get())); 153 eventPathTouchLists[j]->append(touch.cloneWithNewTarget(adjustedNode s[j].get()));
159 } 154 }
160 } 155 }
161 #endif
162 156
163 void EventRetargeter::adjustForRelatedTarget(const Node* node, EventTarget* rela tedTarget, EventPath& eventPath) 157 void EventRetargeter::adjustForRelatedTarget(const Node* node, EventTarget* rela tedTarget, EventPath& eventPath)
164 { 158 {
165 if (!node) 159 if (!node)
166 return; 160 return;
167 if (!relatedTarget) 161 if (!relatedTarget)
168 return; 162 return;
169 Node* relatedNode = relatedTarget->toNode(); 163 Node* relatedNode = relatedTarget->toNode();
170 if (!relatedNode) 164 if (!relatedNode)
171 return; 165 return;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 break; 243 break;
250 } 244 }
251 scope = scope->parentTreeScope(); 245 scope = scope->parentTreeScope();
252 } 246 }
253 for (Vector<TreeScope*, 32>::iterator iter = parentTreeScopes.begin(); iter < parentTreeScopes.end(); ++iter) 247 for (Vector<TreeScope*, 32>::iterator iter = parentTreeScopes.begin(); iter < parentTreeScopes.end(); ++iter)
254 relatedNodeMap.add(*iter, relatedNode); 248 relatedNodeMap.add(*iter, relatedNode);
255 return relatedNode; 249 return relatedNode;
256 } 250 }
257 251
258 } 252 }
OLDNEW
« no previous file with comments | « Source/core/dom/EventRetargeter.h ('k') | Source/core/dom/Node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698