Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: content/browser/renderer_host/input/input_router_impl.cc

Issue 657803002: Update touch selection to only modify one selection point at a time. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
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_message_pending_(false),
72 move_caret_pending_(false), 72 move_caret_pending_(false),
73 mouse_move_pending_(false), 73 mouse_move_pending_(false),
74 mouse_wheel_pending_(false), 74 mouse_wheel_pending_(false),
75 current_view_flags_(0), 75 current_view_flags_(0),
76 current_ack_source_(ACK_SOURCE_NONE), 76 current_ack_source_(ACK_SOURCE_NONE),
77 flush_requested_(false), 77 flush_requested_(false),
78 touch_event_queue_(this, config.touch_config), 78 touch_event_queue_(this, config.touch_config),
79 gesture_event_queue_(this, this, config.gesture_config) { 79 gesture_event_queue_(this, this, config.gesture_config) {
80 DCHECK(sender); 80 DCHECK(sender);
81 DCHECK(client); 81 DCHECK(client);
82 DCHECK(ack_handler); 82 DCHECK(ack_handler);
83 UpdateTouchAckTimeoutEnabled(); 83 UpdateTouchAckTimeoutEnabled();
84 } 84 }
85 85
86 InputRouterImpl::~InputRouterImpl() {} 86 InputRouterImpl::~InputRouterImpl() {
87 STLDeleteElements(&pending_select_messages_);
88 }
87 89
88 void InputRouterImpl::Flush() { 90 void InputRouterImpl::Flush() {
89 flush_requested_ = true; 91 flush_requested_ = true;
90 SignalFlushedIfNecessary(); 92 SignalFlushedIfNecessary();
91 } 93 }
92 94
93 bool InputRouterImpl::SendInput(scoped_ptr<IPC::Message> message) { 95 bool InputRouterImpl::SendInput(scoped_ptr<IPC::Message> message) {
94 DCHECK(IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart); 96 DCHECK(IPC_MESSAGE_ID_CLASS(message->type()) == InputMsgStart);
95 switch (message->type()) { 97 switch (message->type()) {
96 // Check for types that require an ACK. 98 // Check for types that require an ACK.
97 case InputMsg_SelectRange::ID: 99 case InputMsg_SelectRange::ID:
98 return SendSelectRange(message.Pass()); 100 case InputMsg_MoveRangeSelectionExtent::ID:
101 return SendSelectMessage(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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 263
261 // A fixed page scale or mobile viewport should disable the touch ack timeout. 264 // A fixed page scale or mobile viewport should disable the touch ack timeout.
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(InputHostMsg_MoveCaret_ACK, OnMsgMoveCaretAck)
271 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectRange_ACK, OnSelectRangeAck) 274 IPC_MESSAGE_HANDLER(InputHostMsg_SelectRange_ACK, OnSelectMessageAck)
275 IPC_MESSAGE_HANDLER(InputHostMsg_MoveRangeSelectionExtent_ACK,
276 OnSelectMessageAck)
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
282 void InputRouterImpl::OnTouchEventAck(const TouchEventWithLatencyInfo& event, 287 void InputRouterImpl::OnTouchEventAck(const TouchEventWithLatencyInfo& event,
283 InputEventAckState ack_result) { 288 InputEventAckState ack_result) {
284 // Touchstart events sent to the renderer indicate a new touch sequence, but 289 // Touchstart events sent to the renderer indicate a new touch sequence, but
285 // in some cases we may filter out sending the touchstart - catch those here. 290 // in some cases we may filter out sending the touchstart - catch those here.
286 if (WebTouchEventTraits::IsTouchSequenceStart(event.event) && 291 if (WebTouchEventTraits::IsTouchSequenceStart(event.event) &&
287 ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) { 292 ack_result == INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS) {
288 touch_action_filter_.ResetTouchAction(); 293 touch_action_filter_.ResetTouchAction();
289 UpdateTouchAckTimeoutEnabled(); 294 UpdateTouchAckTimeoutEnabled();
290 } 295 }
291 ack_handler_->OnTouchEventAck(event, ack_result); 296 ack_handler_->OnTouchEventAck(event, ack_result);
292 } 297 }
293 298
294 void InputRouterImpl::OnGestureEventAck( 299 void InputRouterImpl::OnGestureEventAck(
295 const GestureEventWithLatencyInfo& event, 300 const GestureEventWithLatencyInfo& event,
296 InputEventAckState ack_result) { 301 InputEventAckState ack_result) {
297 touch_event_queue_.OnGestureEventAck(event, ack_result); 302 touch_event_queue_.OnGestureEventAck(event, ack_result);
298 ack_handler_->OnGestureEventAck(event, ack_result); 303 ack_handler_->OnGestureEventAck(event, ack_result);
299 } 304 }
300 305
301 bool InputRouterImpl::SendSelectRange(scoped_ptr<IPC::Message> message) { 306 bool InputRouterImpl::SendSelectMessage(
302 DCHECK(message->type() == InputMsg_SelectRange::ID); 307 scoped_ptr<IPC::Message> message) {
303 if (select_range_pending_) { 308 DCHECK(message->type() == InputMsg_SelectRange::ID ||
304 next_selection_range_ = message.Pass(); 309 message->type() == InputMsg_MoveRangeSelectionExtent::ID);
310
311 // TODO(jdduke): Factor out common logic between selection and caret-related
312 // IPC messages.
313 if (select_message_pending_) {
314 if (!pending_select_messages_.empty() &&
315 pending_select_messages_.back()->type() == message->type()) {
316 delete pending_select_messages_.back();
317 pending_select_messages_.pop_back();
318 }
319
320 pending_select_messages_.push_back(message.release());
305 return true; 321 return true;
306 } 322 }
307 323
308 select_range_pending_ = true; 324 select_message_pending_ = true;
309 return Send(message.release()); 325 return Send(message.release());
310 } 326 }
311 327
312 bool InputRouterImpl::SendMoveCaret(scoped_ptr<IPC::Message> message) { 328 bool InputRouterImpl::SendMoveCaret(scoped_ptr<IPC::Message> message) {
313 DCHECK(message->type() == InputMsg_MoveCaret::ID); 329 DCHECK(message->type() == InputMsg_MoveCaret::ID);
314 if (move_caret_pending_) { 330 if (move_caret_pending_) {
315 next_move_caret_ = message.Pass(); 331 next_move_caret_ = message.Pass();
316 return true; 332 return true;
317 } 333 }
318 334
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 void InputRouterImpl::OnDidOverscroll(const DidOverscrollParams& params) { 496 void InputRouterImpl::OnDidOverscroll(const DidOverscrollParams& params) {
481 client_->DidOverscroll(params); 497 client_->DidOverscroll(params);
482 } 498 }
483 499
484 void InputRouterImpl::OnMsgMoveCaretAck() { 500 void InputRouterImpl::OnMsgMoveCaretAck() {
485 move_caret_pending_ = false; 501 move_caret_pending_ = false;
486 if (next_move_caret_) 502 if (next_move_caret_)
487 SendMoveCaret(next_move_caret_.Pass()); 503 SendMoveCaret(next_move_caret_.Pass());
488 } 504 }
489 505
490 void InputRouterImpl::OnSelectRangeAck() { 506 void InputRouterImpl::OnSelectMessageAck() {
491 select_range_pending_ = false; 507 select_message_pending_ = false;
492 if (next_selection_range_) 508 if (!pending_select_messages_.empty()) {
493 SendSelectRange(next_selection_range_.Pass()); 509 scoped_ptr<IPC::Message> next_message =
510 make_scoped_ptr(pending_select_messages_.front());
511 pending_select_messages_.pop_front();
512
513 SendSelectMessage(next_message.Pass());
514 }
494 } 515 }
495 516
496 void InputRouterImpl::OnHasTouchEventHandlers(bool has_handlers) { 517 void InputRouterImpl::OnHasTouchEventHandlers(bool has_handlers) {
497 TRACE_EVENT1("input", "InputRouterImpl::OnHasTouchEventHandlers", 518 TRACE_EVENT1("input", "InputRouterImpl::OnHasTouchEventHandlers",
498 "has_handlers", has_handlers); 519 "has_handlers", has_handlers);
499 520
500 // Lack of a touch handler indicates that the page either has no touch-action 521 // 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 522 // modifiers or that all its touch-action modifiers are auto. Resetting the
502 // touch-action here allows forwarding of subsequent gestures even if the 523 // touch-action here allows forwarding of subsequent gestures even if the
503 // underlying touches never reach the router. 524 // underlying touches never reach the router.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 flush_requested_ = false; 693 flush_requested_ = false;
673 client_->DidFlush(); 694 client_->DidFlush();
674 } 695 }
675 696
676 bool InputRouterImpl::HasPendingEvents() const { 697 bool InputRouterImpl::HasPendingEvents() const {
677 return !touch_event_queue_.empty() || 698 return !touch_event_queue_.empty() ||
678 !gesture_event_queue_.empty() || 699 !gesture_event_queue_.empty() ||
679 !key_queue_.empty() || 700 !key_queue_.empty() ||
680 mouse_move_pending_ || 701 mouse_move_pending_ ||
681 mouse_wheel_pending_ || 702 mouse_wheel_pending_ ||
682 select_range_pending_ || 703 select_message_pending_ ||
683 move_caret_pending_; 704 move_caret_pending_;
684 } 705 }
685 706
686 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent() 707 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent()
687 : synthesized_from_pinch(false) { 708 : synthesized_from_pinch(false) {
688 } 709 }
689 710
690 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent( 711 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent(
691 const MouseWheelEventWithLatencyInfo& event, 712 const MouseWheelEventWithLatencyInfo& event,
692 bool synthesized_from_pinch) 713 bool synthesized_from_pinch)
693 : event(event), synthesized_from_pinch(synthesized_from_pinch) { 714 : event(event), synthesized_from_pinch(synthesized_from_pinch) {
694 } 715 }
695 716
696 InputRouterImpl::QueuedWheelEvent::~QueuedWheelEvent() { 717 InputRouterImpl::QueuedWheelEvent::~QueuedWheelEvent() {
697 } 718 }
698 719
699 } // namespace content 720 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698