summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--views/focus/focus_manager.cc34
-rw-r--r--views/focus/focus_manager.h3
-rw-r--r--views/focus/focus_manager_unittest.cc14
3 files changed, 11 insertions, 40 deletions
diff --git a/views/focus/focus_manager.cc b/views/focus/focus_manager.cc
index abbc456..f4b67ff 100644
--- a/views/focus/focus_manager.cc
+++ b/views/focus/focus_manager.cc
@@ -413,37 +413,19 @@ View* FocusManager::GetNextFocusableView(View* original_starting_view,
parent_focus_traversable->GetFocusTraversableParent();
}
- if (!dont_loop) {
- // If we get here, we have reached the end of the focus hierarchy, let's
- // loop.
- if (reverse) {
- // When reversing from the top, the next focusable view is at the end
- // of the focus hierarchy.
- return FindLastFocusableView();
- } else {
- // Easy, just clear the selection and press tab again.
- if (original_starting_view) { // Make sure there was at least a view to
- // start with, to prevent infinitely
- // looping in empty windows.
- // By calling with NULL as the starting view, we'll start from the
- // top_root_view.
- return GetNextFocusableView(NULL, false, true);
- }
- }
+ // If we get here, we have reached the end of the focus hierarchy, let's
+ // loop. Make sure there was at least a view to start with, to prevent
+ // infinitely looping in empty windows.
+ if (!dont_loop && original_starting_view) {
+ // Easy, just clear the selection and press tab again.
+ // By calling with NULL as the starting view, we'll start from the
+ // top_root_view.
+ return GetNextFocusableView(NULL, reverse, true);
}
}
return NULL;
}
-View* FocusManager::FindLastFocusableView() {
- // Just walk the entire focus loop from where we're at until we reach the end.
- View* new_focused = NULL;
- View* last_focused = focused_view_;
- while ((new_focused = GetNextFocusableView(last_focused, false, true)))
- last_focused = new_focused;
- return last_focused;
-}
-
void FocusManager::SetFocusedView(View* view) {
if (focused_view_ != view) {
View* prev_focused_view = focused_view_;
diff --git a/views/focus/focus_manager.h b/views/focus/focus_manager.h
index 59e9b3b..fb48188 100644
--- a/views/focus/focus_manager.h
+++ b/views/focus/focus_manager.h
@@ -299,9 +299,6 @@ class FocusManager {
// Returns the next focusable view.
View* GetNextFocusableView(View* starting_view, bool reverse, bool dont_loop);
- // Returns the last view of the focus traversal hierarchy.
- View* FindLastFocusableView();
-
// Returns the focusable view found in the FocusTraversable specified starting
// at the specified view. This traverses down along the FocusTraversable
// hierarchy.
diff --git a/views/focus/focus_manager_unittest.cc b/views/focus/focus_manager_unittest.cc
index 4821112..cc56271 100644
--- a/views/focus/focus_manager_unittest.cc
+++ b/views/focus/focus_manager_unittest.cc
@@ -885,11 +885,8 @@ TEST_F(FocusTraversalTest, NormalTraversal) {
}
}
- // Focus the 1st item.
- GetFocusManager()->SetFocusedView(
- content_view_->GetViewByID(kTraversalIDs[0]));
-
// Let's traverse in reverse order.
+ GetFocusManager()->SetFocusedView(NULL);
for (int i = 0; i < 3; ++i) {
for (int j = arraysize(kTraversalIDs) - 1; j >= 0; --j) {
GetFocusManager()->AdvanceFocus(true);
@@ -931,6 +928,7 @@ TEST_F(FocusTraversalTest, TraversalWithNonEnabledViews) {
View* focused_view;
// Let's do one traversal (several times, to make sure it loops ok).
+ GetFocusManager()->SetFocusedView(NULL);
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < arraysize(kTraversalIDs); j++) {
GetFocusManager()->AdvanceFocus(false);
@@ -941,14 +939,8 @@ TEST_F(FocusTraversalTest, TraversalWithNonEnabledViews) {
}
}
- // Focus the 1st item.
- GetFocusManager()->AdvanceFocus(false);
- focused_view = GetFocusManager()->GetFocusedView();
- EXPECT_TRUE(focused_view != NULL);
- if (focused_view)
- EXPECT_EQ(kTraversalIDs[0], focused_view->GetID());
-
// Same thing in reverse.
+ GetFocusManager()->SetFocusedView(NULL);
for (int i = 0; i < 3; ++i) {
for (int j = arraysize(kTraversalIDs) - 1; j >= 0; --j) {
GetFocusManager()->AdvanceFocus(true);