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 "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 Loading... |
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; | |
93 if (modeString == switches::kTouchScrollingModeSyncTouchmove) | 91 if (modeString == switches::kTouchScrollingModeSyncTouchmove) |
94 return TouchEventQueue::TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE; | 92 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 const char* GetEventAckName(InputEventAckState ack_result) { | 102 const char* GetEventAckName(InputEventAckState ack_result) { |
103 switch(ack_result) { | 103 switch(ack_result) { |
104 case INPUT_EVENT_ACK_STATE_UNKNOWN: return "UNKNOWN"; | 104 case INPUT_EVENT_ACK_STATE_UNKNOWN: return "UNKNOWN"; |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 if (OfferToOverscrollController(input_event, latency_info)) | 415 if (OfferToOverscrollController(input_event, latency_info)) |
416 return; | 416 return; |
417 | 417 |
418 if (OfferToClient(input_event, latency_info)) | 418 if (OfferToClient(input_event, latency_info)) |
419 return; | 419 return; |
420 | 420 |
421 OfferToRenderer(input_event, latency_info, is_keyboard_shortcut); | 421 OfferToRenderer(input_event, latency_info, is_keyboard_shortcut); |
422 | 422 |
423 // Touch events should always indicate in the event whether they are | 423 // Touch events should always indicate in the event whether they are |
424 // cancelable (respect ACK disposition) or not. | 424 // cancelable (respect ACK disposition) or not. |
425 bool ignores_ack = WebInputEventTraits::IgnoresAckDisposition(input_event); | 425 bool ignoresAck = |
| 426 WebInputEventTraits::IgnoresAckDisposition(input_event.type); |
426 if (WebInputEvent::isTouchEventType(input_event.type)) { | 427 if (WebInputEvent::isTouchEventType(input_event.type)) { |
427 DCHECK(!ignores_ack == | 428 DCHECK(!ignoresAck == |
428 static_cast<const blink::WebTouchEvent&>(input_event).cancelable); | 429 static_cast<const blink::WebTouchEvent&>(input_event).cancelable); |
429 } | 430 } |
430 | 431 |
431 // If we don't care about the ack disposition, send the ack immediately. | 432 // If we don't care about the ack disposition, send the ack immediately. |
432 if (ignores_ack) { | 433 if (ignoresAck) { |
433 ProcessInputEventAck(input_event.type, | 434 ProcessInputEventAck(input_event.type, |
434 INPUT_EVENT_ACK_STATE_IGNORED, | 435 INPUT_EVENT_ACK_STATE_IGNORED, |
435 latency_info, | 436 latency_info, |
436 IGNORING_DISPOSITION); | 437 IGNORING_DISPOSITION); |
437 } | 438 } |
438 } | 439 } |
439 | 440 |
440 bool InputRouterImpl::OfferToOverscrollController( | 441 bool InputRouterImpl::OfferToOverscrollController( |
441 const WebInputEvent& input_event, | 442 const WebInputEvent& input_event, |
442 const ui::LatencyInfo& latency_info) { | 443 const ui::LatencyInfo& latency_info) { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 } | 497 } |
497 | 498 |
498 return consumed; | 499 return consumed; |
499 } | 500 } |
500 | 501 |
501 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event, | 502 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event, |
502 const ui::LatencyInfo& latency_info, | 503 const ui::LatencyInfo& latency_info, |
503 bool is_keyboard_shortcut) { | 504 bool is_keyboard_shortcut) { |
504 if (Send(new InputMsg_HandleInputEvent( | 505 if (Send(new InputMsg_HandleInputEvent( |
505 routing_id(), &input_event, latency_info, is_keyboard_shortcut))) { | 506 routing_id(), &input_event, latency_info, is_keyboard_shortcut))) { |
506 // Ack messages for ignored ack event types should never be sent by the | 507 // Ack messages for ignored ack event types are not required, and might |
507 // renderer. Consequently, such event types should not affect event time | 508 // never be sent by the renderer. Consequently, such event types should not |
508 // or in-flight event count metrics. | 509 // affect event timing or in-flight event count metrics. |
509 if (!WebInputEventTraits::IgnoresAckDisposition(input_event)) { | 510 if (!WebInputEventTraits::IgnoresAckDisposition(input_event.type)) { |
510 input_event_start_time_ = TimeTicks::Now(); | 511 input_event_start_time_ = TimeTicks::Now(); |
511 client_->IncrementInFlightEventCount(); | 512 client_->IncrementInFlightEventCount(); |
512 } | 513 } |
513 return true; | 514 return true; |
514 } | 515 } |
515 return false; | 516 return false; |
516 } | 517 } |
517 | 518 |
518 void InputRouterImpl::OnInputEventAck(WebInputEvent::Type event_type, | 519 void InputRouterImpl::OnInputEventAck(WebInputEvent::Type event_type, |
519 InputEventAckState ack_result, | 520 InputEventAckState ack_result, |
520 const ui::LatencyInfo& latency_info) { | 521 const ui::LatencyInfo& latency_info) { |
| 522 // A synthetic ack will already have been sent for this event, and it should |
| 523 // not affect event timing or in-flight count metrics. |
| 524 if (WebInputEventTraits::IgnoresAckDisposition(event_type)) |
| 525 return; |
| 526 |
521 client_->DecrementInFlightEventCount(); | 527 client_->DecrementInFlightEventCount(); |
522 | 528 |
523 // Log the time delta for processing an input event. | 529 // Log the time delta for processing an input event. |
524 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; | 530 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; |
525 UMA_HISTOGRAM_TIMES("MPArch.IIR_InputEventDelta", delta); | 531 UMA_HISTOGRAM_TIMES("MPArch.IIR_InputEventDelta", delta); |
526 | 532 |
527 ProcessInputEventAck(event_type, ack_result, latency_info, RENDERER); | 533 ProcessInputEventAck(event_type, ack_result, latency_info, RENDERER); |
528 // WARNING: |this| may be deleted at this point. | 534 // WARNING: |this| may be deleted at this point. |
529 | 535 |
530 // This is used only for testing, and the other end does not use the | 536 // This is used only for testing, and the other end does not use the |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 select_range_pending_ || | 752 select_range_pending_ || |
747 move_caret_pending_; | 753 move_caret_pending_; |
748 } | 754 } |
749 | 755 |
750 bool InputRouterImpl::IsInOverscrollGesture() const { | 756 bool InputRouterImpl::IsInOverscrollGesture() const { |
751 OverscrollController* controller = client_->GetOverscrollController(); | 757 OverscrollController* controller = client_->GetOverscrollController(); |
752 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; | 758 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; |
753 } | 759 } |
754 | 760 |
755 } // namespace content | 761 } // namespace content |
OLD | NEW |