Diff
Modified: trunk/ChangeLog (218739 => 218740)
--- trunk/ChangeLog 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/ChangeLog 2017-06-23 11:11:22 UTC (rev 218740)
@@ -1,5 +1,16 @@
2017-06-23 Carlos Garcia Campos <[email protected]>
+ [WPE] User script messages don't work
+ https://bugs.webkit.org/show_bug.cgi?id=173712
+
+ Reviewed by Žan Doberšek.
+
+ Enable user script messages.
+
+ * Source/cmake/OptionsWPE.cmake:
+
+2017-06-23 Carlos Garcia Campos <[email protected]>
+
[WPE] Enable PUBLIC_SUFFIX_LIST
https://bugs.webkit.org/show_bug.cgi?id=173758
Modified: trunk/Source/WebKit2/ChangeLog (218739 => 218740)
--- trunk/Source/WebKit2/ChangeLog 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/ChangeLog 2017-06-23 11:11:22 UTC (rev 218740)
@@ -1,3 +1,50 @@
+2017-06-23 Carlos Garcia Campos <[email protected]>
+
+ [WPE] User script messages don't work
+ https://bugs.webkit.org/show_bug.cgi?id=173712
+
+ Reviewed by Žan Doberšek.
+
+ When a user script message is received we need to create a WebKitJavascriptResult to deserialize the script
+ value. WebKitJavascriptResult is created with a WebKitWebView for two reasons: to get its _javascript_ global
+ context and to take a reference that ensures the _javascript_ context will be alive while the results is
+ alive. However, we could create the WebKitJavascriptResult with the _javascript_ global context and take a
+ reference of the context itself. This way we don't need to access the WebKitWebView from the
+ WebScriptMessageHandler client. But we still need access to the _javascript_ context, so I've added a
+ _javascript_GlobalContext() method to WebPageProxy for GTK+ and WPE that is implemented from the page client.
+
+ Fixes /wpe/WebKitUserContentManager/script-message-received.
+
+ * UIProcess/API/glib/WebKitJavascriptResult.cpp:
+ (_WebKitJavascriptResult::_WebKitJavascriptResult): Create the WebKitJavascriptResult with a JSGlobalContextRef
+ instead of a WEbKitWebView.
+ (webkitJavascriptResultCreate): Pass the js context to the constructor.
+ (webkit_javascript_result_get_global_context): Return the js context.
+ * UIProcess/API/glib/WebKitJavascriptResultPrivate.h:
+ * UIProcess/API/glib/WebKitUserContentManager.cpp:
+ * UIProcess/API/glib/WebKitWebView.cpp:
+ (_WebKitWebViewPrivate::~_WebKitWebViewPrivate): Use JSRetainPtr
+ (webkit_web_view_get_javascript_global_context):
+ (webkitWebViewRunJavaScriptCallback):
+ * UIProcess/API/gtk/PageClientImpl.cpp:
+ (WebKit::PageClientImpl::_javascript_GlobalContext):
+ * UIProcess/API/gtk/PageClientImpl.h:
+ * UIProcess/API/wpe/APIViewClient.h:
+ (API::ViewClient::_javascript_GlobalContext):
+ * UIProcess/API/wpe/PageClientImpl.cpp:
+ (WebKit::PageClientImpl::_javascript_GlobalContext):
+ * UIProcess/API/wpe/PageClientImpl.h:
+ * UIProcess/API/wpe/WPEView.cpp:
+ (WKWPE::View::_javascript_GlobalContext):
+ * UIProcess/API/wpe/WPEView.h:
+ * UIProcess/PageClient.h:
+ (WebKit::PageClient::_javascript_GlobalContext):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/gtk/WebPageProxyGtk.cpp:
+ (WebKit::WebPageProxy::_javascript_GlobalContext):
+ * UIProcess/wpe/WebPageProxyWPE.cpp:
+ (WebKit::WebPageProxy::_javascript_GlobalContext):
+
2017-06-22 Wenson Hsieh <[email protected]>
[iOS DnD] [WK2] Enable in-app dragging from WKWebView on the phone
Modified: trunk/Source/WebKit2/UIProcess/API/glib/WebKitJavascriptResult.cpp (218739 => 218740)
--- trunk/Source/WebKit2/UIProcess/API/glib/WebKitJavascriptResult.cpp 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/UIProcess/API/glib/WebKitJavascriptResult.cpp 2017-06-23 11:11:22 UTC (rev 218740)
@@ -22,17 +22,18 @@
#include "APISerializedScriptValue.h"
#include "WebKitJavascriptResultPrivate.h"
+#include <_javascript_Core/JSRetainPtr.h>
#include <wtf/glib/GRefPtr.h>
struct _WebKitJavascriptResult {
- _WebKitJavascriptResult(WebKitWebView* view, WebCore::SerializedScriptValue& serializedScriptValue)
- : webView(view)
+ _WebKitJavascriptResult(JSGlobalContextRef jsContext, WebCore::SerializedScriptValue& serializedScriptValue)
+ : _javascript_GlobalContext(jsContext)
, referenceCount(1)
{
- value = serializedScriptValue.deserialize(webkit_web_view_get_javascript_global_context(view), nullptr);
+ value = serializedScriptValue.deserialize(_javascript_GlobalContext.get(), nullptr);
}
- GRefPtr<WebKitWebView> webView;
+ JSRetainPtr<JSGlobalContextRef> _javascript_GlobalContext;
JSValueRef value;
int referenceCount;
@@ -40,10 +41,10 @@
G_DEFINE_BOXED_TYPE(WebKitJavascriptResult, webkit_javascript_result, webkit_javascript_result_ref, webkit_javascript_result_unref)
-WebKitJavascriptResult* webkitJavascriptResultCreate(WebKitWebView* webView, WebCore::SerializedScriptValue& serializedScriptValue)
+WebKitJavascriptResult* webkitJavascriptResultCreate(JSGlobalContextRef _javascript_GlobalContext, WebCore::SerializedScriptValue& serializedScriptValue)
{
WebKitJavascriptResult* result = static_cast<WebKitJavascriptResult*>(fastMalloc(sizeof(WebKitJavascriptResult)));
- new (result) WebKitJavascriptResult(webView, serializedScriptValue);
+ new (result) WebKitJavascriptResult(_javascript_GlobalContext, serializedScriptValue);
return result;
}
@@ -90,7 +91,7 @@
*/
JSGlobalContextRef webkit_javascript_result_get_global_context(WebKitJavascriptResult* _javascript_Result)
{
- return webkit_web_view_get_javascript_global_context(_javascript_Result->webView.get());
+ return _javascript_Result->_javascript_GlobalContext.get();
}
/**
Modified: trunk/Source/WebKit2/UIProcess/API/glib/WebKitJavascriptResultPrivate.h (218739 => 218740)
--- trunk/Source/WebKit2/UIProcess/API/glib/WebKitJavascriptResultPrivate.h 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/UIProcess/API/glib/WebKitJavascriptResultPrivate.h 2017-06-23 11:11:22 UTC (rev 218740)
@@ -21,6 +21,5 @@
#include <WebCore/SerializedScriptValue.h>
#include "WebKitJavascriptResult.h"
-#include "WebKitWebView.h"
-WebKitJavascriptResult* webkitJavascriptResultCreate(WebKitWebView*, WebCore::SerializedScriptValue&);
+WebKitJavascriptResult* webkitJavascriptResultCreate(JSGlobalContextRef, WebCore::SerializedScriptValue&);
Modified: trunk/Source/WebKit2/UIProcess/API/glib/WebKitUserContentManager.cpp (218739 => 218740)
--- trunk/Source/WebKit2/UIProcess/API/glib/WebKitUserContentManager.cpp 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/UIProcess/API/glib/WebKitUserContentManager.cpp 2017-06-23 11:11:22 UTC (rev 218740)
@@ -29,6 +29,10 @@
#include <wtf/glib/GRefPtr.h>
#include <wtf/glib/WTFGType.h>
+#if PLATFORM(WPE)
+#include "WPEView.h"
+#endif
+
using namespace WebCore;
using namespace WebKit;
@@ -186,13 +190,9 @@
void didPostMessage(WebPageProxy& page, const FrameInfoData&, WebCore::SerializedScriptValue& serializedScriptValue) override
{
-#if PLATFORM(GTK)
- WebKitJavascriptResult* jsResult = webkitJavascriptResultCreate(WEBKIT_WEB_VIEW(page.viewWidget()), serializedScriptValue);
+ WebKitJavascriptResult* jsResult = webkitJavascriptResultCreate(page._javascript_GlobalContext(), serializedScriptValue);
g_signal_emit(m_manager, signals[SCRIPT_MESSAGE_RECEIVED], m_handlerName, jsResult);
webkit_javascript_result_unref(jsResult);
-#else
- // FIXME: We need a way to get the WebKitWebView here in WPE.
-#endif
}
virtual ~ScriptMessageClientGtk() { }
Modified: trunk/Source/WebKit2/UIProcess/API/glib/WebKitWebView.cpp (218739 => 218740)
--- trunk/Source/WebKit2/UIProcess/API/glib/WebKitWebView.cpp 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/UIProcess/API/glib/WebKitWebView.cpp 2017-06-23 11:11:22 UTC (rev 218740)
@@ -59,6 +59,7 @@
#include "WebKitWebsiteDataManagerPrivate.h"
#include "WebKitWindowPropertiesPrivate.h"
#include <_javascript_Core/APICast.h>
+#include <_javascript_Core/JSRetainPtr.h>
#include <WebCore/CertificateInfo.h>
#include <WebCore/GUniquePtrSoup.h>
#include <WebCore/JSDOMExceptionHandling.h>
@@ -180,9 +181,6 @@
struct _WebKitWebViewPrivate {
~_WebKitWebViewPrivate()
{
- if (_javascript_GlobalContext)
- JSGlobalContextRelease(_javascript_GlobalContext);
-
// For modal dialogs, make sure the main loop is stopped when finalizing the webView.
if (modalLoop && g_main_loop_is_running(modalLoop.get()))
g_main_loop_quit(modalLoop.get());
@@ -215,7 +213,7 @@
WebEvent::Modifiers mouseTargetModifiers;
GRefPtr<WebKitFindController> findController;
- JSGlobalContextRef _javascript_GlobalContext;
+ JSRetainPtr<JSGlobalContextRef> _javascript_GlobalContext;
GRefPtr<WebKitWebResource> mainResource;
LoadingResourcesMap loadingResourcesMap;
@@ -350,6 +348,11 @@
webkitWebViewHandleDownloadRequest(m_webView, &downloadProxy);
}
+ JSGlobalContextRef _javascript_GlobalContext() override
+ {
+ return webkit_web_view_get_javascript_global_context(m_webView);
+ }
+
WebKitWebView* m_webView;
};
#endif
@@ -3069,11 +3072,11 @@
*/
JSGlobalContextRef webkit_web_view_get_javascript_global_context(WebKitWebView* webView)
{
- g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
+ g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), nullptr);
if (!webView->priv->_javascript_GlobalContext)
- webView->priv->_javascript_GlobalContext = JSGlobalContextCreate(0);
- return webView->priv->_javascript_GlobalContext;
+ webView->priv->_javascript_GlobalContext = adopt(JSGlobalContextCreate(nullptr));
+ return webView->priv->_javascript_GlobalContext.get();
}
static void webkitWebViewRunJavaScriptCallback(API::SerializedScriptValue* wkSerializedScriptValue, const WebCore::ExceptionDetails& exceptionDetails, GTask* task)
@@ -3101,8 +3104,8 @@
return;
}
- WebKitWebView* webView = WEBKIT_WEB_VIEW(g_task_get_source_object(task));
- g_task_return_pointer(task, webkitJavascriptResultCreate(webView,
+ auto* jsContext = webkit_web_view_get_javascript_global_context(WEBKIT_WEB_VIEW(g_task_get_source_object(task)));
+ g_task_return_pointer(task, webkitJavascriptResultCreate(jsContext,
*wkSerializedScriptValue->internalRepresentation()),
reinterpret_cast<GDestroyNotify>(webkit_javascript_result_unref));
}
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp (218739 => 218740)
--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp 2017-06-23 11:11:22 UTC (rev 218740)
@@ -468,4 +468,12 @@
}
#endif
+JSGlobalContextRef PageClientImpl::_javascript_GlobalContext()
+{
+ if (!WEBKIT_IS_WEB_VIEW(m_viewWidget))
+ return nullptr;
+
+ return webkit_web_view_get_javascript_global_context(WEBKIT_WEB_VIEW(m_viewWidget));
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h (218739 => 218740)
--- trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h 2017-06-23 11:11:22 UTC (rev 218740)
@@ -148,6 +148,8 @@
void didChangeAvoidsUnsafeArea(bool) override { }
+ JSGlobalContextRef _javascript_GlobalContext() override;
+
// Members of PageClientImpl class
GtkWidget* m_viewWidget;
DefaultUndoController m_undoController;
Modified: trunk/Source/WebKit2/UIProcess/API/wpe/APIViewClient.h (218739 => 218740)
--- trunk/Source/WebKit2/UIProcess/API/wpe/APIViewClient.h 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/UIProcess/API/wpe/APIViewClient.h 2017-06-23 11:11:22 UTC (rev 218740)
@@ -25,6 +25,8 @@
#pragma once
+typedef struct OpaqueJSContext* JSGlobalContextRef;
+
namespace WebKit {
class DownloadProxy;
}
@@ -41,6 +43,7 @@
virtual void frameDisplayed(WKWPE::View&) { }
virtual void handleDownloadRequest(WKWPE::View&, WebKit::DownloadProxy&) { }
+ virtual JSGlobalContextRef _javascript_GlobalContext() { return nullptr; }
};
} // namespace API
Modified: trunk/Source/WebKit2/UIProcess/API/wpe/PageClientImpl.cpp (218739 => 218740)
--- trunk/Source/WebKit2/UIProcess/API/wpe/PageClientImpl.cpp 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/UIProcess/API/wpe/PageClientImpl.cpp 2017-06-23 11:11:22 UTC (rev 218740)
@@ -320,4 +320,9 @@
return WebCore::UserInterfaceLayoutDirection::LTR;
}
+JSGlobalContextRef PageClientImpl::_javascript_GlobalContext()
+{
+ return m_view._javascript_GlobalContext();
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/API/wpe/PageClientImpl.h (218739 => 218740)
--- trunk/Source/WebKit2/UIProcess/API/wpe/PageClientImpl.h 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/UIProcess/API/wpe/PageClientImpl.h 2017-06-23 11:11:22 UTC (rev 218740)
@@ -119,6 +119,8 @@
void didChangeAvoidsUnsafeArea(bool) override { }
+ JSGlobalContextRef _javascript_GlobalContext() override;
+
WKWPE::View& m_view;
std::unique_ptr<ScrollGestureController> m_scrollGestureController;
Modified: trunk/Source/WebKit2/UIProcess/API/wpe/WPEView.cpp (218739 => 218740)
--- trunk/Source/WebKit2/UIProcess/API/wpe/WPEView.cpp 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/UIProcess/API/wpe/WPEView.cpp 2017-06-23 11:11:22 UTC (rev 218740)
@@ -35,6 +35,7 @@
#include "NativeWebWheelEvent.h"
#include "WebPageGroup.h"
#include "WebProcessPool.h"
+#include <_javascript_Core/JSBase.h>
#include <wpe/view-backend.h>
using namespace WebKit;
@@ -150,6 +151,11 @@
m_client->handleDownloadRequest(*this, download);
}
+JSGlobalContextRef View::_javascript_GlobalContext()
+{
+ return m_client->_javascript_GlobalContext();
+}
+
void View::setSize(const WebCore::IntSize& size)
{
m_size = size;
Modified: trunk/Source/WebKit2/UIProcess/API/wpe/WPEView.h (218739 => 218740)
--- trunk/Source/WebKit2/UIProcess/API/wpe/WPEView.h 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/UIProcess/API/wpe/WPEView.h 2017-06-23 11:11:22 UTC (rev 218740)
@@ -33,6 +33,7 @@
#include <memory>
#include <wtf/RefPtr.h>
+typedef struct OpaqueJSContext* JSGlobalContextRef;
struct wpe_view_backend;
namespace API {
@@ -59,6 +60,7 @@
void setClient(std::unique_ptr<API::ViewClient>&&);
void frameDisplayed();
void handleDownloadRequest(WebKit::DownloadProxy&);
+ JSGlobalContextRef _javascript_GlobalContext();
WebKit::WebPageProxy& page() { return *m_pageProxy; }
Modified: trunk/Source/WebKit2/UIProcess/PageClient.h (218739 => 218740)
--- trunk/Source/WebKit2/UIProcess/PageClient.h 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/UIProcess/PageClient.h 2017-06-23 11:11:22 UTC (rev 218740)
@@ -379,6 +379,10 @@
#endif
virtual void didChangeAvoidsUnsafeArea(bool avoidsUnsafeArea) = 0;
+
+#if PLATFORM(GTK) || PLATFORM(WPE)
+ virtual JSGlobalContextRef _javascript_GlobalContext() { return nullptr; }
+#endif
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (218739 => 218740)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h 2017-06-23 11:11:22 UTC (rev 218740)
@@ -177,6 +177,10 @@
typedef GtkWidget* PlatformWidget;
#endif
+#if PLATFORM(GTK) || PLATFORM(WPE)
+typedef struct OpaqueJSContext* JSGlobalContextRef;
+#endif
+
namespace WebKit {
class CertificateInfo;
class DrawingAreaProxy;
@@ -630,6 +634,10 @@
void setBackgroundColor(const WebCore::Color& color) { m_backgroundColor = color; }
#endif
+#if PLATFORM(GTK) || PLATFORM(WPE)
+ JSGlobalContextRef _javascript_GlobalContext();
+#endif
+
void handleMouseEvent(const NativeWebMouseEvent&);
void handleWheelEvent(const NativeWebWheelEvent&);
void handleKeyboardEvent(const NativeWebKeyboardEvent&);
Modified: trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp (218739 => 218740)
--- trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebPageProxyGtk.cpp 2017-06-23 11:11:22 UTC (rev 218740)
@@ -50,6 +50,11 @@
return static_cast<PageClientImpl&>(m_pageClient).viewWidget();
}
+JSGlobalContextRef WebPageProxy::_javascript_GlobalContext()
+{
+ return m_pageClient._javascript_GlobalContext();
+}
+
String WebPageProxy::standardUserAgent(const String& applicationNameForUserAgent)
{
return WebCore::standardUserAgent(applicationNameForUserAgent);
Modified: trunk/Source/WebKit2/UIProcess/wpe/WebPageProxyWPE.cpp (218739 => 218740)
--- trunk/Source/WebKit2/UIProcess/wpe/WebPageProxyWPE.cpp 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/WebKit2/UIProcess/wpe/WebPageProxyWPE.cpp 2017-06-23 11:11:22 UTC (rev 218740)
@@ -26,6 +26,7 @@
#include "config.h"
#include "WebPageProxy.h"
+#include "PageClientImpl.h"
#include "WebsiteDataStore.h"
#include <WebCore/NotImplemented.h>
@@ -36,6 +37,11 @@
notImplemented();
}
+JSGlobalContextRef WebPageProxy::_javascript_GlobalContext()
+{
+ return m_pageClient._javascript_GlobalContext();
+}
+
String WebPageProxy::standardUserAgent(const String&)
{
return "Mozilla/5.0 (Linux; x86_64 GNU/Linux) AppleWebKit/601.1 (KHTML, like Gecko) Version/8.0 Safari/601.1";
Modified: trunk/Source/cmake/OptionsWPE.cmake (218739 => 218740)
--- trunk/Source/cmake/OptionsWPE.cmake 2017-06-23 11:08:09 UTC (rev 218739)
+++ trunk/Source/cmake/OptionsWPE.cmake 2017-06-23 11:11:22 UTC (rev 218740)
@@ -29,6 +29,7 @@
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_PUBLIC_SUFFIX_LIST PRIVATE ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_REMOTE_INSPECTOR PRIVATE ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_TOUCH_EVENTS PUBLIC ON)
+WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_USER_MESSAGE_HANDLERS PRIVATE ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO PUBLIC ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIDEO_TRACK PUBLIC ON)
WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_VIEW_MODE_CSS_MEDIA PUBLIC ON)