| 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 3304bc2ec3a618393ffdfdf2c8a45af619a35f69..32854e4b03abc65190d17347c1cc930e1f95868d 100644
|
| --- a/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
|
| +++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellChecker.cpp
|
| @@ -226,89 +226,30 @@ void SpellChecker::advanceToNextMisspelling(bool startBeforeSelection)
|
| int searchEndOffsetAfterWrap = spellingSearchEnd.offsetInContainerNode();
|
|
|
| int misspellingOffset = 0;
|
| - GrammarDetail grammarDetail;
|
| - int grammarPhraseOffset = 0;
|
| - Position grammarSearchStart, grammarSearchEnd;
|
| - String badGrammarPhrase;
|
| String misspelledWord;
|
|
|
| - bool isSpelling = true;
|
| - int foundOffset = 0;
|
| - String foundItem;
|
| if (unifiedTextCheckerEnabled()) {
|
| - grammarSearchStart = spellingSearchStart;
|
| - grammarSearchEnd = spellingSearchEnd;
|
| - foundItem = TextCheckingHelper(spellCheckerClient(), spellingSearchStart, spellingSearchEnd).findFirstMisspellingOrBadGrammar(isSpelling, foundOffset, grammarDetail);
|
| - if (isSpelling) {
|
| - misspelledWord = foundItem;
|
| - misspellingOffset = foundOffset;
|
| - } else {
|
| - badGrammarPhrase = foundItem;
|
| - grammarPhraseOffset = foundOffset;
|
| - }
|
| + misspelledWord = TextCheckingHelper(spellCheckerClient(), spellingSearchStart, spellingSearchEnd).findFirstMisspellingOrBadGrammar(misspellingOffset);
|
| } else {
|
| misspelledWord = TextCheckingHelper(spellCheckerClient(), spellingSearchStart, spellingSearchEnd).findFirstMisspelling(misspellingOffset, false);
|
| - grammarSearchStart = spellingSearchStart;
|
| - grammarSearchEnd = spellingSearchEnd;
|
| - if (!misspelledWord.isEmpty()) {
|
| - // Stop looking at start of next misspelled word
|
| - CharacterIterator chars(grammarSearchStart, grammarSearchEnd);
|
| - chars.advance(misspellingOffset);
|
| - grammarSearchEnd = chars.startPosition();
|
| - }
|
| -
|
| - badGrammarPhrase = TextCheckingHelper(spellCheckerClient(), grammarSearchStart, grammarSearchEnd).findFirstBadGrammar(grammarDetail, grammarPhraseOffset, false);
|
| }
|
|
|
| - // If we found neither bad grammar nor a misspelled word, wrap and try again (but don't bother if we started at the beginning of the
|
| + // If we did not find a misspelled word, wrap and try again (but don't bother if we started at the beginning of the
|
| // block rather than at a selection).
|
| - if (startedWithSelection && !misspelledWord && !badGrammarPhrase) {
|
| + if (startedWithSelection && !misspelledWord) {
|
| spellingSearchStart = Position::editingPositionOf(topNode, 0);
|
| // going until the end of the very first chunk we tested is far enough
|
| spellingSearchEnd = Position::editingPositionOf(searchEndNodeAfterWrap, searchEndOffsetAfterWrap);
|
|
|
| if (unifiedTextCheckerEnabled()) {
|
| - grammarSearchStart = spellingSearchStart;
|
| - grammarSearchEnd = spellingSearchEnd;
|
| - foundItem = TextCheckingHelper(spellCheckerClient(), spellingSearchStart, spellingSearchEnd).findFirstMisspellingOrBadGrammar(isSpelling, foundOffset, grammarDetail);
|
| - if (isSpelling) {
|
| - misspelledWord = foundItem;
|
| - misspellingOffset = foundOffset;
|
| - } else {
|
| - badGrammarPhrase = foundItem;
|
| - grammarPhraseOffset = foundOffset;
|
| - }
|
| + misspelledWord = TextCheckingHelper(spellCheckerClient(), spellingSearchStart, spellingSearchEnd).findFirstMisspellingOrBadGrammar(misspellingOffset);
|
| } else {
|
| misspelledWord = TextCheckingHelper(spellCheckerClient(), spellingSearchStart, spellingSearchEnd).findFirstMisspelling(misspellingOffset, false);
|
| - grammarSearchStart = spellingSearchStart;
|
| - grammarSearchEnd = spellingSearchEnd;
|
| - if (!misspelledWord.isEmpty()) {
|
| - // Stop looking at start of next misspelled word
|
| - CharacterIterator chars(grammarSearchStart, grammarSearchEnd);
|
| - chars.advance(misspellingOffset);
|
| - grammarSearchEnd = chars.startPosition();
|
| - }
|
| -
|
| - badGrammarPhrase = TextCheckingHelper(spellCheckerClient(), grammarSearchStart, grammarSearchEnd).findFirstBadGrammar(grammarDetail, grammarPhraseOffset, false);
|
| }
|
| }
|
|
|
| - if (!badGrammarPhrase.isEmpty()) {
|
| - // We found bad grammar. Since we only searched for bad grammar up to the first misspelled word, the bad grammar
|
| - // takes precedence and we ignore any potential misspelled word. Select the grammar detail, update the spelling
|
| - // panel, and store a marker so we draw the green squiggle later.
|
| -
|
| - DCHECK_GT(badGrammarPhrase.length(), 0u);
|
| - DCHECK_NE(grammarDetail.location, -1);
|
| - DCHECK_GT(grammarDetail.length, 0);
|
| -
|
| - // FIXME 4859190: This gets confused with doubled punctuation at the end of a paragraph
|
| - const EphemeralRange badGrammarRange = calculateCharacterSubrange(EphemeralRange(grammarSearchStart, grammarSearchEnd), grammarPhraseOffset + grammarDetail.location, grammarDetail.length);
|
| - frame().selection().setSelection(VisibleSelection(badGrammarRange));
|
| - frame().selection().revealSelection();
|
| - frame().document()->markers().addMarker(badGrammarRange.startPosition(), badGrammarRange.endPosition(), DocumentMarker::Grammar, grammarDetail.userDescription);
|
| - } else if (!misspelledWord.isEmpty()) {
|
| - // We found a misspelling, but not any earlier bad grammar. Select the misspelling, update the spelling panel, and store
|
| + if (!misspelledWord.isEmpty()) {
|
| + // We found a misspelling. Select the misspelling, update the spelling panel, and store
|
| // a marker so we draw the red squiggle later.
|
|
|
| const EphemeralRange misspellingRange = calculateCharacterSubrange(EphemeralRange(spellingSearchStart, spellingSearchEnd), misspellingOffset, misspelledWord.length());
|
| @@ -411,7 +352,6 @@ bool SpellChecker::markMisspellingsOrBadGrammar(const VisibleSelection& selectio
|
| if (checkSpelling)
|
| return checker.markAllMisspellings();
|
|
|
| - checker.markAllBadGrammar();
|
| return false;
|
| }
|
|
|
|
|