Chromium Code Reviews| Index: ui/views/style/typography_provider.h |
| diff --git a/ui/views/style/typography_provider.h b/ui/views/style/typography_provider.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5671477e612f6bbc46344f61f4d6d77282016fdc |
| --- /dev/null |
| +++ b/ui/views/style/typography_provider.h |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_ |
| +#define UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_ |
| + |
| +#include "base/macros.h" |
| +#include "third_party/skia/include/core/SkColor.h" |
| +#include "ui/gfx/font.h" |
| +#include "ui/views/views_export.h" |
| + |
| +namespace gfx { |
| +class FontList; |
| +} |
| + |
| +namespace views { |
| + |
| +// Provides fonts to use in toolkit-views UI. |
| +class VIEWS_EXPORT TypographyProvider { |
| + public: |
| + // Gets the FontList for the given |context| and |style|. |
| + virtual const gfx::FontList& GetFont(int context, int style) const = 0; |
| + |
| + // Gets the color for the given |context| and |style|. This may consult |
| + // ui::NativeTheme. |
| + virtual SkColor GetColor(int context, int style) const = 0; |
| + |
| + // Gets the line spacing, or 0 if it should be provided by gfx::FontList. |
| + virtual int GetLineHeight(int context, int style) const = 0; |
| + |
| + virtual ~TypographyProvider() = default; |
|
Peter Kasting
2017/03/17 02:26:01
Nit: Destructor before the other methods; see http
tapted
2017/03/17 10:33:11
Done.
|
| + |
| + protected: |
| + TypographyProvider() = default; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(TypographyProvider); |
| +}; |
| + |
| +// The default provider aims to provide values to match pre-Harmony constants |
| +// for the given contexts so that old UI does not change. |
| +class VIEWS_EXPORT DefaultTypographyProvider : public TypographyProvider { |
| + public: |
| + DefaultTypographyProvider() = default; |
| + |
| + const gfx::FontList& GetFont(int context, int style) const override; |
| + SkColor GetColor(int context, int style) const override; |
| + int GetLineHeight(int context, int style) const override; |
| + |
| + // Describes the font that the default GetFont() implementation uses. Always |
|
Peter Kasting
2017/03/17 02:26:01
Nit: Maybe "Describes" -> "Sets the |size_delta| a
tapted
2017/03/17 10:33:11
Done.
|
| + // writes a value, even for styles it doesn't know about. |
|
Peter Kasting
2017/03/17 02:26:01
Nit: "writes a value" -> "sets values"?
tapted
2017/03/17 10:33:11
Done.
|
| + void GetDefaultFont(int context, |
| + int style, |
| + int* size_delta, |
| + gfx::Font::Weight* font_weight) const; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(DefaultTypographyProvider); |
| +}; |
| + |
| +} // namespace views |
| + |
| +#endif // UI_VIEWS_STYLE_TYPOGRAPHY_PROVIDER_H_ |