| Index: chrome/browser/ui/cocoa/fullscreen_toolbar_controller.mm
|
| diff --git a/chrome/browser/ui/cocoa/fullscreen_toolbar_controller.mm b/chrome/browser/ui/cocoa/fullscreen_toolbar_controller.mm
|
| index e84f9ea822627483496c985b40cf39bfc6c69bfc..800640fcdc5a3c0583e44be1802d85e38bd89695 100644
|
| --- a/chrome/browser/ui/cocoa/fullscreen_toolbar_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/fullscreen_toolbar_controller.mm
|
| @@ -195,7 +195,6 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler,
|
| browserController_ = controller;
|
| systemFullscreenMode_ = base::mac::kFullScreenModeNormal;
|
| slidingStyle_ = style;
|
| - hiddenToolbarState_ = fullscreen_mac::TOOLBAR_HIDDEN;
|
| }
|
|
|
| // Install the Carbon event handler for the menubar show, hide and
|
| @@ -298,7 +297,9 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler,
|
|
|
| [self cancelHideTimer];
|
| [self animateToolbarVisibility:NO];
|
| - shouldShowToolbarWithoutMenu_ = NO;
|
| +
|
| + // The animation will tell us the appropriate progress.
|
| + // shouldShowToolbarWithoutMenu_ = NO;
|
| }
|
|
|
| - (void)cancelAnimationAndTimer {
|
| @@ -317,7 +318,7 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler,
|
| return;
|
|
|
| // Reveal the toolbar for tabstrip changes if the toolbar is hidden.
|
| - if (hiddenToolbarState_ == fullscreen_mac::TOOLBAR_HIDDEN) {
|
| + if ([self toolbarFraction] == 0.0) {
|
| isRevealingToolbarForTabStripChanges_ = YES;
|
| [self showToolbarIfPossibleWithAnimation:YES];
|
| }
|
| @@ -391,16 +392,42 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler,
|
| case fullscreen_mac::OMNIBOX_TABS_NONE:
|
| return kHideFraction;
|
| case fullscreen_mac::OMNIBOX_TABS_HIDDEN:
|
| - if (hiddenToolbarState_ == fullscreen_mac::TOOLBAR_SHOWN)
|
| + // If the menubar is showing, we always want to show the toolbar.
|
| + if (menubarState_ == fullscreen_mac::MENUBAR_SHOWN) {
|
| + return kShowFraction;
|
| + }
|
| +
|
| + // If the menubar is animating in, and the toolbar was not already
|
| + // showing, then it should animate in at the same rate.
|
| + if (menubarState_ == fullscreen_mac::MENUBAR_TRANSITIONING && menubarAnimatingIn_ &&
|
| + !wasToolbarShowingWhenMenubarStartedAnimatingIn_) {
|
| + return menubarFraction_;
|
| + }
|
| +
|
| + // If the menubar is animating in, and the toolbar is already showing,
|
| + // then continue to show it.
|
| + if (menubarState_ == fullscreen_mac::MENUBAR_TRANSITIONING &&
|
| + menubarAnimatingIn_) {
|
| return kShowFraction;
|
| + }
|
|
|
| - if (hiddenToolbarState_ == fullscreen_mac::TOOLBAR_HIDDEN)
|
| - return kHideFraction;
|
| + // If the menubar is animating out, we ignore!.
|
| + if (menubarState_ == fullscreen_mac::MENUBAR_TRANSITIONING &&
|
| + !menubarAnimatingIn_) {
|
| + }
|
|
|
| + // At this point, menubar is not showing. Is there a custom animation?
|
| if (currentAnimation_.get())
|
| return [currentAnimation_ toolbarFraction];
|
|
|
| - return shouldShowToolbarWithoutMenu_ ? kShowFraction : menubarFraction_;
|
| + // If mouse is in tracking rect, show toolbar:
|
| +
|
| + // If there's a hide timer, show toolbar:
|
| +
|
| + // Logic for show & hide tab strip on tab change...haven't thought through
|
| + // all the edge cases.
|
| +
|
| + // Default: hide toolbar.
|
| }
|
| }
|
|
|
| @@ -430,15 +457,9 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler,
|
|
|
| - (void)animationDidStop:(NSAnimation*)animation {
|
| CGFloat toolbarFraction = [self toolbarFraction];
|
| - if (IsCGFloatEqual(toolbarFraction, 1.0))
|
| - hiddenToolbarState_ = fullscreen_mac::TOOLBAR_SHOWN;
|
| - else if (IsCGFloatEqual(toolbarFraction, 0.0))
|
| - hiddenToolbarState_ = fullscreen_mac::TOOLBAR_HIDDEN;
|
| - else
|
| - hiddenToolbarState_ = fullscreen_mac::TOOLBAR_TRANSITIONING;
|
|
|
| if (isRevealingToolbarForTabStripChanges_) {
|
| - if (hiddenToolbarState_ != fullscreen_mac::TOOLBAR_HIDDEN) {
|
| + if (IsCGFloatEqual(toolbarFraction, 0.0)) {
|
| // Set the timer to hide the toolbar.
|
| [hideTimer_ invalidate];
|
| hideTimer_.reset(
|
| @@ -462,31 +483,36 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler,
|
| }
|
|
|
| - (void)setMenuBarRevealProgress:(CGFloat)progress {
|
| + // TODO: What happens if a mouse quickly bounces between two screens? What we
|
| + // really want to know is whether the callback is for the screen that the
|
| + // browser window is on. I'm not sure what the "progress > menubarFraction_"
|
| + // check is for but it seems wrong?
|
| // If the menubarFraction increases, check if we are in the right screen
|
| // so that the toolbar is not revealed on the wrong screen.
|
| if (![self isMouseOnScreen] && progress > menubarFraction_)
|
| return;
|
|
|
| - BOOL isMenuBarDisappearing = progress < menubarFraction_;
|
| - menubarFraction_ = progress;
|
| -
|
| - if (self.slidingStyle == fullscreen_mac::OMNIBOX_TABS_HIDDEN) {
|
| - shouldShowToolbarWithoutMenu_ =
|
| - shouldShowToolbarWithoutMenu_ ||
|
| - (isMenuBarDisappearing && [self isToolbarFocused]);
|
| -
|
| - if (IsCGFloatEqual(menubarFraction_, kShowFraction)) {
|
| - [self setupTrackingArea];
|
| - hiddenToolbarState_ = fullscreen_mac::TOOLBAR_SHOWN;
|
| + if (IsCGFloatEqual(menubarFraction_, kShowFraction)) {
|
| + // NSMenubar fully showing.
|
| + menubarState_ = fullscreen_mac::MENUBAR_SHOWN;
|
| + } else if (IsCGFloatEqual(menubarFraction_, kShowFraction)) {
|
| + // NSMenubar fully hidden.
|
| + menubarState_ = fullscreen_mac::MENUBAR_HIDDEN;
|
| + } else {
|
| + menubarState_ = fullscreen_mac::MENUBAR_TRANSITIONING;
|
| + menubarAnimatingIn_ = progress > menubarFraction_;
|
| + if (IsCGFloatEqual(menubarFraction_, kHideFraction) && menubarAnimatingIn_) {
|
| + // TODO: What if toolbar was animating when menubar starts animating in?
|
| + // We need to decide what behavior we want. I think we want to override
|
| + // the existing animation, so this should be toolbarFraction > 0.
|
| + wasToolbarShowingWhenMenubarStartedAnimatingIn_ = IsCGFloatEqual([self toolbarFraction], kShowFraction);
|
| }
|
| + }
|
| + menubarFraction_ = progress;
|
|
|
| - // If |shouldShowToolbarWithoutMenu_| is true, then |hiddenToolbarState_|
|
| - // should remain fullscreen_mac::TOOLBAR_SHOWN.
|
| - if (!shouldShowToolbarWithoutMenu_) {
|
| - hiddenToolbarState_ = IsCGFloatEqual(menubarFraction_, kHideFraction)
|
| - ? fullscreen_mac::TOOLBAR_HIDDEN
|
| - : fullscreen_mac::TOOLBAR_TRANSITIONING;
|
| - }
|
| + if (self.slidingStyle == fullscreen_mac::OMNIBOX_TABS_HIDDEN &&
|
| + menubarState_ == fullscreen_mac::MENUBAR_SHOWN) {
|
| + [self setupTrackingArea];
|
| }
|
|
|
| // If an animation is not running, then -layoutSubviews will not be called
|
| @@ -609,7 +635,6 @@ OSStatus MenuBarRevealHandler(EventHandlerCallRef handler,
|
| [self removeTrackingAreaIfNecessary];
|
|
|
| [currentAnimation_ startAnimation];
|
| - hiddenToolbarState_ = fullscreen_mac::TOOLBAR_TRANSITIONING;
|
| }
|
|
|
| - (void)cancelHideTimer {
|
|
|