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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_private.mm

Issue 2679273002: [Mac] Retain location bar focus on switching to fullscreen and back. (Closed)
Patch Set: Fix regression with the toolbar not dropping down. Created 3 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
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 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #import "base/auto_reset.h" 9 #import "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
955 [subviews addObject:[bookmarkBarController_ view]]; 955 [subviews addObject:[bookmarkBarController_ view]];
956 if ([toolbarController_ view]) 956 if ([toolbarController_ view])
957 [subviews addObject:[toolbarController_ view]]; 957 [subviews addObject:[toolbarController_ view]];
958 if ([infoBarContainerController_ view]) 958 if ([infoBarContainerController_ view])
959 [subviews addObject:[infoBarContainerController_ view]]; 959 [subviews addObject:[infoBarContainerController_ view]];
960 if ([self tabContentArea]) 960 if ([self tabContentArea])
961 [subviews addObject:[self tabContentArea]]; 961 [subviews addObject:[self tabContentArea]];
962 if ([findBarCocoaController_ view]) 962 if ([findBarCocoaController_ view])
963 [subviews addObject:[findBarCocoaController_ view]]; 963 [subviews addObject:[findBarCocoaController_ view]];
964 964
965 // -setContentViewSubviews: changes the view hierarchy, and if the
spqchan 2017/02/08 19:21:50 "is focused will" -> "is focused, it will
shrike 2017/02/08 19:51:42 I massaged it a bit more to avoid "it will cause i
966 // location bar is focused will cause it to resign first responder.
967 // Remember the location bar's focus state and restore it after changing the
968 // view hierarchy.
969 BOOL locationBarHadFocus = [self locationBarHasFocus];
965 [self setContentViewSubviews:subviews]; 970 [self setContentViewSubviews:subviews];
971 if (locationBarHadFocus) {
spqchan 2017/02/08 19:21:50 nit: No curly brackets required. Also maybe you ca
shrike 2017/02/08 19:51:42 I removed the curly braces. Coding if statements w
spqchan 2017/02/09 01:50:34 Hey, to be fair, the reason I use this style in th
shrike 2017/02/09 02:18:29 I hear you that your reviewers told you that curly
spqchan 2017/02/09 05:09:36 Makes sense. Since the codebase will be changed so
972 [self focusLocationBar:YES];
973 }
966 } 974 }
967 975
968 - (void)updateSubviewZOrderFullscreen { 976 - (void)updateSubviewZOrderFullscreen {
969 base::scoped_nsobject<NSMutableArray> subviews([[NSMutableArray alloc] init]); 977 base::scoped_nsobject<NSMutableArray> subviews([[NSMutableArray alloc] init]);
970 978
971 // The infobar should overlay the toolbar if the toolbar is fully shown. 979 // The infobar should overlay the toolbar if the toolbar is fully shown.
972 FullscreenToolbarLayout layout = [fullscreenToolbarController_ computeLayout]; 980 FullscreenToolbarLayout layout = [fullscreenToolbarController_ computeLayout];
973 BOOL shouldInfoBarOverlayToolbar = 981 BOOL shouldInfoBarOverlayToolbar =
974 ui::IsCGFloatEqual(layout.toolbarFraction, 1.0); 982 ui::IsCGFloatEqual(layout.toolbarFraction, 1.0);
975 983
(...skipping 19 matching lines...) Expand all
995 1003
996 if ([toolbarController_ view]) 1004 if ([toolbarController_ view])
997 [subviews addObject:[toolbarController_ view]]; 1005 [subviews addObject:[toolbarController_ view]];
998 1006
999 if (shouldInfoBarOverlayToolbar && [infoBarContainerController_ view]) 1007 if (shouldInfoBarOverlayToolbar && [infoBarContainerController_ view])
1000 [subviews addObject:[infoBarContainerController_ view]]; 1008 [subviews addObject:[infoBarContainerController_ view]];
1001 1009
1002 if ([findBarCocoaController_ view]) 1010 if ([findBarCocoaController_ view])
1003 [subviews addObject:[findBarCocoaController_ view]]; 1011 [subviews addObject:[findBarCocoaController_ view]];
1004 1012
1013 // -setContentViewSubviews: changes the view hierarchy, and if the
1014 // location bar is focused will cause it to resign first responder.
1015 // Remember the location bar's focus state and restore it after changing the
1016 // view hierarchy.
1017 BOOL locationBarHadFocus = [self locationBarHasFocus];
1005 [self setContentViewSubviews:subviews]; 1018 [self setContentViewSubviews:subviews];
1019 if (locationBarHadFocus) {
1020 [self focusLocationBar:YES];
1021 }
1006 } 1022 }
1007 1023
1008 - (void)setContentViewSubviews:(NSArray*)subviews { 1024 - (void)setContentViewSubviews:(NSArray*)subviews {
1009 // Subviews already match. 1025 // Subviews already match.
1010 if ([[self.chromeContentView subviews] isEqual:subviews]) 1026 if ([[self.chromeContentView subviews] isEqual:subviews])
1011 return; 1027 return;
1012 1028
1013 // The tabContentArea isn't a subview, so just set all the subviews. 1029 // The tabContentArea isn't a subview, so just set all the subviews.
1014 NSView* tabContentArea = [self tabContentArea]; 1030 NSView* tabContentArea = [self tabContentArea];
1015 if (![[self.chromeContentView subviews] containsObject:tabContentArea]) { 1031 if (![[self.chromeContentView subviews] containsObject:tabContentArea]) {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 if (fullscreenLowPowerCoordinator_) 1208 if (fullscreenLowPowerCoordinator_)
1193 fullscreenLowPowerCoordinator_->SetHasActiveSheet(false); 1209 fullscreenLowPowerCoordinator_->SetHasActiveSheet(false);
1194 } 1210 }
1195 1211
1196 - (void)childWindowsDidChange { 1212 - (void)childWindowsDidChange {
1197 if (fullscreenLowPowerCoordinator_) 1213 if (fullscreenLowPowerCoordinator_)
1198 fullscreenLowPowerCoordinator_->ChildWindowsChanged(); 1214 fullscreenLowPowerCoordinator_->ChildWindowsChanged();
1199 } 1215 }
1200 1216
1201 @end // @implementation BrowserWindowController(Private) 1217 @end // @implementation BrowserWindowController(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698