summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-13 18:27:38 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-13 18:27:38 +0000
commit830e2069f5c67d74cd4f2720438ea6a9609994c3 (patch)
treeb282e9c8661b9a041c5ae638b1361d9e3b0901d0
parent8ad2ac49bd0bff04d92162f5e215398eb5372cec (diff)
downloadchromium_src-830e2069f5c67d74cd4f2720438ea6a9609994c3.zip
chromium_src-830e2069f5c67d74cd4f2720438ea6a9609994c3.tar.gz
chromium_src-830e2069f5c67d74cd4f2720438ea6a9609994c3.tar.bz2
Don't focus unfocusable things.
Review URL: http://codereview.chromium.org/20348 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9765 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/tab_contents/tab_contents.cc11
-rw-r--r--chrome/views/base_button.cc3
-rw-r--r--chrome/views/menu_button.cc3
-rw-r--r--chrome/views/native_button.cc3
-rw-r--r--chrome/views/view.cc3
5 files changed, 11 insertions, 12 deletions
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 7a9124f..c928031 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -391,12 +391,15 @@ void TabContents::RestoreFocus() {
// If you hit this DCHECK, please report it to Jay (jcampan).
DCHECK(focus_manager != NULL) << "No focus manager when restoring focus.";
- if (focus_manager && focus_manager->ContainsView(last_focused_view)) {
+ if (last_focused_view->IsFocusable() && focus_manager &&
+ focus_manager->ContainsView(last_focused_view)) {
last_focused_view->RequestFocus();
} else {
- // The focused view may not belong to the same window hierarchy (for
- // example if the location bar was focused and the tab is dragged out).
- // In that case we default to the default focus.
+ // The focused view may not belong to the same window hierarchy (e.g.
+ // if the location bar was focused and the tab is dragged out), or it may
+ // no longer be focusable (e.g. if the location bar was focused and then
+ // we switched to fullscreen mode). In that case we default to the
+ // default focus.
SetInitialFocus();
}
view_storage->RemoveView(last_focused_view_storage_id_);
diff --git a/chrome/views/base_button.cc b/chrome/views/base_button.cc
index bd4987b..bea0c2f 100644
--- a/chrome/views/base_button.cc
+++ b/chrome/views/base_button.cc
@@ -147,8 +147,7 @@ bool BaseButton::OnMousePressed(const MouseEvent& e) {
if (IsTriggerableEvent(e) && HitTest(e.location())) {
SetState(BS_PUSHED);
}
- if (IsFocusable())
- RequestFocus();
+ RequestFocus();
}
return true;
}
diff --git a/chrome/views/menu_button.cc b/chrome/views/menu_button.cc
index 0b696ff..ff0400a 100644
--- a/chrome/views/menu_button.cc
+++ b/chrome/views/menu_button.cc
@@ -180,8 +180,7 @@ bool MenuButton::Activate() {
}
bool MenuButton::OnMousePressed(const MouseEvent& e) {
- if (IsFocusable())
- RequestFocus();
+ RequestFocus();
if (GetState() != BS_DISABLED) {
// If we're draggable (GetDragOperations returns a non-zero value), then
// don't pop on press, instead wait for release.
diff --git a/chrome/views/native_button.cc b/chrome/views/native_button.cc
index 00aea52..d6db326 100644
--- a/chrome/views/native_button.cc
+++ b/chrome/views/native_button.cc
@@ -191,8 +191,7 @@ void NativeButton::Init(const std::wstring& label, bool is_default) {
void NativeButton::Clicked() {
DCHECK(enabled_);
// Give the focus to the button.
- if (IsFocusable())
- RequestFocus();
+ RequestFocus();
if (listener_)
listener_->ButtonPressed(this);
diff --git a/chrome/views/view.cc b/chrome/views/view.cc
index 3a06c3b..59e5b73 100644
--- a/chrome/views/view.cc
+++ b/chrome/views/view.cc
@@ -1372,9 +1372,8 @@ bool View::IsVisibleInRootView() const {
void View::RequestFocus() {
RootView* rv = GetRootView();
- if (rv) {
+ if (rv && IsFocusable())
rv->FocusView(this);
- }
}
void View::WillGainFocus() {