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

Unified Diff: third_party/WebKit/Source/core/editing/SurroundingText.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 | « no previous file | third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/SurroundingText.cpp
diff --git a/third_party/WebKit/Source/core/editing/SurroundingText.cpp b/third_party/WebKit/Source/core/editing/SurroundingText.cpp
index 4d10322b6b3ba3a274a1477ea461381377b74ed5..4a7d5f0965e3495af3f4f1209c9e8795e626f7bc 100644
--- a/third_party/WebKit/Source/core/editing/SurroundingText.cpp
+++ b/third_party/WebKit/Source/core/editing/SurroundingText.cpp
@@ -93,14 +93,12 @@ void SurroundingText::Initialize(const Position& start_position,
if (!backwards_iterator.AtEnd())
backwards_iterator.Advance(half_max_length);
- start_offset_in_content_ =
- Range::Create(*document, backwards_iterator.EndPosition(), start_position)
- ->GetText()
- .length();
- end_offset_in_content_ =
- Range::Create(*document, backwards_iterator.EndPosition(), end_position)
- ->GetText()
- .length();
+ const TextIteratorBehavior behavior =
+ TextIteratorBehavior::NoTrailingSpaceRangeLengthBehavior();
+ start_offset_in_content_ = TextIterator::RangeLength(
+ backwards_iterator.EndPosition(), start_position, behavior);
+ end_offset_in_content_ = TextIterator::RangeLength(
+ backwards_iterator.EndPosition(), end_position, behavior);
content_range_ = Range::Create(*document, backwards_iterator.EndPosition(),
forward_range.StartPosition());
DCHECK(content_range_);
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/iterators/TextIterator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698