Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1388)

Side by Side Diff: content/browser/renderer_host/input/touch_event_queue.cc

Issue 916103002: Avoid sending touchmove events where all pointers are stationary (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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) {
jdduke (slow) 2015/02/11 17:17:12 Nit: Will this now fit on the same line? Also, ma
USE s.singapati at gmail.com 2015/02/12 11:15:02 line exceeds 80.
USE s.singapati at gmail.com 2015/02/13 12:16:48 Done.
51 if (last_point.screenPosition != current_point.screenPosition || 51 if (point_1.screenPosition != point_2.screenPosition ||
52 last_point.position != current_point.position || 52 point_1.position != point_2.position ||
53 last_point.radiusX != current_point.radiusX || 53 point_1.radiusX != point_2.radiusX ||
54 last_point.radiusY != current_point.radiusY || 54 point_1.radiusY != point_2.radiusY ||
55 last_point.rotationAngle != current_point.rotationAngle || 55 point_1.rotationAngle != point_2.rotationAngle ||
56 last_point.force != current_point.force) { 56 point_1.force != point_2.force) {
57 return true; 57 return true;
58 } 58 }
59 return false; 59 return false;
60 } 60 }
61 61
62 } // namespace 62 } // namespace
63 63
64 64
65 // Cancels a touch sequence if a touchstart or touchmove ack response is 65 // Cancels a touch sequence if a touchstart or touchmove ack response is
66 // sufficiently delayed. 66 // sufficiently delayed.
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 const WebTouchPoint& point = event.touches[i]; 722 const WebTouchPoint& point = event.touches[i];
723 if (point.state == WebTouchPoint::StateStationary) 723 if (point.state == WebTouchPoint::StateStationary)
724 continue; 724 continue;
725 725
726 // |last_sent_touchevent_| will be non-null as long as there is an 726 // |last_sent_touchevent_| will be non-null as long as there is an
727 // active touch sequence being forwarded to the renderer. 727 // active touch sequence being forwarded to the renderer.
728 if (!last_sent_touchevent_) 728 if (!last_sent_touchevent_)
729 continue; 729 continue;
730 730
731 for (size_t j = 0; j < last_sent_touchevent_->touchesLength; ++j) { 731 for (size_t j = 0; j < last_sent_touchevent_->touchesLength; ++j) {
732 if (point.id == last_sent_touchevent_->touches[j].id) 732 if (point.id != last_sent_touchevent_->touches[j].id)
733 continue;
734
735 // It is possible that all the pointers in a given TouchMove may have
736 // state as StateMoved, even though none of the pointers have not
737 // changed in real. Avoid sending these events to the renderer.
738 if (event.type == WebInputEvent::TouchMove) {
739 if (HasPointChanged(last_sent_touchevent_->touches[j], point))
jdduke (slow) 2015/02/11 17:17:12 Can we invert this condition? if (event.type == W
USE s.singapati at gmail.com 2015/02/12 11:15:02 Hmm..I think not. ACK_WITH_NOT_CONSUMED should not
jdduke (slow) 2015/02/12 16:55:56 Hmm, yeah I had that completely wrong. It's still
USE s.singapati at gmail.com 2015/02/13 12:16:47 Done.
740 return FORWARD_TO_RENDERER;
741 } else {
733 return FORWARD_TO_RENDERER; 742 return FORWARD_TO_RENDERER;
743 }
744 // Pointer with same id found and handled.
745 break;
734 } 746 }
747
735 } 748 }
736 } 749 }
737 750
738 return ACK_WITH_NO_CONSUMER_EXISTS; 751 return ACK_WITH_NO_CONSUMER_EXISTS;
739 } 752 }
740 753
741 void TouchEventQueue::UpdateTouchConsumerStates(const WebTouchEvent& event, 754 void TouchEventQueue::UpdateTouchConsumerStates(const WebTouchEvent& event,
742 InputEventAckState ack_result) { 755 InputEventAckState ack_result) {
743 if (event.type == WebInputEvent::TouchStart) { 756 if (event.type == WebInputEvent::TouchStart) {
744 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) 757 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED)
745 send_touch_events_async_ = false; 758 send_touch_events_async_ = false;
746 has_handler_for_current_sequence_ |= 759 has_handler_for_current_sequence_ |=
747 ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; 760 ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
748 } else if (WebTouchEventTraits::IsTouchSequenceEnd(event)) { 761 } else if (WebTouchEventTraits::IsTouchSequenceEnd(event)) {
749 has_handler_for_current_sequence_ = false; 762 has_handler_for_current_sequence_ = false;
750 } 763 }
751 } 764 }
752 765
753 } // namespace content 766 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698