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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 InputRouterImpl::InputRouterImpl(IPC::Sender* sender, | 62 InputRouterImpl::InputRouterImpl(IPC::Sender* sender, |
63 InputRouterClient* client, | 63 InputRouterClient* client, |
64 InputAckHandler* ack_handler, | 64 InputAckHandler* ack_handler, |
65 int routing_id, | 65 int routing_id, |
66 const Config& config) | 66 const Config& config) |
67 : sender_(sender), | 67 : sender_(sender), |
68 client_(client), | 68 client_(client), |
69 ack_handler_(ack_handler), | 69 ack_handler_(ack_handler), |
70 routing_id_(routing_id), | 70 routing_id_(routing_id), |
71 select_range_pending_(false), | 71 select_range_pending_(false), |
72 move_selection_extent_pending_(false), | |
72 move_caret_pending_(false), | 73 move_caret_pending_(false), |
73 mouse_move_pending_(false), | 74 mouse_move_pending_(false), |
74 mouse_wheel_pending_(false), | 75 mouse_wheel_pending_(false), |
75 current_view_flags_(0), | 76 current_view_flags_(0), |
76 current_ack_source_(ACK_SOURCE_NONE), | 77 current_ack_source_(ACK_SOURCE_NONE), |
77 flush_requested_(false), | 78 flush_requested_(false), |
78 touch_event_queue_(this, config.touch_config), | 79 touch_event_queue_(this, config.touch_config), |
79 gesture_event_queue_(this, this, config.gesture_config) { | 80 gesture_event_queue_(this, this, config.gesture_config) { |
80 DCHECK(sender); | 81 DCHECK(sender); |
81 DCHECK(client); | 82 DCHECK(client); |
82 DCHECK(ack_handler); | 83 DCHECK(ack_handler); |
83 UpdateTouchAckTimeoutEnabled(); | 84 UpdateTouchAckTimeoutEnabled(); |
84 } | 85 } |
85 | 86 |
86 InputRouterImpl::~InputRouterImpl() {} | 87 InputRouterImpl::~InputRouterImpl() {} |
87 | 88 |
88 void InputRouterImpl::Flush() { | 89 void InputRouterImpl::Flush() { |
89 flush_requested_ = true; | 90 flush_requested_ = true; |
90 SignalFlushedIfNecessary(); | 91 SignalFlushedIfNecessary(); |
91 } | 92 } |
92 | 93 |
93 bool InputRouterImpl::SendInput(scoped_ptr<IPC::Message> message) { | 94 bool InputRouterImpl::SendInput(scoped_ptr<IPC::Message> message) { |
94 DCHECK(IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart); | 95 DCHECK(IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart); |
95 switch (message->type()) { | 96 switch (message->type()) { |
96 // Check for types that require an ACK. | 97 // Check for types that require an ACK. |
97 case InputMsg_SelectRange::ID: | 98 case InputMsg_SelectRange::ID: |
98 return SendSelectRange(message.Pass()); | 99 return SendSelectRange(message.Pass()); |
100 case InputMsg_MoveSelectionExtent::ID: | |
101 return SendMoveSelectionExtent(message.Pass()); | |
99 case InputMsg_MoveCaret::ID: | 102 case InputMsg_MoveCaret::ID: |
100 return SendMoveCaret(message.Pass()); | 103 return SendMoveCaret(message.Pass()); |
101 case InputMsg_HandleInputEvent::ID: | 104 case InputMsg_HandleInputEvent::ID: |
102 NOTREACHED() << "WebInputEvents should never be sent via SendInput."; | 105 NOTREACHED() << "WebInputEvents should never be sent via SendInput."; |
103 return false; | 106 return false; |
104 default: | 107 default: |
105 return Send(message.release()); | 108 return Send(message.release()); |
106 } | 109 } |
107 } | 110 } |
108 | 111 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
262 UpdateTouchAckTimeoutEnabled(); | 265 UpdateTouchAckTimeoutEnabled(); |
263 } | 266 } |
264 | 267 |
265 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) { | 268 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) { |
266 bool handled = true; | 269 bool handled = true; |
267 IPC_BEGIN_MESSAGE_MAP(InputRouterImpl, message) | 270 IPC_BEGIN_MESSAGE_MAP(InputRouterImpl, message) |
268 IPC_MESSAGE_HANDLER(InputHostMsg_HandleInputEvent_ACK, OnInputEventAck) | 271 IPC_MESSAGE_HANDLER(InputHostMsg_HandleInputEvent_ACK, OnInputEventAck) |
269 IPC_MESSAGE_HANDLER(InputHostMsg_DidOverscroll, OnDidOverscroll) | 272 IPC_MESSAGE_HANDLER(InputHostMsg_DidOverscroll, OnDidOverscroll) |
270 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveCaret_ACK, OnMsgMoveCaretAck) | 273 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveCaret_ACK, OnMsgMoveCaretAck) |
271 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectRange_ACK, OnSelectRangeAck) | 274 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectRange_ACK, OnSelectRangeAck) |
275 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveSelectionExtent_ACK, | |
276 OnMoveSelectionExtentAck) | |
272 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, | 277 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, |
273 OnHasTouchEventHandlers) | 278 OnHasTouchEventHandlers) |
274 IPC_MESSAGE_HANDLER(InputHostMsg_SetTouchAction, | 279 IPC_MESSAGE_HANDLER(InputHostMsg_SetTouchAction, |
275 OnSetTouchAction) | 280 OnSetTouchAction) |
276 IPC_MESSAGE_UNHANDLED(handled = false) | 281 IPC_MESSAGE_UNHANDLED(handled = false) |
277 IPC_END_MESSAGE_MAP() | 282 IPC_END_MESSAGE_MAP() |
278 | 283 |
279 return handled; | 284 return handled; |
280 } | 285 } |
281 | 286 |
(...skipping 20 matching lines...) Expand all Loading... | |
302 DCHECK(message->type() == InputMsg_SelectRange::ID); | 307 DCHECK(message->type() == InputMsg_SelectRange::ID); |
303 if (select_range_pending_) { | 308 if (select_range_pending_) { |
304 next_selection_range_ = message.Pass(); | 309 next_selection_range_ = message.Pass(); |
305 return true; | 310 return true; |
306 } | 311 } |
307 | 312 |
308 select_range_pending_ = true; | 313 select_range_pending_ = true; |
309 return Send(message.release()); | 314 return Send(message.release()); |
310 } | 315 } |
311 | 316 |
317 bool InputRouterImpl::SendMoveSelectionExtent( | |
318 scoped_ptr<IPC::Message> message) { | |
319 DCHECK(message->type() == InputMsg_SelectRange::ID); | |
320 if (move_selection_extent_pending_) { | |
jdduke (slow)
2014/10/15 15:46:07
There's probably some common logic between SelectR
christiank
2014/10/17 14:33:05
Yes, I noticed this. I didn't address it in this C
| |
321 next_selection_extent_move_ = message.Pass(); | |
322 return true; | |
323 } | |
324 | |
325 move_selection_extent_pending_ = true; | |
326 return Send(message.release()); | |
327 } | |
328 | |
312 bool InputRouterImpl::SendMoveCaret(scoped_ptr<IPC::Message> message) { | 329 bool InputRouterImpl::SendMoveCaret(scoped_ptr<IPC::Message> message) { |
313 DCHECK(message->type() == InputMsg_MoveCaret::ID); | 330 DCHECK(message->type() == InputMsg_MoveCaret::ID); |
314 if (move_caret_pending_) { | 331 if (move_caret_pending_) { |
315 next_move_caret_ = message.Pass(); | 332 next_move_caret_ = message.Pass(); |
316 return true; | 333 return true; |
317 } | 334 } |
318 | 335 |
319 move_caret_pending_ = true; | 336 move_caret_pending_ = true; |
320 return Send(message.release()); | 337 return Send(message.release()); |
321 } | 338 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 if (next_move_caret_) | 503 if (next_move_caret_) |
487 SendMoveCaret(next_move_caret_.Pass()); | 504 SendMoveCaret(next_move_caret_.Pass()); |
488 } | 505 } |
489 | 506 |
490 void InputRouterImpl::OnSelectRangeAck() { | 507 void InputRouterImpl::OnSelectRangeAck() { |
491 select_range_pending_ = false; | 508 select_range_pending_ = false; |
492 if (next_selection_range_) | 509 if (next_selection_range_) |
493 SendSelectRange(next_selection_range_.Pass()); | 510 SendSelectRange(next_selection_range_.Pass()); |
494 } | 511 } |
495 | 512 |
513 void InputRouterImpl::OnMoveSelectionExtentAck() { | |
514 move_selection_extent_pending_ = false; | |
515 if (next_selection_extent_move_) | |
516 SendMoveSelectionExtent(next_selection_extent_move_.Pass()); | |
517 } | |
518 | |
496 void InputRouterImpl::OnHasTouchEventHandlers(bool has_handlers) { | 519 void InputRouterImpl::OnHasTouchEventHandlers(bool has_handlers) { |
497 TRACE_EVENT1("input", "InputRouterImpl::OnHasTouchEventHandlers", | 520 TRACE_EVENT1("input", "InputRouterImpl::OnHasTouchEventHandlers", |
498 "has_handlers", has_handlers); | 521 "has_handlers", has_handlers); |
499 | 522 |
500 // Lack of a touch handler indicates that the page either has no touch-action | 523 // Lack of a touch handler indicates that the page either has no touch-action |
501 // modifiers or that all its touch-action modifiers are auto. Resetting the | 524 // modifiers or that all its touch-action modifiers are auto. Resetting the |
502 // touch-action here allows forwarding of subsequent gestures even if the | 525 // touch-action here allows forwarding of subsequent gestures even if the |
503 // underlying touches never reach the router. | 526 // underlying touches never reach the router. |
504 // TODO(jdduke): Reset touch-action only at the end of a touch sequence to | 527 // TODO(jdduke): Reset touch-action only at the end of a touch sequence to |
505 // prevent potentially strange mid-sequence behavior, crbug.com/375940. | 528 // prevent potentially strange mid-sequence behavior, crbug.com/375940. |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
673 client_->DidFlush(); | 696 client_->DidFlush(); |
674 } | 697 } |
675 | 698 |
676 bool InputRouterImpl::HasPendingEvents() const { | 699 bool InputRouterImpl::HasPendingEvents() const { |
677 return !touch_event_queue_.empty() || | 700 return !touch_event_queue_.empty() || |
678 !gesture_event_queue_.empty() || | 701 !gesture_event_queue_.empty() || |
679 !key_queue_.empty() || | 702 !key_queue_.empty() || |
680 mouse_move_pending_ || | 703 mouse_move_pending_ || |
681 mouse_wheel_pending_ || | 704 mouse_wheel_pending_ || |
682 select_range_pending_ || | 705 select_range_pending_ || |
706 move_selection_extent_pending_ || | |
683 move_caret_pending_; | 707 move_caret_pending_; |
684 } | 708 } |
685 | 709 |
686 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent() | 710 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent() |
687 : synthesized_from_pinch(false) { | 711 : synthesized_from_pinch(false) { |
688 } | 712 } |
689 | 713 |
690 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent( | 714 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent( |
691 const MouseWheelEventWithLatencyInfo& event, | 715 const MouseWheelEventWithLatencyInfo& event, |
692 bool synthesized_from_pinch) | 716 bool synthesized_from_pinch) |
693 : event(event), synthesized_from_pinch(synthesized_from_pinch) { | 717 : event(event), synthesized_from_pinch(synthesized_from_pinch) { |
694 } | 718 } |
695 | 719 |
696 InputRouterImpl::QueuedWheelEvent::~QueuedWheelEvent() { | 720 InputRouterImpl::QueuedWheelEvent::~QueuedWheelEvent() { |
697 } | 721 } |
698 | 722 |
699 } // namespace content | 723 } // namespace content |
OLD | NEW |