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

Unified Diff: ui/views/style/typography_provider.h

Issue 2734113006: "Bootstrap" a toolkit-views Typography spec. (Closed)
Patch Set: Rebase (conflict in layout_delegate.h due to r457774) Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
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..aab1c0e997d7a325fd33671e07f3756dcea28cfd
--- /dev/null
+++ b/ui/views/style/typography_provider.h
@@ -0,0 +1,66 @@
+// 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:
+ virtual ~TypographyProvider() = default;
+
+ // 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;
+
+ 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;
+
+ // TypographyProvider:
+ 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;
+
+ // Sets the |size_delta| and |font_weight| that the the default GetFont()
+ // implementation uses. Always sets values, even for styles it doesn't know
+ // about.
+ 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_

Powered by Google App Engine
This is Rietveld 408576698