diff options
author | Steve Block <steveblock@google.com> | 2010-04-27 16:31:00 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-05-11 14:42:12 +0100 |
commit | dcc8cf2e65d1aa555cce12431a16547e66b469ee (patch) | |
tree | 92a8d65cd5383bca9749f5327fb5e440563926e6 /WebKit/gtk/webkit | |
parent | ccac38a6b48843126402088a309597e682f40fe6 (diff) | |
download | external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.zip external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.gz external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.bz2 |
Merge webkit.org at r58033 : Initial merge by git
Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1
Diffstat (limited to 'WebKit/gtk/webkit')
22 files changed, 610 insertions, 179 deletions
diff --git a/WebKit/gtk/webkit/webkit.h b/WebKit/gtk/webkit/webkit.h index 4cd0709..17b197b 100644 --- a/WebKit/gtk/webkit/webkit.h +++ b/WebKit/gtk/webkit/webkit.h @@ -24,6 +24,7 @@ #include <webkit/webkitversion.h> #include <webkit/webkitdefines.h> #include <webkit/webkitdownload.h> +#include <webkit/webkitgeolocationpolicydecision.h> #include <webkit/webkithittestresult.h> #include <webkit/webkitnetworkrequest.h> #include <webkit/webkitnetworkresponse.h> diff --git a/WebKit/gtk/webkit/webkitdefines.h b/WebKit/gtk/webkit/webkitdefines.h index a5884f3..b06a3bf 100644 --- a/WebKit/gtk/webkit/webkitdefines.h +++ b/WebKit/gtk/webkit/webkitdefines.h @@ -89,6 +89,9 @@ typedef struct _WebKitSecurityOriginClass WebKitSecurityOriginClass; typedef struct _WebKitHitTestResult WebKitHitTestResult; typedef struct _WebKitHitTestResultClass WebKitHitTestResultClass; +typedef struct _WebKitGeolocationPolicyDecision WebKitGeolocationPolicyDecision; +typedef struct _WebKitGeolocationPolicyDecisionClass WebKitGeolocationPolicyDecisionClass; + G_END_DECLS #endif diff --git a/WebKit/gtk/webkit/webkitdownload.cpp b/WebKit/gtk/webkit/webkitdownload.cpp index 8f3214e..0717e7c 100644 --- a/WebKit/gtk/webkit/webkitdownload.cpp +++ b/WebKit/gtk/webkit/webkitdownload.cpp @@ -20,7 +20,6 @@ #include "config.h" -#include "CString.h" #include <glib/gi18n-lib.h> #include "GRefPtr.h" #include "Noncopyable.h" @@ -34,9 +33,14 @@ #include "webkitmarshal.h" #include "webkitnetworkresponse.h" #include "webkitprivate.h" +#include <wtf/text/CString.h> #include <glib/gstdio.h> +#ifdef ERROR +#undef ERROR +#endif + using namespace WebKit; using namespace WebCore; @@ -149,8 +153,10 @@ static void webkit_download_finalize(GObject* object) // The download object may never have _start called on it, so we // need to make sure timer is non-NULL. - if (priv->timer) + if (priv->timer) { g_timer_destroy(priv->timer); + priv->timer = NULL; + } g_free(priv->destinationURI); g_free(priv->suggestedFilename); @@ -480,7 +486,7 @@ void webkit_download_start(WebKitDownload* download) g_return_if_fail(priv->timer == NULL); if (!priv->resourceHandle) - priv->resourceHandle = ResourceHandle::create(core(priv->networkRequest), priv->downloadClient, 0, false, false, false); + priv->resourceHandle = ResourceHandle::create(core(priv->networkRequest), priv->downloadClient, 0, false, false); else { priv->resourceHandle->setClient(priv->downloadClient); diff --git a/WebKit/gtk/webkit/webkitgeolocationpolicydecision.cpp b/WebKit/gtk/webkit/webkitgeolocationpolicydecision.cpp new file mode 100644 index 0000000..7afd8fa --- /dev/null +++ b/WebKit/gtk/webkit/webkitgeolocationpolicydecision.cpp @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2010 Arno Renevier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "webkitgeolocationpolicydecision.h" + +#include "webkitprivate.h" +#include "Geolocation.h" + +using namespace WebKit; +using namespace WebCore; + +/** + * SECTION:webkitgeolocationpolicydecision + * @short_description: Liaison between WebKit and the application regarding asynchronous geolocation policy decisions + * + * #WebKitGeolocationPolicyDecision objects are given to the application when + * geolocation-policy-decision-requested signal is emitted. The application + * uses it to tell the engine whether it wants to allow or deny geolocation for + * a given frame. + */ + +G_DEFINE_TYPE(WebKitGeolocationPolicyDecision, webkit_geolocation_policy_decision, G_TYPE_OBJECT); + +struct _WebKitGeolocationPolicyDecisionPrivate { + WebKitWebFrame* frame; + Geolocation* geolocation; +}; + +#define WEBKIT_GEOLOCATION_POLICY_DECISION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION, WebKitGeolocationPolicyDecisionPrivate)) + +static void webkit_geolocation_policy_decision_class_init(WebKitGeolocationPolicyDecisionClass* decisionClass) +{ + g_type_class_add_private(decisionClass, sizeof(WebKitGeolocationPolicyDecisionPrivate)); +} + +static void webkit_geolocation_policy_decision_init(WebKitGeolocationPolicyDecision* decision) +{ + decision->priv = WEBKIT_GEOLOCATION_POLICY_DECISION_GET_PRIVATE(decision); +} + +WebKitGeolocationPolicyDecision* webkit_geolocation_policy_decision_new(WebKitWebFrame* frame, Geolocation* geolocation) +{ + g_return_val_if_fail(frame, NULL); + WebKitGeolocationPolicyDecision* decision = WEBKIT_GEOLOCATION_POLICY_DECISION(g_object_new(WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION, NULL)); + WebKitGeolocationPolicyDecisionPrivate* priv = decision->priv; + + priv->frame = frame; + priv->geolocation = geolocation; + return decision; +} + +/** + * webkit_geolocation_policy_allow + * @decision: a #WebKitGeolocationPolicyDecision + * + * Will send the allow decision to the policy implementer. + * + * Since: 1.1.23 + */ +void webkit_geolocation_policy_allow(WebKitGeolocationPolicyDecision* decision) +{ + g_return_if_fail(WEBKIT_IS_GEOLOCATION_POLICY_DECISION(decision)); + + WebKitGeolocationPolicyDecisionPrivate* priv = decision->priv; + priv->geolocation->setIsAllowed(TRUE); +} + +/** + * webkit_geolocation_policy_deny + * @decision: a #WebKitGeolocationPolicyDecision + * + * Will send the deny decision to the policy implementer. + * + * Since: 1.1.23 + */ +void webkit_geolocation_policy_deny(WebKitGeolocationPolicyDecision* decision) +{ + g_return_if_fail(WEBKIT_IS_GEOLOCATION_POLICY_DECISION(decision)); + + WebKitGeolocationPolicyDecisionPrivate* priv = decision->priv; + priv->geolocation->setIsAllowed(FALSE); +} + diff --git a/WebKit/gtk/webkit/webkitgeolocationpolicydecision.h b/WebKit/gtk/webkit/webkitgeolocationpolicydecision.h new file mode 100644 index 0000000..27e0ef2 --- /dev/null +++ b/WebKit/gtk/webkit/webkitgeolocationpolicydecision.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2010 Arno Renevier + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef webkitgeolocationpolicydecision_h +#define webkitgeolocationpolicydecision_h + +#include <glib-object.h> +#include <webkit/webkitdefines.h> + +G_BEGIN_DECLS + +#define WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION (webkit_geolocation_policy_decision_get_type()) +#define WEBKIT_GEOLOCATION_POLICY_DECISION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION, WebKitGeolocationPolicyDecision)) +#define WEBKIT_GEOLOCATION_POLICY_DECISION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION, WebKitGeolocationPolicyDecisionClass)) +#define WEBKIT_IS_GEOLOCATION_POLICY_DECISION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION)) +#define WEBKIT_IS_GEOLOCATION_POLICY_DECISION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION)) +#define WEBKIT_GEOLOCATION_POLICY_DECISION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION, WebKitGeolocationPolicyDecisionClass)) + +typedef struct _WebKitGeolocationPolicyDecisionPrivate WebKitGeolocationPolicyDecisionPrivate; +struct _WebKitGeolocationPolicyDecision { + GObject parent_instance; + + /*< private >*/ + WebKitGeolocationPolicyDecisionPrivate* priv; +}; + +struct _WebKitGeolocationPolicyDecisionClass { + GObjectClass parent_class; + + /* Padding for future expansion */ + void (*_webkit_reserved0) (void); + void (*_webkit_reserved1) (void); + void (*_webkit_reserved2) (void); + void (*_webkit_reserved3) (void); +}; + +WEBKIT_API GType +webkit_geolocation_policy_decision_get_type (void); + +WEBKIT_API void +webkit_geolocation_policy_allow (WebKitGeolocationPolicyDecision* decision); + +WEBKIT_API void +webkit_geolocation_policy_deny (WebKitGeolocationPolicyDecision* decision); + +G_END_DECLS + +#endif diff --git a/WebKit/gtk/webkit/webkithittestresult.cpp b/WebKit/gtk/webkit/webkithittestresult.cpp index be97933..1f8dce6 100644 --- a/WebKit/gtk/webkit/webkithittestresult.cpp +++ b/WebKit/gtk/webkit/webkithittestresult.cpp @@ -21,10 +21,10 @@ #include "config.h" #include "webkithittestresult.h" -#include "CString.h" #include "GOwnPtr.h" #include "webkitenumtypes.h" #include "webkitprivate.h" +#include <wtf/text/CString.h> #include <glib/gi18n-lib.h> diff --git a/WebKit/gtk/webkit/webkitnetworkrequest.cpp b/WebKit/gtk/webkit/webkitnetworkrequest.cpp index be6d5ff..78044aa 100644 --- a/WebKit/gtk/webkit/webkitnetworkrequest.cpp +++ b/WebKit/gtk/webkit/webkitnetworkrequest.cpp @@ -21,10 +21,10 @@ #include "config.h" #include "webkitnetworkrequest.h" -#include "CString.h" #include "GOwnPtr.h" #include "ResourceRequest.h" #include "webkitprivate.h" +#include <wtf/text/CString.h> #include <glib/gi18n-lib.h> diff --git a/WebKit/gtk/webkit/webkitprivate.cpp b/WebKit/gtk/webkit/webkitprivate.cpp index be88bb5..971922f 100644 --- a/WebKit/gtk/webkit/webkitprivate.cpp +++ b/WebKit/gtk/webkit/webkitprivate.cpp @@ -28,6 +28,7 @@ #include "Frame.h" #include "FrameLoader.h" #include "FrameLoaderClientGtk.h" +#include "GtkVersioning.h" #include "HitTestResult.h" #include "IconDatabase.h" #include <libintl.h> @@ -223,11 +224,7 @@ static GtkWidget* currentToplevelCallback(WebKitSoupAuthDialog* feature, SoupMes return NULL; GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(frame->page()->chrome()->platformPageClient())); -#if GTK_CHECK_VERSION(2, 18, 0) if (gtk_widget_is_toplevel(toplevel)) -#else - if (GTK_WIDGET_TOPLEVEL(toplevel)) -#endif return toplevel; else return NULL; @@ -296,10 +293,10 @@ void webkit_init() void webkit_white_list_access_from_origin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains) { - SecurityOrigin::whiteListAccessFromOrigin(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); + SecurityOrigin::addOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains); } void webkit_reset_origin_access_white_lists() { - SecurityOrigin::resetOriginAccessWhiteLists(); + SecurityOrigin::resetOriginAccessWhitelists(); } diff --git a/WebKit/gtk/webkit/webkitprivate.h b/WebKit/gtk/webkit/webkitprivate.h index 44b4d0c..2642d50 100644 --- a/WebKit/gtk/webkit/webkitprivate.h +++ b/WebKit/gtk/webkit/webkitprivate.h @@ -46,9 +46,9 @@ #include "ArchiveResource.h" #include "BackForwardList.h" -#include "CString.h" #include <enchant.h> #include "GOwnPtr.h" +#include "Geolocation.h" #include "HistoryItem.h" #include "Settings.h" #include "Page.h" @@ -60,6 +60,7 @@ #include "ResourceResponse.h" #include "WindowFeatures.h" #include "SecurityOrigin.h" +#include <wtf/text/CString.h> #include <atk/atk.h> #include <glib.h> @@ -102,11 +103,6 @@ namespace WebKit { WebKit::PasteboardHelperGtk* pasteboardHelperInstance(); } -typedef struct { - EnchantBroker* config; - EnchantDict* speller; -} SpellLanguage; - extern "C" { void webkit_init(); @@ -276,6 +272,9 @@ extern "C" { WebKitNetworkResponse* webkit_network_response_new_with_core_response(const WebCore::ResourceResponse& resourceResponse); + WebKitGeolocationPolicyDecision* + webkit_geolocation_policy_decision_new(WebKitWebFrame*, WebCore::Geolocation*); + // FIXME: move this to webkitnetworkrequest.h once the API is agreed upon. WEBKIT_API SoupMessage* webkit_network_request_get_message(WebKitNetworkRequest* request); @@ -301,6 +300,9 @@ extern "C" { WEBKIT_API int webkit_web_frame_page_number_for_element_by_id(WebKitWebFrame* frame, const gchar* id, float pageWidth, float pageHeight); + WEBKIT_API int + webkit_web_frame_number_of_pages(WebKitWebFrame* frame, float pageWidth, float pageHeight); + WEBKIT_API guint webkit_web_frame_get_pending_unload_event_count(WebKitWebFrame* frame); @@ -313,6 +315,9 @@ extern "C" { WEBKIT_API bool webkit_web_frame_pause_svg_animation(WebKitWebFrame* frame, const gchar* animationId, double time, const gchar* elementId); + WEBKIT_API gchar* + webkit_web_frame_marker_text_for_list_item(WebKitWebFrame* frame, JSContextRef context, JSValueRef nodeObject); + WEBKIT_API unsigned int webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame); @@ -332,7 +337,7 @@ extern "C" { webkit_web_settings_add_extra_plugin_directory (WebKitWebView *web_view, const gchar* directory); GSList* - webkit_web_settings_get_spell_languages(WebKitWebView* web_view); + webkit_web_settings_get_enchant_dicts(WebKitWebView* web_view); bool webkit_web_view_use_primary_for_paste(WebKitWebView* web_view); diff --git a/WebKit/gtk/webkit/webkitsecurityorigin.cpp b/WebKit/gtk/webkit/webkitsecurityorigin.cpp index cd80236..0ab0a9c 100644 --- a/WebKit/gtk/webkit/webkitsecurityorigin.cpp +++ b/WebKit/gtk/webkit/webkitsecurityorigin.cpp @@ -22,9 +22,9 @@ #include "webkitprivate.h" -#include "CString.h" #include "PlatformString.h" #include "DatabaseTracker.h" +#include <wtf/text/CString.h> #include <glib/gi18n-lib.h> @@ -353,7 +353,7 @@ void webkit_security_origin_set_web_database_quota(WebKitSecurityOrigin* securit * * Returns a list of all Web Databases in the security origin. * - * Returns: a #Glist of databases in the security origin. + * Returns: a #GList of databases in the security origin. * * Since: 1.1.14 **/ diff --git a/WebKit/gtk/webkit/webkitsoupauthdialog.c b/WebKit/gtk/webkit/webkitsoupauthdialog.c index 538dbfa..15863b3 100644 --- a/WebKit/gtk/webkit/webkitsoupauthdialog.c +++ b/WebKit/gtk/webkit/webkitsoupauthdialog.c @@ -190,8 +190,12 @@ static void show_auth_dialog(WebKitAuthData* authData, const char* login, const GtkWidget* vbox; GtkWidget* icon; GtkWidget* table; - GtkWidget* messageLabel; - char* message; + GtkWidget* serverMessageDescriptionLabel; + GtkWidget* serverMessageLabel; + GtkWidget* descriptionLabel; + char* description; + const char* realm; + gboolean hasRealm; SoupURI* uri; GtkWidget* rememberBox; GtkWidget* checkButton; @@ -241,12 +245,12 @@ static void show_auth_dialog(WebKitAuthData* authData, const char* login, const gtk_box_pack_start(GTK_BOX(hbox), mainVBox, TRUE, TRUE, 0); uri = soup_message_get_uri(authData->msg); - message = g_strdup_printf(_("A username and password are being requested by the site %s"), uri->host); - messageLabel = gtk_label_new(message); - g_free(message); - gtk_misc_set_alignment(GTK_MISC(messageLabel), 0.0, 0.5); - gtk_label_set_line_wrap(GTK_LABEL(messageLabel), TRUE); - gtk_box_pack_start(GTK_BOX(mainVBox), GTK_WIDGET(messageLabel), + description = g_strdup_printf(_("A username and password are being requested by the site %s"), uri->host); + descriptionLabel = gtk_label_new(description); + g_free(description); + gtk_misc_set_alignment(GTK_MISC(descriptionLabel), 0.0, 0.5); + gtk_label_set_line_wrap(GTK_LABEL(descriptionLabel), TRUE); + gtk_box_pack_start(GTK_BOX(mainVBox), GTK_WIDGET(descriptionLabel), FALSE, FALSE, 0); vbox = gtk_vbox_new(FALSE, 6); @@ -261,14 +265,32 @@ static void show_auth_dialog(WebKitAuthData* authData, const char* login, const gtk_box_pack_start(GTK_BOX(vbox), entryContainer, FALSE, FALSE, 0); - table = gtk_table_new(2, 2, FALSE); + realm = soup_auth_get_realm(authData->auth); + // Checking that realm is not an empty string + hasRealm = (realm && (strlen(realm) > 0)); + + table = gtk_table_new(hasRealm ? 3 : 2, 2, FALSE); gtk_table_set_col_spacings(GTK_TABLE(table), 12); gtk_table_set_row_spacings(GTK_TABLE(table), 6); gtk_container_add(GTK_CONTAINER(entryContainer), table); - authData->loginEntry = table_add_entry(table, 0, _("Username:"), + if (hasRealm) { + serverMessageDescriptionLabel = gtk_label_new(_("Server message:")); + serverMessageLabel = gtk_label_new(realm); + gtk_misc_set_alignment(GTK_MISC(serverMessageDescriptionLabel), 0.0, 0.5); + gtk_label_set_line_wrap(GTK_LABEL(serverMessageDescriptionLabel), TRUE); + gtk_misc_set_alignment(GTK_MISC(serverMessageLabel), 0.0, 0.5); + gtk_label_set_line_wrap(GTK_LABEL(serverMessageLabel), TRUE); + + gtk_table_attach_defaults(GTK_TABLE(table), serverMessageDescriptionLabel, + 0, 1, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(table), serverMessageLabel, + 1, 2, 0, 1); + } + + authData->loginEntry = table_add_entry(table, hasRealm ? 1 : 0, _("Username:"), login, NULL); - authData->passwordEntry = table_add_entry(table, 1, _("Password:"), + authData->passwordEntry = table_add_entry(table, hasRealm ? 2 : 1, _("Password:"), password, NULL); gtk_entry_set_visibility(GTK_ENTRY(authData->passwordEntry), FALSE); diff --git a/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp b/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp index 31631a5..b23aeb9 100644 --- a/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp +++ b/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp @@ -252,7 +252,7 @@ GList* webkit_web_back_forward_list_get_back_list_with_limit(WebKitWebBackForwar /** * webkit_web_back_forward_list_get_back_item: - * @web_back_forward_list: a #WebBackForwardList + * @web_back_forward_list: a #WebKitWebBackForwardList * * Returns the item that precedes the current item * @@ -383,7 +383,7 @@ gint webkit_web_back_forward_list_get_forward_length(WebKitWebBackForwardList* w * * Returns the maximum limit of the back forward list. * - * Return value: a #gint indicating the number of #WebHistoryItem the back forward list can hold + * Return value: a #gint indicating the number of #WebKitWebHistoryItem the back forward list can hold */ gint webkit_web_back_forward_list_get_limit(WebKitWebBackForwardList* webBackForwardList) { @@ -438,6 +438,29 @@ void webkit_web_back_forward_list_add_item(WebKitWebBackForwardList *webBackForw backForwardList->addItem(historyItem); } +/** + * webkit_web_back_forward_list_clear: + * @webBackForwardList: a #WebKitWebBackForwardList + * + * Clears the @webBackForwardList by removing all its elements. Note that not even + * the current page is kept in list when cleared so you would have to add it later. + * + * Since: 1.1.30 + **/ +void webkit_web_back_forward_list_clear(WebKitWebBackForwardList* webBackForwardList) +{ + g_return_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList)); + + WebCore::BackForwardList* backForwardList = core(webBackForwardList); + if (!backForwardList || !backForwardList->enabled() || !backForwardList->entries().size()) + return; + + // Clear the current list by setting capacity to 0 + int capacity = backForwardList->capacity(); + backForwardList->setCapacity(0); + backForwardList->setCapacity(capacity); +} + WebCore::BackForwardList* WebKit::core(WebKitWebBackForwardList* webBackForwardList) { g_return_val_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList), NULL); diff --git a/WebKit/gtk/webkit/webkitwebbackforwardlist.h b/WebKit/gtk/webkit/webkitwebbackforwardlist.h index d08566e..2cffc68 100644 --- a/WebKit/gtk/webkit/webkitwebbackforwardlist.h +++ b/WebKit/gtk/webkit/webkitwebbackforwardlist.h @@ -110,6 +110,8 @@ webkit_web_back_forward_list_set_limit (WebKitWebBackForwardLi WEBKIT_API void webkit_web_back_forward_list_add_item (WebKitWebBackForwardList *web_back_forward_list, WebKitWebHistoryItem *history_item); +WEBKIT_API void +webkit_web_back_forward_list_clear (WebKitWebBackForwardList *web_back_forward_list); G_END_DECLS diff --git a/WebKit/gtk/webkit/webkitwebdatabase.cpp b/WebKit/gtk/webkit/webkitwebdatabase.cpp index 100176e..e92c400 100644 --- a/WebKit/gtk/webkit/webkitwebdatabase.cpp +++ b/WebKit/gtk/webkit/webkitwebdatabase.cpp @@ -22,9 +22,9 @@ #include "webkitprivate.h" -#include "CString.h" #include "DatabaseDetails.h" #include "DatabaseTracker.h" +#include <wtf/text/CString.h> #include <glib/gi18n-lib.h> diff --git a/WebKit/gtk/webkit/webkitwebdatasource.cpp b/WebKit/gtk/webkit/webkitwebdatasource.cpp index 059688e..9b755ad 100644 --- a/WebKit/gtk/webkit/webkitwebdatasource.cpp +++ b/WebKit/gtk/webkit/webkitwebdatasource.cpp @@ -418,9 +418,9 @@ G_CONST_RETURN gchar* webkit_web_data_source_get_unreachable_uri(WebKitWebDataSo * @data_source: a #WebKitWebDataSource * * Gives you a #GList of #WebKitWebResource objects that compose the - * #WebView to which this #WebKitWebDataSource is attached. + * #WebKitWebView to which this #WebKitWebDataSource is attached. * - * Return value: a #GList of #WebKitResource objects; the objects are + * Return value: a #GList of #WebKitWebResource objects; the objects are * owned by WebKit, but the GList must be freed. * * Since: 1.1.15 diff --git a/WebKit/gtk/webkit/webkitwebframe.cpp b/WebKit/gtk/webkit/webkitwebframe.cpp index fbd246d..344f94e 100644 --- a/WebKit/gtk/webkit/webkitwebframe.cpp +++ b/WebKit/gtk/webkit/webkitwebframe.cpp @@ -35,7 +35,6 @@ #include "AccessibilityObjectWrapperAtk.h" #include "AnimationController.h" #include "AXObjectCache.h" -#include "CString.h" #include "DocumentLoader.h" #include "DocumentLoaderGtk.h" #include "FrameLoader.h" @@ -45,10 +44,13 @@ #include <glib/gi18n-lib.h> #include "GCController.h" #include "GraphicsContext.h" +#include "GtkVersioning.h" #include "HTMLFrameOwnerElement.h" #include "JSDOMWindow.h" +#include "JSElement.h" #include "JSLock.h" #include "PrintContext.h" +#include "RenderListItem.h" #include "RenderView.h" #include "RenderTreeAsText.h" #include "JSDOMBinding.h" @@ -60,6 +62,7 @@ #include <atk/atk.h> #include <JavaScriptCore/APICast.h> +#include <wtf/text/CString.h> /** * SECTION:webkitwebframe @@ -867,6 +870,25 @@ int webkit_web_frame_page_number_for_element_by_id(WebKitWebFrame* frame, const } /** + * webkit_web_frame_number_of_pages + * @frame: a #WebKitWebFrame + * @pageWidth: width of a page + * @pageHeight: height of a page + * + * Return value: The number of pages to be printed. + */ +int webkit_web_frame_number_of_pages(WebKitWebFrame* frame, float pageWidth, float pageHeight) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL); + + Frame* coreFrame = core(frame); + if (!coreFrame) + return -1; + + return PrintContext::numberOfPages(coreFrame, FloatSize(pageWidth, pageHeight)); +} + +/** * webkit_web_frame_get_pending_unload_event_count: * @frame: a #WebKitWebFrame * @@ -923,7 +945,7 @@ static void end_print_callback(GtkPrintOperation* op, GtkPrintContext* context, * @action: the #GtkPrintOperationAction to be performed * @error: #GError for error return * - * Prints the given #WebKitFrame, using the given #GtkPrintOperation + * Prints the given #WebKitWebFrame, using the given #GtkPrintOperation * and #GtkPrintOperationAction. This function wraps a call to * gtk_print_operation_run() for printing the contents of the * #WebKitWebFrame. @@ -937,11 +959,7 @@ GtkPrintOperationResult webkit_web_frame_print_full(WebKitWebFrame* frame, GtkPr GtkWidget* topLevel = gtk_widget_get_toplevel(GTK_WIDGET(webkit_web_frame_get_web_view(frame))); -#if GTK_CHECK_VERSION(2, 18, 0) if (!gtk_widget_is_toplevel(topLevel)) -#else - if (!GTK_WIDGET_TOPLEVEL(topLevel)) -#endif topLevel = NULL; Frame* coreFrame = core(frame); @@ -961,7 +979,7 @@ GtkPrintOperationResult webkit_web_frame_print_full(WebKitWebFrame* frame, GtkPr * webkit_web_frame_print: * @frame: a #WebKitWebFrame * - * Prints the given #WebKitFrame, by presenting a print dialog to the + * Prints the given #WebKitWebFrame, by presenting a print dialog to the * user. If you need more control over the printing process, see * webkit_web_frame_print_full(). * @@ -980,19 +998,11 @@ void webkit_web_frame_print(WebKitWebFrame* frame) if (error) { GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(priv->webView)); -#if GTK_CHECK_VERSION(2, 18, 0) GtkWidget* dialog = gtk_message_dialog_new(gtk_widget_is_toplevel(window) ? GTK_WINDOW(window) : 0, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "%s", error->message); -#else - GtkWidget* dialog = gtk_message_dialog_new(GTK_WIDGET_TOPLEVEL(window) ? GTK_WINDOW(window) : 0, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - GTK_BUTTONS_CLOSE, - "%s", error->message); -#endif g_error_free(error); @@ -1035,6 +1045,16 @@ bool webkit_web_frame_pause_svg_animation(WebKitWebFrame* frame, const gchar* an #endif } +gchar* webkit_web_frame_marker_text_for_list_item(WebKitWebFrame* frame, JSContextRef context, JSValueRef nodeObject) +{ + JSC::ExecState* exec = toJS(context); + Element* element = toElement(toJS(exec, nodeObject)); + if (!element) + return 0; + + return g_strdup(markerTextForListItem(element).utf8().data()); +} + unsigned int webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame) { Frame* coreFrame = core(frame); diff --git a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp index f2811ea..5177c4c 100644 --- a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp +++ b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp @@ -26,9 +26,9 @@ #include <glib.h> #include <glib/gi18n-lib.h> -#include "CString.h" #include "HistoryItem.h" #include "PlatformString.h" +#include <wtf/text/CString.h> /** * SECTION:webkitwebhistoryitem @@ -37,7 +37,7 @@ * * A history item consists out of a title and a uri. It can be part of the * #WebKitWebBackForwardList and the global history. The global history is used - * for coloring the links of visited sites. #WebKitHistoryItem's constructed with + * for coloring the links of visited sites. #WebKitWebHistoryItem's constructed with * #webkit_web_history_item_new and #webkit_web_history_item_new_with_data are * automatically added to the global history. * @@ -54,10 +54,10 @@ using namespace WebKit; struct _WebKitWebHistoryItemPrivate { WebCore::HistoryItem* historyItem; - WebCore::CString title; - WebCore::CString alternateTitle; - WebCore::CString uri; - WebCore::CString originalUri; + WTF::CString title; + WTF::CString alternateTitle; + WTF::CString uri; + WTF::CString originalUri; gboolean disposed; }; @@ -113,10 +113,10 @@ static void webkit_web_history_item_finalize(GObject* object) WebKitWebHistoryItem* webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(object); WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv; - priv->title = WebCore::CString(); - priv->alternateTitle = WebCore::CString(); - priv->uri = WebCore::CString(); - priv->originalUri = WebCore::CString(); + priv->title = WTF::CString(); + priv->alternateTitle = WTF::CString(); + priv->uri = WTF::CString(); + priv->originalUri = WTF::CString(); G_OBJECT_CLASS(webkit_web_history_item_parent_class)->finalize(object); } @@ -469,7 +469,7 @@ G_CONST_RETURN gchar* webkit_web_history_item_get_target(WebKitWebHistoryItem* w g_return_val_if_fail(item, NULL); - WebCore::CString t = item->target().utf8(); + WTF::CString t = item->target().utf8(); return g_strdup(t.data()); } diff --git a/WebKit/gtk/webkit/webkitwebinspector.cpp b/WebKit/gtk/webkit/webkitwebinspector.cpp index 2feb064..820b20f 100644 --- a/WebKit/gtk/webkit/webkitwebinspector.cpp +++ b/WebKit/gtk/webkit/webkitwebinspector.cpp @@ -125,7 +125,7 @@ static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass) /** * WebKitWebInspector::inspect-web-view: * @web_inspector: the object on which the signal is emitted - * @web_view: the #WebKitWeb which will be inspected + * @web_view: the #WebKitWebView which will be inspected * @return: a newly allocated #WebKitWebView or %NULL * * Emitted when the user activates the 'inspect' context menu item diff --git a/WebKit/gtk/webkit/webkitwebresource.cpp b/WebKit/gtk/webkit/webkitwebresource.cpp index bd3cd69..ba9c3af 100644 --- a/WebKit/gtk/webkit/webkitwebresource.cpp +++ b/WebKit/gtk/webkit/webkitwebresource.cpp @@ -23,13 +23,13 @@ #include "webkitprivate.h" #include "ArchiveResource.h" -#include "CString.h" #include "KURL.h" #include "PlatformString.h" #include "SharedBuffer.h" #include "webkitenumtypes.h" #include "webkitmarshal.h" #include "wtf/Assertions.h" +#include <wtf/text/CString.h> #include <glib.h> #include <glib/gi18n-lib.h> diff --git a/WebKit/gtk/webkit/webkitwebsettings.cpp b/WebKit/gtk/webkit/webkitwebsettings.cpp index 4ff4a8e..5d2d658 100644 --- a/WebKit/gtk/webkit/webkitwebsettings.cpp +++ b/WebKit/gtk/webkit/webkitwebsettings.cpp @@ -30,11 +30,11 @@ #include "webkitprivate.h" #include "webkitversion.h" -#include "CString.h" #include "FileSystem.h" #include "PluginDatabase.h" #include "Language.h" #include "PlatformString.h" +#include <wtf/text/CString.h> #include <glib/gi18n-lib.h> #if OS(UNIX) @@ -88,11 +88,12 @@ struct _WebKitWebSettingsPrivate { gboolean enable_private_browsing; gboolean enable_spell_checking; gchar* spell_checking_languages; - GSList* spell_checking_languages_list; + GSList* enchant_dicts; gboolean enable_caret_browsing; gboolean enable_html5_database; gboolean enable_html5_local_storage; gboolean enable_xss_auditor; + gboolean enable_spatial_navigation; gchar* user_agent; gboolean javascript_can_open_windows_automatically; gboolean enable_offline_web_application_cache; @@ -141,6 +142,7 @@ enum { PROP_ENABLE_HTML5_DATABASE, PROP_ENABLE_HTML5_LOCAL_STORAGE, PROP_ENABLE_XSS_AUDITOR, + PROP_ENABLE_SPATIAL_NAVIGATION, PROP_USER_AGENT, PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY, PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE, @@ -568,7 +570,25 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass) _("Whether to enable teh XSS auditor"), TRUE, flags)); - + /** + * WebKitWebSettings:enable-spatial-navigation + * + * Whether to enable the Spatial Navigation. This feature consists in the ability + * to navigate between focusable elements in a Web page, such as hyperlinks and + * form controls, by using Left, Right, Up and Down arrow keys. For example, if + * an user presses the Right key, heuristics determine whether there is an element + * he might be trying to reach towards the right, and if there are multiple elements, + * which element he probably wants. + * + * Since: 1.1.23 + */ + g_object_class_install_property(gobject_class, + PROP_ENABLE_SPATIAL_NAVIGATION, + g_param_spec_boolean("enable-spatial-navigation", + _("Enable Spatial Navigation"), + _("Whether to enable Spatial Navigation"), + FALSE, + flags)); /** * WebKitWebSettings:user-agent: * @@ -805,9 +825,9 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass) /** * WebKitWebSettings:enable-java-applet: * - * Enable or disable support for the Java <applet> tag. Keep in + * Enable or disable support for the Java <applet> tag. Keep in * mind that Java content can be still shown in the page through - * <object> or <embed>, which are the preferred tags for this task. + * <object> or <embed>, which are the preferred tags for this task. * * Since: 1.1.22 */ @@ -827,16 +847,21 @@ static void webkit_web_settings_init(WebKitWebSettings* web_settings) web_settings->priv = WEBKIT_WEB_SETTINGS_GET_PRIVATE(web_settings); } +static EnchantBroker* get_enchant_broker() +{ + static EnchantBroker* broker = 0; + if (!broker) + broker = enchant_broker_init(); + + return broker; +} + static void free_spell_checking_language(gpointer data, gpointer user_data) { - SpellLanguage* language = static_cast<SpellLanguage*>(data); - if (language->config) { - if (language->speller) - enchant_broker_free_dict(language->config, language->speller); + EnchantDict* dict = static_cast<EnchantDict*>(data); + EnchantBroker* broker = get_enchant_broker(); - enchant_broker_free(language->config); - } - g_slice_free(SpellLanguage, language); + enchant_broker_free_dict(broker, dict); } static void webkit_web_settings_finalize(GObject* object) @@ -854,8 +879,8 @@ static void webkit_web_settings_finalize(GObject* object) g_free(priv->user_stylesheet_uri); g_free(priv->spell_checking_languages); - g_slist_foreach(priv->spell_checking_languages_list, free_spell_checking_language, NULL); - g_slist_free(priv->spell_checking_languages_list); + g_slist_foreach(priv->enchant_dicts, free_spell_checking_language, 0); + g_slist_free(priv->enchant_dicts); g_free(priv->user_agent); @@ -867,8 +892,8 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con WebKitWebSettings* web_settings = WEBKIT_WEB_SETTINGS(object); WebKitWebSettingsPrivate* priv = web_settings->priv; EnchantBroker* broker; - SpellLanguage* lang; - GSList* spellLanguages = NULL; + EnchantDict* dict; + GSList* spellDictionaries = 0; switch(prop_id) { case PROP_DEFAULT_ENCODING: @@ -958,41 +983,36 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con priv->enable_spell_checking = g_value_get_boolean(value); break; case PROP_SPELL_CHECKING_LANGUAGES: + g_free(priv->spell_checking_languages); priv->spell_checking_languages = g_strdup(g_value_get_string(value)); - broker = enchant_broker_init(); + broker = get_enchant_broker(); if (priv->spell_checking_languages) { char** langs = g_strsplit(priv->spell_checking_languages, ",", -1); for (int i = 0; langs[i]; i++) { if (enchant_broker_dict_exists(broker, langs[i])) { - lang = g_slice_new0(SpellLanguage); - lang->config = enchant_broker_init(); - lang->speller = enchant_broker_request_dict(lang->config, langs[i]); - - spellLanguages = g_slist_append(spellLanguages, lang); + dict = enchant_broker_request_dict(broker, langs[i]); + spellDictionaries = g_slist_append(spellDictionaries, dict); } } - g_strfreev(langs); } else { const char* language = pango_language_to_string(gtk_get_default_language()); - if (enchant_broker_dict_exists(broker, language)) { - lang = g_slice_new0(SpellLanguage); - lang->config = enchant_broker_init(); - lang->speller = enchant_broker_request_dict(lang->config, language); - - spellLanguages = g_slist_append(spellLanguages, lang); + dict = enchant_broker_request_dict(broker, language); + spellDictionaries = g_slist_append(spellDictionaries, dict); } } - enchant_broker_free(broker); - g_slist_foreach(priv->spell_checking_languages_list, free_spell_checking_language, NULL); - g_slist_free(priv->spell_checking_languages_list); - priv->spell_checking_languages_list = spellLanguages; + g_slist_foreach(priv->enchant_dicts, free_spell_checking_language, 0); + g_slist_free(priv->enchant_dicts); + priv->enchant_dicts = spellDictionaries; break; case PROP_ENABLE_XSS_AUDITOR: priv->enable_xss_auditor = g_value_get_boolean(value); break; + case PROP_ENABLE_SPATIAL_NAVIGATION: + priv->enable_spatial_navigation = g_value_get_boolean(value); + break; case PROP_USER_AGENT: g_free(priv->user_agent); if (!g_value_get_string(value) || !strlen(g_value_get_string(value))) @@ -1132,6 +1152,9 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa case PROP_ENABLE_XSS_AUDITOR: g_value_set_boolean(value, priv->enable_xss_auditor); break; + case PROP_ENABLE_SPATIAL_NAVIGATION: + g_value_set_boolean(value, priv->enable_spatial_navigation); + break; case PROP_USER_AGENT: g_value_set_string(value, priv->user_agent); break; @@ -1225,11 +1248,11 @@ WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* web_settings) "enable-private-browsing", priv->enable_private_browsing, "enable-spell-checking", priv->enable_spell_checking, "spell-checking-languages", priv->spell_checking_languages, - "spell-checking-languages-list", priv->spell_checking_languages_list, "enable-caret-browsing", priv->enable_caret_browsing, "enable-html5-database", priv->enable_html5_database, "enable-html5-local-storage", priv->enable_html5_local_storage, "enable-xss-auditor", priv->enable_xss_auditor, + "enable-spatial-navigation", priv->enable_spatial_navigation, "user-agent", webkit_web_settings_get_user_agent(web_settings), "javascript-can-open-windows-automatically", priv->javascript_can_open_windows_automatically, "enable-offline-web-application-cache", priv->enable_offline_web_application_cache, @@ -1265,23 +1288,21 @@ void webkit_web_settings_add_extra_plugin_directory(WebKitWebView* webView, cons } /** - * webkit_web_settings_get_spell_languages: + * webkit_web_settings_get_enchant_dicts: * @web_view: a #WebKitWebView * - * Internal use only. Retrieves a GSList of SpellLanguages from the + * Internal use only. Retrieves a GSList of EnchantDicts from the * #WebKitWebSettings of @web_view. * - * Since: 1.1.6 + * Since: 1.1.22 */ -GSList* webkit_web_settings_get_spell_languages(WebKitWebView *web_view) +GSList* webkit_web_settings_get_enchant_dicts(WebKitWebView* webView) { - g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(web_view), 0); + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - WebKitWebSettings* settings = webkit_web_view_get_settings(web_view); - WebKitWebSettingsPrivate* priv = settings->priv; - GSList* list = priv->spell_checking_languages_list; + WebKitWebSettings* settings = webkit_web_view_get_settings(webView); - return list; + return settings->priv->enchant_dicts; } /** diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp index d6a8b83..22f6d04 100644 --- a/WebKit/gtk/webkit/webkitwebview.cpp +++ b/WebKit/gtk/webkit/webkitwebview.cpp @@ -6,7 +6,7 @@ * Copyright (C) 2008 Jan Alonzo <jmalonzo@unpluggable.com> * Copyright (C) 2008 Gustavo Noronha Silva <gns@gnome.org> * Copyright (C) 2008 Nuanti Ltd. - * Copyright (C) 2008, 2009 Collabora Ltd. + * Copyright (C) 2008, 2009, 2010 Collabora Ltd. * Copyright (C) 2009 Igalia S.L. * Copyright (C) 2009 Movial Creative Technologies Inc. * Copyright (C) 2009 Bobby Powers @@ -31,6 +31,7 @@ #include "webkitdownload.h" #include "webkitenumtypes.h" +#include "webkitgeolocationpolicydecision.h" #include "webkitmarshal.h" #include "webkitnetworkrequest.h" #include "webkitnetworkresponse.h" @@ -40,45 +41,47 @@ #include "webkitwebhistoryitem.h" #include "AXObjectCache.h" -#include "NotImplemented.h" #include "BackForwardList.h" #include "Cache.h" -#include "CString.h" #include "ChromeClientGtk.h" -#include "ContextMenu.h" #include "ContextMenuClientGtk.h" #include "ContextMenuController.h" +#include "ContextMenu.h" #include "Cursor.h" +#include "Database.h" #include "Document.h" #include "DocumentLoader.h" #include "DragClientGtk.h" -#include "Editor.h" #include "EditorClientGtk.h" +#include "Editor.h" #include "EventHandler.h" #include "FloatQuad.h" #include "FocusController.h" +#include "FrameLoader.h" #include "FrameLoaderTypes.h" -#include "HitTestRequest.h" -#include "HitTestResult.h" +#include "FrameView.h" #include <glib/gi18n-lib.h> +#include <GOwnPtr.h> #include "GraphicsContext.h" +#include "GtkVersioning.h" +#include "HitTestRequest.h" +#include "HitTestResult.h" #include "IconDatabase.h" #include "InspectorClientGtk.h" -#include "FrameLoader.h" -#include "FrameView.h" #include "MouseEventWithHitTestResults.h" +#include "NotImplemented.h" #include "PageCache.h" #include "Pasteboard.h" -#include "PasteboardHelper.h" #include "PasteboardHelperGtk.h" +#include "PasteboardHelper.h" #include "PlatformKeyboardEvent.h" #include "PlatformWheelEvent.h" #include "ProgressTracker.h" -#include "ResourceHandle.h" #include "RenderView.h" +#include "ResourceHandle.h" #include "ScriptValue.h" #include "Scrollbar.h" -#include <wtf/gtk/GOwnPtr.h> +#include <wtf/text/CString.h> #include <gdk/gdkkeysyms.h> @@ -158,6 +161,10 @@ enum { REDO, DATABASE_QUOTA_EXCEEDED, RESOURCE_REQUEST_STARTING, + DOCUMENT_LOAD_FINISHED, + GEOLOCATION_POLICY_DECISION_REQUESTED, + GEOLOCATION_POLICY_DECISION_CANCELLED, + ONLOAD_EVENT, LAST_SIGNAL }; @@ -201,33 +208,69 @@ static void destroy_menu_cb(GtkObject* object, gpointer data) priv->currentMenu = NULL; } +static void PopupMenuPositionFunc(GtkMenu* menu, gint *x, gint *y, gboolean *pushIn, gpointer userData) +{ + WebKitWebView* view = WEBKIT_WEB_VIEW(userData); + WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(view); + GdkScreen* screen = gtk_widget_get_screen(GTK_WIDGET(view)); + GtkRequisition menuSize; + + gtk_widget_size_request(GTK_WIDGET(menu), &menuSize); + + *x = priv->lastPopupXPosition; + if ((*x + menuSize.width) >= gdk_screen_get_width(screen)) + *x -= menuSize.width; + + *y = priv->lastPopupYPosition; + if ((*y + menuSize.height) >= gdk_screen_get_height(screen)) + *y -= menuSize.height; + + *pushIn = FALSE; +} + static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webView, const PlatformMouseEvent& event) { Page* page = core(webView); page->contextMenuController()->clearContextMenu(); - Frame* focusedFrame = page->focusController()->focusedOrMainFrame(); + Frame* focusedFrame; + Frame* mainFrame = page->mainFrame(); + gboolean mousePressEventResult = FALSE; - if (!focusedFrame->view()) + if (!mainFrame->view()) return FALSE; - focusedFrame->view()->setCursor(pointerCursor()); + mainFrame->view()->setCursor(pointerCursor()); + if (page->frameCount()) { + HitTestRequest request(HitTestRequest::Active); + IntPoint point = mainFrame->view()->windowToContents(event.pos()); + MouseEventWithHitTestResults mev = mainFrame->document()->prepareMouseEvent(request, point, event); + + Frame* targetFrame = EventHandler::subframeForTargetNode(mev.targetNode()); + if (!targetFrame) + targetFrame = mainFrame; + + focusedFrame = page->focusController()->focusedOrMainFrame(); + if (targetFrame != focusedFrame) { + page->focusController()->setFocusedFrame(targetFrame); + focusedFrame = targetFrame; + } + } else + focusedFrame = mainFrame; + + if (focusedFrame->view() && focusedFrame->eventHandler()->handleMousePressEvent(event)) + mousePressEventResult = TRUE; + + bool handledEvent = focusedFrame->eventHandler()->sendContextMenuEvent(event); if (!handledEvent) return FALSE; // If coreMenu is NULL, this means WebCore decided to not create - // the default context menu; this may still mean that the frame - // wants to consume the event - this happens when the page is - // handling the right-click for reasons other than a context menu, - // so we give it to it. + // the default context menu; this may happen when the page is + // handling the right-click for reasons other than the context menu. ContextMenu* coreMenu = page->contextMenuController()->contextMenu(); - if (!coreMenu) { - Frame* frame = core(webView)->mainFrame(); - if (frame->view() && frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event))) - return TRUE; - - return FALSE; - } + if (!coreMenu) + return mousePressEventResult; // If we reach here, it's because WebCore is going to show the // default context menu. We check our setting to figure out @@ -261,8 +304,8 @@ static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webVie NULL); gtk_menu_popup(menu, NULL, NULL, - NULL, - priv, event.button() + 1, gtk_get_current_event_time()); + &PopupMenuPositionFunc, + webView, event.button() + 1, gtk_get_current_event_time()); return TRUE; } @@ -272,17 +315,19 @@ static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget) // The context menu event was generated from the keyboard, so show the context menu by the current selection. Page* page = core(WEBKIT_WEB_VIEW(widget)); - FrameView* view = page->mainFrame()->view(); + Frame* frame = page->focusController()->focusedOrMainFrame(); + FrameView* view = frame->view(); if (!view) return FALSE; - Position start = page->mainFrame()->selection()->selection().start(); - Position end = page->mainFrame()->selection()->selection().end(); + Position start = frame->selection()->selection().start(); + Position end = frame->selection()->selection().end(); int rightAligned = FALSE; IntPoint location; - if (!start.node() || !end.node()) + if (!start.node() || !end.node() + || (frame->selection()->selection().isCaret() && !frame->selection()->selection().isContentEditable())) location = IntPoint(rightAligned ? view->contentsWidth() - contextMenuMargin : contextMenuMargin, contextMenuMargin); else { RenderObject* renderer = start.node()->renderer(); @@ -328,8 +373,17 @@ static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget) // FIXME: The IntSize(0, -1) is a hack to get the hit-testing to result in the selected element. // Ideally we'd have the position of a context menu event be separate from its target node. location = view->contentsToWindow(location) + IntSize(0, -1); + if (location.y() < 0) + location.setY(contextMenuMargin); + else if (location.y() > view->height()) + location.setY(view->height() - contextMenuMargin); + if (location.x() < 0) + location.setX(contextMenuMargin); + else if (location.x() > view->width()) + location.setX(view->width() - contextMenuMargin); IntPoint global = location + IntSize(x, y); - PlatformMouseEvent event(location, global, NoButton, MouseEventPressed, 0, false, false, false, false, gtk_get_current_event_time()); + + PlatformMouseEvent event(location, global, RightButton, MouseEventPressed, 0, false, false, false, false, gtk_get_current_event_time()); return webkit_web_view_forward_context_menu_event(WEBKIT_WEB_VIEW(widget), event); } @@ -510,12 +564,19 @@ static gboolean webkit_web_view_key_release_event(GtkWidget* widget, GdkEventKey { WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); + // GTK+ IM contexts often require us to filter key release events, which + // WebCore does not do by default, so we filter the event here. We only block + // the event if we don't have a pending composition, because that means we + // are using a context like 'simple' which marks every keystroke as filtered. + WebKit::EditorClient* client = static_cast<WebKit::EditorClient*>(core(webView)->editorClient()); + if (gtk_im_context_filter_keypress(webView->priv->imContext, event) && !client->hasPendingComposition()) + return TRUE; + Frame* frame = core(webView)->focusController()->focusedOrMainFrame(); if (!frame->view()) return FALSE; PlatformKeyboardEvent keyboardEvent(event); - if (frame->eventHandler()->keyEvent(keyboardEvent)) return TRUE; @@ -632,16 +693,17 @@ static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allo return; frame->view()->resize(allocation->width, allocation->height); - frame->view()->forceLayout(); - frame->view()->adjustViewSize(); } static void webkit_web_view_grab_focus(GtkWidget* widget) { - if (GTK_WIDGET_IS_SENSITIVE(widget)) { + + if (gtk_widget_is_sensitive(widget)) { WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); FocusController* focusController = core(webView)->focusController(); + focusController->setActive(true); + if (focusController->focusedFrame()) focusController->setFocused(true); else @@ -656,11 +718,7 @@ static gboolean webkit_web_view_focus_in_event(GtkWidget* widget, GdkEventFocus* // TODO: Improve focus handling as suggested in // http://bugs.webkit.org/show_bug.cgi?id=16910 GtkWidget* toplevel = gtk_widget_get_toplevel(widget); -#if GTK_CHECK_VERSION(2, 18, 0) if (gtk_widget_is_toplevel(toplevel) && gtk_window_has_toplevel_focus(GTK_WINDOW(toplevel))) { -#else - if (GTK_WIDGET_TOPLEVEL(toplevel) && gtk_window_has_toplevel_focus(GTK_WINDOW(toplevel))) { -#endif WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); FocusController* focusController = core(webView)->focusController(); @@ -670,6 +728,8 @@ static gboolean webkit_web_view_focus_in_event(GtkWidget* widget, GdkEventFocus* focusController->setFocused(true); else focusController->setFocusedFrame(core(webView)->mainFrame()); + + gtk_im_context_focus_in(webView->priv->imContext); } return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_in_event(widget, event); } @@ -678,8 +738,16 @@ static gboolean webkit_web_view_focus_out_event(GtkWidget* widget, GdkEventFocus { WebKitWebView* webView = WEBKIT_WEB_VIEW(widget); - core(webView)->focusController()->setActive(false); - core(webView)->focusController()->setFocused(false); + // We may hit this code while destroying the widget, and we might + // no longer have a page, then. + Page* page = core(webView); + if (page) { + page->focusController()->setActive(false); + page->focusController()->setFocused(false); + } + + if (webView->priv->imContext) + gtk_im_context_focus_out(webView->priv->imContext); return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_out_event(widget, event); } @@ -849,11 +917,7 @@ static gboolean webkit_web_view_script_dialog(WebKitWebView* webView, WebKitWebF } window = gtk_widget_get_toplevel(GTK_WIDGET(webView)); -#if GTK_CHECK_VERSION(2, 18, 0) dialog = gtk_message_dialog_new(gtk_widget_is_toplevel(window) ? GTK_WINDOW(window) : 0, GTK_DIALOG_DESTROY_WITH_PARENT, messageType, buttons, "%s", message); -#else - dialog = gtk_message_dialog_new(GTK_WIDGET_TOPLEVEL(window) ? GTK_WINDOW(window) : 0, GTK_DIALOG_DESTROY_WITH_PARENT, messageType, buttons, "%s", message); -#endif gchar* title = g_strconcat("JavaScript - ", webkit_web_frame_get_uri(frame), NULL); gtk_window_set_title(GTK_WINDOW(dialog), title); g_free(title); @@ -1432,7 +1496,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) * @web_view: the object on which the signal is emitted * @frame: the #WebKitWebFrame that required the navigation * @request: a #WebKitNetworkRequest - * @navigation_action: a #WebKitWebNavigation + * @navigation_action: a #WebKitWebNavigationAction * @policy_decision: a #WebKitWebPolicyDecision * * Emitted when @frame requests opening a new window. With this @@ -1479,7 +1543,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) * @web_view: the object on which the signal is emitted * @frame: the #WebKitWebFrame that required the navigation * @request: a #WebKitNetworkRequest - * @navigation_action: a #WebKitWebNavigation + * @navigation_action: a #WebKitWebNavigationAction * @policy_decision: a #WebKitWebPolicyDecision * * Emitted when @frame requests a navigation to another page. @@ -1560,7 +1624,6 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) * @context: the #JSGlobalContextRef holding the global object and other * execution state; equivalent to the return value of * webkit_web_frame_get_global_context(@frame) - * * @window_object: the #JSObjectRef representing the frame's JavaScript * window object * @@ -1724,6 +1787,23 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) WEBKIT_TYPE_WEB_FRAME); /** + * WebKitWebView::onload-event: + * @web_view: the object on which the signal is emitted + * @frame: the frame + * + * When a #WebKitWebFrame receives an onload event this signal is emitted. + */ + webkit_web_view_signals[LOAD_STARTED] = g_signal_new("onload-event", + G_TYPE_FROM_CLASS(webViewClass), + (GSignalFlags)G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + WEBKIT_TYPE_WEB_FRAME); + + /** * WebKitWebView::title-changed: * @web_view: the object on which the signal is emitted * @frame: the main frame @@ -2075,7 +2155,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) * @uri: the URI to load * @param: a #GHashTable with additional attributes (strings) * - * The #WebKitWebView::create-plugin signal will be emitted to + * The #WebKitWebView::create-plugin-widget signal will be emitted to * create a plugin widget for embed or object HTML tags. This * allows to embed a GtkWidget as a plugin into HTML content. In * case of a textual selection of the GtkWidget WebCore will attempt @@ -2102,7 +2182,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) * @frame: the relevant frame * @database: the #WebKitWebDatabase which exceeded the quota of its #WebKitSecurityOrigin * - * The #WebKitWebView::database-exceeded-quota signal will be emitted when + * The #WebKitWebView::database-quota-exceeded signal will be emitted when * a Web Database exceeds the quota of its security origin. This signal * may be used to increase the size of the quota before the originating * operation fails. @@ -2159,6 +2239,72 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) WEBKIT_TYPE_NETWORK_REQUEST, WEBKIT_TYPE_NETWORK_RESPONSE); + /** + * WebKitWebView::geolocation-policy-decision-requested: + * @web_view: the object on which the signal is emitted + * @frame: the frame that requests permission + * @policy_decision: a WebKitGeolocationPolicyDecision + * + * When a @frame wants to get its geolocation permission. + * The receiver must reply with a boolean wether it handled or not the + * request. If the request is not handled, default behaviour is to deny + * geolocation. + * + * Since: 1.1.23 + */ + webkit_web_view_signals[GEOLOCATION_POLICY_DECISION_REQUESTED] = g_signal_new("geolocation-policy-decision-requested", + G_TYPE_FROM_CLASS(webViewClass), + (GSignalFlags)(G_SIGNAL_RUN_LAST), + 0, + NULL, NULL, + webkit_marshal_BOOLEAN__OBJECT_OBJECT, + G_TYPE_BOOLEAN, 2, + WEBKIT_TYPE_WEB_FRAME, + WEBKIT_TYPE_GEOLOCATION_POLICY_DECISION); + + /** + * WebKitWebView::geolocation-policy-decision-cancelled: + * @web_view: the object on which the signal is emitted + * @frame: the frame that cancels geolocation request. + * + * When a @frame wants to cancel geolocation permission it had requested + * before. + * + * Since: 1.1.23 + */ + webkit_web_view_signals[GEOLOCATION_POLICY_DECISION_CANCELLED] = g_signal_new("geolocation-policy-decision-cancelled", + G_TYPE_FROM_CLASS(webViewClass), + (GSignalFlags)(G_SIGNAL_RUN_LAST), + 0, + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + WEBKIT_TYPE_WEB_FRAME); + + /* + * DOM-related signals. These signals are experimental, for now, + * and may change API and ABI. Their comments lack one * on + * purpose, to make them not be catched by gtk-doc. + */ + + /* + * WebKitWebView::document-load-finished + * @web_view: the object which received the signal + * @web_frame: the #WebKitWebFrame whose load dispatched this request + * + * Emitted when the DOM document object load is finished for the + * given frame. + */ + webkit_web_view_signals[DOCUMENT_LOAD_FINISHED] = g_signal_new("document-load-finished", + G_TYPE_FROM_CLASS(webViewClass), + (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION), + 0, + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, + WEBKIT_TYPE_WEB_FRAME); + + /* * implementations of virtual methods */ @@ -2549,7 +2695,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) gboolean autoLoadImages, autoShrinkImages, printBackgrounds, enableScripts, enablePlugins, enableDeveloperExtras, resizableTextAreas, enablePrivateBrowsing, enableCaretBrowsing, enableHTML5Database, enableHTML5LocalStorage, - enableXSSAuditor, javascriptCanOpenWindows, enableOfflineWebAppCache, + enableXSSAuditor, enableSpatialNavigation, javascriptCanOpenWindows, enableOfflineWebAppCache, enableUniversalAccessFromFileURI, enableFileAccessFromFileURI, enableDOMPaste, tabKeyCyclesThroughElements, enableSiteSpecificQuirks, usePageCache, enableJavaApplet; @@ -2577,6 +2723,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) "enable-html5-database", &enableHTML5Database, "enable-html5-local-storage", &enableHTML5LocalStorage, "enable-xss-auditor", &enableXSSAuditor, + "enable-spatial-navigation", &enableSpatialNavigation, "javascript-can-open-windows-automatically", &javascriptCanOpenWindows, "enable-offline-web-application-cache", &enableOfflineWebAppCache, "editing-behavior", &editingBehavior, @@ -2606,9 +2753,12 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) settings->setDeveloperExtrasEnabled(enableDeveloperExtras); settings->setPrivateBrowsingEnabled(enablePrivateBrowsing); settings->setCaretBrowsingEnabled(enableCaretBrowsing); - settings->setDatabasesEnabled(enableHTML5Database); +#if ENABLE(DATABASE) + Database::setIsAvailable(enableHTML5Database); +#endif settings->setLocalStorageEnabled(enableHTML5LocalStorage); settings->setXSSAuditorEnabled(enableXSSAuditor); + settings->setSpatialNavigationEnabled(enableSpatialNavigation); settings->setJavaScriptCanOpenWindowsAutomatically(javascriptCanOpenWindows); settings->setOfflineWebApplicationCacheEnabled(enableOfflineWebAppCache); settings->setEditingBehavior(core(editingBehavior)); @@ -2694,12 +2844,17 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar settings->setPrivateBrowsingEnabled(g_value_get_boolean(&value)); else if (name == g_intern_string("enable-caret-browsing")) settings->setCaretBrowsingEnabled(g_value_get_boolean(&value)); - else if (name == g_intern_string("enable-html5-database")) - settings->setDatabasesEnabled(g_value_get_boolean(&value)); +#if ENABLE(DATABASE) + else if (name == g_intern_string("enable-html5-database")) { + Database::setIsAvailable(g_value_get_boolean(&value)); + } +#endif else if (name == g_intern_string("enable-html5-local-storage")) settings->setLocalStorageEnabled(g_value_get_boolean(&value)); else if (name == g_intern_string("enable-xss-auditor")) settings->setXSSAuditorEnabled(g_value_get_boolean(&value)); + else if (name == g_intern_string("enable-spatial-navigation")) + settings->setSpatialNavigationEnabled(g_value_get_boolean(&value)); else if (name == g_intern_string("javascript-can-open-windows-automatically")) settings->setJavaScriptCanOpenWindowsAutomatically(g_value_get_boolean(&value)); else if (name == g_intern_string("enable-offline-web-application-cache")) @@ -2866,8 +3021,11 @@ WebKitWebInspector* webkit_web_view_get_inspector(WebKitWebView* webView) static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures) { WebKitWebViewPrivate* priv = webView->priv; + + if (!webWindowFeatures) + return; - if(webkit_web_window_features_equal(priv->webWindowFeatures, webWindowFeatures)) + if (webkit_web_window_features_equal(priv->webWindowFeatures, webWindowFeatures)) return; g_object_unref(priv->webWindowFeatures); @@ -3259,7 +3417,7 @@ gboolean webkit_web_view_search_text(WebKitWebView* webView, const gchar* string * @web_view: a #WebKitWebView * @string: a string to look for * @case_sensitive: whether to respect the case of text - * @limit: the maximum number of strings to look for or %0 for all + * @limit: the maximum number of strings to look for or 0 for all * * Attempts to highlight all occurances of #string inside #web_view. * @@ -3557,7 +3715,7 @@ void webkit_web_view_set_editable(WebKitWebView* webView, gboolean flag) * * This function returns the list of targets this #WebKitWebView can * provide for clipboard copying and as DND source. The targets in the list are - * added with %info values from the #WebKitWebViewTargetInfo enum, + * added with values from the #WebKitWebViewTargetInfo enum, * using gtk_target_list_add() and * gtk_target_list_add_text_targets(). * @@ -3574,7 +3732,7 @@ GtkTargetList* webkit_web_view_get_copy_target_list(WebKitWebView* webView) * * This function returns the list of targets this #WebKitWebView can * provide for clipboard pasting and as DND destination. The targets in the list are - * added with %info values from the #WebKitWebViewTargetInfo enum, + * added with values from the #WebKitWebViewTargetInfo enum, * using gtk_target_list_add() and * gtk_target_list_add_text_targets(). * @@ -3681,7 +3839,7 @@ static void webkit_web_view_apply_zoom_level(WebKitWebView* webView, gfloat zoom return; WebKitWebViewPrivate* priv = webView->priv; - frame->setZoomFactor(zoomLevel, !priv->zoomFullContent); + frame->setZoomFactor(zoomLevel, priv->zoomFullContent ? ZoomPage : ZoomTextOnly); } /** @@ -3804,6 +3962,7 @@ void webkit_web_view_set_full_content_zoom(WebKitWebView* webView, gboolean zoom */ SoupSession* webkit_get_default_session () { + webkit_init(); return ResourceHandle::defaultSession(); } @@ -3852,7 +4011,7 @@ const gchar* webkit_web_view_get_encoding(WebKitWebView* webView) { g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), NULL); - String encoding = core(webView)->mainFrame()->loader()->encoding(); + String encoding = core(webView)->mainFrame()->loader()->writer()->encoding(); if (!encoding.isEmpty()) { WebKitWebViewPrivate* priv = webView->priv; @@ -4219,6 +4378,8 @@ G_CONST_RETURN gchar* webkit_web_view_get_icon_uri(WebKitWebView* webView) */ void webkit_set_cache_model(WebKitCacheModel model) { + webkit_init(); + if (cacheModel == model) return; @@ -4267,5 +4428,6 @@ void webkit_set_cache_model(WebKitCacheModel model) */ WebKitCacheModel webkit_get_cache_model() { + webkit_init(); return cacheModel; } diff --git a/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp b/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp index cdb6858..a6fe1df 100644 --- a/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp +++ b/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp @@ -422,19 +422,24 @@ WebKitWebWindowFeatures* webkit_web_window_features_new_from_core_features(const */ gboolean webkit_web_window_features_equal(WebKitWebWindowFeatures* features1, WebKitWebWindowFeatures* features2) { + if (features1 == features2) + return TRUE; + if (!features1 || !features2) + return FALSE; + WebKitWebWindowFeaturesPrivate* priv1 = features1->priv; WebKitWebWindowFeaturesPrivate* priv2 = features2->priv; - if((priv1->x == priv2->x) && - (priv1->y == priv2->y) && - (priv1->width == priv2->width) && - (priv1->height == priv2->height) && - (priv1->toolbar_visible == priv2->toolbar_visible) && - (priv1->statusbar_visible == priv2->statusbar_visible) && - (priv1->scrollbar_visible == priv2->scrollbar_visible) && - (priv1->menubar_visible == priv2->menubar_visible) && - (priv1->locationbar_visible == priv2->locationbar_visible) && - (priv1->fullscreen == priv2->fullscreen)) + if ((priv1->x == priv2->x) + && (priv1->y == priv2->y) + && (priv1->width == priv2->width) + && (priv1->height == priv2->height) + && (priv1->toolbar_visible == priv2->toolbar_visible) + && (priv1->statusbar_visible == priv2->statusbar_visible) + && (priv1->scrollbar_visible == priv2->scrollbar_visible) + && (priv1->menubar_visible == priv2->menubar_visible) + && (priv1->locationbar_visible == priv2->locationbar_visible) + && (priv1->fullscreen == priv2->fullscreen)) return TRUE; return FALSE; } |