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

Side by Side Diff: chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.mm

Issue 1435823003: Fix Omnibox update problem on El Capitan. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« 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 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" 5 #include "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/mac/mac_util.h" 9 #include "base/mac/mac_util.h"
10 #import "base/mac/sdk_forward_declarations.h"
10 #include "base/stl_util.h" 11 #include "base/stl_util.h"
11 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
12 #include "chrome/browser/search/search.h" 13 #include "chrome/browser/search/search.h"
13 #include "chrome/browser/ui/cocoa/browser_window_controller.h" 14 #include "chrome/browser/ui/cocoa/browser_window_controller.h"
14 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h" 15 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h"
15 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.h" 16 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_separator_view.h"
16 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 17 #include "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
17 #include "components/omnibox/browser/autocomplete_match.h" 18 #include "components/omnibox/browser/autocomplete_match.h"
18 #include "components/omnibox/browser/autocomplete_match_type.h" 19 #include "components/omnibox/browser/autocomplete_match_type.h"
19 #include "components/omnibox/browser/omnibox_edit_model.h" 20 #include "components/omnibox/browser/omnibox_edit_model.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 // running animations and set the new frame value immediately. In practice, 268 // running animations and set the new frame value immediately. In practice,
268 // zero-length animations are ignored entirely. Work around this AppKit bug 269 // zero-length animations are ignored entirely. Work around this AppKit bug
269 // by explicitly setting an NSNull animation for the "frame" key and then 270 // by explicitly setting an NSNull animation for the "frame" key and then
270 // running the animation with a non-zero(!!) duration. This somehow 271 // running the animation with a non-zero(!!) duration. This somehow
271 // convinces AppKit to do the right thing. Save off the current animations 272 // convinces AppKit to do the right thing. Save off the current animations
272 // dictionary so it can be restored later. 273 // dictionary so it can be restored later.
273 savedAnimations.reset([[popup_ animations] copy]); 274 savedAnimations.reset([[popup_ animations] copy]);
274 [popup_ setAnimations:@{@"frame" : [NSNull null]}]; 275 [popup_ setAnimations:@{@"frame" : [NSNull null]}];
275 } 276 }
276 277
277 if (!animate && base::mac::IsOSElCapitanOrLater()) { 278 [NSAnimationContext beginGrouping];
278 // When using the animator to make |popup_| larger on El Capitan, for some 279 // Don't use the GTM addition for the "Steve" slowdown because this can
279 // reason the window does not get redrawn. There's no animation in this case 280 // happen async from user actions and the effects could be a surprise.
280 // anyway, so just force the frame change. See http://crbug.com/538590 . 281 [[NSAnimationContext currentContext] setDuration:kShrinkAnimationDuration];
281 [popup_ setFrame:popup_frame display:YES]; 282 // When using the animator to update |popup_| on El Capitan, for some reason
283 // the window does not get redrawn. Use a completion handler to make sure
284 // |popup_| gets redrawn once the animation completes. See
285 // http://crbug.com/538590 and http://crbug.com/551007 .
286 if (base::mac::IsOSElCapitanOrLater()) {
287 [[NSAnimationContext currentContext] setCompletionHandler:^{
288 [popup_ display];
289 }];
290 [[popup_ animator] setFrame:popup_frame display:NO];
rohitrao (ping after 24h) 2015/11/11 20:51:27 Why do we need display:NO here?
shrike 2015/11/11 21:40:18 I was thinking that would avoid a redundant redraw
282 } else { 291 } else {
283 [NSAnimationContext beginGrouping];
284 // Don't use the GTM addition for the "Steve" slowdown because this can
285 // happen async from user actions and the effects could be a surprise.
286 [[NSAnimationContext currentContext] setDuration:kShrinkAnimationDuration];
287 [[popup_ animator] setFrame:popup_frame display:YES]; 292 [[popup_ animator] setFrame:popup_frame display:YES];
288 [NSAnimationContext endGrouping];
289 } 293 }
294 [NSAnimationContext endGrouping];
290 295
291 if (!animate) { 296 if (!animate) {
292 // Restore the original animations dictionary. This does not reinstate any 297 // Restore the original animations dictionary. This does not reinstate any
293 // previously running animations. 298 // previously running animations.
294 [popup_ setAnimations:savedAnimations]; 299 [popup_ setAnimations:savedAnimations];
295 } 300 }
296 } 301 }
297 302
298 NSImage* OmniboxPopupViewMac::ImageForMatch( 303 NSImage* OmniboxPopupViewMac::ImageForMatch(
299 const AutocompleteMatch& match) const { 304 const AutocompleteMatch& match) const {
300 gfx::Image image = model_->GetIconIfExtensionMatch(match); 305 gfx::Image image = model_->GetIconIfExtensionMatch(match);
301 if (!image.IsEmpty()) 306 if (!image.IsEmpty())
302 return image.AsNSImage(); 307 return image.AsNSImage();
303 308
304 const int resource_id = model_->IsStarredMatch(match) ? 309 const int resource_id = model_->IsStarredMatch(match) ?
305 IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match.type); 310 IDR_OMNIBOX_STAR : AutocompleteMatch::TypeToIcon(match.type);
306 return OmniboxViewMac::ImageForResource(resource_id); 311 return OmniboxViewMac::ImageForResource(resource_id);
307 } 312 }
308 313
309 void OmniboxPopupViewMac::OpenURLForRow(size_t row, 314 void OmniboxPopupViewMac::OpenURLForRow(size_t row,
310 WindowOpenDisposition disposition) { 315 WindowOpenDisposition disposition) {
311 DCHECK_LT(row, GetResult().size()); 316 DCHECK_LT(row, GetResult().size());
312 omnibox_view_->OpenMatch(GetResult().match_at(row), disposition, GURL(), 317 omnibox_view_->OpenMatch(GetResult().match_at(row), disposition, GURL(),
313 base::string16(), row); 318 base::string16(), row);
314 } 319 }
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