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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 m_frame.document()->markers().removeMarkers(selectedRange.get(), Documen
tMarker::MisspellingMarkers()); | 324 m_frame.document()->markers().removeMarkers(selectedRange.get(), Documen
tMarker::MisspellingMarkers()); |
325 } | 325 } |
326 | 326 |
327 void SpellChecker::markMisspellingsAndBadGrammar(const VisibleSelection &movingS
election) | 327 void SpellChecker::markMisspellingsAndBadGrammar(const VisibleSelection &movingS
election) |
328 { | 328 { |
329 markMisspellingsAndBadGrammar(movingSelection, isContinuousSpellCheckingEnab
led() && isGrammarCheckingEnabled(), movingSelection); | 329 markMisspellingsAndBadGrammar(movingSelection, isContinuousSpellCheckingEnab
led() && isGrammarCheckingEnabled(), movingSelection); |
330 } | 330 } |
331 | 331 |
332 void SpellChecker::markMisspellingsAfterTypingToWord(const VisiblePosition &word
Start, const VisibleSelection& selectionAfterTyping) | 332 void SpellChecker::markMisspellingsAfterTypingToWord(const VisiblePosition &word
Start, const VisibleSelection& selectionAfterTyping) |
333 { | 333 { |
| 334 TempRangeScope scope; |
334 if (unifiedTextCheckerEnabled()) { | 335 if (unifiedTextCheckerEnabled()) { |
335 TextCheckingTypeMask textCheckingOptions = 0; | 336 TextCheckingTypeMask textCheckingOptions = 0; |
336 | 337 |
337 if (isContinuousSpellCheckingEnabled()) | 338 if (isContinuousSpellCheckingEnabled()) |
338 textCheckingOptions |= TextCheckingTypeSpelling; | 339 textCheckingOptions |= TextCheckingTypeSpelling; |
339 | 340 |
340 if (!(textCheckingOptions & TextCheckingTypeSpelling)) | 341 if (!(textCheckingOptions & TextCheckingTypeSpelling)) |
341 return; | 342 return; |
342 | 343 |
343 if (isGrammarCheckingEnabled()) | 344 if (isGrammarCheckingEnabled()) |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 // If this is a change in selection resulting from a delete operation, | 735 // If this is a change in selection resulting from a delete operation, |
735 // oldSelection may no longer be in the document. | 736 // oldSelection may no longer be in the document. |
736 if (shouldCheckSpellingAndGrammar | 737 if (shouldCheckSpellingAndGrammar |
737 && closeTyping | 738 && closeTyping |
738 && oldSelection.isContentEditable() | 739 && oldSelection.isContentEditable() |
739 && oldSelection.start().inDocument() | 740 && oldSelection.start().inDocument() |
740 && !isSelectionInTextField(oldSelection)) { | 741 && !isSelectionInTextField(oldSelection)) { |
741 spellCheckOldSelection(oldSelection, newAdjacentWords, newSelectedSe
ntence); | 742 spellCheckOldSelection(oldSelection, newAdjacentWords, newSelectedSe
ntence); |
742 } | 743 } |
743 | 744 |
| 745 |
744 if (textChecker().shouldEraseMarkersAfterChangeSelection(TextCheckingTyp
eSpelling)) { | 746 if (textChecker().shouldEraseMarkersAfterChangeSelection(TextCheckingTyp
eSpelling)) { |
| 747 TempRangeScope scope; |
745 if (RefPtrWillBeRawPtr<Range> wordRange = newAdjacentWords.toNormali
zedRange()) | 748 if (RefPtrWillBeRawPtr<Range> wordRange = newAdjacentWords.toNormali
zedRange()) |
746 m_frame.document()->markers().removeMarkers(wordRange.get(), Doc
umentMarker::Spelling); | 749 m_frame.document()->markers().removeMarkers(wordRange.get(), Doc
umentMarker::Spelling); |
747 } | 750 } |
748 if (textChecker().shouldEraseMarkersAfterChangeSelection(TextCheckingTyp
eGrammar)) { | 751 if (textChecker().shouldEraseMarkersAfterChangeSelection(TextCheckingTyp
eGrammar)) { |
| 752 TempRangeScope scope; |
749 if (RefPtrWillBeRawPtr<Range> sentenceRange = newSelectedSentence.to
NormalizedRange()) | 753 if (RefPtrWillBeRawPtr<Range> sentenceRange = newSelectedSentence.to
NormalizedRange()) |
750 m_frame.document()->markers().removeMarkers(sentenceRange.get(),
DocumentMarker::Grammar); | 754 m_frame.document()->markers().removeMarkers(sentenceRange.get(),
DocumentMarker::Grammar); |
751 } | 755 } |
752 } | 756 } |
753 | 757 |
754 // When continuous spell checking is off, existing markers disappear after t
he selection changes. | 758 // When continuous spell checking is off, existing markers disappear after t
he selection changes. |
755 if (!isContinuousSpellCheckingEnabled) | 759 if (!isContinuousSpellCheckingEnabled) |
756 m_frame.document()->markers().removeMarkers(DocumentMarker::Spelling); | 760 m_frame.document()->markers().removeMarkers(DocumentMarker::Spelling); |
757 if (!isContinuousGrammarCheckingEnabled) | 761 if (!isContinuousGrammarCheckingEnabled) |
758 m_frame.document()->markers().removeMarkers(DocumentMarker::Grammar); | 762 m_frame.document()->markers().removeMarkers(DocumentMarker::Grammar); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 } | 851 } |
848 | 852 |
849 void SpellChecker::requestTextChecking(const Element& element) | 853 void SpellChecker::requestTextChecking(const Element& element) |
850 { | 854 { |
851 RefPtrWillBeRawPtr<Range> rangeToCheck = rangeOfContents(const_cast<Element*
>(&element)); | 855 RefPtrWillBeRawPtr<Range> rangeToCheck = rangeOfContents(const_cast<Element*
>(&element)); |
852 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec
kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe
ck, rangeToCheck)); | 856 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec
kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe
ck, rangeToCheck)); |
853 } | 857 } |
854 | 858 |
855 | 859 |
856 } // namespace WebCore | 860 } // namespace WebCore |
OLD | NEW |