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 cb219a6984983a6bf8af710bcbd3b62bbe219ad7..b983fd71ed1c6b8b5092f6918ed7a065e2fa06e5 100644 |
--- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
+++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp |
@@ -702,97 +702,9 @@ void SpellChecker::updateMarkersForWordsAffectedByEditing( |
if (!isSpellCheckingEnabledFor(frame().selection().selection())) |
return; |
- Document* document = frame().document(); |
- DCHECK(document); |
- |
- // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
- // needs to be audited. See http://crbug.com/590369 for more details. |
- document->updateStyleAndLayoutIgnorePendingStylesheets(); |
- |
- // We want to remove the markers from a word if an editing command will change |
- // the word. This can happen in one of several scenarios: |
- // 1. Insert in the middle of a word. |
- // 2. Appending non whitespace at the beginning of word. |
- // 3. Appending non whitespace at the end of word. |
- // Note that, appending only whitespaces at the beginning or end of word won't |
- // change the word, so we don't need to remove the markers on that word. Of |
- // course, if current selection is a range, we potentially will edit two words |
- // that fall on the boundaries of selection, and remove words between the |
- // selection boundaries. |
- VisiblePosition startOfSelection = |
- frame().selection().selection().visibleStart(); |
- VisiblePosition endOfSelection = frame().selection().selection().visibleEnd(); |
- if (startOfSelection.isNull()) |
- return; |
- // First word is the word that ends after or on the start of selection. |
- VisiblePosition startOfFirstWord = |
- startOfWord(startOfSelection, LeftWordIfOnBoundary); |
- VisiblePosition endOfFirstWord = |
- endOfWord(startOfSelection, LeftWordIfOnBoundary); |
- // Last word is the word that begins before or on the end of selection |
- VisiblePosition startOfLastWord = |
- startOfWord(endOfSelection, RightWordIfOnBoundary); |
- VisiblePosition endOfLastWord = |
- endOfWord(endOfSelection, RightWordIfOnBoundary); |
- |
- if (startOfFirstWord.isNull()) { |
- startOfFirstWord = startOfWord(startOfSelection, RightWordIfOnBoundary); |
- endOfFirstWord = endOfWord(startOfSelection, RightWordIfOnBoundary); |
- } |
- |
- if (endOfLastWord.isNull()) { |
- startOfLastWord = startOfWord(endOfSelection, LeftWordIfOnBoundary); |
- endOfLastWord = endOfWord(endOfSelection, LeftWordIfOnBoundary); |
- } |
- |
- // If doNotRemoveIfSelectionAtWordBoundary is true, and first word ends at the |
- // start of selection, we choose next word as the first word. |
- if (doNotRemoveIfSelectionAtWordBoundary && |
- endOfFirstWord.deepEquivalent() == startOfSelection.deepEquivalent()) { |
- startOfFirstWord = nextWordPosition(startOfFirstWord); |
- endOfFirstWord = endOfWord(startOfFirstWord, RightWordIfOnBoundary); |
- if (startOfFirstWord.deepEquivalent() == endOfSelection.deepEquivalent()) |
- return; |
- } |
- |
- // If doNotRemoveIfSelectionAtWordBoundary is true, and last word begins at |
- // the end of selection, we choose previous word as the last word. |
- if (doNotRemoveIfSelectionAtWordBoundary && |
- startOfLastWord.deepEquivalent() == endOfSelection.deepEquivalent()) { |
- startOfLastWord = previousWordPosition(startOfLastWord); |
- endOfLastWord = endOfWord(startOfLastWord, RightWordIfOnBoundary); |
- if (endOfLastWord.deepEquivalent() == startOfSelection.deepEquivalent()) |
- return; |
- } |
- |
- 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 garde", we will have CorrectionIndicator |
- // marker on both words and on the whitespace between them. If we then edit |
- // garde, we would like to remove the marker from word "avant" and whitespace |
- // as well. So we need to get the continous range of of marker that contains |
- // the word in question, and remove marker on that whole range. |
- const EphemeralRange wordRange(removeMarkerStart, removeMarkerEnd); |
- document->markers().removeMarkers( |
- wordRange, DocumentMarker::MisspellingMarkers(), |
- DocumentMarkerController::RemovePartiallyOverlappingMarker); |
+ frame().document()->markers().removeMarkersForWordsAffectedByEditing( |
+ DocumentMarker::MisspellingMarkers(), |
+ doNotRemoveIfSelectionAtWordBoundary); |
} |
void SpellChecker::didEndEditingOnTextField(Element* e) { |