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

Unified Diff: ui/views/window/dialog_client_view.cc

Issue 1826433002: DialogClientView: Fix regression in Chrome Task Manager focusing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 4 years, 8 months 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
« no previous file with comments | « no previous file | ui/views/window/dialog_client_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/window/dialog_client_view.cc
diff --git a/ui/views/window/dialog_client_view.cc b/ui/views/window/dialog_client_view.cc
index 62a800c138bb519c60bbd6fe74e8c2e4201fae1c..5b65adb73bd38ba535d53ede80659b3e87565d14 100644
--- a/ui/views/window/dialog_client_view.cc
+++ b/ui/views/window/dialog_client_view.cc
@@ -112,6 +112,8 @@ void DialogClientView::UpdateDialogButtons() {
delete cancel_button_;
cancel_button_ = NULL;
}
+
+ SetupFocusChain();
}
///////////////////////////////////////////////////////////////////////////////
@@ -233,8 +235,6 @@ void DialogClientView::ViewHierarchyChanged(
else if (details.child == extra_view_)
extra_view_ = nullptr;
}
-
- SetupFocusChain();
}
void DialogClientView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
@@ -286,6 +286,7 @@ void DialogClientView::CreateExtraView() {
if (extra_view_) {
extra_view_->SetGroup(kButtonGroup);
AddChildView(extra_view_);
+ SetupFocusChain();
}
}
@@ -352,11 +353,10 @@ void DialogClientView::SetupFocusChain() {
std::remove(child_views.begin(), child_views.end(), nullptr),
child_views.end());
- // Setup focus.
- for (size_t i = 0; i < child_views.size(); i++) {
- child_views[i]->SetNextFocusableView(
- i + 1 != child_views.size() ? child_views[i + 1] : nullptr);
- }
+ // Setup focus by reordering views. It is not safe to use SetNextFocusableView
+ // since child views may be added externally to this view.
+ for (size_t i = 0; i < child_views.size(); i++)
+ ReorderChildView(child_views[i], i);
}
} // namespace views
« no previous file with comments | « no previous file | ui/views/window/dialog_client_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698