summaryrefslogtreecommitdiffstats
path: root/WebKit/gtk/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/gtk/webkit')
-rw-r--r--WebKit/gtk/webkit/webkitapplicationcache.cpp32
-rw-r--r--WebKit/gtk/webkit/webkitdownload.cpp109
-rw-r--r--WebKit/gtk/webkit/webkiterror.cpp37
-rw-r--r--WebKit/gtk/webkit/webkiterror.h71
-rw-r--r--WebKit/gtk/webkit/webkitnetworkrequest.cpp179
-rw-r--r--WebKit/gtk/webkit/webkitnetworkrequest.h4
-rw-r--r--WebKit/gtk/webkit/webkitprivate.cpp22
-rw-r--r--WebKit/gtk/webkit/webkitprivate.h68
-rw-r--r--WebKit/gtk/webkit/webkitsoupauthdialog.c78
-rw-r--r--WebKit/gtk/webkit/webkitsoupauthdialog.h5
-rw-r--r--WebKit/gtk/webkit/webkitversion.cpp4
-rw-r--r--WebKit/gtk/webkit/webkitversion.h.in2
-rw-r--r--WebKit/gtk/webkit/webkitwebbackforwardlist.cpp35
-rw-r--r--WebKit/gtk/webkit/webkitwebframe.cpp251
-rw-r--r--WebKit/gtk/webkit/webkitwebframe.h44
-rw-r--r--WebKit/gtk/webkit/webkitwebhistoryitem.cpp50
-rw-r--r--WebKit/gtk/webkit/webkitwebinspector.cpp29
-rw-r--r--WebKit/gtk/webkit/webkitwebnavigationaction.cpp94
-rw-r--r--WebKit/gtk/webkit/webkitwebnavigationaction.h3
-rw-r--r--WebKit/gtk/webkit/webkitwebpolicydecision.cpp12
-rw-r--r--WebKit/gtk/webkit/webkitwebsettings.cpp492
-rw-r--r--WebKit/gtk/webkit/webkitwebsettings.h10
-rw-r--r--WebKit/gtk/webkit/webkitwebview.cpp768
-rw-r--r--WebKit/gtk/webkit/webkitwebview.h19
-rw-r--r--WebKit/gtk/webkit/webkitwebwindowfeatures.cpp7
25 files changed, 1980 insertions, 445 deletions
diff --git a/WebKit/gtk/webkit/webkitapplicationcache.cpp b/WebKit/gtk/webkit/webkitapplicationcache.cpp
new file mode 100644
index 0000000..2c6b71f
--- /dev/null
+++ b/WebKit/gtk/webkit/webkitapplicationcache.cpp
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2009 Jan Michael Alonzo <jmalonzo@gmail.com>
+ *
+ * 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 "webkitprivate.h"
+
+#include "ApplicationCacheStorage.h"
+
+void webkit_application_cache_set_maximum_size(unsigned long long size)
+{
+ WebCore::cacheStorage().empty();
+ WebCore::cacheStorage().vacuumDatabaseFile();
+ WebCore::cacheStorage().setMaximumSize(size);
+}
+
+
diff --git a/WebKit/gtk/webkit/webkitdownload.cpp b/WebKit/gtk/webkit/webkitdownload.cpp
index 4488304..c0c6ea7 100644
--- a/WebKit/gtk/webkit/webkitdownload.cpp
+++ b/WebKit/gtk/webkit/webkitdownload.cpp
@@ -21,6 +21,7 @@
#include "config.h"
#include "CString.h"
+#include <glib/gi18n-lib.h>
#include "Noncopyable.h"
#include "NotImplemented.h"
#include "ResourceHandleClient.h"
@@ -36,7 +37,17 @@
using namespace WebKit;
using namespace WebCore;
-class DownloadClient : Noncopyable, public ResourceHandleClient {
+/**
+ * SECTION:webkitdownload
+ * @short_description: Object used to communicate with the application when downloading.
+ *
+ * #WebKitDownload carries information about a download request,
+ * including a #WebKitNetworkRequest object. The application may use
+ * this object to control the download process, or to simply figure
+ * out what is to be downloaded, and do it itself.
+ */
+
+class DownloadClient : public Noncopyable, public ResourceHandleClient {
public:
DownloadClient(WebKitDownload*);
@@ -51,8 +62,6 @@ class DownloadClient : Noncopyable, public ResourceHandleClient {
WebKitDownload* m_download;
};
-extern "C" {
-
#define WEBKIT_DOWNLOAD_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_DOWNLOAD, WebKitDownloadPrivate))
struct _WebKitDownloadPrivate {
@@ -179,9 +188,6 @@ static void webkit_download_set_property(GObject* object, guint prop_id, const G
switch(prop_id) {
case PROP_NETWORK_REQUEST:
priv->networkRequest = WEBKIT_NETWORK_REQUEST(g_value_dup_object(value));
- // This is safe as network-request is a construct only property and
- // suggestedFilename is initially null.
- priv->suggestedFilename = g_path_get_basename(webkit_network_request_get_uri(priv->networkRequest));
break;
case PROP_DESTINATION_URI:
webkit_download_set_destination_uri(download, g_value_get_string(value));
@@ -202,6 +208,8 @@ static void webkit_download_class_init(WebKitDownloadClass* downloadClass)
objectClass->get_property = webkit_download_get_property;
objectClass->set_property = webkit_download_set_property;
+ webkit_init();
+
/**
* WebKitDownload::error:
* @download: the object on which the signal is emitted
@@ -214,7 +222,7 @@ static void webkit_download_class_init(WebKitDownloadClass* downloadClass)
*/
webkit_download_signals[ERROR] = g_signal_new("error",
G_TYPE_FROM_CLASS(downloadClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled,
NULL,
@@ -236,8 +244,8 @@ static void webkit_download_class_init(WebKitDownloadClass* downloadClass)
g_object_class_install_property(objectClass,
PROP_NETWORK_REQUEST,
g_param_spec_object("network-request",
- "Network Request",
- "The network request for the URI that should be downloaded",
+ _("Network Request"),
+ _("The network request for the URI that should be downloaded"),
WEBKIT_TYPE_NETWORK_REQUEST,
(GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
@@ -251,8 +259,8 @@ static void webkit_download_class_init(WebKitDownloadClass* downloadClass)
g_object_class_install_property(objectClass,
PROP_DESTINATION_URI,
g_param_spec_string("destination-uri",
- "Destination URI",
- "The destination URI where to save the file",
+ _("Destination URI"),
+ _("The destination URI where to save the file"),
"",
WEBKIT_PARAM_READWRITE));
@@ -266,22 +274,26 @@ static void webkit_download_class_init(WebKitDownloadClass* downloadClass)
g_object_class_install_property(objectClass,
PROP_SUGGESTED_FILENAME,
g_param_spec_string("suggested-filename",
- "Suggested Filename",
- "The filename suggested as default when saving",
+ _("Suggested Filename"),
+ _("The filename suggested as default when saving"),
"",
WEBKIT_PARAM_READABLE));
/**
* WebKitDownload:progress:
*
- * Determines the current progress of the download.
+ * Determines the current progress of the download. Notice that,
+ * although the progress changes are reported as soon as possible,
+ * the emission of the notify signal for this property is
+ * throttled, for the benefit of download managers. If you care
+ * about every update, use WebKitDownload:current-size.
*
* Since: 1.1.2
*/
g_object_class_install_property(objectClass, PROP_PROGRESS,
g_param_spec_double("progress",
- "Progress",
- "Determines the current progress of the download",
+ _("Progress"),
+ _("Determines the current progress of the download"),
0.0, 1.0, 1.0,
WEBKIT_PARAM_READABLE));
@@ -294,8 +306,8 @@ static void webkit_download_class_init(WebKitDownloadClass* downloadClass)
*/
g_object_class_install_property(objectClass, PROP_STATUS,
g_param_spec_enum("status",
- "Status",
- "Determines the current status of the download",
+ _("Status"),
+ _("Determines the current status of the download"),
WEBKIT_TYPE_DOWNLOAD_STATUS,
WEBKIT_DOWNLOAD_STATUS_CREATED,
WEBKIT_PARAM_READABLE));
@@ -310,8 +322,8 @@ static void webkit_download_class_init(WebKitDownloadClass* downloadClass)
g_object_class_install_property(objectClass,
PROP_CURRENT_SIZE,
g_param_spec_uint64("current-size",
- "Current Size",
- "The length of the data already downloaded",
+ _("Current Size"),
+ _("The length of the data already downloaded"),
0, G_MAXUINT64, 0,
WEBKIT_PARAM_READABLE));
@@ -325,8 +337,8 @@ static void webkit_download_class_init(WebKitDownloadClass* downloadClass)
g_object_class_install_property(objectClass,
PROP_CURRENT_SIZE,
g_param_spec_uint64("total-size",
- "Total Size",
- "The total size of the file",
+ _("Total Size"),
+ _("The total size of the file"),
0, G_MAXUINT64, 0,
WEBKIT_PARAM_READABLE));
@@ -415,11 +427,8 @@ void webkit_download_start(WebKitDownload* download)
if (priv->resourceHandle)
priv->resourceHandle->setClient(priv->downloadClient);
- else {
- // FIXME: Use the actual request object when WebKitNetworkRequest is finished.
- ResourceRequest request(webkit_network_request_get_uri(priv->networkRequest));
- priv->resourceHandle = ResourceHandle::create(request, priv->downloadClient, 0, false, false, false);
- }
+ else
+ priv->resourceHandle = ResourceHandle::create(core(priv->networkRequest), priv->downloadClient, 0, false, false, false);
priv->timer = g_timer_new();
webkit_download_open_stream_for_uri(download, priv->destinationURI);
@@ -455,7 +464,7 @@ void webkit_download_cancel(WebKitDownload* download)
webkit_download_set_status(download, WEBKIT_DOWNLOAD_STATUS_CANCELLED);
gboolean handled;
- g_signal_emit_by_name(download, "error", 0, WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER, "User cancelled the download", &handled);
+ g_signal_emit_by_name(download, "error", 0, WEBKIT_DOWNLOAD_ERROR_CANCELLED_BY_USER, _("User cancelled the download"), &handled);
}
/**
@@ -519,9 +528,25 @@ const gchar* webkit_download_get_suggested_filename(WebKitDownload* download)
g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), NULL);
WebKitDownloadPrivate* priv = download->priv;
+ if (priv->suggestedFilename)
+ return priv->suggestedFilename;
+
+ KURL url = KURL(KURL(), webkit_network_request_get_uri(priv->networkRequest));
+ url.setQuery(String());
+ url.removeFragmentIdentifier();
+ priv->suggestedFilename = g_strdup(decodeURLEscapeSequences(url.lastPathComponent()).utf8().data());
return priv->suggestedFilename;
}
+// for internal use only
+void webkit_download_set_suggested_filename(WebKitDownload* download, const gchar* suggestedFilename)
+{
+ WebKitDownloadPrivate* priv = download->priv;
+ g_free(priv->suggestedFilename);
+ priv->suggestedFilename = g_strdup(suggestedFilename);
+}
+
+
/**
* webkit_download_get_destination_uri:
* @download: the #WebKitDownload
@@ -688,6 +713,9 @@ gdouble webkit_download_get_progress(WebKitDownload* download)
g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), 1.0);
WebKitDownloadPrivate* priv = download->priv;
+ if (!priv->networkResponse)
+ return 0;
+
gdouble total_size = (gdouble)priv->networkResponse->expectedContentLength();
if (total_size == 0)
@@ -713,6 +741,9 @@ gdouble webkit_download_get_elapsed_time(WebKitDownload* download)
g_return_val_if_fail(WEBKIT_IS_DOWNLOAD(download), 0.0);
WebKitDownloadPrivate* priv = download->priv;
+ if (!priv->timer)
+ return 0;
+
return g_timer_elapsed(priv->timer, NULL);
}
@@ -745,9 +776,23 @@ static void webkit_download_received_data(WebKitDownload* download, const gchar*
if (priv->currentSize > priv->networkResponse->expectedContentLength())
g_object_notify(G_OBJECT(download), "total-size");
- // FIXME: Throttle the number of updates? Should we remove the
- // previous g_object_notify()s if we are going to throttle the
- // progress updates?
+ gdouble lastProgress = webkit_download_get_progress(download);
+
+ // Throttle progress notification to not consume high amounts of
+ // CPU on fast links, except when the progress is >= 3%, or we
+ // reached the end.
+ static gdouble lastElapsed = 0;
+ gdouble currentElapsed = g_timer_elapsed(priv->timer, NULL);
+
+ if (lastElapsed
+ && (currentElapsed - lastElapsed) < 0.1
+ && (webkit_download_get_progress(download) - lastProgress) < 0.03
+ && webkit_download_get_progress(download) < 1.0) {
+ lastElapsed = currentElapsed;
+ return;
+ }
+ lastElapsed = currentElapsed;
+
g_object_notify(G_OBJECT(download), "progress");
}
@@ -814,5 +859,3 @@ void DownloadClient::cannotShowURL(ResourceHandle*)
// and error handling.
notImplemented();
}
-
-}
diff --git a/WebKit/gtk/webkit/webkiterror.cpp b/WebKit/gtk/webkit/webkiterror.cpp
new file mode 100644
index 0000000..e93a5d5
--- /dev/null
+++ b/WebKit/gtk/webkit/webkiterror.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2008 Luca Bruno <lethalman88@gmail.com>
+ *
+ * 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 "webkiterror.h"
+
+GQuark webkit_network_error_quark(void)
+{
+ return g_quark_from_static_string("webkit-network-error-quark");
+}
+
+GQuark webkit_policy_error_quark(void)
+{
+ return g_quark_from_static_string("webkit-policy-error-quark");
+}
+
+GQuark webkit_plugin_error_quark(void)
+{
+ return g_quark_from_static_string("webkit-plugin-error-quark");
+}
diff --git a/WebKit/gtk/webkit/webkiterror.h b/WebKit/gtk/webkit/webkiterror.h
new file mode 100644
index 0000000..512bc7d
--- /dev/null
+++ b/WebKit/gtk/webkit/webkiterror.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2008 Luca Bruno <lethalman88@gmail.com>
+ *
+ * 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 WEBKIT_ERROR_H
+#define WEBKIT_ERROR_H
+
+#include <glib.h>
+
+#include <webkit/webkitdefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_NETWORK_ERROR webkit_network_error_quark ()
+#define WEBKIT_POLICY_ERROR webkit_policy_error_quark ()
+#define WEBKIT_PLUGIN_ERROR webkit_plugin_error_quark ()
+
+typedef enum {
+ WEBKIT_NETWORK_ERROR_FAILED = 399,
+ WEBKIT_NETWORK_ERROR_TRANSPORT = 300,
+ WEBKIT_NETWORK_ERROR_UNKNOWN_PROTOCOL = 301,
+ WEBKIT_NETWORK_ERROR_CANCELLED = 302,
+ WEBKIT_NETWORK_ERROR_FILE_DOES_NOT_EXIST = 303,
+} WebKitNetworkError;
+
+/* Sync'd with Mac's WebKit Errors */
+typedef enum {
+ WEBKIT_POLICY_ERROR_FAILED = 199,
+ WEBKIT_POLICY_ERROR_CANNOT_SHOW_MIME_TYPE = 100,
+ WEBKIT_POLICY_ERROR_CANNOT_SHOW_URL = 101,
+ WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE = 102,
+ WEBKIT_POLICY_ERROR_CANNOT_USE_RESTRICTED_PORT = 103,
+} WebKitPolicyError;
+
+typedef enum {
+ WEBKIT_PLUGIN_ERROR_FAILED = 299,
+ WEBKIT_PLUGIN_ERROR_CANNOT_FIND_PLUGIN = 200,
+ WEBKIT_PLUGIN_ERROR_CANNOT_LOAD_PLUGIN = 201,
+ WEBKIT_PLUGIN_ERROR_JAVA_UNAVAILABLE = 202,
+ WEBKIT_PLUGIN_ERROR_CONNECTION_CANCELLED = 203,
+ WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD = 204,
+} WebKitPluginError;
+
+
+WEBKIT_API GQuark
+webkit_network_error_quark (void);
+
+WEBKIT_API GQuark
+webkit_policy_error_quark (void);
+
+WEBKIT_API GQuark
+webkit_plugin_error_quark (void);
+
+G_END_DECLS
+
+#endif
diff --git a/WebKit/gtk/webkit/webkitnetworkrequest.cpp b/WebKit/gtk/webkit/webkitnetworkrequest.cpp
index 3ad8b5d..e8a225c 100644
--- a/WebKit/gtk/webkit/webkitnetworkrequest.cpp
+++ b/WebKit/gtk/webkit/webkitnetworkrequest.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2007, 2008 Holger Hans Peter Freyther
+ * Copyright (C) 2009 Gustavo Noronha Silva
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -18,9 +19,25 @@
*/
#include "config.h"
-
#include "webkitnetworkrequest.h"
+#include "CString.h"
+#include "GOwnPtr.h"
+#include "ResourceRequest.h"
+#include "webkitprivate.h"
+
+#include <glib/gi18n-lib.h>
+
+namespace WTF {
+
+template <> void freeOwnedGPtr<SoupMessage>(SoupMessage* soupMessage)
+{
+ if (soupMessage)
+ g_object_unref(soupMessage);
+}
+
+}
+
/**
* SECTION:webkitnetworkrequest
* @short_description: The target of a navigation request
@@ -34,16 +51,22 @@
*
*/
-extern "C" {
-
G_DEFINE_TYPE(WebKitNetworkRequest, webkit_network_request, G_TYPE_OBJECT);
struct _WebKitNetworkRequestPrivate {
gchar* uri;
+ SoupMessage* message;
};
#define WEBKIT_NETWORK_REQUEST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_NETWORK_REQUEST, WebKitNetworkRequestPrivate))
+enum {
+ PROP_0,
+
+ PROP_URI,
+ PROP_MESSAGE,
+};
+
static void webkit_network_request_finalize(GObject* object)
{
WebKitNetworkRequest* request = WEBKIT_NETWORK_REQUEST(object);
@@ -51,12 +74,84 @@ static void webkit_network_request_finalize(GObject* object)
g_free(priv->uri);
+ if (priv->message) {
+ g_object_unref(priv->message);
+ priv->message = NULL;
+ }
+
G_OBJECT_CLASS(webkit_network_request_parent_class)->finalize(object);
}
+static void webkit_network_request_get_property(GObject* object, guint propertyID, GValue* value, GParamSpec* pspec)
+{
+ WebKitNetworkRequest* request = WEBKIT_NETWORK_REQUEST(object);
+
+ switch(propertyID) {
+ case PROP_URI:
+ g_value_set_string(value, webkit_network_request_get_uri(request));
+ break;
+ case PROP_MESSAGE:
+ g_value_set_object(value, webkit_network_request_get_message(request));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec);
+ }
+}
+
+static void webkit_network_request_set_property(GObject* object, guint propertyID, const GValue* value, GParamSpec* pspec)
+{
+ WebKitNetworkRequest* request = WEBKIT_NETWORK_REQUEST(object);
+ WebKitNetworkRequestPrivate* priv = request->priv;
+
+ switch(propertyID) {
+ case PROP_URI:
+ webkit_network_request_set_uri(request, g_value_get_string(value));
+ break;
+ case PROP_MESSAGE:
+ priv->message = SOUP_MESSAGE(g_value_dup_object(value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyID, pspec);
+ }
+}
+
static void webkit_network_request_class_init(WebKitNetworkRequestClass* requestClass)
{
- G_OBJECT_CLASS(requestClass)->finalize = webkit_network_request_finalize;
+ GObjectClass* objectClass = G_OBJECT_CLASS(requestClass);
+
+ objectClass->finalize = webkit_network_request_finalize;
+ objectClass->get_property = webkit_network_request_get_property;
+ objectClass->set_property = webkit_network_request_set_property;
+
+ webkit_init();
+
+ /**
+ * WebKitNetworkRequest:uri:
+ *
+ * The URI to which the request will be made.
+ *
+ * Since: 1.1.10
+ */
+ g_object_class_install_property(objectClass, PROP_URI,
+ g_param_spec_string("uri",
+ _("URI"),
+ _("The URI to which the request will be made."),
+ NULL,
+ (GParamFlags)(WEBKIT_PARAM_READWRITE)));
+
+ /**
+ * WebKitNetworkRequest:message:
+ *
+ * The #SoupMessage that backs the request.
+ *
+ * Since: 1.1.10
+ */
+ g_object_class_install_property(objectClass, PROP_MESSAGE,
+ g_param_spec_object("message",
+ _("Message"),
+ _("The SoupMessage that backs the request."),
+ SOUP_TYPE_MESSAGE,
+ (GParamFlags)(WEBKIT_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY)));
g_type_class_add_private(requestClass, sizeof(WebKitNetworkRequestPrivate));
}
@@ -67,18 +162,42 @@ static void webkit_network_request_init(WebKitNetworkRequest* request)
request->priv = priv;
}
-WebKitNetworkRequest* webkit_network_request_new(const gchar* uri)
+// for internal use only
+WebKitNetworkRequest* webkit_network_request_new_with_core_request(const WebCore::ResourceRequest& resourceRequest)
{
- g_return_val_if_fail(uri, NULL);
+ GOwnPtr<SoupMessage> soupMessage(resourceRequest.toSoupMessage());
+ if (soupMessage)
+ return WEBKIT_NETWORK_REQUEST(g_object_new(WEBKIT_TYPE_NETWORK_REQUEST, "message", soupMessage.get(), NULL));
- WebKitNetworkRequest* request = WEBKIT_NETWORK_REQUEST(g_object_new(WEBKIT_TYPE_NETWORK_REQUEST, NULL));
- WebKitNetworkRequestPrivate* priv = request->priv;
+ return WEBKIT_NETWORK_REQUEST(g_object_new(WEBKIT_TYPE_NETWORK_REQUEST, "uri", resourceRequest.url().string().utf8().data(), NULL));
+}
- priv->uri = g_strdup(uri);
+/**
+ * webkit_network_request_new:
+ * @uri: an URI
+ *
+ * Creates a new #WebKitNetworkRequest initialized with an URI.
+ *
+ * Returns: a new #WebKitNetworkRequest, or %NULL if the URI is
+ * invalid.
+ */
+WebKitNetworkRequest* webkit_network_request_new(const gchar* uri)
+{
+ g_return_val_if_fail(uri, NULL);
- return request;
+ return WEBKIT_NETWORK_REQUEST(g_object_new(WEBKIT_TYPE_NETWORK_REQUEST, "uri", uri, NULL));
}
+/**
+ * webkit_network_request_set_uri:
+ * @request: a #WebKitNetworkRequest
+ * @uri: an URI
+ *
+ * Sets the URI held and used by the given request. When the request
+ * has an associated #SoupMessage, its URI will also be set by this
+ * call.
+ *
+ */
void webkit_network_request_set_uri(WebKitNetworkRequest* request, const gchar* uri)
{
g_return_if_fail(WEBKIT_IS_NETWORK_REQUEST(request));
@@ -86,8 +205,21 @@ void webkit_network_request_set_uri(WebKitNetworkRequest* request, const gchar*
WebKitNetworkRequestPrivate* priv = request->priv;
- g_free(priv->uri);
+ if (priv->uri)
+ g_free(priv->uri);
priv->uri = g_strdup(uri);
+
+ if (!priv->message)
+ return;
+
+ SoupURI* soupURI = soup_uri_new(uri);
+ if (!soupURI) {
+ g_warning("Invalid URI: %s", uri);
+ return;
+ }
+
+ soup_message_set_uri(priv->message, soupURI);
+ soup_uri_free(soupURI);
}
/**
@@ -103,7 +235,32 @@ G_CONST_RETURN gchar* webkit_network_request_get_uri(WebKitNetworkRequest* reque
g_return_val_if_fail(WEBKIT_IS_NETWORK_REQUEST(request), NULL);
WebKitNetworkRequestPrivate* priv = request->priv;
+
+ if (priv->uri)
+ return priv->uri;
+
+ SoupURI* soupURI = soup_message_get_uri(priv->message);
+ priv->uri = soup_uri_to_string(soupURI, FALSE);
return priv->uri;
}
+/**
+ * webkit_network_request_get_soup_message:
+ * @request: a #WebKitNetworkRequest
+ *
+ * Obtains the #SoupMessage held and used by the given request. Notice
+ * that modification of the SoupMessage of a request by signal
+ * handlers is only supported (as in, will only affect what is
+ * actually sent to the server) where explicitly documented.
+ *
+ * Returns: the #SoupMessage
+ * Since: 1.1.9
+ */
+SoupMessage* webkit_network_request_get_message(WebKitNetworkRequest* request)
+{
+ g_return_val_if_fail(WEBKIT_IS_NETWORK_REQUEST(request), NULL);
+
+ WebKitNetworkRequestPrivate* priv = request->priv;
+
+ return priv->message;
}
diff --git a/WebKit/gtk/webkit/webkitnetworkrequest.h b/WebKit/gtk/webkit/webkitnetworkrequest.h
index 01ab8bb..78e04a1 100644
--- a/WebKit/gtk/webkit/webkitnetworkrequest.h
+++ b/WebKit/gtk/webkit/webkitnetworkrequest.h
@@ -21,6 +21,7 @@
#define WEBKIT_NETWORK_REQUEST_H
#include <glib-object.h>
+#include <libsoup/soup.h>
#include <webkit/webkitdefines.h>
@@ -65,6 +66,9 @@ webkit_network_request_set_uri (WebKitNetworkRequest *request,
WEBKIT_API G_CONST_RETURN gchar *
webkit_network_request_get_uri (WebKitNetworkRequest *request);
+WEBKIT_API SoupMessage *
+webkit_network_request_get_message(WebKitNetworkRequest* request);
+
G_END_DECLS
#endif
diff --git a/WebKit/gtk/webkit/webkitprivate.cpp b/WebKit/gtk/webkit/webkitprivate.cpp
index c4264c9..755b4d3 100644
--- a/WebKit/gtk/webkit/webkitprivate.cpp
+++ b/WebKit/gtk/webkit/webkitprivate.cpp
@@ -22,12 +22,13 @@
#include "webkitsoupauthdialog.h"
#include "webkitprivate.h"
+#include "ApplicationCacheStorage.h"
#include "ChromeClientGtk.h"
#include "Frame.h"
#include "FrameLoader.h"
#include "FrameLoaderClientGtk.h"
+#include <libintl.h>
#include "Logging.h"
-#include "NotImplemented.h"
#include "PageCache.h"
#include "PageGroup.h"
#include "Pasteboard.h"
@@ -99,6 +100,16 @@ WebCore::NavigationType core(WebKitWebNavigationReason type)
return (WebCore::NavigationType)type;
}
+WebCore::ResourceRequest core(WebKitNetworkRequest* request)
+{
+ SoupMessage* soupMessage = webkit_network_request_get_message(request);
+ if (soupMessage)
+ return ResourceRequest(soupMessage);
+
+ KURL url = KURL(KURL(), String::fromUTF8(webkit_network_request_get_uri(request)));
+ return ResourceRequest(url);
+}
+
} /** end namespace WebKit */
static GtkWidget* currentToplevelCallback(WebKitSoupAuthDialog* feature, SoupMessage* message, gpointer userData)
@@ -133,6 +144,9 @@ void webkit_init()
return;
isInitialized = true;
+ bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+ bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+
JSC::initializeThreading();
WebCore::InitializeLoggingChannelsIfNecessary();
@@ -145,6 +159,7 @@ void webkit_init()
// FIXME: It should be possible for client applications to override this default location
gchar* databaseDirectory = g_build_filename(g_get_user_data_dir(), "webkit", "databases", NULL);
WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(databaseDirectory);
+ WebCore::cacheStorage().setCacheDirectory(databaseDirectory);
g_free(databaseDirectory);
#endif
@@ -153,8 +168,13 @@ void webkit_init()
Pasteboard::generalPasteboard()->setHelper(new WebKit::PasteboardHelperGtk());
SoupSession* session = webkit_get_default_session();
+
SoupSessionFeature* authDialog = static_cast<SoupSessionFeature*>(g_object_new(WEBKIT_TYPE_SOUP_AUTH_DIALOG, NULL));
g_signal_connect(authDialog, "current-toplevel", G_CALLBACK(currentToplevelCallback), NULL);
soup_session_add_feature(session, authDialog);
g_object_unref(authDialog);
+
+ SoupSessionFeature* sniffer = static_cast<SoupSessionFeature*>(g_object_new(SOUP_TYPE_CONTENT_SNIFFER, NULL));
+ soup_session_add_feature(session, sniffer);
+ g_object_unref(sniffer);
}
diff --git a/WebKit/gtk/webkit/webkitprivate.h b/WebKit/gtk/webkit/webkitprivate.h
index 0b83a11..0c3fbd3 100644
--- a/WebKit/gtk/webkit/webkitprivate.h
+++ b/WebKit/gtk/webkit/webkitprivate.h
@@ -23,12 +23,14 @@
#define WEBKIT_PRIVATE_H
/*
- * This file knows the shared secret of WebKitWebView and WebKitWebFrame.
+ * This file knows the shared secret of WebKitWebView, WebKitWebFrame,
+ * and WebKitNetworkRequest.
* They are using WebCore which musn't be exposed to the outer world.
*/
#include <webkit/webkitdefines.h>
#include <webkit/webkitdownload.h>
+#include <webkit/webkitnetworkrequest.h>
#include <webkit/webkitwebview.h>
#include <webkit/webkitwebframe.h>
#include <webkit/webkitwebpolicydecision.h>
@@ -36,8 +38,10 @@
#include <webkit/webkitwebsettings.h>
#include <webkit/webkitwebwindowfeatures.h>
#include <webkit/webkitwebbackforwardlist.h>
+#include <webkit/webkitnetworkrequest.h>
#include "BackForwardList.h"
+#include <enchant.h>
#include "HistoryItem.h"
#include "Settings.h"
#include "Page.h"
@@ -45,10 +49,13 @@
#include "InspectorClientGtk.h"
#include "FrameLoaderClient.h"
#include "ResourceHandle.h"
+#include "ResourceRequest.h"
#include "ResourceResponse.h"
#include "WindowFeatures.h"
+#include <atk/atk.h>
#include <glib.h>
+#include <libsoup/soup.h>
class DownloadClient;
@@ -68,8 +75,15 @@ namespace WebKit {
WebKitWebNavigationReason kit(WebCore::NavigationType type);
WebCore::NavigationType core(WebKitWebNavigationReason reason);
+
+ WebCore::ResourceRequest core(WebKitNetworkRequest* request);
}
+typedef struct {
+ EnchantBroker* config;
+ EnchantDict* speller;
+} SpellLanguage;
+
extern "C" {
void webkit_init();
@@ -85,9 +99,6 @@ extern "C" {
WebKitWebWindowFeatures* webWindowFeatures;
WebKitWebFrame* mainFrame;
- WebCore::String applicationNameForUserAgent;
- WebCore::String* userAgent;
-
WebKitWebBackForwardList* backForwardList;
gint lastPopupXPosition;
@@ -106,10 +117,12 @@ extern "C" {
GtkAdjustment* verticalAdjustment;
gboolean zoomFullContent;
+ WebKitLoadStatus loadStatus;
char* encoding;
char* customEncoding;
gboolean disposing;
+ gboolean usePrimaryForPaste;
};
#define WEBKIT_WEB_FRAME_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_FRAME, WebKitWebFramePrivate))
@@ -121,6 +134,7 @@ extern "C" {
gchar* name;
gchar* title;
gchar* uri;
+ WebKitLoadStatus loadStatus;
};
PassRefPtr<WebCore::Frame>
@@ -158,12 +172,25 @@ extern "C" {
void
webkit_web_view_notify_ready (WebKitWebView* web_view);
+ void
+ webkit_web_view_request_download(WebKitWebView* web_view, WebKitNetworkRequest* request, const WebCore::ResourceResponse& response = WebCore::ResourceResponse());
+
+ void
+ webkit_download_set_suggested_filename(WebKitDownload* download, const gchar* suggestedFilename);
+
WebKitWebPolicyDecision*
webkit_web_policy_decision_new (WebKitWebFrame*, WebCore::FramePolicyFunction);
void
webkit_web_policy_decision_cancel (WebKitWebPolicyDecision* decision);
+ WebKitNetworkRequest*
+ webkit_network_request_new_with_core_request(const WebCore::ResourceRequest& resourceRequest);
+
+ // FIXME: move this to webkitnetworkrequest.h once the API is agreed upon.
+ WEBKIT_API SoupMessage*
+ webkit_network_request_get_message(WebKitNetworkRequest* request);
+
// FIXME: move this functionality into a 'WebKitWebDataSource' once implemented
WEBKIT_API gchar*
webkit_web_frame_get_response_mime_type(WebKitWebFrame* frame);
@@ -176,9 +203,6 @@ extern "C" {
WEBKIT_API gchar*
webkit_web_frame_get_inner_text (WebKitWebFrame* frame);
- WEBKIT_API void
- webkit_web_frame_print (WebKitWebFrame* frame);
-
WEBKIT_API gchar*
webkit_web_frame_dump_render_tree (WebKitWebFrame* frame);
@@ -191,11 +215,41 @@ extern "C" {
WEBKIT_API unsigned int
webkit_web_frame_number_of_active_animations(WebKitWebFrame* frame);
+ WEBKIT_API void
+ webkit_web_frame_clear_main_frame_name(WebKitWebFrame* frame);
+
+ WEBKIT_API AtkObject*
+ webkit_web_frame_get_focused_accessible_element(WebKitWebFrame* frame);
+
WEBKIT_API gchar*
webkit_web_view_get_selected_text (WebKitWebView* web_view);
WEBKIT_API void
+ webkit_web_view_set_group_name(WebKitWebView* web_view, const gchar* group_name);
+
+ WEBKIT_API void
webkit_web_settings_add_extra_plugin_directory (WebKitWebView *web_view, const gchar* directory);
+
+ GSList*
+ webkit_web_settings_get_spell_languages(WebKitWebView* web_view);
+
+ bool
+ webkit_web_view_use_primary_for_paste(WebKitWebView* web_view);
+
+ GHashTable*
+ webkit_history_items(void);
+
+ WEBKIT_API void
+ webkit_gc_collect_javascript_objects();
+
+ WEBKIT_API void
+ webkit_gc_collect_javascript_objects_on_alternate_thread(gboolean waitUntilDone);
+
+ WEBKIT_API gsize
+ webkit_gc_count_javascript_objects();
+
+ WEBKIT_API void
+ webkit_application_cache_set_maximum_size(unsigned long long size);
}
#endif
diff --git a/WebKit/gtk/webkit/webkitsoupauthdialog.c b/WebKit/gtk/webkit/webkitsoupauthdialog.c
index 139000b..9bc188e 100644
--- a/WebKit/gtk/webkit/webkitsoupauthdialog.c
+++ b/WebKit/gtk/webkit/webkitsoupauthdialog.c
@@ -19,6 +19,7 @@
#include "config.h"
+#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
#include <libsoup/soup.h>
#if USE(GNOMEKEYRING)
@@ -28,6 +29,17 @@
#include "webkitmarshal.h"
#include "webkitsoupauthdialog.h"
+/**
+ * SECTION:webkitsoupauthdialog
+ * @short_description: A #SoupFeature to provide a simple
+ * authentication dialog for HTTP basic auth support.
+ *
+ * #WebKitSoupAuthDialog is a #SoupFeature that you can attach to your
+ * #SoupSession to provide a simple authentication dialog, with
+ * optional GNOME Keyring support, while handling HTTP basic auth. It
+ * is built as a simple C-only module to ease reuse.
+ */
+
static void webkit_soup_auth_dialog_session_feature_init(SoupSessionFeatureInterface* feature_interface, gpointer interface_data);
static void attach(SoupSessionFeature* manager, SoupSession* session);
static void detach(SoupSessionFeature* manager, SoupSession* session);
@@ -79,11 +91,15 @@ typedef struct _WebKitAuthData {
#if USE(GNOMEKEYRING)
GtkWidget* checkButton;
#endif
+ char *username;
+ char *password;
} WebKitAuthData;
static void free_authData(WebKitAuthData* authData)
{
g_object_unref(authData->msg);
+ g_free(authData->username);
+ g_free(authData->password);
g_slice_free(WebKitAuthData, authData);
}
@@ -92,47 +108,49 @@ static void set_password_callback(GnomeKeyringResult result, guint32 val, gpoint
{
/* Dummy callback, gnome_keyring_set_network_password does not accept a NULL one */
}
-#endif
-static void response_callback(GtkDialog* dialog, gint response_id, WebKitAuthData* authData)
+static void save_password_callback(SoupMessage* msg, WebKitAuthData* authData)
{
- const char* login;
- const char* password;
-#if USE(GNOMEKEYRING)
- SoupURI* uri;
- gboolean storePassword;
+ /* Check only for Success status codes (2xx) */
+ if (msg->status_code >= 200 && msg->status_code < 300) {
+ SoupURI* uri = soup_message_get_uri(authData->msg);
+ gnome_keyring_set_network_password(NULL,
+ authData->username,
+ soup_auth_get_realm(authData->auth),
+ uri->host,
+ NULL,
+ uri->scheme,
+ soup_auth_get_scheme_name(authData->auth),
+ uri->port,
+ authData->password,
+ (GnomeKeyringOperationGetIntCallback)set_password_callback,
+ NULL,
+ NULL);
+ }
+ free_authData(authData);
+}
#endif
+static void response_callback(GtkDialog* dialog, gint response_id, WebKitAuthData* authData)
+{
switch(response_id) {
case GTK_RESPONSE_OK:
- login = gtk_entry_get_text(GTK_ENTRY(authData->loginEntry));
- password = gtk_entry_get_text(GTK_ENTRY(authData->passwordEntry));
- soup_auth_authenticate(authData->auth, login, password);
+ authData->username = g_strdup(gtk_entry_get_text(GTK_ENTRY(authData->loginEntry)));
+ authData->password = g_strdup(gtk_entry_get_text(GTK_ENTRY(authData->passwordEntry)));
+ soup_auth_authenticate(authData->auth, authData->username, authData->password);
#if USE(GNOMEKEYRING)
- storePassword = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(authData->checkButton));
- if (storePassword) {
- uri = soup_message_get_uri(authData->msg);
- gnome_keyring_set_network_password(NULL,
- login,
- soup_auth_get_realm(authData->auth),
- uri->host,
- NULL,
- uri->scheme,
- soup_auth_get_scheme_name(authData->auth),
- uri->port,
- password,
- (GnomeKeyringOperationGetIntCallback)set_password_callback,
- NULL,
- NULL);
- }
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(authData->checkButton)))
+ g_signal_connect(authData->msg, "got-headers", G_CALLBACK(save_password_callback), authData);
#endif
default:
break;
}
soup_session_unpause_message(authData->session, authData->msg);
+#if !USE(GNOMEKEYRING)
free_authData(authData);
+#endif
gtk_widget_destroy(GTK_WIDGET(dialog));
}
@@ -229,7 +247,7 @@ 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);
+ 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);
@@ -254,9 +272,9 @@ static void show_auth_dialog(WebKitAuthData* authData, const char* login, const
gtk_table_set_row_spacings(GTK_TABLE (table), 6);
gtk_container_add(GTK_CONTAINER(entryContainer), table);
- authData->loginEntry = table_add_entry(table, 0, "Username:",
+ authData->loginEntry = table_add_entry(table, 0, _("Username:"),
login, NULL);
- authData->passwordEntry = table_add_entry(table, 1, "Password:",
+ authData->passwordEntry = table_add_entry(table, 1, _("Password:"),
password, NULL);
gtk_entry_set_visibility(GTK_ENTRY(authData->passwordEntry), FALSE);
@@ -266,7 +284,7 @@ static void show_auth_dialog(WebKitAuthData* authData, const char* login, const
gtk_box_pack_start (GTK_BOX (vbox), rememberBox,
FALSE, FALSE, 0);
- checkButton = gtk_check_button_new_with_label("Remember password");
+ checkButton = gtk_check_button_new_with_mnemonic(_("_Remember password"));
if (login && password)
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(checkButton), TRUE);
gtk_label_set_line_wrap(GTK_LABEL(gtk_bin_get_child(GTK_BIN(checkButton))), TRUE);
diff --git a/WebKit/gtk/webkit/webkitsoupauthdialog.h b/WebKit/gtk/webkit/webkitsoupauthdialog.h
index 2c030b4..9721c72 100644
--- a/WebKit/gtk/webkit/webkitsoupauthdialog.h
+++ b/WebKit/gtk/webkit/webkitsoupauthdialog.h
@@ -20,6 +20,8 @@
#include <gtk/gtk.h>
#include <libsoup/soup.h>
+#include <webkit/webkitdefines.h>
+
#ifndef WEBKIT_SOUP_AUTH_DIALOG_H
#define WEBKIT_SOUP_AUTH_DIALOG_H 1
@@ -42,7 +44,8 @@ typedef struct {
GtkWidget* (*current_toplevel) (WebKitSoupAuthDialog* feature, SoupMessage* message);
} WebKitSoupAuthDialogClass;
-GType webkit_soup_auth_dialog_get_type (void);
+WEBKIT_API GType
+webkit_soup_auth_dialog_get_type (void);
G_END_DECLS
diff --git a/WebKit/gtk/webkit/webkitversion.cpp b/WebKit/gtk/webkit/webkitversion.cpp
index 3f35750..62750f5 100644
--- a/WebKit/gtk/webkit/webkitversion.cpp
+++ b/WebKit/gtk/webkit/webkitversion.cpp
@@ -20,8 +20,6 @@
#include "config.h"
#include "webkitversion.h"
-extern "C" {
-
/**
* webkit_major_version:
*
@@ -63,5 +61,3 @@ guint webkit_micro_version()
{
return WEBKIT_MICRO_VERSION;
}
-
-}
diff --git a/WebKit/gtk/webkit/webkitversion.h.in b/WebKit/gtk/webkit/webkitversion.h.in
index f70800d..9f1b818 100644
--- a/WebKit/gtk/webkit/webkitversion.h.in
+++ b/WebKit/gtk/webkit/webkitversion.h.in
@@ -28,6 +28,8 @@ G_BEGIN_DECLS
#define WEBKIT_MAJOR_VERSION (@WEBKIT_MAJOR_VERSION@)
#define WEBKIT_MINOR_VERSION (@WEBKIT_MINOR_VERSION@)
#define WEBKIT_MICRO_VERSION (@WEBKIT_MICRO_VERSION@)
+#define WEBKIT_USER_AGENT_MAJOR_VERSION (@WEBKIT_USER_AGENT_MAJOR_VERSION@)
+#define WEBKIT_USER_AGENT_MINOR_VERSION (@WEBKIT_USER_AGENT_MINOR_VERSION@)
#define WEBKIT_CHECK_VERSION(major, minor, micro) \
(WEBKIT_MAJOR_VERSION > (major) || \
diff --git a/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp b/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp
index 5c93df0..31631a5 100644
--- a/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp
+++ b/WebKit/gtk/webkit/webkitwebbackforwardlist.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008 Jan Michael C. Alonzo
+ * Copyright (C) 2009 Igalia S.L.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -51,18 +52,41 @@
using namespace WebKit;
-extern "C" {
-
struct _WebKitWebBackForwardListPrivate {
WebCore::BackForwardList* backForwardList;
+ gboolean disposed;
};
#define WEBKIT_WEB_BACK_FORWARD_LIST_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_BACK_FORWARD_LIST, WebKitWebBackForwardListPrivate))
G_DEFINE_TYPE(WebKitWebBackForwardList, webkit_web_back_forward_list, G_TYPE_OBJECT);
+static void webkit_web_back_forward_list_dispose(GObject* object)
+{
+ WebKitWebBackForwardList* list = WEBKIT_WEB_BACK_FORWARD_LIST(object);
+ WebCore::BackForwardList* backForwardList = core(list);
+ WebKitWebBackForwardListPrivate* priv = list->priv;
+
+ if (!priv->disposed) {
+ priv->disposed = true;
+
+ WebCore::HistoryItemVector items = backForwardList->entries();
+ GHashTable* table = webkit_history_items();
+ for (unsigned i = 0; i < items.size(); i++)
+ g_hash_table_remove(table, items[i].get());
+ }
+
+ G_OBJECT_CLASS(webkit_web_back_forward_list_parent_class)->dispose(object);
+}
+
static void webkit_web_back_forward_list_class_init(WebKitWebBackForwardListClass* klass)
{
+ GObjectClass* object_class = G_OBJECT_CLASS(klass);
+
+ object_class->dispose = webkit_web_back_forward_list_dispose;
+
+ webkit_init();
+
g_type_class_add_private(klass, sizeof(WebKitWebBackForwardListPrivate));
}
@@ -397,20 +421,23 @@ void webkit_web_back_forward_list_set_limit(WebKitWebBackForwardList* webBackFor
*
* Adds the item to the #WebKitWebBackForwardList.
*
+ * The @webBackForwardList will add a reference to the @webHistoryItem, so you
+ * don't need to keep a reference once you've added it to the list.
+ *
* Since: 1.1.1
*/
void webkit_web_back_forward_list_add_item(WebKitWebBackForwardList *webBackForwardList, WebKitWebHistoryItem *webHistoryItem)
{
g_return_if_fail(WEBKIT_IS_WEB_BACK_FORWARD_LIST(webBackForwardList));
+ g_object_ref(webHistoryItem);
+
WebCore::BackForwardList* backForwardList = core(webBackForwardList);
WebCore::HistoryItem* historyItem = core(webHistoryItem);
backForwardList->addItem(historyItem);
}
-} /* end extern "C" */
-
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/webkitwebframe.cpp b/WebKit/gtk/webkit/webkitwebframe.cpp
index e2b10b6..fba084e 100644
--- a/WebKit/gtk/webkit/webkitwebframe.cpp
+++ b/WebKit/gtk/webkit/webkitwebframe.cpp
@@ -6,6 +6,7 @@
* Copyright (C) 2008 Collabora Ltd.
* Copyright (C) 2008 Nuanti Ltd.
* Copyright (C) 2009 Jan Alonzo <jmalonzo@gmail.com>
+ * Copyright (C) 2009 Gustavo Noronha Silva <gns@gnome.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -25,21 +26,27 @@
#include "config.h"
+#include "webkitenumtypes.h"
#include "webkitwebframe.h"
#include "webkitwebview.h"
#include "webkitmarshal.h"
#include "webkitprivate.h"
+#include "AccessibilityObjectWrapperAtk.h"
#include "AnimationController.h"
+#include "AXObjectCache.h"
#include "CString.h"
#include "DocumentLoader.h"
#include "FrameLoader.h"
#include "FrameLoaderClientGtk.h"
#include "FrameTree.h"
#include "FrameView.h"
+#include <glib/gi18n-lib.h>
+#include "GCController.h"
#include "GraphicsContext.h"
#include "HTMLFrameOwnerElement.h"
#include "JSDOMWindow.h"
+#include "JSLock.h"
#include "PrintContext.h"
#include "RenderView.h"
#include "RenderTreeAsText.h"
@@ -47,6 +54,7 @@
#include "ScriptController.h"
#include "SubstituteData.h"
+#include <atk/atk.h>
#include <JavaScriptCore/APICast.h>
/**
@@ -71,8 +79,6 @@ using namespace WebKit;
using namespace WebCore;
using namespace std;
-extern "C" {
-
enum {
CLEARED,
LOAD_COMMITTED,
@@ -87,7 +93,8 @@ enum {
PROP_NAME,
PROP_TITLE,
- PROP_URI
+ PROP_URI,
+ PROP_LOAD_STATUS
};
static guint webkit_web_frame_signals[LAST_SIGNAL] = { 0, };
@@ -108,6 +115,9 @@ static void webkit_web_frame_get_property(GObject* object, guint prop_id, GValue
case PROP_URI:
g_value_set_string(value, webkit_web_frame_get_uri(frame));
break;
+ case PROP_LOAD_STATUS:
+ g_value_set_enum(value, webkit_web_frame_get_load_status(frame));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@@ -149,7 +159,7 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass)
*/
webkit_web_frame_signals[CLEARED] = g_signal_new("cleared",
G_TYPE_FROM_CLASS(frameClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -158,16 +168,25 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass)
webkit_web_frame_signals[LOAD_COMMITTED] = g_signal_new("load-committed",
G_TYPE_FROM_CLASS(frameClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ /**
+ * WebKitWebFrame::load-done
+ * @web_frame: the object on which the signal is emitted
+ *
+ * Emitted when frame loading is done.
+ *
+ * Deprecated: Use WebKitWebView::load-finished instead, and/or
+ * WebKitWebView::load-error to be notified of load errors
+ */
webkit_web_frame_signals[LOAD_DONE] = g_signal_new("load-done",
G_TYPE_FROM_CLASS(frameClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -177,7 +196,7 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass)
webkit_web_frame_signals[TITLE_CHANGED] = g_signal_new("title-changed",
G_TYPE_FROM_CLASS(frameClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -187,7 +206,7 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass)
webkit_web_frame_signals[HOVERING_OVER_LINK] = g_signal_new("hovering-over-link",
G_TYPE_FROM_CLASS(frameClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -207,25 +226,40 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass)
*/
g_object_class_install_property(objectClass, PROP_NAME,
g_param_spec_string("name",
- "Name",
- "The name of the frame",
+ _("Name"),
+ _("The name of the frame"),
NULL,
WEBKIT_PARAM_READABLE));
g_object_class_install_property(objectClass, PROP_TITLE,
g_param_spec_string("title",
- "Title",
- "The document title of the frame",
+ _("Title"),
+ _("The document title of the frame"),
NULL,
WEBKIT_PARAM_READABLE));
g_object_class_install_property(objectClass, PROP_URI,
g_param_spec_string("uri",
- "URI",
- "The current URI of the contents displayed by the frame",
+ _("URI"),
+ _("The current URI of the contents displayed by the frame"),
NULL,
WEBKIT_PARAM_READABLE));
+ /**
+ * WebKitWebFrame:load-status:
+ *
+ * Determines the current status of the load.
+ *
+ * Since: 1.1.7
+ */
+ g_object_class_install_property(objectClass, PROP_LOAD_STATUS,
+ g_param_spec_enum("load-status",
+ "Load Status",
+ "Determines the current status of the load",
+ WEBKIT_TYPE_LOAD_STATUS,
+ WEBKIT_LOAD_FINISHED,
+ WEBKIT_PARAM_READABLE));
+
g_type_class_add_private(frameClass, sizeof(WebKitWebFramePrivate));
}
@@ -396,6 +430,25 @@ void webkit_web_frame_load_uri(WebKitWebFrame* frame, const gchar* uri)
coreFrame->loader()->load(ResourceRequest(KURL(KURL(), String::fromUTF8(uri))), false);
}
+static void webkit_web_frame_load_data(WebKitWebFrame* frame, const gchar* content, const gchar* mimeType, const gchar* encoding, const gchar* baseURL, const gchar* unreachableURL)
+{
+ Frame* coreFrame = core(frame);
+ ASSERT(coreFrame);
+
+ KURL baseKURL = baseURL ? KURL(KURL(), String::fromUTF8(baseURL)) : blankURL();
+
+ ResourceRequest request(baseKURL);
+
+ RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(content, strlen(content));
+ SubstituteData substituteData(sharedBuffer.release(),
+ mimeType ? String::fromUTF8(mimeType) : String::fromUTF8("text/html"),
+ encoding ? String::fromUTF8(encoding) : String::fromUTF8("UTF-8"),
+ baseKURL,
+ KURL(KURL(), String::fromUTF8(unreachableURL)));
+
+ coreFrame->loader()->load(request, substituteData, false);
+}
+
/**
* webkit_web_frame_load_string:
* @frame: a #WebKitWebFrame
@@ -418,15 +471,28 @@ void webkit_web_frame_load_string(WebKitWebFrame* frame, const gchar* content, c
g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame));
g_return_if_fail(content);
- Frame* coreFrame = core(frame);
- if (!coreFrame)
- return;
+ webkit_web_frame_load_data(frame, content, contentMimeType, contentEncoding, baseUri, NULL);
+}
- KURL url(KURL(), baseUri ? String::fromUTF8(baseUri) : "");
- RefPtr<SharedBuffer> sharedBuffer = SharedBuffer::create(content, strlen(content));
- SubstituteData substituteData(sharedBuffer.release(), contentMimeType ? String(contentMimeType) : "text/html", contentEncoding ? String(contentEncoding) : "UTF-8", blankURL(), url);
+/**
+ * webkit_web_frame_load_alternate_string:
+ * @frame: a #WebKitWebFrame
+ * @content: the alternate content to display as the main page of the @frame
+ * @base_url: the base URI for relative locations
+ * @unreachable_url: the URL for the alternate page content
+ *
+ * Request loading of an alternate content for a URL that is unreachable.
+ * Using this method will preserve the back-forward list. The URI passed in
+ * @base_url has to be an absolute URI.
+ *
+ * Since: 1.1.6
+ */
+void webkit_web_frame_load_alternate_string(WebKitWebFrame* frame, const gchar* content, const gchar* baseURL, const gchar* unreachableURL)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame));
+ g_return_if_fail(content);
- coreFrame->loader()->load(ResourceRequest(url), substituteData, false);
+ webkit_web_frame_load_data(frame, content, NULL, NULL, baseURL, unreachableURL);
}
/**
@@ -449,9 +515,7 @@ void webkit_web_frame_load_request(WebKitWebFrame* frame, WebKitNetworkRequest*
if (!coreFrame)
return;
- // TODO: Use the ResourceRequest carried by WebKitNetworkRequest when it is implemented.
- String string = String::fromUTF8(webkit_network_request_get_uri(request));
- coreFrame->loader()->load(ResourceRequest(KURL(KURL(), string)), false);
+ coreFrame->loader()->load(core(request), false);
}
/**
@@ -610,9 +674,7 @@ gchar* webkit_web_frame_dump_render_tree(WebKitWebFrame* frame)
return g_strdup(string.utf8().data());
}
-#if GTK_CHECK_VERSION(2,10,0)
-
-static void begin_print(GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data)
+static void begin_print_callback(GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data)
{
PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data);
@@ -630,7 +692,7 @@ static void begin_print(GtkPrintOperation* op, GtkPrintContext* context, gpointe
gtk_print_operation_set_n_pages(op, printContext->pageCount());
}
-static void draw_page(GtkPrintOperation* op, GtkPrintContext* context, gint page_nr, gpointer user_data)
+static void draw_page_callback(GtkPrintOperation* op, GtkPrintContext* context, gint page_nr, gpointer user_data)
{
PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data);
@@ -640,34 +702,72 @@ static void draw_page(GtkPrintOperation* op, GtkPrintContext* context, gint page
printContext->spoolPage(ctx, page_nr, width);
}
-static void end_print(GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data)
+static void end_print_callback(GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data)
{
PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data);
printContext->end();
}
-void webkit_web_frame_print(WebKitWebFrame* frame)
+/**
+ * webkit_web_frame_print_full:
+ * @frame: a #WebKitWebFrame to be printed
+ * @operation: the #GtkPrintOperation to be carried
+ * @action: the #GtkPrintOperationAction to be performed
+ * @error: #GError for error return
+ *
+ * Prints the given #WebKitFrame, using the given #GtkPrintOperation
+ * and #GtkPrintOperationAction. This function wraps a call to
+ * gtk_print_operation_run() for printing the contents of the
+ * #WebKitWebFrame.
+ *
+ * Since: 1.1.5
+ */
+GtkPrintOperationResult webkit_web_frame_print_full(WebKitWebFrame* frame, GtkPrintOperation* operation, GtkPrintOperationAction action, GError** error)
{
+ g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), GTK_PRINT_OPERATION_RESULT_ERROR);
+ g_return_val_if_fail(GTK_IS_PRINT_OPERATION(operation), GTK_PRINT_OPERATION_RESULT_ERROR);
+
GtkWidget* topLevel = gtk_widget_get_toplevel(GTK_WIDGET(webkit_web_frame_get_web_view(frame)));
if (!GTK_WIDGET_TOPLEVEL(topLevel))
topLevel = NULL;
Frame* coreFrame = core(frame);
if (!coreFrame)
- return;
+ return GTK_PRINT_OPERATION_RESULT_ERROR;
PrintContext printContext(coreFrame);
- GtkPrintOperation* op = gtk_print_operation_new();
- g_signal_connect(op, "begin-print", G_CALLBACK(begin_print), &printContext);
- g_signal_connect(op, "draw-page", G_CALLBACK(draw_page), &printContext);
- g_signal_connect(op, "end-print", G_CALLBACK(end_print), &printContext);
- GError *error = NULL;
- gtk_print_operation_run(op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, GTK_WINDOW(topLevel), &error);
- g_object_unref(op);
+ g_signal_connect(operation, "begin-print", G_CALLBACK(begin_print_callback), &printContext);
+ g_signal_connect(operation, "draw-page", G_CALLBACK(draw_page_callback), &printContext);
+ g_signal_connect(operation, "end-print", G_CALLBACK(end_print_callback), &printContext);
+
+ return gtk_print_operation_run(operation, action, GTK_WINDOW(topLevel), error);
+}
+
+/**
+ * webkit_web_frame_print:
+ * @frame: a #WebKitWebFrame
+ *
+ * Prints the given #WebKitFrame, by presenting a print dialog to the
+ * user. If you need more control over the printing process, see
+ * webkit_web_frame_print_full().
+ *
+ * Since: 1.1.5
+ */
+void webkit_web_frame_print(WebKitWebFrame* frame)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame));
+
+ WebKitWebFramePrivate* priv = frame->priv;
+ GtkPrintOperation* operation = gtk_print_operation_new();
+ GError* error = 0;
+
+ webkit_web_frame_print_full(frame, operation, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, &error);
+ g_object_unref(operation);
if (error) {
- GtkWidget* dialog = gtk_message_dialog_new(GTK_WINDOW(topLevel),
+ GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(priv->webView));
+ 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,
@@ -679,15 +779,6 @@ void webkit_web_frame_print(WebKitWebFrame* frame)
}
}
-#else
-
-void webkit_web_frame_print(WebKitWebFrame*)
-{
- g_warning("Printing support is not available in older versions of GTK+");
-}
-
-#endif
-
bool webkit_web_frame_pause_animation(WebKitWebFrame* frame, const gchar* name, double time, const gchar* element)
{
ASSERT(core(frame));
@@ -727,4 +818,68 @@ gchar* webkit_web_frame_get_response_mime_type(WebKitWebFrame* frame)
return g_strdup(mimeType.utf8().data());
}
+/**
+ * webkit_web_frame_get_load_status:
+ * @frame: a #WebKitWebView
+ *
+ * Determines the current status of the load.
+ *
+ * Since: 1.1.7
+ */
+WebKitLoadStatus webkit_web_frame_get_load_status(WebKitWebFrame* frame)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), WEBKIT_LOAD_FINISHED);
+
+ WebKitWebFramePrivate* priv = frame->priv;
+ return priv->loadStatus;
+}
+
+void webkit_web_frame_clear_main_frame_name(WebKitWebFrame* frame)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_FRAME(frame));
+
+ core(frame)->tree()->clearName();
+}
+
+void webkit_gc_collect_javascript_objects()
+{
+ gcController().garbageCollectNow();
+}
+
+void webkit_gc_collect_javascript_objects_on_alternate_thread(gboolean waitUntilDone)
+{
+ gcController().garbageCollectOnAlternateThreadForDebugging(waitUntilDone);
+}
+
+gsize webkit_gc_count_javascript_objects()
+{
+ JSC::JSLock lock(JSC::SilenceAssertionsOnly);
+ return JSDOMWindow::commonJSGlobalData()->heap.objectCount();
+
+}
+
+AtkObject* webkit_web_frame_get_focused_accessible_element(WebKitWebFrame* frame)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL);
+
+#if HAVE(ACCESSIBILITY)
+ if (!AXObjectCache::accessibilityEnabled())
+ AXObjectCache::enableAccessibility();
+
+ WebKitWebFramePrivate* priv = frame->priv;
+ if (!priv->coreFrame || !priv->coreFrame->document())
+ return NULL;
+
+ RenderView* root = toRenderView(priv->coreFrame->document()->renderer());
+ if (!root)
+ return NULL;
+
+ AtkObject* wrapper = priv->coreFrame->document()->axObjectCache()->getOrCreate(root)->wrapper();
+ if (!wrapper)
+ return NULL;
+
+ return webkit_accessible_get_focused_element(WEBKIT_ACCESSIBLE(wrapper));
+#else
+ return NULL;
+#endif
}
diff --git a/WebKit/gtk/webkit/webkitwebframe.h b/WebKit/gtk/webkit/webkitwebframe.h
index 7e24565..b2e61b9 100644
--- a/WebKit/gtk/webkit/webkitwebframe.h
+++ b/WebKit/gtk/webkit/webkitwebframe.h
@@ -22,6 +22,8 @@
#define WEBKIT_WEB_FRAME_H
#include <glib-object.h>
+#include <gtk/gtk.h>
+
#include <JavaScriptCore/JSBase.h>
#include <webkit/webkitdefines.h>
@@ -57,6 +59,30 @@ struct _WebKitWebFrameClass {
void (*_webkit_reserved6) (void);
};
+/**
+ * WebKitLoadStatus
+ * @WEBKIT_LOAD_PROVISIONAL: No data has been received yet, empty
+ * structures have been allocated to perform the load; the load may
+ * still fail for transport issues such as not being able to resolve a
+ * name, or connect to a port.
+ * @WEBKIT_LOAD_COMMITTED: The first data chunk has arrived, meaning
+ * that the necessary transport requirements are stabilished, and the
+ * load is being performed.
+ * @WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT: The first layout with
+ * actual visible content happened; one or more layouts may have
+ * happened before that caused nothing to be visible on the screen,
+ * because the data available at the time was not significant enough.
+ * @WEBKIT_LOAD_FINISHED: This state means either that everything that
+ * was required to display the page has been loaded, or that an error
+ * has happened.
+ */
+typedef enum {
+ WEBKIT_LOAD_PROVISIONAL,
+ WEBKIT_LOAD_COMMITTED,
+ WEBKIT_LOAD_FINISHED,
+ WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT
+} WebKitLoadStatus;
+
WEBKIT_API GType
webkit_web_frame_get_type (void);
@@ -92,6 +118,12 @@ webkit_web_frame_load_string (WebKitWebFrame *frame,
const gchar *base_uri);
WEBKIT_API void
+webkit_web_frame_load_alternate_string (WebKitWebFrame *frame,
+ const gchar *content,
+ const gchar *base_url,
+ const gchar *unreachable_url);
+
+WEBKIT_API void
webkit_web_frame_load_request (WebKitWebFrame *frame,
WebKitNetworkRequest *request);
@@ -108,6 +140,18 @@ webkit_web_frame_find_frame (WebKitWebFrame *frame,
WEBKIT_API JSGlobalContextRef
webkit_web_frame_get_global_context (WebKitWebFrame *frame);
+WEBKIT_API GtkPrintOperationResult
+webkit_web_frame_print_full (WebKitWebFrame *frame,
+ GtkPrintOperation *operation,
+ GtkPrintOperationAction action,
+ GError **error);
+
+WEBKIT_API void
+webkit_web_frame_print (WebKitWebFrame *frame);
+
+WEBKIT_API WebKitLoadStatus
+webkit_web_frame_get_load_status (WebKitWebFrame *frame);
+
G_END_DECLS
#endif
diff --git a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp
index 42e6a9b..a75bc0d 100644
--- a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp
+++ b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008, 2009 Jan Michael C. Alonzo
+ * Copyright (C) 2009 Igalia S.L.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -23,6 +24,7 @@
#include "webkitprivate.h"
#include <glib.h>
+#include <glib/gi18n-lib.h>
#include "CString.h"
#include "HistoryItem.h"
@@ -49,8 +51,6 @@
using namespace WebKit;
-extern "C" {
-
struct _WebKitWebHistoryItemPrivate {
WebCore::HistoryItem* historyItem;
@@ -80,37 +80,28 @@ static void webkit_web_history_item_set_property(GObject* object, guint prop_id,
static void webkit_web_history_item_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec);
-static GHashTable* webkit_history_items()
+GHashTable* webkit_history_items()
{
static GHashTable* historyItems = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_object_unref);
return historyItems;
}
-static void webkit_history_item_add(WebKitWebHistoryItem* webHistoryItem, WebCore::HistoryItem* historyItem)
+void webkit_history_item_add(WebKitWebHistoryItem* webHistoryItem, WebCore::HistoryItem* historyItem)
{
g_return_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem));
GHashTable* table = webkit_history_items();
-
- g_hash_table_insert(table, historyItem, g_object_ref(webHistoryItem));
+ g_hash_table_insert(table, historyItem, webHistoryItem);
}
static void webkit_web_history_item_dispose(GObject* object)
{
WebKitWebHistoryItem* webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(object);
WebKitWebHistoryItemPrivate* priv = webHistoryItem->priv;
- WebCore::HistoryItem* item = core(webHistoryItem);
if (!priv->disposed) {
- GHashTable* table = webkit_history_items();
-
- g_hash_table_remove(table, item);
+ WebCore::HistoryItem* item = core(webHistoryItem);
item->deref();
-
- /* destroy table if empty */
- if (!g_hash_table_size(table))
- g_hash_table_destroy(table);
-
priv->disposed = true;
}
@@ -139,6 +130,8 @@ static void webkit_web_history_item_class_init(WebKitWebHistoryItemClass* klass)
gobject_class->set_property = webkit_web_history_item_set_property;
gobject_class->get_property = webkit_web_history_item_get_property;
+ webkit_init();
+
/**
* WebKitWebHistoryItem:title:
*
@@ -150,8 +143,8 @@ static void webkit_web_history_item_class_init(WebKitWebHistoryItemClass* klass)
PROP_TITLE,
g_param_spec_string(
"title",
- "Title",
- "The title of the history item",
+ _("Title"),
+ _("The title of the history item"),
NULL,
WEBKIT_PARAM_READABLE));
@@ -166,8 +159,8 @@ static void webkit_web_history_item_class_init(WebKitWebHistoryItemClass* klass)
PROP_ALTERNATE_TITLE,
g_param_spec_string(
"alternate-title",
- "Alternate Title",
- "The alternate title of the history item",
+ _("Alternate Title"),
+ _("The alternate title of the history item"),
NULL,
WEBKIT_PARAM_READWRITE));
@@ -182,8 +175,8 @@ static void webkit_web_history_item_class_init(WebKitWebHistoryItemClass* klass)
PROP_URI,
g_param_spec_string(
"uri",
- "URI",
- "The URI of the history item",
+ _("URI"),
+ _("The URI of the history item"),
NULL,
WEBKIT_PARAM_READABLE));
@@ -198,8 +191,8 @@ static void webkit_web_history_item_class_init(WebKitWebHistoryItemClass* klass)
PROP_ORIGINAL_URI,
g_param_spec_string(
"original-uri",
- "Original URI",
- "The original URI of the history item",
+ _("Original URI"),
+ _("The original URI of the history item"),
NULL,
WEBKIT_PARAM_READABLE));
@@ -214,8 +207,8 @@ static void webkit_web_history_item_class_init(WebKitWebHistoryItemClass* klass)
PROP_LAST_VISITED_TIME,
g_param_spec_double(
"last-visited-time",
- "Last visited Time",
- "The time at which the history item was last visited",
+ _("Last visited Time"),
+ _("The time at which the history item was last visited"),
0, G_MAXDOUBLE, 0,
WEBKIT_PARAM_READABLE));
@@ -485,8 +478,6 @@ GList* webkit_web_history_item_get_children(WebKitWebHistoryItem* webHistoryItem
return g_list_reverse(kids);
}
-} /* end extern "C" */
-
WebCore::HistoryItem* WebKit::core(WebKitWebHistoryItem* webHistoryItem)
{
g_return_val_if_fail(WEBKIT_IS_WEB_HISTORY_ITEM(webHistoryItem), NULL);
@@ -499,11 +490,8 @@ WebKitWebHistoryItem* WebKit::kit(PassRefPtr<WebCore::HistoryItem> historyItem)
g_return_val_if_fail(historyItem, NULL);
RefPtr<WebCore::HistoryItem> item = historyItem;
-
- WebKitWebHistoryItem* webHistoryItem;
GHashTable* table = webkit_history_items();
-
- webHistoryItem = (WebKitWebHistoryItem*) g_hash_table_lookup(table, item.get());
+ WebKitWebHistoryItem* webHistoryItem = (WebKitWebHistoryItem*) g_hash_table_lookup(table, item.get());
if (!webHistoryItem) {
webHistoryItem = WEBKIT_WEB_HISTORY_ITEM(g_object_new(WEBKIT_TYPE_WEB_HISTORY_ITEM, NULL));
diff --git a/WebKit/gtk/webkit/webkitwebinspector.cpp b/WebKit/gtk/webkit/webkitwebinspector.cpp
index 8e1c8c0..4e4f8de 100644
--- a/WebKit/gtk/webkit/webkitwebinspector.cpp
+++ b/WebKit/gtk/webkit/webkitwebinspector.cpp
@@ -20,6 +20,7 @@
#include "config.h"
+#include <glib/gi18n-lib.h>
#include "webkitwebinspector.h"
#include "webkitmarshal.h"
#include "InspectorClientGtk.h"
@@ -56,8 +57,6 @@
using namespace WebKit;
-extern "C" {
-
enum {
INSPECT_WEB_VIEW,
SHOW_WINDOW,
@@ -132,7 +131,7 @@ static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass)
*/
webkit_web_inspector_signals[INSPECT_WEB_VIEW] = g_signal_new("inspect-web-view",
G_TYPE_FROM_CLASS(klass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
webkit_inspect_web_view_request_handled,
NULL,
@@ -153,7 +152,7 @@ static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass)
*/
webkit_web_inspector_signals[SHOW_WINDOW] = g_signal_new("show-window",
G_TYPE_FROM_CLASS(klass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled,
NULL,
@@ -172,7 +171,7 @@ static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass)
*/
webkit_web_inspector_signals[ATTACH_WINDOW] = g_signal_new("attach-window",
G_TYPE_FROM_CLASS(klass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled,
NULL,
@@ -190,7 +189,7 @@ static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass)
*/
webkit_web_inspector_signals[DETACH_WINDOW] = g_signal_new("detach-window",
G_TYPE_FROM_CLASS(klass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled,
NULL,
@@ -217,7 +216,7 @@ static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass)
*/
webkit_web_inspector_signals[CLOSE_WINDOW] = g_signal_new("close-window",
G_TYPE_FROM_CLASS(klass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled,
NULL,
@@ -236,7 +235,7 @@ static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass)
*/
webkit_web_inspector_signals[FINISHED] = g_signal_new("finished",
G_TYPE_FROM_CLASS(klass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -256,8 +255,8 @@ static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass)
*/
g_object_class_install_property(gobject_class, PROP_WEB_VIEW,
g_param_spec_object("web-view",
- "Web View",
- "The Web View that renders the Web Inspector itself",
+ _("Web View"),
+ _("The Web View that renders the Web Inspector itself"),
WEBKIT_TYPE_WEB_VIEW,
WEBKIT_PARAM_READABLE));
@@ -270,8 +269,8 @@ static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass)
*/
g_object_class_install_property(gobject_class, PROP_INSPECTED_URI,
g_param_spec_string("inspected-uri",
- "Inspected URI",
- "The URI that is currently being inspected",
+ _("Inspected URI"),
+ _("The URI that is currently being inspected"),
NULL,
WEBKIT_PARAM_READABLE));
@@ -287,8 +286,8 @@ static void webkit_web_inspector_class_init(WebKitWebInspectorClass* klass)
PROP_JAVASCRIPT_PROFILING_ENABLED,
g_param_spec_boolean(
"javascript-profiling-enabled",
- "Enable JavaScript profiling",
- "Profile the executed JavaScript.",
+ _("Enable JavaScript profiling"),
+ _("Profile the executed JavaScript."),
FALSE,
WEBKIT_PARAM_READWRITE));
@@ -427,5 +426,3 @@ webkit_web_inspector_set_inspector_client(WebKitWebInspector* web_inspector, Web
priv->page = page;
}
-
-}
diff --git a/WebKit/gtk/webkit/webkitwebnavigationaction.cpp b/WebKit/gtk/webkit/webkitwebnavigationaction.cpp
index 48e36ac..c866c0f 100644
--- a/WebKit/gtk/webkit/webkitwebnavigationaction.cpp
+++ b/WebKit/gtk/webkit/webkitwebnavigationaction.cpp
@@ -22,19 +22,30 @@
#include <wtf/Assertions.h>
#include "FrameLoaderTypes.h"
+#include <glib/gi18n-lib.h>
#include "webkitwebnavigationaction.h"
#include "webkitprivate.h"
#include "webkitenumtypes.h"
#include <string.h>
-extern "C" {
+static void webkit_web_navigation_action_set_target_frame(WebKitWebNavigationAction* navigationAction, const gchar* targetFrame);
+
+/**
+ * SECTION:webkitwebnavigationaction
+ * @short_description: Object used to report details of navigation actions
+ *
+ * #WebKitWebNavigationAction is used in signals to provide details about
+ * what led the navigation to happen. This includes, for instance, if the user
+ * clicked a link to start that navigation, and what mouse button was used.
+ */
struct _WebKitWebNavigationActionPrivate {
WebKitWebNavigationReason reason;
gchar* originalUri;
gint button;
gint modifier_state;
+ gchar* targetFrame;
};
#define WEBKIT_WEB_NAVIGATION_ACTION_GET_PRIVATE(obj)(G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_NAVIGATION_ACTION, WebKitWebNavigationActionPrivate))
@@ -45,7 +56,8 @@ enum {
PROP_REASON,
PROP_ORIGINAL_URI,
PROP_BUTTON,
- PROP_MODIFIER_STATE
+ PROP_MODIFIER_STATE,
+ PROP_TARGET_FRAME
};
G_DEFINE_TYPE(WebKitWebNavigationAction, webkit_web_navigation_action, G_TYPE_OBJECT)
@@ -68,6 +80,9 @@ static void webkit_web_navigation_action_get_property(GObject* object, guint pro
case PROP_MODIFIER_STATE:
g_value_set_int(value, webkit_web_navigation_action_get_modifier_state(navigationAction));
break;
+ case PROP_TARGET_FRAME:
+ g_value_set_string(value, webkit_web_navigation_action_get_target_frame(navigationAction));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
break;
@@ -92,6 +107,9 @@ static void webkit_web_navigation_action_set_property(GObject* object, guint pro
case PROP_MODIFIER_STATE:
priv->modifier_state = g_value_get_int(value);
break;
+ case PROP_TARGET_FRAME:
+ webkit_web_navigation_action_set_target_frame(navigationAction, g_value_get_string(value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propertyId, pspec);
break;
@@ -101,8 +119,6 @@ static void webkit_web_navigation_action_set_property(GObject* object, guint pro
static void webkit_web_navigation_action_init(WebKitWebNavigationAction* navigationAction)
{
navigationAction->priv = WEBKIT_WEB_NAVIGATION_ACTION_GET_PRIVATE(navigationAction);
-
- WebKitWebNavigationActionPrivate* priv = navigationAction->priv;
}
static void webkit_web_navigation_action_finalize(GObject* obj)
@@ -119,12 +135,12 @@ static void webkit_web_navigation_action_class_init(WebKitWebNavigationActionCla
{
GObjectClass* objectClass = G_OBJECT_CLASS(requestClass);
- COMPILE_ASSERT(WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED == WebCore::NavigationTypeLinkClicked, navigation_type_link_clicked_enum_match);
- COMPILE_ASSERT(WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED == WebCore::NavigationTypeFormSubmitted, navigation_type_form_submitted_enum_match);
- COMPILE_ASSERT(WEBKIT_WEB_NAVIGATION_REASON_BACK_FORWARD == WebCore::NavigationTypeBackForward, navigation_type_back_forward_enum_match);
- COMPILE_ASSERT(WEBKIT_WEB_NAVIGATION_REASON_RELOAD == WebCore::NavigationTypeReload, navigation_type_reload_enum_match);
- COMPILE_ASSERT(WEBKIT_WEB_NAVIGATION_REASON_FORM_RESUBMITTED == WebCore::NavigationTypeFormResubmitted, navigation_type_form_resubmitted_enum_match);
- COMPILE_ASSERT(WEBKIT_WEB_NAVIGATION_REASON_OTHER == WebCore::NavigationTypeOther, navigation_type_other_enum_match);
+ COMPILE_ASSERT(static_cast<int>(WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) == static_cast<int>(WebCore::NavigationTypeLinkClicked), navigation_type_link_clicked_enum_match);
+ COMPILE_ASSERT(static_cast<int>(WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED) == static_cast<int>(WebCore::NavigationTypeFormSubmitted), navigation_type_form_submitted_enum_match);
+ COMPILE_ASSERT(static_cast<int>(WEBKIT_WEB_NAVIGATION_REASON_BACK_FORWARD) == static_cast<int>(WebCore::NavigationTypeBackForward), navigation_type_back_forward_enum_match);
+ COMPILE_ASSERT(static_cast<int>(WEBKIT_WEB_NAVIGATION_REASON_RELOAD) == static_cast<int>(WebCore::NavigationTypeReload), navigation_type_reload_enum_match);
+ COMPILE_ASSERT(static_cast<int>(WEBKIT_WEB_NAVIGATION_REASON_FORM_RESUBMITTED) == static_cast<int>(WebCore::NavigationTypeFormResubmitted), navigation_type_form_resubmitted_enum_match);
+ COMPILE_ASSERT(static_cast<int>(WEBKIT_WEB_NAVIGATION_REASON_OTHER) == static_cast<int>(WebCore::NavigationTypeOther), navigation_type_other_enum_match);
objectClass->get_property = webkit_web_navigation_action_get_property;
objectClass->set_property = webkit_web_navigation_action_set_property;
@@ -139,8 +155,8 @@ static void webkit_web_navigation_action_class_init(WebKitWebNavigationActionCla
*/
g_object_class_install_property(objectClass, PROP_REASON,
g_param_spec_enum("reason",
- "Reason",
- "The reason why this navigation is occurring",
+ _("Reason"),
+ _("The reason why this navigation is occurring"),
WEBKIT_TYPE_WEB_NAVIGATION_REASON,
WEBKIT_WEB_NAVIGATION_REASON_OTHER,
(GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT)));
@@ -154,8 +170,8 @@ static void webkit_web_navigation_action_class_init(WebKitWebNavigationActionCla
*/
g_object_class_install_property(objectClass, PROP_ORIGINAL_URI,
g_param_spec_string("original-uri",
- "Original URI",
- "The URI that was requested as the target for the navigation",
+ _("Original URI"),
+ _("The URI that was requested as the target for the navigation"),
"",
(GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT)));
/**
@@ -167,8 +183,8 @@ static void webkit_web_navigation_action_class_init(WebKitWebNavigationActionCla
*/
g_object_class_install_property(objectClass, PROP_BUTTON,
g_param_spec_int("button",
- "Button",
- "The button used to click",
+ _("Button"),
+ _("The button used to click"),
-1,
G_MAXINT,
-1,
@@ -183,13 +199,27 @@ static void webkit_web_navigation_action_class_init(WebKitWebNavigationActionCla
*/
g_object_class_install_property(objectClass, PROP_MODIFIER_STATE,
g_param_spec_int("modifier-state",
- "Modifier state",
- "A bitmask representing the state of the modifier keys",
+ _("Modifier state"),
+ _("A bitmask representing the state of the modifier keys"),
0,
G_MAXINT,
0,
(GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+ /**
+ * WebKitWebNavigationAction:target-frame:
+ *
+ * The target frame for the navigation.
+ *
+ * Since: 1.1.13
+ */
+ g_object_class_install_property(objectClass, PROP_TARGET_FRAME,
+ g_param_spec_string("target-frame",
+ _("Target frame"),
+ _("The target frame for the navigation"),
+ NULL,
+ (GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+
g_type_class_add_private(requestClass, sizeof(WebKitWebNavigationActionPrivate));
@@ -308,5 +338,31 @@ gint webkit_web_navigation_action_get_modifier_state(WebKitWebNavigationAction*
return navigationAction->priv->modifier_state;
}
-
+
+/**
+ * webkit_web_navigation_action_get_target_frame:
+ * @navigationAction: a #WebKitWebNavigationAction
+ *
+ * Returns the target frame of the action.
+ *
+ * Return value: the target frame of the action or NULL
+ * if there is no target.
+ *
+ * Since: 1.1.13
+ */
+G_CONST_RETURN gchar* webkit_web_navigation_action_get_target_frame(WebKitWebNavigationAction* navigationAction)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_NAVIGATION_ACTION(navigationAction), NULL);
+
+ return navigationAction->priv->targetFrame;
+}
+
+static void webkit_web_navigation_action_set_target_frame(WebKitWebNavigationAction* navigationAction, const gchar* targetFrame)
+{
+ if (!g_strcmp0(navigationAction->priv->targetFrame, targetFrame))
+ return;
+
+ g_free(navigationAction->priv->targetFrame);
+ navigationAction->priv->targetFrame = g_strdup(targetFrame);
+ g_object_notify(G_OBJECT(navigationAction), "target-frame");
}
diff --git a/WebKit/gtk/webkit/webkitwebnavigationaction.h b/WebKit/gtk/webkit/webkitwebnavigationaction.h
index d83e7a0..c437c50 100644
--- a/WebKit/gtk/webkit/webkitwebnavigationaction.h
+++ b/WebKit/gtk/webkit/webkitwebnavigationaction.h
@@ -88,6 +88,9 @@ webkit_web_navigation_action_get_button(WebKitWebNavigationAction* navigationAct
WEBKIT_API gint
webkit_web_navigation_action_get_modifier_state(WebKitWebNavigationAction* navigationAction);
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_web_navigation_action_get_target_frame(WebKitWebNavigationAction* navigationAction);
+
G_END_DECLS
#endif
diff --git a/WebKit/gtk/webkit/webkitwebpolicydecision.cpp b/WebKit/gtk/webkit/webkitwebpolicydecision.cpp
index db4d10f..b2bab6b 100644
--- a/WebKit/gtk/webkit/webkitwebpolicydecision.cpp
+++ b/WebKit/gtk/webkit/webkitwebpolicydecision.cpp
@@ -27,7 +27,15 @@
using namespace WebKit;
using namespace WebCore;
-extern "C" {
+/**
+ * SECTION:webkitwebpolicydecision
+ * @short_description: Liason between WebKit and the application regarding asynchronous policy decisions
+ *
+ * #WebKitWebPolicyDecision objects are given to the application on
+ * signal emissions that deal with policy decisions, such as if a new
+ * window should be opened, or if a given navigation should be
+ * allowed. The application uses it to tell the engine what to do.
+ */
G_DEFINE_TYPE(WebKitWebPolicyDecision, webkit_web_policy_decision, G_TYPE_OBJECT);
@@ -125,5 +133,3 @@ void webkit_web_policy_decision_cancel(WebKitWebPolicyDecision* decision)
priv->isCancelled = TRUE;
}
-
-}
diff --git a/WebKit/gtk/webkit/webkitwebsettings.cpp b/WebKit/gtk/webkit/webkitwebsettings.cpp
index d31ec2f..061d3e2 100644
--- a/WebKit/gtk/webkit/webkitwebsettings.cpp
+++ b/WebKit/gtk/webkit/webkitwebsettings.cpp
@@ -3,6 +3,7 @@
* Copyright (C) 2008 Nuanti Ltd.
* Copyright (C) 2008 Collabora Ltd.
* Copyright (C) 2008 Holger Hans Peter Freyther
+ * Copyright (C) 2009 Jan Michael Alonzo
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -21,12 +22,21 @@
*/
#include "config.h"
-
#include "webkitwebsettings.h"
+
#include "webkitprivate.h"
+#include "webkitversion.h"
+#include "CString.h"
#include "FileSystem.h"
#include "PluginDatabase.h"
+#include "Language.h"
+#include "PlatformString.h"
+
+#include <glib/gi18n-lib.h>
+#if PLATFORM(UNIX)
+#include <sys/utsname.h>
+#endif
/**
* SECTION:webkitwebsettings
@@ -48,8 +58,6 @@
using namespace WebCore;
-extern "C" {
-
G_DEFINE_TYPE(WebKitWebSettings, webkit_web_settings, G_TYPE_OBJECT)
struct _WebKitWebSettingsPrivate {
@@ -75,6 +83,16 @@ struct _WebKitWebSettingsPrivate {
gfloat zoom_step;
gboolean enable_developer_extras;
gboolean enable_private_browsing;
+ gboolean enable_spell_checking;
+ gchar* spell_checking_languages;
+ GSList* spell_checking_languages_list;
+ gboolean enable_caret_browsing;
+ gboolean enable_html5_database;
+ gboolean enable_html5_local_storage;
+ gboolean enable_xss_auditor;
+ gchar* user_agent;
+ gboolean javascript_can_open_windows_automatically;
+ gboolean enable_offline_web_application_cache;
};
#define WEBKIT_WEB_SETTINGS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_SETTINGS, WebKitWebSettingsPrivate))
@@ -103,9 +121,75 @@ enum {
PROP_USER_STYLESHEET_URI,
PROP_ZOOM_STEP,
PROP_ENABLE_DEVELOPER_EXTRAS,
- PROP_ENABLE_PRIVATE_BROWSING
+ PROP_ENABLE_PRIVATE_BROWSING,
+ PROP_ENABLE_SPELL_CHECKING,
+ PROP_SPELL_CHECKING_LANGUAGES,
+ PROP_ENABLE_CARET_BROWSING,
+ PROP_ENABLE_HTML5_DATABASE,
+ PROP_ENABLE_HTML5_LOCAL_STORAGE,
+ PROP_ENABLE_XSS_AUDITOR,
+ PROP_USER_AGENT,
+ PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY,
+ PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE
};
+// Create a default user agent string
+// This is a liberal interpretation of http://www.mozilla.org/build/revised-user-agent-strings.html
+// See also http://developer.apple.com/internet/safari/faq.html#anchor2
+static String webkit_get_user_agent()
+{
+ gchar* platform;
+ gchar* osVersion;
+
+#if PLATFORM(X11)
+ platform = g_strdup("X11");
+#elif PLATFORM(WIN_OS)
+ platform = g_strdup("Windows");
+#elif PLATFORM(MAC)
+ platform = g_strdup("Macintosh");
+#elif defined(GDK_WINDOWING_DIRECTFB)
+ platform = g_strdup("DirectFB");
+#else
+ platform = g_strdup("Unknown");
+#endif
+
+ // FIXME: platform/version detection can be shared.
+#if PLATFORM(DARWIN)
+
+#if PLATFORM(X86)
+ osVersion = g_strdup("Intel Mac OS X");
+#else
+ osVersion = g_strdup("PPC Mac OS X");
+#endif
+
+#elif PLATFORM(UNIX)
+ struct utsname name;
+ if (uname(&name) != -1)
+ osVersion = g_strdup_printf("%s %s", name.sysname, name.machine);
+ else
+ osVersion = g_strdup("Unknown");
+
+#elif PLATFORM(WIN_OS)
+ // FIXME: Compute the Windows version
+ osVersion = g_strdup("Windows");
+
+#else
+ osVersion = g_strdup("Unknown");
+#endif
+
+ // We mention Safari since many broken sites check for it (OmniWeb does this too)
+ // We re-use the WebKit version, though it doesn't seem to matter much in practice
+
+ DEFINE_STATIC_LOCAL(const String, uaVersion, (String::format("%d.%d+", WEBKIT_USER_AGENT_MAJOR_VERSION, WEBKIT_USER_AGENT_MINOR_VERSION)));
+ DEFINE_STATIC_LOCAL(const String, staticUA, (String::format("Mozilla/5.0 (%s; U; %s; %s) AppleWebKit/%s (KHTML, like Gecko) Safari/%s",
+ platform, osVersion, defaultLanguage().utf8().data(), uaVersion.utf8().data(), uaVersion.utf8().data())));
+
+ g_free(osVersion);
+ g_free(platform);
+
+ return staticUA;
+}
+
static void webkit_web_settings_finalize(GObject* object);
static void webkit_web_settings_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec* pspec);
@@ -119,14 +203,16 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
gobject_class->set_property = webkit_web_settings_set_property;
gobject_class->get_property = webkit_web_settings_get_property;
+ webkit_init();
+
GParamFlags flags = (GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT);
g_object_class_install_property(gobject_class,
PROP_DEFAULT_ENCODING,
g_param_spec_string(
"default-encoding",
- "Default Encoding",
- "The default encoding used to display text.",
+ _("Default Encoding"),
+ _("The default encoding used to display text."),
"iso-8859-1",
flags));
@@ -134,8 +220,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_CURSIVE_FONT_FAMILY,
g_param_spec_string(
"cursive-font-family",
- "Cursive Font Family",
- "The default Cursive font family used to display text.",
+ _("Cursive Font Family"),
+ _("The default Cursive font family used to display text."),
"serif",
flags));
@@ -143,8 +229,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_DEFAULT_FONT_FAMILY,
g_param_spec_string(
"default-font-family",
- "Default Font Family",
- "The default font family used to display text.",
+ _("Default Font Family"),
+ _("The default font family used to display text."),
"sans-serif",
flags));
@@ -152,8 +238,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_FANTASY_FONT_FAMILY,
g_param_spec_string(
"fantasy-font-family",
- "Fantasy Font Family",
- "The default Fantasy font family used to display text.",
+ _("Fantasy Font Family"),
+ _("The default Fantasy font family used to display text."),
"serif",
flags));
@@ -161,8 +247,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_MONOSPACE_FONT_FAMILY,
g_param_spec_string(
"monospace-font-family",
- "Monospace Font Family",
- "The default font family used to display monospace text.",
+ _("Monospace Font Family"),
+ _("The default font family used to display monospace text."),
"monospace",
flags));
@@ -170,8 +256,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_SANS_SERIF_FONT_FAMILY,
g_param_spec_string(
"sans-serif-font-family",
- "Sans Serif Font Family",
- "The default Sans Serif font family used to display text.",
+ _("Sans Serif Font Family"),
+ _("The default Sans Serif font family used to display text."),
"sans-serif",
flags));
@@ -179,8 +265,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_SERIF_FONT_FAMILY,
g_param_spec_string(
"serif-font-family",
- "Serif Font Family",
- "The default Serif font family used to display text.",
+ _("Serif Font Family"),
+ _("The default Serif font family used to display text."),
"serif",
flags));
@@ -188,8 +274,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_DEFAULT_FONT_SIZE,
g_param_spec_int(
"default-font-size",
- "Default Font Size",
- "The default font size used to display text.",
+ _("Default Font Size"),
+ _("The default font size used to display text."),
5, G_MAXINT, 12,
flags));
@@ -197,8 +283,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_DEFAULT_MONOSPACE_FONT_SIZE,
g_param_spec_int(
"default-monospace-font-size",
- "Default Monospace Font Size",
- "The default font size used to display monospace text.",
+ _("Default Monospace Font Size"),
+ _("The default font size used to display monospace text."),
5, G_MAXINT, 10,
flags));
@@ -206,8 +292,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_MINIMUM_FONT_SIZE,
g_param_spec_int(
"minimum-font-size",
- "Minimum Font Size",
- "The minimum font size used to display text.",
+ _("Minimum Font Size"),
+ _("The minimum font size used to display text."),
1, G_MAXINT, 5,
flags));
@@ -215,8 +301,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_MINIMUM_LOGICAL_FONT_SIZE,
g_param_spec_int(
"minimum-logical-font-size",
- "Minimum Logical Font Size",
- "The minimum logical font size used to display text.",
+ _("Minimum Logical Font Size"),
+ _("The minimum logical font size used to display text."),
1, G_MAXINT, 5,
flags));
@@ -235,8 +321,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_ENFORCE_96_DPI,
g_param_spec_boolean(
"enforce-96-dpi",
- "Enforce 96 DPI",
- "Enforce a resolution of 96 DPI",
+ _("Enforce 96 DPI"),
+ _("Enforce a resolution of 96 DPI"),
FALSE,
flags));
@@ -244,8 +330,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_AUTO_LOAD_IMAGES,
g_param_spec_boolean(
"auto-load-images",
- "Auto Load Images",
- "Load images automatically.",
+ _("Auto Load Images"),
+ _("Load images automatically."),
TRUE,
flags));
@@ -253,8 +339,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_AUTO_SHRINK_IMAGES,
g_param_spec_boolean(
"auto-shrink-images",
- "Auto Shrink Images",
- "Automatically shrink standalone images to fit.",
+ _("Auto Shrink Images"),
+ _("Automatically shrink standalone images to fit."),
TRUE,
flags));
@@ -262,8 +348,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_PRINT_BACKGROUNDS,
g_param_spec_boolean(
"print-backgrounds",
- "Print Backgrounds",
- "Whether background images should be printed.",
+ _("Print Backgrounds"),
+ _("Whether background images should be printed."),
TRUE,
flags));
@@ -271,8 +357,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_ENABLE_SCRIPTS,
g_param_spec_boolean(
"enable-scripts",
- "Enable Scripts",
- "Enable embedded scripting languages.",
+ _("Enable Scripts"),
+ _("Enable embedded scripting languages."),
TRUE,
flags));
@@ -280,8 +366,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_ENABLE_PLUGINS,
g_param_spec_boolean(
"enable-plugins",
- "Enable Plugins",
- "Enable embedded plugin objects.",
+ _("Enable Plugins"),
+ _("Enable embedded plugin objects."),
TRUE,
flags));
@@ -289,16 +375,16 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_RESIZABLE_TEXT_AREAS,
g_param_spec_boolean(
"resizable-text-areas",
- "Resizable Text Areas",
- "Whether text areas are resizable.",
+ _("Resizable Text Areas"),
+ _("Whether text areas are resizable."),
TRUE,
flags));
g_object_class_install_property(gobject_class,
PROP_USER_STYLESHEET_URI,
g_param_spec_string("user-stylesheet-uri",
- "User Stylesheet URI",
- "The URI of a stylesheet that is applied to every page.",
+ _("User Stylesheet URI"),
+ _("The URI of a stylesheet that is applied to every page."),
0,
flags));
@@ -313,8 +399,8 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_ZOOM_STEP,
g_param_spec_float(
"zoom-step",
- "Zoom Stepping Value",
- "The value by which the zoom level is changed when zooming in or out.",
+ _("Zoom Stepping Value"),
+ _("The value by which the zoom level is changed when zooming in or out."),
0.0f, G_MAXFLOAT, 0.1f,
flags));
@@ -332,15 +418,20 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_ENABLE_DEVELOPER_EXTRAS,
g_param_spec_boolean(
"enable-developer-extras",
- "Enable Developer Extras",
- "Enables special extensions that help developers",
+ _("Enable Developer Extras"),
+ _("Enables special extensions that help developers"),
FALSE,
flags));
/**
* WebKitWebSettings:enable-private-browsing:
*
- * Whether to enable private browsing mode.
+ * Whether to enable private browsing mode. Private browsing mode prevents
+ * WebKit from updating the global history and storing any session
+ * information e.g., on-disk cache, as well as suppressing any messages
+ * from being printed into the (javascript) console.
+ *
+ * This is currently experimental for WebKitGtk.
*
* Since 1.1.2
*/
@@ -348,11 +439,166 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
PROP_ENABLE_PRIVATE_BROWSING,
g_param_spec_boolean(
"enable-private-browsing",
- "Enable Private Browsing",
- "Enables private browsing mode",
+ _("Enable Private Browsing"),
+ _("Enables private browsing mode"),
FALSE,
flags));
+ /**
+ * WebKitWebSettings:enable-spell-checking:
+ *
+ * Whether to enable spell checking while typing.
+ *
+ * Since 1.1.6
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_ENABLE_SPELL_CHECKING,
+ g_param_spec_boolean(
+ "enable-spell-checking",
+ _("Enable Spell Checking"),
+ _("Enables spell checking while typing"),
+ FALSE,
+ flags));
+
+ /**
+ * WebKitWebSettings:spell-checking-languages:
+ *
+ * The languages to be used for spell checking, separated by commas.
+ *
+ * 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.
+ * For instance, sv_FI for Swedish as written in Finland or pt_BR
+ * for Portuguese as written in Brazil.
+ *
+ * If no value is specified then the value returned by
+ * gtk_get_default_language will be used.
+ *
+ * Since 1.1.6
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_SPELL_CHECKING_LANGUAGES,
+ g_param_spec_string(
+ "spell-checking-languages",
+ _("Languages to use for spell checking"),
+ _("Comma separated list of languages to use for spell checking"),
+ 0,
+ flags));
+
+ /**
+ * WebKitWebSettings:enable-caret-browsing:
+ *
+ * Whether to enable caret browsing mode.
+ *
+ * Since 1.1.6
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_ENABLE_CARET_BROWSING,
+ g_param_spec_boolean("enable-caret-browsing",
+ _("Enable Caret Browsing"),
+ _("Whether to enable accesibility enhanced keyboard navigation"),
+ FALSE,
+ flags));
+ /**
+ * WebKitWebSettings:enable-html5-database:
+ *
+ * Whether to enable HTML5 client-side SQL database support. Client-side
+ * SQL database allows web pages to store structured data and be able to
+ * use SQL to manipulate that data asynchronously.
+ *
+ * Since 1.1.8
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_ENABLE_HTML5_DATABASE,
+ g_param_spec_boolean("enable-html5-database",
+ _("Enable HTML5 Database"),
+ _("Whether to enable HTML5 database support"),
+ TRUE,
+ flags));
+
+ /**
+ * WebKitWebSettings:enable-html5-local-storage:
+ *
+ * Whether to enable HTML5 localStorage support. localStorage provides
+ * simple synchronous storage access.
+ *
+ * Since 1.1.8
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_ENABLE_HTML5_LOCAL_STORAGE,
+ g_param_spec_boolean("enable-html5-local-storage",
+ _("Enable HTML5 Local Storage"),
+ _("Whether to enable HTML5 Local Storage support"),
+ TRUE,
+ flags));
+ /**
+ * WebKitWebSettings:enable-xss-auditor
+ *
+ * Whether to enable the XSS Auditor. This feature filters some kinds of
+ * reflective XSS attacks on vulnerable web sites.
+ *
+ * Since 1.1.11
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_ENABLE_XSS_AUDITOR,
+ g_param_spec_boolean("enable-xss-auditor",
+ _("Enable XSS Auditor"),
+ _("Whether to enable teh XSS auditor"),
+ TRUE,
+ flags));
+
+ /**
+ * WebKitWebSettings:user-agent:
+ *
+ * The User-Agent string used by WebKitGtk.
+ *
+ * This will return a default User-Agent string if a custom string wasn't
+ * provided by the application. Setting this property to a NULL value or
+ * an empty string will result in the User-Agent string being reset to the
+ * default value.
+ *
+ * Since: 1.1.11
+ */
+ g_object_class_install_property(gobject_class, PROP_USER_AGENT,
+ g_param_spec_string("user-agent",
+ _("User Agent"),
+ _("The User-Agent string used by WebKitGtk"),
+ webkit_get_user_agent().utf8().data(),
+ flags));
+
+ /**
+ * WebKitWebSettings:javascript-can-open-windows-automatically
+ *
+ * Whether JavaScript can open popup windows automatically without user
+ * intervention.
+ *
+ * Since 1.1.11
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY,
+ g_param_spec_boolean("javascript-can-open-windows-automatically",
+ _("JavaScript can open windows automatically"),
+ _("Whether JavaScript can open windows automatically"),
+ FALSE,
+ flags));
+ /**
+ * WebKitWebSettings:enable-offline-web-application-cache
+ *
+ * Whether to enable HTML5 offline web application cache support. Offline
+ * Web Application Cache ensures web applications are available even when
+ * the user is not connected to the network.
+ *
+ * Since 1.1.13
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE,
+ g_param_spec_boolean("enable-offline-web-application-cache",
+ _("Enable offline web application cache"),
+ _("Whether to enable offline web application cache"),
+ TRUE,
+ flags));
+
+
+
g_type_class_add_private(klass, sizeof(WebKitWebSettingsPrivate));
}
@@ -361,6 +607,18 @@ static void webkit_web_settings_init(WebKitWebSettings* web_settings)
web_settings->priv = WEBKIT_WEB_SETTINGS_GET_PRIVATE(web_settings);
}
+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);
+
+ enchant_broker_free(language->config);
+ }
+ g_slice_free(SpellLanguage, language);
+}
+
static void webkit_web_settings_finalize(GObject* object)
{
WebKitWebSettings* web_settings = WEBKIT_WEB_SETTINGS(object);
@@ -374,6 +632,12 @@ static void webkit_web_settings_finalize(GObject* object)
g_free(priv->sans_serif_font_family);
g_free(priv->serif_font_family);
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_free(priv->user_agent);
G_OBJECT_CLASS(webkit_web_settings_parent_class)->finalize(object);
}
@@ -382,6 +646,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;
+ SpellLanguage* lang;
+ GSList* spellLanguages = NULL;
switch(prop_id) {
case PROP_DEFAULT_ENCODING:
@@ -458,6 +724,61 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con
case PROP_ENABLE_PRIVATE_BROWSING:
priv->enable_private_browsing = g_value_get_boolean(value);
break;
+ case PROP_ENABLE_CARET_BROWSING:
+ priv->enable_caret_browsing = g_value_get_boolean(value);
+ break;
+ case PROP_ENABLE_HTML5_DATABASE:
+ priv->enable_html5_database = g_value_get_boolean(value);
+ break;
+ case PROP_ENABLE_HTML5_LOCAL_STORAGE:
+ priv->enable_html5_local_storage = g_value_get_boolean(value);
+ break;
+ case PROP_ENABLE_SPELL_CHECKING:
+ priv->enable_spell_checking = g_value_get_boolean(value);
+ break;
+ case PROP_SPELL_CHECKING_LANGUAGES:
+ priv->spell_checking_languages = g_strdup(g_value_get_string(value));
+
+ if (priv->spell_checking_languages) {
+ char** langs = g_strsplit(priv->spell_checking_languages, ",", -1);
+ for (int i = 0; langs[i]; 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);
+ }
+
+ g_strfreev(langs);
+ } else {
+ const char* language = pango_language_to_string(gtk_get_default_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);
+ }
+ 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;
+ break;
+ case PROP_ENABLE_XSS_AUDITOR:
+ priv->enable_xss_auditor = 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)))
+ priv->user_agent = g_strdup(webkit_get_user_agent().utf8().data());
+ else
+ priv->user_agent = g_strdup(g_value_get_string(value));
+ break;
+ case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY:
+ priv->javascript_can_open_windows_automatically = g_value_get_boolean(value);
+ break;
+ case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
+ priv->enable_offline_web_application_cache = g_value_get_boolean(value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@@ -536,6 +857,33 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa
case PROP_ENABLE_PRIVATE_BROWSING:
g_value_set_boolean(value, priv->enable_private_browsing);
break;
+ case PROP_ENABLE_CARET_BROWSING:
+ g_value_set_boolean(value, priv->enable_caret_browsing);
+ break;
+ case PROP_ENABLE_HTML5_DATABASE:
+ g_value_set_boolean(value, priv->enable_html5_database);
+ break;
+ case PROP_ENABLE_HTML5_LOCAL_STORAGE:
+ g_value_set_boolean(value, priv->enable_html5_local_storage);
+ break;
+ case PROP_ENABLE_SPELL_CHECKING:
+ g_value_set_boolean(value, priv->enable_spell_checking);
+ break;
+ case PROP_SPELL_CHECKING_LANGUAGES:
+ g_value_set_string(value, priv->spell_checking_languages);
+ break;
+ case PROP_ENABLE_XSS_AUDITOR:
+ g_value_set_boolean(value, priv->enable_xss_auditor);
+ break;
+ case PROP_USER_AGENT:
+ g_value_set_string(value, priv->user_agent);
+ break;
+ case PROP_JAVASCRIPT_CAN_OPEN_WINDOWS_AUTOMATICALLY:
+ g_value_set_boolean(value, priv->javascript_can_open_windows_automatically);
+ break;
+ case PROP_ENABLE_OFFLINE_WEB_APPLICATION_CACHE:
+ g_value_set_boolean(value, priv->enable_offline_web_application_cache);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
@@ -588,6 +936,16 @@ WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* web_settings)
"zoom-step", priv->zoom_step,
"enable-developer-extras", priv->enable_developer_extras,
"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,
+ "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,
NULL));
return copy;
@@ -609,4 +967,40 @@ void webkit_web_settings_add_extra_plugin_directory(WebKitWebView* webView, cons
PluginDatabase::installedPlugins()->addExtraPluginDirectory(filenameToString(directory));
}
+/**
+ * webkit_web_settings_get_spell_languages:
+ * @web_view: a #WebKitWebView
+ *
+ * Internal use only. Retrieves a GSList of SpellLanguages from the
+ * #WebKitWebSettings of @web_view.
+ *
+ * Since: 1.1.6
+ */
+GSList* webkit_web_settings_get_spell_languages(WebKitWebView *web_view)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(web_view), 0);
+
+ WebKitWebSettings* settings = webkit_web_view_get_settings(web_view);
+ WebKitWebSettingsPrivate* priv = settings->priv;
+ GSList* list = priv->spell_checking_languages_list;
+
+ return list;
+}
+
+/**
+ * webkit_web_settings_get_user_agent:
+ * @web_settings: a #WebKitWebSettings
+ *
+ * Returns the User-Agent string currently used by the web view(s) associated
+ * with the @web_settings.
+ *
+ * Since: 1.1.11
+ */
+G_CONST_RETURN gchar* webkit_web_settings_get_user_agent(WebKitWebSettings* webSettings)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_SETTINGS(webSettings), NULL);
+
+ WebKitWebSettingsPrivate* priv = webSettings->priv;
+
+ return priv->user_agent;
}
diff --git a/WebKit/gtk/webkit/webkitwebsettings.h b/WebKit/gtk/webkit/webkitwebsettings.h
index 5d25fee..9eac321 100644
--- a/WebKit/gtk/webkit/webkitwebsettings.h
+++ b/WebKit/gtk/webkit/webkitwebsettings.h
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2008 Christian Dywan <christian@imendio.com>
+ * Copyright (C) 2009 Jan Michael Alonzo <jmalonzo@gmail.com
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -53,13 +54,16 @@ struct _WebKitWebSettingsClass {
};
WEBKIT_API GType
-webkit_web_settings_get_type (void);
+webkit_web_settings_get_type (void);
WEBKIT_API WebKitWebSettings *
-webkit_web_settings_new (void);
+webkit_web_settings_new (void);
WEBKIT_API WebKitWebSettings *
-webkit_web_settings_copy (WebKitWebSettings *web_settings);
+webkit_web_settings_copy (WebKitWebSettings *web_settings);
+
+WEBKIT_API G_CONST_RETURN gchar *
+webkit_web_settings_get_user_agent (WebKitWebSettings *web_settings);
G_END_DECLS
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index d6a0d54..ec59e60 100644
--- a/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/WebKit/gtk/webkit/webkitwebview.cpp
@@ -55,6 +55,7 @@
#include "FrameLoaderTypes.h"
#include "HitTestRequest.h"
#include "HitTestResult.h"
+#include <glib/gi18n-lib.h>
#include "GraphicsContext.h"
#include "InspectorClientGtk.h"
#include "FrameLoader.h"
@@ -62,6 +63,7 @@
#include "PasteboardHelper.h"
#include "PlatformKeyboardEvent.h"
#include "PlatformWheelEvent.h"
+#include "ProgressTracker.h"
#include "ResourceHandle.h"
#include "ScriptValue.h"
#include "Scrollbar.h"
@@ -71,10 +73,10 @@
/**
* SECTION:webkitwebview
- * @short_description: The central class of the WebKit/Gtk+ API
+ * @short_description: The central class of the WebKitGTK+ API
* @see_also: #WebKitWebSettings, #WebKitWebFrame
*
- * #WebKitWebView is the central class of the WebKit/Gtk+ API. It is a
+ * #WebKitWebView is the central class of the WebKitGTK+ API. It is a
* #GtkWidget implementing the scrolling interface which means you can
* embed in a #GtkScrolledWindow. It is responsible for managing the
* drawing of the content, forwarding of events. You can load any URI
@@ -107,8 +109,6 @@ static const double defaultDPI = 96.0;
using namespace WebKit;
using namespace WebCore;
-extern "C" {
-
enum {
/* normal signals */
NAVIGATION_REQUESTED,
@@ -121,6 +121,7 @@ enum {
LOAD_STARTED,
LOAD_COMMITTED,
LOAD_PROGRESS_CHANGED,
+ LOAD_ERROR,
LOAD_FINISHED,
TITLE_CHANGED,
HOVERING_OVER_LINK,
@@ -137,6 +138,10 @@ enum {
PASTE_CLIPBOARD,
CUT_CLIPBOARD,
DOWNLOAD_REQUESTED,
+ MOVE_CURSOR,
+ PRINT_REQUESTED,
+ PLUGIN_WIDGET,
+ CLOSE_WEB_VIEW,
LAST_SIGNAL
};
@@ -154,6 +159,8 @@ enum {
PROP_TRANSPARENT,
PROP_ZOOM_LEVEL,
PROP_FULL_CONTENT_ZOOM,
+ PROP_LOAD_STATUS,
+ PROP_PROGRESS,
PROP_ENCODING,
PROP_CUSTOM_ENCODING
};
@@ -165,13 +172,6 @@ G_DEFINE_TYPE(WebKitWebView, webkit_web_view, GTK_TYPE_CONTAINER)
static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GParamSpec* pspec, WebKitWebView* webView);
static void webkit_web_view_set_window_features(WebKitWebView* webView, WebKitWebWindowFeatures* webWindowFeatures);
-static void webkit_web_view_context_menu_position_func(GtkMenu*, gint* x, gint* y, gboolean* pushIn, WebKitWebViewPrivate* data)
-{
- *pushIn = FALSE;
- *x = data->lastPopupXPosition;
- *y = data->lastPopupYPosition;
-}
-
static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webView, const PlatformMouseEvent& event)
{
Page* page = core(webView);
@@ -206,7 +206,7 @@ static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webVie
priv->lastPopupXPosition = event.globalX();
priv->lastPopupYPosition = event.globalY();
gtk_menu_popup(menu, NULL, NULL,
- reinterpret_cast<GtkMenuPositionFunc>(webkit_web_view_context_menu_position_func),
+ NULL,
priv, event.button() + 1, gtk_get_current_event_time());
return TRUE;
}
@@ -290,14 +290,12 @@ static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue*
case PROP_URI:
g_value_set_string(value, webkit_web_view_get_uri(webView));
break;
-#if GTK_CHECK_VERSION(2,10,0)
case PROP_COPY_TARGET_LIST:
g_value_set_boxed(value, webkit_web_view_get_copy_target_list(webView));
break;
case PROP_PASTE_TARGET_LIST:
g_value_set_boxed(value, webkit_web_view_get_paste_target_list(webView));
break;
-#endif
case PROP_EDITABLE:
g_value_set_boolean(value, webkit_web_view_get_editable(webView));
break;
@@ -325,6 +323,12 @@ static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue*
case PROP_CUSTOM_ENCODING:
g_value_set_string(value, webkit_web_view_get_custom_encoding(webView));
break;
+ case PROP_LOAD_STATUS:
+ g_value_set_enum(value, webkit_web_view_get_load_status(webView));
+ break;
+ case PROP_PROGRESS:
+ g_value_set_double(value, webkit_web_view_get_progress(webView));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
@@ -437,48 +441,6 @@ static gboolean webkit_web_view_key_press_event(GtkWidget* widget, GdkEventKey*
if (frame->eventHandler()->keyEvent(keyboardEvent))
return TRUE;
- FrameView* view = frame->view();
- SelectionController::EAlteration alteration;
- if (event->state & GDK_SHIFT_MASK)
- alteration = SelectionController::EXTEND;
- else
- alteration = SelectionController::MOVE;
-
- // TODO: We probably want to use GTK+ key bindings here and perhaps take an
- // approach more like the Win and Mac ports for key handling.
- switch (event->keyval) {
- case GDK_Down:
- view->scrollBy(IntSize(0, cScrollbarPixelsPerLineStep));
- return TRUE;
- case GDK_Up:
- view->scrollBy(IntSize(0, -cScrollbarPixelsPerLineStep));
- return TRUE;
- case GDK_Right:
- view->scrollBy(IntSize(cScrollbarPixelsPerLineStep, 0));
- return TRUE;
- case GDK_Left:
- view->scrollBy(IntSize(-cScrollbarPixelsPerLineStep, 0));
- return TRUE;
- case GDK_space:
- if ((event->state & GDK_SHIFT_MASK) == GDK_SHIFT_MASK)
- view->scrollBy(IntSize(0, -view->visibleHeight()));
- else
- view->scrollBy(IntSize(0, view->visibleHeight()));
- return TRUE;
- case GDK_Page_Up:
- view->scrollBy(IntSize(0, -view->visibleHeight()));
- return TRUE;
- case GDK_Page_Down:
- view->scrollBy(IntSize(0, view->visibleHeight()));
- return TRUE;
- case GDK_Home:
- view->scrollBy(IntSize(0, -view->contentsHeight()));
- return TRUE;
- case GDK_End:
- view->scrollBy(IntSize(0, view->contentsHeight()));
- return TRUE;
- }
-
/* Chain up to our parent class for binding activation */
return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->key_press_event(widget, event);
}
@@ -514,7 +476,23 @@ static gboolean webkit_web_view_button_press_event(GtkWidget* widget, GdkEventBu
if (!frame->view())
return FALSE;
- return frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event));
+ gboolean result = frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event));
+
+#if PLATFORM(X11)
+ /* Copy selection to the X11 selection clipboard */
+ if (event->button == 2) {
+ bool primary = webView->priv->usePrimaryForPaste;
+ webView->priv->usePrimaryForPaste = true;
+
+ Editor* editor = webView->priv->corePage->focusController()->focusedOrMainFrame()->editor();
+ result = result || editor->canPaste() || editor->canDHTMLPaste();
+ editor->paste();
+
+ webView->priv->usePrimaryForPaste = primary;
+ }
+#endif
+
+ return result;
}
static gboolean webkit_web_view_button_release_event(GtkWidget* widget, GdkEventButton* event)
@@ -567,6 +545,21 @@ static gboolean webkit_web_view_scroll_event(GtkWidget* widget, GdkEventScroll*
return frame->eventHandler()->handleWheelEvent(wheelEvent);
}
+static void webkit_web_view_size_request(GtkWidget* widget, GtkRequisition* requisition)
+{
+ WebKitWebView* web_view = WEBKIT_WEB_VIEW(widget);
+ Frame* coreFrame = core(webkit_web_view_get_main_frame(web_view));
+ if (!coreFrame)
+ return;
+
+ FrameView* view = coreFrame->view();
+ if (!view)
+ return;
+
+ requisition->width = view->contentsWidth();
+ requisition->height = view->contentsHeight();
+}
+
static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allocation)
{
GTK_WIDGET_CLASS(webkit_web_view_parent_class)->size_allocate(widget,allocation);
@@ -582,6 +575,21 @@ static void webkit_web_view_size_allocate(GtkWidget* widget, GtkAllocation* allo
frame->view()->adjustViewSize();
}
+static void webkit_web_view_grab_focus(GtkWidget* widget)
+{
+ if (GTK_WIDGET_IS_SENSITIVE(widget)) {
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
+ FocusController* focusController = core(webView)->focusController();
+
+ if (focusController->focusedFrame())
+ focusController->setFocused(true);
+ else
+ focusController->setFocusedFrame(core(webView)->mainFrame());
+ }
+
+ return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->grab_focus(widget);
+}
+
static gboolean webkit_web_view_focus_in_event(GtkWidget* widget, GdkEventFocus* event)
{
// TODO: Improve focus handling as suggested in
@@ -589,9 +597,14 @@ static gboolean webkit_web_view_focus_in_event(GtkWidget* widget, GdkEventFocus*
GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
if (GTK_WIDGET_TOPLEVEL(toplevel) && gtk_window_has_toplevel_focus(GTK_WINDOW(toplevel))) {
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
+ FocusController* focusController = core(webView)->focusController();
- Frame* frame = core(webView)->mainFrame();
- core(webView)->focusController()->setActive(frame);
+ focusController->setActive(true);
+
+ if (focusController->focusedFrame())
+ focusController->setFocused(true);
+ else
+ focusController->setFocusedFrame(core(webView)->mainFrame());
}
return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_in_event(widget, event);
}
@@ -601,6 +614,7 @@ 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);
return GTK_WIDGET_CLASS(webkit_web_view_parent_class)->focus_out_event(widget, event);
}
@@ -713,6 +727,11 @@ static gboolean webkit_web_view_real_web_view_ready(WebKitWebView*)
return FALSE;
}
+static gboolean webkit_web_view_real_close_web_view(WebKitWebView*)
+{
+ return FALSE;
+}
+
static WebKitNavigationResponse webkit_web_view_real_navigation_requested(WebKitWebView*, WebKitWebFrame*, WebKitNetworkRequest*)
{
return WEBKIT_NAVIGATION_RESPONSE_ACCEPT;
@@ -847,6 +866,59 @@ static void webkit_web_view_real_copy_clipboard(WebKitWebView* webView)
frame->editor()->command("Copy").execute();
}
+static gboolean webkit_web_view_real_move_cursor (WebKitWebView* webView, GtkMovementStep step, gint count)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW (webView), FALSE);
+ g_return_val_if_fail(step == GTK_MOVEMENT_VISUAL_POSITIONS ||
+ step == GTK_MOVEMENT_DISPLAY_LINES ||
+ step == GTK_MOVEMENT_PAGES ||
+ step == GTK_MOVEMENT_BUFFER_ENDS, FALSE);
+ g_return_val_if_fail(count == 1 || count == -1, FALSE);
+
+ ScrollDirection direction;
+ ScrollGranularity granularity;
+
+ switch (step) {
+ case GTK_MOVEMENT_DISPLAY_LINES:
+ granularity = ScrollByLine;
+ if (count == 1)
+ direction = ScrollDown;
+ else
+ direction = ScrollUp;
+ break;
+ case GTK_MOVEMENT_VISUAL_POSITIONS:
+ granularity = ScrollByLine;
+ if (count == 1)
+ direction = ScrollRight;
+ else
+ direction = ScrollLeft;
+ break;
+ case GTK_MOVEMENT_PAGES:
+ granularity = ScrollByPage;
+ if (count == 1)
+ direction = ScrollDown;
+ else
+ direction = ScrollUp;
+ break;
+ case GTK_MOVEMENT_BUFFER_ENDS:
+ granularity = ScrollByDocument;
+ if (count == 1)
+ direction = ScrollDown;
+ else
+ direction = ScrollUp;
+ break;
+ default:
+ g_assert_not_reached();
+ return false;
+ }
+
+ Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
+ if (!frame->eventHandler()->scrollOverflow(direction, granularity))
+ frame->view()->scroll(direction, granularity);
+
+ return true;
+}
+
static void webkit_web_view_real_paste_clipboard(WebKitWebView* webView)
{
Frame* frame = core(webView)->focusController()->focusedOrMainFrame();
@@ -860,14 +932,6 @@ static void webkit_web_view_dispose(GObject* object)
priv->disposing = TRUE;
- if (priv->corePage) {
- webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object));
-
- core(priv->mainFrame)->loader()->detachChildren();
- delete priv->corePage;
- priv->corePage = NULL;
- }
-
if (priv->horizontalAdjustment) {
g_object_unref(priv->horizontalAdjustment);
priv->horizontalAdjustment = NULL;
@@ -881,7 +945,17 @@ static void webkit_web_view_dispose(GObject* object)
if (priv->backForwardList) {
g_object_unref(priv->backForwardList);
priv->backForwardList = NULL;
+ }
+ if (priv->corePage) {
+ webkit_web_view_stop_loading(WEBKIT_WEB_VIEW(object));
+
+ core(priv->mainFrame)->loader()->detachFromParent();
+ delete priv->corePage;
+ priv->corePage = NULL;
+ }
+
+ if (priv->webSettings) {
g_signal_handlers_disconnect_by_func(priv->webSettings, (gpointer)webkit_web_view_settings_notify, webView);
g_object_unref(priv->webSettings);
priv->webSettings = NULL;
@@ -900,9 +974,6 @@ static void webkit_web_view_dispose(GObject* object)
gtk_target_list_unref(priv->paste_target_list);
priv->paste_target_list = NULL;
-
- delete priv->userAgent;
- priv->userAgent = NULL;
}
G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object);
@@ -919,7 +990,7 @@ static void webkit_web_view_finalize(GObject* object)
G_OBJECT_CLASS(webkit_web_view_parent_class)->finalize(object);
}
-static gboolean webkit_create_web_view_request_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy)
+static gboolean webkit_signal_accumulator_object_handled(GSignalInvocationHint* ihint, GValue* returnAccu, const GValue* handlerReturn, gpointer dummy)
{
gpointer newWebView = g_value_get_object(handlerReturn);
g_value_set_object(returnAccu, newWebView);
@@ -955,13 +1026,61 @@ static AtkObject* webkit_web_view_get_accessible(GtkWidget* widget)
if (!doc)
return NULL;
- AccessibilityObject* coreAccessible = doc->axObjectCache()->get(doc->renderer());
+ AccessibilityObject* coreAccessible = doc->axObjectCache()->getOrCreate(doc->renderer());
if (!coreAccessible || !coreAccessible->wrapper())
return NULL;
return coreAccessible->wrapper();
}
+static gdouble webViewGetDPI(WebKitWebView* webView)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+ WebKitWebSettings* webSettings = priv->webSettings;
+ gboolean enforce96DPI;
+ g_object_get(webSettings, "enforce-96-dpi", &enforce96DPI, NULL);
+ if (enforce96DPI)
+ return 96.0;
+
+ gdouble DPI = defaultDPI;
+ GdkScreen* screen = gtk_widget_has_screen(GTK_WIDGET(webView)) ? gtk_widget_get_screen(GTK_WIDGET(webView)) : gdk_screen_get_default();
+ if (screen) {
+ DPI = gdk_screen_get_resolution(screen);
+ // gdk_screen_get_resolution() returns -1 when no DPI is set.
+ if (DPI == -1)
+ DPI = defaultDPI;
+ }
+ ASSERT(DPI > 0);
+ return DPI;
+}
+
+static void webkit_web_view_screen_changed(GtkWidget* widget, GdkScreen* previousScreen)
+{
+ WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
+ WebKitWebViewPrivate* priv = webView->priv;
+
+ if (priv->disposing)
+ return;
+
+ WebKitWebSettings* webSettings = priv->webSettings;
+ Settings* settings = core(webView)->settings();
+ gdouble DPI = webViewGetDPI(webView);
+
+ guint defaultFontSize, defaultMonospaceFontSize, minimumFontSize, minimumLogicalFontSize;
+
+ g_object_get(webSettings,
+ "default-font-size", &defaultFontSize,
+ "default-monospace-font-size", &defaultMonospaceFontSize,
+ "minimum-font-size", &minimumFontSize,
+ "minimum-logical-font-size", &minimumLogicalFontSize,
+ NULL);
+
+ settings->setDefaultFontSize(defaultFontSize / 72.0 * DPI);
+ settings->setDefaultFixedFontSize(defaultMonospaceFontSize / 72.0 * DPI);
+ settings->setMinimumFontSize(minimumFontSize / 72.0 * DPI);
+ settings->setMinimumLogicalFontSize(minimumLogicalFontSize / 72.0 * DPI);
+}
+
static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
{
GtkBindingSet* binding_set;
@@ -993,9 +1112,9 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[CREATE_WEB_VIEW] = g_signal_new("create-web-view",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (WebKitWebViewClass, create_web_view),
- webkit_create_web_view_request_handled,
+ webkit_signal_accumulator_object_handled,
NULL,
webkit_marshal_OBJECT__OBJECT,
WEBKIT_TYPE_WEB_VIEW , 1,
@@ -1022,7 +1141,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[WEB_VIEW_READY] = g_signal_new("web-view-ready",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (WebKitWebViewClass, web_view_ready),
g_signal_accumulator_true_handled,
NULL,
@@ -1030,6 +1149,26 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
G_TYPE_BOOLEAN, 0);
/**
+ * WebKitWebView::close-web-view:
+ * @web_view: the object on which the signal is emitted
+ * @return: %TRUE to stop handlers from being invoked for the event or
+ * %FALSE to propagate the event furter
+ *
+ * Emitted when closing a WebView is requested. This occurs when a call
+ * is made from JavaScript's window.close function.
+ *
+ * Since 1.1.11
+ */
+ webkit_web_view_signals[CLOSE_WEB_VIEW] = g_signal_new("close-web-view",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (WebKitWebViewClass, close_web_view),
+ g_signal_accumulator_true_handled,
+ NULL,
+ webkit_marshal_BOOLEAN__VOID,
+ G_TYPE_BOOLEAN, 0);
+
+ /**
* WebKitWebView::navigation-requested:
* @web_view: the object on which the signal is emitted
* @frame: the #WebKitWebFrame that required the navigation
@@ -1043,7 +1182,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[NAVIGATION_REQUESTED] = g_signal_new("navigation-requested",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (WebKitWebViewClass, navigation_requested),
webkit_navigation_request_handled,
NULL,
@@ -1059,13 +1198,13 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* @request: a #WebKitNetworkRequest
* @navigation_action: a #WebKitWebNavigation
* @policy_decision: a #WebKitWebPolicyDecision
- * @return: TRUE if the signal will be handled, FALSE to have the
+ * @return: TRUE if a decision was made, FALSE to have the
* default behavior apply
*
* Emitted when @frame requests opening a new window. With this
* signal the browser can use the context of the request to decide
* about the new window. If the request is not handled the default
- * behavior is to allow opening the new window to load the url,
+ * behavior is to allow opening the new window to load the URI,
* which will cause a create-web-view signal emission where the
* browser handles the new window action but without information
* of the context that caused the navigation. The following
@@ -1075,12 +1214,19 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* information about the action that made this new window to be
* opened.
*
+ * Notice that if you return TRUE, meaning that you handled the
+ * signal, you are expected to have decided what to do, by calling
+ * webkit_web_policy_decision_ignore(),
+ * webkit_web_policy_decision_use(), or
+ * webkit_web_policy_decision_download() on the @policy_decision
+ * object.
+ *
* Since: 1.1.4
*/
webkit_web_view_signals[NEW_WINDOW_POLICY_DECISION_REQUESTED] =
g_signal_new("new-window-policy-decision-requested",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled,
NULL,
@@ -1098,18 +1244,25 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* @request: a #WebKitNetworkRequest
* @navigation_action: a #WebKitWebNavigation
* @policy_decision: a #WebKitWebPolicyDecision
- * @return: TRUE if the signal will be handled, FALSE to have the
+ * @return: TRUE if a decision was made, FALSE to have the
* default behavior apply
*
* Emitted when @frame requests a navigation to another page.
* If this signal is not handled, the default behavior is to allow the
* navigation.
*
+ * Notice that if you return TRUE, meaning that you handled the
+ * signal, you are expected to have decided what to do, by calling
+ * webkit_web_policy_decision_ignore(),
+ * webkit_web_policy_decision_use(), or
+ * webkit_web_policy_decision_download() on the @policy_decision
+ * object.
+ *
* Since: 1.0.3
*/
webkit_web_view_signals[NAVIGATION_POLICY_DECISION_REQUESTED] = g_signal_new("navigation-policy-decision-requested",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled,
NULL,
@@ -1127,7 +1280,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* @request: a WebKitNetworkRequest
* @mimetype: the MIME type attempted to load
* @policy_decision: a #WebKitWebPolicyDecision
- * @return: TRUE if the signal will be handled, FALSE to have the
+ * @return: TRUE if a decision was made, FALSE to have the
* default behavior apply
*
* Decide whether or not to display the given MIME type. If this
@@ -1136,11 +1289,18 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* type; if WebKit is not able to show the MIME type nothing
* happens.
*
+ * Notice that if you return TRUE, meaning that you handled the
+ * signal, you are expected to have decided what to do, by calling
+ * webkit_web_policy_decision_ignore(),
+ * webkit_web_policy_decision_use(), or
+ * webkit_web_policy_decision_download() on the @policy_decision
+ * object.
+ *
* Since: 1.0.3
*/
webkit_web_view_signals[MIME_TYPE_POLICY_DECISION_REQUESTED] = g_signal_new("mime-type-policy-decision-requested",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled,
NULL,
@@ -1168,7 +1328,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[WINDOW_OBJECT_CLEARED] = g_signal_new("window-object-cleared",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (WebKitWebViewClass, window_object_cleared),
NULL,
NULL,
@@ -1194,11 +1354,22 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* the #WebKitDownload helper object you must handle this signal,
* and return %FALSE.
*
+ * Also, keep in mind that the default policy for WebKitGTK+ is to
+ * ignore files with a MIME type that it does not know how to
+ * handle, which means this signal won't be emitted in the default
+ * setup. One way to trigger downloads is to connect to
+ * WebKitWebView::mime-type-policy-decision-requested and call
+ * webkit_web_policy_decision_download() on the
+ * #WebKitWebPolicyDecision in the parameter list for the kind of
+ * files you want your application to download (a common solution
+ * is to download anything that WebKit can't handle, which you can
+ * figure out by using webkit_web_view_can_show_mime_type()).
+ *
* Since: 1.1.2
*/
webkit_web_view_signals[DOWNLOAD_REQUESTED] = g_signal_new("download-requested",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
g_signal_accumulator_true_handled,
NULL,
@@ -1215,7 +1386,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[LOAD_STARTED] = g_signal_new("load-started",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1232,7 +1403,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[LOAD_COMMITTED] = g_signal_new("load-committed",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1248,7 +1419,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[LOAD_PROGRESS_CHANGED] = g_signal_new("load-progress-changed",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1256,9 +1427,34 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
G_TYPE_NONE, 1,
G_TYPE_INT);
+ /**
+ * WebKitWebView::load-error
+ * @web_view: the object on which the signal is emitted
+ * @web_frame: the #WebKitWebFrame
+ * @uri: the URI that triggered the error
+ * @web_error: the #GError that was triggered
+ *
+ * An error occurred while loading. By default, if the signal is not
+ * handled, the @web_view will display a stock error page. You need to
+ * handle the signal if you want to provide your own error page.
+ *
+ * Since: 1.1.6
+ */
+ webkit_web_view_signals[LOAD_ERROR] = g_signal_new("load-error",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST),
+ 0,
+ g_signal_accumulator_true_handled,
+ NULL,
+ webkit_marshal_BOOLEAN__OBJECT_STRING_POINTER,
+ G_TYPE_BOOLEAN, 3,
+ WEBKIT_TYPE_WEB_FRAME,
+ G_TYPE_STRING,
+ G_TYPE_POINTER);
+
webkit_web_view_signals[LOAD_FINISHED] = g_signal_new("load-finished",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1278,7 +1474,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[TITLE_CHANGED] = g_signal_new("title-changed",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1297,7 +1493,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[HOVERING_OVER_LINK] = g_signal_new("hovering-over-link",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1317,7 +1513,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[POPULATE_POPUP] = g_signal_new("populate-popup",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1325,9 +1521,38 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
G_TYPE_NONE, 1,
GTK_TYPE_MENU);
+ /**
+ * WebKitWebView::print-requested
+ * @web_view: the object in which the signal is emitted
+ * @web_frame: the frame that is requesting to be printed
+ * @return: %TRUE if the print request has been handled, %FALSE if
+ * the default handler should run
+ *
+ * Emitted when printing is requested by the frame, usually
+ * because of a javascript call. When handling this signal you
+ * should call webkit_web_frame_print_full() or
+ * webkit_web_frame_print() to do the actual printing.
+ *
+ * The default handler will present a print dialog and carry a
+ * print operation. Notice that this means that if you intend to
+ * ignore a print request you must connect to this signal, and
+ * return %TRUE.
+ *
+ * Since: 1.1.5
+ */
+ webkit_web_view_signals[PRINT_REQUESTED] = g_signal_new("print-requested",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
+ 0,
+ g_signal_accumulator_true_handled,
+ NULL,
+ webkit_marshal_BOOLEAN__OBJECT,
+ G_TYPE_BOOLEAN, 1,
+ WEBKIT_TYPE_WEB_FRAME);
+
webkit_web_view_signals[STATUS_BAR_TEXT_CHANGED] = g_signal_new("status-bar-text-changed",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1337,7 +1562,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
webkit_web_view_signals[ICOND_LOADED] = g_signal_new("icon-loaded",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1346,7 +1571,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
webkit_web_view_signals[SELECTION_CHANGED] = g_signal_new("selection-changed",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
0,
NULL,
NULL,
@@ -1365,7 +1590,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[CONSOLE_MESSAGE] = g_signal_new("console-message",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(WebKitWebViewClass, console_message),
g_signal_accumulator_true_handled,
NULL,
@@ -1384,7 +1609,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[SCRIPT_ALERT] = g_signal_new("script-alert",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(WebKitWebViewClass, script_alert),
g_signal_accumulator_true_handled,
NULL,
@@ -1404,7 +1629,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[SCRIPT_CONFIRM] = g_signal_new("script-confirm",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(WebKitWebViewClass, script_confirm),
g_signal_accumulator_true_handled,
NULL,
@@ -1425,7 +1650,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
webkit_web_view_signals[SCRIPT_PROMPT] = g_signal_new("script-prompt",
G_TYPE_FROM_CLASS(webViewClass),
- (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ (GSignalFlags)G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(WebKitWebViewClass, script_prompt),
g_signal_accumulator_true_handled,
NULL,
@@ -1501,11 +1726,60 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
+ /**
+ * WebKitWebView::move-cursor:
+ * @web_view: the object which received the signal
+ * @step: the type of movement, one of #GtkMovementStep
+ * @count: an integer indicating the subtype of movement. Currently
+ * the permitted values are '1' = forward, '-1' = backwards.
+ *
+ * The #WebKitWebView::move-cursor will be emitted to apply the
+ * cursor movement described by its parameters to the @view.
+ *
+ * Since: 1.1.4
+ */
+ webkit_web_view_signals[MOVE_CURSOR] = g_signal_new("move-cursor",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ G_STRUCT_OFFSET(WebKitWebViewClass, move_cursor),
+ NULL, NULL,
+ webkit_marshal_BOOLEAN__ENUM_INT,
+ G_TYPE_BOOLEAN, 2,
+ GTK_TYPE_MOVEMENT_STEP,
+ G_TYPE_INT);
+
+ /**
+ * WebKitWebView::create-plugin-widget:
+ * @web_view: the object which received the signal
+ * @mime_type: the mimetype of the requested object
+ * @uri: the URI to load
+ * @param: a #GHashTable with additional attributes (strings)
+ *
+ * The #WebKitWebView::create-plugin 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
+ * to set the property value of "webkit-widget-is-selected". This can
+ * be used to draw a visual indicator of the selection.
+ *
+ * Since: 1.1.8
+ */
+ webkit_web_view_signals[PLUGIN_WIDGET] = g_signal_new("create-plugin-widget",
+ G_TYPE_FROM_CLASS(webViewClass),
+ (GSignalFlags) (G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
+ 0,
+ webkit_signal_accumulator_object_handled,
+ NULL,
+ webkit_marshal_OBJECT__STRING_STRING_POINTER,
+ GTK_TYPE_WIDGET, 3,
+ G_TYPE_STRING, G_TYPE_STRING, G_TYPE_HASH_TABLE);
+
/*
* implementations of virtual methods
*/
webViewClass->create_web_view = webkit_web_view_real_create_web_view;
webViewClass->web_view_ready = webkit_web_view_real_web_view_ready;
+ webViewClass->close_web_view = webkit_web_view_real_close_web_view;
webViewClass->navigation_requested = webkit_web_view_real_navigation_requested;
webViewClass->window_object_cleared = webkit_web_view_real_window_object_cleared;
webViewClass->choose_file = webkit_web_view_real_choose_file;
@@ -1517,6 +1791,7 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
webViewClass->cut_clipboard = webkit_web_view_real_cut_clipboard;
webViewClass->copy_clipboard = webkit_web_view_real_copy_clipboard;
webViewClass->paste_clipboard = webkit_web_view_real_paste_clipboard;
+ webViewClass->move_cursor = webkit_web_view_real_move_cursor;
GObjectClass* objectClass = G_OBJECT_CLASS(webViewClass);
objectClass->dispose = webkit_web_view_dispose;
@@ -1534,10 +1809,13 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
widgetClass->motion_notify_event = webkit_web_view_motion_event;
widgetClass->scroll_event = webkit_web_view_scroll_event;
widgetClass->size_allocate = webkit_web_view_size_allocate;
+ widgetClass->size_request = webkit_web_view_size_request;
widgetClass->popup_menu = webkit_web_view_popup_menu_handler;
+ widgetClass->grab_focus = webkit_web_view_grab_focus;
widgetClass->focus_in_event = webkit_web_view_focus_in_event;
widgetClass->focus_out_event = webkit_web_view_focus_out_event;
widgetClass->get_accessible = webkit_web_view_get_accessible;
+ widgetClass->screen_changed = webkit_web_view_screen_changed;
GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webViewClass);
containerClass->add = webkit_web_view_container_add;
@@ -1582,6 +1860,49 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
gtk_binding_entry_add_signal(binding_set, GDK_Insert, GDK_SHIFT_MASK,
"paste_clipboard", 0);
+ /* Movement */
+
+ gtk_binding_entry_add_signal(binding_set, GDK_Down, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINES,
+ G_TYPE_INT, 1);
+ gtk_binding_entry_add_signal(binding_set, GDK_Up, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_DISPLAY_LINES,
+ G_TYPE_INT, -1);
+ gtk_binding_entry_add_signal(binding_set, GDK_Right, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
+ G_TYPE_INT, 1);
+ gtk_binding_entry_add_signal(binding_set, GDK_Left, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_VISUAL_POSITIONS,
+ G_TYPE_INT, -1);
+ gtk_binding_entry_add_signal(binding_set, GDK_space, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
+ G_TYPE_INT, 1);
+ gtk_binding_entry_add_signal(binding_set, GDK_space, GDK_SHIFT_MASK,
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
+ G_TYPE_INT, -1);
+ gtk_binding_entry_add_signal(binding_set, GDK_Page_Down, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
+ G_TYPE_INT, 1);
+ gtk_binding_entry_add_signal(binding_set, GDK_Page_Up, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_PAGES,
+ G_TYPE_INT, -1);
+ gtk_binding_entry_add_signal(binding_set, GDK_End, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_BUFFER_ENDS,
+ G_TYPE_INT, 1);
+ gtk_binding_entry_add_signal(binding_set, GDK_Home, static_cast<GdkModifierType>(0),
+ "move-cursor", 2,
+ G_TYPE_ENUM, GTK_MOVEMENT_BUFFER_ENDS,
+ G_TYPE_INT, -1);
+
/*
* properties
*/
@@ -1595,8 +1916,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_TITLE,
g_param_spec_string("title",
- "Title",
- "Returns the @web_view's document title",
+ _("Title"),
+ _("Returns the @web_view's document title"),
NULL,
WEBKIT_PARAM_READABLE));
@@ -1609,12 +1930,11 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_URI,
g_param_spec_string("uri",
- "URI",
- "Returns the current URI of the contents displayed by the @web_view",
+ _("URI"),
+ _("Returns the current URI of the contents displayed by the @web_view"),
NULL,
WEBKIT_PARAM_READABLE));
-#if GTK_CHECK_VERSION(2,10,0)
/**
* WebKitWebView:copy-target-list:
*
@@ -1624,8 +1944,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_COPY_TARGET_LIST,
g_param_spec_boxed("copy-target-list",
- "Copy target list",
- "The list of targets this web view supports for clipboard copying",
+ _("Copy target list"),
+ _("The list of targets this web view supports for clipboard copying"),
GTK_TYPE_TARGET_LIST,
WEBKIT_PARAM_READABLE));
@@ -1638,16 +1958,15 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_PASTE_TARGET_LIST,
g_param_spec_boxed("paste-target-list",
- "Paste target list",
- "The list of targets this web view supports for clipboard pasting",
+ _("Paste target list"),
+ _("The list of targets this web view supports for clipboard pasting"),
GTK_TYPE_TARGET_LIST,
WEBKIT_PARAM_READABLE));
-#endif
g_object_class_install_property(objectClass, PROP_SETTINGS,
g_param_spec_object("settings",
- "Settings",
- "An associated WebKitWebSettings instance",
+ _("Settings"),
+ _("An associated WebKitWebSettings instance"),
WEBKIT_TYPE_WEB_SETTINGS,
WEBKIT_PARAM_READWRITE));
@@ -1660,8 +1979,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_WEB_INSPECTOR,
g_param_spec_object("web-inspector",
- "Web Inspector",
- "The associated WebKitWebInspector instance",
+ _("Web Inspector"),
+ _("The associated WebKitWebInspector instance"),
WEBKIT_TYPE_WEB_INSPECTOR,
WEBKIT_PARAM_READABLE));
@@ -1681,15 +2000,15 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
g_object_class_install_property(objectClass, PROP_EDITABLE,
g_param_spec_boolean("editable",
- "Editable",
- "Whether content can be modified by the user",
+ _("Editable"),
+ _("Whether content can be modified by the user"),
FALSE,
WEBKIT_PARAM_READWRITE));
g_object_class_install_property(objectClass, PROP_TRANSPARENT,
g_param_spec_boolean("transparent",
- "Transparent",
- "Whether content has a transparent background",
+ _("Transparent"),
+ _("Whether content has a transparent background"),
FALSE,
WEBKIT_PARAM_READWRITE));
@@ -1702,8 +2021,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_ZOOM_LEVEL,
g_param_spec_float("zoom-level",
- "Zoom level",
- "The level of zoom of the content",
+ _("Zoom level"),
+ _("The level of zoom of the content"),
G_MINFLOAT,
G_MAXFLOAT,
1.0f,
@@ -1718,8 +2037,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_FULL_CONTENT_ZOOM,
g_param_spec_boolean("full-content-zoom",
- "Full content zoom",
- "Whether the full content is scaled when zooming",
+ _("Full content zoom"),
+ _("Whether the full content is scaled when zooming"),
FALSE,
WEBKIT_PARAM_READWRITE));
@@ -1732,8 +2051,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_ENCODING,
g_param_spec_string("encoding",
- "Encoding",
- "The default encoding of the web view",
+ _("Encoding"),
+ _("The default encoding of the web view"),
NULL,
WEBKIT_PARAM_READABLE));
@@ -1746,57 +2065,41 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*/
g_object_class_install_property(objectClass, PROP_CUSTOM_ENCODING,
g_param_spec_string("custom-encoding",
- "Custom Encoding",
- "The custom encoding of the web view",
+ _("Custom Encoding"),
+ _("The custom encoding of the web view"),
NULL,
WEBKIT_PARAM_READWRITE));
- g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate));
-}
-
-static gdouble webViewGetDPI(WebKitWebView* webView)
-{
- WebKitWebViewPrivate* priv = webView->priv;
- WebKitWebSettings* webSettings = priv->webSettings;
- gboolean enforce96DPI;
- g_object_get(webSettings, "enforce-96-dpi", &enforce96DPI, NULL);
- if (enforce96DPI)
- return 96.0;
-
- gdouble DPI = defaultDPI;
-#if GTK_CHECK_VERSION(2,10,0)
- GdkScreen* screen = gtk_widget_has_screen(GTK_WIDGET(webView)) ? gtk_widget_get_screen(GTK_WIDGET(webView)) : gdk_screen_get_default();
- if (screen) {
- DPI = gdk_screen_get_resolution(screen);
- // gdk_screen_get_resolution() returns -1 when no DPI is set.
- if (DPI == -1)
- DPI = defaultDPI;
- }
-#endif
- ASSERT(DPI > 0);
- return DPI;
-}
-
-static void webkit_web_view_screen_changed(WebKitWebView* webView, GdkScreen* previousScreen, gpointer userdata)
-{
- WebKitWebViewPrivate* priv = webView->priv;
- WebKitWebSettings* webSettings = priv->webSettings;
- Settings* settings = core(webView)->settings();
- gdouble DPI = webViewGetDPI(webView);
-
- guint defaultFontSize, defaultMonospaceFontSize, minimumFontSize, minimumLogicalFontSize;
+ /**
+ * WebKitWebView:load-status:
+ *
+ * Determines the current status of the load.
+ *
+ * Since: 1.1.7
+ */
+ g_object_class_install_property(objectClass, PROP_LOAD_STATUS,
+ g_param_spec_enum("load-status",
+ "Load Status",
+ "Determines the current status of the load",
+ WEBKIT_TYPE_LOAD_STATUS,
+ WEBKIT_LOAD_FINISHED,
+ WEBKIT_PARAM_READABLE));
- g_object_get(webSettings,
- "default-font-size", &defaultFontSize,
- "default-monospace-font-size", &defaultMonospaceFontSize,
- "minimum-font-size", &minimumFontSize,
- "minimum-logical-font-size", &minimumLogicalFontSize,
- NULL);
+ /**
+ * WebKitWebView:progress:
+ *
+ * Determines the current progress of the load.
+ *
+ * Since: 1.1.7
+ */
+ g_object_class_install_property(objectClass, PROP_PROGRESS,
+ g_param_spec_double("progress",
+ "Progress",
+ "Determines the current progress of the load",
+ 0.0, 1.0, 1.0,
+ WEBKIT_PARAM_READABLE));
- settings->setDefaultFontSize(defaultFontSize / 72.0 * DPI);
- settings->setDefaultFixedFontSize(defaultMonospaceFontSize / 72.0 * DPI);
- settings->setMinimumFontSize(minimumFontSize / 72.0 * DPI);
- settings->setMinimumLogicalFontSize(minimumLogicalFontSize / 72.0 * DPI);
+ g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate));
}
static void webkit_web_view_update_settings(WebKitWebView* webView)
@@ -1808,7 +2111,8 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
gchar* defaultEncoding, *cursiveFontFamily, *defaultFontFamily, *fantasyFontFamily, *monospaceFontFamily, *sansSerifFontFamily, *serifFontFamily, *userStylesheetUri;
gboolean autoLoadImages, autoShrinkImages, printBackgrounds,
enableScripts, enablePlugins, enableDeveloperExtras, resizableTextAreas,
- enablePrivateBrowsing;
+ enablePrivateBrowsing, enableCaretBrowsing, enableHTML5Database, enableHTML5LocalStorage,
+ enableXSSAuditor, javascriptCanOpenWindows, enableOfflineWebAppCache;
g_object_get(webSettings,
"default-encoding", &defaultEncoding,
@@ -1827,6 +2131,12 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
"user-stylesheet-uri", &userStylesheetUri,
"enable-developer-extras", &enableDeveloperExtras,
"enable-private-browsing", &enablePrivateBrowsing,
+ "enable-caret-browsing", &enableCaretBrowsing,
+ "enable-html5-database", &enableHTML5Database,
+ "enable-html5-local-storage", &enableHTML5LocalStorage,
+ "enable-xss-auditor", &enableXSSAuditor,
+ "javascript-can-open-windows-automatically", &javascriptCanOpenWindows,
+ "enable-offline-web-application-cache", &enableOfflineWebAppCache,
NULL);
settings->setDefaultTextEncodingName(defaultEncoding);
@@ -1845,6 +2155,12 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
settings->setUserStyleSheetLocation(KURL(KURL(), userStylesheetUri));
settings->setDeveloperExtrasEnabled(enableDeveloperExtras);
settings->setPrivateBrowsingEnabled(enablePrivateBrowsing);
+ settings->setCaretBrowsingEnabled(enableCaretBrowsing);
+ settings->setDatabasesEnabled(enableHTML5Database);
+ settings->setLocalStorageEnabled(enableHTML5LocalStorage);
+ settings->setXSSAuditorEnabled(enableXSSAuditor);
+ settings->setJavaScriptCanOpenWindowsAutomatically(javascriptCanOpenWindows);
+ settings->setOfflineWebApplicationCacheEnabled(enableOfflineWebAppCache);
g_free(defaultEncoding);
g_free(cursiveFontFamily);
@@ -1855,7 +2171,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
g_free(serifFontFamily);
g_free(userStylesheetUri);
- webkit_web_view_screen_changed(webView, NULL, NULL);
+ webkit_web_view_screen_changed(GTK_WIDGET(webView), NULL);
}
static inline gint pixelsFromSize(WebKitWebView* webView, gint size)
@@ -1896,7 +2212,7 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar
else if (name == g_intern_string("minimum-logical-font-size"))
settings->setMinimumLogicalFontSize(pixelsFromSize(webView, g_value_get_int(&value)));
else if (name == g_intern_string("enforce-96-dpi"))
- webkit_web_view_screen_changed(webView, NULL, NULL);
+ webkit_web_view_screen_changed(GTK_WIDGET(webView), NULL);
else if (name == g_intern_string("auto-load-images"))
settings->setLoadsImagesAutomatically(g_value_get_boolean(&value));
else if (name == g_intern_string("auto-shrink-images"))
@@ -1915,6 +2231,18 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar
settings->setDeveloperExtrasEnabled(g_value_get_boolean(&value));
else if (name == g_intern_string("enable-private-browsing"))
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));
+ 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("javascript-can-open-windows-automatically"))
+ settings->setJavaScriptCanOpenWindowsAutomatically(g_value_get_boolean(&value));
+ else if (name == g_intern_string("enable-offline-web-application-cache"))
+ settings->setOfflineWebApplicationCacheEnabled(g_value_get_boolean(&value));
else if (!g_object_class_find_property(G_OBJECT_GET_CLASS(webSettings), name))
g_warning("Unexpected setting '%s'", name);
g_value_unset(&value);
@@ -1950,11 +2278,7 @@ static void webkit_web_view_init(WebKitWebView* webView)
priv->zoomFullContent = FALSE;
-#if GTK_CHECK_VERSION(2,10,0)
GdkAtom textHtml = gdk_atom_intern_static_string("text/html");
-#else
- GdkAtom textHtml = gdk_atom_intern("text/html", false);
-#endif
/* Targets for copy */
priv->copy_target_list = gtk_target_list_new(NULL, 0);
gtk_target_list_add(priv->copy_target_list, textHtml, 0, WEBKIT_WEB_VIEW_TARGET_INFO_HTML);
@@ -1967,7 +2291,6 @@ static void webkit_web_view_init(WebKitWebView* webView)
priv->webSettings = webkit_web_settings_new();
webkit_web_view_update_settings(webView);
- g_signal_connect(webView, "screen-changed", G_CALLBACK(webkit_web_view_screen_changed), NULL);
g_signal_connect(priv->webSettings, "notify", G_CALLBACK(webkit_web_view_settings_notify), webView);
priv->webWindowFeatures = webkit_web_window_features_new();
@@ -1989,6 +2312,31 @@ void webkit_web_view_notify_ready(WebKitWebView* webView)
g_signal_emit(webView, webkit_web_view_signals[WEB_VIEW_READY], 0, &isHandled);
}
+void webkit_web_view_request_download(WebKitWebView* webView, WebKitNetworkRequest* request, const ResourceResponse& response)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ WebKitDownload* download = webkit_download_new(request);
+
+ if (!response.isNull() && !response.suggestedFilename().isEmpty())
+ webkit_download_set_suggested_filename(download, response.suggestedFilename().utf8().data());
+
+ gboolean handled;
+ g_signal_emit(webView, webkit_web_view_signals[DOWNLOAD_REQUESTED], 0, download, &handled);
+
+ if (!handled) {
+ webkit_download_cancel(download);
+ g_object_unref(download);
+ return;
+ }
+
+ webkit_download_start(download);
+}
+
+bool webkit_web_view_use_primary_for_paste(WebKitWebView* webView)
+{
+ return webView->priv->usePrimaryForPaste;
+}
void webkit_web_view_set_settings(WebKitWebView* webView, WebKitWebSettings* webSettings)
{
@@ -2281,7 +2629,7 @@ void webkit_web_view_open(WebKitWebView* webView, const gchar* uri)
// We used to support local paths, unlike the newer
// function webkit_web_view_load_uri
if (g_path_is_absolute(uri)) {
- gchar* fileUri = g_strdup_printf("file://%s", uri);
+ gchar* fileUri = g_filename_to_uri(uri, NULL, NULL);
webkit_web_view_load_uri(webView, fileUri);
g_free(fileUri);
}
@@ -2981,6 +3329,35 @@ SoupSession* webkit_get_default_session ()
return ResourceHandle::defaultSession();
}
+/**
+ * webkit_web_view_get_load_status:
+ * @web_view: a #WebKitWebView
+ *
+ * Determines the current status of the load.
+ *
+ * Since: 1.1.7
+ */
+WebKitLoadStatus webkit_web_view_get_load_status(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), WEBKIT_LOAD_FINISHED);
+
+ WebKitWebViewPrivate* priv = webView->priv;
+ return priv->loadStatus;
+}
+
+/**
+ * webkit_web_view_get_progress:
+ * @web_view: a #WebKitWebView
+ *
+ * Determines the current progress of the load.
+ *
+ * Since: 1.1.7
+ */
+gdouble webkit_web_view_get_progress(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 1.0);
+
+ return core(webView)->progress()->estimatedProgress();
}
/**
@@ -3050,3 +3427,38 @@ const char* webkit_web_view_get_custom_encoding(WebKitWebView* webView)
} else
return NULL;
}
+
+/**
+ * webkit_web_view_move_cursor:
+ * @web_view: a #WebKitWebView
+ * @step: a #GtkMovementStep
+ * @count: integer describing the direction of the movement. 1 for forward, -1 for backwards.
+ *
+ * Move the cursor in @view as described by @step and @count.
+ *
+ * Since: 1.1.4
+ */
+void webkit_web_view_move_cursor(WebKitWebView* webView, GtkMovementStep step, gint count)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+ g_return_if_fail(step == GTK_MOVEMENT_VISUAL_POSITIONS ||
+ step == GTK_MOVEMENT_DISPLAY_LINES ||
+ step == GTK_MOVEMENT_PAGES ||
+ step == GTK_MOVEMENT_BUFFER_ENDS);
+ g_return_if_fail(count == 1 || count == -1);
+
+ gboolean handled;
+ g_signal_emit(webView, webkit_web_view_signals[MOVE_CURSOR], 0, step, count, &handled);
+}
+
+void webkit_web_view_set_group_name(WebKitWebView* webView, const gchar* groupName)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
+
+ WebKitWebViewPrivate* priv = webView->priv;
+
+ if (!priv->corePage)
+ return;
+
+ priv->corePage->setGroupName(String::fromUTF8(groupName));
+}
diff --git a/WebKit/gtk/webkit/webkitwebview.h b/WebKit/gtk/webkit/webkitwebview.h
index 1455a79..fbdefa8 100644
--- a/WebKit/gtk/webkit/webkitwebview.h
+++ b/WebKit/gtk/webkit/webkitwebview.h
@@ -28,6 +28,7 @@
#include <webkit/webkitdefines.h>
#include <webkit/webkitwebbackforwardlist.h>
+#include <webkit/webkitwebframe.h>
#include <webkit/webkitwebhistoryitem.h>
#include <webkit/webkitwebsettings.h>
@@ -73,6 +74,8 @@ struct _WebKitWebViewClass {
gboolean (* web_view_ready) (WebKitWebView* web_view);
+ gboolean (* close_web_view) (WebKitWebView* web_view);
+
WebKitNavigationResponse (* navigation_requested) (WebKitWebView *web_view,
WebKitWebFrame *frame,
WebKitNetworkRequest *request);
@@ -103,6 +106,9 @@ struct _WebKitWebViewClass {
void (* cut_clipboard) (WebKitWebView *web_view);
void (* copy_clipboard) (WebKitWebView *web_view);
void (* paste_clipboard) (WebKitWebView *web_view);
+ gboolean (* move_cursor) (WebKitWebView *web_view,
+ GtkMovementStep step,
+ gint count);
/*
* internal
@@ -117,8 +123,6 @@ struct _WebKitWebViewClass {
void (*_webkit_reserved3) (void);
void (*_webkit_reserved4) (void);
void (*_webkit_reserved5) (void);
- void (*_webkit_reserved6) (void);
- void (*_webkit_reserved7) (void);
};
WEBKIT_API GType
@@ -324,6 +328,17 @@ webkit_web_view_set_custom_encoding (WebKitWebView * webView,
WEBKIT_API const char*
webkit_web_view_get_custom_encoding (WebKitWebView * webView);
+WEBKIT_API void
+webkit_web_view_move_cursor (WebKitWebView * webView,
+ GtkMovementStep step,
+ gint count);
+
+WEBKIT_API WebKitLoadStatus
+webkit_web_view_get_load_status (WebKitWebView *web_view);
+
+WEBKIT_API gdouble
+webkit_web_view_get_progress (WebKitWebView *web_view);
+
G_END_DECLS
#endif
diff --git a/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp b/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp
index 7e61b59..47610d3 100644
--- a/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp
+++ b/WebKit/gtk/webkit/webkitwebwindowfeatures.cpp
@@ -54,8 +54,6 @@
* </programlisting></informalexample>
*/
-extern "C" {
-
enum {
PROP_0,
@@ -102,6 +100,8 @@ static void webkit_web_window_features_class_init(WebKitWebWindowFeaturesClass*
GParamFlags flags = (GParamFlags)(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT);
+ webkit_init();
+
/**
* WebKitWebWindowFeatures:x:
*
@@ -438,6 +438,3 @@ gboolean webkit_web_window_features_equal(WebKitWebWindowFeatures* features1, We
return TRUE;
return FALSE;
}
-
-
-}