| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 InputAckHandler* ack_handler, | 93 InputAckHandler* ack_handler, |
| 94 int routing_id) | 94 int routing_id) |
| 95 : sender_(sender), | 95 : sender_(sender), |
| 96 client_(client), | 96 client_(client), |
| 97 ack_handler_(ack_handler), | 97 ack_handler_(ack_handler), |
| 98 routing_id_(routing_id), | 98 routing_id_(routing_id), |
| 99 select_range_pending_(false), | 99 select_range_pending_(false), |
| 100 move_caret_pending_(false), | 100 move_caret_pending_(false), |
| 101 mouse_move_pending_(false), | 101 mouse_move_pending_(false), |
| 102 mouse_wheel_pending_(false), | 102 mouse_wheel_pending_(false), |
| 103 has_touch_handler_(false), | |
| 104 touch_ack_timeout_enabled_(false), | 103 touch_ack_timeout_enabled_(false), |
| 105 touch_ack_timeout_delay_ms_(std::numeric_limits<size_t>::max()), | 104 touch_ack_timeout_delay_ms_(std::numeric_limits<size_t>::max()), |
| 106 current_ack_source_(ACK_SOURCE_NONE), | 105 current_ack_source_(ACK_SOURCE_NONE), |
| 107 gesture_event_filter_(new GestureEventFilter(this, this)) { | 106 gesture_event_filter_(new GestureEventFilter(this, this)) { |
| 108 DCHECK(sender); | 107 DCHECK(sender); |
| 109 DCHECK(client); | 108 DCHECK(client); |
| 110 DCHECK(ack_handler); | 109 DCHECK(ack_handler); |
| 111 touch_event_queue_.reset(new TouchEventQueue(this)); | 110 touch_event_queue_.reset(new TouchEventQueue(this)); |
| 112 touch_ack_timeout_enabled_ = | 111 touch_ack_timeout_enabled_ = |
| 113 GetTouchAckTimeoutDelayMs(&touch_ack_timeout_delay_ms_); | 112 GetTouchAckTimeoutDelayMs(&touch_ack_timeout_delay_ms_); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false); | 251 FilterAndSendWebInputEvent(gesture_event.event, gesture_event.latency, false); |
| 253 } | 252 } |
| 254 | 253 |
| 255 const NativeWebKeyboardEvent* InputRouterImpl::GetLastKeyboardEvent() const { | 254 const NativeWebKeyboardEvent* InputRouterImpl::GetLastKeyboardEvent() const { |
| 256 if (key_queue_.empty()) | 255 if (key_queue_.empty()) |
| 257 return NULL; | 256 return NULL; |
| 258 return &key_queue_.front(); | 257 return &key_queue_.front(); |
| 259 } | 258 } |
| 260 | 259 |
| 261 bool InputRouterImpl::ShouldForwardTouchEvent() const { | 260 bool InputRouterImpl::ShouldForwardTouchEvent() const { |
| 262 // Always send a touch event if the renderer has a touch-event handler. It is | 261 // Always send a touch event if the renderer has a touch-event handler. |
| 263 // possible that a renderer stops listening to touch-events while there are | 262 return touch_event_queue_->has_handlers(); |
| 264 // still events in the touch-queue. In such cases, the new events should still | |
| 265 // get into the queue. | |
| 266 return has_touch_handler_ || !touch_event_queue_->empty(); | |
| 267 } | 263 } |
| 268 | 264 |
| 269 void InputRouterImpl::OnViewUpdated(int view_flags) { | 265 void InputRouterImpl::OnViewUpdated(int view_flags) { |
| 270 bool fixed_page_scale = (view_flags & FIXED_PAGE_SCALE) != 0; | 266 bool fixed_page_scale = (view_flags & FIXED_PAGE_SCALE) != 0; |
| 271 bool mobile_viewport = (view_flags & MOBILE_VIEWPORT) != 0; | 267 bool mobile_viewport = (view_flags & MOBILE_VIEWPORT) != 0; |
| 272 touch_event_queue_->SetAckTimeoutEnabled( | 268 touch_event_queue_->SetAckTimeoutEnabled( |
| 273 touch_ack_timeout_enabled_ && !(fixed_page_scale || mobile_viewport), | 269 touch_ack_timeout_enabled_ && !(fixed_page_scale || mobile_viewport), |
| 274 touch_ack_timeout_delay_ms_); | 270 touch_ack_timeout_delay_ms_); |
| 275 } | 271 } |
| 276 | 272 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 SendMoveCaret(next_move_caret_.Pass()); | 491 SendMoveCaret(next_move_caret_.Pass()); |
| 496 } | 492 } |
| 497 | 493 |
| 498 void InputRouterImpl::OnSelectRangeAck() { | 494 void InputRouterImpl::OnSelectRangeAck() { |
| 499 select_range_pending_ = false; | 495 select_range_pending_ = false; |
| 500 if (next_selection_range_) | 496 if (next_selection_range_) |
| 501 SendSelectRange(next_selection_range_.Pass()); | 497 SendSelectRange(next_selection_range_.Pass()); |
| 502 } | 498 } |
| 503 | 499 |
| 504 void InputRouterImpl::OnHasTouchEventHandlers(bool has_handlers) { | 500 void InputRouterImpl::OnHasTouchEventHandlers(bool has_handlers) { |
| 505 if (has_touch_handler_ == has_handlers) | 501 if (has_handlers == touch_event_queue_->has_handlers()) |
| 506 return; | 502 return; |
| 507 has_touch_handler_ = has_handlers; | 503 touch_event_queue_->OnHasTouchEventHandlers(has_handlers); |
| 508 if (!has_handlers) | |
| 509 touch_event_queue_->FlushQueue(); | |
| 510 client_->OnHasTouchEventHandlers(has_handlers); | 504 client_->OnHasTouchEventHandlers(has_handlers); |
| 511 } | 505 } |
| 512 | 506 |
| 513 void InputRouterImpl::OnSetTouchAction( | 507 void InputRouterImpl::OnSetTouchAction( |
| 514 content::TouchAction touch_action) { | 508 content::TouchAction touch_action) { |
| 515 // Synthetic touchstart events should get filtered out in RenderWidget. | 509 // Synthetic touchstart events should get filtered out in RenderWidget. |
| 516 DCHECK(touch_event_queue_->IsPendingAckTouchStart()); | 510 DCHECK(touch_event_queue_->IsPendingAckTouchStart()); |
| 517 | 511 |
| 518 touch_action_filter_.OnSetTouchAction(touch_action); | 512 touch_action_filter_.OnSetTouchAction(touch_action); |
| 519 } | 513 } |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 break; | 718 break; |
| 725 } | 719 } |
| 726 } | 720 } |
| 727 | 721 |
| 728 bool InputRouterImpl::IsInOverscrollGesture() const { | 722 bool InputRouterImpl::IsInOverscrollGesture() const { |
| 729 OverscrollController* controller = client_->GetOverscrollController(); | 723 OverscrollController* controller = client_->GetOverscrollController(); |
| 730 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; | 724 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; |
| 731 } | 725 } |
| 732 | 726 |
| 733 } // namespace content | 727 } // namespace content |
| OLD | NEW |