Chromium Code Reviews| Index: chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm |
| diff --git a/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm b/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm |
| index 3bf1e041fff697b21e4642510cff311f42c2135f..91e9008090f1ae1c49fcf8e6ca3c3b0f2d019c94 100644 |
| --- a/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm |
| +++ b/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm |
| @@ -9,6 +9,7 @@ |
| #import "chrome/browser/ui/cocoa/l10n_util.h" |
| #import "chrome/browser/ui/cocoa/view_id_util.h" |
| +#include "chrome/browser/ui/layout_constants.h" |
|
Robert Sesek
2017/01/13 22:53:59
I can't find any other uses of layout_constants.h
Sidney San Martín
2017/01/13 23:03:29
I may have a better option, hang tight.
|
| #include "ui/base/cocoa/appkit_utils.h" |
| #include "ui/events/keycodes/keyboard_code_conversion_mac.h" |
| @@ -32,7 +33,6 @@ NSString* const kBrowserActionsContainerKeyEventKey = |
| namespace { |
| const CGFloat kAnimationDuration = 0.2; |
| const CGFloat kGrippyWidth = 3.0; |
| -const CGFloat kMinimumContainerWidth = 3.0; |
| } // namespace |
| @interface BrowserActionsContainerView(Private) |
| @@ -217,34 +217,27 @@ const CGFloat kMinimumContainerWidth = 3.0; |
| NSPoint location = [self convertPoint:[theEvent locationInWindow] |
| fromView:nil]; |
| - NSRect containerFrame = [self frame]; |
| - CGFloat dX = [theEvent deltaX]; |
| - CGFloat withDelta = location.x - dX; |
| BOOL isRTL = cocoa_l10n_util::ShouldDoExperimentalRTLLayout(); |
| - CGFloat maxAllowedWidth = [self maxAllowedWidth]; |
| + const CGFloat minWidth = GetLayoutConstant(TOOLBAR_STANDARD_SPACING); |
| + const CGFloat maxWidth = std::min([self maxAllowedWidth], maxDesiredWidth_); |
| - const CGFloat maxWidth = std::min(maxAllowedWidth, maxDesiredWidth_); |
| - CGFloat newWidth = NSWidth(containerFrame) + (isRTL ? dX : -dX); |
| - newWidth = std::min(std::max(newWidth, kMinimumContainerWidth), maxWidth); |
| + const CGFloat oldWidth = NSWidth(self.frame); |
| + const CGFloat newWidth = |
| + std::min(std::max((isRTL ? location.x : oldWidth - location.x), minWidth), |
| + maxWidth); |
| - BOOL canGrow = NSWidth(containerFrame) < maxWidth; |
| - BOOL canShrink = NSWidth(containerFrame) > kMinimumContainerWidth; |
| + (isRTL ? canDragLeft_ : canDragRight_) = newWidth < maxWidth; |
| + (isRTL ? canDragRight_ : canDragLeft_) = newWidth > minWidth; |
| - canDragLeft_ = |
| - withDelta <= initialDragPoint_.x && (isRTL ? canShrink : canGrow); |
| - canDragRight_ = |
| - (withDelta >= initialDragPoint_.x) && (isRTL ? canGrow : canShrink); |
| - if ((dX < 0.0 && !canDragLeft_) || (dX > 0.0 && !canDragRight_) || |
| - fabs(dX) < FLT_EPSILON) |
| - return; |
| + grippyPinned_ = newWidth == maxWidth; |
| - grippyPinned_ = newWidth >= maxAllowedWidth; |
| + NSRect newFrame = self.frame; |
| if (!isRTL) |
| - containerFrame.origin.x += dX; |
| - containerFrame.size.width = newWidth; |
| + newFrame.origin.x += oldWidth - newWidth; |
| + newFrame.size.width = newWidth; |
| - [self setFrame:containerFrame]; |
| + [self setFrame:newFrame]; |
| [self setNeedsDisplay:YES]; |
| [[NSNotificationCenter defaultCenter] |
| @@ -282,7 +275,7 @@ const CGFloat kMinimumContainerWidth = 3.0; |
| #pragma mark Public Methods |
| - (void)resizeToWidth:(CGFloat)width animate:(BOOL)animate { |
| - width = std::max(width, kMinimumContainerWidth); |
| + width = std::max(width, CGFloat(GetLayoutConstant(TOOLBAR_STANDARD_SPACING))); |
| NSRect newFrame = [self frame]; |
| CGFloat maxAllowedWidth = [self maxAllowedWidth]; |