Index: third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
diff --git a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
index 3dad9c7ea14f247b7b7d5ed7a265d28c05f41d1f..eea40422530eb4f08e7c33f904c5ac0c9581d610 100644 |
--- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
+++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
@@ -1139,15 +1139,15 @@ std::pair<String, int> SpellChecker::FindFirstMisspelling(const Position& start, |
// needs that much context. Determine the character offset from the start of |
// the paragraph to the start of the original search range, since we will want |
// to ignore results in this area. |
- Position paragraph_start = |
- StartOfParagraph(CreateVisiblePosition(start)).ToParentAnchoredPosition(); |
- Position paragraph_end = end; |
- int total_range_length = |
- TextIterator::RangeLength(paragraph_start, paragraph_end); |
- paragraph_end = |
- EndOfParagraph(CreateVisiblePosition(start)).ToParentAnchoredPosition(); |
- |
- int range_start_offset = TextIterator::RangeLength(paragraph_start, start); |
+ EphemeralRange paragraph_range = |
+ ExpandToParagraphBoundary(EphemeralRange(start, start)); |
+ Position paragraph_start = paragraph_range.StartPosition(); |
+ Position paragraph_end = paragraph_range.EndPosition(); |
+ |
+ const int total_range_length = |
+ TextIterator::RangeLength(paragraph_start, end); |
+ const int range_start_offset = |
+ TextIterator::RangeLength(paragraph_start, start); |
int total_length_processed = 0; |
bool first_iteration = true; |
@@ -1168,8 +1168,7 @@ std::pair<String, int> SpellChecker::FindFirstMisspelling(const Position& start, |
last_iteration = true; |
} |
if (current_start_offset < current_end_offset) { |
- String paragraph_string = |
- PlainText(EphemeralRange(paragraph_start, paragraph_end)); |
+ String paragraph_string = PlainText(paragraph_range); |
if (paragraph_string.length() > 0) { |
int spelling_location = 0; |
@@ -1203,14 +1202,16 @@ std::pair<String, int> SpellChecker::FindFirstMisspelling(const Position& start, |
if (last_iteration || |
total_length_processed + current_length >= total_range_length) |
break; |
- VisiblePosition new_paragraph_start = |
- StartOfNextParagraph(CreateVisiblePosition(paragraph_end)); |
+ Position new_paragraph_start = |
+ StartOfNextParagraph(CreateVisiblePosition(paragraph_end)) |
+ .DeepEquivalent(); |
if (new_paragraph_start.IsNull()) |
break; |
- paragraph_start = new_paragraph_start.ToParentAnchoredPosition(); |
- paragraph_end = |
- EndOfParagraph(new_paragraph_start).ToParentAnchoredPosition(); |
+ paragraph_range = ExpandToParagraphBoundary( |
+ EphemeralRange(new_paragraph_start, new_paragraph_start)); |
+ paragraph_start = paragraph_range.StartPosition(); |
+ paragraph_end = paragraph_range.EndPosition(); |
first_iteration = false; |
total_length_processed += current_length; |
} |