Chromium Code Reviews| Index: views/widget/root_view.cc |
| diff --git a/views/widget/root_view.cc b/views/widget/root_view.cc |
| index b4467f490ca0c41a88cd4b179ea8db0066e88a84..5672e7a7b00364c2b8168819b3d03ac18fdbdfde 100644 |
| --- a/views/widget/root_view.cc |
| +++ b/views/widget/root_view.cc |
| @@ -6,8 +6,10 @@ |
| #include <algorithm> |
| +#include "base/command_line.h" |
| #include "base/logging.h" |
| #include "base/message_loop.h" |
| +#include "chrome/common/chrome_switches.h" |
| #include "ui/base/accessibility/accessible_view_state.h" |
| #include "ui/base/dragdrop/drag_drop_types.h" |
| #include "ui/base/keycodes/keyboard_codes.h" |
| @@ -38,11 +40,16 @@ RootView::RootView(Widget* widget) |
| last_mouse_event_flags_(0), |
| last_mouse_event_x_(-1), |
| last_mouse_event_y_(-1), |
| - gesture_manager_(GestureManager::GetInstance()), |
| + gesture_manager_(NULL), |
| touch_pressed_handler_(NULL), |
| + gesture_handler_(NULL), |
| ALLOW_THIS_IN_INITIALIZER_LIST(focus_search_(this, false, false)), |
| focus_traversable_parent_(NULL), |
| focus_traversable_parent_view_(NULL) { |
| + if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableGesture)) |
|
rjkroege
2011/11/01 18:42:22
I don't think you want to do it this way.
My pre
Gajen
2011/11/02 12:59:35
Currently is it done same way in GR's PTEFG, where
rjkroege
2011/11/04 17:19:28
Currently, we have the following: RootView::OnTouc
Gajen
2011/11/08 08:11:44
Look promising and Great.
Can we push current impl
|
| + gesture_manager_ = GestureRecognizer::GetInstance(); |
| + else |
| + gesture_manager_ = GestureManager::GetInstance(); |
| } |
| RootView::~RootView() { |
| @@ -400,6 +407,52 @@ void RootView::GetAccessibleState(ui::AccessibleViewState* state) { |
| state->role = ui::AccessibilityTypes::ROLE_APPLICATION; |
| } |
| +bool RootView::ForwardGestureEvents(GestureRecognizer::Gestures* gestures) { |
| + scoped_ptr<GestureRecognizer::Gestures> events; |
| + events.reset(gestures); |
| + bool return_value = false; |
| + for (unsigned int i = 0; i < events->size(); i++) { |
| + GestureEvent* event = gestures->at(i).GetGestureEvent(); |
| + GestureEvent e(*event, this); |
| + |
| + ui::GestureStatus status = ui::GESTURE_STATUS_UNKNOWN; |
| + |
| + // Walk up the tree until we find a view that wants the gesture event. |
| + for (gesture_handler_ = GetEventHandlerForPoint(e.location()); |
| + gesture_handler_ && (gesture_handler_ != this); |
| + gesture_handler_ = gesture_handler_->parent()) { |
| + if (!gesture_handler_->IsEnabled()) { |
| + // Disabled views eat events but are treated as not handled by the |
| + // the GestureManager. |
| + status = ui::GESTURE_STATUS_UNKNOWN; |
| + break; |
| + } |
| + |
| + // See if this view wants to handle the Gesture. |
| + GestureEvent gesture_event(e, this, gesture_handler_); |
| + status = gesture_handler_->ProcessGestureEvent(gesture_event); |
|
rjkroege
2011/11/01 18:42:22
see comment about gesture_handler_ -- please renam
Gajen
2011/11/08 08:11:44
Done.
|
| + |
| + // The view could have removed itself from the tree when handling |
| + // OnGestureEvent(). So handle as per OnMousePressed. NB: we |
| + // assume that the RootView itself cannot be so removed. |
| + if (!gesture_handler_) |
| + break; |
| + |
| + // The gesture event wasn't processed. Go up the view hierarchy and |
| + // dispatch the gesture event. |
| + if (status == ui::GESTURE_STATUS_UNKNOWN) { |
| + continue; |
| + } else if (status == ui::GESTURE_STATUS_CONSUMED) { |
| + return_value = true; |
| + } else { |
| + return_value = false; |
| + } |
| + } |
| + if (!return_value) return false; |
| + } |
| + return return_value; |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // RootView, protected: |
| @@ -413,6 +466,8 @@ void RootView::ViewHierarchyChanged(bool is_add, View* parent, View* child) { |
| mouse_move_handler_ = NULL; |
| if (touch_pressed_handler_ == child) |
| touch_pressed_handler_ = NULL; |
| + if (gesture_handler_ == child) |
| + gesture_handler_ = NULL; |
| } |
| } |