|
27 | 27 | #include "PlatformWebView.h"
|
28 | 28 |
|
29 | 29 | #include <WebCore/GUniquePtrGtk.h>
|
| 30 | +#include <WebKit/WKRetainPtr.h> |
30 | 31 | #include <gtk/gtk.h>
|
31 | 32 | #include <wtf/glib/GUniquePtr.h>
|
32 | 33 |
|
33 | 34 | namespace TestWebKitAPI {
|
34 | 35 |
|
35 | 36 | PlatformWebView::PlatformWebView(WKContextRef contextRef, WKPageGroupRef pageGroupRef)
|
36 | 37 | {
|
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()); |
42 | 58 | }
|
43 | 59 |
|
44 | 60 | PlatformWebView::~PlatformWebView()
|
45 | 61 | {
|
46 | 62 | gtk_widget_destroy(m_window);
|
47 | 63 | }
|
48 | 64 |
|
| 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 | + |
49 | 74 | WKPageRef PlatformWebView::page() const
|
50 | 75 | {
|
51 | 76 | return WKViewGetPage(m_view);
|
|
0 commit comments