| 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 case INPUT_EVENT_ACK_STATE_NOT_CONSUMED: return "NOT_CONSUMED"; | 50 case INPUT_EVENT_ACK_STATE_NOT_CONSUMED: return "NOT_CONSUMED"; |
| 51 case INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS: return "NO_CONSUMER_EXISTS"; | 51 case INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS: return "NO_CONSUMER_EXISTS"; |
| 52 case INPUT_EVENT_ACK_STATE_IGNORED: return "IGNORED"; | 52 case INPUT_EVENT_ACK_STATE_IGNORED: return "IGNORED"; |
| 53 } | 53 } |
| 54 DLOG(WARNING) << "Unhandled InputEventAckState in GetEventAckName."; | 54 DLOG(WARNING) << "Unhandled InputEventAckState in GetEventAckName."; |
| 55 return ""; | 55 return ""; |
| 56 } | 56 } |
| 57 | 57 |
| 58 } // namespace | 58 } // namespace |
| 59 | 59 |
| 60 InputRouterImpl::Config::Config() { | 60 InputRouterImpl::Config::Config() {} |
| 61 } | |
| 62 | 61 |
| 63 InputRouterImpl::InputRouterImpl(IPC::Sender* sender, | 62 InputRouterImpl::InputRouterImpl(IPC::Sender* sender, |
| 64 InputRouterClient* client, | 63 InputRouterClient* client, |
| 65 InputAckHandler* ack_handler, | 64 InputAckHandler* ack_handler, |
| 66 int routing_id, | 65 int routing_id, |
| 67 const Config& config) | 66 const Config& config) |
| 68 : sender_(sender), | 67 : sender_(sender), |
| 69 client_(client), | 68 client_(client), |
| 70 ack_handler_(ack_handler), | 69 ack_handler_(ack_handler), |
| 71 routing_id_(routing_id), | 70 routing_id_(routing_id), |
| (...skipping 26 matching lines...) Expand all Loading... |
| 98 case InputMsg_MoveCaret::ID: | 97 case InputMsg_MoveCaret::ID: |
| 99 return SendMoveCaret(message.Pass()); | 98 return SendMoveCaret(message.Pass()); |
| 100 case InputMsg_HandleInputEvent::ID: | 99 case InputMsg_HandleInputEvent::ID: |
| 101 NOTREACHED() << "WebInputEvents should never be sent via SendInput."; | 100 NOTREACHED() << "WebInputEvents should never be sent via SendInput."; |
| 102 return false; | 101 return false; |
| 103 default: | 102 default: |
| 104 return Send(message.release()); | 103 return Send(message.release()); |
| 105 } | 104 } |
| 106 } | 105 } |
| 107 | 106 |
| 107 void InputRouterImpl::FlushInput(base::TimeTicks flush_time) { |
| 108 flush_requested_ = true; |
| 109 SignalFlushedIfNecessary(); |
| 110 } |
| 111 |
| 108 void InputRouterImpl::SendMouseEvent( | 112 void InputRouterImpl::SendMouseEvent( |
| 109 const MouseEventWithLatencyInfo& mouse_event) { | 113 const MouseEventWithLatencyInfo& mouse_event) { |
| 110 if (mouse_event.event.type == WebInputEvent::MouseDown && | 114 if (mouse_event.event.type == WebInputEvent::MouseDown && |
| 111 gesture_event_queue_.GetTouchpadTapSuppressionController()-> | 115 gesture_event_queue_.GetTouchpadTapSuppressionController()-> |
| 112 ShouldDeferMouseDown(mouse_event)) | 116 ShouldDeferMouseDown(mouse_event)) |
| 113 return; | 117 return; |
| 114 if (mouse_event.event.type == WebInputEvent::MouseUp && | 118 if (mouse_event.event.type == WebInputEvent::MouseUp && |
| 115 gesture_event_queue_.GetTouchpadTapSuppressionController()-> | 119 gesture_event_queue_.GetTouchpadTapSuppressionController()-> |
| 116 ShouldSuppressMouseUp()) | 120 ShouldSuppressMouseUp()) |
| 117 return; | 121 return; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 const NativeWebKeyboardEvent* InputRouterImpl::GetLastKeyboardEvent() const { | 239 const NativeWebKeyboardEvent* InputRouterImpl::GetLastKeyboardEvent() const { |
| 236 if (key_queue_.empty()) | 240 if (key_queue_.empty()) |
| 237 return NULL; | 241 return NULL; |
| 238 return &key_queue_.front().event; | 242 return &key_queue_.front().event; |
| 239 } | 243 } |
| 240 | 244 |
| 241 void InputRouterImpl::NotifySiteIsMobileOptimized(bool is_mobile_optimized) { | 245 void InputRouterImpl::NotifySiteIsMobileOptimized(bool is_mobile_optimized) { |
| 242 touch_event_queue_.SetIsMobileOptimizedSite(is_mobile_optimized); | 246 touch_event_queue_.SetIsMobileOptimizedSite(is_mobile_optimized); |
| 243 } | 247 } |
| 244 | 248 |
| 245 void InputRouterImpl::RequestNotificationWhenFlushed() { | |
| 246 flush_requested_ = true; | |
| 247 SignalFlushedIfNecessary(); | |
| 248 } | |
| 249 | |
| 250 bool InputRouterImpl::HasPendingEvents() const { | 249 bool InputRouterImpl::HasPendingEvents() const { |
| 251 return !touch_event_queue_.empty() || | 250 return !touch_event_queue_.empty() || |
| 252 !gesture_event_queue_.empty() || | 251 !gesture_event_queue_.empty() || |
| 253 !key_queue_.empty() || | 252 !key_queue_.empty() || |
| 254 mouse_move_pending_ || | 253 mouse_move_pending_ || |
| 255 mouse_wheel_pending_ || | 254 mouse_wheel_pending_ || |
| 256 select_message_pending_ || | 255 select_message_pending_ || |
| 257 move_caret_pending_ || | 256 move_caret_pending_ || |
| 258 active_renderer_fling_count_ > 0; | 257 active_renderer_fling_count_ > 0; |
| 259 } | 258 } |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 } | 634 } |
| 636 | 635 |
| 637 void InputRouterImpl::SignalFlushedIfNecessary() { | 636 void InputRouterImpl::SignalFlushedIfNecessary() { |
| 638 if (!flush_requested_) | 637 if (!flush_requested_) |
| 639 return; | 638 return; |
| 640 | 639 |
| 641 if (HasPendingEvents()) | 640 if (HasPendingEvents()) |
| 642 return; | 641 return; |
| 643 | 642 |
| 644 flush_requested_ = false; | 643 flush_requested_ = false; |
| 645 client_->DidFlush(); | 644 client_->DidFlushAllInput(); |
| 646 } | 645 } |
| 647 | 646 |
| 648 } // namespace content | 647 } // namespace content |
| OLD | NEW |