Commit 91a2855c authored by jberlin@webkit.org's avatar jberlin@webkit.org

WebKit2: Implement TextChecker on Windows

https://bugs.webkit.org/show_bug.cgi?id=57862
 
Reviewed by Adam Roben.

Part 3: Implement checkSpellingOfString

In WebCore, checkTextOfParagraph is only defined and used on platforms where
WTF_USE_UNIFIED_TEXT_CHECKING is defined (which right now is only non-Leopard and non-Tiger
Mac builds).
 
On other platforms, checkSpellingOfString and checkGrammarOfString (coming in a separate
patch in an attempt to keep things easier to review) are used.

* UIProcess/API/C/win/WKTextChecker.h:
* UIProcess/TextChecker.h:
Surround checkTextOfParagraph by #if USE(UNIFIED_TEXT_CHECKING) and add
checkSpellingOfString.

* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::checkTextOfParagraph):
Surround this by #if USE(UNIFIED_TEXT_CHECKING).
(WebKit::WebPageProxy::checkSpellingOfString):
Call through to the client.
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
Surround checkTextOfParagraph by #if USE(UNIFIED_TEXT_CHECKING) and add
checkSpellingOfString.

* UIProcess/win/TextCheckerWin.cpp:
(WebKit::TextChecker::checkSpellingOfString):
Call through to the WebTextCheckerClient.
* UIProcess/mac/TextCheckerMac.mm:
(WebKit::TextChecker::checkTextOfParagraph):
Surround this by #if USE(UNIFIED_TEXT_CHECKING) for clarity.
(WebKit::TextChecker::checkSpellingOfString):
Add a call to notImplemented.
* UIProcess/qt/TextCheckerQt.cpp:
(WebKit::TextChecker::checkSpellingOfString):
Ditto, and remove the implementation for checkTextOfParagraph.
* UIProcess/gtk/TextCheckerGtk.cpp:
(WebKit::TextChecker::checkSpellingOfString):
Ditto.

* UIProcess/win/WebTextCheckerClient.cpp:
(WebKit::WebTextCheckerClient::checkSpellingOfString):
* UIProcess/win/WebTextCheckerClient.h:

* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::checkSpellingOfString):
Send a sync message to the UI Process (similar to the sync message used for
checkTextOfParagraph).



git-svn-id: svn://svn.chromium.org/blink/trunk@83188 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 829ec707
2011-04-07 Jessie Berlin <jberlin@apple.com>
Reviewed by Adam Roben.
WebKit2: Implement TextChecker on Windows
https://bugs.webkit.org/show_bug.cgi?id=57862
Part 3: Implement checkSpellingOfString
In WebCore, checkTextOfParagraph is only defined and used on platforms where
WTF_USE_UNIFIED_TEXT_CHECKING is defined (which right now is only non-Leopard and non-Tiger
Mac builds).
On other platforms, checkSpellingOfString and checkGrammarOfString (coming in a separate
patch in an attempt to keep things easier to review) are used.
* UIProcess/API/C/win/WKTextChecker.h:
* UIProcess/TextChecker.h:
Surround checkTextOfParagraph by #if USE(UNIFIED_TEXT_CHECKING) and add
checkSpellingOfString.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::checkTextOfParagraph):
Surround this by #if USE(UNIFIED_TEXT_CHECKING).
(WebKit::WebPageProxy::checkSpellingOfString):
Call through to the client.
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
Surround checkTextOfParagraph by #if USE(UNIFIED_TEXT_CHECKING) and add
checkSpellingOfString.
* UIProcess/win/TextCheckerWin.cpp:
(WebKit::TextChecker::checkSpellingOfString):
Call through to the WebTextCheckerClient.
* UIProcess/mac/TextCheckerMac.mm:
(WebKit::TextChecker::checkTextOfParagraph):
Surround this by #if USE(UNIFIED_TEXT_CHECKING) for clarity.
(WebKit::TextChecker::checkSpellingOfString):
Add a call to notImplemented.
* UIProcess/qt/TextCheckerQt.cpp:
(WebKit::TextChecker::checkSpellingOfString):
Ditto, and remove the implementation for checkTextOfParagraph.
* UIProcess/gtk/TextCheckerGtk.cpp:
(WebKit::TextChecker::checkSpellingOfString):
Ditto.
* UIProcess/win/WebTextCheckerClient.cpp:
(WebKit::WebTextCheckerClient::checkSpellingOfString):
* UIProcess/win/WebTextCheckerClient.h:
* WebProcess/WebCoreSupport/WebEditorClient.cpp:
(WebKit::WebEditorClient::checkSpellingOfString):
Send a sync message to the UI Process (similar to the sync message used for
checkTextOfParagraph).
2011-04-07 Siddharth Mathur <siddharth.mathur@nokia.com>
Reviewed by Laszlo Gombos.
......
......@@ -40,6 +40,7 @@ typedef bool (*WKTextCheckerGrammarCheckingEnabled)(const void *clientInfo);
typedef void (*WKTextCheckerSetGrammarCheckingEnabled)(bool enabled, const void *clientInfo);
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);
struct WKTextCheckerClient {
int version;
......@@ -51,6 +52,7 @@ struct WKTextCheckerClient {
WKTextCheckerSetGrammarCheckingEnabled setGrammarCheckingEnabled;
WKTextCheckerUniqueSpellDocumentTag uniqueSpellDocumentTag;
WKTextCheckerCloseSpellDocumentWithTag closeSpellDocumentWithTag;
WKTextCheckerCheckSpellingOfString checkSpellingOfString;
};
typedef struct WKTextCheckerClient WKTextCheckerClient;
......
......@@ -57,8 +57,10 @@ public:
static int64_t uniqueSpellDocumentTag();
static void closeSpellDocumentWithTag(int64_t);
#if USE(UNIFIED_TEXT_CHECKING)
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 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);
......
......@@ -2361,11 +2361,20 @@ int64_t WebPageProxy::spellDocumentTag()
return m_spellDocumentTag;
}
#if USE(UNIFIED_TEXT_CHECKING)
void WebPageProxy::checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<TextCheckingResult>& results)
{
results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text.characters(), text.length(), checkingTypes);
}
#endif
void WebPageProxy::checkSpellingOfString(const String& text, int32_t& misspellingLocation, int32_t& misspellingLength)
{
TextChecker::checkSpellingOfString(spellDocumentTag(), text.characters(), text.length(), misspellingLocation, misspellingLength);
}
void WebPageProxy::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
{
TextChecker::updateSpellingUIWithMisspelledWord(misspelledWord);
......
......@@ -635,7 +635,10 @@ private:
// Spelling and grammar.
int64_t spellDocumentTag();
#if USE(UNIFIED_TEXT_CHECKING)
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 updateSpellingUIWithMisspelledWord(const String& misspelledWord);
void updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const WebCore::GrammarDetail&);
void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses);
......
......@@ -177,7 +177,10 @@ messages -> WebPageProxy {
RequestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, WTF::String originIdentifier)
# Spelling and grammar messages
#if USE(UNIFIED_TEXT_CHECKING)
CheckTextOfParagraph(WTF::String text, uint64_t checkingTypes) -> (Vector<WebCore::TextCheckingResult> results)
#endif
CheckSpellingOfString(WTF::String text) -> (int32_t misspellingLocation, int32_t misspellingLength)
UpdateSpellingUIWithMisspelledWord(WTF::String misspelledWord)
UpdateSpellingUIWithGrammarString(WTF::String badGrammarPhrase, WebCore::GrammarDetail grammarDetail)
GetGuessesForWord(WTF::String word, WTF::String context) -> (Vector<WTF::String> guesses)
......
......@@ -69,10 +69,9 @@ void TextChecker::closeSpellDocumentWithTag(int64_t)
notImplemented();
}
Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&)
{
notImplemented();
return Vector<WebCore::TextCheckingResult>();
}
void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
......
......@@ -27,6 +27,7 @@
#import "TextChecker.h"
#import "TextCheckerState.h"
#import <WebCore/NotImplemented.h>
#import <wtf/RetainPtr.h>
#ifndef BUILDING_ON_SNOW_LEOPARD
......@@ -205,6 +206,8 @@ void TextChecker::closeSpellDocumentWithTag(int64_t tag)
[[NSSpellChecker sharedSpellChecker] closeSpellDocumentWithTag:tag];
}
#if USE(UNIFIED_TEXT_CHECKING)
Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
{
Vector<TextCheckingResult> results;
......@@ -292,6 +295,13 @@ Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocume
return results;
}
#endif
void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&)
{
notImplemented();
}
void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
{
[[NSSpellChecker sharedSpellChecker] updateSpellingPanelWithMisspelledWord:misspelledWord];
......
......@@ -70,10 +70,9 @@ void TextChecker::closeSpellDocumentWithTag(int64_t)
notImplemented();
}
Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&)
{
notImplemented();
return Vector<WebCore::TextCheckingResult>();
}
void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
......
......@@ -92,10 +92,9 @@ void TextChecker::closeSpellDocumentWithTag(int64_t tag)
WebTextChecker::shared()->client().closeSpellDocumentWithTag(tag);
}
Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
void TextChecker::checkSpellingOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, int32_t& misspellingLocation, int32_t& misspellingLength)
{
notImplemented();
return Vector<WebCore::TextCheckingResult>();
WebTextChecker::shared()->client().checkSpellingOfString(spellDocumentTag, String(text, length), misspellingLocation, misspellingLength);
}
void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
......
......@@ -26,6 +26,9 @@
#include "config.h"
#include "WebTextCheckerClient.h"
#include "WKAPICast.h"
#include <wtf/text/WTFString.h>
namespace WebKit {
bool WebTextCheckerClient::continuousSpellCheckingAllowed()
......@@ -84,4 +87,12 @@ void WebTextCheckerClient::closeSpellDocumentWithTag(uint64_t tag)
m_client.closeSpellDocumentWithTag(tag, m_client.clientInfo);
}
void WebTextCheckerClient::checkSpellingOfString(uint64_t tag, const String& text, int32_t& misspellingLocation, int32_t& misspellingLength)
{
if (!m_client.checkSpellingOfString)
return;
m_client.checkSpellingOfString(tag, toAPI(text.impl()), &misspellingLocation, &misspellingLength, m_client.clientInfo);
}
} // namespace WebKit
......@@ -28,6 +28,7 @@
#include "APIClient.h"
#include "WKTextChecker.h"
#include <wtf/Forward.h>
#include <wtf/Vector.h>
namespace WebKit {
......@@ -41,6 +42,7 @@ public:
void setGrammarCheckingEnabled(bool);
uint64_t uniqueSpellDocumentTag();
void closeSpellDocumentWithTag(uint64_t);
void checkSpellingOfString(uint64_t tag, const String& text, int32_t& misspellingLocation, int32_t& misspellingLength);
};
} // namespace WebKit
......
......@@ -398,9 +398,15 @@ void WebEditorClient::learnWord(const String& word)
m_page->send(Messages::WebPageProxy::LearnWord(word));
}
void WebEditorClient::checkSpellingOfString(const UChar*, int, int*, int*)
{
notImplemented();
void WebEditorClient::checkSpellingOfString(const UChar* text, int length, int* misspellingLocation, int* misspellingLength)
{
int32_t resultLocation = -1;
int32_t resultLength = 0;
// FIXME: It would be nice if we wouldn't have to copy the text here.
m_page->sendSync(Messages::WebPageProxy::CheckSpellingOfString(String(text, length)),
Messages::WebPageProxy::CheckSpellingOfString::Reply(resultLocation, resultLength));
*misspellingLocation = resultLocation;
*misspellingLength = resultLength;
}
String WebEditorClient::getAutoCorrectSuggestionForMisspelledWord(const String&)
......
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