diff options
author | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-14 13:33:23 +0000 |
---|---|---|
committer | mazda@chromium.org <mazda@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-14 13:33:23 +0000 |
commit | c5be11f4e5663736128f7c0b34af155155a27806 (patch) | |
tree | e46c093059f09005cec058df6202dc4b4035a7f0 /views/focus | |
parent | 8bff0e34eb5f15a4f1210239a3aced0df9d5d317 (diff) | |
download | chromium_src-c5be11f4e5663736128f7c0b34af155155a27806.zip chromium_src-c5be11f4e5663736128f7c0b34af155155a27806.tar.gz chromium_src-c5be11f4e5663736128f7c0b34af155155a27806.tar.bz2 |
Move views::Accelerator to ui in order to use it from aura code.
This is the first preliminary change for the support of global keyboard shortcut.
BUG=97255
TEST=None
Review URL: http://codereview.chromium.org/8508055
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109872 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/focus')
-rw-r--r-- | views/focus/accelerator_handler_gtk.cc | 1 | ||||
-rw-r--r-- | views/focus/accelerator_handler_gtk_unittest.cc | 11 | ||||
-rw-r--r-- | views/focus/accelerator_handler_touch.cc | 1 | ||||
-rw-r--r-- | views/focus/accelerator_handler_wayland.cc | 1 | ||||
-rw-r--r-- | views/focus/focus_manager.cc | 26 | ||||
-rw-r--r-- | views/focus/focus_manager.h | 24 | ||||
-rw-r--r-- | views/focus/focus_manager_unittest.cc | 25 |
7 files changed, 45 insertions, 44 deletions
diff --git a/views/focus/accelerator_handler_gtk.cc b/views/focus/accelerator_handler_gtk.cc index e795d06..fab3b86 100644 --- a/views/focus/accelerator_handler_gtk.cc +++ b/views/focus/accelerator_handler_gtk.cc @@ -6,7 +6,6 @@ #include <gtk/gtk.h> -#include "views/accelerator.h" #include "views/focus/focus_manager.h" namespace views { diff --git a/views/focus/accelerator_handler_gtk_unittest.cc b/views/focus/accelerator_handler_gtk_unittest.cc index bedd6d5..098325d 100644 --- a/views/focus/accelerator_handler_gtk_unittest.cc +++ b/views/focus/accelerator_handler_gtk_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,6 +6,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/rect.h" +#include "ui/base/models/accelerator.h" #include "views/focus/accelerator_handler.h" #include "views/focus/focus_manager.h" #include "views/view.h" @@ -17,7 +18,7 @@ namespace views { class AcceleratorHandlerGtkTest : public testing::Test, public WidgetDelegate, - public AcceleratorTarget { + public ui::AcceleratorTarget { public: AcceleratorHandlerGtkTest() : kMenuAccelerator(ui::VKEY_MENU, false, false, false), @@ -58,7 +59,7 @@ class AcceleratorHandlerGtkTest } // AcceleratorTarget implementation. - virtual bool AcceleratorPressed(const Accelerator& accelerator) { + virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) { if (accelerator == kMenuAccelerator) menu_pressed_ = true; else if (accelerator == kHomepageAccelerator) @@ -87,8 +88,8 @@ class AcceleratorHandlerGtkTest bool home_pressed_; private: - Accelerator kMenuAccelerator; - Accelerator kHomepageAccelerator; + ui::Accelerator kMenuAccelerator; + ui::Accelerator kHomepageAccelerator; Widget* window_; View* content_view_; MessageLoopForUI message_loop_; diff --git a/views/focus/accelerator_handler_touch.cc b/views/focus/accelerator_handler_touch.cc index 99dd049..6b452bd 100644 --- a/views/focus/accelerator_handler_touch.cc +++ b/views/focus/accelerator_handler_touch.cc @@ -9,7 +9,6 @@ #include <X11/extensions/XInput2.h> #include "ui/base/touch/touch_factory.h" -#include "views/accelerator.h" #include "views/events/event.h" #include "views/focus/focus_manager.h" #include "views/ime/input_method.h" diff --git a/views/focus/accelerator_handler_wayland.cc b/views/focus/accelerator_handler_wayland.cc index 1039570..6a88b03 100644 --- a/views/focus/accelerator_handler_wayland.cc +++ b/views/focus/accelerator_handler_wayland.cc @@ -4,7 +4,6 @@ #include "views/focus/accelerator_handler.h" -#include "views/accelerator.h" #include "views/focus/focus_manager.h" namespace views { diff --git a/views/focus/focus_manager.cc b/views/focus/focus_manager.cc index 9697597..5ebcb71 100644 --- a/views/focus/focus_manager.cc +++ b/views/focus/focus_manager.cc @@ -10,7 +10,7 @@ #include "base/logging.h" #include "build/build_config.h" #include "ui/base/keycodes/keyboard_codes.h" -#include "views/accelerator.h" +#include "ui/base/models/accelerator.h" #include "views/focus/focus_search.h" #include "views/focus/view_storage.h" #include "views/focus/widget_focus_manager.h" @@ -86,10 +86,10 @@ bool FocusManager::OnKeyEvent(const KeyEvent& event) { // Process keyboard accelerators. // If the key combination matches an accelerator, the accelerator is // triggered, otherwise the key event is processed as usual. - Accelerator accelerator(event.key_code(), - event.IsShiftDown(), - event.IsControlDown(), - event.IsAltDown()); + ui::Accelerator accelerator(event.key_code(), + event.IsShiftDown(), + event.IsControlDown(), + event.IsAltDown()); if (ProcessAccelerator(accelerator)) { // If a shortcut was activated for this keydown message, do not propagate // the event further. @@ -359,16 +359,16 @@ View* FocusManager::FindFocusableView(FocusTraversable* focus_traversable, } void FocusManager::RegisterAccelerator( - const Accelerator& accelerator, - AcceleratorTarget* target) { + const ui::Accelerator& accelerator, + ui::AcceleratorTarget* target) { AcceleratorTargetList& targets = accelerators_[accelerator]; DCHECK(std::find(targets.begin(), targets.end(), target) == targets.end()) << "Registering the same target multiple times"; targets.push_front(target); } -void FocusManager::UnregisterAccelerator(const Accelerator& accelerator, - AcceleratorTarget* target) { +void FocusManager::UnregisterAccelerator(const ui::Accelerator& accelerator, + ui::AcceleratorTarget* target) { AcceleratorMap::iterator map_iter = accelerators_.find(accelerator); if (map_iter == accelerators_.end()) { NOTREACHED() << "Unregistering non-existing accelerator"; @@ -386,7 +386,7 @@ void FocusManager::UnregisterAccelerator(const Accelerator& accelerator, targets->erase(target_iter); } -void FocusManager::UnregisterAccelerators(AcceleratorTarget* target) { +void FocusManager::UnregisterAccelerators(ui::AcceleratorTarget* target) { for (AcceleratorMap::iterator map_iter = accelerators_.begin(); map_iter != accelerators_.end(); ++map_iter) { AcceleratorTargetList* targets = &map_iter->second; @@ -394,7 +394,7 @@ void FocusManager::UnregisterAccelerators(AcceleratorTarget* target) { } } -bool FocusManager::ProcessAccelerator(const Accelerator& accelerator) { +bool FocusManager::ProcessAccelerator(const ui::Accelerator& accelerator) { AcceleratorMap::iterator map_iter = accelerators_.find(accelerator); if (map_iter != accelerators_.end()) { // We have to copy the target list here, because an AcceleratorPressed @@ -409,8 +409,8 @@ bool FocusManager::ProcessAccelerator(const Accelerator& accelerator) { return false; } -AcceleratorTarget* FocusManager::GetCurrentTargetForAccelerator( - const views::Accelerator& accelerator) const { +ui::AcceleratorTarget* FocusManager::GetCurrentTargetForAccelerator( + const ui::Accelerator& accelerator) const { AcceleratorMap::const_iterator map_iter = accelerators_.find(accelerator); if (map_iter == accelerators_.end() || map_iter->second.empty()) return NULL; diff --git a/views/focus/focus_manager.h b/views/focus/focus_manager.h index 0fa5139..8ac84c5d 100644 --- a/views/focus/focus_manager.h +++ b/views/focus/focus_manager.h @@ -11,8 +11,10 @@ #include "base/basictypes.h" #include "base/observer_list.h" +#include "ui/base/models/accelerator.h" #include "ui/gfx/native_widget_types.h" -#include "views/accelerator.h" +#include "views/views_export.h" +#include "views/events/event.h" // The FocusManager class is used to handle focus traversal, store/restore // focused views and handle keyboard accelerators. @@ -187,15 +189,15 @@ class VIEWS_EXPORT FocusManager { // - the enter key // - any F key (F1, F2, F3 ...) // - any browser specific keys (as available on special keyboards) - void RegisterAccelerator(const Accelerator& accelerator, - AcceleratorTarget* target); + void RegisterAccelerator(const ui::Accelerator& accelerator, + ui::AcceleratorTarget* target); // Unregister the specified keyboard accelerator for the specified target. - void UnregisterAccelerator(const Accelerator& accelerator, - AcceleratorTarget* target); + void UnregisterAccelerator(const ui::Accelerator& accelerator, + ui::AcceleratorTarget* target); // Unregister all keyboard accelerator for the specified target. - void UnregisterAccelerators(AcceleratorTarget* target); + void UnregisterAccelerators(ui::AcceleratorTarget* target); // Activate the target associated with the specified accelerator. // First, AcceleratorPressed handler of the most recently registered target @@ -203,7 +205,7 @@ class VIEWS_EXPORT FocusManager { // this method immediately returns. If not, we do the same thing on the next // target, and so on. // Returns true if an accelerator was activated. - bool ProcessAccelerator(const Accelerator& accelerator); + bool ProcessAccelerator(const ui::Accelerator& accelerator); // Called by a RootView when a view within its hierarchy is removed // from its parent. This will only be called by a RootView in a @@ -219,8 +221,8 @@ class VIEWS_EXPORT FocusManager { // Returns the AcceleratorTarget that should be activated for the specified // keyboard accelerator, or NULL if no view is registered for that keyboard // accelerator. - AcceleratorTarget* GetCurrentTargetForAccelerator( - const Accelerator& accelertor) const; + ui::AcceleratorTarget* GetCurrentTargetForAccelerator( + const ui::Accelerator& accelertor) const; // Sets the focus to the specified native view. virtual void FocusNativeView(gfx::NativeView native_view); @@ -259,8 +261,8 @@ class VIEWS_EXPORT FocusManager { FocusChangeReason focus_change_reason_; // The accelerators and associated targets. - typedef std::list<AcceleratorTarget*> AcceleratorTargetList; - typedef std::map<Accelerator, AcceleratorTargetList> AcceleratorMap; + typedef std::list<ui::AcceleratorTarget*> AcceleratorTargetList; + typedef std::map<ui::Accelerator, AcceleratorTargetList> AcceleratorMap; AcceleratorMap accelerators_; // The list of registered FocusChange listeners. diff --git a/views/focus/focus_manager_unittest.cc b/views/focus/focus_manager_unittest.cc index 574182d..6485405 100644 --- a/views/focus/focus_manager_unittest.cc +++ b/views/focus/focus_manager_unittest.cc @@ -8,6 +8,7 @@ #include "base/utf_string_conversions.h" #include "third_party/skia/include/core/SkColor.h" #include "ui/base/keycodes/keyboard_codes.h" +#include "ui/base/models/accelerator.h" #include "ui/base/models/combobox_model.h" #include "ui/gfx/rect.h" #include "views/background.h" @@ -1291,12 +1292,12 @@ TEST_F(FocusTraversalTest, PaneTraversal) { } // Counts accelerator calls. -class TestAcceleratorTarget : public AcceleratorTarget { +class TestAcceleratorTarget : public ui::AcceleratorTarget { public: explicit TestAcceleratorTarget(bool process_accelerator) : accelerator_count_(0), process_accelerator_(process_accelerator) {} - virtual bool AcceleratorPressed(const Accelerator& accelerator) { + virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) { ++accelerator_count_; return process_accelerator_; } @@ -1312,8 +1313,8 @@ class TestAcceleratorTarget : public AcceleratorTarget { TEST_F(FocusManagerTest, CallsNormalAcceleratorTarget) { FocusManager* focus_manager = GetFocusManager(); - Accelerator return_accelerator(ui::VKEY_RETURN, false, false, false); - Accelerator escape_accelerator(ui::VKEY_ESCAPE, false, false, false); + ui::Accelerator return_accelerator(ui::VKEY_RETURN, false, false, false); + ui::Accelerator escape_accelerator(ui::VKEY_ESCAPE, false, false, false); TestAcceleratorTarget return_target(true); TestAcceleratorTarget escape_target(true); @@ -1403,16 +1404,16 @@ TEST_F(FocusManagerTest, CallsNormalAcceleratorTarget) { } // Unregisters itself when its accelerator is invoked. -class SelfUnregisteringAcceleratorTarget : public AcceleratorTarget { +class SelfUnregisteringAcceleratorTarget : public ui::AcceleratorTarget { public: - SelfUnregisteringAcceleratorTarget(Accelerator accelerator, + SelfUnregisteringAcceleratorTarget(ui::Accelerator accelerator, FocusManager* focus_manager) : accelerator_(accelerator), focus_manager_(focus_manager), accelerator_count_(0) { } - virtual bool AcceleratorPressed(const Accelerator& accelerator) { + virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) { ++accelerator_count_; focus_manager_->UnregisterAccelerator(accelerator, this); return true; @@ -1421,7 +1422,7 @@ class SelfUnregisteringAcceleratorTarget : public AcceleratorTarget { int accelerator_count() const { return accelerator_count_; } private: - Accelerator accelerator_; + ui::Accelerator accelerator_; FocusManager* focus_manager_; int accelerator_count_; @@ -1430,7 +1431,7 @@ class SelfUnregisteringAcceleratorTarget : public AcceleratorTarget { TEST_F(FocusManagerTest, CallsSelfDeletingAcceleratorTarget) { FocusManager* focus_manager = GetFocusManager(); - Accelerator return_accelerator(ui::VKEY_RETURN, false, false, false); + ui::Accelerator return_accelerator(ui::VKEY_RETURN, false, false, false); SelfUnregisteringAcceleratorTarget target(return_accelerator, focus_manager); EXPECT_EQ(target.accelerator_count(), 0); EXPECT_EQ(NULL, @@ -1467,7 +1468,7 @@ class MessageTrackingView : public View { return true; } - virtual bool AcceleratorPressed(const Accelerator& accelerator) { + virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) { accelerator_pressed_ = true; return true; } @@ -1506,8 +1507,8 @@ class MessageTrackingView : public View { TEST_F(FocusManagerTest, IgnoreKeyupForAccelerators) { FocusManager* focus_manager = GetFocusManager(); MessageTrackingView* mtv = new MessageTrackingView(); - mtv->AddAccelerator(Accelerator(ui::VKEY_0, false, false, false)); - mtv->AddAccelerator(Accelerator(ui::VKEY_1, false, false, false)); + mtv->AddAccelerator(ui::Accelerator(ui::VKEY_0, false, false, false)); + mtv->AddAccelerator(ui::Accelerator(ui::VKEY_1, false, false, false)); content_view_->AddChildView(mtv); focus_manager->SetFocusedView(mtv); |