Chromium Code Reviews| Index: ui/gfx/render_text_harfbuzz.cc |
| diff --git a/ui/gfx/render_text_harfbuzz.cc b/ui/gfx/render_text_harfbuzz.cc |
| index d0b3dd7200278cbaadb91c086ddda01ec5a6638b..e8c0ebb4d10f697f84a45b80feb37d8cd08b5bce 100644 |
| --- a/ui/gfx/render_text_harfbuzz.cc |
| +++ b/ui/gfx/render_text_harfbuzz.cc |
| @@ -847,13 +847,9 @@ std::vector<RenderText::FontSpan> RenderTextHarfBuzz::GetFontSpansForTesting() { |
| internal::TextRunList* run_list = GetRunList(); |
| std::vector<RenderText::FontSpan> spans; |
| for (auto* run : run_list->runs()) { |
| - SkString family_name; |
| - run->skia_face->getFamilyName(&family_name); |
| - Font font(family_name.c_str(), run->font_size); |
| spans.push_back(RenderText::FontSpan( |
| - font, |
| - Range(DisplayIndexToTextIndex(run->range.start()), |
| - DisplayIndexToTextIndex(run->range.end())))); |
| + run->font, Range(DisplayIndexToTextIndex(run->range.start()), |
| + DisplayIndexToTextIndex(run->range.end())))); |
| } |
| return spans; |
| @@ -1590,4 +1586,43 @@ const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { |
| return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); |
| } |
| +bool RenderTextHarfBuzz::GetDecoratedTextForRange( |
| + const Range& range, |
| + DecoratedText* decorated_text) const { |
| + if (obscured()) |
| + return false; |
| + |
| + decorated_text->attributes.clear(); |
| + decorated_text->text = GetTextFromRange(range); |
| + |
| + const internal::TextRunList* run_list = GetRunList(); |
| + for (size_t i = 0; i < run_list->size(); i++) { |
| + const internal::TextRunHarfBuzz& run = *run_list->runs()[i]; |
| + |
| + const Range intersection = range.Intersect(run.range); |
| + DCHECK(!intersection.is_reversed()); |
| + |
| + if (!intersection.is_empty()) { |
| + int style = Font::NORMAL; |
| + if (run.italic) |
| + style |= Font::ITALIC; |
| + if (run.underline) |
| + style |= Font::UNDERLINE; |
| + |
| + Font font_with_style = run.font.Derive(0, style, run.weight); |
|
msw
2016/10/04 01:52:37
optional nit: inline below in DecoratedText::Range
karandeepb
2016/10/04 12:04:24
Done.
|
| + |
| + // Get range relative to the decorated text. |
| + DecoratedText::RangedAttribute attribute( |
|
msw
2016/10/04 01:52:37
producing a range for every run might not give the
karandeepb
2016/10/04 12:04:24
It seems StyleIterator does support strikes and di
msw
2016/10/05 00:24:48
You're right, it does handle strikes as styles, bu
|
| + gfx::Range(intersection.start() - range.GetMin(), |
| + intersection.end() - range.GetMin()), |
| + font_with_style); |
| + |
| + attribute.strike = run.strike; |
| + attribute.diagonal_strike = run.diagonal_strike; |
| + decorated_text->attributes.push_back(attribute); |
| + } |
| + } |
| + return true; |
| +} |
| + |
| } // namespace gfx |