summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorklink@chromium.org <klink@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 21:54:40 +0000
committerklink@chromium.org <klink@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-06 21:54:40 +0000
commit6b4de6b36e8060902307a3e3da9f8693b0751c63 (patch)
tree1f27476a1197f5a2933f2d86cab5d4864dc312b6
parent6e55c884916468a05c9d3f1ed4d4641609d98353 (diff)
downloadchromium_src-6b4de6b36e8060902307a3e3da9f8693b0751c63.zip
chromium_src-6b4de6b36e8060902307a3e3da9f8693b0751c63.tar.gz
chromium_src-6b4de6b36e8060902307a3e3da9f8693b0751c63.tar.bz2
Enables restoring of keyboard focus to the the toolbar button that last had focus, before focus was lost (e.g to a dialog, another window, etc). Setting focus using the toolbar focus keyboard shortcut will still reset focus to the first enabled, visible button (starting at the Back button).
BUG=5750 Review URL: http://codereview.chromium.org/15098 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7620 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/views/frame/browser_view.cc3
-rw-r--r--chrome/browser/views/toolbar_view.cc36
-rw-r--r--chrome/browser/views/toolbar_view.h6
3 files changed, 30 insertions, 15 deletions
diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc
index c6ead0d..ab15b9c 100644
--- a/chrome/browser/views/frame/browser_view.cc
+++ b/chrome/browser/views/frame/browser_view.cc
@@ -501,6 +501,9 @@ void BrowserView::UpdateToolbar(TabContents* contents,
}
void BrowserView::FocusToolbar() {
+ // Do not restore the button that previously had accessibility focus, if
+ // focus is set by using the toolbar focus keyboard shortcut.
+ toolbar_->set_acc_focused_view(NULL);
toolbar_->RequestFocus();
}
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index 855f8a7..ffd423d 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -343,28 +343,35 @@ void BrowserToolbarView::Layout() {
}
void BrowserToolbarView::DidGainFocus() {
- // Find first accessible child (-1 for start search at parent).
- int first_acc_child = GetNextAccessibleViewIndex(-1, false);
-
- // No buttons enabled or visible.
- if (first_acc_child == -1)
- return;
-
- acc_focused_view_ = GetChildViewAt(first_acc_child);
+ // Check to see if MSAA focus should be restored to previously focused button,
+ // and if button is an enabled, visibled child of toolbar.
+ if (!acc_focused_view() ||
+ (acc_focused_view()->GetParent()->GetID() != VIEW_ID_TOOLBAR) ||
+ !acc_focused_view()->IsEnabled() ||
+ !acc_focused_view()->IsVisible()) {
+ // Find first accessible child (-1 to start search at parent).
+ int first_acc_child = GetNextAccessibleViewIndex(-1, false);
+
+ // No buttons enabled or visible.
+ if (first_acc_child == -1)
+ return;
+
+ set_acc_focused_view(GetChildViewAt(first_acc_child));
+ }
// Default focus is on the toolbar.
int view_index = VIEW_ID_TOOLBAR;
// Set hot-tracking for child, and update focused_view for MSAA focus event.
- if (acc_focused_view_) {
- acc_focused_view_->SetHotTracked(true);
+ if (acc_focused_view()) {
+ acc_focused_view()->SetHotTracked(true);
// Show the tooltip for the view that got the focus.
if (GetWidget()->GetTooltipManager())
GetWidget()->GetTooltipManager()->ShowKeyboardTooltip(acc_focused_view_);
// Update focused_view with MSAA-adjusted child id.
- view_index = acc_focused_view_->GetID();
+ view_index = acc_focused_view()->GetID();
}
HWND hwnd = GetWidget()->GetHWND();
@@ -375,12 +382,13 @@ void BrowserToolbarView::DidGainFocus() {
}
void BrowserToolbarView::WillLoseFocus() {
- // Resetting focus state.
- acc_focused_view_->SetHotTracked(false);
+ if (acc_focused_view()) {
+ // Resetting focus state.
+ acc_focused_view()->SetHotTracked(false);
+ }
// Any tooltips that are active should be hidden when toolbar loses focus.
if (GetWidget() && GetWidget()->GetTooltipManager())
GetWidget()->GetTooltipManager()->HideKeyboardTooltip();
- acc_focused_view_ = NULL;
}
bool BrowserToolbarView::OnKeyPressed(const views::KeyEvent& e) {
diff --git a/chrome/browser/views/toolbar_view.h b/chrome/browser/views/toolbar_view.h
index 879c107..a927f0c 100644
--- a/chrome/browser/views/toolbar_view.h
+++ b/chrome/browser/views/toolbar_view.h
@@ -103,10 +103,14 @@ class BrowserToolbarView : public views::View,
// first accessible child, based on the above policy.
int GetNextAccessibleViewIndex(int view_index, bool nav_left);
- views::View* GetAccFocusedChildView() {
+ views::View* acc_focused_view() {
return acc_focused_view_;
}
+ void set_acc_focused_view(views::View* acc_focused_view) {
+ acc_focused_view_ = acc_focused_view;
+ }
+
// Returns the selected tab.
virtual TabContents* GetTabContents();