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

Unified Diff: third_party/WebKit/Source/core/editing/SurroundingText.cpp

Issue 2955973007: Revert of Made surrounding text work for last word in a document (Closed)
Patch Set: Created 3 years, 6 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
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 1f283f1d2d7017f7ba8dcf001e8d7b4a9962e2d0..68e561ed1d9a207ce4c87d1c43b4a7af1f8bd5a8 100644
--- a/third_party/WebKit/Source/core/editing/SurroundingText.cpp
+++ b/third_party/WebKit/Source/core/editing/SurroundingText.cpp
@@ -76,8 +76,17 @@
end_position,
Position::LastPositionInNode(root_element).ParentAnchoredEquivalent(),
TextIteratorBehavior::Builder().SetStopsOnFormControls(true).Build());
+ // FIXME: why do we stop going trough the text if we were not able to select
+ // something on the right?
if (!forward_iterator.AtEnd())
forward_iterator.Advance(max_length - half_max_length);
+
+ EphemeralRange forward_range = forward_iterator.Range();
+ if (forward_range.IsNull() ||
+ !Range::Create(*document, end_position, forward_range.StartPosition())
+ ->GetText()
+ .length())
+ return;
// Same as with the forward range but with the backward range. The range
// starts at the document's or input element's start and ends at the selection
@@ -96,7 +105,7 @@
end_offset_in_content_ = TextIterator::RangeLength(
backwards_iterator.EndPosition(), end_position, behavior);
content_range_ = Range::Create(*document, backwards_iterator.EndPosition(),
- forward_iterator.StartPosition());
+ forward_range.StartPosition());
DCHECK(content_range_);
}

Powered by Google App Engine
This is Rietveld 408576698