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

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

Issue 2845863002: [Idle time spell checker] Correct position passed from undo stack (Closed)
Patch Set: Fix bot failures... 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/spellcheck/IdleSpellCheckCallback.cpp
diff --git a/third_party/WebKit/Source/core/editing/spellcheck/IdleSpellCheckCallback.cpp b/third_party/WebKit/Source/core/editing/spellcheck/IdleSpellCheckCallback.cpp
index 41211b259bc2165bbe308c0610578816aa8d4a08..18cc6797d2b34ce1290e6fa417a29fee0804ee52 100644
--- a/third_party/WebKit/Source/core/editing/spellcheck/IdleSpellCheckCallback.cpp
+++ b/third_party/WebKit/Source/core/editing/spellcheck/IdleSpellCheckCallback.cpp
@@ -34,6 +34,13 @@ const int kInvalidHandle = -1;
const int kDummyHandleForForcedInvocation = -2;
const double kForcedInvocationDeadlineSeconds = 10;
+Position CorrectedReferencePosition(const Position& position,
+ const Document& document) {
+ if (!position.IsConnected() || position.GetDocument() != document)
+ return Position();
+ return CreateVisiblePosition(position).DeepEquivalent();
+}
+
} // namespace
IdleSpellCheckCallback::~IdleSpellCheckCallback() {}
@@ -155,7 +162,13 @@ void IdleSpellCheckCallback::HotModeInvocation(IdleDeadline* deadline) {
std::max(step->SequenceNumber(), last_processed_undo_step_sequence_);
if (deadline->timeRemaining() == 0)
break;
- requester.CheckSpellingAt(step->EndingSelection().Extent());
+ // The reference position stored in undo stack can be invalid, disconnected
+ // or have been moved to another document, in which case it should be
+ // corrected.
+ const Position& stored_position = step->EndingSelection().Extent();
+ const Position& corrected_position =
+ CorrectedReferencePosition(stored_position, *GetFrame().GetDocument());
+ requester.CheckSpellingAt(corrected_position);
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698