Skip to content

Commit 01a3480

Browse files
[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. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@189094 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent fbb8bb4 commit 01a3480

File tree

11 files changed

+92
-26
lines changed

11 files changed

+92
-26
lines changed

Source/WebKit2/ChangeLog

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
2015-08-28 Carlos Garcia Campos <[email protected]>
2+
3+
[GTK] Simplify the internal API to create a WebView
4+
https://bugs.webkit.org/show_bug.cgi?id=148570
5+
6+
Reviewed by Žan Doberšek.
7+
8+
Now that all the information required to create a WebView is in
9+
API::PageConfiguration, we can simplify the internal API to
10+
receive only the configuration instead of receiving a long list of
11+
parameters that we use to build a new API::PageConfiguration.
12+
13+
* UIProcess/API/C/gtk/WKView.cpp:
14+
(WKViewCreate):
15+
* UIProcess/API/C/gtk/WKView.h:
16+
* UIProcess/API/gtk/WebKitWebContext.cpp:
17+
(webkitWebContextCreatePageForWebView):
18+
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
19+
(webkitWebViewBaseCreate):
20+
(webkitWebViewBaseCreateWebPage):
21+
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
22+
* UIProcess/gtk/WebInspectorProxyGtk.cpp:
23+
(WebKit::WebInspectorProxy::platformCreateInspectorPage):
24+
125
2015-08-27 Timothy Horton <[email protected]>
226

327
Video full-screen shouldn't use the DynamicSizeWithMinimumViewSize layout mode

Source/WebKit2/UIProcess/API/C/gtk/WKView.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,12 @@
3131
#include "WKAPICast.h"
3232
#include "WKViewPrivate.h"
3333
#include "WebKitWebViewBasePrivate.h"
34-
#include "WebPageGroup.h"
35-
#include "WebProcessPool.h"
3634

3735
using namespace WebKit;
38-
using namespace WebCore;
3936

40-
WKViewRef WKViewCreate(WKContextRef contextRef, WKPageGroupRef pageGroupRef, WKPageRef relatedPage)
37+
WKViewRef WKViewCreate(WKPageConfigurationRef configuration)
4138
{
42-
return toAPI(webkitWebViewBaseCreate(toImpl(contextRef), nullptr, toImpl(pageGroupRef), nullptr, toImpl(relatedPage)));
39+
return toAPI(webkitWebViewBaseCreate(*toImpl(configuration)));
4340
}
4441

4542
WKPageRef WKViewGetPage(WKViewRef viewRef)

Source/WebKit2/UIProcess/API/C/gtk/WKView.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
extern "C" {
3535
#endif
3636

37-
WK_EXPORT WKViewRef WKViewCreate(WKContextRef context, WKPageGroupRef pageGroup, WKPageRef relatedPage);
37+
WK_EXPORT WKViewRef WKViewCreate(WKPageConfigurationRef configuration);
3838

3939
WK_EXPORT WKPageRef WKViewGetPage(WKViewRef view);
4040

Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1318,12 +1318,13 @@ void webkitWebContextCreatePageForWebView(WebKitWebContext* context, WebKitWebVi
13181318
WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(webView);
13191319

13201320
auto pageConfiguration = API::PageConfiguration::create();
1321+
pageConfiguration->setProcessPool(context->priv->context.get());
13211322
pageConfiguration->setPreferences(webkitSettingsGetPreferences(webkit_web_view_get_settings(webView)));
13221323
pageConfiguration->setRelatedPage(relatedView ? webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(relatedView)) : nullptr);
13231324
pageConfiguration->setUserContentController(userContentManager ? webkitUserContentManagerGetUserContentControllerProxy(userContentManager) : nullptr);
13241325
pageConfiguration->setWebsiteDataStore(&webkitWebsiteDataManagerGetDataStore(context->priv->websiteDataManager.get()));
13251326
pageConfiguration->setSessionID(pageConfiguration->websiteDataStore()->websiteDataStore().sessionID());
1326-
webkitWebViewBaseCreateWebPage(webViewBase, context->priv->context.get(), WTF::move(pageConfiguration));
1327+
webkitWebViewBaseCreateWebPage(webViewBase, WTF::move(pageConfiguration));
13271328

13281329
WebPageProxy* page = webkitWebViewBaseGetPage(webViewBase);
13291330
context->priv->webViews.set(page->pageID(), webView);

Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBase.cpp

+4-10
Original file line numberDiff line numberDiff line change
@@ -1043,17 +1043,10 @@ static void webkit_web_view_base_class_init(WebKitWebViewBaseClass* webkitWebVie
10431043
containerClass->forall = webkitWebViewBaseContainerForall;
10441044
}
10451045

1046-
WebKitWebViewBase* webkitWebViewBaseCreate(WebProcessPool* context, WebPreferences* preferences, WebPageGroup* pageGroup, WebUserContentControllerProxy* userContentController, WebPageProxy* relatedPage)
1046+
WebKitWebViewBase* webkitWebViewBaseCreate(const API::PageConfiguration& configuration)
10471047
{
10481048
WebKitWebViewBase* webkitWebViewBase = WEBKIT_WEB_VIEW_BASE(g_object_new(WEBKIT_TYPE_WEB_VIEW_BASE, nullptr));
1049-
1050-
auto pageConfiguration = API::PageConfiguration::create();
1051-
pageConfiguration->setProcessPool(context);
1052-
pageConfiguration->setPreferences(preferences);
1053-
pageConfiguration->setPageGroup(pageGroup);
1054-
pageConfiguration->setRelatedPage(relatedPage);
1055-
pageConfiguration->setUserContentController(userContentController);
1056-
webkitWebViewBaseCreateWebPage(webkitWebViewBase, context, WTF::move(pageConfiguration));
1049+
webkitWebViewBaseCreateWebPage(webkitWebViewBase, configuration.copy());
10571050
return webkitWebViewBase;
10581051
}
10591052

@@ -1074,9 +1067,10 @@ static void deviceScaleFactorChanged(WebKitWebViewBase* webkitWebViewBase)
10741067
}
10751068
#endif // HAVE(GTK_SCALE_FACTOR)
10761069

1077-
void webkitWebViewBaseCreateWebPage(WebKitWebViewBase* webkitWebViewBase, WebProcessPool* context, Ref<API::PageConfiguration>&& configuration)
1070+
void webkitWebViewBaseCreateWebPage(WebKitWebViewBase* webkitWebViewBase, Ref<API::PageConfiguration>&& configuration)
10781071
{
10791072
WebKitWebViewBasePrivate* priv = webkitWebViewBase->priv;
1073+
WebProcessPool* context = configuration->processPool();
10801074
priv->pageProxy = context->createWebPage(*priv->pageClient, WTF::move(configuration));
10811075
priv->pageProxy->initializeWebPage();
10821076

Source/WebKit2/UIProcess/API/gtk/WebKitWebViewBasePrivate.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#ifndef WebKitWebViewBasePrivate_h
2929
#define WebKitWebViewBasePrivate_h
3030

31+
#include "APIPageConfiguration.h"
3132
#include "DragAndDropHandler.h"
3233
#include "GestureController.h"
3334
#include "WebContextMenuProxyGtk.h"
@@ -36,10 +37,10 @@
3637
#include "WebKitWebViewBase.h"
3738
#include "WebPageProxy.h"
3839

39-
WebKitWebViewBase* webkitWebViewBaseCreate(WebKit::WebProcessPool*, WebKit::WebPreferences*, WebKit::WebPageGroup*, WebKit::WebUserContentControllerProxy*, WebKit::WebPageProxy*);
40+
WebKitWebViewBase* webkitWebViewBaseCreate(const API::PageConfiguration&);
4041
GtkIMContext* webkitWebViewBaseGetIMContext(WebKitWebViewBase*);
4142
WebKit::WebPageProxy* webkitWebViewBaseGetPage(WebKitWebViewBase*);
42-
void webkitWebViewBaseCreateWebPage(WebKitWebViewBase*, WebKit::WebProcessPool*, Ref<API::PageConfiguration>&&);
43+
void webkitWebViewBaseCreateWebPage(WebKitWebViewBase*, Ref<API::PageConfiguration>&&);
4344
void webkitWebViewBaseSetTooltipText(WebKitWebViewBase*, const char*);
4445
void webkitWebViewBaseSetTooltipArea(WebKitWebViewBase*, const WebCore::IntRect&);
4546
void webkitWebViewBaseForwardNextKeyEvent(WebKitWebViewBase*);

Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
7777
preferences->setJavaScriptRuntimeFlags({
7878
});
7979
RefPtr<WebPageGroup> pageGroup = WebPageGroup::create(inspectorPageGroupIdentifier(), false, false);
80-
m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(&inspectorProcessPool(), preferences.get(), pageGroup.get(), nullptr, nullptr));
80+
81+
auto pageConfiguration = API::PageConfiguration::create();
82+
pageConfiguration->setProcessPool(&inspectorProcessPool());
83+
pageConfiguration->setPreferences(preferences.get());
84+
pageConfiguration->setPageGroup(pageGroup.get());
85+
m_inspectorView = GTK_WIDGET(webkitWebViewBaseCreate(*pageConfiguration.ptr()));
8186
g_object_add_weak_pointer(G_OBJECT(m_inspectorView), reinterpret_cast<void**>(&m_inspectorView));
8287

8388
WKPageUIClientV2 uiClient = {

Tools/ChangeLog

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
2015-08-28 Carlos Garcia Campos <[email protected]>
2+
3+
[GTK] Simplify the internal API to create a WebView
4+
https://bugs.webkit.org/show_bug.cgi?id=148570
5+
6+
Reviewed by Žan Doberšek.
7+
8+
* TestWebKitAPI/PlatformWebView.h: Add initialize method for GTK+ too.
9+
* TestWebKitAPI/gtk/PlatformWebViewGtk.cpp:
10+
(TestWebKitAPI::PlatformWebView::PlatformWebView): Implement all
11+
PlatformWebView constructors that end up calling initialize with a PageConfiguration.
12+
(TestWebKitAPI::PlatformWebView::initialize): Create the WebView
13+
passing the received PageConfiguration.
14+
* WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
15+
(WTR::PlatformWebView::PlatformWebView): Create the WebView
16+
passing the received PageConfiguration.
17+
118
2015-08-27 Aakash Jain <[email protected]>
219

320
iOS Simulator API tests fails as Simulator is not running

Tools/TestWebKitAPI/PlatformWebView.h

+2
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ class PlatformWebView {
8080
private:
8181
#if PLATFORM(MAC)
8282
void initialize(WKPageConfigurationRef, Class wkViewSubclass);
83+
#elif PLATFORM(GTK)
84+
void initialize(WKPageConfigurationRef);
8385
#endif
8486

8587
PlatformWKView m_view;

Tools/TestWebKitAPI/gtk/PlatformWebViewGtk.cpp

+30-5
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,50 @@
2727
#include "PlatformWebView.h"
2828

2929
#include <WebCore/GUniquePtrGtk.h>
30+
#include <WebKit/WKRetainPtr.h>
3031
#include <gtk/gtk.h>
3132
#include <wtf/glib/GUniquePtr.h>
3233

3334
namespace TestWebKitAPI {
3435

3536
PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
3637
{
37-
m_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
38-
m_view = WKViewCreate(contextRef, pageGroupRef, nullptr);
39-
gtk_container_add(GTK_CONTAINER(m_window), GTK_WIDGET(m_view));
40-
gtk_widget_show(GTK_WIDGET(m_view));
41-
gtk_widget_show(m_window);
38+
WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageConfigurationCreate());
39+
WKPageConfigurationSetContext(configuration.get(), contextRef);
40+
WKPageConfigurationSetPageGroup(configuration.get(), pageGroupRef);
41+
42+
initialize(configuration.get());
43+
}
44+
45+
PlatformWebView::PlatformWebView(WKPageConfigurationRef configuration)
46+
{
47+
initialize(configuration);
48+
}
49+
50+
PlatformWebView::PlatformWebView(WKPageRef relatedPage)
51+
{
52+
WKRetainPtr<WKPageConfigurationRef> configuration = adoptWK(WKPageConfigurationCreate());
53+
WKPageConfigurationSetContext(configuration.get(), WKPageGetContext(relatedPage));
54+
WKPageConfigurationSetPageGroup(configuration.get(), WKPageGetPageGroup(relatedPage));
55+
WKPageConfigurationSetRelatedPage(configuration.get(), relatedPage);
56+
57+
initialize(configuration.get());
4258
}
4359

4460
PlatformWebView::~PlatformWebView()
4561
{
4662
gtk_widget_destroy(m_window);
4763
}
4864

65+
void PlatformWebView::initialize(WKPageConfigurationRef configuration)
66+
{
67+
m_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
68+
m_view = WKViewCreate(configuration);
69+
gtk_container_add(GTK_CONTAINER(m_window), GTK_WIDGET(m_view));
70+
gtk_widget_show(GTK_WIDGET(m_view));
71+
gtk_widget_show(m_window);
72+
}
73+
4974
WKPageRef PlatformWebView::page() const
5075
{
5176
return WKViewGetPage(m_view);

Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
namespace WTR {
3838

3939
PlatformWebView::PlatformWebView(WKPageConfigurationRef configuration, const ViewOptions& options)
40-
: m_view(WKViewCreate(WKPageConfigurationGetContext(configuration), WKPageConfigurationGetPageGroup(configuration), WKPageConfigurationGetRelatedPage(configuration)))
40+
: m_view(WKViewCreate(configuration))
4141
, m_window(gtk_window_new(GTK_WINDOW_POPUP))
4242
, m_windowIsKey(true)
4343
, m_options(options)

0 commit comments

Comments
 (0)