Commit 756e20b2 authored by jberlin@webkit.org's avatar jberlin@webkit.org
Browse files

WebKit2: Implement TextChecker on Windows

https://bugs.webkit.org/show_bug.cgi?id=57862

Reviewed by Brian Weinstein.

Part 4: Implement checkGrammarOfString.

* Scripts/webkit2/messages.py:
The generated files should include TextCheckerClient.h for WebCore::GrammarDetail.

* Shared/API/c/win/WKBaseWin.h:
* Shared/APIObject.h:
* UIProcess/API/C/win/WKAPICastWin.h:

* UIProcess/API/C/win/WKGrammarDetail.cpp: Added.
(WKGrammarDetailGetTypeID):
(WKGrammarDetailCreate):
* UIProcess/API/C/win/WKGrammarDetail.h: Added.

* UIProcess/API/C/win/WKTextChecker.h:
Add the checkGrammarOfString WKTextCheckerClient function.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::checkGrammarOfString):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:

* UIProcess/TextChecker.h:
* UIProcess/win/TextCheckerWin.cpp:
(WebKit::TextChecker::checkGrammarOfString):
Call the TextCheckerClient.
* UIProcess/mac/TextCheckerMac.mm:
(WebKit::TextChecker::checkSpellingOfString):
Add a comment about this not being used on Mac.
(WebKit::TextChecker::checkGrammarOfString):
Ditto, and call notImplemented.
* UIProcess/gtk/TextCheckerGtk.cpp:
(WebKit::TextChecker::checkGrammarOfString):
Call notImplemented.
* UIProcess/qt/TextCheckerQt.cpp:
(WebKit::TextChecker::checkGrammarOfString):
Ditto.

* UIProcess/win/WebGrammarDetail.cpp: Added.
(WebKit::WebGrammarDetail::create):
(WebKit::WebGrammarDetail::WebGrammarDetail):
Initialize the underlying WebCore::GrammarDetail.
* UIProcess/win/WebGrammarDetail.h: Added.
(WebKit::WebGrammarDetail::grammarDetail):
(WebKit::WebGrammarDetail::type):

* UIProcess/win/WebTextCheckerClient.cpp:
(WebKit::WebTextCheckerClient::checkGrammarOfString):
Populate the Vector of WebCore::GrammarDetails with the WebGrammarDetails.
* UIProcess/win/WebTextCheckerClient.h:

* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::checkSpellingOfString):
Use WTF::notFound as the initial value for resultLocation.
(WebKit::WebEditorClient::checkGrammarOfString):
Send a sync message to the UI Process (similar to checkSpellingOfString and checkTextOfParagraph).

* win/WebKit2.vcproj:
Add WKGrammarDetail.h/.cpp and WebGrammarDetail.h/.cpp.
* win/WebKit2Generated.make:
Copy over WKGrammarDetail.h.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@83232 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5139edc1
2011-04-07 Jessie Berlin <jberlin@apple.com>
Reviewed by Brian Weinstein.
WebKit2: Implement TextChecker on Windows
https://bugs.webkit.org/show_bug.cgi?id=57862
Part 4: Implement checkGrammarOfString.
* Scripts/webkit2/messages.py:
The generated files should include TextCheckerClient.h for WebCore::GrammarDetail.
* Shared/API/c/win/WKBaseWin.h:
* Shared/APIObject.h:
* UIProcess/API/C/win/WKAPICastWin.h:
* UIProcess/API/C/win/WKGrammarDetail.cpp: Added.
(WKGrammarDetailGetTypeID):
(WKGrammarDetailCreate):
* UIProcess/API/C/win/WKGrammarDetail.h: Added.
* UIProcess/API/C/win/WKTextChecker.h:
Add the checkGrammarOfString WKTextCheckerClient function.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::checkGrammarOfString):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/TextChecker.h:
* UIProcess/win/TextCheckerWin.cpp:
(WebKit::TextChecker::checkGrammarOfString):
Call the TextCheckerClient.
* UIProcess/mac/TextCheckerMac.mm:
(WebKit::TextChecker::checkSpellingOfString):
Add a comment about this not being used on Mac.
(WebKit::TextChecker::checkGrammarOfString):
Ditto, and call notImplemented.
* UIProcess/gtk/TextCheckerGtk.cpp:
(WebKit::TextChecker::checkGrammarOfString):
Call notImplemented.
* UIProcess/qt/TextCheckerQt.cpp:
(WebKit::TextChecker::checkGrammarOfString):
Ditto.
* UIProcess/win/WebGrammarDetail.cpp: Added.
(WebKit::WebGrammarDetail::create):
(WebKit::WebGrammarDetail::WebGrammarDetail):
Initialize the underlying WebCore::GrammarDetail.
* UIProcess/win/WebGrammarDetail.h: Added.
(WebKit::WebGrammarDetail::grammarDetail):
(WebKit::WebGrammarDetail::type):
* UIProcess/win/WebTextCheckerClient.cpp:
(WebKit::WebTextCheckerClient::checkGrammarOfString):
Populate the Vector of WebCore::GrammarDetails with the WebGrammarDetails.
* UIProcess/win/WebTextCheckerClient.h:
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::checkSpellingOfString):
Use WTF::notFound as the initial value for resultLocation.
(WebKit::WebEditorClient::checkGrammarOfString):
Send a sync message to the UI Process (similar to checkSpellingOfString and checkTextOfParagraph).
* win/WebKit2.vcproj:
Add WKGrammarDetail.h/.cpp and WebGrammarDetail.h/.cpp.
* win/WebKit2Generated.make:
Copy over WKGrammarDetail.h.
2011-04-07 Enrica Casucci <enrica@apple.com>
Reviewed by Oliver Hunt.
......
......@@ -434,6 +434,7 @@ def headers_for_type(type):
special_cases = {
'WTF::String': '<wtf/text/WTFString.h>',
'WebCore::CompositionUnderline': '<WebCore/Editor.h>',
'WebCore::GrammarDetail': '<WebCore/TextCheckerClient.h>',
'WebCore::KeypressCommand': '<WebCore/KeyboardEvent.h>',
'WebCore::PluginInfo': '<WebCore/PluginData.h>',
'WebCore::TextCheckingResult': '<WebCore/TextCheckerClient.h>',
......
......@@ -33,5 +33,6 @@
typedef const struct OpaqueWKView* WKViewRef;
typedef const struct OpaqueWKEditCommand* WKEditCommandRef;
typedef const struct OpaqueWKTextChecker* WKTextCheckerRef;
typedef const struct OpaqueWKGrammarDetail* WKGrammarDetailRef;
#endif /* WKBaseWin_h */
......@@ -104,9 +104,10 @@ public:
TypeBundleScriptWorld,
// Platform specific
TypeView,
TypeEditCommandProxy,
TypeTextChecker
TypeGrammarDetail,
TypeTextChecker,
TypeView
};
virtual ~APIObject()
......
......@@ -35,10 +35,12 @@ namespace WebKit {
class WebView;
class WebEditCommandProxy;
class WebTextChecker;
class WebGrammarDetail;
WK_ADD_API_MAPPING(WKViewRef, WebView)
WK_ADD_API_MAPPING(WKEditCommandRef, WebEditCommandProxy)
WK_ADD_API_MAPPING(WKTextCheckerRef, WebTextChecker)
WK_ADD_API_MAPPING(WKGrammarDetailRef, WebGrammarDetail)
}
......
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "WKGrammarDetail.h"
#include "APIObject.h"
#include "WKAPICast.h"
#include "WebGrammarDetail.h"
using namespace WebKit;
WKTypeID WKGrammarDetailGetTypeID()
{
return toAPI(APIObject::TypeGrammarDetail);
}
WKGrammarDetailRef WKGrammarDetailCreate(int location, int length, WKArrayRef guesses, WKStringRef userDescription)
{
RefPtr<WebGrammarDetail> detail = WebGrammarDetail::create(location, length, toImpl(guesses), toWTFString(userDescription));
return toAPI(detail.release().releaseRef());
}
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WKGrammarDetail_h
#define WKGrammarDetail_h
#include <WebKit2/WKBase.h>
#ifdef __cplusplus
extern "C" {
#endif
WK_EXPORT WKTypeID WKGrammarDetailGetTypeID();
WK_EXPORT WKGrammarDetailRef WKGrammarDetailCreate(int location, int length, WKArrayRef guesses, WKStringRef userDescription);
#ifdef __cplusplus
}
#endif
#endif /* WKGrammarDetail_h */
......@@ -41,6 +41,7 @@ typedef void (*WKTextCheckerSetGrammarCheckingEnabled)(bool enabled, const void
typedef uint64_t (*WKTextCheckerUniqueSpellDocumentTag)(const void *clientInfo);
typedef void (*WKTextCheckerCloseSpellDocumentWithTag)(uint64_t tag, const void *clientInfo);
typedef void (*WKTextCheckerCheckSpellingOfString)(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void *clientInfo);
typedef void (*WKTextCheckerCheckGrammarOfString)(uint64_t tag, WKStringRef text, WKArrayRef* grammarDetails, int32_t* badGrammarLocation, int32_t* badGrammarLength, const void *clientInfo);
struct WKTextCheckerClient {
int version;
......@@ -53,6 +54,7 @@ struct WKTextCheckerClient {
WKTextCheckerUniqueSpellDocumentTag uniqueSpellDocumentTag;
WKTextCheckerCloseSpellDocumentWithTag closeSpellDocumentWithTag;
WKTextCheckerCheckSpellingOfString checkSpellingOfString;
WKTextCheckerCheckGrammarOfString checkGrammarOfString;
};
typedef struct WKTextCheckerClient WKTextCheckerClient;
......
......@@ -61,6 +61,7 @@ public:
static Vector<WebCore::TextCheckingResult> checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes);
#endif
static void checkSpellingOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, int32_t& misspellingLocation, int32_t& misspellingLength);
static void checkGrammarOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& badGrammarLength);
static void updateSpellingUIWithMisspelledWord(const String& misspelledWord);
static void updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const WebCore::GrammarDetail&);
static void getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses);
......
......@@ -2388,6 +2388,11 @@ void WebPageProxy::checkSpellingOfString(const String& text, int32_t& misspellin
TextChecker::checkSpellingOfString(spellDocumentTag(), text.characters(), text.length(), misspellingLocation, misspellingLength);
}
void WebPageProxy::checkGrammarOfString(const String& text, Vector<WebCore::GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
{
TextChecker::checkGrammarOfString(spellDocumentTag(), text.characters(), text.length(), grammarDetails, badGrammarLocation, badGrammarLength);
}
void WebPageProxy::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
{
TextChecker::updateSpellingUIWithMisspelledWord(misspelledWord);
......
......@@ -643,6 +643,7 @@ private:
void checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<WebCore::TextCheckingResult>& results);
#endif
void checkSpellingOfString(const String& text, int32_t& misspellingLocation, int32_t& misspellingLength);
void checkGrammarOfString(const String& text, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& badGrammarLength);
void updateSpellingUIWithMisspelledWord(const String& misspelledWord);
void updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const WebCore::GrammarDetail&);
void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses);
......
......@@ -183,6 +183,7 @@ messages -> WebPageProxy {
CheckTextOfParagraph(WTF::String text, uint64_t checkingTypes) -> (Vector<WebCore::TextCheckingResult> results)
#endif
CheckSpellingOfString(WTF::String text) -> (int32_t misspellingLocation, int32_t misspellingLength)
CheckGrammarOfString(WTF::String text) -> (Vector<WebCore::GrammarDetail> results, int32_t badGrammarLocation, int32_t badGrammarLength)
UpdateSpellingUIWithMisspelledWord(WTF::String misspelledWord)
UpdateSpellingUIWithGrammarString(WTF::String badGrammarPhrase, WebCore::GrammarDetail grammarDetail)
GetGuessesForWord(WTF::String word, WTF::String context) -> (Vector<WTF::String> guesses)
......
......@@ -74,6 +74,11 @@ void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t
notImplemented();
}
void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&)
{
notImplemented();
}
void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
{
notImplemented();
......
......@@ -299,6 +299,13 @@ Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocume
void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&)
{
// Mac uses checkTextOfParagraph instead.
notImplemented();
}
void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&)
{
// Mac uses checkTextOfParagraph instead.
notImplemented();
}
......
......@@ -75,6 +75,11 @@ void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t
notImplemented();
}
void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&)
{
notImplemented();
}
void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
{
notImplemented();
......
......@@ -97,6 +97,11 @@ void TextChecker::checkSpellingOfString(int64_t spellDocumentTag, const UChar* t
WebTextChecker::shared()->client().checkSpellingOfString(spellDocumentTag, String(text, length), misspellingLocation, misspellingLength);
}
void TextChecker::checkGrammarOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, Vector<WebCore::GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
{
WebTextChecker::shared()->client().checkGrammarOfString(spellDocumentTag, String(text, length), grammarDetails, badGrammarLocation, badGrammarLength);
}
void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
{
notImplemented();
......
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "WebGrammarDetail.h"
#include "ImmutableArray.h"
#include "WKGrammarDetail.h"
#include "WebString.h"
namespace WebKit {
PassRefPtr<WebGrammarDetail> WebGrammarDetail::create(int location, int length, ImmutableArray* guesses, const String& userDescription)
{
return adoptRef(new WebGrammarDetail(location, length, guesses, userDescription));
}
WebGrammarDetail::WebGrammarDetail(int location, int length, ImmutableArray* guesses, const String& userDescription)
{
m_grammarDetail.location = location;
m_grammarDetail.length = length;
size_t numGuesses = guesses->size();
m_grammarDetail.guesses.reserveCapacity(numGuesses);
for (size_t i = 0; i < numGuesses; ++i)
m_grammarDetail.guesses.uncheckedAppend(guesses->at<WebString>(i)->string());
m_grammarDetail.userDescription = userDescription;
}
} // namespace WebKit
/*
* Copyright (C) 2011 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef WebGrammarDetail_h
#define WebGrammarDetail_h
#include "APIObject.h"
#include <WebCore/TextCheckerClient.h>
#include <wtf/Forward.h>
#include <wtf/PassRefPtr.h>
namespace WebKit {
class ImmutableArray;
class WebGrammarDetail : public APIObject {
public:
static const Type APIType = TypeGrammarDetail;
static PassRefPtr<WebGrammarDetail> create(int location, int length, ImmutableArray* guesses, const String& userDescription);
const WebCore::GrammarDetail& grammarDetail() { return m_grammarDetail; }
private:
WebGrammarDetail(int location, int length, ImmutableArray* guesses, const String& userDescription);
virtual Type type() const { return APIType; }
WebCore::GrammarDetail m_grammarDetail;
};
} // namespace WebKit
#endif // WebGrammarDetail_h
......@@ -26,7 +26,10 @@
#include "config.h"
#include "WebTextCheckerClient.h"
#include "ImmutableArray.h"
#include "WKAPICast.h"
#include "WKSharedAPICast.h"
#include "WebGrammarDetail.h"
#include <wtf/text/WTFString.h>
namespace WebKit {
......@@ -95,4 +98,18 @@ void WebTextCheckerClient::checkSpellingOfString(uint64_t tag, const String& tex
m_client.checkSpellingOfString(tag, toAPI(text.impl()), &misspellingLocation, &misspellingLength, m_client.clientInfo);
}
void WebTextCheckerClient::checkGrammarOfString(uint64_t tag, const String& text, Vector<WebCore::GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
{
if (!m_client.checkGrammarOfString)
return;
WKArrayRef wkGrammarDetailsRef = 0;
m_client.checkGrammarOfString(tag, toAPI(text.impl()), &wkGrammarDetailsRef, &badGrammarLocation, &badGrammarLength, m_client.clientInfo);
RefPtr<ImmutableArray> wkGrammarDetails = adoptRef(toImpl(wkGrammarDetailsRef));
size_t numGrammarDetails = wkGrammarDetails->size();
for (size_t i = 0; i < numGrammarDetails; ++i)
grammarDetails.append(wkGrammarDetails->at<WebGrammarDetail>(i)->grammarDetail());
}
} // namespace WebKit
......@@ -28,6 +28,7 @@
#include "APIClient.h"
#include "WKTextChecker.h"
#include <WebCore/TextCheckerClient.h>
#include <wtf/Forward.h>
#include <wtf/Vector.h>
......@@ -43,6 +44,7 @@ public:
uint64_t uniqueSpellDocumentTag();
void closeSpellDocumentWithTag(uint64_t);
void checkSpellingOfString(uint64_t tag, const String& text, int32_t& misspellingLocation, int32_t& misspellingLength);
void checkGrammarOfString(uint64_t tag, const String& text, Vector<WebCore::GrammarDetail>&, int32_t& badGrammarLocation, int32_t& badGrammarLength);
};
} // namespace WebKit
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment