Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(848)

Unified Diff: third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp

Issue 2832123002: Do not count extra trailing space for the last word in a range (Closed)
Patch Set: getElementById Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/iterators/TextIteratorBehavior.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp
index 8938d190a226763c1461e75f800d7a763177fc3e..2c679bdacf1ff6e921a2da445dcc18c3c91383b4 100644
--- a/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp
+++ b/third_party/WebKit/Source/core/editing/iterators/TextIteratorTest.cpp
@@ -459,6 +459,34 @@ TEST_F(TextIteratorTest, RangeLengthWithReplacedElements) {
range->EndPosition()));
}
+TEST_F(TextIteratorTest, RangeLengthInMultilineSpan) {
+ static const char* body_content =
+ "<table style='width:5em'>"
+ "<tbody>"
+ "<tr>"
+ "<td>"
+ "<span id='span1'>one two three four five</span>"
+ "</td>"
+ "</tr>"
+ "</tbody>"
+ "</table>";
+
+ SetBodyContent(body_content);
+ GetDocument().View()->UpdateAllLifecyclePhases();
+
+ Node* span_node = GetDocument().getElementById("span1");
+ Node* text_node = span_node->firstChild();
+
+ // Select the word "two", this is the last word on the line.
+ const Position start = Position(text_node, 4);
+ const Position end = Position(text_node, 7);
+
+ EXPECT_EQ(4, TextIterator::RangeLength(start, end));
+ EXPECT_EQ(3, TextIterator::RangeLength(
+ start, end,
+ TextIteratorBehavior::NoTrailingSpaceRangeLengthBehavior()));
+}
+
TEST_F(TextIteratorTest, WhitespaceCollapseForReplacedElements) {
static const char* body_content =
"<span>Some text </span> <input type='button' value='Button "
« no previous file with comments | « third_party/WebKit/Source/core/editing/iterators/TextIteratorBehavior.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698