ChangeLog

 12012-10-12 Grzegorz Czajkowski <g.czajkowski@samsung.com>, Michal Roj <m.roj@sasmung.com>
 2
 3 [WK2][EFL] Implementation of spellchecking feature.
 4 https://bugs.webkit.org/show_bug.cgi?id=91854
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Define SPELLCHECK macro and enable it for WK2-Efl.
 9
 10 * Source/cmake/FindEnchant.cmake: Added.
 11 * Source/cmake/OptionsEfl.cmake: Enable spellchecking feature for WebKit2-EFL.
 12 * Source/cmake/WebKitFeatures.cmake: Define the SPELLCHECK macro.
 13 The spellchecking implementation is based on the Enchant library.
 14 It can be used by other WebKit ports.
 15 * Source/cmakeconfig.h.cmake: Add the feature.
 16
1172012-10-12 Balazs Kelemen <kbalazs@webkit.org>
218
319 Unreviewed, rolling out r130389.

Source/WebCore/ChangeLog

 12012-10-12 Grzegorz Czajkowski <g.czajkowski@samsung.com>, Michal Roj <m.roj@samsung.com>
 2
 3 [WK2][EFL] Implementation of spellchecking feature.
 4 https://bugs.webkit.org/show_bug.cgi?id=91854
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * PlatformEfl.cmake:
 9 Add enchant-related compiler flags: header paths and the library flag.
 10
1112012-10-12 Yury Semikhatsky <yurys@chromium.org>
212
313 Web Inspector: move delete watch expression farther from the expand triangle

Source/WebCore/PlatformEfl.cmake

@@LIST(APPEND WebCore_SOURCES
8484 platform/PlatformStrategies.cpp
8585 platform/posix/FileSystemPOSIX.cpp
8686 platform/text/efl/TextBreakIteratorInternalICUEfl.cpp
 87 platform/text/enchant/TextCheckerEnchant.cpp
8788)
8889
8990IF (ENABLE_BATTERY_STATUS)

@@IF (ENABLE_WEB_AUDIO)
325326 INSTALL(FILES ${WEB_AUDIO_DATA} DESTINATION ${WEB_AUDIO_DIR})
326327 ADD_DEFINITIONS(-DUNINSTALLED_AUDIO_RESOURCES_DIR="${WEBCORE_DIR}/platform/audio/resources")
327328ENDIF ()
 329
 330IF (ENABLE_SPELLCHECK)
 331 LIST(APPEND WebCore_INCLUDE_DIRECTORIES
 332 ${ENCHANT_INCLUDE_DIRS}
 333 )
 334 LIST(APPEND WebCore_LIBRARIES
 335 ${ENCHANT_LIBRARIES}
 336 )
 337ENDIF()

Source/WebKit2/ChangeLog

 12012-10-12 Grzegorz Czajkowski <g.czajkowski@samsung.com>, Michal Roj <m.roj@samsung.com>
 2
 3 Implementation of spellchecking feature.
 4 https://bugs.webkit.org/show_bug.cgi?id=91854
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Add spelling implementation for WebKit2-EFL that is based on Enchant library.
 9
 10 Additionally the patch provides API to overwrite the default WebKit spellchecker implementation
 11 as Enchant library doesn't ensure grammar checking.
 12 Application is able to overwrite it (both grammar and spell checking) by defining
 13 its own implementation and setting appropriate callback functions.
 14
 15 * PlatformEfl.cmake:
 16 Add enchant-related compiler flags: header paths and the library flag.
 17
 18 * UIProcess/API/efl/EWebKit2.h:
 19 Add ewk_text_checker.h to the main WebKit2-EFL's header to be available for applications.
 20
 21 * UIProcess/API/efl/WebKitTextChecker.cpp: Added.
 22 Implement callbacks functions of WKTextChecker.
 23
 24 (WebKit):
 25 (WebKit::isContinuousSpellCheckingEnabled):
 26 (WebKit::setContinuousSpellCheckingEnabled):
 27 (WebKit::uniqueSpellDocumentTag):
 28 (WebKit::closeSpellDocumentWithTag):
 29 (WebKit::checkSpellingOfString):
 30 (WebKit::guessesForWord):
 31 (WebKit::learnWord):
 32 (WebKit::ignoreWord):
 33 Those methods are directly given as callback functions for WKTextChecker's client.
 34 They choose between WebKit's spelling implementation and client's ones.
 35
 36 (WebKit::availableSpellCheckingLanguages):
 37 (WebKit::updateSpellCheckingLanguages):
 38 (WebKit::loadedSpellCheckingLanguages):
 39 They are used by ewk_settings.cpp file and allow to do not
 40 expose 'textCheckerEnchant'.
 41
 42 * UIProcess/API/efl/WebKitTextChecker.h: Added.
 43 Define the functions which choose between client's implementation of
 44 spelling and the WebKit one.
 45
 46 (WebKit):
 47 * UIProcess/API/efl/ewk_context.cpp:
 48 (_Ewk_Context::_Ewk_Context):
 49 Attach the spellchecker feature for the context.
 50
 51 * UIProcess/API/efl/ewk_text_checker.cpp: Added.
 52 (ewk_text_checker_callbacks_get):
 53 Get the client's callback functions.
 54
 55 * UIProcess/API/efl/ewk_text_checker.h: Added.
 56 Define API to set the client's own spelling implementation.
 57
 58 * UIProcess/API/efl/ewk_text_checker_private.h: Added.
 59 (_Ewk_Text_Checker):
 60 Define struct with client's callbacks responisble for spelling.
 61
 62 * UIProcess/API/efl/ewk_settings.cpp:
 63 (onContinuousSpellCheckingIdler):
 64 The application is notified about spelling setting change.
 65 It may be changed through context menu option on idler
 66 to do not block WebKit.
 67
 68 (spellCheckingLanguagesSetUpdate):
 69 The dictionaries are requested on idler to do not block WebKit.
 70
 71 (spellCheckingLanguagesSet):
 72 Set the languages.
 73
 74 (ewk_settings_continuous_spell_checking_change_cb_set):
 75 Set the callback function used to notify the client when the spelling
 76 setting was changed by WebKit.
 77
 78 (ewk_settings_continuous_spell_checking_enabled_get):
 79 (ewk_settings_continuous_spell_checking_enabled_set):
 80 API to set/get the continuous spell checking.
 81
 82 (ewk_settings_spell_checking_languages_get):
 83 (ewk_settings_spell_checking_languages_enabled_set):
 84 (ewk_settings_spell_checking_languages_enabled_get):
 85 API to get/set languages to use by WebKit implementation based on Enchant library.
 86
 87 * UIProcess/efl/TextCheckerEfl.cpp:
 88 (WebKit::TextChecker::state):
 89 (WebKit::TextChecker::isContinuousSpellCheckingAllowed):
 90 (WebKit::TextChecker::setContinuousSpellCheckingEnabled):
 91 (WebKit::TextChecker::setGrammarCheckingEnabled):
 92 (WebKit::TextChecker::continuousSpellCheckingEnabledStateChanged):
 93 (WebKit::TextChecker::grammarCheckingEnabledStateChanged):
 94 (WebKit::TextChecker::uniqueSpellDocumentTag):
 95 (WebKit::TextChecker::closeSpellDocumentWithTag):
 96 (WebKit::TextChecker::checkSpellingOfString):
 97 (WebKit::TextChecker::checkGrammarOfString): Remove WebCore namaspace as it's already defined for the whole file.
 98 (WebKit::TextChecker::spellingUIIsShowing):
 99 (WebKit::TextChecker::toggleSpellingUIIsShowing):
 100 (WebKit::TextChecker::updateSpellingUIWithMisspelledWord):
 101 (WebKit::TextChecker::updateSpellingUIWithGrammarString):
 102 (WebKit::TextChecker::getGuessesForWord):
 103 (WebKit::TextChecker::learnWord):
 104 (WebKit::TextChecker::ignoreWord):
 105 Those call WKTextChecker client methods.
 106
11072012-10-12 Sheriff Bot <webkit.review.bot@gmail.com>
2108
3109 Unreviewed, rolling out r131160.

Source/WebKit2/PlatformEfl.cmake

@@LIST(APPEND WebKit2_SOURCES
4646 UIProcess/API/efl/NetworkInfoProvider.cpp
4747 UIProcess/API/efl/PageClientImpl.cpp
4848 UIProcess/API/efl/VibrationProvider.cpp
 49 UIProcess/API/efl/WebKitTextChecker.cpp
4950 UIProcess/API/efl/ewk_back_forward_list.cpp
5051 UIProcess/API/efl/ewk_back_forward_list_item.cpp
5152 UIProcess/API/efl/ewk_context.cpp

@@LIST(APPEND WebKit2_SOURCES
6465 UIProcess/API/efl/ewk_popup_menu_item.cpp
6566 UIProcess/API/efl/ewk_resource.cpp
6667 UIProcess/API/efl/ewk_settings.cpp
 68 UIProcess/API/efl/ewk_text_checker.cpp
6769 UIProcess/API/efl/ewk_url_request.cpp
6870 UIProcess/API/efl/ewk_url_response.cpp
6971 UIProcess/API/efl/ewk_url_scheme_request.cpp

@@LIST(APPEND WebKit2_INCLUDE_DIRECTORIES
135137 "${WEBCORE_DIR}/platform/efl"
136138 "${WEBCORE_DIR}/platform/graphics/cairo"
137139 "${WEBCORE_DIR}/platform/network/soup"
 140 "${WEBCORE_DIR}/platform/text/enchant"
138141 "${WEBCORE_DIR}/svg/graphics"
139142 "${WEBKIT2_DIR}/Shared/efl"
140143 "${WEBKIT2_DIR}/Shared/soup"

@@SET (EWebKit2_HEADERS
240243 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_popup_menu_item.h"
241244 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_resource.h"
242245 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_settings.h"
 246 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_text_checker.h"
243247 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_touch.h"
244248 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_url_request.h"
245249 "${CMAKE_CURRENT_SOURCE_DIR}/UIProcess/API/efl/ewk_url_response.h"

@@IF (ENABLE_INSPECTOR)
367371 PATTERN "*.gif"
368372 PATTERN "*.png")
369373ENDIF ()
 374
 375IF (ENABLE_SPELLCHECK)
 376 LIST(APPEND WebKit2_INCLUDE_DIRECTORIES
 377 ${ENCHANT_INCLUDE_DIRS}
 378 )
 379 LIST(APPEND WebKit2_LIBRARIES
 380 ${ENCHANT_LIBRARIES}
 381 )
 382ENDIF()

Source/WebKit2/UIProcess/API/efl/EWebKit2.h

4343#include "ewk_popup_menu_item.h"
4444#include "ewk_resource.h"
4545#include "ewk_settings.h"
 46#include "ewk_text_checker.h"
4647#include "ewk_touch.h"
4748#include "ewk_url_request.h"
4849#include "ewk_url_response.h"

Source/WebKit2/UIProcess/API/efl/WebKitTextChecker.cpp

 1/*
 2 * Copyright (C) 2012 Samsung Electronics
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 14 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 22 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "WebKitTextChecker.h"
 28
 29#if ENABLE(SPELLCHECK)
 30
 31#include "NotImplemented.h"
 32#include "WKAPICast.h"
 33#include "WKMutableArray.h"
 34#include "WKRetainPtr.h"
 35#include "WebPageProxy.h"
 36#include "WebString.h"
 37#include "ewk_settings.h"
 38#include "ewk_text_checker_private.h"
 39#include <Eina.h>
 40#include <wtf/OwnPtr.h>
 41#include <wtf/text/CString.h>
 42
 43namespace WebKit {
 44
 45static OwnPtr<WebCore::TextCheckerEnchant> textCheckerEnchant = WebCore::TextCheckerEnchant::create();
 46
 47static Ewk_Text_Checker* ewkTextCheckerCallbacks = ewk_text_checker_callbacks_get();
 48
 49bool isContinuousSpellCheckingEnabled(const void*)
 50{
 51 return ewk_settings_continuous_spell_checking_enabled_get();
 52}
 53
 54void setContinuousSpellCheckingEnabled(bool enabled, const void*)
 55{
 56 ewk_settings_continuous_spell_checking_enabled_set(enabled);
 57}
 58
 59uint64_t uniqueSpellDocumentTag(WKPageRef page, const void*)
 60{
 61 if (ewkTextCheckerCallbacks->unique_spell_document_tag_get)
 62 return ewkTextCheckerCallbacks->unique_spell_document_tag_get(toImpl(page)->viewWidget());
 63
 64 return 0;
 65}
 66
 67void closeSpellDocumentWithTag(uint64_t tag, const void*)
 68{
 69 if (ewkTextCheckerCallbacks->unique_spell_document_tag_close)
 70 ewkTextCheckerCallbacks->unique_spell_document_tag_close(tag);
 71}
 72
 73void checkSpellingOfString(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void*)
 74{
 75 if (ewkTextCheckerCallbacks->string_spelling_check)
 76 ewkTextCheckerCallbacks->string_spelling_check(tag, toImpl(text)->string().utf8().data(), misspellingLocation, misspellingLength);
 77 else
 78 textCheckerEnchant->checkSpellingOfString(toImpl(text)->string(), *misspellingLocation, *misspellingLength);
 79}
 80
 81WKArrayRef guessesForWord(uint64_t tag, WKStringRef word, const void*)
 82{
 83 WKMutableArrayRef suggestionsForWord = WKMutableArrayCreate();
 84
 85 if (ewkTextCheckerCallbacks->word_guesses_get) {
 86 Eina_List* list = ewkTextCheckerCallbacks->word_guesses_get(tag, toImpl(word)->string().utf8().data());
 87 void* item;
 88
 89 EINA_LIST_FREE(list, item) {
 90 WKRetainPtr<WKStringRef> suggestion(AdoptWK, WKStringCreateWithUTF8CString(static_cast<char*>(item)));
 91 WKArrayAppendItem(suggestionsForWord, suggestion.get());
 92 free(item);
 93 }
 94 } else {
 95 Vector<String> guesses = textCheckerEnchant->getGuessesForWord(toImpl(word)->string());
 96 size_t numberOfGuesses = guesses.size();
 97 for (size_t i = 0; i < numberOfGuesses; ++i) {
 98 WKRetainPtr<WKStringRef> suggestion(AdoptWK, WKStringCreateWithUTF8CString(guesses[i].utf8().data()));
 99 WKArrayAppendItem(suggestionsForWord, suggestion.get());
 100 }
 101 }
 102
 103 return suggestionsForWord;
 104}
 105
 106void learnWord(uint64_t tag, WKStringRef word, const void*)
 107{
 108 if (ewkTextCheckerCallbacks->word_learn)
 109 ewkTextCheckerCallbacks->word_learn(tag, toImpl(word)->string().utf8().data());
 110 else
 111 textCheckerEnchant->learnWord(toImpl(word)->string());
 112}
 113
 114void ignoreWord(uint64_t tag, WKStringRef word, const void*)
 115{
 116 if (ewkTextCheckerCallbacks->word_ignore)
 117 ewkTextCheckerCallbacks->word_ignore(tag, toImpl(word)->string().utf8().data());
 118 else
 119 textCheckerEnchant->ignoreWord(toImpl(word)->string());
 120}
 121
 122Vector<String> availableSpellCheckingLanguages()
 123{
 124 return textCheckerEnchant->availableSpellCheckingLanguages();
 125}
 126
 127void updateSpellCheckingLanguages(const Vector<String>& languages)
 128{
 129 textCheckerEnchant->updateSpellCheckingLanguages(languages);
 130}
 131
 132Vector<String> loadedSpellCheckingLanguages()
 133{
 134 return textCheckerEnchant->loadedSpellCheckingLanguages();
 135}
 136
 137} // namespace WebKit
 138
 139#endif // ENABLE(SPELLCHECK)

Source/WebKit2/UIProcess/API/efl/WebKitTextChecker.h

 1/*
 2 * Copyright (C) 2012 Samsung Electronics
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 14 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 22 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef WebKitTextChecker_h
 27#define WebKitTextChecker_h
 28
 29#if ENABLE(SPELLCHECK)
 30
 31#include "TextCheckerEnchant.h"
 32#include "WKArray.h"
 33#include "WKPage.h"
 34#include "WKString.h"
 35
 36namespace WebKit {
 37
 38// The functions mainly choose between client's implementation of spelling and the WebKit one.
 39
 40// Callbacks required by WKTextChecker.
 41bool isContinuousSpellCheckingEnabled(const void* clientInfo);
 42void setContinuousSpellCheckingEnabled(bool enabled, const void* clientInfo);
 43
 44uint64_t uniqueSpellDocumentTag(WKPageRef page, const void* clientInfo);
 45void closeSpellDocumentWithTag(uint64_t tag, const void* clientInfo);
 46
 47void checkSpellingOfString(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void* clientInfo);
 48WKArrayRef guessesForWord(uint64_t tag, WKStringRef word, const void* clientInfo);
 49void learnWord(uint64_t tag, WKStringRef word, const void* clientInfo);
 50void ignoreWord(uint64_t tag, WKStringRef word, const void* clientInfo);
 51
 52// Enchant's helper.
 53Vector<String> availableSpellCheckingLanguages();
 54void updateSpellCheckingLanguages(const Vector<String>& languages);
 55Vector<String> loadedSpellCheckingLanguages();
 56
 57} // namespace WebKit
 58
 59#endif // ENABLE(SPELLCHECK)
 60#endif // WebKitTextChecker_h

Source/WebKit2/UIProcess/API/efl/ewk_context.cpp

4040#include <WebCore/FileSystem.h>
4141#include <wtf/HashMap.h>
4242#include <wtf/text/WTFString.h>
 43#if ENABLE(SPELLCHECK)
 44#include "ewk_settings.h"
 45#include "ewk_text_checker_private.h"
 46#endif
4347
4448using namespace WebCore;
4549using namespace WebKit;

@@struct _Ewk_Context {
114118 ewk_context_request_manager_client_attach(this);
115119 ewk_context_download_client_attach(this);
116120 ewk_context_history_client_attach(this);
 121#if ENABLE(SPELLCHECK)
 122 ewk_text_checker_client_attach();
 123 if (ewk_settings_continuous_spell_checking_enabled_get()) {
 124 // Load the default language.
 125 ewk_settings_spell_checking_languages_enabled_set(0);
 126 }
 127#endif
117128 }
118129
119130 ~_Ewk_Context()

Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp

2929#include "ewk_settings_private.h"
3030#include <WebKit2/WKPreferences.h>
3131#include <WebKit2/WKPreferencesPrivate.h>
 32#if ENABLE(SPELLCHECK)
 33#include "WKTextChecker.h"
 34#include "WebKitTextChecker.h"
 35#include <Ecore.h>
 36#include <wtf/Vector.h>
 37#include <wtf/text/CString.h>
 38#endif
3239
3340using namespace WebKit;
3441
 42#if ENABLE(SPELLCHECK)
 43static struct {
 44 bool isContinuousSpellCheckingEnabled : 1;
 45 Vector<String> spellCheckingLanguages;
 46 Ewk_Settings_Continuous_Spell_Checking_Change_Cb onContinuousSpellChecking;
 47} ewkTextCheckerSettings = { false, Vector<String>(), 0 };
 48
 49static Eina_Bool onContinuousSpellCheckingIdler(void*)
 50{
 51 if (ewkTextCheckerSettings.onContinuousSpellChecking)
 52 ewkTextCheckerSettings.onContinuousSpellChecking(ewkTextCheckerSettings.isContinuousSpellCheckingEnabled);
 53
 54 return ECORE_CALLBACK_CANCEL;
 55}
 56
 57static Eina_Bool spellCheckingLanguagesSetUpdate(void*)
 58{
 59 // FIXME: Consider to delegate calling of this method in WebProcess to do not delay/block UIProcess.
 60 updateSpellCheckingLanguages(ewkTextCheckerSettings.spellCheckingLanguages);
 61 return ECORE_CALLBACK_CANCEL;
 62}
 63
 64static void spellCheckingLanguagesSet(const Vector<String>& newLanguages)
 65{
 66 ewkTextCheckerSettings.spellCheckingLanguages = newLanguages;
 67 ecore_idler_add(spellCheckingLanguagesSetUpdate, 0);
 68}
 69#endif // ENABLE(SPELLCHECK)
 70
3571Eina_Bool ewk_settings_fullscreen_enabled_set(Ewk_Settings* settings, Eina_Bool enable)
3672{
3773#if ENABLE(FULLSCREEN_API)

@@Eina_Bool ewk_settings_dns_prefetching_enabled_get(const Ewk_Settings* settings)
148184
149185 return WKPreferencesGetDNSPrefetchingEnabled(settings->preferences.get());
150186}
 187
 188void ewk_settings_continuous_spell_checking_change_cb_set(Ewk_Settings_Continuous_Spell_Checking_Change_Cb callback)
 189{
 190#if ENABLE(SPELLCHECK)
 191 ewkTextCheckerSettings.onContinuousSpellChecking = callback;
 192#endif
 193}
 194
 195Eina_Bool ewk_settings_continuous_spell_checking_enabled_get()
 196{
 197#if ENABLE(SPELLCHECK)
 198 return ewkTextCheckerSettings.isContinuousSpellCheckingEnabled;
 199#else
 200 return false;
 201#endif
 202}
 203
 204void ewk_settings_continuous_spell_checking_enabled_set(Eina_Bool enable)
 205{
 206#if ENABLE(SPELLCHECK)
 207 enable = !!enable;
 208 if (ewkTextCheckerSettings.isContinuousSpellCheckingEnabled != enable) {
 209 ewkTextCheckerSettings.isContinuousSpellCheckingEnabled = enable;
 210
 211 WKTextCheckerContinuousSpellCheckingEnabledStateChanged(enable);
 212
 213 // Sets default language if user didn't specify any.
 214 if (enable && loadedSpellCheckingLanguages().isEmpty())
 215 spellCheckingLanguagesSet(Vector<String>());
 216
 217 if (ewkTextCheckerSettings.onContinuousSpellChecking)
 218 ecore_idler_add(onContinuousSpellCheckingIdler, 0);
 219 }
 220#endif
 221}
 222
 223Eina_List* ewk_settings_spell_checking_languages_get()
 224{
 225 Eina_List* listOflanguages = 0;
 226#if ENABLE(SPELLCHECK)
 227 Vector<String> languages = availableSpellCheckingLanguages();
 228 size_t numberOfLanuages = languages.size();
 229
 230 for (size_t i = 0; i < numberOfLanuages; ++i)
 231 listOflanguages = eina_list_append(listOflanguages, eina_stringshare_add(languages[i].utf8().data()));
 232#endif
 233 return listOflanguages;
 234}
 235
 236void ewk_settings_spell_checking_languages_enabled_set(const char* languages)
 237{
 238#if ENABLE(SPELLCHECK)
 239 Vector<String> newLanguages;
 240 String::fromUTF8(languages).split(',', newLanguages);
 241
 242 spellCheckingLanguagesSet(newLanguages);
 243#endif
 244}
 245
 246Eina_List* ewk_settings_spell_checking_languages_enabled_get()
 247{
 248 Eina_List* listOflanguages = 0;
 249#if ENABLE(SPELLCHECK)
 250 Vector<String> languages = loadedSpellCheckingLanguages();
 251 size_t numberOfLanuages = languages.size();
 252
 253 for (size_t i = 0; i < numberOfLanuages; ++i)
 254 listOflanguages = eina_list_append(listOflanguages, eina_stringshare_add(languages[i].utf8().data()));
 255
 256#endif
 257 return listOflanguages;
 258}

Source/WebKit2/UIProcess/API/efl/ewk_settings.h

@@extern "C" {
4444typedef struct _Ewk_Settings Ewk_Settings;
4545
4646/**
 47 * Creates a type name for the callback function used to notify the client when
 48 * the continuous spell checking setting was changed by WebKit.
 49 *
 50 * @param enable @c EINA_TRUE if continuous spell checking is enabled or @c EINA_FALSE if it's disabled
 51 */
 52typedef void (*Ewk_Settings_Continuous_Spell_Checking_Change_Cb)(Eina_Bool enable);
 53
 54
 55/**
4756 * Enables/disables the Javascript Fullscreen API. The Javascript API allows
4857 * to request full screen mode, for more information see:
4958 * http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html

@@EAPI Eina_Bool ewk_settings_dns_prefetching_enabled_set(Ewk_Settings *settings,
219228 */
220229EAPI Eina_Bool ewk_settings_dns_prefetching_enabled_get(const Ewk_Settings *settings);
221230
 231/**
 232 * Sets a callback function used to notify the client when
 233 * the continuous spell checking setting was changed by WebKit.
 234 *
 235 * Specifying of this callback is needed if the application wants to receive notifications
 236 * once WebKit changes this setting.
 237 * If the application is not interested, this callback is not set.
 238 * Changing of this setting at the WebKit level can be made as a result of modifying
 239 * options in a Context Menu by a user.
 240 *
 241 * @param cb a new callback function to set or @c NULL to invalidate the previous one
 242 */
 243EAPI void ewk_settings_continuous_spell_checking_change_cb_set(Ewk_Settings_Continuous_Spell_Checking_Change_Cb cb);
 244
 245/**
 246 * Queries if continuous spell checking is enabled.
 247 *
 248 * @return @c EINA_TRUE if continuous spell checking is enabled or @c EINA_FALSE if it's disabled
 249 */
 250EAPI Eina_Bool ewk_settings_continuous_spell_checking_enabled_get(void);
 251
 252/**
 253 * Enables/disables continuous spell checking.
 254 *
 255 * Additionally, this function calls a callback function (if defined) to notify
 256 * the client about the change of the setting.
 257 * This feature is disabled by default.
 258 *
 259 * @see ewk_settings_continuous_spell_checking_change_cb_set
 260 *
 261 * @param enable @c EINA_TRUE to enable continuous spell checking or @c EINA_FALSE to disable
 262 */
 263EAPI void ewk_settings_continuous_spell_checking_enabled_set(Eina_Bool enable);
 264
 265/**
 266 * Gets the the list of all available the spell checking languages to use.
 267 *
 268 * @see ewk_settings_spell_checking_languages_enabled_set
 269 *
 270 * @return the list with available spell checking languages, or @c NULL on failure
 271 * the Eina_List and its items should be freed after, use eina_stringshare_del()
 272 */
 273EAPI Eina_List *ewk_settings_spell_checking_languages_get(void);
 274
 275/**
 276 * Sets @a languages as the list of languages to use by default WebKit
 277 * implementation of spellchecker feature with Enchant library support.
 278 *
 279 * If @languages is @c NULL, the default language is used.
 280 * If the default language can not be determined then any available dictionary will be used.
 281 *
 282 * @note This function invalidates the previously set languages.
 283 * The dictionaries are requested asynchronously.
 284 *
 285 * @param languages a list of comma (',') separated language codes
 286 * of the form 'en_US', ie, language_VARIANT, may be @c NULL.
 287 */
 288EAPI void ewk_settings_spell_checking_languages_enabled_set(const char *languages);
 289
 290/**
 291 * Gets the the list of the spell checking languages in use.
 292 *
 293 * @see ewk_settings_spell_checking_languages_get
 294 * @see Ewk_Settings_spell_checking_languages_enabled_set
 295 *
 296 * @return the list with the spell checking languages in use,
 297 * the Eina_List and its items should be freed after, use eina_stringshare_del()
 298 */
 299EAPI Eina_List *ewk_settings_spell_checking_languages_enabled_get(void);
 300
222301#ifdef __cplusplus
223302}
224303#endif

Source/WebKit2/UIProcess/API/efl/ewk_text_checker.cpp

 1/*
 2 * Copyright (C) 2012 Samsung Electronics
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 14 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 22 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "ewk_text_checker.h"
 28
 29#if ENABLE(SPELLCHECK)
 30#include "WKTextChecker.h"
 31#include "WebKitTextChecker.h"
 32#include "ewk_text_checker_private.h"
 33
 34using namespace WebKit;
 35
 36// Initializes the client's functions to @c 0 to be sure that they are not defined.
 37static Ewk_Text_Checker ewkTextCheckerCallbacks = {
 38 0, // unique_spell_document_tag_get
 39 0, // unique_spell_document_tag_close
 40 0, // string_spelling_check
 41 0, // word_guesses_get
 42 0, // word_learn
 43 0 // word_ignore
 44};
 45
 46#define EWK_TEXT_CHECKER_CALLBACK_SET(TYPE_NAME, NAME) \
 47void ewk_text_checker_##NAME##_cb_set(TYPE_NAME cb) \
 48{ \
 49 ewkTextCheckerCallbacks.NAME = cb; \
 50}
 51
 52/**
 53 * Attaches spellchecker feature.
 54 *
 55 * @internal
 56 *
 57 * The default spellchecker feature is based on Enchant library.
 58 * Client may use own implementation of spellchecker previously set
 59 * through the callback functions.
 60 */
 61void ewk_text_checker_client_attach()
 62{
 63 static bool didInitializeTextCheckerClient = false;
 64 if (didInitializeTextCheckerClient)
 65 return;
 66
 67 WKTextCheckerClient textCheckerClient = {
 68 kWKTextCheckerClientCurrentVersion,
 69 0, // clientInfo
 70 0, // isContinuousSpellCheckingAllowed
 71 isContinuousSpellCheckingEnabled,
 72 setContinuousSpellCheckingEnabled,
 73 0, // isGrammarCheckingEnabled
 74 0, // setGrammarCheckingEnabled
 75 uniqueSpellDocumentTag,
 76 closeSpellDocumentWithTag,
 77 checkSpellingOfString,
 78 0, // checkGrammarOfString
 79 0, // spellingUIIsShowing
 80 0, // toggleSpellingUIIsShowing
 81 0, // updateSpellingUIWithMisspelledWord
 82 0, // updateSpellingUIWithGrammarString
 83 guessesForWord,
 84 learnWord,
 85 ignoreWord
 86 };
 87 WKTextCheckerSetClient(&textCheckerClient);
 88
 89 didInitializeTextCheckerClient = true;
 90}
 91
 92/*
 93 * Gets the client's callbacks.
 94 *
 95 * @internal
 96 *
 97 * The client't callbacks are not defined by default.
 98 * If the client hasn't set the callback, the corresponding callback will
 99 * return @c 0 and the default WebKit implementation will be used for this
 100 * functionality.
 101 *
 102 * @return the struct with the client's callbacks.
 103 */
 104Ewk_Text_Checker* ewk_text_checker_callbacks_get()
 105{
 106 return &ewkTextCheckerCallbacks;
 107}
 108
 109#else
 110
 111// Defines an empty API to do not break build.
 112#define EWK_TEXT_CHECKER_CALLBACK_SET(TYPE_NAME, NAME) \
 113void ewk_text_checker_##NAME##_cb_set(TYPE_NAME) \
 114{ \
 115}
 116#endif // ENABLE(SPELLCHECK)
 117
 118EWK_TEXT_CHECKER_CALLBACK_SET(Ewk_Text_Checker_Unique_Spell_Document_Tag_Get_Cb, unique_spell_document_tag_get)
 119EWK_TEXT_CHECKER_CALLBACK_SET(Ewk_Text_Checker_Unique_Spell_Document_Tag_Close_Cb, unique_spell_document_tag_close)
 120EWK_TEXT_CHECKER_CALLBACK_SET(Ewk_Text_Checker_String_Spelling_Check_Cb, string_spelling_check)
 121EWK_TEXT_CHECKER_CALLBACK_SET(Ewk_Text_Checker_Word_Guesses_Get_Cb, word_guesses_get)
 122EWK_TEXT_CHECKER_CALLBACK_SET(Ewk_Text_Checker_Word_Learn_Cb, word_learn)
 123EWK_TEXT_CHECKER_CALLBACK_SET(Ewk_Text_Checker_Word_Ignore_Cb, word_ignore)

Source/WebKit2/UIProcess/API/efl/ewk_text_checker.h

 1/*
 2 * Copyright (C) 2012 Samsung Electronics
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 14 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 22 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26/**
 27 * @file ewk_text_checker.h
 28 * @brief Provides API to overwrite the default WebKit spellchecker implementation.
 29 *
 30 * There is one spellchecker object per application and it's disabled by default.
 31 * It allows to check spelling in the editable areas.
 32 * If application wants to enable the feature, API from @a ewk_text_checker_setting.h
 33 * should be used.
 34 *
 35 * The default WebKit spellchecker implementation is based on the Enchant library.
 36 * It doesn't ensure grammar checking. Application is able to overwrite the default
 37 * WebKit spellchecker implementation by defining its own implementation and setting
 38 * appropriate callback functions.
 39 */
 40
 41#ifndef ewk_text_checker_h
 42#define ewk_text_checker_h
 43
 44#include <Evas.h>
 45
 46#ifdef __cplusplus
 47extern "C" {
 48#endif
 49
 50/**
 51 * Defines a type name for the callback function to return a tag (identifier) which is guaranteed to be unique.
 52 *
 53 * Unique tags help to avoid collisions with other objects that are checked for spelling mistakes.
 54 *
 55 * @param o the view object to get unique tag
 56 *
 57 * @return unique tag for the given @a o view object
 58 */
 59typedef uint64_t (*Ewk_Text_Checker_Unique_Spell_Document_Tag_Get_Cb)(const Evas_Object *o);
 60
 61/**
 62 * Defines a type name for the callback function to close the prviously set tag.
 63 *
 64 * This callback will notify the receiver that the user has finished with the tagged document.
 65 *
 66 * @param tag the tag to be closed
 67 */
 68typedef void (*Ewk_Text_Checker_Unique_Spell_Document_Tag_Close_Cb)(uint64_t tag);
 69
 70/**
 71 * Defines a type name for the callback function to search for a misspelled words in the given string.
 72 *
 73 * @param tag unique tag to notify the spell checker which document that @a text is associated,
 74 * in most cases not necessarily, just for ignored word,
 75 * @c 0 can be passed in for text not associated with a particular document
 76 * @param text the text containing the words to spellcheck
 77 * @param misspelling_location a pointer to store the beginning of the misspelled @a text, @c -1 if the @a text is correct
 78 * @param misspelling_length a pointer to store the length of misspelled @a text, @c 0 if the @a text is correct
 79 */
 80typedef void (*Ewk_Text_Checker_String_Spelling_Check_Cb)(uint64_t tag, const char *text, int32_t *misspelling_location, int32_t *misspelling_length);
 81
 82/**
 83 * Defines a type name for the callback function to get a list of suggested spellings for a misspelled @a word.
 84 *
 85 * @param tag unique tag to notify the spell checker which document that @a text is associated,
 86 * @c 0 can be passed for text not associated with a particular document
 87 * @param word the word to get guesses
 88 * @return a list of dynamically allocated strings (as char*) and
 89 * caller is responsible for destroying them.
 90 */
 91typedef Eina_List *(*Ewk_Text_Checker_Word_Guesses_Get_Cb)(uint64_t tag, const char *word);
 92
 93/**
 94 * Sets a callback function to add the word to the spell checker dictionary.
 95 *
 96 * @param tag unique tag to notify the spell checker which document that @a text is associated,
 97 * @c 0 can be passed for text not associated with a particular document
 98 * @param word the word to add
 99 */
 100typedef void (*Ewk_Text_Checker_Word_Learn_Cb)(uint64_t tag, const char *word);
 101
 102/**
 103 * Sets a callback function to tell the spell checker to ignore a given word.
 104 *
 105 * @param tag unique tag to notify the spell checker which document that @a text is associated,
 106 * @c 0 can be passed for text not associated with a particular document
 107 * @param word the word to ignore
 108 */
 109typedef void (*Ewk_Text_Checker_Word_Ignore_Cb)(uint64_t tag, const char *word);
 110
 111/**
 112 * Sets a callback function to get a unique spell document tag.
 113 *
 114 * @param cb a new callback to set or @c NULL to restore the default WebKit callback implementation
 115 */
 116EAPI void ewk_text_checker_unique_spell_document_tag_get_cb_set(Ewk_Text_Checker_Unique_Spell_Document_Tag_Get_Cb cb);
 117
 118/**
 119 * Sets a callback function to close a unique spell document tag.
 120 *
 121 * @param cb a new callback to set or @c NULL to restore the default WebKit callback implementation
 122 */
 123EAPI void ewk_text_checker_unique_spell_document_tag_close_cb_set(Ewk_Text_Checker_Unique_Spell_Document_Tag_Close_Cb cb);
 124
 125/**
 126 * Sets a callback function to search for a misspelled words in the given string.
 127 *
 128 * @param cb a new callback to set or @c NULL to restore the default WebKit callback implementation
 129 */
 130EAPI void ewk_text_checker_string_spelling_check_cb_set(Ewk_Text_Checker_String_Spelling_Check_Cb cb);
 131
 132/**
 133 * Sets a callback function to get an array of suggested spellings for a misspelled word.
 134 *
 135 * @param cb a new callback to set or @c NULL to restore the default WebKit callback implementation
 136 */
 137EAPI void ewk_text_checker_word_guesses_get_cb_set(Ewk_Text_Checker_Word_Guesses_Get_Cb cb);
 138
 139/**
 140 * Sets a callback function to add the word to the spell checker dictionary.
 141 *
 142 * @param cb a new callback to set or @c NULL to restore the default WebKit callback implementation
 143 */
 144EAPI void ewk_text_checker_word_learn_cb_set(Ewk_Text_Checker_Word_Learn_Cb cb);
 145
 146/**
 147 * Sets a callback function to tell the spell checker to ignore a given word.
 148 *
 149 * @param cb a new callback to set or @c NULL to restore the default WebKit callback implementation
 150 */
 151EAPI void ewk_text_checker_word_ignore_cb_set(Ewk_Text_Checker_Word_Ignore_Cb cb);
 152
 153#ifdef __cplusplus
 154}
 155#endif
 156#endif // ewk_text_checker_h

Source/WebKit2/UIProcess/API/efl/ewk_text_checker_private.h

 1/*
 2 * Copyright (C) 2012 Samsung Electronics
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 14 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 22 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 23 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef ewk_text_checker_private_h
 27#define ewk_text_checker_private_h
 28
 29#if ENABLE(SPELLCHECK)
 30#include "ewk_text_checker.h"
 31
 32/**
 33 * @brief Structure keeps client's callback functions.
 34 *
 35 * @internal
 36 */
 37struct _Ewk_Text_Checker {
 38 Ewk_Text_Checker_Unique_Spell_Document_Tag_Get_Cb unique_spell_document_tag_get;
 39 Ewk_Text_Checker_Unique_Spell_Document_Tag_Close_Cb unique_spell_document_tag_close;
 40 Ewk_Text_Checker_String_Spelling_Check_Cb string_spelling_check;
 41 Ewk_Text_Checker_Word_Guesses_Get_Cb word_guesses_get;
 42 Ewk_Text_Checker_Word_Learn_Cb word_learn;
 43 Ewk_Text_Checker_Word_Ignore_Cb word_ignore;
 44};
 45typedef _Ewk_Text_Checker Ewk_Text_Checker;
 46
 47Ewk_Text_Checker* ewk_text_checker_callbacks_get();
 48
 49// Makes it visible for WTR.
 50EAPI void ewk_text_checker_client_attach();
 51
 52#endif // ENABLE(SPELLCHECK)
 53#endif // ewk_text_checker_private_h

Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp

11/*
2  * Copyright (C) 2011 Samsung Electronics
 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
 3 * Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
 4 * Copyright (C) 2012 Samsung Electronics
35 *
46 * Redistribution and use in source and binary forms, with or without
57 * modification, are permitted provided that the following conditions

2729#include "TextChecker.h"
2830
2931#include "TextCheckerState.h"
30 #include <WebCore/NotImplemented.h>
 32
 33#if ENABLE(SPELLCHECK)
 34#include "WebTextChecker.h"
 35#endif
3136
3237using namespace WebCore;
3338

@@static TextCheckerState textCheckerState;
3742
3843const TextCheckerState& TextChecker::state()
3944{
40  notImplemented();
 45#if ENABLE(SPELLCHECK)
 46 static bool didInitializeState = false;
 47 if (didInitializeState)
 48 return textCheckerState;
 49
 50 WebTextCheckerClient& client = WebTextChecker::shared()->client();
 51 textCheckerState.isContinuousSpellCheckingEnabled = client.continuousSpellCheckingEnabled();
 52 textCheckerState.isGrammarCheckingEnabled = client.grammarCheckingEnabled();
 53
 54 didInitializeState = true;
 55#endif
4156 return textCheckerState;
4257}
4358
4459bool TextChecker::isContinuousSpellCheckingAllowed()
4560{
46  notImplemented();
 61#if ENABLE(SPELLCHECK)
 62 return WebTextChecker::shared()->client().continuousSpellCheckingAllowed();
 63#else
4764 return false;
 65#endif
4866}
4967
50 void TextChecker::setContinuousSpellCheckingEnabled(bool)
 68void TextChecker::setContinuousSpellCheckingEnabled(bool isContinuousSpellCheckingEnabled)
5169{
52  notImplemented();
 70#if ENABLE(SPELLCHECK)
 71 if (state().isContinuousSpellCheckingEnabled == isContinuousSpellCheckingEnabled)
 72 return;
 73
 74 textCheckerState.isContinuousSpellCheckingEnabled = isContinuousSpellCheckingEnabled;
 75 WebTextChecker::shared()->client().setContinuousSpellCheckingEnabled(isContinuousSpellCheckingEnabled);
 76#else
 77 UNUSED_PARAM(isContinuousSpellCheckingEnabled);
 78#endif
5379}
5480
55 void TextChecker::setGrammarCheckingEnabled(bool)
 81void TextChecker::setGrammarCheckingEnabled(bool isGrammarCheckingEnabled)
5682{
57  notImplemented();
 83#if ENABLE(SPELLCHECK)
 84 if (state().isGrammarCheckingEnabled == isGrammarCheckingEnabled)
 85 return;
 86
 87 textCheckerState.isGrammarCheckingEnabled = isGrammarCheckingEnabled;
 88 WebTextChecker::shared()->client().setGrammarCheckingEnabled(isGrammarCheckingEnabled);
 89#else
 90 UNUSED_PARAM(isGrammarCheckingEnabled);
 91#endif
5892}
5993
60 void TextChecker::continuousSpellCheckingEnabledStateChanged(bool /*enabled*/)
 94void TextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled)
6195{
62  notImplemented();
 96#if ENABLE(SPELLCHECK)
 97 textCheckerState.isContinuousSpellCheckingEnabled = enabled;
 98#else
 99 UNUSED_PARAM(enabled);
 100#endif
63101}
64102
65 void TextChecker::grammarCheckingEnabledStateChanged(bool /*enabled*/)
 103void TextChecker::grammarCheckingEnabledStateChanged(bool enabled)
66104{
67  notImplemented();
 105#if ENABLE(SPELLCHECK)
 106 textCheckerState.isGrammarCheckingEnabled = enabled;
 107#else
 108 UNUSED_PARAM(enabled);
 109#endif
68110}
69111
70 int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy*)
 112int64_t TextChecker::uniqueSpellDocumentTag(WebPageProxy* page)
71113{
72  notImplemented();
 114#if ENABLE(SPELLCHECK)
 115 return WebTextChecker::shared()->client().uniqueSpellDocumentTag(page);
 116#else
 117 UNUSED_PARAM(page);
73118 return 0;
 119#endif
74120}
75121
76 void TextChecker::closeSpellDocumentWithTag(int64_t)
 122void TextChecker::closeSpellDocumentWithTag(int64_t tag)
77123{
78  notImplemented();
 124#if ENABLE(SPELLCHECK)
 125 WebTextChecker::shared()->client().closeSpellDocumentWithTag(tag);
 126#else
 127 UNUSED_PARAM(tag);
 128#endif
79129}
80130
81 void TextChecker::checkSpellingOfString(int64_t, const UChar*, uint32_t, int32_t&, int32_t&)
 131void TextChecker::checkSpellingOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, int32_t& misspellingLocation, int32_t& misspellingLength)
82132{
83  notImplemented();
 133#if ENABLE(SPELLCHECK)
 134 WebTextChecker::shared()->client().checkSpellingOfString(spellDocumentTag, String(text, length), misspellingLocation, misspellingLength);
 135#else
 136 UNUSED_PARAM(spellDocumentTag);
 137 UNUSED_PARAM(text);
 138 UNUSED_PARAM(length);
 139 UNUSED_PARAM(misspellingLocation);
 140 UNUSED_PARAM(misspellingLength);
 141#endif
84142}
85143
86 void TextChecker::checkGrammarOfString(int64_t, const UChar*, uint32_t, Vector<WebCore::GrammarDetail>&, int32_t&, int32_t&)
 144void TextChecker::checkGrammarOfString(int64_t spellDocumentTag, const UChar* text, uint32_t length, Vector<GrammarDetail>& grammarDetails, int32_t& badGrammarLocation, int32_t& badGrammarLength)
87145{
88  notImplemented();
 146#if ENABLE(SPELLCHECK)
 147 WebTextChecker::shared()->client().checkGrammarOfString(spellDocumentTag, String(text, length), grammarDetails, badGrammarLocation, badGrammarLength);
 148#else
 149 UNUSED_PARAM(spellDocumentTag);
 150 UNUSED_PARAM(text);
 151 UNUSED_PARAM(length);
 152 UNUSED_PARAM(grammarDetails);
 153 UNUSED_PARAM(badGrammarLocation);
 154 UNUSED_PARAM(badGrammarLength);
 155#endif
89156}
90157
91158bool TextChecker::spellingUIIsShowing()
92159{
93  notImplemented();
 160#if ENABLE(SPELLCHECK)
 161 return WebTextChecker::shared()->client().spellingUIIsShowing();
 162#else
94163 return false;
 164#endif
95165}
96166
97167void TextChecker::toggleSpellingUIIsShowing()
98168{
99  notImplemented();
 169#if ENABLE(SPELLCHECK)
 170 WebTextChecker::shared()->client().toggleSpellingUIIsShowing();
 171#endif
100172}
101173
102 void TextChecker::updateSpellingUIWithMisspelledWord(int64_t, const String&)
 174void TextChecker::updateSpellingUIWithMisspelledWord(int64_t spellDocumentTag, const String& misspelledWord)
103175{
104  notImplemented();
 176#if ENABLE(SPELLCHECK)
 177 WebTextChecker::shared()->client().updateSpellingUIWithMisspelledWord(spellDocumentTag, misspelledWord);
 178#else
 179 UNUSED_PARAM(spellDocumentTag);
 180 UNUSED_PARAM(misspelledWord);
 181#endif
105182}
106183
107 void TextChecker::updateSpellingUIWithGrammarString(int64_t, const String&, const GrammarDetail&)
 184void TextChecker::updateSpellingUIWithGrammarString(int64_t spellDocumentTag, const String& badGrammarPhrase, const GrammarDetail& grammarDetail)
108185{
109  notImplemented();
 186#if ENABLE(SPELLCHECK)
 187 WebTextChecker::shared()->client().updateSpellingUIWithGrammarString(spellDocumentTag, badGrammarPhrase, grammarDetail);
 188#else
 189 UNUSED_PARAM(spellDocumentTag);
 190 UNUSED_PARAM(badGrammarPhrase);
 191 UNUSED_PARAM(grammarDetail);
 192#endif
110193}
111194
112 void TextChecker::getGuessesForWord(int64_t, const String&, const String&, Vector<String>&)
 195void TextChecker::getGuessesForWord(int64_t spellDocumentTag, const String& word, const String& , Vector<String>& guesses)
113196{
114  notImplemented();
 197#if ENABLE(SPELLCHECK)
 198 WebTextChecker::shared()->client().guessesForWord(spellDocumentTag, word, guesses);
 199#else
 200 UNUSED_PARAM(spellDocumentTag);
 201 UNUSED_PARAM(word);
 202 UNUSED_PARAM(guesses);
 203#endif
115204}
116205
117 void TextChecker::learnWord(int64_t, const String&)
 206void TextChecker::learnWord(int64_t spellDocumentTag, const String& word)
118207{
119  notImplemented();
 208#if ENABLE(SPELLCHECK)
 209 WebTextChecker::shared()->client().learnWord(spellDocumentTag, word);
 210#else
 211 UNUSED_PARAM(spellDocumentTag);
 212 UNUSED_PARAM(word);
 213#endif
120214}
121215
122 void TextChecker::ignoreWord(int64_t, const String&)
 216void TextChecker::ignoreWord(int64_t spellDocumentTag, const String& word)
123217{
124  notImplemented();
 218#if ENABLE(SPELLCHECK)
 219 WebTextChecker::shared()->client().ignoreWord(spellDocumentTag, word);
 220#else
 221 UNUSED_PARAM(spellDocumentTag);
 222 UNUSED_PARAM(word);
 223#endif
125224}
126225
127226} // namespace WebKit

Source/cmake/FindEnchant.cmake

 1# - Try to find Enchant
 2# Once done, this will define
 3#
 4# ENCHANT_INCLUDE_DIRS - the Enchant include drectories
 5# ENCHANT_LIBRARIES - link these to use Enchant
 6#
 7# Copyright (C) 2012 Samsung Electronics
 8#
 9# Redistribution and use in source and binary forms, with or without
 10# modification, are permitted provided that the following conditions
 11# are met:
 12# 1. Redistributions of source code must retain the above copyright
 13# notice, this list of conditions and the following disclaimer.
 14# 2. Redistributions in binary form must reproduce the above copyright
 15# notice, this list of conditions and the following disclaimer in the
 16# documentation and/or other materials provided with the distribution.
 17#
 18# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
 19# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 20# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
 22# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 23# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 24# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 25# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 26# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 27# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 28# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 29
 30FIND_PACKAGE(PkgConfig)
 31PKG_CHECK_MODULES(PC_ENCHANT enchant)
 32
 33FIND_PATH(ENCHANT_INCLUDE_DIRS
 34 NAMES enchant.h
 35 PATHS ${PC_ENCHANT_INCLUDEDIR}
 36 ${PC_ENCHANT_INCLUDE_DIRS}
 37)
 38
 39FIND_LIBRARY(ENCHANT_LIBRARIES
 40 NAMES enchant
 41 PATHS ${PC_ENCHANT_LIBDIR}
 42 ${PC_ENCHANT_LIBRARY_DIRS}
 43)

Source/cmake/OptionsEfl.cmake

@@WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REGIONS ON)
8282WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REQUEST_ANIMATION_FRAME ON)
8383WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SHADOW_DOM ON)
8484WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SHARED_WORKERS ON)
 85WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_SPELLCHECK ON)
8586WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_EVENTS ON)
8687WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIBRATION ON)
8788WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO ON)

@@IF (WTF_USE_TILED_BACKING_STORE)
178179 FIND_PACKAGE(OpenGL REQUIRED)
179180ENDIF()
180181
 182IF (ENABLE_SPELLCHECK)
 183 FIND_PACKAGE(Enchant REQUIRED)
 184 ADD_DEFINITIONS(-DENABLE_SPELLCHECK=1)
 185ENDIF()

Source/cmake/WebKitFeatures.cmake

@@MACRO (WEBKIT_OPTION_BEGIN)
9898 WEBKIT_OPTION_DEFINE(ENABLE_SCRIPTED_SPEECH "Toggle Scripted Speech API support" OFF)
9999 WEBKIT_OPTION_DEFINE(ENABLE_SHADOW_DOM "Toggle Shadow DOM support" OFF)
100100 WEBKIT_OPTION_DEFINE(ENABLE_SHARED_WORKERS "Toggle SharedWorkers support" OFF)
 101 WEBKIT_OPTION_DEFINE(ENABLE_SPELLCHECK "Toggle Spellchecking support (requires Enchant)" OFF)
101102 WEBKIT_OPTION_DEFINE(ENABLE_SQL_DATABASE "Toggle SQL Database Support" ON)
102103 WEBKIT_OPTION_DEFINE(ENABLE_STYLE_SCOPED "Toggle <style scoped> support" OFF)
103104 WEBKIT_OPTION_DEFINE(ENABLE_SVG "Toggle SVG support" ON)

Source/cmakeconfig.h.cmake

9494#cmakedefine01 ENABLE_SHADOW_DOM
9595#cmakedefine01 ENABLE_SHARED_WORKERS
9696#cmakedefine01 ENABLE_SMOOTH_SCROLLING
 97#cmakedefine01 ENABLE_SPELLCHECK
9798#cmakedefine01 ENABLE_SQL_DATABASE
9899#cmakedefine01 ENABLE_STYLE_SCOPED
99100#cmakedefine01 ENABLE_SVG