Diff
Modified: trunk/Source/WebCore/ChangeLog (126297 => 126298)
--- trunk/Source/WebCore/ChangeLog 2012-08-22 13:22:51 UTC (rev 126297)
+++ trunk/Source/WebCore/ChangeLog 2012-08-22 13:34:13 UTC (rev 126298)
@@ -1,3 +1,19 @@
+2012-08-22 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Preferred languages and spellchecker APIs are not consistent in WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=94683
+
+ Reviewed by Alejandro G. Castro.
+
+ Use a Vector<String> instead of a comma-separated string to
+ get/set languages.
+
+ * platform/text/gtk/TextCheckerEnchant.cpp:
+ (TextCheckerEnchant::updateSpellCheckingLanguages):
+ (TextCheckerEnchant::getSpellCheckingLanguages):
+ * platform/text/gtk/TextCheckerEnchant.h:
+ (TextCheckerEnchant):
+
2012-08-22 Pavel Feldman <[email protected]>
Web Inspector: move NavigatorView and NavigatorOverlayController to ScriptsPanel module
Modified: trunk/Source/WebCore/platform/text/gtk/TextCheckerEnchant.cpp (126297 => 126298)
--- trunk/Source/WebCore/platform/text/gtk/TextCheckerEnchant.cpp 2012-08-22 13:22:51 UTC (rev 126297)
+++ trunk/Source/WebCore/platform/text/gtk/TextCheckerEnchant.cpp 2012-08-22 13:34:13 UTC (rev 126298)
@@ -155,14 +155,12 @@
return guesses;
}
-void TextCheckerEnchant::updateSpellCheckingLanguages(const String& languages)
+void TextCheckerEnchant::updateSpellCheckingLanguages(const Vector<String>& languages)
{
Vector<EnchantDict*> spellDictionaries;
if (!languages.isEmpty()) {
- Vector<String> languagesVector;
- languages.split(static_cast<UChar>(','), languagesVector);
- for (Vector<String>::const_iterator iter = languagesVector.begin(); iter != languagesVector.end(); ++iter) {
+ for (Vector<String>::const_iterator iter = languages.begin(); iter != languages.end(); ++iter) {
CString currentLanguage = iter->utf8();
if (enchant_broker_dict_exists(m_broker, currentLanguage.data())) {
EnchantDict* dict = enchant_broker_request_dict(m_broker, currentLanguage.data());
@@ -188,24 +186,21 @@
m_enchantDictionaries = spellDictionaries;
}
-String TextCheckerEnchant::getSpellCheckingLanguages()
+Vector<String> TextCheckerEnchant::getSpellCheckingLanguages()
{
+ Vector<String> languages;
if (m_enchantDictionaries.isEmpty())
- return String();
+ return languages;
// Get a Vector<CString> with the list of languages in use.
Vector<CString> currentDictionaries;
for (Vector<EnchantDict*>::const_iterator iter = m_enchantDictionaries.begin(); iter != m_enchantDictionaries.end(); ++iter)
enchant_dict_describe(*iter, enchantDictDescribeCallback, ¤tDictionaries);
- // Build the result String;
- StringBuilder builder;
- for (Vector<CString>::const_iterator iter = currentDictionaries.begin(); iter != currentDictionaries.end(); ++iter) {
- if (iter != currentDictionaries.begin())
- builder.append(",");
- builder.append(String::fromUTF8(iter->data()));
- }
- return builder.toString();
+ for (Vector<CString>::const_iterator iter = currentDictionaries.begin(); iter != currentDictionaries.end(); ++iter)
+ languages.append(String::fromUTF8(iter->data()));
+
+ return languages;
}
void TextCheckerEnchant::freeEnchantBrokerDictionaries()
Modified: trunk/Source/WebCore/platform/text/gtk/TextCheckerEnchant.h (126297 => 126298)
--- trunk/Source/WebCore/platform/text/gtk/TextCheckerEnchant.h 2012-08-22 13:22:51 UTC (rev 126297)
+++ trunk/Source/WebCore/platform/text/gtk/TextCheckerEnchant.h 2012-08-22 13:34:13 UTC (rev 126298)
@@ -41,8 +41,8 @@
void learnWord(const String&);
void checkSpellingOfString(const String&, int& misspellingLocation, int& misspellingLength);
Vector<String> getGuessesForWord(const String&);
- void updateSpellCheckingLanguages(const String& languages);
- String getSpellCheckingLanguages();
+ void updateSpellCheckingLanguages(const Vector<String>& languages);
+ Vector<String> getSpellCheckingLanguages();
private:
TextCheckerEnchant();
Modified: trunk/Source/WebKit/gtk/ChangeLog (126297 => 126298)
--- trunk/Source/WebKit/gtk/ChangeLog 2012-08-22 13:22:51 UTC (rev 126297)
+++ trunk/Source/WebKit/gtk/ChangeLog 2012-08-22 13:34:13 UTC (rev 126298)
@@ -1,3 +1,14 @@
+2012-08-22 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Preferred languages and spellchecker APIs are not consistent in WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=94683
+
+ Reviewed by Alejandro G. Castro.
+
+ * webkit/webkitspellcheckerenchant.cpp:
+ (updateSpellCheckingLanguages): Split the languages string to pass a
+ Vector to updateSpellCheckingLanguages().
+
2012-08-21 Joanmarie Diggs <[email protected]>
[Gtk] No accessible caret-moved events found in certain content
https://bugs.webkit.org/show_bug.cgi?id=72811
Modified: trunk/Source/WebKit/gtk/webkit/webkitspellcheckerenchant.cpp (126297 => 126298)
--- trunk/Source/WebKit/gtk/webkit/webkitspellcheckerenchant.cpp 2012-08-22 13:22:51 UTC (rev 126297)
+++ trunk/Source/WebKit/gtk/webkit/webkitspellcheckerenchant.cpp 2012-08-22 13:34:13 UTC (rev 126298)
@@ -99,7 +99,10 @@
static void updateSpellCheckingLanguages(WebKitSpellChecker* checker, const char* languages)
{
WebKitSpellCheckerEnchantPrivate* priv = WEBKIT_SPELL_CHECKER_ENCHANT(checker)->priv;
- priv->textCheckerEnchant->updateSpellCheckingLanguages(String::fromUTF8(languages));
+
+ Vector<String> languagesVector;
+ String::fromUTF8(languages).split(static_cast<UChar>(','), languagesVector);
+ priv->textCheckerEnchant->updateSpellCheckingLanguages(languagesVector);
}
static char* getAutocorrectSuggestionsForMisspelledWord(WebKitSpellChecker* checker, const char* word)
Modified: trunk/Source/WebKit2/ChangeLog (126297 => 126298)
--- trunk/Source/WebKit2/ChangeLog 2012-08-22 13:22:51 UTC (rev 126297)
+++ trunk/Source/WebKit2/ChangeLog 2012-08-22 13:34:13 UTC (rev 126298)
@@ -1,3 +1,30 @@
+2012-08-22 Carlos Garcia Campos <[email protected]>
+
+ [GTK] Preferred languages and spellchecker APIs are not consistent in WebKit2
+ https://bugs.webkit.org/show_bug.cgi?id=94683
+
+ Reviewed by Alejandro G. Castro.
+
+ Change spell-checker and preferred languages API to use a GStrv
+ instead of a comma-separated string and GList. This makes the API
+ more consistent and convenient to use.
+
+ * UIProcess/API/gtk/WebKitTextChecker.cpp:
+ (WebKitTextChecker::getSpellCheckingLanguages): Return a
+ Vector<String> instead of a String.
+ (WebKitTextChecker::setSpellCheckingLanguages): Receive a
+ Vector<String> instead of a String.
+ * UIProcess/API/gtk/WebKitTextChecker.h:
+ (WebKitTextChecker): Use a GPtrArray to cache languages.
+ * UIProcess/API/gtk/WebKitWebContext.cpp:
+ (webkit_web_context_get_spell_checking_languages):
+ (webkit_web_context_set_spell_checking_languages):
+ (webkit_web_context_set_preferred_languages):
+ * UIProcess/API/gtk/WebKitWebContext.h:
+ * UIProcess/API/gtk/tests/TestWebKitWebContext.cpp:
+ (testWebContextSpellChecker):
+ (testWebContextLanguages):
+
2012-08-22 Csaba Osztrogonác <[email protected]>
[Qt][WK2] Enable runtime enabled features: DeviceMotion and DeviceOrientation
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp (126297 => 126298)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp 2012-08-22 13:22:51 UTC (rev 126297)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp 2012-08-22 13:34:13 UTC (rev 126298)
@@ -29,8 +29,6 @@
#if ENABLE(SPELLCHECK)
#include "WebKitPrivate.h"
-#include <wtf/Vector.h>
-#include <wtf/text/CString.h>
using namespace WebKit;
@@ -140,15 +138,25 @@
WKTextCheckerContinuousSpellCheckingEnabledStateChanged(enabled);
}
-const CString& WebKitTextChecker::getSpellCheckingLanguages()
+const char* const* WebKitTextChecker::getSpellCheckingLanguages()
{
- String spellCheckingLanguages = m_textChecker->getSpellCheckingLanguages();
- m_spellCheckingLanguages = spellCheckingLanguages.isEmpty() ? CString() : spellCheckingLanguages.utf8();
- return m_spellCheckingLanguages;
+ Vector<String> spellCheckingLanguages = m_textChecker->getSpellCheckingLanguages();
+ if (spellCheckingLanguages.isEmpty())
+ return 0;
+
+ m_spellCheckingLanguages = adoptGRef(g_ptr_array_new_with_free_func(g_free));
+ for (size_t i = 0; i < spellCheckingLanguages.size(); ++i)
+ g_ptr_array_add(m_spellCheckingLanguages.get(), g_strdup(spellCheckingLanguages[i].utf8().data()));
+ g_ptr_array_add(m_spellCheckingLanguages.get(), 0);
+
+ return reinterpret_cast<char**>(m_spellCheckingLanguages->pdata);
}
-void WebKitTextChecker::setSpellCheckingLanguages(const CString& languages)
+void WebKitTextChecker::setSpellCheckingLanguages(const char* const* languages)
{
- m_textChecker->updateSpellCheckingLanguages(String::fromUTF8(languages.data()));
+ Vector<String> spellCheckingLanguages;
+ for (size_t i = 0; languages[i]; ++i)
+ spellCheckingLanguages.append(String::fromUTF8(languages[i]));
+ m_textChecker->updateSpellCheckingLanguages(spellCheckingLanguages);
}
#endif // ENABLE(SPELLCHECK)
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h (126297 => 126298)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h 2012-08-22 13:22:51 UTC (rev 126297)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h 2012-08-22 13:34:13 UTC (rev 126298)
@@ -26,6 +26,7 @@
#include <wtf/FastAllocBase.h>
#include <wtf/PassOwnPtr.h>
#include <wtf/Vector.h>
+#include <wtf/gobject/GRefPtr.h>
#include <wtf/text/CString.h>
class WebKitTextChecker {
@@ -44,14 +45,14 @@
void ignoreWord(const String& word);
// To be called from WebKitWebContext only.
- const CString& getSpellCheckingLanguages();
- void setSpellCheckingLanguages(const CString& spellCheckingLanguages);
+ const char* const* getSpellCheckingLanguages();
+ void setSpellCheckingLanguages(const char* const* spellCheckingLanguages);
private:
WebKitTextChecker();
OwnPtr<WebCore::TextCheckerEnchant> m_textChecker;
- CString m_spellCheckingLanguages;
+ GRefPtr<GPtrArray> m_spellCheckingLanguages;
bool m_spellCheckingEnabled;
};
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (126297 => 126298)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp 2012-08-22 13:22:51 UTC (rev 126297)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp 2012-08-22 13:34:13 UTC (rev 126298)
@@ -495,24 +495,20 @@
* @context: a #WebKitWebContext
*
* Get the the list of spell checking languages associated with
- * @context separated by commas, or %NULL if no languages have been
- * previously set.
-
+ * @context, or %NULL if no languages have been previously set.
+ *
* See webkit_web_context_set_spell_checking_languages() for more
* details on the format of the languages in the list.
*
- * Returns: (transfer none): A comma separated list of languages if
- * available, or %NULL otherwise.
+ * Returns: (array zero-terminated=1) (element-type utf8) (transfer none): A %NULL-terminated
+ * array of languages if available, or %NULL otherwise.
*/
-const gchar* webkit_web_context_get_spell_checking_languages(WebKitWebContext* context)
+const gchar* const* webkit_web_context_get_spell_checking_languages(WebKitWebContext* context)
{
g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), 0);
#if ENABLE(SPELLCHECK)
- CString spellCheckingLanguages = context->priv->textChecker->getSpellCheckingLanguages();
- if (spellCheckingLanguages.isNull())
- return 0;
- return spellCheckingLanguages.data();
+ return context->priv->textChecker->getSpellCheckingLanguages();
#else
return 0;
#endif
@@ -521,11 +517,10 @@
/**
* webkit_web_context_set_spell_checking_languages:
* @context: a #WebKitWebContext
- * @languages: new list of spell checking languages separated by
- * commas
+ * @languages: (array zero-terminated=1) (transfer none): a %NULL-terminated list of spell checking languages
*
* Set the list of spell checking languages to be used for spell
- * checking, separated by commas.
+ * checking.
*
* The locale string typically is in the form lang_COUNTRY, where lang
* is an ISO-639 language code, and COUNTRY is an ISO-3166 country code.
@@ -536,7 +531,7 @@
* least once in order to properly enable the spell checking feature
* in WebKit.
*/
-void webkit_web_context_set_spell_checking_languages(WebKitWebContext* context, const gchar* languages)
+void webkit_web_context_set_spell_checking_languages(WebKitWebContext* context, const gchar* const* languages)
{
g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
g_return_if_fail(languages);
@@ -549,23 +544,23 @@
/**
* webkit_web_context_set_preferred_languages:
* @context: a #WebKitWebContext
- * @languages: (element-type utf8): a #GList of language identifiers
+ * @languages: (allow-none) (array zero-terminated=1) (element-type utf8) (transfer none): a %NULL-terminated list of language identifiers
*
* Set the list of preferred languages, sorted from most desirable
* to least desirable. The list will be used to build the "Accept-Language"
* header that will be included in the network requests started by
* the #WebKitWebContext.
*/
-void webkit_web_context_set_preferred_languages(WebKitWebContext* context, GList* languageList)
+void webkit_web_context_set_preferred_languages(WebKitWebContext* context, const gchar* const* languageList)
{
g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
- if (!languageList)
+ if (!languageList || !g_strv_length(const_cast<char**>(languageList)))
return;
Vector<String> languages;
- for (GList* iter = languageList; iter; iter = g_list_next(iter))
- languages.append(String::fromUTF8(static_cast<char*>(iter->data)).lower().replace("_", "-"));
+ for (size_t i = 0; languageList[i]; ++i)
+ languages.append(String::fromUTF8(languageList[i]).lower().replace("_", "-"));
WebCore::overrideUserPreferredLanguages(languages);
WebCore::languageDidChange();
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h (126297 => 126298)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h 2012-08-22 13:22:51 UTC (rev 126297)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h 2012-08-22 13:34:13 UTC (rev 126298)
@@ -140,16 +140,16 @@
WEBKIT_API void
webkit_web_context_set_spell_checking_enabled (WebKitWebContext *context,
gboolean enabled);
-WEBKIT_API const gchar *
+WEBKIT_API const gchar * const *
webkit_web_context_get_spell_checking_languages (WebKitWebContext *context);
WEBKIT_API void
webkit_web_context_set_spell_checking_languages (WebKitWebContext *context,
- const gchar *languages);
+ const gchar * const *languages);
WEBKIT_API void
webkit_web_context_set_preferred_languages (WebKitWebContext *context,
- GList *languages);
+ const gchar * const *languages);
G_END_DECLS
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp (126297 => 126298)
--- trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp 2012-08-22 13:22:51 UTC (rev 126297)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp 2012-08-22 13:34:13 UTC (rev 126298)
@@ -210,26 +210,44 @@
WebKitWebContext* webContext = webkit_web_context_get_default();
// Check what happens if no spell checking language has been set.
- const gchar* currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
+ const gchar* const* currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
g_assert(!currentLanguage);
// Set the language to a specific one.
- webkit_web_context_set_spell_checking_languages(webContext, "en_US");
+ GRefPtr<GPtrArray> languages = adoptGRef(g_ptr_array_new());
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("en_US")));
+ g_ptr_array_add(languages.get(), 0);
+ webkit_web_context_set_spell_checking_languages(webContext, reinterpret_cast<const char* const*>(languages->pdata));
currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
- g_assert_cmpstr(currentLanguage, ==, "en_US");
+ g_assert_cmpuint(g_strv_length(const_cast<char**>(currentLanguage)), ==, 1);
+ g_assert_cmpstr(currentLanguage[0], ==, "en_US");
// Set the language string to list of valid languages.
- webkit_web_context_set_spell_checking_languages(webContext, "en_GB,en_US");
+ g_ptr_array_remove_index_fast(languages.get(), languages->len - 1);
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("en_GB")));
+ g_ptr_array_add(languages.get(), 0);
+ webkit_web_context_set_spell_checking_languages(webContext, reinterpret_cast<const char* const*>(languages->pdata));
currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
- g_assert_cmpstr(currentLanguage, ==, "en_GB,en_US");
+ g_assert_cmpuint(g_strv_length(const_cast<char**>(currentLanguage)), ==, 2);
+ g_assert_cmpstr(currentLanguage[0], ==, "en_US");
+ g_assert_cmpstr(currentLanguage[1], ==, "en_GB");
// Try passing a wrong language along with good ones.
- webkit_web_context_set_spell_checking_languages(webContext, "bd_WR,en_US,en_GB");
+ g_ptr_array_remove_index_fast(languages.get(), languages->len - 1);
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("bd_WR")));
+ g_ptr_array_add(languages.get(), 0);
+ webkit_web_context_set_spell_checking_languages(webContext, reinterpret_cast<const char* const*>(languages->pdata));
currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
- g_assert_cmpstr(currentLanguage, ==, "en_US,en_GB");
+ g_assert_cmpuint(g_strv_length(const_cast<char**>(currentLanguage)), ==, 2);
+ g_assert_cmpstr(currentLanguage[0], ==, "en_US");
+ g_assert_cmpstr(currentLanguage[1], ==, "en_GB");
// Try passing a list with only wrong languages.
- webkit_web_context_set_spell_checking_languages(webContext, "bd_WR,wr_BD");
+ languages = adoptGRef(g_ptr_array_new());
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("bd_WR")));
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("wr_BD")));
+ g_ptr_array_add(languages.get(), 0);
+ webkit_web_context_set_spell_checking_languages(webContext, reinterpret_cast<const char* const*>(languages->pdata));
currentLanguage = webkit_web_context_get_spell_checking_languages(webContext);
g_assert(!currentLanguage);
@@ -250,11 +268,12 @@
g_assert_cmpuint(mainResourceDataSize, ==, strlen(expectedDefaultLanguage));
g_assert(!strncmp(mainResourceData, expectedDefaultLanguage, mainResourceDataSize));
- GList* languages = g_list_prepend(0, const_cast<gpointer>(static_cast<const void*>("dE")));
- languages = g_list_prepend(languages, const_cast<gpointer>(static_cast<const void*>("ES_es")));
- languages = g_list_prepend(languages, const_cast<gpointer>(static_cast<const void*>("en")));
- webkit_web_context_set_preferred_languages(webkit_web_context_get_default(), languages);
- g_list_free(languages);
+ GRefPtr<GPtrArray> languages = adoptGRef(g_ptr_array_new());
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("en")));
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("ES_es")));
+ g_ptr_array_add(languages.get(), const_cast<gpointer>(static_cast<const void*>("dE")));
+ g_ptr_array_add(languages.get(), 0);
+ webkit_web_context_set_preferred_languages(webkit_web_context_get_default(), reinterpret_cast<const char* const*>(languages->pdata));
static const char* expectedLanguages = "en, es-es;q=0.90, de;q=0.80";
test->loadURI(kServer->getURIForPath("/").data());