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

Unified Diff: ui/views/style/typography_provider.cc

Issue 2801583002: Use views::style for buttons, bootstrap ash_typography to do so. (Closed)
Patch Set: placate gn check. new_avatar_button now just avatar_button Created 3 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
Index: ui/views/style/typography_provider.cc
diff --git a/ui/views/style/typography_provider.cc b/ui/views/style/typography_provider.cc
index 521e2bf8ddba781e3ea5305f2df7ac4a8cd2867b..ab46a0a9302cd072ba81234fc1e0eeda4ec4be09 100644
--- a/ui/views/style/typography_provider.cc
+++ b/ui/views/style/typography_provider.cc
@@ -9,26 +9,70 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/views/style/typography.h"
+using gfx::Font;
+
namespace views {
+namespace {
+
+Font::Weight GetValueBolderThan(Font::Weight weight) {
+ switch (weight) {
+ case Font::Weight::BOLD:
+ return Font::Weight::EXTRA_BOLD;
+ case Font::Weight::EXTRA_BOLD:
+ case Font::Weight::BLACK:
+ return Font::Weight::BLACK;
+ default:
+ return Font::Weight::BOLD;
+ }
+}
+
+} // namespace
+
+// static
+Font::Weight TypographyProvider::WeightNotLighterThanNormal(
+ Font::Weight weight) {
+ if (ResourceBundle::GetSharedInstance()
+ .GetFontListWithDelta(0, Font::NORMAL, Font::Weight::NORMAL)
+ .GetFontWeight() < weight)
+ return weight;
+ return Font::Weight::NORMAL;
+}
const gfx::FontList& DefaultTypographyProvider::GetFont(int context,
int style) const {
int size_delta;
- gfx::Font::Weight font_weight;
+ Font::Weight font_weight;
GetDefaultFont(context, style, &size_delta, &font_weight);
return ResourceBundle::GetSharedInstance().GetFontListWithDelta(
- size_delta, gfx::Font::NORMAL, font_weight);
+ size_delta, Font::NORMAL, font_weight);
}
-void DefaultTypographyProvider::GetDefaultFont(
- int context,
- int style,
- int* size_delta,
- gfx::Font::Weight* font_weight) const {
+SkColor DefaultTypographyProvider::GetColor(int context, int style) const {
+ return SK_ColorBLACK;
+}
+
+int DefaultTypographyProvider::GetLineHeight(int context, int style) const {
+ return 0;
+}
+
+// static
+void DefaultTypographyProvider::GetDefaultFont(int context,
+ int style,
+ int* size_delta,
+ Font::Weight* font_weight) {
+ *font_weight = Font::Weight::NORMAL;
+
switch (context) {
+ case style::CONTEXT_BUTTON_MD:
+ *size_delta = ui::kLabelFontSizeDelta;
+ *font_weight = WeightNotLighterThanNormal(Font::Weight::MEDIUM);
+ break;
case style::CONTEXT_DIALOG_TITLE:
*size_delta = ui::kTitleFontSizeDelta;
break;
+ case style::CONTEXT_TOUCH_MENU:
+ *size_delta = -1;
+ break;
default:
*size_delta = ui::kLabelFontSizeDelta;
break;
@@ -36,20 +80,18 @@ void DefaultTypographyProvider::GetDefaultFont(
switch (style) {
case style::STYLE_TAB_ACTIVE:
- *font_weight = gfx::Font::Weight::BOLD;
+ *font_weight = Font::Weight::BOLD;
break;
- default:
- *font_weight = gfx::Font::Weight::NORMAL;
+ case style::STYLE_DIALOG_BUTTON_DEFAULT:
+ // Only non-MD default buttons should "increase" in boldness.
+ if (context == style::CONTEXT_BUTTON) {
+ *font_weight = GetValueBolderThan(
+ ResourceBundle::GetSharedInstance()
+ .GetFontListWithDelta(*size_delta, Font::NORMAL, *font_weight)
+ .GetFontWeight());
+ }
break;
}
}
-SkColor DefaultTypographyProvider::GetColor(int context, int style) const {
- return SK_ColorBLACK;
-}
-
-int DefaultTypographyProvider::GetLineHeight(int context, int style) const {
- return 0;
-}
-
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698