diff options
Diffstat (limited to 'Source/WebKit2/UIProcess')
89 files changed, 1535 insertions, 1291 deletions
diff --git a/Source/WebKit2/UIProcess/API/C/WKNotification.cpp b/Source/WebKit2/UIProcess/API/C/WKNotification.cpp index db7d1f02f..634aa9824 100644 --- a/Source/WebKit2/UIProcess/API/C/WKNotification.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKNotification.cpp @@ -47,6 +47,11 @@ WKStringRef WKNotificationCopyBody(WKNotificationRef notification) return toCopiedAPI(toImpl(notification)->body()); } +WKStringRef WKNotificationCopyIconURL(WKNotificationRef notification) +{ + return toCopiedAPI(toImpl(notification)->iconURL()); +} + WKSecurityOriginRef WKNotificationGetSecurityOrigin(WKNotificationRef notification) { return toAPI(toImpl(notification)->origin()); diff --git a/Source/WebKit2/UIProcess/API/C/WKNotification.h b/Source/WebKit2/UIProcess/API/C/WKNotification.h index 07311af3f..7c2723896 100644 --- a/Source/WebKit2/UIProcess/API/C/WKNotification.h +++ b/Source/WebKit2/UIProcess/API/C/WKNotification.h @@ -36,6 +36,7 @@ WK_EXPORT WKTypeID WKNotificationGetTypeID(); WK_EXPORT WKStringRef WKNotificationCopyTitle(WKNotificationRef notification); WK_EXPORT WKStringRef WKNotificationCopyBody(WKNotificationRef notification); +WK_EXPORT WKStringRef WKNotificationCopyIconURL(WKNotificationRef notification); WK_EXPORT WKSecurityOriginRef WKNotificationGetSecurityOrigin(WKNotificationRef notification); WK_EXPORT uint64_t WKNotificationGetID(WKNotificationRef notification); diff --git a/Source/WebKit2/UIProcess/API/C/WKNotificationProvider.h b/Source/WebKit2/UIProcess/API/C/WKNotificationProvider.h index 42a4beb92..bc99ec9b0 100644 --- a/Source/WebKit2/UIProcess/API/C/WKNotificationProvider.h +++ b/Source/WebKit2/UIProcess/API/C/WKNotificationProvider.h @@ -38,6 +38,7 @@ typedef void (*WKNotificationProviderDidDestroyNotificationCallback)(WKNotificat typedef void (*WKNotificationProviderAddNotificationManagerCallback)(WKNotificationManagerRef manager, const void* clientInfo); typedef void (*WKNotificationProviderRemoveNotificationManagerCallback)(WKNotificationManagerRef manager, const void* clientInfo); typedef WKDictionaryRef (*WKNotificationProviderNotificationPermissionsCallback)(const void* clientInfo); +typedef void (*WKNotificationProviderClearNotificationsCallback)(WKArrayRef notificationIDs, const void* clientInfo); struct WKNotificationProvider { int version; @@ -48,6 +49,7 @@ struct WKNotificationProvider { WKNotificationProviderAddNotificationManagerCallback addNotificationManager; WKNotificationProviderRemoveNotificationManagerCallback removeNotificationManager; WKNotificationProviderNotificationPermissionsCallback notificationPermissions; + WKNotificationProviderClearNotificationsCallback clearNotifications; }; typedef struct WKNotificationProvider WKNotificationProvider; diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp index 60e7b7264..521e6d4a0 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp +++ b/Source/WebKit2/UIProcess/API/C/WKPreferences.cpp @@ -52,6 +52,12 @@ WKPreferencesRef WKPreferencesCreateWithIdentifier(WKStringRef identifierRef) return toAPI(preferences.release().leakRef()); } +WKPreferencesRef WKPreferencesCreateCopy(WKPreferencesRef preferencesRef) +{ + RefPtr<WebPreferences> preferences = WebPreferences::create(*toImpl(preferencesRef)); + return toAPI(preferences.release().leakRef()); +} + void WKPreferencesSetJavaScriptEnabled(WKPreferencesRef preferencesRef, bool javaScriptEnabled) { toImpl(preferencesRef)->setJavaScriptEnabled(javaScriptEnabled); diff --git a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h index 3208c6ea3..9153ccab8 100644 --- a/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h +++ b/Source/WebKit2/UIProcess/API/C/WKPreferencesPrivate.h @@ -52,6 +52,9 @@ enum WKEditableLinkBehavior { }; typedef enum WKEditableLinkBehavior WKEditableLinkBehavior; +// Creates a copy with no identifier. +WK_EXPORT WKPreferencesRef WKPreferencesCreateCopy(WKPreferencesRef); + // Defaults to kWKFontSmoothingLevelWindows on Windows, kWKFontSmoothingLevelMedium on other platforms. WK_EXPORT void WKPreferencesSetFontSmoothingLevel(WKPreferencesRef, WKFontSmoothingLevel); WK_EXPORT WKFontSmoothingLevel WKPreferencesGetFontSmoothingLevel(WKPreferencesRef); diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitEditingCommands.h b/Source/WebKit2/UIProcess/API/gtk/WebKitEditingCommands.h new file mode 100644 index 000000000..f85bf31bd --- /dev/null +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitEditingCommands.h @@ -0,0 +1,68 @@ +/* + * 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 WebKitEditingCommands_h +#define WebKitEditingCommands_h + +G_BEGIN_DECLS + +/** + * WEBKIT_EDITING_COMMAND_CUT: + * + * The cut clipboard command. Copies the current selection inside + * a #WebKitWebView to the clipboard and deletes the selected content. + * You can check whether it's possible to execute the command with + * webkit_web_view_can_execute_editing_command(). In general it's + * possible to cut to the clipboard when the #WebKitWebView content is + * editable and there is an active selection. + */ +#define WEBKIT_EDITING_COMMAND_CUT "Cut" + +/** + * WEBKIT_EDITING_COMMAND_COPY: + * + * The copy clipboard command. Copies the current selection inside + * a #WebKitWebView to the clipboard. + * You can check whether it's possible to execute the command with + * webkit_web_view_can_execute_editing_command(). In general it's + * possible to copy to the clipboard when there is an active selection + * inside the #WebKitWebView. + */ +#define WEBKIT_EDITING_COMMAND_COPY "Copy" + +/** + * WEBKIT_EDITING_COMMAND_PASTE: + * + * The paste clipboard command. Pastes the contents of the clipboard to + * a #WebKitWebView. + * You can check whether it's possible to execute the command with + * webkit_web_view_can_execute_editing_command(). In general it's possible + * to paste from the clipboard when the #WebKitWebView content is editable + * and clipboard is not empty. + */ +#define WEBKIT_EDITING_COMMAND_PASTE "Paste" + + +G_END_DECLS + +#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyClient.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyClient.cpp index 61757d428..87fe90799 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyClient.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPolicyClient.cpp @@ -23,6 +23,7 @@ #include "WebKitNavigationPolicyDecisionPrivate.h" #include "WebKitPolicyDecision.h" #include "WebKitPrivate.h" +#include "WebKitResponsePolicyDecisionPrivate.h" #include "WebKitWebViewBasePrivate.h" #include "WebKitWebViewPrivate.h" #include <wtf/gobject/GRefPtr.h> @@ -57,6 +58,15 @@ static void decidePolicyForNewWindowActionCallback(WKPageRef page, WKFrameRef fr WEBKIT_POLICY_DECISION(decision.get())); } +static void decidePolicyForResponseCallback(WKPageRef page, WKFrameRef frame, WKURLResponseRef response, WKURLRequestRef request, WKFramePolicyListenerRef listener, WKTypeRef userData, const void* clientInfo) +{ + GRefPtr<WebKitResponsePolicyDecision> decision = + adoptGRef(webkitResponsePolicyDecisionCreate(request, response, listener)); + webkitWebViewMakePolicyDecision(WEBKIT_WEB_VIEW(clientInfo), + WEBKIT_POLICY_DECISION_TYPE_RESPONSE, + WEBKIT_POLICY_DECISION(decision.get())); +} + void attachPolicyClientToPage(WebKitWebView* webView) { WKPagePolicyClient policyClient = { @@ -64,7 +74,7 @@ void attachPolicyClientToPage(WebKitWebView* webView) webView, // clientInfo decidePolicyForNavigationActionCallback, decidePolicyForNewWindowActionCallback, - 0, // decidePolicyForResponseCallback, + decidePolicyForResponseCallback, 0, // unableToImplementPolicy }; WKPageSetPagePolicyClient(toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))), &policyClient); diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h index 13280d600..c44d877e0 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitPrivate.h @@ -33,9 +33,9 @@ #include <glib.h> #include <wtf/Assertions.h> -#define WEBKIT_PARAM_READABLE (static_cast<GParamFlags>(G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)) -#define WEBKIT_PARAM_WRITABLE (static_cast<GParamFlags>(G_PARAM_WRITABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)) -#define WEBKIT_PARAM_READWRITE (static_cast<GParamFlags>(G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB)) +#define WEBKIT_PARAM_READABLE (static_cast<GParamFlags>(G_PARAM_READABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)) +#define WEBKIT_PARAM_WRITABLE (static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)) +#define WEBKIT_PARAM_READWRITE (static_cast<GParamFlags>(G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)) #define COMPILE_ASSERT_MATCHING_ENUM(webkitName, webcoreName) \ COMPILE_ASSERT(int(webkitName) == int(webcoreName), mismatchingEnums) diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecision.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecision.cpp new file mode 100644 index 000000000..adfcdfdd7 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecision.cpp @@ -0,0 +1,160 @@ +/* + * 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 "WebKitResponsePolicyDecision.h" + +#include "WebKitPolicyDecisionPrivate.h" +#include "WebKitPrivate.h" +#include "WebKitURIRequestPrivate.h" +#include "WebKitURIResponsePrivate.h" +#include "WebURLRequest.h" +#include "WebURLResponse.h" +#include <glib/gi18n-lib.h> +#include <wtf/gobject/GRefPtr.h> +#include <wtf/text/CString.h> + +using namespace WebKit; + +/** + * SECTION: WebKitResponsePolicyDecision + * @Short_description: A policy decision for resource responses + * @Title: WebKitResponsePolicyDecision + * @See_also: #WebKitPolicyDecision, #WebKitWebView + * + * WebKitResponsePolicyDecision represents a policy decision for a + * resource response, whether from the network or the local system. + * A very common usecase for these types of decision is deciding + * whether or not to download a particular resource or to load it + * normally. + */ +G_DEFINE_TYPE(WebKitResponsePolicyDecision, webkit_response_policy_decision, WEBKIT_TYPE_POLICY_DECISION) + +struct _WebKitResponsePolicyDecisionPrivate { + GRefPtr<WebKitURIRequest> request; + GRefPtr<WebKitURIResponse> response; +}; + +enum { + PROP_0, + PROP_REQUEST, + PROP_RESPONSE, +}; + +static void webkit_response_policy_decision_init(WebKitResponsePolicyDecision* decision) +{ + decision->priv = G_TYPE_INSTANCE_GET_PRIVATE(decision, WEBKIT_TYPE_RESPONSE_POLICY_DECISION, WebKitResponsePolicyDecisionPrivate); + new (decision->priv) WebKitResponsePolicyDecisionPrivate(); +} + +static void webkitResponsePolicyDecisionFinalize(GObject* object) +{ + WEBKIT_RESPONSE_POLICY_DECISION(object)->priv->~WebKitResponsePolicyDecisionPrivate(); + G_OBJECT_CLASS(webkit_response_policy_decision_parent_class)->finalize(object); +} + +static void webkitResponsePolicyDecisionGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec) +{ + WebKitResponsePolicyDecision* decision = WEBKIT_RESPONSE_POLICY_DECISION(object); + switch (propId) { + case PROP_REQUEST: + g_value_set_object(value, webkit_response_policy_decision_get_request(decision)); + break; + case PROP_RESPONSE: + g_value_set_object(value, webkit_response_policy_decision_get_response(decision)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); + break; + } +} + +static void webkit_response_policy_decision_class_init(WebKitResponsePolicyDecisionClass* decisionClass) +{ + GObjectClass* objectClass = G_OBJECT_CLASS(decisionClass); + objectClass->finalize = webkitResponsePolicyDecisionFinalize; + objectClass->get_property = webkitResponsePolicyDecisionGetProperty; + g_type_class_add_private(decisionClass, sizeof(WebKitResponsePolicyDecisionPrivate)); + + /** + * WebKitResponsePolicyDecision:request: + * + * This property contains the #WebKitURIRequest associated with this + * policy decision. + */ + g_object_class_install_property(objectClass, + PROP_REQUEST, + g_param_spec_object("request", + _("Response URI request"), + _("The URI request that is associated with this policy decision"), + WEBKIT_TYPE_URI_REQUEST, + WEBKIT_PARAM_READABLE)); + + /** + * WebKitResponsePolicyDecision:response: + * + * This property contains the #WebKitURIResponse associated with this + * policy decision. + */ + g_object_class_install_property(objectClass, + PROP_REQUEST, + g_param_spec_object("response", + _("URI response"), + _("The URI response that is associated with this policy decision"), + WEBKIT_TYPE_URI_REQUEST, + WEBKIT_PARAM_READABLE)); + +} + +/** + * webkit_response_policy_decision_get_request: + * @decision: a #WebKitResponsePolicyDecision + * + * Gets the value of the #WebKitResponsePolicyDecision:request property. + * + * Returns: (transfer none): The URI request that is associated with this policy decision. + */ +WebKitURIRequest* webkit_response_policy_decision_get_request(WebKitResponsePolicyDecision* decision) +{ + g_return_val_if_fail(WEBKIT_IS_RESPONSE_POLICY_DECISION(decision), 0); + return decision->priv->request.get(); +} + +/** + * webkit_response_policy_decision_get_response: + * @decision: a #WebKitResponsePolicyDecision + * + * Gets the value of the #WebKitResponsePolicyDecision:response property. + * + * Returns: (transfer none): The URI response that is associated with this policy decision. + */ +WebKitURIResponse* webkit_response_policy_decision_get_response(WebKitResponsePolicyDecision* decision) +{ + g_return_val_if_fail(WEBKIT_IS_RESPONSE_POLICY_DECISION(decision), 0); + return decision->priv->response.get(); +} + +WebKitResponsePolicyDecision* webkitResponsePolicyDecisionCreate(WKURLRequestRef request, WKURLResponseRef response, WKFramePolicyListenerRef listener) +{ + WebKitResponsePolicyDecision* decision = WEBKIT_RESPONSE_POLICY_DECISION(g_object_new(WEBKIT_TYPE_RESPONSE_POLICY_DECISION, NULL)); + decision->priv->request = adoptGRef(webkitURIRequestCreateForResourceRequest(toImpl(request)->resourceRequest())); + decision->priv->response = adoptGRef(webkitURIResponseCreateForResourceResponse(toImpl(response)->resourceResponse())); + webkitPolicyDecisionSetListener(WEBKIT_POLICY_DECISION(decision), listener); + return decision; +} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecision.h b/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecision.h new file mode 100644 index 000000000..7653fcc14 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecision.h @@ -0,0 +1,68 @@ +/* + * 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 WebKitResponsePolicyDecision_h +#define WebKitResponsePolicyDecision_h + +#include <glib-object.h> +#include <webkit2/WebKitDefines.h> +#include <webkit2/WebKitPolicyDecision.h> +#include <webkit2/WebKitURIResponse.h> +#include <webkit2/WebKitURIRequest.h> + +G_BEGIN_DECLS + +#define WEBKIT_TYPE_RESPONSE_POLICY_DECISION (webkit_response_policy_decision_get_type()) +#define WEBKIT_RESPONSE_POLICY_DECISION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_RESPONSE_POLICY_DECISION, WebKitResponsePolicyDecision)) +#define WEBKIT_RESPONSE_POLICY_DECISION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_RESPONSE_POLICY_DECISION, WebKitResponsePolicyDecisionClass)) +#define WEBKIT_IS_RESPONSE_POLICY_DECISION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_RESPONSE_POLICY_DECISION)) +#define WEBKIT_IS_RESPONSE_POLICY_DECISION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_RESPONSE_POLICY_DECISION)) +#define WEBKIT_RESPONSE_POLICY_DECISION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_RESPONSE_POLICY_DECISION, WebKitResponsePolicyDecisionClass)) + +typedef struct _WebKitResponsePolicyDecision WebKitResponsePolicyDecision; +typedef struct _WebKitResponsePolicyDecisionClass WebKitResponsePolicyDecisionClass; +typedef struct _WebKitResponsePolicyDecisionPrivate WebKitResponsePolicyDecisionPrivate; + +struct _WebKitResponsePolicyDecision { + WebKitPolicyDecision parent; + + /*< private >*/ + WebKitResponsePolicyDecisionPrivate *priv; +}; + +struct _WebKitResponsePolicyDecisionClass { + WebKitPolicyDecisionClass parent_class; +}; + +WEBKIT_API GType +webkit_response_policy_decision_get_type (void); + +WEBKIT_API WebKitURIRequest * +webkit_response_policy_decision_get_request (WebKitResponsePolicyDecision *decision); + +WEBKIT_API WebKitURIResponse * +webkit_response_policy_decision_get_response (WebKitResponsePolicyDecision *decision); + +G_END_DECLS + +#endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecisionPrivate.h b/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecisionPrivate.h new file mode 100644 index 000000000..b508aa525 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitResponsePolicyDecisionPrivate.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 WebKitResponsePolicyDecisionPrivate_h +#define WebKitResponsePolicyDecisionPrivate_h + +#include "WebKitPrivate.h" +#include "WebKitResponsePolicyDecision.h" + +WebKitResponsePolicyDecision* webkitResponsePolicyDecisionCreate(WKURLRequestRef, WKURLResponseRef, WKFramePolicyListenerRef); + +#endif // WebKitResponsePolicyDecisionPrivate_h diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp index 06418613d..774f17190 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.cpp @@ -101,7 +101,8 @@ enum { PROP_ENABLE_DNS_PREFETCHING, PROP_ENABLE_CARET_BROWSING, PROP_ENABLE_FULLSCREEN, - PROP_PRINT_BACKGROUNDS + PROP_PRINT_BACKGROUNDS, + PROP_ENABLE_WEBAUDIO }; static void webKitSettingsSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec) @@ -202,6 +203,9 @@ static void webKitSettingsSetProperty(GObject* object, guint propId, const GValu case PROP_PRINT_BACKGROUNDS: webkit_settings_set_print_backgrounds(settings, g_value_get_boolean(value)); break; + case PROP_ENABLE_WEBAUDIO: + webkit_settings_set_enable_webaudio(settings, g_value_get_boolean(value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); break; @@ -306,6 +310,9 @@ static void webKitSettingsGetProperty(GObject* object, guint propId, GValue* val case PROP_PRINT_BACKGROUNDS: g_value_set_boolean(value, webkit_settings_get_print_backgrounds(settings)); break; + case PROP_ENABLE_WEBAUDIO: + g_value_set_boolean(value, webkit_settings_get_enable_webaudio(settings)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec); break; @@ -768,6 +775,25 @@ static void webkit_settings_class_init(WebKitSettingsClass* klass) TRUE, readWriteConstructParamFlags)); + /** + * WebKitSettings:enable-webaudio: + * + * + * Enable or disable support for WebAudio on pages. WebAudio is an + * experimental proposal for allowing web pages to generate Audio + * WAVE data from JavaScript. The standard is currently a + * work-in-progress by the W3C Audio Working Group. + * + * See also https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html + */ + g_object_class_install_property(gObjectClass, + PROP_ENABLE_WEBAUDIO, + g_param_spec_boolean("enable-webaudio", + _("Enable WebAudio"), + _("Whether WebAudio content should be handled"), + FALSE, + readWriteConstructParamFlags)); + g_type_class_add_private(klass, sizeof(WebKitSettingsPrivate)); } @@ -1955,3 +1981,38 @@ void webkit_settings_set_print_backgrounds(WebKitSettings* settings, gboolean pr WKPreferencesSetShouldPrintBackgrounds(priv->preferences.get(), printBackgrounds); g_object_notify(G_OBJECT(settings), "print-backgrounds"); } + +/** + * webkit_settings_get_enable_webaudio: + * @settings: a #WebKitSettings + * + * Get the #WebKitSettings:enable-webaudio property. + * + * Returns: %TRUE If webaudio support is enabled or %FALSE otherwise. + */ +gboolean webkit_settings_get_enable_webaudio(WebKitSettings* settings) +{ + g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE); + + return WKPreferencesGetWebAudioEnabled(settings->priv->preferences.get()); +} + +/** + * webkit_settings_set_enable_webaudio: + * @settings: a #WebKitSettings + * @enabled: Value to be set + * + * Set the #WebKitSettings:enable-webaudio property. + */ +void webkit_settings_set_enable_webaudio(WebKitSettings* settings, gboolean enabled) +{ + g_return_if_fail(WEBKIT_IS_SETTINGS(settings)); + + WebKitSettingsPrivate* priv = settings->priv; + bool currentValue = WKPreferencesGetWebAudioEnabled(priv->preferences.get()); + if (currentValue == enabled) + return; + + WKPreferencesSetWebAudioEnabled(priv->preferences.get(), enabled); + g_object_notify(G_OBJECT(settings), "enable-webaudio"); +} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h index a6769fc0e..27cb7c75a 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitSettings.h @@ -293,6 +293,13 @@ WEBKIT_API void webkit_settings_set_print_backgrounds (WebKitSettings *settings, gboolean print_backgrounds); +WEBKIT_API gboolean +webkit_settings_get_enable_webaudio (WebKitSettings *settings); + +WEBKIT_API void +webkit_settings_set_enable_webaudio (WebKitSettings *settings, + gboolean enabled); + G_END_DECLS #endif /* WebKitSettings_h */ diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp index fcaa2db1d..c3accccbb 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp @@ -27,13 +27,13 @@ #include "WebKitLoaderClient.h" #include "WebKitMarshal.h" #include "WebKitPolicyClient.h" +#include "WebKitPrivate.h" #include "WebKitSettingsPrivate.h" #include "WebKitUIClient.h" #include "WebKitWebContextPrivate.h" #include "WebKitWebViewBasePrivate.h" #include "WebKitWebViewPrivate.h" #include "WebKitWindowPropertiesPrivate.h" -#include "WebKitPrivate.h" #include "WebPageProxy.h" #include <WebCore/DragIcon.h> #include <WebCore/GtkUtilities.h> @@ -180,9 +180,11 @@ static void webkitWebViewSetProperty(GObject* object, guint propId, const GValue WebKitWebView* webView = WEBKIT_WEB_VIEW(object); switch (propId) { - case PROP_WEB_CONTEXT: - webView->priv->context = WEBKIT_WEB_CONTEXT(g_value_get_object(value)); + case PROP_WEB_CONTEXT: { + gpointer webContext = g_value_get_object(value); + webView->priv->context = webContext ? WEBKIT_WEB_CONTEXT(webContext) : webkit_web_context_get_default(); break; + } case PROP_ZOOM_LEVEL: webkit_web_view_set_zoom_level(webView, g_value_get_double(value)); break; @@ -554,9 +556,9 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass) G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); /** - * WebKitPolicyClient::decide-policy + * WebKitWebView::decide-policy: * @web_view: the #WebKitWebView on which the signal is emitted - * @decision: the #WebKitNavigationPolicyDecision + * @decision: the #WebKitPolicyDecision * @decision_type: a #WebKitPolicyDecisionType denoting the type of @decision * * This signal is emitted when WebKit is requesting the client to decide a policy @@ -1267,3 +1269,77 @@ gdouble webkit_web_view_get_zoom_level(WebKitWebView* webView) WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView))); return WKPageGetPageZoomFactor(wkPage); } + + +static void didValidateCommand(WKStringRef command, bool isEnabled, int32_t state, WKErrorRef, void* context) +{ + GRefPtr<GSimpleAsyncResult> result = adoptGRef(G_SIMPLE_ASYNC_RESULT(context)); + g_simple_async_result_set_op_res_gboolean(result.get(), isEnabled); + g_simple_async_result_complete(result.get()); +} + +/** + * webkit_web_view_can_execute_editing_command: + * @web_view: a #WebKitWebView + * @command: the command to check + * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied + * @user_data: (closure): the data to pass to callback function + * + * Asynchronously execute the given editing command. + * + * When the operation is finished, @callback will be called. You can then call + * webkit_web_view_can_execute_editing_command_finish() to get the result of the operation. + */ +void webkit_web_view_can_execute_editing_command(WebKitWebView* webView, const char* command, GAsyncReadyCallback callback, gpointer userData) +{ + g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); + g_return_if_fail(command); + + GSimpleAsyncResult* result = g_simple_async_result_new(G_OBJECT(webView), callback, userData, + reinterpret_cast<gpointer>(webkit_web_view_can_execute_editing_command)); + WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)); + WKRetainPtr<WKStringRef> wkCommand(AdoptWK, WKStringCreateWithUTF8CString(command)); + WKPageValidateCommand(toAPI(page), wkCommand.get(), result, didValidateCommand); +} + +/** + * webkit_web_view_can_execute_editing_command_finish: + * @web_view: a #WebKitWebView + * @result: a #GAsyncResult + * @error: return location for error or %NULL to ignore + * + * Finish an asynchronous operation started with webkit_web_view_can_execute_editing_command(). + * + * Returns: %TRUE if a selection can be cut or %FALSE otherwise + */ +gboolean webkit_web_view_can_execute_editing_command_finish(WebKitWebView* webView, GAsyncResult* result, GError** error) +{ + g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE); + g_return_val_if_fail(G_IS_ASYNC_RESULT(result), FALSE); + + GSimpleAsyncResult* simple = G_SIMPLE_ASYNC_RESULT(result); + g_warn_if_fail(g_simple_async_result_get_source_tag(simple) == webkit_web_view_can_execute_editing_command); + + if (g_simple_async_result_propagate_error(simple, error)) + return FALSE; + return g_simple_async_result_get_op_res_gboolean(simple); +} + +/** + * webkit_web_view_execute_editing_command: + * @web_view: a #WebKitWebView + * @command: the command to execute + * + * Request to execute the given @command for @web_view. You can use + * webkit_web_view_can_execute_editing_command() to check whether + * it's possible to execute the command. + */ +void webkit_web_view_execute_editing_command(WebKitWebView* webView, const char* command) +{ + g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView)); + g_return_if_fail(command); + + WebPageProxy* page = webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)); + WKRetainPtr<WKStringRef> wkCommand(AdoptWK, WKStringCreateWithUTF8CString(command)); + WKPageExecuteCommand(toAPI(page), wkCommand.get()); +} diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h index 697fcdc80..d4768e3b6 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h @@ -39,6 +39,17 @@ G_BEGIN_DECLS +#define WEBKIT_TYPE_WEB_VIEW (webkit_web_view_get_type()) +#define WEBKIT_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebView)) +#define WEBKIT_IS_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_VIEW)) +#define WEBKIT_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass)) +#define WEBKIT_IS_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_VIEW)) +#define WEBKIT_WEB_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass)) + +typedef struct _WebKitWebView WebKitWebView; +typedef struct _WebKitWebViewClass WebKitWebViewClass; +typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate; + /** * WebKitPolicyDecisionType: * @WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: This type of policy decision @@ -73,17 +84,6 @@ typedef enum { WEBKIT_POLICY_DECISION_TYPE_RESPONSE, } WebKitPolicyDecisionType; -#define WEBKIT_TYPE_WEB_VIEW (webkit_web_view_get_type()) -#define WEBKIT_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebView)) -#define WEBKIT_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass)) -#define WEBKIT_IS_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_VIEW)) -#define WEBKIT_IS_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_VIEW)) -#define WEBKIT_WEB_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass)) - -typedef struct _WebKitWebView WebKitWebView; -typedef struct _WebKitWebViewClass WebKitWebViewClass; -typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate; - /** * WebKitLoadEvent * @WEBKIT_LOAD_STARTED: A new load request has been made. @@ -152,99 +152,113 @@ struct _WebKitWebViewClass { }; WEBKIT_API GType -webkit_web_view_get_type (void); +webkit_web_view_get_type (void); WEBKIT_API GtkWidget * -webkit_web_view_new (void); +webkit_web_view_new (void); WEBKIT_API GtkWidget * -webkit_web_view_new_with_context (WebKitWebContext *context); +webkit_web_view_new_with_context (WebKitWebContext *context); WEBKIT_API WebKitWebContext * -webkit_web_view_get_context (WebKitWebView *web_view); +webkit_web_view_get_context (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_load_uri (WebKitWebView *web_view, - const gchar *uri); +webkit_web_view_load_uri (WebKitWebView *web_view, + const gchar *uri); WEBKIT_API void -webkit_web_view_load_html (WebKitWebView *web_view, - const gchar *content, - const gchar *base_uri); +webkit_web_view_load_html (WebKitWebView *web_view, + const gchar *content, + const gchar *base_uri); WEBKIT_API void -webkit_web_view_load_plain_text (WebKitWebView *web_view, - const gchar *plain_text); +webkit_web_view_load_plain_text (WebKitWebView *web_view, + const gchar *plain_text); WEBKIT_API void -webkit_web_view_load_request (WebKitWebView *web_view, - WebKitURIRequest *request); +webkit_web_view_load_request (WebKitWebView *web_view, + WebKitURIRequest *request); WEBKIT_API void -webkit_web_view_stop_loading (WebKitWebView *web_view); +webkit_web_view_stop_loading (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_replace_content (WebKitWebView *web_view, - const gchar *content, - const gchar *content_uri, - const gchar *base_uri); +webkit_web_view_replace_content (WebKitWebView *web_view, + const gchar *content, + const gchar *content_uri, + const gchar *base_uri); WEBKIT_API const gchar * -webkit_web_view_get_title (WebKitWebView *web_view); +webkit_web_view_get_title (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_reload (WebKitWebView *web_view); +webkit_web_view_reload (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_reload_bypass_cache (WebKitWebView *web_view); +webkit_web_view_reload_bypass_cache (WebKitWebView *web_view); WEBKIT_API gdouble -webkit_web_view_get_estimated_load_progress (WebKitWebView *web_view); +webkit_web_view_get_estimated_load_progress (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_go_back (WebKitWebView *web_view); +webkit_web_view_go_back (WebKitWebView *web_view); WEBKIT_API gboolean -webkit_web_view_can_go_back (WebKitWebView *web_view); +webkit_web_view_can_go_back (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_go_forward (WebKitWebView *web_view); +webkit_web_view_go_forward (WebKitWebView *web_view); WEBKIT_API gboolean -webkit_web_view_can_go_forward (WebKitWebView *web_view); +webkit_web_view_can_go_forward (WebKitWebView *web_view); WEBKIT_API WebKitBackForwardList * -webkit_web_view_get_back_forward_list (WebKitWebView *web_view); +webkit_web_view_get_back_forward_list (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_go_to_back_forward_list_item (WebKitWebView *web_view, - WebKitBackForwardListItem *list_item); +webkit_web_view_go_to_back_forward_list_item (WebKitWebView *web_view, + WebKitBackForwardListItem *list_item); WEBKIT_API const gchar * -webkit_web_view_get_uri (WebKitWebView *web_view); +webkit_web_view_get_uri (WebKitWebView *web_view); WEBKIT_API const gchar * -webkit_web_view_get_custom_charset (WebKitWebView *web_view); +webkit_web_view_get_custom_charset (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_set_custom_charset (WebKitWebView *web_view, - const gchar *charset); +webkit_web_view_set_custom_charset (WebKitWebView *web_view, + const gchar *charset); WEBKIT_API void -webkit_web_view_set_settings (WebKitWebView *web_view, - WebKitSettings *settings); +webkit_web_view_set_settings (WebKitWebView *web_view, + WebKitSettings *settings); WEBKIT_API WebKitSettings * -webkit_web_view_get_settings (WebKitWebView *web_view); +webkit_web_view_get_settings (WebKitWebView *web_view); WEBKIT_API WebKitWindowProperties * -webkit_web_view_get_window_properties (WebKitWebView *web_view); +webkit_web_view_get_window_properties (WebKitWebView *web_view); WEBKIT_API void -webkit_web_view_set_zoom_level (WebKitWebView *web_view, - gdouble zoom_level); +webkit_web_view_set_zoom_level (WebKitWebView *web_view, + gdouble zoom_level); WEBKIT_API gdouble -webkit_web_view_get_zoom_level (WebKitWebView *web_view); +webkit_web_view_get_zoom_level (WebKitWebView *web_view); + +WEBKIT_API void +webkit_web_view_can_execute_editing_command (WebKitWebView *web_view, + const gchar *command, + GAsyncReadyCallback callback, + gpointer user_data); +WEBKIT_API gboolean +webkit_web_view_can_execute_editing_command_finish (WebKitWebView *web_view, + GAsyncResult *result, + GError **error); + +WEBKIT_API void +webkit_web_view_execute_editing_command (WebKitWebView *web_view, + const gchar *command); G_END_DECLS #endif diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp index d9ccaa32a..adcc34ae3 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp @@ -71,6 +71,7 @@ struct _WebKitWebViewBasePrivate { DragIcon dragIcon; IntSize resizerSize; GRefPtr<AtkObject> accessible; + bool needsResizeOnMap; }; G_DEFINE_TYPE(WebKitWebViewBase, webkit_web_view_base, GTK_TYPE_CONTAINER) @@ -202,20 +203,43 @@ static gboolean webkitWebViewBaseDraw(GtkWidget* widget, cairo_t* cr) return FALSE; } +static void resizeWebKitWebViewBaseFromAllocation(WebKitWebViewBase* webViewBase, GtkAllocation* allocation) +{ + WebKitWebViewBasePrivate* priv = webViewBase->priv; + + if (priv->pageProxy->drawingArea()) + priv->pageProxy->drawingArea()->setSize(IntSize(allocation->width, allocation->height), IntSize()); + + GtkWidget* toplevel = gtk_widget_get_toplevel(GTK_WIDGET(webViewBase)); + if (widgetIsOnscreenToplevelWindow(toplevel)) + webkitWebViewBaseNotifyResizerSizeForWindow(webViewBase, GTK_WINDOW(toplevel)); +} + static void webkitWebViewBaseSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { + GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->size_allocate(widget, allocation); + WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); - WebKitWebViewBasePrivate* priv = webViewBase->priv; + if (!gtk_widget_get_mapped(GTK_WIDGET(webViewBase)) && !webViewBase->priv->pageProxy->drawingArea()->size().isEmpty()) { + webViewBase->priv->needsResizeOnMap = true; + return; + } + resizeWebKitWebViewBaseFromAllocation(webViewBase, allocation); +} + +static void webkitWebViewBaseMap(GtkWidget* widget) +{ + GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->map(widget); - if (!priv->pageProxy->drawingArea()) + WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(widget); + if (!webViewBase->priv->needsResizeOnMap) return; - GTK_WIDGET_CLASS(webkit_web_view_base_parent_class)->size_allocate(widget, allocation); - priv->pageProxy->drawingArea()->setSize(IntSize(allocation->width, allocation->height), IntSize()); + GtkAllocation allocation; + gtk_widget_get_allocation(widget, &allocation); + resizeWebKitWebViewBaseFromAllocation(webViewBase, &allocation); + webViewBase->priv->needsResizeOnMap = false; - GtkWidget* toplevel = gtk_widget_get_toplevel(widget); - if (widgetIsOnscreenToplevelWindow(toplevel)) - webkitWebViewBaseNotifyResizerSizeForWindow(webViewBase, GTK_WINDOW(toplevel)); } static gboolean webkitWebViewBaseFocusInEvent(GtkWidget* widget, GdkEventFocus* event) @@ -454,6 +478,7 @@ static void webkit_web_view_base_class_init(WebKitWebViewBaseClass* webkitWebVie widgetClass->realize = webkitWebViewBaseRealize; widgetClass->draw = webkitWebViewBaseDraw; widgetClass->size_allocate = webkitWebViewBaseSizeAllocate; + widgetClass->map = webkitWebViewBaseMap; widgetClass->focus_in_event = webkitWebViewBaseFocusInEvent; widgetClass->focus_out_event = webkitWebViewBaseFocusOutEvent; widgetClass->key_press_event = webkitWebViewBaseKeyPressEvent; diff --git a/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp b/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp index b170c82c9..413890203 100644 --- a/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/WebKitWindowProperties.cpp @@ -38,7 +38,7 @@ * scrollbar, statusbar, locationbar should be visible to the user, * and the request to show the #WebKitWebView fullscreen. * - * The #WebKitWebView:ready-to-show signal handler is the proper place + * The #WebKitWebView::ready-to-show signal handler is the proper place * to apply the initial window properties. Then you can monitor the * #WebKitWindowProperties by connecting to ::notify signal. * diff --git a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml index c6f943ab2..af0cdae7c 100644 --- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml +++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml @@ -23,6 +23,7 @@ <xi:include href="xml/WebKitDownload.xml"/> <xi:include href="xml/WebKitPolicyDecision.xml"/> <xi:include href="xml/WebKitNavigationPolicyDecision.xml"/> + <xi:include href="xml/WebKitResponsePolicyDecision.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 ef44b2bed..52cd89ee7 100644 --- a/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt +++ b/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt @@ -49,6 +49,13 @@ webkit_web_context_get_type WebKitWebView WebKitLoadEvent WebKitPolicyDecisionType + +<SUBSECTION Editing Commands> +WEBKIT_EDITING_COMMAND_CUT +WEBKIT_EDITING_COMMAND_COPY +WEBKIT_EDITING_COMMAND_PASTE + +<SUBSECTION> webkit_web_view_new webkit_web_view_new_with_context webkit_web_view_get_context @@ -76,6 +83,9 @@ webkit_web_view_get_settings webkit_web_view_get_window_properties webkit_web_view_set_zoom_level webkit_web_view_get_zoom_level +webkit_web_view_can_execute_editing_command +webkit_web_view_can_execute_editing_command_finish +webkit_web_view_execute_editing_command <SUBSECTION Standard> WebKitWebViewClass @@ -206,6 +216,8 @@ webkit_settings_get_enable_fullscreen webkit_settings_set_enable_fullscreen webkit_settings_get_print_backgrounds webkit_settings_set_print_backgrounds +webkit_settings_get_enable_webaudio +webkit_settings_set_enable_webaudio <SUBSECTION Standard> WebKitSettingsClass @@ -358,6 +370,26 @@ webkit_navigation_policy_decision_get_type </SECTION> <SECTION> +<FILE>WebKitResponsePolicyDecision</FILE> +WebKitResponsePolicyDecision +webkit_response_policy_decision_get_request +webkit_response_policy_decision_get_response + +<SUBSECTION Standard> +WebKitResponsePolicyDecisionClass +WEBKIT_TYPE_RESPONSE_POLICY_DECISION +WEBKIT_RESPONSE_POLICY_DECISION +WEBKIT_IS_RESPONSE_POLICY_DECISION +WEBKIT_RESPONSE_POLICY_DECISION_CLASS +WEBKIT_IS_RESPONSE_POLICY_DECISION_CLASS +WEBKIT_RESPONSE_POLICY_DECISION_GET_CLASS + +<SUBSECTION Private> +WebKitResponsePolicyDecisionPrivate +webkit_response_policy_decision_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 175a149e4..7241b9980 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am +++ b/Source/WebKit2/UIProcess/API/gtk/tests/GNUmakefile.am @@ -5,7 +5,8 @@ TEST_PROGS += \ Programs/WebKit2APITests/TestWebKitSettings \ Programs/WebKit2APITests/TestBackForwardList \ Programs/WebKit2APITests/TestDownloads \ - Programs/WebKit2APITests/TestWebKitPolicyClient + Programs/WebKit2APITests/TestWebKitPolicyClient \ + Programs/WebKit2APITests/TestWebViewEditor noinst_PROGRAMS += $(TEST_PROGS) @@ -111,3 +112,9 @@ Programs_WebKit2APITests_TestDownloads_SOURCES = \ Programs_WebKit2APITests_TestDownloads_CPPFLAGS = $(webkit2_tests_cppflags) Programs_WebKit2APITests_TestDownloads_LDADD = $(webkit2_tests_ldadd) Programs_WebKit2APITests_TestDownloads_LDFLAGS = $(webkit2_tests_ldflags) + +Programs_WebKit2APITests_TestWebViewEditor_SOURCES = \ + Source/WebKit2/UIProcess/API/gtk/tests/TestWebViewEditor.cpp +Programs_WebKit2APITests_TestWebViewEditor_CPPFLAGS = $(webkit2_tests_cppflags) +Programs_WebKit2APITests_TestWebViewEditor_LDADD = $(webkit2_tests_ldadd) +Programs_WebKit2APITests_TestWebViewEditor_LDFLAGS = $(webkit2_tests_ldflags) diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp index 9eb08575d..a35c8745b 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/LoadTrackingTest.cpp @@ -110,8 +110,6 @@ void LoadTrackingTest::provisionalLoadReceivedServerRedirect() void LoadTrackingTest::provisionalLoadFailed(const gchar* failingURI, GError* error) { m_loadEvents.append(ProvisionalLoadFailed); - if (m_runLoadUntilCompletion) - g_main_loop_quit(m_mainLoop); } void LoadTrackingTest::loadCommitted() diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp index cc657cc64..e70e391ff 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestBackForwardList.cpp @@ -19,8 +19,8 @@ #include "config.h" -#include "LoadTrackingTest.h" #include "WebKitTestServer.h" +#include "WebViewTest.h" #include <gtk/gtk.h> #include <libsoup/soup.h> #include <string.h> @@ -46,7 +46,7 @@ static void serverCallback(SoupServer* server, SoupMessage* msg, const char* pat soup_message_body_complete(msg->response_body); } -class BackForwardListTest: public LoadTrackingTest { +class BackForwardListTest: public WebViewTest { public: MAKE_GLIB_TEST_FIXTURE(BackForwardListTest); @@ -130,7 +130,7 @@ public: void waitUntilLoadFinished() { m_hasChanged = false; - LoadTrackingTest::waitUntilLoadFinished(); + WebViewTest::waitUntilLoadFinished(); g_assert(m_hasChanged); } diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h b/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h index 631096a76..39a2000ac 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestMain.h @@ -20,9 +20,9 @@ #ifndef TestMain_h #define TestMain_h -#include <glib-object.h> #include <JavaScriptCore/GOwnPtr.h> #include <JavaScriptCore/HashSet.h> +#include <glib-object.h> #define MAKE_GLIB_TEST_FIXTURE(ClassName) \ static void setUp(ClassName* fixture, gconstpointer data) \ @@ -39,8 +39,7 @@ g_test_add(testPath.get(), ClassName, 0, ClassName::setUp, testFunc, ClassName::tearDown); \ } -class Test -{ +class Test { public: MAKE_GLIB_TEST_FIXTURE(Test); diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitPolicyClient.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitPolicyClient.cpp index 7cbe4e7f9..9f6ce7819 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitPolicyClient.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitPolicyClient.cpp @@ -20,9 +20,12 @@ #include "config.h" #include "LoadTrackingTest.h" +#include "WebKitTestServer.h" #include <wtf/gobject/GRefPtr.h> #include <wtf/text/CString.h> +static WebKitTestServer* kServer; + class PolicyClientTest: public LoadTrackingTest { public: MAKE_GLIB_TEST_FIXTURE(PolicyClientTest); @@ -142,6 +145,37 @@ static void testNavigationPolicy(PolicyClientTest* test, gconstpointer) g_assert_cmpint(test->m_loadEvents.size(), ==, 0); } +static void testResponsePolicy(PolicyClientTest* test, gconstpointer) +{ + test->m_policyDecisionTypeFilter = WEBKIT_POLICY_DECISION_TYPE_RESPONSE; + + test->m_policyDecisionResponse = PolicyClientTest::Use; + test->loadURI(kServer->getURIForPath("/").data()); + test->waitUntilLoadFinished(); + g_assert_cmpint(test->m_loadEvents.size(), ==, 3); + g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted); + g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted); + g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished); + + test->m_respondToPolicyDecisionAsynchronously = true; + test->loadURI(kServer->getURIForPath("/").data()); + test->waitUntilLoadFinished(); + g_assert_cmpint(test->m_loadEvents.size(), ==, 3); + g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted); + g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::LoadCommitted); + g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished); + + test->m_respondToPolicyDecisionAsynchronously = false; + test->m_policyDecisionResponse = PolicyClientTest::Ignore; + test->loadURI(kServer->getURIForPath("/").data()); + test->waitUntilLoadFinished(); + + g_assert_cmpint(test->m_loadEvents.size(), ==, 3); + g_assert_cmpint(test->m_loadEvents[0], ==, LoadTrackingTest::ProvisionalLoadStarted); + g_assert_cmpint(test->m_loadEvents[1], ==, LoadTrackingTest::ProvisionalLoadFailed); + g_assert_cmpint(test->m_loadEvents[2], ==, LoadTrackingTest::LoadFinished); +} + struct CreateCallbackData { bool triedToOpenWindow; GMainLoop* mainLoop; @@ -191,12 +225,31 @@ static void testNewWindowPolicy(PolicyClientTest* test, gconstpointer) g_assert(!data.triedToOpenWindow); } +static void serverCallback(SoupServer* server, SoupMessage* message, const char* path, GHashTable*, SoupClientContext*, gpointer) +{ + if (message->method != SOUP_METHOD_GET) { + soup_message_set_status(message, SOUP_STATUS_NOT_IMPLEMENTED); + return; + } + + soup_message_set_status(message, SOUP_STATUS_OK); + + static const char* responseString = "<html><body>Testing!</body></html>"; + soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, responseString, strlen(responseString)); + soup_message_body_complete(message->response_body); +} + void beforeAll() { + kServer = new WebKitTestServer(); + kServer->run(serverCallback); + PolicyClientTest::add("WebKitPolicyClient", "navigation-policy", testNavigationPolicy); + PolicyClientTest::add("WebKitPolicyClient", "response-policy", testResponsePolicy); PolicyClientTest::add("WebKitPolicyClient", "new-window-policy", testNewWindowPolicy); } void afterAll() { + delete kServer; } diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp index cce7e1fe7..0ecea5604 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitSettings.cpp @@ -189,6 +189,11 @@ static void testWebKitSettings(Test*, gconstpointer) webkit_settings_set_print_backgrounds(settings, FALSE); g_assert(!webkit_settings_get_print_backgrounds(settings)); + // WebAudio is disabled by default. + g_assert(!webkit_settings_get_enable_webaudio(settings)); + webkit_settings_set_enable_webaudio(settings, TRUE); + g_assert(webkit_settings_get_enable_webaudio(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 16375ed20..3d59ee917 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebKitWebView.cpp @@ -26,6 +26,10 @@ static void testWebViewDefaultContext(WebViewTest* test, gconstpointer) { g_assert(webkit_web_view_get_context(test->m_webView) == webkit_web_context_get_default()); + + // Check that a web view created with g_object_new has the default context. + GRefPtr<WebKitWebView> webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW, NULL)); + g_assert(webkit_web_view_get_context(webView.get()) == webkit_web_context_get_default()); } static void testWebViewCustomCharset(WebViewTest* test, gconstpointer) diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/TestWebViewEditor.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebViewEditor.cpp new file mode 100644 index 000000000..644584a3e --- /dev/null +++ b/Source/WebKit2/UIProcess/API/gtk/tests/TestWebViewEditor.cpp @@ -0,0 +1,142 @@ +/* + * 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 <wtf/gobject/GRefPtr.h> + +class EditorTest: public WebViewTest { +public: + MAKE_GLIB_TEST_FIXTURE(EditorTest); + + static const unsigned int kClipboardWaitTimeout = 50; + static const unsigned int kClipboardWaitMaxTries = 2; + + EditorTest() + : m_clipboard(gtk_clipboard_get(GDK_SELECTION_CLIPBOARD)) + , m_canExecuteEditingCommand(false) + , m_triesCount(0) + { + gtk_clipboard_clear(m_clipboard); + } + + static void canExecuteEditingCommandReadyCallback(GObject*, GAsyncResult* result, EditorTest* test) + { + GOwnPtr<GError> error; + test->m_canExecuteEditingCommand = webkit_web_view_can_execute_editing_command_finish(test->m_webView, result, &error.outPtr()); + g_assert(!error.get()); + g_main_loop_quit(test->m_mainLoop); + } + + bool canExecuteEditingCommand(const char* command) + { + m_canExecuteEditingCommand = false; + webkit_web_view_can_execute_editing_command(m_webView, command, reinterpret_cast<GAsyncReadyCallback>(canExecuteEditingCommandReadyCallback), this); + g_main_loop_run(m_mainLoop); + return m_canExecuteEditingCommand; + } + + static gboolean waitForClipboardText(EditorTest* test) + { + test->m_triesCount++; + if (gtk_clipboard_wait_is_text_available(test->m_clipboard) || test->m_triesCount > kClipboardWaitMaxTries) { + g_main_loop_quit(test->m_mainLoop); + return FALSE; + } + + return TRUE; + } + + void copyClipboard() + { + webkit_web_view_execute_editing_command(m_webView, WEBKIT_EDITING_COMMAND_COPY); + // There's no way to know when the selection has been copied to + // the clipboard, so use a timeout source to query the clipboard. + m_triesCount = 0; + g_timeout_add(kClipboardWaitTimeout, reinterpret_cast<GSourceFunc>(waitForClipboardText), this); + g_main_loop_run(m_mainLoop); + } + + GtkClipboard* m_clipboard; + bool m_canExecuteEditingCommand; + size_t m_triesCount; +}; + +static void testWebViewEditorCutCopyPasteNonEditable(EditorTest* test, gconstpointer) +{ + static const char* selectedSpanHTML = "<html><body contentEditable=\"false\">" + "<span id=\"mainspan\">All work and no play <span id=\"subspan\">make Jack a dull</span> boy.</span>" + "<script>document.getSelection().collapse();\n" + "document.getSelection().selectAllChildren(document.getElementById('subspan'));\n" + "</script></body></html>"; + + // Nothing loaded yet. + g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT)); + g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY)); + g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE)); + + test->loadHtml(selectedSpanHTML, 0); + test->waitUntilLoadFinished(); + + g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY)); + // It's not possible to cut and paste when content is not editable + // even if there's a selection. + g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT)); + g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE)); + + test->copyClipboard(); + GOwnPtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard)); + g_assert_cmpstr(clipboardText.get(), ==, "make Jack a dull"); +} + +static void testWebViewEditorCutCopyPasteEditable(EditorTest* test, gconstpointer) +{ + static const char* selectedSpanHTML = "<html><body contentEditable=\"true\">" + "<span id=\"mainspan\">All work and no play <span>make Jack a dull</span> boy.</span>" + "<script>document.getSelection().collapse();\n" + "document.getSelection().selectAllChildren(document.getElementById('mainspan'));\n" + "</script></body></html>"; + + // Nothing loaded yet. + g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT)); + g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY)); + g_assert(!test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE)); + + test->loadHtml(selectedSpanHTML, 0); + test->waitUntilLoadFinished(); + + // There's a selection. + g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_CUT)); + g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_COPY)); + g_assert(test->canExecuteEditingCommand(WEBKIT_EDITING_COMMAND_PASTE)); + + test->copyClipboard(); + GOwnPtr<char> clipboardText(gtk_clipboard_wait_for_text(test->m_clipboard)); + g_assert_cmpstr(clipboardText.get(), ==, "All work and no play make Jack a dull boy."); +} + +void beforeAll() +{ + EditorTest::add("WebKitWebView", "cut-copy-paste/non-editable", testWebViewEditorCutCopyPasteNonEditable); + EditorTest::add("WebKitWebView", "cut-copy-paste/editable", testWebViewEditorCutCopyPasteEditable); +} + +void afterAll() +{ +} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp index 099eabda5..20895eccb 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp +++ b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.cpp @@ -116,3 +116,17 @@ void WebViewTest::wait(double seconds) g_timeout_add_seconds(seconds, reinterpret_cast<GSourceFunc>(testLoadTimeoutFinishLoop), m_mainLoop); g_main_loop_run(m_mainLoop); } + +static void loadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent, WebViewTest* test) +{ + if (loadEvent != WEBKIT_LOAD_FINISHED) + return; + g_signal_handlers_disconnect_by_func(webView, reinterpret_cast<void*>(loadChanged), test); + g_main_loop_quit(test->m_mainLoop); +} + +void WebViewTest::waitUntilLoadFinished() +{ + g_signal_connect(m_webView, "load-changed", G_CALLBACK(loadChanged), this); + g_main_loop_run(m_mainLoop); +} diff --git a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h index 882e8b224..4ad6fa648 100644 --- a/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h +++ b/Source/WebKit2/UIProcess/API/gtk/tests/WebViewTest.h @@ -41,6 +41,7 @@ public: void goToBackForwardListItem(WebKitBackForwardListItem*); void wait(double seconds); + void waitUntilLoadFinished(); WebKitWebView* m_webView; GMainLoop* m_mainLoop; diff --git a/Source/WebKit2/UIProcess/API/gtk/webkit2.h b/Source/WebKit2/UIProcess/API/gtk/webkit2.h index e9d892b54..78e53d508 100644 --- a/Source/WebKit2/UIProcess/API/gtk/webkit2.h +++ b/Source/WebKit2/UIProcess/API/gtk/webkit2.h @@ -27,6 +27,7 @@ #include <webkit2/WebKitBackForwardListItem.h> #include <webkit2/WebKitDefines.h> #include <webkit2/WebKitDownload.h> +#include <webkit2/WebKitEditingCommands.h> #include <webkit2/WebKitEnumTypes.h> #include <webkit2/WebKitError.h> #include <webkit2/WebKitSettings.h> diff --git a/Source/WebKit2/UIProcess/API/mac/WKView.mm b/Source/WebKit2/UIProcess/API/mac/WKView.mm index 7d21e9b7f..728f0e56f 100644 --- a/Source/WebKit2/UIProcess/API/mac/WKView.mm +++ b/Source/WebKit2/UIProcess/API/mac/WKView.mm @@ -1709,7 +1709,7 @@ static bool maybeCreateSandboxExtensionFromPasteboard(NSPasteboard *pasteboard, - (void)_updateWindowVisibility { - _data->_page->updateWindowIsVisible(![[self window] isMiniaturized]); + _data->_page->updateWindowIsVisible([[self window] isVisible]); } - (BOOL)_ownsWindowGrowBox @@ -1924,6 +1924,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl // we hide it first and then update the active state. _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible); _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive); + [self _updateWindowVisibility]; } - (void)_windowDidOrderOnScreen:(NSNotification *)notification @@ -1932,6 +1933,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl // we update the active state first and then make it visible. _data->_page->viewStateDidChange(WebPageProxy::ViewWindowIsActive); _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible); + [self _updateWindowVisibility]; } - (void)_windowDidChangeBackingProperties:(NSNotification *)notification @@ -2279,12 +2281,12 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I - (NSRect)_convertToDeviceSpace:(NSRect)rect { - return toDeviceSpace(rect, [self window], _data->_page->deviceScaleFactor()); + return toDeviceSpace(rect, [self window]); } - (NSRect)_convertToUserSpace:(NSRect)rect { - return toUserSpace(rect, [self window], _data->_page->deviceScaleFactor()); + return toUserSpace(rect, [self window]); } // Any non-zero value will do, but using something recognizable might help us debug some day. @@ -2734,6 +2736,7 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I _data->_pageClient = PageClientImpl::create(self); _data->_page = toImpl(contextRef)->createWebPage(_data->_pageClient.get(), toImpl(pageGroupRef)); _data->_page->initializeWebPage(); + _data->_page->setIntrinsicDeviceScaleFactor([self _intrinsicDeviceScaleFactor]); #if ENABLE(FULLSCREEN_API) _data->_page->fullScreenManager()->setWebView(self); #endif diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp index 206ba2522..22c6703c4 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp @@ -46,31 +46,13 @@ QQuickWebPage::~QQuickWebPage() delete d; } -QtSGUpdateQueue *QQuickWebPage::sceneGraphUpdateQueue() const -{ - return &d->sgUpdateQueue; -} - -void QQuickWebPage::geometryChanged(const QRectF& newGeometry, const QRectF& oldGeometry) -{ - QQuickItem::geometryChanged(newGeometry, oldGeometry); - - if (!d->useTraditionalDesktopBehaviour) - return; - - if (newGeometry.size() != oldGeometry.size()) - d->setDrawingAreaSize(newGeometry.size().toSize()); -} - QQuickWebPagePrivate::QQuickWebPagePrivate(QQuickWebPage* q, QQuickWebView* viewportItem) : q(q) , viewportItem(viewportItem) , webPageProxy(0) - , sgUpdateQueue(q) , paintingIsInitialized(false) , m_paintNode(0) - , contentScale(1) - , useTraditionalDesktopBehaviour(false) + , contentsScale(1) { } @@ -112,7 +94,7 @@ void QQuickWebPagePrivate::paintToCurrentGLContext() return; QTransform transform = q->itemTransform(0, 0); - transform.scale(contentScale, contentScale); + transform.scale(contentsScale, contentsScale); float opacity = computeEffectiveOpacity(q); QRectF clipRect = q->parentItem()->mapRectToScene(q->parentItem()->boundingRect()); @@ -220,47 +202,37 @@ QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) return proxyNode; } -bool QQuickWebPage::usesTraditionalDesktopBehaviour() const -{ - return d->useTraditionalDesktopBehaviour; -} - -void QQuickWebPage::setUsesTraditionalDesktopBehaviour(bool enable) -{ - d->useTraditionalDesktopBehaviour = enable; -} - QtWebPageEventHandler* QQuickWebPage::eventHandler() const { return d->eventHandler.data(); } -void QQuickWebPage::setContentSize(const QSizeF& size) +void QQuickWebPage::setContentsSize(const QSizeF& size) { - if (size.isEmpty() || d->contentSize == size) + if (size.isEmpty() || d->contentsSize == size) return; - d->contentSize = size; + d->contentsSize = size; d->updateSize(); - d->setDrawingAreaSize(d->contentSize.toSize()); + d->setDrawingAreaSize(d->contentsSize.toSize()); } -const QSizeF& QQuickWebPage::contentSize() const +const QSizeF& QQuickWebPage::contentsSize() const { - return d->contentSize; + return d->contentsSize; } -void QQuickWebPage::setContentScale(qreal scale) +void QQuickWebPage::setContentsScale(qreal scale) { ASSERT(scale > 0); - d->contentScale = scale; + d->contentsScale = scale; d->updateSize(); } -qreal QQuickWebPage::contentScale() const +qreal QQuickWebPage::contentsScale() const { - ASSERT(d->contentScale > 0); - return d->contentScale; + ASSERT(d->contentsScale > 0); + return d->contentsScale; } QTransform QQuickWebPage::transformFromItem() const @@ -270,12 +242,12 @@ QTransform QQuickWebPage::transformFromItem() const QTransform QQuickWebPage::transformToItem() const { - return QTransform(d->contentScale, 0, 0, 0, d->contentScale, 0, x(), y(), 1); + return QTransform(d->contentsScale, 0, 0, 0, d->contentsScale, 0, x(), y(), 1); } void QQuickWebPagePrivate::updateSize() { - QSizeF scaledSize = contentSize * contentScale; + QSizeF scaledSize = contentsSize * contentsScale; q->setSize(scaledSize); } diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h index bf44b9dc7..9d791ac25 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h @@ -31,34 +31,23 @@ class QQuickWebView; class QtWebPageEventHandler; class QWebPreferences; -namespace WebKit { -class QtSGUpdateQueue; -} - class QWEBKIT_EXPORT QQuickWebPage : public QQuickItem { Q_OBJECT public: QQuickWebPage(QQuickWebView* view = 0); virtual ~QQuickWebPage(); - void setContentSize(const QSizeF& size); - const QSizeF& contentSize() const; - void setContentScale(qreal); - qreal contentScale() const; + void setContentsSize(const QSizeF& size); + const QSizeF& contentsSize() const; + void setContentsScale(qreal); + qreal contentsScale() const; QTransform transformFromItem() const; QTransform transformToItem() const; - bool usesTraditionalDesktopBehaviour() const; - void setUsesTraditionalDesktopBehaviour(bool enable); - QtWebPageEventHandler* eventHandler() const; - // Internal. To be removed soon. - WebKit::QtSGUpdateQueue* sceneGraphUpdateQueue() const; - protected: - virtual void geometryChanged(const QRectF&, const QRectF&); virtual QSGNode* updatePaintNode(QSGNode*, UpdatePaintNodeData*); private: diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h index 0c17aa5b5..dfd223dbe 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h @@ -21,7 +21,6 @@ #ifndef qquickwebpage_p_p_h #define qquickwebpage_p_p_h -#include "QtSGUpdateQueue.h" #include "qquickwebpage_p.h" #include <QTransform> @@ -50,13 +49,11 @@ public: QQuickWebPage* const q; QQuickWebView* const viewportItem; WebKit::WebPageProxy* webPageProxy; - WebKit::QtSGUpdateQueue sgUpdateQueue; bool paintingIsInitialized; QSGNode* m_paintNode; - QSizeF contentSize; - qreal contentScale; - bool useTraditionalDesktopBehaviour; + QSizeF contentsSize; + qreal contentsScale; }; #endif // qquickwebpage_p_p_h diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp index 5712ca593..7ea6d347c 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview.cpp @@ -55,6 +55,15 @@ using namespace WebCore; +static bool s_flickableViewportEnabled = true; + +static QQuickWebViewPrivate* createPrivateObject(QQuickWebView* publicObject) +{ + if (s_flickableViewportEnabled) + return new QQuickWebViewFlickablePrivate(publicObject); + return new QQuickWebViewLegacyPrivate(publicObject); +} + QQuickWebViewPrivate::QQuickWebViewPrivate(QQuickWebView* viewport) : q_ptr(viewport) , alertDialog(0) @@ -63,9 +72,6 @@ QQuickWebViewPrivate::QQuickWebViewPrivate(QQuickWebView* viewport) , authenticationDialog(0) , certificateVerificationDialog(0) , itemSelector(0) - , postTransitionState(adoptPtr(new PostTransitionState(this))) - , isTransitioningToNewPage(false) - , pageIsSuspended(false) , m_navigatorQtObjectEnabled(false) , m_renderToOffscreenBuffer(false) { @@ -76,8 +82,6 @@ QQuickWebViewPrivate::QQuickWebViewPrivate(QQuickWebView* viewport) QQuickWebViewPrivate::~QQuickWebViewPrivate() { - if (interactionEngine) - interactionEngine->disconnect(); webPageProxy->close(); } @@ -106,15 +110,11 @@ void QQuickWebViewPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pa QObject::connect(q_ptr, SIGNAL(urlChanged(QUrl)), iconDatabase, SLOT(requestIconForPageURL(QUrl))); // Any page setting should preferrable be set before creating the page. - setUseTraditionalDesktopBehaviour(false); webPageProxy->pageGroup()->preferences()->setAcceleratedCompositingEnabled(true); webPageProxy->pageGroup()->preferences()->setForceCompositingMode(true); pageClient.initialize(q_ptr, pageViewPrivate->eventHandler.data(), &undoController); webPageProxy->initializeWebPage(); - - // Trigger setting of correct visibility flags after everything was allocated and initialized. - _q_onVisibleChanged(); } void QQuickWebViewPrivate::enableMouseEvents() @@ -131,30 +131,11 @@ void QQuickWebViewPrivate::disableMouseEvents() q->setAcceptHoverEvents(false); } -void QQuickWebViewPrivate::initializeDesktop(QQuickWebView* viewport) -{ - if (interactionEngine) { - QObject::disconnect(interactionEngine.data(), SIGNAL(contentSuspendRequested()), viewport, SLOT(_q_suspend())); - QObject::disconnect(interactionEngine.data(), SIGNAL(contentResumeRequested()), viewport, SLOT(_q_resume())); - QObject::disconnect(interactionEngine.data(), SIGNAL(viewportTrajectoryVectorChanged(const QPointF&)), viewport, SLOT(_q_viewportTrajectoryVectorChanged(const QPointF&))); - QObject::disconnect(interactionEngine.data(), SIGNAL(visibleContentRectAndScaleChanged()), viewport, SLOT(_q_updateVisibleContentRectAndScale())); - } - interactionEngine.reset(0); - pageView->d->eventHandler->setViewportInteractionEngine(0); - enableMouseEvents(); - updateDesktopViewportSize(); -} - -void QQuickWebViewPrivate::initializeTouch(QQuickWebView* viewport) +void QQuickWebViewPrivate::loadDidSucceed() { - interactionEngine.reset(new QtViewportInteractionEngine(viewport, pageView.data())); - pageView->d->eventHandler->setViewportInteractionEngine(interactionEngine.data()); - disableMouseEvents(); - QObject::connect(interactionEngine.data(), SIGNAL(contentSuspendRequested()), viewport, SLOT(_q_suspend())); - QObject::connect(interactionEngine.data(), SIGNAL(contentResumeRequested()), viewport, SLOT(_q_resume())); - QObject::connect(interactionEngine.data(), SIGNAL(viewportTrajectoryVectorChanged(const QPointF&)), viewport, SLOT(_q_viewportTrajectoryVectorChanged(const QPointF&))); - QObject::connect(interactionEngine.data(), SIGNAL(visibleContentRectAndScaleChanged()), viewport, SLOT(_q_updateVisibleContentRectAndScale())); - updateTouchViewportSize(); + Q_Q(QQuickWebView); + emit q->navigationStateChanged(); + emit q->loadSucceeded(); } void QQuickWebViewPrivate::setNeedsDisplay() @@ -171,28 +152,6 @@ void QQuickWebViewPrivate::setNeedsDisplay() q->page()->update(); } -void QQuickWebViewPrivate::loadDidCommit() -{ - // Due to entering provisional load before committing, we - // might actually be suspended here. - - if (pageView->usesTraditionalDesktopBehaviour()) - return; - - isTransitioningToNewPage = true; -} - -void QQuickWebViewPrivate::didFinishFirstNonEmptyLayout() -{ - if (pageView->usesTraditionalDesktopBehaviour()) - return; - - if (!pageIsSuspended) { - isTransitioningToNewPage = false; - postTransitionState->apply(); - } -} - void QQuickWebViewPrivate::_q_onIconChangedForPageURL(const QUrl& pageURL, const QUrl& iconURL) { Q_Q(QQuickWebView); @@ -202,74 +161,15 @@ void QQuickWebViewPrivate::_q_onIconChangedForPageURL(const QUrl& pageURL, const setIcon(iconURL); } -void QQuickWebViewPrivate::_q_suspend() -{ - pageIsSuspended = true; -} - -void QQuickWebViewPrivate::_q_resume() -{ - pageIsSuspended = false; - - if (isTransitioningToNewPage) { - isTransitioningToNewPage = false; - postTransitionState->apply(); - } - - _q_updateVisibleContentRectAndScale(); -} - -void QQuickWebViewPrivate::didChangeContentsSize(const QSize& newSize) -{ - Q_Q(QQuickWebView); - if (pageView->usesTraditionalDesktopBehaviour()) - return; - - // FIXME: We probably want to handle suspend here as well - if (isTransitioningToNewPage) { - postTransitionState->contentsSize = newSize; - return; - } - - pageView->setContentSize(newSize); - q->m_experimental->viewportInfo()->didUpdateContentsSize(); -} - -void QQuickWebViewPrivate::didChangeViewportProperties(const WebCore::ViewportArguments& args) -{ - if (pageView->usesTraditionalDesktopBehaviour()) - return; - - viewportArguments = args; - - if (isTransitioningToNewPage) - return; - - interactionEngine->applyConstraints(computeViewportConstraints()); -} - void QQuickWebViewPrivate::didChangeBackForwardList() { navigationHistory->d->reset(); } -void QQuickWebViewPrivate::pageDidRequestScroll(const QPoint& pos) -{ - if (pageView->usesTraditionalDesktopBehaviour()) - return; - - if (isTransitioningToNewPage) { - postTransitionState->position = pos; - return; - } - - interactionEngine->pagePositionRequest(pos); -} - void QQuickWebViewPrivate::processDidCrash() { emit q_ptr->navigationStateChanged(); - pageView->d->eventHandler->resetGestureRecognizers(); + pageView->eventHandler()->resetGestureRecognizers(); WebCore::KURL url(WebCore::ParsedURLString, webPageProxy->urlAtProcessExit()); qWarning("WARNING: The web process experienced a crash on '%s'.", qPrintable(QUrl(url).toString(QUrl::RemoveUserInfo))); } @@ -300,24 +200,6 @@ void QQuickWebViewPrivate::handleDownloadRequest(DownloadProxy* download) context->downloadManager()->addDownload(download, downloadItem); } -void QQuickWebViewPrivate::_q_updateVisibleContentRectAndScale() -{ - DrawingAreaProxy* drawingArea = webPageProxy->drawingArea(); - if (!drawingArea) - return; - - Q_Q(QQuickWebView); - const QRectF visibleRectInCSSCoordinates = q->mapRectToWebContent(q->boundingRect()).intersected(pageView->boundingRect()); - float scale = pageView->contentScale(); - - QRect alignedVisibleContentRect = visibleRectInCSSCoordinates.toAlignedRect(); - drawingArea->setVisibleContentsRectAndScale(alignedVisibleContentRect, scale); - - // 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->m_experimental->viewportInfo()->didUpdateCurrentScale(); -} - void QQuickWebViewPrivate::_q_viewportTrajectoryVectorChanged(const QPointF& trajectoryVector) { DrawingAreaProxy* drawingArea = webPageProxy->drawingArea(); @@ -342,85 +224,6 @@ void QQuickWebViewPrivate::_q_onReceivedResponseFromDownload(QWebDownloadItem* d emit q->experimental()->downloadRequested(downloadItem); } -void QQuickWebViewPrivate::updateDesktopViewportSize() -{ - Q_Q(QQuickWebView); - QSize viewportSize = q->boundingRect().size().toSize(); - pageView->setWidth(viewportSize.width()); - pageView->setHeight(viewportSize.height()); - // The fixed layout is handled by the FrameView and the drawing area doesn't behave differently - // wether 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); -} - -void QQuickWebViewPrivate::updateTouchViewportSize() -{ - Q_Q(QQuickWebView); - QSize viewportSize = q->boundingRect().size().toSize(); - - if (viewportSize.isEmpty()) - return; - - // 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(); -} - -void QQuickWebViewPrivate::PostTransitionState::apply() -{ - p->interactionEngine->reset(); - p->interactionEngine->applyConstraints(p->computeViewportConstraints()); - p->interactionEngine->pagePositionRequest(position); - - if (contentsSize.isValid()) { - p->pageView->setContentSize(contentsSize); - p->q_ptr->experimental()->viewportInfo()->didUpdateContentsSize(); - } - - position = QPoint(); - contentsSize = QSize(); -} - -QtViewportInteractionEngine::Constraints QQuickWebViewPrivate::computeViewportConstraints() -{ - Q_Q(QQuickWebView); - - QtViewportInteractionEngine::Constraints newConstraints; - QSize availableSize = q->boundingRect().size().toSize(); - - // Return default values for zero sized viewport. - if (availableSize.isEmpty()) - return newConstraints; - - WebPreferences* wkPrefs = webPageProxy->pageGroup()->preferences(); - - // FIXME: Remove later; Hardcode some values for now to make sure the DPI adjustment is being tested. - wkPrefs->setDeviceDPI(240); - wkPrefs->setDeviceWidth(480); - wkPrefs->setDeviceHeight(720); - - int minimumLayoutFallbackWidth = qMax<int>(wkPrefs->layoutFallbackWidth(), availableSize.width()); - - WebCore::ViewportAttributes attr = WebCore::computeViewportAttributes(viewportArguments, minimumLayoutFallbackWidth, wkPrefs->deviceWidth(), wkPrefs->deviceHeight(), wkPrefs->deviceDPI(), availableSize); - WebCore::restrictMinimumScaleFactorToViewportSize(attr, availableSize); - WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attr); - - newConstraints.initialScale = attr.initialScale; - newConstraints.minimumScale = attr.minimumScale; - newConstraints.maximumScale = attr.maximumScale; - newConstraints.devicePixelRatio = attr.devicePixelRatio; - newConstraints.isUserScalable = !!attr.userScalable; - newConstraints.layoutSize = attr.layoutSize; - - q->m_experimental->viewportInfo()->didUpdateViewportConstraints(); - - return newConstraints; -} - void QQuickWebViewPrivate::runJavaScriptAlert(const QString& alertText) { if (!alertDialog) @@ -565,20 +368,6 @@ void QQuickWebViewPrivate::_q_onOpenPanelFinished(int result) fileDialog = 0; } -void QQuickWebViewPrivate::setUseTraditionalDesktopBehaviour(bool enable) -{ - Q_Q(QQuickWebView); - - // Do not guard, testing for the same value, as we call this from the constructor. - - webPageProxy->setUseFixedLayout(!enable); - pageView->setUsesTraditionalDesktopBehaviour(enable); - if (enable) - initializeDesktop(q); - else - initializeTouch(q); -} - void QQuickWebViewPrivate::setViewInAttachedProperties(QObject* object) { Q_Q(QQuickWebView); @@ -634,6 +423,236 @@ void QQuickWebViewPrivate::didReceiveMessageFromNavigatorQtObject(const String& emit q_ptr->experimental()->messageReceived(variantMap); } +QQuickWebViewLegacyPrivate::QQuickWebViewLegacyPrivate(QQuickWebView* viewport) + : QQuickWebViewPrivate(viewport) +{ +} + +void QQuickWebViewLegacyPrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef) +{ + QQuickWebViewPrivate::initialize(contextRef, pageGroupRef); + enableMouseEvents(); + + // Trigger setting of correct visibility flags after everything was allocated and initialized. + _q_onVisibleChanged(); +} + +void QQuickWebViewLegacyPrivate::updateViewportSize() +{ + Q_Q(QQuickWebView); + QSize viewportSize = q->boundingRect().size().toSize(); + pageView->setContentsSize(viewportSize); + // 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); +} + +QQuickWebViewFlickablePrivate::QQuickWebViewFlickablePrivate(QQuickWebView* viewport) + : QQuickWebViewPrivate(viewport) + , postTransitionState(adoptPtr(new PostTransitionState(this))) + , isTransitioningToNewPage(false) + , pageIsSuspended(true) + , loadSuccessDispatchIsPending(false) +{ +} + +QQuickWebViewFlickablePrivate::~QQuickWebViewFlickablePrivate() +{ + interactionEngine->disconnect(); +} + +void QQuickWebViewFlickablePrivate::initialize(WKContextRef contextRef, WKPageGroupRef pageGroupRef) +{ + QQuickWebViewPrivate::initialize(contextRef, pageGroupRef); + webPageProxy->setUseFixedLayout(true); +} + +void QQuickWebViewFlickablePrivate::onComponentComplete() +{ + Q_Q(QQuickWebView); + interactionEngine.reset(new QtViewportInteractionEngine(q, pageView.data())); + 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())); + + _q_resume(); + + if (loadSuccessDispatchIsPending) { + QQuickWebViewPrivate::loadDidSucceed(); + loadSuccessDispatchIsPending = false; + } + + // Trigger setting of correct visibility flags after everything was allocated and initialized. + _q_onVisibleChanged(); +} + +void QQuickWebViewFlickablePrivate::loadDidSucceed() +{ + if (interactionEngine) + QQuickWebViewPrivate::loadDidSucceed(); + else + loadSuccessDispatchIsPending = true; + +} + +void QQuickWebViewFlickablePrivate::loadDidCommit() +{ + // Due to entering provisional load before committing, we + // might actually be suspended here. + + isTransitioningToNewPage = true; +} + +void QQuickWebViewFlickablePrivate::didFinishFirstNonEmptyLayout() +{ + if (!pageIsSuspended) { + isTransitioningToNewPage = false; + postTransitionState->apply(); + } +} + +void QQuickWebViewFlickablePrivate::didChangeViewportProperties(const WebCore::ViewportArguments& args) +{ + viewportArguments = args; + + if (isTransitioningToNewPage) + return; + + interactionEngine->applyConstraints(computeViewportConstraints()); +} + +void QQuickWebViewFlickablePrivate::updateViewportSize() +{ + Q_Q(QQuickWebView); + QSize viewportSize = q->boundingRect().size().toSize(); + + if (viewportSize.isEmpty() || !interactionEngine) + return; + + // 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(); +} + +void QQuickWebViewFlickablePrivate::_q_updateVisibleContentRectAndScale() +{ + DrawingAreaProxy* drawingArea = webPageProxy->drawingArea(); + if (!drawingArea) + return; + + Q_Q(QQuickWebView); + const QRectF visibleRectInCSSCoordinates = q->mapRectToWebContent(q->boundingRect()).intersected(pageView->boundingRect()); + float scale = pageView->contentsScale(); + + QRect alignedVisibleContentRect = visibleRectInCSSCoordinates.toAlignedRect(); + drawingArea->setVisibleContentsRectAndScale(alignedVisibleContentRect, scale); + + // 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() +{ + pageIsSuspended = true; +} + +void QQuickWebViewFlickablePrivate::_q_resume() +{ + if (!interactionEngine) + return; + + pageIsSuspended = false; + + if (isTransitioningToNewPage) { + isTransitioningToNewPage = false; + postTransitionState->apply(); + } + + _q_updateVisibleContentRectAndScale(); +} + +void QQuickWebViewFlickablePrivate::pageDidRequestScroll(const QPoint& pos) +{ + if (isTransitioningToNewPage) { + postTransitionState->position = pos; + return; + } + + interactionEngine->pagePositionRequest(pos); +} + +void QQuickWebViewFlickablePrivate::didChangeContentsSize(const QSize& newSize) +{ + Q_Q(QQuickWebView); + // FIXME: We probably want to handle suspend here as well + if (isTransitioningToNewPage) { + postTransitionState->contentsSize = newSize; + return; + } + + pageView->setContentsSize(newSize); + q->experimental()->viewportInfo()->didUpdateContentsSize(); +} + +QtViewportInteractionEngine::Constraints QQuickWebViewFlickablePrivate::computeViewportConstraints() +{ + Q_Q(QQuickWebView); + + QtViewportInteractionEngine::Constraints newConstraints; + QSize availableSize = q->boundingRect().size().toSize(); + + // Return default values for zero sized viewport. + if (availableSize.isEmpty()) + return newConstraints; + + WebPreferences* wkPrefs = webPageProxy->pageGroup()->preferences(); + + // FIXME: Remove later; Hardcode some values for now to make sure the DPI adjustment is being tested. + wkPrefs->setDeviceDPI(240); + wkPrefs->setDeviceWidth(480); + wkPrefs->setDeviceHeight(720); + + int minimumLayoutFallbackWidth = qMax<int>(wkPrefs->layoutFallbackWidth(), availableSize.width()); + + WebCore::ViewportAttributes attr = WebCore::computeViewportAttributes(viewportArguments, minimumLayoutFallbackWidth, wkPrefs->deviceWidth(), wkPrefs->deviceHeight(), wkPrefs->deviceDPI(), availableSize); + WebCore::restrictMinimumScaleFactorToViewportSize(attr, availableSize); + WebCore::restrictScaleFactorToInitialScaleIfNotUserScalable(attr); + + newConstraints.initialScale = attr.initialScale; + newConstraints.minimumScale = attr.minimumScale; + newConstraints.maximumScale = attr.maximumScale; + newConstraints.devicePixelRatio = attr.devicePixelRatio; + newConstraints.isUserScalable = !!attr.userScalable; + newConstraints.layoutSize = attr.layoutSize; + + q->experimental()->viewportInfo()->didUpdateViewportConstraints(); + + return newConstraints; +} + +void QQuickWebViewFlickablePrivate::PostTransitionState::apply() +{ + p->interactionEngine->reset(); + p->interactionEngine->applyConstraints(p->computeViewportConstraints()); + p->interactionEngine->pagePositionRequest(position); + + if (contentsSize.isValid()) { + p->pageView->setContentsSize(contentsSize); + p->q_ptr->experimental()->viewportInfo()->didUpdateContentsSize(); + } + + position = QPoint(); + contentsSize = QSize(); +} + /*! \qmlsignal WebView::onNavigationRequested(request) @@ -674,16 +693,6 @@ QQuickWebViewExperimental::~QQuickWebViewExperimental() { } -void QQuickWebViewExperimental::setUseTraditionalDesktopBehaviour(bool enable) -{ - Q_D(QQuickWebView); - - if (enable == d->pageView->usesTraditionalDesktopBehaviour()) - return; - - d->setUseTraditionalDesktopBehaviour(enable); -} - void QQuickWebViewExperimental::setRenderToOffscreenBuffer(bool enable) { Q_D(QQuickWebView); @@ -696,6 +705,16 @@ bool QQuickWebViewExperimental::renderToOffscreenBuffer() const return d->renderToOffscreenBuffer(); } +void QQuickWebViewExperimental::setFlickableViewportEnabled(bool enable) +{ + s_flickableViewportEnabled = enable; +} + +bool QQuickWebViewExperimental::flickableViewportEnabled() +{ + return s_flickableViewportEnabled; +} + void QQuickWebViewExperimental::postMessage(const QString& message) { Q_D(QQuickWebView); @@ -805,12 +824,6 @@ void QQuickWebViewExperimental::setItemSelector(QDeclarativeComponent* itemSelec emit itemSelectorChanged(); } -bool QQuickWebViewExperimental::useTraditionalDesktopBehaviour() const -{ - Q_D(const QQuickWebView); - return d->pageView->usesTraditionalDesktopBehaviour(); -} - QQuickUrlSchemeDelegate* QQuickWebViewExperimental::schemeDelegates_At(QDeclarativeListProperty<QQuickUrlSchemeDelegate>* property, int index) { const QObjectList children = property->object->children(); @@ -899,7 +912,7 @@ QQuickWebPage* QQuickWebViewExperimental::page() QQuickWebView::QQuickWebView(QQuickItem* parent) : QQuickItem(parent) - , d_ptr(new QQuickWebViewPrivate(this)) + , d_ptr(createPrivateObject(this)) , m_experimental(new QQuickWebViewExperimental(this)) { Q_D(QQuickWebView); @@ -908,7 +921,7 @@ QQuickWebView::QQuickWebView(QQuickItem* parent) QQuickWebView::QQuickWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef, QQuickItem* parent) : QQuickItem(parent) - , d_ptr(new QQuickWebViewPrivate(this)) + , d_ptr(createPrivateObject(this)) , m_experimental(new QQuickWebViewExperimental(this)) { Q_D(QQuickWebView); @@ -1084,12 +1097,17 @@ void QQuickWebView::geometryChanged(const QRectF& newGeometry, const QRectF& old { Q_D(QQuickWebView); QQuickItem::geometryChanged(newGeometry, oldGeometry); - if (newGeometry.size() != oldGeometry.size()) { - if (d->pageView->usesTraditionalDesktopBehaviour()) - d->updateDesktopViewportSize(); - else - d->updateTouchViewportSize(); - } + if (newGeometry.size() != oldGeometry.size()) + d->updateViewportSize(); +} + +void QQuickWebView::componentComplete() +{ + Q_D(QQuickWebView); + QQuickItem::componentComplete(); + + d->onComponentComplete(); + d->updateViewportSize(); } void QQuickWebView::keyPressEvent(QKeyEvent* event) diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h index 7a713d133..69f1cd81b 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p.h @@ -60,6 +60,10 @@ class QPainter; class QUrl; QT_END_NAMESPACE + +// Instantiating the WebView in C++ is only possible by creating +// a QDeclarativeComponent as the initialization depends on the +// componentComplete method being called. class QWEBKIT_EXPORT QQuickWebView : public QQuickItem { Q_OBJECT Q_PROPERTY(QString title READ title NOTIFY titleChanged) @@ -135,7 +139,7 @@ Q_SIGNALS: protected: virtual void geometryChanged(const QRectF&, const QRectF&); - + virtual void componentComplete(); virtual void keyPressEvent(QKeyEvent*); virtual void keyReleaseEvent(QKeyEvent*); virtual void inputMethodEvent(QInputMethodEvent*); @@ -213,7 +217,6 @@ class QWEBKIT_EXPORT QQuickWebViewExperimental : public QObject { 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) - Q_PROPERTY(bool useTraditionalDesktopBehaviour READ useTraditionalDesktopBehaviour WRITE setUseTraditionalDesktopBehaviour) Q_PROPERTY(QWebViewportInfo* viewportInfo READ viewportInfo CONSTANT FINAL) Q_PROPERTY(QDeclarativeListProperty<QQuickUrlSchemeDelegate> urlSchemeDelegates READ schemeDelegates) Q_ENUMS(NavigationRequestAction) @@ -238,8 +241,6 @@ public: void setCertificateVerificationDialog(QDeclarativeComponent*); QDeclarativeComponent* itemSelector() const; void setItemSelector(QDeclarativeComponent*); - bool useTraditionalDesktopBehaviour() const; - void setUseTraditionalDesktopBehaviour(bool enable); QWebViewportInfo* viewportInfo(); @@ -258,6 +259,8 @@ public: // C++ only bool renderToOffscreenBuffer() const; void setRenderToOffscreenBuffer(bool enable); + static void setFlickableViewportEnabled(bool enable); + static bool flickableViewportEnabled(); public Q_SLOTS: void goBackTo(int index); diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h index 17a5cf82a..9e27ce322 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebview_p_p.h @@ -61,32 +61,29 @@ class QQuickWebViewPrivate { public: static QQuickWebViewPrivate* get(QQuickWebView* q) { return q->d_ptr.data(); } - QQuickWebViewPrivate(QQuickWebView* viewport); virtual ~QQuickWebViewPrivate(); - void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0); + virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0); - void initializeTouch(QQuickWebView* viewport); - void initializeDesktop(QQuickWebView* viewport); void enableMouseEvents(); void disableMouseEvents(); - void loadDidCommit(); - - void didFinishFirstNonEmptyLayout(); - void didChangeViewportProperties(const WebCore::ViewportArguments& args); + virtual void loadDidSucceed(); + virtual void onComponentComplete() { } + virtual void loadDidCommit() { } + virtual void didFinishFirstNonEmptyLayout() { } + virtual void didChangeViewportProperties(const WebCore::ViewportArguments& args) { } void didChangeBackForwardList(); void setNeedsDisplay(); - void updateDesktopViewportSize(); + virtual QtViewportInteractionEngine* viewportInteractionEngine() { return 0; } + virtual void updateViewportSize() { } void updateTouchViewportSize(); - QtViewportInteractionEngine::Constraints computeViewportConstraints(); - - void _q_updateVisibleContentRectAndScale(); + virtual void _q_updateVisibleContentRectAndScale() { } - void _q_suspend(); - void _q_resume(); + virtual void _q_suspend() { } + virtual void _q_resume() { } void _q_viewportTrajectoryVectorChanged(const QPointF&); void _q_onOpenPanelFilesSelected(); void _q_onOpenPanelFinished(int result); @@ -102,7 +99,6 @@ public: void handleAuthenticationRequiredRequest(const QString& hostname, const QString& realm, const QString& prefilledUsername, QString& username, QString& password); bool handleCertificateVerificationRequest(const QString& hostname); - void setUseTraditionalDesktopBehaviour(bool enable); void setRenderToOffscreenBuffer(bool enable) { m_renderToOffscreenBuffer = enable; } void setViewInAttachedProperties(QObject*); void setIcon(const QUrl&); @@ -114,30 +110,15 @@ public: // PageClient. WebCore::IntSize viewSize() const; void didReceiveMessageFromNavigatorQtObject(const String& message); - void pageDidRequestScroll(const QPoint& pos); - void didChangeContentsSize(const QSize& newSize); + virtual void pageDidRequestScroll(const QPoint& pos) { } + virtual void didChangeContentsSize(const QSize& newSize) { } void processDidCrash(); void didRelaunchProcess(); PassOwnPtr<DrawingAreaProxy> createDrawingAreaProxy(); void handleDownloadRequest(DownloadProxy*); -private: - // This class is responsible for collecting and applying all properties - // on the viewport item, when transitioning from page A to page B is finished. - // See more at https://trac.webkit.org/wiki/QtWebKitLayoutInteraction - class PostTransitionState { - public: - PostTransitionState(QQuickWebViewPrivate* parent) - : p(parent) - { } - - void apply(); - - QQuickWebViewPrivate* p; - QSize contentsSize; - QPoint position; - }; - +protected: + QQuickWebViewPrivate(QQuickWebView* viewport); RefPtr<QtWebContext> context; RefPtr<WebKit::WebPageProxy> webPageProxy; @@ -151,8 +132,6 @@ private: QScopedPointer<QtWebPageUIClient> pageUIClient; QScopedPointer<QQuickWebPage> pageView; - QScopedPointer<QtViewportInteractionEngine> interactionEngine; - QQuickWebView* q_ptr; QDeclarativeComponent* alertDialog; @@ -163,15 +142,68 @@ private: QDeclarativeComponent* itemSelector; WebCore::ViewportArguments viewportArguments; - OwnPtr<PostTransitionState> postTransitionState; QFileDialog* fileDialog; WKOpenPanelResultListenerRef openPanelResultListener; - bool isTransitioningToNewPage; - bool pageIsSuspended; bool m_navigatorQtObjectEnabled; bool m_renderToOffscreenBuffer; QUrl m_iconURL; }; +class QQuickWebViewLegacyPrivate : public QQuickWebViewPrivate { + Q_DECLARE_PUBLIC(QQuickWebView) +public: + QQuickWebViewLegacyPrivate(QQuickWebView* viewport); + virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0); + + virtual void updateViewportSize(); +}; + +class QQuickWebViewFlickablePrivate : public QQuickWebViewPrivate { + Q_DECLARE_PUBLIC(QQuickWebView) +public: + QQuickWebViewFlickablePrivate(QQuickWebView* viewport); + virtual ~QQuickWebViewFlickablePrivate(); + virtual void initialize(WKContextRef contextRef = 0, WKPageGroupRef pageGroupRef = 0); + + virtual void loadDidSucceed(); + virtual void onComponentComplete(); + virtual void loadDidCommit(); + virtual void didFinishFirstNonEmptyLayout(); + 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 pageDidRequestScroll(const QPoint& pos); + virtual void didChangeContentsSize(const QSize& newSize); + + QtViewportInteractionEngine::Constraints computeViewportConstraints(); + +private: + // This class is responsible for collecting and applying all properties + // on the viewport item, when transitioning from page A to page B is finished. + // See more at https://trac.webkit.org/wiki/QtWebKitLayoutInteraction + class PostTransitionState { + public: + PostTransitionState(QQuickWebViewFlickablePrivate* parent) + : p(parent) + { } + + void apply(); + + QQuickWebViewFlickablePrivate* p; + QSize contentsSize; + QPoint position; + }; + + QScopedPointer<QtViewportInteractionEngine> interactionEngine; + OwnPtr<PostTransitionState> postTransitionState; + bool isTransitioningToNewPage; + bool pageIsSuspended; + bool loadSuccessDispatchIsPending; +}; + #endif // qquickwebview_p_p_h diff --git a/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp b/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp index 735196f86..22863be29 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo.cpp @@ -38,63 +38,63 @@ QWebViewportInfo::~QWebViewportInfo() QSize QWebViewportInfo::contentsSize() const { - return QSize(m_webViewPrivate->pageView->contentSize().toSize()); + return QSize(m_webViewPrivate->pageView->contentsSize().toSize()); } QVariant QWebViewportInfo::currentScale() const { - if (!m_webViewPrivate->interactionEngine) - return QVariant(); + if (QtViewportInteractionEngine* interactionEngine = m_webViewPrivate->viewportInteractionEngine()) + return interactionEngine->currentCSSScale(); - return m_webViewPrivate->interactionEngine->currentCSSScale(); + return QtViewportInteractionEngine::Constraints().initialScale; } QVariant QWebViewportInfo::devicePixelRatio() const { - if (!m_webViewPrivate->interactionEngine) - return QVariant(); + if (QtViewportInteractionEngine* interactionEngine = m_webViewPrivate->viewportInteractionEngine()) + return interactionEngine->constraints().devicePixelRatio; - return m_webViewPrivate->interactionEngine->constraints().devicePixelRatio; + return QtViewportInteractionEngine::Constraints().devicePixelRatio; } QVariant QWebViewportInfo::initialScale() const { - if (!m_webViewPrivate->interactionEngine) - return QVariant(); + if (QtViewportInteractionEngine* interactionEngine = m_webViewPrivate->viewportInteractionEngine()) + return interactionEngine->constraints().initialScale; - return m_webViewPrivate->interactionEngine->constraints().initialScale; + return QtViewportInteractionEngine::Constraints().initialScale; } QVariant QWebViewportInfo::minimumScale() const { - if (!m_webViewPrivate->interactionEngine) - return QVariant(); + if (QtViewportInteractionEngine* interactionEngine = m_webViewPrivate->viewportInteractionEngine()) + return interactionEngine->constraints().minimumScale; - return m_webViewPrivate->interactionEngine->constraints().minimumScale; + return QtViewportInteractionEngine::Constraints().minimumScale; } QVariant QWebViewportInfo::maximumScale() const { - if (!m_webViewPrivate->interactionEngine) - return QVariant(); + if (QtViewportInteractionEngine* interactionEngine = m_webViewPrivate->viewportInteractionEngine()) + return interactionEngine->constraints().maximumScale; - return m_webViewPrivate->interactionEngine->constraints().maximumScale; + return QtViewportInteractionEngine::Constraints().maximumScale; } QVariant QWebViewportInfo::isScalable() const { - if (!m_webViewPrivate->interactionEngine) - return QVariant(); + if (QtViewportInteractionEngine* interactionEngine = m_webViewPrivate->viewportInteractionEngine()) + return interactionEngine->constraints().isUserScalable; - return m_webViewPrivate->interactionEngine->constraints().isUserScalable; + return QtViewportInteractionEngine::Constraints().isUserScalable; } QVariant QWebViewportInfo::layoutSize() const { - if (!m_webViewPrivate->interactionEngine) - return QVariant(); + if (QtViewportInteractionEngine* interactionEngine = m_webViewPrivate->viewportInteractionEngine()) + return interactionEngine->constraints().layoutSize; - return m_webViewPrivate->interactionEngine->constraints().layoutSize; + return QVariant(QSize()); } void QWebViewportInfo::didUpdateContentsSize() diff --git a/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo_p.h b/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo_p.h index e1dea6575..653018221 100644 --- a/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo_p.h +++ b/Source/WebKit2/UIProcess/API/qt/qwebviewportinfo_p.h @@ -29,9 +29,6 @@ #include <QtCore/QVariant> #include <QtDeclarative/QtDeclarative> -namespace WebCore { -class ViewportAttributes; -} class QQuickWebViewPrivate; class QWEBKIT_EXPORT QWebViewportInfo : public QObject { diff --git a/Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro b/Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro index 728521f8a..0f0d4f52c 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro +++ b/Source/WebKit2/UIProcess/API/qt/tests/publicapi/publicapi.pro @@ -1,2 +1,3 @@ include(../tests.pri) +SOURCES += $${TARGET}.cpp CONFIG += qtwebkit-private diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro new file mode 100644 index 000000000..8b5b3cbb8 --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior.pro @@ -0,0 +1,22 @@ +include(../tests.pri) +SOURCES += tst_qmltests.cpp +TARGET = tst_qmltests_DesktopBehavior +OBJECTS_DIR = obj_DesktopBehavior/$$activeBuildConfig() + +CONFIG += qtwebkit-private +CONFIG += warn_on testcase + +QT -= testlib +QT += qmltest + +DEFINES += DISABLE_FLICKABLE_VIEWPORT=1 +# Test the QML files under DesktopBehavior in the source repository. +DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD$${QMAKE_DIR_SEP}DesktopBehavior\\\"\" +DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\" + +OTHER_FILES += \ + DesktopBehavior/DesktopWebView.qml \ + DesktopBehavior/tst_linkHovered.qml \ + DesktopBehavior/tst_loadHtml.qml \ + DesktopBehavior/tst_messaging.qml \ + DesktopBehavior/tst_navigationRequested.qml diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/DesktopWebView.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/DesktopWebView.qml deleted file mode 100644 index 4dce0918b..000000000 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/DesktopWebView.qml +++ /dev/null @@ -1,9 +0,0 @@ -import QtQuick 2.0 -import QtWebKit 3.0 -import QtWebKit.experimental 3.0 - -WebView { - id: component - experimental.useTraditionalDesktopBehaviour: true -} - diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_itemSelector.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_itemSelector.qml index 03d68be5b..432416a63 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_itemSelector.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_itemSelector.qml @@ -1,13 +1,11 @@ import QtQuick 2.0 import QtTest 1.0 import QtWebKit 3.0 -import QtWebKit.experimental 3.0 +import QtWebKit.experimental 1.0 -// FIXME: used because we want to have mouseClick() to open the <select> tag. We can remove this +// FIXME: Moved to Desktop tests because we want to have mouseClick() to open the <select> tag. We can move it back // when TestCase starts supporting touch events, see https://bugreports.qt.nokia.com/browse/QTBUG-23083. -import "../DesktopBehavior" - -DesktopWebView { +WebView { id: webView width: 400 diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_linkHovered.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_linkHovered.qml index c98958319..b8ab29496 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_linkHovered.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_linkHovered.qml @@ -2,7 +2,7 @@ import QtQuick 2.0 import QtTest 1.0 import QtWebKit 3.0 -DesktopWebView { +WebView { id: webView width: 200 height: 400 diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_loadHtml.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_loadHtml.qml index b45b01ac8..9e173d56a 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_loadHtml.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_loadHtml.qml @@ -2,7 +2,7 @@ import QtQuick 2.0 import QtTest 1.0 import QtWebKit 3.0 -DesktopWebView { +WebView { id: webView width: 200 height: 400 diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_messaging.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_messaging.qml index 7fcc91a64..eb18a8216 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_messaging.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_messaging.qml @@ -1,10 +1,10 @@ import QtQuick 2.0 import QtTest 1.0 import QtWebKit 3.0 -import QtWebKit.experimental 3.0 +import QtWebKit.experimental 1.0 Item { - DesktopWebView { + WebView { id: webView property variant lastMessage experimental.preferences.navigatorQtObjectEnabled: true @@ -13,7 +13,7 @@ Item { } } - DesktopWebView { + WebView { id: otherWebView property variant lastMessage experimental.preferences.navigatorQtObjectEnabled: true @@ -22,7 +22,7 @@ Item { } } - DesktopWebView { + WebView { id: disabledWebView property bool receivedMessage experimental.preferences.navigatorQtObjectEnabled: false diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml index 3ef7d5516..169a0273e 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/DesktopBehavior/tst_navigationRequested.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import QtTest 1.0 import QtWebKit 3.0 -import QtWebKit.experimental 3.0 +import QtWebKit.experimental 1.0 Item { property int expectedLength: 0 @@ -11,7 +11,7 @@ Item { property url beginUrl: Qt.resolvedUrl("../common/test2.html") property url endUrl: Qt.resolvedUrl("../common/test1.html") - DesktopWebView { + WebView { id: webView width: 200 height: 200 @@ -51,7 +51,7 @@ Item { signalName: "loadSucceeded" } - DesktopWebView { + WebView { id: otherWebView } diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro new file mode 100644 index 000000000..8cd15ff4d --- /dev/null +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView.pro @@ -0,0 +1,30 @@ +include(../tests.pri) +SOURCES += tst_qmltests.cpp +TARGET = tst_qmltests_WebView +OBJECTS_DIR = obj_WebView/$$activeBuildConfig() + +CONFIG += qtwebkit-private +CONFIG += warn_on testcase + +QT -= testlib +QT += qmltest + +# Test the QML files under WebView in the source repository. +DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD$${QMAKE_DIR_SEP}WebView\\\"\" +DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\" + +OTHER_FILES += \ + WebView/tst_favIconLoad.qml \ + WebView/tst_download.qml \ + WebView/tst_geopermission.qml \ + WebView/tst_itemSelector.qml \ + WebView/tst_javaScriptDialogs.qml \ + WebView/tst_loadFail.qml \ + WebView/tst_loadIgnore.qml \ + WebView/tst_loadHtml.qml \ + WebView/tst_loadProgress.qml \ + WebView/tst_loadProgressSignal.qml \ + WebView/tst_preferences.qml \ + WebView/tst_properties.qml \ + WebView/tst_titleChanged.qml \ + WebView/tst_applicationScheme.qml diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml index 239483c5b..8bcb5eccb 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_applicationScheme.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import QtTest 1.0 import QtWebKit 3.0 -import QtWebKit.experimental 3.0 +import QtWebKit.experimental 1.0 import Test 1.0 WebView { diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_download.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_download.qml index 6c25af3bc..f8324a606 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_download.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_download.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import QtTest 1.0 import QtWebKit 3.0 -import QtWebKit.experimental 3.0 +import QtWebKit.experimental 1.0 WebView { id: webView diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_geopermission.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_geopermission.qml index 697ab085a..fd898a78e 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_geopermission.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_geopermission.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import QtTest 1.0 import QtWebKit 3.0 -import QtWebKit.experimental 3.0 +import QtWebKit.experimental 1.0 WebView { id: webView diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_javaScriptDialogs.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_javaScriptDialogs.qml index 56c34abcd..13adb3b2d 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_javaScriptDialogs.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_javaScriptDialogs.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import QtTest 1.0 import QtWebKit 3.0 -import QtWebKit.experimental 3.0 +import QtWebKit.experimental 1.0 WebView { id: webView diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_navigationHistory.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_navigationHistory.qml index 68aeeb556..b886e48f3 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_navigationHistory.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_navigationHistory.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import QtTest 1.0 import QtWebKit 3.0 -import QtWebKit.experimental 3.0 +import QtWebKit.experimental 1.0 WebView { id: webView diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_preferences.qml b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_preferences.qml index 8bec01418..917b689e6 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_preferences.qml +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_preferences.qml @@ -1,7 +1,7 @@ import QtQuick 2.0 import QtTest 1.0 import QtWebKit 3.0 -import QtWebKit.experimental 3.0 +import QtWebKit.experimental 1.0 Item { WebView { diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro index c8ce87a7f..8ddc4484e 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/qmltests.pro @@ -1,32 +1,3 @@ -include(../tests.pri) +TEMPLATE = subdirs -CONFIG += qtwebkit-private -CONFIG += warn_on testcase - -QT -= testlib -QT += qmltest - -# QML files tested are the ones in WebKit source repository. -DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"$$PWD\\\"\" -DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\" - -OTHER_FILES += \ - DesktopBehavior/DesktopWebView.qml \ - DesktopBehavior/tst_linkHovered.qml \ - DesktopBehavior/tst_loadHtml.qml \ - DesktopBehavior/tst_messaging.qml \ - DesktopBehavior/tst_navigationRequested.qml \ - WebView/tst_favIconLoad.qml \ - WebView/tst_download.qml \ - WebView/tst_geopermission.qml \ - WebView/tst_itemSelector.qml \ - WebView/tst_javaScriptDialogs.qml \ - WebView/tst_loadFail.qml \ - WebView/tst_loadIgnore.qml \ - WebView/tst_loadHtml.qml \ - WebView/tst_loadProgress.qml \ - WebView/tst_loadProgressSignal.qml \ - WebView/tst_preferences.qml \ - WebView/tst_properties.qml \ - WebView/tst_titleChanged.qml \ - WebView/tst_applicationScheme.qml +SUBDIRS += DesktopBehavior.pro WebView.pro 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 8c8c4b3e6..a80c5c389 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp +++ b/Source/WebKit2/UIProcess/API/qt/tests/qmltests/tst_qmltests.cpp @@ -20,6 +20,7 @@ #include "../bytearraytestdata.h" #include "../util.h" +#include "qquickwebview_p.h" #include <QVarLengthArray> #include <QtQuickTest/quicktest.h> #include <QtWidgets/QApplication> @@ -43,5 +44,9 @@ int main(int argc, char** argv) // This can be removed as soon as we do not use QtWidgets any more. QApplication app(argc, argv); qmlRegisterType<ByteArrayTestData>("Test", 1, 0, "ByteArrayTestData"); + +#ifdef DISABLE_FLICKABLE_VIEWPORT + QQuickWebViewExperimental::setFlickableViewportEnabled(false); +#endif return quick_test_main(argc, argv, "qmltests", 0, QUICK_TEST_SOURCE_DIR); } diff --git a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro index 728521f8a..25cd8324f 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro +++ b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/qquickwebview.pro @@ -1,2 +1,4 @@ include(../tests.pri) +SOURCES += $${TARGET}.cpp CONFIG += qtwebkit-private +DEFINES += IMPORT_DIR=\"\\\"$${ROOT_BUILD_DIR}$${QMAKE_DIR_SEP}imports\\\"\" 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 1d14d1844..db3f9c977 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp +++ b/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp @@ -20,6 +20,7 @@ #include "../testwindow.h" #include "../util.h" +#include <QDeclarativeEngine> #include <QScopedPointer> #include <QtTest/QtTest> #include <qquickwebpage_p.h> @@ -55,19 +56,42 @@ private slots: void multipleWebViews(); private: + void prepareWebViewComponent(); + inline QQuickWebView* newWebView(); inline QQuickWebView* webView() const; QScopedPointer<TestWindow> m_window; + QScopedPointer<QDeclarativeComponent> m_component; }; tst_QQuickWebView::tst_QQuickWebView() { addQtWebProcessToPath(); - qRegisterMetaType<QQuickWebPage*>("QQuickWebPage*"); + prepareWebViewComponent(); +} + +void tst_QQuickWebView::prepareWebViewComponent() +{ + static QDeclarativeEngine* engine = new QDeclarativeEngine(this); + engine->addImportPath(QString::fromUtf8(IMPORT_DIR)); + + m_component.reset(new QDeclarativeComponent(engine, this)); + + m_component->setData(QByteArrayLiteral("import QtQuick 2.0\n" + "import QtWebKit 3.0\n" + "WebView {}") + , QUrl()); +} + +QQuickWebView* tst_QQuickWebView::newWebView() +{ + QObject* viewInstance = m_component->create(); + + return qobject_cast<QQuickWebView*>(viewInstance); } void tst_QQuickWebView::init() { - m_window.reset(new TestWindow(new QQuickWebView())); + m_window.reset(new TestWindow(newWebView())); } void tst_QQuickWebView::cleanup() @@ -277,9 +301,9 @@ void tst_QQuickWebView::multipleWebViewWindows() showWebView(); // This should not crash. - QQuickWebView* webView1 = new QQuickWebView(); + QQuickWebView* webView1 = newWebView(); QScopedPointer<TestWindow> window1(new TestWindow(webView1)); - QQuickWebView* webView2 = new QQuickWebView(); + QQuickWebView* webView2 = newWebView(); QScopedPointer<TestWindow> window2(new TestWindow(webView2)); webView1->setSize(QSizeF(300, 400)); @@ -301,9 +325,9 @@ void tst_QQuickWebView::multipleWebViews() showWebView(); // This should not crash. - QScopedPointer<QQuickWebView> webView1(new QQuickWebView()); + QScopedPointer<QQuickWebView> webView1(newWebView()); webView1->setParentItem(m_window->rootItem()); - QScopedPointer<QQuickWebView> webView2(new QQuickWebView()); + QScopedPointer<QQuickWebView> webView2(newWebView()); webView2->setParentItem(m_window->rootItem()); webView1->setSize(QSizeF(300, 400)); @@ -328,7 +352,7 @@ 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()->contentScale()); + int y = -qRound(50 * webView()->page()->contentsScale()); QVERIFY(webView()->page()->pos().y() == y); } diff --git a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri index 06ff1a0a3..ed91d3942 100644 --- a/Source/WebKit2/UIProcess/API/qt/tests/tests.pri +++ b/Source/WebKit2/UIProcess/API/qt/tests/tests.pri @@ -5,8 +5,7 @@ TARGET = tst_$$TARGET HEADERS += ../bytearraytestdata.h -SOURCES += $${TARGET}.cpp \ - ../util.cpp \ +SOURCES += ../util.cpp \ ../bytearraytestdata.cpp INCLUDEPATH += $$PWD diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxy.cpp b/Source/WebKit2/UIProcess/DrawingAreaProxy.cpp index aa25dd1fd..9bb9783ca 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxy.cpp +++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.cpp @@ -69,9 +69,12 @@ WebCore::IntRect DrawingAreaProxy::contentsRect() const return IntRect(IntPoint::zero(), m_webPageProxy->viewSize()); } +#if USE(TILED_BACKING_STORE) void DrawingAreaProxy::didReceiveLayerTreeHostProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments) { } #endif +#endif + } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxy.h b/Source/WebKit2/UIProcess/DrawingAreaProxy.h index 617c17506..c5b713c39 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxy.h +++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.h @@ -130,14 +130,6 @@ private: #if PLATFORM(MAC) virtual void didUpdateGeometry() { } #endif -#if USE(TILED_BACKING_STORE) - virtual void snapshotTaken(const UpdateInfo&) { } - virtual void createTile(int tileID, const UpdateInfo& updateInfo) { } - virtual void updateTile(int tileID, const UpdateInfo& updateInfo) { } - virtual void didRenderFrame() { } - virtual void removeTile(int tileID) { } - virtual void allTileUpdatesProcessed() { } -#endif }; } // namespace WebKit diff --git a/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in b/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in index 89f7328a3..e27b5bf26 100644 --- a/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in +++ b/Source/WebKit2/UIProcess/DrawingAreaProxy.messages.in @@ -32,12 +32,4 @@ messages -> DrawingAreaProxy { // Used by TiledCoreAnimationDrawingAreaProxy. DidUpdateGeometry() #endif - -#if USE(TILED_BACKING_STORE) - CreateTile(int tileID, WebKit::UpdateInfo updateInfo) - UpdateTile(int tileID, WebKit::UpdateInfo updateInfo) - DidRenderFrame() - RemoveTile(int tileID) - SnapshotTaken(WebKit::UpdateInfo updateInfo) -#endif } diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp b/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp index 065bbbf7f..d6b209286 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp +++ b/Source/WebKit2/UIProcess/Notifications/WebNotification.cpp @@ -33,9 +33,10 @@ namespace WebKit { -WebNotification::WebNotification(const String& title, const String& body, const String& originString, uint64_t notificationID) +WebNotification::WebNotification(const String& title, const String& body, const String& iconURL, const String& originString, uint64_t notificationID) : m_title(title) , m_body(body) + , m_iconURL(iconURL) , m_origin(WebSecurityOrigin::createFromString(originString)) , m_notificationID(notificationID) { diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotification.h b/Source/WebKit2/UIProcess/Notifications/WebNotification.h index 9447da427..4a6fc7e49 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotification.h +++ b/Source/WebKit2/UIProcess/Notifications/WebNotification.h @@ -45,24 +45,26 @@ class WebNotification : public APIObject { public: static const Type APIType = TypeNotification; - static PassRefPtr<WebNotification> create(const String& title, const String& body, const String& originString, uint64_t notificationID) + static PassRefPtr<WebNotification> create(const String& title, const String& body, const String& iconURL, const String& originString, uint64_t notificationID) { - return adoptRef(new WebNotification(title, body, originString, notificationID)); + return adoptRef(new WebNotification(title, body, iconURL, originString, notificationID)); } const String& title() const { return m_title; } const String& body() const { return m_body; } + const String& iconURL() const { return m_iconURL; } WebSecurityOrigin* origin() const { return m_origin.get(); } uint64_t notificationID() const { return m_notificationID; } private: - WebNotification(const String& title, const String& body, const String& originString, uint64_t notificationID); + WebNotification(const String& title, const String& body, const String& iconURL, const String& originString, uint64_t notificationID); virtual Type type() const { return APIType; } String m_title; String m_body; + String m_iconURL; RefPtr<WebSecurityOrigin> m_origin; uint64_t m_notificationID; }; diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp index e74ad07b7..0c0850bee 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp +++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.cpp @@ -77,12 +77,12 @@ void WebNotificationManagerProxy::didReceiveMessage(CoreIPC::Connection* connect didReceiveWebNotificationManagerProxyMessage(connection, messageID, arguments); } -void WebNotificationManagerProxy::show(WebPageProxy* page, const String& title, const String& body, const String& originString, uint64_t notificationID) +void WebNotificationManagerProxy::show(WebPageProxy* page, const String& title, const String& body, const String& iconURL, const String& originString, uint64_t notificationID) { if (!isNotificationIDValid(notificationID)) return; - RefPtr<WebNotification> notification = WebNotification::create(title, body, originString, notificationID); + RefPtr<WebNotification> notification = WebNotification::create(title, body, iconURL, originString, notificationID); m_notifications.set(notificationID, notification); m_provider.show(page, notification.get()); } @@ -111,6 +111,14 @@ void WebNotificationManagerProxy::didDestroyNotification(uint64_t notificationID m_provider.didDestroyNotification(notification.get()); } +void WebNotificationManagerProxy::clearNotifications(const Vector<uint64_t>& notificationIDs) +{ + m_provider.clearNotifications(notificationIDs); + size_t count = notificationIDs.size(); + for (size_t i = 0; i < count; ++i) + m_notifications.remove(notificationIDs[i]); +} + void WebNotificationManagerProxy::providerDidShowNotification(uint64_t notificationID) { if (!m_context) diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h index 8f4b9e9de..d62b9f28f 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h +++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.h @@ -60,7 +60,7 @@ public: void initializeProvider(const WKNotificationProvider*); void populateCopyOfNotificationPermissions(HashMap<String, bool>&); - void show(WebPageProxy*, const String& title, const String& body, const String& originString, uint64_t notificationID); + void show(WebPageProxy*, const String& title, const String& body, const String& iconURL, const String& originString, uint64_t notificationID); void providerDidShowNotification(uint64_t notificationID); void providerDidClickNotification(uint64_t notificationID); @@ -80,6 +80,7 @@ private: // Message handlers void cancel(uint64_t notificationID); void didDestroyNotification(uint64_t notificationID); + void clearNotifications(const Vector<uint64_t>& notificationIDs); typedef HashMap<uint64_t, RefPtr<WebNotification> > WebNotificationMap; diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in index a06fd0292..a06e92812 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in +++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationManagerProxy.messages.in @@ -23,4 +23,5 @@ messages -> WebNotificationManagerProxy { Cancel(uint64_t notificationID); DidDestroyNotification(uint64_t notificationID); + ClearNotifications(Vector<uint64_t> notificationIDs); } diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp b/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp index afd13bccd..133e79aaa 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp +++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.cpp @@ -27,9 +27,11 @@ #include "WebNotificationProvider.h" #include "ImmutableDictionary.h" +#include "MutableArray.h" #include "WKAPICast.h" #include "WebNotification.h" #include "WebNotificationManagerProxy.h" +#include "WebNumber.h" #include "WebSecurityOrigin.h" namespace WebKit { @@ -58,6 +60,20 @@ void WebNotificationProvider::didDestroyNotification(WebNotification* notificati m_client.didDestroyNotification(toAPI(notification), m_client.clientInfo); } +void WebNotificationProvider::clearNotifications(const Vector<uint64_t>& notificationIDs) +{ + if (!m_client.clearNotifications) + return; + + RefPtr<MutableArray> arrayIDs = MutableArray::create(); + size_t count = notificationIDs.size(); + arrayIDs->reserveCapacity(count); + for (size_t i = 0; i < count; ++i) + arrayIDs->append(WebUInt64::create(notificationIDs[i]).leakRef()); + + m_client.clearNotifications(toAPI(arrayIDs.get()), m_client.clientInfo); +} + void WebNotificationProvider::addNotificationManager(WebNotificationManagerProxy* manager) { if (!m_client.addNotificationManager) diff --git a/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h b/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h index 8503ee27c..574b887a4 100644 --- a/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h +++ b/Source/WebKit2/UIProcess/Notifications/WebNotificationProvider.h @@ -29,6 +29,7 @@ #include "APIClient.h" #include "WKNotificationProvider.h" #include <wtf/Forward.h> +#include <wtf/Vector.h> namespace WebKit { @@ -43,6 +44,7 @@ public: void show(WebPageProxy*, WebNotification*); void cancel(WebNotification*); void didDestroyNotification(WebNotification*); + void clearNotifications(const Vector<uint64_t>& notificationIDs); void addNotificationManager(WebNotificationManagerProxy*); void removeNotificationManager(WebNotificationManagerProxy*); diff --git a/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.cpp b/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.cpp deleted file mode 100644 index 6f544407e..000000000 --- a/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "TiledDrawingAreaProxy.h" - -#if USE(TILED_BACKING_STORE) -#include "DrawingAreaMessages.h" -#include "DrawingAreaProxyMessages.h" -#include "MessageID.h" -#include "NotImplemented.h" -#include "WebCoreArgumentCoders.h" -#include "WebPageProxy.h" -#include "WebProcessProxy.h" - -using namespace WebCore; - -namespace WebKit { - -PassOwnPtr<TiledDrawingAreaProxy> TiledDrawingAreaProxy::create(PlatformWebView* webView, WebPageProxy* webPageProxy) -{ - return adoptPtr(new TiledDrawingAreaProxy(webView, webPageProxy)); -} - -TiledDrawingAreaProxy::TiledDrawingAreaProxy(PlatformWebView* webView, WebPageProxy* webPageProxy) - : DrawingAreaProxy(DrawingAreaTypeTiled, webPageProxy) - , m_isWaitingForDidSetFrameNotification(false) - , m_webView(webView) -{ -} - -TiledDrawingAreaProxy::~TiledDrawingAreaProxy() -{ -} - -void TiledDrawingAreaProxy::setVisibleContentRectAndScale(const WebCore::IntRect& visibleContentRect, float scale) -{ - page()->process()->send(Messages::DrawingArea::SetVisibleContentRectAndScale(visibleContentRect, scale), page()->pageID()); -} - -void TiledDrawingAreaProxy::setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint& trajectoryVector) -{ - page()->process()->send(Messages::DrawingArea::SetVisibleContentRectTrajectoryVector(trajectoryVector), page()->pageID()); -} - -void TiledDrawingAreaProxy::renderNextFrame() -{ -} - -void TiledDrawingAreaProxy::sizeDidChange() -{ - WebPageProxy* page = this->page(); - if (!page || !page->isValid()) - return; - - if (m_size.isEmpty()) - return; - - if (m_isWaitingForDidSetFrameNotification) - return; - m_isWaitingForDidSetFrameNotification = true; - - page->process()->responsivenessTimer()->start(); - page->process()->send(Messages::DrawingArea::SetSize(m_size), page->pageID()); -} - -void TiledDrawingAreaProxy::deviceScaleFactorDidChange() -{ - notImplemented(); -} - -} // namespace WebKit - -#endif diff --git a/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.h b/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.h deleted file mode 100644 index 0fcccf4e1..000000000 --- a/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef TiledDrawingAreaProxy_h -#define TiledDrawingAreaProxy_h - -#if USE(TILED_BACKING_STORE) - -#include "DrawingAreaProxy.h" -#include <WebCore/GraphicsContext.h> -#include <WebCore/IntRect.h> -#include <WebCore/RunLoop.h> -#include <wtf/HashSet.h> - -#if PLATFORM(MAC) -#include <wtf/RetainPtr.h> -#ifdef __OBJC__ -@class WKView; -#else -class WKView; -#endif -#endif - -namespace WebCore { -class GraphicsContext; -} - -#if PLATFORM(QT) -class QQuickWebPage; -typedef QQuickWebPage PlatformWebView; -#endif - -namespace WebKit { - -class ShareableBitmap; -class TiledDrawingAreaTileSet; -class WebPageProxy; - -#if PLATFORM(MAC) -typedef WKView PlatformWebView; -#elif PLATFORM(WIN) -class WebView; -typedef WebView PlatformWebView; -#endif - -class TiledDrawingAreaProxy : public DrawingAreaProxy { -public: - static PassOwnPtr<TiledDrawingAreaProxy> create(PlatformWebView* webView, WebPageProxy*); - - TiledDrawingAreaProxy(PlatformWebView*, WebPageProxy*); - virtual ~TiledDrawingAreaProxy(); - - void setVisibleContentRectAndScale(const WebCore::IntRect&, float); - void setVisibleContentRectTrajectoryVector(const WebCore::FloatPoint&); - void renderNextFrame(); - -#if USE(ACCELERATED_COMPOSITING) - virtual void attachCompositingContext(uint32_t /* contextID */) { } - virtual void detachCompositingContext() { } -#endif - -private: - WebPageProxy* page(); - void updateWebView(const Vector<WebCore::IntRect>& paintedArea); - - // DrawingAreaProxy - virtual void sizeDidChange(); - virtual void deviceScaleFactorDidChange(); - - virtual void createTile(int tileID, const UpdateInfo&); - virtual void updateTile(int tileID, const UpdateInfo&); - virtual void didRenderFrame(); - virtual void removeTile(int tileID); - - -private: - bool m_isWaitingForDidSetFrameNotification; - - PlatformWebView* m_webView; -#if PLATFORM(QT) - // Maps tile IDs to node IDs. - HashMap<int, int> m_tileNodeMap; -#endif -}; - -} // namespace WebKit - -#endif // USE(TILED_BACKING_STORE) - -#endif // TiledDrawingAreaProxy_h diff --git a/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp b/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp index be814c0a9..84280a73d 100644 --- a/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp +++ b/Source/WebKit2/UIProcess/WebConnectionToWebProcess.cpp @@ -109,6 +109,7 @@ void WebConnectionToWebProcess::didClose(CoreIPC::Connection* connection) void WebConnectionToWebProcess::didReceiveInvalidMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID) { + RefPtr<WebConnectionToWebProcess> protector = this; RefPtr<WebProcessProxy> process = m_process; // This will invalidate the CoreIPC::Connection and the WebProcessProxy member diff --git a/Source/WebKit2/UIProcess/WebInspectorProxy.cpp b/Source/WebKit2/UIProcess/WebInspectorProxy.cpp index 825420a4a..cb5df7906 100644 --- a/Source/WebKit2/UIProcess/WebInspectorProxy.cpp +++ b/Source/WebKit2/UIProcess/WebInspectorProxy.cpp @@ -207,6 +207,8 @@ void WebInspectorProxy::createInspectorPage(uint64_t& inspectorPageID, WebPageCr if (!m_page) return; + m_isAttached = shouldOpenAttached(); + WebPageProxy* inspectorPage = platformCreateInspectorPage(); ASSERT(inspectorPage); if (!inspectorPage) @@ -216,7 +218,7 @@ void WebInspectorProxy::createInspectorPage(uint64_t& inspectorPageID, WebPageCr inspectorPageParameters = inspectorPage->creationParameters(); String url = inspectorPageURL(); - if (shouldOpenAttached()) + if (m_isAttached) url += "?docked=true"; m_page->process()->assumeReadAccessToBaseURL(inspectorBaseURL()); inspectorPage->loadURL(url); @@ -225,7 +227,6 @@ void WebInspectorProxy::createInspectorPage(uint64_t& inspectorPageID, WebPageCr void WebInspectorProxy::didLoadInspectorPage() { m_isVisible = true; - m_isAttached = shouldOpenAttached(); // platformOpen is responsible for rendering attached mode depending on m_isAttached. platformOpen(); diff --git a/Source/WebKit2/UIProcess/WebInspectorProxy.h b/Source/WebKit2/UIProcess/WebInspectorProxy.h index a70ac700c..56df78cd2 100644 --- a/Source/WebKit2/UIProcess/WebInspectorProxy.h +++ b/Source/WebKit2/UIProcess/WebInspectorProxy.h @@ -34,6 +34,7 @@ #include <wtf/Forward.h> #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> +#include <wtf/text/WTFString.h> #if PLATFORM(MAC) #include <wtf/RetainPtr.h> @@ -82,6 +83,8 @@ public: void close(); #if PLATFORM(MAC) + void createInspectorWindow(); + void updateInspectorWindowTitle() const; void inspectedViewFrameDidChange(); #elif PLATFORM(GTK) void windowDestroyed(); @@ -175,6 +178,7 @@ private: RetainPtr<WKWebInspectorWKView> m_inspectorView; RetainPtr<NSWindow> m_inspectorWindow; RetainPtr<WKWebInspectorProxyObjCAdapter> m_inspectorProxyObjCAdapter; + String m_urlString; #elif PLATFORM(WIN) HWND m_inspectorWindow; RefPtr<WebView> m_inspectorView; diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp index b945ef0b5..85b7d54ca 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.cpp +++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp @@ -195,6 +195,7 @@ WebPageProxy::WebPageProxy(PageClient* pageClient, PassRefPtr<WebProcessProxy> p , m_mainFrameHasCustomRepresentation(false) , m_mainFrameHasHorizontalScrollbar(false) , m_mainFrameHasVerticalScrollbar(false) + , m_canShortCircuitHorizontalWheelEvents(true) , m_mainFrameIsPinnedToLeftSide(false) , m_mainFrameIsPinnedToRightSide(false) , m_pageCount(0) @@ -1533,7 +1534,7 @@ void WebPageProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::M return; } -#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) +#if USE(ACCELERATED_COMPOSITING) && USE(TEXTURE_MAPPER) && USE(TILED_BACKING_STORE) if (messageID.is<CoreIPC::MessageClassLayerTreeHostProxy>()) { m_drawingArea->didReceiveLayerTreeHostProxyMessage(connection, messageID, arguments); return; @@ -3377,9 +3378,9 @@ void WebPageProxy::requestNotificationPermission(uint64_t requestID, const Strin request->deny(); } -void WebPageProxy::showNotification(const String& title, const String& body, const String& originString, uint64_t notificationID) +void WebPageProxy::showNotification(const String& title, const String& body, const String& iconURL, const String& originString, uint64_t notificationID) { - m_process->context()->notificationManagerProxy()->show(this, title, body, originString, notificationID); + m_process->context()->notificationManagerProxy()->show(this, title, body, iconURL, originString, notificationID); } float WebPageProxy::headerHeight(WebFrameProxy* frame) @@ -3456,7 +3457,7 @@ void WebPageProxy::didFailToInitializePlugin(const String& mimeType) bool WebPageProxy::willHandleHorizontalScrollEvents() const { - return m_wheelEventHandlerCount > 0; + return !m_canShortCircuitHorizontalWheelEvents; } void WebPageProxy::didFinishLoadingDataForCustomRepresentation(const String& suggestedFilename, const CoreIPC::DataReference& dataReference) diff --git a/Source/WebKit2/UIProcess/WebPageProxy.h b/Source/WebKit2/UIProcess/WebPageProxy.h index caa5df4a2..2e64d16ec 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.h +++ b/Source/WebKit2/UIProcess/WebPageProxy.h @@ -719,13 +719,13 @@ private: void didChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide); void didChangePageCount(unsigned); void didFailToInitializePlugin(const String& mimeType); - void numWheelEventHandlersChanged(unsigned count) { m_wheelEventHandlerCount = count; } + void setCanShortCircuitHorizontalWheelEvents(bool canShortCircuitHorizontalWheelEvents) { m_canShortCircuitHorizontalWheelEvents = canShortCircuitHorizontalWheelEvents; } void reattachToWebProcess(); void reattachToWebProcessWithItem(WebBackForwardListItem*); void requestNotificationPermission(uint64_t notificationID, const String& originString); - void showNotification(const String& title, const String& body, const String& originString, uint64_t notificationID); + void showNotification(const String& title, const String& body, const String& iconURL, const String& originString, uint64_t notificationID); #if USE(TILED_BACKING_STORE) void pageDidRequestScroll(const WebCore::IntPoint&); @@ -1009,7 +1009,9 @@ private: bool m_mainFrameHasHorizontalScrollbar; bool m_mainFrameHasVerticalScrollbar; - int m_wheelEventHandlerCount; + + // Whether horizontal wheel events can be handled directly for swiping purposes. + bool m_canShortCircuitHorizontalWheelEvents; bool m_mainFrameIsPinnedToLeftSide; bool m_mainFrameIsPinnedToRightSide; diff --git a/Source/WebKit2/UIProcess/WebPageProxy.messages.in b/Source/WebKit2/UIProcess/WebPageProxy.messages.in index 8c8ce4995..9ba1d5254 100644 --- a/Source/WebKit2/UIProcess/WebPageProxy.messages.in +++ b/Source/WebKit2/UIProcess/WebPageProxy.messages.in @@ -66,7 +66,7 @@ messages -> WebPageProxy { DidChangeScrollOffsetPinningForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar) DidChangePageCount(unsigned pageCount); DidFailToInitializePlugin(WTF::String mimeType) - NumWheelEventHandlersChanged(unsigned count) + SetCanShortCircuitHorizontalWheelEvents(bool canShortCircuitHorizontalWheelEvents) #if USE(TILED_BACKING_STORE) PageDidRequestScroll(WebCore::IntPoint point) @@ -206,7 +206,7 @@ messages -> WebPageProxy { # Notification messages RequestNotificationPermission(uint64_t requestID, WTF::String originIdentifier) - ShowNotification(WTF::String title, WTF::String body, WTF::String originIdentifier, uint64_t notificationID) + ShowNotification(WTF::String title, WTF::String body, WTF::String iconURL, WTF::String originIdentifier, uint64_t notificationID) # Spelling and grammar messages #if USE(UNIFIED_TEXT_CHECKING) diff --git a/Source/WebKit2/UIProcess/WebPreferences.cpp b/Source/WebKit2/UIProcess/WebPreferences.cpp index efda4cdf0..ca00bb963 100644 --- a/Source/WebKit2/UIProcess/WebPreferences.cpp +++ b/Source/WebKit2/UIProcess/WebPreferences.cpp @@ -41,6 +41,13 @@ WebPreferences::WebPreferences(const String& identifier) platformInitializeStore(); } +WebPreferences::WebPreferences(const WebPreferences& other) + : APIObject() + , m_store(other.m_store) +{ + platformInitializeStore(); +} + WebPreferences::~WebPreferences() { } diff --git a/Source/WebKit2/UIProcess/WebPreferences.h b/Source/WebKit2/UIProcess/WebPreferences.h index 53b610200..1cb9731e1 100644 --- a/Source/WebKit2/UIProcess/WebPreferences.h +++ b/Source/WebKit2/UIProcess/WebPreferences.h @@ -54,6 +54,11 @@ public: return adoptRef(new WebPreferences(identifier)); } + static PassRefPtr<WebPreferences> create(const WebPreferences& other) + { + return adoptRef(new WebPreferences(other)); + } + virtual ~WebPreferences(); void addPageGroup(WebPageGroup*); @@ -75,6 +80,7 @@ public: private: WebPreferences(); WebPreferences(const String& identifier); + WebPreferences(const WebPreferences&); void platformInitializeStore(); diff --git a/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm b/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm index d43a2ac04..d90ad1215 100644 --- a/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm +++ b/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm @@ -99,25 +99,10 @@ static const CGFloat windowContentBorderThickness = 55; namespace WebKit { -WebPageProxy* WebInspectorProxy::platformCreateInspectorPage() -{ - ASSERT(m_page); - ASSERT(!m_inspectorView); - - m_inspectorView.adoptNS([[WKWebInspectorWKView alloc] initWithFrame:NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight) contextRef:toAPI(page()->process()->context()) pageGroupRef:toAPI(inspectorPageGroup())]); - ASSERT(m_inspectorView); - - [m_inspectorView.get() setDrawsBackground:NO]; - - return toImpl(m_inspectorView.get().pageRef); -} - -void WebInspectorProxy::platformOpen() +void WebInspectorProxy::createInspectorWindow() { ASSERT(!m_inspectorWindow); - m_inspectorProxyObjCAdapter.adoptNS([[WKWebInspectorProxyObjCAdapter alloc] initWithWebInspectorProxy:this]); - bool useTexturedWindow = page()->process()->context()->overrideWebInspectorPagePath().isEmpty(); NSUInteger styleMask = (NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask); @@ -135,31 +120,72 @@ void WebInspectorProxy::platformOpen() WKNSWindowMakeBottomCornersSquare(window); } + NSView *contentView = [window contentView]; + [m_inspectorView.get() setFrame:[contentView bounds]]; + [contentView addSubview:m_inspectorView.get()]; + // Center the window initially before setting the frame autosave name so that the window will be in a good // position if there is no saved frame yet. [window center]; [window setFrameAutosaveName:@"Web Inspector 2"]; - NSView *contentView = [window contentView]; - [m_inspectorView.get() setFrame:[contentView bounds]]; + m_inspectorWindow.adoptNS(window); + + updateInspectorWindowTitle(); +} + +void WebInspectorProxy::updateInspectorWindowTitle() const +{ + if (!m_inspectorWindow) + return; + + NSString *title = [NSString stringWithFormat:WEB_UI_STRING("Web Inspector — %@", "Web Inspector window title"), (NSString *)m_urlString]; + [m_inspectorWindow.get() setTitle:title]; +} + +WebPageProxy* WebInspectorProxy::platformCreateInspectorPage() +{ + ASSERT(m_page); + ASSERT(!m_inspectorView); + + m_inspectorView.adoptNS([[WKWebInspectorWKView alloc] initWithFrame:NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight) contextRef:toAPI(page()->process()->context()) pageGroupRef:toAPI(inspectorPageGroup())]); + ASSERT(m_inspectorView); + + [m_inspectorView.get() setDrawsBackground:NO]; [m_inspectorView.get() setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)]; - [contentView addSubview:m_inspectorView.get()]; - m_inspectorWindow.adoptNS(window); + m_inspectorProxyObjCAdapter.adoptNS([[WKWebInspectorProxyObjCAdapter alloc] initWithWebInspectorProxy:this]); if (m_isAttached) platformAttach(); else - [window makeKeyAndOrderFront:nil]; + createInspectorWindow(); + + return toImpl(m_inspectorView.get().pageRef); +} + +void WebInspectorProxy::platformOpen() +{ + if (m_isAttached) { + // Make the inspector view visible since it was hidden while loading. + [m_inspectorView.get() setHidden:NO]; + + // Adjust the frames now that we are visible and inspectedViewFrameDidChange wont return early. + inspectedViewFrameDidChange(); + } else + [m_inspectorWindow.get() makeKeyAndOrderFront:nil]; } void WebInspectorProxy::platformDidClose() { - [m_inspectorWindow.get() setDelegate:nil]; - [m_inspectorWindow.get() orderOut:nil]; + if (m_inspectorWindow) { + [m_inspectorWindow.get() setDelegate:nil]; + [m_inspectorWindow.get() orderOut:nil]; + m_inspectorWindow = 0; + } - m_inspectorWindow = 0; m_inspectorView = 0; + m_inspectorProxyObjCAdapter = 0; } @@ -171,13 +197,14 @@ void WebInspectorProxy::platformBringToFront() void WebInspectorProxy::platformInspectedURLChanged(const String& urlString) { - NSString *title = [NSString stringWithFormat:WEB_UI_STRING("Web Inspector — %@", "Web Inspector window title"), (NSString *)urlString]; - [m_inspectorWindow.get() setTitle:title]; + m_urlString = urlString; + + updateInspectorWindowTitle(); } void WebInspectorProxy::inspectedViewFrameDidChange() { - if (!m_isAttached) + if (!m_isAttached || !m_isVisible) return; WKView *inspectedView = m_page->wkView(); @@ -187,7 +214,7 @@ void WebInspectorProxy::inspectedViewFrameDidChange() CGFloat inspectedTop = NSMaxY(inspectedViewFrame); CGFloat inspectedWidth = NSWidth(inspectedViewFrame); CGFloat inspectorHeight = NSHeight([m_inspectorView.get() frame]); - + CGFloat parentHeight = NSHeight([[inspectedView superview] frame]); inspectorHeight = InspectorFrontendClientLocal::constrainedAttachedWindowHeight(inspectorHeight, parentHeight); @@ -213,9 +240,16 @@ void WebInspectorProxy::platformAttach() NSRect inspectedViewFrame = [inspectedView frame]; [m_inspectorView.get() setFrame:NSMakeRect(NSMinX(inspectedViewFrame), 0, NSWidth(inspectedViewFrame), inspectorPageGroup()->preferences()->inspectorAttachedHeight())]; + // Start out hidden if we are not visible yet. When platformOpen is called, hidden will be set to NO. + [m_inspectorView.get() setHidden:!m_isVisible]; + [[inspectedView superview] addSubview:m_inspectorView.get() positioned:NSWindowBelow relativeTo:inspectedView]; - [m_inspectorWindow.get() orderOut:nil]; + if (m_inspectorWindow) { + [m_inspectorWindow.get() setDelegate:nil]; + [m_inspectorWindow.get() orderOut:nil]; + m_inspectorWindow = 0; + } inspectedViewFrameDidChange(); } @@ -227,10 +261,10 @@ void WebInspectorProxy::platformDetach() [m_inspectorView.get() removeFromSuperview]; - // Move the inspector view back into the inspector window. - NSView *inspectorWindowContentView = [m_inspectorWindow.get() contentView]; - [m_inspectorView.get() setFrame:[inspectorWindowContentView bounds]]; - [inspectorWindowContentView addSubview:m_inspectorView.get()]; + createInspectorWindow(); + + // Make the inspector view visible in case it is still hidden from loading while attached. + [m_inspectorView.get() setHidden:NO]; // Make sure that we size the inspected view's frame after detaching so that it takes up the space that the // attached inspector used to. This assumes the previous height was the Y origin. diff --git a/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp b/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp index 8969bbbe3..c7ca7f116 100644 --- a/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp +++ b/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp @@ -26,8 +26,7 @@ #include "MainThread.h" #include "MessageID.h" #include "ShareableBitmap.h" -#include "TextureMapperGL.h" -#include "TextureMapperQt.h" +#include "TextureMapper.h" #include "UpdateInfo.h" #include "WebCoreArgumentCoders.h" #include "WebLayerTreeInfo.h" @@ -171,8 +170,8 @@ LayerTreeHostProxy::~LayerTreeHostProxy() void LayerTreeHostProxy::paintToCurrentGLContext(const TransformationMatrix& matrix, float opacity, const FloatRect& clipRect) { if (!m_textureMapper) - m_textureMapper = TextureMapperGL::create(); - ASSERT(dynamic_cast<TextureMapperGL*>(m_textureMapper.get())); + m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode); + ASSERT(m_textureMapper->accelerationMode() == TextureMapper::OpenGLMode); syncRemoteContent(); GraphicsLayer* currentRootLayer = rootLayer(); @@ -184,9 +183,6 @@ void LayerTreeHostProxy::paintToCurrentGLContext(const TransformationMatrix& mat if (!node) return; - GLint viewport[4]; - glGetIntegerv(GL_VIEWPORT, viewport); - m_textureMapper->setViewportSize(IntSize(viewport[2], viewport[3])); node->setTextureMapper(m_textureMapper.get()); m_textureMapper->beginPainting(); m_textureMapper->bindSurface(0); @@ -211,9 +207,8 @@ void LayerTreeHostProxy::paintToCurrentGLContext(const TransformationMatrix& mat void LayerTreeHostProxy::paintToGraphicsContext(QPainter* painter) { if (!m_textureMapper) - m_textureMapper = TextureMapperQt::create(); - ASSERT(dynamic_cast<TextureMapperQt*>(m_textureMapper.get())); - + m_textureMapper = TextureMapper::create(); + ASSERT(m_textureMapper->accelerationMode() == TextureMapper::SoftwareMode); syncRemoteContent(); TextureMapperNode* node = toTextureMapperNode(rootLayer()); @@ -410,7 +405,7 @@ void LayerTreeHostProxy::createImage(int64_t imageID, ShareableBitmap* bitmap) subImage = image.copy(rect); RefPtr<BitmapTexture> texture = m_textureMapper->createTexture(); texture->reset(rect.size(), !imageHasAlpha); - texture->updateRawContents(IntRect(IntPoint::zero(), rect.size()), subImage.constBits()); + texture->updateContents(subImage.constBits(), IntRect(IntPoint::zero(), rect.size())); tiledImage.add(rect.location(), texture); } } @@ -473,7 +468,7 @@ void LayerTreeHostProxy::ensureRootLayer() // The root layer should not have zero size, or it would be optimized out. m_rootLayer->setSize(FloatSize(1.0, 1.0)); if (!m_textureMapper) - m_textureMapper = TextureMapperGL::create(); + m_textureMapper = TextureMapper::create(TextureMapper::OpenGLMode); toTextureMapperNode(m_rootLayer.get())->setTextureMapper(m_textureMapper.get()); } diff --git a/Source/WebKit2/UIProcess/qt/QtSGTileNode.cpp b/Source/WebKit2/UIProcess/qt/QtSGTileNode.cpp deleted file mode 100644 index 229bafc7c..000000000 --- a/Source/WebKit2/UIProcess/qt/QtSGTileNode.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2010, 2011 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 program 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 program; 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 "QtSGTileNode.h" - -#include <QtQuick/QSGEngine> -#include <QtQuick/QSGFlatColorMaterial> -#include <QtQuick/QSGTexture> - -namespace WebKit { - -QtSGTileNode::QtSGTileNode(QSGEngine* engine) - : m_engine(engine) - , m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 4) - , m_textureMaterialsCreated(false) -{ - setFlags(OwnsMaterial | OwnsOpaqueMaterial); - setGeometry(&m_geometry); - setMaterial(new QSGFlatColorMaterial); - setOpaqueMaterial(new QSGFlatColorMaterial); -} - -void QtSGTileNode::setBackBuffer(const QImage& backBuffer, const QRectF& sourceRect, const QRectF& targetRect) -{ - m_backBufferTexture.reset(m_engine->createTextureFromImage(backBuffer)); - m_backBufferTargetRect = targetRect; - m_backBufferSourceRect = m_backBufferTexture->convertToNormalizedSourceRect(sourceRect); - - // Force the texture upload. - m_backBufferTexture->bind(); -} - -void QtSGTileNode::swapBuffersIfNeeded() -{ - if (!m_backBufferTexture) - return; - - if (!m_textureMaterialsCreated) { - setMaterial(new QSGTextureMaterial); - setOpaqueMaterial(new QSGOpaqueTextureMaterial); - m_textureMaterialsCreated = true; - } - - static_cast<QSGTextureMaterial*>(material())->setTexture(m_backBufferTexture.data()); - static_cast<QSGOpaqueTextureMaterial*>(opaqueMaterial())->setTexture(m_backBufferTexture.data()); - markDirty(DirtyMaterial); - - QSGGeometry::updateTexturedRectGeometry(&m_geometry, m_backBufferTargetRect, m_backBufferSourceRect); - markDirty(DirtyGeometry); - - m_frontBufferTexture.swap(m_backBufferTexture); - m_backBufferTexture.reset(); -} - -} diff --git a/Source/WebKit2/UIProcess/qt/QtSGTileNode.h b/Source/WebKit2/UIProcess/qt/QtSGTileNode.h deleted file mode 100644 index 11aaecad8..000000000 --- a/Source/WebKit2/UIProcess/qt/QtSGTileNode.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2011 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 program 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 program; 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 QtSGTileNode_h -#define QtSGTileNode_h - -#include <QtQuick/QSGGeometryNode> -#include <QtQuick/QSGOpaqueTextureMaterial> -#include <QtQuick/QSGTextureMaterial> - -QT_BEGIN_NAMESPACE -class QSGEngine; -class QSGTexture; -QT_END_NAMESPACE - -namespace WebKit { - -class QtSGTileNode : public QSGGeometryNode { -public: - QtSGTileNode(QSGEngine*); - void setBackBuffer(const QImage&, const QRectF& sourceRect, const QRectF& targetRect); - void swapBuffersIfNeeded(); - -private: - QSGEngine* m_engine; - QSGGeometry m_geometry; - QScopedPointer<QSGTexture> m_frontBufferTexture; - QScopedPointer<QSGTexture> m_backBufferTexture; - bool m_textureMaterialsCreated; - - QRectF m_backBufferTargetRect; - QRectF m_backBufferSourceRect; -}; - -} - -#endif // QtSGTileNode_h diff --git a/Source/WebKit2/UIProcess/qt/QtSGUpdateQueue.cpp b/Source/WebKit2/UIProcess/qt/QtSGUpdateQueue.cpp deleted file mode 100644 index 7b1675dfe..000000000 --- a/Source/WebKit2/UIProcess/qt/QtSGUpdateQueue.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2010, 2011 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 program 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 program; 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 "QtSGUpdateQueue.h" - -#include "PassOwnPtr.h" -#include "QtSGTileNode.h" -#include <QtQuick/QQuickItem> - -namespace WebKit { - -struct NodeUpdateCreateTile : public NodeUpdate { - NodeUpdateCreateTile(int nodeID, float scale) - : NodeUpdate(CreateTile) - , nodeID(nodeID) - , scale(scale) - { } - int nodeID; - float scale; -}; - -struct NodeUpdateRemoveTile : public NodeUpdate { - NodeUpdateRemoveTile(int nodeID) - : NodeUpdate(RemoveTile) - , nodeID(nodeID) - { } - int nodeID; -}; - -struct NodeUpdateSetBackBuffer : public NodeUpdate { - NodeUpdateSetBackBuffer(int nodeID, const QImage& backBuffer, const QRect& sourceRect, const QRect& targetRect) - : NodeUpdate(SetBackBuffer) - , nodeID(nodeID) - , backBuffer(backBuffer) - , sourceRect(sourceRect) - , targetRect(targetRect) - { } - int nodeID; - QImage backBuffer; - QRect sourceRect; - QRect targetRect; -}; - -struct NodeUpdateSwapTileBuffers : public NodeUpdate { - NodeUpdateSwapTileBuffers() - : NodeUpdate(SwapTileBuffers) - { } -}; - -QtSGUpdateQueue::QtSGUpdateQueue(QQuickItem *item) - : item(item) - , lastScale(0) - , lastScaleNode(0) - , nextNodeID(1) - , m_isSwapPending(false) -{ -} - -int QtSGUpdateQueue::createTileNode(float scale) -{ - int nodeID = nextNodeID++; - nodeUpdateQueue.append(adoptPtr(new NodeUpdateCreateTile(nodeID, scale))); - item->update(); - return nodeID; -} - -void QtSGUpdateQueue::removeTileNode(int nodeID) -{ - nodeUpdateQueue.append(adoptPtr(new NodeUpdateRemoveTile(nodeID))); - item->update(); -} - -void QtSGUpdateQueue::setNodeBackBuffer(int nodeID, const QImage& backBuffer, const QRect& sourceRect, const QRect& targetRect) -{ - nodeUpdateQueue.append(adoptPtr(new NodeUpdateSetBackBuffer(nodeID, backBuffer, sourceRect, targetRect))); - item->update(); -} - -void QtSGUpdateQueue::swapTileBuffers() -{ - nodeUpdateQueue.append(adoptPtr(new NodeUpdateSwapTileBuffers())); - m_isSwapPending = true; - item->update(); -} - -void QtSGUpdateQueue::applyUpdates(QSGNode* itemNode) -{ - while (!nodeUpdateQueue.isEmpty()) { - OwnPtr<NodeUpdate> nodeUpdate(nodeUpdateQueue.takeFirst()); - switch (nodeUpdate->type) { - case NodeUpdate::CreateTile: { - NodeUpdateCreateTile* createTileUpdate = static_cast<NodeUpdateCreateTile*>(nodeUpdate.get()); - QtSGTileNode* tileNode = new QtSGTileNode(item->sceneGraphEngine()); - getScaleNode(createTileUpdate->scale, itemNode)->prependChildNode(tileNode); - nodes.set(createTileUpdate->nodeID, tileNode); - break; - } - case NodeUpdate::RemoveTile: { - NodeUpdateRemoveTile* removeUpdate = static_cast<NodeUpdateRemoveTile*>(nodeUpdate.get()); - QSGNode* node = nodes.take(removeUpdate->nodeID); - QSGNode* scaleNode = node->parent(); - - scaleNode->removeChildNode(node); - if (!scaleNode->childCount()) { - if (scaleNode == lastScaleNode) { - lastScale = 0; - lastScaleNode = 0; - } - delete scaleNode; - } - delete node; - break; - } - case NodeUpdate::SetBackBuffer: { - NodeUpdateSetBackBuffer* setBackBufferUpdate = static_cast<NodeUpdateSetBackBuffer*>(nodeUpdate.get()); - QtSGTileNode* tileNode = nodes.get(setBackBufferUpdate->nodeID); - tileNode->setBackBuffer(setBackBufferUpdate->backBuffer, setBackBufferUpdate->sourceRect, setBackBufferUpdate->targetRect); - break; - } - case NodeUpdate::SwapTileBuffers: { - HashMap<int, QtSGTileNode*>::iterator end = nodes.end(); - for (HashMap<int, QtSGTileNode*>::iterator it = nodes.begin(); it != end; ++it) - it->second->swapBuffersIfNeeded(); - m_isSwapPending = false; - break; - } - default: - ASSERT_NOT_REACHED(); - } - } -} - -QSGNode* QtSGUpdateQueue::getScaleNode(float scale, QSGNode* itemNode) -{ - if (scale == lastScale) - return lastScaleNode; - - QSGTransformNode* scaleNode = new QSGTransformNode; - QMatrix4x4 scaleMatrix; - // Use scale(float,float) to prevent scaling the Z component. - // Reverse the item's transform scale since our tiles were generated for this specific scale. - scaleMatrix.scale(1 / scale, 1 / scale); - scaleNode->setMatrix(scaleMatrix); - // Prepend instead of append to paint the new, incomplete, scale before/behind the previous one. - itemNode->prependChildNode(scaleNode); - - lastScale = scale; - lastScaleNode = scaleNode; - return lastScaleNode; -} - -} diff --git a/Source/WebKit2/UIProcess/qt/QtSGUpdateQueue.h b/Source/WebKit2/UIProcess/qt/QtSGUpdateQueue.h deleted file mode 100644 index f70c50668..000000000 --- a/Source/WebKit2/UIProcess/qt/QtSGUpdateQueue.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2011 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 program 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 program; 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 QtSGUpdateQueue_h -#define QtSGUpdateQueue_h - -#include "Deque.h" -#include "HashMap.h" -#include "OwnPtr.h" - -class QImage; -class QRect; -class QQuickItem; -class QSGNode; -class QSize; - -namespace WebKit { - -class NodeUpdate; -class PageNode; -class QtSGTileNode; - -// Takes care of taking update requests then fulfilling them asynchronously on the scene graph thread. -class QtSGUpdateQueue { -public: - QtSGUpdateQueue(QQuickItem*); - - int createTileNode(float scale); - void removeTileNode(int nodeID); - void setNodeBackBuffer(int nodeID, const QImage& texture, const QRect& sourceRect, const QRect& targetRect); - void swapTileBuffers(); - - // Called by the QQuickItem. - void applyUpdates(QSGNode* itemNode); - bool isSwapPending() const { return m_isSwapPending; } - -private: - QSGNode* getScaleNode(float scale, QSGNode* itemNode); - - QQuickItem* item; - Deque<OwnPtr<NodeUpdate> > nodeUpdateQueue; - HashMap<int, QtSGTileNode*> nodes; - float lastScale; - QSGNode* lastScaleNode; - int nextNodeID; - bool m_isSwapPending; -}; - -struct NodeUpdate { - enum Type { - CreateTile, - RemoveTile, - SetBackBuffer, - SwapTileBuffers - }; - NodeUpdate(Type type) - : type(type) - { } - virtual ~NodeUpdate() { } - Type type; -}; - -} - -#endif // QtSGUpdateQueue_h diff --git a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp index d2eb1566d..62400fa42 100644 --- a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp +++ b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp @@ -180,7 +180,7 @@ void QtViewportInteractionEngine::setItemRectVisible(const QRectF& itemRect) qreal itemScale = m_viewport->width() / itemRect.width(); - m_content->setContentScale(itemScale); + m_content->setContentsScale(itemScale); // We need to animate the content but the position represents the viewport hence we need to invert the position here. // To animate the position together with the scale we multiply the position with the current scale; @@ -244,7 +244,7 @@ bool QtViewportInteractionEngine::event(QEvent* event) QScrollPrepareEvent* prepareEvent = static_cast<QScrollPrepareEvent*>(event); const QRectF viewportRect = m_viewport->boundingRect(); const QRectF contentRect = m_viewport->mapRectFromItem(m_content, m_content->boundingRect()); - const QRectF posRange = computePosRangeForItemAtScale(m_content->contentScale()); + const QRectF posRange = computePosRangeForItemAtScale(m_content->contentsScale()); prepareEvent->setContentPosRange(posRange); prepareEvent->setViewportSize(viewportRect.size()); @@ -303,7 +303,7 @@ void QtViewportInteractionEngine::wheelEvent(QWheelEvent* ev) else newPos.ry() += delta; - QRectF endPosRange = computePosRangeForItemAtScale(m_content->contentScale()); + QRectF endPosRange = computePosRangeForItemAtScale(m_content->contentsScale()); m_content->setPos(-boundPosition(endPosRange.topLeft(), newPos, endPosRange.bottomRight())); emit visibleContentRectAndScaleChanged(); @@ -315,7 +315,7 @@ void QtViewportInteractionEngine::pagePositionRequest(const QPoint& pagePosition if (m_suspendCount) return; - qreal endItemScale = m_content->contentScale(); // Stay at same scale. + qreal endItemScale = m_content->contentsScale(); // Stay at same scale. QRectF endPosRange = computePosRangeForItemAtScale(endItemScale); QPointF endPosition = boundPosition(endPosRange.topLeft(), pagePosition * endItemScale, endPosRange.bottomRight()); @@ -327,7 +327,7 @@ void QtViewportInteractionEngine::pagePositionRequest(const QPoint& pagePosition QRectF QtViewportInteractionEngine::computePosRangeForItemAtScale(qreal itemScale) const { - const QSizeF contentItemSize = m_content->contentSize() * itemScale; + const QSizeF contentItemSize = m_content->contentsSize() * itemScale; const QSizeF viewportItemSize = m_viewport->boundingRect().size(); const qreal horizontalRange = contentItemSize.width() - viewportItemSize.width(); @@ -449,7 +449,7 @@ void QtViewportInteractionEngine::applyConstraints(const Constraints& constraint if (!m_hadUserInteraction) { qreal initialScale = innerBoundedCSSScale(m_constraints.initialScale); - m_content->setContentScale(itemScaleFromCSS(initialScale)); + m_content->setContentsScale(itemScaleFromCSS(initialScale)); } // If the web app changes successively changes the viewport on purpose @@ -459,7 +459,7 @@ void QtViewportInteractionEngine::applyConstraints(const Constraints& constraint qreal QtViewportInteractionEngine::currentCSSScale() { - return cssScaleFromItem(m_content->contentScale()); + return cssScaleFromItem(m_content->contentsScale()); } bool QtViewportInteractionEngine::scrollAnimationActive() const @@ -532,7 +532,7 @@ void QtViewportInteractionEngine::pinchGestureStarted(const QPointF& pinchCenter m_scaleUpdateDeferrer = adoptPtr(new ViewportUpdateDeferrer(this)); m_lastPinchCenterInViewportCoordinates = pinchCenterInViewportCoordinates; - m_pinchStartScale = m_content->contentScale(); + m_pinchStartScale = m_content->contentsScale(); // Reset the tiling look-ahead vector so that tiles all around the viewport will be requested on pinch-end. emit viewportTrajectoryVectorChanged(QPointF()); @@ -586,7 +586,7 @@ void QtViewportInteractionEngine::itemSizeChanged() void QtViewportInteractionEngine::scaleContent(const QPointF& centerInCSSCoordinates, qreal cssScale) { QPointF oldPinchCenterOnViewport = m_viewport->mapFromWebContent(centerInCSSCoordinates); - m_content->setContentScale(itemScaleFromCSS(cssScale)); + m_content->setContentsScale(itemScaleFromCSS(cssScale)); QPointF newPinchCenterOnViewport = m_viewport->mapFromWebContent(centerInCSSCoordinates); m_content->setPos(m_content->pos() - (newPinchCenterOnViewport - oldPinchCenterOnViewport)); } diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp index 09f896021..a07967801 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp @@ -87,6 +87,7 @@ static inline WebCore::DragOperation dropActionToDragOperation(Qt::DropActions a QtWebPageEventHandler::QtWebPageEventHandler(WKPageRef pageRef, QQuickWebPage* qmlWebPage, QQuickWebView* qmlWebView) : m_webPageProxy(toImpl(pageRef)) + , m_interactionEngine(0) , m_panGestureRecognizer(this) , m_pinchGestureRecognizer(this) , m_tapGestureRecognizer(this) @@ -297,7 +298,7 @@ void QtWebPageEventHandler::handleSingleTapEvent(const QTouchEvent::TouchPoint& m_postponeTextInputStateChanged = true; QTransform fromItemTransform = m_webPage->transformFromItem(); - WebGestureEvent gesture(WebEvent::GestureSingleTap, fromItemTransform.map(point.pos()).toPoint(), point.screenPos().toPoint(), WebEvent::Modifiers(0), 0); + WebGestureEvent gesture(WebEvent::GestureSingleTap, fromItemTransform.map(point.pos()).toPoint(), point.screenPos().toPoint(), WebEvent::Modifiers(0), 0, IntSize(point.rect().size().toSize()), FloatPoint(0, 0)); m_webPageProxy->handleGestureEvent(gesture); } diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp index 3ba8c74f6..2601f4802 100644 --- a/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp +++ b/Source/WebKit2/UIProcess/qt/QtWebPageLoadClient.cpp @@ -85,8 +85,7 @@ void QtWebPageLoadClient::didChangeBackForwardList() void QtWebPageLoadClient::dispatchLoadSucceeded() { - emit m_webView->navigationStateChanged(); - emit m_webView->loadSucceeded(); + m_webView->d_func()->loadDidSucceed(); } void QtWebPageLoadClient::dispatchLoadFailed(WKErrorRef error) diff --git a/Source/WebKit2/UIProcess/qt/TiledDrawingAreaProxyQt.cpp b/Source/WebKit2/UIProcess/qt/TiledDrawingAreaProxyQt.cpp deleted file mode 100644 index 2c76062f5..000000000 --- a/Source/WebKit2/UIProcess/qt/TiledDrawingAreaProxyQt.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF - * THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "TiledDrawingAreaProxy.h" - -#include "QtSGUpdateQueue.h" -#include "qquickwebpage_p.h" -#include "ShareableBitmap.h" -#include "UpdateInfo.h" -#include "WKAPICast.h" -#include "WebPageProxy.h" - -using namespace WebCore; - -#define TILE_DEBUG_LOG - -namespace WebKit { - -void TiledDrawingAreaProxy::updateWebView(const Vector<IntRect>& paintedArea) -{ - // SG updates are triggered through QtSGUpdateQueue. -} - -WebPageProxy* TiledDrawingAreaProxy::page() -{ - return m_webPageProxy; -} - -void TiledDrawingAreaProxy::createTile(int tileID, const UpdateInfo& updateInfo) -{ - int nodeID = m_webView->sceneGraphUpdateQueue()->createTileNode(updateInfo.updateScaleFactor); - m_tileNodeMap.set(tileID, nodeID); - updateTile(tileID, updateInfo); -} - -void TiledDrawingAreaProxy::updateTile(int tileID, const UpdateInfo& updateInfo) -{ - int nodeID = m_tileNodeMap.get(tileID); - ASSERT(nodeID); - - RefPtr<ShareableBitmap> bitmap = ShareableBitmap::create(updateInfo.bitmapHandle); - // FIXME: We could avoid this copy by carying the ShareableBitmap all the way up to texture uploading. - // Currently won't work since the SharedMemory handle is owned by updateInfo. - QImage image(bitmap->createQImage().copy()); - QRect sourceRect(0, 0, updateInfo.updateRectBounds.width(), updateInfo.updateRectBounds.height()); - m_webView->sceneGraphUpdateQueue()->setNodeBackBuffer(nodeID, image, sourceRect, updateInfo.updateRectBounds); -} - -void TiledDrawingAreaProxy::didRenderFrame() -{ - m_webView->sceneGraphUpdateQueue()->swapTileBuffers(); -} - -void TiledDrawingAreaProxy::removeTile(int tileID) -{ - int nodeID = m_tileNodeMap.take(tileID); - m_webView->sceneGraphUpdateQueue()->removeTileNode(nodeID); -} - -} // namespace WebKit |