Chromium Code Reviews| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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. It is |
| 263 // possible that a renderer stops listening to touch-events while there are | 262 // possible that a renderer stops listening to touch-events while there are |
| 264 // still events in the touch-queue. In such cases, the new events should still | 263 // still events in the touch-queue, but those events should be flushed, while |
| 265 // get into the queue. | 264 // subsequent touch events will never stay in the queue (at least until |
| 266 return has_touch_handler_ || !touch_event_queue_->empty(); | 265 // another touch handler is registered). |
| 266 DCHECK(touch_event_queue_->has_handlers() || touch_event_queue_->empty()); | |
|
tdresser
2014/01/09 21:14:32
This DCHECK doesn't seem to make sense in conjunct
jdduke (slow)
2014/01/09 22:05:04
The comment wording was poorly modified on my part
| |
| 267 return touch_event_queue_->has_handlers(); | |
| 267 } | 268 } |
| 268 | 269 |
| 269 void InputRouterImpl::OnViewUpdated(int view_flags) { | 270 void InputRouterImpl::OnViewUpdated(int view_flags) { |
| 270 bool fixed_page_scale = (view_flags & FIXED_PAGE_SCALE) != 0; | 271 bool fixed_page_scale = (view_flags & FIXED_PAGE_SCALE) != 0; |
| 271 bool mobile_viewport = (view_flags & MOBILE_VIEWPORT) != 0; | 272 bool mobile_viewport = (view_flags & MOBILE_VIEWPORT) != 0; |
| 272 touch_event_queue_->SetAckTimeoutEnabled( | 273 touch_event_queue_->SetAckTimeoutEnabled( |
| 273 touch_ack_timeout_enabled_ && !(fixed_page_scale || mobile_viewport), | 274 touch_ack_timeout_enabled_ && !(fixed_page_scale || mobile_viewport), |
| 274 touch_ack_timeout_delay_ms_); | 275 touch_ack_timeout_delay_ms_); |
| 275 } | 276 } |
| 276 | 277 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 495 SendMoveCaret(next_move_caret_.Pass()); | 496 SendMoveCaret(next_move_caret_.Pass()); |
| 496 } | 497 } |
| 497 | 498 |
| 498 void InputRouterImpl::OnSelectRangeAck() { | 499 void InputRouterImpl::OnSelectRangeAck() { |
| 499 select_range_pending_ = false; | 500 select_range_pending_ = false; |
| 500 if (next_selection_range_) | 501 if (next_selection_range_) |
| 501 SendSelectRange(next_selection_range_.Pass()); | 502 SendSelectRange(next_selection_range_.Pass()); |
| 502 } | 503 } |
| 503 | 504 |
| 504 void InputRouterImpl::OnHasTouchEventHandlers(bool has_handlers) { | 505 void InputRouterImpl::OnHasTouchEventHandlers(bool has_handlers) { |
| 505 if (has_touch_handler_ == has_handlers) | 506 if (has_handlers == touch_event_queue_->has_handlers()) |
| 506 return; | 507 return; |
| 507 has_touch_handler_ = has_handlers; | 508 touch_event_queue_->OnHasTouchEventHandlers(has_handlers); |
| 508 if (!has_handlers) | |
| 509 touch_event_queue_->FlushQueue(); | |
| 510 client_->OnHasTouchEventHandlers(has_handlers); | 509 client_->OnHasTouchEventHandlers(has_handlers); |
| 511 } | 510 } |
| 512 | 511 |
| 513 void InputRouterImpl::OnSetTouchAction( | 512 void InputRouterImpl::OnSetTouchAction( |
| 514 content::TouchAction touch_action) { | 513 content::TouchAction touch_action) { |
| 515 // Synthetic touchstart events should get filtered out in RenderWidget. | 514 // Synthetic touchstart events should get filtered out in RenderWidget. |
| 516 DCHECK(touch_event_queue_->IsPendingAckTouchStart()); | 515 DCHECK(touch_event_queue_->IsPendingAckTouchStart()); |
| 517 | 516 |
| 518 touch_action_filter_.OnSetTouchAction(touch_action); | 517 touch_action_filter_.OnSetTouchAction(touch_action); |
| 519 } | 518 } |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 724 break; | 723 break; |
| 725 } | 724 } |
| 726 } | 725 } |
| 727 | 726 |
| 728 bool InputRouterImpl::IsInOverscrollGesture() const { | 727 bool InputRouterImpl::IsInOverscrollGesture() const { |
| 729 OverscrollController* controller = client_->GetOverscrollController(); | 728 OverscrollController* controller = client_->GetOverscrollController(); |
| 730 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; | 729 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; |
| 731 } | 730 } |
| 732 | 731 |
| 733 } // namespace content | 732 } // namespace content |
| OLD | NEW |