| 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; |
| 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 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 | 440 |
| 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 // If we don't care about the ack disposition, send the ack immediately. | 449 // If we don't care about the ack disposition, send the ack immediately. |
| 450 if (WebInputEventTraits::IgnoresAckDisposition(input_event.type)) { | 450 if (WebInputEventTraits::IgnoresAckDisposition(input_event)) { |
| 451 ProcessInputEventAck(input_event.type, | 451 ProcessInputEventAck(input_event.type, |
| 452 INPUT_EVENT_ACK_STATE_IGNORED, | 452 INPUT_EVENT_ACK_STATE_IGNORED, |
| 453 latency_info, | 453 latency_info, |
| 454 IGNORING_DISPOSITION); | 454 IGNORING_DISPOSITION); |
| 455 } | 455 } |
| 456 } | 456 } |
| 457 | 457 |
| 458 bool InputRouterImpl::OfferToOverscrollController( | 458 bool InputRouterImpl::OfferToOverscrollController( |
| 459 const WebInputEvent& input_event, | 459 const WebInputEvent& input_event, |
| 460 const ui::LatencyInfo& latency_info) { | 460 const ui::LatencyInfo& latency_info) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 514 } | 514 } |
| 515 | 515 |
| 516 return consumed; | 516 return consumed; |
| 517 } | 517 } |
| 518 | 518 |
| 519 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event, | 519 bool InputRouterImpl::OfferToRenderer(const WebInputEvent& input_event, |
| 520 const ui::LatencyInfo& latency_info, | 520 const ui::LatencyInfo& latency_info, |
| 521 bool is_keyboard_shortcut) { | 521 bool is_keyboard_shortcut) { |
| 522 if (Send(new InputMsg_HandleInputEvent( | 522 if (Send(new InputMsg_HandleInputEvent( |
| 523 routing_id(), &input_event, latency_info, is_keyboard_shortcut))) { | 523 routing_id(), &input_event, latency_info, is_keyboard_shortcut))) { |
| 524 // Ack messages for ignored ack event types are not required, and might | 524 // Ack messages for ignored ack event types should never be sent by the |
| 525 // never be sent by the renderer. Consequently, such event types should not | 525 // renderer. Consequently, such event types should not affect event time |
| 526 // affect event timing or in-flight event count metrics. | 526 // or in-flight event count metrics. |
| 527 if (!WebInputEventTraits::IgnoresAckDisposition(input_event.type)) { | 527 if (!WebInputEventTraits::IgnoresAckDisposition(input_event)) { |
| 528 input_event_start_time_ = TimeTicks::Now(); | 528 input_event_start_time_ = TimeTicks::Now(); |
| 529 client_->IncrementInFlightEventCount(); | 529 client_->IncrementInFlightEventCount(); |
| 530 } | 530 } |
| 531 return true; | 531 return true; |
| 532 } | 532 } |
| 533 return false; | 533 return false; |
| 534 } | 534 } |
| 535 | 535 |
| 536 void InputRouterImpl::OnInputEventAck(WebInputEvent::Type event_type, | 536 void InputRouterImpl::OnInputEventAck(WebInputEvent::Type event_type, |
| 537 InputEventAckState ack_result, | 537 InputEventAckState ack_result, |
| 538 const ui::LatencyInfo& latency_info) { | 538 const ui::LatencyInfo& latency_info) { |
| 539 // A synthetic ack will already have been sent for this event, and it should | |
| 540 // not affect event timing or in-flight count metrics. | |
| 541 if (WebInputEventTraits::IgnoresAckDisposition(event_type)) | |
| 542 return; | |
| 543 | |
| 544 client_->DecrementInFlightEventCount(); | 539 client_->DecrementInFlightEventCount(); |
| 545 | 540 |
| 546 // Log the time delta for processing an input event. | 541 // Log the time delta for processing an input event. |
| 547 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; | 542 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; |
| 548 UMA_HISTOGRAM_TIMES("MPArch.IIR_InputEventDelta", delta); | 543 UMA_HISTOGRAM_TIMES("MPArch.IIR_InputEventDelta", delta); |
| 549 | 544 |
| 550 ProcessInputEventAck(event_type, ack_result, latency_info, RENDERER); | 545 ProcessInputEventAck(event_type, ack_result, latency_info, RENDERER); |
| 551 // WARNING: |this| may be deleted at this point. | 546 // WARNING: |this| may be deleted at this point. |
| 552 | 547 |
| 553 // This is used only for testing, and the other end does not use the | 548 // 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 Loading... |
| 849 select_range_pending_ || | 844 select_range_pending_ || |
| 850 move_caret_pending_; | 845 move_caret_pending_; |
| 851 } | 846 } |
| 852 | 847 |
| 853 bool InputRouterImpl::IsInOverscrollGesture() const { | 848 bool InputRouterImpl::IsInOverscrollGesture() const { |
| 854 OverscrollController* controller = client_->GetOverscrollController(); | 849 OverscrollController* controller = client_->GetOverscrollController(); |
| 855 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; | 850 return controller && controller->overscroll_mode() != OVERSCROLL_NONE; |
| 856 } | 851 } |
| 857 | 852 |
| 858 } // namespace content | 853 } // namespace content |
| OLD | NEW |