blob: e7f3dd66cd03454364506b303a516c7706b5b59d [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
achristensen@apple.comade2d5f2017-05-09 02:22:45 +000026#pragma once
andersca@apple.com36f2f522010-12-21 00:35:16 +000027
g.czajkowski@samsung.com12f32022013-03-01 11:39:02 +000028#include "TextCheckerCompletion.h"
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);
jbedard@apple.comd44979c2016-09-22 17:39:51 +000044
45 static void setTestingMode(bool);
46 static bool isTestingMode();
andersca@apple.come95efb12011-01-04 19:49:18 +000047
mitz@apple.com1b970882014-02-15 17:06:17 +000048#if PLATFORM(COCOA)
andersca@apple.come95efb12011-01-04 19:49:18 +000049 static void setAutomaticSpellingCorrectionEnabled(bool);
andersca@apple.com95dcf972011-01-05 18:28:29 +000050 static void setAutomaticQuoteSubstitutionEnabled(bool);
51 static void setAutomaticDashSubstitutionEnabled(bool);
52 static void setAutomaticLinkDetectionEnabled(bool);
53 static void setAutomaticTextReplacementEnabled(bool);
andersca@apple.com2fa2dba2011-01-05 21:22:04 +000054
rniwa@webkit.org7c46afc2013-05-02 01:54:27 +000055 static void didChangeAutomaticTextReplacementEnabled();
56 static void didChangeAutomaticSpellingCorrectionEnabled();
57 static void didChangeAutomaticQuoteSubstitutionEnabled();
58 static void didChangeAutomaticDashSubstitutionEnabled();
59
andersca@apple.com2fa2dba2011-01-05 21:22:04 +000060 static bool isSmartInsertDeleteEnabled();
61 static void setSmartInsertDeleteEnabled(bool);
jberlin@webkit.org4c2c8262011-04-09 01:31:30 +000062
63 static bool substitutionsPanelIsShowing();
64 static void toggleSubstitutionsPanelIsShowing();
andersca@apple.com190ba932011-01-04 22:41:52 +000065#endif
andersca@apple.com33241f72011-01-05 02:13:12 +000066
mrobinson@webkit.org3c04cae2015-05-07 18:24:31 +000067#if PLATFORM(GTK)
68 static void setSpellCheckingLanguages(const Vector<String>&);
69 static Vector<String> loadedSpellCheckingLanguages();
70#endif
71
commit-queue@webkit.org35902942011-10-13 19:36:34 +000072 static void continuousSpellCheckingEnabledStateChanged(bool);
73 static void grammarCheckingEnabledStateChanged(bool);
jberlin@webkit.orgc008ff72011-04-11 18:00:07 +000074 static int64_t uniqueSpellDocumentTag(WebPageProxy*);
andersca@apple.com33241f72011-01-05 02:13:12 +000075 static void closeSpellDocumentWithTag(int64_t);
jberlin@webkit.orgf0cc7d02011-04-07 18:01:19 +000076#if USE(UNIFIED_TEXT_CHECKING)
enrica@apple.com3a51f072016-06-17 23:31:42 +000077 static Vector<WebCore::TextCheckingResult> checkTextOfParagraph(int64_t spellDocumentTag, StringView text, int32_t insertionPoint, uint64_t checkingTypes, bool initialCapitalizationEnabled);
jberlin@webkit.orgf0cc7d02011-04-07 18:01:19 +000078#endif
darin@apple.com11c80792014-03-16 06:22:02 +000079 static void checkSpellingOfString(int64_t spellDocumentTag, StringView text, int32_t& misspellingLocation, int32_t& misspellingLength);
80 static void checkGrammarOfString(int64_t spellDocumentTag, StringView text, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& badGrammarLength);
jberlin@webkit.org53b56062011-04-09 00:18:01 +000081 static bool spellingUIIsShowing();
82 static void toggleSpellingUIIsShowing();
jberlin@webkit.orgc008ff72011-04-11 18:00:07 +000083 static void updateSpellingUIWithMisspelledWord(int64_t spellDocumentTag, const String& misspelledWord);
84 static void updateSpellingUIWithGrammarString(int64_t spellDocumentTag, const String& badGrammarPhrase, const WebCore::GrammarDetail&);
enrica@apple.com3a51f072016-06-17 23:31:42 +000085 static void getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, int32_t insertionPoint, Vector<String>& guesses, bool initialCapitalizationEnabled);
jberlin@webkit.org5daca922011-04-11 21:19:22 +000086 static void learnWord(int64_t spellDocumentTag, const String& word);
andersca@apple.com047c4002011-01-05 19:41:03 +000087 static void ignoreWord(int64_t spellDocumentTag, const String& word);
achristensen@apple.comade2d5f2017-05-09 02:22:45 +000088 static void requestCheckingOfString(Ref<TextCheckerCompletion>&&, int32_t insertionPoint);
andersca@apple.com36f2f522010-12-21 00:35:16 +000089};
90
91} // namespace WebKit