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

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: sadrul comments 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
« no previous file with comments | « ui/views/widget/root_view.h ('k') | ui/views/widget/root_view_targeter.cc » ('j') | 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 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()) 253 if (!event->IsGestureEvent())
254 return EventProcessor::OnEventFromSource(event); 254 return;
255 255
256 if (event->IsScrollEvent()) 256 ui::GestureEvent* gesture_event = event->AsGestureEvent();
257 return EventProcessor::OnEventFromSource(event);
258 257
259 if (event->IsGestureEvent()) { 258 // Do not process ui::ET_GESTURE_BEGIN events.
260 // TODO(tdanderson): Once DispatchGestureEvent() has been removed, move 259 if (gesture_event->type() == ui::ET_GESTURE_BEGIN) {
261 // all of this logic into an override of a new 260 event->SetHandled();
262 // virtual method 261 return;
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();
269
270 // Do not dispatch ui::ET_GESTURE_BEGIN events.
271 if (gesture_event->type() == ui::ET_GESTURE_BEGIN)
272 return DispatchDetails();
273
274 // Ignore ui::ET_GESTURE_END events which do not correspond to the
275 // removal of the final touch point.
276 if (gesture_event->type() == ui::ET_GESTURE_END &&
277 gesture_event->details().touch_points() > 1) {
278 return DispatchDetails();
279 }
280
281 // Ignore subsequent gesture scroll events if no handler was set for a
282 // ui::ET_GESTURE_SCROLL_BEGIN event.
283 if (!gesture_handler_ &&
284 (gesture_event->type() == ui::ET_GESTURE_SCROLL_UPDATE ||
285 gesture_event->type() == ui::ET_GESTURE_SCROLL_END ||
286 gesture_event->type() == ui::ET_SCROLL_FLING_START)) {
287 return DispatchDetails();
288 }
289
290 gesture_handler_set_before_processing_ = !!gesture_handler_;
291 return EventProcessor::OnEventFromSource(event);
292 } 262 }
293 263
294 if (event->IsTouchEvent()) 264 // Do not process ui::ET_GESTURE_END events which do not correspond to the
295 NOTREACHED() << "Touch events should not be sent to RootView."; 265 // removal of the final touch point.
266 if (gesture_event->type() == ui::ET_GESTURE_END &&
267 gesture_event->details().touch_points() > 1) {
268 event->SetHandled();
269 return;
270 }
296 271
297 if (event->IsMouseEvent()) 272 // Do not process subsequent gesture scroll events if no handler was set for
298 NOTREACHED() << "Should not be called with a MouseEvent."; 273 // a ui::ET_GESTURE_SCROLL_BEGIN event.
274 if (!gesture_handler_ &&
275 (gesture_event->type() == ui::ET_GESTURE_SCROLL_UPDATE ||
276 gesture_event->type() == ui::ET_GESTURE_SCROLL_END ||
277 gesture_event->type() == ui::ET_SCROLL_FLING_START)) {
278 event->SetHandled();
279 return;
280 }
299 281
300 return DispatchDetails(); 282 gesture_handler_set_before_processing_ = !!gesture_handler_;
301 } 283 }
302 284
303 void RootView::OnEventProcessingFinished(ui::Event* event) { 285 void RootView::OnEventProcessingFinished(ui::Event* event) {
304 // If |event| was not handled and |gesture_handler_| was not set by the 286 // 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 287 // dispatch of a previous gesture event, then no default gesture handler
306 // should be set prior to the next gesture event being received. 288 // should be set prior to the next gesture event being received.
307 if (event->IsGestureEvent() && 289 if (event->IsGestureEvent() &&
308 !event->handled() && 290 !event->handled() &&
309 !gesture_handler_set_before_processing_) { 291 !gesture_handler_set_before_processing_) {
310 gesture_handler_ = NULL; 292 gesture_handler_ = NULL;
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 719
738 #ifndef NDEBUG 720 #ifndef NDEBUG
739 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); 721 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_));
740 #endif 722 #endif
741 723
742 return details; 724 return details;
743 } 725 }
744 726
745 } // namespace internal 727 } // namespace internal
746 } // namespace views 728 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/root_view.h ('k') | ui/views/widget/root_view_targeter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698