blob: 69e28378153477ae44bc720ebb299b0ea0857f3b [file] [log] [blame]
andersca@apple.com36f2f522010-12-21 00:35:16 +00001/*
2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#ifndef TextChecker_h
27#define TextChecker_h
28
andersca@apple.com33241f72011-01-05 02:13:12 +000029#include <WebCore/EditorClient.h>
morrita@google.com7692b422011-02-15 08:28:20 +000030#include <WebCore/TextCheckerClient.h>
andersca@apple.com33241f72011-01-05 02:13:12 +000031
andersca@apple.com36f2f522010-12-21 00:35:16 +000032namespace WebKit {
33
jberlin@webkit.orgc008ff72011-04-11 18:00:07 +000034class WebPageProxy;
mrowe@apple.comd82db122011-01-22 01:46:39 +000035struct TextCheckerState;
andersca@apple.com190ba932011-01-04 22:41:52 +000036
andersca@apple.com36f2f522010-12-21 00:35:16 +000037class TextChecker {
38public:
andersca@apple.com190ba932011-01-04 22:41:52 +000039 static const TextCheckerState& state();
andersca@apple.com36f2f522010-12-21 00:35:16 +000040 static bool isContinuousSpellCheckingAllowed();
andersca@apple.com36f2f522010-12-21 00:35:16 +000041
andersca@apple.com190ba932011-01-04 22:41:52 +000042 static void setContinuousSpellCheckingEnabled(bool);
andersca@apple.com36f2f522010-12-21 00:35:16 +000043 static void setGrammarCheckingEnabled(bool);
andersca@apple.come95efb12011-01-04 19:49:18 +000044
andersca@apple.com190ba932011-01-04 22:41:52 +000045#if PLATFORM(MAC)
andersca@apple.come95efb12011-01-04 19:49:18 +000046 static void setAutomaticSpellingCorrectionEnabled(bool);
andersca@apple.com95dcf972011-01-05 18:28:29 +000047 static void setAutomaticQuoteSubstitutionEnabled(bool);
48 static void setAutomaticDashSubstitutionEnabled(bool);
49 static void setAutomaticLinkDetectionEnabled(bool);
50 static void setAutomaticTextReplacementEnabled(bool);
andersca@apple.com2fa2dba2011-01-05 21:22:04 +000051
52 static bool isSmartInsertDeleteEnabled();
53 static void setSmartInsertDeleteEnabled(bool);
jberlin@webkit.org4c2c8262011-04-09 01:31:30 +000054
55 static bool substitutionsPanelIsShowing();
56 static void toggleSubstitutionsPanelIsShowing();
jberlin@webkit.orgad3993612011-04-06 15:15:36 +000057#elif PLATFORM(WIN)
58 static void continuousSpellCheckingEnabledStateChanged(bool);
59 static void grammarCheckingEnabledStateChanged(bool);
andersca@apple.com190ba932011-01-04 22:41:52 +000060#endif
andersca@apple.com33241f72011-01-05 02:13:12 +000061
jberlin@webkit.orgc008ff72011-04-11 18:00:07 +000062 static int64_t uniqueSpellDocumentTag(WebPageProxy*);
andersca@apple.com33241f72011-01-05 02:13:12 +000063 static void closeSpellDocumentWithTag(int64_t);
jberlin@webkit.orgf0cc7d02011-04-07 18:01:19 +000064#if USE(UNIFIED_TEXT_CHECKING)
andersca@apple.com33241f72011-01-05 02:13:12 +000065 static Vector<WebCore::TextCheckingResult> checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes);
jberlin@webkit.orgf0cc7d02011-04-07 18:01:19 +000066#endif
67 static void checkSpellingOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, int32_t& misspellingLocation, int32_t& misspellingLength);
jberlin@webkit.org756e20b2011-04-08 00:38:20 +000068 static void checkGrammarOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& badGrammarLength);
jberlin@webkit.org53b56062011-04-09 00:18:01 +000069 static bool spellingUIIsShowing();
70 static void toggleSpellingUIIsShowing();
jberlin@webkit.orgc008ff72011-04-11 18:00:07 +000071 static void updateSpellingUIWithMisspelledWord(int64_t spellDocumentTag, const String& misspelledWord);
72 static void updateSpellingUIWithGrammarString(int64_t spellDocumentTag, const String& badGrammarPhrase, const WebCore::GrammarDetail&);
andersca@apple.com33241f72011-01-05 02:13:12 +000073 static void getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses);
jberlin@webkit.org5daca922011-04-11 21:19:22 +000074 static void learnWord(int64_t spellDocumentTag, const String& word);
andersca@apple.com047c4002011-01-05 19:41:03 +000075 static void ignoreWord(int64_t spellDocumentTag, const String& word);
andersca@apple.com36f2f522010-12-21 00:35:16 +000076};
77
78} // namespace WebKit
79
80#endif // TextChecker_h