Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 bool 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()) { |
| 260 // TODO(tdanderson): Once DispatchGestureEvent() has been removed, move | 254 gesture_handler_set_before_processing_ = !!gesture_handler_; |
|
sadrul
2014/09/15 14:10:36
Should you move this down so this is set only when
tdanderson
2014/09/15 18:20:26
With the CL as-is, this will need to stay where it
| |
| 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(); | 255 ui::GestureEvent* gesture_event = event->AsGestureEvent(); |
| 269 | 256 |
| 270 // Do not dispatch ui::ET_GESTURE_BEGIN events. | 257 // Do not process ui::ET_GESTURE_BEGIN events. |
| 271 if (gesture_event->type() == ui::ET_GESTURE_BEGIN) | 258 if (gesture_event->type() == ui::ET_GESTURE_BEGIN) |
| 272 return DispatchDetails(); | 259 return false; |
| 273 | 260 |
| 274 // Ignore ui::ET_GESTURE_END events which do not correspond to the | 261 // Do not process ui::ET_GESTURE_END events which do not correspond to the |
| 275 // removal of the final touch point. | 262 // removal of the final touch point. |
| 276 if (gesture_event->type() == ui::ET_GESTURE_END && | 263 if (gesture_event->type() == ui::ET_GESTURE_END && |
| 277 gesture_event->details().touch_points() > 1) { | 264 gesture_event->details().touch_points() > 1) { |
| 278 return DispatchDetails(); | 265 return false; |
| 279 } | 266 } |
| 280 | 267 |
| 281 // Ignore subsequent gesture scroll events if no handler was set for a | 268 // Do not process subsequent gesture scroll events if no handler was set for |
| 282 // ui::ET_GESTURE_SCROLL_BEGIN event. | 269 // a ui::ET_GESTURE_SCROLL_BEGIN event. |
| 283 if (!gesture_handler_ && | 270 if (!gesture_handler_ && |
| 284 (gesture_event->type() == ui::ET_GESTURE_SCROLL_UPDATE || | 271 (gesture_event->type() == ui::ET_GESTURE_SCROLL_UPDATE || |
| 285 gesture_event->type() == ui::ET_GESTURE_SCROLL_END || | 272 gesture_event->type() == ui::ET_GESTURE_SCROLL_END || |
| 286 gesture_event->type() == ui::ET_SCROLL_FLING_START)) { | 273 gesture_event->type() == ui::ET_SCROLL_FLING_START)) { |
| 287 return DispatchDetails(); | 274 return false; |
| 288 } | 275 } |
| 289 | |
| 290 gesture_handler_set_before_processing_ = !!gesture_handler_; | |
| 291 return EventProcessor::OnEventFromSource(event); | |
| 292 } | 276 } |
| 293 | 277 |
| 294 if (event->IsTouchEvent()) | 278 return true; |
| 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 } | 279 } |
| 302 | 280 |
| 303 void RootView::OnEventProcessingFinished(ui::Event* event) { | 281 void RootView::OnEventProcessingFinished(ui::Event* event) { |
| 304 // If |event| was not handled and |gesture_handler_| was not set by the | 282 // 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 | 283 // dispatch of a previous gesture event, then no default gesture handler |
| 306 // should be set prior to the next gesture event being received. | 284 // should be set prior to the next gesture event being received. |
| 307 if (event->IsGestureEvent() && | 285 if (event->IsGestureEvent() && |
| 308 !event->handled() && | 286 !event->handled() && |
| 309 !gesture_handler_set_before_processing_) { | 287 !gesture_handler_set_before_processing_) { |
| 310 gesture_handler_ = NULL; | 288 gesture_handler_ = NULL; |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 737 | 715 |
| 738 #ifndef NDEBUG | 716 #ifndef NDEBUG |
| 739 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); | 717 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); |
| 740 #endif | 718 #endif |
| 741 | 719 |
| 742 return details; | 720 return details; |
| 743 } | 721 } |
| 744 | 722 |
| 745 } // namespace internal | 723 } // namespace internal |
| 746 } // namespace views | 724 } // namespace views |
| OLD | NEW |