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

Side by Side Diff: content/renderer/input/render_widget_input_handler.cc

Issue 2453663002: Remove complexity from the input pipeline. (Closed)
Patch Set: Created 4 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
« no previous file with comments | « content/renderer/input/render_widget_input_handler.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/renderer/input/render_widget_input_handler.h" 5 #include "content/renderer/input/render_widget_input_handler.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 RenderWidgetInputHandler::RenderWidgetInputHandler( 174 RenderWidgetInputHandler::RenderWidgetInputHandler(
175 RenderWidgetInputHandlerDelegate* delegate, 175 RenderWidgetInputHandlerDelegate* delegate,
176 RenderWidget* widget) 176 RenderWidget* widget)
177 : delegate_(delegate), 177 : delegate_(delegate),
178 widget_(widget), 178 widget_(widget),
179 handling_input_event_(false), 179 handling_input_event_(false),
180 handling_event_overscroll_(nullptr), 180 handling_event_overscroll_(nullptr),
181 handling_event_type_(WebInputEvent::Undefined), 181 handling_event_type_(WebInputEvent::Undefined),
182 context_menu_source_type_(ui::MENU_SOURCE_MOUSE), 182 context_menu_source_type_(ui::MENU_SOURCE_MOUSE),
183 suppress_next_char_events_(false), 183 suppress_next_char_events_(false) {
184 ignore_ack_for_mouse_move_from_debugger_(false) {
185 DCHECK(delegate); 184 DCHECK(delegate);
186 DCHECK(widget); 185 DCHECK(widget);
187 delegate->SetInputHandler(this); 186 delegate->SetInputHandler(this);
188 } 187 }
189 188
190 RenderWidgetInputHandler::~RenderWidgetInputHandler() {} 189 RenderWidgetInputHandler::~RenderWidgetInputHandler() {}
191 190
192 void RenderWidgetInputHandler::HandleInputEvent( 191 void RenderWidgetInputHandler::HandleInputEvent(
193 const WebInputEvent& input_event, 192 const WebInputEvent& input_event,
194 const ui::LatencyInfo& latency_info, 193 const ui::LatencyInfo& latency_info,
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 delegate_->ObserveGestureEventAndResult( 389 delegate_->ObserveGestureEventAndResult(
391 gesture_event, 390 gesture_event,
392 event_overscroll ? event_overscroll->latest_overscroll_delta 391 event_overscroll ? event_overscroll->latest_overscroll_delta
393 : gfx::Vector2dF(), 392 : gfx::Vector2dF(),
394 processed != WebInputEventResult::NotHandled); 393 processed != WebInputEventResult::NotHandled);
395 } 394 }
396 } 395 }
397 396
398 TRACE_EVENT_SYNTHETIC_DELAY_END("blink.HandleInputEvent"); 397 TRACE_EVENT_SYNTHETIC_DELAY_END("blink.HandleInputEvent");
399 398
400 // Note that we can't use handling_event_type_ here since it will be
401 // overridden by reentrant calls for events after the paused one.
402 bool can_send_ack = !(ignore_ack_for_mouse_move_from_debugger_ &&
403 input_event.type == WebInputEvent::MouseMove);
404 if (dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN) { 399 if (dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN) {
405 // |non_blocking| means it was ack'd already by the InputHandlerProxy 400 // |non_blocking| means it was ack'd already by the InputHandlerProxy
406 // so let the delegate know the event has been handled. 401 // so let the delegate know the event has been handled.
407 delegate_->NotifyInputEventHandled(input_event.type, ack_result); 402 delegate_->NotifyInputEventHandled(input_event.type, ack_result);
408 } 403 }
409 404
410 if ((dispatch_type == DISPATCH_TYPE_BLOCKING || 405 if ((dispatch_type == DISPATCH_TYPE_BLOCKING ||
411 dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN) && 406 dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN)) {
412 can_send_ack) {
413 std::unique_ptr<InputEventAck> response(new InputEventAck( 407 std::unique_ptr<InputEventAck> response(new InputEventAck(
414 input_event.type, ack_result, swap_latency_info, 408 input_event.type, ack_result, swap_latency_info,
415 std::move(event_overscroll), 409 std::move(event_overscroll),
416 ui::WebInputEventTraits::GetUniqueTouchEventId(input_event))); 410 ui::WebInputEventTraits::GetUniqueTouchEventId(input_event)));
417 delegate_->OnInputEventAck(std::move(response)); 411 delegate_->OnInputEventAck(std::move(response));
418 } else { 412 } else {
419 DCHECK(!event_overscroll) << "Unexpected overscroll for un-acked event"; 413 DCHECK(!event_overscroll) << "Unexpected overscroll for un-acked event";
420 } 414 }
421 if (can_send_ack && RenderThreadImpl::current()) { 415 if (RenderThreadImpl::current()) {
422 RenderThreadImpl::current() 416 RenderThreadImpl::current()
423 ->GetRendererScheduler() 417 ->GetRendererScheduler()
424 ->DidHandleInputEventOnMainThread(input_event); 418 ->DidHandleInputEventOnMainThread(input_event);
425 } 419 }
426 if (input_event.type == WebInputEvent::MouseMove)
427 ignore_ack_for_mouse_move_from_debugger_ = false;
428 420
429 #if defined(OS_ANDROID) 421 #if defined(OS_ANDROID)
430 // Allow the IME to be shown when the focus changes as a consequence 422 // Allow the IME to be shown when the focus changes as a consequence
431 // of a processed touch end event. 423 // of a processed touch end event.
432 if (input_event.type == WebInputEvent::TouchEnd && 424 if (input_event.type == WebInputEvent::TouchEnd &&
433 processed != WebInputEventResult::NotHandled) { 425 processed != WebInputEventResult::NotHandled) {
434 delegate_->UpdateTextInputState(ShowIme::IF_NEEDED, 426 delegate_->UpdateTextInputState(ShowIme::IF_NEEDED,
435 ChangeSource::FROM_NON_IME); 427 ChangeSource::FROM_NON_IME);
436 } 428 }
437 #elif defined(USE_AURA) 429 #elif defined(USE_AURA)
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 // If we're currently handling an event, stash the overscroll data such that 468 // If we're currently handling an event, stash the overscroll data such that
477 // it can be bundled in the event ack. 469 // it can be bundled in the event ack.
478 if (handling_event_overscroll_) { 470 if (handling_event_overscroll_) {
479 *handling_event_overscroll_ = std::move(params); 471 *handling_event_overscroll_ = std::move(params);
480 return; 472 return;
481 } 473 }
482 474
483 delegate_->OnDidOverscroll(*params); 475 delegate_->OnDidOverscroll(*params);
484 } 476 }
485 477
486 bool RenderWidgetInputHandler::SendAckForMouseMoveFromDebugger() {
487 if (handling_event_type_ == WebInputEvent::MouseMove) {
488 // If we pause multiple times during a single mouse move event, we should
489 // only send ACK once.
490 if (!ignore_ack_for_mouse_move_from_debugger_) {
491 std::unique_ptr<InputEventAck> ack(new InputEventAck(
492 handling_event_type_, INPUT_EVENT_ACK_STATE_CONSUMED));
493 delegate_->OnInputEventAck(std::move(ack));
494 return true;
495 }
496 }
497 return false;
498 }
499
500 void RenderWidgetInputHandler::IgnoreAckForMouseMoveFromDebugger() {
501 ignore_ack_for_mouse_move_from_debugger_ = true;
502 }
503
504 } // namespace content 478 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/input/render_widget_input_handler.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698