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 28 matching lines...) Expand all Loading... | |
39 return event; | 39 return event; |
40 } | 40 } |
41 | 41 |
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::IgnoresAckDisposition(event); | 45 !WebInputEventTraits::IgnoresAckDisposition(event); |
46 } | 46 } |
47 | 47 |
48 // Compare all properties of touch points to determine the state. | 48 // Compare all properties of touch points to determine the state. |
49 bool HasPointChanged(const WebTouchPoint& last_point, | 49 bool HasPointChanged(const WebTouchPoint& point_1, |
50 const WebTouchPoint& current_point) { | 50 const WebTouchPoint& point_2) { |
51 if (last_point.screenPosition != current_point.screenPosition || | 51 DCHECK_EQ(point_1.id, point_2.id); |
52 last_point.position != current_point.position || | 52 if (point_1.screenPosition != point_2.screenPosition || |
53 last_point.radiusX != current_point.radiusX || | 53 point_1.position != point_2.position || |
54 last_point.radiusY != current_point.radiusY || | 54 point_1.radiusX != point_2.radiusX || |
55 last_point.rotationAngle != current_point.rotationAngle || | 55 point_1.radiusY != point_2.radiusY || |
56 last_point.force != current_point.force) { | 56 point_1.rotationAngle != point_2.rotationAngle || |
57 point_1.force != point_2.force) { | |
57 return true; | 58 return true; |
58 } | 59 } |
59 return false; | 60 return false; |
60 } | 61 } |
61 | 62 |
62 } // namespace | 63 } // namespace |
63 | 64 |
64 | 65 |
65 // Cancels a touch sequence if a touchstart or touchmove ack response is | 66 // Cancels a touch sequence if a touchstart or touchmove ack response is |
66 // sufficiently delayed. | 67 // sufficiently delayed. |
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
722 const WebTouchPoint& point = event.touches[i]; | 723 const WebTouchPoint& point = event.touches[i]; |
723 if (point.state == WebTouchPoint::StateStationary) | 724 if (point.state == WebTouchPoint::StateStationary) |
724 continue; | 725 continue; |
725 | 726 |
726 // |last_sent_touchevent_| will be non-null as long as there is an | 727 // |last_sent_touchevent_| will be non-null as long as there is an |
727 // active touch sequence being forwarded to the renderer. | 728 // active touch sequence being forwarded to the renderer. |
728 if (!last_sent_touchevent_) | 729 if (!last_sent_touchevent_) |
729 continue; | 730 continue; |
730 | 731 |
731 for (size_t j = 0; j < last_sent_touchevent_->touchesLength; ++j) { | 732 for (size_t j = 0; j < last_sent_touchevent_->touchesLength; ++j) { |
732 if (point.id == last_sent_touchevent_->touches[j].id) | 733 if (point.id != last_sent_touchevent_->touches[j].id) |
734 continue; | |
735 | |
736 if (event.type != WebInputEvent::TouchMove) | |
733 return FORWARD_TO_RENDERER; | 737 return FORWARD_TO_RENDERER; |
738 | |
739 // All pointers in TouchMove events may have state as StateMoved, | |
740 // even though none of the pointers have not changed in real. | |
741 // Forward these events when at least one pointer has changed. | |
742 if (HasPointChanged(last_sent_touchevent_->touches[j], point)) | |
743 return FORWARD_TO_RENDERER; | |
744 | |
745 // This is a TouchMove event and not forwarded yet. | |
jdduke (slow)
2015/02/13 16:37:37
Nit: Maybe reword this like:
// This is a TouchMo
USE s.singapati at gmail.com
2015/02/16 10:52:01
Done.
| |
746 // Continue checking the next pointers in the |event|. | |
747 break; | |
734 } | 748 } |
jdduke (slow)
2015/02/13 16:37:37
It's a shame we can't "clean up" the pointer state
USE s.singapati at gmail.com
2015/02/16 10:52:01
Acknowledged. Lets see if this can be done may be
| |
749 | |
735 } | 750 } |
736 } | 751 } |
737 | 752 |
753 if (event.type == WebInputEvent::TouchMove) | |
jdduke (slow)
2015/02/13 16:37:37
This isn't always correct. Let's just go ahead and
USE s.singapati at gmail.com
2015/02/16 10:52:01
Done.
| |
754 return ACK_WITH_NOT_CONSUMED; | |
755 | |
738 return ACK_WITH_NO_CONSUMER_EXISTS; | 756 return ACK_WITH_NO_CONSUMER_EXISTS; |
739 } | 757 } |
740 | 758 |
741 void TouchEventQueue::UpdateTouchConsumerStates(const WebTouchEvent& event, | 759 void TouchEventQueue::UpdateTouchConsumerStates(const WebTouchEvent& event, |
742 InputEventAckState ack_result) { | 760 InputEventAckState ack_result) { |
743 if (event.type == WebInputEvent::TouchStart) { | 761 if (event.type == WebInputEvent::TouchStart) { |
744 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) | 762 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) |
745 send_touch_events_async_ = false; | 763 send_touch_events_async_ = false; |
746 has_handler_for_current_sequence_ |= | 764 has_handler_for_current_sequence_ |= |
747 ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; | 765 ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; |
748 } else if (WebTouchEventTraits::IsTouchSequenceEnd(event)) { | 766 } else if (WebTouchEventTraits::IsTouchSequenceEnd(event)) { |
749 has_handler_for_current_sequence_ = false; | 767 has_handler_for_current_sequence_ = false; |
750 } | 768 } |
751 } | 769 } |
752 | 770 |
753 } // namespace content | 771 } // namespace content |
OLD | NEW |