| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 // - Shows keyboard-triggered context menus. | 57 // - Shows keyboard-triggered context menus. |
| 58 class PreEventDispatchHandler : public ui::EventHandler { | 58 class PreEventDispatchHandler : public ui::EventHandler { |
| 59 public: | 59 public: |
| 60 explicit PreEventDispatchHandler(View* owner) | 60 explicit PreEventDispatchHandler(View* owner) |
| 61 : owner_(owner) { | 61 : owner_(owner) { |
| 62 } | 62 } |
| 63 virtual ~PreEventDispatchHandler() {} | 63 virtual ~PreEventDispatchHandler() {} |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 // ui::EventHandler: | 66 // ui::EventHandler: |
| 67 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { | 67 virtual void OnKeyEvent(ui::KeyEvent* event) override { |
| 68 CHECK_EQ(ui::EP_PRETARGET, event->phase()); | 68 CHECK_EQ(ui::EP_PRETARGET, event->phase()); |
| 69 if (event->handled()) | 69 if (event->handled()) |
| 70 return; | 70 return; |
| 71 | 71 |
| 72 View* v = NULL; | 72 View* v = NULL; |
| 73 if (owner_->GetFocusManager()) // Can be NULL in unittests. | 73 if (owner_->GetFocusManager()) // Can be NULL in unittests. |
| 74 v = owner_->GetFocusManager()->GetFocusedView(); | 74 v = owner_->GetFocusManager()->GetFocusedView(); |
| 75 | 75 |
| 76 // Special case to handle keyboard-triggered context menus. | 76 // Special case to handle keyboard-triggered context menus. |
| 77 if (v && v->enabled() && ((event->key_code() == ui::VKEY_APPS) || | 77 if (v && v->enabled() && ((event->key_code() == ui::VKEY_APPS) || |
| (...skipping 21 matching lines...) Expand all Loading... |
| 99 // - Generates context menu, or initiates drag-and-drop, from gesture events. | 99 // - Generates context menu, or initiates drag-and-drop, from gesture events. |
| 100 class PostEventDispatchHandler : public ui::EventHandler { | 100 class PostEventDispatchHandler : public ui::EventHandler { |
| 101 public: | 101 public: |
| 102 PostEventDispatchHandler() | 102 PostEventDispatchHandler() |
| 103 : touch_dnd_enabled_(::switches::IsTouchDragDropEnabled()) { | 103 : touch_dnd_enabled_(::switches::IsTouchDragDropEnabled()) { |
| 104 } | 104 } |
| 105 virtual ~PostEventDispatchHandler() {} | 105 virtual ~PostEventDispatchHandler() {} |
| 106 | 106 |
| 107 private: | 107 private: |
| 108 // Overridden from ui::EventHandler: | 108 // Overridden from ui::EventHandler: |
| 109 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 109 virtual void OnGestureEvent(ui::GestureEvent* event) override { |
| 110 DCHECK_EQ(ui::EP_POSTTARGET, event->phase()); | 110 DCHECK_EQ(ui::EP_POSTTARGET, event->phase()); |
| 111 if (event->handled()) | 111 if (event->handled()) |
| 112 return; | 112 return; |
| 113 | 113 |
| 114 View* target = static_cast<View*>(event->target()); | 114 View* target = static_cast<View*>(event->target()); |
| 115 gfx::Point location = event->location(); | 115 gfx::Point location = event->location(); |
| 116 if (touch_dnd_enabled_ && | 116 if (touch_dnd_enabled_ && |
| 117 event->type() == ui::ET_GESTURE_LONG_PRESS && | 117 event->type() == ui::ET_GESTURE_LONG_PRESS && |
| 118 (!target->drag_controller() || | 118 (!target->drag_controller() || |
| 119 target->drag_controller()->CanStartDragForView( | 119 target->drag_controller()->CanStartDragForView( |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 | 723 |
| 724 #ifndef NDEBUG | 724 #ifndef NDEBUG |
| 725 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); | 725 DCHECK(!event_dispatch_target_ || Contains(event_dispatch_target_)); |
| 726 #endif | 726 #endif |
| 727 | 727 |
| 728 return details; | 728 return details; |
| 729 } | 729 } |
| 730 | 730 |
| 731 } // namespace internal | 731 } // namespace internal |
| 732 } // namespace views | 732 } // namespace views |
| OLD | NEW |