Diff
Modified: trunk/Tools/ChangeLog (242983 => 242984)
--- trunk/Tools/ChangeLog 2019-03-15 01:54:22 UTC (rev 242983)
+++ trunk/Tools/ChangeLog 2019-03-15 02:14:45 UTC (rev 242984)
@@ -1,3 +1,41 @@
+2019-03-14 Fujii Hironori <[email protected]>
+
+ [Win][MinBrowser][WK2] Implement createNewPage of WKPageUIClient to open a new window
+ https://bugs.webkit.org/show_bug.cgi?id=195740
+
+ Reviewed by Ross Kirsling.
+
+ window.open doesn't work for WebKitBrowserWindow because it is not
+ implemented yet.
+
+ 1. Implemented createNewPage callback of WKPageUIClient.
+ 2. Changed MainWindow to take a BrowserWindow factory function
+ instead of BrowserWindowType to be flexible to create
+ BrowserWindow with extra settings.
+ 3. Renamed MainWindow::BrowserWindowType to BrowserWindowType
+ because it is not relevant with MainWindow anymore.
+
+ * MiniBrowser/win/Common.cpp:
+ (parseCommandLine):
+ * MiniBrowser/win/Common.h:
+ (CommandLineOptions::CommandLineOptions):
+ * MiniBrowser/win/MainWindow.cpp:
+ (MainWindow::MainWindow):
+ (MainWindow::create):
+ (MainWindow::init):
+ (MainWindow::WndProc):
+ * MiniBrowser/win/MainWindow.h:
+ * MiniBrowser/win/PrintWebUIDelegate.cpp:
+ (PrintWebUIDelegate::createWebViewWithRequest):
+ * MiniBrowser/win/WebKitBrowserWindow.cpp:
+ (WebKitBrowserWindow::create): Moved WKPageConfigurationRef related code from WebKitBrowserWindow::WebKitBrowserWindow.
+ (WebKitBrowserWindow::WebKitBrowserWindow): Added a WKPageConfigurationRef parameter.
+ (WebKitBrowserWindow::updateProxySettings):
+ (WebKitBrowserWindow::createNewPage):
+ * MiniBrowser/win/WebKitBrowserWindow.h:
+ * MiniBrowser/win/WinMain.cpp:
+ (wWinMain):
+
2019-03-14 Simon Fraser <[email protected]>
Make it possible to test scrolling tree layer manipulation more easily
Modified: trunk/Tools/MiniBrowser/win/Common.cpp (242983 => 242984)
--- trunk/Tools/MiniBrowser/win/Common.cpp 2019-03-15 01:54:22 UTC (rev 242983)
+++ trunk/Tools/MiniBrowser/win/Common.cpp 2019-03-15 02:14:45 UTC (rev 242984)
@@ -245,10 +245,10 @@
else if (!wcsicmp(argv[i], L"--performance"))
options.pageLoadTesting = true;
else if (!wcsicmp(argv[i], L"--wk1") || !wcsicmp(argv[i], L"--legacy"))
- options.windowType = MainWindow::BrowserWindowType::WebKitLegacy;
+ options.windowType = BrowserWindowType::WebKitLegacy;
#if ENABLE(WEBKIT)
else if (!wcsicmp(argv[i], L"--wk2") || !wcsicmp(argv[i], L"--webkit"))
- options.windowType = MainWindow::BrowserWindowType::WebKit;
+ options.windowType = BrowserWindowType::WebKit;
#endif
else if (!options.requestedURL)
options.requestedURL = argv[i];
Modified: trunk/Tools/MiniBrowser/win/Common.h (242983 => 242984)
--- trunk/Tools/MiniBrowser/win/Common.h 2019-03-15 01:54:22 UTC (rev 242983)
+++ trunk/Tools/MiniBrowser/win/Common.h 2019-03-15 02:14:45 UTC (rev 242984)
@@ -29,18 +29,23 @@
#include "MainWindow.h"
#include "WebKitLegacyBrowserWindow.h"
+enum class BrowserWindowType {
+ WebKit,
+ WebKitLegacy
+};
+
struct CommandLineOptions {
bool usesLayeredWebView { };
bool useFullDesktop { };
bool pageLoadTesting { };
- MainWindow::BrowserWindowType windowType;
+ BrowserWindowType windowType;
_bstr_t requestedURL;
CommandLineOptions()
#if ENABLE(WEBKIT)
- : windowType(MainWindow::BrowserWindowType::WebKit)
+ : windowType(BrowserWindowType::WebKit)
#else
- : windowType(MainWindow::BrowserWindowType::WebKitLegacy)
+ : windowType(BrowserWindowType::WebKitLegacy)
#endif
{
}
Modified: trunk/Tools/MiniBrowser/win/MainWindow.cpp (242983 => 242984)
--- trunk/Tools/MiniBrowser/win/MainWindow.cpp 2019-03-15 01:54:22 UTC (rev 242983)
+++ trunk/Tools/MiniBrowser/win/MainWindow.cpp 2019-03-15 02:14:45 UTC (rev 242984)
@@ -83,8 +83,7 @@
RegisterClassEx(&wcex);
}
-MainWindow::MainWindow(BrowserWindowType type)
- : m_browserWindowType(type)
+MainWindow::MainWindow()
{
s_numInstances++;
}
@@ -94,12 +93,12 @@
s_numInstances--;
}
-Ref<MainWindow> MainWindow::create(BrowserWindowType type)
+Ref<MainWindow> MainWindow::create()
{
- return adoptRef(*new MainWindow(type));
+ return adoptRef(*new MainWindow());
}
-bool MainWindow::init(HINSTANCE hInstance, bool usesLayeredWebView, bool pageLoadTesting)
+bool MainWindow::init(BrowserWindowFactory factory, HINSTANCE hInstance, bool usesLayeredWebView, bool pageLoadTesting)
{
registerClass(hInstance);
@@ -123,11 +122,6 @@
DefEditProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC));
SetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(EditProc));
- auto factory = WebKitLegacyBrowserWindow::create;
-#if ENABLE(WEBKIT)
- if (m_browserWindowType == BrowserWindowType::WebKit)
- factory = WebKitBrowserWindow::create;
-#endif
m_browserWindow = factory(m_hMainWnd, m_hURLBarWnd, usesLayeredWebView, pageLoadTesting);
if (!m_browserWindow)
return false;
@@ -186,15 +180,17 @@
case IDC_URL_BAR:
thisWindow->onURLBarEnter();
break;
+#if ENABLE(WEBKIT)
case IDM_NEW_WEBKIT_WINDOW: {
- auto& newWindow = MainWindow::create(BrowserWindowType::WebKit).leakRef();
- newWindow.init(hInst);
+ auto& newWindow = MainWindow::create().leakRef();
+ newWindow.init(WebKitBrowserWindow::create, hInst);
ShowWindow(newWindow.hwnd(), SW_SHOW);
break;
}
+#endif
case IDM_NEW_WEBKITLEGACY_WINDOW: {
- auto& newWindow = MainWindow::create(BrowserWindowType::WebKitLegacy).leakRef();
- newWindow.init(hInst);
+ auto& newWindow = MainWindow::create().leakRef();
+ newWindow.init(WebKitLegacyBrowserWindow::create, hInst);
ShowWindow(newWindow.hwnd(), SW_SHOW);
break;
}
Modified: trunk/Tools/MiniBrowser/win/MainWindow.h (242983 => 242984)
--- trunk/Tools/MiniBrowser/win/MainWindow.h 2019-03-15 01:54:22 UTC (rev 242983)
+++ trunk/Tools/MiniBrowser/win/MainWindow.h 2019-03-15 02:14:45 UTC (rev 242984)
@@ -26,6 +26,7 @@
#pragma once
#include "BrowserWindow.h"
+#include <functional>
#include <memory>
#include <string>
#include <wtf/RefPtr.h>
@@ -32,14 +33,12 @@
class MainWindow : public RefCounted<MainWindow> {
public:
- enum class BrowserWindowType {
- WebKit,
- WebKitLegacy
- };
- static Ref<MainWindow> create(BrowserWindowType);
+ using BrowserWindowFactory = std::function<Ref<BrowserWindow>(HWND mainWnd, HWND urlBarWnd, bool usesLayeredWebView, bool pageLoadTesting)>;
+ static Ref<MainWindow> create();
+
~MainWindow();
- bool init(HINSTANCE hInstance, bool usesLayeredWebView = false, bool pageLoadTesting = false);
+ bool init(BrowserWindowFactory, HINSTANCE hInstance, bool usesLayeredWebView = false, bool pageLoadTesting = false);
void resizeSubViews();
HWND hwnd() const { return m_hMainWnd; }
@@ -55,7 +54,7 @@
static std::wstring s_windowClass;
static size_t s_numInstances;
- MainWindow(BrowserWindowType);
+ MainWindow();
bool toggleMenuItem(UINT menuID);
void onURLBarEnter();
void updateDeviceScaleFactor();
@@ -66,6 +65,5 @@
HWND m_hForwardButtonWnd { nullptr };
HWND m_hCacheWnd { nullptr };
HGDIOBJ m_hURLBarFont { nullptr };
- BrowserWindowType m_browserWindowType;
RefPtr<BrowserWindow> m_browserWindow;
};
Modified: trunk/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp (242983 => 242984)
--- trunk/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp 2019-03-15 01:54:22 UTC (rev 242983)
+++ trunk/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp 2019-03-15 02:14:45 UTC (rev 242984)
@@ -65,8 +65,8 @@
if (!request)
return E_POINTER;
- auto& newWindow = MainWindow::create(MainWindow::BrowserWindowType::WebKitLegacy).leakRef();
- bool ok = newWindow.init(hInst);
+ auto& newWindow = MainWindow::create().leakRef();
+ bool ok = newWindow.init(WebKitLegacyBrowserWindow::create, hInst);
if (!ok)
return E_FAIL;
ShowWindow(newWindow.hwnd(), SW_SHOW);
Modified: trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp (242983 => 242984)
--- trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp 2019-03-15 01:54:22 UTC (rev 242983)
+++ trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp 2019-03-15 02:14:45 UTC (rev 242984)
@@ -84,24 +84,24 @@
Ref<BrowserWindow> WebKitBrowserWindow::create(HWND mainWnd, HWND urlBarWnd, bool, bool)
{
- return adoptRef(*new WebKitBrowserWindow(mainWnd, urlBarWnd));
+ auto conf = WKPageConfigurationCreate();
+
+ auto prefs = WKPreferencesCreate();
+ WKPreferencesSetDeveloperExtrasEnabled(prefs, true);
+ WKPageConfigurationSetPreferences(conf, prefs);
+
+ auto context = WKContextCreateWithConfiguration(nullptr);
+ WKPageConfigurationSetContext(conf, context);
+
+ return adoptRef(*new WebKitBrowserWindow(conf, mainWnd, urlBarWnd));
}
-WebKitBrowserWindow::WebKitBrowserWindow(HWND mainWnd, HWND urlBarWnd)
+WebKitBrowserWindow::WebKitBrowserWindow(WKPageConfigurationRef conf, HWND mainWnd, HWND urlBarWnd)
: m_hMainWnd(mainWnd)
, m_urlBarWnd(urlBarWnd)
{
RECT rect = { };
- auto conf = adoptWK(WKPageConfigurationCreate());
-
- auto prefs = WKPreferencesCreate();
- WKPreferencesSetDeveloperExtrasEnabled(prefs, true);
- WKPageConfigurationSetPreferences(conf.get(), prefs);
-
- m_context = adoptWK(WKContextCreateWithConfiguration(nullptr));
- WKPageConfigurationSetContext(conf.get(), m_context.get());
-
- m_view = adoptWK(WKViewCreate(rect, conf.get(), mainWnd));
+ m_view = adoptWK(WKViewCreate(rect, conf, mainWnd));
auto page = WKViewGetPage(m_view.get());
WKPageNavigationClientV0 navigationClient = { };
@@ -112,12 +112,19 @@
navigationClient.didReceiveAuthenticationChallenge = didReceiveAuthenticationChallenge;
WKPageSetPageNavigationClient(page, &navigationClient.base);
+ WKPageUIClientV13 uiClient = { };
+ uiClient.base.version = 13;
+ uiClient.base.clientInfo = this;
+ uiClient.createNewPage = createNewPage;
+ WKPageSetPageUIClient(page, &uiClient.base);
+
updateProxySettings();
}
void WebKitBrowserWindow::updateProxySettings()
{
- auto store = WKContextGetWebsiteDataStore(m_context.get());
+ auto context = WKPageGetContext(WKViewGetPage(m_view.get()));
+ auto store = WKContextGetWebsiteDataStore(context);
if (!m_proxy.enable) {
WKWebsiteDataStoreDisableNetworkProxySettings(store);
@@ -291,3 +298,18 @@
WKAuthenticationDecisionListenerUseCredential(decisionListener, nullptr);
}
+
+WKPageRef WebKitBrowserWindow::createNewPage(WKPageRef page, WKPageConfigurationRef configuration, WKNavigationActionRef navigationAction, WKWindowFeaturesRef windowFeatures, const void *clientInfo)
+{
+ auto& newWindow = MainWindow::create().leakRef();
+ auto factory = [configuration](HWND mainWnd, HWND urlBarWnd, bool, bool) -> auto {
+ return adoptRef(*new WebKitBrowserWindow(configuration, mainWnd, urlBarWnd));
+ };
+ bool ok = newWindow.init(factory, hInst);
+ if (!ok)
+ return nullptr;
+ ShowWindow(newWindow.hwnd(), SW_SHOW);
+ auto& newBrowserWindow = *static_cast<WebKitBrowserWindow*>(newWindow.browserWindow());
+ WKRetainPtr<WKPageRef> newPage = WKViewGetPage(newBrowserWindow.m_view.get());
+ return newPage.leakRef();
+}
Modified: trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.h (242983 => 242984)
--- trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.h 2019-03-15 01:54:22 UTC (rev 242983)
+++ trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.h 2019-03-15 02:14:45 UTC (rev 242984)
@@ -34,7 +34,7 @@
static Ref<BrowserWindow> create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false, bool pageLoadTesting = false);
private:
- WebKitBrowserWindow(HWND mainWnd, HWND urlBarWnd);
+ WebKitBrowserWindow(WKPageConfigurationRef, HWND mainWnd, HWND urlBarWnd);
HRESULT init() override;
HWND hwnd() override;
@@ -64,8 +64,8 @@
static void didFinishNavigation(WKPageRef, WKNavigationRef, WKTypeRef, const void*);
static void didCommitNavigation(WKPageRef, WKNavigationRef, WKTypeRef, const void*);
static void didReceiveAuthenticationChallenge(WKPageRef, WKAuthenticationChallengeRef, const void*);
+ static WKPageRef createNewPage(WKPageRef, WKPageConfigurationRef, WKNavigationActionRef, WKWindowFeaturesRef, const void *);
- WKRetainPtr<WKContextRef> m_context;
WKRetainPtr<WKViewRef> m_view;
HWND m_hMainWnd { nullptr };
HWND m_urlBarWnd { nullptr };
Modified: trunk/Tools/MiniBrowser/win/WinMain.cpp (242983 => 242984)
--- trunk/Tools/MiniBrowser/win/WinMain.cpp 2019-03-15 01:54:22 UTC (rev 242983)
+++ trunk/Tools/MiniBrowser/win/WinMain.cpp 2019-03-15 02:14:45 UTC (rev 242984)
@@ -32,8 +32,13 @@
#include "Common.h"
#include "MiniBrowserLibResource.h"
#include "MiniBrowserReplace.h"
+#include "WebKitLegacyBrowserWindow.h"
#include <WebKitLegacy/WebKitCOMAPI.h>
+#if ENABLE(WEBKIT)
+#include "WebKitBrowserWindow.h"
+#endif
+
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpstrCmdLine, _In_ int nCmdShow)
{
#ifdef _CRTDBG_MAP_ALLOC
@@ -60,8 +65,13 @@
::SetProcessDPIAware();
- auto& mainWindow = MainWindow::create(options.windowType).leakRef();
- HRESULT hr = mainWindow.init(hInst, options.usesLayeredWebView, options.pageLoadTesting);
+ auto factory = WebKitLegacyBrowserWindow::create;
+#if ENABLE(WEBKIT)
+ if (options.windowType == BrowserWindowType::WebKit)
+ factory = WebKitBrowserWindow::create;
+#endif
+ auto& mainWindow = MainWindow::create().leakRef();
+ HRESULT hr = mainWindow.init(factory, hInst, options.usesLayeredWebView, options.pageLoadTesting);
if (FAILED(hr))
goto exit;