| 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 4deeba2580f3a7a72928cd3cec30f4a401aa2f18..149b8235d6b5f050d1c1d279854c2958cc63c806 100644
|
| --- a/ui/events/gesture_detection/gesture_provider.cc
|
| +++ b/ui/events/gesture_detection/gesture_provider.cc
|
| @@ -31,30 +31,40 @@ const char* GetMotionEventActionName(MotionEvent::Action action) {
|
| }
|
|
|
| GestureEventData CreateGesture(EventType type,
|
| + int motion_event_id,
|
| base::TimeTicks time,
|
| float x,
|
| float y,
|
| const GestureEventDetails& details) {
|
| - return GestureEventData(type, time, x, y, details);
|
| + return GestureEventData(type, motion_event_id, time, x, y, details);
|
| }
|
|
|
| GestureEventData CreateGesture(EventType type,
|
| + int motion_event_id,
|
| base::TimeTicks time,
|
| float x,
|
| float y) {
|
| - return GestureEventData(type, time, x, y);
|
| - }
|
| + return GestureEventData(type, motion_event_id, time, x, y);
|
| +}
|
|
|
| GestureEventData CreateGesture(EventType type,
|
| const MotionEvent& event,
|
| const GestureEventDetails& details) {
|
| - return CreateGesture(
|
| - type, event.GetEventTime(), event.GetX(), event.GetY(), details);
|
| + return GestureEventData(type,
|
| + event.GetId(),
|
| + event.GetEventTime(),
|
| + event.GetX(),
|
| + event.GetY(),
|
| + details);
|
| }
|
|
|
| GestureEventData CreateGesture(EventType type,
|
| const MotionEvent& event) {
|
| - return CreateGesture(type, event.GetEventTime(), event.GetX(), event.GetY());
|
| + return CreateGesture(type,
|
| + event.GetId(),
|
| + event.GetEventTime(),
|
| + event.GetX(),
|
| + event.GetY());
|
| }
|
|
|
| float Round(float f) {
|
| @@ -105,27 +115,34 @@ class GestureProvider::ScaleGestureListenerImpl
|
| }
|
|
|
| // ScaleGestureDetector::ScaleGestureListener implementation.
|
| - virtual bool OnScaleBegin(const ScaleGestureDetector& detector) OVERRIDE {
|
| + virtual bool OnScaleBegin(const ScaleGestureDetector& detector,
|
| + const MotionEvent& e) OVERRIDE {
|
| if (ignore_detector_events_)
|
| return false;
|
| pinch_event_sent_ = false;
|
| return true;
|
| }
|
|
|
| - virtual void OnScaleEnd(const ScaleGestureDetector& detector) OVERRIDE {
|
| + virtual void OnScaleEnd(const ScaleGestureDetector& detector,
|
| + const MotionEvent& e) OVERRIDE {
|
| if (!pinch_event_sent_)
|
| return;
|
| - provider_->Send(
|
| - CreateGesture(ET_GESTURE_PINCH_END, detector.GetEventTime(), 0, 0));
|
| + provider_->Send(CreateGesture(ET_GESTURE_PINCH_END,
|
| + e.GetId(),
|
| + detector.GetEventTime(),
|
| + 0,
|
| + 0));
|
| pinch_event_sent_ = false;
|
| }
|
|
|
| - virtual bool OnScale(const ScaleGestureDetector& detector) OVERRIDE {
|
| + virtual bool OnScale(const ScaleGestureDetector& detector,
|
| + const MotionEvent& e) OVERRIDE {
|
| if (ignore_detector_events_)
|
| return false;
|
| if (!pinch_event_sent_) {
|
| pinch_event_sent_ = true;
|
| provider_->Send(CreateGesture(ET_GESTURE_PINCH_BEGIN,
|
| + e.GetId(),
|
| detector.GetEventTime(),
|
| detector.GetFocusX(),
|
| detector.GetFocusY()));
|
| @@ -133,6 +150,7 @@ class GestureProvider::ScaleGestureListenerImpl
|
| GestureEventDetails pinch_details(
|
| ET_GESTURE_PINCH_UPDATE, detector.GetScaleFactor(), 0);
|
| provider_->Send(CreateGesture(ET_GESTURE_PINCH_UPDATE,
|
| + e.GetId(),
|
| detector.GetEventTime(),
|
| detector.GetFocusX(),
|
| detector.GetFocusY(),
|
| @@ -275,6 +293,7 @@ class GestureProvider::GestureListenerImpl
|
| GestureEventDetails scroll_details(
|
| ET_GESTURE_SCROLL_BEGIN, -raw_distance_x, -raw_distance_y);
|
| provider_->Send(CreateGesture(ET_GESTURE_SCROLL_BEGIN,
|
| + e2.GetId(),
|
| e2.GetEventTime(),
|
| e1.GetX(),
|
| e1.GetY(),
|
| @@ -314,8 +333,12 @@ class GestureProvider::GestureListenerImpl
|
| }
|
| }
|
|
|
| - provider_->Fling(
|
| - e2.GetEventTime(), e1.GetX(), e1.GetY(), velocity_x, velocity_y);
|
| + provider_->Fling(e2.GetEventTime(),
|
| + e2.GetId(),
|
| + e1.GetX(),
|
| + e1.GetY(),
|
| + velocity_x,
|
| + velocity_y);
|
| return true;
|
| }
|
|
|
| @@ -403,10 +426,11 @@ class GestureProvider::GestureListenerImpl
|
| if (IsDistanceGreaterThanTouchSlop(distance_x, distance_y)) {
|
| GestureEventDetails scroll_details(
|
| ET_GESTURE_SCROLL_BEGIN, -distance_x, -distance_y);
|
| - provider_->Send(
|
| - CreateGesture(ET_GESTURE_SCROLL_BEGIN, e, scroll_details));
|
| + provider_->Send(CreateGesture(
|
| + ET_GESTURE_SCROLL_BEGIN, e, scroll_details));
|
| provider_->Send(
|
| CreateGesture(ET_GESTURE_PINCH_BEGIN,
|
| + e.GetId(),
|
| e.GetEventTime(),
|
| Round(double_tap_drag_zoom_anchor_x_),
|
| Round(double_tap_drag_zoom_anchor_y_)));
|
| @@ -421,6 +445,7 @@ class GestureProvider::GestureListenerImpl
|
| std::abs(dy * px_to_dp_));
|
| GestureEventDetails pinch_details(ET_GESTURE_PINCH_UPDATE, scale, 0);
|
| provider_->Send(CreateGesture(ET_GESTURE_PINCH_UPDATE,
|
| + e.GetId(),
|
| e.GetEventTime(),
|
| Round(double_tap_drag_zoom_anchor_x_),
|
| Round(double_tap_drag_zoom_anchor_y_),
|
| @@ -637,7 +662,7 @@ bool GestureProvider::OnTouchEvent(const MotionEvent& event) {
|
| // "Last finger raised" could be an end to movement, but it should
|
| // only terminate scrolling if the event did not cause a fling.
|
| if (was_touch_scrolling_ && !handled)
|
| - EndTouchScrollIfNecessary(event.GetEventTime(), true);
|
| + EndTouchScrollIfNecessary(event.GetEventTime(), event.GetId(), true);
|
|
|
| // We shouldn't necessarily cancel a tap on ACTION_UP, as the double-tap
|
| // timeout may yet trigger a SINGLE_TAP.
|
| @@ -703,12 +728,13 @@ bool GestureProvider::CanHandle(const MotionEvent& event) const {
|
| }
|
|
|
| void GestureProvider::Fling(base::TimeTicks time,
|
| + int motion_event_id,
|
| float x,
|
| float y,
|
| float velocity_x,
|
| float velocity_y) {
|
| if (!velocity_x && !velocity_y) {
|
| - EndTouchScrollIfNecessary(time, true);
|
| + EndTouchScrollIfNecessary(time, motion_event_id, true);
|
| return;
|
| }
|
|
|
| @@ -719,13 +745,15 @@ void GestureProvider::Fling(base::TimeTicks time,
|
| // start hint.
|
| GestureEventDetails scroll_details(
|
| ET_GESTURE_SCROLL_BEGIN, velocity_x, velocity_y);
|
| - Send(CreateGesture(ET_GESTURE_SCROLL_BEGIN, time, x, y, scroll_details));
|
| + Send(CreateGesture(
|
| + ET_GESTURE_SCROLL_BEGIN, motion_event_id, time, x, y, scroll_details));
|
| }
|
| - EndTouchScrollIfNecessary(time, false);
|
| + EndTouchScrollIfNecessary(time, motion_event_id, false);
|
|
|
| GestureEventDetails fling_details(
|
| ET_SCROLL_FLING_START, velocity_x, velocity_y);
|
| - Send(CreateGesture(ET_SCROLL_FLING_START, time, x, y, fling_details));
|
| + Send(CreateGesture(
|
| + ET_SCROLL_FLING_START, motion_event_id, time, x, y, fling_details));
|
| }
|
|
|
| void GestureProvider::Send(const GestureEventData& gesture) {
|
| @@ -745,8 +773,11 @@ void GestureProvider::Send(const GestureEventData& gesture) {
|
| break;
|
| case ET_GESTURE_TAP:
|
| if (needs_show_press_event_)
|
| - Send(CreateGesture(
|
| - ET_GESTURE_SHOW_PRESS, gesture.time, gesture.x, gesture.y));
|
| + Send(CreateGesture(ET_GESTURE_SHOW_PRESS,
|
| + gesture.motion_event_id,
|
| + gesture.time,
|
| + gesture.x,
|
| + gesture.y));
|
| needs_tap_ending_event_ = false;
|
| break;
|
| case ET_GESTURE_DOUBLE_TAP:
|
| @@ -770,7 +801,7 @@ void GestureProvider::Send(const GestureEventData& gesture) {
|
| break;
|
| case ET_GESTURE_SCROLL_BEGIN:
|
| touch_scroll_in_progress_ = true;
|
| - SendTapCancelIfNecessary(*current_down_event_);
|
| + SendTapCancelIfNecessary(gesture);
|
| break;
|
| case ET_GESTURE_SCROLL_END:
|
| touch_scroll_in_progress_ = false;
|
| @@ -795,6 +826,18 @@ void GestureProvider::SendTapCancelIfNecessary(const MotionEvent& event) {
|
| Send(CreateGesture(ET_GESTURE_TAP_CANCEL, event));
|
| }
|
|
|
| +void GestureProvider::SendTapCancelIfNecessary(
|
| + const GestureEventData& gesture) {
|
| + if (!needs_tap_ending_event_)
|
| + return;
|
| + current_longpress_time_ = base::TimeTicks();
|
| + Send(CreateGesture(ET_GESTURE_TAP_CANCEL,
|
| + gesture.motion_event_id,
|
| + gesture.time,
|
| + gesture.x,
|
| + gesture.y));
|
| +}
|
| +
|
| bool GestureProvider::SendLongTapIfNecessary(const MotionEvent& event) {
|
| if (event.GetAction() == MotionEvent::ACTION_UP &&
|
| !current_longpress_time_.is_null() &&
|
| @@ -810,12 +853,13 @@ bool GestureProvider::SendLongTapIfNecessary(const MotionEvent& event) {
|
| }
|
|
|
| void GestureProvider::EndTouchScrollIfNecessary(base::TimeTicks time,
|
| + int motion_event_id,
|
| bool send_scroll_end_event) {
|
| if (!touch_scroll_in_progress_)
|
| return;
|
| touch_scroll_in_progress_ = false;
|
| if (send_scroll_end_event)
|
| - Send(CreateGesture(ET_GESTURE_SCROLL_END, time, 0, 0));
|
| + Send(CreateGesture(ET_GESTURE_SCROLL_END, motion_event_id, time, 0, 0));
|
| }
|
|
|
| } // namespace ui
|
|
|