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

Unified Diff: chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm

Issue 636283004: To ensure that the location bar will not reach the minimum width. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make naming consistent. Created 6 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
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm
diff --git a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm
index a33f9a33888889e3ee24e189fb6be45b908c5e7d..626d8eb6a07d700455ff5a436cff9b1265b35da2 100644
--- a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm
+++ b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm
@@ -90,6 +90,7 @@ const CGFloat kWrenchMenuLeftPadding = 3.0;
- (void)pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:(BOOL)animate;
- (void)maintainMinimumLocationBarWidth;
- (void)adjustBrowserActionsContainerForNewWindow:(NSNotification*)notification;
+- (void)browserActionsContainerWillDrag:(NSNotification*)notification;
- (void)browserActionsContainerDragged:(NSNotification*)notification;
- (void)browserActionsContainerDragFinished:(NSNotification*)notification;
- (void)browserActionsVisibilityChanged:(NSNotification*)notification;
@@ -591,6 +592,11 @@ class NotificationBridge : public WrenchMenuBadgeController::Delegate {
containerView:browserActionsContainerView_]);
[[NSNotificationCenter defaultCenter]
addObserver:self
+ selector:@selector(browserActionsContainerWillDrag:)
+ name:kBrowserActionGrippyWillDragNotification
+ object:browserActionsController_];
+ [[NSNotificationCenter defaultCenter]
+ addObserver:self
selector:@selector(browserActionsContainerDragged:)
name:kBrowserActionGrippyDraggingNotification
object:browserActionsController_];
@@ -639,6 +645,18 @@ class NotificationBridge : public WrenchMenuBadgeController::Delegate {
[self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:YES];
}
+- (void)browserActionsContainerWillDrag:(NSNotification*)notification {
+ CGFloat deltaX = [[notification.userInfo objectForKey:kTranslationWithDelta]
+ floatValue];
+ CGFloat locationBarWidth = NSWidth([locationBar_ frame]);
+ BOOL locationBarWillBeAtMinSize =
+ (locationBarWidth + deltaX) <= kMinimumLocationBarWidth;
+
+ // Prevent the |browserActionsContainerView_| from dragging if the width of
+ // location bar will reach the minimum.
+ [browserActionsContainerView_ setCanDragLeft:!locationBarWillBeAtMinSize];
+}
+
- (void)browserActionsVisibilityChanged:(NSNotification*)notification {
[self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:NO];
}
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/browser_actions_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698