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 <WebKit/WKBase.h> |
30 | |
31 | #ifdef __cplusplus |
32 | extern "C" { |
33 | #endif |
34 | |
35 | WK_EXPORT void WKTextCheckerSetTestingMode(bool enabled); |
36 | |
37 | #if defined(BUILDING_GTK__) |
38 | |
39 | // TextChecker Client |
40 | typedef bool (*WKTextCheckerContinousSpellCheckingAllowed)(const void *clientInfo); |
41 | typedef bool (*WKTextCheckerContinousSpellCheckingEnabled)(const void *clientInfo); |
42 | typedef void (*WKTextCheckerSetContinousSpellCheckingEnabled)(bool enabled, const void *clientInfo); |
43 | typedef bool (*WKTextCheckerGrammarCheckingEnabled)(const void *clientInfo); |
44 | typedef void (*WKTextCheckerSetGrammarCheckingEnabled)(bool enabled, const void *clientInfo); |
45 | typedef uint64_t (*WKTextCheckerUniqueSpellDocumentTag)(WKPageRef page, const void *clientInfo); |
46 | typedef void (*WKTextCheckerCloseSpellDocumentWithTag)(uint64_t tag, const void *clientInfo); |
47 | typedef void (*WKTextCheckerCheckSpellingOfString)(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void *clientInfo); |
48 | typedef void (*WKTextCheckerCheckGrammarOfString)(uint64_t tag, WKStringRef text, WKArrayRef* grammarDetails, int32_t* badGrammarLocation, int32_t* badGrammarLength, const void *clientInfo); |
49 | typedef bool (*WKTextCheckerSpellingUIIsShowing)(const void *clientInfo); |
50 | typedef void (*WKTextCheckerToggleSpellingUIIsShowing)(const void *clientInfo); |
51 | typedef void (*WKTextCheckerUpdateSpellingUIWithMisspelledWord)(uint64_t tag, WKStringRef misspelledWord, const void *clientInfo); |
52 | typedef void (*WKTextCheckerUpdateSpellingUIWithGrammarString)(uint64_t tag, WKStringRef badGrammarPhrase, WKGrammarDetailRef grammarDetail, const void *clientInfo); |
53 | typedef WKArrayRef (*WKTextCheckerGuessesForWord)(uint64_t tag, WKStringRef word, const void *clientInfo); |
54 | typedef void (*WKTextCheckerLearnWord)(uint64_t tag, WKStringRef word, const void *clientInfo); |
55 | typedef void (*WKTextCheckerIgnoreWord)(uint64_t tag, WKStringRef word, const void *clientInfo); |
56 | |
57 | typedef struct WKTextCheckerClientBase { |
58 | int version; |
59 | const void * clientInfo; |
60 | } WKTextCheckerClientBase; |
61 | |
62 | typedef struct WKTextCheckerClientV0 { |
63 | WKTextCheckerClientBase base; |
64 | |
65 | WKTextCheckerContinousSpellCheckingAllowed continuousSpellCheckingAllowed; |
66 | WKTextCheckerContinousSpellCheckingEnabled continuousSpellCheckingEnabled; |
67 | WKTextCheckerSetContinousSpellCheckingEnabled setContinuousSpellCheckingEnabled; |
68 | WKTextCheckerGrammarCheckingEnabled grammarCheckingEnabled; |
69 | WKTextCheckerSetGrammarCheckingEnabled setGrammarCheckingEnabled; |
70 | WKTextCheckerUniqueSpellDocumentTag uniqueSpellDocumentTag; |
71 | WKTextCheckerCloseSpellDocumentWithTag closeSpellDocumentWithTag; |
72 | WKTextCheckerCheckSpellingOfString checkSpellingOfString; |
73 | WKTextCheckerCheckGrammarOfString checkGrammarOfString; |
74 | WKTextCheckerSpellingUIIsShowing spellingUIIsShowing; |
75 | WKTextCheckerToggleSpellingUIIsShowing toggleSpellingUIIsShowing; |
76 | WKTextCheckerUpdateSpellingUIWithMisspelledWord updateSpellingUIWithMisspelledWord; |
77 | WKTextCheckerUpdateSpellingUIWithGrammarString updateSpellingUIWithGrammarString; |
78 | WKTextCheckerGuessesForWord guessesForWord; |
79 | WKTextCheckerLearnWord learnWord; |
80 | WKTextCheckerIgnoreWord ignoreWord; |
81 | } WKTextCheckerClientV0; |
82 | |
83 | WK_EXPORT void WKTextCheckerSetClient(const WKTextCheckerClientBase* client); |
84 | |
85 | WK_EXPORT void WKTextCheckerContinuousSpellCheckingEnabledStateChanged(bool); |
86 | WK_EXPORT void WKTextCheckerGrammarCheckingEnabledStateChanged(bool); |
87 | |
88 | WK_EXPORT void WKTextCheckerCheckSpelling(WKPageRef page, bool startBeforeSelection); |
89 | WK_EXPORT void WKTextCheckerChangeSpellingToWord(WKPageRef page, WKStringRef word); |
90 | |
91 | #endif |
92 | |
93 | #ifdef __cplusplus |
94 | } |
95 | #endif |
96 | |
97 | #endif /* WKTextChecker_h */ |
98 | |