summaryrefslogtreecommitdiffstats
path: root/WebKit/gtk/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/gtk/webkit')
-rw-r--r--WebKit/gtk/webkit/webkitdownload.cpp20
-rw-r--r--WebKit/gtk/webkit/webkitprivate.cpp14
-rw-r--r--WebKit/gtk/webkit/webkitprivate.h4
-rw-r--r--WebKit/gtk/webkit/webkitwebframe.cpp37
-rw-r--r--WebKit/gtk/webkit/webkitwebhistoryitem.cpp27
-rw-r--r--WebKit/gtk/webkit/webkitwebhistoryitem.h3
-rw-r--r--WebKit/gtk/webkit/webkitwebnavigationaction.cpp9
-rw-r--r--WebKit/gtk/webkit/webkitwebresource.cpp6
-rw-r--r--WebKit/gtk/webkit/webkitwebsettings.cpp113
-rw-r--r--WebKit/gtk/webkit/webkitwebview.cpp232
-rw-r--r--WebKit/gtk/webkit/webkitwebview.h11
11 files changed, 442 insertions, 34 deletions
diff --git a/WebKit/gtk/webkit/webkitdownload.cpp b/WebKit/gtk/webkit/webkitdownload.cpp
index dd6629b..1912a12 100644
--- a/WebKit/gtk/webkit/webkitdownload.cpp
+++ b/WebKit/gtk/webkit/webkitdownload.cpp
@@ -22,6 +22,7 @@
#include "CString.h"
#include <glib/gi18n-lib.h>
+#include "GRefPtr.h"
#include "Noncopyable.h"
#include "NotImplemented.h"
#include "ResourceHandleClient.h"
@@ -853,22 +854,24 @@ static void webkit_download_received_data(WebKitDownload* download, const gchar*
if (priv->currentSize > webkit_download_get_total_size(download))
g_object_notify(G_OBJECT(download), "total-size");
- 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.
+ // CPU on fast links, except when the last notification occured
+ // in more then 0.7 secs from now, or the last notified progress
+ // is passed in 1% or we reached the end.
+ static gdouble lastProgress = 0;
static gdouble lastElapsed = 0;
gdouble currentElapsed = g_timer_elapsed(priv->timer, NULL);
+ gdouble currentProgress = webkit_download_get_progress(download);
if (lastElapsed
- && (currentElapsed - lastElapsed) < 0.1
- && (webkit_download_get_progress(download) - lastProgress) < 0.03
- && webkit_download_get_progress(download) < 1.0) {
- lastElapsed = currentElapsed;
+ && lastProgress
+ && (currentElapsed - lastElapsed) < 0.7
+ && (currentProgress - lastProgress) < 0.01
+ && currentProgress < 1.0) {
return;
}
lastElapsed = currentElapsed;
+ lastProgress = currentProgress;
g_object_notify(G_OBJECT(download), "progress");
}
@@ -890,6 +893,7 @@ static void webkit_download_error(WebKitDownload* download, const ResourceError&
webkit_download_close_stream(download);
WebKitDownloadPrivate* priv = download->priv;
+ GRefPtr<WebKitDownload> protect(download);
g_timer_stop(priv->timer);
webkit_download_set_status(download, WEBKIT_DOWNLOAD_STATUS_ERROR);
diff --git a/WebKit/gtk/webkit/webkitprivate.cpp b/WebKit/gtk/webkit/webkitprivate.cpp
index c80160c..be88bb5 100644
--- a/WebKit/gtk/webkit/webkitprivate.cpp
+++ b/WebKit/gtk/webkit/webkitprivate.cpp
@@ -23,6 +23,7 @@
#include "webkitsoupauthdialog.h"
#include "webkitprivate.h"
#include "ApplicationCacheStorage.h"
+#include "Chrome.h"
#include "ChromeClientGtk.h"
#include "Frame.h"
#include "FrameLoader.h"
@@ -42,6 +43,7 @@
#include <runtime/InitializeThreading.h>
#include "SecurityOrigin.h"
#include <stdlib.h>
+#include "TextEncodingRegistry.h"
#include "webkitnetworkresponse.h"
#if ENABLE(DATABASE)
@@ -221,7 +223,11 @@ static GtkWidget* currentToplevelCallback(WebKitSoupAuthDialog* feature, SoupMes
return NULL;
GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(frame->page()->chrome()->platformPageClient()));
+#if GTK_CHECK_VERSION(2, 18, 0)
+ if (gtk_widget_is_toplevel(toplevel))
+#else
if (GTK_WIDGET_TOPLEVEL(toplevel))
+#endif
return toplevel;
else
return NULL;
@@ -245,10 +251,14 @@ void webkit_init()
JSC::initializeThreading();
WebCore::InitializeLoggingChannelsIfNecessary();
+ // We make sure the text codecs have been initialized, because
+ // that may only be done by the main thread.
+ atomicCanonicalTextEncodingName("UTF-8");
+
// Page cache capacity (in pages). Comment from Mac port:
// (Research indicates that value / page drops substantially after 3 pages.)
// FIXME: Expose this with an API and/or calculate based on available resources
- WebCore::pageCache()->setCapacity(3);
+ webkit_set_cache_model(WEBKIT_CACHE_MODEL_WEB_BROWSER);
#if ENABLE(DATABASE)
gchar* databaseDirectory = g_build_filename(g_get_user_data_dir(), "webkit", "databases", NULL);
@@ -280,6 +290,8 @@ void webkit_init()
SoupSessionFeature* sniffer = static_cast<SoupSessionFeature*>(g_object_new(SOUP_TYPE_CONTENT_SNIFFER, NULL));
soup_session_add_feature(session, sniffer);
g_object_unref(sniffer);
+
+ soup_session_add_feature_by_type(session, SOUP_TYPE_CONTENT_DECODER);
}
void webkit_white_list_access_from_origin(const gchar* sourceOrigin, const gchar* destinationProtocol, const gchar* destinationHost, bool allowDestinationSubdomains)
diff --git a/WebKit/gtk/webkit/webkitprivate.h b/WebKit/gtk/webkit/webkitprivate.h
index e17e79e..e9d61a6 100644
--- a/WebKit/gtk/webkit/webkitprivate.h
+++ b/WebKit/gtk/webkit/webkitprivate.h
@@ -152,6 +152,7 @@ extern "C" {
WebKitWebResource* mainResource;
char* mainResourceIdentifier;
GHashTable* subResources;
+ char* tooltipText;
};
#define WEBKIT_WEB_FRAME_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_FRAME, WebKitWebFramePrivate))
@@ -254,6 +255,9 @@ extern "C" {
GList*
webkit_web_view_get_subresources(WebKitWebView*);
+ void
+ webkit_web_view_set_tooltip_text(WebKitWebView*, const char*);
+
WebKitDownload*
webkit_download_new_with_handle(WebKitNetworkRequest* request, WebCore::ResourceHandle* handle, const WebCore::ResourceResponse& response);
diff --git a/WebKit/gtk/webkit/webkitwebframe.cpp b/WebKit/gtk/webkit/webkitwebframe.cpp
index 64fdc40..35d9524 100644
--- a/WebKit/gtk/webkit/webkitwebframe.cpp
+++ b/WebKit/gtk/webkit/webkitwebframe.cpp
@@ -54,7 +54,9 @@
#include "JSDOMBinding.h"
#include "ScriptController.h"
#include "SubstituteData.h"
+#if ENABLE(SVG)
#include "SVGSMILElement.h"
+#endif
#include <atk/atk.h>
#include <JavaScriptCore/APICast.h>
@@ -182,6 +184,14 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass)
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 the "load-status" property instead.
+ */
webkit_web_frame_signals[LOAD_COMMITTED] = g_signal_new("load-committed",
G_TYPE_FROM_CLASS(frameClass),
(GSignalFlags)G_SIGNAL_RUN_LAST,
@@ -197,7 +207,7 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass)
*
* Emitted when frame loading is done.
*
- * Deprecated: Use WebKitWebView::load-finished instead, and/or
+ * Deprecated: Use the "load-status" property instead, and/or
* WebKitWebView::load-error to be notified of load errors
*/
webkit_web_frame_signals[LOAD_DONE] = g_signal_new("load-done",
@@ -210,6 +220,15 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass)
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
+ /**
+ * WebKitWebFrame::title-changed:
+ * @frame: the object on which the signal is emitted
+ * @title: the new title
+ *
+ * When a #WebKitWebFrame changes the document title this signal is emitted.
+ *
+ * Deprecated: 1.1.18: Use "notify::title" instead.
+ */
webkit_web_frame_signals[TITLE_CHANGED] = g_signal_new("title-changed",
G_TYPE_FROM_CLASS(frameClass),
(GSignalFlags)G_SIGNAL_RUN_LAST,
@@ -891,7 +910,12 @@ GtkPrintOperationResult webkit_web_frame_print_full(WebKitWebFrame* frame, GtkPr
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_CHECK_VERSION(2, 18, 0)
+ if (!gtk_widget_is_toplevel(topLevel))
+#else
if (!GTK_WIDGET_TOPLEVEL(topLevel))
+#endif
topLevel = NULL;
Frame* coreFrame = core(frame);
@@ -930,11 +954,20 @@ void webkit_web_frame_print(WebKitWebFrame* frame)
if (error) {
GtkWidget* window = gtk_widget_get_toplevel(GTK_WIDGET(priv->webView));
+#if GTK_CHECK_VERSION(2, 18, 0)
+ GtkWidget* dialog = gtk_message_dialog_new(gtk_widget_is_toplevel(window) ? GTK_WINDOW(window) : 0,
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ "%s", error->message);
+#else
GtkWidget* dialog = gtk_message_dialog_new(GTK_WIDGET_TOPLEVEL(window) ? GTK_WINDOW(window) : 0,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"%s", error->message);
+#endif
+
g_error_free(error);
g_signal_connect(dialog, "response", G_CALLBACK(gtk_widget_destroy), NULL);
@@ -963,13 +996,13 @@ bool webkit_web_frame_pause_transition(WebKitWebFrame* frame, const gchar* name,
bool webkit_web_frame_pause_svg_animation(WebKitWebFrame* frame, const gchar* animationId, double time, const gchar* elementId)
{
ASSERT(core(frame));
+#if ENABLE(SVG)
Document* document = core(frame)->document();
if (!document || !document->svgExtensions())
return false;
Element* coreElement = document->getElementById(AtomicString(animationId));
if (!coreElement || !SVGSMILElement::isSMILElement(coreElement))
return false;
-#if ENABLE(SVG)
return document->accessSVGExtensions()->sampleAnimationAtTime(elementId, static_cast<SVGSMILElement*>(coreElement), time);
#else
return false;
diff --git a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp
index aab8b51..f2811ea 100644
--- a/WebKit/gtk/webkit/webkitwebhistoryitem.cpp
+++ b/WebKit/gtk/webkit/webkitwebhistoryitem.cpp
@@ -432,6 +432,33 @@ gdouble webkit_web_history_item_get_last_visited_time(WebKitWebHistoryItem* webH
return item->lastVisitedTime();
}
+/**
+ * webkit_web_history_item_copy :
+ * @web_history_item: a #WebKitWebHistoryItem
+ *
+ * Makes a copy of the item for use with other WebView objects.
+ *
+ * Since: 1.1.18
+ *
+ * Return value: the new #WebKitWebHistoryItem.
+ */
+WebKitWebHistoryItem* webkit_web_history_item_copy(WebKitWebHistoryItem* self)
+{
+ WebKitWebHistoryItemPrivate* selfPrivate = self->priv;
+
+ WebKitWebHistoryItem* item = WEBKIT_WEB_HISTORY_ITEM(g_object_new(WEBKIT_TYPE_WEB_HISTORY_ITEM, 0));
+ WebKitWebHistoryItemPrivate* priv = item->priv;
+
+ priv->title = selfPrivate->title;
+ priv->alternateTitle = selfPrivate->alternateTitle;
+ priv->uri = selfPrivate->uri;
+ priv->originalUri = selfPrivate->originalUri;
+
+ priv->historyItem = selfPrivate->historyItem->copy().releaseRef();
+
+ return item;
+}
+
/* private methods */
G_CONST_RETURN gchar* webkit_web_history_item_get_target(WebKitWebHistoryItem* webHistoryItem)
diff --git a/WebKit/gtk/webkit/webkitwebhistoryitem.h b/WebKit/gtk/webkit/webkitwebhistoryitem.h
index cafeb36..1820736 100644
--- a/WebKit/gtk/webkit/webkitwebhistoryitem.h
+++ b/WebKit/gtk/webkit/webkitwebhistoryitem.h
@@ -82,6 +82,9 @@ webkit_web_history_item_get_original_uri (WebKitWebHistoryItem *web_history
WEBKIT_API gdouble
webkit_web_history_item_get_last_visited_time (WebKitWebHistoryItem *web_history_item);
+WEBKIT_API WebKitWebHistoryItem*
+webkit_web_history_item_copy (WebKitWebHistoryItem *web_history_item);
+
G_END_DECLS
#endif /* webkitwebhistoryitem_h */
diff --git a/WebKit/gtk/webkit/webkitwebnavigationaction.cpp b/WebKit/gtk/webkit/webkitwebnavigationaction.cpp
index c866c0f..f421f40 100644
--- a/WebKit/gtk/webkit/webkitwebnavigationaction.cpp
+++ b/WebKit/gtk/webkit/webkitwebnavigationaction.cpp
@@ -177,7 +177,9 @@ static void webkit_web_navigation_action_class_init(WebKitWebNavigationActionCla
/**
* WebKitWebNavigationAction:button:
*
- * The button used to click if the action was a mouse event.
+ * The DOM identifier for the mouse button used to click. DOM button values
+ * are 0, 1 and 2 for left, middle and right buttons. If the action was not
+ * initiated by a mouse click the value will be -1.
*
* Since: 1.0.3
*/
@@ -308,8 +310,9 @@ void webkit_web_navigation_action_set_original_uri(WebKitWebNavigationAction* na
* webkit_web_navigation_action_get_button:
* @navigationAction: a #WebKitWebNavigationAction
*
- * Returns the mouse button used to click if the action was a mouse event.
- * Otherwise returns -1.
+ * Returns the DOM identifier for the mouse button used to click.
+ * DOM button values are 0, 1 and 2 for left, middle and right buttons.
+ * If the action was not initiated by a mouse click, returns -1.
*
* Return value: the mouse button used to click
*
diff --git a/WebKit/gtk/webkit/webkitwebresource.cpp b/WebKit/gtk/webkit/webkitwebresource.cpp
index e995e08..bd3cd69 100644
--- a/WebKit/gtk/webkit/webkitwebresource.cpp
+++ b/WebKit/gtk/webkit/webkitwebresource.cpp
@@ -245,13 +245,13 @@ void webkit_web_resource_init_with_core_resource(WebKitWebResource* webResource,
/**
* webkit_web_resource_new:
* @data: the data to initialize the #WebKitWebResource
- * @length: the length of @data
+ * @size: the length of @data
* @uri: the uri of the #WebKitWebResource
* @mime_type: the MIME type of the #WebKitWebResource
- * @text_encoding_name: the text encoding name of the #WebKitWebResource
+ * @encoding: the text encoding name of the #WebKitWebResource
* @frame_name: the frame name of the #WebKitWebResource
*
- * Returns a new #WebKitWebResource. The @text_encoding_name can be %NULL. The
+ * Returns a new #WebKitWebResource. The @encoding can be %NULL. The
* @frame_name argument can be used if the resource represents contents of an
* entire HTML frame, otherwise pass %NULL.
*
diff --git a/WebKit/gtk/webkit/webkitwebsettings.cpp b/WebKit/gtk/webkit/webkitwebsettings.cpp
index 143ae06..1e2f8cc 100644
--- a/WebKit/gtk/webkit/webkitwebsettings.cpp
+++ b/WebKit/gtk/webkit/webkitwebsettings.cpp
@@ -4,6 +4,8 @@
* Copyright (C) 2008 Collabora Ltd.
* Copyright (C) 2008 Holger Hans Peter Freyther
* Copyright (C) 2009 Jan Michael Alonzo
+ * Copyright (C) 2009 Movial Creative Technologies Inc.
+ * 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
@@ -35,7 +37,7 @@
#include "PlatformString.h"
#include <glib/gi18n-lib.h>
-#if PLATFORM(UNIX)
+#if OS(UNIX)
#include <sys/utsname.h>
#endif
@@ -98,6 +100,9 @@ struct _WebKitWebSettingsPrivate {
gboolean enable_universal_access_from_file_uris;
gboolean enable_dom_paste;
gboolean tab_key_cycles_through_elements;
+ gboolean enable_default_context_menu;
+ gboolean enable_site_specific_quirks;
+ gboolean enable_page_cache;
};
#define WEBKIT_WEB_SETTINGS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_SETTINGS, WebKitWebSettingsPrivate))
@@ -139,7 +144,10 @@ enum {
PROP_EDITING_BEHAVIOR,
PROP_ENABLE_UNIVERSAL_ACCESS_FROM_FILE_URIS,
PROP_ENABLE_DOM_PASTE,
- PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS
+ PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS,
+ PROP_ENABLE_DEFAULT_CONTEXT_MENU,
+ PROP_ENABLE_SITE_SPECIFIC_QUIRKS,
+ PROP_ENABLE_PAGE_CACHE
};
// Create a default user agent string
@@ -152,7 +160,7 @@ static String webkit_get_user_agent()
#if PLATFORM(X11)
platform = g_strdup("X11");
-#elif PLATFORM(WIN_OS)
+#elif OS(WINDOWS)
platform = g_strdup("Windows");
#elif PLATFORM(MAC)
platform = g_strdup("Macintosh");
@@ -163,22 +171,22 @@ static String webkit_get_user_agent()
#endif
// FIXME: platform/version detection can be shared.
-#if PLATFORM(DARWIN)
+#if OS(DARWIN)
-#if PLATFORM(X86)
+#if CPU(X86)
osVersion = g_strdup("Intel Mac OS X");
#else
osVersion = g_strdup("PPC Mac OS X");
#endif
-#elif PLATFORM(UNIX)
+#elif OS(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)
+#elif OS(WINDOWS)
// FIXME: Compute the Windows version
osVersion = g_strdup("Windows");
@@ -686,6 +694,71 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass)
TRUE,
flags));
+ /**
+ * WebKitWebSettings:enable-default-context-menu:
+ *
+ * Whether right-clicks should be handled automatically to create,
+ * and display the context menu. Turning this off will make
+ * WebKitGTK+ not emit the populate-popup signal. Notice that the
+ * default button press event handler may still handle right
+ * clicks for other reasons, such as in-page context menus, or
+ * right-clicks that are handled by the page itself.
+ *
+ * Since: 1.1.18
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_ENABLE_DEFAULT_CONTEXT_MENU,
+ g_param_spec_boolean(
+ "enable-default-context-menu",
+ _("Enable Default Context Menu"),
+ _("Enables the handling of right-clicks for the creation of the default context menu"),
+ TRUE,
+ flags));
+
+ /**
+ * WebKitWebSettings::enable-site-specific-quirks
+ *
+ * Whether to turn on site-specific hacks. Turning this on will
+ * tell WebKitGTK+ to use some site-specific workarounds for
+ * better web compatibility. For example, older versions of
+ * MediaWiki will incorrectly send WebKit a css file with KHTML
+ * workarounds. By turning on site-specific quirks, WebKit will
+ * special-case this and other cases to make the sites work.
+ *
+ * Since: 1.1.18
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_ENABLE_SITE_SPECIFIC_QUIRKS,
+ g_param_spec_boolean(
+ "enable-site-specific-quirks",
+ _("Enable Site Specific Quirks"),
+ _("Enables the site-specific compatibility workarounds"),
+ FALSE,
+ flags));
+
+ /**
+ * WebKitWebSettings:enable-page-cache:
+ *
+ * Enable or disable the page cache. Disabling the page cache is
+ * generally only useful for special circumstances like low-memory
+ * scenarios or special purpose applications like static HTML
+ * viewers. This setting only controls the Page Cache, this cache
+ * is different than the disk-based or memory-based traditional
+ * resource caches, its point is to make going back and forth
+ * between pages much faster. For details about the different types
+ * of caches and their purposes see:
+ * http://webkit.org/blog/427/webkit-page-cache-i-the-basics/
+ *
+ * Since: 1.1.18
+ */
+ g_object_class_install_property(gobject_class,
+ PROP_ENABLE_PAGE_CACHE,
+ g_param_spec_boolean("enable-page-cache",
+ _("Enable page cache"),
+ _("Whether the page cache should be used"),
+ FALSE,
+ flags));
+
g_type_class_add_private(klass, sizeof(WebKitWebSettingsPrivate));
}
@@ -883,7 +956,16 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con
priv->enable_dom_paste = g_value_get_boolean(value);
break;
case PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS:
- priv->tab_key_cycles_through_elements = g_value_get_boolean(value);
+ priv->tab_key_cycles_through_elements = g_value_get_boolean(value);
+ break;
+ case PROP_ENABLE_DEFAULT_CONTEXT_MENU:
+ priv->enable_default_context_menu = g_value_get_boolean(value);
+ break;
+ case PROP_ENABLE_SITE_SPECIFIC_QUIRKS:
+ priv->enable_site_specific_quirks = g_value_get_boolean(value);
+ break;
+ case PROP_ENABLE_PAGE_CACHE:
+ priv->enable_page_cache = g_value_get_boolean(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
@@ -1002,7 +1084,16 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa
case PROP_TAB_KEY_CYCLES_THROUGH_ELEMENTS:
g_value_set_boolean(value, priv->tab_key_cycles_through_elements);
break;
- default:
+ case PROP_ENABLE_DEFAULT_CONTEXT_MENU:
+ g_value_set_boolean(value, priv->enable_default_context_menu);
+ break;
+ case PROP_ENABLE_SITE_SPECIFIC_QUIRKS:
+ g_value_set_boolean(value, priv->enable_site_specific_quirks);
+ break;
+ case PROP_ENABLE_PAGE_CACHE:
+ g_value_set_boolean(value, priv->enable_page_cache);
+ break;
+ default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
@@ -1067,6 +1158,10 @@ WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* web_settings)
"editing-behavior", priv->editing_behavior,
"enable-universal-access-from-file-uris", priv->enable_universal_access_from_file_uris,
"enable-dom-paste", priv->enable_dom_paste,
+ "tab-key-cycles-through-elements", priv->tab_key_cycles_through_elements,
+ "enable-default-context-menu", priv->enable_default_context_menu,
+ "enable-site-specific-quirks", priv->enable_site_specific_quirks,
+ "enable-page-cache", priv->enable_page_cache,
NULL));
return copy;
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index 211f671..ad13895 100644
--- a/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/WebKit/gtk/webkit/webkitwebview.cpp
@@ -8,6 +8,8 @@
* Copyright (C) 2008 Nuanti Ltd.
* Copyright (C) 2008, 2009 Collabora Ltd.
* Copyright (C) 2009 Igalia S.L.
+ * Copyright (C) 2009 Movial Creative Technologies Inc.
+ * Copyright (C) 2009 Bobby Powers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -40,6 +42,7 @@
#include "AXObjectCache.h"
#include "NotImplemented.h"
#include "BackForwardList.h"
+#include "Cache.h"
#include "CString.h"
#include "ChromeClientGtk.h"
#include "ContextMenu.h"
@@ -64,6 +67,7 @@
#include "FrameLoader.h"
#include "FrameView.h"
#include "MouseEventWithHitTestResults.h"
+#include "PageCache.h"
#include "Pasteboard.h"
#include "PasteboardHelper.h"
#include "PasteboardHelperGtk.h"
@@ -112,6 +116,7 @@
*/
static const double defaultDPI = 96.0;
+static WebKitCacheModel cacheModel;
using namespace WebKit;
using namespace WebCore;
@@ -174,7 +179,8 @@ enum {
PROP_PROGRESS,
PROP_ENCODING,
PROP_CUSTOM_ENCODING,
- PROP_ICON_URI
+ PROP_ICON_URI,
+ PROP_IM_CONTEXT
};
static guint webkit_web_view_signals[LAST_SIGNAL] = { 0, };
@@ -184,6 +190,8 @@ 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 GtkIMContext* webkit_web_view_get_im_context(WebKitWebView*);
+
static void destroy_menu_cb(GtkObject* object, gpointer data)
{
WebKitWebView* webView = WEBKIT_WEB_VIEW(data);
@@ -207,8 +215,28 @@ static gboolean webkit_web_view_forward_context_menu_event(WebKitWebView* webVie
if (!handledEvent)
return FALSE;
+ // If coreMenu is NULL, this means WebCore decided to not create
+ // the default context menu; this may still mean that the frame
+ // wants to consume the event - this happens when the page is
+ // handling the right-click for reasons other than a context menu,
+ // so we give it to it.
ContextMenu* coreMenu = page->contextMenuController()->contextMenu();
- if (!coreMenu)
+ if (!coreMenu) {
+ Frame* frame = core(webView)->mainFrame();
+ if (frame->view() && frame->eventHandler()->handleMousePressEvent(PlatformMouseEvent(event)))
+ return TRUE;
+
+ return FALSE;
+ }
+
+ // If we reach here, it's because WebCore is going to show the
+ // default context menu. We check our setting to figure out
+ // whether we want it or not.
+ WebKitWebSettings* settings = webkit_web_view_get_settings(webView);
+ gboolean enableDefaultContextMenu;
+ g_object_get(settings, "enable-default-context-menu", &enableDefaultContextMenu, NULL);
+
+ if (!enableDefaultContextMenu)
return FALSE;
GtkMenu* menu = GTK_MENU(coreMenu->platformDescription());
@@ -359,6 +387,9 @@ static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue*
case PROP_ICON_URI:
g_value_set_string(value, webkit_web_view_get_icon_uri(webView));
break;
+ case PROP_IM_CONTEXT:
+ g_value_set_object(value, webkit_web_view_get_im_context(webView));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
@@ -625,7 +656,11 @@ static gboolean webkit_web_view_focus_in_event(GtkWidget* widget, GdkEventFocus*
// TODO: Improve focus handling as suggested in
// http://bugs.webkit.org/show_bug.cgi?id=16910
GtkWidget* toplevel = gtk_widget_get_toplevel(widget);
+#if GTK_CHECK_VERSION(2, 18, 0)
+ if (gtk_widget_is_toplevel(toplevel) && gtk_window_has_toplevel_focus(GTK_WINDOW(toplevel))) {
+#else
if (GTK_WIDGET_TOPLEVEL(toplevel) && gtk_window_has_toplevel_focus(GTK_WINDOW(toplevel))) {
+#endif
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
FocusController* focusController = core(webView)->focusController();
@@ -814,7 +849,11 @@ static gboolean webkit_web_view_script_dialog(WebKitWebView* webView, WebKitWebF
}
window = gtk_widget_get_toplevel(GTK_WIDGET(webView));
+#if GTK_CHECK_VERSION(2, 18, 0)
+ dialog = gtk_message_dialog_new(gtk_widget_is_toplevel(window) ? GTK_WINDOW(window) : 0, GTK_DIALOG_DESTROY_WITH_PARENT, messageType, buttons, "%s", message);
+#else
dialog = gtk_message_dialog_new(GTK_WIDGET_TOPLEVEL(window) ? GTK_WINDOW(window) : 0, GTK_DIALOG_DESTROY_WITH_PARENT, messageType, buttons, "%s", message);
+#endif
gchar* title = g_strconcat("JavaScript - ", webkit_web_frame_get_uri(frame), NULL);
gtk_window_set_title(GTK_WINDOW(dialog), title);
g_free(title);
@@ -1028,6 +1067,7 @@ static void webkit_web_view_finalize(GObject* object)
WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
WebKitWebViewPrivate* priv = webView->priv;
+ g_free(priv->tooltipText);
g_free(priv->mainResourceIdentifier);
g_free(priv->encoding);
g_free(priv->customEncoding);
@@ -1251,6 +1291,26 @@ static void webkit_web_view_drag_data_get(GtkWidget* widget, GdkDragContext* con
clipboard_contents_received, contents_request);
}
+#if GTK_CHECK_VERSION(2, 12, 0)
+static gboolean webkit_web_view_query_tooltip(GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip)
+{
+ WebKitWebViewPrivate* priv = WEBKIT_WEB_VIEW_GET_PRIVATE(widget);
+
+ if (priv->tooltipText) {
+ gtk_tooltip_set_text(tooltip, priv->tooltipText);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+#endif
+
+static GtkIMContext* webkit_web_view_get_im_context(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+ return GTK_IM_CONTEXT(webView->priv->imContext);
+}
+
static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
{
GtkBindingSet* binding_set;
@@ -1521,9 +1581,10 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* @return: %TRUE if the download should be performed, %FALSE to cancel it.
*
* A new Download is being requested. By default, if the signal is
- * not handled, the download is cancelled. Notice that while
- * handling this signal you must set the target URI using
- * webkit_download_set_target_uri().
+ * not handled, the download is cancelled. If you handle the download
+ * and call webkit_download_set_destination_uri(), it will be
+ * started for you. If you need to set the destination asynchronously
+ * you are responsible for starting or cancelling it yourself.
*
* If you intend to handle downloads yourself rather than using
* the #WebKitDownload helper object you must handle this signal,
@@ -1558,6 +1619,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* @frame: the frame going to do the load
*
* When a #WebKitWebFrame begins to load this signal is emitted.
+ *
+ * Deprecated: Use the "load-status" property instead.
*/
webkit_web_view_signals[LOAD_STARTED] = g_signal_new("load-started",
G_TYPE_FROM_CLASS(webViewClass),
@@ -1575,6 +1638,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* @frame: the main frame that received the first data
*
* When a #WebKitWebFrame loaded the first data this signal is emitted.
+ *
+ * Deprecated: Use the "load-status" property instead.
*/
webkit_web_view_signals[LOAD_COMMITTED] = g_signal_new("load-committed",
G_TYPE_FROM_CLASS(webViewClass),
@@ -1591,6 +1656,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
* WebKitWebView::load-progress-changed:
* @web_view: the #WebKitWebView
* @progress: the global progress
+ *
+ * Deprecated: Use the "progress" property instead.
*/
webkit_web_view_signals[LOAD_PROGRESS_CHANGED] = g_signal_new("load-progress-changed",
G_TYPE_FROM_CLASS(webViewClass),
@@ -1627,6 +1694,13 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
G_TYPE_STRING,
G_TYPE_POINTER);
+ /**
+ * WebKitWebView::load-finished:
+ * @web_view: the #WebKitWebView
+ * @frame: the #WebKitWebFrame
+ *
+ * Deprecated: Use the "load-status" property instead.
+ */
webkit_web_view_signals[LOAD_FINISHED] = g_signal_new("load-finished",
G_TYPE_FROM_CLASS(webViewClass),
(GSignalFlags)G_SIGNAL_RUN_LAST,
@@ -2106,6 +2180,9 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
widgetClass->screen_changed = webkit_web_view_screen_changed;
widgetClass->drag_end = webkit_web_view_drag_end;
widgetClass->drag_data_get = webkit_web_view_drag_data_get;
+#if GTK_CHECK_VERSION(2, 12, 0)
+ widgetClass->query_tooltip = webkit_web_view_query_tooltip;
+#endif
GtkContainerClass* containerClass = GTK_CONTAINER_CLASS(webViewClass);
containerClass->add = webkit_web_view_container_add;
@@ -2369,6 +2446,16 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
*
* Determines the current status of the load.
*
+ * Connect to "notify::load-status" to monitor loading.
+ *
+ * Some versions of WebKitGTK+ emitted this signal for the default
+ * error page, while loading it. This behavior was considered bad,
+ * because it was essentially exposing an implementation
+ * detail. From 1.1.19 onwards this signal is no longer emitted for
+ * the default error pages, but keep in mind that if you override
+ * the error pages by using webkit_web_frame_load_alternate_string()
+ * the signals will be emitted.
+ *
* Since: 1.1.7
*/
g_object_class_install_property(objectClass, PROP_LOAD_STATUS,
@@ -2406,6 +2493,23 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
_("The URI for the favicon for the #WebKitWebView."),
NULL,
WEBKIT_PARAM_READABLE));
+ /**
+ * WebKitWebView:im-context:
+ *
+ * The GtkIMMulticontext for the #WebKitWebView.
+ *
+ * This is the input method context used for all text entry widgets inside
+ * the #WebKitWebView. It can be used to generate context menu items for
+ * controlling the active input method.
+ *
+ * Since: 1.1.20
+ */
+ g_object_class_install_property(objectClass, PROP_IM_CONTEXT,
+ g_param_spec_object("im-context",
+ "IM Context",
+ "The GtkIMMultiContext for the #WebKitWebView.",
+ GTK_TYPE_IM_CONTEXT,
+ WEBKIT_PARAM_READABLE));
g_type_class_add_private(webViewClass, sizeof(WebKitWebViewPrivate));
}
@@ -2421,7 +2525,8 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
enableScripts, enablePlugins, enableDeveloperExtras, resizableTextAreas,
enablePrivateBrowsing, enableCaretBrowsing, enableHTML5Database, enableHTML5LocalStorage,
enableXSSAuditor, javascriptCanOpenWindows, enableOfflineWebAppCache,
- enableUniversalAccessFromFileURI, enableDOMPaste, tabKeyCyclesThroughElements;
+ enableUniversalAccessFromFileURI, enableDOMPaste, tabKeyCyclesThroughElements,
+ enableSiteSpecificQuirks, usePageCache;
WebKitEditingBehavior editingBehavior;
@@ -2452,6 +2557,8 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
"enable-universal-access-from-file-uris", &enableUniversalAccessFromFileURI,
"enable-dom-paste", &enableDOMPaste,
"tab-key-cycles-through-elements", &tabKeyCyclesThroughElements,
+ "enable-site-specific-quirks", &enableSiteSpecificQuirks,
+ "enable-page-cache", &usePageCache,
NULL);
settings->setDefaultTextEncodingName(defaultEncoding);
@@ -2479,6 +2586,8 @@ static void webkit_web_view_update_settings(WebKitWebView* webView)
settings->setEditingBehavior(core(editingBehavior));
settings->setAllowUniversalAccessFromFileURLs(enableUniversalAccessFromFileURI);
settings->setDOMPasteAllowed(enableDOMPaste);
+ settings->setNeedsSiteSpecificQuirks(enableSiteSpecificQuirks);
+ settings->setUsesPageCache(usePageCache);
Page* page = core(webView);
if (page)
@@ -2575,7 +2684,10 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar
Page* page = core(webView);
if (page)
page->setTabKeyCyclesThroughElements(g_value_get_boolean(&value));
- }
+ } else if (name == g_intern_string("enable-site-specific-quirks"))
+ settings->setNeedsSiteSpecificQuirks(g_value_get_boolean(&value));
+ else if (name == g_intern_string("enable-page-cache"))
+ settings->setUsesPageCache(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);
@@ -2618,6 +2730,8 @@ static void webkit_web_view_init(WebKitWebView* webView)
priv->webWindowFeatures = webkit_web_window_features_new();
priv->subResources = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref);
+
+ priv->tooltipText = 0;
}
GtkWidget* webkit_web_view_new(void)
@@ -2656,7 +2770,10 @@ void webkit_web_view_request_download(WebKitWebView* webView, WebKitNetworkReque
return;
}
- webkit_download_start(download);
+ /* Start the download now if it has a destination URI, otherwise it
+ may be handled asynchronously by the application. */
+ if (webkit_download_get_destination_uri(download))
+ webkit_download_start(download);
}
bool webkit_web_view_use_primary_for_paste(WebKitWebView* webView)
@@ -3969,6 +4086,27 @@ static IntPoint documentPointForWindowPoint(Frame* frame, const IntPoint& window
return view ? view->windowToContents(windowPoint) : windowPoint;
}
+void webkit_web_view_set_tooltip_text(WebKitWebView* webView, const char* tooltip)
+{
+#if GTK_CHECK_VERSION(2, 12, 0)
+ WebKitWebViewPrivate* priv = webView->priv;
+ g_free(priv->tooltipText);
+ if (tooltip && *tooltip != '\0') {
+ priv->tooltipText = g_strdup(tooltip);
+ gtk_widget_set_has_tooltip(GTK_WIDGET(webView), TRUE);
+ } else {
+ priv->tooltipText = 0;
+ gtk_widget_set_has_tooltip(GTK_WIDGET(webView), FALSE);
+ }
+
+ gtk_widget_trigger_tooltip_query(GTK_WIDGET(webView));
+#else
+ // TODO: Support older GTK+ versions
+ // See http://bugs.webkit.org/show_bug.cgi?id=15793
+ notImplemented();
+#endif
+}
+
/**
* webkit_web_view_get_hit_test_result:
* @webView: a #WebKitWebView
@@ -4019,3 +4157,81 @@ G_CONST_RETURN gchar* webkit_web_view_get_icon_uri(WebKitWebView* webView)
priv->iconURI = g_strdup(iconURL.utf8().data());
return priv->iconURI;
}
+
+/**
+ * webkit_set_cache_model:
+ * @cache_model: a #WebKitCacheModel
+ *
+ * Specifies a usage model for WebViews, which WebKit will use to
+ * determine its caching behavior. All web views follow the cache
+ * model. This cache model determines the RAM and disk space to use
+ * for caching previously viewed content .
+ *
+ * Research indicates that users tend to browse within clusters of
+ * documents that hold resources in common, and to revisit previously
+ * visited documents. WebKit and the frameworks below it include
+ * built-in caches that take advantage of these patterns,
+ * substantially improving document load speed in browsing
+ * situations. The WebKit cache model controls the behaviors of all of
+ * these caches, including various WebCore caches.
+ *
+ * Browsers can improve document load speed substantially by
+ * specifying WEBKIT_CACHE_MODEL_WEB_BROWSER. Applications without a
+ * browsing interface can reduce memory usage substantially by
+ * specifying WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER. Default value is
+ * WEBKIT_CACHE_MODEL_WEB_BROWSER.
+ *
+ * Since: 1.1.18
+ */
+void webkit_set_cache_model(WebKitCacheModel model)
+{
+ if (cacheModel == model)
+ return;
+
+ // FIXME: Add disk cache handling when soup has the API
+ guint cacheTotalCapacity;
+ guint cacheMinDeadCapacity;
+ guint cacheMaxDeadCapacity;
+ gdouble deadDecodedDataDeletionInterval;
+ guint pageCacheCapacity;
+
+ switch (model) {
+ case WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER:
+ pageCacheCapacity = 0;
+ cacheTotalCapacity = 0;
+ cacheMinDeadCapacity = 0;
+ cacheMaxDeadCapacity = 0;
+ deadDecodedDataDeletionInterval = 0;
+ break;
+ case WEBKIT_CACHE_MODEL_WEB_BROWSER:
+ pageCacheCapacity = 3;
+ cacheTotalCapacity = 32 * 1024 * 1024;
+ cacheMinDeadCapacity = cacheTotalCapacity / 4;
+ cacheMaxDeadCapacity = cacheTotalCapacity / 2;
+ deadDecodedDataDeletionInterval = 60;
+ break;
+ default:
+ g_return_if_reached();
+ }
+
+ cache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity);
+ cache()->setDeadDecodedDataDeletionInterval(deadDecodedDataDeletionInterval);
+ pageCache()->setCapacity(pageCacheCapacity);
+ cacheModel = model;
+}
+
+/**
+ * webkit_get_cache_model:
+ *
+ * Returns the current cache model. For more information about this
+ * value check the documentation of the function
+ * webkit_set_cache_model().
+ *
+ * Return value: the current #WebKitCacheModel
+ *
+ * Since: 1.1.18
+ */
+WebKitCacheModel webkit_get_cache_model()
+{
+ return cacheModel;
+}
diff --git a/WebKit/gtk/webkit/webkitwebview.h b/WebKit/gtk/webkit/webkitwebview.h
index 8dd7f39..e69de0a 100644
--- a/WebKit/gtk/webkit/webkitwebview.h
+++ b/WebKit/gtk/webkit/webkitwebview.h
@@ -49,6 +49,11 @@ typedef enum {
WEBKIT_NAVIGATION_RESPONSE_DOWNLOAD
} WebKitNavigationResponse;
+typedef enum {
+ WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER = 1,
+ WEBKIT_CACHE_MODEL_WEB_BROWSER
+} WebKitCacheModel;
+
typedef enum
{
WEBKIT_WEB_VIEW_TARGET_INFO_HTML,
@@ -370,6 +375,12 @@ webkit_web_view_get_hit_test_result (WebKitWebView *webView,
WEBKIT_API G_CONST_RETURN gchar *
webkit_web_view_get_icon_uri (WebKitWebView *webView);
+WEBKIT_API void
+webkit_set_cache_model (WebKitCacheModel cache_model);
+
+WEBKIT_API WebKitCacheModel
+webkit_get_cache_model (void);
+
G_END_DECLS
#endif