Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Mac: fix fullscreen floating bar in popup windows.

BUG=37699
TEST=Make sure the following types of windows look correct in fullscreen mode (in particular, the toolbar/menu should slide down properly and look nice): (1) normal windows (with tab strip), (2) popup windows with location bar, (3) "app" windows such as the dev tools window. Also make sure these things show correctly with themes and the bookmark bar enabled.

Review URL: http://codereview.chromium.org/747001

git-svn-id: http://src.chromium.org/svn/trunk/src/chrome/browser@41073 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
  • Loading branch information...
commit 772c83d37bf760544dd195095b070dcfab934307 1 parent 6ad66f6
viettrungluu@chromium.org authored
View
2  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)
View
3  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
View
4 cocoa/browser_window_controller.mm
@@ -434,7 +434,7 @@ - (void)windowDidBecomeMain:(NSNotification*)notification {
// 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 @@ - (void)windowDidResignMain:(NSNotification*)notification {
// 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).
View
62 cocoa/browser_window_controller_private.mm
@@ -140,8 +140,11 @@ - (void)layoutSubviews {
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 @@ - (void)layoutSubviews {
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 @@ - (CGFloat)floatingBarHeight {
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 @@ - (CGFloat)floatingBarHeight {
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 @@ - (CGFloat)layoutTabStripAtMaxY:(CGFloat)maxY
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 @@ - (void)layoutFloatingBarBackingViewAtY:(CGFloat)y
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 @@ - (void)adjustToolbarAndBookmarkBarForCompression:(CGFloat)compression {
// |-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]);
}
View
9 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.
View
9 cocoa/fullscreen_controller.mm
@@ -21,8 +21,9 @@
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 @@ - (void)windowDidResignMain:(NSNotification*)notification {
[self hideActiveWindowUI];
}
-- (CGFloat)tabStripVerticalOffset {
- return [self isWindowOnPrimaryScreen] ? kTabStripVerticalOffset : 0;
+- (CGFloat)floatingBarVerticalOffset {
+ return [self isWindowOnPrimaryScreen] ? kFloatingBarVerticalOffset : 0;
}
- (void)overlayFrameChanged:(NSRect)frame {
Please sign in to comment.
Something went wrong with that request. Please try again.