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

Side by Side Diff: chrome/browser/ui/cocoa/browser_window_controller_private.mm

Issue 523723002: mac, fullscreen: Several bug fixes after major refactor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new_fullscreen2
Patch Set: Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" 5 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 // Suppress title drawing if necessary. 191 // Suppress title drawing if necessary.
192 if ([window respondsToSelector:@selector(setShouldHideTitle:)]) 192 if ([window respondsToSelector:@selector(setShouldHideTitle:)])
193 [(id)window setShouldHideTitle:![self hasTitleBar]]; 193 [(id)window setShouldHideTitle:![self hasTitleBar]];
194 194
195 // Update z-order. The code below depends on this. 195 // Update z-order. The code below depends on this.
196 [self updateSubviewZOrder:[self isInFullscreenWithOmniboxSliding]]; 196 [self updateSubviewZOrder:[self isInFullscreenWithOmniboxSliding]];
197 197
198 CGFloat floatingBarHeight = [self floatingBarHeight]; 198 CGFloat floatingBarHeight = [self floatingBarHeight];
199 CGFloat yOffset = 0; 199 CGFloat yOffset = 0;
200 if ([self isInFullscreenWithOmniboxSliding]) { 200 if ([self isInFullscreenWithOmniboxSliding]) {
201 switch (fullscreenStyle_) { 201 yOffset += [presentationModeController_ menubarOffset];
202 switch (presentationModeController_.get().slidingStyle) {
202 case fullscreen_mac::OMNIBOX_TABS_PRESENT: 203 case fullscreen_mac::OMNIBOX_TABS_PRESENT:
203 // In system fullscreen mode, |yOffset| accounts for the extra offset
204 // needed to dodge the menu bar.
205 yOffset = -std::floor(
206 (floatingBarShownFraction_) *
207 [presentationModeController_ floatingBarVerticalOffset]);
208 break; 204 break;
209 case fullscreen_mac::OMNIBOX_PRESENT: { 205 case fullscreen_mac::OMNIBOX_PRESENT: {
210 // At rest: omnibox showing. yOffset should be tabstrip height 206 // At rest: omnibox showing. yOffset should be tabstrip height
211 // When cursor is at top: everything shows. yOffset should be -menubar 207 // When cursor is at top: everything shows. yOffset should be -menubar
212 // height. 208 // height.
213 CGFloat tabStripHeight = 0; 209 CGFloat tabStripHeight = 0;
214 if ([self hasTabStrip]) 210 if ([self hasTabStrip])
215 tabStripHeight = NSHeight([[self tabStripView] frame]); 211 tabStripHeight = NSHeight([[self tabStripView] frame]);
216 yOffset = std::floor( 212 yOffset += std::floor(
217 (1 - floatingBarShownFraction_) * tabStripHeight - 213 (1 - presentationModeController_.get().toolbarPercentage) *
218 floatingBarShownFraction_ * 214 tabStripHeight);
219 [presentationModeController_ floatingBarVerticalOffset]);
220 break; 215 break;
221 } 216 }
222 case fullscreen_mac::OMNIBOX_TABS_HIDDEN: 217 case fullscreen_mac::OMNIBOX_TABS_HIDDEN:
223 // In presentation mode, |yOffset| accounts for the sliding position of 218 // In presentation mode, |yOffset| accounts for the sliding position of
224 // the floating bar and the extra offset needed to dodge the menu bar. 219 // the floating bar and the extra offset needed to dodge the menu bar.
225 yOffset = 220 yOffset += std::floor(
226 std::floor((1 - floatingBarShownFraction_) * floatingBarHeight) - 221 (1 - presentationModeController_.get().toolbarPercentage) *
227 [presentationModeController_ floatingBarVerticalOffset]; 222 floatingBarHeight);
228 break; 223 break;
229 } 224 }
230 } 225 }
231 226
232 CGFloat maxY = NSMaxY(contentBounds) + yOffset; 227 CGFloat maxY = NSMaxY(contentBounds) + yOffset;
233 228
234 if ([self hasTabStrip]) { 229 if ([self hasTabStrip]) {
235 // If we need to lay out the top tab strip, replace |maxY| with a higher 230 // If we need to lay out the top tab strip, replace |maxY| with a higher
236 // value, and then lay out the tab strip. 231 // value, and then lay out the tab strip.
237 NSRect windowFrame = [contentView convertRect:[window frame] fromView:nil]; 232 NSRect windowFrame = [contentView convertRect:[window frame] fromView:nil];
(...skipping 22 matching lines...) Expand all
260 [self layoutFloatingBarBackingView:floatingBarBackingRect 255 [self layoutFloatingBarBackingView:floatingBarBackingRect
261 presentationMode:[self isInFullscreenWithOmniboxSliding]]; 256 presentationMode:[self isInFullscreenWithOmniboxSliding]];
262 257
263 // Place the find bar immediately below the toolbar/attached bookmark bar. In 258 // Place the find bar immediately below the toolbar/attached bookmark bar. In
264 // presentation mode, it hangs off the top of the screen when the bar is 259 // presentation mode, it hangs off the top of the screen when the bar is
265 // hidden. 260 // hidden.
266 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:width]; 261 [findBarCocoaController_ positionFindBarViewAtMaxY:maxY maxWidth:width];
267 [fullscreenExitBubbleController_ positionInWindowAtTop:maxY width:width]; 262 [fullscreenExitBubbleController_ positionInWindowAtTop:maxY width:width];
268 263
269 if ([self isInFullscreenWithOmniboxSliding]) { 264 if ([self isInFullscreenWithOmniboxSliding]) {
270 switch (fullscreenStyle_) { 265 switch (presentationModeController_.get().slidingStyle) {
271 case fullscreen_mac::OMNIBOX_TABS_PRESENT: 266 case fullscreen_mac::OMNIBOX_TABS_PRESENT:
272 case fullscreen_mac::OMNIBOX_PRESENT: 267 case fullscreen_mac::OMNIBOX_PRESENT:
273 // Do nothing in Canonical Fullscreen and Simplified Fullscreen. All 268 // Do nothing in Canonical Fullscreen and Simplified Fullscreen. All
274 // content slides. 269 // content slides.
275 break; 270 break;
276 case fullscreen_mac::OMNIBOX_TABS_HIDDEN: 271 case fullscreen_mac::OMNIBOX_TABS_HIDDEN:
277 // If in presentation mode, reset |maxY| to top of screen, so that the 272 // If in presentation mode, reset |maxY| to top of screen, so that the
278 // floating bar slides over the things which appear to be in the content 273 // floating bar slides over the things which appear to be in the content
279 // area. 274 // area.
280 maxY = NSMaxY(contentBounds); 275 maxY = NSMaxY(contentBounds);
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 - (void)adjustUIForExitingFullscreenAndStopOmniboxSliding { 706 - (void)adjustUIForExitingFullscreenAndStopOmniboxSliding {
712 [presentationModeController_ exitPresentationMode]; 707 [presentationModeController_ exitPresentationMode];
713 presentationModeController_.reset(); 708 presentationModeController_.reset();
714 709
715 // Force the bookmark bar z-order to update. 710 // Force the bookmark bar z-order to update.
716 [[bookmarkBarController_ view] removeFromSuperview]; 711 [[bookmarkBarController_ view] removeFromSuperview];
717 [self layoutSubviews]; 712 [self layoutSubviews];
718 } 713 }
719 714
720 - (void)adjustUIForSlidingFullscreenStyle:(fullscreen_mac::SlidingStyle)style { 715 - (void)adjustUIForSlidingFullscreenStyle:(fullscreen_mac::SlidingStyle)style {
721 fullscreenStyle_ = style;
722
723 if (!presentationModeController_) { 716 if (!presentationModeController_) {
724 presentationModeController_.reset( 717 presentationModeController_.reset(
725 [[PresentationModeController alloc] initWithBrowserController:self]); 718 [[PresentationModeController alloc] initWithBrowserController:self
719 style:style]);
726 [self configurePresentationModeController]; 720 [self configurePresentationModeController];
721 } else {
722 presentationModeController_.get().slidingStyle = style;
727 } 723 }
728 724
729 if (!floatingBarBackingView_.get() && 725 if (!floatingBarBackingView_.get() &&
730 ([self hasTabStrip] || [self hasToolbar] || [self hasLocationBar])) { 726 ([self hasTabStrip] || [self hasToolbar] || [self hasLocationBar])) {
731 floatingBarBackingView_.reset( 727 floatingBarBackingView_.reset(
732 [[FloatingBarBackingView alloc] initWithFrame:NSZeroRect]); 728 [[FloatingBarBackingView alloc] initWithFrame:NSZeroRect]);
733 [floatingBarBackingView_ 729 [floatingBarBackingView_
734 setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; 730 setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)];
735 } 731 }
736 732
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 relativeTo:[self tabContentArea]]; 1083 relativeTo:[self tabContentArea]];
1088 } 1084 }
1089 1085
1090 // TODO(erikchen): Remove and then add the tabStripView to the root NSView. 1086 // TODO(erikchen): Remove and then add the tabStripView to the root NSView.
1091 // This fixes a layer ordering problem that occurs between the contentView 1087 // This fixes a layer ordering problem that occurs between the contentView
1092 // and the tabStripView. This is a hack required because NSThemeFrame is not 1088 // and the tabStripView. This is a hack required because NSThemeFrame is not
1093 // layer backed, and because Chrome adds subviews directly to the 1089 // layer backed, and because Chrome adds subviews directly to the
1094 // NSThemeFrame. 1090 // NSThemeFrame.
1095 // http://crbug.com/407921 1091 // http://crbug.com/407921
1096 if (enteringAppKitFullscreen_) { 1092 if (enteringAppKitFullscreen_) {
1097 // Disable implicit animations. 1093 // The tabstrip frequently lies outside the bounds of its superview.
1098 [CATransaction begin]; 1094 // Repeatedly adding/removing the tabstrip from its superview during the
1099 [CATransaction setDisableActions:YES]; 1095 // AppKit Fullscreen transition causes graphical glitches on 10.10. The
1096 // correct solution is to use the AppKit fullscreen transition APIs added
1097 // in 10.7+.
1098 // http://crbug.com/408791
1099 if (!hasAdjustedTabStripWhileEnteringAppKitFullscreen_) {
1100 // Disable implicit animations.
1101 [CATransaction begin];
1102 [CATransaction setDisableActions:YES];
1100 1103
1101 // Get the current position of the tabStripView. 1104 // Get the current position of the tabStripView.
1102 NSView* superview = [[self tabStripView] superview]; 1105 NSView* superview = [[self tabStripView] superview];
1103 NSArray* subviews = [superview subviews]; 1106 NSArray* subviews = [superview subviews];
1104 NSInteger index = [subviews indexOfObject:[self tabStripView]]; 1107 NSInteger index = [subviews indexOfObject:[self tabStripView]];
1105 NSView* siblingBelow = nil; 1108 NSView* siblingBelow = nil;
1106 if (index > 0) 1109 if (index > 0)
1107 siblingBelow = [subviews objectAtIndex:index - 1]; 1110 siblingBelow = [subviews objectAtIndex:index - 1];
1108 1111
1109 // Remove the tabStripView. 1112 // Remove the tabStripView.
1110 [[self tabStripView] removeFromSuperview]; 1113 [[self tabStripView] removeFromSuperview];
1111 1114
1112 // Add it to the same position. 1115 // Add it to the same position.
1113 if (siblingBelow) { 1116 if (siblingBelow) {
1114 [superview addSubview:[self tabStripView] 1117 [superview addSubview:[self tabStripView]
1115 positioned:NSWindowAbove 1118 positioned:NSWindowAbove
1116 relativeTo:siblingBelow]; 1119 relativeTo:siblingBelow];
1117 } else { 1120 } else {
1118 [superview addSubview:[self tabStripView] 1121 [superview addSubview:[self tabStripView]
1119 positioned:NSWindowBelow 1122 positioned:NSWindowBelow
1120 relativeTo:nil]; 1123 relativeTo:nil];
1124 }
1125
1126 [CATransaction commit];
1127 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES;
1121 } 1128 }
1122 1129 } else {
1123 [CATransaction commit]; 1130 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO;
1124 } 1131 }
1125 } 1132 }
1126 1133
1127 - (void)updateInfoBarTipVisibility { 1134 - (void)updateInfoBarTipVisibility {
1128 // If there's no toolbar then hide the infobar tip. 1135 // If there's no toolbar then hide the infobar tip.
1129 [infoBarContainerController_ 1136 [infoBarContainerController_
1130 setShouldSuppressTopInfoBarTip:![self hasToolbar]]; 1137 setShouldSuppressTopInfoBarTip:![self hasToolbar]];
1131 } 1138 }
1132 1139
1133 - (void)enterAppKitFullscreen { 1140 - (void)enterAppKitFullscreen {
1134 if (FramedBrowserWindow* framedBrowserWindow = 1141 if (FramedBrowserWindow* framedBrowserWindow =
1135 base::mac::ObjCCast<FramedBrowserWindow>([self window])) { 1142 base::mac::ObjCCast<FramedBrowserWindow>([self window])) {
1136 [framedBrowserWindow toggleSystemFullScreen]; 1143 [framedBrowserWindow toggleSystemFullScreen];
1137 } 1144 }
1138 } 1145 }
1139 1146
1140 - (void)exitAppKitFullscreen { 1147 - (void)exitAppKitFullscreen {
1141 if (FramedBrowserWindow* framedBrowserWindow = 1148 if (FramedBrowserWindow* framedBrowserWindow =
1142 base::mac::ObjCCast<FramedBrowserWindow>([self window])) { 1149 base::mac::ObjCCast<FramedBrowserWindow>([self window])) {
1143 [framedBrowserWindow toggleSystemFullScreen]; 1150 [framedBrowserWindow toggleSystemFullScreen];
1144 } 1151 }
1145 } 1152 }
1146 1153
1147 @end // @implementation BrowserWindowController(Private) 1154 @end // @implementation BrowserWindowController(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698