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