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

Side by Side Diff: third_party/WebKit/Source/core/input/TouchEventManager.cpp

Issue 2860663006: Remove WebTouchEvent from TouchEventManager APIs (Closed)
Patch Set: Apply the comments Created 3 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/input/TouchEventManager.h" 5 #include "core/input/TouchEventManager.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 #include "core/events/TouchEvent.h" 9 #include "core/events/TouchEvent.h"
10 #include "core/frame/Deprecation.h" 10 #include "core/frame/Deprecation.h"
(...skipping 19 matching lines...) Expand all
30 return registry.HasEventHandlers( 30 return registry.HasEventHandlers(
31 EventHandlerRegistry::kTouchStartOrMoveEventBlocking) || 31 EventHandlerRegistry::kTouchStartOrMoveEventBlocking) ||
32 registry.HasEventHandlers( 32 registry.HasEventHandlers(
33 EventHandlerRegistry::kTouchStartOrMoveEventPassive) || 33 EventHandlerRegistry::kTouchStartOrMoveEventPassive) ||
34 registry.HasEventHandlers( 34 registry.HasEventHandlers(
35 EventHandlerRegistry::kTouchEndOrCancelEventBlocking) || 35 EventHandlerRegistry::kTouchEndOrCancelEventBlocking) ||
36 registry.HasEventHandlers( 36 registry.HasEventHandlers(
37 EventHandlerRegistry::kTouchEndOrCancelEventPassive); 37 EventHandlerRegistry::kTouchEndOrCancelEventPassive);
38 } 38 }
39 39
40 const AtomicString& TouchEventNameForTouchPointState( 40 const AtomicString& TouchEventNameForPointerEventType(
41 WebTouchPoint::State state) { 41 WebInputEvent::Type type) {
42 switch (state) { 42 switch (type) {
43 case WebTouchPoint::kStateReleased: 43 case WebInputEvent::kPointerUp:
44 return EventTypeNames::touchend; 44 return EventTypeNames::touchend;
45 case WebTouchPoint::kStateCancelled: 45 case WebInputEvent::kPointerCancel:
46 return EventTypeNames::touchcancel; 46 return EventTypeNames::touchcancel;
47 case WebTouchPoint::kStatePressed: 47 case WebInputEvent::kPointerDown:
48 return EventTypeNames::touchstart; 48 return EventTypeNames::touchstart;
49 case WebTouchPoint::kStateMoved: 49 case WebInputEvent::kPointerMove:
50 return EventTypeNames::touchmove; 50 return EventTypeNames::touchmove;
51 case WebTouchPoint::kStateStationary:
52 // Fall through to default
53 default: 51 default:
54 NOTREACHED(); 52 NOTREACHED();
55 return g_empty_atom; 53 return g_empty_atom;
56 } 54 }
57 } 55 }
58 56
59 enum TouchEventDispatchResultType { 57 enum TouchEventDispatchResultType {
60 kUnhandledTouches, // Unhandled touch events. 58 kUnhandledTouches, // Unhandled touch events.
61 kHandledTouches, // Handled touch events. 59 kHandledTouches, // Handled touch events.
62 kTouchEventDispatchResultTypeMax, 60 kTouchEventDispatchResultTypeMax,
63 }; 61 };
64 62
65 bool IsTouchSequenceStart(const WebTouchEvent& event) { 63 WebTouchPoint::State TouchPointStateFromPointerEventType(
66 if (!event.touches_length) 64 WebInputEvent::Type type,
67 return false; 65 bool stale) {
68 if (event.GetType() != WebInputEvent::kTouchStart) 66 if (stale)
69 return false; 67 return WebTouchPoint::kStateStationary;
70 for (size_t i = 0; i < event.touches_length; ++i) { 68 switch (type) {
71 if (event.touches[i].state != blink::WebTouchPoint::kStatePressed) 69 case WebInputEvent::Type::kPointerUp:
72 return false; 70 return WebTouchPoint::kStateReleased;
71 case WebInputEvent::Type::kPointerCancel:
72 return WebTouchPoint::kStateCancelled;
73 case WebInputEvent::Type::kPointerDown:
74 return WebTouchPoint::kStatePressed;
75 case WebInputEvent::Type::kPointerMove:
76 return WebTouchPoint::kStateMoved;
77 default:
78 NOTREACHED();
79 return WebTouchPoint::kStateUndefined;
73 } 80 }
74 return true;
75 } 81 }
76 82
77 // Defining this class type local to dispatchTouchEvents() and annotating 83 // Defining this class type local to dispatchTouchEvents() and annotating
78 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning 84 // it with STACK_ALLOCATED(), runs into MSVC(VS 2013)'s C4822 warning
79 // that the local class doesn't provide a local definition for 'operator new'. 85 // that the local class doesn't provide a local definition for 'operator new'.
80 // Which it intentionally doesn't and shouldn't. 86 // Which it intentionally doesn't and shouldn't.
81 // 87 //
82 // Work around such toolchain bugginess by lifting out the type, thereby 88 // Work around such toolchain bugginess by lifting out the type, thereby
83 // taking it out of C4822's reach. 89 // taking it out of C4822's reach.
84 class ChangedTouches final { 90 class ChangedTouches final {
85 STACK_ALLOCATED(); 91 STACK_ALLOCATED();
86 92
87 public: 93 public:
88 // The touches corresponding to the particular change state this struct 94 // The touches corresponding to the particular change state this struct
89 // instance represents. 95 // instance represents.
90 Member<TouchList> touches_; 96 Member<TouchList> touches_;
91 97
92 using EventTargetSet = HeapHashSet<Member<EventTarget>>; 98 using EventTargetSet = HeapHashSet<Member<EventTarget>>;
93 // Set of targets involved in m_touches. 99 // Set of targets involved in m_touches.
94 EventTargetSet targets_; 100 EventTargetSet targets_;
95
96 WebPointerProperties::PointerType pointer_type_;
97 }; 101 };
98 102
99 } // namespace 103 } // namespace
100 104
101 TouchEventManager::TouchEventManager(LocalFrame& frame) : frame_(frame) { 105 TouchEventManager::TouchEventManager(LocalFrame& frame) : frame_(frame) {
102 Clear(); 106 Clear();
103 } 107 }
104 108
105 void TouchEventManager::Clear() { 109 void TouchEventManager::Clear() {
106 touch_sequence_document_.Clear(); 110 touch_sequence_document_.Clear();
107 target_for_touch_id_.clear(); 111 touch_points_attributes_.clear();
108 region_for_touch_id_.clear();
109 touch_pressed_ = false;
110 suppressing_touchmoves_within_slop_ = false; 112 suppressing_touchmoves_within_slop_ = false;
111 current_touch_action_ = TouchAction::kTouchActionAuto; 113 current_touch_action_ = TouchAction::kTouchActionAuto;
112 } 114 }
113 115
114 DEFINE_TRACE(TouchEventManager) { 116 DEFINE_TRACE(TouchEventManager) {
115 visitor->Trace(frame_); 117 visitor->Trace(frame_);
116 visitor->Trace(touch_sequence_document_); 118 visitor->Trace(touch_sequence_document_);
117 visitor->Trace(target_for_touch_id_); 119 visitor->Trace(touch_points_attributes_);
118 } 120 }
119 121
120 Touch* TouchEventManager::CreateDomTouch(const WebTouchPoint& point, 122 Touch* TouchEventManager::CreateDomTouch(
121 bool* known_target) { 123 const TouchEventManager::TouchPointAttributes* point_attr,
122 Node* touch_node = nullptr; 124 bool* known_target) {
123 String region_id; 125 Node* touch_node = point_attr->target_;
126 String region_id = point_attr->region_;
124 *known_target = false; 127 *known_target = false;
125 FloatPoint content_point; 128 FloatPoint content_point;
126 FloatSize adjusted_radius; 129 FloatSize adjusted_radius;
127 130
128 if (point.state == WebTouchPoint::kStateReleased ||
129 point.state == WebTouchPoint::kStateCancelled) {
130 // The target should be the original target for this touch, so get
131 // it from the hashmap. As it's a release or cancel we also remove
132 // it from the map.
133 touch_node = target_for_touch_id_.Take(point.id);
134 region_id = region_for_touch_id_.Take(point.id);
135 } else {
136 // No hittest is performed on move or stationary, since the target
137 // is not allowed to change anyway.
138 touch_node = target_for_touch_id_.at(point.id);
139 region_id = region_for_touch_id_.at(point.id);
140 }
141
142 LocalFrame* target_frame = nullptr; 131 LocalFrame* target_frame = nullptr;
143 if (touch_node) { 132 if (touch_node) {
144 Document& doc = touch_node->GetDocument(); 133 Document& doc = touch_node->GetDocument();
145 // If the target node has moved to a new document while it was being 134 // If the target node has moved to a new document while it was being
146 // touched, we can't send events to the new document because that could 135 // touched, we can't send events to the new document because that could
147 // leak nodes from one document to another. See http://crbug.com/394339. 136 // leak nodes from one document to another. See http://crbug.com/394339.
148 if (&doc == touch_sequence_document_.Get()) { 137 if (&doc == touch_sequence_document_.Get()) {
149 target_frame = doc.GetFrame(); 138 target_frame = doc.GetFrame();
150 *known_target = true; 139 *known_target = true;
151 } 140 }
(...skipping 10 matching lines...) Expand all
162 // Document so that there's some valid node here. Perhaps this 151 // Document so that there's some valid node here. Perhaps this
163 // should really be LocalDOMWindow, but in all other cases the target of 152 // should really be LocalDOMWindow, but in all other cases the target of
164 // a Touch is a Node so using the window could be a breaking change. 153 // a Touch is a Node so using the window could be a breaking change.
165 // Since we know there was no handler invoked, the specific target 154 // Since we know there was no handler invoked, the specific target
166 // should be completely irrelevant to the application. 155 // should be completely irrelevant to the application.
167 touch_node = touch_sequence_document_; 156 touch_node = touch_sequence_document_;
168 target_frame = touch_sequence_document_->GetFrame(); 157 target_frame = touch_sequence_document_->GetFrame();
169 } 158 }
170 DCHECK(target_frame); 159 DCHECK(target_frame);
171 160
161 WebPointerEvent transformed_event =
162 point_attr->event_.WebPointerEventInRootFrame();
172 // pagePoint should always be in the target element's document coordinates. 163 // pagePoint should always be in the target element's document coordinates.
173 FloatPoint page_point = 164 FloatPoint page_point = target_frame->View()->RootFrameToContents(
174 target_frame->View()->RootFrameToContents(point.PositionInWidget()); 165 transformed_event.PositionInWidget());
175 float scale_factor = 1.0f / target_frame->PageZoomFactor(); 166 float scale_factor = 1.0f / target_frame->PageZoomFactor();
176 167
177 content_point = page_point.ScaledBy(scale_factor); 168 content_point = page_point.ScaledBy(scale_factor);
178 adjusted_radius = 169 adjusted_radius = FloatSize(transformed_event.width, transformed_event.height)
179 FloatSize(point.radius_x, point.radius_y).ScaledBy(scale_factor); 170 .ScaledBy(scale_factor);
180 171
181 return Touch::Create(target_frame, touch_node, point.id, 172 return Touch::Create(target_frame, touch_node, point_attr->event_.id,
182 point.PositionInScreen(), content_point, adjusted_radius, 173 transformed_event.PositionInScreen(), content_point,
183 point.rotation_angle, point.force, region_id); 174 adjusted_radius, transformed_event.rotation_angle,
175 transformed_event.force, region_id);
184 } 176 }
185 177
186 WebInputEventResult TouchEventManager::DispatchTouchEvents( 178 WebCoalescedInputEvent TouchEventManager::GenerateWebCoalescedInputEvent() {
187 const WebTouchEvent& event, 179 DCHECK(!touch_points_attributes_.IsEmpty());
188 const Vector<WebTouchEvent>& coalesced_events, 180
189 bool all_touches_released) { 181 WebTouchEvent event;
182
183 const auto& first_touch_pointer_event =
184 touch_points_attributes_.begin()->value->event_;
185 event.dispatch_type = first_touch_pointer_event.dispatch_type;
186 event.touch_start_or_first_touch_move =
187 first_touch_pointer_event.touch_start_or_first_touch_move;
188 event.moved_beyond_slop_region =
189 first_touch_pointer_event.moved_beyond_slop_region;
190 event.dispatch_type = first_touch_pointer_event.dispatch_type;
191 event.dispatch_type = first_touch_pointer_event.dispatch_type;
192 event.SetFrameScale(first_touch_pointer_event.FrameScale());
193 event.SetFrameTranslate(first_touch_pointer_event.FrameTranslate());
194 event.SetTimeStampSeconds(first_touch_pointer_event.TimeStampSeconds());
195 event.SetModifiers(first_touch_pointer_event.GetModifiers());
196
197 WebInputEvent::Type touch_event_type = WebInputEvent::kTouchMove;
198 Vector<WebPointerEvent> all_coalesced_events;
199 Vector<int> available_ids;
200 for (const auto& id : touch_points_attributes_.Keys())
201 available_ids.push_back(id);
202 std::sort(available_ids.begin(), available_ids.end());
203 for (const int& touch_point_id : available_ids) {
204 const auto& touch_point_attribute =
205 touch_points_attributes_.at(touch_point_id);
206 const WebPointerEvent& touch_pointer_event = touch_point_attribute->event_;
207 WebTouchPoint web_touch_point(touch_pointer_event);
208 web_touch_point.state = TouchPointStateFromPointerEventType(
209 touch_pointer_event.GetType(), touch_point_attribute->stale_);
210 web_touch_point.radius_x = touch_pointer_event.width;
mustaq 2017/06/09 16:12:27 Repeat the TODO here for radius/width problem.
Navid Zolghadr 2017/06/12 16:17:31 I didn't have TODO anywhere else. I added a TODO h
211 web_touch_point.radius_y = touch_pointer_event.height;
212 web_touch_point.rotation_angle = touch_pointer_event.rotation_angle;
213 event.touches[event.touches_length++] = web_touch_point;
214
215 // Only change the touch event type from move. So if we have two pointers
216 // in up and down state we just set the touch event type to the first one
217 // we see.
218 if (touch_event_type == WebInputEvent::kTouchMove) {
mustaq 2017/06/09 16:12:27 You already hardcoded the event type in Line 197 a
Navid Zolghadr 2017/06/12 16:17:31 This is in a for loop. So the value of the touch_e
219 if (touch_pointer_event.GetType() == WebInputEvent::kPointerDown)
220 touch_event_type = WebInputEvent::kTouchStart;
221 else if (touch_pointer_event.GetType() == WebInputEvent::kPointerCancel)
222 touch_event_type = WebInputEvent::kTouchCancel;
223 else if (touch_pointer_event.GetType() == WebInputEvent::kPointerUp)
224 touch_event_type = WebInputEvent::kTouchEnd;
225 }
226
227 event.SetType(touch_event_type);
228
229 for (const WebPointerEvent& coalesced_event :
230 touch_point_attribute->coalesced_events_)
231 all_coalesced_events.push_back(coalesced_event);
232 }
233
234 // Create all coalesced touch events based on pointerevents
235 struct {
236 bool operator()(const WebPointerEvent& a, const WebPointerEvent& b) {
237 return a.TimeStampSeconds() < b.TimeStampSeconds();
238 }
239 } timestamp_based_event_comparison;
240 std::sort(all_coalesced_events.begin(), all_coalesced_events.end(),
241 timestamp_based_event_comparison);
242 WebCoalescedInputEvent result(event);
243 // This assumes that we only get move events as coalesced events.
mustaq 2017/06/09 16:12:27 This comment also applies to the above hardcoded k
Navid Zolghadr 2017/06/12 16:17:31 I added a DCHECK. However, I also changed the code
244 for (const auto& web_pointer_event : all_coalesced_events) {
245 for (unsigned i = 0; i < event.touches_length; ++i) {
246 if (event.touches[i].id == web_pointer_event.id &&
247 event.touches[i].state == blink::WebTouchPoint::kStateMoved &&
248 web_pointer_event.GetType() == WebInputEvent::kPointerMove) {
249 event.touches[i].movement_x = web_pointer_event.movement_x;
250 event.touches[i].movement_y = web_pointer_event.movement_y;
251 event.SetTimeStampSeconds(web_pointer_event.TimeStampSeconds());
252 result.AddCoalescedEvent(event);
253 break;
254 }
255 }
256 for (unsigned i = 0; i < event.touches_length; ++i) {
mustaq 2017/06/09 16:12:27 After adding to the coalesced events, |event| is n
Navid Zolghadr 2017/06/12 16:17:31 It's used for the next coalesced event (i.e. next
257 event.touches[i].state = blink::WebTouchPoint::kStateStationary;
258 event.touches[i].movement_x = 0;
259 event.touches[i].movement_y = 0;
260 }
261 }
262
263 return result;
264 }
265
266 WebInputEventResult TouchEventManager::DispatchTouchEvents() {
190 // Build up the lists to use for the |touches|, |targetTouches| and 267 // Build up the lists to use for the |touches|, |targetTouches| and
191 // |changedTouches| attributes in the JS event. See 268 // |changedTouches| attributes in the JS event. See
192 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these 269 // http://www.w3.org/TR/touch-events/#touchevent-interface for how these
193 // lists fit together. 270 // lists fit together.
194 271
195 if (event.GetType() == WebInputEvent::kTouchEnd || 272 bool new_touch_point_since_last_raf = false;
mustaq 2017/06/09 16:12:27 Let's not use "raf" here since this method will ev
Navid Zolghadr 2017/06/12 16:17:31 Done.
196 event.GetType() == WebInputEvent::kTouchCancel || 273 bool any_touch_canceled_ended = false;
mustaq 2017/06/09 16:12:27 ..._canceled_or_ended?
Navid Zolghadr 2017/06/12 16:17:32 Done.
197 event.touches_length > 1) { 274 bool all_touch_points_pressed = true;
198 suppressing_touchmoves_within_slop_ = false; 275
276 for (const auto& attr : touch_points_attributes_.Values()) {
277 if (!attr->stale_)
278 new_touch_point_since_last_raf = true;
279 if (attr->event_.GetType() == WebInputEvent::kPointerUp ||
280 attr->event_.GetType() == WebInputEvent::kPointerCancel)
281 any_touch_canceled_ended = true;
282 if (attr->event_.GetType() != WebInputEvent::kPointerDown)
283 all_touch_points_pressed = false;
199 } 284 }
200 285
201 if (suppressing_touchmoves_within_slop_ && 286 if (!new_touch_point_since_last_raf)
202 event.GetType() == WebInputEvent::kTouchMove) { 287 return WebInputEventResult::kNotHandled;
203 if (!event.moved_beyond_slop_region) 288
204 return WebInputEventResult::kHandledSuppressed; 289 if (any_touch_canceled_ended || touch_points_attributes_.size() > 1)
205 suppressing_touchmoves_within_slop_ = false; 290 suppressing_touchmoves_within_slop_ = false;
291
292 if (suppressing_touchmoves_within_slop_) {
293 // There is exactly one touch point here otherwise
294 // |suppressing_touchmoves_within_slop_| would have been false.
295 DCHECK_EQ(touch_points_attributes_.size(), 1);
296 const auto& touch_point_attribute = touch_points_attributes_.begin()->value;
297 if (touch_point_attribute->event_.GetType() ==
298 WebInputEvent::kPointerMove) {
299 if (!touch_point_attribute->event_.moved_beyond_slop_region)
300 return WebInputEventResult::kHandledSuppressed;
301 suppressing_touchmoves_within_slop_ = false;
302 }
206 } 303 }
207 304
208 // Holds the complete set of touches on the screen. 305 // Holds the complete set of touches on the screen.
209 TouchList* touches = TouchList::Create(); 306 TouchList* touches = TouchList::Create();
210 307
211 // A different view on the 'touches' list above, filtered and grouped by 308 // A different view on the 'touches' list above, filtered and grouped by
212 // event target. Used for the |targetTouches| list in the JS event. 309 // event target. Used for the |targetTouches| list in the JS event.
213 using TargetTouchesHeapMap = HeapHashMap<EventTarget*, Member<TouchList>>; 310 using TargetTouchesHeapMap = HeapHashMap<EventTarget*, Member<TouchList>>;
214 TargetTouchesHeapMap touches_by_target; 311 TargetTouchesHeapMap touches_by_target;
215 312
216 // Array of touches per state, used to assemble the |changedTouches| list. 313 // Array of touches per state, used to assemble the |changedTouches| list.
217 ChangedTouches changed_touches[WebTouchPoint::kStateMax + 1]; 314 ChangedTouches changed_touches[WebInputEvent::kPointerTypeLast -
315 WebInputEvent::kPointerTypeFirst + 1];
218 316
219 for (unsigned touch_point_idx = 0; touch_point_idx < event.touches_length; 317 Vector<int> available_ids;
220 touch_point_idx++) { 318 for (const auto& id : touch_points_attributes_.Keys())
221 const WebTouchPoint& point = event.TouchPointInRootFrame(touch_point_idx); 319 available_ids.push_back(id);
222 WebTouchPoint::State point_state = point.state; 320 std::sort(available_ids.begin(), available_ids.end());
321 for (const int& touch_point_id : available_ids) {
322 const auto& touch_point_attribute =
323 touch_points_attributes_.at(touch_point_id);
324 WebInputEvent::Type pointer_action =
mustaq 2017/06/09 16:12:27 s/pointer_action/pointer_event_type/
Navid Zolghadr 2017/06/12 16:17:31 Done.
325 touch_point_attribute->event_.GetType();
326 size_t pointer_action_idx =
mustaq 2017/06/09 16:12:27 event_type_idx?
Navid Zolghadr 2017/06/12 16:17:31 Done.
327 pointer_action - WebInputEvent::kPointerTypeFirst;
223 bool known_target; 328 bool known_target;
224 329
225 Touch* touch = CreateDomTouch(point, &known_target); 330 Touch* touch = CreateDomTouch(touch_point_attribute, &known_target);
226 EventTarget* touch_target = touch->target(); 331 EventTarget* touch_target = touch->target();
227 332
228 // Ensure this target's touch list exists, even if it ends up empty, so 333 // Ensure this target's touch list exists, even if it ends up empty, so
229 // it can always be passed to TouchEvent::Create below. 334 // it can always be passed to TouchEvent::Create below.
230 TargetTouchesHeapMap::iterator target_touches_iterator = 335 TargetTouchesHeapMap::iterator target_touches_iterator =
231 touches_by_target.find(touch_target); 336 touches_by_target.find(touch_target);
232 if (target_touches_iterator == touches_by_target.end()) { 337 if (target_touches_iterator == touches_by_target.end()) {
233 touches_by_target.Set(touch_target, TouchList::Create()); 338 touches_by_target.Set(touch_target, TouchList::Create());
234 target_touches_iterator = touches_by_target.find(touch_target); 339 target_touches_iterator = touches_by_target.find(touch_target);
235 } 340 }
236 341
237 // |touches| and |targetTouches| should only contain information about 342 // |touches| and |targetTouches| should only contain information about
238 // touches still on the screen, so if this point is released or 343 // touches still on the screen, so if this point is released or
239 // cancelled it will only appear in the |changedTouches| list. 344 // cancelled it will only appear in the |changedTouches| list.
240 if (point_state != WebTouchPoint::kStateReleased && 345 if (pointer_action != WebInputEvent::kPointerUp &&
241 point_state != WebTouchPoint::kStateCancelled) { 346 pointer_action != WebInputEvent::kPointerCancel) {
242 touches->Append(touch); 347 touches->Append(touch);
243 target_touches_iterator->value->Append(touch); 348 target_touches_iterator->value->Append(touch);
244 } 349 }
245 350
246 // Now build up the correct list for |changedTouches|. 351 // Now build up the correct list for |changedTouches|.
247 // Note that any touches that are in the TouchStationary state (e.g. if 352 // Note that any touches that are in the TouchStationary state (e.g. if
248 // the user had several points touched but did not move them all) should 353 // the user had several points touched but did not move them all) should
249 // never be in the |changedTouches| list so we do not handle them 354 // never be in the |changedTouches| list so we do not handle them
250 // explicitly here. See https://bugs.webkit.org/show_bug.cgi?id=37609 355 // explicitly here. See https://bugs.webkit.org/show_bug.cgi?id=37609
251 // for further discussion about the TouchStationary state. 356 // for further discussion about the TouchStationary state.
252 if (point_state != WebTouchPoint::kStateStationary && known_target) { 357 if (!touch_point_attribute->stale_ && known_target) {
253 DCHECK_LE(point_state, WebTouchPoint::kStateMax); 358 if (!changed_touches[pointer_action_idx].touches_)
254 if (!changed_touches[point_state].touches_) 359 changed_touches[pointer_action_idx].touches_ = TouchList::Create();
255 changed_touches[point_state].touches_ = TouchList::Create(); 360 changed_touches[pointer_action_idx].touches_->Append(touch);
256 changed_touches[point_state].touches_->Append(touch); 361 changed_touches[pointer_action_idx].targets_.insert(touch_target);
257 changed_touches[point_state].targets_.insert(touch_target);
258 changed_touches[point_state].pointer_type_ = point.pointer_type;
259 } 362 }
260 } 363 }
261 364
262 if (all_touches_released) { 365 WebInputEventResult event_result = WebInputEventResult::kNotHandled;
263 touch_sequence_document_.Clear();
264 current_touch_action_ = TouchAction::kTouchActionAuto;
265 }
266 366
267 WebInputEventResult event_result = WebInputEventResult::kNotHandled;
268 // First we construct the webcoalescedinputevent contains all the coalesced 367 // First we construct the webcoalescedinputevent contains all the coalesced
mustaq 2017/06/09 16:12:27 /containing/
Navid Zolghadr 2017/06/12 16:17:31 Done.
269 // touch event. 368 // touch event.
270 std::vector<const WebInputEvent*> coalesced_touches; 369 WebCoalescedInputEvent coalesced_event = GenerateWebCoalescedInputEvent();
271 for (size_t i = 0; i < coalesced_events.size(); ++i) {
272 coalesced_touches.push_back(&coalesced_events[i]);
273 }
274 WebCoalescedInputEvent coalesced_event(event, coalesced_touches);
275 370
276 // Now iterate through the |changedTouches| list and |m_targets| within it, 371 // Now iterate through the |changedTouches| list and |m_targets| within it,
277 // sending TouchEvents to the targets as required. 372 // sending TouchEvents to the targets as required.
278 for (unsigned state = 0; state <= WebTouchPoint::kStateMax; ++state) { 373 for (unsigned action = WebInputEvent::kPointerTypeFirst;
279 if (!changed_touches[state].touches_) 374 action <= WebInputEvent::kPointerTypeLast; ++action) {
375 size_t action_idx = action - WebInputEvent::kPointerTypeFirst;
376 if (!changed_touches[action_idx].touches_)
280 continue; 377 continue;
281 378
282 const AtomicString& event_name(TouchEventNameForTouchPointState( 379 const AtomicString& event_name(TouchEventNameForPointerEventType(
283 static_cast<WebTouchPoint::State>(state))); 380 static_cast<WebInputEvent::Type>(action)));
284 for (const auto& event_target : changed_touches[state].targets_) { 381
382 for (const auto& event_target : changed_touches[action_idx].targets_) {
285 EventTarget* touch_event_target = event_target; 383 EventTarget* touch_event_target = event_target;
286 TouchEvent* touch_event = TouchEvent::Create( 384 TouchEvent* touch_event = TouchEvent::Create(
287 coalesced_event, touches, touches_by_target.at(touch_event_target), 385 coalesced_event, touches, touches_by_target.at(touch_event_target),
288 changed_touches[state].touches_.Get(), event_name, 386 changed_touches[action_idx].touches_.Get(), event_name,
289 touch_event_target->ToNode()->GetDocument().domWindow(), 387 touch_event_target->ToNode()->GetDocument().domWindow(),
290 current_touch_action_); 388 current_touch_action_);
291 389
292 DispatchEventResult dom_dispatch_result = 390 DispatchEventResult dom_dispatch_result =
293 touch_event_target->DispatchEvent(touch_event); 391 touch_event_target->DispatchEvent(touch_event);
mustaq 2017/06/09 16:12:27 Consider these event sequece, all within the same
Navid Zolghadr 2017/06/12 16:17:31 This code does not handle that. My understanding a
294 392
295 // Only report for top level documents with a single touch on 393 // Only report for top level documents with a single touch on
mustaq 2017/06/09 16:12:27 The UMA block is too long and a bit distracting he
Navid Zolghadr 2017/06/12 16:17:31 Done.
296 // touch-start or the first touch-move. 394 // touch-start or the first touch-move.
297 if (event.touch_start_or_first_touch_move && event.touches_length == 1 && 395 if (touch_points_attributes_.size() == 1 && frame_->IsMainFrame()) {
298 frame_->IsMainFrame()) { 396 const auto& event = touch_points_attributes_.begin()->value->event_;
299 // Record the disposition and latency of touch starts and first touch 397 if (event.touch_start_or_first_touch_move) {
300 // moves before and after the page is fully loaded respectively. 398 // Record the disposition and latency of touch starts and first touch
301 int64_t latency_in_micros = 399 // moves before and after the page is fully loaded respectively.
302 (TimeTicks::Now() - 400 int64_t latency_in_micros =
303 TimeTicks::FromSeconds(event.TimeStampSeconds())) 401 (TimeTicks::Now() -
304 .InMicroseconds(); 402 TimeTicks::FromSeconds(event.TimeStampSeconds()))
305 if (event.IsCancelable()) { 403 .InMicroseconds();
306 if (frame_->GetDocument()->IsLoadCompleted()) { 404 if (event.IsCancelable()) {
405 if (frame_->GetDocument()->IsLoadCompleted()) {
406 DEFINE_STATIC_LOCAL(EnumerationHistogram,
407 touch_dispositions_after_page_load_histogram,
408 ("Event.Touch.TouchDispositionsAfterPageLoad",
409 kTouchEventDispatchResultTypeMax));
410 touch_dispositions_after_page_load_histogram.Count(
411 (dom_dispatch_result != DispatchEventResult::kNotCanceled)
412 ? kHandledTouches
413 : kUnhandledTouches);
414
415 DEFINE_STATIC_LOCAL(
416 CustomCountHistogram, event_latency_after_page_load_histogram,
417 ("Event.Touch.TouchLatencyAfterPageLoad", 1, 100000000, 50));
418 event_latency_after_page_load_histogram.Count(latency_in_micros);
419 } else {
420 DEFINE_STATIC_LOCAL(
421 EnumerationHistogram,
422 touch_dispositions_before_page_load_histogram,
423 ("Event.Touch.TouchDispositionsBeforePageLoad",
424 kTouchEventDispatchResultTypeMax));
425 touch_dispositions_before_page_load_histogram.Count(
426 (dom_dispatch_result != DispatchEventResult::kNotCanceled)
427 ? kHandledTouches
428 : kUnhandledTouches);
429
430 DEFINE_STATIC_LOCAL(
431 CustomCountHistogram,
432 event_latency_before_page_load_histogram,
433 ("Event.Touch.TouchLatencyBeforePageLoad", 1, 100000000, 50));
434 event_latency_before_page_load_histogram.Count(latency_in_micros);
435 }
436 // Report the touch disposition there is no active fling animation.
307 DEFINE_STATIC_LOCAL(EnumerationHistogram, 437 DEFINE_STATIC_LOCAL(EnumerationHistogram,
308 touch_dispositions_after_page_load_histogram, 438 touch_dispositions_outside_fling_histogram,
309 ("Event.Touch.TouchDispositionsAfterPageLoad", 439 ("Event.Touch.TouchDispositionsOutsideFling2",
310 kTouchEventDispatchResultTypeMax)); 440 kTouchEventDispatchResultTypeMax));
311 touch_dispositions_after_page_load_histogram.Count( 441 touch_dispositions_outside_fling_histogram.Count(
312 (dom_dispatch_result != DispatchEventResult::kNotCanceled) 442 (dom_dispatch_result != DispatchEventResult::kNotCanceled)
313 ? kHandledTouches 443 ? kHandledTouches
314 : kUnhandledTouches); 444 : kUnhandledTouches);
445 }
315 446
316 DEFINE_STATIC_LOCAL( 447 // Report the touch disposition when there is an active fling
317 CustomCountHistogram, event_latency_after_page_load_histogram, 448 // animation.
318 ("Event.Touch.TouchLatencyAfterPageLoad", 1, 100000000, 50)); 449 // if (event[0].first.dispatch_type ==
319 event_latency_after_page_load_histogram.Count(latency_in_micros); 450 if (event.dispatch_type ==
320 } else { 451 WebInputEvent::kListenersForcedNonBlockingDueToFling) {
321 DEFINE_STATIC_LOCAL(EnumerationHistogram, 452 DEFINE_STATIC_LOCAL(EnumerationHistogram,
322 touch_dispositions_before_page_load_histogram, 453 touch_dispositions_during_fling_histogram,
323 ("Event.Touch.TouchDispositionsBeforePageLoad", 454 ("Event.Touch.TouchDispositionsDuringFling2",
324 kTouchEventDispatchResultTypeMax)); 455 kTouchEventDispatchResultTypeMax));
325 touch_dispositions_before_page_load_histogram.Count( 456 touch_dispositions_during_fling_histogram.Count(
326 (dom_dispatch_result != DispatchEventResult::kNotCanceled) 457 touch_event->PreventDefaultCalledOnUncancelableEvent()
327 ? kHandledTouches 458 ? kHandledTouches
328 : kUnhandledTouches); 459 : kUnhandledTouches);
329
330 DEFINE_STATIC_LOCAL(
331 CustomCountHistogram, event_latency_before_page_load_histogram,
332 ("Event.Touch.TouchLatencyBeforePageLoad", 1, 100000000, 50));
333 event_latency_before_page_load_histogram.Count(latency_in_micros);
334 } 460 }
335 // Report the touch disposition there is no active fling animation.
336 DEFINE_STATIC_LOCAL(EnumerationHistogram,
337 touch_dispositions_outside_fling_histogram,
338 ("Event.Touch.TouchDispositionsOutsideFling2",
339 kTouchEventDispatchResultTypeMax));
340 touch_dispositions_outside_fling_histogram.Count(
341 (dom_dispatch_result != DispatchEventResult::kNotCanceled)
342 ? kHandledTouches
343 : kUnhandledTouches);
344 }
345
346 // Report the touch disposition when there is an active fling animation.
347 if (event.dispatch_type ==
348 WebInputEvent::kListenersForcedNonBlockingDueToFling) {
349 DEFINE_STATIC_LOCAL(EnumerationHistogram,
350 touch_dispositions_during_fling_histogram,
351 ("Event.Touch.TouchDispositionsDuringFling2",
352 kTouchEventDispatchResultTypeMax));
353 touch_dispositions_during_fling_histogram.Count(
354 touch_event->PreventDefaultCalledOnUncancelableEvent()
355 ? kHandledTouches
356 : kUnhandledTouches);
357 } 461 }
358 } 462 }
359 event_result = EventHandlingUtil::MergeEventResult( 463 event_result = EventHandlingUtil::MergeEventResult(
360 event_result, 464 event_result,
361 EventHandlingUtil::ToWebInputEventResult(dom_dispatch_result)); 465 EventHandlingUtil::ToWebInputEventResult(dom_dispatch_result));
362 } 466 }
363 } 467 }
364 468
365 // Do not suppress any touchmoves if the touchstart is consumed. 469 // Suppress following touchmoves within the slop region if the touchstart is
366 if (IsTouchSequenceStart(event) && 470 // not consumed.
471 if (all_touch_points_pressed &&
367 event_result == WebInputEventResult::kNotHandled) { 472 event_result == WebInputEventResult::kNotHandled) {
368 suppressing_touchmoves_within_slop_ = true; 473 suppressing_touchmoves_within_slop_ = true;
369 } 474 }
370 475
371 return event_result; 476 return event_result;
372 } 477 }
373 478
374 void TouchEventManager::UpdateTargetAndRegionMapsForTouchStart( 479 void TouchEventManager::UpdateTouchAttributeMapsForPointerDown(
375 const WebTouchPoint& touch_point, 480 const WebPointerEvent& event,
376 const EventHandlingUtil::PointerEventTarget& pointer_event_target) { 481 const EventHandlingUtil::PointerEventTarget& pointer_event_target) {
377 // Touch events implicitly capture to the touched node, and don't change 482 // Touch events implicitly capture to the touched node, and don't change
378 // active/hover states themselves (Gesture events do). So we only need 483 // active/hover states themselves (Gesture events do). So we only need
379 // to hit-test on touchstart and when the target could be different than 484 // to hit-test on touchstart and when the target could be different than
380 // the corresponding pointer event target. 485 // the corresponding pointer event target.
381 DCHECK(touch_point.state == WebTouchPoint::kStatePressed); 486 DCHECK(event.GetType() == WebInputEvent::kPointerDown);
487 // Ideally we'd DCHECK(!touch_points_attributes_.Contains(event.id))
488 // since we shouldn't get a touchstart for a touch that's already
489 // down. However EventSender allows this to be violated and there's
490 // some tests that take advantage of it. There may also be edge
491 // cases in the browser where this happens.
492 // See http://crbug.com/345372.
493 touch_points_attributes_.Set(event.id, new TouchPointAttributes(event));
494
382 Node* touch_node = pointer_event_target.target_node; 495 Node* touch_node = pointer_event_target.target_node;
383 String region = pointer_event_target.region; 496 String region = pointer_event_target.region;
384 497
385 HitTestRequest::HitTestRequestType hit_type = HitTestRequest::kTouchEvent | 498 HitTestRequest::HitTestRequestType hit_type = HitTestRequest::kTouchEvent |
386 HitTestRequest::kReadOnly | 499 HitTestRequest::kReadOnly |
387 HitTestRequest::kActive; 500 HitTestRequest::kActive;
388 HitTestResult result; 501 HitTestResult result;
389 // For the touchPressed points hit-testing is done in 502 // For the touchPressed points hit-testing is done in
390 // PointerEventManager. If it was the second touch there is a 503 // PointerEventManager. If it was the second touch there is a
391 // capturing documents for the touch and |m_touchSequenceDocument| 504 // capturing documents for the touch and |m_touchSequenceDocument|
392 // is not null. So if PointerEventManager should hit-test again 505 // is not null. So if PointerEventManager should hit-test again
393 // against |m_touchSequenceDocument| if the target set by 506 // against |m_touchSequenceDocument| if the target set by
394 // PointerEventManager was either null or not in 507 // PointerEventManager was either null or not in
395 // |m_touchSequenceDocument|. 508 // |m_touchSequenceDocument|.
396 if (touch_sequence_document_ && 509 if (touch_sequence_document_ &&
397 (!touch_node || &touch_node->GetDocument() != touch_sequence_document_)) { 510 (!touch_node || &touch_node->GetDocument() != touch_sequence_document_)) {
398 if (touch_sequence_document_->GetFrame()) { 511 if (touch_sequence_document_->GetFrame()) {
399 LayoutPoint frame_point = LayoutPoint( 512 LayoutPoint frame_point = LayoutPoint(
400 touch_sequence_document_->GetFrame()->View()->RootFrameToContents( 513 touch_sequence_document_->GetFrame()->View()->RootFrameToContents(
401 touch_point.PositionInWidget())); 514 event.PositionInWidget()));
402 result = EventHandlingUtil::HitTestResultInFrame( 515 result = EventHandlingUtil::HitTestResultInFrame(
403 touch_sequence_document_->GetFrame(), frame_point, hit_type); 516 touch_sequence_document_->GetFrame(), frame_point, hit_type);
404 Node* node = result.InnerNode(); 517 Node* node = result.InnerNode();
405 if (!node) 518 if (!node)
406 return; 519 return;
407 if (isHTMLCanvasElement(node)) { 520 if (isHTMLCanvasElement(node)) {
408 HitTestCanvasResult* hit_test_canvas_result = 521 HitTestCanvasResult* hit_test_canvas_result =
409 toHTMLCanvasElement(node)->GetControlAndIdIfHitRegionExists( 522 toHTMLCanvasElement(node)->GetControlAndIdIfHitRegionExists(
410 result.PointInInnerNodeFrame()); 523 result.PointInInnerNodeFrame());
411 if (hit_test_canvas_result->GetControl()) 524 if (hit_test_canvas_result->GetControl())
(...skipping 11 matching lines...) Expand all
423 if (!touch_node) 536 if (!touch_node)
424 return; 537 return;
425 if (!touch_sequence_document_) { 538 if (!touch_sequence_document_) {
426 // Keep track of which document should receive all touch events 539 // Keep track of which document should receive all touch events
427 // in the active sequence. This must be a single document to 540 // in the active sequence. This must be a single document to
428 // ensure we don't leak Nodes between documents. 541 // ensure we don't leak Nodes between documents.
429 touch_sequence_document_ = &(touch_node->GetDocument()); 542 touch_sequence_document_ = &(touch_node->GetDocument());
430 DCHECK(touch_sequence_document_->GetFrame()->View()); 543 DCHECK(touch_sequence_document_->GetFrame()->View());
431 } 544 }
432 545
433 // Ideally we'd DCHECK(!m_targetForTouchID.contains(point.id()) 546 TouchPointAttributes* attributes = touch_points_attributes_.at(event.id);
434 // since we shouldn't get a touchstart for a touch that's already 547 attributes->target_ = touch_node;
435 // down. However EventSender allows this to be violated and there's 548 attributes->region_ = region;
436 // some tests that take advantage of it. There may also be edge
437 // cases in the browser where this happens.
438 // See http://crbug.com/345372.
439 target_for_touch_id_.Set(touch_point.id, touch_node);
440
441 region_for_touch_id_.Set(touch_point.id, region);
442 549
443 TouchAction effective_touch_action = 550 TouchAction effective_touch_action =
444 TouchActionUtil::ComputeEffectiveTouchAction(*touch_node); 551 TouchActionUtil::ComputeEffectiveTouchAction(*touch_node);
445 if (effective_touch_action != TouchAction::kTouchActionAuto) { 552 if (effective_touch_action != TouchAction::kTouchActionAuto) {
446 frame_->GetPage()->GetChromeClient().SetTouchAction(frame_, 553 frame_->GetPage()->GetChromeClient().SetTouchAction(frame_,
447 effective_touch_action); 554 effective_touch_action);
448 555
449 // Combine the current touch action sequence with the touch action 556 // Combine the current touch action sequence with the touch action
450 // for the current finger press. 557 // for the current finger press.
451 current_touch_action_ &= effective_touch_action; 558 current_touch_action_ &= effective_touch_action;
452 } 559 }
453 } 560 }
454 561
455 bool TouchEventManager::HitTestTouchPointsIfNeeded( 562 void TouchEventManager::HandleTouchPoint(
456 const WebTouchEvent& event, 563 const WebPointerEvent& event,
457 const HeapVector<EventHandlingUtil::PointerEventTarget>& 564 const Vector<WebPointerEvent>& coalesced_events,
458 pointer_event_targets) { 565 const EventHandlingUtil::PointerEventTarget& pointer_event_target) {
459 bool new_touch_sequence = true; 566 DCHECK_GE(event.GetType(), WebInputEvent::kPointerTypeFirst);
460 bool all_touches_released = true; 567 DCHECK_LE(event.GetType(), WebInputEvent::kPointerTypeLast);
461 568
462 for (unsigned i = 0; i < event.touches_length; ++i) { 569 if (touch_points_attributes_.IsEmpty()) {
463 WebTouchPoint::State state = event.touches[i].state;
464 if (state != WebTouchPoint::kStatePressed)
465 new_touch_sequence = false;
466 if (state != WebTouchPoint::kStateReleased &&
467 state != WebTouchPoint::kStateCancelled)
468 all_touches_released = false;
469 }
470 if (new_touch_sequence) {
471 // Ideally we'd DCHECK(!m_touchSequenceDocument) here since we should 570 // Ideally we'd DCHECK(!m_touchSequenceDocument) here since we should
472 // have cleared the active document when we saw the last release. But we 571 // have cleared the active document when we saw the last release. But we
473 // have some tests that violate this, ClusterFuzz could trigger it, and 572 // have some tests that violate this, ClusterFuzz could trigger it, and
474 // there may be cases where the browser doesn't reliably release all 573 // there may be cases where the browser doesn't reliably release all
475 // touches. http://crbug.com/345372 tracks this. 574 // touches. http://crbug.com/345372 tracks this.
476 touch_sequence_document_.Clear(); 575 allTouchesReleasedCleanup();
477 } 576 }
478 577
479 DCHECK(frame_->View()); 578 DCHECK(frame_->View());
480 if (touch_sequence_document_ && 579 if (touch_sequence_document_ &&
481 (!touch_sequence_document_->GetFrame() || 580 (!touch_sequence_document_->GetFrame() ||
482 !touch_sequence_document_->GetFrame()->View())) { 581 !touch_sequence_document_->GetFrame()->View())) {
483 // If the active touch document has no frame or view, it's probably being 582 // If the active touch document has no frame or view, it's probably being
484 // destroyed so we can't dispatch events. 583 // destroyed so we can't dispatch events.
485 return false; 584 return;
486 } 585 }
487 586
488 for (unsigned i = 0; i < event.touches_length; ++i) { 587 // In touch event model only touch starts can set the target and after that
489 // In touch event model only touch starts can set the target and after that 588 // the touch event always goes to that target.
490 // the touch event always goes to that target. 589 if (event.GetType() == WebInputEvent::kPointerDown) {
491 if (event.touches[i].state == WebTouchPoint::kStatePressed) { 590 UpdateTouchAttributeMapsForPointerDown(event, pointer_event_target);
492 UpdateTargetAndRegionMapsForTouchStart(event.TouchPointInRootFrame(i), 591 }
493 pointer_event_targets[i]); 592
593 // We might not receive the down action for a touch point. In that case we
594 // would have never added them to |touch_points_attributes_| or hit-tested
595 // them. For those just keep them in the map with a null target. Later they
596 // will be targeted at the |touch_sequence_document_|.
597 if (!touch_points_attributes_.Contains(event.id)) {
598 touch_points_attributes_.insert(event.id, new TouchPointAttributes(event));
599 }
600
601 TouchPointAttributes* attributes = touch_points_attributes_.at(event.id);
602 attributes->event_ = event;
603 attributes->coalesced_events_ = coalesced_events;
604 attributes->stale_ = false;
605 }
606
607 WebInputEventResult TouchEventManager::HandleVSyncSignal() {
608 // If there's no document receiving touch events, or no handlers on the
609 // document set to receive the events, then we can skip all the rest of
610 // sending the event.
611 WebInputEventResult result = WebInputEventResult::kNotHandled;
612 if (touch_sequence_document_ && touch_sequence_document_->GetPage() &&
613 HasTouchHandlers(
614 touch_sequence_document_->GetPage()->GetEventHandlerRegistry()) &&
615 touch_sequence_document_->GetFrame() &&
616 touch_sequence_document_->GetFrame()->View()) {
617 result = DispatchTouchEvents();
618 }
619
620 // Cleanup the |touch_points_attributes_| map from released and canceled
621 // touch points.
622 Vector<int> releasedCanceledPoints;
623 for (auto& attributes : touch_points_attributes_.Values()) {
624 if (attributes->event_.GetType() == WebInputEvent::kPointerUp ||
625 attributes->event_.GetType() == WebInputEvent::kPointerCancel) {
626 releasedCanceledPoints.push_back(attributes->event_.id);
627 } else {
628 attributes->stale_ = true;
629 attributes->event_.movement_x = 0;
630 attributes->event_.movement_y = 0;
494 } 631 }
495 } 632 }
496 633 for (int id : releasedCanceledPoints) {
497 touch_pressed_ = !all_touches_released; 634 touch_points_attributes_.erase(id);
mustaq 2017/06/09 16:12:27 Can use .erase(releasedCanceledPoints) instead?
Navid Zolghadr 2017/06/12 16:17:31 Not quite. But there seems to be a RemoveAll funct
498
499 // If there's no document receiving touch events, or no handlers on the
500 // document set to receive the events, then we can skip all the rest of
501 // this work.
502 if (!touch_sequence_document_ || !touch_sequence_document_->GetPage() ||
503 !HasTouchHandlers(
504 touch_sequence_document_->GetPage()->GetEventHandlerRegistry()) ||
505 !touch_sequence_document_->GetFrame()) {
506 if (all_touches_released) {
507 touch_sequence_document_.Clear();
508 }
509 return false;
510 } 635 }
511 636
512 return true; 637 if (touch_points_attributes_.IsEmpty()) {
638 allTouchesReleasedCleanup();
639 }
640
641 return result;
513 } 642 }
514 643
515 WebInputEventResult TouchEventManager::HandleTouchEvent( 644 void TouchEventManager::allTouchesReleasedCleanup() {
516 const WebTouchEvent& event, 645 touch_sequence_document_.Clear();
517 const Vector<WebTouchEvent>& coalesced_events, 646 current_touch_action_ = TouchAction::kTouchActionAuto;
518 const HeapVector<EventHandlingUtil::PointerEventTarget>&
519 pointer_event_targets) {
520 DCHECK(event.touches_length == pointer_event_targets.size());
521
522 if (!HitTestTouchPointsIfNeeded(event, pointer_event_targets))
523 return WebInputEventResult::kNotHandled;
524
525 bool all_touches_released = true;
526 for (unsigned i = 0; i < event.touches_length; ++i) {
527 WebTouchPoint::State state = event.touches[i].state;
528 if (state != WebTouchPoint::kStateReleased &&
529 state != WebTouchPoint::kStateCancelled)
530 all_touches_released = false;
531 }
532
533 return DispatchTouchEvents(event, coalesced_events, all_touches_released);
534 } 647 }
535 648
536 bool TouchEventManager::IsAnyTouchActive() const { 649 bool TouchEventManager::IsAnyTouchActive() const {
537 return touch_pressed_; 650 return !touch_points_attributes_.IsEmpty();
538 } 651 }
539 652
540 } // namespace blink 653 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698