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

Unified Diff: content/browser/renderer_host/input/touch_event_queue.cc

Issue 718153002: Indicate whether a touch event will cause scrolling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/input/touch_event_queue.cc
diff --git a/content/browser/renderer_host/input/touch_event_queue.cc b/content/browser/renderer_host/input/touch_event_queue.cc
index fa109dedddf9bd87868d6edbe6a7a7fc1cbe9351..8c6b89820f022b3ae974e68e907c56850035a069 100644
--- a/content/browser/renderer_host/input/touch_event_queue.cc
+++ b/content/browser/renderer_host/input/touch_event_queue.cc
@@ -28,11 +28,6 @@ const double kAsyncTouchMoveIntervalSec = .2;
// trigger an immediate async touchmove to cancel potential tap-related logic.
const double kApplicationSlopRegionLengthDipsSqared = 15. * 15.;
-// Using a small epsilon when comparing slop distances allows pixel perfect
-// slop determination when using fractional DIP coordinates (assuming the slop
-// region and DPI scale are reasonably proportioned).
-const float kSlopEpsilon = .05f;
-
TouchEventWithLatencyInfo ObtainCancelEventForTouchEvent(
const TouchEventWithLatencyInfo& event_to_cancel) {
TouchEventWithLatencyInfo event = event_to_cancel;
@@ -215,28 +210,15 @@ class TouchEventQueue::TouchTimeoutHandler {
bool enabled_for_current_sequence_;
};
-// Provides touchmove slop suppression for a single touch that remains within
-// a given slop region, unless the touchstart is preventDefault'ed.
-// TODO(jdduke): Use a flag bundled with each TouchEvent declaring whether it
-// has exceeded the slop region, removing duplicated slop determination logic.
+// Provides touchmove slop suppression for a touch sequence until a
+// (unprevented) touch will trigger immediate scrolling.
class TouchEventQueue::TouchMoveSlopSuppressor {
public:
- TouchMoveSlopSuppressor(double slop_suppression_length_dips)
- : slop_suppression_length_dips_squared_(0),
- suppressing_touchmoves_(false) {
- if (slop_suppression_length_dips) {
- slop_suppression_length_dips += kSlopEpsilon;
- slop_suppression_length_dips_squared_ =
- slop_suppression_length_dips * slop_suppression_length_dips;
- }
- }
+ TouchMoveSlopSuppressor() : suppressing_touchmoves_(false) {}
bool FilterEvent(const WebTouchEvent& event) {
- if (WebTouchEventTraits::IsTouchSequenceStart(event)) {
- touch_sequence_start_position_ =
- gfx::PointF(event.touches[0].position);
- suppressing_touchmoves_ = slop_suppression_length_dips_squared_ != 0;
- }
+ if (WebTouchEventTraits::IsTouchSequenceStart(event))
+ suppressing_touchmoves_ = true;
if (event.type == WebInputEvent::TouchEnd ||
event.type == WebInputEvent::TouchCancel)
@@ -246,17 +228,12 @@ class TouchEventQueue::TouchMoveSlopSuppressor {
return false;
if (suppressing_touchmoves_) {
- // Movement with a secondary pointer should terminate suppression.
- if (event.touchesLength > 1) {
+ if (event.touchesLength > 1)
+ suppressing_touchmoves_ = false;
+ if (event.causesScrollingIfUncanceled)
suppressing_touchmoves_ = false;
- } else if (event.touchesLength == 1) {
- // Movement outside of the slop region should terminate suppression.
- gfx::PointF position(event.touches[0].position);
- if ((position - touch_sequence_start_position_).LengthSquared() >
- slop_suppression_length_dips_squared_)
- suppressing_touchmoves_ = false;
- }
}
+
return suppressing_touchmoves_;
}
@@ -268,8 +245,6 @@ class TouchEventQueue::TouchMoveSlopSuppressor {
bool suppressing_touchmoves() const { return suppressing_touchmoves_; }
private:
- double slop_suppression_length_dips_squared_;
- gfx::PointF touch_sequence_start_position_;
bool suppressing_touchmoves_;
DISALLOW_COPY_AND_ASSIGN(TouchMoveSlopSuppressor);
@@ -362,8 +337,7 @@ class CoalescedWebTouchEvent {
};
TouchEventQueue::Config::Config()
- : touchmove_slop_suppression_length_dips(0),
- touch_scrolling_mode(TOUCH_SCROLLING_MODE_DEFAULT),
+ : touch_scrolling_mode(TOUCH_SCROLLING_MODE_DEFAULT),
touch_ack_timeout_delay(base::TimeDelta::FromMilliseconds(200)),
touch_ack_timeout_supported(false) {
}
@@ -375,8 +349,7 @@ TouchEventQueue::TouchEventQueue(TouchEventQueueClient* client,
dispatching_touch_(false),
has_handlers_(true),
drop_remaining_touches_in_sequence_(false),
- touchmove_slop_suppressor_(new TouchMoveSlopSuppressor(
- config.touchmove_slop_suppression_length_dips)),
+ touchmove_slop_suppressor_(new TouchMoveSlopSuppressor),
send_touch_events_async_(false),
needs_async_touchmove_for_outer_slop_region_(false),
last_sent_touch_timestamp_sec_(0),

Powered by Google App Engine
This is Rietveld 408576698