Description"Bootstrap" a toolkit-views Typography spec.
Under Harmony, we want to abstract away decisions about font selection.
Harmony has a set of styles as part of the spec that encapsulate:
- Font (typeface)
- Font size, weight and color
- Line spacing ("leading")
gfx::Font[List] can represent Font, size and weight, but not color or
line spacing. Also callers typically _never_ care about typeface, but
APIs using gfx::Font are unable to encapsulate this. One side-effect is
that a lot of callers use gfx::Font::Derive(..) rather than
ResourceBundle::GetFontWithDelta(..) and so miss out on caching
benefits.
The typography concepts are split into "TextContext" and "TextStyle".
The former describes the location of the text, and the latter describes
its current state (e.g. Disabled) or other appearance (e.g. a Hyperlink)
in that context.
This CL exposes a set of abstract typography concepts at
views::style, and explores the impact on client code by refactoring
the views::Label constructor that takes a gfx::FontList to take a
Label::CustomFont instead. Where it makes sense, callers are migrated to
typography concepts rather than use Label::CustomFont.
The transformations typically look like:
- ui::ResourceBundle::MediumFont -> views::style::CONTEXT_DIALOG_TITLE "15pt"
- GetFontListWithDelta(ui::kTitleFontSizeDelta) ->
views::style::CONTEXT_DIALOG_TITLE
- GetFontListWithDelta(1) -> (chrome) CONTEXT_BODY_TEXT_LARGE "13pt"
- [default constructor] or ResourceBundle::BaseFont ->
CONTEXT_BODY_TEXT_LARGE or views::style::CONTEXT_LABEL "12pt"
- ui::ResourceBundle::SmallFont -> (chrome) CONTEXT_DEPRECATED_SMALL
(Harmony doesn't have an 11pt font in the spec)
- ui::ResourceBundle::BoldFont -> (chrome) STYLE_EMPHASIZED
(Harmony doesn't have a "bold" font in the spec)
These transformations, and the default TypographyProvider, are chosen to
effectively be a "no-op" so that no existing dialogs change font sizes
or other properties.
Follow-ups will:
- Implement a Harmony TypographyProvider.
- Require all Label constructors to take a typography concept or
Label::CustomFont.
- Remove Label::SetFontList, Label::Set*Color, etc. (use typography or
merge into CustomFont).
- Remove gfx::FontList from the API of other toolkit-views classes.
- Audit remaining users of Label::CustomFont to see if they can be
replaced by Typography concepts.
- Remove ResourceBundle::FontStyle (SmallFont, etc.)
- Remove ui/default_style.h (ui::kFooFontSizeDelta, etc.)
BUG=691891, 701241
Review-Url: https://codereview.chromium.org/2734113006
Cr-Commit-Position: refs/heads/master@{#458261}
Committed: https://chromium.googlesource.com/chromium/src/+/9577332120682b5400df78b16edcc0c759bb5881
Patch Set 1 : Get more insight #Patch Set 2 : API shell #Patch Set 3 : All builds on mac_views_browser #Patch Set 4 : ChromeOS pass #Patch Set 5 : fix windows #
Total comments: 40
Patch Set 6 : ExtendableEnum #
Total comments: 7
Patch Set 7 : Do TextStyle. Make Windows happy. #Patch Set 8 : respond to comments #Patch Set 9 : Rebase (conflict in test/BUILD.gn) #Patch Set 10 : Shred Typography class, follow-up on some other things. fix compile. #
Total comments: 10
Patch Set 11 : Red builds give tapted ocd #Patch Set 12 : delegate to delegate delegate. enummify. lint. make gcc happy #Patch Set 13 : Fix tests failing because they have no ViewsDelegate, but it looks like I also need to rebase #Patch Set 14 : Rebase #
Total comments: 78
Patch Set 15 : respond to comments #
Total comments: 12
Patch Set 16 : pkasting comments #Patch Set 17 : Rebase (conflict in layout_delegate.h due to r457774) #
Total comments: 5
Messages
Total messages: 143 (117 generated)
|