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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/browser_window_controller_private.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
index f084fb039ddfc634afb1cc0415d6dd245e856c66..5cb48760ddcfe063f7cf2857b6f82784e82695d8 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -962,7 +962,14 @@ willPositionSheet:(NSWindow*)sheet
if ([findBarCocoaController_ view])
[subviews addObject:[findBarCocoaController_ view]];
+ // -setContentViewSubviews: changes the view hierarchy. As a result, if the
+ // location bar is focused it will end up resigning first responder.
+ // Remember the location bar's focus state and restore it after changing the
+ // view hierarchy.
+ BOOL locationBarHadFocus = [self locationBarHasFocus];
[self setContentViewSubviews:subviews];
+ 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
+ [self focusLocationBar:YES];
}
- (void)updateSubviewZOrderFullscreen {
@@ -1002,7 +1009,15 @@ willPositionSheet:(NSWindow*)sheet
if ([findBarCocoaController_ view])
[subviews addObject:[findBarCocoaController_ view]];
+ // -setContentViewSubviews: changes the view hierarchy, and if the
+ // location bar is focused will cause it to resign first responder.
+ // Remember the location bar's focus state and restore it after changing the
+ // view hierarchy.
+ BOOL locationBarHadFocus = [self locationBarHasFocus];
[self setContentViewSubviews:subviews];
+ if (locationBarHadFocus) {
spqchan 2017/02/09 01:50:34 Ditto from above
+ [self focusLocationBar:YES];
+ }
}
- (void)setContentViewSubviews:(NSArray*)subviews {

Powered by Google App Engine
This is Rietveld 408576698