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

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

Issue 217163006: Defer synthetic gesture completions until events have been flushed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Restore browser test Created 6 years, 8 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 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/input_router_impl.h" 5 #include "content/browser/renderer_host/input/input_router_impl.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 client_(client), 139 client_(client),
140 ack_handler_(ack_handler), 140 ack_handler_(ack_handler),
141 routing_id_(routing_id), 141 routing_id_(routing_id),
142 select_range_pending_(false), 142 select_range_pending_(false),
143 move_caret_pending_(false), 143 move_caret_pending_(false),
144 mouse_move_pending_(false), 144 mouse_move_pending_(false),
145 mouse_wheel_pending_(false), 145 mouse_wheel_pending_(false),
146 touch_ack_timeout_supported_(false), 146 touch_ack_timeout_supported_(false),
147 current_view_flags_(0), 147 current_view_flags_(0),
148 current_ack_source_(ACK_SOURCE_NONE), 148 current_ack_source_(ACK_SOURCE_NONE),
149 gesture_event_queue_(new GestureEventQueue(this, this)) { 149 flush_requested_(false),
150 touch_event_queue_(this,
151 GetTouchScrollingMode(),
152 GetTouchMoveSlopSuppressionLengthDips()),
153 gesture_event_queue_(this, this) {
150 DCHECK(sender); 154 DCHECK(sender);
151 DCHECK(client); 155 DCHECK(client);
152 DCHECK(ack_handler); 156 DCHECK(ack_handler);
153 touch_event_queue_.reset(new TouchEventQueue(
154 this, GetTouchScrollingMode(), GetTouchMoveSlopSuppressionLengthDips()));
155 touch_ack_timeout_supported_ = 157 touch_ack_timeout_supported_ =
156 GetTouchAckTimeoutDelay(&touch_ack_timeout_delay_); 158 GetTouchAckTimeoutDelay(&touch_ack_timeout_delay_);
157 UpdateTouchAckTimeoutEnabled(); 159 UpdateTouchAckTimeoutEnabled();
158 } 160 }
159 161
160 InputRouterImpl::~InputRouterImpl() {} 162 InputRouterImpl::~InputRouterImpl() {}
161 163
162 void InputRouterImpl::Flush() {} 164 void InputRouterImpl::Flush() {
165 flush_requested_ = true;
166 SignalFlushedIfNecessary();
167 }
163 168
164 bool InputRouterImpl::SendInput(scoped_ptr<IPC::Message> message) { 169 bool InputRouterImpl::SendInput(scoped_ptr<IPC::Message> message) {
165 DCHECK(IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart); 170 DCHECK(IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart);
166 switch (message->type()) { 171 switch (message->type()) {
167 // Check for types that require an ACK. 172 // Check for types that require an ACK.
168 case InputMsg_SelectRange::ID: 173 case InputMsg_SelectRange::ID:
169 return SendSelectRange(message.Pass()); 174 return SendSelectRange(message.Pass());
170 case InputMsg_MoveCaret::ID: 175 case InputMsg_MoveCaret::ID:
171 return SendMoveCaret(message.Pass()); 176 return SendMoveCaret(message.Pass());
172 case InputMsg_HandleInputEvent::ID: 177 case InputMsg_HandleInputEvent::ID:
173 NOTREACHED() << "WebInputEvents should never be sent via SendInput."; 178 NOTREACHED() << "WebInputEvents should never be sent via SendInput.";
174 return false; 179 return false;
175 default: 180 default:
176 return Send(message.release()); 181 return Send(message.release());
177 } 182 }
178 } 183 }
179 184
180 void InputRouterImpl::SendMouseEvent( 185 void InputRouterImpl::SendMouseEvent(
181 const MouseEventWithLatencyInfo& mouse_event) { 186 const MouseEventWithLatencyInfo& mouse_event) {
182 // Order is important here; we need to convert all MouseEvents before they 187 // Order is important here; we need to convert all MouseEvents before they
183 // propagate further, e.g., to the tap suppression controller. 188 // propagate further, e.g., to the tap suppression controller.
184 if (CommandLine::ForCurrentProcess()->HasSwitch( 189 if (CommandLine::ForCurrentProcess()->HasSwitch(
185 switches::kSimulateTouchScreenWithMouse)) { 190 switches::kSimulateTouchScreenWithMouse)) {
186 SimulateTouchGestureWithMouse(mouse_event); 191 SimulateTouchGestureWithMouse(mouse_event);
187 return; 192 return;
188 } 193 }
189 194
190 if (mouse_event.event.type == WebInputEvent::MouseDown && 195 if (mouse_event.event.type == WebInputEvent::MouseDown &&
191 gesture_event_queue_->GetTouchpadTapSuppressionController()-> 196 gesture_event_queue_.GetTouchpadTapSuppressionController()->
192 ShouldDeferMouseDown(mouse_event)) 197 ShouldDeferMouseDown(mouse_event))
193 return; 198 return;
194 if (mouse_event.event.type == WebInputEvent::MouseUp && 199 if (mouse_event.event.type == WebInputEvent::MouseUp &&
195 gesture_event_queue_->GetTouchpadTapSuppressionController()-> 200 gesture_event_queue_.GetTouchpadTapSuppressionController()->
196 ShouldSuppressMouseUp()) 201 ShouldSuppressMouseUp())
197 return; 202 return;
198 203
199 SendMouseEventImmediately(mouse_event); 204 SendMouseEventImmediately(mouse_event);
200 } 205 }
201 206
202 void InputRouterImpl::SendWheelEvent( 207 void InputRouterImpl::SendWheelEvent(
203 const MouseWheelEventWithLatencyInfo& wheel_event) { 208 const MouseWheelEventWithLatencyInfo& wheel_event) {
204 // If there's already a mouse wheel event waiting to be sent to the renderer, 209 // If there's already a mouse wheel event waiting to be sent to the renderer,
205 // add the new deltas to that event. Not doing so (e.g., by dropping the old 210 // add the new deltas to that event. Not doing so (e.g., by dropping the old
(...skipping 19 matching lines...) Expand all
225 230
226 void InputRouterImpl::SendKeyboardEvent(const NativeWebKeyboardEvent& key_event, 231 void InputRouterImpl::SendKeyboardEvent(const NativeWebKeyboardEvent& key_event,
227 const ui::LatencyInfo& latency_info, 232 const ui::LatencyInfo& latency_info,
228 bool is_keyboard_shortcut) { 233 bool is_keyboard_shortcut) {
229 // Put all WebKeyboardEvent objects in a queue since we can't trust the 234 // Put all WebKeyboardEvent objects in a queue since we can't trust the
230 // renderer and we need to give something to the HandleKeyboardEvent 235 // renderer and we need to give something to the HandleKeyboardEvent
231 // handler. 236 // handler.
232 key_queue_.push_back(key_event); 237 key_queue_.push_back(key_event);
233 HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size()); 238 HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size());
234 239
235 gesture_event_queue_->FlingHasBeenHalted(); 240 gesture_event_queue_.FlingHasBeenHalted();
236 241
237 // Only forward the non-native portions of our event. 242 // Only forward the non-native portions of our event.
238 FilterAndSendWebInputEvent(key_event, latency_info, is_keyboard_shortcut); 243 FilterAndSendWebInputEvent(key_event, latency_info, is_keyboard_shortcut);
239 } 244 }
240 245
241 void InputRouterImpl::SendGestureEvent( 246 void InputRouterImpl::SendGestureEvent(
242 const GestureEventWithLatencyInfo& original_gesture_event) { 247 const GestureEventWithLatencyInfo& original_gesture_event) {
243 event_stream_validator_.OnEvent(original_gesture_event.event); 248 event_stream_validator_.OnEvent(original_gesture_event.event);
244 GestureEventWithLatencyInfo gesture_event(original_gesture_event); 249 GestureEventWithLatencyInfo gesture_event(original_gesture_event);
245 250
246 if (touch_action_filter_.FilterGestureEvent(&gesture_event.event)) 251 if (touch_action_filter_.FilterGestureEvent(&gesture_event.event))
247 return; 252 return;
248 253
249 touch_event_queue_->OnGestureScrollEvent(gesture_event); 254 touch_event_queue_.OnGestureScrollEvent(gesture_event);
250 255
251 if (!IsInOverscrollGesture() && 256 if (!IsInOverscrollGesture() &&
252 !gesture_event_queue_->ShouldForward(gesture_event)) { 257 !gesture_event_queue_.ShouldForward(gesture_event)) {
253 OverscrollController* controller = client_->GetOverscrollController(); 258 OverscrollController* controller = client_->GetOverscrollController();
254 if (controller) 259 if (controller)
255 controller->DiscardingGestureEvent(gesture_event.event); 260 controller->DiscardingGestureEvent(gesture_event.event);
256 return; 261 return;
257 } 262 }
258 263
259 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false); 264 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false);
260 } 265 }
261 266
262 void InputRouterImpl::SendTouchEvent( 267 void InputRouterImpl::SendTouchEvent(
263 const TouchEventWithLatencyInfo& touch_event) { 268 const TouchEventWithLatencyInfo& touch_event) {
264 touch_event_queue_->QueueEvent(touch_event); 269 touch_event_queue_.QueueEvent(touch_event);
265 } 270 }
266 271
267 // Forwards MouseEvent without passing it through 272 // Forwards MouseEvent without passing it through
268 // TouchpadTapSuppressionController. 273 // TouchpadTapSuppressionController.
269 void InputRouterImpl::SendMouseEventImmediately( 274 void InputRouterImpl::SendMouseEventImmediately(
270 const MouseEventWithLatencyInfo& mouse_event) { 275 const MouseEventWithLatencyInfo& mouse_event) {
271 // Avoid spamming the renderer with mouse move events. It is important 276 // Avoid spamming the renderer with mouse move events. It is important
272 // to note that WM_MOUSEMOVE events are anyways synthetic, but since our 277 // to note that WM_MOUSEMOVE events are anyways synthetic, but since our
273 // thread is able to rapidly consume WM_MOUSEMOVE events, we may get way 278 // thread is able to rapidly consume WM_MOUSEMOVE events, we may get way
274 // more WM_MOUSEMOVE events than we wish to send to the renderer. 279 // more WM_MOUSEMOVE events than we wish to send to the renderer.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 312
308 const NativeWebKeyboardEvent* InputRouterImpl::GetLastKeyboardEvent() const { 313 const NativeWebKeyboardEvent* InputRouterImpl::GetLastKeyboardEvent() const {
309 if (key_queue_.empty()) 314 if (key_queue_.empty())
310 return NULL; 315 return NULL;
311 return &key_queue_.front(); 316 return &key_queue_.front();
312 } 317 }
313 318
314 bool InputRouterImpl::ShouldForwardTouchEvent() const { 319 bool InputRouterImpl::ShouldForwardTouchEvent() const {
315 // Always send a touch event if the renderer has a touch-event handler or 320 // Always send a touch event if the renderer has a touch-event handler or
316 // there are pending touch events. 321 // there are pending touch events.
317 return touch_event_queue_->has_handlers() || !touch_event_queue_->empty(); 322 return touch_event_queue_.has_handlers() || !touch_event_queue_.empty();
318 } 323 }
319 324
320 void InputRouterImpl::OnViewUpdated(int view_flags) { 325 void InputRouterImpl::OnViewUpdated(int view_flags) {
321 current_view_flags_ = view_flags; 326 current_view_flags_ = view_flags;
322 327
323 // A fixed page scale or mobile viewport should disable the touch ack timeout. 328 // A fixed page scale or mobile viewport should disable the touch ack timeout.
324 UpdateTouchAckTimeoutEnabled(); 329 UpdateTouchAckTimeoutEnabled();
325 } 330 }
326 331
327 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) { 332 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) {
(...skipping 24 matching lines...) Expand all
352 ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) { 357 ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) {
353 touch_action_filter_.ResetTouchAction(); 358 touch_action_filter_.ResetTouchAction();
354 UpdateTouchAckTimeoutEnabled(); 359 UpdateTouchAckTimeoutEnabled();
355 } 360 }
356 ack_handler_->OnTouchEventAck(event, ack_result); 361 ack_handler_->OnTouchEventAck(event, ack_result);
357 } 362 }
358 363
359 void InputRouterImpl::OnGestureEventAck( 364 void InputRouterImpl::OnGestureEventAck(
360 const GestureEventWithLatencyInfo& event, 365 const GestureEventWithLatencyInfo& event,
361 InputEventAckState ack_result) { 366 InputEventAckState ack_result) {
362 touch_event_queue_->OnGestureEventAck(event, ack_result); 367 touch_event_queue_.OnGestureEventAck(event, ack_result);
363 ProcessAckForOverscroll(event.event, ack_result); 368 ProcessAckForOverscroll(event.event, ack_result);
364 ack_handler_->OnGestureEventAck(event, ack_result); 369 ack_handler_->OnGestureEventAck(event, ack_result);
365 } 370 }
366 371
367 bool InputRouterImpl::SendSelectRange(scoped_ptr<IPC::Message> message) { 372 bool InputRouterImpl::SendSelectRange(scoped_ptr<IPC::Message> message) {
368 DCHECK(message->type() == InputMsg_SelectRange::ID); 373 DCHECK(message->type() == InputMsg_SelectRange::ID);
369 if (select_range_pending_) { 374 if (select_range_pending_) {
370 next_selection_range_ = message.Pass(); 375 next_selection_range_ = message.Pass();
371 return true; 376 return true;
372 } 377 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 OverscrollController::Disposition disposition = 465 OverscrollController::Disposition disposition =
461 controller->DispatchEvent(input_event, latency_info); 466 controller->DispatchEvent(input_event, latency_info);
462 467
463 bool consumed = disposition == OverscrollController::CONSUMED; 468 bool consumed = disposition == OverscrollController::CONSUMED;
464 469
465 if (disposition == OverscrollController::SHOULD_FORWARD_TO_GESTURE_QUEUE) { 470 if (disposition == OverscrollController::SHOULD_FORWARD_TO_GESTURE_QUEUE) {
466 DCHECK(WebInputEvent::isGestureEventType(input_event.type)); 471 DCHECK(WebInputEvent::isGestureEventType(input_event.type));
467 const blink::WebGestureEvent& gesture_event = 472 const blink::WebGestureEvent& gesture_event =
468 static_cast<const blink::WebGestureEvent&>(input_event); 473 static_cast<const blink::WebGestureEvent&>(input_event);
469 // An ACK is expected for the event, so mark it as consumed. 474 // An ACK is expected for the event, so mark it as consumed.
470 consumed = !gesture_event_queue_->ShouldForward( 475 consumed = !gesture_event_queue_.ShouldForward(
471 GestureEventWithLatencyInfo(gesture_event, latency_info)); 476 GestureEventWithLatencyInfo(gesture_event, latency_info));
472 } 477 }
473 478
474 if (consumed) { 479 if (consumed) {
475 InputEventAckState overscroll_ack = 480 InputEventAckState overscroll_ack =
476 WebInputEvent::isTouchEventType(input_event.type) ? 481 WebInputEvent::isTouchEventType(input_event.type) ?
477 INPUT_EVENT_ACK_STATE_NOT_CONSUMED : INPUT_EVENT_ACK_STATE_CONSUMED; 482 INPUT_EVENT_ACK_STATE_NOT_CONSUMED : INPUT_EVENT_ACK_STATE_CONSUMED;
478 ProcessInputEventAck(input_event.type, 483 ProcessInputEventAck(input_event.type,
479 overscroll_ack, 484 overscroll_ack,
480 latency_info, 485 latency_info,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 void InputRouterImpl::OnSelectRangeAck() { 573 void InputRouterImpl::OnSelectRangeAck() {
569 select_range_pending_ = false; 574 select_range_pending_ = false;
570 if (next_selection_range_) 575 if (next_selection_range_)
571 SendSelectRange(next_selection_range_.Pass()); 576 SendSelectRange(next_selection_range_.Pass());
572 } 577 }
573 578
574 void InputRouterImpl::OnHasTouchEventHandlers(bool has_handlers) { 579 void InputRouterImpl::OnHasTouchEventHandlers(bool has_handlers) {
575 TRACE_EVENT1("input", "InputRouterImpl::OnHasTouchEventHandlers", 580 TRACE_EVENT1("input", "InputRouterImpl::OnHasTouchEventHandlers",
576 "has_handlers", has_handlers); 581 "has_handlers", has_handlers);
577 582
578 touch_event_queue_->OnHasTouchEventHandlers(has_handlers); 583 touch_event_queue_.OnHasTouchEventHandlers(has_handlers);
579 client_->OnHasTouchEventHandlers(has_handlers); 584 client_->OnHasTouchEventHandlers(has_handlers);
580 } 585 }
581 586
582 void InputRouterImpl::OnSetTouchAction(TouchAction touch_action) { 587 void InputRouterImpl::OnSetTouchAction(TouchAction touch_action) {
583 // Synthetic touchstart events should get filtered out in RenderWidget. 588 // Synthetic touchstart events should get filtered out in RenderWidget.
584 DCHECK(touch_event_queue_->IsPendingAckTouchStart()); 589 DCHECK(touch_event_queue_.IsPendingAckTouchStart());
585 TRACE_EVENT1("input", "InputRouterImpl::OnSetTouchAction", 590 TRACE_EVENT1("input", "InputRouterImpl::OnSetTouchAction",
586 "action", touch_action); 591 "action", touch_action);
587 592
588 touch_action_filter_.OnSetTouchAction(touch_action); 593 touch_action_filter_.OnSetTouchAction(touch_action);
589 594
590 // TOUCH_ACTION_NONE should disable the touch ack timeout. 595 // TOUCH_ACTION_NONE should disable the touch ack timeout.
591 UpdateTouchAckTimeoutEnabled(); 596 UpdateTouchAckTimeoutEnabled();
592 } 597 }
593 598
594 void InputRouterImpl::ProcessInputEventAck( 599 void InputRouterImpl::ProcessInputEventAck(
(...skipping 21 matching lines...) Expand all
616 ProcessMouseAck(event_type, ack_result); 621 ProcessMouseAck(event_type, ack_result);
617 } else if (event_type == WebInputEvent::MouseWheel) { 622 } else if (event_type == WebInputEvent::MouseWheel) {
618 ProcessWheelAck(ack_result, latency_info); 623 ProcessWheelAck(ack_result, latency_info);
619 } else if (WebInputEvent::isTouchEventType(event_type)) { 624 } else if (WebInputEvent::isTouchEventType(event_type)) {
620 ProcessTouchAck(ack_result, latency_info); 625 ProcessTouchAck(ack_result, latency_info);
621 } else if (WebInputEvent::isGestureEventType(event_type)) { 626 } else if (WebInputEvent::isGestureEventType(event_type)) {
622 ProcessGestureAck(event_type, ack_result, latency_info); 627 ProcessGestureAck(event_type, ack_result, latency_info);
623 } else if (event_type != WebInputEvent::Undefined) { 628 } else if (event_type != WebInputEvent::Undefined) {
624 ack_handler_->OnUnexpectedEventAck(InputAckHandler::BAD_ACK_MESSAGE); 629 ack_handler_->OnUnexpectedEventAck(InputAckHandler::BAD_ACK_MESSAGE);
625 } 630 }
631
632 SignalFlushedIfNecessary();
626 } 633 }
627 634
628 void InputRouterImpl::ProcessKeyboardAck(blink::WebInputEvent::Type type, 635 void InputRouterImpl::ProcessKeyboardAck(blink::WebInputEvent::Type type,
629 InputEventAckState ack_result) { 636 InputEventAckState ack_result) {
630 if (key_queue_.empty()) { 637 if (key_queue_.empty()) {
631 ack_handler_->OnUnexpectedEventAck(InputAckHandler::UNEXPECTED_ACK); 638 ack_handler_->OnUnexpectedEventAck(InputAckHandler::UNEXPECTED_ACK);
632 } else if (key_queue_.front().type != type) { 639 } else if (key_queue_.front().type != type) {
633 // Something must be wrong. Clear the |key_queue_| and char event 640 // Something must be wrong. Clear the |key_queue_| and char event
634 // suppression so that we can resume from the error. 641 // suppression so that we can resume from the error.
635 key_queue_.clear(); 642 key_queue_.clear();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 SendWheelEvent(next_wheel_event); 688 SendWheelEvent(next_wheel_event);
682 } 689 }
683 } 690 }
684 691
685 void InputRouterImpl::ProcessGestureAck(WebInputEvent::Type type, 692 void InputRouterImpl::ProcessGestureAck(WebInputEvent::Type type,
686 InputEventAckState ack_result, 693 InputEventAckState ack_result,
687 const ui::LatencyInfo& latency) { 694 const ui::LatencyInfo& latency) {
688 // If |ack_result| originated from the overscroll controller, only 695 // If |ack_result| originated from the overscroll controller, only
689 // feed |gesture_event_queue_| the ack if it was expecting one. 696 // feed |gesture_event_queue_| the ack if it was expecting one.
690 if (current_ack_source_ == OVERSCROLL_CONTROLLER && 697 if (current_ack_source_ == OVERSCROLL_CONTROLLER &&
691 !gesture_event_queue_->HasQueuedGestureEvents()) { 698 !gesture_event_queue_.ExpectingGestureAck()) {
692 return; 699 return;
693 } 700 }
694 701
695 // |gesture_event_queue_| will forward to OnGestureEventAck when appropriate. 702 // |gesture_event_queue_| will forward to OnGestureEventAck when appropriate.
696 gesture_event_queue_->ProcessGestureAck(ack_result, type, latency); 703 gesture_event_queue_.ProcessGestureAck(ack_result, type, latency);
697 } 704 }
698 705
699 void InputRouterImpl::ProcessTouchAck( 706 void InputRouterImpl::ProcessTouchAck(
700 InputEventAckState ack_result, 707 InputEventAckState ack_result,
701 const ui::LatencyInfo& latency) { 708 const ui::LatencyInfo& latency) {
702 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate. 709 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate.
703 touch_event_queue_->ProcessTouchAck(ack_result, latency); 710 touch_event_queue_.ProcessTouchAck(ack_result, latency);
704 } 711 }
705 712
706 void InputRouterImpl::ProcessAckForOverscroll(const WebInputEvent& event, 713 void InputRouterImpl::ProcessAckForOverscroll(const WebInputEvent& event,
707 InputEventAckState ack_result) { 714 InputEventAckState ack_result) {
708 // Acks sent from the overscroll controller need not be fed back into the 715 // Acks sent from the overscroll controller need not be fed back into the
709 // overscroll controller. 716 // overscroll controller.
710 if (current_ack_source_ == OVERSCROLL_CONTROLLER) 717 if (current_ack_source_ == OVERSCROLL_CONTROLLER)
711 return; 718 return;
712 719
713 OverscrollController* controller = client_->GetOverscrollController(); 720 OverscrollController* controller = client_->GetOverscrollController();
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 x, y, 0, event.latency)); 800 x, y, 0, event.latency));
794 } 801 }
795 break; 802 break;
796 case WebMouseEvent::ButtonNone: 803 case WebMouseEvent::ButtonNone:
797 break; 804 break;
798 } 805 }
799 } 806 }
800 807
801 void InputRouterImpl::UpdateTouchAckTimeoutEnabled() { 808 void InputRouterImpl::UpdateTouchAckTimeoutEnabled() {
802 if (!touch_ack_timeout_supported_) { 809 if (!touch_ack_timeout_supported_) {
803 touch_event_queue_->SetAckTimeoutEnabled(false, base::TimeDelta()); 810 touch_event_queue_.SetAckTimeoutEnabled(false, base::TimeDelta());
804 return; 811 return;
805 } 812 }
806 813
807 // Mobile sites tend to be well-behaved with respect to touch handling, so 814 // Mobile sites tend to be well-behaved with respect to touch handling, so
808 // they have less need for the touch timeout fallback. 815 // they have less need for the touch timeout fallback.
809 const bool fixed_page_scale = (current_view_flags_ & FIXED_PAGE_SCALE) != 0; 816 const bool fixed_page_scale = (current_view_flags_ & FIXED_PAGE_SCALE) != 0;
810 const bool mobile_viewport = (current_view_flags_ & MOBILE_VIEWPORT) != 0; 817 const bool mobile_viewport = (current_view_flags_ & MOBILE_VIEWPORT) != 0;
811 818
812 // TOUCH_ACTION_NONE will prevent scrolling, in which case the timeout serves 819 // TOUCH_ACTION_NONE will prevent scrolling, in which case the timeout serves
813 // little purpose. It's also a strong signal that touch handling is critical 820 // little purpose. It's also a strong signal that touch handling is critical
814 // to page functionality, so the timeout could do more harm than good. 821 // to page functionality, so the timeout could do more harm than good.
815 const bool touch_action_none = 822 const bool touch_action_none =
816 touch_action_filter_.allowed_touch_action() == TOUCH_ACTION_NONE; 823 touch_action_filter_.allowed_touch_action() == TOUCH_ACTION_NONE;
817 824
818 const bool touch_ack_timeout_enabled = !fixed_page_scale && 825 const bool touch_ack_timeout_enabled = !fixed_page_scale &&
819 !mobile_viewport && 826 !mobile_viewport &&
820 !touch_action_none; 827 !touch_action_none;
821 touch_event_queue_->SetAckTimeoutEnabled(touch_ack_timeout_enabled, 828 touch_event_queue_.SetAckTimeoutEnabled(touch_ack_timeout_enabled,
822 touch_ack_timeout_delay_); 829 touch_ack_timeout_delay_);
830 }
831
832 void InputRouterImpl::SignalFlushedIfNecessary() {
833 if (!flush_requested_)
834 return;
835
836 if (HasPendingEvents())
837 return;
838
839 flush_requested_ = false;
840 client_->DidFlush();
841 }
842
843 bool InputRouterImpl::HasPendingEvents() const {
844 return !touch_event_queue_.empty() ||
845 !gesture_event_queue_.empty() ||
846 !key_queue_.empty() ||
847 mouse_move_pending_ ||
848 mouse_wheel_pending_ ||
849 select_range_pending_ ||
850 move_caret_pending_;
823 } 851 }
824 852
825 bool InputRouterImpl::IsInOverscrollGesture() const { 853 bool InputRouterImpl::IsInOverscrollGesture() const {
826 OverscrollController* controller = client_->GetOverscrollController(); 854 OverscrollController* controller = client_->GetOverscrollController();
827 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; 855 return controller && controller->overscroll_mode() != OVERSCROLL_NONE;
828 } 856 }
829 857
830 } // namespace content 858 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698