Title: [124741] trunk
Revision
124741
Author
ma...@webkit.org
Date
2012-08-06 01:00:02 -0700 (Mon, 06 Aug 2012)

Log Message

[WK2][GTK] Implement a new spell checker API for WebKit2GTK+
https://bugs.webkit.org/show_bug.cgi?id=90268

Reviewed by Martin Robinson.

Source/WebKit2:

Add a simple spell checking API to WK2, allowing to enable/disable
this feature and to define a list of languages associated to it.

* GNUmakefile.am: Add flags to handle the SPELLCHECK feature.
* GNUmakefile.list.am: Added new files

Added new internal class that will act both as the implementation
of TextCheckerClient and as the object WebKitWebContext will
depend on to implement the newly added API.

* UIProcess/API/gtk/WebKitTextChecker.cpp: Added.
(toTextChecker):
(continuousSpellCheckingEnabledCallback):
(setContinuousSpellCheckingEnabledCallback):
(checkSpellingOfStringCallback):
(guessesForWordCallback):
(learnWordCallback):
(ignoreWordCallback):
(WebKitTextChecker::~WebKitTextChecker):
(WebKitTextChecker::create):
(WebKitTextChecker::WebKitTextChecker):
(WebKitTextChecker::checkSpellingOfString):
(WebKitTextChecker::getGuessesForWord):
(WebKitTextChecker::learnWord):
(WebKitTextChecker::ignoreWord):
(WebKitTextChecker::setSpellCheckingEnabled):
(WebKitTextChecker::setSpellCheckingLanguages):
* UIProcess/API/gtk/WebKitTextChecker.h: Added.
(WebKitTextChecker):
(WebKitTextChecker::isSpellCheckingEnabled):
(WebKitTextChecker::getSpellCheckingLanguages):

Added WKTextChecker to WebKitPrivate.h, needed in WebKitTextChecker.

* UIProcess/API/gtk/WebKitPrivate.h:

Add new API to WebKitWebContext to allow enabling/disabling this
spell checking feature, and to set/get the list of languages used
to decide which dictionaries will be consulted.

* UIProcess/API/gtk/WebKitWebContext.cpp:
(_WebKitWebContextPrivate):
(createDefaultWebContext):
(webkit_web_context_get_spell_checking_enabled): New API.
(webkit_web_context_set_spell_checking_enabled): Ditto.
(webkit_web_context_get_spell_checking_languages): Ditto.
(webkit_web_context_set_spell_checking_languages): Ditto.
* UIProcess/API/gtk/WebKitWebContext.h:

New tests for checking the new API added to WebKitWebContext.

* UIProcess/API/gtk/tests/TestWebKitWebContext.cpp:
(testWebContextSpellChecker):
(beforeAll):

Update documentation with new sections and symbols.

* UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt:

Tools:

Ignore WebKitTextChecker.* private files for gtk-doc.

* gtk/generate-gtkdoc:
(get_webkit2_options):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (124740 => 124741)


--- trunk/Source/WebKit2/ChangeLog	2012-08-06 07:57:14 UTC (rev 124740)
+++ trunk/Source/WebKit2/ChangeLog	2012-08-06 08:00:02 UTC (rev 124741)
@@ -1,3 +1,70 @@
+2012-08-06  Mario Sanchez Prada  <msanc...@igalia.com>
+
+        [WK2][GTK] Implement a new spell checker API for WebKit2GTK+
+        https://bugs.webkit.org/show_bug.cgi?id=90268
+
+        Reviewed by Martin Robinson.
+
+        Add a simple spell checking API to WK2, allowing to enable/disable
+        this feature and to define a list of languages associated to it.
+
+        * GNUmakefile.am: Add flags to handle the SPELLCHECK feature.
+        * GNUmakefile.list.am: Added new files
+
+        Added new internal class that will act both as the implementation
+        of TextCheckerClient and as the object WebKitWebContext will
+        depend on to implement the newly added API.
+
+        * UIProcess/API/gtk/WebKitTextChecker.cpp: Added.
+        (toTextChecker):
+        (continuousSpellCheckingEnabledCallback):
+        (setContinuousSpellCheckingEnabledCallback):
+        (checkSpellingOfStringCallback):
+        (guessesForWordCallback):
+        (learnWordCallback):
+        (ignoreWordCallback):
+        (WebKitTextChecker::~WebKitTextChecker):
+        (WebKitTextChecker::create):
+        (WebKitTextChecker::WebKitTextChecker):
+        (WebKitTextChecker::checkSpellingOfString):
+        (WebKitTextChecker::getGuessesForWord):
+        (WebKitTextChecker::learnWord):
+        (WebKitTextChecker::ignoreWord):
+        (WebKitTextChecker::setSpellCheckingEnabled):
+        (WebKitTextChecker::setSpellCheckingLanguages):
+        * UIProcess/API/gtk/WebKitTextChecker.h: Added.
+        (WebKitTextChecker):
+        (WebKitTextChecker::isSpellCheckingEnabled):
+        (WebKitTextChecker::getSpellCheckingLanguages):
+
+        Added WKTextChecker to WebKitPrivate.h, needed in WebKitTextChecker.
+
+        * UIProcess/API/gtk/WebKitPrivate.h:
+
+        Add new API to WebKitWebContext to allow enabling/disabling this
+        spell checking feature, and to set/get the list of languages used
+        to decide which dictionaries will be consulted.
+
+        * UIProcess/API/gtk/WebKitWebContext.cpp:
+        (_WebKitWebContextPrivate):
+        (createDefaultWebContext):
+        (webkit_web_context_get_spell_checking_enabled): New API.
+        (webkit_web_context_set_spell_checking_enabled): Ditto.
+        (webkit_web_context_get_spell_checking_languages): Ditto.
+        (webkit_web_context_set_spell_checking_languages): Ditto.
+        * UIProcess/API/gtk/WebKitWebContext.h:
+
+        New tests for checking the new API added to WebKitWebContext.
+
+        * UIProcess/API/gtk/tests/TestWebKitWebContext.cpp:
+        (testWebContextSpellChecker):
+        (beforeAll):
+
+        Update documentation with new sections and symbols.
+
+        * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
+        * UIProcess/API/gtk/docs/webkit2gtk-sections.txt:
+
 2012-08-05  Benjamin Poulain  <bpoul...@apple.com>
 
         Assert in checkValidity() in hashtable.h from WebGeolocationManager::didFailToDeterminePosition() when fetching http://html5demos.com/geo

Modified: trunk/Source/WebKit2/GNUmakefile.am (124740 => 124741)


--- trunk/Source/WebKit2/GNUmakefile.am	2012-08-06 07:57:14 UTC (rev 124740)
+++ trunk/Source/WebKit2/GNUmakefile.am	2012-08-06 08:00:02 UTC (rev 124741)
@@ -162,7 +162,6 @@
 	libWebCoreGtk.la \
 	$(CAIRO_LIBS) \
 	$(COVERAGE_LDFLAGS) \
-	$(ENCHANT_LIBS) \
 	$(FARSTREAM_LIBS) \
 	$(GAIL_LIBS) \
 	$(GAMEPAD_LIBS) \
@@ -184,6 +183,16 @@
 	$(XT_LIBS) \
 	$(ZLIB_LIBS)
 
+if ENABLE_SPELLCHECK
+libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_CPPFLAGS += \
+	-DENABLE_SPELLCHECK=1 \
+	$(ENCHANT_CFLAGS)
+
+libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_LIBADD += \
+	$(ENCHANT_LIBS)
+endif
+
+
 if ENABLE_WEBKIT2
 pkgconfig_DATA += Source/WebKit2/webkit2gtk-@WEBKITGTK_API_VERSION@.pc
 endif

Modified: trunk/Source/WebKit2/GNUmakefile.list.am (124740 => 124741)


--- trunk/Source/WebKit2/GNUmakefile.list.am	2012-08-06 07:57:14 UTC (rev 124740)
+++ trunk/Source/WebKit2/GNUmakefile.list.am	2012-08-06 08:00:02 UTC (rev 124741)
@@ -697,6 +697,8 @@
 	Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp \
 	Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h \
 	Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h \
+	Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp \
+	Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h \
 	Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp \
 	Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.h \
 	Source/WebKit2/UIProcess/API/gtk/WebKitURIRequest.cpp \

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h (124740 => 124741)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h	2012-08-06 07:57:14 UTC (rev 124740)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h	2012-08-06 08:00:02 UTC (rev 124741)
@@ -40,6 +40,7 @@
 #include <WebKit2/WKSerializedScriptValue.h>
 #include <WebKit2/WKSoupRequestManager.h>
 #include <WebKit2/WKString.h>
+#include <WebKit2/WKTextChecker.h>
 #include <WebKit2/WebKit2_C.h>
 #include <glib.h>
 #include <wtf/Assertions.h>

Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp (0 => 124741)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp	2012-08-06 08:00:02 UTC (rev 124741)
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * 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 "WebKitTextChecker.h"
+
+#if ENABLE(SPELLCHECK)
+
+#include "WebKitPrivate.h"
+#include <wtf/Vector.h>
+#include <wtf/text/CString.h>
+
+using namespace WebKit;
+
+static inline WebKitTextChecker* toTextChecker(const void* clientInfo)
+{
+    return static_cast<WebKitTextChecker*>(const_cast<void*>(clientInfo));
+}
+
+static bool continuousSpellCheckingEnabledCallback(const void* clientInfo)
+{
+    return toTextChecker(clientInfo)->isSpellCheckingEnabled();
+}
+
+static void setContinuousSpellCheckingEnabledCallback(bool enabled, const void* clientInfo)
+{
+    toTextChecker(clientInfo)->setSpellCheckingEnabled(enabled);
+}
+
+static void checkSpellingOfStringCallback(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void* clientInfo)
+{
+    toTextChecker(clientInfo)->checkSpellingOfString(toImpl(text)->string(), *misspellingLocation, *misspellingLength);
+}
+
+static WKArrayRef guessesForWordCallback(uint64_t tag, WKStringRef word, const void* clientInfo)
+{
+    Vector<String> guesses = toTextChecker(clientInfo)->getGuessesForWord(toImpl(word)->string());
+    if (guesses.isEmpty())
+        return 0;
+
+    WKMutableArrayRef wkSuggestions = WKMutableArrayCreate();
+    for (Vector<String>::const_iterator iter = guesses.begin(); iter != guesses.end(); ++iter) {
+        WKRetainPtr<WKStringRef> wkSuggestion(AdoptWK, WKStringCreateWithUTF8CString(iter->utf8().data()));
+        WKArrayAppendItem(wkSuggestions, wkSuggestion.get());
+    }
+
+    return wkSuggestions;
+}
+
+static void learnWordCallback(uint64_t tag, WKStringRef word, const void* clientInfo)
+{
+    toTextChecker(clientInfo)->learnWord(toImpl(word)->string());
+}
+
+static void ignoreWordCallback(uint64_t tag, WKStringRef word, const void* clientInfo)
+{
+    toTextChecker(clientInfo)->ignoreWord(toImpl(word)->string());
+}
+
+WebKitTextChecker::~WebKitTextChecker()
+{
+}
+
+WebKitTextChecker::WebKitTextChecker()
+    : m_textChecker(WebCore::TextCheckerEnchant::create())
+    , m_spellCheckingEnabled(false)
+{
+    WKTextCheckerClient wkTextCheckerClient = {
+        kWKTextCheckerClientCurrentVersion,
+        this, // clientInfo
+        0, // continuousSpellCheckingAllowed
+        continuousSpellCheckingEnabledCallback,
+        setContinuousSpellCheckingEnabledCallback,
+        0, // grammarCheckingEnabled
+        0, // setGrammarCheckingEnabled
+        0, // uniqueSpellDocumentTag
+        0, // closeSpellDocumentWithTag
+        checkSpellingOfStringCallback,
+        0, // checkGrammarOfString
+        0, // spellingUIIsShowing
+        0, // toggleSpellingUIIsShowing
+        0, // updateSpellingUIWithMisspelledWord
+        0, // updateSpellingUIWithGrammarString
+        guessesForWordCallback,
+        learnWordCallback,
+        ignoreWordCallback,
+    };
+    WKTextCheckerSetClient(&wkTextCheckerClient);
+}
+
+void WebKitTextChecker::checkSpellingOfString(const String& string, int& misspellingLocation, int& misspellingLength)
+{
+    m_textChecker->checkSpellingOfString(string, misspellingLocation, misspellingLength);
+}
+
+Vector<String> WebKitTextChecker::getGuessesForWord(const String& word)
+{
+    return m_textChecker->getGuessesForWord(word);
+}
+
+void WebKitTextChecker::learnWord(const String& word)
+{
+    m_textChecker->learnWord(word);
+}
+
+void WebKitTextChecker::ignoreWord(const String& word)
+{
+    m_textChecker->ignoreWord(word);
+}
+
+void WebKitTextChecker::setSpellCheckingEnabled(bool enabled)
+{
+    if (m_spellCheckingEnabled == enabled)
+        return;
+    m_spellCheckingEnabled = enabled;
+
+    // We need to notify the Web process that this has changed.
+    WKTextCheckerContinuousSpellCheckingEnabledStateChanged(enabled);
+}
+
+void WebKitTextChecker::setSpellCheckingLanguages(const String& languages)
+{
+    if (m_spellCheckingLanguages == languages)
+        return;
+    m_spellCheckingLanguages = languages;
+
+    // We need to update the languages in the enchant-based checker too.
+    m_textChecker->updateSpellCheckingLanguages(languages);
+}
+#endif // ENABLE(SPELLCHECK)

Added: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h (0 => 124741)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h	2012-08-06 08:00:02 UTC (rev 124741)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef WebKitTextChecker_h
+#define WebKitTextChecker_h
+
+#if ENABLE(SPELLCHECK)
+
+#include <WebCore/TextCheckerEnchant.h>
+#include <wtf/FastAllocBase.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/Vector.h>
+
+class WebKitTextChecker {
+    WTF_MAKE_FAST_ALLOCATED;
+
+public:
+    static PassOwnPtr<WebKitTextChecker> create() { return adoptPtr(new WebKitTextChecker()); }
+    virtual ~WebKitTextChecker();
+
+    // For implementing TextCheckerClient.
+    bool isSpellCheckingEnabled() { return m_spellCheckingEnabled; }
+    void setSpellCheckingEnabled(bool enabled);
+    void checkSpellingOfString(const String& string, int& misspellingLocation, int& misspellingLength);
+    Vector<String> getGuessesForWord(const String& word);
+    void learnWord(const String& word);
+    void ignoreWord(const String& word);
+
+    // To be called from WebKitWebContext only.
+    const String getSpellCheckingLanguages() { return m_spellCheckingLanguages; }
+    void setSpellCheckingLanguages(const String& spellCheckingLanguages);
+
+private:
+    WebKitTextChecker();
+
+    OwnPtr<WebCore::TextCheckerEnchant> m_textChecker;
+    String m_spellCheckingLanguages;
+    bool m_spellCheckingEnabled;
+};
+
+#endif // ENABLE(SPELLCHECK)
+
+#endif // WebKitTextChecker_h

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (124740 => 124741)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp	2012-08-06 07:57:14 UTC (rev 124740)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp	2012-08-06 08:00:02 UTC (rev 124741)
@@ -28,10 +28,13 @@
 #include "WebKitPluginPrivate.h"
 #include "WebKitPrivate.h"
 #include "WebKitRequestManagerClient.h"
+#include "WebKitTextChecker.h"
 #include "WebKitURISchemeRequestPrivate.h"
 #include "WebKitWebContextPrivate.h"
 #include <WebCore/FileSystem.h>
 #include <wtf/HashMap.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/gobject/GOwnPtr.h>
 #include <wtf/gobject/GRefPtr.h>
 #include <wtf/text/CString.h>
 
@@ -72,6 +75,10 @@
 #if ENABLE(GEOLOCATION)
     RefPtr<WebKitGeolocationProvider> geolocationProvider;
 #endif
+#if ENABLE(SPELLCHECK)
+    OwnPtr<WebKitTextChecker> textChecker;
+    GOwnPtr<gchar> spellCheckingLanguages;
+#endif
 };
 
 static guint signals[LAST_SIGNAL] = { 0, };
@@ -127,6 +134,9 @@
     WKGeolocationManagerRef wkGeolocationManager = WKContextGetGeolocationManager(webContext->priv->context.get());
     webContext->priv->geolocationProvider = WebKitGeolocationProvider::create(wkGeolocationManager);
 #endif
+#if ENABLE(SPELLCHECK)
+    webContext->priv->textChecker = WebKitTextChecker::create();
+#endif
     return webContext.get();
 }
 
@@ -418,6 +428,88 @@
     WKSoupRequestManagerRegisterURIScheme(context->priv->requestManager.get(), wkScheme.get());
 }
 
+/**
+ * webkit_web_context_get_spell_checking_enabled:
+ * @context: a #WebKitWebContext
+ *
+ * Get the current status of the spell checking feature.
+ *
+ * Returns: %TRUE If spell checking is enabled, or %FALSE otherwise.
+ */
+gboolean webkit_web_context_get_spell_checking_enabled(WebKitWebContext* context)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), FALSE);
+
+#if ENABLE(SPELLCHECK)
+    return context->priv->textChecker->isSpellCheckingEnabled();
+#else
+    return false;
+#endif
+}
+
+/**
+ * webkit_web_context_set_spell_checking_enabled:
+ * @context: a #WebKitWebContext
+ * @enabled: Value to be set
+ *
+ * Enable or disable the spell checking feature.
+ */
+void webkit_web_context_set_spell_checking_enabled(WebKitWebContext* context, gboolean enabled)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
+
+#if ENABLE(SPELLCHECK)
+    context->priv->textChecker->setSpellCheckingEnabled(enabled);
+#endif
+}
+
+/**
+ * webkit_web_context_get_spell_checking_languages:
+ * @context: a #WebKitWebContext
+ *
+ * Get the the list of spell checking languages associated with
+ * @context, separated by commas. See
+ * webkit_web_context_set_spell_checking_languages() for more details
+ * on the format of the languages in the list.
+ *
+ * Returns: (transfer none): A comma separated list of languages.
+ */
+const gchar* webkit_web_context_get_spell_checking_languages(WebKitWebContext* context)
+{
+    g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0);
+
+#if ENABLE(SPELLCHECK)
+    return context->priv->spellCheckingLanguages.get();
+#else
+    return 0;
+#endif
+}
+
+/**
+ * webkit_web_context_set_spell_checking_languages:
+ * @context: a #WebKitWebContext
+ * @languages: (allow-none): new list of spell checking
+ * languages separated by commas, or %NULL
+ *
+ * Set the list of spell checking languages to be used for spell
+ * checking, separated by commas. In case %NULL is passed, the default
+ * value as returned by gtk_get_default_language() will be used.
+ *
+ * The locale string typically is in the form lang_COUNTRY, where lang
+ * is an ISO-639 language code, and COUNTRY is an ISO-3166 country code.
+ * For instance, sv_FI for Swedish as written in Finland or pt_BR
+ * for Portuguese as written in Brazil.
+ */
+void webkit_web_context_set_spell_checking_languages(WebKitWebContext* context, const gchar* languages)
+{
+    g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
+
+#if ENABLE(SPELLCHECK)
+    context->priv->textChecker->setSpellCheckingLanguages(String(languages));
+    context->priv->spellCheckingLanguages.set(g_strdup(languages));
+#endif
+}
+
 WebKitDownload* webkitWebContextGetOrCreateDownload(WKDownloadRef wkDownload)
 {
     GRefPtr<WebKitDownload> download = downloadsMap().get(wkDownload);

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h (124740 => 124741)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h	2012-08-06 07:57:14 UTC (rev 124740)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h	2012-08-06 08:00:02 UTC (rev 124741)
@@ -132,6 +132,20 @@
                                                      const gchar                   *scheme,
                                                      WebKitURISchemeRequestCallback callback,
                                                      gpointer                       user_data);
+
+WEBKIT_API gboolean
+webkit_web_context_get_spell_checking_enabled       (WebKitWebContext              *context);
+
+WEBKIT_API void
+webkit_web_context_set_spell_checking_enabled       (WebKitWebContext              *context,
+                                                     gboolean                       enabled);
+WEBKIT_API const gchar *
+webkit_web_context_get_spell_checking_languages     (WebKitWebContext              *context);
+
+WEBKIT_API void
+webkit_web_context_set_spell_checking_languages     (WebKitWebContext              *context,
+                                                     const gchar                   *languages);
+
 G_END_DECLS
 
 #endif

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (124740 => 124741)


--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2012-08-06 07:57:14 UTC (rev 124740)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt	2012-08-06 08:00:02 UTC (rev 124741)
@@ -33,6 +33,10 @@
 webkit_web_context_set_additional_plugins_directory
 webkit_web_context_get_plugins
 webkit_web_context_get_plugins_finish
+webkit_web_context_get_spell_checking_enabled
+webkit_web_context_set_spell_checking_enabled
+webkit_web_context_get_spell_checking_languages
+webkit_web_context_set_spell_checking_languages
 
 <SUBSECTION URI Scheme>
 WebKitURISchemeRequestCallback

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp (124740 => 124741)


--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp	2012-08-06 07:57:14 UTC (rev 124740)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp	2012-08-06 08:00:02 UTC (rev 124741)
@@ -231,11 +231,38 @@
     g_assert(!test->m_loadEvents.contains(LoadTrackingTest::LoadFailed));
 }
 
+static void testWebContextSpellChecker(Test* test, gconstpointer)
+{
+    GRefPtr<WebKitWebContext> webContext(webkit_web_context_get_default());
+
+    // Set the language to a specific one, an empty one and a list of them.
+    webkit_web_context_set_spell_checking_languages(webContext.get(), "en_US");
+    const gchar* currentLanguage(webkit_web_context_get_spell_checking_languages(webContext.get()));
+    g_assert_cmpstr(currentLanguage, ==, "en_US");
+
+    webkit_web_context_set_spell_checking_languages(webContext.get(), 0);
+    currentLanguage = webkit_web_context_get_spell_checking_languages(webContext.get());
+    g_assert_cmpstr(currentLanguage, ==, 0);
+
+    webkit_web_context_set_spell_checking_languages(webContext.get(), "es_ES,en_US");
+    currentLanguage = webkit_web_context_get_spell_checking_languages(webContext.get());
+    g_assert_cmpstr(currentLanguage, ==, "es_ES,en_US");
+
+    // Check disabling and re-enabling spell checking.
+    webkit_web_context_set_spell_checking_enabled(webContext.get(), FALSE);
+    gboolean isSpellCheckingEnabled = webkit_web_context_get_spell_checking_enabled(webContext.get());
+    g_assert(!isSpellCheckingEnabled);
+    webkit_web_context_set_spell_checking_enabled(webContext.get(), TRUE);
+    isSpellCheckingEnabled = webkit_web_context_get_spell_checking_enabled(webContext.get());
+    g_assert(isSpellCheckingEnabled);
+}
+
 void beforeAll()
 {
     Test::add("WebKitWebContext", "default-context", testWebContextDefault);
     PluginsTest::add("WebKitWebContext", "get-plugins", testWebContextGetPlugins);
     URISchemeTest::add("WebKitWebContext", "uri-scheme", testWebContextURIScheme);
+    Test::add("WebKitWebContext", "spell-checker", testWebContextSpellChecker);
 }
 
 void afterAll()

Modified: trunk/Tools/ChangeLog (124740 => 124741)


--- trunk/Tools/ChangeLog	2012-08-06 07:57:14 UTC (rev 124740)
+++ trunk/Tools/ChangeLog	2012-08-06 08:00:02 UTC (rev 124741)
@@ -1,3 +1,15 @@
+2012-08-06  Mario Sanchez Prada  <msanc...@igalia.com>
+
+        [WK2][GTK] Implement a new spell checker API for WebKit2GTK+
+        https://bugs.webkit.org/show_bug.cgi?id=90268
+
+        Reviewed by Martin Robinson.
+
+        Ignore WebKitTextChecker.* private files for gtk-doc.
+
+        * gtk/generate-gtkdoc:
+        (get_webkit2_options):
+
 2012-08-06  Gyuyoung Kim  <gyuyoung....@samsung.com>
 
         Unreviewed. Roll out r124728 because of build bot test fail.

Modified: trunk/Tools/gtk/generate-gtkdoc (124740 => 124741)


--- trunk/Tools/gtk/generate-gtkdoc	2012-08-06 07:57:14 UTC (rev 124740)
+++ trunk/Tools/gtk/generate-gtkdoc	2012-08-06 08:00:02 UTC (rev 124741)
@@ -99,6 +99,7 @@
                          glob.glob(src_path('*Client*')) + \
                          glob.glob(src_path('WebKitWebViewBaseAccessible.*')) + \
                          glob.glob(src_path('WebKitGeolocationProvider.*')) + \
+                         glob.glob(src_path('WebKitTextChecker.*')) + \
                          glob.glob(derived_sources_path('webkit2gtk', 'webkit2', 'WebKitMarshal.*')) + \
                          glob.glob(derived_sources_path('webkit2gtk', 'webkit2', 'WebKitEnumTypes.*')) + \
                          glob.glob(src_path('tests/*.h'))
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to