diff options
Diffstat (limited to 'Source/WebKit/gtk/webkit')
-rw-r--r-- | Source/WebKit/gtk/webkit/webkit.h | 1 | ||||
-rw-r--r-- | Source/WebKit/gtk/webkit/webkitapplicationcache.cpp | 28 | ||||
-rw-r--r-- | Source/WebKit/gtk/webkit/webkitapplicationcache.h | 7 | ||||
-rw-r--r-- | Source/WebKit/gtk/webkit/webkitdefines.h | 3 | ||||
-rw-r--r-- | Source/WebKit/gtk/webkit/webkitglobals.cpp | 45 | ||||
-rw-r--r-- | Source/WebKit/gtk/webkit/webkitglobals.h | 3 | ||||
-rw-r--r-- | Source/WebKit/gtk/webkit/webkitglobalsprivate.h | 1 | ||||
-rw-r--r-- | Source/WebKit/gtk/webkit/webkiticondatabase.cpp | 317 | ||||
-rw-r--r-- | Source/WebKit/gtk/webkit/webkiticondatabase.h | 78 | ||||
-rw-r--r-- | Source/WebKit/gtk/webkit/webkitviewportattributes.cpp | 2 | ||||
-rw-r--r-- | Source/WebKit/gtk/webkit/webkitwebframe.cpp | 17 | ||||
-rw-r--r-- | Source/WebKit/gtk/webkit/webkitwebplugindatabase.cpp | 3 | ||||
-rw-r--r-- | Source/WebKit/gtk/webkit/webkitwebsettings.cpp | 31 | ||||
-rw-r--r-- | Source/WebKit/gtk/webkit/webkitwebview.cpp | 63 | ||||
-rw-r--r-- | Source/WebKit/gtk/webkit/webkitwebview.h | 3 |
15 files changed, 519 insertions, 83 deletions
diff --git a/Source/WebKit/gtk/webkit/webkit.h b/Source/WebKit/gtk/webkit/webkit.h index d85d698..77e96bc 100644 --- a/Source/WebKit/gtk/webkit/webkit.h +++ b/Source/WebKit/gtk/webkit/webkit.h @@ -30,6 +30,7 @@ #include <webkit/webkitgeolocationpolicydecision.h> #include <webkit/webkitglobals.h> #include <webkit/webkithittestresult.h> +#include <webkit/webkiticondatabase.h> #include <webkit/webkitnetworkrequest.h> #include <webkit/webkitnetworkresponse.h> #include <webkit/webkitsecurityorigin.h> diff --git a/Source/WebKit/gtk/webkit/webkitapplicationcache.cpp b/Source/WebKit/gtk/webkit/webkitapplicationcache.cpp index ab179b5..0b65d04 100644 --- a/Source/WebKit/gtk/webkit/webkitapplicationcache.cpp +++ b/Source/WebKit/gtk/webkit/webkitapplicationcache.cpp @@ -26,8 +26,6 @@ #include <wtf/UnusedParam.h> #include <wtf/text/CString.h> -// keeps current directory path to offline web applications cache database -static WTF::CString cacheDirectoryPath = ""; // web application cache maximum storage size static unsigned long long cacheMaxSize = UINT_MAX; @@ -89,33 +87,9 @@ G_CONST_RETURN gchar* webkit_application_cache_get_database_directory_path() { #if ENABLE(OFFLINE_WEB_APPLICATIONS) CString path = WebCore::fileSystemRepresentation(WebCore::cacheStorage().cacheDirectory()); - - if (path != cacheDirectoryPath) - cacheDirectoryPath = path; - - return cacheDirectoryPath.data(); + return path.data(); #else return ""; #endif } -/** - * webkit_application_cache_set_database_directory_path: - * @path: the new web application cache database path - * - * Sets the current path to the directory WebKit will write web aplication cache - * databases. - * - * Since: 1.3.13 - **/ -void webkit_application_cache_set_database_directory_path(const gchar* path) -{ -#if ENABLE(OFFLINE_WEB_APPLICATIONS) - WTF::CString pathString(path); - if (pathString != cacheDirectoryPath) - cacheDirectoryPath = pathString; - - WebCore::cacheStorage().setCacheDirectory(WebCore::filenameToString(cacheDirectoryPath.data())); -#endif -} - diff --git a/Source/WebKit/gtk/webkit/webkitapplicationcache.h b/Source/WebKit/gtk/webkit/webkitapplicationcache.h index 810a5d6..bb0f867 100644 --- a/Source/WebKit/gtk/webkit/webkitapplicationcache.h +++ b/Source/WebKit/gtk/webkit/webkitapplicationcache.h @@ -25,16 +25,13 @@ G_BEGIN_DECLS WEBKIT_API unsigned long long -webkit_application_cache_get_maximum_size(); +webkit_application_cache_get_maximum_size(void); WEBKIT_API void webkit_application_cache_set_maximum_size(unsigned long long size); WEBKIT_API G_CONST_RETURN gchar* -webkit_application_cache_get_database_directory_path (void); - -WEBKIT_API void -webkit_application_cache_set_database_directory_path (const gchar* path); +webkit_application_cache_get_database_directory_path(void); G_END_DECLS diff --git a/Source/WebKit/gtk/webkit/webkitdefines.h b/Source/WebKit/gtk/webkit/webkitdefines.h index b0b607b..0b88084 100644 --- a/Source/WebKit/gtk/webkit/webkitdefines.h +++ b/Source/WebKit/gtk/webkit/webkitdefines.h @@ -41,6 +41,9 @@ G_BEGIN_DECLS +typedef struct _WebKitIconDatabase WebKitIconDatabase; +typedef struct _WebKitIconDatabaseClass WebKitIconDatabaseClass; + typedef struct _WebKitNetworkRequest WebKitNetworkRequest; typedef struct _WebKitNetworkRequestClass WebKitNetworkRequestClass; diff --git a/Source/WebKit/gtk/webkit/webkitglobals.cpp b/Source/WebKit/gtk/webkit/webkitglobals.cpp index 4d07ceb..b8d8b1f 100644 --- a/Source/WebKit/gtk/webkit/webkitglobals.cpp +++ b/Source/WebKit/gtk/webkit/webkitglobals.cpp @@ -40,6 +40,7 @@ #include "ResourceResponse.h" #include "webkitapplicationcache.h" #include "webkitglobalsprivate.h" +#include "webkiticondatabase.h" #include "webkitsoupauthdialog.h" #include "webkitwebdatabase.h" #include "webkitwebplugindatabaseprivate.h" @@ -223,9 +224,24 @@ static GtkWidget* currentToplevelCallback(WebKitSoupAuthDialog* feature, SoupMes return NULL; } -static void closeIconDatabaseOnExit() +/** + * webkit_get_icon_database: + * + * Returns the #WebKitIconDatabase providing access to website icons. + * + * Return value: (transfer none): the current #WebKitIconDatabase + * + * Since: 1.3.13 + */ +WebKitIconDatabase* webkit_get_icon_database() { - iconDatabase().close(); + webkitInit(); + + static WebKitIconDatabase* database = 0; + if (!database) + database = WEBKIT_ICON_DATABASE(g_object_new(WEBKIT_TYPE_ICON_DATABASE, NULL)); + + return database; } void webkitInit() @@ -249,14 +265,15 @@ void webkitInit() gchar* databaseDirectory = g_build_filename(g_get_user_data_dir(), "webkit", "databases", NULL); webkit_set_web_database_directory_path(databaseDirectory); - webkit_application_cache_set_database_directory_path(databaseDirectory); + WebCore::cacheStorage().setCacheDirectory(databaseDirectory); g_free(databaseDirectory); PageGroup::setShouldTrackVisitedLinks(true); Pasteboard::generalPasteboard()->setHelper(WebKit::pasteboardHelperInstance()); - WebKit::setIconDatabaseEnabled(true); + GOwnPtr<gchar> iconDatabasePath(g_build_filename(g_get_user_data_dir(), "webkit", "icondatabase", NULL)); + webkit_icon_database_set_path(webkit_get_icon_database(), iconDatabasePath.get()); SoupSession* session = webkit_get_default_session(); @@ -280,25 +297,5 @@ PasteboardHelperGtk* pasteboardHelperInstance() return helper; } -void setIconDatabaseEnabled(bool enabled) -{ - static bool initialized = false; - if (enabled && !initialized) { - initialized = true; - atexit(closeIconDatabaseOnExit); - } - - if (enabled) { - iconDatabase().setEnabled(true); - GOwnPtr<gchar> iconDatabasePath(g_build_filename(g_get_user_data_dir(), "webkit", "icondatabase", NULL)); - iconDatabase().open(iconDatabasePath.get()); - return; - } - - iconDatabase().setEnabled(false); - iconDatabase().close(); -} - - } /** end namespace WebKit */ diff --git a/Source/WebKit/gtk/webkit/webkitglobals.h b/Source/WebKit/gtk/webkit/webkitglobals.h index 612c195..33d2b8b 100644 --- a/Source/WebKit/gtk/webkit/webkitglobals.h +++ b/Source/WebKit/gtk/webkit/webkitglobals.h @@ -58,6 +58,9 @@ webkit_get_default_session (void); WEBKIT_API WebKitWebPluginDatabase * webkit_get_web_plugin_database (void); +WEBKIT_API WebKitIconDatabase * +webkit_get_icon_database (void); + WEBKIT_API void webkit_set_cache_model (WebKitCacheModel cache_model); diff --git a/Source/WebKit/gtk/webkit/webkitglobalsprivate.h b/Source/WebKit/gtk/webkit/webkitglobalsprivate.h index 7eb3aae..5923f2e 100644 --- a/Source/WebKit/gtk/webkit/webkitglobalsprivate.h +++ b/Source/WebKit/gtk/webkit/webkitglobalsprivate.h @@ -33,7 +33,6 @@ namespace WebKit { class PasteboardHelperGtk; PasteboardHelperGtk* pasteboardHelperInstance(); -void setIconDatabaseEnabled(bool); } extern "C" { diff --git a/Source/WebKit/gtk/webkit/webkiticondatabase.cpp b/Source/WebKit/gtk/webkit/webkiticondatabase.cpp new file mode 100644 index 0000000..397bd51 --- /dev/null +++ b/Source/WebKit/gtk/webkit/webkiticondatabase.cpp @@ -0,0 +1,317 @@ +/* + * Copyright (C) 2011 Christian Dywan <christian@lanedo.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 "webkiticondatabase.h" + +#include "DatabaseDetails.h" +#include "DatabaseTracker.h" +#include "FileSystem.h" +#include "IconDatabase.h" +#include "Image.h" +#include "IntSize.h" +#include "webkitglobalsprivate.h" +#include "webkitmarshal.h" +#include "webkitsecurityoriginprivate.h" +#include "webkitwebframe.h" +#include <glib/gi18n-lib.h> +#include <wtf/gobject/GOwnPtr.h> +#include <wtf/text/CString.h> + +/** + * SECTION:webkitwebdatabase + * @short_description: A WebKit web application database + * + * #WebKitIconDatabase provides access to website icons, as shown + * in tab labels, window captions or bookmarks. All views share + * the same icon database. + * + * The icon database is enabled by default and stored in + * ~/.local/share/webkit/icondatabase, depending on XDG_DATA_HOME. + * + * WebKit will automatically look for available icons in link elements + * on opened pages as well as an existing favicon.ico and load the + * images found into the memory cache if possible. The signal "icon-loaded" + * will be emitted when any icon is found and loaded. + * Old Icons are automatically cleaned up after 4 days. + * + * webkit_icon_database_set_path() can be used to change the location + * of the database and also to disable it by passing %NULL. + * + * If WebKitWebSettings::enable-private-browsing is %TRUE new icons + * won't be added to the database on disk and no existing icons will + * be deleted from it. + * + * Since: 1.3.13 + */ + +using namespace WebKit; + +enum { + PROP_0, + + PROP_PATH, +}; + +enum { + ICON_LOADED, + + LAST_SIGNAL +}; + +static guint webkit_icon_database_signals[LAST_SIGNAL] = { 0, }; + +G_DEFINE_TYPE(WebKitIconDatabase, webkit_icon_database, G_TYPE_OBJECT); + +struct _WebKitIconDatabasePrivate { + GOwnPtr<gchar> path; +}; + +static void webkit_icon_database_finalize(GObject* object) +{ + // Call C++ destructors, the reverse of 'placement new syntax' + WEBKIT_ICON_DATABASE(object)->priv->~WebKitIconDatabasePrivate(); + + G_OBJECT_CLASS(webkit_icon_database_parent_class)->finalize(object); +} + +static void webkit_icon_database_dispose(GObject* object) +{ + G_OBJECT_CLASS(webkit_icon_database_parent_class)->dispose(object); +} + +static void webkit_icon_database_set_property(GObject* object, guint propId, const GValue* value, GParamSpec* pspec) +{ + WebKitIconDatabase* database = WEBKIT_ICON_DATABASE(object); + + switch (propId) { + case PROP_PATH: + webkit_icon_database_set_path(database, g_value_get_string(value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, pspec); + break; + } +} + +static void webkit_icon_database_get_property(GObject* object, guint propId, GValue* value, GParamSpec* pspec) +{ + WebKitIconDatabase* database = WEBKIT_ICON_DATABASE(object); + + switch (propId) { + case PROP_PATH: + g_value_set_string(value, webkit_icon_database_get_path(database)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, pspec); + break; + } +} + +static void webkit_icon_database_class_init(WebKitIconDatabaseClass* klass) +{ + webkitInit(); + + GObjectClass* gobjectClass = G_OBJECT_CLASS(klass); + gobjectClass->dispose = webkit_icon_database_dispose; + gobjectClass->finalize = webkit_icon_database_finalize; + gobjectClass->set_property = webkit_icon_database_set_property; + gobjectClass->get_property = webkit_icon_database_get_property; + + /** + * WebKitIconDatabase:path: + * + * The absolute path of the icon database folder. + * + * Since: 1.3.13 + */ + g_object_class_install_property(gobjectClass, PROP_PATH, + g_param_spec_string("path", + _("Path"), + _("The absolute path of the icon database folder"), + NULL, + WEBKIT_PARAM_READWRITE)); + + /** + * WebKitIconDatabase::icon-loaded: + * @database: the object on which the signal is emitted + * @frame: the frame containing the icon + * @frame_uri: the URI of the frame containing the icon + * + * This signal is emitted when a favicon is available for a page, + * or a child frame. + * See WebKitWebView::icon-loaded if you only need the favicon for + * the main frame of a particular #WebKitWebView. + * + * Since: 1.3.13 + */ + webkit_icon_database_signals[ICON_LOADED] = g_signal_new("icon-loaded", + G_TYPE_FROM_CLASS(klass), + (GSignalFlags)G_SIGNAL_RUN_LAST, + 0, + NULL, + NULL, + webkit_marshal_VOID__OBJECT_STRING, + G_TYPE_NONE, 2, + WEBKIT_TYPE_WEB_FRAME, + G_TYPE_STRING); + + g_type_class_add_private(klass, sizeof(WebKitIconDatabasePrivate)); +} + +static void webkit_icon_database_init(WebKitIconDatabase* database) +{ + database->priv = G_TYPE_INSTANCE_GET_PRIVATE(database, WEBKIT_TYPE_ICON_DATABASE, WebKitIconDatabasePrivate); + // 'placement new syntax', see webkitwebview.cpp + new (database->priv) WebKitIconDatabasePrivate(); +} + +/** + * webkit_icon_database_get_path: + * @database: a #WebKitIconDatabase + * + * Determines the absolute path to the database folder on disk. + * + * Returns: the absolute path of the database folder, or %NULL + * + * Since: 1.3.13 + **/ +G_CONST_RETURN gchar* webkit_icon_database_get_path(WebKitIconDatabase* database) +{ + g_return_val_if_fail(WEBKIT_IS_ICON_DATABASE(database), 0); + + return database->priv->path.get(); +} + +static void closeIconDatabaseOnExit() +{ + if (WebCore::iconDatabase().isEnabled()) { + WebCore::iconDatabase().setEnabled(false); + WebCore::iconDatabase().close(); + } +} + +/** + * webkit_icon_database_set_path: + * @database: a #WebKitIconDatabase + * @path: an absolute path to the icon database folder + * + * Specifies the absolute path to the database folder on disk. + * + * Passing %NULL or "" disables the icon database. + * + * Since: 1.3.13 + **/ +void webkit_icon_database_set_path(WebKitIconDatabase* database, const gchar* path) +{ + g_return_if_fail(WEBKIT_IS_ICON_DATABASE(database)); + + if (database->priv->path.get()) + WebCore::iconDatabase().close(); + + if (!(path && path[0])) { + database->priv->path.set(0); + WebCore::iconDatabase().setEnabled(false); + return; + } + + database->priv->path.set(g_strdup(path)); + + WebCore::iconDatabase().setEnabled(true); + WebCore::iconDatabase().open(WebCore::filenameToString(database->priv->path.get()), WebCore::IconDatabase::defaultDatabaseFilename()); + + static bool initialized = false; + if (!initialized) { + atexit(closeIconDatabaseOnExit); + initialized = true; + } +} + +/** + * webkit_icon_database_get_icon_uri: + * @database: a #WebKitIconDatabase + * @page_uri: URI of the page containing the icon + * + * Obtains the URI for the favicon for the given page URI. + * See also webkit_web_view_get_icon_uri(). + * + * Returns: a newly allocated URI for the favicon, or %NULL + * + * Since: 1.3.13 + **/ +gchar* webkit_icon_database_get_icon_uri(WebKitIconDatabase* database, const gchar* pageURI) +{ + g_return_val_if_fail(WEBKIT_IS_ICON_DATABASE(database), 0); + g_return_val_if_fail(pageURI, 0); + + String pageURL = String::fromUTF8(pageURI); + return g_strdup(WebCore::iconDatabase().synchronousIconURLForPageURL(pageURL).utf8().data()); +} + +/** + * webkit_icon_database_get_icon_pixbuf: + * @database: a #WebKitIconDatabase + * @page_uri: URI of the page containing the icon + * + * Obtains a #GdkPixbuf of the favicon for the given page URI, or + * a default icon if there is no icon for the given page. Use + * webkit_icon_database_get_icon_uri() if you need to distinguish these cases. + * Usually you want to connect to WebKitIconDatabase::icon-loaded and call this + * method in the callback. + * + * The pixbuf will have the largest size provided by the server and should + * be resized before it is displayed. + * See also webkit_web_view_get_icon_pixbuf(). + * + * Returns: (transfer full): a new reference to a #GdkPixbuf, or %NULL + * + * Since: 1.3.13 + **/ +GdkPixbuf* webkit_icon_database_get_icon_pixbuf(WebKitIconDatabase* database, const gchar* pageURI) +{ + g_return_val_if_fail(WEBKIT_IS_ICON_DATABASE(database), 0); + g_return_val_if_fail(pageURI, 0); + + String pageURL = String::fromUTF8(pageURI); + // The exact size we pass is irrelevant to the WebCore::iconDatabase code. + // We must pass something greater than 0, 0 to get a pixbuf. + WebCore::Image* icon = WebCore::iconDatabase().synchronousIconForPageURL(pageURL, WebCore::IntSize(16, 16)); + if (!icon) + return 0; + GdkPixbuf* pixbuf = icon->getGdkPixbuf(); + if (!pixbuf) + return 0; + return static_cast<GdkPixbuf*>(g_object_ref(pixbuf)); +} + +/** + * webkit_icon_database_clear(): + * @database: a #WebKitIconDatabase + * + * Clears all icons from the database. + * + * Since: 1.3.13 + **/ +void webkit_icon_database_clear(WebKitIconDatabase* database) +{ + g_return_if_fail(WEBKIT_IS_ICON_DATABASE(database)); + + WebCore::iconDatabase().removeAllIcons(); +} + diff --git a/Source/WebKit/gtk/webkit/webkiticondatabase.h b/Source/WebKit/gtk/webkit/webkiticondatabase.h new file mode 100644 index 0000000..7fe5acd --- /dev/null +++ b/Source/WebKit/gtk/webkit/webkiticondatabase.h @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2011 Christian Dywan <christian@lanedo.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 webkiticondatabase_h +#define webkiticondatabase_h + +#include <gdk-pixbuf/gdk-pixbuf.h> +#include <glib-object.h> +#include <webkit/webkitdefines.h> + +G_BEGIN_DECLS + +#define WEBKIT_TYPE_ICON_DATABASE (webkit_icon_database_get_type()) +#define WEBKIT_ICON_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_ICON_DATABASE, WebKitIconDatabase)) +#define WEBKIT_ICON_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_ICON_DATABASE, WebKitIconDatabaseClass)) +#define WEBKIT_IS_ICON_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_ICON_DATABASE)) +#define WEBKIT_IS_ICON_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_ICON_DATABASE)) +#define WEBKIT_ICON_DATABASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_ICON_DATABASE, WebKitIconDatabaseClass)) + +typedef struct _WebKitIconDatabasePrivate WebKitIconDatabasePrivate; + +struct _WebKitIconDatabase { + GObject parent_instance; + + /*< private >*/ + WebKitIconDatabasePrivate* priv; +}; + +struct _WebKitIconDatabaseClass { + GObjectClass parent_class; + + /* Padding for future expansion */ + void (*_webkit_reserved1) (void); + void (*_webkit_reserved2) (void); + void (*_webkit_reserved3) (void); + void (*_webkit_reserved4) (void); +}; + +WEBKIT_API GType +webkit_icon_database_get_type (void); + +WEBKIT_API G_CONST_RETURN gchar* +webkit_icon_database_get_path (WebKitIconDatabase* database); + +WEBKIT_API void +webkit_icon_database_set_path (WebKitIconDatabase* database, + const gchar* path); + +WEBKIT_API gchar* +webkit_icon_database_get_icon_uri (WebKitIconDatabase* database, + const gchar* page_uri); + +WEBKIT_API GdkPixbuf* +webkit_icon_database_get_icon_pixbuf (WebKitIconDatabase* database, + const gchar* page_uri); + +WEBKIT_API void +webkit_icon_database_clear (WebKitIconDatabase* database); + +G_END_DECLS + +#endif /* webkiticondatabase_h */ diff --git a/Source/WebKit/gtk/webkit/webkitviewportattributes.cpp b/Source/WebKit/gtk/webkit/webkitviewportattributes.cpp index 9a98e44..742cddd 100644 --- a/Source/WebKit/gtk/webkit/webkitviewportattributes.cpp +++ b/Source/WebKit/gtk/webkit/webkitviewportattributes.cpp @@ -542,7 +542,7 @@ void webkitViewportAttributesRecompute(WebKitViewportAttributes* viewportAttribu priv->minimumScaleFactor = attributes.minimumScale; priv->maximumScaleFactor = attributes.maximumScale; priv->devicePixelRatio = attributes.devicePixelRatio; - priv->userScalable = arguments.userScalable; + priv->userScalable = static_cast<bool>(arguments.userScalable); if (!priv->isValid) { priv->isValid = TRUE; diff --git a/Source/WebKit/gtk/webkit/webkitwebframe.cpp b/Source/WebKit/gtk/webkit/webkitwebframe.cpp index fd90a6c..a0e40b3 100644 --- a/Source/WebKit/gtk/webkit/webkitwebframe.cpp +++ b/Source/WebKit/gtk/webkit/webkitwebframe.cpp @@ -44,6 +44,7 @@ #include "JSDOMBinding.h" #include "JSDOMWindow.h" #include "JSElement.h" +#include "PlatformContextCairo.h" #include "PrintContext.h" #include "RenderListItem.h" #include "RenderTreeAsText.h" @@ -765,17 +766,17 @@ static void begin_print_callback(GtkPrintOperation* op, GtkPrintContext* context gtk_print_operation_set_n_pages(op, printContext->pageCount()); } -static void draw_page_callback(GtkPrintOperation* op, GtkPrintContext* context, gint page_nr, gpointer user_data) +static void draw_page_callback(GtkPrintOperation*, GtkPrintContext* gtkPrintContext, gint pageNumber, PrintContext* corePrintContext) { - PrintContext* printContext = reinterpret_cast<PrintContext*>(user_data); - - if (page_nr >= static_cast<gint>(printContext->pageCount())) + if (pageNumber >= static_cast<gint>(corePrintContext->pageCount())) return; - cairo_t* cr = gtk_print_context_get_cairo_context(context); - GraphicsContext ctx(cr); - float width = gtk_print_context_get_width(context); - printContext->spoolPage(ctx, page_nr, width); + cairo_t* cr = gtk_print_context_get_cairo_context(gtkPrintContext); + float pageWidth = gtk_print_context_get_width(gtkPrintContext); + + PlatformContextCairo platformContext(cr); + GraphicsContext graphicsContext(&platformContext); + corePrintContext->spoolPage(graphicsContext, pageNumber, pageWidth); } static void end_print_callback(GtkPrintOperation* op, GtkPrintContext* context, gpointer user_data) diff --git a/Source/WebKit/gtk/webkit/webkitwebplugindatabase.cpp b/Source/WebKit/gtk/webkit/webkitwebplugindatabase.cpp index 2d36115..1ed5205 100644 --- a/Source/WebKit/gtk/webkit/webkitwebplugindatabase.cpp +++ b/Source/WebKit/gtk/webkit/webkitwebplugindatabase.cpp @@ -74,7 +74,8 @@ static void webkit_web_plugin_database_init(WebKitWebPluginDatabase* database) */ void webkit_web_plugin_database_plugins_list_free(GSList* list) { - g_return_if_fail(list); + if (!list) + return; for (GSList* p = list; p; p = p->next) g_object_unref(p->data); diff --git a/Source/WebKit/gtk/webkit/webkitwebsettings.cpp b/Source/WebKit/gtk/webkit/webkitwebsettings.cpp index 7e7a506..3b4cf57 100644 --- a/Source/WebKit/gtk/webkit/webkitwebsettings.cpp +++ b/Source/WebKit/gtk/webkit/webkitwebsettings.cpp @@ -39,6 +39,8 @@ #if OS(UNIX) #include <sys/utsname.h> +#elif OS(WINDOWS) +#include "SystemInfo.h" #endif /** @@ -110,6 +112,7 @@ struct _WebKitWebSettingsPrivate { gboolean enable_java_applet; gboolean enable_hyperlink_auditing; gboolean enable_fullscreen; + gboolean enable_dns_prefetching; }; #define WEBKIT_WEB_SETTINGS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_SETTINGS, WebKitWebSettingsPrivate)) @@ -162,7 +165,8 @@ enum { PROP_AUTO_RESIZE_WINDOW, PROP_ENABLE_JAVA_APPLET, PROP_ENABLE_HYPERLINK_AUDITING, - PROP_ENABLE_FULLSCREEN + PROP_ENABLE_FULLSCREEN, + PROP_ENABLE_DNS_PREFETCHING }; // Create a default user agent string @@ -208,7 +212,7 @@ static String webkitOSVersion() else uaOSVersion = String("Unknown"); #elif OS(WINDOWS) - DEFINE_STATIC_LOCAL(const String, uaOSVersion, (String("Windows"))); + DEFINE_STATIC_LOCAL(const String, uaOSVersion, (windowsVersionForUAString())); #else DEFINE_STATIC_LOCAL(const String, uaOSVersion, (String("Unknown"))); #endif @@ -909,6 +913,22 @@ static void webkit_web_settings_class_init(WebKitWebSettingsClass* klass) FALSE, flags)); + /** + * WebKitWebSettings:enable-dns-prefetching + * + * Whether webkit prefetches domain names. This is a separate knob from private browsing. + * Whether private browsing should set this or not is up for debate, for now it doesn't. + * + * Since: 1.3.13. + */ + g_object_class_install_property(gobject_class, + PROP_ENABLE_DNS_PREFETCHING, + g_param_spec_boolean("enable-dns-prefetching", + _("WebKit prefetches domain names"), + _("Whether WebKit prefetches domain names"), + TRUE, + flags)); + g_type_class_add_private(klass, sizeof(WebKitWebSettingsPrivate)); } @@ -1094,6 +1114,9 @@ static void webkit_web_settings_set_property(GObject* object, guint prop_id, con case PROP_ENABLE_FULLSCREEN: priv->enable_fullscreen = g_value_get_boolean(value); break; + case PROP_ENABLE_DNS_PREFETCHING: + priv->enable_dns_prefetching = g_value_get_boolean(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -1244,6 +1267,9 @@ static void webkit_web_settings_get_property(GObject* object, guint prop_id, GVa case PROP_ENABLE_FULLSCREEN: g_value_set_boolean(value, priv->enable_fullscreen); break; + case PROP_ENABLE_DNS_PREFETCHING: + g_value_set_boolean(value, priv->enable_dns_prefetching); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -1320,6 +1346,7 @@ WebKitWebSettings* webkit_web_settings_copy(WebKitWebSettings* web_settings) "enable-java-applet", priv->enable_java_applet, "enable-hyperlink-auditing", priv->enable_hyperlink_auditing, "enable-fullscreen", priv->enable_fullscreen, + "enable-dns-prefetching", priv->enable_dns_prefetching, NULL)); return copy; diff --git a/Source/WebKit/gtk/webkit/webkitwebview.cpp b/Source/WebKit/gtk/webkit/webkitwebview.cpp index 0ffc9d9..bf74d7b 100644 --- a/Source/WebKit/gtk/webkit/webkitwebview.cpp +++ b/Source/WebKit/gtk/webkit/webkitwebview.cpp @@ -85,6 +85,7 @@ #include "webkitgeolocationpolicydecision.h" #include "webkitglobalsprivate.h" #include "webkithittestresultprivate.h" +#include "webkiticondatabase.h" #include "webkitmarshal.h" #include "webkitnetworkrequest.h" #include "webkitnetworkresponse.h" @@ -709,8 +710,8 @@ static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose* frame->view()->updateLayoutAndStyleIfNeededRecursive(); RefPtr<cairo_t> cr = adoptRef(gdk_cairo_create(event->window)); - GraphicsContext ctx(cr.get()); - ctx.setGdkExposeEvent(event); + GraphicsContext gc(cr.get()); + gc.setGdkExposeEvent(event); int rectCount; GOwnPtr<GdkRectangle> rects; @@ -719,7 +720,7 @@ static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose* for (int i = 0; i < rectCount; i++) paintRects.append(IntRect(rects.get()[i])); - paintWebView(frame, priv->transparent, ctx, static_cast<IntRect>(event->area), paintRects); + paintWebView(frame, priv->transparent, gc, static_cast<IntRect>(event->area), paintRects); } return FALSE; @@ -736,7 +737,7 @@ static gboolean webkit_web_view_draw(GtkWidget* widget, cairo_t* cr) Frame* frame = core(webView)->mainFrame(); if (frame->contentRenderer() && frame->view()) { - GraphicsContext ctx(cr); + GraphicsContext gc(cr); IntRect rect = clipRect; cairo_rectangle_list_t* rectList = cairo_copy_clip_rectangle_list(cr); @@ -747,7 +748,7 @@ static gboolean webkit_web_view_draw(GtkWidget* widget, cairo_t* cr) for (int i = 0; i < rectList->num_rectangles; i++) rects.append(enclosingIntRect(FloatRect(rectList->rectangles[i]))); } - paintWebView(frame, priv->transparent, ctx, rect, rects); + paintWebView(frame, priv->transparent, gc, rect, rects); cairo_rectangle_list_destroy(rectList); } @@ -2315,6 +2316,8 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) * @icon_uri: the URI for the icon * * This signal is emitted when the main frame has got a favicon. + * See WebKitIconDatabase::icon-loaded if you want to keep track of + * icons for child frames. * * Since: 1.1.18 */ @@ -3290,7 +3293,8 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) javaScriptCanAccessClipboard, enableOfflineWebAppCache, enableUniversalAccessFromFileURI, enableFileAccessFromFileURI, enableDOMPaste, tabKeyCyclesThroughElements, - enableSiteSpecificQuirks, usePageCache, enableJavaApplet, enableHyperlinkAuditing, enableFullscreen; + enableSiteSpecificQuirks, usePageCache, enableJavaApplet, + enableHyperlinkAuditing, enableFullscreen, enableDNSPrefetching; WebKitEditingBehavior editingBehavior; @@ -3331,6 +3335,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) "enable-hyperlink-auditing", &enableHyperlinkAuditing, "spell-checking-languages", &defaultSpellCheckingLanguages, "enable-fullscreen", &enableFullscreen, + "enable-dns-prefetching", &enableDNSPrefetching, NULL); settings->setDefaultTextEncodingName(defaultEncoding); @@ -3375,6 +3380,7 @@ static void webkit_web_view_update_settings(WebKitWebView* webView) WebKit::EditorClient* client = static_cast<WebKit::EditorClient*>(core(webView)->editorClient()); static_cast<WebKit::TextCheckerClientEnchant*>(client->textChecker())->updateSpellCheckingLanguage(defaultSpellCheckingLanguages); #endif + settings->setDNSPrefetchingEnabled(enableDNSPrefetching); Page* page = core(webView); if (page) @@ -3441,6 +3447,8 @@ static void webkit_web_view_settings_notify(WebKitWebSettings* webSettings, GPar settings->setJavaScriptEnabled(g_value_get_boolean(&value)); else if (name == g_intern_string("enable-plugins")) settings->setPluginsEnabled(g_value_get_boolean(&value)); + else if (name == g_intern_string("enable-dns-prefetching")) + settings->setDNSPrefetchingEnabled(g_value_get_boolean(&value)); else if (name == g_intern_string("resizable-text-areas")) settings->setTextAreasAreResizable(g_value_get_boolean(&value)); else if (name == g_intern_string("user-stylesheet-uri")) @@ -4337,8 +4345,7 @@ gboolean webkit_web_view_get_editable(WebKitWebView* webView) { g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); - Frame* frame = core(webView)->mainFrame(); - return frame && frame->document()->inDesignMode(); + return core(webView)->isEditable(); } /** @@ -4363,15 +4370,14 @@ void webkit_web_view_set_editable(WebKitWebView* webView, gboolean flag) { g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); - Frame* frame = core(webView)->mainFrame(); - g_return_if_fail(frame); - - // TODO: What happens when the frame is replaced? flag = flag != FALSE; if (flag == webkit_web_view_get_editable(webView)) return; - frame->document()->setDesignMode(flag ? WebCore::Document::on : WebCore::Document::off); + core(webView)->setEditable(flag); + + Frame* frame = core(webView)->mainFrame(); + g_return_if_fail(frame); if (flag) { frame->editor()->applyEditingStyleToBodyElement(); @@ -5058,12 +5064,41 @@ WebKitHitTestResult* webkit_web_view_get_hit_test_result(WebKitWebView* webView, G_CONST_RETURN gchar* webkit_web_view_get_icon_uri(WebKitWebView* webView) { g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); - String iconURL = iconDatabase().iconURLForPageURL(core(webView)->mainFrame()->document()->url().prettyURL()); + String iconURL = iconDatabase().synchronousIconURLForPageURL(core(webView)->mainFrame()->document()->url().prettyURL()); webView->priv->iconURI = iconURL.utf8(); return webView->priv->iconURI.data(); } /** + * webkit_web_view_get_icon_pixbuf: + * @webView: the #WebKitWebView object + * + * Obtains a #GdkPixbuf of the favicon for the given #WebKitWebView, or + * a default icon if there is no icon for the given page. Use + * webkit_web_view_get_icon_uri() if you need to distinguish these cases. + * Usually you want to connect to WebKitWebView::icon-loaded and call this + * method in the callback. + * + * The pixbuf will have the largest size provided by the server and should + * be resized before it is displayed. + * See also webkit_icon_database_get_icon_pixbuf(). + * + * Returns: (transfer full): a new reference to a #GdkPixbuf, or %NULL + * + * Since: 1.3.13 + */ +GdkPixbuf* webkit_web_view_get_icon_pixbuf(WebKitWebView* webView) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0); + + const gchar* pageURI = webkit_web_view_get_uri(webView); + WebKitIconDatabase* database = webkit_get_icon_database(); + return webkit_icon_database_get_icon_pixbuf(database, pageURI); +} + + + +/** * webkit_web_view_get_dom_document: * @webView: a #WebKitWebView * diff --git a/Source/WebKit/gtk/webkit/webkitwebview.h b/Source/WebKit/gtk/webkit/webkitwebview.h index 1838bfe..38c9a70 100644 --- a/Source/WebKit/gtk/webkit/webkitwebview.h +++ b/Source/WebKit/gtk/webkit/webkitwebview.h @@ -397,6 +397,9 @@ 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 GdkPixbuf * +webkit_web_view_get_icon_pixbuf (WebKitWebView *webView); + WEBKIT_API WebKitDOMDocument * webkit_web_view_get_dom_document (WebKitWebView *webView); |