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

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 nits. 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. As a result, if the
966 // location bar is focused it will end up resigning 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/09 01:50:34 optional nit: if ([self locationBarHasFocus]) and
shrike 2017/02/09 02:18:29 The problem is that [self setContentViewSubviews:s
spqchan 2017/02/09 05:09:36 Ah, gotcha
972 [self focusLocationBar:YES];
966 } 973 }
967 974
968 - (void)updateSubviewZOrderFullscreen { 975 - (void)updateSubviewZOrderFullscreen {
969 base::scoped_nsobject<NSMutableArray> subviews([[NSMutableArray alloc] init]); 976 base::scoped_nsobject<NSMutableArray> subviews([[NSMutableArray alloc] init]);
970 977
971 // The infobar should overlay the toolbar if the toolbar is fully shown. 978 // The infobar should overlay the toolbar if the toolbar is fully shown.
972 FullscreenToolbarLayout layout = [fullscreenToolbarController_ computeLayout]; 979 FullscreenToolbarLayout layout = [fullscreenToolbarController_ computeLayout];
973 BOOL shouldInfoBarOverlayToolbar = 980 BOOL shouldInfoBarOverlayToolbar =
974 ui::IsCGFloatEqual(layout.toolbarFraction, 1.0); 981 ui::IsCGFloatEqual(layout.toolbarFraction, 1.0);
975 982
(...skipping 19 matching lines...) Expand all
995 1002
996 if ([toolbarController_ view]) 1003 if ([toolbarController_ view])
997 [subviews addObject:[toolbarController_ view]]; 1004 [subviews addObject:[toolbarController_ view]];
998 1005
999 if (shouldInfoBarOverlayToolbar && [infoBarContainerController_ view]) 1006 if (shouldInfoBarOverlayToolbar && [infoBarContainerController_ view])
1000 [subviews addObject:[infoBarContainerController_ view]]; 1007 [subviews addObject:[infoBarContainerController_ view]];
1001 1008
1002 if ([findBarCocoaController_ view]) 1009 if ([findBarCocoaController_ view])
1003 [subviews addObject:[findBarCocoaController_ view]]; 1010 [subviews addObject:[findBarCocoaController_ view]];
1004 1011
1012 // -setContentViewSubviews: changes the view hierarchy, and if the
1013 // location bar is focused will cause it to resign first responder.
1014 // Remember the location bar's focus state and restore it after changing the
1015 // view hierarchy.
1016 BOOL locationBarHadFocus = [self locationBarHasFocus];
1005 [self setContentViewSubviews:subviews]; 1017 [self setContentViewSubviews:subviews];
1018 if (locationBarHadFocus) {
spqchan 2017/02/09 01:50:34 Ditto from above
1019 [self focusLocationBar:YES];
1020 }
1006 } 1021 }
1007 1022
1008 - (void)setContentViewSubviews:(NSArray*)subviews { 1023 - (void)setContentViewSubviews:(NSArray*)subviews {
1009 // Subviews already match. 1024 // Subviews already match.
1010 if ([[self.chromeContentView subviews] isEqual:subviews]) 1025 if ([[self.chromeContentView subviews] isEqual:subviews])
1011 return; 1026 return;
1012 1027
1013 // The tabContentArea isn't a subview, so just set all the subviews. 1028 // The tabContentArea isn't a subview, so just set all the subviews.
1014 NSView* tabContentArea = [self tabContentArea]; 1029 NSView* tabContentArea = [self tabContentArea];
1015 if (![[self.chromeContentView subviews] containsObject:tabContentArea]) { 1030 if (![[self.chromeContentView subviews] containsObject:tabContentArea]) {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 if (fullscreenLowPowerCoordinator_) 1207 if (fullscreenLowPowerCoordinator_)
1193 fullscreenLowPowerCoordinator_->SetHasActiveSheet(false); 1208 fullscreenLowPowerCoordinator_->SetHasActiveSheet(false);
1194 } 1209 }
1195 1210
1196 - (void)childWindowsDidChange { 1211 - (void)childWindowsDidChange {
1197 if (fullscreenLowPowerCoordinator_) 1212 if (fullscreenLowPowerCoordinator_)
1198 fullscreenLowPowerCoordinator_->ChildWindowsChanged(); 1213 fullscreenLowPowerCoordinator_->ChildWindowsChanged();
1199 } 1214 }
1200 1215
1201 @end // @implementation BrowserWindowController(Private) 1216 @end // @implementation BrowserWindowController(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698