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

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

Issue 245833002: Implement async touchmove dispatch during scroll (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix win Created 6 years, 8 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 "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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 #else 82 #else
83 double GetTouchMoveSlopSuppressionLengthDips() { 83 double GetTouchMoveSlopSuppressionLengthDips() {
84 return 0; 84 return 0;
85 } 85 }
86 #endif 86 #endif
87 87
88 TouchEventQueue::TouchScrollingMode GetTouchScrollingMode() { 88 TouchEventQueue::TouchScrollingMode GetTouchScrollingMode() {
89 std::string modeString = CommandLine::ForCurrentProcess()-> 89 std::string modeString = CommandLine::ForCurrentProcess()->
90 GetSwitchValueASCII(switches::kTouchScrollingMode); 90 GetSwitchValueASCII(switches::kTouchScrollingMode);
91 if (modeString == switches::kTouchScrollingModeAsyncTouchmove)
92 return TouchEventQueue::TOUCH_SCROLLING_MODE_ASYNC_TOUCHMOVE;
91 if (modeString == switches::kTouchScrollingModeSyncTouchmove) 93 if (modeString == switches::kTouchScrollingModeSyncTouchmove)
92 return TouchEventQueue::TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE; 94 return TouchEventQueue::TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE;
93 if (modeString == switches::kTouchScrollingModeAbsorbTouchmove)
94 return TouchEventQueue::TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE;
95 if (modeString == switches::kTouchScrollingModeTouchcancel) 95 if (modeString == switches::kTouchScrollingModeTouchcancel)
96 return TouchEventQueue::TOUCH_SCROLLING_MODE_TOUCHCANCEL; 96 return TouchEventQueue::TOUCH_SCROLLING_MODE_TOUCHCANCEL;
97 if (modeString != "") 97 if (modeString != "")
98 LOG(ERROR) << "Invalid --touch-scrolling-mode option: " << modeString; 98 LOG(ERROR) << "Invalid --touch-scrolling-mode option: " << modeString;
99 return TouchEventQueue::TOUCH_SCROLLING_MODE_DEFAULT; 99 return TouchEventQueue::TOUCH_SCROLLING_MODE_DEFAULT;
100 } 100 }
101 101
102 GestureEventWithLatencyInfo MakeGestureEvent(WebInputEvent::Type type, 102 GestureEventWithLatencyInfo MakeGestureEvent(WebInputEvent::Type type,
103 double timestamp_seconds, 103 double timestamp_seconds,
104 int x, 104 int x,
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 if (OfferToOverscrollController(input_event, latency_info)) 441 if (OfferToOverscrollController(input_event, latency_info))
442 return; 442 return;
443 443
444 if (OfferToClient(input_event, latency_info)) 444 if (OfferToClient(input_event, latency_info))
445 return; 445 return;
446 446
447 OfferToRenderer(input_event, latency_info, is_keyboard_shortcut); 447 OfferToRenderer(input_event, latency_info, is_keyboard_shortcut);
448 448
449 // Touch events should always indicate in the event whether they are 449 // Touch events should always indicate in the event whether they are
450 // cancelable (respect ACK disposition) or not. 450 // cancelable (respect ACK disposition) or not.
451 bool ignoresAck = 451 bool ignores_ack = WebInputEventTraits::IgnoresAckDisposition(input_event);
452 WebInputEventTraits::IgnoresAckDisposition(input_event.type);
453 if (WebInputEvent::isTouchEventType(input_event.type)) { 452 if (WebInputEvent::isTouchEventType(input_event.type)) {
454 DCHECK(!ignoresAck == 453 DCHECK(!ignores_ack ==
455 static_cast<const blink::WebTouchEvent&>(input_event).cancelable); 454 static_cast<const blink::WebTouchEvent&>(input_event).cancelable);
456 } 455 }
457 456
458 // If we don't care about the ack disposition, send the ack immediately. 457 // If we don't care about the ack disposition, send the ack immediately.
459 if (ignoresAck) { 458 if (ignores_ack) {
460 ProcessInputEventAck(input_event.type, 459 ProcessInputEventAck(input_event.type,
461 INPUT_EVENT_ACK_STATE_IGNORED, 460 INPUT_EVENT_ACK_STATE_IGNORED,
462 latency_info, 461 latency_info,
463 IGNORING_DISPOSITION); 462 IGNORING_DISPOSITION);
464 } 463 }
465 } 464 }
466 465
467 bool InputRouterImpl::OfferToOverscrollController( 466 bool InputRouterImpl::OfferToOverscrollController(
468 const WebInputEvent& input_event, 467 const WebInputEvent& input_event,
469 const ui::LatencyInfo& latency_info) { 468 const ui::LatencyInfo& latency_info) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 } 522 }
524 523
525 return consumed; 524 return consumed;
526 } 525 }
527 526
528 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event, 527 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event,
529 const ui::LatencyInfo& latency_info, 528 const ui::LatencyInfo& latency_info,
530 bool is_keyboard_shortcut) { 529 bool is_keyboard_shortcut) {
531 if (Send(new InputMsg_HandleInputEvent( 530 if (Send(new InputMsg_HandleInputEvent(
532 routing_id(), &input_event, latency_info, is_keyboard_shortcut))) { 531 routing_id(), &input_event, latency_info, is_keyboard_shortcut))) {
533 // Ack messages for ignored ack event types are not required, and might 532 // Ack messages for ignored ack event types should never be sent by the
534 // never be sent by the renderer. Consequently, such event types should not 533 // renderer. Consequently, such event types should not affect event time
535 // affect event timing or in-flight event count metrics. 534 // or in-flight event count metrics.
536 if (!WebInputEventTraits::IgnoresAckDisposition(input_event.type)) { 535 if (!WebInputEventTraits::IgnoresAckDisposition(input_event)) {
537 input_event_start_time_ = TimeTicks::Now(); 536 input_event_start_time_ = TimeTicks::Now();
538 client_->IncrementInFlightEventCount(); 537 client_->IncrementInFlightEventCount();
539 } 538 }
540 return true; 539 return true;
541 } 540 }
542 return false; 541 return false;
543 } 542 }
544 543
545 void InputRouterImpl::OnInputEventAck(WebInputEvent::Type event_type, 544 void InputRouterImpl::OnInputEventAck(WebInputEvent::Type event_type,
546 InputEventAckState ack_result, 545 InputEventAckState ack_result,
547 const ui::LatencyInfo& latency_info) { 546 const ui::LatencyInfo& latency_info) {
548 // A synthetic ack will already have been sent for this event, and it should
549 // not affect event timing or in-flight count metrics.
550 if (WebInputEventTraits::IgnoresAckDisposition(event_type))
551 return;
552
553 client_->DecrementInFlightEventCount(); 547 client_->DecrementInFlightEventCount();
554 548
555 // Log the time delta for processing an input event. 549 // Log the time delta for processing an input event.
556 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; 550 TimeDelta delta = TimeTicks::Now() - input_event_start_time_;
557 UMA_HISTOGRAM_TIMES("MPArch.IIR_InputEventDelta", delta); 551 UMA_HISTOGRAM_TIMES("MPArch.IIR_InputEventDelta", delta);
558 552
559 ProcessInputEventAck(event_type, ack_result, latency_info, RENDERER); 553 ProcessInputEventAck(event_type, ack_result, latency_info, RENDERER);
560 // WARNING: |this| may be deleted at this point. 554 // WARNING: |this| may be deleted at this point.
561 555
562 // This is used only for testing, and the other end does not use the 556 // This is used only for testing, and the other end does not use the
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 select_range_pending_ || 852 select_range_pending_ ||
859 move_caret_pending_; 853 move_caret_pending_;
860 } 854 }
861 855
862 bool InputRouterImpl::IsInOverscrollGesture() const { 856 bool InputRouterImpl::IsInOverscrollGesture() const {
863 OverscrollController* controller = client_->GetOverscrollController(); 857 OverscrollController* controller = client_->GetOverscrollController();
864 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; 858 return controller && controller->overscroll_mode() != OVERSCROLL_NONE;
865 } 859 }
866 860
867 } // namespace content 861 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | content/browser/renderer_host/input/input_router_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698