2009-04-24 Diego Escalante Urrelo <diegoe@gnome.org>
authorkov@webkit.org <kov@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Apr 2009 13:16:57 +0000 (13:16 +0000)
committerkov@webkit.org <kov@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Apr 2009 13:16:57 +0000 (13:16 +0000)
        Reviewed by Gustavo Noronha.

        https://bugs.webkit.org/show_bug.cgi?id=15616
        [GTK] Add spell checking

        Implement EditorClient::ignoreWordInSpellDocument,
        EditorClient::learnWord and EditorClient::getGuessesForWord. This
        enables the corresponding user actions.

        * WebCoreSupport/EditorClientGtk.cpp:
        (WebKit::EditorClient::ignoreWordInSpellDocument):
        (WebKit::EditorClient::learnWord):
        (WebKit::EditorClient::getGuessesForWord):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@42820 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/gtk/ChangeLog
WebKit/gtk/WebCoreSupport/EditorClientGtk.cpp

index 0344839..b1f9d19 100644 (file)
@@ -5,6 +5,22 @@
         https://bugs.webkit.org/show_bug.cgi?id=15616
         [GTK] Add spell checking
 
+        Implement EditorClient::ignoreWordInSpellDocument,
+        EditorClient::learnWord and EditorClient::getGuessesForWord. This
+        enables the corresponding user actions.
+
+        * WebCoreSupport/EditorClientGtk.cpp:
+        (WebKit::EditorClient::ignoreWordInSpellDocument):
+        (WebKit::EditorClient::learnWord):
+        (WebKit::EditorClient::getGuessesForWord):
+
+2009-04-24  Diego Escalante Urrelo  <diegoe@gnome.org>
+
+        Reviewed by Gustavo Noronha.
+
+        https://bugs.webkit.org/show_bug.cgi?id=15616
+        [GTK] Add spell checking
+
         Implement EditorClient::checkSpellingOfString; enabling spell checking
         to actually happen, this is the basis for other spelling functions.
 
index 9114b48..96f33bc 100644 (file)
@@ -517,14 +517,26 @@ void EditorClient::textDidChangeInTextArea(Element*)
     notImplemented();
 }
 
-void EditorClient::ignoreWordInSpellDocument(const String&)
+void EditorClient::ignoreWordInSpellDocument(const String& text)
 {
-    notImplemented();
+    GSList* langs = webkit_web_settings_get_spell_languages(m_webView);
+
+    for (; langs; langs = langs->next) {
+        SpellLanguage* lang = static_cast<SpellLanguage*>(langs->data);
+
+        enchant_dict_add_to_session(lang->speller, text.utf8().data(), -1);
+    }
 }
 
-void EditorClient::learnWord(const String&)
+void EditorClient::learnWord(const String& text)
 {
-    notImplemented();
+    GSList* langs = webkit_web_settings_get_spell_languages(m_webView);
+
+    for (; langs; langs = langs->next) {
+        SpellLanguage* lang = static_cast<SpellLanguage*>(langs->data);
+
+        enchant_dict_add_to_personal(lang->speller, text.utf8().data(), -1);
+    }
 }
 
 void EditorClient::checkSpellingOfString(const UChar* text, int length, int* misspellingLocation, int* misspellingLength)
@@ -606,9 +618,24 @@ bool EditorClient::spellingUIIsShowing()
     return false;
 }
 
-void EditorClient::getGuessesForWord(const String&, Vector<String>&)
+void EditorClient::getGuessesForWord(const String& word, WTF::Vector<String>& guesses)
 {
-    notImplemented();
+    GSList* langs = webkit_web_settings_get_spell_languages(m_webView);
+    guesses.clear();
+
+    for (; langs; langs = langs->next) {
+        size_t numberOfSuggestions;
+        size_t i;
+
+        SpellLanguage* lang = static_cast<SpellLanguage*>(langs->data);
+        gchar** suggestions = enchant_dict_suggest(lang->speller, word.utf8().data(), -1, &numberOfSuggestions);
+
+        for (i = 0; i < numberOfSuggestions && i < 10; i++)
+            guesses.append(String::fromUTF8(suggestions[i]));
+
+        if (numberOfSuggestions > 0)
+            enchant_dict_free_suggestions(lang->speller, suggestions);
+    }
 }
 
 }