Changeset 132657 in webkit
- Timestamp:
- Oct 26, 2012 7:58:31 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r132647 r132657 1 2012-10-26 Christophe Dumez <christophe.dumez@intel.com> 2 3 [EFL][WK2] Get rid of C'ism in text checker API 4 https://bugs.webkit.org/show_bug.cgi?id=100513 5 6 Reviewed by Kenneth Rohde Christiansen. 7 8 Make Ewk_Text_Checker a C++ class and move the 9 WebKitTextChecker code to this new class. This 10 gets rid of the C'ism in the text checker code 11 and make it consistent with other Ewk classes. 12 13 * PlatformEfl.cmake: 14 * UIProcess/API/efl/ewk_context.cpp: 15 (Ewk_Context::Ewk_Context): 16 * UIProcess/API/efl/ewk_settings.cpp: 17 (spellCheckingLanguagesSetUpdate): 18 (ewk_settings_continuous_spell_checking_enabled_set): 19 (ewk_settings_spell_checking_available_languages_get): 20 (ewk_settings_spell_checking_languages_get): 21 * UIProcess/API/efl/ewk_text_checker.cpp: 22 (ClientCallbacks): 23 (textCheckerEnchant): 24 (clientCallbacks): 25 (isContinuousSpellCheckingEnabled): 26 (setContinuousSpellCheckingEnabled): 27 (uniqueSpellDocumentTag): 28 (closeSpellDocumentWithTag): 29 (checkSpellingOfString): 30 (guessesForWord): 31 (learnWord): 32 (ignoreWord): 33 (Ewk_Text_Checker): 34 (Ewk_Text_Checker::availableSpellCheckingLanguages): 35 (Ewk_Text_Checker::updateSpellCheckingLanguages): 36 (Ewk_Text_Checker::loadedSpellCheckingLanguages): 37 (Ewk_Text_Checker::initialize): 38 * UIProcess/API/efl/ewk_text_checker_private.h: 39 (Ewk_Text_Checker): 40 * UIProcess/efl/WebKitTextChecker.cpp: Removed. 41 * UIProcess/efl/WebKitTextChecker.h: Removed. 42 1 43 2012-10-26 Mikhail Pozdnyakov <mikhail.pozdnyakov@intel.com> 2 44 -
trunk/Source/WebKit2/PlatformEfl.cmake
r132617 r132657 88 88 UIProcess/efl/WebFullScreenManagerProxyEfl.cpp 89 89 UIProcess/efl/WebInspectorProxyEfl.cpp 90 UIProcess/efl/WebKitTextChecker.cpp91 90 UIProcess/efl/WebPageProxyEfl.cpp 92 91 UIProcess/efl/WebPopupMenuProxyEfl.cpp -
trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp
r132643 r132657 91 91 92 92 #if ENABLE(SPELLCHECK) 93 ewk_text_checker_client_attach();93 Ewk_Text_Checker::initialize(); 94 94 if (ewk_settings_continuous_spell_checking_enabled_get()) { 95 95 // Load the default language. -
trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp
r132647 r132657 36 36 #if ENABLE(SPELLCHECK) 37 37 #include "WKTextChecker.h" 38 #include " WebKitTextChecker.h"38 #include "ewk_text_checker_private.h" 39 39 #include <Ecore.h> 40 40 #include <wtf/Vector.h> … … 72 72 { 73 73 // FIXME: Consider to delegate calling of this method in WebProcess to do not delay/block UIProcess. 74 updateSpellCheckingLanguages(ewkTextCheckerSettings.spellCheckingLanguages);74 Ewk_Text_Checker::updateSpellCheckingLanguages(ewkTextCheckerSettings.spellCheckingLanguages); 75 75 return ECORE_CALLBACK_CANCEL; 76 76 } … … 226 226 227 227 // Sets the default language if user didn't specify any. 228 if (enable && loadedSpellCheckingLanguages().isEmpty())228 if (enable && Ewk_Text_Checker::loadedSpellCheckingLanguages().isEmpty()) 229 229 spellCheckingLanguagesSet(Vector<String>()); 230 230 … … 239 239 Eina_List* listOflanguages = 0; 240 240 #if ENABLE(SPELLCHECK) 241 Vector<String> languages =availableSpellCheckingLanguages();241 const Vector<String>& languages = Ewk_Text_Checker::availableSpellCheckingLanguages(); 242 242 size_t numberOfLanuages = languages.size(); 243 243 … … 262 262 Eina_List* listOflanguages = 0; 263 263 #if ENABLE(SPELLCHECK) 264 Vector<String> languages = loadedSpellCheckingLanguages();264 Vector<String> languages = Ewk_Text_Checker::loadedSpellCheckingLanguages(); 265 265 size_t numberOfLanuages = languages.size(); 266 266 -
trunk/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.cpp
r131579 r132657 1 1 /* 2 2 * Copyright (C) 2012 Samsung Electronics 3 * Copyright (C) 2012 Intel Corporation 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 29 30 #if ENABLE(SPELLCHECK) 30 31 32 #include "TextCheckerEnchant.h" 33 #include "WKAPICast.h" 34 #include "WKMutableArray.h" 35 #include "WKRetainPtr.h" 36 #include "WKString.h" 31 37 #include "WKTextChecker.h" 32 #include "WebKitTextChecker.h" 38 #include "WebPageProxy.h" 39 #include "WebString.h" 40 #include "ewk_settings.h" 33 41 #include "ewk_text_checker_private.h" 34 42 #include <Eina.h> 43 #include <wtf/OwnPtr.h> 44 #include <wtf/text/CString.h> 45 46 using namespace WebCore; 35 47 using namespace WebKit; 36 48 37 // Initializes the client's functions to @c 0 to be sure that they are not defined. 38 static Ewk_Text_Checker ewkTextCheckerCallbacks = { 39 0, // unique_spell_document_tag_get 40 0, // unique_spell_document_tag_close 41 0, // string_spelling_check 42 0, // word_guesses_get 43 0, // word_learn 44 0 // word_ignore 49 /** 50 * @brief Structure to store client callback functions. 51 * 52 * @internal 53 */ 54 struct ClientCallbacks { 55 Ewk_Text_Checker_Unique_Spell_Document_Tag_Get_Cb unique_spell_document_tag_get; 56 Ewk_Text_Checker_Unique_Spell_Document_Tag_Close_Cb unique_spell_document_tag_close; 57 Ewk_Text_Checker_String_Spelling_Check_Cb string_spelling_check; 58 Ewk_Text_Checker_Word_Guesses_Get_Cb word_guesses_get; 59 Ewk_Text_Checker_Word_Learn_Cb word_learn; 60 Ewk_Text_Checker_Word_Ignore_Cb word_ignore; 45 61 }; 46 62 47 #define EWK_TEXT_CHECKER_CALLBACK_SET(TYPE_NAME, NAME) \ 48 void ewk_text_checker_##NAME##_cb_set(TYPE_NAME cb) \ 49 { \ 50 ewkTextCheckerCallbacks.NAME = cb; \ 63 static inline TextCheckerEnchant* textCheckerEnchant() 64 { 65 static OwnPtr<TextCheckerEnchant> textCheckerEnchant = TextCheckerEnchant::create(); 66 return textCheckerEnchant.get(); 67 } 68 69 static inline ClientCallbacks& clientCallbacks() 70 { 71 DEFINE_STATIC_LOCAL(ClientCallbacks, clientCallbacks, ()); 72 return clientCallbacks; 73 } 74 75 static bool isContinuousSpellCheckingEnabled(const void*) 76 { 77 return ewk_settings_continuous_spell_checking_enabled_get(); 78 } 79 80 static void setContinuousSpellCheckingEnabled(bool enabled, const void*) 81 { 82 ewk_settings_continuous_spell_checking_enabled_set(enabled); 83 } 84 85 static uint64_t uniqueSpellDocumentTag(WKPageRef page, const void*) 86 { 87 if (clientCallbacks().unique_spell_document_tag_get) 88 return clientCallbacks().unique_spell_document_tag_get(toImpl(page)->viewWidget()); 89 90 return 0; 91 } 92 93 static void closeSpellDocumentWithTag(uint64_t tag, const void*) 94 { 95 if (clientCallbacks().unique_spell_document_tag_close) 96 clientCallbacks().unique_spell_document_tag_close(tag); 97 } 98 99 static void checkSpellingOfString(uint64_t tag, WKStringRef text, int32_t* misspellingLocation, int32_t* misspellingLength, const void*) 100 { 101 if (clientCallbacks().string_spelling_check) 102 clientCallbacks().string_spelling_check(tag, toImpl(text)->string().utf8().data(), misspellingLocation, misspellingLength); 103 else 104 textCheckerEnchant()->checkSpellingOfString(toImpl(text)->string(), *misspellingLocation, *misspellingLength); 105 } 106 107 static WKArrayRef guessesForWord(uint64_t tag, WKStringRef word, const void*) 108 { 109 WKMutableArrayRef suggestionsForWord = WKMutableArrayCreate(); 110 111 if (clientCallbacks().word_guesses_get) { 112 Eina_List* list = clientCallbacks().word_guesses_get(tag, toImpl(word)->string().utf8().data()); 113 void* item; 114 115 EINA_LIST_FREE(list, item) { 116 WKRetainPtr<WKStringRef> suggestion(AdoptWK, WKStringCreateWithUTF8CString(static_cast<const char*>(item))); 117 WKArrayAppendItem(suggestionsForWord, suggestion.get()); 118 free(item); 119 } 120 } else { 121 const Vector<String>& guesses = textCheckerEnchant()->getGuessesForWord(toImpl(word)->string()); 122 size_t numberOfGuesses = guesses.size(); 123 for (size_t i = 0; i < numberOfGuesses; ++i) { 124 WKRetainPtr<WKStringRef> suggestion(AdoptWK, WKStringCreateWithUTF8CString(guesses[i].utf8().data())); 125 WKArrayAppendItem(suggestionsForWord, suggestion.get()); 126 } 127 } 128 129 return suggestionsForWord; 130 } 131 132 static void learnWord(uint64_t tag, WKStringRef word, const void*) 133 { 134 if (clientCallbacks().word_learn) 135 clientCallbacks().word_learn(tag, toImpl(word)->string().utf8().data()); 136 else 137 textCheckerEnchant()->learnWord(toImpl(word)->string()); 138 } 139 140 static void ignoreWord(uint64_t tag, WKStringRef word, const void*) 141 { 142 if (clientCallbacks().word_ignore) 143 clientCallbacks().word_ignore(tag, toImpl(word)->string().utf8().data()); 144 else 145 textCheckerEnchant()->ignoreWord(toImpl(word)->string()); 146 } 147 148 namespace Ewk_Text_Checker { 149 150 Vector<String> availableSpellCheckingLanguages() 151 { 152 return textCheckerEnchant()->availableSpellCheckingLanguages(); 153 } 154 155 void updateSpellCheckingLanguages(const Vector<String>& languages) 156 { 157 textCheckerEnchant()->updateSpellCheckingLanguages(languages); 158 } 159 160 Vector<String> loadedSpellCheckingLanguages() 161 { 162 return textCheckerEnchant()->loadedSpellCheckingLanguages(); 51 163 } 52 164 53 165 /** 54 * Attaches spellcheckerfeature.166 * Initializes spellcheck feature. 55 167 * 56 168 * @internal 57 169 * 58 * The default spellcheck erfeature is based on Enchant library.59 * Client may use own implementation of spellcheckerpreviously set170 * The default spellcheck feature is based on Enchant library. 171 * Client may use own spellcheck implementation previously set 60 172 * through the callback functions. 61 173 */ 62 void ewk_text_checker_client_attach()174 void initialize() 63 175 { 64 176 static bool didInitializeTextCheckerClient = false; … … 91 203 } 92 204 93 /* 94 * Gets the client's callbacks. 95 * 96 * @internal 97 * 98 * The client't callbacks are not defined by default. 99 * If the client hasn't set the callback, the corresponding callback will 100 * return @c 0 and the default WebKit implementation will be used for this 101 * functionality. 102 * 103 * @return the struct with the client's callbacks. 104 */ 105 Ewk_Text_Checker* ewk_text_checker_callbacks_get() 106 { 107 return &ewkTextCheckerCallbacks; 205 } // namespace Ewk_Text_Checker 206 207 #define EWK_TEXT_CHECKER_CALLBACK_SET(TYPE_NAME, NAME) \ 208 void ewk_text_checker_##NAME##_cb_set(TYPE_NAME cb) \ 209 { \ 210 clientCallbacks().NAME = cb; \ 108 211 } 109 212 -
trunk/Source/WebKit2/UIProcess/API/efl/ewk_text_checker_private.h
r131712 r132657 1 1 /* 2 2 * Copyright (C) 2012 Samsung Electronics 3 * Copyright (C) 2012 Intel Corporation 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 31 32 #include "ewk_text_checker.h" 32 33 33 /** 34 * @brief Structure keeps client's callback functions. 35 * 36 * @internal 37 */ 38 struct Ewk_Text_Checker { 39 Ewk_Text_Checker_Unique_Spell_Document_Tag_Get_Cb unique_spell_document_tag_get; 40 Ewk_Text_Checker_Unique_Spell_Document_Tag_Close_Cb unique_spell_document_tag_close; 41 Ewk_Text_Checker_String_Spelling_Check_Cb string_spelling_check; 42 Ewk_Text_Checker_Word_Guesses_Get_Cb word_guesses_get; 43 Ewk_Text_Checker_Word_Learn_Cb word_learn; 44 Ewk_Text_Checker_Word_Ignore_Cb word_ignore; 45 }; 34 namespace Ewk_Text_Checker { 46 35 47 Ewk_Text_Checker* ewk_text_checker_callbacks_get();36 void initialize(); 48 37 49 // Makes it visible for WTR. 50 EAPI void ewk_text_checker_client_attach(); 38 // Enchant helpers. 39 Vector<String> availableSpellCheckingLanguages(); 40 void updateSpellCheckingLanguages(const Vector<String>& languages); 41 Vector<String> loadedSpellCheckingLanguages(); 42 43 } 51 44 52 45 #endif // ENABLE(SPELLCHECK)
Note: See TracChangeset
for help on using the changeset viewer.