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

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

Issue 2124213002: Make EphemeralRange constructor not to accept invalid start and end positions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2016-07-07T18:31:23 Created 4 years, 5 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/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 f17814815d787019ef06bccb4505b0d08ef8b882..45fc8ee0d359d1c54999b0d8a18b673489bb9beb 100644
--- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
+++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
@@ -679,6 +679,7 @@ void SpellChecker::markMisspellingsAndBadGrammar(const VisibleSelection& spellin
void SpellChecker::updateMarkersForWordsAffectedByEditing(bool doNotRemoveIfSelectionAtWordBoundary)
{
+ DCHECK(frame().selection().isAvailable());
TRACE_EVENT0("blink", "SpellChecker::updateMarkersForWordsAffectedByEditing");
if (!isSpellCheckingEnabledFor(frame().selection().selection()))
return;
@@ -735,6 +736,17 @@ void SpellChecker::updateMarkersForWordsAffectedByEditing(bool doNotRemoveIfSele
if (startOfFirstWord.isNull() || endOfFirstWord.isNull() || startOfLastWord.isNull() || endOfLastWord.isNull())
return;
+ const Position& removeMarkerStart = startOfFirstWord.deepEquivalent();
+ const Position& removeMarkerEnd = endOfLastWord.deepEquivalent();
+ if (removeMarkerStart > removeMarkerEnd) {
+ // editing/inserting/insert-br-008.html and more reach here.
+ // TODO(yosin): To avoid |DCHECK(removeMarkerStart <= removeMarkerEnd)|
+ // in |EphemeralRange| constructor, we have this if-statement. Once we
+ // fix |startOfWord()| and |endOfWord()|, we should remove this
+ // if-statement.
+ return;
+ }
+
// Now we remove markers on everything between startOfFirstWord and endOfLastWord.
// However, if an autocorrection change a single word to multiple words, we want to remove correction mark from all the
// resulted words even we only edit one of them. For example, assuming autocorrection changes "avantgarde" to "avant
@@ -743,7 +755,7 @@ void SpellChecker::updateMarkersForWordsAffectedByEditing(bool doNotRemoveIfSele
// of marker that contains the word in question, and remove marker on that whole range.
Document* document = frame().document();
DCHECK(document);
- const EphemeralRange wordRange(startOfFirstWord.deepEquivalent(), endOfLastWord.deepEquivalent());
+ const EphemeralRange wordRange(removeMarkerStart, removeMarkerEnd);
document->markers().removeMarkers(wordRange, DocumentMarker::MisspellingMarkers(), DocumentMarkerController::RemovePartiallyOverlappingMarker);
}

Powered by Google App Engine
This is Rietveld 408576698