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

Unified Diff: ui/events/gesture_detection/gesture_provider.cc

Issue 227743007: ui::GestureProvider gives GestureEventData the number of touch points. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No more compiler errors. Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: ui/events/gesture_detection/gesture_provider.cc
diff --git a/ui/events/gesture_detection/gesture_provider.cc b/ui/events/gesture_detection/gesture_provider.cc
index 6c581febd91294374a308c53e6675d7bec098932..d675a4752677da84899c1554b21769f4abc7f819 100644
--- a/ui/events/gesture_detection/gesture_provider.cc
+++ b/ui/events/gesture_detection/gesture_provider.cc
@@ -35,16 +35,24 @@ GestureEventData CreateGesture(EventType type,
base::TimeTicks time,
float x,
float y,
+ size_t touch_point_count,
const GestureEventDetails& details) {
jdduke (slow) 2014/04/08 21:07:41 Might as well pass this by value, then you can cal
tdresser 2014/04/09 14:50:48 I'm still passing by reference, based on the chang
- return GestureEventData(type, motion_event_id, time, x, y, details);
+ DCHECK_NE(0u, touch_point_count);
+ GestureEventDetails d = details;
+ d.set_touch_points(touch_point_count);
+ return GestureEventData(type, motion_event_id, time, x, y, d);
}
GestureEventData CreateGesture(EventType type,
int motion_event_id,
base::TimeTicks time,
float x,
- float y) {
- return GestureEventData(type, motion_event_id, time, x, y);
+ float y,
+ size_t touch_point_count) {
+ DCHECK_NE(0u, touch_point_count);
+ GestureEventDetails details;
+ details.set_touch_points(touch_point_count);
+ return GestureEventData(type, motion_event_id, time, x, y, details);
jdduke (slow) 2014/04/08 21:07:41 Hmm, now that we only use one constructor for Gest
tdresser 2014/04/09 14:50:48 Is this what you were thinking?
}
GestureEventData CreateGesture(EventType type,
@@ -55,13 +63,18 @@ GestureEventData CreateGesture(EventType type,
event.GetEventTime(),
event.GetX(),
event.GetY(),
+ event.GetPointerCount(),
details);
}
GestureEventData CreateGesture(EventType type,
const MotionEvent& event) {
- return CreateGesture(
- type, event.GetId(), event.GetEventTime(), event.GetX(), event.GetY());
+ return CreateGesture(type,
+ event.GetId(),
+ event.GetEventTime(),
+ event.GetX(),
+ event.GetY(),
+ event.GetPointerCount());
}
GestureEventDetails CreateTapGestureDetails(EventType type,
@@ -123,8 +136,12 @@ class GestureProvider::ScaleGestureListenerImpl
const MotionEvent& e) OVERRIDE {
if (!pinch_event_sent_)
return;
- provider_->Send(CreateGesture(
- ET_GESTURE_PINCH_END, e.GetId(), detector.GetEventTime(), 0, 0));
+ provider_->Send(CreateGesture(ET_GESTURE_PINCH_END,
+ e.GetId(),
+ detector.GetEventTime(),
+ 0,
+ 0,
+ e.GetPointerCount()));
pinch_event_sent_ = false;
}
@@ -138,7 +155,8 @@ class GestureProvider::ScaleGestureListenerImpl
e.GetId(),
detector.GetEventTime(),
detector.GetFocusX(),
- detector.GetFocusY()));
+ detector.GetFocusY(),
+ e.GetPointerCount()));
}
float scale = detector.GetScaleFactor();
@@ -163,6 +181,7 @@ class GestureProvider::ScaleGestureListenerImpl
detector.GetEventTime(),
detector.GetFocusX(),
detector.GetFocusY(),
+ e.GetPointerCount(),
pinch_details));
return true;
}
@@ -274,6 +293,9 @@ class GestureProvider::GestureListenerImpl
const MotionEvent& e2,
float raw_distance_x,
float raw_distance_y) OVERRIDE {
+ DCHECK_NE(0u, e1.GetPointerCount());
+ DCHECK_NE(0u, e2.GetPointerCount());
+
float distance_x = raw_distance_x;
float distance_y = raw_distance_y;
if (!seen_first_scroll_event_) {
@@ -305,12 +327,8 @@ class GestureProvider::GestureListenerImpl
// scroll deltas are in the opposite direction.
GestureEventDetails scroll_details(
ET_GESTURE_SCROLL_BEGIN, -raw_distance_x, -raw_distance_y);
- provider_->Send(CreateGesture(ET_GESTURE_SCROLL_BEGIN,
- e2.GetId(),
- e2.GetEventTime(),
jdduke (slow) 2014/04/08 21:07:41 This is a change in behavior. GestureScrollBegin
tdresser 2014/04/09 14:50:48 Done.
- e1.GetX(),
- e1.GetY(),
- scroll_details));
+ provider_->Send(
+ CreateGesture(ET_GESTURE_SCROLL_BEGIN, e2, scroll_details));
}
// distance_x and distance_y is the scrolling offset since last OnScroll.
@@ -544,6 +562,9 @@ GestureProvider::~GestureProvider() {}
bool GestureProvider::OnTouchEvent(const MotionEvent& event) {
TRACE_EVENT1("input", "GestureProvider::OnTouchEvent",
"action", GetMotionEventActionName(event.GetAction()));
+
+ DCHECK_NE(0u, event.GetPointerCount());
+
if (!CanHandle(event))
return false;
@@ -667,7 +688,8 @@ void GestureProvider::Send(const GestureEventData& gesture) {
gesture.motion_event_id,
gesture.time,
gesture.x,
- gesture.y));
+ gesture.y,
+ gesture.details.touch_points()));
needs_tap_ending_event_ = false;
break;
case ET_GESTURE_DOUBLE_TAP:
@@ -702,7 +724,8 @@ void GestureProvider::Send(const GestureEventData& gesture) {
gesture.motion_event_id,
gesture.time,
gesture.x,
- gesture.y));
+ gesture.y,
+ gesture.details.touch_points()));
pinch_in_progress_ = true;
break;
case ET_GESTURE_PINCH_END:
@@ -731,7 +754,8 @@ void GestureProvider::SendTapCancelIfNecessary(
gesture.motion_event_id,
gesture.time,
gesture.x,
- gesture.y));
+ gesture.y,
+ gesture.details.touch_points()));
}
bool GestureProvider::SendLongTapIfNecessary(const MotionEvent& event) {

Powered by Google App Engine
This is Rietveld 408576698