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

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

Issue 1387473002: Switch HTML5 Fullscreen Over to AppKit (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing line Created 5 years, 2 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
Index: chrome/browser/ui/cocoa/browser_window_controller_private.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_private.mm b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
index 99ef304ce6729e554005c42a8fe0fa3db73f2f27..d2cc7d59282f0f04cc4f8beb52d29dd007e5ba09 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_private.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_private.mm
@@ -216,6 +216,9 @@ willPositionSheet:(NSWindow*)sheet
}
- (void)layoutSubviews {
+ if (blockLayoutSubviews_)
+ return;
+
// Suppress title drawing if necessary.
if ([self.window respondsToSelector:@selector(setShouldHideTitle:)])
[(id)self.window setShouldHideTitle:![self hasTitleBar]];
@@ -684,21 +687,18 @@ willPositionSheet:(NSWindow*)sheet
enteringAppKitFullscreenOnPrimaryScreen_ =
[[[self window] screen] isEqual:[[NSScreen screens] objectAtIndex:0]];
- fullscreen_mac::SlidingStyle style;
- if (browser_->exclusive_access_manager()
- ->fullscreen_controller()
- ->IsWindowFullscreenForTabOrPending()) {
- style = fullscreen_mac::OMNIBOX_TABS_NONE;
- } else if (enteringPresentationMode_) {
- style = fullscreen_mac::OMNIBOX_TABS_HIDDEN;
- } else {
- style = fullscreen_mac::OMNIBOX_TABS_PRESENT;
- }
-
- [self adjustUIForSlidingFullscreenStyle:style];
+ // If we are using custom fullscreen animations, the layout will resize
+ // in startCustomAnimationToEnterFullScreenWithDuration. In order to prevent
+ // multiple resizing messages from being sent to the renderer, we should call
+ // adjustUIForEnteringFullscreen after the layout gets resized.
+ if ([self shouldUseCustomAppKitFullscreenTransition:YES])
+ blockLayoutSubviews_ = YES;
+ else
+ [self adjustUIForEnteringFullscreen];
}
- (void)windowDidEnterFullScreen:(NSNotification*)notification {
+ blockLayoutSubviews_ = NO;
fullscreenTransition_.reset();
// In Yosemite, some combination of the titlebar and toolbar always show in
@@ -755,8 +755,13 @@ willPositionSheet:(NSWindow*)sheet
[self registerForContentViewResizeNotifications];
exitingAppKitFullscreen_ = YES;
- [self destroyFullscreenExitBubbleIfNecessary];
- [self adjustUIForExitingFullscreenAndStopOmniboxSliding];
+ // Like windowWillEnterFullScreen, if we use custom animations,
+ // adjustUIForExitingFullscreen should be called after the layout resizes in
+ // startCustomAnimationToExitFullScreenWithDuration.
+ if ([self shouldUseCustomAppKitFullscreenTransition:NO])
+ blockLayoutSubviews_ = YES;
+ else
+ [self adjustUIForExitingFullscreen];
}
- (void)windowDidExitFullScreen:(NSNotification*)notification {
@@ -765,19 +770,19 @@ willPositionSheet:(NSWindow*)sheet
if (notification) // For System Fullscreen when non-nil.
[self deregisterForContentViewResizeNotifications];
- // Since the content view was forcefully resized during the transition, we
- // want to ensure that the subviews are layout correctly after it ended.
- [self layoutSubviews];
browser_->WindowFullscreenStateChanged();
exitingAppKitFullscreen_ = NO;
fullscreenTransition_.reset();
+
+ blockLayoutSubviews_ = NO;
}
- (void)windowDidFailToEnterFullScreen:(NSWindow*)window {
[self deregisterForContentViewResizeNotifications];
enteringAppKitFullscreen_ = NO;
fullscreenTransition_.reset();
+ blockLayoutSubviews_ = NO;
[self adjustUIForExitingFullscreenAndStopOmniboxSliding];
}
@@ -785,10 +790,31 @@ willPositionSheet:(NSWindow*)sheet
[self deregisterForContentViewResizeNotifications];
exitingAppKitFullscreen_ = NO;
fullscreenTransition_.reset();
+ blockLayoutSubviews_ = NO;
// Force a relayout to try and get the window back into a reasonable state.
[self layoutSubviews];
}
+- (void)adjustUIForExitingFullscreen {
+ [self destroyFullscreenExitBubbleIfNecessary];
+ [self adjustUIForExitingFullscreenAndStopOmniboxSliding];
+}
+
+- (void)adjustUIForEnteringFullscreen {
+ fullscreen_mac::SlidingStyle style;
+ if (browser_->exclusive_access_manager()
+ ->fullscreen_controller()
+ ->IsWindowFullscreenForTabOrPending()) {
+ style = fullscreen_mac::OMNIBOX_TABS_NONE;
+ } else if (enteringPresentationMode_) {
+ style = fullscreen_mac::OMNIBOX_TABS_HIDDEN;
+ } else {
+ style = fullscreen_mac::OMNIBOX_TABS_PRESENT;
+ }
+
+ [self adjustUIForSlidingFullscreenStyle:style];
+}
+
- (void)enableBarVisibilityUpdates {
// Early escape if there's nothing to do.
if (barVisibilityUpdatesEnabled_)
@@ -1083,9 +1109,9 @@ willPositionSheet:(NSWindow*)sheet
// works on OSX 10.10.
// TODO(spqchan): Fix exit fullscreen animation so that it works on all
// OSX versions.
- if (!enterFullScreen)
+ // if (!enterFullScreen)
erikchen 2015/10/07 21:51:03 Huh? What are you trying to do here? If you want t
spqchan 2015/10/07 22:54:01 This change was accidentally added to this CL when
return NO;
-
+ //
if (base::mac::IsOSMountainLionOrEarlier())
return NO;
@@ -1137,6 +1163,10 @@ willPositionSheet:(NSWindow*)sheet
startCustomAnimationToEnterFullScreenWithDuration:(NSTimeInterval)duration {
DCHECK([window isEqual:self.window]);
[fullscreenTransition_ startCustomFullScreenAnimationWithDuration:duration];
+
+ blockLayoutSubviews_ = NO;
+ [self adjustUIForEnteringFullscreen];
+ blockLayoutSubviews_ = YES;
}
- (void)window:(NSWindow*)window
@@ -1144,6 +1174,10 @@ willPositionSheet:(NSWindow*)sheet
DCHECK([window isEqual:self.window]);
[fullscreenTransition_ startCustomFullScreenAnimationWithDuration:duration];
+
+ blockLayoutSubviews_ = NO;
erikchen 2015/10/07 21:51:03 This code assumes that blockLayoutSubviews_ is YES
spqchan 2015/10/07 22:54:01 Done.
+ [self adjustUIForExitingFullscreen];
+ blockLayoutSubviews_ = YES;
}
- (BOOL)shouldConstrainFrameRect {

Powered by Google App Engine
This is Rietveld 408576698