Changeset 148670 in webkit


Ignore:
Timestamp:
Apr 18, 2013 6:04:15 AM (11 years ago)
Author:
g.czajkowski@samsung.com
Message:

[WK2][EFL] Text Checker's settings refactor
https://bugs.webkit.org/show_bug.cgi?id=111713

Reviewed by Andreas Kling.

Source/WebKit2:

Use WK2's TextCheckerState object as the store for the text checker settings.
It's shared between the client (Ewk API part) and WebProcess (read only).
Thanks to it, we don't have to keep any additional structure with
the settings on ewk side.

In the consistency with WKTextChecker C API, move the Ewk's text checker settings APIs
to the ewk_text_checker.h/cpp. They're not connected to Ewk_View/Ewk_Settings object to
keep them in ewk_setting.h/cpp.

Introduce a new class to implement WKTextCheckerClient callbacks to call spelling
methods through WK2 C API.
The main purpose of this change is to detach text checker initialization from ewk_context.

  • PlatformEfl.cmake:

Add a new files to the build.

  • UIProcess/API/efl/ewk_context.cpp:

(EwkContext::EwkContext):
Detach the text checker initialization from context.
There might be more than default context.
There is one text checker object per application.

  • UIProcess/API/efl/ewk_settings.cpp:
  • UIProcess/API/efl/ewk_settings.h:

Remove the text checker settings.

  • UIProcess/API/efl/ewk_text_checker.cpp:

Add the text checker settings to the ewk_text_checker.h/cpp

(convertLanguagesToEinaList):
Add helper function to convert Vector's values to Eina_List.

(clientCallbacks):
Add the client callback responsible for the continuous spell checking
setting change to the struct.

(ewk_text_checker_continuous_spell_checking_enabled_set):
Do not call the client's callback responsible for the setting
change unless WebKit changes the setting (trough the context
'Check Spelling While Typing' option).

  • UIProcess/API/efl/ewk_text_checker.h:

Adjust APIs name to the ewk_text_checker syntax.
Update the documentation according to the changes.

  • UIProcess/API/efl/ewk_text_checker_private.h:

(ClientCallbacks):
Move ClientCallbacks structure to TextCheckerClientEfl.
The client callbacks (Ewk API) have to be accessible in WKTextCheckerClient callbacks
to choose what implementation will be used - the client's (if definied) or Enchant impl.

  • UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:

Update the unit tests according to the APIs change.
Update the test responsible for the notification about the setting change
according to changes in 'ewk_text_checker_continuous_spell_checking_enabled_set'.

  • UIProcess/efl/TextCheckerClientEfl.cpp: Added.

Implement WKTextCheckerClient callbacks.

(TextCheckerClientEfl::TextCheckerClientEfl):
(TextCheckerClientEfl::instance):
Allow to get and create TextCheckerClientEfl object.

(TextCheckerClientEfl::isContinuousSpellCheckingEnabled):
Get the setting value based on WK2 C API.

(TextCheckerClientEfl::ensureSpellCheckingLanguage):
Load the default languages if user didn't specify any.

(TextCheckerClientEfl::updateSpellCheckingLanguages):
(TextCheckerClientEfl::languagesUpdateTimerFired):
(TextCheckerClientEfl::availableSpellCheckingLanguages):
(TextCheckerClientEfl::loadedSpellCheckingLanguages):
(TextCheckerClientEfl::availableSpellCheckingLanguages):
(TextCheckerClientEfl::loadedSpellCheckingLanguages):
Provide support for languages.

(TextCheckerClientEfl::spellCheckingSettingChangeTimerFired):
(TextCheckerClientEfl::callContinuousSpellCheckingChangeCallbackAsync):
Notify the client about the setting change.

(TextCheckerClientEfl::isContinuousSpellCheckingEnabledCallback):
(TextCheckerClientEfl::setContinuousSpellCheckingEnabledCallback):
(TextCheckerClientEfl::uniqueSpellDocumentTagCallback):
(TextCheckerClientEfl::closeSpellDocumentWithTagCallback):
(TextCheckerClientEfl::checkSpellingOfStringCallback):
(TextCheckerClientEfl::guessesForWordCallback):
(TextCheckerClientEfl::learnWordCallback):
(TextCheckerClientEfl::ignoreWordCallback):
WKTextCheckerClient callbacks implementation.

  • UIProcess/efl/TextCheckerClientEfl.h: Added.

(TextCheckerClientEfl):
(TextCheckerClientEfl::clientCallbacks):
Return the client callbacks to be used in ewk_text_checker.cpp.

  • UIProcess/efl/TextCheckerEfl.cpp:

(WebKit::TextChecker::state):
Initialize the TextCheckerState's members to false.

(WebKit::TextChecker::setContinuousSpellCheckingEnabled):
Set the default language if user didn't specify any.
Notify the client about the setting change.
This method is called when context menu 'Check Spelling While Typing'
option has been toggled.

(WebKit::TextChecker::continuousSpellCheckingEnabledStateChanged):
Set the default language if user didn't specify any.
Called by WKTextChecker's API.

Tools:

  • MiniBrowser/efl/main.c:

(window_create):
Use a new text checker API to enable spell checking.

Location:
trunk
Files:
2 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r148666 r148670  
     12013-04-18  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
     2
     3        [WK2][EFL] Text Checker's settings refactor
     4        https://bugs.webkit.org/show_bug.cgi?id=111713
     5
     6        Reviewed by Andreas Kling.
     7
     8        Use WK2's TextCheckerState object as the store for the text checker settings.
     9        It's shared between the client (Ewk API part) and WebProcess (read only).
     10        Thanks to it, we don't have to keep any additional structure with
     11        the settings on ewk side.
     12
     13        In the consistency with WKTextChecker C API, move the Ewk's text checker settings APIs
     14        to the ewk_text_checker.h/cpp. They're not connected to Ewk_View/Ewk_Settings object to
     15        keep them in ewk_setting.h/cpp.
     16
     17        Introduce a new class to implement WKTextCheckerClient callbacks to call spelling
     18        methods through WK2 C API.
     19        The main purpose of this change is to detach text checker initialization from ewk_context.
     20
     21        * PlatformEfl.cmake:
     22        Add a new files to the build.
     23
     24        * UIProcess/API/efl/ewk_context.cpp:
     25        (EwkContext::EwkContext):
     26        Detach the text checker initialization from context.
     27        There might be more than default context.
     28        There is one text checker object per application.
     29
     30        * UIProcess/API/efl/ewk_settings.cpp:
     31        * UIProcess/API/efl/ewk_settings.h:
     32        Remove the text checker settings.
     33
     34        * UIProcess/API/efl/ewk_text_checker.cpp:
     35        Add the text checker settings to the ewk_text_checker.h/cpp
     36
     37        (convertLanguagesToEinaList):
     38        Add helper function to convert Vector's values to Eina_List.
     39
     40        (clientCallbacks):
     41        Add the client callback responsible for the continuous spell checking
     42        setting change to the struct.
     43
     44        (ewk_text_checker_continuous_spell_checking_enabled_set):
     45        Do not call the client's callback responsible for the setting
     46        change unless WebKit changes the setting (trough the context
     47        'Check Spelling While Typing' option).
     48
     49        * UIProcess/API/efl/ewk_text_checker.h:
     50        Adjust APIs name to the ewk_text_checker syntax.
     51        Update the documentation according to the changes.
     52
     53        * UIProcess/API/efl/ewk_text_checker_private.h:
     54        (ClientCallbacks):
     55        Move ClientCallbacks structure to TextCheckerClientEfl.
     56        The client callbacks (Ewk API) have to be accessible in WKTextCheckerClient callbacks
     57        to choose what implementation will be used - the client's (if definied) or Enchant impl.
     58
     59        * UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:
     60        Update the unit tests according to the APIs change.
     61        Update the test responsible for the notification about the setting change
     62        according to changes in 'ewk_text_checker_continuous_spell_checking_enabled_set'.
     63
     64        * UIProcess/efl/TextCheckerClientEfl.cpp: Added.
     65        Implement WKTextCheckerClient callbacks.
     66
     67        (TextCheckerClientEfl::TextCheckerClientEfl):
     68        (TextCheckerClientEfl::instance):
     69        Allow to get and create TextCheckerClientEfl object.
     70
     71        (TextCheckerClientEfl::isContinuousSpellCheckingEnabled):
     72        Get the setting value based on WK2 C API.
     73
     74        (TextCheckerClientEfl::ensureSpellCheckingLanguage):
     75        Load the default languages if user didn't specify any.
     76
     77        (TextCheckerClientEfl::updateSpellCheckingLanguages):
     78        (TextCheckerClientEfl::languagesUpdateTimerFired):
     79        (TextCheckerClientEfl::availableSpellCheckingLanguages):
     80        (TextCheckerClientEfl::loadedSpellCheckingLanguages):
     81        (TextCheckerClientEfl::availableSpellCheckingLanguages):
     82        (TextCheckerClientEfl::loadedSpellCheckingLanguages):
     83        Provide support for languages.
     84
     85        (TextCheckerClientEfl::spellCheckingSettingChangeTimerFired):
     86        (TextCheckerClientEfl::callContinuousSpellCheckingChangeCallbackAsync):
     87        Notify the client about the setting change.
     88
     89        (TextCheckerClientEfl::isContinuousSpellCheckingEnabledCallback):
     90        (TextCheckerClientEfl::setContinuousSpellCheckingEnabledCallback):
     91        (TextCheckerClientEfl::uniqueSpellDocumentTagCallback):
     92        (TextCheckerClientEfl::closeSpellDocumentWithTagCallback):
     93        (TextCheckerClientEfl::checkSpellingOfStringCallback):
     94        (TextCheckerClientEfl::guessesForWordCallback):
     95        (TextCheckerClientEfl::learnWordCallback):
     96        (TextCheckerClientEfl::ignoreWordCallback):
     97        WKTextCheckerClient callbacks implementation.
     98
     99        * UIProcess/efl/TextCheckerClientEfl.h: Added.
     100        (TextCheckerClientEfl):
     101        (TextCheckerClientEfl::clientCallbacks):
     102        Return the client callbacks to be used in ewk_text_checker.cpp.
     103
     104        * UIProcess/efl/TextCheckerEfl.cpp:
     105        (WebKit::TextChecker::state):
     106        Initialize the TextCheckerState's members to false.
     107
     108        (WebKit::TextChecker::setContinuousSpellCheckingEnabled):
     109        Set the default language if user didn't specify any.
     110        Notify the client about the setting change.
     111        This method is called when context menu 'Check Spelling While Typing'
     112        option has been toggled.
     113
     114        (WebKit::TextChecker::continuousSpellCheckingEnabledStateChanged):
     115        Set the default language if user didn't specify any.
     116        Called by WKTextChecker's API.
     117
    11182013-04-18  Manuel Rego Casasnovas  <rego@igalia.com>
    2119
  • trunk/Source/WebKit2/PlatformEfl.cmake

    r148025 r148670  
    108108    UIProcess/efl/PageViewportControllerClientEfl.cpp
    109109    UIProcess/efl/RequestManagerClientEfl.cpp
     110    UIProcess/efl/TextCheckerClientEfl.cpp
    110111    UIProcess/efl/TextCheckerEfl.cpp
    111112    UIProcess/efl/VibrationClientEfl.cpp
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_context.cpp

    r145535 r148670  
    4545#include <wtf/text/WTFString.h>
    4646
    47 #if ENABLE(SPELLCHECK)
    48 #include "ewk_settings.h"
    49 #include "ewk_text_checker_private.h"
    50 #endif
    51 
    5247using namespace WebCore;
    5348using namespace WebKit;
     
    8782    }
    8883#endif
    89 
    90 #if ENABLE(SPELLCHECK)
    91     Ewk_Text_Checker::initialize();
    92     if (ewk_settings_continuous_spell_checking_enabled_get()) {
    93         // Load the default language.
    94         ewk_settings_spell_checking_languages_set(0);
    95     }
    96 #endif
    9784}
    9885
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.cpp

    r140686 r148670  
    3434#include <WebKit2/WebPreferences.h>
    3535
    36 #if ENABLE(SPELLCHECK)
    37 #include "WKTextChecker.h"
    38 #include "ewk_text_checker_private.h"
    39 #include <Ecore.h>
    40 #include <wtf/Vector.h>
    41 #include <wtf/text/CString.h>
    42 #endif
    43 
    4436using namespace WebKit;
    4537
     
    5345    return m_view->page()->pageGroup()->preferences();
    5446}
    55 
    56 #if ENABLE(SPELLCHECK)
    57 static struct {
    58     bool isContinuousSpellCheckingEnabled : 1;
    59     Vector<String> spellCheckingLanguages;
    60     Ewk_Settings_Continuous_Spell_Checking_Change_Cb onContinuousSpellChecking;
    61 } ewkTextCheckerSettings = { false, Vector<String>(), 0 };
    62 
    63 static Eina_Bool onContinuousSpellCheckingIdler(void*)
    64 {
    65     if (ewkTextCheckerSettings.onContinuousSpellChecking)
    66         ewkTextCheckerSettings.onContinuousSpellChecking(ewkTextCheckerSettings.isContinuousSpellCheckingEnabled);
    67 
    68     return ECORE_CALLBACK_CANCEL;
    69 }
    70 
    71 static Eina_Bool spellCheckingLanguagesSetUpdate(void*)
    72 {
    73     // FIXME: Consider to delegate calling of this method in WebProcess to do not delay/block UIProcess.
    74     Ewk_Text_Checker::updateSpellCheckingLanguages(ewkTextCheckerSettings.spellCheckingLanguages);
    75     return ECORE_CALLBACK_CANCEL;
    76 }
    77 
    78 static void spellCheckingLanguagesSet(const Vector<String>& newLanguages)
    79 {
    80     ewkTextCheckerSettings.spellCheckingLanguages = newLanguages;
    81     ecore_idler_add(spellCheckingLanguagesSetUpdate, 0);
    82 }
    83 #endif // ENABLE(SPELLCHECK)
    8447
    8548Eina_Bool ewk_settings_fullscreen_enabled_set(Ewk_Settings* settings, Eina_Bool enable)
     
    203166}
    204167
    205 void ewk_settings_continuous_spell_checking_change_cb_set(Ewk_Settings_Continuous_Spell_Checking_Change_Cb callback)
    206 {
    207 #if ENABLE(SPELLCHECK)
    208     ewkTextCheckerSettings.onContinuousSpellChecking = callback;
    209 #endif
    210 }
    211 
    212 Eina_Bool ewk_settings_continuous_spell_checking_enabled_get()
    213 {
    214 #if ENABLE(SPELLCHECK)
    215     return ewkTextCheckerSettings.isContinuousSpellCheckingEnabled;
    216 #else
    217     return false;
    218 #endif
    219 }
    220 
    221 void ewk_settings_continuous_spell_checking_enabled_set(Eina_Bool enable)
    222 {
    223 #if ENABLE(SPELLCHECK)
    224     enable = !!enable;
    225     if (ewkTextCheckerSettings.isContinuousSpellCheckingEnabled != enable) {
    226         ewkTextCheckerSettings.isContinuousSpellCheckingEnabled = enable;
    227 
    228         WKTextCheckerContinuousSpellCheckingEnabledStateChanged(enable);
    229 
    230         // Sets the default language if user didn't specify any.
    231         if (enable && !Ewk_Text_Checker::hasDictionary())
    232             spellCheckingLanguagesSet(Vector<String>());
    233 
    234         if (ewkTextCheckerSettings.onContinuousSpellChecking)
    235             ecore_idler_add(onContinuousSpellCheckingIdler, 0);
    236     }
    237 #endif
    238 }
    239 
    240 Eina_List* ewk_settings_spell_checking_available_languages_get()
    241 {
    242     Eina_List* listOflanguages = 0;
    243 #if ENABLE(SPELLCHECK)
    244     const Vector<String>& languages = Ewk_Text_Checker::availableSpellCheckingLanguages();
    245     size_t numberOfLanuages = languages.size();
    246 
    247     for (size_t i = 0; i < numberOfLanuages; ++i)
    248         listOflanguages = eina_list_append(listOflanguages, eina_stringshare_add(languages[i].utf8().data()));
    249 #endif
    250     return listOflanguages;
    251 }
    252 
    253 void ewk_settings_spell_checking_languages_set(const char* languages)
    254 {
    255 #if ENABLE(SPELLCHECK)
    256     Vector<String> newLanguages;
    257     String::fromUTF8(languages).split(',', newLanguages);
    258 
    259     spellCheckingLanguagesSet(newLanguages);
    260 #endif
    261 }
    262 
    263 Eina_List* ewk_settings_spell_checking_languages_get()
    264 {
    265     Eina_List* listOflanguages = 0;
    266 #if ENABLE(SPELLCHECK)
    267     Vector<String> languages = Ewk_Text_Checker::loadedSpellCheckingLanguages();
    268     size_t numberOfLanuages = languages.size();
    269 
    270     for (size_t i = 0; i < numberOfLanuages; ++i)
    271         listOflanguages = eina_list_append(listOflanguages, eina_stringshare_add(languages[i].utf8().data()));
    272 
    273 #endif
    274     return listOflanguages;
    275 }
    276 
    277168Eina_Bool ewk_settings_encoding_detector_enabled_set(Ewk_Settings* settings, Eina_Bool enable)
    278169{
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_settings.h

    r136941 r148670  
    4444typedef struct EwkSettings Ewk_Settings;
    4545
    46 /**
    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  */
    52 typedef void (*Ewk_Settings_Continuous_Spell_Checking_Change_Cb)(Eina_Bool enable);
    53 
    5446
    5547/**
     
    228220 */
    229221EAPI Eina_Bool ewk_settings_dns_prefetching_enabled_get(const Ewk_Settings *settings);
    230 
    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  */
    243 EAPI 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  */
    250 EAPI 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  */
    263 EAPI 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_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  */
    273 EAPI Eina_List *ewk_settings_spell_checking_available_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  */
    288 EAPI void ewk_settings_spell_checking_languages_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_available_languages_get
    294  * @see ewk_settings_spell_checking_languages_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  */
    299 EAPI Eina_List *ewk_settings_spell_checking_languages_get(void);
    300222
    301223/**
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.cpp

    r145880 r148670  
    11/*
    2  * Copyright (C) 2012 Samsung Electronics
     2 * Copyright (C) 2012-2013 Samsung Electronics
    33 * Copyright (C) 2012 Intel Corporation
    44 *
     
    2929
    3030#if ENABLE(SPELLCHECK)
     31#include "TextCheckerClientEfl.h"
     32#else
     33#include <wtf/UnusedParam.h>
     34#endif // ENABLE(SPELLCHECK)
    3135
    32 #include "EwkView.h"
    33 #include "TextCheckerEnchant.h"
    34 #include "WKAPICast.h"
    35 #include "WKEinaSharedString.h"
    36 #include "WKMutableArray.h"
    37 #include "WKRetainPtr.h"
    38 #include "WKString.h"
    39 #include "WKTextChecker.h"
    40 #include "WebPageProxy.h"
    41 #include "ewk_settings.h"
    42 #include "ewk_text_checker_private.h"
    43 #include <Eina.h>
    44 #include <wtf/OwnPtr.h>
     36#if ENABLE(SPELLCHECK)
    4537
    4638using namespace WebCore;
    4739using namespace WebKit;
    4840
    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;
    61 };
     41static Eina_List* convertLanguagesToEinaList(const Vector<String>& languages)
     42{
     43    Eina_List* listOflanguages = 0;
     44    size_t numberOfLanguages = languages.size();
    6245
    63 static inline TextCheckerEnchant* textCheckerEnchant()
    64 {
    65     static OwnPtr<TextCheckerEnchant> textCheckerEnchant = TextCheckerEnchant::create();
    66     return textCheckerEnchant.get();
     46    for (size_t i = 0; i < numberOfLanguages; ++i)
     47        listOflanguages = eina_list_append(listOflanguages, eina_stringshare_add(languages[i].utf8().data()));
     48
     49    return listOflanguages;
    6750}
    6851
    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(EwkView::toEvasObject(page));
    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, WKEinaSharedString(text), misspellingLocation, misspellingLength);
    103     else
    104         textCheckerEnchant()->checkSpellingOfString(toWTFString(text), *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, WKEinaSharedString(word));
    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(toWTFString(word));
    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, WKEinaSharedString(word));
    136     else
    137         textCheckerEnchant()->learnWord(toWTFString(word));
    138 }
    139 
    140 static void ignoreWord(uint64_t tag, WKStringRef word, const void*)
    141 {
    142     if (clientCallbacks().word_ignore)
    143         clientCallbacks().word_ignore(tag, WKEinaSharedString(word));
    144     else
    145         textCheckerEnchant()->ignoreWord(toWTFString(word));
    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();
    163 }
    164 
    165 bool hasDictionary()
    166 {
    167     return textCheckerEnchant()->hasDictionary();
    168 }
    169 
    170 /**
    171  * Initializes spellcheck feature.
    172  *
    173  * @internal
    174  *
    175  * The default spellcheck feature is based on Enchant library.
    176  * Client may use own spellcheck implementation previously set
    177  * through the callback functions.
    178  */
    179 void initialize()
    180 {
    181     static bool didInitializeTextCheckerClient = false;
    182     if (didInitializeTextCheckerClient)
    183         return;
    184 
    185     WKTextCheckerClient textCheckerClient = {
    186         kWKTextCheckerClientCurrentVersion,
    187         0, // clientInfo
    188         0, // isContinuousSpellCheckingAllowed
    189         isContinuousSpellCheckingEnabled,
    190         setContinuousSpellCheckingEnabled,
    191         0, // isGrammarCheckingEnabled
    192         0, // setGrammarCheckingEnabled
    193         uniqueSpellDocumentTag,
    194         closeSpellDocumentWithTag,
    195         checkSpellingOfString,
    196         0, // checkGrammarOfString
    197         0, // spellingUIIsShowing
    198         0, // toggleSpellingUIIsShowing
    199         0, // updateSpellingUIWithMisspelledWord
    200         0, // updateSpellingUIWithGrammarString
    201         guessesForWord,
    202         learnWord,
    203         ignoreWord
    204     };
    205     WKTextCheckerSetClient(&textCheckerClient);
    206 
    207     didInitializeTextCheckerClient = true;
    208 }
    209 
    210 } // namespace Ewk_Text_Checker
    211 
    212 #define EWK_TEXT_CHECKER_CALLBACK_SET(TYPE_NAME, NAME)  \
    213 void ewk_text_checker_##NAME##_cb_set(TYPE_NAME cb)     \
    214 {                                                       \
    215     clientCallbacks().NAME = cb;      \
     52#define EWK_TEXT_CHECKER_CALLBACK_SET(TYPE_NAME, NAME)            \
     53void ewk_text_checker_##NAME##_cb_set(TYPE_NAME cb)               \
     54{                                                                 \
     55    TextCheckerClientEfl::instance().clientCallbacks().NAME = cb; \
    21656}
    21757
     
    22565#endif // ENABLE(SPELLCHECK)
    22666
     67Eina_Bool ewk_text_checker_continuous_spell_checking_enabled_get()
     68{
     69#if ENABLE(SPELLCHECK)
     70    return TextCheckerClientEfl::instance().isContinuousSpellCheckingEnabled();
     71#else
     72    return false;
     73#endif
     74}
     75
     76void ewk_text_checker_continuous_spell_checking_enabled_set(Eina_Bool enable)
     77{
     78#if ENABLE(SPELLCHECK)
     79    WKTextCheckerContinuousSpellCheckingEnabledStateChanged(!!enable);
     80#else
     81    UNUSED_PARAM(enable);
     82#endif
     83}
     84
     85Eina_List* ewk_text_checker_spell_checking_available_languages_get()
     86{
     87    Eina_List* listOflanguages = 0;
     88#if ENABLE(SPELLCHECK)
     89    // FIXME: Expose WK2 C API to get available spell checking languages.
     90    listOflanguages = convertLanguagesToEinaList(TextCheckerClientEfl::instance().availableSpellCheckingLanguages());
     91#endif
     92    return listOflanguages;
     93}
     94
     95void ewk_text_checker_spell_checking_languages_set(const char* languages)
     96{
     97#if ENABLE(SPELLCHECK)
     98    Vector<String> newLanguages;
     99    String::fromUTF8(languages).split(',', newLanguages);
     100
     101    // FIXME: Expose WK2 C API to set spell checking languages.
     102    TextCheckerClientEfl::instance().updateSpellCheckingLanguages(newLanguages);
     103#else
     104    UNUSED_PARAM(languages);
     105#endif
     106}
     107
     108Eina_List* ewk_text_checker_spell_checking_languages_get()
     109{
     110    Eina_List* listOflanguages = 0;
     111#if ENABLE(SPELLCHECK)
     112    // FIXME: Expose WK2 C API to get loaded spell checking languages.
     113    listOflanguages = convertLanguagesToEinaList(TextCheckerClientEfl::instance().loadedSpellCheckingLanguages());
     114#endif
     115    return listOflanguages;
     116}
     117
     118EWK_TEXT_CHECKER_CALLBACK_SET(Ewk_Text_Checker_Continuous_Spell_Checking_Change_Cb, continuous_spell_checking_change)
    227119EWK_TEXT_CHECKER_CALLBACK_SET(Ewk_Text_Checker_Unique_Spell_Document_Tag_Get_Cb, unique_spell_document_tag_get)
    228120EWK_TEXT_CHECKER_CALLBACK_SET(Ewk_Text_Checker_Unique_Spell_Document_Tag_Close_Cb, unique_spell_document_tag_close)
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_text_checker.h

    r131579 r148670  
    11/*
    2  * Copyright (C) 2012 Samsung Electronics
     2 * Copyright (C) 2012-2013 Samsung Electronics
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626/**
    2727 * @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.
     28 * @brief Provides API to overwrite the default WebKit spellchecker implementation
     29 *        and contains API to manipulate spellchecker settings.
     30 *
     31 * There is one spellchecker object per application.
    3132 * It allows to check spelling in the editable areas.
    32  * If application wants to enable the feature, API from ewk_settings.h
     33 *
     34 * The feature is disabled by default.
     35 * If application wants to enable it, ewk_text_checker_continuous_spell_checking_enabled_set API
    3336 * should be used.
    3437 *
     
    4750extern "C" {
    4851#endif
     52
     53/**
     54 * Creates a type name for the callback function used to notify the client when
     55 * the continuous spell checking setting was changed by WebKit.
     56 *
     57 * @param enable @c EINA_TRUE if continuous spell checking is enabled or @c EINA_FALSE if it's disabled
     58 */
     59typedef void (*Ewk_Text_Checker_Continuous_Spell_Checking_Change_Cb)(Eina_Bool enable);
    4960
    5061/**
     
    109120typedef void (*Ewk_Text_Checker_Word_Ignore_Cb)(uint64_t tag, const char *word);
    110121
     122
     123/**
     124 * Queries if continuous spell checking is enabled.
     125 *
     126 * @return @c EINA_TRUE if continuous spell checking is enabled or @c EINA_FALSE if it's disabled
     127 */
     128EAPI Eina_Bool ewk_text_checker_continuous_spell_checking_enabled_get(void);
     129
     130/**
     131 * Enables/disables continuous spell checking.
     132 *
     133 * This feature is disabled by default.
     134 *
     135 * @see ewk_text_checker_continuous_spell_checking_change_cb_set
     136 *
     137 * @param enable @c EINA_TRUE to enable continuous spell checking or @c EINA_FALSE to disable
     138 */
     139EAPI void ewk_text_checker_continuous_spell_checking_enabled_set(Eina_Bool enable);
     140
     141/**
     142 * Gets the the list of all available the spell checking languages to use.
     143 *
     144 * @see ewk_settings_spell_checking_languages_set
     145 *
     146 * @return the list with available spell checking languages, or @c NULL on failure
     147 *         the Eina_List and its items should be freed after, use eina_stringshare_del()
     148 */
     149EAPI Eina_List *ewk_text_checker_spell_checking_available_languages_get(void);
     150
     151/**
     152 * Sets @a languages as the list of languages to use by default WebKit
     153 * implementation of spellchecker feature with Enchant library support.
     154 *
     155 * If @languages is @c NULL, the default language is used.
     156 * If the default language can not be determined then any available dictionary will be used.
     157 *
     158 * @note This function invalidates the previously set languages.
     159 *       The dictionaries are requested asynchronously.
     160 *
     161 * @param languages a list of comma (',') separated language codes
     162 *        of the form 'en_US', ie, language_VARIANT, may be @c NULL.
     163 */
     164EAPI void ewk_text_checker_spell_checking_languages_set(const char *languages);
     165
     166/**
     167 * Gets the the list of the spell checking languages in use.
     168 *
     169 * @see ewk_settings_spell_checking_available_languages_get
     170 * @see ewk_settings_spell_checking_languages_set
     171 *
     172 * @return the list with the spell checking languages in use,
     173 *         the Eina_List and its items should be freed after, use eina_stringshare_del()
     174 */
     175EAPI Eina_List *ewk_text_checker_spell_checking_languages_get(void);
     176
     177/**
     178 * Sets a callback function used to notify the client when
     179 * the continuous spell checking setting was changed by WebKit.
     180 *
     181 * Specifying of this callback is needed if the application wants to receive notifications
     182 * once WebKit changes this setting.
     183 * If the application is not interested, this callback is not set.
     184 * Changing of this setting at the WebKit level can be made as a result of modifying
     185 * options in a Context Menu by a user.
     186 *
     187 * @param cb a new callback function to set or @c NULL to invalidate the previous one
     188 */
     189EAPI void ewk_text_checker_continuous_spell_checking_change_cb_set(Ewk_Text_Checker_Continuous_Spell_Checking_Change_Cb cb);
     190
    111191/**
    112192 * Sets a callback function to get a unique spell document tag.
  • trunk/Source/WebKit2/UIProcess/API/efl/ewk_text_checker_private.h

    r134021 r148670  
    11/*
    2  * Copyright (C) 2012 Samsung Electronics
     2 * Copyright (C) 2012-2013 Samsung Electronics
    33 * Copyright (C) 2012 Intel Corporation
    44 *
     
    3232#include "ewk_text_checker.h"
    3333
    34 namespace Ewk_Text_Checker {
    35 
    36 void initialize();
    37 
    38 // Enchant helpers.
    39 Vector<String> availableSpellCheckingLanguages();
    40 void updateSpellCheckingLanguages(const Vector<String>& languages);
    41 Vector<String> loadedSpellCheckingLanguages();
    42 bool hasDictionary();
    43 
    44 }
     34/**
     35 * @brief Structure to store client callback functions.
     36 *
     37 * @internal
     38 */
     39struct ClientCallbacks {
     40    Ewk_Text_Checker_Continuous_Spell_Checking_Change_Cb continuous_spell_checking_change;
     41    Ewk_Text_Checker_Unique_Spell_Document_Tag_Get_Cb unique_spell_document_tag_get;
     42    Ewk_Text_Checker_Unique_Spell_Document_Tag_Close_Cb unique_spell_document_tag_close;
     43    Ewk_Text_Checker_String_Spelling_Check_Cb string_spelling_check;
     44    Ewk_Text_Checker_Word_Guesses_Get_Cb word_guesses_get;
     45    Ewk_Text_Checker_Word_Learn_Cb word_learn;
     46    Ewk_Text_Checker_Word_Ignore_Cb word_ignore;
     47};
    4548
    4649#endif // ENABLE(SPELLCHECK)
  • trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp

    r135349 r148670  
    214214
    215215/**
    216  * Test setter/getter for the continous spell checking:
    217  *  - ewk_settings_continuous_spell_checking_enabled_get
    218  *  - ewk_settings_continuous_spell_checking_enabled_set
    219  */
    220 TEST_F(EWK2UnitTestBase, ewk_settings_continuous_spell_checking_enabled)
    221 {
    222     ewk_settings_continuous_spell_checking_enabled_set(true);
     216 * Test setter/getter for the continuous spell checking:
     217 *  - ewk_text_checker_continuous_spell_checking_enabled_get
     218 *  - ewk_text_checker_continuous_spell_checking_enabled_set
     219 */
     220TEST_F(EWK2UnitTestBase, ewk_text_checker_continuous_spell_checking_enabled)
     221{
     222    ewk_text_checker_continuous_spell_checking_enabled_set(true);
    223223#if ENABLE(SPELLCHECK)
    224     EXPECT_TRUE(ewk_settings_continuous_spell_checking_enabled_get());
     224    EXPECT_TRUE(ewk_text_checker_continuous_spell_checking_enabled_get());
    225225
    226226    // When the spell checking has been enabled, the default language is set (if the user
     
    229229    ecore_main_loop_begin();
    230230
    231     Eina_List* loadedLanguages = ewk_settings_spell_checking_languages_get();
     231    Eina_List* loadedLanguages = ewk_text_checker_spell_checking_languages_get();
    232232    // No dictionary is available/installed.
    233233    if (!loadedLanguages)
     
    240240        eina_stringshare_del(static_cast<const char*>(data));
    241241#else
    242     EXPECT_FALSE(ewk_settings_continuous_spell_checking_enabled_get());
     242    EXPECT_FALSE(ewk_text_checker_continuous_spell_checking_enabled_get());
    243243#endif
    244244
    245     ewk_settings_continuous_spell_checking_enabled_set(false);
    246     EXPECT_FALSE(ewk_settings_continuous_spell_checking_enabled_get());
    247 }
    248 
    249 /**
    250  * Test whether the callback is called when the spell checking setting has been changed.
    251  */
    252 TEST_F(EWK2UnitTestBase, ewk_settings_continuous_spell_checking_change_cb_set)
    253 {
    254     ewk_settings_continuous_spell_checking_change_cb_set(onSettingChange);
    255 
    256     isSettingEnabled = ewk_settings_continuous_spell_checking_enabled_get();
     245    ewk_text_checker_continuous_spell_checking_enabled_set(false);
     246    EXPECT_FALSE(ewk_text_checker_continuous_spell_checking_enabled_get());
     247}
     248
     249/**
     250 * Test whether the callback is called when the spell checking setting was changed by WebKit.
     251 * Changing of this setting at the WebKit level can be made as a result of modifying
     252 * options in a Context Menu by a user.
     253 */
     254TEST_F(EWK2UnitTestBase, ewk_text_checker_continuous_spell_checking_change_cb_set)
     255{
     256    ewk_text_checker_continuous_spell_checking_change_cb_set(onSettingChange);
     257
     258    isSettingEnabled = ewk_text_checker_continuous_spell_checking_enabled_get();
    257259    isSettingEnabled = !isSettingEnabled;
    258     ewk_settings_continuous_spell_checking_enabled_set(isSettingEnabled);
     260    // The notifications about the setting change shouldn't be sent if the change was made
     261    // on the client's request (public API).
     262    ewk_text_checker_continuous_spell_checking_enabled_set(isSettingEnabled);
    259263
    260264    timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
     
    265269    ecore_main_loop_begin();
    266270
    267 #if ENABLE(SPELLCHECK)
    268     EXPECT_FALSE(timeoutTimer);
    269 #else
    270271    EXPECT_TRUE(timeoutTimer);
    271 #endif
    272 
    273     // The callback shouldn't be called if the setting option is already set.
    274     isSettingEnabled = ewk_settings_continuous_spell_checking_enabled_get();
    275     ewk_settings_continuous_spell_checking_enabled_set(isSettingEnabled);
    276 
    277     timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
    278     ecore_main_loop_begin();
    279 
    280     // When the SPELLCHECK macro is disabled the callback won't be called too.
    281     EXPECT_TRUE(timeoutTimer);
    282 
    283     // The callback shouldn't be called if the user has invalidated it.
    284     ewk_settings_continuous_spell_checking_change_cb_set(0);
    285     isSettingEnabled = ewk_settings_continuous_spell_checking_enabled_get();
    286     isSettingEnabled = !isSettingEnabled;
    287     ewk_settings_continuous_spell_checking_enabled_set(isSettingEnabled);
    288 
    289     timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
    290     ecore_main_loop_begin();
    291 
    292     // If the SPELLCHECK macro is disabled, the callback is not set.
    293     EXPECT_TRUE(timeoutTimer);
     272
     273    /* The callback should be called if the context menu "Check Spelling While Typing" option
     274       was toggled by the user.
     275    FIXME:
     276    1) Invoke the context menu on the input field.
     277    2) Choose the sub menu "Spelling and Grammar" option (not implemented for WK2).
     278    3) Toggle "Check Spelling While Typing" option.
     279    4) Check whether the callback is called. */
     280
     281    /* The callback shouldn't be called if the user has invalidated it.
     282    FIXME:
     283    1) Call ewk_text_checker_continuous_spell_checking_change_cb_set(0) to notify the WebKit that
     284       the client is not interested in the setting change.
     285    2) Invoke the context menu on the input field.
     286    3) Choose the sub menu "Spelling and Grammar" option (not implemented for WK2).
     287    4) Toggle "Check Spelling While Typing" option.
     288    5) Check whether the callback was called. */
    294289}
    295290
     
    299294 * All the dictionaries from the list can be set to perform spellchecking.
    300295 */
    301 TEST_F(EWK2UnitTestBase, ewk_settings_spell_checking_available_languages_get)
    302 {
    303     Eina_List* availableLanguages = ewk_settings_spell_checking_available_languages_get();
     296TEST_F(EWK2UnitTestBase, ewk_text_checker_spell_checking_available_languages_get)
     297{
     298    Eina_List* availableLanguages = ewk_text_checker_spell_checking_available_languages_get();
    304299    // No dictionary is available/installed or the SPELLCHECK macro is disabled.
    305300    if (!availableLanguages)
     
    320315
    321316    // Set all available languages.
    322     ewk_settings_spell_checking_languages_set(languages.toString().utf8().data());
     317    ewk_text_checker_spell_checking_languages_set(languages.toString().utf8().data());
    323318
    324319    // Languages are being loaded on the idler, wait for them.
     
    327322
    328323    // Get the languages in use.
    329     Eina_List* loadedLanguages = ewk_settings_spell_checking_languages_get();
     324    Eina_List* loadedLanguages = ewk_text_checker_spell_checking_languages_get();
    330325    ASSERT_EQ(eina_list_count(loadedLanguages), eina_list_count(availableLanguages));
    331326
     
    351346 *  - if two arbitrarily selected dictionaries are set correctly.
    352347 */
    353 TEST_F(EWK2UnitTestBase, ewk_settings_spell_checking_languages)
     348TEST_F(EWK2UnitTestBase, ewk_text_checker_spell_checking_languages)
    354349{
    355350    // Set the default language.
    356     ewk_settings_spell_checking_languages_set(0);
     351    ewk_text_checker_spell_checking_languages_set(0);
    357352
    358353    // Languages are being loaded on the idler, wait for them.
     
    360355    ecore_main_loop_begin();
    361356
    362     Eina_List* loadedLanguages = ewk_settings_spell_checking_languages_get();
     357    Eina_List* loadedLanguages = ewk_text_checker_spell_checking_languages_get();
    363358    // No dictionary is available/installed or the SPELLCHECK macro is disabled.
    364359    if (!loadedLanguages)
     
    373368
    374369    // Get the first and last language from installed dictionaries.
    375     Eina_List* availableLanguages = ewk_settings_spell_checking_available_languages_get();
     370    Eina_List* availableLanguages = ewk_text_checker_spell_checking_available_languages_get();
    376371    unsigned numberOfAvailableLanguages = eina_list_count(availableLanguages);
    377372    // We assume that user has installed at lest two dictionaries.
     
    390385
    391386    // Set both languages (the first and the last) from the list.
    392     ewk_settings_spell_checking_languages_set(languages.toString().utf8().data());
     387    ewk_text_checker_spell_checking_languages_set(languages.toString().utf8().data());
    393388
    394389    timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
    395390    ecore_main_loop_begin();
    396391
    397     loadedLanguages = ewk_settings_spell_checking_languages_get();
     392    loadedLanguages = ewk_text_checker_spell_checking_languages_get();
    398393    ASSERT_EQ(2, eina_list_count(loadedLanguages));
    399394
     
    415410{
    416411    resetCallbacksExecutionStats();
    417     ewk_settings_continuous_spell_checking_enabled_set(true);
     412    ewk_text_checker_continuous_spell_checking_enabled_set(true);
    418413
    419414    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
     
    437432    resetCallbacksExecutionStats();
    438433    defaultView = webView();
    439     ewk_settings_continuous_spell_checking_enabled_set(true);
     434    ewk_text_checker_continuous_spell_checking_enabled_set(true);
    440435
    441436    ewk_text_checker_unique_spell_document_tag_get_cb_set(onSpellDocumentTag);
     
    459454    resetCallbacksExecutionStats();
    460455    defaultView = webView();
    461     ewk_settings_continuous_spell_checking_enabled_set(true);
     456    ewk_text_checker_continuous_spell_checking_enabled_set(true);
    462457
    463458    ewk_text_checker_string_spelling_check_cb_set(onSpellingCheck);
     
    477472    resetCallbacksExecutionStats();
    478473    defaultView = webView();
    479     ewk_settings_continuous_spell_checking_enabled_set(true);
     474    ewk_text_checker_continuous_spell_checking_enabled_set(true);
    480475
    481476    ewk_text_checker_word_guesses_get_cb_set(onWordGuesses);
     
    499494    resetCallbacksExecutionStats();
    500495    defaultView = webView();
    501     ewk_settings_continuous_spell_checking_enabled_set(true);
     496    ewk_text_checker_continuous_spell_checking_enabled_set(true);
    502497
    503498    ewk_text_checker_word_learn_cb_set(onWordLearn);
     
    519514    resetCallbacksExecutionStats();
    520515    defaultView = webView();
    521     ewk_settings_continuous_spell_checking_enabled_set(true);
     516    ewk_text_checker_continuous_spell_checking_enabled_set(true);
    522517
    523518    ewk_text_checker_word_ignore_cb_set(onWordIgnore);
  • trunk/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp

    r147993 r148670  
    22 * Copyright (C) 2010 Apple Inc. All rights reserved.
    33 * Portions Copyright (c) 2010 Motorola Mobility, Inc.  All rights reserved.
    4  * Copyright (C) 2011-2012 Samsung Electronics
     4 * Copyright (C) 2011-2013 Samsung Electronics
    55 *
    66 * Redistribution and use in source and binary forms, with or without
     
    3434#if ENABLE(SPELLCHECK)
    3535#include "TextBreakIterator.h"
     36#include "TextCheckerClientEfl.h"
    3637#include "WebTextChecker.h"
    3738#endif
     
    4546const TextCheckerState& TextChecker::state()
    4647{
    47 #if ENABLE(SPELLCHECK)
    4848    static bool didInitializeState = false;
    4949    if (didInitializeState)
    5050        return textCheckerState;
    5151
    52     WebTextCheckerClient& client = WebTextChecker::shared()->client();
    53     textCheckerState.isContinuousSpellCheckingEnabled = client.continuousSpellCheckingEnabled();
    54     textCheckerState.isGrammarCheckingEnabled = client.grammarCheckingEnabled();
     52    textCheckerState.isContinuousSpellCheckingEnabled = false;
     53    textCheckerState.isGrammarCheckingEnabled = false;
    5554
    5655    didInitializeState = true;
    57 #endif
     56
    5857    return textCheckerState;
    5958}
     
    7271
    7372    textCheckerState.isContinuousSpellCheckingEnabled = isContinuousSpellCheckingEnabled;
     73
     74    if (isContinuousSpellCheckingEnabled)
     75        TextCheckerClientEfl::instance().ensureSpellCheckingLanguage();
     76
     77    // Notify the client about the setting change.
    7478    WebTextChecker::shared()->client().setContinuousSpellCheckingEnabled(isContinuousSpellCheckingEnabled);
    7579#else
     
    8589void TextChecker::continuousSpellCheckingEnabledStateChanged(bool enabled)
    8690{
    87     TextChecker::setContinuousSpellCheckingEnabled(enabled);
     91#if ENABLE(SPELLCHECK)
     92    if (state().isContinuousSpellCheckingEnabled == enabled)
     93        return;
     94
     95    textCheckerState.isContinuousSpellCheckingEnabled = enabled;
     96
     97    if (enabled)
     98        TextCheckerClientEfl::instance().ensureSpellCheckingLanguage();
     99#else
     100    UNUSED_PARAM(enabled);
     101#endif
    88102}
    89103
  • trunk/Tools/ChangeLog

    r148662 r148670  
     12013-04-18  Grzegorz Czajkowski  <g.czajkowski@samsung.com>
     2
     3        [WK2][EFL] Text Checker's settings refactor
     4        https://bugs.webkit.org/show_bug.cgi?id=111713
     5
     6        Reviewed by Andreas Kling.
     7
     8        * MiniBrowser/efl/main.c:
     9        (window_create):
     10        Use a new text checker API to enable spell checking.
     11
    1122013-04-18  Seokju Kwon  <seokju.kwon@gmail.com>
    213
  • trunk/Tools/MiniBrowser/efl/main.c

    r148662 r148670  
    15451545    ewk_settings_developer_extras_enabled_set(settings, EINA_TRUE);
    15461546    ewk_settings_preferred_minimum_contents_width_set(settings, 0);
    1547     ewk_settings_continuous_spell_checking_enabled_set(spell_checking_enabled);
     1547    ewk_text_checker_continuous_spell_checking_enabled_set(spell_checking_enabled);
    15481548
    15491549    evas_object_smart_callback_add(window->ewk_view, "authentication,request", on_authentication_request, window);
Note: See TracChangeset for help on using the changeset viewer.