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

Unified Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 16114003: Don't send touch move to renderer while scrolling (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fix the case touch event queue could be empty when GetLatestEvent() is called Created 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_impl.cc
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index dae48644401620fd85acc828cfd81647504de6f8..8fe4150955c4447e4523cd3f6bbfa21c7659df8e 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -169,6 +169,7 @@ RenderWidgetHostImpl::RenderWidgetHostImpl(RenderWidgetHostDelegate* delegate,
suppress_next_char_events_(false),
pending_mouse_lock_request_(false),
allow_privileged_mouse_lock_(false),
+ scroll_update_in_progress_(false),
has_touch_handler_(false),
weak_factory_(this),
touch_event_queue_(new TouchEventQueue(this)),
@@ -1064,6 +1065,24 @@ void RenderWidgetHostImpl::ForwardGestureEvent(
if (ignore_input_events_ || process_->IgnoreInputEvents())
return;
+ if (CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kTouchCancelOnScroll) == "1") {
+ // When there is touch handler on the page, once scrolling is started,
+ // we send a touch cancel to the page, and stops forwarding touch events to
+ // the renderer. This is to align with Chrome on Android behavior.
+ if (gesture_event.type == WebInputEvent::GestureScrollUpdate &&
sadrul 2013/06/20 08:51:27 You should do this on GestureScrollBegin event, wh
Yufeng Shen (Slow to review) 2013/06/20 17:56:45 I have a comment in the description of the CL abou
+ ShouldForwardTouchEvent() &&
+ !scroll_update_in_progress_) {
+ scroll_update_in_progress_ = true;
+ touch_event_queue_->OnGestureScrollStart();
+ }
+
+ if (gesture_event.type == WebInputEvent::GestureScrollEnd ||
+ gesture_event.type == WebInputEvent::GestureFlingStart) {
+ scroll_update_in_progress_ = false;
+ }
+ }
+
ui::LatencyInfo latency_info = NewInputLatencyInfo();
if (!IsInOverscrollGesture() &&
@@ -2287,11 +2306,15 @@ const gfx::Vector2d& RenderWidgetHostImpl::GetLastScrollOffset() const {
}
bool RenderWidgetHostImpl::ShouldForwardTouchEvent() const {
+ // 1. Scroll update is in progress:
+ // Don't send any touch events to the renderer.
+ // 2. Scroll update is not in progress:
// Always send a touch event if the renderer has a touch-event handler. It is
// possible that a renderer stops listening to touch-events while there are
// still events in the touch-queue. In such cases, the new events should still
// get into the queue.
- return has_touch_handler_ || !touch_event_queue_->empty();
+ return (has_touch_handler_ || !touch_event_queue_->empty()) &&
+ !scroll_update_in_progress_;
sadrul 2013/06/20 08:51:27 Can you expose gesture_event_filter_->scrolling_in
Yufeng Shen (Slow to review) 2013/06/20 17:56:45 gesture_event_filter->scrolling_in_progress_ is d
}
void RenderWidgetHostImpl::StartUserGesture() {

Powered by Google App Engine
This is Rietveld 408576698