summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-08-23 17:03:15 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-08-23 17:03:15 +0200
commita73d1c176f2f3e0458861de8590dc20321a501ae (patch)
treed897fc5974797c3cb300d7f5916f258df765401f /Source/WebKit2/UIProcess/API
parentc311cf639cc1d6570d67b0a80a8ba04dc992a658 (diff)
downloadqtwebkit-a73d1c176f2f3e0458861de8590dc20321a501ae.tar.gz
Imported WebKit commit a5ae8a56a48e44ebfb9b81aaa5488affaffdb175 (http://svn.webkit.org/repository/webkit/trunk@126420)
New snapshot with OS X 10.6 build fix
Diffstat (limited to 'Source/WebKit2/UIProcess/API')
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPage.cpp28
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPage.h2
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp24
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h7
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp33
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h6
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp45
7 files changed, 88 insertions, 57 deletions
diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.cpp b/Source/WebKit2/UIProcess/API/C/WKPage.cpp
index a53a83161..437179bfb 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPage.cpp
+++ b/Source/WebKit2/UIProcess/API/C/WKPage.cpp
@@ -352,22 +352,22 @@ bool WKPageIsPinnedToRightSide(WKPageRef pageRef)
void WKPageSetPaginationMode(WKPageRef pageRef, WKPaginationMode paginationMode)
{
- Page::Pagination::Mode mode;
+ Pagination::Mode mode;
switch (paginationMode) {
case kWKPaginationModeUnpaginated:
- mode = Page::Pagination::Unpaginated;
+ mode = Pagination::Unpaginated;
break;
case kWKPaginationModeLeftToRight:
- mode = Page::Pagination::LeftToRightPaginated;
+ mode = Pagination::LeftToRightPaginated;
break;
case kWKPaginationModeRightToLeft:
- mode = Page::Pagination::RightToLeftPaginated;
+ mode = Pagination::RightToLeftPaginated;
break;
case kWKPaginationModeTopToBottom:
- mode = Page::Pagination::TopToBottomPaginated;
+ mode = Pagination::TopToBottomPaginated;
break;
case kWKPaginationModeBottomToTop:
- mode = Page::Pagination::BottomToTopPaginated;
+ mode = Pagination::BottomToTopPaginated;
break;
default:
return;
@@ -378,15 +378,15 @@ void WKPageSetPaginationMode(WKPageRef pageRef, WKPaginationMode paginationMode)
WKPaginationMode WKPageGetPaginationMode(WKPageRef pageRef)
{
switch (toImpl(pageRef)->paginationMode()) {
- case Page::Pagination::Unpaginated:
+ case Pagination::Unpaginated:
return kWKPaginationModeUnpaginated;
- case Page::Pagination::LeftToRightPaginated:
+ case Pagination::LeftToRightPaginated:
return kWKPaginationModeLeftToRight;
- case Page::Pagination::RightToLeftPaginated:
+ case Pagination::RightToLeftPaginated:
return kWKPaginationModeRightToLeft;
- case Page::Pagination::TopToBottomPaginated:
+ case Pagination::TopToBottomPaginated:
return kWKPaginationModeTopToBottom;
- case Page::Pagination::BottomToTopPaginated:
+ case Pagination::BottomToTopPaginated:
return kWKPaginationModeBottomToTop;
}
@@ -712,3 +712,9 @@ void WKPageSetMediaVolume(WKPageRef page, float volume)
{
toImpl(page)->setMediaVolume(volume);
}
+
+void WKPagePostMessageToInjectedBundle(WKPageRef pageRef, WKStringRef messageNameRef, WKTypeRef messageBodyRef)
+{
+ toImpl(pageRef)->postMessageToInjectedBundle(toImpl(messageNameRef)->string(), toImpl(messageBodyRef));
+}
+
diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.h b/Source/WebKit2/UIProcess/API/C/WKPage.h
index ab3b8eede..f7946080b 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPage.h
+++ b/Source/WebKit2/UIProcess/API/C/WKPage.h
@@ -489,6 +489,8 @@ typedef void (*WKPageValidateCommandCallback)(WKStringRef command, bool isEnable
WK_EXPORT void WKPageValidateCommand(WKPageRef page, WKStringRef command, void* context, WKPageValidateCommandCallback callback);
WK_EXPORT void WKPageExecuteCommand(WKPageRef page, WKStringRef command);
+WK_EXPORT void WKPagePostMessageToInjectedBundle(WKPageRef page, WKStringRef messageName, WKTypeRef messageBody);
+
#ifdef __cplusplus
}
#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp
index 5ae62c6fd..39f402227 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.cpp
@@ -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 @@ void WebKitTextChecker::setSpellCheckingEnabled(bool enabled)
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)
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h b/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h
index 3cca5622a..15f764f61 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitTextChecker.h
@@ -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 @@ public:
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;
};
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
index 211133f0a..e9231e47b 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp
@@ -495,24 +495,20 @@ void webkit_web_context_set_spell_checking_enabled(WebKitWebContext* context, gb
* @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 @@ const gchar* webkit_web_context_get_spell_checking_languages(WebKitWebContext* c
/**
* 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 @@ const gchar* webkit_web_context_get_spell_checking_languages(WebKitWebContext* c
* 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 @@ void webkit_web_context_set_spell_checking_languages(WebKitWebContext* context,
/**
* 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();
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
index 3c97c71cb..a2bf573f5 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h
@@ -140,16 +140,16 @@ webkit_web_context_get_spell_checking_enabled (WebKitWebContext
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
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
index 27f6a5447..7c712244e 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebContext.cpp
@@ -210,26 +210,44 @@ static void testWebContextSpellChecker(Test* test, gconstpointer)
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 @@ static void testWebContextLanguages(WebViewTest* test, gconstpointer)
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());