Commit c70ce43e authored by erikchen's avatar erikchen Committed by Commit bot

Mac: Minor fullscreen adjustments.

- In Canonical Fullscreen, the toolbar/tabstrip now slide over the content when
the AppKit menu bar is revealed. This prevents a series of fast resizes of the
content view, which is janky.
- Adjust the z-ordering of the infobar so that it shows in front of the
bookmark bar and toolbar in Canonical Fullscreen.
- Removed method -isInFullscreenWithOmniboxSliding, as it has the same behavior
as -isInAnyFullscreenMode.

BUG=413210

Review URL: https://codereview.chromium.org/607603003

Cr-Commit-Position: refs/heads/master@{#296832}
parent cc742a2c
......@@ -515,10 +515,6 @@ class Command;
// the AppKit Fullscreen API.
- (BOOL)isInAppKitFullscreen;
// Returns YES if the PresentationModeController exists and hence the omnibox
// and other UI is expected to slide.
- (BOOL)isInFullscreenWithOmniboxSliding;
// Enters presentation mode.
- (void)enterPresentationMode;
......
......@@ -2097,10 +2097,6 @@ willAnimateFromState:(BookmarkBar::State)oldState
enteringAppKitFullscreen_;
}
- (BOOL)isInFullscreenWithOmniboxSliding {
return presentationModeController_.get() != nil;
}
- (void)enterPresentationMode {
if (!chrome::mac::SupportsSystemFullscreen()) {
[self enterImmersiveFullscreen];
......
......@@ -831,7 +831,7 @@ willPositionSheet:(NSWindow*)sheet
[layout setContentViewSize:[[[self window] contentView] bounds].size];
[layout setWindowSize:[[self window] frame].size];
[layout setInAnyFullscreen:[self isInFullscreenWithOmniboxSliding]];
[layout setInAnyFullscreen:[self isInAnyFullscreenMode]];
[layout setFullscreenSlidingStyle:
presentationModeController_.get().slidingStyle];
[layout setFullscreenMenubarOffset:
......@@ -911,7 +911,7 @@ willPositionSheet:(NSWindow*)sheet
}
- (void)updateSubviewZOrder {
if ([self isInFullscreenWithOmniboxSliding])
if ([self isInAnyFullscreenMode])
[self updateSubviewZOrderFullscreen];
else
[self updateSubviewZOrderNormal];
......@@ -941,8 +941,6 @@ willPositionSheet:(NSWindow*)sheet
base::scoped_nsobject<NSMutableArray> subviews([[NSMutableArray alloc] init]);
if ([downloadShelfController_ view])
[subviews addObject:[downloadShelfController_ view]];
if ([infoBarContainerController_ view])
[subviews addObject:[infoBarContainerController_ view]];
if ([self tabContentArea])
[subviews addObject:[self tabContentArea]];
if ([self placeBookmarkBarBelowInfoBar]) {
......@@ -956,9 +954,10 @@ willPositionSheet:(NSWindow*)sheet
if ([bookmarkBarController_ view])
[subviews addObject:[bookmarkBarController_ view]];
}
if ([toolbarController_ view])
[subviews addObject:[toolbarController_ view]];
if ([infoBarContainerController_ view])
[subviews addObject:[infoBarContainerController_ view]];
if ([findBarCocoaController_ view])
[subviews addObject:[findBarCocoaController_ view]];
......
......@@ -195,18 +195,12 @@ const CGFloat kLocBarBottomInset = 1;
output_.findBarMaxY = maxY;
output_.fullscreenExitButtonMaxY = maxY;
if (parameters_.inAnyFullscreen) {
switch (parameters_.slidingStyle) {
case fullscreen_mac::OMNIBOX_TABS_PRESENT:
// Do nothing in Canonical Fullscreen. All content slides.
break;
case fullscreen_mac::OMNIBOX_TABS_HIDDEN:
// If in presentation mode, reset |maxY| to top of screen, so that the
// floating bar slides over the things which appear to be in the content
// area.
maxY = parameters_.contentViewSize.height;
break;
}
if (parameters_.inAnyFullscreen &&
parameters_.slidingStyle == fullscreen_mac::OMNIBOX_TABS_HIDDEN) {
// If in presentation mode, reset |maxY| to top of screen, so that the
// floating bar slides over the things which appear to be in the content
// area.
maxY = parameters_.windowSize.height;
}
// Lay out the info bar. It is never hidden. The frame needs to be high
......@@ -245,6 +239,17 @@ const CGFloat kLocBarBottomInset = 1;
minY = NSMaxY(output_.downloadShelfFrame);
}
if (parameters_.inAnyFullscreen &&
parameters_.slidingStyle == fullscreen_mac::OMNIBOX_TABS_PRESENT) {
// If in Canonical Fullscreen, content should be shifted down by an amount
// equal to all the widgets and views at the top of the window. It should
// not be further shifted by the appearance/disappearance of the AppKit
// menu bar.
maxY = parameters_.windowSize.height;
maxY -= NSHeight(output_.toolbarFrame) + NSHeight(output_.tabStripFrame) +
NSHeight(output_.bookmarkFrame) + parameters.infoBarHeight;
}
// All the remaining space becomes the frame of the content area.
output_.contentAreaFrame = NSMakeRect(0, minY, width, maxY - minY);
}
......
......@@ -74,6 +74,30 @@ TEST_F(BrowserWindowLayoutTest, TestAllViewsFullscreen) {
NSEqualRects(NSMakeRect(0, 44, 600, 411), output.contentAreaFrame));
}
TEST_F(BrowserWindowLayoutTest, TestAllViewsFullscreenMenuBarShowing) {
// Content view has same size as window in AppKit Fullscreen.
[layout setContentViewSize:NSMakeSize(600, 622)];
[layout setInAnyFullscreen:YES];
[layout setFullscreenSlidingStyle:fullscreen_mac::OMNIBOX_TABS_PRESENT];
[layout setFullscreenMenubarOffset:-10];
[layout setFullscreenToolbarFraction:0];
chrome::LayoutOutput output = [layout computeLayout];
EXPECT_TRUE(NSEqualRects(NSMakeRect(0, 575, 600, 37), output.tabStripFrame));
EXPECT_TRUE(NSEqualRects(NSMakeRect(0, 543, 600, 32), output.toolbarFrame));
EXPECT_TRUE(NSEqualRects(NSMakeRect(0, 517, 600, 26), output.bookmarkFrame));
EXPECT_TRUE(NSEqualRects(NSMakeRect(0, 517, 600, 95),
output.fullscreenBackingBarFrame));
EXPECT_EQ(517, output.findBarMaxY);
EXPECT_EQ(517, output.fullscreenExitButtonMaxY);
EXPECT_TRUE(NSEqualRects(NSMakeRect(0, 445, 600, 111), output.infoBarFrame));
EXPECT_TRUE(
NSEqualRects(NSMakeRect(0, 0, 600, 44), output.downloadShelfFrame));
EXPECT_TRUE(
NSEqualRects(NSMakeRect(0, 44, 600, 411), output.contentAreaFrame));
}
TEST_F(BrowserWindowLayoutTest, TestPopupWindow) {
[layout setHasTabStrip:NO];
[layout setHasToolbar:NO];
......
......@@ -152,19 +152,27 @@ TEST_F(PresentationModeControllerTest, CanonicalFullscreenAppKitLayout) {
CheckLayoutNoOverlap(controller_);
// The menu bar is starting to animate in. All views should slide down by a
// small amount.
// small amount. The content area doesn't change size.
[controller_->presentationController_ setMenuBarRevealProgress:0.3];
EXPECT_LT(MaxYInWindow([controller_ tabStripView]), windowHeight - 1);
EXPECT_GT(MaxYInWindow([controller_ tabStripView]),
windowHeight - kMenuBarHeight + 1);
CheckLayoutNoOverlap(controller_);
CheckToolbarLayoutNoOverlap(controller_);
EXPECT_EQ(MinYInWindow([[controller_ bookmarkBarController] view]),
MaxYInWindow([[controller_ infoBarContainerController] view]));
EXPECT_LT(MinYInWindow([[controller_ infoBarContainerController] view]),
MaxYInWindow([controller_ tabContentArea]));
// The menu bar is fully visible. All views should slide down by the size of
// the menu bar.
// the menu bar. The content area doesn't change size.
[controller_->presentationController_ setMenuBarRevealProgress:1];
EXPECT_FLOAT_EQ(windowHeight - kMenuBarHeight,
MaxYInWindow([controller_ tabStripView]));
CheckLayoutNoOverlap(controller_);
CheckToolbarLayoutNoOverlap(controller_);
EXPECT_EQ(MinYInWindow([[controller_ bookmarkBarController] view]),
MaxYInWindow([[controller_ infoBarContainerController] view]));
EXPECT_LT(MinYInWindow([[controller_ infoBarContainerController] view]),
MaxYInWindow([controller_ tabContentArea]));
// The menu bar has disappeared. All views should return to normal.
[controller_->presentationController_ setMenuBarRevealProgress:0];
......@@ -192,7 +200,7 @@ TEST_F(PresentationModeControllerTest, PresentationModeAppKitLayout) {
CGFloat contentHeight = NSHeight([[[controller_ window] contentView] bounds]);
CheckToolbarLayoutNoOverlap(controller_);
EXPECT_EQ(windowHeight, MinYInWindow(LowestViewInToolbarArea(controller_)));
EXPECT_EQ(contentHeight, MaxYInWindow([controller_ tabContentArea]));
EXPECT_EQ(windowHeight, MaxYInWindow([controller_ tabContentArea]));
// The menu bar is starting to animate in. All views except the content view
// should slide down by a small amount.
......@@ -201,7 +209,7 @@ TEST_F(PresentationModeControllerTest, PresentationModeAppKitLayout) {
CheckToolbarLayoutNoOverlap(controller_);
EXPECT_LT(MinYInWindow(LowestViewInToolbarArea(controller_)), contentHeight);
EXPECT_GT(MaxYInWindow(HighestViewInToolbarArea(controller_)), contentHeight);
EXPECT_EQ(contentHeight, MaxYInWindow([controller_ tabContentArea]));
EXPECT_EQ(windowHeight, MaxYInWindow([controller_ tabContentArea]));
// The menu bar is fully visible. All views should slide down by the size of
// the menu bar.
......@@ -209,12 +217,12 @@ TEST_F(PresentationModeControllerTest, PresentationModeAppKitLayout) {
[controller_->presentationController_ changeToolbarFraction:1];
CheckToolbarLayoutNoOverlap(controller_);
EXPECT_EQ(contentHeight, MaxYInWindow(HighestViewInToolbarArea(controller_)));
EXPECT_EQ(contentHeight, MaxYInWindow([controller_ tabContentArea]));
EXPECT_EQ(windowHeight, MaxYInWindow([controller_ tabContentArea]));
// The menu bar has disappeared. All views should return to normal.
[controller_->presentationController_ setMenuBarRevealProgress:0];
[controller_->presentationController_ changeToolbarFraction:0];
CheckToolbarLayoutNoOverlap(controller_);
EXPECT_EQ(windowHeight, MinYInWindow(LowestViewInToolbarArea(controller_)));
EXPECT_EQ(contentHeight, MaxYInWindow([controller_ tabContentArea]));
EXPECT_EQ(windowHeight, MaxYInWindow([controller_ tabContentArea]));
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment