| 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/touch_event_queue.h" | 5 #include "content/browser/renderer_host/input/touch_event_queue.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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 DCHECK(timeout_handler_); | 419 DCHECK(timeout_handler_); |
| 420 timeout_handler_->Start(touch); | 420 timeout_handler_->Start(touch); |
| 421 } | 421 } |
| 422 } | 422 } |
| 423 | 423 |
| 424 void TouchEventQueue::OnGestureScrollEvent( | 424 void TouchEventQueue::OnGestureScrollEvent( |
| 425 const GestureEventWithLatencyInfo& gesture_event) { | 425 const GestureEventWithLatencyInfo& gesture_event) { |
| 426 if (gesture_event.event.type != blink::WebInputEvent::GestureScrollBegin) | 426 if (gesture_event.event.type != blink::WebInputEvent::GestureScrollBegin) |
| 427 return; | 427 return; |
| 428 | 428 |
| 429 if (touch_scrolling_mode_ == TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE) |
| 430 absorbing_touch_moves_ = true; |
| 431 |
| 429 if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_TOUCHCANCEL) | 432 if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_TOUCHCANCEL) |
| 430 return; | 433 return; |
| 431 | 434 |
| 432 // We assume that scroll events are generated synchronously from | 435 // We assume that scroll events are generated synchronously from |
| 433 // dispatching a touch event ack. This allows us to generate a synthetic | 436 // dispatching a touch event ack. This allows us to generate a synthetic |
| 434 // cancel event that has the same touch ids as the touch event that | 437 // cancel event that has the same touch ids as the touch event that |
| 435 // is being acked. Otherwise, we don't perform the touch-cancel optimization. | 438 // is being acked. Otherwise, we don't perform the touch-cancel optimization. |
| 436 if (!dispatching_touch_ack_) | 439 if (!dispatching_touch_ack_) |
| 437 return; | 440 return; |
| 438 | 441 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 459 return; | 462 return; |
| 460 | 463 |
| 461 if (event.event.type != blink::WebInputEvent::GestureScrollUpdate) | 464 if (event.event.type != blink::WebInputEvent::GestureScrollUpdate) |
| 462 return; | 465 return; |
| 463 | 466 |
| 464 // Suspend sending touchmove events as long as the scroll events are handled. | 467 // Suspend sending touchmove events as long as the scroll events are handled. |
| 465 // Note that there's no guarantee that this ACK is for the most recent | 468 // Note that there's no guarantee that this ACK is for the most recent |
| 466 // gesture event (or even part of the current sequence). Worst case, the | 469 // gesture event (or even part of the current sequence). Worst case, the |
| 467 // delay in updating the absorption state should only result in minor UI | 470 // delay in updating the absorption state should only result in minor UI |
| 468 // glitches. | 471 // glitches. |
| 469 // TODO(rbyers): Define precise timing requirements and potentially implement | |
| 470 // mitigations for races. | |
| 471 absorbing_touch_moves_ = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); | 472 absorbing_touch_moves_ = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); |
| 472 } | 473 } |
| 473 | 474 |
| 474 void TouchEventQueue::OnHasTouchEventHandlers(bool has_handlers) { | 475 void TouchEventQueue::OnHasTouchEventHandlers(bool has_handlers) { |
| 475 DCHECK(!dispatching_touch_ack_); | 476 DCHECK(!dispatching_touch_ack_); |
| 476 DCHECK(!dispatching_touch_); | 477 DCHECK(!dispatching_touch_); |
| 477 | 478 |
| 478 if (has_handlers) { | 479 if (has_handlers) { |
| 479 if (touch_filtering_state_ == DROP_ALL_TOUCHES) { | 480 if (touch_filtering_state_ == DROP_ALL_TOUCHES) { |
| 480 // If no touch handler was previously registered, ensure that we don't | 481 // If no touch handler was previously registered, ensure that we don't |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 } else if (event.type == WebInputEvent::TouchStart) { | 632 } else if (event.type == WebInputEvent::TouchStart) { |
| 632 for (unsigned i = 0; i < event.touchesLength; ++i) { | 633 for (unsigned i = 0; i < event.touchesLength; ++i) { |
| 633 const WebTouchPoint& point = event.touches[i]; | 634 const WebTouchPoint& point = event.touches[i]; |
| 634 if (point.state == WebTouchPoint::StatePressed) | 635 if (point.state == WebTouchPoint::StatePressed) |
| 635 touch_ack_states_[point.id] = ack_result; | 636 touch_ack_states_[point.id] = ack_result; |
| 636 } | 637 } |
| 637 } | 638 } |
| 638 } | 639 } |
| 639 | 640 |
| 640 } // namespace content | 641 } // namespace content |
| OLD | NEW |