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

Unified Diff: chrome/browser/autocomplete/autocomplete_popup_view_mac.mm

Issue 2010002: [Mac] Fixes janky animations in the omnibox popup.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 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/autocomplete/autocomplete_popup_view_mac.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
===================================================================
--- chrome/browser/autocomplete/autocomplete_popup_view_mac.mm (revision 46538)
+++ chrome/browser/autocomplete/autocomplete_popup_view_mac.mm (working copy)
@@ -44,8 +44,11 @@
const CGFloat kTextXOffset = 29.0;
// Animation duration when animating the popup window smaller.
-const CGFloat kShrinkAnimationDuration = 0.1;
+const NSTimeInterval kShrinkAnimationDuration = 0.1;
+// A very short animation duration used to cancel running animations.
+const NSTimeInterval kCancelAnimationDuration = 0.00001;
+
// Maximum fraction of the popup width that can be used to display match
// contents.
const float kMaxContentsFraction = 0.7;
@@ -296,6 +299,29 @@
}
}
+void AutocompletePopupViewMac::SetPopupFrame(const NSRect frame) {
+ // Do nothing if the popup is already animating to the given |frame|.
+ if (NSEqualRects(frame, targetPopupFrame_))
+ return;
+
+ NSRect currentPopupFrame = [popup_ frame];
+ targetPopupFrame_ = frame;
+
+ // Animate the frame change if the only change is that the height got smaller.
+ // Otherwise, resize immediately.
+ bool animate = (NSHeight(frame) < NSHeight(currentPopupFrame) &&
+ NSWidth(frame) == NSWidth(currentPopupFrame));
+ NSTimeInterval duration =
+ (animate ? kShrinkAnimationDuration: kCancelAnimationDuration);
+
+ [NSAnimationContext beginGrouping];
+ // Don't use the GTM additon for the "Steve" slowdown because this can happen
+ // async from user actions and the effects could be a surprise.
+ [[NSAnimationContext currentContext] setDuration:duration];
+ [[popup_ animator] setFrame:frame display:YES];
+ [NSAnimationContext endGrouping];
+}
+
void AutocompletePopupViewMac::UpdatePopupAppearance() {
DCHECK([NSThread isMainThread]);
const AutocompleteResult& result = model_->result();
@@ -354,6 +380,9 @@
[matrix setCellSize:NSMakeSize(r.size.width,
cellSize.height + kCellHeightAdjust)];
+ // Save the old matrix frame in order to later restore it.
+ NSRect savedMatrixFrame = [matrix frame];
+
// Make the matrix big enough to hold all the cells.
[matrix sizeToCells];
@@ -361,24 +390,14 @@
r.size.height = [matrix frame].size.height;
r.origin.y -= r.size.height + kPopupFieldGap;
+ // Resize the matrix back to its original size, since we aren't resizing the
+ // window immediately.
+ [matrix setFrame:savedMatrixFrame];
+
// Update the selection.
PaintUpdatesNow();
- // Animate the frame change if the only change is that the height got smaller.
- // Otherwise, resize immediately.
- NSRect oldFrame = [popup_ frame];
- if (r.size.height < oldFrame.size.height &&
- r.origin.x == oldFrame.origin.x &&
- r.size.width == oldFrame.size.width) {
- [NSAnimationContext beginGrouping];
- // Don't use the GTM additon for the "Steve" slowdown because this can
- // happen async from user actions and the effects could be a surprise.
- [[NSAnimationContext currentContext] setDuration:kShrinkAnimationDuration];
- [[popup_ animator] setFrame:r display:YES];
- [NSAnimationContext endGrouping];
- } else {
- [popup_ setFrame:r display:YES];
- }
+ SetPopupFrame(r);
if (!IsOpen()) {
[[field_ window] addChildWindow:popup_ ordered:NSWindowAbove];
@@ -484,6 +503,8 @@
@implementation AutocompleteMatrix
+
+
// Remove all tracking areas and initialize the one we want. Removing
// all might be overkill, but it's unclear why there would be others
// for the popup window.
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_popup_view_mac.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698