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

Side by Side Diff: ui/events/gesture_detection/gesture_provider.cc

Issue 999423003: Set the unique_event_id when converting from TouchEvent to WebTouchEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
« no previous file with comments | « ui/events/events.gyp ('k') | ui/events/gesture_detection/gesture_provider_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/events/gesture_detection/gesture_provider.h" 5 #include "ui/events/gesture_detection/gesture_provider.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 return; 210 return;
211 Send(CreateGesture(ET_GESTURE_PINCH_END, e)); 211 Send(CreateGesture(ET_GESTURE_PINCH_END, e));
212 } 212 }
213 213
214 bool OnScale(const ScaleGestureDetector& detector, 214 bool OnScale(const ScaleGestureDetector& detector,
215 const MotionEvent& e) override { 215 const MotionEvent& e) override {
216 if (ignore_multitouch_zoom_events_ && !detector.InDoubleTapMode()) 216 if (ignore_multitouch_zoom_events_ && !detector.InDoubleTapMode())
217 return false; 217 return false;
218 if (!pinch_event_sent_) { 218 if (!pinch_event_sent_) {
219 Send(CreateGesture(ET_GESTURE_PINCH_BEGIN, 219 Send(CreateGesture(ET_GESTURE_PINCH_BEGIN,
220 e.GetId(), 220 e.GetPointerId(),
221 e.GetToolType(), 221 e.GetToolType(),
222 detector.GetEventTime(), 222 detector.GetEventTime(),
223 detector.GetFocusX(), 223 detector.GetFocusX(),
224 detector.GetFocusY(), 224 detector.GetFocusY(),
225 detector.GetFocusX() + e.GetRawOffsetX(), 225 detector.GetFocusX() + e.GetRawOffsetX(),
226 detector.GetFocusY() + e.GetRawOffsetY(), 226 detector.GetFocusY() + e.GetRawOffsetY(),
227 e.GetPointerCount(), 227 e.GetPointerCount(),
228 GetBoundingBox(e, ET_GESTURE_PINCH_BEGIN), 228 GetBoundingBox(e, ET_GESTURE_PINCH_BEGIN),
229 e.GetFlags())); 229 e.GetFlags()));
230 } 230 }
(...skipping 15 matching lines...) Expand all
246 // the scale delta remains constant if the touch velocity is constant. 246 // the scale delta remains constant if the touch velocity is constant.
247 float dy = 247 float dy =
248 (detector.GetCurrentSpanY() - detector.GetPreviousSpanY()) * 0.5f; 248 (detector.GetCurrentSpanY() - detector.GetPreviousSpanY()) * 0.5f;
249 scale = std::pow(scale > 1 ? 1.0f + kDoubleTapDragZoomSpeed 249 scale = std::pow(scale > 1 ? 1.0f + kDoubleTapDragZoomSpeed
250 : 1.0f - kDoubleTapDragZoomSpeed, 250 : 1.0f - kDoubleTapDragZoomSpeed,
251 std::abs(dy)); 251 std::abs(dy));
252 } 252 }
253 GestureEventDetails pinch_details(ET_GESTURE_PINCH_UPDATE); 253 GestureEventDetails pinch_details(ET_GESTURE_PINCH_UPDATE);
254 pinch_details.set_scale(scale); 254 pinch_details.set_scale(scale);
255 Send(CreateGesture(pinch_details, 255 Send(CreateGesture(pinch_details,
256 e.GetId(), 256 e.GetPointerId(),
257 e.GetToolType(), 257 e.GetToolType(),
258 detector.GetEventTime(), 258 detector.GetEventTime(),
259 detector.GetFocusX(), 259 detector.GetFocusX(),
260 detector.GetFocusY(), 260 detector.GetFocusY(),
261 detector.GetFocusX() + e.GetRawOffsetX(), 261 detector.GetFocusX() + e.GetRawOffsetX(),
262 detector.GetFocusY() + e.GetRawOffsetY(), 262 detector.GetFocusY() + e.GetRawOffsetY(),
263 e.GetPointerCount(), 263 e.GetPointerCount(),
264 GetBoundingBox(e, pinch_details.type()), 264 GetBoundingBox(e, pinch_details.type()),
265 e.GetFlags())); 265 e.GetFlags()));
266 return true; 266 return true;
(...skipping 30 matching lines...) Expand all
297 } 297 }
298 298
299 // Note that scroll start hints are in distance traveled, where 299 // Note that scroll start hints are in distance traveled, where
300 // scroll deltas are in the opposite direction. 300 // scroll deltas are in the opposite direction.
301 GestureEventDetails scroll_details( 301 GestureEventDetails scroll_details(
302 ET_GESTURE_SCROLL_BEGIN, -raw_distance_x, -raw_distance_y); 302 ET_GESTURE_SCROLL_BEGIN, -raw_distance_x, -raw_distance_y);
303 303
304 // Use the co-ordinates from the touch down, as these co-ordinates are 304 // Use the co-ordinates from the touch down, as these co-ordinates are
305 // used to determine which layer the scroll should affect. 305 // used to determine which layer the scroll should affect.
306 Send(CreateGesture(scroll_details, 306 Send(CreateGesture(scroll_details,
307 e2.GetId(), 307 e2.GetPointerId(),
308 e2.GetToolType(), 308 e2.GetToolType(),
309 e2.GetEventTime(), 309 e2.GetEventTime(),
310 e1.GetX(), 310 e1.GetX(),
311 e1.GetY(), 311 e1.GetY(),
312 e1.GetRawX(), 312 e1.GetRawX(),
313 e1.GetRawY(), 313 e1.GetRawY(),
314 e2.GetPointerCount(), 314 e2.GetPointerCount(),
315 GetBoundingBox(e2, scroll_details.type()), 315 GetBoundingBox(e2, scroll_details.type()),
316 e2.GetFlags())); 316 e2.GetFlags()));
317 DCHECK(scroll_event_sent_); 317 DCHECK(scroll_event_sent_);
318 } 318 }
319 319
320 snap_scroll_controller_.UpdateSnapScrollMode(distance_x, distance_y); 320 snap_scroll_controller_.UpdateSnapScrollMode(distance_x, distance_y);
321 if (snap_scroll_controller_.IsSnappingScrolls()) { 321 if (snap_scroll_controller_.IsSnappingScrolls()) {
322 if (snap_scroll_controller_.IsSnapHorizontal()) 322 if (snap_scroll_controller_.IsSnapHorizontal())
323 distance_y = 0; 323 distance_y = 0;
324 else 324 else
325 distance_x = 0; 325 distance_x = 0;
326 } 326 }
327 327
328 if (distance_x || distance_y) { 328 if (distance_x || distance_y) {
329 GestureEventDetails scroll_details( 329 GestureEventDetails scroll_details(
330 ET_GESTURE_SCROLL_UPDATE, -distance_x, -distance_y); 330 ET_GESTURE_SCROLL_UPDATE, -distance_x, -distance_y);
331 const gfx::RectF bounding_box = GetBoundingBox(e2, scroll_details.type()); 331 const gfx::RectF bounding_box = GetBoundingBox(e2, scroll_details.type());
332 const gfx::PointF center = bounding_box.CenterPoint(); 332 const gfx::PointF center = bounding_box.CenterPoint();
333 const gfx::PointF raw_center = 333 const gfx::PointF raw_center =
334 center + gfx::Vector2dF(e2.GetRawOffsetX(), e2.GetRawOffsetY()); 334 center + gfx::Vector2dF(e2.GetRawOffsetX(), e2.GetRawOffsetY());
335 Send(CreateGesture(scroll_details, 335 Send(CreateGesture(scroll_details,
336 e2.GetId(), 336 e2.GetPointerId(),
337 e2.GetToolType(), 337 e2.GetToolType(),
338 e2.GetEventTime(), 338 e2.GetEventTime(),
339 center.x(), 339 center.x(),
340 center.y(), 340 center.y(),
341 raw_center.x(), 341 raw_center.x(),
342 raw_center.y(), 342 raw_center.y(),
343 e2.GetPointerCount(), 343 e2.GetPointerCount(),
344 bounding_box, 344 bounding_box,
345 e2.GetFlags())); 345 e2.GetFlags()));
346 } 346 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 Send(CreateGesture(swipe_details, e2)); 386 Send(CreateGesture(swipe_details, e2));
387 return true; 387 return true;
388 } 388 }
389 389
390 bool OnTwoFingerTap(const MotionEvent& e1, const MotionEvent& e2) override { 390 bool OnTwoFingerTap(const MotionEvent& e1, const MotionEvent& e2) override {
391 // The location of the two finger tap event should be the location of the 391 // The location of the two finger tap event should be the location of the
392 // primary pointer. 392 // primary pointer.
393 GestureEventDetails two_finger_tap_details( 393 GestureEventDetails two_finger_tap_details(
394 ET_GESTURE_TWO_FINGER_TAP, e1.GetTouchMajor(), e1.GetTouchMajor()); 394 ET_GESTURE_TWO_FINGER_TAP, e1.GetTouchMajor(), e1.GetTouchMajor());
395 Send(CreateGesture(two_finger_tap_details, 395 Send(CreateGesture(two_finger_tap_details,
396 e2.GetId(), 396 e2.GetPointerId(),
397 e2.GetToolType(), 397 e2.GetToolType(),
398 e2.GetEventTime(), 398 e2.GetEventTime(),
399 e1.GetX(), 399 e1.GetX(),
400 e1.GetY(), 400 e1.GetY(),
401 e1.GetRawX(), 401 e1.GetRawX(),
402 e1.GetRawY(), 402 e1.GetRawY(),
403 e2.GetPointerCount(), 403 e2.GetPointerCount(),
404 GetBoundingBox(e2, two_finger_tap_details.type()), 404 GetBoundingBox(e2, two_finger_tap_details.type()),
405 e2.GetFlags())); 405 e2.GetFlags()));
406 return true; 406 return true;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 raw_x, 534 raw_x,
535 raw_y, 535 raw_y,
536 touch_point_count, 536 touch_point_count,
537 bounding_box, 537 bounding_box,
538 flags); 538 flags);
539 } 539 }
540 540
541 GestureEventData CreateGesture(const GestureEventDetails& details, 541 GestureEventData CreateGesture(const GestureEventDetails& details,
542 const MotionEvent& event) { 542 const MotionEvent& event) {
543 return GestureEventData(details, 543 return GestureEventData(details,
544 event.GetId(), 544 event.GetPointerId(),
545 event.GetToolType(), 545 event.GetToolType(),
546 event.GetEventTime(), 546 event.GetEventTime(),
547 event.GetX(), 547 event.GetX(),
548 event.GetY(), 548 event.GetY(),
549 event.GetRawX(), 549 event.GetRawX(),
550 event.GetRawY(), 550 event.GetRawY(),
551 event.GetPointerCount(), 551 event.GetPointerCount(),
552 GetBoundingBox(event, details.type()), 552 GetBoundingBox(event, details.type()),
553 event.GetFlags()); 553 event.GetFlags());
554 } 554 }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 current_down_event_ = event.Clone(); 765 current_down_event_ = event.Clone();
766 if (gesture_begin_end_types_enabled_) 766 if (gesture_begin_end_types_enabled_)
767 gesture_listener_->Send( 767 gesture_listener_->Send(
768 gesture_listener_->CreateGesture(ET_GESTURE_BEGIN, event)); 768 gesture_listener_->CreateGesture(ET_GESTURE_BEGIN, event));
769 break; 769 break;
770 case MotionEvent::ACTION_POINTER_DOWN: 770 case MotionEvent::ACTION_POINTER_DOWN:
771 if (gesture_begin_end_types_enabled_) { 771 if (gesture_begin_end_types_enabled_) {
772 const int action_index = event.GetActionIndex(); 772 const int action_index = event.GetActionIndex();
773 gesture_listener_->Send(gesture_listener_->CreateGesture( 773 gesture_listener_->Send(gesture_listener_->CreateGesture(
774 ET_GESTURE_BEGIN, 774 ET_GESTURE_BEGIN,
775 event.GetId(), 775 event.GetPointerId(),
776 event.GetToolType(), 776 event.GetToolType(),
777 event.GetEventTime(), 777 event.GetEventTime(),
778 event.GetX(action_index), 778 event.GetX(action_index),
779 event.GetY(action_index), 779 event.GetY(action_index),
780 event.GetRawX(action_index), 780 event.GetRawX(action_index),
781 event.GetRawY(action_index), 781 event.GetRawY(action_index),
782 event.GetPointerCount(), 782 event.GetPointerCount(),
783 gesture_listener_->GetBoundingBox(event, ET_GESTURE_BEGIN), 783 gesture_listener_->GetBoundingBox(event, ET_GESTURE_BEGIN),
784 event.GetFlags())); 784 event.GetFlags()));
785 } 785 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 // null'ing of the listener until the sequence has ended. 823 // null'ing of the listener until the sequence has ended.
824 if (current_down_event_) 824 if (current_down_event_)
825 return; 825 return;
826 826
827 const bool double_tap_enabled = 827 const bool double_tap_enabled =
828 double_tap_support_for_page_ && double_tap_support_for_platform_; 828 double_tap_support_for_page_ && double_tap_support_for_platform_;
829 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled); 829 gesture_listener_->SetDoubleTapEnabled(double_tap_enabled);
830 } 830 }
831 831
832 } // namespace ui 832 } // namespace ui
OLDNEW
« no previous file with comments | « ui/events/events.gyp ('k') | ui/events/gesture_detection/gesture_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698