summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrdevlin.cronin <rdevlin.cronin@chromium.org>2014-12-19 16:34:03 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-20 00:34:41 +0000
commitfe43b8ac558890fcd204b1f4354281065e026d74 (patch)
treeadd62083f22ea4a42965e2e3eddfc2aa02e0cec2
parent71b094d30830c9af20c779a20ae967f68a6dbd50 (diff)
downloadchromium_src-fe43b8ac558890fcd204b1f4354281065e026d74.zip
chromium_src-fe43b8ac558890fcd204b1f4354281065e026d74.tar.gz
chromium_src-fe43b8ac558890fcd204b1f4354281065e026d74.tar.bz2
[Extensions Toolbar Mac] Fix extensions toolbar drift
If the extensions toolbar is animating while the toolbar frame is also changing height (e.g., when adding the bookmark bar), then we need to update the extensions toolbar's frame to match the new height. BUG=442721 Review URL: https://codereview.chromium.org/792733004 Cr-Commit-Position: refs/heads/master@{#309310}
-rw-r--r--chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h6
-rw-r--r--chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm12
-rw-r--r--chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm14
3 files changed, 30 insertions, 2 deletions
diff --git a/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h b/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h
index 3098eea..ccdbca3 100644
--- a/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h
+++ b/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h
@@ -83,6 +83,12 @@ extern NSString* const kTranslationWithDelta;
// If no animation is running, returns the container's current frame.
- (NSRect)animationEndFrame;
+// Returns true if the view is animating.
+- (BOOL)isAnimating;
+
+// Stops any animation in progress.
+- (void)stopAnimation;
+
@property(nonatomic) BOOL canDragLeft;
@property(nonatomic) BOOL canDragRight;
@property(nonatomic) BOOL grippyPinned;
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 b6d98a2..3fa8ee3 100644
--- a/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm
+++ b/chrome/browser/ui/cocoa/extensions/browser_actions_container_view.mm
@@ -174,8 +174,7 @@ const CGFloat kMinimumContainerWidth = 10.0;
frame.size.width = width;
NSRect newFrame = NSOffsetRect(frame, dX, 0);
- if ([resizeAnimation_ isAnimating])
- [resizeAnimation_ stopAnimation];
+ [self stopAnimation];
if (animate) {
NSDictionary* animationDictionary = @{
@@ -209,6 +208,15 @@ const CGFloat kMinimumContainerWidth = 10.0;
}
}
+- (BOOL)isAnimating {
+ return [resizeAnimation_ isAnimating];
+}
+
+- (void)stopAnimation {
+ if ([resizeAnimation_ isAnimating])
+ [resizeAnimation_ stopAnimation];
+}
+
#pragma mark -
#pragma mark Private Methods
diff --git a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm
index c59b70b..0abedb2 100644
--- a/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm
+++ b/chrome/browser/ui/cocoa/toolbar/toolbar_controller.mm
@@ -691,6 +691,20 @@ class NotificationBridge : public WrenchMenuBadgeController::Delegate {
if (!browserActionsController_.get())
return;
+ if ([browserActionsContainerView_ isAnimating]) {
+ // If the browser actions container is animating, we need to stop it first,
+ // because the frame it's animating for could be incorrect with the new
+ // bounds (if, for instance, the bookmark bar was added).
+ // This will advance to the end of the animation, so we also need to adjust
+ // it afterwards.
+ [browserActionsContainerView_ stopAnimation];
+ NSRect containerFrame = [browserActionsContainerView_ frame];
+ containerFrame.origin.y =
+ NSHeight([[self view] frame]) - NSHeight(containerFrame) - 1;
+ [browserActionsContainerView_ setFrame:containerFrame];
+ [self pinLocationBarToLeftOfBrowserActionsContainerAndAnimate:NO];
+ }
+
[self maintainMinimumLocationBarWidth];
if (locationBarAtMinSize_) {