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

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: Fix DCHECK Created 6 years, 2 months 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_range_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_MoveRangeSelectionExtent::ID:
101 return SendMoveRangeSelectionExtent(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, OnSelectRangeAck)
275 IPC_MESSAGE_HANDLER(InputHostMsg_MoveRangeSelectionExtent_ACK,
276 OnMoveRangeSelectionExtentAck)
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
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::SendMoveRangeSelectionExtent(
318 scoped_ptr<IPC::Message> message) {
319 DCHECK(message->type() == InputMsg_MoveRangeSelectionExtent::ID);
jdduke (slow) 2014/10/21 16:57:36 Hmm, so, in theory |SelectRange| and |MoveRangeSel
christiank 2014/10/22 12:16:06 I think you're right. Maybe we could use the queue
320 // TODO(jdduke): Factor out common logic between selection and caret-related
321 // IPC messages.
322 if (move_range_selection_extent_pending_) {
323 next_range_selection_extent_move_ = message.Pass();
324 return true;
325 }
326
327 move_range_selection_extent_pending_ = true;
328 return Send(message.release());
329 }
330
312 bool InputRouterImpl::SendMoveCaret(scoped_ptr<IPC::Message> message) { 331 bool InputRouterImpl::SendMoveCaret(scoped_ptr<IPC::Message> message) {
313 DCHECK(message->type() == InputMsg_MoveCaret::ID); 332 DCHECK(message->type() == InputMsg_MoveCaret::ID);
314 if (move_caret_pending_) { 333 if (move_caret_pending_) {
315 next_move_caret_ = message.Pass(); 334 next_move_caret_ = message.Pass();
316 return true; 335 return true;
317 } 336 }
318 337
319 move_caret_pending_ = true; 338 move_caret_pending_ = true;
320 return Send(message.release()); 339 return Send(message.release());
321 } 340 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 if (next_move_caret_) 505 if (next_move_caret_)
487 SendMoveCaret(next_move_caret_.Pass()); 506 SendMoveCaret(next_move_caret_.Pass());
488 } 507 }
489 508
490 void InputRouterImpl::OnSelectRangeAck() { 509 void InputRouterImpl::OnSelectRangeAck() {
491 select_range_pending_ = false; 510 select_range_pending_ = false;
492 if (next_selection_range_) 511 if (next_selection_range_)
493 SendSelectRange(next_selection_range_.Pass()); 512 SendSelectRange(next_selection_range_.Pass());
494 } 513 }
495 514
515 void InputRouterImpl::OnMoveRangeSelectionExtentAck() {
516 move_range_selection_extent_pending_ = false;
517 if (next_range_selection_extent_move_)
518 SendMoveRangeSelectionExtent(next_range_selection_extent_move_.Pass());
519 }
520
496 void InputRouterImpl::OnHasTouchEventHandlers(bool has_handlers) { 521 void InputRouterImpl::OnHasTouchEventHandlers(bool has_handlers) {
497 TRACE_EVENT1("input", "InputRouterImpl::OnHasTouchEventHandlers", 522 TRACE_EVENT1("input", "InputRouterImpl::OnHasTouchEventHandlers",
498 "has_handlers", has_handlers); 523 "has_handlers", has_handlers);
499 524
500 // Lack of a touch handler indicates that the page either has no touch-action 525 // 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 526 // modifiers or that all its touch-action modifiers are auto. Resetting the
502 // touch-action here allows forwarding of subsequent gestures even if the 527 // touch-action here allows forwarding of subsequent gestures even if the
503 // underlying touches never reach the router. 528 // underlying touches never reach the router.
504 // TODO(jdduke): Reset touch-action only at the end of a touch sequence to 529 // TODO(jdduke): Reset touch-action only at the end of a touch sequence to
505 // prevent potentially strange mid-sequence behavior, crbug.com/375940. 530 // prevent potentially strange mid-sequence behavior, crbug.com/375940.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 client_->DidFlush(); 698 client_->DidFlush();
674 } 699 }
675 700
676 bool InputRouterImpl::HasPendingEvents() const { 701 bool InputRouterImpl::HasPendingEvents() const {
677 return !touch_event_queue_.empty() || 702 return !touch_event_queue_.empty() ||
678 !gesture_event_queue_.empty() || 703 !gesture_event_queue_.empty() ||
679 !key_queue_.empty() || 704 !key_queue_.empty() ||
680 mouse_move_pending_ || 705 mouse_move_pending_ ||
681 mouse_wheel_pending_ || 706 mouse_wheel_pending_ ||
682 select_range_pending_ || 707 select_range_pending_ ||
708 move_range_selection_extent_pending_ ||
683 move_caret_pending_; 709 move_caret_pending_;
684 } 710 }
685 711
686 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent() 712 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent()
687 : synthesized_from_pinch(false) { 713 : synthesized_from_pinch(false) {
688 } 714 }
689 715
690 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent( 716 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent(
691 const MouseWheelEventWithLatencyInfo& event, 717 const MouseWheelEventWithLatencyInfo& event,
692 bool synthesized_from_pinch) 718 bool synthesized_from_pinch)
693 : event(event), synthesized_from_pinch(synthesized_from_pinch) { 719 : event(event), synthesized_from_pinch(synthesized_from_pinch) {
694 } 720 }
695 721
696 InputRouterImpl::QueuedWheelEvent::~QueuedWheelEvent() { 722 InputRouterImpl::QueuedWheelEvent::~QueuedWheelEvent() {
697 } 723 }
698 724
699 } // namespace content 725 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698