diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-17 20:40:49 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-17 20:40:49 +0000 |
commit | 86b423f4321ba469cf8eb15edd27cc6f2bf29ae2 (patch) | |
tree | 9b2217fffe5f5d036456389dea5d897acee79db0 /chrome/browser/cocoa | |
parent | bca55853af8c26218137bca075a8972bf36d2120 (diff) | |
download | chromium_src-86b423f4321ba469cf8eb15edd27cc6f2bf29ae2.zip chromium_src-86b423f4321ba469cf8eb15edd27cc6f2bf29ae2.tar.gz chromium_src-86b423f4321ba469cf8eb15edd27cc6f2bf29ae2.tar.bz2 |
Mac: prevent the overlay from sliding in and out on fullscreen mode switch.
BUG=35959
TEST=Go to various web pages, focus various things, switch in and out of fullscreen mode; overlay should never slide in and then out (it should either be and stay in, if appropriate, or be out and stay out).
Review URL: http://codereview.chromium.org/601090
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39258 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
6 files changed, 60 insertions, 10 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.h b/chrome/browser/cocoa/browser_window_controller.h index 3021770..c2a5ab8 100644 --- a/chrome/browser/cocoa/browser_window_controller.h +++ b/chrome/browser/cocoa/browser_window_controller.h @@ -114,6 +114,10 @@ class TabStripModelObserverBridge; // itself added to |barVisibilityLocks_|. When it no longer requires bar // visibility, it has itself removed. scoped_nsobject<NSMutableSet> barVisibilityLocks_; + + // Bar visibility locks and releases only result (when appropriate) in changes + // in visible state when the following is |YES|. + BOOL barVisibilityUpdatesEnabled_; } // A convenience class method which gets the controller for window containing diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index df4cc6f..e719987 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -278,6 +278,9 @@ // |-awakeFromNib|. [self updateBookmarkBarVisibilityWithAnimation:NO]; + // Allow bar visibility to be changed. + [self enableBarVisibilityUpdates]; + // Force a relayout of all the various bars. [self layoutSubviews]; @@ -1601,6 +1604,9 @@ willAnimateFromState:(bookmarks::VisualState)oldState [[FocusTracker alloc] initWithWindow:window]); BOOL showDropdown = [self floatingBarHasFocus]; + // While we move views (and focus) around, disable any bar visibility changes. + [self disableBarVisibilityUpdates]; + // If we're entering fullscreen, create the fullscreen controller. If we're // exiting fullscreen, kill the controller. if (fullscreen) { @@ -1608,7 +1614,7 @@ willAnimateFromState:(bookmarks::VisualState)oldState initWithBrowserController:self]); } else { [fullscreenController_ exitFullscreen]; - fullscreenController_.reset(nil); + fullscreenController_.reset(); } // Destroy the tab strip's sheet controller. We will recreate it in the new @@ -1681,6 +1687,9 @@ willAnimateFromState:(bookmarks::VisualState)oldState [destWindow makeKeyAndOrderFront:self]; [focusTracker restoreFocusInWindow:destWindow]; [window orderOut:self]; + + // We're done moving focus, so re-enable bar visibility changes. + [self enableBarVisibilityUpdates]; } - (BOOL)isFullscreen { @@ -1708,9 +1717,11 @@ willAnimateFromState:(bookmarks::VisualState)oldState if (![self isBarVisibilityLockedForOwner:owner]) { [barVisibilityLocks_ addObject:owner]; - // Show the overlay if necessary (and if in fullscreen mode). - [fullscreenController_ ensureOverlayShownWithAnimation:animate - delay:delay]; + // If enabled, show the overlay if necessary (and if in fullscreen mode). + if (barVisibilityUpdatesEnabled_) { + [fullscreenController_ ensureOverlayShownWithAnimation:animate + delay:delay]; + } } } @@ -1720,8 +1731,9 @@ willAnimateFromState:(bookmarks::VisualState)oldState if ([self isBarVisibilityLockedForOwner:owner]) { [barVisibilityLocks_ removeObject:owner]; - // Hide the overlay if necessary (and if in fullscreen mode). - if (![barVisibilityLocks_ count]) { + // If enabled, hide the overlay if necessary (and if in fullscreen mode). + if (barVisibilityUpdatesEnabled_ && + ![barVisibilityLocks_ count]) { [fullscreenController_ ensureOverlayHiddenWithAnimation:animate delay:delay]; } diff --git a/chrome/browser/cocoa/browser_window_controller_private.h b/chrome/browser/cocoa/browser_window_controller_private.h index 3ae054a..5d84b66f 100644 --- a/chrome/browser/cocoa/browser_window_controller_private.h +++ b/chrome/browser/cocoa/browser_window_controller_private.h @@ -102,6 +102,12 @@ // Adjust the UI when entering or leaving fullscreen mode. - (void)adjustUIForFullscreen:(BOOL)fullscreen; +// Allows/prevents bar visibility locks and releases from updating the visual +// state. Enabling makes changes instantaneously; disabling cancels any +// timers/animation. +- (void)enableBarVisibilityUpdates; +- (void)disableBarVisibilityUpdates; + @end // @interface BrowserWindowController(Private) diff --git a/chrome/browser/cocoa/browser_window_controller_private.mm b/chrome/browser/cocoa/browser_window_controller_private.mm index 45da0bf..70a0b53 100644 --- a/chrome/browser/cocoa/browser_window_controller_private.mm +++ b/chrome/browser/cocoa/browser_window_controller_private.mm @@ -437,4 +437,26 @@ willPositionSheet:(NSWindow*)sheet } } +- (void)enableBarVisibilityUpdates { + // Early escape if there's nothing to do. + if (barVisibilityUpdatesEnabled_) + return; + + barVisibilityUpdatesEnabled_ = YES; + + if ([barVisibilityLocks_ count]) + [fullscreenController_ ensureOverlayShownWithAnimation:NO delay:NO]; + else + [fullscreenController_ ensureOverlayHiddenWithAnimation:NO delay:NO]; +} + +- (void)disableBarVisibilityUpdates { + // Early escape if there's nothing to do. + if (!barVisibilityUpdatesEnabled_) + return; + + barVisibilityUpdatesEnabled_ = NO; + [fullscreenController_ cancelAnimationAndTimers]; +} + @end // @implementation BrowserWindowController(Private) diff --git a/chrome/browser/cocoa/fullscreen_controller.h b/chrome/browser/cocoa/fullscreen_controller.h index f44b590..07a4712 100644 --- a/chrome/browser/cocoa/fullscreen_controller.h +++ b/chrome/browser/cocoa/fullscreen_controller.h @@ -79,6 +79,9 @@ - (void)ensureOverlayShownWithAnimation:(BOOL)animate delay:(BOOL)delay; - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate delay:(BOOL)delay; +// Cancels any running animation and timers. +- (void)cancelAnimationAndTimers; + @end #endif // CHROME_BROWSER_COCOA_FULLSCREEN_CONTROLLER_H_ diff --git a/chrome/browser/cocoa/fullscreen_controller.mm b/chrome/browser/cocoa/fullscreen_controller.mm index f50643b..be90cf6 100644 --- a/chrome/browser/cocoa/fullscreen_controller.mm +++ b/chrome/browser/cocoa/fullscreen_controller.mm @@ -233,6 +233,12 @@ const NSTimeInterval kDropdownHideDelay = 0.2; } } +- (void)cancelAnimationAndTimers { + [self cancelAllTimers]; + [currentAnimation_ stopAnimation]; + currentAnimation_.reset(); +} + // Used to activate the floating bar in fullscreen mode. - (void)mouseEntered:(NSEvent*)event { DCHECK(isFullscreen_); @@ -459,10 +465,7 @@ const NSTimeInterval kDropdownHideDelay = 0.2; - (void)cleanup { [self cancelMouseExitCheck]; - [self cancelAllTimers]; - - [currentAnimation_ stopAnimation]; - currentAnimation_.reset(); + [self cancelAnimationAndTimers]; [contentView_ removeTrackingArea:trackingArea_]; contentView_ = nil; |