| 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/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "content/browser/renderer_host/input/timeout_monitor.h" | 10 #include "content/browser/renderer_host/input/timeout_monitor.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 bool ShouldTouchTriggerTimeout(const WebTouchEvent& event) { | 42 bool ShouldTouchTriggerTimeout(const WebTouchEvent& event) { |
| 43 return (event.type == WebInputEvent::TouchStart || | 43 return (event.type == WebInputEvent::TouchStart || |
| 44 event.type == WebInputEvent::TouchMove) && | 44 event.type == WebInputEvent::TouchMove) && |
| 45 WebInputEventTraits::WillReceiveAckFromRenderer(event) && | 45 WebInputEventTraits::WillReceiveAckFromRenderer(event) && |
| 46 event.cancelable; | 46 event.cancelable; |
| 47 } | 47 } |
| 48 | 48 |
| 49 // Compare all properties of touch points to determine the state. | 49 // Compare all properties of touch points to determine the state. |
| 50 bool HasPointChanged(const WebTouchPoint& point_1, | 50 bool HasPointChanged(const WebTouchPoint& point_1, |
| 51 const WebTouchPoint& point_2) { | 51 const WebTouchPoint& point_2) { |
| 52 DCHECK_EQ(point_1.id, point_2.id); | 52 DCHECK_EQ(point_1.pointerId, point_2.pointerId); |
| 53 if (point_1.screenPosition != point_2.screenPosition || | 53 if (point_1.screenPosition != point_2.screenPosition || |
| 54 point_1.position != point_2.position || | 54 point_1.position != point_2.position || |
| 55 point_1.radiusX != point_2.radiusX || | 55 point_1.width != point_2.width || |
| 56 point_1.radiusY != point_2.radiusY || | 56 point_1.height != point_2.height || |
| 57 point_1.rotationAngle != point_2.rotationAngle || | 57 point_1.rotationAngle != point_2.rotationAngle || |
| 58 point_1.force != point_2.force) { | 58 point_1.pressure != point_2.pressure) { |
| 59 return true; | 59 return true; |
| 60 } | 60 } |
| 61 return false; | 61 return false; |
| 62 } | 62 } |
| 63 | 63 |
| 64 } // namespace | 64 } // namespace |
| 65 | 65 |
| 66 | 66 |
| 67 // Cancels a touch sequence if a touchstart or touchmove ack response is | 67 // Cancels a touch sequence if a touchstart or touchmove ack response is |
| 68 // sufficiently delayed. | 68 // sufficiently delayed. |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 // For touchmove events, compare touch points position from current event | 694 // For touchmove events, compare touch points position from current event |
| 695 // to last sent event and update touch points state. | 695 // to last sent event and update touch points state. |
| 696 if (touch->event.type == WebInputEvent::TouchMove) { | 696 if (touch->event.type == WebInputEvent::TouchMove) { |
| 697 CHECK(last_sent_touchevent_); | 697 CHECK(last_sent_touchevent_); |
| 698 for (unsigned int i = 0; i < last_sent_touchevent_->touchesLength; ++i) { | 698 for (unsigned int i = 0; i < last_sent_touchevent_->touchesLength; ++i) { |
| 699 const WebTouchPoint& last_touch_point = | 699 const WebTouchPoint& last_touch_point = |
| 700 last_sent_touchevent_->touches[i]; | 700 last_sent_touchevent_->touches[i]; |
| 701 // Touches with same id may not have same index in Touches array. | 701 // Touches with same id may not have same index in Touches array. |
| 702 for (unsigned int j = 0; j < touch->event.touchesLength; ++j) { | 702 for (unsigned int j = 0; j < touch->event.touchesLength; ++j) { |
| 703 const WebTouchPoint& current_touchmove_point = touch->event.touches[j]; | 703 const WebTouchPoint& current_touchmove_point = touch->event.touches[j]; |
| 704 if (current_touchmove_point.id != last_touch_point.id) | 704 if (current_touchmove_point.pointerId != last_touch_point.pointerId) |
| 705 continue; | 705 continue; |
| 706 | 706 |
| 707 if (!HasPointChanged(last_touch_point, current_touchmove_point)) | 707 if (!HasPointChanged(last_touch_point, current_touchmove_point)) |
| 708 touch->event.touches[j].state = WebTouchPoint::StateStationary; | 708 touch->event.touches[j].state = WebTouchPoint::StateStationary; |
| 709 | 709 |
| 710 break; | 710 break; |
| 711 } | 711 } |
| 712 } | 712 } |
| 713 } | 713 } |
| 714 | 714 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 const WebTouchPoint& point = event.touches[i]; | 783 const WebTouchPoint& point = event.touches[i]; |
| 784 if (point.state == WebTouchPoint::StateStationary) | 784 if (point.state == WebTouchPoint::StateStationary) |
| 785 continue; | 785 continue; |
| 786 | 786 |
| 787 // |last_sent_touchevent_| will be non-null as long as there is an | 787 // |last_sent_touchevent_| will be non-null as long as there is an |
| 788 // active touch sequence being forwarded to the renderer. | 788 // active touch sequence being forwarded to the renderer. |
| 789 if (!last_sent_touchevent_) | 789 if (!last_sent_touchevent_) |
| 790 continue; | 790 continue; |
| 791 | 791 |
| 792 for (size_t j = 0; j < last_sent_touchevent_->touchesLength; ++j) { | 792 for (size_t j = 0; j < last_sent_touchevent_->touchesLength; ++j) { |
| 793 if (point.id != last_sent_touchevent_->touches[j].id) | 793 if (point.pointerId != last_sent_touchevent_->touches[j].pointerId) |
| 794 continue; | 794 continue; |
| 795 | 795 |
| 796 if (event.type != WebInputEvent::TouchMove) | 796 if (event.type != WebInputEvent::TouchMove) |
| 797 return FORWARD_TO_RENDERER; | 797 return FORWARD_TO_RENDERER; |
| 798 | 798 |
| 799 // All pointers in TouchMove events may have state as StateMoved, | 799 // All pointers in TouchMove events may have state as StateMoved, |
| 800 // even though none of the pointers have not changed in real. | 800 // even though none of the pointers have not changed in real. |
| 801 // Forward these events when at least one pointer has changed. | 801 // Forward these events when at least one pointer has changed. |
| 802 if (HasPointChanged(last_sent_touchevent_->touches[j], point)) | 802 if (HasPointChanged(last_sent_touchevent_->touches[j], point)) |
| 803 return FORWARD_TO_RENDERER; | 803 return FORWARD_TO_RENDERER; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 820 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) | 820 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) |
| 821 send_touch_events_async_ = false; | 821 send_touch_events_async_ = false; |
| 822 has_handler_for_current_sequence_ |= | 822 has_handler_for_current_sequence_ |= |
| 823 ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; | 823 ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; |
| 824 } else if (WebTouchEventTraits::IsTouchSequenceEnd(event)) { | 824 } else if (WebTouchEventTraits::IsTouchSequenceEnd(event)) { |
| 825 has_handler_for_current_sequence_ = false; | 825 has_handler_for_current_sequence_ = false; |
| 826 } | 826 } |
| 827 } | 827 } |
| 828 | 828 |
| 829 } // namespace content | 829 } // namespace content |
| OLD | NEW |