OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 void SpellChecker::ignoreSpelling() | 154 void SpellChecker::ignoreSpelling() |
155 { | 155 { |
156 removeMarkers(frame().selection().selection(), DocumentMarker::Spelling); | 156 removeMarkers(frame().selection().selection(), DocumentMarker::Spelling); |
157 } | 157 } |
158 | 158 |
159 void SpellChecker::advanceToNextMisspelling(bool startBeforeSelection) | 159 void SpellChecker::advanceToNextMisspelling(bool startBeforeSelection) |
160 { | 160 { |
| 161 DocumentLifecycle::DisallowTransitionScope(frame().document()->lifecycle()); |
| 162 |
161 // The basic approach is to search in two phases - from the selection end to
the end of the doc, and | 163 // The basic approach is to search in two phases - from the selection end to
the end of the doc, and |
162 // then we wrap and search from the doc start to (approximately) where we st
arted. | 164 // then we wrap and search from the doc start to (approximately) where we st
arted. |
163 | 165 |
164 // Start at the end of the selection, search to edge of document. Starting a
t the selection end makes | 166 // Start at the end of the selection, search to edge of document. Starting a
t the selection end makes |
165 // repeated "check spelling" commands work. | 167 // repeated "check spelling" commands work. |
166 VisibleSelection selection(frame().selection().selection()); | 168 VisibleSelection selection(frame().selection().selection()); |
167 Position spellingSearchStart, spellingSearchEnd; | 169 Position spellingSearchStart, spellingSearchEnd; |
168 Range::selectNodeContents(frame().document(), spellingSearchStart, spellingS
earchEnd); | 170 Range::selectNodeContents(frame().document(), spellingSearchStart, spellingS
earchEnd); |
169 | 171 |
170 bool startedWithSelection = false; | 172 bool startedWithSelection = false; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 // panel, and store a marker so we draw the green squiggle later. | 299 // panel, and store a marker so we draw the green squiggle later. |
298 | 300 |
299 DCHECK_GT(badGrammarPhrase.length(), 0u); | 301 DCHECK_GT(badGrammarPhrase.length(), 0u); |
300 DCHECK_NE(grammarDetail.location, -1); | 302 DCHECK_NE(grammarDetail.location, -1); |
301 DCHECK_GT(grammarDetail.length, 0); | 303 DCHECK_GT(grammarDetail.length, 0); |
302 | 304 |
303 // FIXME 4859190: This gets confused with doubled punctuation at the end
of a paragraph | 305 // FIXME 4859190: This gets confused with doubled punctuation at the end
of a paragraph |
304 const EphemeralRange badGrammarRange = calculateCharacterSubrange(Epheme
ralRange(grammarSearchStart, grammarSearchEnd), grammarPhraseOffset + grammarDet
ail.location, grammarDetail.length); | 306 const EphemeralRange badGrammarRange = calculateCharacterSubrange(Epheme
ralRange(grammarSearchStart, grammarSearchEnd), grammarPhraseOffset + grammarDet
ail.location, grammarDetail.length); |
305 frame().selection().setSelection(VisibleSelection(badGrammarRange)); | 307 frame().selection().setSelection(VisibleSelection(badGrammarRange)); |
306 frame().selection().revealSelection(); | 308 frame().selection().revealSelection(); |
307 | |
308 frame().document()->markers().addMarker(badGrammarRange.startPosition(),
badGrammarRange.endPosition(), DocumentMarker::Grammar, grammarDetail.userDescr
iption); | 309 frame().document()->markers().addMarker(badGrammarRange.startPosition(),
badGrammarRange.endPosition(), DocumentMarker::Grammar, grammarDetail.userDescr
iption); |
309 } else if (!misspelledWord.isEmpty()) { | 310 } else if (!misspelledWord.isEmpty()) { |
310 // We found a misspelling, but not any earlier bad grammar. Select the m
isspelling, update the spelling panel, and store | 311 // We found a misspelling, but not any earlier bad grammar. Select the m
isspelling, update the spelling panel, and store |
311 // a marker so we draw the red squiggle later. | 312 // a marker so we draw the red squiggle later. |
312 | 313 |
313 const EphemeralRange misspellingRange = calculateCharacterSubrange(Ephem
eralRange(spellingSearchStart, spellingSearchEnd), misspellingOffset, misspelled
Word.length()); | 314 const EphemeralRange misspellingRange = calculateCharacterSubrange(Ephem
eralRange(spellingSearchStart, spellingSearchEnd), misspellingOffset, misspelled
Word.length()); |
314 frame().selection().setSelection(VisibleSelection(misspellingRange)); | 315 frame().selection().setSelection(VisibleSelection(misspellingRange)); |
315 frame().selection().revealSelection(); | 316 frame().selection().revealSelection(); |
316 | |
317 spellCheckerClient().updateSpellingUIWithMisspelledWord(misspelledWord); | 317 spellCheckerClient().updateSpellingUIWithMisspelledWord(misspelledWord); |
318 frame().document()->markers().addMarker(misspellingRange.startPosition()
, misspellingRange.endPosition(), DocumentMarker::Spelling); | 318 frame().document()->markers().addMarker(misspellingRange.startPosition()
, misspellingRange.endPosition(), DocumentMarker::Spelling); |
319 } | 319 } |
320 } | 320 } |
321 | 321 |
322 void SpellChecker::showSpellingGuessPanel() | 322 void SpellChecker::showSpellingGuessPanel() |
323 { | 323 { |
324 if (spellCheckerClient().spellingUIIsShowing()) { | 324 if (spellCheckerClient().spellingUIIsShowing()) { |
325 spellCheckerClient().showSpellingUI(false); | 325 spellCheckerClient().showSpellingUI(false); |
326 return; | 326 return; |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 frame().document()->markers().addMarker(badGrammarRange.
startPosition(), badGrammarRange.endPosition(), DocumentMarker::Grammar, detail-
>userDescription, result->hash); | 640 frame().document()->markers().addMarker(badGrammarRange.
startPosition(), badGrammarRange.endPosition(), DocumentMarker::Grammar, detail-
>userDescription, result->hash); |
641 } | 641 } |
642 } | 642 } |
643 } else if (result->decoration == TextDecorationTypeInvisibleSpellche
ck && resultLocation >= paragraph.checkingStart() && resultLocation + resultLeng
th <= spellingRangeEndOffset) { | 643 } else if (result->decoration == TextDecorationTypeInvisibleSpellche
ck && resultLocation >= paragraph.checkingStart() && resultLocation + resultLeng
th <= spellingRangeEndOffset) { |
644 DCHECK_GT(resultLength, 0); | 644 DCHECK_GT(resultLength, 0); |
645 DCHECK_GE(resultLocation, 0); | 645 DCHECK_GE(resultLocation, 0); |
646 const EphemeralRange invisibleSpellcheckRange = calculateCharact
erSubrange(paragraph.paragraphRange(), resultLocation, resultLength); | 646 const EphemeralRange invisibleSpellcheckRange = calculateCharact
erSubrange(paragraph.paragraphRange(), resultLocation, resultLength); |
647 frame().document()->markers().addMarker(invisibleSpellcheckRange
.startPosition(), invisibleSpellcheckRange.endPosition(), DocumentMarker::Invisi
bleSpellcheck, result->replacement, result->hash); | 647 frame().document()->markers().addMarker(invisibleSpellcheckRange
.startPosition(), invisibleSpellcheckRange.endPosition(), DocumentMarker::Invisi
bleSpellcheck, result->replacement, result->hash); |
648 } | 648 } |
649 } | 649 } |
650 | |
651 } | 650 } |
652 | 651 |
653 if (selectionChanged) { | 652 if (selectionChanged) { |
654 TextCheckingParagraph extendedParagraph(paragraph); | 653 TextCheckingParagraph extendedParagraph(paragraph); |
655 // Restore the caret position if we have made any replacements | 654 // Restore the caret position if we have made any replacements |
656 extendedParagraph.expandRangeToNextEnd(); | 655 extendedParagraph.expandRangeToNextEnd(); |
657 if (restoreSelectionAfterChange && selectionOffset >= 0 && selectionOffs
et <= extendedParagraph.rangeLength()) { | 656 if (restoreSelectionAfterChange && selectionOffset >= 0 && selectionOffs
et <= extendedParagraph.rangeLength()) { |
658 EphemeralRange selectionRange = extendedParagraph.subrange(0, select
ionOffset); | 657 EphemeralRange selectionRange = extendedParagraph.subrange(0, select
ionOffset); |
659 frame().selection().moveTo(selectionRange.endPosition(), TextAffinit
y::Downstream); | 658 frame().selection().moveTo(selectionRange.endPosition(), TextAffinit
y::Downstream); |
660 if (adjustSelectionForParagraphBoundaries) | 659 if (adjustSelectionForParagraphBoundaries) |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 visitor->trace(m_frame); | 978 visitor->trace(m_frame); |
980 visitor->trace(m_spellCheckRequester); | 979 visitor->trace(m_spellCheckRequester); |
981 } | 980 } |
982 | 981 |
983 void SpellChecker::prepareForLeakDetection() | 982 void SpellChecker::prepareForLeakDetection() |
984 { | 983 { |
985 m_spellCheckRequester->prepareForLeakDetection(); | 984 m_spellCheckRequester->prepareForLeakDetection(); |
986 } | 985 } |
987 | 986 |
988 } // namespace blink | 987 } // namespace blink |
OLD | NEW |