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 "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 Loading... |
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 flush_requested_(false), |
149 gesture_event_queue_(new GestureEventQueue(this, this)) { | 150 gesture_event_queue_(new GestureEventQueue(this, this)) { |
150 DCHECK(sender); | 151 DCHECK(sender); |
151 DCHECK(client); | 152 DCHECK(client); |
152 DCHECK(ack_handler); | 153 DCHECK(ack_handler); |
153 touch_event_queue_.reset(new TouchEventQueue( | 154 touch_event_queue_.reset(new TouchEventQueue( |
154 this, GetTouchScrollingMode(), GetTouchMoveSlopSuppressionLengthDips())); | 155 this, GetTouchScrollingMode(), GetTouchMoveSlopSuppressionLengthDips())); |
155 touch_ack_timeout_supported_ = | 156 touch_ack_timeout_supported_ = |
156 GetTouchAckTimeoutDelay(&touch_ack_timeout_delay_); | 157 GetTouchAckTimeoutDelay(&touch_ack_timeout_delay_); |
157 UpdateTouchAckTimeoutEnabled(); | 158 UpdateTouchAckTimeoutEnabled(); |
158 } | 159 } |
159 | 160 |
160 InputRouterImpl::~InputRouterImpl() {} | 161 InputRouterImpl::~InputRouterImpl() {} |
161 | 162 |
162 void InputRouterImpl::Flush() {} | 163 void InputRouterImpl::Flush() { |
| 164 flush_requested_ = true; |
| 165 SignalFlushedIfNecessary(); |
| 166 } |
163 | 167 |
164 bool InputRouterImpl::SendInput(scoped_ptr<IPC::Message> message) { | 168 bool InputRouterImpl::SendInput(scoped_ptr<IPC::Message> message) { |
165 DCHECK(IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart); | 169 DCHECK(IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart); |
166 switch (message->type()) { | 170 switch (message->type()) { |
167 // Check for types that require an ACK. | 171 // Check for types that require an ACK. |
168 case InputMsg_SelectRange::ID: | 172 case InputMsg_SelectRange::ID: |
169 return SendSelectRange(message.Pass()); | 173 return SendSelectRange(message.Pass()); |
170 case InputMsg_MoveCaret::ID: | 174 case InputMsg_MoveCaret::ID: |
171 return SendMoveCaret(message.Pass()); | 175 return SendMoveCaret(message.Pass()); |
172 case InputMsg_HandleInputEvent::ID: | 176 case InputMsg_HandleInputEvent::ID: |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 ProcessMouseAck(event_type, ack_result); | 620 ProcessMouseAck(event_type, ack_result); |
617 } else if (event_type == WebInputEvent::MouseWheel) { | 621 } else if (event_type == WebInputEvent::MouseWheel) { |
618 ProcessWheelAck(ack_result, latency_info); | 622 ProcessWheelAck(ack_result, latency_info); |
619 } else if (WebInputEvent::isTouchEventType(event_type)) { | 623 } else if (WebInputEvent::isTouchEventType(event_type)) { |
620 ProcessTouchAck(ack_result, latency_info); | 624 ProcessTouchAck(ack_result, latency_info); |
621 } else if (WebInputEvent::isGestureEventType(event_type)) { | 625 } else if (WebInputEvent::isGestureEventType(event_type)) { |
622 ProcessGestureAck(event_type, ack_result, latency_info); | 626 ProcessGestureAck(event_type, ack_result, latency_info); |
623 } else if (event_type != WebInputEvent::Undefined) { | 627 } else if (event_type != WebInputEvent::Undefined) { |
624 ack_handler_->OnUnexpectedEventAck(InputAckHandler::BAD_ACK_MESSAGE); | 628 ack_handler_->OnUnexpectedEventAck(InputAckHandler::BAD_ACK_MESSAGE); |
625 } | 629 } |
| 630 |
| 631 SignalFlushedIfNecessary(); |
626 } | 632 } |
627 | 633 |
628 void InputRouterImpl::ProcessKeyboardAck(blink::WebInputEvent::Type type, | 634 void InputRouterImpl::ProcessKeyboardAck(blink::WebInputEvent::Type type, |
629 InputEventAckState ack_result) { | 635 InputEventAckState ack_result) { |
630 if (key_queue_.empty()) { | 636 if (key_queue_.empty()) { |
631 ack_handler_->OnUnexpectedEventAck(InputAckHandler::UNEXPECTED_ACK); | 637 ack_handler_->OnUnexpectedEventAck(InputAckHandler::UNEXPECTED_ACK); |
632 } else if (key_queue_.front().type != type) { | 638 } else if (key_queue_.front().type != type) { |
633 // Something must be wrong. Clear the |key_queue_| and char event | 639 // Something must be wrong. Clear the |key_queue_| and char event |
634 // suppression so that we can resume from the error. | 640 // suppression so that we can resume from the error. |
635 key_queue_.clear(); | 641 key_queue_.clear(); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 const bool touch_action_none = | 821 const bool touch_action_none = |
816 touch_action_filter_.allowed_touch_action() == TOUCH_ACTION_NONE; | 822 touch_action_filter_.allowed_touch_action() == TOUCH_ACTION_NONE; |
817 | 823 |
818 const bool touch_ack_timeout_enabled = !fixed_page_scale && | 824 const bool touch_ack_timeout_enabled = !fixed_page_scale && |
819 !mobile_viewport && | 825 !mobile_viewport && |
820 !touch_action_none; | 826 !touch_action_none; |
821 touch_event_queue_->SetAckTimeoutEnabled(touch_ack_timeout_enabled, | 827 touch_event_queue_->SetAckTimeoutEnabled(touch_ack_timeout_enabled, |
822 touch_ack_timeout_delay_); | 828 touch_ack_timeout_delay_); |
823 } | 829 } |
824 | 830 |
| 831 void InputRouterImpl::SignalFlushedIfNecessary() { |
| 832 if (!flush_requested_) |
| 833 return; |
| 834 |
| 835 if (HasPendingEvents()) |
| 836 return; |
| 837 |
| 838 flush_requested_ = false; |
| 839 client_->DidFlush(); |
| 840 } |
| 841 |
| 842 bool InputRouterImpl::HasPendingEvents() const { |
| 843 return !touch_event_queue_->empty() || |
| 844 gesture_event_queue_->HasQueuedGestureEvents() || |
| 845 !key_queue_.empty() || |
| 846 mouse_move_pending_ || |
| 847 mouse_wheel_pending_ || |
| 848 select_range_pending_ || |
| 849 move_caret_pending_; |
| 850 } |
| 851 |
825 bool InputRouterImpl::IsInOverscrollGesture() const { | 852 bool InputRouterImpl::IsInOverscrollGesture() const { |
826 OverscrollController* controller = client_->GetOverscrollController(); | 853 OverscrollController* controller = client_->GetOverscrollController(); |
827 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; | 854 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; |
828 } | 855 } |
829 | 856 |
830 } // namespace content | 857 } // namespace content |
OLD | NEW |