| 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/legacy_touch_event_queue.h" | 5 #include "content/browser/renderer_host/input/legacy_touch_event_queue.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 using blink::WebTouchPoint; | 21 using blink::WebTouchPoint; |
| 22 using ui::LatencyInfo; | 22 using ui::LatencyInfo; |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 // Time interval at which touchmove events will be forwarded to the client while | 27 // Time interval at which touchmove events will be forwarded to the client while |
| 28 // scrolling is active and possible. | 28 // scrolling is active and possible. |
| 29 const double kAsyncTouchMoveIntervalSec = .2; | 29 const double kAsyncTouchMoveIntervalSec = .2; |
| 30 | 30 |
| 31 // FIXME: Identical HasPointChanged in passthrough_touch_event_queue() |
| 31 // Compare all properties of touch points to determine the state. | 32 // Compare all properties of touch points to determine the state. |
| 32 bool HasPointChanged(const WebTouchPoint& point_1, | 33 bool HasPointChangedLegacy(const WebTouchPoint& point_1, |
| 33 const WebTouchPoint& point_2) { | 34 const WebTouchPoint& point_2) { |
| 34 DCHECK_EQ(point_1.id, point_2.id); | 35 DCHECK_EQ(point_1.id, point_2.id); |
| 35 if (point_1.PositionInScreen() != point_2.PositionInScreen() || | 36 if (point_1.PositionInScreen() != point_2.PositionInScreen() || |
| 36 point_1.PositionInWidget() != point_2.PositionInWidget() || | 37 point_1.PositionInWidget() != point_2.PositionInWidget() || |
| 37 point_1.radius_x != point_2.radius_x || | 38 point_1.radius_x != point_2.radius_x || |
| 38 point_1.radius_y != point_2.radius_y || | 39 point_1.radius_y != point_2.radius_y || |
| 39 point_1.rotation_angle != point_2.rotation_angle || | 40 point_1.rotation_angle != point_2.rotation_angle || |
| 40 point_1.force != point_2.force || point_1.tilt_x != point_2.tilt_x || | 41 point_1.force != point_2.force || point_1.tilt_x != point_2.tilt_x || |
| 41 point_1.tilt_y != point_2.tilt_y) { | 42 point_1.tilt_y != point_2.tilt_y) { |
| 42 return true; | 43 return true; |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 if (last_sent_touchevent_->GetType() == WebInputEvent::kTouchStart) | 520 if (last_sent_touchevent_->GetType() == WebInputEvent::kTouchStart) |
| 520 touch->event.touch_start_or_first_touch_move = true; | 521 touch->event.touch_start_or_first_touch_move = true; |
| 521 for (unsigned int i = 0; i < last_sent_touchevent_->touches_length; ++i) { | 522 for (unsigned int i = 0; i < last_sent_touchevent_->touches_length; ++i) { |
| 522 const WebTouchPoint& last_touch_point = last_sent_touchevent_->touches[i]; | 523 const WebTouchPoint& last_touch_point = last_sent_touchevent_->touches[i]; |
| 523 // Touches with same id may not have same index in Touches array. | 524 // Touches with same id may not have same index in Touches array. |
| 524 for (unsigned int j = 0; j < touch->event.touches_length; ++j) { | 525 for (unsigned int j = 0; j < touch->event.touches_length; ++j) { |
| 525 const WebTouchPoint& current_touchmove_point = touch->event.touches[j]; | 526 const WebTouchPoint& current_touchmove_point = touch->event.touches[j]; |
| 526 if (current_touchmove_point.id != last_touch_point.id) | 527 if (current_touchmove_point.id != last_touch_point.id) |
| 527 continue; | 528 continue; |
| 528 | 529 |
| 529 if (!HasPointChanged(last_touch_point, current_touchmove_point)) | 530 if (!HasPointChangedLegacy(last_touch_point, current_touchmove_point)) |
| 530 touch->event.touches[j].state = WebTouchPoint::kStateStationary; | 531 touch->event.touches[j].state = WebTouchPoint::kStateStationary; |
| 531 | 532 |
| 532 break; | 533 break; |
| 533 } | 534 } |
| 534 } | 535 } |
| 535 } | 536 } |
| 536 | 537 |
| 537 if (touch->event.GetType() != WebInputEvent::kTouchScrollStarted) { | 538 if (touch->event.GetType() != WebInputEvent::kTouchScrollStarted) { |
| 538 if (last_sent_touchevent_) | 539 if (last_sent_touchevent_) |
| 539 *last_sent_touchevent_ = touch->event; | 540 *last_sent_touchevent_ = touch->event; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 for (size_t j = 0; j < last_sent_touchevent_->touches_length; ++j) { | 616 for (size_t j = 0; j < last_sent_touchevent_->touches_length; ++j) { |
| 616 if (point.id != last_sent_touchevent_->touches[j].id) | 617 if (point.id != last_sent_touchevent_->touches[j].id) |
| 617 continue; | 618 continue; |
| 618 | 619 |
| 619 if (event.GetType() != WebInputEvent::kTouchMove) | 620 if (event.GetType() != WebInputEvent::kTouchMove) |
| 620 return FORWARD_TO_RENDERER; | 621 return FORWARD_TO_RENDERER; |
| 621 | 622 |
| 622 // All pointers in TouchMove events may have state as StateMoved, | 623 // All pointers in TouchMove events may have state as StateMoved, |
| 623 // even though none of the pointers have not changed in real. | 624 // even though none of the pointers have not changed in real. |
| 624 // Forward these events when at least one pointer has changed. | 625 // Forward these events when at least one pointer has changed. |
| 625 if (HasPointChanged(last_sent_touchevent_->touches[j], point)) | 626 if (HasPointChangedLegacy(last_sent_touchevent_->touches[j], point)) |
| 626 return FORWARD_TO_RENDERER; | 627 return FORWARD_TO_RENDERER; |
| 627 | 628 |
| 628 // This is a TouchMove event for which we have yet to find a | 629 // This is a TouchMove event for which we have yet to find a |
| 629 // non-stationary pointer. Continue checking the next pointers | 630 // non-stationary pointer. Continue checking the next pointers |
| 630 // in the |event|. | 631 // in the |event|. |
| 631 break; | 632 break; |
| 632 } | 633 } |
| 633 } | 634 } |
| 634 } | 635 } |
| 635 | 636 |
| 636 return ACK_WITH_NO_CONSUMER_EXISTS; | 637 return ACK_WITH_NO_CONSUMER_EXISTS; |
| 637 } | 638 } |
| 638 | 639 |
| 639 void LegacyTouchEventQueue::UpdateTouchConsumerStates( | 640 void LegacyTouchEventQueue::UpdateTouchConsumerStates( |
| 640 const WebTouchEvent& event, | 641 const WebTouchEvent& event, |
| 641 InputEventAckState ack_result) { | 642 InputEventAckState ack_result) { |
| 642 if (event.GetType() == WebInputEvent::kTouchStart) { | 643 if (event.GetType() == WebInputEvent::kTouchStart) { |
| 643 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) | 644 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) |
| 644 send_touch_events_async_ = false; | 645 send_touch_events_async_ = false; |
| 645 has_handler_for_current_sequence_ |= | 646 has_handler_for_current_sequence_ |= |
| 646 ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; | 647 ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; |
| 647 } else if (WebTouchEventTraits::IsTouchSequenceEnd(event)) { | 648 } else if (WebTouchEventTraits::IsTouchSequenceEnd(event)) { |
| 648 has_handler_for_current_sequence_ = false; | 649 has_handler_for_current_sequence_ = false; |
| 649 } | 650 } |
| 650 } | 651 } |
| 651 | 652 |
| 652 } // namespace content | 653 } // namespace content |
| OLD | NEW |