diff options
-rw-r--r-- | chrome/browser/cocoa/browser_frame_view.mm | 2 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.h | 3 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller_private.mm | 62 | ||||
-rw-r--r-- | chrome/browser/cocoa/fullscreen_controller.h | 9 | ||||
-rw-r--r-- | chrome/browser/cocoa/fullscreen_controller.mm | 9 |
6 files changed, 49 insertions, 40 deletions
diff --git a/chrome/browser/cocoa/browser_frame_view.mm b/chrome/browser/cocoa/browser_frame_view.mm index a30807f..3189acf 100644 --- a/chrome/browser/cocoa/browser_frame_view.mm +++ b/chrome/browser/cocoa/browser_frame_view.mm @@ -14,7 +14,7 @@ #import "chrome/browser/cocoa/themed_window.h" #include "grit/theme_resources.h" -static const CGFloat kBrowserFrameViewPaintHeight = 52.0; +static const CGFloat kBrowserFrameViewPaintHeight = 60.0; static const NSPoint kBrowserFrameViewPatternPhaseOffset = { -5, 3 }; @interface NSView (Swizzles) diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h index b6b95a9..64b9696 100644 --- a/chrome/browser/cocoa/browser_window_controller.h +++ b/chrome/browser/cocoa/browser_window_controller.h @@ -100,7 +100,8 @@ class TabStripModelObserverBridge; scoped_nsobject<IncognitoImageView> incognitoBadge_; // Lazily created view which draws the background for the floating set of bars - // in fullscreen mode. + // in fullscreen mode (for window types having a floating bar; it remains nil + // for those which don't). scoped_nsobject<NSView> floatingBarBackingView_; // Tracks whether the floating bar is above or below the bookmark bar, in diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index 0e47bd1..de01113 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -434,7 +434,7 @@ // TODO(viettrungluu): For some reason, the above doesn't suffice. if ([self isFullscreen]) - [floatingBarBackingView_ setNeedsDisplay:YES]; + [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil. } - (void)windowDidResignMain:(NSNotification*)notification { @@ -444,7 +444,7 @@ // TODO(viettrungluu): For some reason, the above doesn't suffice. if ([self isFullscreen]) - [floatingBarBackingView_ setNeedsDisplay:YES]; + [floatingBarBackingView_ setNeedsDisplay:YES]; // Okay even if nil. } // Called when we are activated (when we gain focus). diff --git a/chrome/browser/cocoa/browser_window_controller_private.mm b/chrome/browser/cocoa/browser_window_controller_private.mm index 5251112..f05b02b2 100644 --- a/chrome/browser/cocoa/browser_window_controller_private.mm +++ b/chrome/browser/cocoa/browser_window_controller_private.mm @@ -140,8 +140,11 @@ willPositionSheet:(NSWindow*)sheet BOOL isFullscreen = [self isFullscreen]; CGFloat floatingBarHeight = [self floatingBarHeight]; - CGFloat yOffset = floor( - isFullscreen ? (1 - floatingBarShownFraction_) * floatingBarHeight : 0); + // In fullscreen mode, |yOffset| accounts for the sliding position of the + // floating bar and the extra offset needed to dodge the menu bar. + CGFloat yOffset = isFullscreen ? + (floor((1 - floatingBarShownFraction_) * floatingBarHeight) - + [fullscreenController_ floatingBarVerticalOffset]) : 0; CGFloat maxY = NSMaxY(contentBounds) + yOffset; CGFloat startMaxY = maxY; @@ -171,8 +174,6 @@ willPositionSheet:(NSWindow*)sheet height:floatingBarHeight fullscreen:isFullscreen]; - [fullscreenController_ overlayFrameChanged:[floatingBarBackingView_ frame]]; - // Place the find bar immediately below the toolbar/attached bookmark bar. In // fullscreen mode, it hangs off the top of the screen when the bar is hidden. [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:width]; @@ -209,7 +210,7 @@ willPositionSheet:(NSWindow*)sheet if (![self isFullscreen]) return 0; - CGFloat totalHeight = [fullscreenController_ tabStripVerticalOffset]; + CGFloat totalHeight = [fullscreenController_ floatingBarVerticalOffset]; if ([self hasTabStrip]) totalHeight += NSHeight([[self tabStripView] frame]); @@ -218,7 +219,7 @@ willPositionSheet:(NSWindow*)sheet totalHeight += NSHeight([[toolbarController_ view] frame]); } else if ([self hasLocationBar]) { totalHeight += NSHeight([[toolbarController_ view] frame]) + - kLocBarTopInset + kLocBarBottomInset; + kLocBarTopInset + kLocBarBottomInset; } if (![self placeBookmarkBarBelowInfoBar]) @@ -236,10 +237,6 @@ willPositionSheet:(NSWindow*)sheet NSView* tabStripView = [self tabStripView]; CGFloat tabStripHeight = NSHeight([tabStripView frame]); - // In fullscreen mode, push the tab strip down so that the main menu (which - // also slides down) doesn't run it over. - if (fullscreen) - maxY -= [fullscreenController_ tabStripVerticalOffset]; maxY -= tabStripHeight; [tabStripView setFrame:NSMakeRect(0, maxY, width, tabStripHeight)]; @@ -327,25 +324,33 @@ willPositionSheet:(NSWindow*)sheet fullscreen:(BOOL)fullscreen { // Only display when in fullscreen mode. if (fullscreen) { - DCHECK(floatingBarBackingView_.get()); - BOOL aboveBookmarkBar = [self placeBookmarkBarBelowInfoBar]; - - // Insert it into the view hierarchy if necessary. - if (![floatingBarBackingView_ superview] || - aboveBookmarkBar != floatingBarAboveBookmarkBar_) { - NSView* contentView = [[self window] contentView]; - // z-order gets messed up unless we explicitly remove the floatingbar view - // and re-add it. - [floatingBarBackingView_ removeFromSuperview]; - [contentView addSubview:floatingBarBackingView_ - positioned:(aboveBookmarkBar ? - NSWindowAbove : NSWindowBelow) - relativeTo:[bookmarkBarController_ view]]; - floatingBarAboveBookmarkBar_ = aboveBookmarkBar; + // For certain window types such as app windows (e.g., the dev tools + // window), there's no actual overlay. (Displaying one would result in an + // overly sliding in only under the menu, which gives an ugly effect.) + NSRect frame = NSMakeRect(0, y, width, height); + if (floatingBarBackingView_.get()) { + BOOL aboveBookmarkBar = [self placeBookmarkBarBelowInfoBar]; + + // Insert it into the view hierarchy if necessary. + if (![floatingBarBackingView_ superview] || + aboveBookmarkBar != floatingBarAboveBookmarkBar_) { + NSView* contentView = [[self window] contentView]; + // z-order gets messed up unless we explicitly remove the floatingbar + // view and re-add it. + [floatingBarBackingView_ removeFromSuperview]; + [contentView addSubview:floatingBarBackingView_ + positioned:(aboveBookmarkBar ? + NSWindowAbove : NSWindowBelow) + relativeTo:[bookmarkBarController_ view]]; + floatingBarAboveBookmarkBar_ = aboveBookmarkBar; + } + + // Set its frame. + [floatingBarBackingView_ setFrame:frame]; } - // Set its frame. - [floatingBarBackingView_ setFrame:NSMakeRect(0, y, width, height)]; + // But we want the logic to work as usual (for show/hide/etc. purposes). + [fullscreenController_ overlayFrameChanged:frame]; } else { // Okay to call even if |floatingBarBackingView_| is nil. if ([floatingBarBackingView_ superview]) @@ -431,7 +436,8 @@ willPositionSheet:(NSWindow*)sheet // |-setFullscreen:| into smaller pieces. http://crbug.com/36449 - (void)adjustUIForFullscreen:(BOOL)fullscreen { // Create the floating bar backing view if necessary. - if (fullscreen && !floatingBarBackingView_.get()) { + if (fullscreen && !floatingBarBackingView_.get() && + ([self hasTabStrip] || [self hasToolbar] || [self hasLocationBar])) { floatingBarBackingView_.reset( [[FloatingBarBackingView alloc] initWithFrame:NSZeroRect]); } diff --git a/chrome/browser/cocoa/fullscreen_controller.h b/chrome/browser/cocoa/fullscreen_controller.h index f599835..832d3de 100644 --- a/chrome/browser/cocoa/fullscreen_controller.h +++ b/chrome/browser/cocoa/fullscreen_controller.h @@ -83,10 +83,11 @@ showDropdown:(BOOL)showDropdown; - (void)exitFullscreen; -// Returns the amount by which the tab strip should be offset and the overlay -// view should be enlarged, vertically. Generally, this is > 0 when the -// fullscreen window is on the primary screen and 0 otherwise. -- (CGFloat)tabStripVerticalOffset; +// Returns the amount by which the floating bar should be offset downwards (to +// avoid the menu) and by which the overlay view should be enlarged vertically. +// Generally, this is > 0 when the fullscreen window is on the primary screen +// and 0 otherwise. +- (CGFloat)floatingBarVerticalOffset; // Informs the controller that the overlay's frame has changed. The controller // uses this information to update its tracking areas. diff --git a/chrome/browser/cocoa/fullscreen_controller.mm b/chrome/browser/cocoa/fullscreen_controller.mm index 3c67409..39e2cf5 100644 --- a/chrome/browser/cocoa/fullscreen_controller.mm +++ b/chrome/browser/cocoa/fullscreen_controller.mm @@ -21,8 +21,9 @@ const NSTimeInterval kDropdownShowDelay = 0.3; const NSTimeInterval kDropdownHideDelay = 0.2; // The amount by which the floating bar is offset downwards (to avoid the menu) -// in fullscreen mode. -const CGFloat kTabStripVerticalOffset = 14; +// in fullscreen mode. (We can't use |-[NSMenu menuBarHeight]| since it returns +// 0 when the menu bar is hidden.) +const CGFloat kFloatingBarVerticalOffset = 22; } // end namespace @@ -210,8 +211,8 @@ const CGFloat kTabStripVerticalOffset = 14; [self hideActiveWindowUI]; } -- (CGFloat)tabStripVerticalOffset { - return [self isWindowOnPrimaryScreen] ? kTabStripVerticalOffset : 0; +- (CGFloat)floatingBarVerticalOffset { + return [self isWindowOnPrimaryScreen] ? kFloatingBarVerticalOffset : 0; } - (void)overlayFrameChanged:(NSRect)frame { |