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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_popup_view_mac.mm

Issue 178007: [Mac] Tweaks to Omnibox metrics. (Closed)
Patch Set: Oops, fixed unit test. Created 11 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/cocoa/autocomplete_text_field_cell.mm » ('j') | 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/autocomplete/autocomplete_popup_view_mac.h" 5 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h"
6 6
7 #include "app/gfx/text_elider.h" 7 #include "app/gfx/text_elider.h"
8 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 #include "base/gfx/rect.h" 9 #include "base/gfx/rect.h"
10 #include "chrome/browser/autocomplete/autocomplete_edit.h" 10 #include "chrome/browser/autocomplete/autocomplete_edit.h"
11 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" 11 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h"
12 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" 12 #include "chrome/browser/autocomplete/autocomplete_popup_model.h"
13 #include "chrome/browser/cocoa/event_utils.h" 13 #include "chrome/browser/cocoa/event_utils.h"
14 #include "chrome/browser/cocoa/nsimage_cache.h" 14 #include "chrome/browser/cocoa/nsimage_cache.h"
15 15
16 namespace { 16 namespace {
17 17
18 // The size delta between the font used for the edit and the result 18 // The size delta between the font used for the edit and the result
19 // rows. 19 // rows.
20 const int kEditFontAdjust = -1; 20 const int kEditFontAdjust = -1;
21 21
22 // How much to adjust the cell sizing up from the default determined 22 // How much to adjust the cell sizing up from the default determined
23 // by the font. 23 // by the font.
24 const int kCellHeightAdjust = 7.0; 24 const int kCellHeightAdjust = 7.0;
25 25
26 // How to round off the popup's corners. Goal is to match star and go 26 // How to round off the popup's corners. Goal is to match star and go
27 // buttons. 27 // buttons.
28 const CGFloat kPopupRoundingRadius = 4.0; 28 const CGFloat kPopupRoundingRadius = 3.5;
29
30 // Gap between the field and the popup.
31 const CGFloat kPopupFieldGap = 2.0;
29 32
30 // How much space to leave for the left and right margins. 33 // How much space to leave for the left and right margins.
31 const CGFloat kLeftRightMargin = 8.0; 34 const CGFloat kLeftRightMargin = 8.0;
32 35
33 // How far to offset the text column from the left. 36 // How far to offset the text column from the left.
34 const CGFloat kTextXOffset = 33.0; 37 const CGFloat kTextXOffset = 33.0;
35 38
36 // Animation duration when animating the popup window smaller. 39 // Animation duration when animating the popup window smaller.
37 const float kShrinkAnimationDuration = 0.1; 40 const float kShrinkAnimationDuration = 0.1;
38 41
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 const NSSize cellSize = [[matrix cellAtRow:0 column:0] cellSize]; 352 const NSSize cellSize = [[matrix cellAtRow:0 column:0] cellSize];
350 DCHECK_GT(cellSize.height, 0.0); 353 DCHECK_GT(cellSize.height, 0.0);
351 [matrix setCellSize:NSMakeSize(r.size.width, 354 [matrix setCellSize:NSMakeSize(r.size.width,
352 cellSize.height + kCellHeightAdjust)]; 355 cellSize.height + kCellHeightAdjust)];
353 356
354 // Make the matrix big enough to hold all the cells. 357 // Make the matrix big enough to hold all the cells.
355 [matrix sizeToCells]; 358 [matrix sizeToCells];
356 359
357 // Make the window just as big. 360 // Make the window just as big.
358 r.size.height = [matrix frame].size.height; 361 r.size.height = [matrix frame].size.height;
359 r.origin.y -= r.size.height + 2; 362 r.origin.y -= r.size.height + kPopupFieldGap;
360 363
361 // Update the selection. 364 // Update the selection.
362 PaintUpdatesNow(); 365 PaintUpdatesNow();
363 366
364 // Animate the frame change if the only change is that the height got smaller. 367 // Animate the frame change if the only change is that the height got smaller.
365 // Otherwise, resize immediately. 368 // Otherwise, resize immediately.
366 NSRect oldFrame = [popup_ frame]; 369 NSRect oldFrame = [popup_ frame];
367 if (r.size.height < oldFrame.size.height && 370 if (r.size.height < oldFrame.size.height &&
368 r.origin.x == oldFrame.origin.x && 371 r.origin.x == oldFrame.origin.x &&
369 r.size.width == oldFrame.size.width) { 372 r.size.width == oldFrame.size.width) {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 DCHECK(popup_view_); 603 DCHECK(popup_view_);
601 604
602 // TODO(shess): UpdatePopupAppearance() is called frequently, so it 605 // TODO(shess): UpdatePopupAppearance() is called frequently, so it
603 // should be really cheap, but in this case we could probably make 606 // should be really cheap, but in this case we could probably make
604 // things even cheaper by refactoring between the popup-placement 607 // things even cheaper by refactoring between the popup-placement
605 // code and the matrix-population code. 608 // code and the matrix-population code.
606 popup_view_->UpdatePopupAppearance(); 609 popup_view_->UpdatePopupAppearance();
607 } 610 }
608 611
609 @end 612 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/cocoa/autocomplete_text_field_cell.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698