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

Side by Side Diff: content/browser/renderer_host/input/touch_event_queue.cc

Issue 2680013009: Move touch slop suppression from LegacyTouchEventQueue to TouchEventManager (Closed)
Patch Set: slop region Created 3 years, 10 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
« no previous file with comments | « no previous file | content/browser/renderer_host/input/touch_event_queue_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/renderer_host/input/touch_event_queue.h" 5 #include "content/browser/renderer_host/input/touch_event_queue.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 bool sequence_using_mobile_timeout_; 285 bool sequence_using_mobile_timeout_;
286 }; 286 };
287 287
288 // Provides touchmove slop suppression for a touch sequence until a 288 // Provides touchmove slop suppression for a touch sequence until a
289 // (unprevented) touch will trigger immediate scrolling. 289 // (unprevented) touch will trigger immediate scrolling.
290 class TouchEventQueue::TouchMoveSlopSuppressor { 290 class TouchEventQueue::TouchMoveSlopSuppressor {
291 public: 291 public:
292 TouchMoveSlopSuppressor() : suppressing_touchmoves_(false) {} 292 TouchMoveSlopSuppressor() : suppressing_touchmoves_(false) {}
293 293
294 bool FilterEvent(const WebTouchEvent& event) { 294 bool FilterEvent(const WebTouchEvent& event) {
295 if (WebTouchEventTraits::IsTouchSequenceStart(event)) { 295 suppressing_touchmoves_ = false;
296 suppressing_touchmoves_ = true; 296 return false;
297 touch_start_location_ = gfx::PointF(event.touches[0].position);
298 }
299
300 if (event.type() == WebInputEvent::TouchEnd ||
301 event.type() == WebInputEvent::TouchCancel)
302 suppressing_touchmoves_ = false;
303
304 if (event.type() != WebInputEvent::TouchMove)
305 return false;
306
307 if (suppressing_touchmoves_) {
308 if (event.touchesLength > 1) {
309 suppressing_touchmoves_ = false;
310 } else if (event.movedBeyondSlopRegion) {
311 suppressing_touchmoves_ = false;
312 } else {
313 // No sane slop region should be larger than 60 DIPs.
314 DCHECK_LT((gfx::PointF(event.touches[0].position) -
315 touch_start_location_).LengthSquared(),
316 kMaxConceivablePlatformSlopRegionLengthDipsSquared);
317 }
318 }
319
320 return suppressing_touchmoves_;
321 } 297 }
322 298
323 void ConfirmTouchEvent(InputEventAckState ack_result) { 299 void ConfirmTouchEvent(InputEventAckState ack_result) {
324 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) 300 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED)
325 suppressing_touchmoves_ = false; 301 suppressing_touchmoves_ = false;
326 } 302 }
327 303
328 bool suppressing_touchmoves() const { return suppressing_touchmoves_; } 304 bool suppressing_touchmoves() const { return suppressing_touchmoves_; }
329 305
330 private: 306 private:
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) 912 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED)
937 send_touch_events_async_ = false; 913 send_touch_events_async_ = false;
938 has_handler_for_current_sequence_ |= 914 has_handler_for_current_sequence_ |=
939 ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; 915 ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
940 } else if (WebTouchEventTraits::IsTouchSequenceEnd(event)) { 916 } else if (WebTouchEventTraits::IsTouchSequenceEnd(event)) {
941 has_handler_for_current_sequence_ = false; 917 has_handler_for_current_sequence_ = false;
942 } 918 }
943 } 919 }
944 920
945 } // namespace content 921 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/input/touch_event_queue_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698