Changeset 123967 in webkit
- Timestamp:
- Jul 28, 2012 11:45:12 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r123933 r123967 1 2012-07-28 Mario Sanchez Prada <msanchez@igalia.com> 2 3 [WK2][GTK] Implement a new spell checker API for WebKit2GTK+ 4 https://bugs.webkit.org/show_bug.cgi?id=90268 5 6 Reviewed by Martin Robinson. 7 8 Add a simple spell checking API to WK2, allowing to enable/disable 9 this feature and to define a list of languages associated to it. 10 11 * GNUmakefile.am: Add flags to handle the SPELLCHECK feature. 12 * GNUmakefile.list.am: Added new files 13 14 Added new internal class that will act both as the implementation 15 of TextCheckerClient and as the object WebKitWebContext will 16 depend on to implement the newly added API. 17 18 * UIProcess/API/gtk/WebKitTextChecker.cpp: Added. 19 (toTextChecker): 20 (continuousSpellCheckingEnabledCallback): 21 (setContinuousSpellCheckingEnabledCallback): 22 (checkSpellingOfStringCallback): 23 (guessesForWordCallback): 24 (learnWordCallback): 25 (ignoreWordCallback): 26 (WebKitTextChecker::~WebKitTextChecker): 27 (WebKitTextChecker::create): 28 (WebKitTextChecker::WebKitTextChecker): 29 (WebKitTextChecker::checkSpellingOfString): 30 (WebKitTextChecker::getGuessesForWord): 31 (WebKitTextChecker::learnWord): 32 (WebKitTextChecker::ignoreWord): 33 (WebKitTextChecker::setSpellCheckingEnabled): 34 (WebKitTextChecker::setSpellCheckingLanguages): 35 * UIProcess/API/gtk/WebKitTextChecker.h: Added. 36 (WebKitTextChecker): 37 (WebKitTextChecker::isSpellCheckingEnabled): 38 (WebKitTextChecker::getSpellCheckingLanguages): 39 40 Added WKTextChecker to WebKitPrivate.h, needed in WebKitTextChecker. 41 42 * UIProcess/API/gtk/WebKitPrivate.h: 43 44 Add new API to WebKitWebContext to allow enabling/disabling this 45 spell checking feature, and to set/get the list of languages used 46 to decide which dictionaries will be consulted. 47 48 * UIProcess/API/gtk/WebKitWebContext.cpp: 49 (_WebKitWebContextPrivate): 50 (createDefaultWebContext): 51 (webkit_web_context_get_spell_checking_enabled): New API. 52 (webkit_web_context_set_spell_checking_enabled): Ditto. 53 (webkit_web_context_get_spell_checking_languages): Ditto. 54 (webkit_web_context_set_spell_checking_languages): Ditto. 55 * UIProcess/API/gtk/WebKitWebContext.h: 56 57 New tests for checking the new API added to WebKitWebContext. 58 59 * UIProcess/API/gtk/tests/TestWebKitWebContext.cpp: 60 (testWebContextSpellChecker): 61 (beforeAll): 62 63 Update documentation with new sections and symbols. 64 65 * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: 66 * UIProcess/API/gtk/docs/webkit2gtk-sections.txt: 67 1 68 2012-07-27 Christophe Dumez <christophe.dumez@intel.com> 2 69 -
trunk/Source/WebKit2/GNUmakefile.am
r123019 r123967 163 163 $(CAIRO_LIBS) \ 164 164 $(COVERAGE_LDFLAGS) \ 165 $(ENCHANT_LIBS) \166 165 $(GAIL_LIBS) \ 167 166 $(GAMEPAD_LIBS) \ … … 183 182 $(XT_LIBS) \ 184 183 $(ZLIB_LIBS) 184 185 if ENABLE_SPELLCHECK 186 libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_CPPFLAGS += \ 187 -DENABLE_SPELLCHECK=1 \ 188 $(ENCHANT_CFLAGS) 189 190 libwebkit2gtk_@WEBKITGTK_API_MAJOR_VERSION@_@WEBKITGTK_API_MINOR_VERSION@_la_LIBADD += \ 191 $(ENCHANT_LIBS) 192 endif 193 185 194 186 195 if ENABLE_WEBKIT2 -
trunk/Source/WebKit2/GNUmakefile.list.am
r123778 r123967 702 702 Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h \ 703 703 Source/WebKit2/UIProcess/API/gtk/WebKitSettingsPrivate.h \ 704 Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp \ 705 Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h \ 704 706 Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp \ 705 707 Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.h \ -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
r119700 r123967 41 41 #include <WebKit2/WKSoupRequestManager.h> 42 42 #include <WebKit2/WKString.h> 43 #include <WebKit2/WKTextChecker.h> 43 44 #include <WebKit2/WebKit2.h> 44 45 #include <glib.h> -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
r122223 r123967 29 29 #include "WebKitPrivate.h" 30 30 #include "WebKitRequestManagerClient.h" 31 #include "WebKitTextChecker.h" 31 32 #include "WebKitURISchemeRequestPrivate.h" 32 33 #include "WebKitWebContextPrivate.h" 33 34 #include <WebCore/FileSystem.h> 34 35 #include <wtf/HashMap.h> 36 #include <wtf/OwnPtr.h> 37 #include <wtf/gobject/GOwnPtr.h> 35 38 #include <wtf/gobject/GRefPtr.h> 36 39 #include <wtf/text/CString.h> … … 72 75 #if ENABLE(GEOLOCATION) 73 76 RefPtr<WebKitGeolocationProvider> geolocationProvider; 77 #endif 78 #if ENABLE(SPELLCHECK) 79 OwnPtr<WebKitTextChecker> textChecker; 80 GOwnPtr<gchar> spellCheckingLanguages; 74 81 #endif 75 82 }; … … 127 134 WKGeolocationManagerRef wkGeolocationManager = WKContextGetGeolocationManager(webContext->priv->context.get()); 128 135 webContext->priv->geolocationProvider = WebKitGeolocationProvider::create(wkGeolocationManager); 136 #endif 137 #if ENABLE(SPELLCHECK) 138 webContext->priv->textChecker = WebKitTextChecker::create(); 129 139 #endif 130 140 return webContext.get(); … … 419 429 } 420 430 431 /** 432 * webkit_web_context_get_spell_checking_enabled: 433 * @context: a #WebKitWebContext 434 * 435 * Get the current status of the spell checking feature. 436 * 437 * Returns: %TRUE If spell checking is enabled, or %FALSE otherwise. 438 */ 439 gboolean webkit_web_context_get_spell_checking_enabled(WebKitWebContext* context) 440 { 441 g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), FALSE); 442 443 #if ENABLE(SPELLCHECK) 444 return context->priv->textChecker->isSpellCheckingEnabled(); 445 #else 446 return false; 447 #endif 448 } 449 450 /** 451 * webkit_web_context_set_spell_checking_enabled: 452 * @context: a #WebKitWebContext 453 * @enabled: Value to be set 454 * 455 * Enable or disable the spell checking feature. 456 */ 457 void webkit_web_context_set_spell_checking_enabled(WebKitWebContext* context, gboolean enabled) 458 { 459 g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); 460 461 #if ENABLE(SPELLCHECK) 462 context->priv->textChecker->setSpellCheckingEnabled(enabled); 463 #endif 464 } 465 466 /** 467 * webkit_web_context_get_spell_checking_languages: 468 * @context: a #WebKitWebContext 469 * 470 * Get the the list of spell checking languages associated with 471 * @context, separated by commas. See 472 * webkit_web_context_set_spell_checking_languages() for more details 473 * on the format of the languages in the list. 474 * 475 * Returns: (transfer none): A comma separated list of languages. 476 */ 477 const gchar* webkit_web_context_get_spell_checking_languages(WebKitWebContext* context) 478 { 479 g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0); 480 481 #if ENABLE(SPELLCHECK) 482 return context->priv->spellCheckingLanguages.get(); 483 #else 484 return 0; 485 #endif 486 } 487 488 /** 489 * webkit_web_context_set_spell_checking_languages: 490 * @context: a #WebKitWebContext 491 * @languages: (allow-none): new list of spell checking 492 * languages separated by commas, or %NULL 493 * 494 * Set the list of spell checking languages to be used for spell 495 * checking, separated by commas. In case %NULL is passed, the default 496 * value as returned by gtk_get_default_language() will be used. 497 * 498 * The locale string typically is in the form lang_COUNTRY, where lang 499 * is an ISO-639 language code, and COUNTRY is an ISO-3166 country code. 500 * For instance, sv_FI for Swedish as written in Finland or pt_BR 501 * for Portuguese as written in Brazil. 502 */ 503 void webkit_web_context_set_spell_checking_languages(WebKitWebContext* context, const gchar* languages) 504 { 505 g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context)); 506 507 #if ENABLE(SPELLCHECK) 508 context->priv->textChecker->setSpellCheckingLanguages(String(languages)); 509 context->priv->spellCheckingLanguages.set(g_strdup(languages)); 510 #endif 511 } 512 421 513 WebKitDownload* webkitWebContextGetOrCreateDownload(WKDownloadRef wkDownload) 422 514 { -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
r122223 r123967 133 133 WebKitURISchemeRequestCallback callback, 134 134 gpointer user_data); 135 136 WEBKIT_API gboolean 137 webkit_web_context_get_spell_checking_enabled (WebKitWebContext *context); 138 139 WEBKIT_API void 140 webkit_web_context_set_spell_checking_enabled (WebKitWebContext *context, 141 gboolean enabled); 142 WEBKIT_API const gchar * 143 webkit_web_context_get_spell_checking_languages (WebKitWebContext *context); 144 145 WEBKIT_API void 146 webkit_web_context_set_spell_checking_languages (WebKitWebContext *context, 147 const gchar *languages); 148 135 149 G_END_DECLS 136 150 -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
r122961 r123967 34 34 webkit_web_context_get_plugins 35 35 webkit_web_context_get_plugins_finish 36 webkit_web_context_get_spell_checking_enabled 37 webkit_web_context_set_spell_checking_enabled 38 webkit_web_context_get_spell_checking_languages 39 webkit_web_context_set_spell_checking_languages 36 40 37 41 <SUBSECTION URI Scheme> -
trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
r119700 r123967 232 232 } 233 233 234 static void testWebContextSpellChecker(Test* test, gconstpointer) 235 { 236 GRefPtr<WebKitWebContext> webContext(webkit_web_context_get_default()); 237 238 // Set the language to a specific one, an empty one and a list of them. 239 webkit_web_context_set_spell_checking_languages(webContext.get(), "en_US"); 240 const gchar* currentLanguage(webkit_web_context_get_spell_checking_languages(webContext.get())); 241 g_assert_cmpstr(currentLanguage, ==, "en_US"); 242 243 webkit_web_context_set_spell_checking_languages(webContext.get(), 0); 244 currentLanguage = webkit_web_context_get_spell_checking_languages(webContext.get()); 245 g_assert_cmpstr(currentLanguage, ==, 0); 246 247 webkit_web_context_set_spell_checking_languages(webContext.get(), "es_ES,en_US"); 248 currentLanguage = webkit_web_context_get_spell_checking_languages(webContext.get()); 249 g_assert_cmpstr(currentLanguage, ==, "es_ES,en_US"); 250 251 // Check disabling and re-enabling spell checking. 252 webkit_web_context_set_spell_checking_enabled(webContext.get(), FALSE); 253 gboolean isSpellCheckingEnabled = webkit_web_context_get_spell_checking_enabled(webContext.get()); 254 g_assert(!isSpellCheckingEnabled); 255 webkit_web_context_set_spell_checking_enabled(webContext.get(), TRUE); 256 isSpellCheckingEnabled = webkit_web_context_get_spell_checking_enabled(webContext.get()); 257 g_assert(isSpellCheckingEnabled); 258 } 259 234 260 void beforeAll() 235 261 { … … 237 263 PluginsTest::add("WebKitWebContext", "get-plugins", testWebContextGetPlugins); 238 264 URISchemeTest::add("WebKitWebContext", "uri-scheme", testWebContextURIScheme); 265 Test::add("WebKitWebContext", "spell-checker", testWebContextSpellChecker); 239 266 } 240 267 -
trunk/Tools/ChangeLog
r123959 r123967 1 2012-07-28 Mario Sanchez Prada <msanchez@igalia.com> 2 3 [WK2][GTK] Implement a new spell checker API for WebKit2GTK+ 4 https://bugs.webkit.org/show_bug.cgi?id=90268 5 6 Reviewed by Martin Robinson. 7 8 Ignore WebKitTextChecker.* private files for gtk-doc. 9 10 * gtk/generate-gtkdoc: 11 (get_webkit2_options): 12 1 13 2012-07-28 Philippe Normand <pnormand@igalia.com> 2 14 -
trunk/Tools/gtk/generate-gtkdoc
r119837 r123967 100 100 glob.glob(src_path('WebKitWebViewBaseAccessible.*')) + \ 101 101 glob.glob(src_path('WebKitGeolocationProvider.*')) + \ 102 glob.glob(src_path('WebKitTextChecker.*')) + \ 102 103 glob.glob(derived_sources_path('webkit2gtk', 'webkit2', 'WebKitMarshal.*')) + \ 103 104 glob.glob(derived_sources_path('webkit2gtk', 'webkit2', 'WebKitEnumTypes.*')) + \
Note: See TracChangeset
for help on using the changeset viewer.