| 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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 return false; | 501 return false; |
| 502 | 502 |
| 503 const blink::WebTouchEvent& event = | 503 const blink::WebTouchEvent& event = |
| 504 touch_queue_.front()->coalesced_event().event; | 504 touch_queue_.front()->coalesced_event().event; |
| 505 return (event.type == WebInputEvent::TouchStart); | 505 return (event.type == WebInputEvent::TouchStart); |
| 506 } | 506 } |
| 507 | 507 |
| 508 void TouchEventQueue::SetAckTimeoutEnabled(bool enabled, | 508 void TouchEventQueue::SetAckTimeoutEnabled(bool enabled, |
| 509 size_t ack_timeout_delay_ms) { | 509 size_t ack_timeout_delay_ms) { |
| 510 if (!enabled) { | 510 if (!enabled) { |
| 511 // Avoid resetting |timeout_handler_|, as an outstanding timeout may | |
| 512 // be active and must be completed for ack handling consistency. | |
| 513 ack_timeout_enabled_ = false; | 511 ack_timeout_enabled_ = false; |
| 512 if (touch_filtering_state_ == FORWARD_TOUCHES_UNTIL_TIMEOUT) |
| 513 touch_filtering_state_ = FORWARD_ALL_TOUCHES; |
| 514 // Only reset the |timeout_handler_| if the timer is running and has not yet |
| 515 // timed out. This ensures that an already timed out sequence is properly |
| 516 // flushed by the handler. |
| 517 if (timeout_handler_ && timeout_handler_->IsTimeoutTimerRunning()) |
| 518 timeout_handler_->Reset(); |
| 514 return; | 519 return; |
| 515 } | 520 } |
| 516 | 521 |
| 517 ack_timeout_enabled_ = true; | 522 ack_timeout_enabled_ = true; |
| 518 if (!timeout_handler_) | 523 if (!timeout_handler_) |
| 519 timeout_handler_.reset(new TouchTimeoutHandler(this, ack_timeout_delay_ms)); | 524 timeout_handler_.reset(new TouchTimeoutHandler(this, ack_timeout_delay_ms)); |
| 520 } | 525 } |
| 521 | 526 |
| 522 bool TouchEventQueue::IsTimeoutRunningForTesting() const { | 527 bool TouchEventQueue::IsTimeoutRunningForTesting() const { |
| 523 return timeout_handler_ && timeout_handler_->IsTimeoutTimerRunning(); | 528 return timeout_handler_ && timeout_handler_->IsTimeoutTimerRunning(); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 } else if (event.type == WebInputEvent::TouchStart) { | 629 } else if (event.type == WebInputEvent::TouchStart) { |
| 625 for (unsigned i = 0; i < event.touchesLength; ++i) { | 630 for (unsigned i = 0; i < event.touchesLength; ++i) { |
| 626 const WebTouchPoint& point = event.touches[i]; | 631 const WebTouchPoint& point = event.touches[i]; |
| 627 if (point.state == WebTouchPoint::StatePressed) | 632 if (point.state == WebTouchPoint::StatePressed) |
| 628 touch_ack_states_[point.id] = ack_result; | 633 touch_ack_states_[point.id] = ack_result; |
| 629 } | 634 } |
| 630 } | 635 } |
| 631 } | 636 } |
| 632 | 637 |
| 633 } // namespace content | 638 } // namespace content |
| OLD | NEW |