summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/UIProcess/API')
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKInspector.cpp10
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKInspector.h2
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPage.h3
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPreferences.cpp18
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPreferences.h4
-rw-r--r--Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h4
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitDefines.h2
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp430
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h102
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResultPrivate.h29
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp3
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp17
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp410
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.h95
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperationPrivate.h28
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.cpp37
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h2
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp59
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h7
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp14
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp101
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h54
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h2
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp2
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml2
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt56
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am13
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestPrinting.cpp152
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp5
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp82
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp50
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h4
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/webkit2.h2
-rw-r--r--Source/WebKit2/UIProcess/API/gtk/webkit2marshal.list1
-rw-r--r--Source/WebKit2/UIProcess/API/mac/WKView.mm3
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp74
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp218
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h48
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h21
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qtwebsecurityorigin.cpp60
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qtwebsecurityorigin_p.h57
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest.cpp14
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest_p.h6
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest.cpp24
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest_p.h11
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp16
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h5
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/bytearraytestdata.h1
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp7
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro3
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_origin.qml57
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp4
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp6
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/tests.pri2
-rw-r--r--Source/WebKit2/UIProcess/API/qt/tests/util.h10
55 files changed, 2269 insertions, 180 deletions
diff --git a/Source/WebKit2/UIProcess/API/C/WKInspector.cpp b/Source/WebKit2/UIProcess/API/C/WKInspector.cpp
index 325db5ae9..1a4ecc7c9 100644
--- a/Source/WebKit2/UIProcess/API/C/WKInspector.cpp
+++ b/Source/WebKit2/UIProcess/API/C/WKInspector.cpp
@@ -63,6 +63,16 @@ void WKInspectorShowConsole(WKInspectorRef inspectorRef)
toImpl(inspectorRef)->showConsole();
}
+void WKInspectorShowResources(WKInspectorRef inspectorRef)
+{
+ toImpl(inspectorRef)->showResources();
+}
+
+void WKInspectorShowMainResourceForFrame(WKInspectorRef inspectorRef, WKFrameRef frameRef)
+{
+ toImpl(inspectorRef)->showMainResourceForFrame(toImpl(frameRef));
+}
+
bool WKInspectorIsAttached(WKInspectorRef inspectorRef)
{
return toImpl(inspectorRef)->isAttached();
diff --git a/Source/WebKit2/UIProcess/API/C/WKInspector.h b/Source/WebKit2/UIProcess/API/C/WKInspector.h
index c147015f0..2e85688d0 100644
--- a/Source/WebKit2/UIProcess/API/C/WKInspector.h
+++ b/Source/WebKit2/UIProcess/API/C/WKInspector.h
@@ -47,6 +47,8 @@ WK_EXPORT void WKInspectorShow(WKInspectorRef inspector);
WK_EXPORT void WKInspectorClose(WKInspectorRef inspector);
WK_EXPORT void WKInspectorShowConsole(WKInspectorRef inspector);
+WK_EXPORT void WKInspectorShowResources(WKInspectorRef inspector);
+WK_EXPORT void WKInspectorShowMainResourceForFrame(WKInspectorRef inspector, WKFrameRef frame);
WK_EXPORT bool WKInspectorIsAttached(WKInspectorRef inspector);
WK_EXPORT void WKInspectorAttach(WKInspectorRef inspector);
diff --git a/Source/WebKit2/UIProcess/API/C/WKPage.h b/Source/WebKit2/UIProcess/API/C/WKPage.h
index ea8049dd5..96d097c60 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPage.h
+++ b/Source/WebKit2/UIProcess/API/C/WKPage.h
@@ -71,6 +71,7 @@ typedef void (*WKPageDidChangeBackForwardListCallback)(WKPageRef page, WKBackFor
typedef bool (*WKPageShouldGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, const void *clientInfo);
typedef void (*WKPageDidFailToInitializePluginCallback)(WKPageRef page, WKStringRef mimeType, const void* clientInfo);
typedef void (*WKPageDidNewFirstVisuallyNonEmptyLayoutCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo);
+typedef void (*WKPageWillGoToBackForwardListItemCallback)(WKPageRef page, WKBackForwardListItemRef item, const void *clientInfo);
struct WKPageLoaderClient {
int version;
@@ -110,6 +111,8 @@ struct WKPageLoaderClient {
// FIXME: didFirstVisuallyNonEmptyLayoutForFrame and didNewFirstVisuallyNonEmptyLayout should be merged.
WKPageDidNewFirstVisuallyNonEmptyLayoutCallback didNewFirstVisuallyNonEmptyLayout;
+
+ WKPageWillGoToBackForwardListItemCallback willGoToBackForwardListItem;
};
typedef struct WKPageLoaderClient WKPageLoaderClient;
diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
index 521e6d4a0..87d32ed2f 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
+++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp
@@ -408,6 +408,16 @@ bool WKPreferencesGetWebGLEnabled(WKPreferencesRef preferencesRef)
return toImpl(preferencesRef)->webGLEnabled();
}
+void WKPreferencesSetCSSRegionsEnabled(WKPreferencesRef preferencesRef, bool flag)
+{
+ toImpl(preferencesRef)->setCSSRegionsEnabled(flag);
+}
+
+bool WKPreferencesGetCSSRegionsEnabled(WKPreferencesRef preferencesRef)
+{
+ return toImpl(preferencesRef)->cssRegionsEnabled();
+}
+
void WKPreferencesSetNeedsSiteSpecificQuirks(WKPreferencesRef preferencesRef, bool flag)
{
toImpl(preferencesRef)->setNeedsSiteSpecificQuirks(flag);
@@ -668,14 +678,14 @@ bool WKPreferencesGetApplicationChromeModeEnabled(WKPreferencesRef preferencesRe
return toImpl(preferencesRef)->applicationChromeMode();
}
-void WKPreferencesSetSuppressIncrementalRendering(WKPreferencesRef preferencesRef, bool enabled)
+void WKPreferencesSetSuppressesIncrementalRendering(WKPreferencesRef preferencesRef, bool enabled)
{
- toImpl(preferencesRef)->setSuppressIncrementalRendering(enabled);
+ toImpl(preferencesRef)->setSuppressesIncrementalRendering(enabled);
}
-bool WKPreferencesGetSuppressIncrementalRendering(WKPreferencesRef preferencesRef)
+bool WKPreferencesGetSuppressesIncrementalRendering(WKPreferencesRef preferencesRef)
{
- return toImpl(preferencesRef)->suppressIncrementalRendering();
+ return toImpl(preferencesRef)->suppressesIncrementalRendering();
}
void WKPreferencesSetBackspaceKeyNavigationEnabled(WKPreferencesRef preferencesRef, bool enabled)
diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.h b/Source/WebKit2/UIProcess/API/C/WKPreferences.h
index f13559acb..8054e00f3 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPreferences.h
+++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.h
@@ -170,8 +170,8 @@ WK_EXPORT void WKPreferencesSetWebAudioEnabled(WKPreferencesRef preferencesRef,
WK_EXPORT bool WKPreferencesGetWebAudioEnabled(WKPreferencesRef preferencesRef);
// Defaults to false
-WK_EXPORT void WKPreferencesSetSuppressIncrementalRendering(WKPreferencesRef preferencesRef, bool enabled);
-WK_EXPORT bool WKPreferencesGetSuppressIncrementalRendering(WKPreferencesRef preferencesRef);
+WK_EXPORT void WKPreferencesSetSuppressesIncrementalRendering(WKPreferencesRef preferencesRef, bool enabled);
+WK_EXPORT bool WKPreferencesGetSuppressesIncrementalRendering(WKPreferencesRef preferencesRef);
// Defaults to true
WK_EXPORT void WKPreferencesSetBackspaceKeyNavigationEnabled(WKPreferencesRef preferencesRef, bool enabled);
diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
index 9153ccab8..36950e891 100644
--- a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
+++ b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h
@@ -91,6 +91,10 @@ WK_EXPORT bool WKPreferencesGetCSSCustomFilterEnabled(WKPreferencesRef);
WK_EXPORT void WKPreferencesSetWebGLEnabled(WKPreferencesRef, bool);
WK_EXPORT bool WKPreferencesGetWebGLEnabled(WKPreferencesRef);
+// Defaults to true
+WK_EXPORT void WKPreferencesSetCSSRegionsEnabled(WKPreferencesRef, bool flag);
+WK_EXPORT bool WKPreferencesGetCSSRegionsEnabled(WKPreferencesRef);
+
// Defaults to false.
WK_EXPORT void WKPreferencesSetNeedsSiteSpecificQuirks(WKPreferencesRef, bool);
WK_EXPORT bool WKPreferencesGetNeedsSiteSpecificQuirks(WKPreferencesRef);
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitDefines.h b/Source/WebKit2/UIProcess/API/gtk/WebKitDefines.h
index 79b338360..8c3eec2a4 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitDefines.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitDefines.h
@@ -32,6 +32,8 @@
#include <glib.h>
+typedef struct _WebKitPrintOperation WebKitPrintOperation;
+
#ifdef G_OS_WIN32
# ifdef BUILDING_WEBKIT
# define WEBKIT_API __declspec(dllexport)
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp
new file mode 100644
index 000000000..928b4dc42
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.cpp
@@ -0,0 +1,430 @@
+/*
+ * Copyright (C) 2012 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
+ * 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 "WebKitHitTestResult.h"
+
+#include "WebHitTestResult.h"
+#include "WebKitHitTestResultPrivate.h"
+#include <glib/gi18n-lib.h>
+#include <wtf/text/CString.h>
+
+/**
+ * SECTION: WebKitHitTestResult
+ * @Short_description: Result of a Hit Test
+ * @Title: WebKitHitTestResult
+ * @See_also: #WebKitWebView
+ *
+ * A Hit Test is an operation to get context information about a given
+ * point in a #WebKitWebView. #WebKitHitTestResult represents the
+ * result of a Hit Test. It provides context information about what is
+ * at the coordinates of the Hit Test, such as if there's a link,
+ * an image or a media.
+ *
+ * You can get the context of the HitTestResult with
+ * webkit_hit_test_result_get_context() that returns a bitmask of
+ * #WebKitHitTestResultContext flags. You can also use
+ * webkit_hit_test_result_context_is_link(), webkit_hit_test_result_context_is_image() and
+ * webkit_hit_test_result_context_is_media() to determine whether there's
+ * a link, image or a media element at the coordinates of the Hit Test.
+ * Note that it's possible that several #WebKitHitTestResultContext flags
+ * are active at the same time, for example if there's a link containing an image.
+ *
+ * When the mouse is moved over a #WebKitWebView a Hit Test is performed
+ * for the mouse coordinates and #WebKitWebView::mouse-target-changed
+ * signal is emitted with a #WebKitHitTestResult.
+ *
+ */
+
+using namespace WebKit;
+
+enum {
+ PROP_0,
+
+ PROP_CONTEXT,
+ PROP_LINK_URI,
+ PROP_LINK_TITLE,
+ PROP_LINK_LABEL,
+ PROP_IMAGE_URI,
+ PROP_MEDIA_URI
+};
+
+struct _WebKitHitTestResultPrivate {
+ unsigned int context;
+ CString linkURI;
+ CString linkTitle;
+ CString linkLabel;
+ CString imageURI;
+ CString mediaURI;
+};
+
+G_DEFINE_TYPE(WebKitHitTestResult, webkit_hit_test_result, G_TYPE_OBJECT)
+
+static void webkitHitTestResultFinalize(GObject* object)
+{
+ WEBKIT_HIT_TEST_RESULT(object)->priv->~WebKitHitTestResultPrivate();
+ G_OBJECT_CLASS(webkit_hit_test_result_parent_class)->finalize(object);
+}
+
+static void webkitHitTestResultGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)
+{
+ WebKitHitTestResult* hitTestResult = WEBKIT_HIT_TEST_RESULT(object);
+
+ switch (propId) {
+ case PROP_CONTEXT:
+ g_value_set_uint(value, webkit_hit_test_result_get_context(hitTestResult));
+ break;
+ case PROP_LINK_URI:
+ g_value_set_string(value, webkit_hit_test_result_get_link_uri(hitTestResult));
+ break;
+ case PROP_LINK_TITLE:
+ g_value_set_string(value, webkit_hit_test_result_get_link_title(hitTestResult));
+ break;
+ case PROP_LINK_LABEL:
+ g_value_set_string(value, webkit_hit_test_result_get_link_label(hitTestResult));
+ break;
+ case PROP_IMAGE_URI:
+ g_value_set_string(value, webkit_hit_test_result_get_image_uri(hitTestResult));
+ break;
+ case PROP_MEDIA_URI:
+ g_value_set_string(value, webkit_hit_test_result_get_media_uri(hitTestResult));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ }
+}
+
+static void webkitHitTestResultSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
+{
+ WebKitHitTestResult* hitTestResult = WEBKIT_HIT_TEST_RESULT(object);
+
+ switch (propId) {
+ case PROP_CONTEXT:
+ hitTestResult->priv->context = g_value_get_uint(value);
+ break;
+ case PROP_LINK_URI:
+ hitTestResult->priv->linkURI = g_value_get_string(value);
+ break;
+ case PROP_LINK_TITLE:
+ hitTestResult->priv->linkTitle = g_value_get_string(value);
+ break;
+ case PROP_LINK_LABEL:
+ hitTestResult->priv->linkLabel = g_value_get_string(value);
+ break;
+ case PROP_IMAGE_URI:
+ hitTestResult->priv->imageURI = g_value_get_string(value);
+ break;
+ case PROP_MEDIA_URI:
+ hitTestResult->priv->mediaURI = g_value_get_string(value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ }
+}
+
+static void webkit_hit_test_result_init(WebKitHitTestResult* hitTestResult)
+{
+ WebKitHitTestResultPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(hitTestResult, WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResultPrivate);
+ hitTestResult->priv = priv;
+ new (priv) WebKitHitTestResultPrivate();
+}
+
+static void webkit_hit_test_result_class_init(WebKitHitTestResultClass* hitTestResultClass)
+{
+ GObjectClass* objectClass = G_OBJECT_CLASS(hitTestResultClass);
+ objectClass->get_property = webkitHitTestResultGetProperty;
+ objectClass->set_property = webkitHitTestResultSetProperty;
+ objectClass->finalize = webkitHitTestResultFinalize;
+
+ GParamFlags paramFlags = static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
+
+ /**
+ * WebKitHitTestResult:context:
+ *
+ * Bitmask of #WebKitHitTestResultContext flags representing
+ * the context of the #WebKitHitTestResult.
+ */
+ g_object_class_install_property(objectClass,
+ PROP_CONTEXT,
+ g_param_spec_uint("context",
+ _("Context"),
+ _("Flags with the context of the WebKitHitTestResult"),
+ 0, G_MAXUINT, 0,
+ paramFlags));
+
+ /**
+ * WebKitHitTestResult:link-uri:
+ *
+ * The URI of the link if flag %WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK
+ * is present in #WebKitHitTestResult:context
+ */
+ g_object_class_install_property(objectClass,
+ PROP_LINK_URI,
+ g_param_spec_string("link-uri",
+ _("Link URI"),
+ _("The link URI"),
+ 0,
+ paramFlags));
+ /**
+ * WebKitHitTestResult:link-title:
+ *
+ * The title of the link if flag %WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK
+ * is present in #WebKitHitTestResult:context
+ */
+ g_object_class_install_property(objectClass,
+ PROP_LINK_TITLE,
+ g_param_spec_string("link-title",
+ _("Link Title"),
+ _("The link title"),
+ 0,
+ paramFlags));
+ /**
+ * WebKitHitTestResult:link-label:
+ *
+ * The label of the link if flag %WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK
+ * is present in #WebKitHitTestResult:context
+ */
+ g_object_class_install_property(objectClass,
+ PROP_LINK_LABEL,
+ g_param_spec_string("link-label",
+ _("Link Label"),
+ _("The link label"),
+ 0,
+ paramFlags));
+ /**
+ * WebKitHitTestResult:image-uri:
+ *
+ * The URI of the image if flag %WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE
+ * is present in #WebKitHitTestResult:context
+ */
+ g_object_class_install_property(objectClass,
+ PROP_IMAGE_URI,
+ g_param_spec_string("image-uri",
+ _("Image URI"),
+ _("The image URI"),
+ 0,
+ paramFlags));
+ /**
+ * WebKitHitTestResult:media-uri:
+ *
+ * The URI of the media if flag %WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA
+ * is present in #WebKitHitTestResult:context
+ */
+ g_object_class_install_property(objectClass,
+ PROP_MEDIA_URI,
+ g_param_spec_string("media-uri",
+ _("Media URI"),
+ _("The media URI"),
+ 0,
+ paramFlags));
+
+ g_type_class_add_private(hitTestResultClass, sizeof(WebKitHitTestResultPrivate));
+}
+
+WebKitHitTestResult* webkitHitTestResultCreate(WKHitTestResultRef wkHitTestResult)
+{
+ unsigned context = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT;
+
+ const String& linkURL = toImpl(wkHitTestResult)->absoluteLinkURL();
+ if (!linkURL.isEmpty())
+ context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK;
+
+ const String& imageURL = toImpl(wkHitTestResult)->absoluteImageURL();
+ if (!imageURL.isEmpty())
+ context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE;
+
+ const String& mediaURL = toImpl(wkHitTestResult)->absoluteMediaURL();
+ if (!mediaURL.isEmpty())
+ context |= WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA;
+
+ const String& linkTitle = toImpl(wkHitTestResult)->linkTitle();
+ const String& linkLabel = toImpl(wkHitTestResult)->linkLabel();
+
+ return WEBKIT_HIT_TEST_RESULT(g_object_new(WEBKIT_TYPE_HIT_TEST_RESULT,
+ "context", context,
+ "link-uri", !linkURL.isEmpty() ? linkURL.utf8().data() : 0,
+ "image-uri", !imageURL.isEmpty() ? imageURL.utf8().data() : 0,
+ "media-uri", !mediaURL.isEmpty() ? mediaURL.utf8().data() : 0,
+ "link-title", !linkTitle.isEmpty() ? linkTitle.utf8().data() : 0,
+ "link-label", !linkLabel.isEmpty() ? linkLabel.utf8().data() : 0,
+ NULL));
+}
+
+static bool stringIsEqualToCString(const String& string, const CString& cString)
+{
+ return ((string.isEmpty() && cString.isNull()) || (string.utf8() == cString));
+}
+
+bool webkitHitTestResultCompare(WebKitHitTestResult* hitTestResult, WKHitTestResultRef wkHitTestResult)
+{
+ WebKitHitTestResultPrivate* priv = hitTestResult->priv;
+ return stringIsEqualToCString(toImpl(wkHitTestResult)->absoluteLinkURL(), priv->linkURI)
+ && stringIsEqualToCString(toImpl(wkHitTestResult)->linkTitle(), priv->linkTitle)
+ && stringIsEqualToCString(toImpl(wkHitTestResult)->linkLabel(), priv->linkLabel)
+ && stringIsEqualToCString(toImpl(wkHitTestResult)->absoluteImageURL(), priv->imageURI)
+ && stringIsEqualToCString(toImpl(wkHitTestResult)->absoluteMediaURL(), priv->mediaURI);
+}
+
+/**
+ * webkit_hit_test_result_get_context:
+ * @hit_test_result: a #WebKitHitTestResult
+ *
+ * Gets the value of the #WebKitHitTestResult:context property.
+ *
+ * Returns: a bitmask of #WebKitHitTestResultContext flags
+ */
+guint webkit_hit_test_result_get_context(WebKitHitTestResult* hitTestResult)
+{
+ g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), 0);
+
+ return hitTestResult->priv->context;
+}
+
+/**
+ * webkit_hit_test_result_context_is_link:
+ * @hit_test_result: a #WebKitHitTestResult
+ *
+ * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK flag is present in
+ * #WebKitHitTestResult:context.
+ *
+ * Returns: %TRUE if there's a link element in the coordinates of the Hit Test,
+ * or %FALSE otherwise
+ */
+gboolean webkit_hit_test_result_context_is_link(WebKitHitTestResult* hitTestResult)
+{
+ g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), FALSE);
+
+ return hitTestResult->priv->context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK;
+}
+
+/**
+ * webkit_hit_test_result_context_is_image:
+ * @hit_test_result: a #WebKitHitTestResult
+ *
+ * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE flag is present in
+ * #WebKitHitTestResult:context.
+ *
+ * Returns: %TRUE if there's an image element in the coordinates of the Hit Test,
+ * or %FALSE otherwise
+ */
+gboolean webkit_hit_test_result_context_is_image(WebKitHitTestResult* hitTestResult)
+{
+ g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), FALSE);
+
+ return hitTestResult->priv->context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE;
+}
+
+/**
+ * webkit_hit_test_result_context_is_media:
+ * @hit_test_result: a #WebKitHitTestResult
+ *
+ * Gets whether %WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA flag is present in
+ * #WebKitHitTestResult:context.
+ *
+ * Returns: %TRUE if there's a media element in the coordinates of the Hit Test,
+ * or %FALSE otherwise
+ */
+gboolean webkit_hit_test_result_context_is_media(WebKitHitTestResult* hitTestResult)
+{
+ g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), FALSE);
+
+ return hitTestResult->priv->context & WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA;
+}
+
+/**
+ * webkit_hit_test_result_get_link_uri:
+ * @hit_test_result: a #WebKitHitTestResult
+ *
+ * Gets the value of the #WebKitHitTestResult:link-uri property.
+ *
+ * Returns: the URI of the link element in the coordinates of the Hit Test,
+ * or %NULL if there ins't a link element in @hit_test_result context
+ */
+const gchar* webkit_hit_test_result_get_link_uri(WebKitHitTestResult* hitTestResult)
+{
+ g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), 0);
+
+ return hitTestResult->priv->linkURI.data();
+}
+
+/**
+ * webkit_hit_test_result_get_link_title:
+ * @hit_test_result: a #WebKitHitTestResult
+ *
+ * Gets the value of the #WebKitHitTestResult:link-title property.
+ *
+ * Returns: the title of the link element in the coordinates of the Hit Test,
+ * or %NULL if there ins't a link element in @hit_test_result context or the
+ * link element doesn't have a title
+ */
+const gchar* webkit_hit_test_result_get_link_title(WebKitHitTestResult* hitTestResult)
+{
+ g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), 0);
+
+ return hitTestResult->priv->linkTitle.data();
+}
+
+/**
+ * webkit_hit_test_result_get_link_label:
+ * @hit_test_result: a #WebKitHitTestResult
+ *
+ * Gets the value of the #WebKitHitTestResult:link-label property.
+ *
+ * Returns: the label of the link element in the coordinates of the Hit Test,
+ * or %NULL if there ins't a link element in @hit_test_result context or the
+ * link element doesn't have a label
+ */
+const gchar* webkit_hit_test_result_get_link_label(WebKitHitTestResult* hitTestResult)
+{
+ g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), 0);
+
+ return hitTestResult->priv->linkLabel.data();
+}
+
+/**
+ * webkit_hit_test_result_get_image_uri:
+ * @hit_test_result: a #WebKitHitTestResult
+ *
+ * Gets the value of the #WebKitHitTestResult:image-uri property.
+ *
+ * Returns: the URI of the image element in the coordinates of the Hit Test,
+ * or %NULL if there ins't an image element in @hit_test_result context
+ */
+const gchar* webkit_hit_test_result_get_image_uri(WebKitHitTestResult* hitTestResult)
+{
+ g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), 0);
+
+ return hitTestResult->priv->imageURI.data();
+}
+
+/**
+ * webkit_hit_test_result_get_media_uri:
+ * @hit_test_result: a #WebKitHitTestResult
+ *
+ * Gets the value of the #WebKitHitTestResult:media-uri property.
+ *
+ * Returns: the URI of the media element in the coordinates of the Hit Test,
+ * or %NULL if there ins't a media element in @hit_test_result context
+ */
+const gchar* webkit_hit_test_result_get_media_uri(WebKitHitTestResult* hitTestResult)
+{
+ g_return_val_if_fail(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult), 0);
+
+ return hitTestResult->priv->mediaURI.data();
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h b/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h
new file mode 100644
index 000000000..d8916e5f3
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2012 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
+ * 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.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitHitTestResult_h
+#define WebKitHitTestResult_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_HIT_TEST_RESULT (webkit_hit_test_result_get_type())
+#define WEBKIT_HIT_TEST_RESULT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResult))
+#define WEBKIT_IS_HIT_TEST_RESULT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_HIT_TEST_RESULT))
+#define WEBKIT_HIT_TEST_RESULT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResultClass))
+#define WEBKIT_IS_HIT_TEST_RESULT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_HIT_TEST_RESULT))
+#define WEBKIT_HIT_TEST_RESULT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_HIT_TEST_RESULT, WebKitHitTestResultClass))
+
+typedef struct _WebKitHitTestResult WebKitHitTestResult;
+typedef struct _WebKitHitTestResultClass WebKitHitTestResultClass;
+typedef struct _WebKitHitTestResultPrivate WebKitHitTestResultPrivate;
+
+/**
+ * WebKitHitTestResultContext:
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT: anywhere in the document.
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK: a hyperlink element.
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE: an image element.
+ * @WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA: a video or audio element.
+ *
+ * Enum values with flags representing the context of a #WebKitHitTestResult.
+ */
+typedef enum
+{
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT = 1 << 1,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK = 1 << 2,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE = 1 << 3,
+ WEBKIT_HIT_TEST_RESULT_CONTEXT_MEDIA = 1 << 4
+} WebKitHitTestResultContext;
+
+struct _WebKitHitTestResult {
+ GObject parent;
+
+ WebKitHitTestResultPrivate *priv;
+};
+
+struct _WebKitHitTestResultClass {
+ GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_hit_test_result_get_type (void);
+
+WEBKIT_API guint
+webkit_hit_test_result_get_context (WebKitHitTestResult *hit_test_result);
+
+WEBKIT_API gboolean
+webkit_hit_test_result_context_is_link (WebKitHitTestResult *hit_test_result);
+
+WEBKIT_API gboolean
+webkit_hit_test_result_context_is_image (WebKitHitTestResult *hit_test_result);
+
+WEBKIT_API gboolean
+webkit_hit_test_result_context_is_media (WebKitHitTestResult *hit_test_result);
+
+WEBKIT_API const gchar *
+webkit_hit_test_result_get_link_uri (WebKitHitTestResult *hit_test_result);
+
+WEBKIT_API const gchar *
+webkit_hit_test_result_get_link_title (WebKitHitTestResult *hit_test_result);
+
+WEBKIT_API const gchar *
+webkit_hit_test_result_get_link_label (WebKitHitTestResult *hit_test_result);
+
+WEBKIT_API const gchar *
+webkit_hit_test_result_get_image_uri (WebKitHitTestResult *hit_test_result);
+
+WEBKIT_API const gchar *
+webkit_hit_test_result_get_media_uri (WebKitHitTestResult *hit_test_result);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResultPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResultPrivate.h
new file mode 100644
index 000000000..6088006e7
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResultPrivate.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2012 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
+ * 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 WebKitHitTestResultPrivate_h
+#define WebKitHitTestResultPrivate_h
+
+#include "WebKitHitTestResult.h"
+#include "WebKitPrivate.h"
+
+WebKitHitTestResult* webkitHitTestResultCreate(WKHitTestResultRef);
+bool webkitHitTestResultCompare(WebKitHitTestResult*, WKHitTestResultRef);
+
+#endif // WebKitHitTestResultPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp
index 6d1133941..c26d8ebe9 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitLoaderClient.cpp
@@ -144,7 +144,8 @@ void attachLoaderClientToView(WebKitWebView* webView)
didChangeBackForwardList,
0, // shouldGoToBackForwardListItem
0, // didFailToInitializePlugin
- 0 // didDetectXSSForFrame
+ 0, // didDetectXSSForFrame
+ 0 // didFirstVisuallyNonEmptyLayoutForFrame
};
WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)));
WKPageSetPageLoaderClient(wkPage, &wkLoaderClient);
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp
index fcd57b4a6..94d13eab2 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitNavigationPolicyDecision.cpp
@@ -25,7 +25,6 @@
#include "WebKitPrivate.h"
#include "WebKitURIRequestPrivate.h"
#include "WebURLRequest.h"
-#include <gdk/gdk.h>
#include <glib/gi18n-lib.h>
#include <wtf/gobject/GRefPtr.h>
#include <wtf/text/CString.h>
@@ -280,26 +279,12 @@ static unsigned wkEventMouseButtonToWebKitMouseButton(WKEventMouseButton wkButto
return 0;
}
-unsigned wkEventModifiersToUnsigned(WKEventModifiers wkModifiers)
-{
- unsigned modifiers = 0;
- if (wkModifiers & kWKEventModifiersShiftKey)
- modifiers |= GDK_SHIFT_MASK;
- if (wkModifiers & kWKEventModifiersControlKey)
- modifiers |= GDK_CONTROL_MASK;
- if (wkModifiers & kWKEventModifiersAltKey)
- modifiers |= GDK_MOD1_MASK;
- if (wkModifiers & kWKEventModifiersMetaKey)
- modifiers |= GDK_META_MASK;
- return modifiers;
-}
-
WebKitNavigationPolicyDecision* webkitNavigationPolicyDecisionCreate(WKFrameNavigationType navigationType, WKEventMouseButton mouseButton, WKEventModifiers modifiers, WKURLRequestRef request, const char* frameName, WKFramePolicyListenerRef listener)
{
WebKitNavigationPolicyDecision* decision = WEBKIT_NAVIGATION_POLICY_DECISION(g_object_new(WEBKIT_TYPE_NAVIGATION_POLICY_DECISION, NULL));
decision->priv->navigationType = static_cast<WebKitNavigationType>(navigationType);
decision->priv->mouseButton = wkEventMouseButtonToWebKitMouseButton(mouseButton);
- decision->priv->modifiers = wkEventModifiersToUnsigned(modifiers);
+ decision->priv->modifiers = wkEventModifiersToGdkModifiers(modifiers);
decision->priv->request = adoptGRef(webkitURIRequestCreateForResourceRequest(toImpl(request)->resourceRequest()));
decision->priv->frameName = frameName;
webkitPolicyDecisionSetListener(WEBKIT_POLICY_DECISION(decision), listener);
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp
new file mode 100644
index 000000000..a20ccb2a6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.cpp
@@ -0,0 +1,410 @@
+/*
+ * Copyright (C) 2012 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
+ * 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 "WebKitPrintOperation.h"
+
+#include "PrintInfo.h"
+#include "WebKitPrintOperationPrivate.h"
+#include "WebKitPrivate.h"
+#include "WebKitWebViewBasePrivate.h"
+#include "WebPageProxy.h"
+#include <WebCore/GtkUtilities.h>
+#include <WebCore/NotImplemented.h>
+#include <glib/gi18n-lib.h>
+#include <wtf/gobject/GRefPtr.h>
+
+#ifdef HAVE_GTK_UNIX_PRINTING
+#include <gtk/gtkunixprint.h>
+#endif
+
+using namespace WebKit;
+
+enum {
+ PROP_0,
+
+ PROP_WEB_VIEW,
+ PROP_PRINT_SETTINGS,
+ PROP_PAGE_SETUP
+};
+
+enum {
+ FINISHED,
+
+ LAST_SIGNAL
+};
+
+struct _WebKitPrintOperationPrivate {
+ WebKitWebView* webView;
+ gulong webViewDestroyedId;
+
+ GRefPtr<GtkPrintSettings> printSettings;
+ GRefPtr<GtkPageSetup> pageSetup;
+};
+
+static guint signals[LAST_SIGNAL] = { 0, };
+
+G_DEFINE_TYPE(WebKitPrintOperation, webkit_print_operation, G_TYPE_OBJECT)
+
+static void webkitPrintOperationFinalize(GObject* object)
+{
+ WebKitPrintOperationPrivate* priv = WEBKIT_PRINT_OPERATION(object)->priv;
+ g_signal_handler_disconnect(priv->webView, priv->webViewDestroyedId);
+
+ priv->~WebKitPrintOperationPrivate();
+ G_OBJECT_CLASS(webkit_print_operation_parent_class)->finalize(object);
+}
+
+static void webViewDestroyed(GtkWidget* webView, GObject* printOperation)
+{
+ g_object_unref(printOperation);
+}
+
+static void webkitPrintOperationConstructed(GObject* object)
+{
+ WebKitPrintOperation* printOperation = WEBKIT_PRINT_OPERATION(object);
+ WebKitPrintOperationPrivate* priv = printOperation->priv;
+
+ if (G_OBJECT_CLASS(webkit_print_operation_parent_class)->constructed)
+ G_OBJECT_CLASS(webkit_print_operation_parent_class)->constructed(object);
+
+ priv->webViewDestroyedId = g_signal_connect(priv->webView, "destroy", G_CALLBACK(webViewDestroyed), printOperation);
+}
+
+static void webkitPrintOperationGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)
+{
+ WebKitPrintOperation* printOperation = WEBKIT_PRINT_OPERATION(object);
+
+ switch (propId) {
+ case PROP_WEB_VIEW:
+ g_value_take_object(value, printOperation->priv->webView);
+ break;
+ case PROP_PRINT_SETTINGS:
+ g_value_set_object(value, printOperation->priv->printSettings.get());
+ break;
+ case PROP_PAGE_SETUP:
+ g_value_set_object(value, printOperation->priv->pageSetup.get());
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ }
+}
+
+static void webkitPrintOperationSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
+{
+ WebKitPrintOperation* printOperation = WEBKIT_PRINT_OPERATION(object);
+
+ switch (propId) {
+ case PROP_WEB_VIEW:
+ printOperation->priv->webView = WEBKIT_WEB_VIEW(g_value_get_object(value));
+ break;
+ case PROP_PRINT_SETTINGS:
+ webkit_print_operation_set_print_settings(printOperation, GTK_PRINT_SETTINGS(g_value_get_object(value)));
+ break;
+ case PROP_PAGE_SETUP:
+ webkit_print_operation_set_page_setup(printOperation, GTK_PAGE_SETUP(g_value_get_object(value)));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
+ }
+}
+
+static void webkit_print_operation_init(WebKitPrintOperation* printOperation)
+{
+ WebKitPrintOperationPrivate* priv = G_TYPE_INSTANCE_GET_PRIVATE(printOperation, WEBKIT_TYPE_PRINT_OPERATION, WebKitPrintOperationPrivate);
+ printOperation->priv = priv;
+ new (priv) WebKitPrintOperationPrivate();
+}
+
+static void webkit_print_operation_class_init(WebKitPrintOperationClass* printOperationClass)
+{
+ GObjectClass* gObjectClass = G_OBJECT_CLASS(printOperationClass);
+ gObjectClass->finalize = webkitPrintOperationFinalize;
+ gObjectClass->constructed = webkitPrintOperationConstructed;
+ gObjectClass->get_property = webkitPrintOperationGetProperty;
+ gObjectClass->set_property = webkitPrintOperationSetProperty;
+
+ /**
+ * WebKitPrintOperation:web-view:
+ *
+ * The #WebKitWebView that will be printed.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_WEB_VIEW,
+ g_param_spec_object("web-view",
+ _("Web View"),
+ _("The web view that will be printed"),
+ WEBKIT_TYPE_WEB_VIEW,
+ static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
+
+ /**
+ * WebKitPrintOperation:print-settings:
+ *
+ * The initial #GtkPrintSettings for the print operation.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_PRINT_SETTINGS,
+ g_param_spec_object("print-settings",
+ _("Print Settings"),
+ _("The initial print settings for the print operation"),
+ GTK_TYPE_PRINT_SETTINGS,
+ WEBKIT_PARAM_READWRITE));
+ /**
+ * WebKitPrintOperation:page-setup:
+ *
+ * The initial #GtkPageSetup for the print operation.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_PAGE_SETUP,
+ g_param_spec_object("page-setup",
+ _("Page Setup"),
+ _("The initial page setup for the print operation"),
+ GTK_TYPE_PAGE_SETUP,
+ WEBKIT_PARAM_READWRITE));
+
+ /**
+ * WebKitPrintOperation::finished:
+ * @print_operation: the #WebKitPrintOperation on which the signal was emitted
+ *
+ * Emitted when the print operation has finished doing everything
+ * required for printing.
+ */
+ signals[FINISHED] =
+ g_signal_new("finished",
+ G_TYPE_FROM_CLASS(gObjectClass),
+ G_SIGNAL_RUN_LAST,
+ 0, 0, 0,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ g_type_class_add_private(printOperationClass, sizeof(WebKitPrintOperationPrivate));
+}
+
+#ifdef HAVE_GTK_UNIX_PRINTING
+static WebKitPrintOperationResponse webkitPrintOperationRunDialog(WebKitPrintOperation* printOperation, GtkWindow* parent)
+{
+ GtkPrintUnixDialog* printDialog = GTK_PRINT_UNIX_DIALOG(gtk_print_unix_dialog_new(0, parent));
+ gtk_print_unix_dialog_set_manual_capabilities(printDialog, static_cast<GtkPrintCapabilities>(GTK_PRINT_CAPABILITY_NUMBER_UP
+ | GTK_PRINT_CAPABILITY_NUMBER_UP_LAYOUT
+ | GTK_PRINT_CAPABILITY_PAGE_SET
+ | GTK_PRINT_CAPABILITY_REVERSE
+ | GTK_PRINT_CAPABILITY_COPIES
+ | GTK_PRINT_CAPABILITY_COLLATE
+ | GTK_PRINT_CAPABILITY_SCALE));
+
+ WebKitPrintOperationPrivate* priv = printOperation->priv;
+ if (priv->printSettings)
+ gtk_print_unix_dialog_set_settings(printDialog, priv->printSettings.get());
+
+ if (priv->pageSetup)
+ gtk_print_unix_dialog_set_page_setup(printDialog, priv->pageSetup.get());
+
+ gtk_print_unix_dialog_set_embed_page_setup(printDialog, TRUE);
+
+ WebKitPrintOperationResponse returnValue = WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL;
+ if (gtk_dialog_run(GTK_DIALOG(printDialog)) == GTK_RESPONSE_OK) {
+ priv->printSettings = adoptGRef(gtk_print_unix_dialog_get_settings(printDialog));
+ priv->pageSetup = gtk_print_unix_dialog_get_page_setup(printDialog);
+ returnValue = WEBKIT_PRINT_OPERATION_RESPONSE_PRINT;
+ }
+
+ gtk_widget_destroy(GTK_WIDGET(printDialog));
+
+ return returnValue;
+}
+#else
+// TODO: We need to add an implementation for Windows.
+static WebKitPrintOperationResponse webkitPrintOperationRunDialog(WebKitPrintOperation*, GtkWindow*)
+{
+ notImplemented();
+ return WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL;
+}
+#endif
+
+static void drawPagesForPrintingCompleted(WKErrorRef, void* context)
+{
+ GRefPtr<WebKitPrintOperation> printOperation = adoptGRef(WEBKIT_PRINT_OPERATION(context));
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView));
+ page->endPrinting();
+ g_signal_emit(printOperation.get(), signals[FINISHED], 0, NULL);
+}
+
+static void webkitPrintOperationPrintPagesForFrame(WebKitPrintOperation* printOperation, WebFrameProxy* webFrame, GtkPrintSettings* printSettings, GtkPageSetup* pageSetup)
+{
+ PrintInfo printInfo(printSettings, pageSetup);
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView));
+ page->drawPagesForPrinting(webFrame, printInfo, VoidCallback::create(g_object_ref(printOperation), &drawPagesForPrintingCompleted));
+}
+
+WebKitPrintOperationResponse webkitPrintOperationRunDialogForFrame(WebKitPrintOperation* printOperation, GtkWindow* parent, WebFrameProxy* webFrame)
+{
+ WebKitPrintOperationPrivate* priv = printOperation->priv;
+ if (!parent) {
+ GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(priv->webView));
+ if (WebCore::widgetIsOnscreenToplevelWindow(toplevel))
+ parent = GTK_WINDOW(toplevel);
+ }
+
+ WebKitPrintOperationResponse response = webkitPrintOperationRunDialog(printOperation, parent);
+ if (response == WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL)
+ return response;
+
+ webkitPrintOperationPrintPagesForFrame(printOperation, webFrame, priv->printSettings.get(), priv->pageSetup.get());
+ return response;
+}
+
+/**
+ * webkit_print_operation_new:
+ * @web_view: a #WebKitWebView
+ *
+ * Create a new #WebKitPrintOperation to print @web_view contents.
+ *
+ * Returns: (transfer full): a new #WebKitPrintOperation.
+ */
+WebKitPrintOperation* webkit_print_operation_new(WebKitWebView* webView)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+
+ return WEBKIT_PRINT_OPERATION(g_object_new(WEBKIT_TYPE_PRINT_OPERATION, "web-view", webView, NULL));
+}
+
+/**
+ * webkit_print_operation_get_print_settings:
+ * @print_operation: a #WebKitPrintOperation
+ *
+ * Return the current print settings of @print_operation. It returns %NULL until
+ * either webkit_print_operation_set_print_settings() or webkit_print_operation_run_dialog()
+ * have been called.
+ *
+ * Returns: (transfer none): the current #GtkPrintSettings of @print_operation.
+ */
+GtkPrintSettings* webkit_print_operation_get_print_settings(WebKitPrintOperation* printOperation)
+{
+ g_return_val_if_fail(WEBKIT_IS_PRINT_OPERATION(printOperation), 0);
+
+ return printOperation->priv->printSettings.get();
+}
+
+/**
+ * webkit_print_operation_set_print_settings:
+ * @print_operation: a #WebKitPrintOperation
+ * @print_settings: a #GtkPrintSettings to set
+ *
+ * Set the current print settings of @print_operation. Current print settings are used for
+ * the initial values of the print dialog when webkit_print_operation_run_dialog() is called.
+ */
+void webkit_print_operation_set_print_settings(WebKitPrintOperation* printOperation, GtkPrintSettings* printSettings)
+{
+ g_return_if_fail(WEBKIT_IS_PRINT_OPERATION(printOperation));
+ g_return_if_fail(GTK_IS_PRINT_SETTINGS(printSettings));
+
+ if (printOperation->priv->printSettings.get() == printSettings)
+ return;
+
+ printOperation->priv->printSettings = printSettings;
+ g_object_notify(G_OBJECT(printOperation), "print-settings");
+}
+
+/**
+ * webkit_print_operation_get_page_setup:
+ * @print_operation: a #WebKitPrintOperation
+ *
+ * Return the current page setup of @print_operation. It returns %NULL until
+ * either webkit_print_operation_set_print_settings() or webkit_print_operation_run_dialog()
+ * have been called.
+ *
+ * Returns: (transfer none): the current #GtkPageSetup of @print_operation.
+ */
+GtkPageSetup* webkit_print_operation_get_page_setup(WebKitPrintOperation* printOperation)
+{
+ g_return_val_if_fail(WEBKIT_IS_PRINT_OPERATION(printOperation), 0);
+
+ return printOperation->priv->pageSetup.get();
+}
+
+/**
+ * webkit_print_operation_set_page_setup:
+ * @print_operation: a #WebKitPrintOperation
+ * @page_setup: a #GtkPageSetup to set
+ *
+ * Set the current page setup of @print_operation. Current page setup is used for the
+ * initial values of the print dialog when webkit_print_operation_run_dialog() is called.
+ */
+void webkit_print_operation_set_page_setup(WebKitPrintOperation* printOperation, GtkPageSetup* pageSetup)
+{
+ g_return_if_fail(WEBKIT_IS_PRINT_OPERATION(printOperation));
+ g_return_if_fail(GTK_IS_PAGE_SETUP(pageSetup));
+
+ if (printOperation->priv->pageSetup.get() == pageSetup)
+ return;
+
+ printOperation->priv->pageSetup = pageSetup;
+ g_object_notify(G_OBJECT(printOperation), "page-setup");
+}
+
+/**
+ * webkit_print_operation_run_dialog:
+ * @print_operation: a #WebKitPrintOperation
+ * @parent: (allow-none): transient parent of the print dialog
+ *
+ * Run the print dialog and start printing using the options selected by
+ * the user. This method returns when the print dialog is closed.
+ * If the print dialog is cancelled %WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL
+ * is returned. If the user clicks on the print button, %WEBKIT_PRINT_OPERATION_RESPONSE_PRINT
+ * is returned and the print operation starts. In this case, the WebKitPrintOperation::finished
+ * signal is emitted when the operation finishes.
+ * If the print dialog is not cancelled current print settings and page setup of @print_operation
+ * are updated with options selected by the user when Print button is pressed in print dialog.
+ * You can get the updated print settings and page setup by calling
+ * webkit_print_operation_get_print_settings() and webkit_print_operation_get_page_setup()
+ * after this method.
+ *
+ * Returns: the #WebKitPrintOperationResponse of the print dialog
+ */
+WebKitPrintOperationResponse webkit_print_operation_run_dialog(WebKitPrintOperation* printOperation, GtkWindow* parent)
+{
+ g_return_val_if_fail(WEBKIT_IS_PRINT_OPERATION(printOperation), WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL);
+
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView));
+ return webkitPrintOperationRunDialogForFrame(printOperation, parent, page->mainFrame());
+}
+
+/**
+ * webkit_print_operation_print:
+ * @print_operation: a #WebKitPrintOperation
+ *
+ * Start a print operation using current print settings and page setup
+ * without showing the print dialog. If either print settings or page setup
+ * are not set with webkit_print_operation_set_print_settings() and
+ * webkit_print_operation_set_page_setup(), the default options will be used
+ * and the print job will be sent to the default printer.
+ * The WebKitPrintOperation::finished signal is emitted when the printing
+ * operation finishes.
+ */
+void webkit_print_operation_print(WebKitPrintOperation* printOperation)
+{
+ g_return_if_fail(WEBKIT_IS_PRINT_OPERATION(printOperation));
+
+ WebKitPrintOperationPrivate* priv = printOperation->priv;
+ GRefPtr<GtkPrintSettings> printSettings = priv->printSettings ? priv->printSettings : adoptGRef(gtk_print_settings_new());
+ GRefPtr<GtkPageSetup> pageSetup = priv->pageSetup ? priv->pageSetup : adoptGRef(gtk_page_setup_new());
+
+ WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(printOperation->priv->webView));
+ webkitPrintOperationPrintPagesForFrame(printOperation, page->mainFrame(), printSettings.get(), pageSetup.get());
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.h
new file mode 100644
index 000000000..a02f4e809
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperation.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2012 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
+ * 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.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitPrintOperation_h
+#define WebKitPrintOperation_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+#include <webkit2/WebKitWebView.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_PRINT_OPERATION (webkit_print_operation_get_type())
+#define WEBKIT_PRINT_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_PRINT_OPERATION, WebKitPrintOperation))
+#define WEBKIT_IS_PRINT_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_PRINT_OPERATION))
+#define WEBKIT_PRINT_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_PRINT_OPERATION, WebKitPrintOperationClass))
+#define WEBKIT_IS_PRINT_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_PRINT_OPERATION))
+#define WEBKIT_PRINT_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_PRINT_OPERATION, WebKitPrintOperationClass))
+
+typedef struct _WebKitPrintOperationClass WebKitPrintOperationClass;
+typedef struct _WebKitPrintOperationPrivate WebKitPrintOperationPrivate;
+
+/**
+ * WebKitPrintOperationResponse:
+ * @WEBKIT_PRINT_OPERATION_RESPONSE_PRINT: Print button was cliked in print dialog
+ * @WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL: Print dialog was cancelled
+ *
+ * Enum values representing the response of the print dialog shown with
+ * webkit_print_operation_run_dialog().
+ */
+typedef enum {
+ WEBKIT_PRINT_OPERATION_RESPONSE_PRINT,
+ WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL
+} WebKitPrintOperationResponse;
+
+struct _WebKitPrintOperation {
+ GObject parent;
+
+ WebKitPrintOperationPrivate *priv;
+};
+
+struct _WebKitPrintOperationClass {
+ GObjectClass parent_class;
+};
+
+WEBKIT_API GType
+webkit_print_operation_get_type (void);
+
+WEBKIT_API WebKitPrintOperation *
+webkit_print_operation_new (WebKitWebView *web_view);
+
+WEBKIT_API GtkPrintSettings *
+webkit_print_operation_get_print_settings (WebKitPrintOperation *print_operation);
+
+WEBKIT_API void
+webkit_print_operation_set_print_settings (WebKitPrintOperation *print_operation,
+ GtkPrintSettings *print_settings);
+
+WEBKIT_API GtkPageSetup *
+webkit_print_operation_get_page_setup (WebKitPrintOperation *print_operation);
+
+WEBKIT_API void
+webkit_print_operation_set_page_setup (WebKitPrintOperation *print_operation,
+ GtkPageSetup *page_setup);
+
+WEBKIT_API WebKitPrintOperationResponse
+webkit_print_operation_run_dialog (WebKitPrintOperation *print_operation,
+ GtkWindow *parent);
+
+WEBKIT_API void
+webkit_print_operation_print (WebKitPrintOperation *print_operation);
+
+G_END_DECLS
+
+#endif
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperationPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperationPrivate.h
new file mode 100644
index 000000000..7a4fb4e43
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPrintOperationPrivate.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2012 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
+ * 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 WebKitPrintOperationPrivate_h
+#define WebKitPrintOperationPrivate_h
+
+#include "WebFrameProxy.h"
+#include "WebKitPrintOperation.h"
+
+WebKitPrintOperationResponse webkitPrintOperationRunDialogForFrame(WebKitPrintOperation*, GtkWindow* parent, WebKit::WebFrameProxy*);
+
+#endif // WebKitPrintOperationPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.cpp
new file mode 100644
index 000000000..998c3abfa
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 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
+ * 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 <gdk/gdk.h>
+
+unsigned wkEventModifiersToGdkModifiers(WKEventModifiers wkModifiers)
+{
+ unsigned modifiers = 0;
+ if (wkModifiers & kWKEventModifiersShiftKey)
+ modifiers |= GDK_SHIFT_MASK;
+ if (wkModifiers & kWKEventModifiersControlKey)
+ modifiers |= GDK_CONTROL_MASK;
+ if (wkModifiers & kWKEventModifiersAltKey)
+ modifiers |= GDK_MOD1_MASK;
+ if (wkModifiers & kWKEventModifiersMetaKey)
+ modifiers |= GDK_META_MASK;
+ return modifiers;
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
index c44d877e0..43d26cc85 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h
@@ -40,4 +40,6 @@
#define COMPILE_ASSERT_MATCHING_ENUM(webkitName, webcoreName) \
COMPILE_ASSERT(int(webkitName) == int(webcoreName), mismatchingEnums)
+unsigned wkEventModifiersToGdkModifiers(WKEventModifiers);
+
#endif // WebKitPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
index 774f17190..c1c4a970b 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp
@@ -102,7 +102,8 @@ enum {
PROP_ENABLE_CARET_BROWSING,
PROP_ENABLE_FULLSCREEN,
PROP_PRINT_BACKGROUNDS,
- PROP_ENABLE_WEBAUDIO
+ PROP_ENABLE_WEBAUDIO,
+ PROP_ENABLE_WEBGL
};
static void webKitSettingsSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
@@ -206,6 +207,9 @@ static void webKitSettingsSetProperty(GObject* object, guint propId, const GValu
case PROP_ENABLE_WEBAUDIO:
webkit_settings_set_enable_webaudio(settings, g_value_get_boolean(value));
break;
+ case PROP_ENABLE_WEBGL:
+ webkit_settings_set_enable_webgl(settings, g_value_get_boolean(value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
break;
@@ -313,6 +317,9 @@ static void webKitSettingsGetProperty(GObject* object, guint propId, GValue* val
case PROP_ENABLE_WEBAUDIO:
g_value_set_boolean(value, webkit_settings_get_enable_webaudio(settings));
break;
+ case PROP_ENABLE_WEBGL:
+ g_value_set_boolean(value, webkit_settings_get_enable_webgl(settings));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
break;
@@ -794,6 +801,21 @@ static void webkit_settings_class_init(WebKitSettingsClass* klass)
FALSE,
readWriteConstructParamFlags));
+ /**
+ * WebKitSettings:enable-webgl:
+ *
+ * Enable or disable support for WebGL on pages. WebGL is an experimental
+ * proposal for allowing web pages to use OpenGL ES-like calls directly. The
+ * standard is currently a work-in-progress by the Khronos Group.
+ */
+ g_object_class_install_property(gObjectClass,
+ PROP_ENABLE_WEBGL,
+ g_param_spec_boolean("enable-webgl",
+ _("Enable WebGL"),
+ _("Whether WebGL content should be rendered"),
+ FALSE,
+ readWriteConstructParamFlags));
+
g_type_class_add_private(klass, sizeof(WebKitSettingsPrivate));
}
@@ -2016,3 +2038,38 @@ void webkit_settings_set_enable_webaudio(WebKitSettings* settings, gboolean enab
WKPreferencesSetWebAudioEnabled(priv->preferences.get(), enabled);
g_object_notify(G_OBJECT(settings), "enable-webaudio");
}
+
+/**
+ * webkit_settings_get_enable_webgl:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-webgl property.
+ *
+ * Returns: %TRUE If webgl support is enabled or %FALSE otherwise.
+ */
+gboolean webkit_settings_get_enable_webgl(WebKitSettings* settings)
+{
+ g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+ return WKPreferencesGetWebGLEnabled(settings->priv->preferences.get());
+}
+
+/**
+ * webkit_settings_set_enable_webgl:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-webgl property.
+ */
+void webkit_settings_set_enable_webgl(WebKitSettings* settings, gboolean enabled)
+{
+ g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+ WebKitSettingsPrivate* priv = settings->priv;
+ bool currentValue = WKPreferencesGetWebGLEnabled(priv->preferences.get());
+ if (currentValue == enabled)
+ return;
+
+ WKPreferencesSetWebGLEnabled(priv->preferences.get(), enabled);
+ g_object_notify(G_OBJECT(settings), "enable-webgl");
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h
index 27cb7c75a..b22ba00ff 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h
@@ -300,6 +300,13 @@ WEBKIT_API void
webkit_settings_set_enable_webaudio (WebKitSettings *settings,
gboolean enabled);
+WEBKIT_API gboolean
+webkit_settings_get_enable_webgl (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_webgl (WebKitSettings *settings,
+ gboolean enabled);
+
G_END_DECLS
#endif /* WebKitSettings_h */
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
index a659ad314..6f0e11c82 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitUIClient.cpp
@@ -126,6 +126,16 @@ static void setWindowFrame(WKPageRef page, WKRect frame, const void* clientInfo)
webkitWindowPropertiesSetGeometry(windowProperties, &geometry);
}
+static void mouseDidMoveOverElement(WKPageRef page, WKHitTestResultRef hitTestResult, WKEventModifiers modifiers, WKTypeRef userData, const void* clientInfo)
+{
+ webkitWebViewMouseTargetChanged(WEBKIT_WEB_VIEW(clientInfo), hitTestResult, wkEventModifiersToGdkModifiers(modifiers));
+}
+
+static void printFrame(WKPageRef page, WKFrameRef frame, const void*)
+{
+ webkitWebViewPrintFrame(WEBKIT_WEB_VIEW(toImpl(page)->viewWidget()), frame);
+}
+
void attachUIClientToView(WebKitWebView* webView)
{
WKPageUIClient wkUIClient = {
@@ -165,13 +175,13 @@ void attachUIClientToView(WebKitWebView* webView)
0, // footerHeight
0, // drawHeader
0, // drawFooter
- 0, // printFrame
+ printFrame,
0, // runModal
0, // didCompleteRubberBandForMainFrame
0, // saveDataToFileInDownloadsFolder
0, // shouldInterruptJavaScript
createNewPage,
- 0, // mouseDidMoveOverElement
+ mouseDidMoveOverElement,
0, // decidePolicyForNotificationPermissionRequest
};
WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)));
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
index c3accccbb..be590ff33 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
@@ -24,9 +24,11 @@
#include "WebKitBackForwardListPrivate.h"
#include "WebKitEnumTypes.h"
#include "WebKitError.h"
+#include "WebKitHitTestResultPrivate.h"
#include "WebKitLoaderClient.h"
#include "WebKitMarshal.h"
#include "WebKitPolicyClient.h"
+#include "WebKitPrintOperationPrivate.h"
#include "WebKitPrivate.h"
#include "WebKitSettingsPrivate.h"
#include "WebKitUIClient.h"
@@ -59,6 +61,10 @@ enum {
DECIDE_POLICY,
+ MOUSE_TARGET_CHANGED,
+
+ PRINT_REQUESTED,
+
LAST_SIGNAL
};
@@ -83,6 +89,9 @@ struct _WebKitWebViewPrivate {
GRefPtr<WebKitBackForwardList> backForwardList;
GRefPtr<WebKitSettings> settings;
GRefPtr<WebKitWindowProperties> windowProperties;
+
+ GRefPtr<WebKitHitTestResult> mouseTargetHitTestResult;
+ unsigned mouseTargetModifiers;
};
static guint signals[LAST_SIGNAL] = { 0, };
@@ -615,6 +624,59 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
G_TYPE_BOOLEAN, 2, /* number of parameters */
WEBKIT_TYPE_POLICY_DECISION,
WEBKIT_TYPE_POLICY_DECISION_TYPE);
+
+ /**
+ * WebKitWebView::mouse-target-changed:
+ * @web_view: the #WebKitWebView on which the signal is emitted
+ * @hit_test_result: a #WebKitHitTestResult
+ * @modifiers: a bitmask of #GdkModifierType
+ *
+ * This signal is emitted when the mouse cursor moves over an
+ * element such as a link, image or a media element. To determine
+ * what type of element the mouse cursor is over, a Hit Test is performed
+ * on the current mouse coordinates and the result is passed in the
+ * @hit_test_result argument. The @modifiers argument is a bitmask of
+ * #GdkModifierType flags indicating the state of modifier keys.
+ * The signal is emitted again when the mouse is moved out of the
+ * current element with a new @hit_test_result.
+ */
+ signals[MOUSE_TARGET_CHANGED] =
+ g_signal_new("mouse-target-changed",
+ G_TYPE_FROM_CLASS(webViewClass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(WebKitWebViewClass, mouse_target_changed),
+ 0, 0,
+ webkit_marshal_VOID__OBJECT_UINT,
+ G_TYPE_NONE, 2,
+ WEBKIT_TYPE_HIT_TEST_RESULT,
+ G_TYPE_UINT);
+ /**
+ * WebKitWebView::print-requested:
+ * @web_view: the #WebKitWebView on which the signal is emitted
+ * @print_operation: the #WebKitPrintOperation that will handle the print request
+ *
+ * Emitted when printing is requested on @web_view, usually by a javascript call,
+ * before the print dialog is shown. This signal can be used to set the initial
+ * print settings and page setup of @print_operation to be used as default values in
+ * the print dialog. You can call webkit_print_operation_set_print_settings() and
+ * webkit_print_operation_set_page_setup() and then return %FALSE to propagate the
+ * event so that the print dialog is shown.
+ *
+ * You can connect to this signal and return %TRUE to cancel the print operation
+ * or implement your own print dialog.
+ *
+ * Returns: %TRUE to stop other handlers from being invoked for the event.
+ * %FALSE to propagate the event further.
+ */
+ signals[PRINT_REQUESTED] =
+ g_signal_new("print-requested",
+ G_TYPE_FROM_CLASS(webViewClass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(WebKitWebViewClass, print_requested),
+ g_signal_accumulator_true_handled, 0,
+ webkit_marshal_BOOLEAN__OBJECT,
+ G_TYPE_BOOLEAN, 1,
+ WEBKIT_TYPE_PRINT_OPERATION);
}
void webkitWebViewLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent)
@@ -726,6 +788,33 @@ void webkitWebViewMakePolicyDecision(WebKitWebView* webView, WebKitPolicyDecisio
g_signal_emit(webView, signals[DECIDE_POLICY], 0, decision, type, &returnValue);
}
+void webkitWebViewMouseTargetChanged(WebKitWebView* webView, WKHitTestResultRef wkHitTestResult, unsigned modifiers)
+{
+ WebKitWebViewPrivate* priv = webView->priv;
+ if (priv->mouseTargetHitTestResult
+ && priv->mouseTargetModifiers == modifiers
+ && webkitHitTestResultCompare(priv->mouseTargetHitTestResult.get(), wkHitTestResult))
+ return;
+
+ priv->mouseTargetModifiers = modifiers;
+ priv->mouseTargetHitTestResult = adoptGRef(webkitHitTestResultCreate(wkHitTestResult));
+ g_signal_emit(webView, signals[MOUSE_TARGET_CHANGED], 0, priv->mouseTargetHitTestResult.get(), modifiers);
+}
+
+void webkitWebViewPrintFrame(WebKitWebView* webView, WKFrameRef wkFrame)
+{
+ GRefPtr<WebKitPrintOperation> printOperation = adoptGRef(webkit_print_operation_new(webView));
+ gboolean returnValue;
+ g_signal_emit(webView, signals[PRINT_REQUESTED], 0, printOperation.get(), &returnValue);
+ if (returnValue)
+ return;
+
+ WebKitPrintOperationResponse response = webkitPrintOperationRunDialogForFrame(printOperation.get(), 0, toImpl(wkFrame));
+ if (response == WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL)
+ return;
+ g_signal_connect(printOperation.leakRef(), "finished", G_CALLBACK(g_object_unref), 0);
+}
+
/**
* webkit_web_view_new:
*
@@ -796,10 +885,14 @@ void webkit_web_view_load_uri(WebKitWebView* webView, const gchar* uri)
* @base_uri: (allow-none): The base URI for relative locations or %NULL
*
* Load the given @content string with the specified @base_uri.
- * Relative URLs in the @content will be resolved against @base_uri.
- * When @base_uri is %NULL, it defaults to "about:blank". The mime type
- * of the document will be "text/html". You can monitor the load operation
- * by connecting to #WebKitWebView::load-changed signal.
+ * If @base_uri is not %NULL, relative URLs in the @content will be
+ * resolved against @base_uri and absolute local paths must be children of the @base_uri.
+ * For security reasons absolute local paths that are not children of @base_uri
+ * will cause the web process to terminate.
+ * If you need to include URLs in @content that are local paths in a different
+ * directory than @base_uri you can build a data URI for them. When @base_uri is %NULL,
+ * it defaults to "about:blank". The mime type of the document will be "text/html".
+ * You can monitor the load operation by connecting to #WebKitWebView::load-changed signal.
*/
void webkit_web_view_load_html(WebKitWebView* webView, const gchar* content, const gchar* baseURI)
{
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
index d4768e3b6..a1b21420b 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
@@ -30,9 +30,10 @@
#include <webkit2/WebKitBackForwardList.h>
#include <webkit2/WebKitDefines.h>
-#include <webkit2/WebKitWebContext.h>
+#include <webkit2/WebKitHitTestResult.h>
#include <webkit2/WebKitSettings.h>
#include <webkit2/WebKitURIRequest.h>
+#include <webkit2/WebKitWebContext.h>
#include <webkit2/WebKitWebViewBase.h>
#include <webkit2/WebKitWindowProperties.h>
#include <webkit2/WebKitPolicyDecision.h>
@@ -116,29 +117,34 @@ struct _WebKitWebView {
struct _WebKitWebViewClass {
WebKitWebViewBaseClass parent;
- void (* load_changed) (WebKitWebView *web_view,
- WebKitLoadEvent load_event);
- gboolean (* load_failed) (WebKitWebView *web_view,
- WebKitLoadEvent load_event,
- const gchar *failing_uri,
- GError *error);
-
- GtkWidget *(* create) (WebKitWebView *web_view);
- void (* ready_to_show) (WebKitWebView *web_view);
- void (* close) (WebKitWebView *web_view);
-
- gboolean (* script_alert) (WebKitWebView *web_view,
- const gchar *message);
- gboolean (* script_confirm) (WebKitWebView *web_view,
- const gchar *message,
- gboolean *confirmed);
- gboolean (* script_prompt) (WebKitWebView *web_view,
- const gchar *message,
- const gchar *default_text,
- gchar **text);
- gboolean (* decide_policy) (WebKitWebView *web_view,
- WebKitPolicyDecision *decision,
- WebKitPolicyDecisionType type);
+ void (* load_changed) (WebKitWebView *web_view,
+ WebKitLoadEvent load_event);
+ gboolean (* load_failed) (WebKitWebView *web_view,
+ WebKitLoadEvent load_event,
+ const gchar *failing_uri,
+ GError *error);
+
+ GtkWidget *(* create) (WebKitWebView *web_view);
+ void (* ready_to_show) (WebKitWebView *web_view);
+ void (* close) (WebKitWebView *web_view);
+
+ gboolean (* script_alert) (WebKitWebView *web_view,
+ const gchar *message);
+ gboolean (* script_confirm) (WebKitWebView *web_view,
+ const gchar *message,
+ gboolean *confirmed);
+ gboolean (* script_prompt) (WebKitWebView *web_view,
+ const gchar *message,
+ const gchar *default_text,
+ gchar **text);
+ gboolean (* decide_policy) (WebKitWebView *web_view,
+ WebKitPolicyDecision *decision,
+ WebKitPolicyDecisionType type);
+ void (* mouse_target_changed) (WebKitWebView *web_view,
+ WebKitHitTestResult *hit_test_result,
+ guint modifiers);
+ gboolean (* print_requested) (WebKitWebView *web_view,
+ WebKitPrintOperation *print_operation);
/* Padding for future expansion */
void (*_webkit_reserved0) (void);
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
index 66386d028..ad8ab2038 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
@@ -43,5 +43,7 @@ void webkitWebViewRunJavaScriptAlert(WebKitWebView*, const CString& message);
bool webkitWebViewRunJavaScriptConfirm(WebKitWebView*, const CString& message);
WKStringRef webkitWebViewRunJavaScriptPrompt(WebKitWebView*, const CString& message, const CString& defaultText);
void webkitWebViewMakePolicyDecision(WebKitWebView*, WebKitPolicyDecisionType, WebKitPolicyDecision*);
+void webkitWebViewMouseTargetChanged(WebKitWebView*, WKHitTestResultRef, unsigned modifiers);
+void webkitWebViewPrintFrame(WebKitWebView*, WKFrameRef);
#endif // WebKitWebViewPrivate_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp
index 413890203..242b753e8 100644
--- a/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp
@@ -377,7 +377,7 @@ void webkitWindowPropertiesSetResizable(WebKitWindowProperties* windowProperties
if (windowProperties->priv->resizable == resizable)
return;
windowProperties->priv->resizable = resizable;
- g_object_notify(G_OBJECT(windowProperties), "resizable-visible");
+ g_object_notify(G_OBJECT(windowProperties), "resizable");
}
void webkitWindowPropertiesSetFullscreen(WebKitWindowProperties* windowProperties, bool fullscreen)
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
index af0cdae7c..5cd859dad 100644
--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
@@ -24,6 +24,8 @@
<xi:include href="xml/WebKitPolicyDecision.xml"/>
<xi:include href="xml/WebKitNavigationPolicyDecision.xml"/>
<xi:include href="xml/WebKitResponsePolicyDecision.xml"/>
+ <xi:include href="xml/WebKitHitTestResult.xml"/>
+ <xi:include href="xml/WebKitPrintOperation.xml"/>
<xi:include href="xml/WebKitError.xml"/>
</chapter>
diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
index 52cd89ee7..5bfc129b2 100644
--- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
+++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
@@ -218,6 +218,8 @@ webkit_settings_get_print_backgrounds
webkit_settings_set_print_backgrounds
webkit_settings_get_enable_webaudio
webkit_settings_set_enable_webaudio
+webkit_settings_get_enable_webgl
+webkit_settings_set_enable_webgl
<SUBSECTION Standard>
WebKitSettingsClass
@@ -390,6 +392,60 @@ webkit_response_policy_decision_get_type
</SECTION>
<SECTION>
+<FILE>WebKitHitTestResult</FILE>
+WebKitHitTestResult
+WebKitHitTestResultContext
+webkit_hit_test_result_get_context
+webkit_hit_test_result_context_is_link
+webkit_hit_test_result_context_is_image
+webkit_hit_test_result_context_is_media
+webkit_hit_test_result_get_link_uri
+webkit_hit_test_result_get_link_title
+webkit_hit_test_result_get_link_label
+webkit_hit_test_result_get_image_uri
+webkit_hit_test_result_get_media_uri
+
+<SUBSECTION Standard>
+WebKitHitTestResultClass
+WEBKIT_TYPE_HIT_TEST_RESULT
+WEBKIT_HIT_TEST_RESULT
+WEBKIT_IS_HIT_TEST_RESULT
+WEBKIT_HIT_TEST_RESULT_CLASS
+WEBKIT_IS_HIT_TEST_RESULT_CLASS
+WEBKIT_HIT_TEST_RESULT_GET_CLASS
+
+<SUBSECTION Private>
+WebKitHitTestResultPrivate
+webkit_hit_test_result_get_type
+</SECTION>
+
+<SECTION>
+<FILE>WebKitPrintOperation</FILE>
+WebKitPrintOperation
+WebKitPrintOperationResponse
+webkit_print_operation_new
+webkit_print_operation_get_print_settings
+webkit_print_operation_set_print_settings
+webkit_print_operation_get_page_setup
+webkit_print_operation_set_page_setup
+webkit_print_operation_run_dialog
+webkit_print_operation_print
+
+<SUBSECTION Standard>
+WebKitPrintOperationClass
+WEBKIT_TYPE_PRINT_OPERATION
+WEBKIT_PRINT_OPERATION
+WEBKIT_IS_PRINT_OPERATION
+WEBKIT_PRINT_OPERATION_CLASS
+WEBKIT_IS_PRINT_OPERATION_CLASS
+WEBKIT_PRINT_OPERATION_GET_CLASS
+
+<SUBSECTION Private>
+WebKitPrintOperationPrivate
+webkit_print_operation_get_type
+</SECTION>
+
+<SECTION>
<FILE>WebKitError</FILE>
WEBKIT_NETWORK_ERROR
WEBKIT_PLUGIN_ERROR
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am b/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
index 7241b9980..35ece6845 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am
@@ -1,3 +1,5 @@
+if ENABLE_WEBKIT2
+
TEST_PROGS += \
Programs/WebKit2APITests/TestWebKitWebContext \
Programs/WebKit2APITests/TestWebKitWebView \
@@ -6,7 +8,8 @@ TEST_PROGS += \
Programs/WebKit2APITests/TestBackForwardList \
Programs/WebKit2APITests/TestDownloads \
Programs/WebKit2APITests/TestWebKitPolicyClient \
- Programs/WebKit2APITests/TestWebViewEditor
+ Programs/WebKit2APITests/TestWebViewEditor \
+ Programs/WebKit2APITests/TestPrinting
noinst_PROGRAMS += $(TEST_PROGS)
@@ -118,3 +121,11 @@ Programs_WebKit2APITests_TestWebViewEditor_SOURCES = \
Programs_WebKit2APITests_TestWebViewEditor_CPPFLAGS = $(webkit2_tests_cppflags)
Programs_WebKit2APITests_TestWebViewEditor_LDADD = $(webkit2_tests_ldadd)
Programs_WebKit2APITests_TestWebViewEditor_LDFLAGS = $(webkit2_tests_ldflags)
+
+Programs_WebKit2APITests_TestPrinting_SOURCES = \
+ Source/WebKit2/UIProcess/API/gtk/tests/TestPrinting.cpp
+Programs_WebKit2APITests_TestPrinting_CPPFLAGS = $(webkit2_tests_cppflags) $(GTK_UNIX_PRINTING_CFLAGS)
+Programs_WebKit2APITests_TestPrinting_LDADD = $(webkit2_tests_ldadd) $(GTK_UNIX_PRINTING_LIBS)
+Programs_WebKit2APITests_TestPrinting_LDFLAGS = $(webkit2_tests_ldflags)
+
+endif # ENABLE_WEBKIT2
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestPrinting.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestPrinting.cpp
new file mode 100644
index 000000000..1ddde0858
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestPrinting.cpp
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2012 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 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 "WebViewTest.h"
+#include <glib/gstdio.h>
+#include <wtf/gobject/GRefPtr.h>
+
+#ifdef HAVE_GTK_UNIX_PRINTING
+#include <gtk/gtkunixprint.h>
+#endif
+
+static char* kTempDirectory;
+
+static void testPrintOperationPrintSettings(WebViewTest* test, gconstpointer)
+{
+ GRefPtr<WebKitPrintOperation> printOperation = adoptGRef(webkit_print_operation_new(test->m_webView));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(printOperation.get()));
+
+ g_assert(!webkit_print_operation_get_print_settings(printOperation.get()));
+ g_assert(!webkit_print_operation_get_page_setup(printOperation.get()));
+
+ GRefPtr<GtkPrintSettings> printSettings = adoptGRef(gtk_print_settings_new());
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(printSettings.get()));
+
+ GRefPtr<GtkPageSetup> pageSetup = adoptGRef(gtk_page_setup_new());
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(pageSetup.get()));
+
+ webkit_print_operation_set_print_settings(printOperation.get(), printSettings.get());
+ webkit_print_operation_set_page_setup(printOperation.get(), pageSetup.get());
+
+ g_assert(webkit_print_operation_get_print_settings(printOperation.get()) == printSettings.get());
+ g_assert(webkit_print_operation_get_page_setup(printOperation.get()) == pageSetup.get());
+}
+
+static gboolean webViewPrintRequestedCallback(WebKitWebView* webView, WebKitPrintOperation* printOperation, WebViewTest* test)
+{
+ g_assert(webView == test->m_webView);
+
+ g_assert(WEBKIT_IS_PRINT_OPERATION(printOperation));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(printOperation));
+
+ g_assert(!webkit_print_operation_get_print_settings(printOperation));
+ g_assert(!webkit_print_operation_get_page_setup(printOperation));
+
+ g_main_loop_quit(test->m_mainLoop);
+
+ return TRUE;
+}
+
+static void testWebViewPrintRequested(WebViewTest* test, gconstpointer)
+{
+ g_signal_connect(test->m_webView, "print-requested", G_CALLBACK(webViewPrintRequestedCallback), test);
+ test->loadHtml("<html><body onLoad=\"print();\">WebKitGTK+ printing test</body></html>", 0);
+ g_main_loop_run(test->m_mainLoop);
+}
+
+#ifdef HAVE_GTK_UNIX_PRINTING
+static void testPrintOperationPrintLoadChanged(WebKitWebView*, WebKitLoadEvent loadEvent, WebViewTest* test)
+{
+ if (loadEvent != WEBKIT_LOAD_FINISHED)
+ return;
+ g_main_loop_quit(test->m_mainLoop);
+}
+
+static void testPrintOperationPrintFinished(WebKitPrintOperation* printOperation, WebViewTest* test)
+{
+ g_object_unref(printOperation);
+ g_main_loop_quit(test->m_mainLoop);
+}
+
+static gboolean testPrintOperationPrintPrinter(GtkPrinter* printer, gpointer userData)
+{
+ if (strcmp(gtk_printer_get_name(printer), "Print to File"))
+ return FALSE;
+
+ GtkPrinter** foundPrinter = static_cast<GtkPrinter**>(userData);
+ *foundPrinter = static_cast<GtkPrinter*>(g_object_ref(printer));
+ return TRUE;
+}
+
+static void testPrintOperationPrint(WebViewTest* test, gconstpointer)
+{
+ g_signal_connect(test->m_webView, "load-changed", G_CALLBACK(testPrintOperationPrintLoadChanged), test);
+ test->loadHtml("<html><body>WebKitGTK+ printing test</body></html>", 0);
+ g_main_loop_run(test->m_mainLoop);
+
+ GtkPrinter* printer = 0;
+ gtk_enumerate_printers(testPrintOperationPrintPrinter, &printer, 0, TRUE);
+ if (!printer) {
+ g_message("%s", "Cannot test WebKitPrintOperation/print: no suitable printer found");
+ return;
+ }
+
+ GOwnPtr<char> outputFilename(g_build_filename(kTempDirectory, "webkit-print.pdf", NULL));
+ GRefPtr<GFile> outputFile = adoptGRef(g_file_new_for_path(outputFilename.get()));
+ GOwnPtr<char> outputURI(g_file_get_uri(outputFile.get()));
+
+ GRefPtr<GtkPrintSettings> printSettings = adoptGRef(gtk_print_settings_new());
+ gtk_print_settings_set_printer(printSettings.get(), gtk_printer_get_name(printer));
+ gtk_print_settings_set(printSettings.get(), GTK_PRINT_SETTINGS_OUTPUT_URI, outputURI.get());
+ g_object_unref(printer);
+
+ GRefPtr<WebKitPrintOperation> printOperation = webkit_print_operation_new(test->m_webView);
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(printOperation.get()));
+ g_signal_connect(printOperation.get(), "finished", G_CALLBACK(testPrintOperationPrintFinished), test);
+ webkit_print_operation_set_print_settings(printOperation.get(), printSettings.get());
+ webkit_print_operation_print(printOperation.get());
+ g_main_loop_run(test->m_mainLoop);
+
+ GRefPtr<GFileInfo> fileInfo = adoptGRef(g_file_query_info(outputFile.get(), G_FILE_ATTRIBUTE_STANDARD_SIZE","G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE,
+ static_cast<GFileQueryInfoFlags>(0), 0, 0));
+ g_assert(fileInfo.get());
+ g_assert_cmpint(g_file_info_get_size(fileInfo.get()), >, 0);
+ g_assert_cmpstr(g_file_info_get_content_type(fileInfo.get()), ==, "application/pdf");
+
+ g_file_delete(outputFile.get(), 0, 0);
+}
+#endif // HAVE_GTK_UNIX_PRINTING
+
+void beforeAll()
+{
+ kTempDirectory = g_dir_make_tmp("WebKit2Tests-XXXXXX", 0);
+ g_assert(kTempDirectory);
+
+ WebViewTest::add("WebKitPrintOperation", "printing-settings", testPrintOperationPrintSettings);
+ WebViewTest::add("WebKitWebView", "print-requested", testWebViewPrintRequested);
+#ifdef HAVE_GTK_UNIX_PRINTING
+ WebViewTest::add("WebKitPrintOperation", "print", testPrintOperationPrint);
+#endif
+}
+
+void afterAll()
+{
+ g_rmdir(kTempDirectory);
+}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp
index 0ecea5604..a3ce7dece 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp
@@ -194,6 +194,11 @@ static void testWebKitSettings(Test*, gconstpointer)
webkit_settings_set_enable_webaudio(settings, TRUE);
g_assert(webkit_settings_get_enable_webaudio(settings));
+ // WebGL is disabled by default.
+ g_assert(!webkit_settings_get_enable_webgl(settings));
+ webkit_settings_set_enable_webgl(settings, TRUE);
+ g_assert(webkit_settings_get_enable_webgl(settings));
+
g_object_unref(G_OBJECT(settings));
}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
index 3d59ee917..47da98eb3 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp
@@ -267,15 +267,27 @@ public:
return TRUE;
}
+ static void mouseTargetChanged(WebKitWebView*, WebKitHitTestResult* hitTestResult, guint modifiers, UIClientTest* test)
+ {
+ g_assert(WEBKIT_IS_HIT_TEST_RESULT(hitTestResult));
+ test->assertObjectIsDeletedWhenTestFinishes(G_OBJECT(hitTestResult));
+
+ test->m_mouseTargetHitTestResult = hitTestResult;
+ test->m_mouseTargetModifiers = modifiers;
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
UIClientTest()
: m_scriptType(Alert)
, m_scriptDialogConfirmed(true)
+ , m_mouseTargetModifiers(0)
{
webkit_settings_set_javascript_can_open_windows_automatically(webkit_web_view_get_settings(m_webView), TRUE);
g_signal_connect(m_webView, "create", G_CALLBACK(viewCreate), this);
g_signal_connect(m_webView, "script-alert", G_CALLBACK(scriptAlert), this);
g_signal_connect(m_webView, "script-confirm", G_CALLBACK(scriptConfirm), this);
g_signal_connect(m_webView, "script-prompt", G_CALLBACK(scriptPrompt), this);
+ g_signal_connect(m_webView, "mouse-target-changed", G_CALLBACK(mouseTargetChanged), this);
}
~UIClientTest()
@@ -293,11 +305,20 @@ public:
m_windowProperties = windowProperties;
}
+ WebKitHitTestResult* moveMouseAndWaitUntilMouseTargetChanged(int x, int y, unsigned int mouseModifiers = 0)
+ {
+ mouseMoveTo(x, y, mouseModifiers);
+ g_main_loop_run(m_mainLoop);
+ return m_mouseTargetHitTestResult.get();
+ }
+
Vector<WebViewEvents> m_webViewEvents;
ScriptType m_scriptType;
bool m_scriptDialogConfirmed;
WindowProperties m_windowProperties;
HashSet<WTF::String> m_windowPropertiesChanged;
+ GRefPtr<WebKitHitTestResult> m_mouseTargetHitTestResult;
+ unsigned int m_mouseTargetModifiers;
};
static void testWebViewCreateReadyClose(UIClientTest* test, gconstpointer)
@@ -361,6 +382,66 @@ static void testWebViewWindowProperties(UIClientTest* test, gconstpointer)
g_assert_cmpint(events[2], ==, UIClientTest::Close);
}
+static void testWebViewMouseTarget(UIClientTest* test, gconstpointer)
+{
+ test->showInWindowAndWaitUntilMapped();
+
+ const char* linksHoveredHTML =
+ "<html><body>"
+ " <a style='position:absolute; left:1; top:1' href='http://www.webkitgtk.org' title='WebKitGTK+ Title'>WebKitGTK+ Website</a>"
+ " <img style='position:absolute; left:1; top:10' src='0xdeadbeef' width=5 height=5></img>"
+ " <a style='position:absolute; left:1; top:20' href='http://www.webkitgtk.org/logo' title='WebKitGTK+ Logo'><img src='0xdeadbeef' width=5 height=5></img></a>"
+ " <video style='position:absolute; left:1; top:30' width=10 height=10 controls='controls'><source src='movie.ogg' type='video/ogg' /></video>"
+ "</body></html>";
+
+ test->loadHtml(linksHoveredHTML, "file:///");
+ test->waitUntilLoadFinished();
+
+ // Move over link.
+ WebKitHitTestResult* hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 1);
+ g_assert(webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/");
+ g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Title");
+ g_assert_cmpstr(webkit_hit_test_result_get_link_label(hitTestResult), ==, "WebKitGTK+ Website");
+ g_assert(!test->m_mouseTargetModifiers);
+
+ // Move out of the link.
+ hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(0, 0);
+ g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert(!test->m_mouseTargetModifiers);
+
+ // Move over image with GDK_CONTROL_MASK.
+ hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 10, GDK_CONTROL_MASK);
+ g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef");
+ g_assert(test->m_mouseTargetModifiers & GDK_CONTROL_MASK);
+
+ // Move over image link.
+ hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 20);
+ g_assert(webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert_cmpstr(webkit_hit_test_result_get_link_uri(hitTestResult), ==, "http://www.webkitgtk.org/logo");
+ g_assert_cmpstr(webkit_hit_test_result_get_image_uri(hitTestResult), ==, "file:///0xdeadbeef");
+ g_assert_cmpstr(webkit_hit_test_result_get_link_title(hitTestResult), ==, "WebKitGTK+ Logo");
+ g_assert(!webkit_hit_test_result_get_link_label(hitTestResult));
+ g_assert(!test->m_mouseTargetModifiers);
+
+ // Move over media.
+ hitTestResult = test->moveMouseAndWaitUntilMouseTargetChanged(1, 30);
+ g_assert(!webkit_hit_test_result_context_is_link(hitTestResult));
+ g_assert(!webkit_hit_test_result_context_is_image(hitTestResult));
+ g_assert(webkit_hit_test_result_context_is_media(hitTestResult));
+ g_assert_cmpstr(webkit_hit_test_result_get_media_uri(hitTestResult), ==, "file:///movie.ogg");
+ g_assert(!test->m_mouseTargetModifiers);
+}
+
static void testWebViewZoomLevel(WebViewTest* test, gconstpointer)
{
g_assert_cmpfloat(webkit_web_view_get_zoom_level(test->m_webView), ==, 1);
@@ -377,6 +458,7 @@ void beforeAll()
UIClientTest::add("WebKitWebView", "create-ready-close", testWebViewCreateReadyClose);
UIClientTest::add("WebKitWebView", "javascript-dialogs", testWebViewJavaScriptDialogs);
UIClientTest::add("WebKitWebView", "window-properties", testWebViewWindowProperties);
+ UIClientTest::add("WebKitWebView", "mouse-target", testWebViewMouseTarget);
WebViewTest::add("WebKitWebView", "zoom-level", testWebViewZoomLevel);
}
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp
index 20895eccb..00d3b3e20 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp
@@ -21,15 +21,20 @@
#include "config.h"
#include "WebViewTest.h"
+#include <WebCore/GOwnPtrGtk.h>
+
WebViewTest::WebViewTest()
: m_webView(WEBKIT_WEB_VIEW(g_object_ref_sink(webkit_web_view_new())))
, m_mainLoop(g_main_loop_new(0, TRUE))
+ , m_parentWindow(0)
{
assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_webView));
}
WebViewTest::~WebViewTest()
{
+ if (m_parentWindow)
+ gtk_widget_destroy(m_parentWindow);
g_object_unref(m_webView);
g_main_loop_unref(m_mainLoop);
}
@@ -130,3 +135,48 @@ void WebViewTest::waitUntilLoadFinished()
g_signal_connect(m_webView, "load-changed", G_CALLBACK(loadChanged), this);
g_main_loop_run(m_mainLoop);
}
+
+static gboolean parentWindowMapped(GtkWidget* widget, GdkEvent*, WebViewTest* test)
+{
+ g_signal_handlers_disconnect_by_func(widget, reinterpret_cast<void*>(parentWindowMapped), test);
+ g_main_loop_quit(test->m_mainLoop);
+
+ return FALSE;
+}
+
+void WebViewTest::showInWindowAndWaitUntilMapped()
+{
+ g_assert(!m_parentWindow);
+ m_parentWindow = gtk_window_new(GTK_WINDOW_POPUP);
+ gtk_container_add(GTK_CONTAINER(m_parentWindow), GTK_WIDGET(m_webView));
+ gtk_widget_show(GTK_WIDGET(m_webView));
+
+ g_signal_connect(m_parentWindow, "map-event", G_CALLBACK(parentWindowMapped), this);
+ gtk_widget_show(m_parentWindow);
+ g_main_loop_run(m_mainLoop);
+}
+
+void WebViewTest::mouseMoveTo(int x, int y, unsigned int mouseModifiers)
+{
+ g_assert(m_parentWindow);
+ GtkWidget* viewWidget = GTK_WIDGET(m_webView);
+ g_assert(gtk_widget_get_realized(viewWidget));
+
+ GOwnPtr<GdkEvent> event(gdk_event_new(GDK_MOTION_NOTIFY));
+ event->motion.x = x;
+ event->motion.y = y;
+
+ event->motion.time = GDK_CURRENT_TIME;
+ event->motion.window = gtk_widget_get_window(viewWidget);
+ g_object_ref(event->motion.window);
+ event->button.device = gdk_device_manager_get_client_pointer(gdk_display_get_device_manager(gtk_widget_get_display(viewWidget)));
+ event->motion.state = mouseModifiers;
+ event->motion.axes = 0;
+
+ int xRoot, yRoot;
+ gdk_window_get_root_coords(gtk_widget_get_window(viewWidget), x, y, &xRoot, &yRoot);
+ event->motion.x_root = xRoot;
+ event->motion.y_root = yRoot;
+ gtk_main_do_event(event.get());
+}
+
diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h
index 4ad6fa648..95a569cd6 100644
--- a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h
+++ b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h
@@ -42,10 +42,14 @@ public:
void wait(double seconds);
void waitUntilLoadFinished();
+ void showInWindowAndWaitUntilMapped();
+
+ void mouseMoveTo(int x, int y, unsigned int mouseModifiers = 0);
WebKitWebView* m_webView;
GMainLoop* m_mainLoop;
CString m_activeURI;
+ GtkWidget* m_parentWindow;
};
#endif // WebViewTest_h
diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2.h b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
index 78e53d508..f78b873a3 100644
--- a/Source/WebKit2/UIProcess/API/gtk/webkit2.h
+++ b/Source/WebKit2/UIProcess/API/gtk/webkit2.h
@@ -30,6 +30,8 @@
#include <webkit2/WebKitEditingCommands.h>
#include <webkit2/WebKitEnumTypes.h>
#include <webkit2/WebKitError.h>
+#include <webkit2/WebKitHitTestResult.h>
+#include <webkit2/WebKitPrintOperation.h>
#include <webkit2/WebKitSettings.h>
#include <webkit2/WebKitURIRequest.h>
#include <webkit2/WebKitURIResponse.h>
diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2marshal.list b/Source/WebKit2/UIProcess/API/gtk/webkit2marshal.list
index 5918d095a..77d269a75 100644
--- a/Source/WebKit2/UIProcess/API/gtk/webkit2marshal.list
+++ b/Source/WebKit2/UIProcess/API/gtk/webkit2marshal.list
@@ -10,5 +10,6 @@ BOOLEAN:UINT64
BOOLEAN:VOID
OBJECT:VOID
VOID:ENUM
+VOID:OBJECT,UINT
VOID:OBJECT,POINTER
diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm
index 728f0e56f..d50a7269a 100644
--- a/Source/WebKit2/UIProcess/API/mac/WKView.mm
+++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm
@@ -2561,6 +2561,9 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
return;
_data->_dragHasStarted = YES;
+ IntSize size([image size]);
+ size.scale(1.0 / _data->_page->deviceScaleFactor());
+ [image setSize:size];
// The call to super could release this WKView.
RetainPtr<WKView> protector(self);
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
index 22c6703c4..d164a6b85 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
@@ -29,6 +29,7 @@
#include <QtQuick/QQuickCanvas>
#include <QtQuick/QSGGeometryNode>
#include <QtQuick/QSGMaterial>
+#include <private/qsgrendernode_p.h>
QQuickWebPage::QQuickWebPage(QQuickWebView* viewportItem)
: QQuickItem(viewportItem)
@@ -97,7 +98,7 @@ void QQuickWebPagePrivate::paintToCurrentGLContext()
transform.scale(contentsScale, contentsScale);
float opacity = computeEffectiveOpacity(q);
- QRectF clipRect = q->parentItem()->mapRectToScene(q->parentItem()->boundingRect());
+ QRectF clipRect = viewportItem->mapRectToScene(viewportItem->boundingRect());
if (!clipRect.isValid())
return;
@@ -109,57 +110,22 @@ void QQuickWebPagePrivate::paintToCurrentGLContext()
drawingArea->paintToCurrentGLContext(transform, opacity, clipRect);
}
-struct PageProxyMaterial;
-struct PageProxyNode;
-
-// FIXME: temporary until Qt Scenegraph will support custom painting.
-struct PageProxyMaterialShader : public QSGMaterialShader {
- virtual void updateState(const RenderState& state, QSGMaterial* newMaterial, QSGMaterial* oldMaterial);
- virtual char const* const* attributeNames() const
- {
- static char const* const attr[] = { "vertex", 0 };
- return attr;
- }
-
- // vertexShader and fragmentShader are no-op shaders.
- // All real painting is gone by TextureMapper through LayerTreeHostProxy.
- virtual const char* vertexShader() const
- {
- return "attribute highp vec4 vertex; \n"
- "void main() { gl_Position = vertex; }";
- }
-
- virtual const char* fragmentShader() const
- {
- return "void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); }";
- }
-};
-
-struct PageProxyMaterial : public QSGMaterial {
- PageProxyMaterial(PageProxyNode* node) : m_node(node) { }
-
- QSGMaterialType* type() const
+struct PageProxyNode : public QSGRenderNode {
+ PageProxyNode(QQuickWebPagePrivate* page)
+ : m_pagePrivate(page)
{
- static QSGMaterialType type;
- return &type;
}
- QSGMaterialShader* createShader() const
+ virtual StateFlags changedStates()
{
- return new PageProxyMaterialShader;
+ return StateFlags(DepthState) | StencilState | ScissorState | ColorState | BlendState
+ | CullState | ViewportState;
}
- PageProxyNode* m_node;
-};
-
-struct PageProxyNode : public QSGGeometryNode {
- PageProxyNode(QQuickWebPagePrivate* page) :
- m_pagePrivate(page)
- , m_material(this)
- , m_geometry(QSGGeometry::defaultAttributes_Point2D(), 4)
+ virtual void render(const RenderState &)
{
- setGeometry(&m_geometry);
- setMaterial(&m_material);
+ if (m_pagePrivate)
+ m_pagePrivate->paintToCurrentGLContext();
}
~PageProxyNode()
@@ -169,22 +135,8 @@ struct PageProxyNode : public QSGGeometryNode {
}
QQuickWebPagePrivate* m_pagePrivate;
- PageProxyMaterial m_material;
- QSGGeometry m_geometry;
};
-void PageProxyMaterialShader::updateState(const RenderState& state, QSGMaterial* newMaterial, QSGMaterial* oldMaterial)
-{
- if (!newMaterial)
- return;
-
- PageProxyNode* node = static_cast<PageProxyMaterial*>(newMaterial)->m_node;
- // FIXME: Normally we wouldn't paint inside QSGMaterialShader::updateState,
- // but this is a temporary hack until custom paint nodes are available.
- if (node->m_pagePrivate)
- node->m_pagePrivate->paintToCurrentGLContext();
-}
-
QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*)
{
if (!(flags() & ItemHasContents)) {
@@ -242,13 +194,15 @@ QTransform QQuickWebPage::transformFromItem() const
QTransform QQuickWebPage::transformToItem() const
{
- return QTransform(d->contentsScale, 0, 0, 0, d->contentsScale, 0, x(), y(), 1);
+ QPointF pos = d->viewportItem->pageItemPos();
+ return QTransform(d->contentsScale, 0, 0, 0, d->contentsScale, 0, pos.x(), pos.y(), 1);
}
void QQuickWebPagePrivate::updateSize()
{
QSizeF scaledSize = contentsSize * contentsScale;
q->setSize(scaledSize);
+ viewportItem->updateContentsSize(scaledSize);
}
void QQuickWebPagePrivate::resetPaintNode()
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
index 7ea6d347c..f40e28924 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp
@@ -51,6 +51,7 @@
#include <WebCore/IntPoint.h>
#include <WebCore/IntRect.h>
#include <WKOpenPanelResultListener.h>
+#include <wtf/Assertions.h>
#include <wtf/text/WTFString.h>
using namespace WebCore;
@@ -66,12 +67,16 @@ static QQuickWebViewPrivate* createPrivateObject(QQuickWebView* publicObject)
QQuickWebViewPrivate::QQuickWebViewPrivate(QQuickWebView* viewport)
: q_ptr(viewport)
+ , flickProvider(0)
, alertDialog(0)
, confirmDialog(0)
, promptDialog(0)
, authenticationDialog(0)
, certificateVerificationDialog(0)
, itemSelector(0)
+ , proxyAuthenticationDialog(0)
+ , userDidOverrideContentWidth(false)
+ , userDidOverrideContentHeight(false)
, m_navigatorQtObjectEnabled(false)
, m_renderToOffscreenBuffer(false)
{
@@ -112,6 +117,7 @@ void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pa
// Any page setting should preferrable be set before creating the page.
webPageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true);
webPageProxy->pageGroup()->preferences()->setForceCompositingMode(true);
+ webPageProxy->pageGroup()->preferences()->setFrameFlatteningEnabled(true);
pageClient.initialize(q_ptr, pageViewPrivate->eventHandler.data(), &undoController);
webPageProxy->initializeWebPage();
@@ -131,6 +137,12 @@ void QQuickWebViewPrivate::disableMouseEvents()
q->setAcceptHoverEvents(false);
}
+QPointF QQuickWebViewPrivate::pageItemPos()
+{
+ ASSERT(pageView);
+ return pageView->pos();
+}
+
void QQuickWebViewPrivate::loadDidSucceed()
{
Q_Q(QQuickWebView);
@@ -200,14 +212,6 @@ void QQuickWebViewPrivate::handleDownloadRequest(DownloadProxy* download)
context->downloadManager()->addDownload(download, downloadItem);
}
-void QQuickWebViewPrivate::_q_viewportTrajectoryVectorChanged(const QPointF& trajectoryVector)
-{
- DrawingAreaProxy* drawingArea = webPageProxy->drawingArea();
- if (!drawingArea)
- return;
- drawingArea->setVisibleContentRectTrajectoryVector(trajectoryVector);
-}
-
void QQuickWebViewPrivate::_q_onVisibleChanged()
{
webPageProxy->viewStateDidChange(WebPageProxy::ViewIsVisible);
@@ -301,6 +305,25 @@ void QQuickWebViewPrivate::handleAuthenticationRequiredRequest(const QString& ho
password = dialogRunner.password();
}
+void QQuickWebViewPrivate::handleProxyAuthenticationRequiredRequest(const QString& hostname, uint16_t port, const QString& prefilledUsername, QString& username, QString& password)
+{
+ if (!proxyAuthenticationDialog)
+ return;
+
+ Q_Q(QQuickWebView);
+ QtDialogRunner dialogRunner;
+ if (!dialogRunner.initForProxyAuthentication(proxyAuthenticationDialog, q, hostname, port, prefilledUsername))
+ return;
+
+ setViewInAttachedProperties(dialogRunner.dialog());
+ disableMouseEvents();
+ dialogRunner.exec();
+ enableMouseEvents();
+
+ username = dialogRunner.username();
+ password = dialogRunner.password();
+}
+
bool QQuickWebViewPrivate::handleCertificateVerificationRequest(const QString& hostname)
{
if (!certificateVerificationDialog)
@@ -445,7 +468,7 @@ void QQuickWebViewLegacyPrivate::updateViewportSize()
// The fixed layout is handled by the FrameView and the drawing area doesn't behave differently
// whether its fixed or not. We still need to tell the drawing area which part of it
// has to be rendered on tiles, and in desktop mode it's all of it.
- webPageProxy->drawingArea()->setVisibleContentsRectAndScale(IntRect(IntPoint(), viewportSize), 1);
+ webPageProxy->drawingArea()->setVisibleContentsRectForScaling(IntRect(IntPoint(), viewportSize), 1);
}
QQuickWebViewFlickablePrivate::QQuickWebViewFlickablePrivate(QQuickWebView* viewport)
@@ -468,16 +491,52 @@ void QQuickWebViewFlickablePrivate::initialize(WKContextRef contextRef, WKPageGr
webPageProxy->setUseFixedLayout(true);
}
+QPointF QQuickWebViewFlickablePrivate::pageItemPos()
+{
+ // Flickable moves its contentItem so we need to take that position into account,
+ // as well as the potential displacement of the page on the contentItem because
+ // of additional QML items.
+ qreal xPos = flickProvider->contentItem()->x() + pageView->x();
+ qreal yPos = flickProvider->contentItem()->y() + pageView->y();
+ return QPointF(xPos, yPos);
+}
+
+void QQuickWebViewFlickablePrivate::updateContentsSize(const QSizeF& size)
+{
+ ASSERT(flickProvider);
+
+ // Make sure that the contentItem is sized to the page
+ // if the user did not add other flickable items in QML.
+ // If the user adds items in QML he has to make sure to
+ // also bind the contentWidth and contentHeight accordingly.
+ // This is in accordance with normal QML Flickable behaviour.
+ if (!userDidOverrideContentWidth)
+ flickProvider->setContentWidth(size.width());
+ if (!userDidOverrideContentHeight)
+ flickProvider->setContentHeight(size.height());
+}
+
void QQuickWebViewFlickablePrivate::onComponentComplete()
{
Q_Q(QQuickWebView);
- interactionEngine.reset(new QtViewportInteractionEngine(q, pageView.data()));
+
+ ASSERT(!flickProvider);
+ flickProvider = new QtFlickProvider(q, pageView.data());
+
+ // Propagate flickable signals.
+ const QQuickWebViewExperimental* experimental = q->experimental();
+ QObject::connect(flickProvider, SIGNAL(contentWidthChanged()), experimental, SIGNAL(contentWidthChanged()));
+ QObject::connect(flickProvider, SIGNAL(contentHeightChanged()), experimental, SIGNAL(contentHeightChanged()));
+ QObject::connect(flickProvider, SIGNAL(contentXChanged()), experimental, SIGNAL(contentXChanged()));
+ QObject::connect(flickProvider, SIGNAL(contentYChanged()), experimental, SIGNAL(contentYChanged()));
+
+ interactionEngine.reset(new QtViewportInteractionEngine(q, pageView.data(), flickProvider));
pageView->eventHandler()->setViewportInteractionEngine(interactionEngine.data());
QObject::connect(interactionEngine.data(), SIGNAL(contentSuspendRequested()), q, SLOT(_q_suspend()));
QObject::connect(interactionEngine.data(), SIGNAL(contentResumeRequested()), q, SLOT(_q_resume()));
- QObject::connect(interactionEngine.data(), SIGNAL(viewportTrajectoryVectorChanged(const QPointF&)), q, SLOT(_q_viewportTrajectoryVectorChanged(const QPointF&)));
- QObject::connect(interactionEngine.data(), SIGNAL(visibleContentRectAndScaleChanged()), q, SLOT(_q_updateVisibleContentRectAndScale()));
+ QObject::connect(interactionEngine.data(), SIGNAL(contentWasMoved(const QPointF&)), q, SLOT(_q_commitPositionChange(const QPointF&)));
+ QObject::connect(interactionEngine.data(), SIGNAL(contentWasScaled()), q, SLOT(_q_commitScaleChange()));
_q_resume();
@@ -533,15 +592,17 @@ void QQuickWebViewFlickablePrivate::updateViewportSize()
if (viewportSize.isEmpty() || !interactionEngine)
return;
+ flickProvider->setViewportSize(viewportSize);
+
// Let the WebProcess know about the new viewport size, so that
// it can resize the content accordingly.
webPageProxy->setViewportSize(viewportSize);
interactionEngine->applyConstraints(computeViewportConstraints());
- _q_updateVisibleContentRectAndScale();
+ _q_commitScaleChange();
}
-void QQuickWebViewFlickablePrivate::_q_updateVisibleContentRectAndScale()
+void QQuickWebViewFlickablePrivate::_q_commitScaleChange()
{
DrawingAreaProxy* drawingArea = webPageProxy->drawingArea();
if (!drawingArea)
@@ -551,12 +612,31 @@ void QQuickWebViewFlickablePrivate::_q_updateVisibleContentRectAndScale()
const QRectF visibleRectInCSSCoordinates = q->mapRectToWebContent(q->boundingRect()).intersected(pageView->boundingRect());
float scale = pageView->contentsScale();
+ // This is only for our QML ViewportInfo debugging API.
+ q->experimental()->viewportInfo()->didUpdateCurrentScale();
+
QRect alignedVisibleContentRect = visibleRectInCSSCoordinates.toAlignedRect();
- drawingArea->setVisibleContentsRectAndScale(alignedVisibleContentRect, scale);
+ drawingArea->setVisibleContentsRectForScaling(alignedVisibleContentRect, scale);
+
+ webPageProxy->setFixedVisibleContentRect(alignedVisibleContentRect);
+}
+
+void QQuickWebViewPrivate::_q_commitPositionChange(const QPointF& trajectoryVector)
+{
+ DrawingAreaProxy* drawingArea = webPageProxy->drawingArea();
+ if (!drawingArea)
+ return;
+
+ Q_Q(QQuickWebView);
+ const QRectF visibleRectInCSSCoordinates = q->mapRectToWebContent(q->boundingRect()).intersected(pageView->boundingRect());
+
+ QRect alignedVisibleContentRect = visibleRectInCSSCoordinates.toAlignedRect();
+ drawingArea->setVisibleContentsRectForPanning(alignedVisibleContentRect, trajectoryVector);
+
+ if (!trajectoryVector.isNull())
+ return;
- // FIXME: Once we support suspend and resume, this should be delayed until the page is active if the page is suspended.
webPageProxy->setFixedVisibleContentRect(alignedVisibleContentRect);
- q->experimental()->viewportInfo()->didUpdateCurrentScale();
}
void QQuickWebViewFlickablePrivate::_q_suspend()
@@ -576,7 +656,8 @@ void QQuickWebViewFlickablePrivate::_q_resume()
postTransitionState->apply();
}
- _q_updateVisibleContentRectAndScale();
+ // FIXME: Revise this.
+ _q_commitScaleChange();
}
void QQuickWebViewFlickablePrivate::pageDidRequestScroll(const QPoint& pos)
@@ -794,6 +875,20 @@ void QQuickWebViewExperimental::setAuthenticationDialog(QDeclarativeComponent* a
emit authenticationDialogChanged();
}
+QDeclarativeComponent* QQuickWebViewExperimental::proxyAuthenticationDialog() const
+{
+ Q_D(const QQuickWebView);
+ return d->proxyAuthenticationDialog;
+}
+
+void QQuickWebViewExperimental::setProxyAuthenticationDialog(QDeclarativeComponent* proxyAuthenticationDialog)
+{
+ Q_D(QQuickWebView);
+ if (d->proxyAuthenticationDialog == proxyAuthenticationDialog)
+ return;
+ d->proxyAuthenticationDialog = proxyAuthenticationDialog;
+ emit proxyAuthenticationDialogChanged();
+}
QDeclarativeComponent* QQuickWebViewExperimental::certificateVerificationDialog() const
{
Q_D(const QQuickWebView);
@@ -910,6 +1005,78 @@ QQuickWebPage* QQuickWebViewExperimental::page()
return q_ptr->page();
}
+QDeclarativeListProperty<QObject> QQuickWebViewExperimental::flickableData()
+{
+ Q_D(const QQuickWebView);
+ ASSERT(d->flickProvider);
+ return d->flickProvider->flickableData();
+}
+
+QQuickItem* QQuickWebViewExperimental::contentItem()
+{
+ Q_D(QQuickWebView);
+ ASSERT(d->flickProvider);
+ return d->flickProvider->contentItem();
+}
+
+qreal QQuickWebViewExperimental::contentWidth() const
+{
+ Q_D(const QQuickWebView);
+ ASSERT(d->flickProvider);
+ return d->flickProvider->contentWidth();
+}
+
+void QQuickWebViewExperimental::setContentWidth(qreal width)
+{
+ Q_D(QQuickWebView);
+ ASSERT(d->flickProvider);
+ d->userDidOverrideContentWidth = true;
+ d->flickProvider->setContentWidth(width);
+}
+
+qreal QQuickWebViewExperimental::contentHeight() const
+{
+ Q_D(const QQuickWebView);
+ ASSERT(d->flickProvider);
+ return d->flickProvider->contentHeight();
+}
+
+void QQuickWebViewExperimental::setContentHeight(qreal height)
+{
+ Q_D(QQuickWebView);
+ ASSERT(d->flickProvider);
+ d->userDidOverrideContentHeight = true;
+ d->flickProvider->setContentHeight(height);
+}
+
+qreal QQuickWebViewExperimental::contentX() const
+{
+ Q_D(const QQuickWebView);
+ ASSERT(d->flickProvider);
+ return d->flickProvider->contentX();
+}
+
+void QQuickWebViewExperimental::setContentX(qreal x)
+{
+ Q_D(QQuickWebView);
+ ASSERT(d->flickProvider);
+ d->flickProvider->setContentX(x);
+}
+
+qreal QQuickWebViewExperimental::contentY() const
+{
+ Q_D(const QQuickWebView);
+ ASSERT(d->flickProvider);
+ return d->flickProvider->contentY();
+}
+
+void QQuickWebViewExperimental::setContentY(qreal y)
+{
+ Q_D(QQuickWebView);
+ ASSERT(d->flickProvider);
+ d->flickProvider->setContentY(y);
+}
+
QQuickWebView::QQuickWebView(QQuickItem* parent)
: QQuickItem(parent)
, d_ptr(createPrivateObject(this))
@@ -1071,6 +1238,8 @@ QVariant QQuickWebView::inputMethodQuery(Qt::InputMethodQuery property) const
return QString(state.selectedText);
case Qt::ImMaximumTextLength:
return QVariant(); // No limit.
+ case Qt::ImHints:
+ return int(Qt::InputMethodHints(state.inputMethodHints));
default:
// Rely on the base implementation for ImEnabled, ImHints and ImPreferredLanguage.
return QQuickItem::inputMethodQuery(property);
@@ -1225,6 +1394,7 @@ bool QQuickWebView::event(QEvent* ev)
case QEvent::FocusOut:
case QEvent::TouchBegin:
case QEvent::TouchEnd:
+ case QEvent::TouchCancel:
case QEvent::TouchUpdate:
if (d->pageView->eventHandler()->handleEvent(ev))
return true;
@@ -1256,4 +1426,16 @@ void QQuickWebView::loadHtml(const QString& html, const QUrl& baseUrl)
d->webPageProxy->loadHTMLString(html, baseUrl.toString());
}
+QPointF QQuickWebView::pageItemPos()
+{
+ Q_D(QQuickWebView);
+ return d->pageItemPos();
+}
+
+void QQuickWebView::updateContentsSize(const QSizeF& size)
+{
+ Q_D(QQuickWebView);
+ d->updateContentsSize(size);
+}
+
#include "moc_qquickwebview_p.cpp"
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h
index 69f1cd81b..674c18fe7 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h
@@ -76,6 +76,7 @@ class QWEBKIT_EXPORT QQuickWebView : public QQuickItem {
Q_PROPERTY(bool canReload READ canReload NOTIFY navigationStateChanged FINAL)
Q_ENUMS(NavigationRequestAction)
Q_ENUMS(ErrorDomain)
+ Q_ENUMS(NavigationType)
public:
enum NavigationRequestAction {
@@ -89,6 +90,16 @@ public:
HttpErrorDomain,
DownloadErrorDomain
};
+
+ enum NavigationType {
+ LinkClickedNavigation,
+ FormSubmittedNavigation,
+ BackForwardNavigation,
+ ReloadNavigation,
+ FormResubmittedNavigation,
+ OtherNavigation
+ };
+
QQuickWebView(QQuickItem* parent = 0);
virtual ~QQuickWebView();
@@ -116,6 +127,10 @@ public:
static void platformInitialize(); // Only needed by WTR.
+ // Internal API used by WebPage.
+ void updateContentsSize(const QSizeF&);
+ QPointF pageItemPos();
+
public Q_SLOTS:
void load(const QUrl&);
void loadHtml(const QString& html, const QUrl& baseUrl = QUrl());
@@ -168,8 +183,9 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_suspend());
Q_PRIVATE_SLOT(d_func(), void _q_resume());
- Q_PRIVATE_SLOT(d_func(), void _q_viewportTrajectoryVectorChanged(const QPointF&));
- Q_PRIVATE_SLOT(d_func(), void _q_updateVisibleContentRectAndScale());
+ Q_PRIVATE_SLOT(d_func(), void _q_commitPositionChange(const QPointF&));
+ Q_PRIVATE_SLOT(d_func(), void _q_commitScaleChange());
+
Q_PRIVATE_SLOT(d_func(), void _q_onOpenPanelFilesSelected());
Q_PRIVATE_SLOT(d_func(), void _q_onOpenPanelFinished(int result));
Q_PRIVATE_SLOT(d_func(), void _q_onVisibleChanged());
@@ -209,11 +225,21 @@ QML_DECLARE_TYPEINFO(QQuickWebView, QML_HAS_ATTACHED_PROPERTIES)
class QWEBKIT_EXPORT QQuickWebViewExperimental : public QObject {
Q_OBJECT
Q_PROPERTY(QQuickWebPage* page READ page CONSTANT FINAL)
+
+ // QML Flickable API.
+ Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged)
+ Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
+ Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
+ Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
+ Q_PROPERTY(QQuickItem* contentItem READ contentItem CONSTANT)
+ Q_PROPERTY(QDeclarativeListProperty<QObject> flickableData READ flickableData)
+
Q_PROPERTY(QWebNavigationHistory* navigationHistory READ navigationHistory CONSTANT FINAL)
Q_PROPERTY(QDeclarativeComponent* alertDialog READ alertDialog WRITE setAlertDialog NOTIFY alertDialogChanged)
Q_PROPERTY(QDeclarativeComponent* confirmDialog READ confirmDialog WRITE setConfirmDialog NOTIFY confirmDialogChanged)
Q_PROPERTY(QDeclarativeComponent* promptDialog READ promptDialog WRITE setPromptDialog NOTIFY promptDialogChanged)
Q_PROPERTY(QDeclarativeComponent* authenticationDialog READ authenticationDialog WRITE setAuthenticationDialog NOTIFY authenticationDialogChanged)
+ Q_PROPERTY(QDeclarativeComponent* proxyAuthenticationDialog READ proxyAuthenticationDialog WRITE setProxyAuthenticationDialog NOTIFY proxyAuthenticationDialogChanged)
Q_PROPERTY(QDeclarativeComponent* certificateVerificationDialog READ certificateVerificationDialog WRITE setCertificateVerificationDialog NOTIFY certificateVerificationDialogChanged)
Q_PROPERTY(QDeclarativeComponent* itemSelector READ itemSelector WRITE setItemSelector NOTIFY itemSelectorChanged)
Q_PROPERTY(QWebPreferences* preferences READ preferences CONSTANT FINAL)
@@ -241,6 +267,8 @@ public:
void setCertificateVerificationDialog(QDeclarativeComponent*);
QDeclarativeComponent* itemSelector() const;
void setItemSelector(QDeclarativeComponent*);
+ QDeclarativeComponent* proxyAuthenticationDialog() const;
+ void setProxyAuthenticationDialog(QDeclarativeComponent*);
QWebViewportInfo* viewportInfo();
@@ -253,9 +281,20 @@ public:
static int schemeDelegates_Count(QDeclarativeListProperty<QQuickUrlSchemeDelegate>*);
static void schemeDelegates_Clear(QDeclarativeListProperty<QQuickUrlSchemeDelegate>*);
QDeclarativeListProperty<QQuickUrlSchemeDelegate> schemeDelegates();
+ QDeclarativeListProperty<QObject> flickableData();
void invokeApplicationSchemeHandler(WTF::PassRefPtr<WebKit::QtRefCountedNetworkRequestData>);
void sendApplicationSchemeReply(QQuickNetworkReply*);
+ QQuickItem* contentItem();
+ qreal contentWidth() const;
+ void setContentWidth(qreal);
+ qreal contentHeight() const;
+ void setContentHeight(qreal);
+ qreal contentX() const;
+ void setContentX(qreal);
+ qreal contentY() const;
+ void setContentY(qreal);
+
// C++ only
bool renderToOffscreenBuffer() const;
void setRenderToOffscreenBuffer(bool enable);
@@ -268,6 +307,10 @@ public Q_SLOTS:
void postMessage(const QString&);
Q_SIGNALS:
+ void contentWidthChanged();
+ void contentHeightChanged();
+ void contentXChanged();
+ void contentYChanged();
void alertDialogChanged();
void confirmDialogChanged();
void promptDialogChanged();
@@ -277,6 +320,7 @@ Q_SIGNALS:
void downloadRequested(QWebDownloadItem* downloadItem);
void permissionRequested(QWebPermissionRequest* permission);
void messageReceived(const QVariantMap& message);
+ void proxyAuthenticationDialogChanged();
private:
QQuickWebView* q_ptr;
diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
index 9e27ce322..300b4759d 100644
--- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h
@@ -22,6 +22,7 @@
#define qquickwebview_p_p_h
#include "DrawingAreaProxy.h"
+#include "QtFlickProvider.h"
#include "QtPageClient.h"
#include "QtViewportInteractionEngine.h"
#include "QtWebPageLoadClient.h"
@@ -68,6 +69,9 @@ public:
void enableMouseEvents();
void disableMouseEvents();
+ virtual QPointF pageItemPos();
+ virtual void updateContentsSize(const QSizeF&) { }
+
virtual void loadDidSucceed();
virtual void onComponentComplete() { }
virtual void loadDidCommit() { }
@@ -80,11 +84,13 @@ public:
virtual QtViewportInteractionEngine* viewportInteractionEngine() { return 0; }
virtual void updateViewportSize() { }
void updateTouchViewportSize();
- virtual void _q_updateVisibleContentRectAndScale() { }
virtual void _q_suspend() { }
virtual void _q_resume() { }
- void _q_viewportTrajectoryVectorChanged(const QPointF&);
+
+ virtual void _q_commitScaleChange() { }
+ void _q_commitPositionChange(const QPointF&);
+
void _q_onOpenPanelFilesSelected();
void _q_onOpenPanelFinished(int result);
void _q_onVisibleChanged();
@@ -98,6 +104,7 @@ public:
void handleAuthenticationRequiredRequest(const QString& hostname, const QString& realm, const QString& prefilledUsername, QString& username, QString& password);
bool handleCertificateVerificationRequest(const QString& hostname);
+ void handleProxyAuthenticationRequiredRequest(const QString& hostname, uint16_t port, const QString& prefilledUsername, QString& username, QString& password);
void setRenderToOffscreenBuffer(bool enable) { m_renderToOffscreenBuffer = enable; }
void setViewInAttachedProperties(QObject*);
@@ -133,6 +140,7 @@ protected:
QScopedPointer<QQuickWebPage> pageView;
QQuickWebView* q_ptr;
+ QtFlickProvider* flickProvider;
QDeclarativeComponent* alertDialog;
QDeclarativeComponent* confirmDialog;
@@ -140,11 +148,14 @@ protected:
QDeclarativeComponent* authenticationDialog;
QDeclarativeComponent* certificateVerificationDialog;
QDeclarativeComponent* itemSelector;
+ QDeclarativeComponent* proxyAuthenticationDialog;
WebCore::ViewportArguments viewportArguments;
QFileDialog* fileDialog;
WKOpenPanelResultListenerRef openPanelResultListener;
+ bool userDidOverrideContentWidth;
+ bool userDidOverrideContentHeight;
bool m_navigatorQtObjectEnabled;
bool m_renderToOffscreenBuffer;
QUrl m_iconURL;
@@ -166,6 +177,9 @@ public:
virtual ~QQuickWebViewFlickablePrivate();
virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0);
+ virtual QPointF pageItemPos();
+ virtual void updateContentsSize(const QSizeF&);
+
virtual void loadDidSucceed();
virtual void onComponentComplete();
virtual void loadDidCommit();
@@ -173,9 +187,10 @@ public:
virtual void didChangeViewportProperties(const WebCore::ViewportArguments& args);
virtual QtViewportInteractionEngine* viewportInteractionEngine() { return interactionEngine.data(); }
virtual void updateViewportSize();
- virtual void _q_updateVisibleContentRectAndScale();
+
virtual void _q_suspend();
virtual void _q_resume();
+ virtual void _q_commitScaleChange();
virtual void pageDidRequestScroll(const QPoint& pos);
virtual void didChangeContentsSize(const QSize& newSize);
diff --git a/Source/WebKit2/UIProcess/API/qt/qtwebsecurityorigin.cpp b/Source/WebKit2/UIProcess/API/qt/qtwebsecurityorigin.cpp
new file mode 100644
index 000000000..4491dc40a
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qtwebsecurityorigin.cpp
@@ -0,0 +1,60 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+
+ 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 "qtwebsecurityorigin_p.h"
+
+#include <QtCore/QFileInfo>
+#include <QtCore/QStringList>
+#include <SchemeRegistry.h>
+#include <SecurityOrigin.h>
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKRetainPtr.h>
+#include <WebKit2/WKSecurityOrigin.h>
+
+using namespace WebCore;
+
+QtWebSecurityOrigin::QtWebSecurityOrigin(QObject* parent)
+ : QObject(parent)
+{
+}
+
+QtWebSecurityOrigin::~QtWebSecurityOrigin()
+{
+}
+
+QString QtWebSecurityOrigin::host() const
+{
+ return m_url.host();
+}
+
+QString QtWebSecurityOrigin::scheme() const
+{
+ return m_url.scheme();
+}
+
+QString QtWebSecurityOrigin::path() const
+{
+ return m_url.path();
+}
+
+int QtWebSecurityOrigin::port() const
+{
+ return m_url.port();
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/qtwebsecurityorigin_p.h b/Source/WebKit2/UIProcess/API/qt/qtwebsecurityorigin_p.h
new file mode 100644
index 000000000..df09fb8ea
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/qtwebsecurityorigin_p.h
@@ -0,0 +1,57 @@
+/*
+ Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+
+ 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 qtwebsecurityorigin_p_h
+#define qtwebsecurityorigin_p_h
+
+#include "qwebkitglobal.h"
+
+#include <QtCore/QDataStream>
+#include <QtCore/QObject>
+#include <QtCore/QString>
+#include <QtCore/QUrl>
+#include <QtCore/qshareddata.h>
+
+class QWEBKIT_EXPORT QtWebSecurityOrigin : public QObject {
+ Q_OBJECT
+ Q_PROPERTY(QString scheme READ scheme CONSTANT)
+ Q_PROPERTY(QString host READ host CONSTANT)
+ Q_PROPERTY(int port READ port CONSTANT)
+ Q_PROPERTY(QString path READ path CONSTANT)
+
+public:
+ QtWebSecurityOrigin(QObject* parent = 0);
+ virtual ~QtWebSecurityOrigin();
+
+ QString scheme() const;
+ QString host() const;
+ int port() const;
+ QString path() const;
+
+ // Used to set security information in a permission request event (e.g.
+ // geolocation permission)
+ void setScheme(const QString& scheme) { m_url.setScheme(scheme); }
+ void setHost(const QString& host) { m_url.setHost(host); }
+ void setPath(const QString& path) { m_url.setPath(path); }
+ void setPort(int port) { m_url.setPort(port); }
+
+private:
+ QUrl m_url;
+};
+
+#endif // qtwebsecurityorigin_p_h
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest.cpp b/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest.cpp
index 5208a061c..3a63f80e3 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest.cpp
@@ -25,12 +25,14 @@
class QWebNavigationRequestPrivate {
public:
- QWebNavigationRequestPrivate(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button, Qt::KeyboardModifiers modifiers)
+ QWebNavigationRequestPrivate(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button,
+ Qt::KeyboardModifiers modifiers, QQuickWebView::NavigationType navigationType)
: url(url)
, originatingUrl(originatingUrl)
, button(button)
, modifiers(modifiers)
, action(QQuickWebView::AcceptRequest)
+ , navigationType(navigationType)
{
}
@@ -43,11 +45,13 @@ public:
Qt::MouseButton button;
Qt::KeyboardModifiers modifiers;
int action;
+ QQuickWebView::NavigationType navigationType;
};
-QWebNavigationRequest::QWebNavigationRequest(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button, Qt::KeyboardModifiers modifiers, QObject* parent)
+QWebNavigationRequest::QWebNavigationRequest(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button,
+ Qt::KeyboardModifiers modifiers, QQuickWebView::NavigationType navigationType, QObject* parent)
: QObject(parent)
- , d(new QWebNavigationRequestPrivate(url, originatingUrl, button, modifiers))
+ , d(new QWebNavigationRequestPrivate(url, originatingUrl, button, modifiers, navigationType))
{
}
@@ -90,3 +94,7 @@ int QWebNavigationRequest::action() const
return int(d->action);
}
+QQuickWebView::NavigationType QWebNavigationRequest::navigationType() const
+{
+ return d->navigationType;
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest_p.h b/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest_p.h
index 986b1c12d..46333f0e8 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qwebnavigationrequest_p.h
@@ -20,6 +20,7 @@
#ifndef qwebnavigationrequest_p_h
#define qwebnavigationrequest_p_h
+#include "qquickwebview_p.h"
#include "qwebkitglobal.h"
#include <QtCore/QObject>
@@ -34,9 +35,11 @@ class QWEBKIT_EXPORT QWebNavigationRequest : public QObject {
Q_PROPERTY(int button READ button CONSTANT FINAL)
Q_PROPERTY(int modifiers READ modifiers CONSTANT FINAL)
Q_PROPERTY(int action READ action WRITE setAction NOTIFY actionChanged FINAL)
+ Q_PROPERTY(QQuickWebView::NavigationType navigationType READ navigationType CONSTANT FINAL)
public:
- QWebNavigationRequest(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button, Qt::KeyboardModifiers modifiers, QObject* parent = 0);
+ QWebNavigationRequest(const QUrl& url, const QUrl& originatingUrl, Qt::MouseButton button, Qt::KeyboardModifiers modifiers,
+ QQuickWebView::NavigationType navigationType, QObject* parent = 0);
~QWebNavigationRequest();
QUrl url() const;
@@ -46,6 +49,7 @@ public:
int action() const;
void setAction(int action);
+ QQuickWebView::NavigationType navigationType() const;
Q_SIGNALS:
void actionChanged();
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest.cpp b/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest.cpp
index 16a438560..c4c1af825 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest.cpp
@@ -34,7 +34,15 @@ public:
, request(permissionRequest)
, allow(false)
{
+ WKRetainPtr<WKStringRef> url = adoptWK(WKSecurityOriginCopyProtocol(origin.get()));
+ securityInfo.setScheme(WKStringCopyQString(url.get()));
+
+ WKRetainPtr<WKStringRef> host = adoptWK(WKSecurityOriginCopyHost(origin.get()));
+ securityInfo.setHost(WKStringCopyQString(host.get()));
+
+ securityInfo.setPort(static_cast<int>(WKSecurityOriginGetPort(origin.get())));
}
+
~QWebPermissionRequestPrivate()
{
}
@@ -42,6 +50,7 @@ public:
WKRetainPtr<WKSecurityOriginRef> origin;
QWebPermissionRequest::RequestType type;
WKRetainPtr<WKGeolocationPermissionRequestRef> request;
+ QtWebSecurityOrigin securityInfo;
bool allow;
};
@@ -88,19 +97,8 @@ bool QWebPermissionRequest::allow() const
return d->allow;
}
-QString QWebPermissionRequest::scheme() const
-{
- WKRetainPtr<WKStringRef> url = adoptWK(WKSecurityOriginCopyProtocol(d->origin.get()));
- return WKStringCopyQString(url.get());
-}
-
-QString QWebPermissionRequest::host() const
+QtWebSecurityOrigin* QWebPermissionRequest::securityOrigin()
{
- WKRetainPtr<WKStringRef> origin = adoptWK(WKSecurityOriginCopyHost(d->origin.get()));
- return WKStringCopyQString(origin.get());
+ return &(d->securityInfo);
}
-int QWebPermissionRequest::port() const
-{
- return static_cast<int>(WKSecurityOriginGetPort(d->origin.get()));
-}
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest_p.h
index 5824c4ccd..4708b71a6 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpermissionrequest_p.h
@@ -20,6 +20,7 @@
#ifndef qwebpermissionrequest_p_h
#define qwebpermissionrequest_p_h
+#include "qtwebsecurityorigin_p.h"
#include "qwebkitglobal.h"
#include <QtCore/QObject>
@@ -32,10 +33,8 @@ class QWebPermissionRequestPrivate;
class QWEBKIT_EXPORT QWebPermissionRequest : public QObject {
Q_OBJECT
Q_PROPERTY(bool allow READ allow WRITE setAllow)
- Q_PROPERTY(RequestType type READ type)
- Q_PROPERTY(QString scheme READ scheme)
- Q_PROPERTY(QString host READ host)
- Q_PROPERTY(int port READ port)
+ Q_PROPERTY(RequestType type READ type CONSTANT)
+ Q_PROPERTY(QtWebSecurityOrigin* origin READ securityOrigin)
Q_ENUMS(RequestType)
public:
@@ -48,12 +47,10 @@ public:
RequestType type() const;
bool allow() const;
- QString scheme() const;
- QString host() const;
- int port() const;
public Q_SLOTS:
void setAllow(bool);
+ QtWebSecurityOrigin* securityOrigin();
private:
friend class QWebPermissionRequestPrivate;
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
index 71c11afe5..835c698db 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp
@@ -54,6 +54,8 @@ bool QWebPreferencesPrivate::testAttribute(QWebPreferencesPrivate::WebAttribute
return WKPreferencesGetPrivateBrowsingEnabled(preferencesRef());
case DnsPrefetchEnabled:
return WKPreferencesGetDNSPrefetchingEnabled(preferencesRef());
+ case FrameFlatteningEnabled:
+ return WKPreferencesGetFrameFlatteningEnabled(preferencesRef());
default:
ASSERT_NOT_REACHED();
return false;
@@ -87,6 +89,9 @@ void QWebPreferencesPrivate::setAttribute(QWebPreferencesPrivate::WebAttribute a
case DnsPrefetchEnabled:
WKPreferencesSetDNSPrefetchingEnabled(preferencesRef(), enable);
break;
+ case FrameFlatteningEnabled:
+ WKPreferencesSetFrameFlatteningEnabled(preferencesRef(), enable);
+ break;
default:
ASSERT_NOT_REACHED();
}
@@ -293,6 +298,17 @@ void QWebPreferences::setNavigatorQtObjectEnabled(bool enable)
emit navigatorQtObjectEnabledChanged();
}
+bool QWebPreferences::frameFlatteningEnabled() const
+{
+ return d->testAttribute(QWebPreferencesPrivate::FrameFlatteningEnabled);
+}
+
+void QWebPreferences::setFrameFlatteningEnabled(bool enable)
+{
+ d->setAttribute(QWebPreferencesPrivate::FrameFlatteningEnabled, enable);
+ emit frameFlatteningEnabledChanged();
+}
+
QString QWebPreferences::standardFontFamily() const
{
return d->fontFamily(QWebPreferencesPrivate::StandardFont);
diff --git a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h
index 29df04cea..82b738fbf 100644
--- a/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h
+++ b/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h
@@ -40,6 +40,7 @@ public:
Q_PROPERTY(bool privateBrowsingEnabled READ privateBrowsingEnabled WRITE setPrivateBrowsingEnabled NOTIFY privateBrowsingEnabledChanged FINAL)
Q_PROPERTY(bool dnsPrefetchEnabled READ dnsPrefetchEnabled WRITE setDnsPrefetchEnabled NOTIFY dnsPrefetchEnabledChanged FINAL)
Q_PROPERTY(bool navigatorQtObjectEnabled READ navigatorQtObjectEnabled WRITE setNavigatorQtObjectEnabled NOTIFY navigatorQtObjectEnabledChanged FINAL)
+ Q_PROPERTY(bool frameFlatteningEnabled READ frameFlatteningEnabled WRITE setFrameFlatteningEnabled NOTIFY frameFlatteningEnabledChanged FINAL)
Q_PROPERTY(QString standardFontFamily READ standardFontFamily WRITE setStandardFontFamily NOTIFY standardFontFamilyChanged FINAL)
Q_PROPERTY(QString fixedFontFamily READ fixedFontFamily WRITE setFixedFontFamily NOTIFY fixedFontFamilyChanged FINAL)
@@ -79,6 +80,9 @@ public:
bool navigatorQtObjectEnabled() const;
void setNavigatorQtObjectEnabled(bool);
+ bool frameFlatteningEnabled() const;
+ void setFrameFlatteningEnabled(bool enable);
+
QString standardFontFamily() const;
void setStandardFontFamily(const QString& family);
@@ -116,6 +120,7 @@ Q_SIGNALS:
void privateBrowsingEnabledChanged();
void dnsPrefetchEnabledChanged();
void navigatorQtObjectEnabledChanged();
+ void frameFlatteningEnabledChanged();
void standardFontFamilyChanged();
void fixedFontFamilyChanged();
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/bytearraytestdata.h b/Source/WebKit2/UIProcess/API/qt/tests/bytearraytestdata.h
index 7170f6594..f7838f072 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/bytearraytestdata.h
+++ b/Source/WebKit2/UIProcess/API/qt/tests/bytearraytestdata.h
@@ -33,6 +33,7 @@ class QWEBKIT_EXPORT ByteArrayTestData : public QObject {
public:
ByteArrayTestData(QObject* parent = 0);
+ virtual ~ByteArrayTestData() { }
QVariant latin1Data() const;
QVariant utf8Data() const;
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp b/Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp
index f1a81bc18..3ad4729a9 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/tests/publicapi/tst_publicapi.cpp
@@ -43,6 +43,12 @@ static QStringList expectedAPI = QStringList()
<< "QQuickWebView.NetworkErrorDomain --> ErrorDomain"
<< "QQuickWebView.HttpErrorDomain --> ErrorDomain"
<< "QQuickWebView.DownloadErrorDomain --> ErrorDomain"
+ << "QQuickWebView.LinkClickedNavigation --> NavigationType"
+ << "QQuickWebView.FormSubmittedNavigation --> NavigationType"
+ << "QQuickWebView.BackForwardNavigation --> NavigationType"
+ << "QQuickWebView.ReloadNavigation --> NavigationType"
+ << "QQuickWebView.FormResubmittedNavigation --> NavigationType"
+ << "QQuickWebView.OtherNavigation --> NavigationType"
<< "QQuickWebView.title --> QString"
<< "QQuickWebView.url --> QUrl"
<< "QQuickWebView.icon --> QUrl"
@@ -73,6 +79,7 @@ static QStringList expectedAPI = QStringList()
<< "QWebNavigationRequest.button --> int"
<< "QWebNavigationRequest.modifiers --> int"
<< "QWebNavigationRequest.action --> int"
+ << "QWebNavigationRequest.navigationType --> QQuickWebView::NavigationType"
<< "QWebNavigationRequest.actionChanged() --> void"
;
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro
index 8cd15ff4d..7f4e3d12f 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro
@@ -27,4 +27,5 @@ OTHER_FILES += \
WebView/tst_preferences.qml \
WebView/tst_properties.qml \
WebView/tst_titleChanged.qml \
- WebView/tst_applicationScheme.qml
+ WebView/tst_applicationScheme.qml \
+ WebView/tst_origin.qml
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_origin.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_origin.qml
new file mode 100644
index 000000000..70745d8d6
--- /dev/null
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_origin.qml
@@ -0,0 +1,57 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+import QtWebKit.experimental 1.0
+
+WebView {
+ id: webView
+ width: 200
+ height: 200
+
+ property bool success: true
+ property int port: 0
+ property string scheme: "file"
+
+ SignalSpy {
+ id: spy
+ target: experimental
+ signalName: "permissionRequested"
+ }
+
+ experimental.onPermissionRequested: {
+ if (permission.origin.port != webView.port) {
+ console.log("Expected port value should be zero.")
+ webView.success = false
+ }
+
+ if (permission.origin.scheme != webView.scheme) {
+ console.log("Expected scheme should be \"file\".")
+ webView.success = false
+ }
+ }
+
+ TestCase {
+ name: "WebViewSecurityOrigin"
+
+ // Delayed windowShown to workaround problems with Qt5 in debug mode.
+ when: false
+ Timer {
+ running: parent.windowShown
+ repeat: false
+ interval: 1
+ onTriggered: parent.when = true
+ }
+
+ function init() {
+ spy.clear()
+ }
+
+ function test_permissionRequest() {
+ compare(spy.count, 0)
+ webView.load(Qt.resolvedUrl("../common/geolocation.html"))
+ spy.wait()
+ compare(spy.count, 1)
+ compare(webView.success, true)
+ }
+ }
+}
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp
index a80c5c389..bcc246db4 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp
@@ -21,9 +21,9 @@
#include "../util.h"
#include "qquickwebview_p.h"
+#include <QGuiApplication>
#include <QVarLengthArray>
#include <QtQuickTest/quicktest.h>
-#include <QtWidgets/QApplication>
int main(int argc, char** argv)
{
@@ -42,7 +42,7 @@ int main(int argc, char** argv)
// Instantiate QApplication to prevent quick_test_main to instantiate a QGuiApplication.
// This can be removed as soon as we do not use QtWidgets any more.
- QApplication app(argc, argv);
+ QGuiApplication app(argc, argv);
qmlRegisterType<ByteArrayTestData>("Test", 1, 0, "ByteArrayTestData");
#ifdef DISABLE_FLICKABLE_VIEWPORT
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp
index db3f9c977..12886b314 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp
+++ b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp
@@ -352,11 +352,11 @@ void tst_QQuickWebView::scrollRequest()
// COMPARE with the position requested in the html
// Use qRound as that is also used when calculating the position
// in WebKit.
- int y = -qRound(50 * webView()->page()->contentsScale());
- QVERIFY(webView()->page()->pos().y() == y);
+ int y = qRound(50 * webView()->page()->contentsScale());
+ QVERIFY(webView()->experimental()->contentY() == y);
}
-QTWEBKIT_API_TEST_MAIN(tst_QQuickWebView)
+QTEST_MAIN(tst_QQuickWebView)
#include "tst_qquickwebview.moc"
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri
index ed91d3942..faf445397 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri
+++ b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri
@@ -9,7 +9,7 @@ SOURCES += ../util.cpp \
../bytearraytestdata.cpp
INCLUDEPATH += $$PWD
-QT += testlib declarative widgets quick
+QT += testlib declarative quick
CONFIG += qtwebkit
diff --git a/Source/WebKit2/UIProcess/API/qt/tests/util.h b/Source/WebKit2/UIProcess/API/qt/tests/util.h
index 007964fe5..1c052bc9a 100644
--- a/Source/WebKit2/UIProcess/API/qt/tests/util.h
+++ b/Source/WebKit2/UIProcess/API/qt/tests/util.h
@@ -29,13 +29,3 @@
void addQtWebProcessToPath();
bool waitForSignal(QObject*, const char* signal, int timeout = 10000);
void suppressDebugOutput();
-
-#define QTWEBKIT_API_TEST_MAIN(TestObject) \
-int main(int argc, char** argv) \
-{ \
- suppressDebugOutput(); \
- QApplication app(argc, argv); \
- QTEST_DISABLE_KEYPAD_NAVIGATION \
- TestObject tc; \
- return QTest::qExec(&tc, argc, argv); \
-}