Implement TextChecker for WebKit2 GTK+
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Oct 2011 19:36:34 +0000 (19:36 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Oct 2011 19:36:34 +0000 (19:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=68548

Patch by Ravi Phaneendra Kasibhatla <ravi.kasibhatla@motorola.com> on 2011-10-13
Reviewed by Anders Carlsson.

Added implementation for all functions in TextCheckerGtk.cpp removing earlier stubbed implementations.
Moved couple of API earlier specific to win port to common section and added stubbed implementation
of the same for remaining ports of Qt, Efl and Mac.

* GNUmakefile.am: Added TextChecker implementation files.
* UIProcess/TextChecker.h: Moved spellCheckingEnabled and grammarCheckingEnabled API outside of win port.
* UIProcess/efl/TextCheckerEfl.cpp: Stubbed implementation of API which was moved outside win port.
* UIProcess/gtk/TextCheckerGtk.cpp: Implementation of all TextChecker API.
(WebKit::TextChecker::state):
(WebKit::TextChecker::isContinuousSpellCheckingAllowed):
(WebKit::TextChecker::setContinuousSpellCheckingEnabled):
(WebKit::TextChecker::setGrammarCheckingEnabled):
(WebKit::TextChecker::continuousSpellCheckingEnabledStateChanged):
(WebKit::TextChecker::grammarCheckingEnabledStateChanged):
(WebKit::TextChecker::uniqueSpellDocumentTag):
(WebKit::TextChecker::closeSpellDocumentWithTag):
(WebKit::TextChecker::checkSpellingOfString):
(WebKit::TextChecker::checkGrammarOfString):
(WebKit::TextChecker::spellingUIIsShowing):
(WebKit::TextChecker::toggleSpellingUIIsShowing):
(WebKit::TextChecker::updateSpellingUIWithMisspelledWord):
(WebKit::TextChecker::updateSpellingUIWithGrammarString):
(WebKit::TextChecker::getGuessesForWord):
(WebKit::TextChecker::learnWord):
(WebKit::TextChecker::ignoreWord):
* UIProcess/mac/TextCheckerMac.mm: Implementation of API which was moved outside win port.
* UIProcess/qt/TextCheckerQt.cpp: Stubbed implementation of API which was moved outside win port.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@97385 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/GNUmakefile.am
Source/WebKit2/UIProcess/TextChecker.h
Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp
Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp
Source/WebKit2/UIProcess/mac/TextCheckerMac.mm
Source/WebKit2/UIProcess/qt/TextCheckerQt.cpp

index c71e98f..4aae95e 100644 (file)
@@ -1,3 +1,38 @@
+2011-10-13  Ravi Phaneendra Kasibhatla  <ravi.kasibhatla@motorola.com>
+
+        Implement TextChecker for WebKit2 GTK+
+        https://bugs.webkit.org/show_bug.cgi?id=68548
+
+        Reviewed by Anders Carlsson.
+
+        Added implementation for all functions in TextCheckerGtk.cpp removing earlier stubbed implementations.
+        Moved couple of API earlier specific to win port to common section and added stubbed implementation
+        of the same for remaining ports of Qt, Efl and Mac.
+
+        * GNUmakefile.am: Added TextChecker implementation files.
+        * UIProcess/TextChecker.h: Moved spellCheckingEnabled and grammarCheckingEnabled API outside of win port.
+        * UIProcess/efl/TextCheckerEfl.cpp: Stubbed implementation of API which was moved outside win port.
+        * UIProcess/gtk/TextCheckerGtk.cpp: Implementation of all TextChecker API.
+        (WebKit::TextChecker::state):
+        (WebKit::TextChecker::isContinuousSpellCheckingAllowed):
+        (WebKit::TextChecker::setContinuousSpellCheckingEnabled):
+        (WebKit::TextChecker::setGrammarCheckingEnabled):
+        (WebKit::TextChecker::continuousSpellCheckingEnabledStateChanged):
+        (WebKit::TextChecker::grammarCheckingEnabledStateChanged):
+        (WebKit::TextChecker::uniqueSpellDocumentTag):
+        (WebKit::TextChecker::closeSpellDocumentWithTag):
+        (WebKit::TextChecker::checkSpellingOfString):
+        (WebKit::TextChecker::checkGrammarOfString):
+        (WebKit::TextChecker::spellingUIIsShowing):
+        (WebKit::TextChecker::toggleSpellingUIIsShowing):
+        (WebKit::TextChecker::updateSpellingUIWithMisspelledWord):
+        (WebKit::TextChecker::updateSpellingUIWithGrammarString):
+        (WebKit::TextChecker::getGuessesForWord):
+        (WebKit::TextChecker::learnWord):
+        (WebKit::TextChecker::ignoreWord):
+        * UIProcess/mac/TextCheckerMac.mm: Implementation of API which was moved outside win port.
+        * UIProcess/qt/TextCheckerQt.cpp: Stubbed implementation of API which was moved outside win port.
+
 2011-10-13  Jesus Sanchez-Palencia  <jesus.palencia@openbossa.org>
 
         [Qt][WK2] Implement decidePolicyForResponse in our PolicyClient
index 360472c..ca658c5 100644 (file)
@@ -48,6 +48,7 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_HEA
        $(WebKit2)/UIProcess/API/C/WKFormSubmissionListener.h \
        $(WebKit2)/UIProcess/API/C/WKFrame.h \
        $(WebKit2)/UIProcess/API/C/WKFramePolicyListener.h \
+       $(WebKit2)/UIProcess/API/C/WKGrammarDetail.h \
        $(WebKit2)/UIProcess/API/C/WKHitTestResult.h \
        $(WebKit2)/UIProcess/API/C/WKInspector.h \
        $(WebKit2)/UIProcess/API/C/WKKeyValueStorageManager.h \
@@ -65,6 +66,7 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_HEA
        $(WebKit2)/UIProcess/API/C/WKProtectionSpace.h \
        $(WebKit2)/UIProcess/API/C/WKProtectionSpaceTypes.h \
        $(WebKit2)/UIProcess/API/C/WKResourceCacheManager.h \
+       $(WebKit2)/UIProcess/API/C/WKTextChecker.h \
        $(WebKit2)/UIProcess/API/cpp/WKRetainPtr.h
 
 libwebkit2gtkincludedir = $(libwebkitgtkincludedir)/webkit2
@@ -432,6 +434,8 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_SOU
        Source/WebKit2/UIProcess/API/C/WKFrame.h \
        Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.cpp \
        Source/WebKit2/UIProcess/API/C/WKFramePolicyListener.h \
+       Source/WebKit2/UIProcess/API/C/WKGrammarDetail.cpp \
+       Source/WebKit2/UIProcess/API/C/WKGrammarDetail.h \
        Source/WebKit2/UIProcess/API/C/WKHitTestResult.cpp \
        Source/WebKit2/UIProcess/API/C/WKHitTestResult.h \
        Source/WebKit2/UIProcess/API/C/WKIconDatabase.cpp \
@@ -464,6 +468,8 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_SOU
        Source/WebKit2/UIProcess/API/C/WKProtectionSpaceTypes.h \
        Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.h \
        Source/WebKit2/UIProcess/API/C/WKResourceCacheManager.cpp \
+       Source/WebKit2/UIProcess/API/C/WKTextChecker.h \
+       Source/WebKit2/UIProcess/API/C/WKTextChecker.cpp \
        Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h \
        Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h \
        Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp \
@@ -582,6 +588,8 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_SOU
        Source/WebKit2/UIProcess/WebGeolocationManagerProxy.h \
        Source/WebKit2/UIProcess/WebGeolocationProvider.cpp \
        Source/WebKit2/UIProcess/WebGeolocationProvider.h \
+       Source/WebKit2/UIProcess/WebGrammarDetail.cpp \
+       Source/WebKit2/UIProcess/WebGrammarDetail.h \
        Source/WebKit2/UIProcess/WebHistoryClient.cpp \
        Source/WebKit2/UIProcess/WebHistoryClient.h \
        Source/WebKit2/UIProcess/WebIconDatabase.cpp \
@@ -617,6 +625,10 @@ libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_SOU
        Source/WebKit2/UIProcess/WebResourceCacheManagerProxy.cpp \
        Source/WebKit2/UIProcess/WebResourceLoadClient.cpp \
        Source/WebKit2/UIProcess/WebResourceLoadClient.h \
+       Source/WebKit2/UIProcess/WebTextChecker.cpp \
+       Source/WebKit2/UIProcess/WebTextChecker.h \
+       Source/WebKit2/UIProcess/WebTextCheckerClient.cpp \
+       Source/WebKit2/UIProcess/WebTextCheckerClient.h \
        Source/WebKit2/UIProcess/WebUIClient.cpp \
        Source/WebKit2/UIProcess/WebUIClient.h \
        Source/WebKit2/WebProcess/ApplicationCache/WebApplicationCacheManager.h \
index 69e2837..49b5a48 100644 (file)
@@ -54,11 +54,10 @@ public:
 
     static bool substitutionsPanelIsShowing();
     static void toggleSubstitutionsPanelIsShowing();
-#elif PLATFORM(WIN)
-    static void continuousSpellCheckingEnabledStateChanged(bool);
-    static void grammarCheckingEnabledStateChanged(bool);
 #endif
 
+    static void continuousSpellCheckingEnabledStateChanged(bool);
+    static void grammarCheckingEnabledStateChanged(bool);
     static int64_t uniqueSpellDocumentTag(WebPageProxy*);
     static void closeSpellDocumentWithTag(int64_t);
 #if USE(UNIFIED_TEXT_CHECKING)
index 55e0d1a..aa33f2f 100644 (file)
@@ -57,6 +57,16 @@ void TextChecker::setGrammarCheckingEnabled(bool)
     notImplemented();
 }
 
+void TextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled)
+{
+    notImplemented();
+}
+
+void TextChecker::grammarCheckingEnabledStateChanged(bool enabled)
+{
+    notImplemented();
+}
+
 int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy*)
 {
     notImplemented();
index 118bee1..5b26d12 100644 (file)
@@ -28,7 +28,7 @@
 #include "TextChecker.h"
 
 #include "TextCheckerState.h"
-#include <WebCore/NotImplemented.h>
+#include "WebTextChecker.h"
 
 using namespace WebCore;
  
@@ -38,81 +38,103 @@ static TextCheckerState textCheckerState;
 
 const TextCheckerState& TextChecker::state()
 {
-    notImplemented();
+    static bool didInitializeState;
+    if (didInitializeState)
+        return textCheckerState;
+
+    WebTextCheckerClient& client = WebTextChecker::shared()->client();
+    textCheckerState.isContinuousSpellCheckingEnabled = client.continuousSpellCheckingEnabled();
+    textCheckerState.isGrammarCheckingEnabled =  client.grammarCheckingEnabled();
+
+    didInitializeState = true;
+
     return textCheckerState;
 }
-
+  
 bool TextChecker::isContinuousSpellCheckingAllowed()
 {
-    notImplemented();
-    return false;
+    return WebTextChecker::shared()->client().continuousSpellCheckingAllowed();
 }
 
 void TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled)
 {
-    notImplemented();
+    if (state().isContinuousSpellCheckingEnabled == isContinuousSpellCheckingEnabled)
+        return;
+    textCheckerState.isContinuousSpellCheckingEnabled = isContinuousSpellCheckingEnabled;
+    WebTextChecker::shared()->client().setContinuousSpellCheckingEnabled(isContinuousSpellCheckingEnabled);
 }
 
 void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled)
 {
-    notImplemented();
+    if (state().isGrammarCheckingEnabled == isGrammarCheckingEnabled)
+        return;
+    textCheckerState.isGrammarCheckingEnabled = isGrammarCheckingEnabled;
+    WebTextChecker::shared()->client().setGrammarCheckingEnabled(isGrammarCheckingEnabled);
+}
+
+void TextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled)
+{
+    textCheckerState.isContinuousSpellCheckingEnabled = enabled;
+}
+
+void TextChecker::grammarCheckingEnabledStateChanged(bool enabled)
+{
+    textCheckerState.isGrammarCheckingEnabled = enabled;
 }
 
-int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy*)
+int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy* page)
 {
-    notImplemented();
-    return 0;
+    return WebTextChecker::shared()->client().uniqueSpellDocumentTag(page);
 }
 
-void TextChecker::closeSpellDocumentWithTag(int64_t)
+void TextChecker::closeSpellDocumentWithTag(int64_t tag)
 {
-    notImplemented();
+    WebTextChecker::shared()->client().closeSpellDocumentWithTag(tag);
 }
 
-void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&)
+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);
 }
 
-void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&)
+void TextChecker::checkGrammarOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, Vector<WebCore::GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
 {
-    notImplemented();
+    WebTextChecker::shared()->client().checkGrammarOfString(spellDocumentTag, String(text, length), grammarDetails, badGrammarLocation, badGrammarLength);
 }
 
 bool TextChecker::spellingUIIsShowing()
 {
-    notImplemented();
-    return false;
+    return WebTextChecker::shared()->client().spellingUIIsShowing();
 }
 
 void TextChecker::toggleSpellingUIIsShowing()
 {
-    notImplemented();
+    WebTextChecker::shared()->client().toggleSpellingUIIsShowing();
 }
 
-void TextChecker::updateSpellingUIWithMisspelledWord(int64_t, const String&)
+void TextChecker::updateSpellingUIWithMisspelledWord(int64_t spellDocumentTag, const String& misspelledWord)
 {
-    notImplemented();
+    WebTextChecker::shared()->client().updateSpellingUIWithMisspelledWord(spellDocumentTag, misspelledWord);
 }
 
-void TextChecker::updateSpellingUIWithGrammarString(int64_t, const String&, const GrammarDetail&)
+void TextChecker::updateSpellingUIWithGrammarString(int64_t spellDocumentTag, const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
 {
-    notImplemented();
+    WebTextChecker::shared()->client().updateSpellingUIWithGrammarString(spellDocumentTag, badGrammarPhrase, grammarDetail);
 }
 
 void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& context, Vector<String>& guesses)
 {
-    notImplemented();
+    WebTextChecker::shared()->client().guessesForWord(spellDocumentTag, word, guesses);
 }
 
-void TextChecker::learnWord(int64_t, const String&)
+void TextChecker::learnWord(int64_t spellDocumentTag, const String& word)
 {
-    notImplemented();
+    WebTextChecker::shared()->client().learnWord(spellDocumentTag, word);
 }
 
 void TextChecker::ignoreWord(int64_t spellDocumentTag, const String& word)
 {
-    notImplemented();
+    WebTextChecker::shared()->client().ignoreWord(spellDocumentTag, word);
 }
 
 } // namespace WebKit
index 426f655..20a63ea 100644 (file)
@@ -213,6 +213,16 @@ void TextChecker::toggleSubstitutionsPanelIsShowing()
     [substitutionsPanel orderFront:nil];
 }
 
+void TextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled)
+{
+    textCheckerState.isContinuousSpellCheckingEnabled = enabled;
+}
+
+void TextChecker::grammarCheckingEnabledStateChanged(bool enabled)
+{
+    textCheckerState.isGrammarCheckingEnabled = enabled;
+}
+
 int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy*)
 {
     return [NSSpellChecker uniqueSpellDocumentTag];
index 2582cc2..4a33184 100644 (file)
@@ -59,6 +59,16 @@ void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled)
     notImplemented();
 }
 
+void TextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled)
+{
+    notImplemented();
+}
+
+void TextChecker::grammarCheckingEnabledStateChanged(bool enabled)
+{
+    notImplemented();
+}
+
 int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy*)
 {
     notImplemented();