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 "ui/views/style/typography.h" | 5 #include "ui/views/style/typography.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/native_theme/native_theme.h" | |
8 #include "ui/views/layout/layout_provider.h" | 9 #include "ui/views/layout/layout_provider.h" |
9 #include "ui/views/style/typography_provider.h" | 10 #include "ui/views/style/typography_provider.h" |
10 | 11 |
11 namespace views { | 12 namespace views { |
12 namespace style { | 13 namespace style { |
13 namespace { | 14 namespace { |
14 | 15 |
15 void ValidateContextAndStyle(int text_context, int text_style) { | 16 void ValidateContextAndStyle(int text_context, int text_style) { |
16 DCHECK_GE(text_context, VIEWS_TEXT_CONTEXT_START); | 17 DCHECK_GE(text_context, VIEWS_TEXT_CONTEXT_START); |
17 DCHECK_LT(text_context, TEXT_CONTEXT_MAX); | 18 DCHECK_LT(text_context, TEXT_CONTEXT_MAX); |
18 DCHECK_GE(text_style, VIEWS_TEXT_STYLE_START); | 19 DCHECK_GE(text_style, VIEWS_TEXT_STYLE_START); |
19 } | 20 } |
20 | 21 |
21 } // namespace | 22 } // namespace |
22 | 23 |
23 const gfx::FontList& GetFont(int text_context, int text_style) { | 24 const gfx::FontList& GetFont(int text_context, int text_style) { |
24 ValidateContextAndStyle(text_context, text_style); | 25 ValidateContextAndStyle(text_context, text_style); |
25 return LayoutProvider::Get()->GetTypographyProvider().GetFont(text_context, | 26 return LayoutProvider::Get()->GetTypographyProvider().GetFont(text_context, |
26 text_style); | 27 text_style); |
27 } | 28 } |
28 | 29 |
29 SkColor GetColor(int text_context, int text_style) { | 30 SkColor GetColor(int text_context, |
31 int text_style, | |
32 const ui::NativeTheme* native_theme) { | |
30 ValidateContextAndStyle(text_context, text_style); | 33 ValidateContextAndStyle(text_context, text_style); |
31 return LayoutProvider::Get()->GetTypographyProvider().GetColor(text_context, | 34 DCHECK(native_theme); |
Peter Kasting
2017/06/01 04:55:58
Why not just pass in by const ref then, as typogra
tapted
2017/06/01 11:22:18
Then all the callsites need an extra character in
Peter Kasting
2017/06/01 19:08:01
Hmm. That sounds like a "maybe it would be useful
tapted
2017/06/02 01:29:15
I feel a '*' at callsites is more cognitive load f
| |
32 text_style); | 35 return LayoutProvider::Get()->GetTypographyProvider().GetColor( |
36 text_context, text_style, *native_theme); | |
33 } | 37 } |
34 | 38 |
35 int GetLineHeight(int text_context, int text_style) { | 39 int GetLineHeight(int text_context, int text_style) { |
36 ValidateContextAndStyle(text_context, text_style); | 40 ValidateContextAndStyle(text_context, text_style); |
37 return LayoutProvider::Get()->GetTypographyProvider().GetLineHeight( | 41 return LayoutProvider::Get()->GetTypographyProvider().GetLineHeight( |
38 text_context, text_style); | 42 text_context, text_style); |
39 } | 43 } |
40 | 44 |
41 } // namespace style | 45 } // namespace style |
42 } // namespace views | 46 } // namespace views |
OLD | NEW |