OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 11 matching lines...) Expand all Loading... | |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #ifndef SpellChecker_h | 26 #ifndef SpellChecker_h |
27 #define SpellChecker_h | 27 #define SpellChecker_h |
28 | 28 |
29 #include "core/dom/DocumentMarker.h" | 29 #include "core/dom/DocumentMarker.h" |
30 #include "core/editing/FrameSelection.h" | 30 #include "core/editing/FrameSelection.h" |
31 #include "core/editing/VisibleSelection.h" | 31 #include "core/editing/VisibleSelection.h" |
32 #include "platform/heap/Handle.h" | |
32 #include "platform/text/TextChecking.h" | 33 #include "platform/text/TextChecking.h" |
33 | 34 |
34 namespace blink { | 35 namespace blink { |
35 | 36 |
36 class LocalFrame; | 37 class LocalFrame; |
37 class SpellCheckerClient; | 38 class SpellCheckerClient; |
38 class SpellCheckRequest; | 39 class SpellCheckRequest; |
39 class SpellCheckRequester; | 40 class SpellCheckRequester; |
40 class TextCheckerClient; | 41 class TextCheckerClient; |
41 class TextCheckingParagraph; | 42 class TextCheckingParagraph; |
42 struct TextCheckingResult; | 43 struct TextCheckingResult; |
43 | 44 |
44 class SpellChecker { | 45 class SpellChecker FINAL : public NoBaseWillBeGarbageCollectedFinalized<SpellChe cker> { |
45 WTF_MAKE_NONCOPYABLE(SpellChecker); | 46 WTF_MAKE_NONCOPYABLE(SpellChecker); |
46 public: | 47 public: |
47 static PassOwnPtr<SpellChecker> create(LocalFrame&); | 48 static PassOwnPtrWillBeRawPtr<SpellChecker> create(LocalFrame&); |
48 | 49 |
49 ~SpellChecker(); | 50 ~SpellChecker(); |
51 void trace(Visitor*); | |
50 | 52 |
51 SpellCheckerClient& spellCheckerClient() const; | 53 SpellCheckerClient& spellCheckerClient() const; |
52 TextCheckerClient& textChecker() const; | 54 TextCheckerClient& textChecker() const; |
53 | 55 |
54 bool isContinuousSpellCheckingEnabled() const; | 56 bool isContinuousSpellCheckingEnabled() const; |
55 void toggleContinuousSpellChecking(); | 57 void toggleContinuousSpellChecking(); |
56 bool isGrammarCheckingEnabled(); | 58 bool isGrammarCheckingEnabled(); |
57 void ignoreSpelling(); | 59 void ignoreSpelling(); |
58 bool isSpellCheckingEnabledInFocusedNode() const; | 60 bool isSpellCheckingEnabledInFocusedNode() const; |
59 bool isSpellCheckingEnabledFor(Node*) const; | 61 bool isSpellCheckingEnabledFor(Node*) const; |
60 void markMisspellingsAfterLineBreak(const VisibleSelection& wordSelection); | 62 void markMisspellingsAfterLineBreak(const VisibleSelection& wordSelection); |
61 void markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart, con st VisibleSelection& selectionAfterTyping); | 63 void markMisspellingsAfterTypingToWord(const VisiblePosition &wordStart, con st VisibleSelection& selectionAfterTyping); |
62 void markMisspellings(const VisibleSelection&, RefPtrWillBeRawPtr<Range>& fi rstMisspellingRange); | 64 void markMisspellings(const VisibleSelection&, RefPtrWillBeRawPtr<Range>& fi rstMisspellingRange); |
63 void markBadGrammar(const VisibleSelection&); | 65 void markBadGrammar(const VisibleSelection&); |
64 void markMisspellingsAndBadGrammar(const VisibleSelection& spellingSelection , bool markGrammar, const VisibleSelection& grammarSelection); | 66 void markMisspellingsAndBadGrammar(const VisibleSelection& spellingSelection , bool markGrammar, const VisibleSelection& grammarSelection); |
65 void markAndReplaceFor(PassRefPtr<SpellCheckRequest>, const Vector<TextCheck ingResult>&); | 67 void markAndReplaceFor(PassRefPtrWillBeRawPtr<SpellCheckRequest>, const Vect or<TextCheckingResult>&); |
66 void markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask, Range* s pellingRange, Range* grammarRange); | 68 void markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask, Range* s pellingRange, Range* grammarRange); |
67 void advanceToNextMisspelling(bool startBeforeSelection = false); | 69 void advanceToNextMisspelling(bool startBeforeSelection = false); |
68 void showSpellingGuessPanel(); | 70 void showSpellingGuessPanel(); |
69 void didBeginEditing(Element*); | 71 void didBeginEditing(Element*); |
70 void clearMisspellingsAndBadGrammar(const VisibleSelection&); | 72 void clearMisspellingsAndBadGrammar(const VisibleSelection&); |
71 void markMisspellingsAndBadGrammar(const VisibleSelection&); | 73 void markMisspellingsAndBadGrammar(const VisibleSelection&); |
72 void respondToChangedSelection(const VisibleSelection& oldSelection, FrameSe lection::SetSelectionOptions); | 74 void respondToChangedSelection(const VisibleSelection& oldSelection, FrameSe lection::SetSelectionOptions); |
73 void replaceMisspelledRange(const String&); | 75 void replaceMisspelledRange(const String&); |
74 void removeSpellingMarkers(); | 76 void removeSpellingMarkers(); |
75 void removeSpellingMarkersUnderWords(const Vector<String>& words); | 77 void removeSpellingMarkersUnderWords(const Vector<String>& words); |
76 void spellCheckAfterBlur(); | 78 void spellCheckAfterBlur(); |
77 void spellCheckOldSelection(const VisibleSelection& oldSelection, const Visi bleSelection& newAdjacentWords); | 79 void spellCheckOldSelection(const VisibleSelection& oldSelection, const Visi bleSelection& newAdjacentWords); |
78 | 80 |
79 void didEndEditingOnTextField(Element*); | 81 void didEndEditingOnTextField(Element*); |
80 bool selectionStartHasMarkerFor(DocumentMarker::MarkerType, int from, int le ngth) const; | 82 bool selectionStartHasMarkerFor(DocumentMarker::MarkerType, int from, int le ngth) const; |
81 bool selectionStartHasSpellingMarkerFor(int from, int length) const; | 83 bool selectionStartHasSpellingMarkerFor(int from, int length) const; |
82 void updateMarkersForWordsAffectedByEditing(bool onlyHandleWordsContainingSe lection); | 84 void updateMarkersForWordsAffectedByEditing(bool onlyHandleWordsContainingSe lection); |
83 void cancelCheck(); | 85 void cancelCheck(); |
84 void chunkAndMarkAllMisspellingsAndBadGrammar(Node*); | 86 void chunkAndMarkAllMisspellingsAndBadGrammar(Node*); |
85 void requestTextChecking(const Element&); | 87 void requestTextChecking(const Element&); |
86 | 88 |
87 // Exposed for testing only | 89 // Exposed for testing only |
88 SpellCheckRequester& spellCheckRequester() const { return *m_spellCheckReque ster; } | 90 SpellCheckRequester& spellCheckRequester() const { return *m_spellCheckReque ster; } |
89 | 91 |
90 private: | 92 private: |
91 LocalFrame& m_frame; | 93 explicit SpellChecker(LocalFrame&); |
92 const OwnPtr<SpellCheckRequester> m_spellCheckRequester; | |
93 | 94 |
94 explicit SpellChecker(LocalFrame&); | 95 LocalFrame& frame() const { return *m_frame; } |
haraken
2014/09/22 05:35:22
Add ASSERT(m_frame).
| |
95 | 96 |
96 void markMisspellingsOrBadGrammar(const VisibleSelection&, bool checkSpellin g, RefPtrWillBeRawPtr<Range>& firstMisspellingRange); | 97 void markMisspellingsOrBadGrammar(const VisibleSelection&, bool checkSpellin g, RefPtrWillBeRawPtr<Range>& firstMisspellingRange); |
97 TextCheckingTypeMask resolveTextCheckingTypeMask(TextCheckingTypeMask); | 98 TextCheckingTypeMask resolveTextCheckingTypeMask(TextCheckingTypeMask); |
98 | 99 |
99 bool unifiedTextCheckerEnabled() const; | 100 bool unifiedTextCheckerEnabled() const; |
100 | 101 |
101 void chunkAndMarkAllMisspellingsAndBadGrammar(TextCheckingTypeMask textCheck ingOptions, const TextCheckingParagraph& fullParagraphToCheck, bool asynchronous ); | 102 void chunkAndMarkAllMisspellingsAndBadGrammar(TextCheckingTypeMask textCheck ingOptions, const TextCheckingParagraph& fullParagraphToCheck, bool asynchronous ); |
102 void markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textCheck ingOptions, Range* checkingRange, Range* paragraphRange, bool asynchronous, int requestNumber, int* checkingLength = 0); | 103 void markAllMisspellingsAndBadGrammarInRanges(TextCheckingTypeMask textCheck ingOptions, Range* checkingRange, Range* paragraphRange, bool asynchronous, int requestNumber, int* checkingLength = 0); |
104 | |
105 RawPtrWillBeMember<LocalFrame> m_frame; | |
106 const OwnPtrWillBeMember<SpellCheckRequester> m_spellCheckRequester; | |
103 }; | 107 }; |
104 | 108 |
105 } // namespace blink | 109 } // namespace blink |
106 | 110 |
107 #endif // SpellChecker_h | 111 #endif // SpellChecker_h |
OLD | NEW |