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

Side by Side 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: comments addressed, moved fuzzing utility functions to new file Created 7 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/root_view.h" 5 #include "ui/views/widget/root_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 // events are not dispatched to any views. 271 // events are not dispatched to any views.
272 switch (event->type()) { 272 switch (event->type()) {
273 case ui::ET_GESTURE_SCROLL_UPDATE: 273 case ui::ET_GESTURE_SCROLL_UPDATE:
274 case ui::ET_GESTURE_SCROLL_END: 274 case ui::ET_GESTURE_SCROLL_END:
275 case ui::ET_SCROLL_FLING_START: 275 case ui::ET_SCROLL_FLING_START:
276 return; 276 return;
277 default: 277 default:
278 break; 278 break;
279 } 279 }
280 280
281 // Terry: A runtime flag will specify whether or not fuzzing should be
282 // used here (and will possibly also specify an overlap percentage).
283 bool use_fuzzing = true;
284
285 View* gesture_handler = NULL;
286 if (use_fuzzing) {
287 gfx::Rect touch_rect(event->details().bounding_box());
288 gfx::Point origin(touch_rect.origin());
289 View::ConvertPointFromScreen(this, &origin);
290 touch_rect.set_origin(origin);
291 gesture_handler = GetEventHandlerForRect(touch_rect);
292 } else {
293 gesture_handler = GetEventHandlerForPoint(event->location());
294 }
295
281 // Walk up the tree until we find a view that wants the gesture event. 296 // Walk up the tree until we find a view that wants the gesture event.
282 for (gesture_handler_ = GetEventHandlerForPoint(event->location()); 297 for (gesture_handler_ = gesture_handler;
283 gesture_handler_ && (gesture_handler_ != this); 298 gesture_handler_ && (gesture_handler_ != this);
284 gesture_handler_ = gesture_handler_->parent()) { 299 gesture_handler_ = gesture_handler_->parent()) {
285 if (!gesture_handler_->enabled()) { 300 if (!gesture_handler_->enabled()) {
286 // Disabled views eat events but are treated as not handled. 301 // Disabled views eat events but are treated as not handled.
287 return; 302 return;
288 } 303 }
289 304
290 // See if this view wants to handle the Gesture. 305 // See if this view wants to handle the Gesture.
291 ui::GestureEvent gesture_event(*event, static_cast<View*>(this), 306 ui::GestureEvent gesture_event(*event, static_cast<View*>(this),
292 gesture_handler_); 307 gesture_handler_);
293 DispatchEventToTarget(gesture_handler_, &gesture_event); 308 DispatchEventToTarget(gesture_handler_, &gesture_event);
294 309
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 return; 729 return;
715 } 730 }
716 } 731 }
717 732
718 bool RootView::CanDispatchToTarget(ui::EventTarget* target) { 733 bool RootView::CanDispatchToTarget(ui::EventTarget* target) {
719 return event_dispatch_target_ == target; 734 return event_dispatch_target_ == target;
720 } 735 }
721 736
722 } // namespace internal 737 } // namespace internal
723 } // namespace views 738 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698