Title: [189094] trunk
Revision
189094
Author
[email protected]
Date
2015-08-28 04:16:05 -0700 (Fri, 28 Aug 2015)

Log Message

[GTK] Simplify the internal API to create a WebView
https://bugs.webkit.org/show_bug.cgi?id=148570

Reviewed by Žan Doberšek.

Source/WebKit2:

Now that all the information required to create a WebView is in
API::PageConfiguration, we can simplify the internal API to
receive only the configuration instead of receiving a long list of
parameters that we use to build a new API::PageConfiguration.

* UIProcess/API/C/gtk/WKView.cpp:
(WKViewCreate):
* UIProcess/API/C/gtk/WKView.h:
* UIProcess/API/gtk/WebKitWebContext.cpp:
(webkitWebContextCreatePageForWebView):
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
(webkitWebViewBaseCreate):
(webkitWebViewBaseCreateWebPage):
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
* UIProcess/gtk/WebInspectorProxyGtk.cpp:
(WebKit::WebInspectorProxy::platformCreateInspectorPage):

Tools:

* TestWebKitAPI/PlatformWebView.h: Add initialize method for GTK+ too.
* TestWebKitAPI/gtk/PlatformWebViewGtk.cpp:
(TestWebKitAPI::PlatformWebView::PlatformWebView): Implement all
PlatformWebView constructors that end up calling initialize with a PageConfiguration.
(TestWebKitAPI::PlatformWebView::initialize): Create the WebView
passing the received PageConfiguration.
* WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
(WTR::PlatformWebView::PlatformWebView): Create the WebView
passing the received PageConfiguration.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (189093 => 189094)


--- trunk/Source/WebKit2/ChangeLog	2015-08-28 09:48:41 UTC (rev 189093)
+++ trunk/Source/WebKit2/ChangeLog	2015-08-28 11:16:05 UTC (rev 189094)
@@ -1,3 +1,27 @@
+2015-08-28  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Simplify the internal API to create a WebView
+        https://bugs.webkit.org/show_bug.cgi?id=148570
+
+        Reviewed by Žan Doberšek.
+
+        Now that all the information required to create a WebView is in
+        API::PageConfiguration, we can simplify the internal API to
+        receive only the configuration instead of receiving a long list of
+        parameters that we use to build a new API::PageConfiguration.
+
+        * UIProcess/API/C/gtk/WKView.cpp:
+        (WKViewCreate):
+        * UIProcess/API/C/gtk/WKView.h:
+        * UIProcess/API/gtk/WebKitWebContext.cpp:
+        (webkitWebContextCreatePageForWebView):
+        * UIProcess/API/gtk/WebKitWebViewBase.cpp:
+        (webkitWebViewBaseCreate):
+        (webkitWebViewBaseCreateWebPage):
+        * UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
+        * UIProcess/gtk/WebInspectorProxyGtk.cpp:
+        (WebKit::WebInspectorProxy::platformCreateInspectorPage):
+
 2015-08-27  Timothy Horton  <[email protected]>
 
         Video full-screen shouldn't use the DynamicSizeWithMinimumViewSize layout mode

Modified: trunk/Source/WebKit2/UIProcess/API/C/gtk/WKView.cpp (189093 => 189094)


--- trunk/Source/WebKit2/UIProcess/API/C/gtk/WKView.cpp	2015-08-28 09:48:41 UTC (rev 189093)
+++ trunk/Source/WebKit2/UIProcess/API/C/gtk/WKView.cpp	2015-08-28 11:16:05 UTC (rev 189094)
@@ -31,15 +31,12 @@
 #include "WKAPICast.h"
 #include "WKViewPrivate.h"
 #include "WebKitWebViewBasePrivate.h"
-#include "WebPageGroup.h"
-#include "WebProcessPool.h"
 
 using namespace WebKit;
-using namespace WebCore;
 
-WKViewRef WKViewCreate(WKContextRef contextRef, WKPageGroupRef pageGroupRef, WKPageRef relatedPage)
+WKViewRef WKViewCreate(WKPageConfigurationRef configuration)
 {
-    return toAPI(webkitWebViewBaseCreate(toImpl(contextRef), nullptr, toImpl(pageGroupRef), nullptr, toImpl(relatedPage)));
+    return toAPI(webkitWebViewBaseCreate(*toImpl(configuration)));
 }
 
 WKPageRef WKViewGetPage(WKViewRef viewRef)

Modified: trunk/Source/WebKit2/UIProcess/API/C/gtk/WKView.h (189093 => 189094)


--- trunk/Source/WebKit2/UIProcess/API/C/gtk/WKView.h	2015-08-28 09:48:41 UTC (rev 189093)
+++ trunk/Source/WebKit2/UIProcess/API/C/gtk/WKView.h	2015-08-28 11:16:05 UTC (rev 189094)
@@ -34,7 +34,7 @@
 extern "C" {
 #endif
 
-WK_EXPORT WKViewRef WKViewCreate(WKContextRef context, WKPageGroupRef pageGroup, WKPageRef relatedPage);
+WK_EXPORT WKViewRef WKViewCreate(WKPageConfigurationRef configuration);
 
 WK_EXPORT WKPageRef WKViewGetPage(WKViewRef view);
 

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (189093 => 189094)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp	2015-08-28 09:48:41 UTC (rev 189093)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp	2015-08-28 11:16:05 UTC (rev 189094)
@@ -1318,12 +1318,13 @@
     WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(webView);
 
     auto pageConfiguration = API::PageConfiguration::create();
+    pageConfiguration->setProcessPool(context->priv->context.get());
     pageConfiguration->setPreferences(webkitSettingsGetPreferences(webkit_web_view_get_settings(webView)));
     pageConfiguration->setRelatedPage(relatedView ? webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(relatedView)) : nullptr);
     pageConfiguration->setUserContentController(userContentManager ? webkitUserContentManagerGetUserContentControllerProxy(userContentManager) : nullptr);
     pageConfiguration->setWebsiteDataStore(&webkitWebsiteDataManagerGetDataStore(context->priv->websiteDataManager.get()));
     pageConfiguration->setSessionID(pageConfiguration->websiteDataStore()->websiteDataStore().sessionID());
-    webkitWebViewBaseCreateWebPage(webViewBase, context->priv->context.get(), WTF::move(pageConfiguration));
+    webkitWebViewBaseCreateWebPage(webViewBase, WTF::move(pageConfiguration));
 
     WebPageProxy* page = webkitWebViewBaseGetPage(webViewBase);
     context->priv->webViews.set(page->pageID(), webView);

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp (189093 => 189094)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp	2015-08-28 09:48:41 UTC (rev 189093)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp	2015-08-28 11:16:05 UTC (rev 189094)
@@ -1043,17 +1043,10 @@
     containerClass->forall = webkitWebViewBaseContainerForall;
 }
 
-WebKitWebViewBase* webkitWebViewBaseCreate(WebProcessPool* context, WebPreferences* preferences, WebPageGroup* pageGroup, WebUserContentControllerProxy* userContentController, WebPageProxy* relatedPage)
+WebKitWebViewBase* webkitWebViewBaseCreate(const API::PageConfiguration& configuration)
 {
     WebKitWebViewBase* webkitWebViewBase = WEBKIT_WEB_VIEW_BASE(g_object_new(WEBKIT_TYPE_WEB_VIEW_BASE, nullptr));
-
-    auto pageConfiguration = API::PageConfiguration::create();
-    pageConfiguration->setProcessPool(context);
-    pageConfiguration->setPreferences(preferences);
-    pageConfiguration->setPageGroup(pageGroup);
-    pageConfiguration->setRelatedPage(relatedPage);
-    pageConfiguration->setUserContentController(userContentController);
-    webkitWebViewBaseCreateWebPage(webkitWebViewBase, context, WTF::move(pageConfiguration));
+    webkitWebViewBaseCreateWebPage(webkitWebViewBase, configuration.copy());
     return webkitWebViewBase;
 }
 
@@ -1074,9 +1067,10 @@
 }
 #endif // HAVE(GTK_SCALE_FACTOR)
 
-void webkitWebViewBaseCreateWebPage(WebKitWebViewBase* webkitWebViewBase, WebProcessPool* context, Ref<API::PageConfiguration>&& configuration)
+void webkitWebViewBaseCreateWebPage(WebKitWebViewBase* webkitWebViewBase, Ref<API::PageConfiguration>&& configuration)
 {
     WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
+    WebProcessPool* context = configuration->processPool();
     priv->pageProxy = context->createWebPage(*priv->pageClient, WTF::move(configuration));
     priv->pageProxy->initializeWebPage();
 

Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h (189093 => 189094)


--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h	2015-08-28 09:48:41 UTC (rev 189093)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h	2015-08-28 11:16:05 UTC (rev 189094)
@@ -28,6 +28,7 @@
 #ifndef WebKitWebViewBasePrivate_h
 #define WebKitWebViewBasePrivate_h
 
+#include "APIPageConfiguration.h"
 #include "DragAndDropHandler.h"
 #include "GestureController.h"
 #include "WebContextMenuProxyGtk.h"
@@ -36,10 +37,10 @@
 #include "WebKitWebViewBase.h"
 #include "WebPageProxy.h"
 
-WebKitWebViewBase* webkitWebViewBaseCreate(WebKit::WebProcessPool*, WebKit::WebPreferences*, WebKit::WebPageGroup*, WebKit::WebUserContentControllerProxy*, WebKit::WebPageProxy*);
+WebKitWebViewBase* webkitWebViewBaseCreate(const API::PageConfiguration&);
 GtkIMContext* webkitWebViewBaseGetIMContext(WebKitWebViewBase*);
 WebKit::WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase*);
-void webkitWebViewBaseCreateWebPage(WebKitWebViewBase*, WebKit::WebProcessPool*, Ref<API::PageConfiguration>&&);
+void webkitWebViewBaseCreateWebPage(WebKitWebViewBase*, Ref<API::PageConfiguration>&&);
 void webkitWebViewBaseSetTooltipText(WebKitWebViewBase*, const char*);
 void webkitWebViewBaseSetTooltipArea(WebKitWebViewBase*, const WebCore::IntRect&);
 void webkitWebViewBaseForwardNextKeyEvent(WebKitWebViewBase*);

Modified: trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp (189093 => 189094)


--- trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp	2015-08-28 09:48:41 UTC (rev 189093)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp	2015-08-28 11:16:05 UTC (rev 189094)
@@ -77,7 +77,12 @@
     preferences->setJavaScriptRuntimeFlags({
     });
     RefPtr<WebPageGroup> pageGroup = WebPageGroup::create(inspectorPageGroupIdentifier(), false, false);
-    m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(&inspectorProcessPool(), preferences.get(), pageGroup.get(), nullptr, nullptr));
+
+    auto pageConfiguration = API::PageConfiguration::create();
+    pageConfiguration->setProcessPool(&inspectorProcessPool());
+    pageConfiguration->setPreferences(preferences.get());
+    pageConfiguration->setPageGroup(pageGroup.get());
+    m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(*pageConfiguration.ptr()));
     g_object_add_weak_pointer(G_OBJECT(m_inspectorView), reinterpret_cast<void**>(&m_inspectorView));
 
     WKPageUIClientV2 uiClient = {

Modified: trunk/Tools/ChangeLog (189093 => 189094)


--- trunk/Tools/ChangeLog	2015-08-28 09:48:41 UTC (rev 189093)
+++ trunk/Tools/ChangeLog	2015-08-28 11:16:05 UTC (rev 189094)
@@ -1,3 +1,20 @@
+2015-08-28  Carlos Garcia Campos  <[email protected]>
+
+        [GTK] Simplify the internal API to create a WebView
+        https://bugs.webkit.org/show_bug.cgi?id=148570
+
+        Reviewed by Žan Doberšek.
+
+        * TestWebKitAPI/PlatformWebView.h: Add initialize method for GTK+ too.
+        * TestWebKitAPI/gtk/PlatformWebViewGtk.cpp:
+        (TestWebKitAPI::PlatformWebView::PlatformWebView): Implement all
+        PlatformWebView constructors that end up calling initialize with a PageConfiguration.
+        (TestWebKitAPI::PlatformWebView::initialize): Create the WebView
+        passing the received PageConfiguration.
+        * WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
+        (WTR::PlatformWebView::PlatformWebView): Create the WebView
+        passing the received PageConfiguration.
+
 2015-08-27  Aakash Jain  <[email protected]>
 
         iOS Simulator API tests fails as Simulator is not running

Modified: trunk/Tools/TestWebKitAPI/PlatformWebView.h (189093 => 189094)


--- trunk/Tools/TestWebKitAPI/PlatformWebView.h	2015-08-28 09:48:41 UTC (rev 189093)
+++ trunk/Tools/TestWebKitAPI/PlatformWebView.h	2015-08-28 11:16:05 UTC (rev 189094)
@@ -80,6 +80,8 @@
 private:
 #if PLATFORM(MAC)
     void initialize(WKPageConfigurationRef, Class wkViewSubclass);
+#elif PLATFORM(GTK)
+    void initialize(WKPageConfigurationRef);
 #endif
 
     PlatformWKView m_view;

Modified: trunk/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp (189093 => 189094)


--- trunk/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp	2015-08-28 09:48:41 UTC (rev 189093)
+++ trunk/Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp	2015-08-28 11:16:05 UTC (rev 189094)
@@ -27,6 +27,7 @@
 #include "PlatformWebView.h"
 
 #include <WebCore/GUniquePtrGtk.h>
+#include <WebKit/WKRetainPtr.h>
 #include <gtk/gtk.h>
 #include <wtf/glib/GUniquePtr.h>
 
@@ -34,18 +35,42 @@
 
 PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
 {
-    m_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-    m_view = WKViewCreate(contextRef, pageGroupRef, nullptr);
-    gtk_container_add(GTK_CONTAINER(m_window), GTK_WIDGET(m_view));
-    gtk_widget_show(GTK_WIDGET(m_view));
-    gtk_widget_show(m_window);
+    WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageConfigurationCreate());
+    WKPageConfigurationSetContext(configuration.get(), contextRef);
+    WKPageConfigurationSetPageGroup(configuration.get(), pageGroupRef);
+
+    initialize(configuration.get());
 }
 
+PlatformWebView::PlatformWebView(WKPageConfigurationRef configuration)
+{
+    initialize(configuration);
+}
+
+PlatformWebView::PlatformWebView(WKPageRef relatedPage)
+{
+    WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageConfigurationCreate());
+    WKPageConfigurationSetContext(configuration.get(), WKPageGetContext(relatedPage));
+    WKPageConfigurationSetPageGroup(configuration.get(), WKPageGetPageGroup(relatedPage));
+    WKPageConfigurationSetRelatedPage(configuration.get(), relatedPage);
+
+    initialize(configuration.get());
+}
+
 PlatformWebView::~PlatformWebView()
 {
     gtk_widget_destroy(m_window);
 }
 
+void PlatformWebView::initialize(WKPageConfigurationRef configuration)
+{
+    m_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+    m_view = WKViewCreate(configuration);
+    gtk_container_add(GTK_CONTAINER(m_window), GTK_WIDGET(m_view));
+    gtk_widget_show(GTK_WIDGET(m_view));
+    gtk_widget_show(m_window);
+}
+
 WKPageRef PlatformWebView::page() const
 {
     return WKViewGetPage(m_view);

Modified: trunk/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp (189093 => 189094)


--- trunk/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp	2015-08-28 09:48:41 UTC (rev 189093)
+++ trunk/Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp	2015-08-28 11:16:05 UTC (rev 189094)
@@ -37,7 +37,7 @@
 namespace WTR {
 
 PlatformWebView::PlatformWebView(WKPageConfigurationRef configuration, const ViewOptions& options)
-    : m_view(WKViewCreate(WKPageConfigurationGetContext(configuration), WKPageConfigurationGetPageGroup(configuration), WKPageConfigurationGetRelatedPage(configuration)))
+    : m_view(WKViewCreate(configuration))
     , m_window(gtk_window_new(GTK_WINDOW_POPUP))
     , m_windowIsKey(true)
     , m_options(options)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to