Index: chrome/browser/ui/cocoa/fullscreen_toolbar_controller.h |
diff --git a/chrome/browser/ui/cocoa/fullscreen_toolbar_controller.h b/chrome/browser/ui/cocoa/fullscreen_toolbar_controller.h |
index 8d54af9773d982149981497957028cea860c0aa7..a604461088002ef94f417a8c2b8475f62abf1b08 100644 |
--- a/chrome/browser/ui/cocoa/fullscreen_toolbar_controller.h |
+++ b/chrome/browser/ui/cocoa/fullscreen_toolbar_controller.h |
@@ -12,6 +12,7 @@ |
#include "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
@class BrowserWindowController; |
+@class CrTrackingArea; |
@class DropdownAnimation; |
namespace fullscreen_mac { |
@@ -35,6 +36,25 @@ enum SlidingStyle { |
// when the animation finishes. This is largely done for ease of |
// implementation; it is easier to check the mouse location at each animation |
// step than it is to manage a constantly-changing tracking area. |
+// |
+ |
+// The |toolbarFraction_| is usually set by |setMenuBarRevealProgress:|, which |
+// is called by MenuBarRevealHandler(). This makes the toolbar show/hide in |
+// sync with the menubar. However, there's an edge case that appears when the |
+// sliding style is set to OMNIBOX_TABS_HIDDEN. If the user interacts with the |
+// bottom half of the toolbar, the menubar will disappear and take the toolbar |
+// with it. This prevents users from interacting properly with the omnibox and |
+// bookmarks bar. |
+// |
+// To prevent the toolbar from disappearing when the user is still interacting |
+// with it, we lock its visibility so that the toolbar will remain, even after |
+// the menubar had disappeared. The tracking area is then used to check if the |
+// user is still interacting with the toolbar. Once we receive a mouse exit |
+// event, we release the visibility lock so that the toolbar can hidden by the |
+// menubar (if it's still there) or via a DropdownAnimation (if the menubar is |
+// gone). |
+ |
+// TODO (spqchan): Write tests for this class. See crbug.com/640064. |
@interface FullscreenToolbarController : NSObject<NSAnimationDelegate> { |
@private |
// Our parent controller. |
@@ -43,6 +63,18 @@ enum SlidingStyle { |
// Whether or not we are in fullscreen mode. |
BOOL inFullscreenMode_; |
+ // The content view for the window. This is nil when not in fullscreen mode. |
+ NSView* contentView_; // weak |
+ |
+ // The frame for the tracking area. The value is the toolbar overlay's frame |
+ // with additional height added at the bottom. |
+ NSRect trackingAreaFrame_; |
+ |
+ // The tracking area associated with the toolbar overlay bar. This tracking |
+ // area is used to keep the toolbar active if the menubar had animated out |
+ // but the mouse is still on the toolbar. |
+ base::scoped_nsobject<CrTrackingArea> trackingArea_; |
+ |
// Pointer to the currently running animation. Is nil if no animation is |
// running. |
base::scoped_nsobject<DropdownAnimation> currentAnimation_; |
@@ -87,14 +119,15 @@ enum SlidingStyle { |
- (id)initWithBrowserController:(BrowserWindowController*)controller |
style:(fullscreen_mac::SlidingStyle)style; |
-// Informs the controller that the browser has entered or exited presentation |
+// Informs the controller that the browser has entered or exited fullscreen |
// mode. |-setupFullscreenToolbarForContentView:showDropdown:| should be called |
// after the window is setup, just before it is shown. |-exitFullscreenMode| |
// should be called before any views are moved back to the non-fullscreen |
// window. If |-setupFullscreenToolbarForContentView:showDropdown:| is called, |
// it must be balanced with a call to |-exitFullscreenMode| before the |
// controller is released. |
-- (void)setupFullscreenToolbarWithDropdown:(BOOL)showDropdown; |
+- (void)setupFullscreenToolbarForContentView:(NSView*)contentView |
+ showDropdown:(BOOL)showDropdown; |
- (void)exitFullscreenMode; |
// Returns the amount by which the floating bar should be offset downwards (to |
@@ -124,10 +157,16 @@ enum SlidingStyle { |
// only be revealed if the mouse is there. |
- (BOOL)isMouseOnScreen; |
-// Returns true if the browser is in the process of entering/exiting |
+// Sets |trackingAreaFrame_| from the given overlay frame. |
+- (void)setTrackingAreaFromOverlayFrame:(NSRect)frame; |
+ |
+// Returns YES if the browser is in the process of entering/exiting |
// fullscreen. |
- (BOOL)isFullscreenTransitionInProgress; |
+// Returns YES if the browser in in fullscreen. |
+- (BOOL)isInFullscreen; |
+ |
@end |
// Private methods exposed for testing. |
@@ -140,7 +179,8 @@ enum SlidingStyle { |
// Updates the local state that reflects the fraction of the toolbar area that |
// is showing. This function has the side effect of changing the AppKit |
-// Fullscreen option for whether the menu bar is shown. |
+// Fullscreen option for whether the menu bar is shown. If the toolbar |
+// visibility is locked, the fraction will be updated to 1.0; |
- (void)changeToolbarFraction:(CGFloat)fraction; |
@end |