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

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

Issue 164418: Mac: Omnibox popup metrics. (Closed)
Patch Set: Last-minute changes. Created 11 years, 4 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
Index: chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm b/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
index f2a33d8785e7039e5eb41ea93682fc34c33be9fb..b240853f1c05b33f714bfc08deca192527696a45 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_mac.mm
@@ -12,6 +12,14 @@
namespace {
+// The size delta between the font used for the edit and the result
+// rows.
+const int kEditFontAdjust = -1;
+
+// How much to adjust the cell sizing up from the default determined
+// by the font.
+const int kCellHeightAdjust = 7.0;
+
// Background colors for different states of the popup elements.
NSColor* BackgroundColor() {
return [NSColor controlBackgroundColor];
@@ -131,23 +139,23 @@ NSAttributedString* AutocompletePopupViewMac::MatchText(
ContentTextColor(), font);
// If there is a description, append it, separated from the contents
- // with an em dash, and decorated with a distinct color.
+ // with an en dash, and decorated with a distinct color.
if (!match.description.empty()) {
NSDictionary* attributes =
[NSDictionary dictionaryWithObjectsAndKeys:
font, NSFontAttributeName,
ContentTextColor(), NSForegroundColorAttributeName,
nil];
- NSString* rawEmDash = [NSString stringWithFormat:@" %C ", 0x2014];
- NSAttributedString* emDash =
- [[[NSAttributedString alloc] initWithString:rawEmDash
+ NSString* rawEnDash = [NSString stringWithFormat:@" %C ", 0x2013];
+ NSAttributedString* enDash =
+ [[[NSAttributedString alloc] initWithString:rawEnDash
attributes:attributes] autorelease];
NSAttributedString* description =
DecorateMatchedString(match.description, match.description_class,
DescriptionTextColor(), font);
- [as appendAttributedString:emDash];
+ [as appendAttributedString:enDash];
[as appendAttributedString:description];
}
@@ -261,6 +269,13 @@ void AutocompletePopupViewMac::UpdatePopupAppearance() {
CreatePopupIfNeeded();
+ // The popup's font is a slightly smaller version of what |field_|
+ // uses.
+ NSFont* fieldFont = [field_ font];
+ const CGFloat resultFontSize = [fieldFont pointSize] + kEditFontAdjust;
+ NSFont* resultFont =
+ [NSFont fontWithName:[fieldFont fontName] size:resultFontSize];
+
// Load the results into the popup's matrix.
AutocompleteMatrix* matrix = [popup_ contentView];
const size_t rows = model_->result().size();
@@ -270,7 +285,7 @@ void AutocompletePopupViewMac::UpdatePopupAppearance() {
AutocompleteButtonCell* cell = [matrix cellAtRow:ii column:0];
const AutocompleteMatch& match = model_->result().match_at(ii);
[cell setImage:MatchIcon(match)];
- [cell setAttributedTitle:MatchText(match, [field_ font])];
+ [cell setAttributedTitle:MatchText(match, resultFont)];
}
// Layout the popup and size it to land underneath the field.
@@ -289,7 +304,8 @@ void AutocompletePopupViewMac::UpdatePopupAppearance() {
// line, so they should all be about the same height.
const NSSize cellSize = [[matrix cellAtRow:0 column:0] cellSize];
DCHECK_GT(cellSize.height, 0.0);
- [matrix setCellSize:NSMakeSize(r.size.width, cellSize.height)];
+ [matrix setCellSize:NSMakeSize(r.size.width,
+ cellSize.height + kCellHeightAdjust)];
// Make the matrix big enough to hold all the cells.
[matrix sizeToCells];
@@ -394,7 +410,9 @@ void AutocompletePopupViewMac::AcceptInput() {
if (self) {
[self setCellClass:[AutocompleteButtonCell class]];
- [self setIntercellSpacing:NSMakeSize(1.0, 1.0)];
+ // Cells pack with no spacing.
+ [self setIntercellSpacing:NSMakeSize(0.0, 0.0)];
+
[self setDrawsBackground:YES];
[self setBackgroundColor:BackgroundColor()];
[self renewRows:0 columns:1];

Powered by Google App Engine
This is Rietveld 408576698