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

Side by Side Diff: chrome/browser/ui/views/harmony/harmony_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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/views/harmony/harmony_typography_provider.h" 5 #include "chrome/browser/ui/views/harmony/harmony_typography_provider.h"
6 6
7 #include "chrome/browser/ui/views/harmony/chrome_typography.h" 7 #include "chrome/browser/ui/views/harmony/chrome_typography.h"
8 #include "ui/base/resource/resource_bundle.h" 8 #include "ui/base/resource/resource_bundle.h"
9 #include "ui/gfx/platform_font.h" 9 #include "ui/gfx/platform_font.h"
10 10
11 #if defined(USE_ASH)
12 #include "ash/public/cpp/ash_typography.h"
13 #endif
14
11 const gfx::FontList& HarmonyTypographyProvider::GetFont(int text_context, 15 const gfx::FontList& HarmonyTypographyProvider::GetFont(int text_context,
12 int text_style) const { 16 int text_style) const {
13 // "Target" font size constants from the Harmony spec. 17 // "Target" font size constants from the Harmony spec.
14 constexpr int kHeadlineSize = 20; 18 constexpr int kHeadlineSize = 20;
15 constexpr int kTitleSize = 15; 19 constexpr int kTitleSize = 15;
16 constexpr int kBodyTextLargeSize = 13; 20 constexpr int kBodyTextLargeSize = 13;
17 constexpr int kDefaultSize = 12; 21 constexpr int kDefaultSize = 12;
18 22
19 #if defined(OS_WIN) 23 #if defined(OS_WIN)
20 constexpr gfx::Font::Weight kButtonFontWeight = gfx::Font::Weight::BOLD; 24 constexpr gfx::Font::Weight kButtonFontWeight = gfx::Font::Weight::BOLD;
21 #else 25 #else
22 constexpr gfx::Font::Weight kButtonFontWeight = gfx::Font::Weight::MEDIUM; 26 constexpr gfx::Font::Weight kButtonFontWeight = gfx::Font::Weight::MEDIUM;
23 #endif 27 #endif
24 28
25 int size_delta = kDefaultSize - gfx::PlatformFont::kDefaultBaseFontSize; 29 int size_delta = kDefaultSize - gfx::PlatformFont::kDefaultBaseFontSize;
26 gfx::Font::Weight font_weight = gfx::Font::Weight::NORMAL; 30 gfx::Font::Weight font_weight = gfx::Font::Weight::NORMAL;
31
32 #if defined(USE_ASH)
33 ash::ApplyAshFontStyles(text_context, text_style, &size_delta, &font_weight);
34 #endif
35
27 switch (text_context) { 36 switch (text_context) {
28 case CONTEXT_HEADLINE: 37 case views::style::CONTEXT_BUTTON_MD:
29 size_delta = kHeadlineSize - gfx::PlatformFont::kDefaultBaseFontSize; 38 font_weight = WeightNotLighterThanNormal(kButtonFontWeight);
30 break; 39 break;
31 case views::style::CONTEXT_DIALOG_TITLE: 40 case views::style::CONTEXT_DIALOG_TITLE:
32 size_delta = kTitleSize - gfx::PlatformFont::kDefaultBaseFontSize; 41 size_delta = kTitleSize - gfx::PlatformFont::kDefaultBaseFontSize;
33 break; 42 break;
34 case CONTEXT_BODY_TEXT_LARGE: 43 case CONTEXT_BODY_TEXT_LARGE:
35 size_delta = kBodyTextLargeSize - gfx::PlatformFont::kDefaultBaseFontSize; 44 size_delta = kBodyTextLargeSize - gfx::PlatformFont::kDefaultBaseFontSize;
36 break; 45 break;
37 case views::style::CONTEXT_BUTTON: 46 case CONTEXT_HEADLINE:
38 font_weight = kButtonFontWeight; 47 size_delta = kHeadlineSize - gfx::PlatformFont::kDefaultBaseFontSize;
39 break; 48 break;
40 default: 49 default:
41 break; 50 break;
42 } 51 }
43 52
44 // Ignore |text_style| since it only affects color in the Harmony spec. 53 // Ignore |text_style| since it only affects color in the Harmony spec.
54
45 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( 55 return ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
46 size_delta, gfx::Font::NORMAL, font_weight); 56 size_delta, gfx::Font::NORMAL, font_weight);
47 } 57 }
48 58
49 SkColor HarmonyTypographyProvider::GetColor(int text_context, 59 SkColor HarmonyTypographyProvider::GetColor(int text_context,
50 int text_style) const { 60 int text_style) const {
51 // TODO(tapted): Look up colors from the spec. 61 // TODO(tapted): Look up colors from the spec.
52 return SK_ColorBLACK; 62 return SK_ColorBLACK;
53 } 63 }
54 64
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 GetFont(views::style::CONTEXT_DIALOG_TITLE, kTemplateStyle).GetHeight() - 110 GetFont(views::style::CONTEXT_DIALOG_TITLE, kTemplateStyle).GetHeight() -
101 kTitlePlatformHeight + kTitleHeight; 111 kTitlePlatformHeight + kTitleHeight;
102 static const int body_large_height = 112 static const int body_large_height =
103 GetFont(CONTEXT_BODY_TEXT_LARGE, kTemplateStyle).GetHeight() - 113 GetFont(CONTEXT_BODY_TEXT_LARGE, kTemplateStyle).GetHeight() -
104 kBodyTextLargePlatformHeight + kBodyHeight; 114 kBodyTextLargePlatformHeight + kBodyHeight;
105 static const int default_height = 115 static const int default_height =
106 GetFont(CONTEXT_BODY_TEXT_SMALL, kTemplateStyle).GetHeight() - 116 GetFont(CONTEXT_BODY_TEXT_SMALL, kTemplateStyle).GetHeight() -
107 kBodyTextSmallPlatformHeight + kBodyHeight; 117 kBodyTextSmallPlatformHeight + kBodyHeight;
108 118
109 switch (text_context) { 119 switch (text_context) {
110 case CONTEXT_HEADLINE: 120 case views::style::CONTEXT_BUTTON:
111 return headline_height; 121 case views::style::CONTEXT_BUTTON_MD:
122 return kButtonAbsoluteHeight;
112 case views::style::CONTEXT_DIALOG_TITLE: 123 case views::style::CONTEXT_DIALOG_TITLE:
113 return title_height; 124 return title_height;
114 case CONTEXT_BODY_TEXT_LARGE: 125 case CONTEXT_BODY_TEXT_LARGE:
115 return body_large_height; 126 return body_large_height;
116 case views::style::CONTEXT_BUTTON: 127 case CONTEXT_HEADLINE:
117 return kButtonAbsoluteHeight; 128 return headline_height;
118 default: 129 default:
119 return default_height; 130 return default_height;
120 } 131 }
121 } 132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698