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

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: Comments from rsesek. (Includes a rebase against the latest fullscreen refactor) 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 +=
217 (1 - floatingBarShownFraction_) * tabStripHeight - 213 std::floor((1 - presentationModeController_.get().toolbarFraction) *
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 +=
226 std::floor((1 - floatingBarShownFraction_) * floatingBarHeight) - 221 std::floor((1 - presentationModeController_.get().toolbarFraction) *
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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 - (void)adjustUIForExitingFullscreenAndStopOmniboxSliding { 708 - (void)adjustUIForExitingFullscreenAndStopOmniboxSliding {
714 [presentationModeController_ exitPresentationMode]; 709 [presentationModeController_ exitPresentationMode];
715 presentationModeController_.reset(); 710 presentationModeController_.reset();
716 711
717 // Force the bookmark bar z-order to update. 712 // Force the bookmark bar z-order to update.
718 [[bookmarkBarController_ view] removeFromSuperview]; 713 [[bookmarkBarController_ view] removeFromSuperview];
719 [self layoutSubviews]; 714 [self layoutSubviews];
720 } 715 }
721 716
722 - (void)adjustUIForSlidingFullscreenStyle:(fullscreen_mac::SlidingStyle)style { 717 - (void)adjustUIForSlidingFullscreenStyle:(fullscreen_mac::SlidingStyle)style {
723 fullscreenStyle_ = style;
724
725 if (!presentationModeController_) { 718 if (!presentationModeController_) {
726 presentationModeController_.reset( 719 presentationModeController_.reset(
727 [[PresentationModeController alloc] initWithBrowserController:self]); 720 [[PresentationModeController alloc] initWithBrowserController:self
721 style:style]);
728 [self configurePresentationModeController]; 722 [self configurePresentationModeController];
723 } else {
724 presentationModeController_.get().slidingStyle = style;
729 } 725 }
730 726
731 if (!floatingBarBackingView_.get() && 727 if (!floatingBarBackingView_.get() &&
732 ([self hasTabStrip] || [self hasToolbar] || [self hasLocationBar])) { 728 ([self hasTabStrip] || [self hasToolbar] || [self hasLocationBar])) {
733 floatingBarBackingView_.reset( 729 floatingBarBackingView_.reset(
734 [[FloatingBarBackingView alloc] initWithFrame:NSZeroRect]); 730 [[FloatingBarBackingView alloc] initWithFrame:NSZeroRect]);
735 [floatingBarBackingView_ 731 [floatingBarBackingView_
736 setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; 732 setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)];
737 } 733 }
738 734
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 relativeTo:[self tabContentArea]]; 1085 relativeTo:[self tabContentArea]];
1090 } 1086 }
1091 1087
1092 // TODO(erikchen): Remove and then add the tabStripView to the root NSView. 1088 // TODO(erikchen): Remove and then add the tabStripView to the root NSView.
1093 // This fixes a layer ordering problem that occurs between the contentView 1089 // This fixes a layer ordering problem that occurs between the contentView
1094 // and the tabStripView. This is a hack required because NSThemeFrame is not 1090 // and the tabStripView. This is a hack required because NSThemeFrame is not
1095 // layer backed, and because Chrome adds subviews directly to the 1091 // layer backed, and because Chrome adds subviews directly to the
1096 // NSThemeFrame. 1092 // NSThemeFrame.
1097 // http://crbug.com/407921 1093 // http://crbug.com/407921
1098 if (enteringAppKitFullscreen_) { 1094 if (enteringAppKitFullscreen_) {
1099 // Disable implicit animations. 1095 // The tabstrip frequently lies outside the bounds of its superview.
1100 [CATransaction begin]; 1096 // Repeatedly adding/removing the tabstrip from its superview during the
1101 [CATransaction setDisableActions:YES]; 1097 // AppKit Fullscreen transition causes graphical glitches on 10.10. The
1098 // correct solution is to use the AppKit fullscreen transition APIs added
1099 // in 10.7+.
1100 // http://crbug.com/408791
1101 if (!hasAdjustedTabStripWhileEnteringAppKitFullscreen_) {
1102 // Disable implicit animations.
1103 [CATransaction begin];
1104 [CATransaction setDisableActions:YES];
1102 1105
1103 // Get the current position of the tabStripView. 1106 // Get the current position of the tabStripView.
1104 NSView* superview = [[self tabStripView] superview]; 1107 NSView* superview = [[self tabStripView] superview];
1105 NSArray* subviews = [superview subviews]; 1108 NSArray* subviews = [superview subviews];
1106 NSInteger index = [subviews indexOfObject:[self tabStripView]]; 1109 NSInteger index = [subviews indexOfObject:[self tabStripView]];
1107 NSView* siblingBelow = nil; 1110 NSView* siblingBelow = nil;
1108 if (index > 0) 1111 if (index > 0)
1109 siblingBelow = [subviews objectAtIndex:index - 1]; 1112 siblingBelow = [subviews objectAtIndex:index - 1];
1110 1113
1111 // Remove the tabStripView. 1114 // Remove the tabStripView.
1112 [[self tabStripView] removeFromSuperview]; 1115 [[self tabStripView] removeFromSuperview];
1113 1116
1114 // Add it to the same position. 1117 // Add it to the same position.
1115 if (siblingBelow) { 1118 if (siblingBelow) {
1116 [superview addSubview:[self tabStripView] 1119 [superview addSubview:[self tabStripView]
1117 positioned:NSWindowAbove 1120 positioned:NSWindowAbove
1118 relativeTo:siblingBelow]; 1121 relativeTo:siblingBelow];
1119 } else { 1122 } else {
1120 [superview addSubview:[self tabStripView] 1123 [superview addSubview:[self tabStripView]
1121 positioned:NSWindowBelow 1124 positioned:NSWindowBelow
1122 relativeTo:nil]; 1125 relativeTo:nil];
1126 }
1127
1128 [CATransaction commit];
1129 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = YES;
1123 } 1130 }
1124 1131 } else {
1125 [CATransaction commit]; 1132 hasAdjustedTabStripWhileEnteringAppKitFullscreen_ = NO;
1126 } 1133 }
1127 } 1134 }
1128 1135
1129 - (void)updateInfoBarTipVisibility { 1136 - (void)updateInfoBarTipVisibility {
1130 // If there's no toolbar then hide the infobar tip. 1137 // If there's no toolbar then hide the infobar tip.
1131 [infoBarContainerController_ 1138 [infoBarContainerController_
1132 setShouldSuppressTopInfoBarTip:![self hasToolbar]]; 1139 setShouldSuppressTopInfoBarTip:![self hasToolbar]];
1133 } 1140 }
1134 1141
1135 - (NSInteger)infoBarMaxTopArrowHeight { 1142 - (NSInteger)infoBarMaxTopArrowHeight {
(...skipping 23 matching lines...) Expand all
1159 1166
1160 - (void)exitAppKitFullscreen { 1167 - (void)exitAppKitFullscreen {
1161 DCHECK(base::mac::IsOSLionOrLater()); 1168 DCHECK(base::mac::IsOSLionOrLater());
1162 if (FramedBrowserWindow* framedBrowserWindow = 1169 if (FramedBrowserWindow* framedBrowserWindow =
1163 base::mac::ObjCCast<FramedBrowserWindow>([self window])) { 1170 base::mac::ObjCCast<FramedBrowserWindow>([self window])) {
1164 [framedBrowserWindow toggleSystemFullScreen]; 1171 [framedBrowserWindow toggleSystemFullScreen];
1165 } 1172 }
1166 } 1173 }
1167 1174
1168 @end // @implementation BrowserWindowController(Private) 1175 @end // @implementation BrowserWindowController(Private)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698