| OLD | NEW |
| 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 <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 current_view_flags_ = view_flags; | 241 current_view_flags_ = view_flags; |
| 242 | 242 |
| 243 // A fixed page scale or mobile viewport should disable the touch ack timeout. | 243 // A fixed page scale or mobile viewport should disable the touch ack timeout. |
| 244 UpdateTouchAckTimeoutEnabled(); | 244 UpdateTouchAckTimeoutEnabled(); |
| 245 } | 245 } |
| 246 | 246 |
| 247 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) { | 247 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) { |
| 248 bool handled = true; | 248 bool handled = true; |
| 249 IPC_BEGIN_MESSAGE_MAP(InputRouterImpl, message) | 249 IPC_BEGIN_MESSAGE_MAP(InputRouterImpl, message) |
| 250 IPC_MESSAGE_HANDLER(InputHostMsg_HandleInputEvent_ACK, OnInputEventAck) | 250 IPC_MESSAGE_HANDLER(InputHostMsg_HandleInputEvent_ACK, OnInputEventAck) |
| 251 IPC_MESSAGE_HANDLER(InputHostMsg_HandleAsyncTouchEvent_ACK, |
| 252 OnAsyncTouchEventAck) |
| 251 IPC_MESSAGE_HANDLER(InputHostMsg_DidOverscroll, OnDidOverscroll) | 253 IPC_MESSAGE_HANDLER(InputHostMsg_DidOverscroll, OnDidOverscroll) |
| 252 IPC_MESSAGE_HANDLER(InputHostMsg_MoveCaret_ACK, OnMsgMoveCaretAck) | 254 IPC_MESSAGE_HANDLER(InputHostMsg_MoveCaret_ACK, OnMsgMoveCaretAck) |
| 253 IPC_MESSAGE_HANDLER(InputHostMsg_SelectRange_ACK, OnSelectMessageAck) | 255 IPC_MESSAGE_HANDLER(InputHostMsg_SelectRange_ACK, OnSelectMessageAck) |
| 254 IPC_MESSAGE_HANDLER(InputHostMsg_MoveRangeSelectionExtent_ACK, | 256 IPC_MESSAGE_HANDLER(InputHostMsg_MoveRangeSelectionExtent_ACK, |
| 255 OnSelectMessageAck) | 257 OnSelectMessageAck) |
| 256 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, | 258 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, |
| 257 OnHasTouchEventHandlers) | 259 OnHasTouchEventHandlers) |
| 258 IPC_MESSAGE_HANDLER(InputHostMsg_SetTouchAction, | 260 IPC_MESSAGE_HANDLER(InputHostMsg_SetTouchAction, |
| 259 OnSetTouchAction) | 261 OnSetTouchAction) |
| 260 IPC_MESSAGE_UNHANDLED(handled = false) | 262 IPC_MESSAGE_UNHANDLED(handled = false) |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 output_stream_validator_.Validate(input_event); | 342 output_stream_validator_.Validate(input_event); |
| 341 | 343 |
| 342 if (OfferToClient(input_event, latency_info)) | 344 if (OfferToClient(input_event, latency_info)) |
| 343 return; | 345 return; |
| 344 | 346 |
| 345 OfferToRenderer(input_event, latency_info, is_keyboard_shortcut); | 347 OfferToRenderer(input_event, latency_info, is_keyboard_shortcut); |
| 346 | 348 |
| 347 // Touch events should always indicate in the event whether they are | 349 // Touch events should always indicate in the event whether they are |
| 348 // cancelable (respect ACK disposition) or not. | 350 // cancelable (respect ACK disposition) or not. |
| 349 bool ignores_ack = WebInputEventTraits::IgnoresAckDisposition(input_event); | 351 bool ignores_ack = WebInputEventTraits::IgnoresAckDisposition(input_event); |
| 352 bool is_async_touch_move = false; |
| 350 if (WebInputEvent::isTouchEventType(input_event.type)) { | 353 if (WebInputEvent::isTouchEventType(input_event.type)) { |
| 351 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); | 354 const WebTouchEvent& touch = static_cast<const WebTouchEvent&>(input_event); |
| 352 DCHECK_NE(ignores_ack, !!touch.cancelable); | 355 if (touch.type == WebInputEvent::TouchMove && !touch.cancelable) |
| 356 is_async_touch_move = true; |
| 357 |
| 358 if (touch.type != WebInputEvent::TouchMove) |
| 359 DCHECK_NE(ignores_ack, touch.cancelable); |
| 353 } | 360 } |
| 354 | 361 |
| 355 // If we don't care about the ack disposition, send the ack immediately. | 362 // If we don't care about the ack disposition, or it is an async touchmove |
| 356 if (ignores_ack) { | 363 // event, send the ack immediately. |
| 364 if (ignores_ack || is_async_touch_move) { |
| 357 ProcessInputEventAck(input_event.type, | 365 ProcessInputEventAck(input_event.type, |
| 358 INPUT_EVENT_ACK_STATE_IGNORED, | 366 INPUT_EVENT_ACK_STATE_IGNORED, |
| 359 latency_info, | 367 latency_info, |
| 360 IGNORING_DISPOSITION); | 368 IGNORING_DISPOSITION); |
| 361 } | 369 } |
| 362 } | 370 } |
| 363 | 371 |
| 364 bool InputRouterImpl::OfferToClient(const WebInputEvent& input_event, | 372 bool InputRouterImpl::OfferToClient(const WebInputEvent& input_event, |
| 365 const ui::LatencyInfo& latency_info) { | 373 const ui::LatencyInfo& latency_info) { |
| 366 bool consumed = false; | 374 bool consumed = false; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 // (ProcessInputEventAck) method, but not on other platforms; using | 436 // (ProcessInputEventAck) method, but not on other platforms; using |
| 429 // 'void' instead is just as safe (since NotificationSource | 437 // 'void' instead is just as safe (since NotificationSource |
| 430 // is not actually typesafe) and avoids this error. | 438 // is not actually typesafe) and avoids this error. |
| 431 int type = static_cast<int>(ack.type); | 439 int type = static_cast<int>(ack.type); |
| 432 NotificationService::current()->Notify( | 440 NotificationService::current()->Notify( |
| 433 NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK, | 441 NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK, |
| 434 Source<void>(this), | 442 Source<void>(this), |
| 435 Details<int>(&type)); | 443 Details<int>(&type)); |
| 436 } | 444 } |
| 437 | 445 |
| 446 void InputRouterImpl::OnAsyncTouchEventAck( |
| 447 const InputHostMsg_HandleAsyncTouchEvent_ACK_Params& ack) { |
| 448 ProcessAsyncTouchAck(); |
| 449 int type = static_cast<int>(ack.type); |
| 450 NotificationService::current()->Notify( |
| 451 NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK, |
| 452 Source<void>(this), Details<int>(&type)); |
| 453 } |
| 454 |
| 438 void InputRouterImpl::OnDidOverscroll(const DidOverscrollParams& params) { | 455 void InputRouterImpl::OnDidOverscroll(const DidOverscrollParams& params) { |
| 439 client_->DidOverscroll(params); | 456 client_->DidOverscroll(params); |
| 440 } | 457 } |
| 441 | 458 |
| 442 void InputRouterImpl::OnMsgMoveCaretAck() { | 459 void InputRouterImpl::OnMsgMoveCaretAck() { |
| 443 move_caret_pending_ = false; | 460 move_caret_pending_ = false; |
| 444 if (next_move_caret_) | 461 if (next_move_caret_) |
| 445 SendMoveCaret(next_move_caret_.Pass()); | 462 SendMoveCaret(next_move_caret_.Pass()); |
| 446 } | 463 } |
| 447 | 464 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 gesture_event_queue_.ProcessGestureAck(ack_result, type, latency); | 607 gesture_event_queue_.ProcessGestureAck(ack_result, type, latency); |
| 591 } | 608 } |
| 592 | 609 |
| 593 void InputRouterImpl::ProcessTouchAck( | 610 void InputRouterImpl::ProcessTouchAck( |
| 594 InputEventAckState ack_result, | 611 InputEventAckState ack_result, |
| 595 const ui::LatencyInfo& latency) { | 612 const ui::LatencyInfo& latency) { |
| 596 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate. | 613 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate. |
| 597 touch_event_queue_.ProcessTouchAck(ack_result, latency); | 614 touch_event_queue_.ProcessTouchAck(ack_result, latency); |
| 598 } | 615 } |
| 599 | 616 |
| 617 void InputRouterImpl::ProcessAsyncTouchAck() { |
| 618 touch_event_queue_.ProcessAsyncTouchAck(); |
| 619 } |
| 620 |
| 600 void InputRouterImpl::UpdateTouchAckTimeoutEnabled() { | 621 void InputRouterImpl::UpdateTouchAckTimeoutEnabled() { |
| 601 // Mobile sites tend to be well-behaved with respect to touch handling, so | 622 // Mobile sites tend to be well-behaved with respect to touch handling, so |
| 602 // they have less need for the touch timeout fallback. | 623 // they have less need for the touch timeout fallback. |
| 603 const bool fixed_page_scale = (current_view_flags_ & FIXED_PAGE_SCALE) != 0; | 624 const bool fixed_page_scale = (current_view_flags_ & FIXED_PAGE_SCALE) != 0; |
| 604 const bool mobile_viewport = (current_view_flags_ & MOBILE_VIEWPORT) != 0; | 625 const bool mobile_viewport = (current_view_flags_ & MOBILE_VIEWPORT) != 0; |
| 605 | 626 |
| 606 // TOUCH_ACTION_NONE will prevent scrolling, in which case the timeout serves | 627 // TOUCH_ACTION_NONE will prevent scrolling, in which case the timeout serves |
| 607 // little purpose. It's also a strong signal that touch handling is critical | 628 // little purpose. It's also a strong signal that touch handling is critical |
| 608 // to page functionality, so the timeout could do more harm than good. | 629 // to page functionality, so the timeout could do more harm than good. |
| 609 const bool touch_action_none = | 630 const bool touch_action_none = |
| (...skipping 20 matching lines...) Expand all Loading... |
| 630 return !touch_event_queue_.empty() || | 651 return !touch_event_queue_.empty() || |
| 631 !gesture_event_queue_.empty() || | 652 !gesture_event_queue_.empty() || |
| 632 !key_queue_.empty() || | 653 !key_queue_.empty() || |
| 633 mouse_move_pending_ || | 654 mouse_move_pending_ || |
| 634 mouse_wheel_pending_ || | 655 mouse_wheel_pending_ || |
| 635 select_message_pending_ || | 656 select_message_pending_ || |
| 636 move_caret_pending_; | 657 move_caret_pending_; |
| 637 } | 658 } |
| 638 | 659 |
| 639 } // namespace content | 660 } // namespace content |
| OLD | NEW |