summaryrefslogtreecommitdiffstats
path: root/views/focus/focus_manager.cc
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 20:39:58 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-24 20:39:58 +0000
commit56235c632f18380a4455b6ea113cd6e2a2df0d69 (patch)
tree82150c0c7f8bb6c2c80c5580c56c9772059aa92f /views/focus/focus_manager.cc
parent64b29caf448b26c316533dbd98efbdc92f6163bd (diff)
downloadchromium_src-56235c632f18380a4455b6ea113cd6e2a2df0d69.zip
chromium_src-56235c632f18380a4455b6ea113cd6e2a2df0d69.tar.gz
chromium_src-56235c632f18380a4455b6ea113cd6e2a2df0d69.tar.bz2
Move some more direct uses of RootView to Widget.
The idea is to remove RootView from the public API of Views and eventually move it into the internal namespace. It is really an implementation detail of event propagation into a view hierarchy. Anyone that calls GetRootView() and does something that isn't a View method should be calling that method on the Widget instead... e.g. instead of calling GetRootView()->NotifyThemeChanged(), call GetWidget()->ThemeChanged(). The RootView is a focus traversable, which is fine, but calling code should call GetWidget()->GetFocusTraversable() to obtain it, rather than knowing RootView is-a focus traversable and just calling GetRootView(). This also changes FocusManager::ContainsView to be simpler and cross platform. Since there is one FocusManager per view hierarchy (attached to the toplevel Widget), getting the view's focus manager and comparing it to the current focus manager is a sufficient test. BUG=72040 TEST=existing unittests, none Review URL: http://codereview.chromium.org/6577017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75940 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/focus/focus_manager.cc')
-rw-r--r--views/focus/focus_manager.cc31
1 files changed, 7 insertions, 24 deletions
diff --git a/views/focus/focus_manager.cc b/views/focus/focus_manager.cc
index baaf2a0..ae3e760 100644
--- a/views/focus/focus_manager.cc
+++ b/views/focus/focus_manager.cc
@@ -168,27 +168,8 @@ void FocusManager::ValidateFocusedView() {
// Tests whether a view is valid, whether it still belongs to the window
// hierarchy of the FocusManager.
bool FocusManager::ContainsView(View* view) {
- DCHECK(view);
- RootView* root_view = view->GetRootView();
- if (!root_view)
- return false;
-
- Widget* widget = root_view->GetWidget();
- if (!widget)
- return false;
-
- gfx::NativeView top_window = widget_->GetNativeView();
- gfx::NativeView window = widget->GetNativeView();
- while (window) {
- if (window == top_window)
- return true;
-#if defined(OS_WIN)
- window = ::GetParent(window);
-#else
- window = gtk_widget_get_parent(window);
-#endif
- }
- return false;
+ Widget* widget = view->GetWidget();
+ return widget ? widget->GetFocusManager() == this : false;
}
void FocusManager::AdvanceFocus(bool reverse) {
@@ -235,18 +216,20 @@ View* FocusManager::GetNextFocusableView(View* original_starting_view,
// Otherwise default to the root view.
if (!focus_traversable) {
- focus_traversable = original_starting_view->GetRootView();
+ focus_traversable =
+ original_starting_view->GetWidget()->GetFocusTraversable();
starting_view = original_starting_view;
}
} else {
// When you are going back, starting view's FocusTraversable
// should not be used.
- focus_traversable = original_starting_view->GetRootView();
+ focus_traversable =
+ original_starting_view->GetWidget()->GetFocusTraversable();
starting_view = original_starting_view;
}
}
} else {
- focus_traversable = widget_->GetRootView();
+ focus_traversable = widget_->GetFocusTraversable();
}
// Traverse the FocusTraversable tree down to find the focusable view.