summaryrefslogtreecommitdiffstats
path: root/views/focus
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-02 18:22:10 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-02 18:22:10 +0000
commit0c96668965e17a98f29b6862468783e5a04af0d7 (patch)
tree0386d0b802abcb6bc0c143648bdbfaaea6cdb154 /views/focus
parent134efc37e03e2d8da955f855533fbb5c7c6177f1 (diff)
downloadchromium_src-0c96668965e17a98f29b6862468783e5a04af0d7.zip
chromium_src-0c96668965e17a98f29b6862468783e5a04af0d7.tar.gz
chromium_src-0c96668965e17a98f29b6862468783e5a04af0d7.tar.bz2
Nix GetFocusManagerForNativeView|Window.
Use Widget|View::GetFocusManager instead. Use Widget::Get[TopLevel]WidgetForNativeView|Window as necessary. BUG=88718 TEST=none Review URL: http://codereview.chromium.org/7532015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95111 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/focus')
-rw-r--r--views/focus/accelerator_handler_win.cc7
-rw-r--r--views/focus/focus_manager.cc19
-rw-r--r--views/focus/focus_manager.h8
-rw-r--r--views/focus/focus_manager_unittest.cc46
4 files changed, 30 insertions, 50 deletions
diff --git a/views/focus/accelerator_handler_win.cc b/views/focus/accelerator_handler_win.cc
index ad401f3..8f2c8e8 100644
--- a/views/focus/accelerator_handler_win.cc
+++ b/views/focus/accelerator_handler_win.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 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.
@@ -8,6 +8,7 @@
#include "ui/base/keycodes/keyboard_code_conversion_win.h"
#include "views/events/event.h"
#include "views/focus/focus_manager.h"
+#include "views/widget/widget.h"
namespace views {
@@ -18,8 +19,8 @@ bool AcceleratorHandler::Dispatch(const MSG& msg) {
bool process_message = true;
if (msg.message >= WM_KEYFIRST && msg.message <= WM_KEYLAST) {
- FocusManager* focus_manager =
- FocusManager::GetFocusManagerForNativeView(msg.hwnd);
+ Widget* widget = Widget::GetTopLevelWidgetForNativeView(msg.hwnd);
+ FocusManager* focus_manager = widget ? widget->GetFocusManager() : NULL;
if (focus_manager) {
switch (msg.message) {
case WM_KEYDOWN:
diff --git a/views/focus/focus_manager.cc b/views/focus/focus_manager.cc
index e2942a6..2dff171f 100644
--- a/views/focus/focus_manager.cc
+++ b/views/focus/focus_manager.cc
@@ -463,25 +463,6 @@ bool FocusManager::IsTabTraversalKeyEvent(const KeyEvent& key_event) {
return key_event.key_code() == ui::VKEY_TAB && !key_event.IsControlDown();
}
-// static
-FocusManager* FocusManager::GetFocusManagerForNativeView(
- gfx::NativeView native_view) {
- // TODO(beng): This method probably isn't necessary.
- Widget* widget = Widget::GetTopLevelWidgetForNativeView(native_view);
- return widget ? widget->GetFocusManager() : NULL;
-}
-
-// static
-FocusManager* FocusManager::GetFocusManagerForNativeWindow(
- gfx::NativeWindow native_window) {
- // TODO(beng): This method probably isn't necessary.
- Widget* widget = Widget::GetWidgetForNativeWindow(native_window);
- if (!widget)
- return NULL;
- widget = widget->GetTopLevelWidget();
- return widget ? widget->GetFocusManager() : NULL;
-}
-
void FocusManager::ViewRemoved(View* removed) {
// If the view being removed contains (or is) the focused view,
// clear the focus. However, it's not safe to call ClearFocus()
diff --git a/views/focus/focus_manager.h b/views/focus/focus_manager.h
index 018a4f2..ca31752 100644
--- a/views/focus/focus_manager.h
+++ b/views/focus/focus_manager.h
@@ -280,14 +280,6 @@ class VIEWS_API FocusManager {
// pressed).
static bool IsTabTraversalKeyEvent(const KeyEvent& key_event);
- // Retrieves the FocusManager associated with the passed native view.
- static FocusManager* GetFocusManagerForNativeView(
- gfx::NativeView native_view);
-
- // Retrieves the FocusManager associated with the passed native view.
- static FocusManager* GetFocusManagerForNativeWindow(
- gfx::NativeWindow native_window);
-
private:
// Returns the next focusable view.
View* GetNextFocusableView(View* starting_view, bool reverse, bool dont_loop);
diff --git a/views/focus/focus_manager_unittest.cc b/views/focus/focus_manager_unittest.cc
index cec153c..8c4c29a 100644
--- a/views/focus/focus_manager_unittest.cc
+++ b/views/focus/focus_manager_unittest.cc
@@ -1601,32 +1601,38 @@ TEST_F(FocusManagerTest, CreationForNativeRoot) {
// Get the focus manager directly from the first window. Should exist
// because the first window is the root widget.
- views::FocusManager* focus_manager_member1 = widget1->GetFocusManager();
- EXPECT_TRUE(focus_manager_member1);
+ views::FocusManager* focus_manager1 = widget1->GetFocusManager();
+ EXPECT_TRUE(focus_manager1);
// Create another view window parented to the first view window.
scoped_ptr<Widget> widget2(new Widget);
params.parent = widget1->GetNativeView();
widget2->Init(params);
- // Get the focus manager directly from the second window. Should return the
- // first window's focus manager.
- views::FocusManager* focus_manager_member2 = widget2->GetFocusManager();
- EXPECT_EQ(focus_manager_member2, focus_manager_member1);
-
- // Get the focus manager indirectly using the first window handle. Should
- // return the first window's focus manager.
- views::FocusManager* focus_manager_indirect =
- views::FocusManager::GetFocusManagerForNativeView(
- widget1->GetNativeView());
- EXPECT_EQ(focus_manager_indirect, focus_manager_member1);
-
- // Get the focus manager indirectly using the second window handle. Should
- // return the first window's focus manager.
- focus_manager_indirect =
- views::FocusManager::GetFocusManagerForNativeView(
- widget2->GetNativeView());
- EXPECT_EQ(focus_manager_indirect, focus_manager_member1);
+ // Access the shared focus manager directly from the second window.
+ views::FocusManager* focus_manager2 = widget2->GetFocusManager();
+ EXPECT_EQ(focus_manager2, focus_manager1);
+
+ // Access the shared focus manager indirectly from the first window handle.
+ gfx::NativeWindow native_window = widget1->GetNativeWindow();
+ views::Widget* widget =
+ views::Widget::GetWidgetForNativeWindow(native_window);
+ EXPECT_EQ(widget->GetFocusManager(), focus_manager1);
+
+ // Access the shared focus manager indirectly from the second window handle.
+ native_window = widget2->GetNativeWindow();
+ widget = views::Widget::GetWidgetForNativeWindow(native_window);
+ EXPECT_EQ(widget->GetFocusManager(), focus_manager1);
+
+ // Access the shared focus manager indirectly from the first view handle.
+ gfx::NativeView native_view = widget1->GetNativeView();
+ widget = views::Widget::GetTopLevelWidgetForNativeView(native_view);
+ EXPECT_EQ(widget->GetFocusManager(), focus_manager1);
+
+ // Access the shared focus manager indirectly from the second view handle.
+ native_view = widget2->GetNativeView();
+ widget = views::Widget::GetTopLevelWidgetForNativeView(native_view);
+ EXPECT_EQ(widget->GetFocusManager(), focus_manager1);
DestroyWindow(hwnd);
}