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

Side by Side Diff: ui/views/window/dialog_client_view.cc

Issue 1690133003: DialogClientView: Correct the order in which subviews are focused. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments. Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « ui/views/window/dialog_client_view.h ('k') | ui/views/window/dialog_client_view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/window/dialog_client_view.h" 5 #include "ui/views/window/dialog_client_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "ui/events/keycodes/keyboard_codes.h" 10 #include "ui/events/keycodes/keyboard_codes.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 245
246 void DialogClientView::ViewHierarchyChanged( 246 void DialogClientView::ViewHierarchyChanged(
247 const ViewHierarchyChangedDetails& details) { 247 const ViewHierarchyChangedDetails& details) {
248 ClientView::ViewHierarchyChanged(details); 248 ClientView::ViewHierarchyChanged(details);
249 if (details.is_add && details.child == this) { 249 if (details.is_add && details.child == this) {
250 UpdateDialogButtons(); 250 UpdateDialogButtons();
251 CreateExtraView(); 251 CreateExtraView();
252 CreateFootnoteView(); 252 CreateFootnoteView();
253 } else if (!details.is_add && details.child != this) { 253 } else if (!details.is_add && details.child != this) {
254 if (details.child == ok_button_) 254 if (details.child == ok_button_)
255 ok_button_ = NULL; 255 ok_button_ = nullptr;
256 if (details.child == cancel_button_) 256 else if (details.child == cancel_button_)
257 cancel_button_ = NULL; 257 cancel_button_ = nullptr;
258 else if (details.child == extra_view_)
259 extra_view_ = nullptr;
260 else if (details.child == footnote_view_)
261 footnote_view_ = nullptr;
258 } 262 }
263
264 SetupFocusChain();
259 } 265 }
260 266
261 void DialogClientView::OnNativeThemeChanged(const ui::NativeTheme* theme) { 267 void DialogClientView::OnNativeThemeChanged(const ui::NativeTheme* theme) {
262 // The old dialog style needs an explicit background color, while the new 268 // The old dialog style needs an explicit background color, while the new
263 // dialog style simply inherits the bubble's frame view color. 269 // dialog style simply inherits the bubble's frame view color.
264 const DialogDelegate* dialog = GetDialogDelegate(); 270 const DialogDelegate* dialog = GetDialogDelegate();
265 271
266 if (dialog && !dialog->UseNewStyleForThisDialog()) { 272 if (dialog && !dialog->UseNewStyleForThisDialog()) {
267 set_background(views::Background::CreateSolidBackground(GetNativeTheme()-> 273 set_background(views::Background::CreateSolidBackground(GetNativeTheme()->
268 GetSystemColor(ui::NativeTheme::kColorId_DialogBackground))); 274 GetSystemColor(ui::NativeTheme::kColorId_DialogBackground)));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 return GetButtonsAndExtraViewRowHeight() == 0 ? gfx::Insets() : 379 return GetButtonsAndExtraViewRowHeight() == 0 ? gfx::Insets() :
374 gfx::Insets(0, kButtonHEdgeMarginNew, 380 gfx::Insets(0, kButtonHEdgeMarginNew,
375 kButtonVEdgeMarginNew, kButtonHEdgeMarginNew); 381 kButtonVEdgeMarginNew, kButtonHEdgeMarginNew);
376 } 382 }
377 383
378 void DialogClientView::Close() { 384 void DialogClientView::Close() {
379 GetWidget()->Close(); 385 GetWidget()->Close();
380 GetDialogDelegate()->OnClosed(); 386 GetDialogDelegate()->OnClosed();
381 } 387 }
382 388
389 void DialogClientView::SetupFocusChain() {
390 // Create a vector of child views in the order of intended focus.
391 std::vector<View*> child_views;
392 child_views.push_back(contents_view());
393 child_views.push_back(extra_view_);
394 if (kIsOkButtonOnLeftSide) {
395 child_views.push_back(ok_button_);
396 child_views.push_back(cancel_button_);
397 } else {
398 child_views.push_back(cancel_button_);
399 child_views.push_back(ok_button_);
400 }
401 child_views.push_back(footnote_view_);
402
403 // Remove all null views from the vector.
404 child_views.erase(
405 std::remove(child_views.begin(), child_views.end(), nullptr),
406 child_views.end());
407
408 // Setup focus.
409 for (size_t i = 0; i < child_views.size(); i++) {
410 child_views[i]->SetNextFocusableView(
411 i + 1 != child_views.size() ? child_views[i + 1] : nullptr);
412 }
413 }
414
383 } // namespace views 415 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/window/dialog_client_view.h ('k') | ui/views/window/dialog_client_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698