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

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

Issue 552503003: Introduce EventProcessor::OnEventProcessingStarted() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NOTREACHED in test failure addressed Created 6 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
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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 return focus_traversable_parent_view_; 242 return focus_traversable_parent_view_;
243 } 243 }
244 244
245 //////////////////////////////////////////////////////////////////////////////// 245 ////////////////////////////////////////////////////////////////////////////////
246 // RootView, ui::EventProcessor overrides: 246 // RootView, ui::EventProcessor overrides:
247 247
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 void RootView::OnEventProcessingStarted(ui::Event* event) {
253 if (event->IsKeyEvent())
254 return EventProcessor::OnEventFromSource(event);
255
256 if (event->IsScrollEvent())
257 return EventProcessor::OnEventFromSource(event);
258
259 if (event->IsGestureEvent()) { 253 if (event->IsGestureEvent()) {
sadrul 2014/09/25 16:12:01 Early return if !gesture-event instead
tdanderson 2014/09/25 17:11:58 Done.
260 // TODO(tdanderson): Once DispatchGestureEvent() has been removed, move
261 // all of this logic into an override of a new
262 // virtual method
263 // EventProcessor::OnEventProcessingStarted() (which
264 // returns false if no processing should take place).
265 // Also move the implementation of
266 // PrepareEventForDispatch() into this new method.
267 // Then RootView::OnEventFromSource() can be removed.
268 ui::GestureEvent* gesture_event = event->AsGestureEvent(); 254 ui::GestureEvent* gesture_event = event->AsGestureEvent();
269 255
270 // Do not dispatch ui::ET_GESTURE_BEGIN events. 256 // Do not process ui::ET_GESTURE_BEGIN events.
271 if (gesture_event->type() == ui::ET_GESTURE_BEGIN) 257 if (gesture_event->type() == ui::ET_GESTURE_BEGIN) {
272 return DispatchDetails(); 258 event->SetHandled();
259 return;
260 }
273 261
274 // Ignore ui::ET_GESTURE_END events which do not correspond to the 262 // Do not process ui::ET_GESTURE_END events which do not correspond to the
275 // removal of the final touch point. 263 // removal of the final touch point.
276 if (gesture_event->type() == ui::ET_GESTURE_END && 264 if (gesture_event->type() == ui::ET_GESTURE_END &&
277 gesture_event->details().touch_points() > 1) { 265 gesture_event->details().touch_points() > 1) {
278 return DispatchDetails(); 266 event->SetHandled();
267 return;
279 } 268 }
280 269
281 // Ignore subsequent gesture scroll events if no handler was set for a 270 // Do not process subsequent gesture scroll events if no handler was set for
282 // ui::ET_GESTURE_SCROLL_BEGIN event. 271 // a ui::ET_GESTURE_SCROLL_BEGIN event.
283 if (!gesture_handler_ && 272 if (!gesture_handler_ &&
284 (gesture_event->type() == ui::ET_GESTURE_SCROLL_UPDATE || 273 (gesture_event->type() == ui::ET_GESTURE_SCROLL_UPDATE ||
285 gesture_event->type() == ui::ET_GESTURE_SCROLL_END || 274 gesture_event->type() == ui::ET_GESTURE_SCROLL_END ||
286 gesture_event->type() == ui::ET_SCROLL_FLING_START)) { 275 gesture_event->type() == ui::ET_SCROLL_FLING_START)) {
287 return DispatchDetails(); 276 event->SetHandled();
277 return;
288 } 278 }
289 279
290 gesture_handler_set_before_processing_ = !!gesture_handler_; 280 gesture_handler_set_before_processing_ = !!gesture_handler_;
291 return EventProcessor::OnEventFromSource(event);
292 } 281 }
293
294 if (event->IsTouchEvent())
295 NOTREACHED() << "Touch events should not be sent to RootView.";
296
297 if (event->IsMouseEvent())
298 NOTREACHED() << "Should not be called with a MouseEvent.";
299
300 return DispatchDetails();
301 } 282 }
302 283
303 void RootView::OnEventProcessingFinished(ui::Event* event) { 284 void RootView::OnEventProcessingFinished(ui::Event* event) {
304 // If |event| was not handled and |gesture_handler_| was not set by the 285 // If |event| was not handled and |gesture_handler_| was not set by the
305 // dispatch of a previous gesture event, then no default gesture handler 286 // dispatch of a previous gesture event, then no default gesture handler
306 // should be set prior to the next gesture event being received. 287 // should be set prior to the next gesture event being received.
307 if (event->IsGestureEvent() && 288 if (event->IsGestureEvent() &&
308 !event->handled() && 289 !event->handled() &&
309 !gesture_handler_set_before_processing_) { 290 !gesture_handler_set_before_processing_) {
310 gesture_handler_ = NULL; 291 gesture_handler_ = NULL;
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 718
738 #ifndef NDEBUG 719 #ifndef NDEBUG
739 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); 720 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_));
740 #endif 721 #endif
741 722
742 return details; 723 return details;
743 } 724 }
744 725
745 } // namespace internal 726 } // namespace internal
746 } // namespace views 727 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698