Chromium Code Reviews| Index: ui/gfx/render_text.h |
| diff --git a/ui/gfx/render_text.h b/ui/gfx/render_text.h |
| index 5a1825351bdf5c8bc97b7b754e1d3be3f7c2b7ea..edbfe166cee96840198b5ee3c5ed90ae6e7d9b09 100644 |
| --- a/ui/gfx/render_text.h |
| +++ b/ui/gfx/render_text.h |
| @@ -109,15 +109,18 @@ class SkiaTextRenderer { |
| DISALLOW_COPY_AND_ASSIGN(SkiaTextRenderer); |
| }; |
| -// Internal helper class used by derived classes to iterate colors and styles. |
| +// Internal helper class used by derived classes to iterate colors, baselines, |
|
msw
2015/02/18 23:32:08
nit: remove "by derived classes" for a one-liner.
dschuyler
2015/02/19 00:29:14
Done.
|
| +// and styles. |
| class StyleIterator { |
| public: |
| StyleIterator(const BreakList<SkColor>& colors, |
| + const BreakList<BaselineStyle>& baselines, |
| const std::vector<BreakList<bool> >& styles); |
| ~StyleIterator(); |
| // Get the colors and styles at the current iterator position. |
| SkColor color() const { return color_->second; } |
| + BaselineStyle baseline() const { return baseline_->second; } |
| bool style(TextStyle s) const { return style_[s]->second; } |
| // Get the intersecting range of the current iterator set. |
| @@ -128,9 +131,11 @@ class StyleIterator { |
| private: |
| BreakList<SkColor> colors_; |
| + BreakList<BaselineStyle> baselines_; |
| std::vector<BreakList<bool> > styles_; |
| BreakList<SkColor>::const_iterator color_; |
| + BreakList<BaselineStyle>::const_iterator baseline_; |
| std::vector<BreakList<bool>::const_iterator> style_; |
| DISALLOW_COPY_AND_ASSIGN(StyleIterator); |
| @@ -330,6 +335,11 @@ class GFX_EXPORT RenderText { |
| void SetColor(SkColor value); |
| void ApplyColor(SkColor value, const Range& range); |
| + // Set the baseline style over the entire text or a logical character range. |
|
msw
2015/02/18 23:32:08
nit: remove the extra space before "baseline"
dschuyler
2015/02/19 00:29:14
Done.
|
| + // The |range| should be valid, non-reversed, and within [0, text().length()]. |
| + void SetBaselineStyle(BaselineStyle value); |
| + void ApplyBaselineStyle(BaselineStyle value, const Range& range); |
| + |
| // Set various text styles over the entire text or a logical character range. |
| // The respective |style| is applied if |value| is true, or removed if false. |
| // The |range| should be valid, non-reversed, and within [0, text().length()]. |
| @@ -454,6 +464,7 @@ class GFX_EXPORT RenderText { |
| bool text_elided() const { return text_elided_; } |
| const BreakList<SkColor>& colors() const { return colors_; } |
| + const BreakList<BaselineStyle>& baselines() const { return baselines_; } |
| const std::vector<BreakList<bool> >& styles() const { return styles_; } |
| const std::vector<internal::Line>& lines() const { return lines_; } |
| @@ -626,6 +637,13 @@ class GFX_EXPORT RenderText { |
| // Updates |layout_text_| and |display_text_| as needed (or marks them dirty). |
| void OnTextAttributeChanged(); |
| + // Make sure ranges don't break text graphemes. If a range in |break_list| |
| + // does break a grapheme in |render_text|, the range will be slightly |
|
msw
2015/02/18 23:32:08
nit: remove the double space before "grapheme".
dschuyler
2015/02/19 00:29:14
Done.
|
| + // extended to encompass the grapheme. |
| + template <typename T> |
| + void RestoreBreakList(RenderText* render_text, |
| + T& break_list); |
| + |
| // Elides |text| as needed to fit in the |available_width| using |behavior|. |
| // |text_width| is the pre-calculated width of the text shaped by this render |
| // text, or pass 0 if the width is unknown. |
| @@ -690,10 +708,11 @@ class GFX_EXPORT RenderText { |
| // Composition text range. |
| Range composition_range_; |
| - // Color and style breaks, used to color and stylize ranges of text. |
| + // Color, baseline, and style breaks, used to modify ranges of text. |
| // BreakList positions are stored with text indices, not display indices. |
| // TODO(msw): Expand to support cursor, selection, background, etc. colors. |
| BreakList<SkColor> colors_; |
| + BreakList<BaselineStyle> baselines_; |
| std::vector<BreakList<bool> > styles_; |
| // Breaks saved without temporary composition and selection styling. |