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

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

Issue 148453012: Chrome requires WebTouchPoint to store WebFloatPoint, instead of WebPoint. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address jdduke's comments. Created 6 years, 9 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 | Annotate | Revision Log
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/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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 TouchEventWithLatencyInfo timeout_event_; 162 TouchEventWithLatencyInfo timeout_event_;
163 163
164 // Provides timeout-based callback behavior. 164 // Provides timeout-based callback behavior.
165 TimeoutMonitor timeout_monitor_; 165 TimeoutMonitor timeout_monitor_;
166 }; 166 };
167 167
168 // Provides touchmove slop suppression for a single touch that remains within 168 // Provides touchmove slop suppression for a single touch that remains within
169 // a given slop region, unless the touchstart is preventDefault'ed. 169 // a given slop region, unless the touchstart is preventDefault'ed.
170 class TouchEventQueue::TouchMoveSlopSuppressor { 170 class TouchEventQueue::TouchMoveSlopSuppressor {
171 public: 171 public:
172 // TODO(jdduke): Remove int cast on suppression length, crbug.com/336807.
173 TouchMoveSlopSuppressor(double slop_suppression_length_dips) 172 TouchMoveSlopSuppressor(double slop_suppression_length_dips)
174 : slop_suppression_length_dips_squared_( 173 : slop_suppression_length_dips_squared_(slop_suppression_length_dips *
175 static_cast<int>(slop_suppression_length_dips) * 174 slop_suppression_length_dips),
176 static_cast<int>(slop_suppression_length_dips)),
177 suppressing_touch_moves_(false) {} 175 suppressing_touch_moves_(false) {}
178 176
179 bool FilterEvent(const WebTouchEvent& event) { 177 bool FilterEvent(const WebTouchEvent& event) {
180 if (WebTouchEventTraits::IsTouchSequenceStart(event)) { 178 if (WebTouchEventTraits::IsTouchSequenceStart(event)) {
181 touch_sequence_start_position_ = 179 touch_sequence_start_position_ =
182 gfx::PointF(event.touches[0].position.x, event.touches[0].position.y); 180 gfx::PointF(event.touches[0].position);
183 suppressing_touch_moves_ = slop_suppression_length_dips_squared_ != 0; 181 suppressing_touch_moves_ = slop_suppression_length_dips_squared_ != 0;
184 } 182 }
185 183
186 if (event.type != WebInputEvent::TouchMove) 184 if (event.type != WebInputEvent::TouchMove)
187 return false; 185 return false;
188 186
189 if (suppressing_touch_moves_) { 187 if (suppressing_touch_moves_) {
190 // Movement with a secondary pointer should terminate suppression. 188 // Movement with a secondary pointer should terminate suppression.
191 if (event.touchesLength > 1) { 189 if (event.touchesLength > 1) {
192 suppressing_touch_moves_ = false; 190 suppressing_touch_moves_ = false;
193 } else if (event.touchesLength == 1) { 191 } else if (event.touchesLength == 1) {
194 // Movement outside of the slop region should terminate suppression. 192 // Movement outside of the slop region should terminate suppression.
195 // TODO(jdduke): Use strict inequality, crbug.com/336807. 193 gfx::PointF position(event.touches[0].position);
196 gfx::PointF position(event.touches[0].position.x, 194 if ((position - touch_sequence_start_position_).LengthSquared() >
197 event.touches[0].position.y); 195 slop_suppression_length_dips_squared_)
198 if ((position - touch_sequence_start_position_).LengthSquared() >=
199 slop_suppression_length_dips_squared_)
200 suppressing_touch_moves_ = false; 196 suppressing_touch_moves_ = false;
201 } 197 }
202 } 198 }
203 return suppressing_touch_moves_; 199 return suppressing_touch_moves_;
204 } 200 }
205 201
206 void ConfirmTouchEvent(InputEventAckState ack_result) { 202 void ConfirmTouchEvent(InputEventAckState ack_result) {
207 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) 203 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED)
208 suppressing_touch_moves_ = false; 204 suppressing_touch_moves_ = false;
209 } 205 }
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 } else if (event.type == WebInputEvent::TouchStart) { 628 } else if (event.type == WebInputEvent::TouchStart) {
633 for (unsigned i = 0; i < event.touchesLength; ++i) { 629 for (unsigned i = 0; i < event.touchesLength; ++i) {
634 const WebTouchPoint& point = event.touches[i]; 630 const WebTouchPoint& point = event.touches[i];
635 if (point.state == WebTouchPoint::StatePressed) 631 if (point.state == WebTouchPoint::StatePressed)
636 touch_ack_states_[point.id] = ack_result; 632 touch_ack_states_[point.id] = ack_result;
637 } 633 }
638 } 634 }
639 } 635 }
640 636
641 } // namespace content 637 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698