Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/color_palette.h" | 9 #include "ui/gfx/color_palette.h" |
| 10 #include "ui/gfx/platform_font.h" | 10 #include "ui/gfx/platform_font.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 const SkColor foreground_color = | 59 const SkColor foreground_color = |
| 60 theme.GetSystemColor(ui::NativeTheme::kColorId_LabelEnabledColor); | 60 theme.GetSystemColor(ui::NativeTheme::kColorId_LabelEnabledColor); |
| 61 | 61 |
| 62 // If the default foreground color from the native theme isn't black, the rest | 62 // If the default foreground color from the native theme isn't black, the rest |
| 63 // of the Harmony spec isn't going to work. TODO(tapted): Something more | 63 // of the Harmony spec isn't going to work. TODO(tapted): Something more |
| 64 // generic would be nice here, but that requires knowing the background color | 64 // generic would be nice here, but that requires knowing the background color |
| 65 // for the text. At the time of writing, very few UI surfaces need native- | 65 // for the text. At the time of writing, very few UI surfaces need native- |
| 66 // themed typography with a custom native theme. Typically just incognito | 66 // themed typography with a custom native theme. Typically just incognito |
| 67 // browser windows, when the native theme is NativeThemeDarkAura. | 67 // browser windows, when the native theme is NativeThemeDarkAura. |
| 68 if (foreground_color != SK_ColorBLACK) { | 68 if (foreground_color != SK_ColorBLACK) { |
| 69 if (context == views::style::CONTEXT_TEXTFIELD) { | |
| 70 return theme.GetSystemColor( | |
|
Peter Kasting
2017/06/29 20:24:57
Can we just return TypographyProvider::GetColor(..
tapted
2017/06/30 05:53:43
I ended up tearing out this "what to do when we ca
| |
| 71 style == views::style::STYLE_DISABLED | |
| 72 ? ui::NativeTheme::kColorId_TextfieldReadOnlyColor | |
| 73 : ui::NativeTheme::kColorId_TextfieldDefaultColor); | |
| 74 } | |
| 69 switch (style) { | 75 switch (style) { |
| 70 case views::style::STYLE_DISABLED: | 76 case views::style::STYLE_DISABLED: |
| 71 case STYLE_SECONDARY: | 77 case STYLE_SECONDARY: |
| 72 case STYLE_HINT: | 78 case STYLE_HINT: |
| 73 return theme.GetSystemColor( | 79 return theme.GetSystemColor( |
| 74 ui::NativeTheme::kColorId_LabelDisabledColor); | 80 ui::NativeTheme::kColorId_LabelDisabledColor); |
| 75 case views::style::STYLE_LINK: | 81 case views::style::STYLE_LINK: |
| 76 return theme.GetSystemColor(ui::NativeTheme::kColorId_LinkEnabled); | 82 return theme.GetSystemColor(ui::NativeTheme::kColorId_LinkEnabled); |
| 77 case STYLE_RED: | 83 case STYLE_RED: |
| 78 return foreground_color == SK_ColorWHITE ? gfx::kGoogleRed300 | 84 return foreground_color == SK_ColorWHITE ? gfx::kGoogleRed300 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 92 case views::style::STYLE_LINK: | 98 case views::style::STYLE_LINK: |
| 93 return gfx::kGoogleBlue700; | 99 return gfx::kGoogleBlue700; |
| 94 case STYLE_SECONDARY: | 100 case STYLE_SECONDARY: |
| 95 case STYLE_HINT: | 101 case STYLE_HINT: |
| 96 return SkColorSetRGB(0x75, 0x75, 0x75); | 102 return SkColorSetRGB(0x75, 0x75, 0x75); |
| 97 case STYLE_RED: | 103 case STYLE_RED: |
| 98 return gfx::kGoogleRed700; | 104 return gfx::kGoogleRed700; |
| 99 case STYLE_GREEN: | 105 case STYLE_GREEN: |
| 100 return gfx::kGoogleGreen700; | 106 return gfx::kGoogleGreen700; |
| 101 } | 107 } |
| 102 return SkColorSetRGB(0x21, 0x21, 0x21); // Primary for everything else. | 108 return SkColorSetRGB(0x21, 0x21, 0x21); // Primary for everything else. |
|
tapted
2017/06/29 10:29:33
This is what the text will be otherwise.. I haven'
| |
| 103 } | 109 } |
| 104 | 110 |
| 105 int HarmonyTypographyProvider::GetLineHeight(int context, int style) const { | 111 int HarmonyTypographyProvider::GetLineHeight(int context, int style) const { |
| 106 // "Target" line height constants from the Harmony spec. A default OS | 112 // "Target" line height constants from the Harmony spec. A default OS |
| 107 // configuration should use these heights. However, if the user overrides OS | 113 // configuration should use these heights. However, if the user overrides OS |
| 108 // defaults, then GetLineHeight() should return the height that would add the | 114 // defaults, then GetLineHeight() should return the height that would add the |
| 109 // same extra space between lines as the default configuration would have. | 115 // same extra space between lines as the default configuration would have. |
| 110 constexpr int kHeadlineHeight = 32; | 116 constexpr int kHeadlineHeight = 32; |
| 111 constexpr int kTitleHeight = 22; | 117 constexpr int kTitleHeight = 22; |
| 112 constexpr int kBodyHeight = 20; // For both large and small. | 118 constexpr int kBodyHeight = 20; // For both large and small. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 case views::style::CONTEXT_DIALOG_TITLE: | 168 case views::style::CONTEXT_DIALOG_TITLE: |
| 163 return title_height; | 169 return title_height; |
| 164 case CONTEXT_BODY_TEXT_LARGE: | 170 case CONTEXT_BODY_TEXT_LARGE: |
| 165 return body_large_height; | 171 return body_large_height; |
| 166 case CONTEXT_HEADLINE: | 172 case CONTEXT_HEADLINE: |
| 167 return headline_height; | 173 return headline_height; |
| 168 default: | 174 default: |
| 169 return default_height; | 175 return default_height; |
| 170 } | 176 } |
| 171 } | 177 } |
| OLD | NEW |