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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_popup_controller.mm

Issue 111493003: [Mac] Always animate extension popup window size changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/extensions/extension_popup_controller.h" 5 #import "chrome/browser/ui/cocoa/extensions/extension_popup_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // positioned correctly at the middle and slightly down from the button. 333 // positioned correctly at the middle and slightly down from the button.
334 NSPoint windowOrigin = self.anchorPoint; 334 NSPoint windowOrigin = self.anchorPoint;
335 NSSize offsets = NSMakeSize(info_bubble::kBubbleArrowXOffset + 335 NSSize offsets = NSMakeSize(info_bubble::kBubbleArrowXOffset +
336 info_bubble::kBubbleArrowWidth / 2.0, 336 info_bubble::kBubbleArrowWidth / 2.0,
337 info_bubble::kBubbleArrowHeight / 2.0); 337 info_bubble::kBubbleArrowHeight / 2.0);
338 offsets = [extensionView_ convertSize:offsets toView:nil]; 338 offsets = [extensionView_ convertSize:offsets toView:nil];
339 windowOrigin.x -= NSWidth(frame) - offsets.width; 339 windowOrigin.x -= NSWidth(frame) - offsets.width;
340 windowOrigin.y -= NSHeight(frame) - offsets.height; 340 windowOrigin.y -= NSHeight(frame) - offsets.height;
341 frame.origin = windowOrigin; 341 frame.origin = windowOrigin;
342 342
343 // Is the window still animating in? If so, then cancel that and create a new 343 // In case the window is animating already, change its size by creating a
344 // animation setting the opacity and new frame value. Otherwise the current 344 // new animation setting the opacity and new frame value. Otherwise, a
345 // animation will continue after this frame is set, reverting the frame to 345 // preexisting animation would continue after the frame is set, reverting
346 // what it was when the animation started. 346 // the frame to what it was when the animation started.
347 NSWindow* window = [self window]; 347 NSWindow* window = [self window];
348 if ([window isVisible] && [[window animator] alphaValue] < 1.0) { 348 id animator = [window animator];
349 [NSAnimationContext beginGrouping]; 349 [NSAnimationContext beginGrouping];
350 [[NSAnimationContext currentContext] setDuration:kAnimationDuration]; 350 [[NSAnimationContext currentContext] setDuration:kAnimationDuration];
351 [[window animator] setAlphaValue:1.0]; 351 [animator setAlphaValue:1.0];
352 [[window animator] setFrame:frame display:YES]; 352 [animator setFrame:frame display:YES];
353 [NSAnimationContext endGrouping]; 353 [NSAnimationContext endGrouping];
354 } else {
355 [window setFrame:frame display:YES];
356 }
357 354
358 // A NSViewFrameDidChangeNotification won't be sent until the extension view 355 // A NSViewFrameDidChangeNotification won't be sent until the extension view
359 // content is loaded. The window is hidden on init, so show it the first time 356 // content is loaded. The window is hidden on init, so show it the first time
360 // the notification is fired (and consequently the view contents have loaded). 357 // the notification is fired (and consequently the view contents have loaded).
361 if (![window isVisible]) { 358 if (![window isVisible]) {
362 [self showWindow:self]; 359 [self showWindow:self];
363 } 360 }
364 } 361 }
365 362
366 - (void)onSizeChanged:(NSSize)newSize { 363 - (void)onSizeChanged:(NSSize)newSize {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 return minSize; 406 return minSize;
410 } 407 }
411 408
412 // Private (TestingAPI) 409 // Private (TestingAPI)
413 + (NSSize)maxPopupSize { 410 + (NSSize)maxPopupSize {
414 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight}; 411 NSSize maxSize = {ExtensionViewMac::kMaxWidth, ExtensionViewMac::kMaxHeight};
415 return maxSize; 412 return maxSize;
416 } 413 }
417 414
418 @end 415 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698