OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gfx/render_text_harfbuzz.h" | 5 #include "ui/gfx/render_text_harfbuzz.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/i18n/bidi_line_iterator.h" | 10 #include "base/i18n/bidi_line_iterator.h" |
(...skipping 831 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
842 } | 842 } |
843 | 843 |
844 std::vector<RenderText::FontSpan> RenderTextHarfBuzz::GetFontSpansForTesting() { | 844 std::vector<RenderText::FontSpan> RenderTextHarfBuzz::GetFontSpansForTesting() { |
845 EnsureLayout(); | 845 EnsureLayout(); |
846 | 846 |
847 internal::TextRunList* run_list = GetRunList(); | 847 internal::TextRunList* run_list = GetRunList(); |
848 std::vector<RenderText::FontSpan> spans; | 848 std::vector<RenderText::FontSpan> spans; |
849 for (auto* run : run_list->runs()) { | 849 for (auto* run : run_list->runs()) { |
850 SkString family_name; | 850 SkString family_name; |
851 run->skia_face->getFamilyName(&family_name); | 851 run->skia_face->getFamilyName(&family_name); |
852 Font font(family_name.c_str(), run->font_size); | 852 Font font(family_name.c_str(), run->font_size); |
karandeepb
2016/09/30 08:29:36
Any reason why run->font wasn't used here, instead
| |
853 spans.push_back(RenderText::FontSpan( | 853 spans.push_back(RenderText::FontSpan( |
854 font, | 854 font, |
855 Range(DisplayIndexToTextIndex(run->range.start()), | 855 Range(DisplayIndexToTextIndex(run->range.start()), |
856 DisplayIndexToTextIndex(run->range.end())))); | 856 DisplayIndexToTextIndex(run->range.end())))); |
857 } | 857 } |
858 | 858 |
859 return spans; | 859 return spans; |
860 } | 860 } |
861 | 861 |
862 Range RenderTextHarfBuzz::GetGlyphBounds(size_t index) { | 862 Range RenderTextHarfBuzz::GetGlyphBounds(size_t index) { |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1583 internal::TextRunList* RenderTextHarfBuzz::GetRunList() { | 1583 internal::TextRunList* RenderTextHarfBuzz::GetRunList() { |
1584 DCHECK(!update_layout_run_list_); | 1584 DCHECK(!update_layout_run_list_); |
1585 DCHECK(!update_display_run_list_); | 1585 DCHECK(!update_display_run_list_); |
1586 return text_elided() ? display_run_list_.get() : &layout_run_list_; | 1586 return text_elided() ? display_run_list_.get() : &layout_run_list_; |
1587 } | 1587 } |
1588 | 1588 |
1589 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { | 1589 const internal::TextRunList* RenderTextHarfBuzz::GetRunList() const { |
1590 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); | 1590 return const_cast<RenderTextHarfBuzz*>(this)->GetRunList(); |
1591 } | 1591 } |
1592 | 1592 |
1593 bool RenderTextHarfBuzz::GetDecoratedTextForRange( | |
1594 const Range& range, | |
1595 DecoratedText* decorated_text) const { | |
1596 if (obscured()) | |
1597 return false; | |
1598 | |
1599 decorated_text->attributes.clear(); | |
1600 decorated_text->text = GetTextFromRange(range); | |
1601 | |
1602 const internal::TextRunList* run_list = GetRunList(); | |
1603 for (size_t i = 0; i < run_list->size(); i++) { | |
1604 const internal::TextRunHarfBuzz& run = *run_list->runs()[i]; | |
1605 | |
1606 const Range intersection = range.Intersect(run.range); | |
1607 DCHECK(!intersection.is_reversed()); | |
1608 | |
1609 if (!intersection.is_empty()) { | |
1610 int style = Font::NORMAL; | |
1611 if (run.italic) | |
1612 style |= Font::ITALIC; | |
1613 if (run.underline) | |
1614 style |= Font::UNDERLINE; | |
1615 | |
1616 Font font_with_style = run.font.Derive(0, style, run.weight); | |
1617 | |
1618 // Get range relative to the decorated text. | |
1619 DecoratedText::RangedAttribute attribute( | |
1620 gfx::Range(intersection.start() - range.GetMin(), | |
1621 intersection.end() - range.GetMin()), | |
1622 font_with_style); | |
1623 | |
1624 attribute.strike = run.strike; | |
1625 attribute.diagonal_strike = run.diagonal_strike; | |
1626 decorated_text->attributes.push_back(attribute); | |
1627 } | |
1628 } | |
1629 return true; | |
1630 } | |
1631 | |
1593 } // namespace gfx | 1632 } // namespace gfx |
OLD | NEW |