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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 DCHECK(timeout_handler_); | 414 DCHECK(timeout_handler_); |
415 timeout_handler_->Start(touch); | 415 timeout_handler_->Start(touch); |
416 } | 416 } |
417 } | 417 } |
418 | 418 |
419 void TouchEventQueue::OnGestureScrollEvent( | 419 void TouchEventQueue::OnGestureScrollEvent( |
420 const GestureEventWithLatencyInfo& gesture_event) { | 420 const GestureEventWithLatencyInfo& gesture_event) { |
421 if (gesture_event.event.type != blink::WebInputEvent::GestureScrollBegin) | 421 if (gesture_event.event.type != blink::WebInputEvent::GestureScrollBegin) |
422 return; | 422 return; |
423 | 423 |
| 424 if (touch_scrolling_mode_ == TOUCH_SCROLLING_MODE_ABSORB_TOUCHMOVE) |
| 425 absorbing_touch_moves_ = true; |
| 426 |
424 if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_TOUCHCANCEL) | 427 if (touch_scrolling_mode_ != TOUCH_SCROLLING_MODE_TOUCHCANCEL) |
425 return; | 428 return; |
426 | 429 |
427 // We assume that scroll events are generated synchronously from | 430 // We assume that scroll events are generated synchronously from |
428 // dispatching a touch event ack. This allows us to generate a synthetic | 431 // dispatching a touch event ack. This allows us to generate a synthetic |
429 // cancel event that has the same touch ids as the touch event that | 432 // cancel event that has the same touch ids as the touch event that |
430 // is being acked. Otherwise, we don't perform the touch-cancel optimization. | 433 // is being acked. Otherwise, we don't perform the touch-cancel optimization. |
431 if (!dispatching_touch_ack_) | 434 if (!dispatching_touch_ack_) |
432 return; | 435 return; |
433 | 436 |
(...skipping 20 matching lines...) Expand all Loading... |
454 return; | 457 return; |
455 | 458 |
456 if (event.event.type != blink::WebInputEvent::GestureScrollUpdate) | 459 if (event.event.type != blink::WebInputEvent::GestureScrollUpdate) |
457 return; | 460 return; |
458 | 461 |
459 // Suspend sending touchmove events as long as the scroll events are handled. | 462 // Suspend sending touchmove events as long as the scroll events are handled. |
460 // Note that there's no guarantee that this ACK is for the most recent | 463 // Note that there's no guarantee that this ACK is for the most recent |
461 // gesture event (or even part of the current sequence). Worst case, the | 464 // gesture event (or even part of the current sequence). Worst case, the |
462 // delay in updating the absorption state should only result in minor UI | 465 // delay in updating the absorption state should only result in minor UI |
463 // glitches. | 466 // glitches. |
464 // TODO(rbyers): Define precise timing requirements and potentially implement | |
465 // mitigations for races. | |
466 absorbing_touch_moves_ = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); | 467 absorbing_touch_moves_ = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); |
467 } | 468 } |
468 | 469 |
469 void TouchEventQueue::OnHasTouchEventHandlers(bool has_handlers) { | 470 void TouchEventQueue::OnHasTouchEventHandlers(bool has_handlers) { |
470 DCHECK(!dispatching_touch_ack_); | 471 DCHECK(!dispatching_touch_ack_); |
471 DCHECK(!dispatching_touch_); | 472 DCHECK(!dispatching_touch_); |
472 | 473 |
473 if (has_handlers) { | 474 if (has_handlers) { |
474 if (touch_filtering_state_ == DROP_ALL_TOUCHES) { | 475 if (touch_filtering_state_ == DROP_ALL_TOUCHES) { |
475 // If no touch handler was previously registered, ensure that we don't | 476 // If no touch handler was previously registered, ensure that we don't |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
619 } else if (event.type == WebInputEvent::TouchStart) { | 620 } else if (event.type == WebInputEvent::TouchStart) { |
620 for (unsigned i = 0; i < event.touchesLength; ++i) { | 621 for (unsigned i = 0; i < event.touchesLength; ++i) { |
621 const WebTouchPoint& point = event.touches[i]; | 622 const WebTouchPoint& point = event.touches[i]; |
622 if (point.state == WebTouchPoint::StatePressed) | 623 if (point.state == WebTouchPoint::StatePressed) |
623 touch_ack_states_[point.id] = ack_result; | 624 touch_ack_states_[point.id] = ack_result; |
624 } | 625 } |
625 } | 626 } |
626 } | 627 } |
627 | 628 |
628 } // namespace content | 629 } // namespace content |
OLD | NEW |