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

Unified Diff: third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp

Issue 2909923005: Expand TextCheckingParagraph::OffsetTo() into SelectionController::MarkAndReplaceFor() (Closed)
Patch Set: 2017-05-30T18:54:14 Created 3 years, 7 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/spellcheck/TextCheckingParagraph.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() &&
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/spellcheck/TextCheckingParagraph.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698