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

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

Issue 22891016: Add support for rect-based event targeting in views (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch for landing Created 7 years, 1 month 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
« no previous file with comments | « ui/views/views_switches.cc ('k') | ui/views/window/non_client_view.h » ('j') | 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 95f94dc31076afd42e9f183222741392408b2ea7..14facd2971996dd26593614144da9d9f3aac31e9 100644
--- a/ui/views/widget/root_view.cc
+++ b/ui/views/widget/root_view.cc
@@ -16,6 +16,7 @@
#include "ui/gfx/canvas.h"
#include "ui/views/focus/view_storage.h"
#include "ui/views/layout/fill_layout.h"
+#include "ui/views/views_switches.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/widget/widget_deletion_observer.h"
@@ -286,10 +287,22 @@ void RootView::DispatchGestureEvent(ui::GestureEvent* event) {
break;
}
+ View* gesture_handler = NULL;
+ if (views::switches::UseRectBasedTargeting()) {
+ // 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_ = GetEventHandlerForPoint(event->location());
- gesture_handler_ && (gesture_handler_ != this);
- gesture_handler_ = gesture_handler_->parent()) {
+ for (gesture_handler_ = gesture_handler;
+ gesture_handler_ && (gesture_handler_ != this);
+ gesture_handler_ = gesture_handler_->parent()) {
if (!gesture_handler_->enabled()) {
// Disabled views eat events but are treated as not handled.
return;
« no previous file with comments | « ui/views/views_switches.cc ('k') | ui/views/window/non_client_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698