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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 bool shouldCheckSpellingAndGrammar = !(options & FrameSelection::SpellCo
rrectionTriggered); | 746 bool shouldCheckSpellingAndGrammar = !(options & FrameSelection::SpellCo
rrectionTriggered); |
747 | 747 |
748 // When typing we check spelling elsewhere, so don't redo it here. | 748 // When typing we check spelling elsewhere, so don't redo it here. |
749 // If this is a change in selection resulting from a delete operation, | 749 // If this is a change in selection resulting from a delete operation, |
750 // oldSelection may no longer be in the document. | 750 // oldSelection may no longer be in the document. |
751 if (shouldCheckSpellingAndGrammar | 751 if (shouldCheckSpellingAndGrammar |
752 && closeTyping | 752 && closeTyping |
753 && oldSelection.isContentEditable() | 753 && oldSelection.isContentEditable() |
754 && oldSelection.start().inDocument() | 754 && oldSelection.start().inDocument() |
755 && !isSelectionInTextField(oldSelection)) { | 755 && !isSelectionInTextField(oldSelection)) { |
756 spellCheckOldSelection(oldSelection, newAdjacentWords, newSelectedSe
ntence); | 756 spellCheckOldSelection(oldSelection, newAdjacentWords); |
757 } | 757 } |
758 | 758 |
759 if (textChecker().shouldEraseMarkersAfterChangeSelection(TextCheckingTyp
eSpelling)) { | 759 if (textChecker().shouldEraseMarkersAfterChangeSelection(TextCheckingTyp
eSpelling)) { |
760 if (RefPtrWillBeRawPtr<Range> wordRange = newAdjacentWords.toNormali
zedRange()) | 760 if (RefPtrWillBeRawPtr<Range> wordRange = newAdjacentWords.toNormali
zedRange()) |
761 m_frame.document()->markers().removeMarkers(wordRange.get(), Doc
umentMarker::Spelling); | 761 m_frame.document()->markers().removeMarkers(wordRange.get(), Doc
umentMarker::Spelling); |
762 } | 762 } |
763 if (textChecker().shouldEraseMarkersAfterChangeSelection(TextCheckingTyp
eGrammar)) { | 763 if (textChecker().shouldEraseMarkersAfterChangeSelection(TextCheckingTyp
eGrammar)) { |
764 if (RefPtrWillBeRawPtr<Range> sentenceRange = newSelectedSentence.to
NormalizedRange()) | 764 if (RefPtrWillBeRawPtr<Range> sentenceRange = newSelectedSentence.to
NormalizedRange()) |
765 m_frame.document()->markers().removeMarkers(sentenceRange.get(),
DocumentMarker::Grammar); | 765 m_frame.document()->markers().removeMarkers(sentenceRange.get(),
DocumentMarker::Grammar); |
766 } | 766 } |
(...skipping 15 matching lines...) Expand all Loading... |
782 { | 782 { |
783 if (!m_frame.selection().selection().isContentEditable()) | 783 if (!m_frame.selection().selection().isContentEditable()) |
784 return; | 784 return; |
785 | 785 |
786 if (isSelectionInTextField(m_frame.selection().selection())) { | 786 if (isSelectionInTextField(m_frame.selection().selection())) { |
787 // textFieldDidEndEditing() and textFieldDidBeginEditing() handle this. | 787 // textFieldDidEndEditing() and textFieldDidBeginEditing() handle this. |
788 return; | 788 return; |
789 } | 789 } |
790 | 790 |
791 VisibleSelection empty; | 791 VisibleSelection empty; |
792 spellCheckOldSelection(m_frame.selection().selection(), empty, empty); | 792 spellCheckOldSelection(m_frame.selection().selection(), empty); |
793 } | 793 } |
794 | 794 |
795 void SpellChecker::spellCheckOldSelection(const VisibleSelection& oldSelection,
const VisibleSelection& newAdjacentWords, const VisibleSelection& newSelectedSen
tence) | 795 void SpellChecker::spellCheckOldSelection(const VisibleSelection& oldSelection,
const VisibleSelection& newAdjacentWords) |
796 { | 796 { |
797 VisiblePosition oldStart(oldSelection.visibleStart()); | 797 VisiblePosition oldStart(oldSelection.visibleStart()); |
798 VisibleSelection oldAdjacentWords = VisibleSelection(startOfWord(oldStart, L
eftWordIfOnBoundary), endOfWord(oldStart, RightWordIfOnBoundary)); | 798 VisibleSelection oldAdjacentWords = VisibleSelection(startOfWord(oldStart, L
eftWordIfOnBoundary), endOfWord(oldStart, RightWordIfOnBoundary)); |
799 if (oldAdjacentWords != newAdjacentWords) { | 799 if (oldAdjacentWords != newAdjacentWords) { |
800 if (isContinuousSpellCheckingEnabled() && isGrammarCheckingEnabled()) { | 800 if (isContinuousSpellCheckingEnabled() && isGrammarCheckingEnabled()) { |
801 VisibleSelection selectedSentence = VisibleSelection(startOfSentence
(oldStart), endOfSentence(oldStart)); | 801 VisibleSelection selectedSentence = VisibleSelection(startOfSentence
(oldStart), endOfSentence(oldStart)); |
802 markMisspellingsAndBadGrammar(oldAdjacentWords, true, selectedSenten
ce); | 802 markMisspellingsAndBadGrammar(oldAdjacentWords, true, selectedSenten
ce); |
803 } else { | 803 } else { |
804 markMisspellingsAndBadGrammar(oldAdjacentWords, false, oldAdjacentWo
rds); | 804 markMisspellingsAndBadGrammar(oldAdjacentWords, false, oldAdjacentWo
rds); |
805 } | 805 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 } | 872 } |
873 | 873 |
874 void SpellChecker::requestTextChecking(const Element& element) | 874 void SpellChecker::requestTextChecking(const Element& element) |
875 { | 875 { |
876 RefPtrWillBeRawPtr<Range> rangeToCheck = rangeOfContents(const_cast<Element*
>(&element)); | 876 RefPtrWillBeRawPtr<Range> rangeToCheck = rangeOfContents(const_cast<Element*
>(&element)); |
877 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec
kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe
ck, rangeToCheck)); | 877 m_spellCheckRequester->requestCheckingFor(SpellCheckRequest::create(TextChec
kingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToChe
ck, rangeToCheck)); |
878 } | 878 } |
879 | 879 |
880 | 880 |
881 } // namespace WebCore | 881 } // namespace WebCore |
OLD | NEW |