Chromium Code Reviews| Index: content/browser/renderer_host/input/touch_event_queue.cc |
| diff --git a/content/browser/renderer_host/input/touch_event_queue.cc b/content/browser/renderer_host/input/touch_event_queue.cc |
| index ee1c7c242ef3faae6f696a758241c2a3557443f8..fd6aa31c046eada4e00ada9a81d5a26c4bc33477 100644 |
| --- a/content/browser/renderer_host/input/touch_event_queue.cc |
| +++ b/content/browser/renderer_host/input/touch_event_queue.cc |
| @@ -240,7 +240,9 @@ TouchEventQueue::TouchEventQueue(TouchEventQueueClient* client) |
| dispatching_touch_ack_(NULL), |
| dispatching_touch_(false), |
| touch_filtering_state_(TOUCH_FILTERING_STATE_DEFAULT), |
| - ack_timeout_enabled_(false) { |
| + ack_timeout_enabled_(false), |
| + touch_scrolling_mode_(GetTouchScrollingMode()), |
| + absorbing_touch_moves_(false) { |
| DCHECK(client); |
| } |
| @@ -326,6 +328,7 @@ void TouchEventQueue::ForwardToRenderer( |
| ack_timeout_enabled_ ? FORWARD_TOUCHES_UNTIL_TIMEOUT |
| : FORWARD_ALL_TOUCHES; |
| touch_ack_states_.clear(); |
| + absorbing_touch_moves_ = false; |
| } |
| // A synchronous ack will reset |dispatching_touch_|, in which case |
| @@ -345,6 +348,9 @@ void TouchEventQueue::OnGestureScrollEvent( |
| if (gesture_event.event.type != blink::WebInputEvent::GestureScrollBegin) |
| return; |
| + if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_TOUCHCANCEL) |
| + return; |
| + |
| // We assume that scroll events are generated synchronously from |
| // dispatching a touch event ack. This allows us to generate a synthetic |
| // cancel event that has the same touch ids as the touch event that |
| @@ -368,6 +374,19 @@ void TouchEventQueue::OnGestureScrollEvent( |
| dispatching_touch_ack_->coalesced_event()), true)); |
| } |
| +void TouchEventQueue::OnGestureEventAck( |
| + const GestureEventWithLatencyInfo& event, |
| + InputEventAckState ack_result) { |
| + if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE) |
|
jdduke (slow)
2014/01/31 20:01:16
Could this be racy? If the GSU ack is delayed? Or
Rick Byers
2014/02/01 23:09:34
Yes, this could be racy. I was thinking it was OK
|
| + return; |
| + |
| + if (event.event.type != blink::WebInputEvent::GestureScrollUpdate) |
| + return; |
| + |
| + // Suspend sending touchmove events as long as the scroll events are handled. |
| + absorbing_touch_moves_ = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); |
| +} |
| + |
| void TouchEventQueue::OnHasTouchEventHandlers(bool has_handlers) { |
| DCHECK(!dispatching_touch_ack_); |
| DCHECK(!dispatching_touch_); |
| @@ -478,6 +497,9 @@ bool TouchEventQueue::ShouldForwardToRenderer( |
| return false; |
| } |
| + if (absorbing_touch_moves_ && event.type == WebInputEvent::TouchMove) |
| + return false; |
| + |
| // Touch press events should always be forwarded to the renderer. |
| if (event.type == WebInputEvent::TouchStart) |
| return true; |
| @@ -523,4 +545,20 @@ void TouchEventQueue::UpdateTouchAckStates(const WebTouchEvent& event, |
| } |
| } |
| +// static |
| +TouchEventQueue::TouchScrollingMode TouchEventQueue::GetTouchScrollingMode() |
|
jdduke (slow)
2014/01/31 20:01:16
Any reason not to just put this in the anon namesp
Rick Byers
2014/02/01 23:09:34
Done.
|
| +{ |
| + std::string modeString = CommandLine::ForCurrentProcess()-> |
| + GetSwitchValueASCII(switches::kTouchScrollingMode); |
| + if (modeString == switches::kTouchScrollingModeSyncTouchmove) |
| + return TOUCH_SCROLLING_MODE_SYNC_TOUCHMOVE; |
| + if (modeString == switches::kTouchScrollingModeAbsorbTouchmove) |
| + return TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE; |
| + if (modeString != "" && |
| + modeString != switches::kTouchScrollingModeTouchcancel) |
| + LOG(ERROR) << "Invalid --touch-scrolling-mode option: " << modeString; |
| + return TOUCH_SCROLLING_MODE_TOUCHCANCEL; |
| +} |
| + |
| + |
| } // namespace content |