diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-07-30 11:37:48 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-07-30 11:38:52 +0200 |
commit | 89e2486a48b739f8d771d69ede5a6a1b244a10fc (patch) | |
tree | 503b1a7812cf97d93704c32437eb5f62dc1a1ff9 /Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp | |
parent | 625f028249cb37c55bbbd153f3902afd0b0756d9 (diff) | |
download | qtwebkit-89e2486a48b739f8d771d69ede5a6a1b244a10fc.tar.gz |
Imported WebKit commit 0282df8ca7c11d8c8a66ea18543695c69f545a27 (http://svn.webkit.org/repository/webkit/trunk@124002)
New snapshot with prospective Mountain Lion build fix
Diffstat (limited to 'Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp')
-rw-r--r-- | Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp index 8a0625c07..4008e865f 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp @@ -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 @@ struct _WebKitWebContextPrivate { #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 @@ static gpointer createDefaultWebContext(gpointer) 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 @@ void webkit_web_context_register_uri_scheme(WebKitWebContext* context, const cha 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); |