Chromium Code Reviews| Index: ui/views/widget/root_view.cc |
| diff --git a/ui/views/widget/root_view.cc b/ui/views/widget/root_view.cc |
| index 2e799a8f2324b16b68e29a426cbc8beb5646d2c9..c5b189cefb8722f430a9373719058e4e95f3a05a 100644 |
| --- a/ui/views/widget/root_view.cc |
| +++ b/ui/views/widget/root_view.cc |
| @@ -452,9 +452,55 @@ ui::TouchStatus RootView::OnTouchEvent(const TouchEvent& event) { |
| } |
| ui::GestureStatus RootView::OnGestureEvent(const GestureEvent& event) { |
| - GestureEvent e(event, this); |
|
sadrul
2012/07/18 23:42:31
This creates an event to take RootView's transform
tdanderson
2012/07/25 23:08:57
Okay, I will put |e| back in for this CL.
|
| ui::GestureStatus status = ui::GESTURE_STATUS_UNKNOWN; |
| + // TODO(tdanderson): Store radius values for a ui::ET_GESTURE_LONG_PRESS |
| + // event so that fuzzing may also be used for a long press. |
| + if (event.type() == ui::ET_GESTURE_TAP) { |
| + float radius = event.details().radius_x(); |
| + gfx::Point adjusted_loc(event.x() - radius, event.y() - radius); |
| + ConvertPointToScreen(this, &adjusted_loc); |
| + gfx::Rect touch_rect(adjusted_loc.x(), |
| + adjusted_loc.y(), |
| + radius * 2, |
| + radius * 2); |
| + |
| + // If |new_gesture_handler| is not NULL, it should handle the tap event. |
| + // Screen coordinates are used to eliminate the overhead of switching |
| + // between parent/child coordinate systems in View::GetEventHandlerForRect. |
| + View* new_gesture_handler = GetEventHandlerForRect(touch_rect); |
| + if (new_gesture_handler) { |
| + if (!gesture_handler_) |
|
sadrul
2012/07/18 23:42:31
brace
tdanderson
2012/07/25 23:08:57
Done.
|
| + gesture_handler_ = new_gesture_handler; |
| + else if (gesture_handler_ != new_gesture_handler) { |
| + // Send an ET_GESTURE_END event to the original handler |
| + GestureEvent end_event(ui::ET_GESTURE_END, |
| + event.x(), |
| + event.y(), |
| + event.flags()); |
| + gesture_handler_->ProcessGestureEvent(end_event); |
| + |
| + // Send ET_GESTURE_BEGIN and ET_GESTURE_TAP_DOWN events to the new |
| + // handler before processing the ET_GESTURE_TAP event. |
| + gfx::Rect new_handler_bounds(new_gesture_handler->GetScreenBounds()); |
| + gfx::Point new_center(new_handler_bounds.CenterPoint()); |
| + ConvertPointFromScreen(this, &new_center); |
| + GestureEvent begin_event(ui::ET_GESTURE_BEGIN, |
|
tdanderson
2012/07/18 22:35:42
sadrul@: you mentioned that I should make sure the
sadrul
2012/07/18 23:42:31
Yes. You need to update GestureEvent::details_ to
tdanderson
2012/07/25 23:08:57
This will no longer be relevant in the next CL.
|
| + new_center.x(), |
| + new_center.y(), |
| + event.flags()); |
| + new_gesture_handler->ProcessGestureEvent(begin_event); |
| + GestureEvent tap_down_event(ui::ET_GESTURE_TAP_DOWN, |
| + new_center.x(), |
| + new_center.y(), |
| + event.flags()); |
| + new_gesture_handler->ProcessGestureEvent(tap_down_event); |
| + |
| + gesture_handler_ = new_gesture_handler; |
| + } |
| + } |
| + } |
| + |
| if (gesture_handler_) { |
| // |gesture_handler_| (or |scroll_gesture_handler_|) can be deleted during |
| // processing. |
| @@ -485,7 +531,7 @@ ui::GestureStatus RootView::OnGestureEvent(const GestureEvent& event) { |
| for (scroll_gesture_handler_ = gesture_handler_->parent(); |
| scroll_gesture_handler_ && scroll_gesture_handler_ != this; |
| scroll_gesture_handler_ = scroll_gesture_handler_->parent()) { |
| - GestureEvent gesture_event(e, this, scroll_gesture_handler_); |
| + GestureEvent gesture_event(event, this, scroll_gesture_handler_); |
| status = scroll_gesture_handler_->ProcessGestureEvent(gesture_event); |
| if (status == ui::GESTURE_STATUS_CONSUMED) |
| return status; |
| @@ -494,10 +540,11 @@ ui::GestureStatus RootView::OnGestureEvent(const GestureEvent& event) { |
| } |
| return ui::GESTURE_STATUS_UNKNOWN; |
| + |
|
sadrul
2012/07/18 23:42:31
-
tdanderson
2012/07/25 23:08:57
Done.
|
| } |
| // Walk up the tree until we find a view that wants the gesture event. |
| - for (gesture_handler_ = GetEventHandlerForPoint(e.location()); |
| + for (gesture_handler_ = GetEventHandlerForPoint(event.location()); |
| gesture_handler_ && (gesture_handler_ != this); |
| gesture_handler_ = gesture_handler_->parent()) { |
| if (!gesture_handler_->enabled()) { |
| @@ -506,7 +553,7 @@ ui::GestureStatus RootView::OnGestureEvent(const GestureEvent& event) { |
| } |
| // See if this view wants to handle the Gesture. |
| - GestureEvent gesture_event(e, this, gesture_handler_); |
| + GestureEvent gesture_event(event, this, gesture_handler_); |
| status = gesture_handler_->ProcessGestureEvent(gesture_event); |
| // The view could have removed itself from the tree when handling |