Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Unified Diff: ui/views/view.cc

Issue 108063004: Give up focus if the focused view becomes unfocusable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Try to advance focus first Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/views/view.cc
diff --git a/ui/views/view.cc b/ui/views/view.cc
index f74d0f9e79014748448da8bbece2de023ab2217d..1f6ffaa90a2dab1037cdc7e377ed07e78da9d957 100644
--- a/ui/views/view.cc
+++ b/ui/views/view.cc
@@ -453,6 +453,7 @@ void View::SetVisible(bool visible) {
SchedulePaint();
visible_ = visible;
+ ReviseFocusedView();
// Notify the parent.
if (parent_)
@@ -475,6 +476,7 @@ bool View::IsDrawn() const {
void View::SetEnabled(bool enabled) {
if (enabled != enabled_) {
enabled_ = enabled;
+ ReviseFocusedView();
OnEnabledChanged();
}
}
@@ -1205,6 +1207,14 @@ void View::SetNextFocusableView(View* view) {
next_focusable_view_ = view;
}
+void View::SetFocusable(bool focusable) {
+ if (focusable_ == focusable)
+ return;
+
+ focusable_ = focusable;
+ ReviseFocusedView();
+}
+
bool View::IsFocusable() const {
return focusable_ && enabled_ && IsDrawn();
}
@@ -1213,6 +1223,14 @@ bool View::IsAccessibilityFocusable() const {
return (focusable_ || accessibility_focusable_) && enabled_ && IsDrawn();
}
+void View::SetAccessibilityFocusable(bool accessibility_focusable) {
+ if (accessibility_focusable_ == accessibility_focusable)
+ return;
+
+ accessibility_focusable_ = accessibility_focusable;
+ ReviseFocusedView();
+}
+
FocusManager* View::GetFocusManager() {
Widget* widget = GetWidget();
return widget ? widget->GetFocusManager() : NULL;
@@ -2336,6 +2354,12 @@ void View::InitFocusSiblings(View* v, int index) {
}
}
+void View::ReviseFocusedView() {
+ FocusManager* focus_manager = GetFocusManager();
+ if (focus_manager)
+ focus_manager->ReviseFocusedView();
+}
+
// System events ---------------------------------------------------------------
void View::PropagateThemeChanged() {
« no previous file with comments | « ui/views/view.h ('k') | ui/views/view_unittest.cc » ('j') | ui/views/view_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698