WebKit2: Implement TextChecker on Windows
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / C / win / WKTextChecker.h
1 /*
2  * Copyright (C) 2011 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 WKTextChecker_h
27 #define WKTextChecker_h
28
29 #include <WebKit2/WKBase.h>
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 // TextChecker Client
36 typedef bool (*WKTextCheckerContinousSpellCheckingAllowed)(const void *clientInfo);
37 typedef bool (*WKTextCheckerContinousSpellCheckingEnabled)(const void *clientInfo);
38 typedef void (*WKTextCheckerSetContinousSpellCheckingEnabled)(bool enabled, const void *clientInfo);
39 typedef bool (*WKTextCheckerGrammarCheckingEnabled)(const void *clientInfo);
40 typedef void (*WKTextCheckerSetGrammarCheckingEnabled)(bool enabled, const void *clientInfo);
41 typedef uint64_t (*WKTextCheckerUniqueSpellDocumentTag)(WKPageRef page, const void *clientInfo);
42 typedef void (*WKTextCheckerCloseSpellDocumentWithTag)(uint64_t tag, const void *clientInfo);
43 typedef void (*WKTextCheckerCheckSpellingOfString)(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void *clientInfo);
44 typedef void (*WKTextCheckerCheckGrammarOfString)(uint64_t tag, WKStringRef text, WKArrayRef* grammarDetails, int32_t* badGrammarLocation, int32_t* badGrammarLength, const void *clientInfo);
45 typedef bool (*WKTextCheckerSpellingUIIsShowing)(const void *clientInfo);
46 typedef void (*WKTextCheckerToggleSpellingUIIsShowing)(const void *clientInfo);
47 typedef void (*WKTextCheckerUpdateSpellingUIWithMisspelledWord)(uint64_t tag, WKStringRef misspelledWord, const void *clientInfo);
48 typedef void (*WKTextCheckerUpdateSpellingUIWithGrammarString)(uint64_t tag, WKStringRef badGrammarPhrase, WKGrammarDetailRef grammarDetail, const void *clientInfo);
49 typedef WKArrayRef (*WKTextCheckerGuessesForWord)(uint64_t tag, WKStringRef word, const void *clientInfo);
50 typedef void (*WKTextCheckerLearnWord)(uint64_t tag, WKStringRef word, const void *clientInfo);
51 typedef void (*WKTextCheckerIgnoreWord)(uint64_t tag, WKStringRef word, const void *clientInfo);
52
53 struct WKTextCheckerClient {
54     int                                                                     version;
55     const void *                                                            clientInfo;
56     WKTextCheckerContinousSpellCheckingAllowed                              continuousSpellCheckingAllowed;
57     WKTextCheckerContinousSpellCheckingEnabled                              continuousSpellCheckingEnabled;
58     WKTextCheckerSetContinousSpellCheckingEnabled                           setContinuousSpellCheckingEnabled;
59     WKTextCheckerGrammarCheckingEnabled                                     grammarCheckingEnabled;
60     WKTextCheckerSetGrammarCheckingEnabled                                  setGrammarCheckingEnabled;
61     WKTextCheckerUniqueSpellDocumentTag                                     uniqueSpellDocumentTag;
62     WKTextCheckerCloseSpellDocumentWithTag                                  closeSpellDocumentWithTag;
63     WKTextCheckerCheckSpellingOfString                                      checkSpellingOfString;
64     WKTextCheckerCheckGrammarOfString                                       checkGrammarOfString;
65     WKTextCheckerSpellingUIIsShowing                                        spellingUIIsShowing;
66     WKTextCheckerToggleSpellingUIIsShowing                                  toggleSpellingUIIsShowing;
67     WKTextCheckerUpdateSpellingUIWithMisspelledWord                         updateSpellingUIWithMisspelledWord;
68     WKTextCheckerUpdateSpellingUIWithGrammarString                          updateSpellingUIWithGrammarString;
69     WKTextCheckerGuessesForWord                                             guessesForWord;
70     WKTextCheckerLearnWord                                                  learnWord;
71     WKTextCheckerIgnoreWord                                                 ignoreWord;
72 };
73 typedef struct WKTextCheckerClient WKTextCheckerClient;
74
75 WK_EXPORT void WKTextCheckerSetClient(const WKTextCheckerClient* client);
76
77 WK_EXPORT void WKTextCheckerContinuousSpellCheckingEnabledStateChanged(bool);
78 WK_EXPORT void WKTextCheckerGrammarCheckingEnabledStateChanged(bool);
79
80 WK_EXPORT void WKTextCheckerCheckSpelling(WKPageRef page, bool startBeforeSelection);
81 WK_EXPORT void WKTextCheckerChangeSpellingToWord(WKPageRef page, WKStringRef word);
82
83 #ifdef __cplusplus
84 }
85 #endif
86
87 #endif /* WKTextChecker_h */