From 05f1fa924066d351f9714a9edf534022a04e15a2 Mon Sep 17 00:00:00 2001 From: NoamDev <37066741+NoamDev@users.noreply.github.com> Date: Thu, 27 Feb 2020 19:55:00 +0200 Subject: [PATCH] Revert "[libtxt] Assign a unique ID to each glyph cluster within a line (#15742)" This reverts commit 4ac4153e11b8bf8a128e010bc38ced06b85f6912. --- third_party/txt/src/txt/paragraph_txt.cc | 12 ++++---- third_party/txt/tests/paragraph_unittests.cc | 31 -------------------- 2 files changed, 5 insertions(+), 38 deletions(-) diff --git a/third_party/txt/src/txt/paragraph_txt.cc b/third_party/txt/src/txt/paragraph_txt.cc index 4b28234e83876..ceb5c08f08eea 100644 --- a/third_party/txt/src/txt/paragraph_txt.cc +++ b/third_party/txt/src/txt/paragraph_txt.cc @@ -796,7 +796,6 @@ void ParagraphTxt::Layout(double width) { double run_x_offset = 0; double justify_x_offset = 0; - size_t cluster_unique_id = 0; std::vector paint_records; for (auto line_run_it = line_runs.begin(); line_run_it != line_runs.end(); @@ -957,10 +956,10 @@ void ParagraphTxt::Layout(double width) { float grapheme_advance = glyph_advance / grapheme_code_unit_counts.size(); - glyph_positions.emplace_back( - run_x_offset + glyph_x_offset, grapheme_advance, - run.start() + glyph_code_units.start, - grapheme_code_unit_counts[0], cluster_unique_id); + glyph_positions.emplace_back(run_x_offset + glyph_x_offset, + grapheme_advance, + run.start() + glyph_code_units.start, + grapheme_code_unit_counts[0], cluster); // Compute positions for the additional graphemes in the ligature. for (size_t i = 1; i < grapheme_code_unit_counts.size(); ++i) { @@ -968,9 +967,8 @@ void ParagraphTxt::Layout(double width) { glyph_positions.back().x_pos.end, grapheme_advance, glyph_positions.back().code_units.start + grapheme_code_unit_counts[i - 1], - grapheme_code_unit_counts[i], cluster_unique_id); + grapheme_code_unit_counts[i], cluster); } - cluster_unique_id++; bool at_word_start = false; bool at_word_end = false; diff --git a/third_party/txt/tests/paragraph_unittests.cc b/third_party/txt/tests/paragraph_unittests.cc index 057273eddf9c7..31375f50cd332 100644 --- a/third_party/txt/tests/paragraph_unittests.cc +++ b/third_party/txt/tests/paragraph_unittests.cc @@ -175,37 +175,6 @@ TEST_F(ParagraphTest, GetGlyphPositionAtCoordinateSegfault) { ASSERT_TRUE(Snapshot()); } -// Check that GetGlyphPositionAtCoordinate computes correct text positions for -// a paragraph containing multiple styled runs. -TEST_F(ParagraphTest, GetGlyphPositionAtCoordinateMultiRun) { - txt::ParagraphStyle paragraph_style; - txt::ParagraphBuilderTxt builder(paragraph_style, GetTestFontCollection()); - - txt::TextStyle text_style; - text_style.font_families = std::vector(1, "Ahem"); - text_style.color = SK_ColorBLACK; - text_style.font_size = 10; - builder.PushStyle(text_style); - builder.AddText(u"A"); - text_style.font_size = 20; - builder.PushStyle(text_style); - builder.AddText(u"B"); - text_style.font_size = 30; - builder.PushStyle(text_style); - builder.AddText(u"C"); - - auto paragraph = BuildParagraph(builder); - paragraph->Layout(GetTestCanvasWidth()); - - paragraph->Paint(GetCanvas(), 10.0, 15.0); - - ASSERT_EQ(paragraph->GetGlyphPositionAtCoordinate(2.0, 5.0).position, 0ull); - ASSERT_EQ(paragraph->GetGlyphPositionAtCoordinate(12.0, 5.0).position, 1ull); - ASSERT_EQ(paragraph->GetGlyphPositionAtCoordinate(32.0, 5.0).position, 2ull); - - ASSERT_TRUE(Snapshot()); -} - TEST_F(ParagraphTest, LineMetricsParagraph1) { const char* text = "Hello! What is going on?\nSecond line \nthirdline"; auto icu_text = icu::UnicodeString::fromUTF8(text);