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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/render_widget_host_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 abort_get_backing_store_(false), 162 abort_get_backing_store_(false),
163 view_being_painted_(false), 163 view_being_painted_(false),
164 ignore_input_events_(false), 164 ignore_input_events_(false),
165 input_method_active_(false), 165 input_method_active_(false),
166 text_direction_updated_(false), 166 text_direction_updated_(false),
167 text_direction_(WebKit::WebTextDirectionLeftToRight), 167 text_direction_(WebKit::WebTextDirectionLeftToRight),
168 text_direction_canceled_(false), 168 text_direction_canceled_(false),
169 suppress_next_char_events_(false), 169 suppress_next_char_events_(false),
170 pending_mouse_lock_request_(false), 170 pending_mouse_lock_request_(false),
171 allow_privileged_mouse_lock_(false), 171 allow_privileged_mouse_lock_(false),
172 scroll_update_in_progress_(false),
172 has_touch_handler_(false), 173 has_touch_handler_(false),
173 weak_factory_(this), 174 weak_factory_(this),
174 touch_event_queue_(new TouchEventQueue(this)), 175 touch_event_queue_(new TouchEventQueue(this)),
175 gesture_event_filter_(new GestureEventFilter(this)), 176 gesture_event_filter_(new GestureEventFilter(this)),
176 last_input_number_(0) { 177 last_input_number_(0) {
177 CHECK(delegate_); 178 CHECK(delegate_);
178 if (routing_id_ == MSG_ROUTING_NONE) { 179 if (routing_id_ == MSG_ROUTING_NONE) {
179 routing_id_ = process_->GetNextRoutingID(); 180 routing_id_ = process_->GetNextRoutingID();
180 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( 181 surface_id_ = GpuSurfaceTracker::Get()->AddSurfaceForRenderer(
181 process_->GetID(), 182 process_->GetID(),
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 ForwardInputEvent(wheel_event, sizeof(WebMouseWheelEvent), latency_info, 1058 ForwardInputEvent(wheel_event, sizeof(WebMouseWheelEvent), latency_info,
1058 false); 1059 false);
1059 } 1060 }
1060 1061
1061 void RenderWidgetHostImpl::ForwardGestureEvent( 1062 void RenderWidgetHostImpl::ForwardGestureEvent(
1062 const WebKit::WebGestureEvent& gesture_event) { 1063 const WebKit::WebGestureEvent& gesture_event) {
1063 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent"); 1064 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardGestureEvent");
1064 if (ignore_input_events_ || process_->IgnoreInputEvents()) 1065 if (ignore_input_events_ || process_->IgnoreInputEvents())
1065 return; 1066 return;
1066 1067
1068 if (CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
1069 switches::kTouchCancelOnScroll) == "1") {
1070 // When there is touch handler on the page, once scrolling is started,
1071 // we send a touch cancel to the page, and stops forwarding touch events to
1072 // the renderer. This is to align with Chrome on Android behavior.
1073 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
1074 ShouldForwardTouchEvent() &&
1075 !scroll_update_in_progress_) {
1076 scroll_update_in_progress_ = true;
1077 touch_event_queue_->OnGestureScrollStart();
1078 }
1079
1080 if (gesture_event.type == WebInputEvent::GestureScrollEnd ||
1081 gesture_event.type == WebInputEvent::GestureFlingStart) {
1082 scroll_update_in_progress_ = false;
1083 }
1084 }
1085
1067 ui::LatencyInfo latency_info = NewInputLatencyInfo(); 1086 ui::LatencyInfo latency_info = NewInputLatencyInfo();
1068 1087
1069 if (!IsInOverscrollGesture() && 1088 if (!IsInOverscrollGesture() &&
1070 !gesture_event_filter_->ShouldForward( 1089 !gesture_event_filter_->ShouldForward(
1071 GestureEventWithLatencyInfo(gesture_event, latency_info))) { 1090 GestureEventWithLatencyInfo(gesture_event, latency_info))) {
1072 if (overscroll_controller_.get()) 1091 if (overscroll_controller_.get())
1073 overscroll_controller_->DiscardingGestureEvent(gesture_event); 1092 overscroll_controller_->DiscardingGestureEvent(gesture_event);
1074 return; 1093 return;
1075 } 1094 }
1076 1095
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after
2280 // HandleKeyboardEvent destroys this RenderWidgetHostImpl). 2299 // HandleKeyboardEvent destroys this RenderWidgetHostImpl).
2281 } 2300 }
2282 } 2301 }
2283 } 2302 }
2284 2303
2285 const gfx::Vector2d& RenderWidgetHostImpl::GetLastScrollOffset() const { 2304 const gfx::Vector2d& RenderWidgetHostImpl::GetLastScrollOffset() const {
2286 return last_scroll_offset_; 2305 return last_scroll_offset_;
2287 } 2306 }
2288 2307
2289 bool RenderWidgetHostImpl::ShouldForwardTouchEvent() const { 2308 bool RenderWidgetHostImpl::ShouldForwardTouchEvent() const {
2309 // 1. Scroll update is in progress:
2310 // Don't send any touch events to the renderer.
2311 // 2. Scroll update is not in progress:
2290 // Always send a touch event if the renderer has a touch-event handler. It is 2312 // Always send a touch event if the renderer has a touch-event handler. It is
2291 // possible that a renderer stops listening to touch-events while there are 2313 // possible that a renderer stops listening to touch-events while there are
2292 // still events in the touch-queue. In such cases, the new events should still 2314 // still events in the touch-queue. In such cases, the new events should still
2293 // get into the queue. 2315 // get into the queue.
2294 return has_touch_handler_ || !touch_event_queue_->empty(); 2316 return (has_touch_handler_ || !touch_event_queue_->empty()) &&
2317 !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
2295 } 2318 }
2296 2319
2297 void RenderWidgetHostImpl::StartUserGesture() { 2320 void RenderWidgetHostImpl::StartUserGesture() {
2298 OnUserGesture(); 2321 OnUserGesture();
2299 } 2322 }
2300 2323
2301 void RenderWidgetHostImpl::Stop() { 2324 void RenderWidgetHostImpl::Stop() {
2302 Send(new ViewMsg_Stop(GetRoutingID())); 2325 Send(new ViewMsg_Stop(GetRoutingID()));
2303 } 2326 }
2304 2327
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
2558 if (!host) 2581 if (!host)
2559 continue; 2582 continue;
2560 RenderWidgetHost* rwh = host->GetRenderWidgetHostByID(routing_id); 2583 RenderWidgetHost* rwh = host->GetRenderWidgetHostByID(routing_id);
2561 if (!rwh) 2584 if (!rwh)
2562 continue; 2585 continue;
2563 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info); 2586 RenderWidgetHostImpl::From(rwh)->FrameSwapped(latency_info);
2564 } 2587 }
2565 } 2588 }
2566 2589
2567 } // namespace content 2590 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698