| 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 9ebfbdeacce016b2e65697de247f07545357f17c..c8432e8782a2568a4c5e24d5aa1bc3708f2b3e91 100644
|
| --- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
|
| @@ -604,7 +604,6 @@ void SpellChecker::MarkAndReplaceFor(
|
| // and should be rewritten.
|
| // Expand the range to encompass entire paragraphs, since text checking needs
|
| // that much context.
|
| - int selection_offset = 0;
|
| int ambiguous_boundary_offset = -1;
|
|
|
| if (GetFrame().Selection().ComputeVisibleSelectionInDOMTree().IsCaret()) {
|
| @@ -613,7 +612,11 @@ void SpellChecker::MarkAndReplaceFor(
|
| // Attempt to save the caret position so we can restore it later if needed
|
| const Position& caret_position =
|
| GetFrame().Selection().ComputeVisibleSelectionInDOMTree().end();
|
| - selection_offset = paragraph.OffsetTo(caret_position);
|
| + const Position& paragraph_start = checking_range.StartPosition();
|
| + const int selection_offset =
|
| + paragraph_start < caret_position
|
| + ? TextIterator::RangeLength(paragraph_start, caret_position)
|
| + : 0;
|
| if (selection_offset > 0 &&
|
| static_cast<unsigned>(selection_offset) <=
|
| paragraph.GetText().length() &&
|
|
|