Commit 7df9529c authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Make TextIterator::RangeLength() to return valid value when ending in ::first-letter

This patch changes |TextIteratorTextNodeHandler::HandleTextBox()| to handle
range ends at end of leading collapsed whitespace of first-letter part, e.g.
"<p>^ |(1) foo</p>" where P has ::first-letter.

Bug: 810623
Change-Id: I6888bf0cba305d33c193b6cd4c3f191c8dcf36bd
Reviewed-on: https://chromium-review.googlesource.com/910543
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#536916}
parent 151790ad
...@@ -514,10 +514,7 @@ TEST_P(ParameterizedTextIteratorTest, RangeLengthWithFirstLetter) { ...@@ -514,10 +514,7 @@ TEST_P(ParameterizedTextIteratorTest, RangeLengthWithFirstLetter) {
InsertStyleElement("p::first-letter {font-size:200%;}"); InsertStyleElement("p::first-letter {font-size:200%;}");
// Expectation should be as same as |RangeLengthBasic| // Expectation should be as same as |RangeLengthBasic|
EXPECT_EQ(0, TestRangeLength("<p>^| (1) abc def</p>")); EXPECT_EQ(0, TestRangeLength("<p>^| (1) abc def</p>"));
// TODO(editing-dev): We should fix legacy layout tree version. EXPECT_EQ(0, TestRangeLength("<p>^ |(1) abc def</p>"));
// See http://crbug.com/810623
EXPECT_EQ(LayoutNGEnabled() ? 0 : 8,
TestRangeLength("<p>^ |(1) abc def</p>"));
EXPECT_EQ(1, TestRangeLength("<p>^ (|1) abc def</p>")); EXPECT_EQ(1, TestRangeLength("<p>^ (|1) abc def</p>"));
EXPECT_EQ(2, TestRangeLength("<p>^ (1|) abc def</p>")); EXPECT_EQ(2, TestRangeLength("<p>^ (1|) abc def</p>"));
EXPECT_EQ(3, TestRangeLength("<p>^ (1)| abc def</p>")); EXPECT_EQ(3, TestRangeLength("<p>^ (1)| abc def</p>"));
......
...@@ -465,6 +465,12 @@ void TextIteratorTextNodeHandler::HandleTextBox() { ...@@ -465,6 +465,12 @@ void TextIteratorTextNodeHandler::HandleTextBox() {
return; return;
} }
// Advance and continue // Advance and continue
if (run_start == run_end && run_end == end) {
// "<p>^ |(1) foo</p>" with ::first-letter reaches here.
// Where "^" is start of range and "|" is end of range.
offset_ = end_offset_;
return;
}
text_box_ = next_text_box; text_box_ = next_text_box;
if (layout_object->ContainsReversedText()) if (layout_object->ContainsReversedText())
++sorted_text_boxes_position_; ++sorted_text_boxes_position_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment