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..9d1f3fae008182205eb24a44d45f9c9fe5bd73b4 |
| --- /dev/null |
| +++ b/ui/views/style/typography_provider.h |
| @@ -0,0 +1,74 @@ |
| +// 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 <memory> |
| + |
| +#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 { |
| + |
| +class TextContext; |
| +class TextStyle; |
| + |
| +// 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(TextContext context, |
| + TextStyle style) const = 0; |
| + |
| + // Gets the color for the given |context| and |style|. This may consult |
| + // ui::NativeTheme. |
| + virtual SkColor GetColor(TextContext context, TextStyle style) const = 0; |
| + |
| + // Gets the line spacing, or 0 if it should be provided by gfx::FontList. |
| + virtual int GetLineSpacing(TextContext context, TextStyle style) const = 0; |
|
tapted
2017/03/15 11:04:07
(note to self: rename to GetLineHeight to match vi
tapted
2017/03/16 11:13:39
Done.
|
| + |
| + virtual ~TypographyProvider() = default; |
| + |
| + static void Set(std::unique_ptr<TypographyProvider> provider); |
| + static const TypographyProvider& Get(); |
| + |
| + 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(TextContext context, |
| + TextStyle style) const override; |
| + SkColor GetColor(TextContext context, TextStyle style) const override; |
| + int GetLineSpacing(TextContext context, TextStyle style) const override; |
| + |
| + // Describes the font that the default GetFont() implementation uses. Always |
| + // writes a value, even for styles it doesn't know about. |
| + void GetDefaultFont(TextContext context, |
| + TextStyle 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_ |