diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-12 14:27:29 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-13 09:35:20 +0000 |
commit | c30a6232df03e1efbd9f3b226777b07e087a1122 (patch) | |
tree | e992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/ui/gfx/render_text_harfbuzz.cc | |
parent | 7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff) | |
download | qtwebengine-chromium-85-based.tar.gz |
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ui/gfx/render_text_harfbuzz.cc')
-rw-r--r-- | chromium/ui/gfx/render_text_harfbuzz.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/chromium/ui/gfx/render_text_harfbuzz.cc b/chromium/ui/gfx/render_text_harfbuzz.cc index 540c1fc200f..64d00af2c83 100644 --- a/chromium/ui/gfx/render_text_harfbuzz.cc +++ b/chromium/ui/gfx/render_text_harfbuzz.cc @@ -485,6 +485,14 @@ class HarfBuzzLineBreaker { // Finishes line breaking and outputs the results. Can be called at most once. void FinalizeLines(std::vector<internal::Line>* lines, SizeF* size) { DCHECK(!lines_.empty()); + // If the last character of the text is a new line character, then the last + // line is any empty string, which contains no segments. This means that the + // display_text_index will not have been set in AdvanceLine. So here, set + // display_text_index to the text length, which is the true text index of + // the final line. + internal::Line* line = &lines_.back(); + if (line->display_text_index == 0) + line->display_text_index = text_.size(); // Add an empty line to finish the line size calculation and remove it. AdvanceLine(); lines_.pop_back(); @@ -505,6 +513,11 @@ class HarfBuzzLineBreaker { void AdvanceLine() { if (!lines_.empty()) { internal::Line* line = &lines_.back(); + // Compute the line start while the line segments are in the logical order + // so that the start of the line is the start of the char range, + // regardless of i18n. + if (!line->segments.empty()) + line->display_text_index = line->segments[0].char_range.start(); std::sort(line->segments.begin(), line->segments.end(), [this](const internal::LineSegment& s1, const internal::LineSegment& s2) -> bool { @@ -1685,7 +1698,7 @@ void RenderTextHarfBuzz::EnsureLayout() { } void RenderTextHarfBuzz::DrawVisualText(internal::SkiaTextRenderer* renderer, - const std::vector<Range> selections) { + const std::vector<Range>& selections) { DCHECK(!update_layout_run_list_); DCHECK(!update_display_run_list_); DCHECK(!update_display_text_); @@ -1834,7 +1847,7 @@ void RenderTextHarfBuzz::ItemizeTextToRuns( // to misbehave since they expect non-zero text metrics from a non-empty text. ui::gfx::BiDiLineIterator bidi_iterator; - if (!bidi_iterator.Open(text, GetTextDirection(text))) { + if (!bidi_iterator.Open(text, GetTextDirectionForGivenText(text))) { auto run = std::make_unique<internal::TextRunHarfBuzz>( font_list().GetPrimaryFont()); run->range = Range(0, text.length()); |