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

Unified Diff: chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm

Issue 2057043002: Align the Mac Omnibox items vertically again. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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/ui/cocoa/omnibox/omnibox_view_mac.mm
diff --git a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
index 61ee0ec2237224e24e2f23da1c3fab5bc6d56a92..bed929ac6b6434424e034d282b654c7219aa5187 100644
--- a/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
+++ b/chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.mm
@@ -43,7 +43,6 @@
#include "ui/base/material_design/material_design_controller.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/color_palette.h"
-#include "ui/gfx/font.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/geometry/rect.h"
@@ -78,10 +77,6 @@ using content::WebContents;
// things work on other platforms.
namespace {
-const int kOmniboxLargeFontSizeDelta = 9;
-const int kOmniboxNormalFontSizeDelta = 1;
-const int kOmniboxSmallFontSizeDelta = 0;
-const int kOmniboxSmallMaterialFontSizeDelta = -1;
// TODO(shess): This is ugly, find a better way. Using it right now
// so that I can crib from gtk and still be able to see that I'm using
@@ -549,9 +544,10 @@ void OmniboxViewMac::EmphasizeURLComponents() {
void OmniboxViewMac::ApplyTextStyle(
NSMutableAttributedString* attributedString) {
- [attributedString addAttribute:NSFontAttributeName
- value:GetNormalFieldFont()
- range:NSMakeRange(0, [attributedString length])];
+ [attributedString
+ addAttribute:NSFontAttributeName
+ value:GetFieldFont(gfx::Font::NORMAL, gfx::Font::Weight::NORMAL)
+ range:NSMakeRange(0, [attributedString length])];
// Make a paragraph style locking in the standard line height as the maximum,
// otherwise the baseline may shift "downwards".
@@ -1084,42 +1080,34 @@ void OmniboxViewMac::FocusLocation(bool select_all) {
}
// static
-NSFont* OmniboxViewMac::GetNormalFieldFont() {
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- return rb
- .GetFontWithDelta(kOmniboxNormalFontSizeDelta, gfx::Font::NORMAL,
- gfx::Font::Weight::NORMAL)
- .GetNativeFont();
-}
-
-NSFont* OmniboxViewMac::GetBoldFieldFont() {
+NSFont* OmniboxViewMac::GetFieldFont(int style, gfx::Font::Weight weight) {
+ // This value should be kept in sync with InstantPage::InitializeFonts.
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- return rb
tapted 2016/06/14 05:51:34 So the minimal fix seems to be to do // Request
- .GetFontWithDelta(kOmniboxNormalFontSizeDelta, gfx::Font::NORMAL,
- gfx::Font::Weight::BOLD)
+ return rb.GetFontList(ui::ResourceBundle::BaseFont)
+ .Derive(1, style, weight)
+ .GetPrimaryFont()
.GetNativeFont();
}
-NSFont* OmniboxViewMac::GetLargeFont() {
+NSFont* OmniboxViewMac::GetLargeFont(int style, gfx::Font::Weight weight) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
- return rb
- .GetFontWithDelta(kOmniboxLargeFontSizeDelta, gfx::Font::NORMAL,
- gfx::Font::Weight::NORMAL)
+ return rb.GetFontList(ui::ResourceBundle::LargeFont)
+ .Derive(1, style, weight)
+ .GetPrimaryFont()
.GetNativeFont();
}
-NSFont* OmniboxViewMac::GetSmallFont() {
+NSFont* OmniboxViewMac::GetSmallFont(int style, gfx::Font::Weight weight) {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
if (!ui::MaterialDesignController::IsModeMaterial()) {
- return rb
- .GetFontWithDelta(kOmniboxSmallFontSizeDelta, gfx::Font::NORMAL,
- gfx::Font::Weight::NORMAL)
+ return rb.GetFontList(ui::ResourceBundle::SmallFont)
+ .Derive(1, style, weight)
+ .GetPrimaryFont()
.GetNativeFont();
}
-
- return rb
- .GetFontWithDelta(kOmniboxSmallMaterialFontSizeDelta, gfx::Font::NORMAL,
- gfx::Font::Weight::NORMAL)
+ return rb.GetFontListWithDelta(-2, gfx::Font::NORMAL)
+ .Derive(1, style, weight)
+ .GetPrimaryFont()
.GetNativeFont();
}

Powered by Google App Engine
This is Rietveld 408576698