Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/presentation_mode_controller.h" | 5 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/mac/sdk_forward_declarations.h" | 10 #include "base/mac/sdk_forward_declarations.h" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 const NSTimeInterval kMouseExitCheckDelay = 0.1; | 28 const NSTimeInterval kMouseExitCheckDelay = 0.1; |
| 29 // This show delay attempts to match the delay for the main menu. | 29 // This show delay attempts to match the delay for the main menu. |
| 30 const NSTimeInterval kDropdownShowDelay = 0.3; | 30 const NSTimeInterval kDropdownShowDelay = 0.3; |
| 31 const NSTimeInterval kDropdownHideDelay = 0.2; | 31 const NSTimeInterval kDropdownHideDelay = 0.2; |
| 32 | 32 |
| 33 // The amount by which the floating bar is offset downwards (to avoid the menu) | 33 // The amount by which the floating bar is offset downwards (to avoid the menu) |
| 34 // in presentation mode. (We can't use |-[NSMenu menuBarHeight]| since it | 34 // in presentation mode. (We can't use |-[NSMenu menuBarHeight]| since it |
| 35 // returns 0 when the menu bar is hidden.) | 35 // returns 0 when the menu bar is hidden.) |
| 36 const CGFloat kFloatingBarVerticalOffset = 22; | 36 const CGFloat kFloatingBarVerticalOffset = 22; |
| 37 | 37 |
| 38 OSStatus MenuBarRevealHandler(EventHandlerCallRef handler, | |
| 39 EventRef event, | |
| 40 void* context) { | |
| 41 PresentationModeController* self = | |
| 42 static_cast<PresentationModeController*>(context); | |
| 43 CGFloat revealFraction = 0; | |
| 44 GetEventParameter(event, | |
| 45 FOUR_CHAR_CODE('rvlf'), | |
| 46 typeCGFloat, | |
| 47 NULL, | |
| 48 sizeof(CGFloat), | |
| 49 NULL, | |
| 50 &revealFraction); | |
| 51 [self setMenuBarRevealProgress:revealFraction]; | |
| 52 return CallNextEventHandler(handler, event); | |
| 53 } | |
| 54 | |
| 38 } // end namespace | 55 } // end namespace |
| 39 | 56 |
| 57 @interface PresentationModeController () | |
| 58 // Sets a new current floating bar shown fraction. NOTE: This function has side | |
| 59 // effects, such as modifying the system fullscreen mode (menu bar shown state). | |
| 60 - (void)changeToolbarPercentage:(CGFloat)fraction; | |
| 61 @end | |
| 40 | 62 |
| 41 // Helper class to manage animations for the dropdown bar. Calls | 63 // Helper class to manage animations for the dropdown bar. Calls |
| 42 // [PresentationModeController changeFloatingBarShownFraction] once per | 64 // [PresentationModeController changeToolbarPercentage] once per |
| 43 // animation step. | 65 // animation step. |
| 44 @interface DropdownAnimation : NSAnimation { | 66 @interface DropdownAnimation : NSAnimation { |
| 45 @private | 67 @private |
| 46 PresentationModeController* controller_; | 68 PresentationModeController* controller_; |
| 47 CGFloat startFraction_; | 69 CGFloat startFraction_; |
| 48 CGFloat endFraction_; | 70 CGFloat endFraction_; |
| 49 } | 71 } |
| 50 | 72 |
| 51 @property(readonly, nonatomic) CGFloat startFraction; | 73 @property(readonly, nonatomic) CGFloat startFraction; |
| 52 @property(readonly, nonatomic) CGFloat endFraction; | 74 @property(readonly, nonatomic) CGFloat endFraction; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 65 | 87 |
| 66 @synthesize startFraction = startFraction_; | 88 @synthesize startFraction = startFraction_; |
| 67 @synthesize endFraction = endFraction_; | 89 @synthesize endFraction = endFraction_; |
| 68 | 90 |
| 69 - (id)initWithFraction:(CGFloat)toFraction | 91 - (id)initWithFraction:(CGFloat)toFraction |
| 70 fullDuration:(CGFloat)fullDuration | 92 fullDuration:(CGFloat)fullDuration |
| 71 animationCurve:(NSAnimationCurve)animationCurve | 93 animationCurve:(NSAnimationCurve)animationCurve |
| 72 controller:(PresentationModeController*)controller { | 94 controller:(PresentationModeController*)controller { |
| 73 // Calculate the effective duration, based on the current shown fraction. | 95 // Calculate the effective duration, based on the current shown fraction. |
| 74 DCHECK(controller); | 96 DCHECK(controller); |
| 75 CGFloat fromFraction = [controller floatingBarShownFraction]; | 97 CGFloat fromFraction = controller.toolbarPercentage; |
| 76 CGFloat effectiveDuration = fabs(fullDuration * (fromFraction - toFraction)); | 98 CGFloat effectiveDuration = fabs(fullDuration * (fromFraction - toFraction)); |
| 77 | 99 |
| 78 if ((self = [super gtm_initWithDuration:effectiveDuration | 100 if ((self = [super gtm_initWithDuration:effectiveDuration |
| 79 eventMask:NSLeftMouseDownMask | 101 eventMask:NSLeftMouseDownMask |
| 80 animationCurve:animationCurve])) { | 102 animationCurve:animationCurve])) { |
| 81 startFraction_ = fromFraction; | 103 startFraction_ = fromFraction; |
| 82 endFraction_ = toFraction; | 104 endFraction_ = toFraction; |
| 83 controller_ = controller; | 105 controller_ = controller; |
| 84 } | 106 } |
| 85 return self; | 107 return self; |
| 86 } | 108 } |
| 87 | 109 |
| 88 // Called once per animation step. Overridden to change the floating bar's | 110 // Called once per animation step. Overridden to change the floating bar's |
| 89 // position based on the animation's progress. | 111 // position based on the animation's progress. |
| 90 - (void)setCurrentProgress:(NSAnimationProgress)progress { | 112 - (void)setCurrentProgress:(NSAnimationProgress)progress { |
| 91 CGFloat fraction = | 113 CGFloat fraction = |
| 92 startFraction_ + (progress * (endFraction_ - startFraction_)); | 114 startFraction_ + (progress * (endFraction_ - startFraction_)); |
| 93 [controller_ changeFloatingBarShownFraction:fraction]; | 115 [controller_ changeToolbarPercentage:fraction]; |
| 94 } | 116 } |
| 95 | 117 |
| 96 @end | 118 @end |
| 97 | 119 |
| 98 | 120 |
| 99 @interface PresentationModeController (PrivateMethods) | 121 @interface PresentationModeController (PrivateMethods) |
| 100 | 122 |
| 101 // Updates the visibility of the menu bar and the dock. | 123 // Updates the visibility of the menu bar and the dock. |
| 102 - (void)updateMenuBarAndDockVisibility; | 124 - (void)updateMenuBarAndDockVisibility; |
| 103 | 125 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 | 178 |
| 157 // Stops any running animations, removes tracking areas, etc. | 179 // Stops any running animations, removes tracking areas, etc. |
| 158 - (void)cleanup; | 180 - (void)cleanup; |
| 159 | 181 |
| 160 // Shows and hides the UI associated with this window being active (having main | 182 // Shows and hides the UI associated with this window being active (having main |
| 161 // status). This includes hiding the menu bar. These functions are called when | 183 // status). This includes hiding the menu bar. These functions are called when |
| 162 // the window gains or loses main status as well as in |-cleanup|. | 184 // the window gains or loses main status as well as in |-cleanup|. |
| 163 - (void)showActiveWindowUI; | 185 - (void)showActiveWindowUI; |
| 164 - (void)hideActiveWindowUI; | 186 - (void)hideActiveWindowUI; |
| 165 | 187 |
| 188 // In Immersive Fullscreen, the menubar is visible iff. toolbarPercentage_ >= | |
| 189 // 1.0. | |
| 190 - (BOOL)shouldShowMenubarInImmersiveFullscreen; | |
| 191 | |
| 166 @end | 192 @end |
| 167 | 193 |
| 168 | 194 |
| 169 @implementation PresentationModeController | 195 @implementation PresentationModeController |
| 170 | 196 |
| 171 @synthesize inPresentationMode = inPresentationMode_; | 197 @synthesize inPresentationMode = inPresentationMode_; |
| 198 @synthesize slidingStyle = slidingStyle_; | |
| 199 @synthesize toolbarPercentage = toolbarPercentage_; | |
| 172 | 200 |
| 173 - (id)initWithBrowserController:(BrowserWindowController*)controller { | 201 - (id)initWithBrowserController:(BrowserWindowController*)controller |
| 202 style:(fullscreen_mac::SlidingStyle)style { | |
| 174 if ((self = [super init])) { | 203 if ((self = [super init])) { |
| 175 browserController_ = controller; | 204 browserController_ = controller; |
| 176 systemFullscreenMode_ = base::mac::kFullScreenModeNormal; | 205 systemFullscreenMode_ = base::mac::kFullScreenModeNormal; |
| 206 slidingStyle_ = style; | |
| 177 } | 207 } |
| 178 | 208 |
| 179 // Let the world know what we're up to. | 209 // Let the world know what we're up to. |
| 180 [[NSNotificationCenter defaultCenter] | 210 [[NSNotificationCenter defaultCenter] |
| 181 postNotificationName:kWillEnterFullscreenNotification | 211 postNotificationName:kWillEnterFullscreenNotification |
| 182 object:nil]; | 212 object:nil]; |
| 183 | 213 |
| 214 // Install the Carbon event handler for the undocumented menu bar show/hide | |
| 215 // event. | |
| 216 EventTypeSpec eventSpec = {kEventClassMenu, 2004}; | |
|
Robert Sesek
2014/09/02 19:59:48
nit: I think style is for spaces inside {}
erikchen
2014/09/02 20:43:21
This is the output of clang-format. According to t
| |
| 217 InstallApplicationEventHandler(NewEventHandlerUPP(&MenuBarRevealHandler), | |
| 218 1, | |
| 219 &eventSpec, | |
| 220 self, | |
| 221 &menuBarTrackingHandler_); | |
| 184 return self; | 222 return self; |
| 185 } | 223 } |
| 186 | 224 |
| 187 - (void)dealloc { | 225 - (void)dealloc { |
| 226 RemoveEventHandler(menuBarTrackingHandler_); | |
| 188 DCHECK(!inPresentationMode_); | 227 DCHECK(!inPresentationMode_); |
| 189 DCHECK(!trackingArea_); | 228 DCHECK(!trackingArea_); |
| 190 [super dealloc]; | 229 [super dealloc]; |
| 191 } | 230 } |
| 192 | 231 |
| 193 - (void)enterPresentationModeForContentView:(NSView*)contentView | 232 - (void)enterPresentationModeForContentView:(NSView*)contentView |
| 194 showDropdown:(BOOL)showDropdown { | 233 showDropdown:(BOOL)showDropdown { |
| 195 DCHECK(!inPresentationMode_); | 234 DCHECK(!inPresentationMode_); |
| 196 enteringPresentationMode_ = YES; | 235 enteringPresentationMode_ = YES; |
| 197 inPresentationMode_ = YES; | 236 inPresentationMode_ = YES; |
| 198 contentView_ = contentView; | 237 contentView_ = contentView; |
| 199 [self changeFloatingBarShownFraction:(showDropdown ? 1 : 0)]; | 238 [self changeToolbarPercentage:(showDropdown ? 1 : 0)]; |
| 239 [self updateMenuBarAndDockVisibility]; | |
| 200 | 240 |
| 201 // Register for notifications. Self is removed as an observer in |-cleanup|. | 241 // Register for notifications. Self is removed as an observer in |-cleanup|. |
| 202 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; | 242 NSNotificationCenter* nc = [NSNotificationCenter defaultCenter]; |
| 203 NSWindow* window = [browserController_ window]; | 243 NSWindow* window = [browserController_ window]; |
| 204 | 244 |
| 205 // Disable these notifications on Lion as they cause crashes. | 245 // Disable these notifications on Lion as they cause crashes. |
| 206 // TODO(rohitrao): Figure out what happens if a fullscreen window changes | 246 // TODO(rohitrao): Figure out what happens if a fullscreen window changes |
| 207 // monitors on Lion. | 247 // monitors on Lion. |
| 208 if (base::mac::IsOSSnowLeopard()) { | 248 if (base::mac::IsOSSnowLeopard()) { |
| 209 [nc addObserver:self | 249 [nc addObserver:self |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 [self setupTrackingArea]; | 335 [self setupTrackingArea]; |
| 296 } | 336 } |
| 297 | 337 |
| 298 - (void)ensureOverlayShownWithAnimation:(BOOL)animate delay:(BOOL)delay { | 338 - (void)ensureOverlayShownWithAnimation:(BOOL)animate delay:(BOOL)delay { |
| 299 if (!inPresentationMode_) | 339 if (!inPresentationMode_) |
| 300 return; | 340 return; |
| 301 | 341 |
| 302 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) | 342 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kKioskMode)) |
| 303 return; | 343 return; |
| 304 | 344 |
| 345 if (self.slidingStyle == fullscreen_mac::OMNIBOX_TABS_PRESENT) | |
| 346 return; | |
| 347 | |
| 305 if (animate) { | 348 if (animate) { |
| 306 if (delay) { | 349 if (delay) { |
| 307 [self startShowTimer]; | 350 [self startShowTimer]; |
| 308 } else { | 351 } else { |
| 309 [self cancelAllTimers]; | 352 [self cancelAllTimers]; |
| 310 [self changeOverlayToFraction:1 withAnimation:YES]; | 353 [self changeOverlayToFraction:1 withAnimation:YES]; |
| 311 } | 354 } |
| 312 } else { | 355 } else { |
| 313 DCHECK(!delay); | 356 DCHECK(!delay); |
| 314 [self cancelAllTimers]; | 357 [self cancelAllTimers]; |
| 315 [self changeOverlayToFraction:1 withAnimation:NO]; | 358 [self changeOverlayToFraction:1 withAnimation:NO]; |
| 316 } | 359 } |
| 317 } | 360 } |
| 318 | 361 |
| 319 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate delay:(BOOL)delay { | 362 - (void)ensureOverlayHiddenWithAnimation:(BOOL)animate delay:(BOOL)delay { |
| 320 if (!inPresentationMode_) | 363 if (!inPresentationMode_) |
| 321 return; | 364 return; |
| 322 | 365 |
| 366 if (self.slidingStyle == fullscreen_mac::OMNIBOX_TABS_PRESENT) | |
| 367 return; | |
| 368 | |
| 323 if (animate) { | 369 if (animate) { |
| 324 if (delay) { | 370 if (delay) { |
| 325 [self startHideTimer]; | 371 [self startHideTimer]; |
| 326 } else { | 372 } else { |
| 327 [self cancelAllTimers]; | 373 [self cancelAllTimers]; |
| 328 [self changeOverlayToFraction:0 withAnimation:YES]; | 374 [self changeOverlayToFraction:0 withAnimation:YES]; |
| 329 } | 375 } |
| 330 } else { | 376 } else { |
| 331 DCHECK(!delay); | 377 DCHECK(!delay); |
| 332 [self cancelAllTimers]; | 378 [self cancelAllTimers]; |
| 333 [self changeOverlayToFraction:0 withAnimation:NO]; | 379 [self changeOverlayToFraction:0 withAnimation:NO]; |
| 334 } | 380 } |
| 335 } | 381 } |
| 336 | 382 |
| 337 - (void)cancelAnimationAndTimers { | 383 - (void)cancelAnimationAndTimers { |
| 338 [self cancelAllTimers]; | 384 [self cancelAllTimers]; |
| 339 [currentAnimation_ stopAnimation]; | 385 [currentAnimation_ stopAnimation]; |
| 340 currentAnimation_.reset(); | 386 currentAnimation_.reset(); |
| 341 } | 387 } |
| 342 | 388 |
| 343 - (CGFloat)floatingBarShownFraction { | |
| 344 return [browserController_ floatingBarShownFraction]; | |
| 345 } | |
| 346 | |
| 347 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode { | 389 - (void)setSystemFullscreenModeTo:(base::mac::FullScreenMode)mode { |
| 348 if (mode == systemFullscreenMode_) | 390 if (mode == systemFullscreenMode_) |
| 349 return; | 391 return; |
| 350 if (systemFullscreenMode_ == base::mac::kFullScreenModeNormal) | 392 if (systemFullscreenMode_ == base::mac::kFullScreenModeNormal) |
| 351 base::mac::RequestFullScreen(mode); | 393 base::mac::RequestFullScreen(mode); |
| 352 else if (mode == base::mac::kFullScreenModeNormal) | 394 else if (mode == base::mac::kFullScreenModeNormal) |
| 353 base::mac::ReleaseFullScreen(systemFullscreenMode_); | 395 base::mac::ReleaseFullScreen(systemFullscreenMode_); |
| 354 else | 396 else |
| 355 base::mac::SwitchFullScreenModes(systemFullscreenMode_, mode); | 397 base::mac::SwitchFullScreenModes(systemFullscreenMode_, mode); |
| 356 systemFullscreenMode_ = mode; | 398 systemFullscreenMode_ = mode; |
| 357 } | 399 } |
| 358 | 400 |
| 359 - (void)changeFloatingBarShownFraction:(CGFloat)fraction { | 401 - (void)changeToolbarPercentage:(CGFloat)fraction { |
| 360 [browserController_ setFloatingBarShownFraction:fraction]; | 402 toolbarPercentage_ = fraction; |
| 403 [browserController_ layoutSubviews]; | |
| 361 | 404 |
| 362 [self updateMenuBarAndDockVisibility]; | 405 // In AppKit fullscreen, moving the mouse to the top of the screen toggles |
| 406 // menu visibility. Replicate the same effect for immersive fullscreen. | |
| 407 if ([browserController_ isInImmersiveFullscreen]) | |
| 408 [self updateMenuBarAndDockVisibility]; | |
| 409 } | |
| 410 | |
| 411 // This method works, but is fragile. | |
| 412 // | |
| 413 // It gets used during view layout, which sometimes needs to be done at the | |
| 414 // beginning of an animation. As such, this method needs to reflect the | |
| 415 // menubarOffset expected at the end of the animation. This information is not | |
| 416 // readily available. (The layout logic needs a refactor). | |
| 417 // | |
| 418 // For AppKit Fullscreen, the menubar always starts hidden, and | |
| 419 // menubarPercentage_ always starts at 0, so the logic happens to work. For | |
| 420 // Immersive Fullscreen, this class controls the visibility of the menu bar, so | |
| 421 // the logic is correct and not fragile. | |
| 422 - (CGFloat)menubarOffset { | |
| 423 if ([browserController_ isInAppKitFullscreen]) | |
| 424 return -std::floor((menubarPercentage_) * [self floatingBarVerticalOffset]); | |
|
Robert Sesek
2014/09/02 19:59:48
Why parens around the first multiplicand?
erikchen
2014/09/02 20:43:21
removed.
| |
| 425 | |
| 426 return [self shouldShowMenubarInImmersiveFullscreen] | |
| 427 ? -[self floatingBarVerticalOffset] | |
| 428 : 0; | |
| 363 } | 429 } |
| 364 | 430 |
| 365 // Used to activate the floating bar in presentation mode. | 431 // Used to activate the floating bar in presentation mode. |
| 366 - (void)mouseEntered:(NSEvent*)event { | 432 - (void)mouseEntered:(NSEvent*)event { |
| 367 DCHECK(inPresentationMode_); | 433 DCHECK(inPresentationMode_); |
| 368 | 434 |
| 369 // Having gotten a mouse entered, we no longer need to do exit checks. | 435 // Having gotten a mouse entered, we no longer need to do exit checks. |
| 370 [self cancelMouseExitCheck]; | 436 [self cancelMouseExitCheck]; |
| 371 | 437 |
| 372 NSTrackingArea* trackingArea = [event trackingArea]; | 438 NSTrackingArea* trackingArea = [event trackingArea]; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 419 // |any updates that may have come while the animation was running. Install a | 485 // |any updates that may have come while the animation was running. Install a |
| 420 // new tracking area with these bounds. | 486 // new tracking area with these bounds. |
| 421 [self setupTrackingArea]; | 487 [self setupTrackingArea]; |
| 422 | 488 |
| 423 // TODO(viettrungluu): Better would be to check during the animation; doing it | 489 // TODO(viettrungluu): Better would be to check during the animation; doing it |
| 424 // here means that the timing is slightly off. | 490 // here means that the timing is slightly off. |
| 425 if (![self mouseInsideTrackingRect]) | 491 if (![self mouseInsideTrackingRect]) |
| 426 [self scheduleHideForMouse]; | 492 [self scheduleHideForMouse]; |
| 427 } | 493 } |
| 428 | 494 |
| 495 - (void)setMenuBarRevealProgress:(CGFloat)progress { | |
| 496 menubarPercentage_ = progress; | |
| 497 | |
| 498 // If an animation is not running, then -layoutSubviews will not be called | |
| 499 // for each tick of the menu bar reveal. Do that manually. | |
| 500 // TODO(erikchen): The animation is janky. layoutSubviews need a refactor so | |
| 501 // that it calls setFrameOffset: instead of setFrame: if the frame's size has | |
| 502 // not changed. | |
| 503 if (!currentAnimation_.get()) | |
| 504 [browserController_ layoutSubviews]; | |
| 505 } | |
| 506 | |
| 429 @end | 507 @end |
| 430 | 508 |
| 431 | 509 |
| 432 @implementation PresentationModeController (PrivateMethods) | 510 @implementation PresentationModeController (PrivateMethods) |
| 433 | 511 |
| 434 - (void)updateMenuBarAndDockVisibility { | 512 - (void)updateMenuBarAndDockVisibility { |
| 435 if (![[browserController_ window] isMainWindow] || | 513 if (![[browserController_ window] isMainWindow] || |
| 436 ![browserController_ isInImmersiveFullscreen]) { | 514 ![browserController_ isInImmersiveFullscreen]) { |
| 437 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeNormal]; | 515 [self setSystemFullscreenModeTo:base::mac::kFullScreenModeNormal]; |
| 438 return; | 516 return; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 456 return eachScreenShouldHaveMenuBar ?: [self isWindowOnPrimaryScreen]; | 534 return eachScreenShouldHaveMenuBar ?: [self isWindowOnPrimaryScreen]; |
| 457 } | 535 } |
| 458 | 536 |
| 459 - (BOOL)isWindowOnPrimaryScreen { | 537 - (BOOL)isWindowOnPrimaryScreen { |
| 460 NSScreen* screen = [[browserController_ window] screen]; | 538 NSScreen* screen = [[browserController_ window] screen]; |
| 461 NSScreen* primaryScreen = [[NSScreen screens] objectAtIndex:0]; | 539 NSScreen* primaryScreen = [[NSScreen screens] objectAtIndex:0]; |
| 462 return (screen == primaryScreen); | 540 return (screen == primaryScreen); |
| 463 } | 541 } |
| 464 | 542 |
| 465 - (base::mac::FullScreenMode)desiredSystemFullscreenMode { | 543 - (base::mac::FullScreenMode)desiredSystemFullscreenMode { |
| 466 if ([browserController_ floatingBarShownFraction] >= 1.0) | 544 if ([self shouldShowMenubarInImmersiveFullscreen]) |
| 467 return base::mac::kFullScreenModeHideDock; | 545 return base::mac::kFullScreenModeHideDock; |
| 468 return base::mac::kFullScreenModeHideAll; | 546 return base::mac::kFullScreenModeHideAll; |
| 469 } | 547 } |
| 470 | 548 |
| 471 - (void)changeOverlayToFraction:(CGFloat)fraction | 549 - (void)changeOverlayToFraction:(CGFloat)fraction |
| 472 withAnimation:(BOOL)animate { | 550 withAnimation:(BOOL)animate { |
| 473 // The non-animated case is really simple, so do it and return. | 551 // The non-animated case is really simple, so do it and return. |
| 474 if (!animate) { | 552 if (!animate) { |
| 475 [currentAnimation_ stopAnimation]; | 553 [currentAnimation_ stopAnimation]; |
| 476 [self changeFloatingBarShownFraction:fraction]; | 554 [self changeToolbarPercentage:fraction]; |
| 477 return; | 555 return; |
| 478 } | 556 } |
| 479 | 557 |
| 480 // If we're already animating to the given fraction, then there's nothing more | 558 // If we're already animating to the given fraction, then there's nothing more |
| 481 // to do. | 559 // to do. |
| 482 if (currentAnimation_ && [currentAnimation_ endFraction] == fraction) | 560 if (currentAnimation_ && [currentAnimation_ endFraction] == fraction) |
| 483 return; | 561 return; |
| 484 | 562 |
| 485 // In all other cases, we want to cancel any running animation (which may be | 563 // In all other cases, we want to cancel any running animation (which may be |
| 486 // to show or to hide). | 564 // to show or to hide). |
| 487 [currentAnimation_ stopAnimation]; | 565 [currentAnimation_ stopAnimation]; |
| 488 | 566 |
| 489 // Now, if it happens to already be in the right state, there's nothing more | |
| 490 // to do. | |
| 491 if ([browserController_ floatingBarShownFraction] == fraction) | |
| 492 return; | |
| 493 | |
| 494 // Create the animation and set it up. | 567 // Create the animation and set it up. |
| 495 currentAnimation_.reset( | 568 currentAnimation_.reset( |
| 496 [[DropdownAnimation alloc] initWithFraction:fraction | 569 [[DropdownAnimation alloc] initWithFraction:fraction |
| 497 fullDuration:kDropdownAnimationDuration | 570 fullDuration:kDropdownAnimationDuration |
| 498 animationCurve:NSAnimationEaseOut | 571 animationCurve:NSAnimationEaseOut |
| 499 controller:self]); | 572 controller:self]); |
| 500 DCHECK(currentAnimation_); | 573 DCHECK(currentAnimation_); |
| 501 [currentAnimation_ setAnimationBlockingMode:NSAnimationNonblocking]; | 574 [currentAnimation_ setAnimationBlockingMode:NSAnimationNonblocking]; |
| 502 [currentAnimation_ setDelegate:self]; | 575 [currentAnimation_ setDelegate:self]; |
| 503 | 576 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 | 742 |
| 670 // TODO(rohitrao): Insert the Exit Fullscreen button. http://crbug.com/35956 | 743 // TODO(rohitrao): Insert the Exit Fullscreen button. http://crbug.com/35956 |
| 671 } | 744 } |
| 672 | 745 |
| 673 - (void)hideActiveWindowUI { | 746 - (void)hideActiveWindowUI { |
| 674 [self updateMenuBarAndDockVisibility]; | 747 [self updateMenuBarAndDockVisibility]; |
| 675 | 748 |
| 676 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956 | 749 // TODO(rohitrao): Remove the Exit Fullscreen button. http://crbug.com/35956 |
| 677 } | 750 } |
| 678 | 751 |
| 752 - (BOOL)shouldShowMenubarInImmersiveFullscreen { | |
| 753 return toolbarPercentage_ >= 1.0; | |
| 754 } | |
| 755 | |
| 679 @end | 756 @end |
| OLD | NEW |