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

Unified Diff: chrome/browser/cocoa/browser_window_controller_private.mm

Issue 3136003: [Mac] Refactor the fullscreen code to move logic from BWC into FullscreenCont... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 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
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.mm ('k') | chrome/browser/cocoa/fullscreen_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/browser_window_controller_private.mm
===================================================================
--- chrome/browser/cocoa/browser_window_controller_private.mm (revision 58173)
+++ chrome/browser/cocoa/browser_window_controller_private.mm (working copy)
@@ -159,10 +159,12 @@
BOOL isFullscreen = [self isFullscreen];
CGFloat floatingBarHeight = [self floatingBarHeight];
+ CGFloat floatingBarShownFraction =
+ isFullscreen ? [fullscreenController_ floatingBarShownFraction] : 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) -
+ (floor((1 - floatingBarShownFraction) * floatingBarHeight) -
[fullscreenController_ floatingBarVerticalOffset]) : 0;
CGFloat maxY = NSMaxY(contentBounds) + yOffset;
CGFloat startMaxY = maxY;
@@ -242,6 +244,11 @@
if (![self isFullscreen])
return 0;
+ // If there's nothing in the floating bar, it has zero height.
+ // TODO(rohitrao): Should be possible to check [subviews count] here.
+ if (!([self hasLocationBar] || [self hasTabStrip] || [self hasToolbar]))
+ return 0;
+
CGFloat totalHeight = [fullscreenController_ floatingBarVerticalOffset];
if ([self hasTabStrip])
@@ -358,38 +365,30 @@
- (void)layoutFloatingBarBackingView:(NSRect)frame
fullscreen:(BOOL)fullscreen {
// Only display when in fullscreen mode.
- if (fullscreen) {
- // 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.)
- if (floatingBarBackingView_.get()) {
- BOOL aboveBookmarkBar = [self placeBookmarkBarBelowInfoBar];
+ if (!fullscreen)
+ return;
- // 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;
- }
+ NSView* floatingBarBackingView =
+ [fullscreenController_ floatingBarBackingView];
+ BOOL aboveBookmarkBar = [self placeBookmarkBarBelowInfoBar];
- // Set its frame.
- [floatingBarBackingView_ setFrame:frame];
- }
-
- // 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])
- [floatingBarBackingView_ removeFromSuperview];
+ // 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];
+ [fullscreenController_ overlayFrameChanged:frame];
}
- (CGFloat)layoutInfoBarAtMinX:(CGFloat)minX
@@ -469,16 +468,7 @@
[self layoutSubviews];
}
-// TODO(rohitrao): This function has shrunk into uselessness, and
-// |-setFullscreen:| has grown rather large. Find a good way to break up
-// |-setFullscreen:| into smaller pieces. http://crbug.com/36449
- (void)adjustUIForFullscreen:(BOOL)fullscreen {
- // Create the floating bar backing view if necessary.
- if (fullscreen && !floatingBarBackingView_.get() &&
- ([self hasTabStrip] || [self hasToolbar] || [self hasLocationBar])) {
- floatingBarBackingView_.reset(
- [[FloatingBarBackingView alloc] initWithFrame:NSZeroRect]);
- }
}
- (void)enableBarVisibilityUpdates {
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.mm ('k') | chrome/browser/cocoa/fullscreen_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698