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

Unified Diff: ui/views/widget/root_view.cc

Issue 481433006: Support targeting for gestures in ViewTargeter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: whitespace Created 6 years, 4 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
« ui/views/widget/root_view.h ('K') | « ui/views/widget/root_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/widget/root_view.cc
diff --git a/ui/views/widget/root_view.cc b/ui/views/widget/root_view.cc
index 5bf3248067b951134b1c8977a659bdf29fec9214..fdd4bef68d783f5528c7a19583dc8d9b012615d4 100644
--- a/ui/views/widget/root_view.cc
+++ b/ui/views/widget/root_view.cc
@@ -20,7 +20,6 @@
#include "ui/views/focus/view_storage.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/view_targeter.h"
-#include "ui/views/views_switches.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
@@ -159,6 +158,7 @@ RootView::RootView(Widget* widget)
last_mouse_event_x_(-1),
last_mouse_event_y_(-1),
gesture_handler_(NULL),
+ dispatch_to_gesture_handler_(false),
pre_dispatch_handler_(new internal::PreEventDispatchHandler(this)),
post_dispatch_handler_(new internal::PostEventDispatchHandler),
focus_search_(this, false, false),
@@ -284,6 +284,11 @@ ui::EventDispatchDetails RootView::OnEventFromSource(ui::Event* event) {
return DispatchDetails();
}
+ // If |gesture_handler_| is non-null (as a result of dispatching a previous
+ // gesture event), then |gesture_event| should be dispatched to
+ // |gesture_handler_|.
+ dispatch_to_gesture_handler_ = gesture_handler_ ? true : false;
+
DispatchGestureEvent(gesture_event);
return DispatchDetails();
}
@@ -679,9 +684,9 @@ void RootView::DispatchGestureEvent(ui::GestureEvent* event) {
// process scroll-gesture events. In such case, we allow the event to
// bubble up. |gesture_handler_| is changed to its nearest ancestor
// that handles scroll-gesture events.
- for (gesture_handler_ = gesture_handler_->parent();
- gesture_handler_ && gesture_handler_ != this;
- gesture_handler_ = gesture_handler_->parent()) {
+ gesture_handler_ = static_cast<View*>(
+ targeter()->FindNextBestTarget(gesture_handler_, event));
+ while (gesture_handler_ && gesture_handler_ != this) {
ui::GestureEvent gesture_event(*event,
static_cast<View*>(this),
gesture_handler_);
@@ -697,6 +702,8 @@ void RootView::DispatchGestureEvent(ui::GestureEvent* event) {
dispatch_details.target_destroyed) {
return;
}
+ gesture_handler_ = static_cast<View*>(
+ targeter()->FindNextBestTarget(gesture_handler_, event));
}
gesture_handler_ = NULL;
}
@@ -704,23 +711,10 @@ void RootView::DispatchGestureEvent(ui::GestureEvent* event) {
return;
}
- View* gesture_handler = NULL;
- if (views::switches::IsRectBasedTargetingEnabled() &&
- !event->details().bounding_box().IsEmpty()) {
- // TODO(tdanderson): Pass in the bounding box to GetEventHandlerForRect()
- // once crbug.com/313392 is resolved.
- gfx::Rect touch_rect(event->details().bounding_box());
- touch_rect.set_origin(event->location());
- touch_rect.Offset(-touch_rect.width() / 2, -touch_rect.height() / 2);
- gesture_handler = GetEventHandlerForRect(touch_rect);
- } else {
- gesture_handler = GetEventHandlerForPoint(event->location());
- }
-
// Walk up the tree until we find a view that wants the gesture event.
- for (gesture_handler_ = gesture_handler;
- gesture_handler_ && (gesture_handler_ != this);
- gesture_handler_ = gesture_handler_->parent()) {
+ gesture_handler_ =
+ static_cast<View*>(targeter()->FindTargetForEvent(this, event));
+ while (gesture_handler_ && gesture_handler_ != this) {
// Disabled views are permitted to be targets of gesture events, but
// gesture events should never actually be dispatched to them.
if (!gesture_handler_->enabled()) {
@@ -765,6 +759,8 @@ void RootView::DispatchGestureEvent(ui::GestureEvent* event) {
// The gesture event wasn't processed. Go up the view hierarchy and
// dispatch the gesture event.
+ gesture_handler_ = static_cast<View*>(
+ targeter()->FindNextBestTarget(gesture_handler_, event));
}
gesture_handler_ = NULL;
« ui/views/widget/root_view.h ('K') | « ui/views/widget/root_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698