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

Side by Side Diff: ui/views/widget/root_view.cc

Issue 406683002: Move early return out of RootView::DispatchGestureEvent() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments addressed Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 ui::EventTarget* RootView::GetRootTarget() { 248 ui::EventTarget* RootView::GetRootTarget() {
249 return this; 249 return this;
250 } 250 }
251 251
252 ui::EventDispatchDetails RootView::OnEventFromSource(ui::Event* event) { 252 ui::EventDispatchDetails RootView::OnEventFromSource(ui::Event* event) {
253 // TODO(tdanderson): Replace the calls to Dispatch*Event() with calls to 253 // TODO(tdanderson): Replace the calls to Dispatch*Event() with calls to
254 // EventProcessor::OnEventFromSource() once the code for 254 // EventProcessor::OnEventFromSource() once the code for
255 // that event type has been refactored, and then 255 // that event type has been refactored, and then
256 // eventually remove this function altogether. See 256 // eventually remove this function altogether. See
257 // crbug.com/348083. 257 // crbug.com/348083.
258
258 if (event->IsKeyEvent()) 259 if (event->IsKeyEvent())
259 return EventProcessor::OnEventFromSource(event); 260 return EventProcessor::OnEventFromSource(event);
260 else if (event->IsScrollEvent()) 261
262 if (event->IsScrollEvent())
261 return EventProcessor::OnEventFromSource(event); 263 return EventProcessor::OnEventFromSource(event);
262 else if (event->IsTouchEvent()) 264
265 if (event->IsGestureEvent()) {
266 // Ignore subsequent gesture scroll events if no handler was set for a
267 // ui::ET_GESTURE_SCROLL_BEGIN event.
268 if (!gesture_handler_ &&
269 (event->type() == ui::ET_GESTURE_SCROLL_UPDATE ||
270 event->type() == ui::ET_GESTURE_SCROLL_END ||
271 event->type() == ui::ET_SCROLL_FLING_START)) {
272 return DispatchDetails();
273 }
274
275 DispatchGestureEvent(event->AsGestureEvent());
276 return DispatchDetails();
277 }
278
279 if (event->IsTouchEvent())
263 NOTREACHED() << "Touch events should not be sent to RootView."; 280 NOTREACHED() << "Touch events should not be sent to RootView.";
264 else if (event->IsGestureEvent()) 281
265 DispatchGestureEvent(event->AsGestureEvent()); 282 if (event->IsMouseEvent())
266 else if (event->IsMouseEvent())
267 NOTREACHED() << "Should not be called with a MouseEvent."; 283 NOTREACHED() << "Should not be called with a MouseEvent.";
268 else
269 NOTREACHED() << "Invalid event type.";
270 284
271 return DispatchDetails(); 285 return DispatchDetails();
272 } 286 }
273 287
274 //////////////////////////////////////////////////////////////////////////////// 288 ////////////////////////////////////////////////////////////////////////////////
275 // RootView, View overrides: 289 // RootView, View overrides:
276 290
277 const Widget* RootView::GetWidget() const { 291 const Widget* RootView::GetWidget() const {
278 return widget_; 292 return widget_;
279 } 293 }
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 dispatch_details.target_destroyed) { 689 dispatch_details.target_destroyed) {
676 return; 690 return;
677 } 691 }
678 } 692 }
679 scroll_gesture_handler_ = NULL; 693 scroll_gesture_handler_ = NULL;
680 } 694 }
681 695
682 return; 696 return;
683 } 697 }
684 698
685 // If there was no handler for a SCROLL_BEGIN event, then subsequent scroll
686 // events are not dispatched to any views.
687 switch (event->type()) {
688 case ui::ET_GESTURE_SCROLL_UPDATE:
689 case ui::ET_GESTURE_SCROLL_END:
690 case ui::ET_SCROLL_FLING_START:
691 return;
692 default:
693 break;
694 }
695
696 View* gesture_handler = NULL; 699 View* gesture_handler = NULL;
697 if (views::switches::IsRectBasedTargetingEnabled() && 700 if (views::switches::IsRectBasedTargetingEnabled() &&
698 !event->details().bounding_box().IsEmpty()) { 701 !event->details().bounding_box().IsEmpty()) {
699 // TODO(tdanderson): Pass in the bounding box to GetEventHandlerForRect() 702 // TODO(tdanderson): Pass in the bounding box to GetEventHandlerForRect()
700 // once crbug.com/313392 is resolved. 703 // once crbug.com/313392 is resolved.
701 gfx::Rect touch_rect(event->details().bounding_box()); 704 gfx::Rect touch_rect(event->details().bounding_box());
702 touch_rect.set_origin(event->location()); 705 touch_rect.set_origin(event->location());
703 touch_rect.Offset(-touch_rect.width() / 2, -touch_rect.height() / 2); 706 touch_rect.Offset(-touch_rect.width() / 2, -touch_rect.height() / 2);
704 gesture_handler = GetEventHandlerForRect(touch_rect); 707 gesture_handler = GetEventHandlerForRect(touch_rect);
705 } else { 708 } else {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 811
809 #ifndef NDEBUG 812 #ifndef NDEBUG
810 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); 813 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_));
811 #endif 814 #endif
812 815
813 return details; 816 return details;
814 } 817 }
815 818
816 } // namespace internal 819 } // namespace internal
817 } // namespace views 820 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698