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> 2011-04-07 Siddharth Mathur <siddharth.mathur@nokia.com>
Reviewed by Laszlo Gombos. Reviewed by Laszlo Gombos.
......
...@@ -40,6 +40,7 @@ typedef bool (*WKTextCheckerGrammarCheckingEnabled)(const void *clientInfo); ...@@ -40,6 +40,7 @@ typedef bool (*WKTextCheckerGrammarCheckingEnabled)(const void *clientInfo);
typedef void (*WKTextCheckerSetGrammarCheckingEnabled)(bool enabled, const void *clientInfo); typedef void (*WKTextCheckerSetGrammarCheckingEnabled)(bool enabled, const void *clientInfo);
typedef uint64_t (*WKTextCheckerUniqueSpellDocumentTag)(const void *clientInfo); typedef uint64_t (*WKTextCheckerUniqueSpellDocumentTag)(const void *clientInfo);
typedef void (*WKTextCheckerCloseSpellDocumentWithTag)(uint64_t tag, 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 { struct WKTextCheckerClient {
int version; int version;
...@@ -51,6 +52,7 @@ struct WKTextCheckerClient { ...@@ -51,6 +52,7 @@ struct WKTextCheckerClient {
WKTextCheckerSetGrammarCheckingEnabled setGrammarCheckingEnabled; WKTextCheckerSetGrammarCheckingEnabled setGrammarCheckingEnabled;
WKTextCheckerUniqueSpellDocumentTag uniqueSpellDocumentTag; WKTextCheckerUniqueSpellDocumentTag uniqueSpellDocumentTag;
WKTextCheckerCloseSpellDocumentWithTag closeSpellDocumentWithTag; WKTextCheckerCloseSpellDocumentWithTag closeSpellDocumentWithTag;
WKTextCheckerCheckSpellingOfString checkSpellingOfString;
}; };
typedef struct WKTextCheckerClient WKTextCheckerClient; typedef struct WKTextCheckerClient WKTextCheckerClient;
......
...@@ -57,8 +57,10 @@ public: ...@@ -57,8 +57,10 @@ public:
static int64_t uniqueSpellDocumentTag(); static int64_t uniqueSpellDocumentTag();
static void closeSpellDocumentWithTag(int64_t); 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); 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 updateSpellingUIWithMisspelledWord(const String& misspelledWord);
static void updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const WebCore::GrammarDetail&); static void updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const WebCore::GrammarDetail&);
static void getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses); static void getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses);
......
...@@ -2361,11 +2361,20 @@ int64_t WebPageProxy::spellDocumentTag() ...@@ -2361,11 +2361,20 @@ int64_t WebPageProxy::spellDocumentTag()
return m_spellDocumentTag; return m_spellDocumentTag;
} }
#if USE(UNIFIED_TEXT_CHECKING)
void WebPageProxy::checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<TextCheckingResult>& results) void WebPageProxy::checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<TextCheckingResult>& results)
{ {
results = TextChecker::checkTextOfParagraph(spellDocumentTag(), text.characters(), text.length(), checkingTypes); 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) void WebPageProxy::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
{ {
TextChecker::updateSpellingUIWithMisspelledWord(misspelledWord); TextChecker::updateSpellingUIWithMisspelledWord(misspelledWord);
......
...@@ -635,7 +635,10 @@ private: ...@@ -635,7 +635,10 @@ private:
// Spelling and grammar. // Spelling and grammar.
int64_t spellDocumentTag(); int64_t spellDocumentTag();
#if USE(UNIFIED_TEXT_CHECKING)
void checkTextOfParagraph(const String& text, uint64_t checkingTypes, Vector<WebCore::TextCheckingResult>& results); 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 updateSpellingUIWithMisspelledWord(const String& misspelledWord);
void updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const WebCore::GrammarDetail&); void updateSpellingUIWithGrammarString(const String& badGrammarPhrase, const WebCore::GrammarDetail&);
void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses); void getGuessesForWord(const String& word, const String& context, Vector<String>& guesses);
......
...@@ -177,7 +177,10 @@ messages -> WebPageProxy { ...@@ -177,7 +177,10 @@ messages -> WebPageProxy {
RequestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, WTF::String originIdentifier) RequestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, WTF::String originIdentifier)
# Spelling and grammar messages # Spelling and grammar messages
#if USE(UNIFIED_TEXT_CHECKING)
CheckTextOfParagraph(WTF::String text, uint64_t checkingTypes) -> (Vector<WebCore::TextCheckingResult> results) 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) UpdateSpellingUIWithMisspelledWord(WTF::String misspelledWord)
UpdateSpellingUIWithGrammarString(WTF::String badGrammarPhrase, WebCore::GrammarDetail grammarDetail) UpdateSpellingUIWithGrammarString(WTF::String badGrammarPhrase, WebCore::GrammarDetail grammarDetail)
GetGuessesForWord(WTF::String word, WTF::String context) -> (Vector<WTF::String> guesses) GetGuessesForWord(WTF::String word, WTF::String context) -> (Vector<WTF::String> guesses)
......
...@@ -69,10 +69,9 @@ void TextChecker::closeSpellDocumentWithTag(int64_t) ...@@ -69,10 +69,9 @@ void TextChecker::closeSpellDocumentWithTag(int64_t)
notImplemented(); 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(); notImplemented();
return Vector<WebCore::TextCheckingResult>();
} }
void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord) void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#import "TextChecker.h" #import "TextChecker.h"
#import "TextCheckerState.h" #import "TextCheckerState.h"
#import <WebCore/NotImplemented.h>
#import <wtf/RetainPtr.h> #import <wtf/RetainPtr.h>
#ifndef BUILDING_ON_SNOW_LEOPARD #ifndef BUILDING_ON_SNOW_LEOPARD
...@@ -205,6 +206,8 @@ void TextChecker::closeSpellDocumentWithTag(int64_t tag) ...@@ -205,6 +206,8 @@ void TextChecker::closeSpellDocumentWithTag(int64_t tag)
[[NSSpellChecker sharedSpellChecker] closeSpellDocumentWithTag: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> TextChecker::checkTextOfParagraph(int64_t spellDocumentTag, const UChar* text, int length, uint64_t checkingTypes)
{ {
Vector<TextCheckingResult> results; Vector<TextCheckingResult> results;
...@@ -292,6 +295,13 @@ Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocume ...@@ -292,6 +295,13 @@ Vector<TextCheckingResult> TextChecker::checkTextOfParagraph(int64_t spellDocume
return results; return results;
} }
#endif
void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&)
{
notImplemented();
}
void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord) void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
{ {
[[NSSpellChecker sharedSpellChecker] updateSpellingPanelWithMisspelledWord:misspelledWord]; [[NSSpellChecker sharedSpellChecker] updateSpellingPanelWithMisspelledWord:misspelledWord];
......
...@@ -70,10 +70,9 @@ void TextChecker::closeSpellDocumentWithTag(int64_t) ...@@ -70,10 +70,9 @@ void TextChecker::closeSpellDocumentWithTag(int64_t)
notImplemented(); 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(); notImplemented();
return Vector<WebCore::TextCheckingResult>();
} }
void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord) void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
......
...@@ -92,10 +92,9 @@ void TextChecker::closeSpellDocumentWithTag(int64_t tag) ...@@ -92,10 +92,9 @@ void TextChecker::closeSpellDocumentWithTag(int64_t tag)
WebTextChecker::shared()->client().closeSpellDocumentWithTag(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(); WebTextChecker::shared()->client().checkSpellingOfString(spellDocumentTag, String(text, length), misspellingLocation, misspellingLength);
return Vector<WebCore::TextCheckingResult>();
} }
void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord) void TextChecker::updateSpellingUIWithMisspelledWord(const String& misspelledWord)
......
...@@ -26,6 +26,9 @@ ...@@ -26,6 +26,9 @@
#include "config.h" #include "config.h"
#include "WebTextCheckerClient.h" #include "WebTextCheckerClient.h"
#include "WKAPICast.h"
#include <wtf/text/WTFString.h>
namespace WebKit { namespace WebKit {
bool WebTextCheckerClient::continuousSpellCheckingAllowed() bool WebTextCheckerClient::continuousSpellCheckingAllowed()
...@@ -84,4 +87,12 @@ void WebTextCheckerClient::closeSpellDocumentWithTag(uint64_t tag) ...@@ -84,4 +87,12 @@ void WebTextCheckerClient::closeSpellDocumentWithTag(uint64_t tag)
m_client.closeSpellDocumentWithTag(tag, m_client.clientInfo); 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 } // namespace WebKit
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "APIClient.h" #include "APIClient.h"
#include "WKTextChecker.h" #include "WKTextChecker.h"
#include <wtf/Forward.h>
#include <wtf/Vector.h> #include <wtf/Vector.h>
namespace WebKit { namespace WebKit {
...@@ -41,6 +42,7 @@ public: ...@@ -41,6 +42,7 @@ public:
void setGrammarCheckingEnabled(bool); void setGrammarCheckingEnabled(bool);
uint64_t uniqueSpellDocumentTag(); uint64_t uniqueSpellDocumentTag();
void closeSpellDocumentWithTag(uint64_t); void closeSpellDocumentWithTag(uint64_t);
void checkSpellingOfString(uint64_t tag, const String& text, int32_t& misspellingLocation, int32_t& misspellingLength);
}; };
} // namespace WebKit } // namespace WebKit
......
...@@ -398,9 +398,15 @@ void WebEditorClient::learnWord(const String& word) ...@@ -398,9 +398,15 @@ void WebEditorClient::learnWord(const String& word)
m_page->send(Messages::WebPageProxy::LearnWord(word)); m_page->send(Messages::WebPageProxy::LearnWord(word));
} }
void WebEditorClient::checkSpellingOfString(const UChar*, int, int*, int*) void WebEditorClient::checkSpellingOfString(const UChar* text, int length, int* misspellingLocation, int* misspellingLength)
{ {
notImplemented(); 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&) 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