Diff
Modified: trunk/Tools/ChangeLog (232722 => 232723)
--- trunk/Tools/ChangeLog 2018-06-11 18:11:23 UTC (rev 232722)
+++ trunk/Tools/ChangeLog 2018-06-11 18:59:21 UTC (rev 232723)
@@ -1,3 +1,56 @@
+2018-06-11 Fujii Hironori <hironori.fu...@sony.com>
+
+ [Win][MiniBrowser] Add WebKitBrowserWindow class for modern WebKit API
+ https://bugs.webkit.org/show_bug.cgi?id=186478
+
+ Reviewed by Alex Christensen.
+
+ Added "New WebKit Window" and "New WebKitLegacy Window" menu
+ items. Disabled the menu item "New WebKit Window" if
+ !ENABLE(WEBKIT).
+
+ * MiniBrowser/win/CMakeLists.txt: Added WebKitBrowserWindow.cpp
+ source file and ENABLE_WEBKIT macro if ENABLE_WEBKIT.
+ * MiniBrowser/win/MainWindow.cpp:
+ (MainWindow::MainWindow):
+ (MainWindow::create):
+ (MainWindow::init):
+ (MainWindow::WndProc):
+ * MiniBrowser/win/MainWindow.h:
+ * MiniBrowser/win/MiniBrowserLib.rc:
+ * MiniBrowser/win/MiniBrowserLibResource.h:
+ * MiniBrowser/win/PrintWebUIDelegate.cpp:
+ (PrintWebUIDelegate::createWebViewWithRequest):
+ * MiniBrowser/win/WebKitBrowserWindow.cpp: Added.
+ (createString):
+ (toUtf8):
+ (createWKString):
+ (createWKURL):
+ (WebKitBrowserWindow::create):
+ (WebKitBrowserWindow::WebKitBrowserWindow):
+ (WebKitBrowserWindow::init):
+ (WebKitBrowserWindow::hwnd):
+ (WebKitBrowserWindow::loadURL):
+ (WebKitBrowserWindow::loadHTMLString):
+ (WebKitBrowserWindow::navigateForwardOrBackward):
+ (WebKitBrowserWindow::navigateToHistory):
+ (WebKitBrowserWindow::setPreference):
+ (WebKitBrowserWindow::print):
+ (WebKitBrowserWindow::launchInspector):
+ (WebKitBrowserWindow::setUserAgent):
+ (WebKitBrowserWindow::userAgent):
+ (WebKitBrowserWindow::showLayerTree):
+ (WebKitBrowserWindow::updateStatistics):
+ (WebKitBrowserWindow::resetZoom):
+ (WebKitBrowserWindow::zoomIn):
+ (WebKitBrowserWindow::zoomOut):
+ (toWebKitBrowserWindow):
+ (WebKitBrowserWindow::didReceiveTitleForFrame):
+ (WebKitBrowserWindow::didCommitLoadForFrame):
+ * MiniBrowser/win/WebKitBrowserWindow.h:
+ * MiniBrowser/win/WinMain.cpp:
+ (wWinMain):
+
2018-06-11 Keith Miller <keith_mil...@apple.com>
Add missing whitespace to run-jsc command
Modified: trunk/Tools/MiniBrowser/win/CMakeLists.txt (232722 => 232723)
--- trunk/Tools/MiniBrowser/win/CMakeLists.txt 2018-06-11 18:11:23 UTC (rev 232722)
+++ trunk/Tools/MiniBrowser/win/CMakeLists.txt 2018-06-11 18:59:21 UTC (rev 232723)
@@ -38,6 +38,14 @@
)
endif ()
+if (ENABLE_WEBKIT)
+ add_definitions(-DENABLE_WEBKIT)
+ list(APPEND MiniBrowser_SOURCES
+ WebKitBrowserWindow.cpp
+ )
+ list(APPEND MiniBrowser_LIBRARIES WebKit)
+endif ()
+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${MSVC_RUNTIME_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ENTRY:wWinMainCRTStartup")
Modified: trunk/Tools/MiniBrowser/win/MainWindow.cpp (232722 => 232723)
--- trunk/Tools/MiniBrowser/win/MainWindow.cpp 2018-06-11 18:11:23 UTC (rev 232722)
+++ trunk/Tools/MiniBrowser/win/MainWindow.cpp 2018-06-11 18:59:21 UTC (rev 232723)
@@ -28,7 +28,12 @@
#include "Common.h"
#include "MiniBrowserLibResource.h"
+#include "WebKitLegacyBrowserWindow.h"
+#if ENABLE(WEBKIT)
+#include "WebKitBrowserWindow.h"
+#endif
+
namespace WebCore {
float deviceScaleFactorForWindow(HWND);
}
@@ -78,7 +83,8 @@
RegisterClassEx(&wcex);
}
-MainWindow::MainWindow()
+MainWindow::MainWindow(BrowserWindowType type)
+ : m_browserWindowType(type)
{
s_numInstances++;
}
@@ -88,9 +94,9 @@
s_numInstances--;
}
-Ref<MainWindow> MainWindow::create()
+Ref<MainWindow> MainWindow::create(BrowserWindowType type)
{
- return adoptRef(*new MainWindow());
+ return adoptRef(*new MainWindow(type));
}
bool MainWindow::init(HINSTANCE hInstance, bool usesLayeredWebView, bool pageLoadTesting)
@@ -105,6 +111,10 @@
if (!m_hMainWnd)
return false;
+#if !ENABLE(WEBKIT)
+ EnableMenuItem(GetMenu(m_hMainWnd), IDM_NEW_WEBKIT_WINDOW, MF_GRAYED);
+#endif
+
float scaleFactor = WebCore::deviceScaleFactorForWindow(nullptr);
m_hBackButtonWnd = CreateWindow(L"BUTTON", L"<", WS_CHILD | WS_VISIBLE | BS_TEXT, 0, 0, 0, 0, m_hMainWnd, reinterpret_cast<HMENU>(IDM_HISTORY_BACKWARD), hInstance, 0);
m_hForwardButtonWnd = CreateWindow(L"BUTTON", L">", WS_CHILD | WS_VISIBLE | BS_TEXT, scaleFactor * controlButtonWidth, 0, 0, 0, m_hMainWnd, reinterpret_cast<HMENU>(IDM_HISTORY_FORWARD), hInstance, 0);
@@ -113,7 +123,12 @@
DefEditProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC));
SetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(EditProc));
- m_browserWindow = WebKitLegacyBrowserWindow::create(m_hMainWnd, m_hURLBarWnd, usesLayeredWebView, pageLoadTesting);
+ 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;
HRESULT hr = m_browserWindow->init();
@@ -171,6 +186,18 @@
case IDC_URL_BAR:
thisWindow->onURLBarEnter();
break;
+ case IDM_NEW_WEBKIT_WINDOW: {
+ auto& newWindow = MainWindow::create(BrowserWindowType::WebKit).leakRef();
+ newWindow.init(hInst);
+ ShowWindow(newWindow.hwnd(), SW_SHOW);
+ break;
+ }
+ case IDM_NEW_WEBKITLEGACY_WINDOW: {
+ auto& newWindow = MainWindow::create(BrowserWindowType::WebKitLegacy).leakRef();
+ newWindow.init(hInst);
+ ShowWindow(newWindow.hwnd(), SW_SHOW);
+ break;
+ }
case IDM_ABOUT:
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
break;
Modified: trunk/Tools/MiniBrowser/win/MainWindow.h (232722 => 232723)
--- trunk/Tools/MiniBrowser/win/MainWindow.h 2018-06-11 18:11:23 UTC (rev 232722)
+++ trunk/Tools/MiniBrowser/win/MainWindow.h 2018-06-11 18:59:21 UTC (rev 232723)
@@ -25,7 +25,7 @@
#pragma once
-#include "WebKitLegacyBrowserWindow.h"
+#include "BrowserWindow.h"
#include <memory>
#include <string>
#include <wtf/RefPtr.h>
@@ -32,7 +32,11 @@
class MainWindow : public RefCounted<MainWindow> {
public:
- static Ref<MainWindow> create();
+ enum class BrowserWindowType {
+ WebKit,
+ WebKitLegacy
+ };
+ static Ref<MainWindow> create(BrowserWindowType);
~MainWindow();
bool init(HINSTANCE hInstance, bool usesLayeredWebView = false, bool pageLoadTesting = false);
@@ -51,7 +55,7 @@
static std::wstring s_windowClass;
static size_t s_numInstances;
- MainWindow();
+ MainWindow(BrowserWindowType);
bool toggleMenuItem(UINT menuID);
void onURLBarEnter();
void updateDeviceScaleFactor();
@@ -62,5 +66,6 @@
HWND m_hForwardButtonWnd { nullptr };
HWND m_hCacheWnd { nullptr };
HGDIOBJ m_hURLBarFont { nullptr };
+ BrowserWindowType m_browserWindowType;
RefPtr<BrowserWindow> m_browserWindow;
};
Modified: trunk/Tools/MiniBrowser/win/MiniBrowserLib.rc (232722 => 232723)
--- trunk/Tools/MiniBrowser/win/MiniBrowserLib.rc 2018-06-11 18:11:23 UTC (rev 232722)
+++ trunk/Tools/MiniBrowser/win/MiniBrowserLib.rc 2018-06-11 18:59:21 UTC (rev 232723)
@@ -44,6 +44,8 @@
BEGIN
MENUITEM "&Print\tCtrl-P", IDM_PRINT
MENUITEM "E&xit", IDM_EXIT
+ MENUITEM "New WebKit Window", IDM_NEW_WEBKIT_WINDOW
+ MENUITEM "New WebKitLegacy Window", IDM_NEW_WEBKITLEGACY_WINDOW
END
POPUP "&View"
BEGIN
Property changes on: trunk/Tools/MiniBrowser/win/MiniBrowserLib.rc
___________________________________________________________________
Added: svn:executable
+*
\ No newline at end of property
Modified: trunk/Tools/MiniBrowser/win/MiniBrowserLibResource.h (232722 => 232723)
--- trunk/Tools/MiniBrowser/win/MiniBrowserLibResource.h 2018-06-11 18:11:23 UTC (rev 232722)
+++ trunk/Tools/MiniBrowser/win/MiniBrowserLibResource.h 2018-06-11 18:59:21 UTC (rev 232723)
@@ -110,6 +110,8 @@
#define IDC_AUTH_USER 1053
#define IDC_AUTH_PASSWORD 1054
#define IDC_URL_BAR 1055
+#define IDM_NEW_WEBKIT_WINDOW 32776
+#define IDM_NEW_WEBKITLEGACY_WINDOW 32777
#define IDC_STATIC -1
// Next default values for new objects
@@ -118,7 +120,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 175
-#define _APS_NEXT_COMMAND_VALUE 32776
+#define _APS_NEXT_COMMAND_VALUE 32778
#define _APS_NEXT_CONTROL_VALUE 1055
#define _APS_NEXT_SYMED_VALUE 110
#endif
Property changes on: trunk/Tools/MiniBrowser/win/MiniBrowserLibResource.h
___________________________________________________________________
Added: svn:executable
+*
\ No newline at end of property
Modified: trunk/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp (232722 => 232723)
--- trunk/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp 2018-06-11 18:11:23 UTC (rev 232722)
+++ trunk/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp 2018-06-11 18:59:21 UTC (rev 232723)
@@ -65,7 +65,7 @@
if (!request)
return E_POINTER;
- auto& newWindow = MainWindow::create().leakRef();
+ auto& newWindow = MainWindow::create(MainWindow::BrowserWindowType::WebKitLegacy).leakRef();
bool ok = newWindow.init(hInst);
if (!ok)
return E_FAIL;
Added: trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp (0 => 232723)
--- trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp (rev 0)
+++ trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.cpp 2018-06-11 18:59:21 UTC (rev 232723)
@@ -0,0 +1,240 @@
+/*
+ * Copyright (C) 2018 Sony Interactive Entertainment Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "stdafx.h"
+#include "WebKitBrowserWindow.h"
+
+#include "MiniBrowserLibResource.h"
+#include <WebKit/WKInspector.h>
+
+std::wstring
+createString(WKStringRef wkString)
+{
+ size_t maxSize = WKStringGetMaximumUTF8CStringSize(wkString);
+ char* utf8Buffer = new char[maxSize];
+ size_t utf8Length = WKStringGetUTF8CString(wkString, utf8Buffer, maxSize);
+
+ int wcharLength = MultiByteToWideChar(CP_UTF8, 0, utf8Buffer, utf8Length, 0, 0);
+ wchar_t* wcharBuffer = new wchar_t[wcharLength + 1];
+ MultiByteToWideChar(CP_UTF8, 0, utf8Buffer, utf8Length, wcharBuffer, wcharLength);
+ wcharBuffer[wcharLength] = L'\0';
+ std::wstring dest(wcharBuffer);
+ return dest;
+}
+
+std::wstring createString(WKURLRef wkURL)
+{
+ WKRetainPtr<WKStringRef> url = ""
+ return createString(url.get());
+}
+
+std::string toUtf8(const wchar_t* src, size_t srcLength)
+{
+ int utf8Length = WideCharToMultiByte(CP_UTF8, 0, src, srcLength, 0, 0, nullptr, nullptr);
+ char* utf8Buffer = new char[utf8Length];
+ WideCharToMultiByte(CP_UTF8, 0, src, srcLength,
+ utf8Buffer, utf8Length, nullptr, nullptr);
+ utf8Buffer[utf8Length] = '\0';
+ std::string dest(utf8Buffer);
+ delete[] utf8Buffer;
+ return dest;
+}
+
+WKRetainPtr<WKStringRef>
+createWKString(_bstr_t str)
+{
+ auto utf8 = toUtf8(str, str.length());
+ return adoptWK(WKStringCreateWithUTF8CString(utf8.c_str()));
+}
+
+WKRetainPtr<WKURLRef>
+createWKURL(_bstr_t str)
+{
+ auto utf8 = toUtf8(str, str.length());
+ return adoptWK(WKURLCreateWithUTF8CString(utf8.c_str()));
+}
+
+Ref<BrowserWindow> WebKitBrowserWindow::create(HWND mainWnd, HWND urlBarWnd, bool, bool)
+{
+ return adoptRef(*new WebKitBrowserWindow(mainWnd, urlBarWnd));
+}
+
+WebKitBrowserWindow::WebKitBrowserWindow(HWND mainWnd, HWND urlBarWnd)
+ : m_hMainWnd(mainWnd)
+ , m_urlBarWnd(urlBarWnd)
+{
+ RECT rect = { };
+ auto conf = adoptWK(WKPageConfigurationCreate());
+ auto context = adoptWK(WKContextCreate());
+ WKPageConfigurationSetContext(conf.get(), context.get());
+
+ m_view = adoptWK(WKViewCreate(rect, conf.get(), mainWnd));
+ auto page = WKViewGetPage(m_view.get());
+
+ WKPageLoaderClientV0 loadClient = {{ 0, this }};
+ loadClient.didReceiveTitleForFrame = didReceiveTitleForFrame;
+ loadClient.didCommitLoadForFrame = didCommitLoadForFrame;
+ WKPageSetPageLoaderClient(page, &loadClient.base);
+}
+
+HRESULT WebKitBrowserWindow::init()
+{
+ return S_OK;
+}
+
+HWND WebKitBrowserWindow::hwnd()
+{
+ return WKViewGetWindow(m_view.get());
+}
+
+HRESULT WebKitBrowserWindow::loadURL(const BSTR& url)
+{
+ auto page = WKViewGetPage(m_view.get());
+ WKPageLoadURL(page, createWKURL(url).get());
+ return true;
+}
+
+HRESULT WebKitBrowserWindow::loadHTMLString(const BSTR& str)
+{
+ auto page = WKViewGetPage(m_view.get());
+ auto url = ""
+ WKPageLoadHTMLString(page, createWKString(_bstr_t(str)).get(), url.get());
+ return true;
+}
+
+void WebKitBrowserWindow::navigateForwardOrBackward(UINT menuID)
+{
+ auto page = WKViewGetPage(m_view.get());
+ if (menuID == IDM_HISTORY_FORWARD)
+ WKPageGoForward(page);
+ else
+ WKPageGoBack(page);
+}
+
+void WebKitBrowserWindow::navigateToHistory(UINT menuID)
+{
+ // Not implemented
+}
+
+void WebKitBrowserWindow::setPreference(UINT menuID, bool enable)
+{
+ auto page = WKViewGetPage(m_view.get());
+ auto pgroup = WKPageGetPageGroup(page);
+ auto pref = WKPageGroupGetPreferences(pgroup);
+ switch (menuID) {
+ case IDM_DISABLE_IMAGES:
+ WKPreferencesSetLoadsImagesAutomatically(pref, !enable);
+ break;
+ case IDM_DISABLE_JAVASCRIPT:
+ WKPreferencesSetJavaScriptEnabled(pref, !enable);
+ break;
+ }
+}
+
+void WebKitBrowserWindow::print()
+{
+ // Not implemented
+}
+
+void WebKitBrowserWindow::launchInspector()
+{
+ auto page = WKViewGetPage(m_view.get());
+ auto inspector = WKPageGetInspector(page);
+ WKInspectorShow(inspector);
+}
+
+void WebKitBrowserWindow::setUserAgent(UINT menuID)
+{
+ // This method should be removed.
+}
+
+void WebKitBrowserWindow::setUserAgent(_bstr_t& customUAString)
+{
+ auto page = WKViewGetPage(m_view.get());
+ auto ua = createWKString(customUAString);
+ WKPageSetCustomUserAgent(page, ua.get());
+}
+
+_bstr_t WebKitBrowserWindow::userAgent()
+{
+ auto page = WKViewGetPage(m_view.get());
+ auto ua = adoptWK(WKPageCopyUserAgent(page));
+ return createString(ua.get()).c_str();
+}
+
+void WebKitBrowserWindow::showLayerTree()
+{
+ // Not implemented
+}
+
+void WebKitBrowserWindow::updateStatistics(HWND hDlg)
+{
+ // Not implemented
+}
+
+
+void WebKitBrowserWindow::resetZoom()
+{
+ auto page = WKViewGetPage(m_view.get());
+ WKPageSetPageZoomFactor(page, 1);
+}
+
+void WebKitBrowserWindow::zoomIn()
+{
+ auto page = WKViewGetPage(m_view.get());
+ double s = WKPageGetPageZoomFactor(page);
+ WKPageSetPageZoomFactor(page, s * 1.25);
+}
+
+void WebKitBrowserWindow::zoomOut()
+{
+ auto page = WKViewGetPage(m_view.get());
+ double s = WKPageGetPageZoomFactor(page);
+ WKPageSetPageZoomFactor(page, s * 0.8);
+}
+
+static WebKitBrowserWindow& toWebKitBrowserWindow(const void *clientInfo)
+{
+ return *const_cast<WebKitBrowserWindow*>(static_cast<const WebKitBrowserWindow*>(clientInfo));
+}
+
+void WebKitBrowserWindow::didReceiveTitleForFrame(WKPageRef page, WKStringRef title, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+ std::wstring titleString = createString(title) + L" [WebKit]";
+ auto& thisWindow = toWebKitBrowserWindow(clientInfo);
+ SetWindowText(thisWindow.m_hMainWnd, titleString.c_str());
+}
+
+void WebKitBrowserWindow::didCommitLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
+{
+ if (!WKFrameIsMainFrame(frame))
+ return;
+ auto& thisWindow = toWebKitBrowserWindow(clientInfo);
+
+ WKRetainPtr<WKURLRef> wkurl = adoptWK(WKFrameCopyURL(frame));
+ std::wstring urlString = createString(wkurl.get());
+ SetWindowText(thisWindow.m_urlBarWnd, urlString.c_str());
+}
Copied: trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.h (from rev 232722, trunk/Tools/MiniBrowser/win/MainWindow.h) (0 => 232723)
--- trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.h (rev 0)
+++ trunk/Tools/MiniBrowser/win/WebKitBrowserWindow.h 2018-06-11 18:59:21 UTC (rev 232723)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2018 Sony Interactive Entertainment Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#pragma once
+
+#include "BrowserWindow.h"
+#include <WebKit/WKRetainPtr.h>
+#include <WebKit/WebKit2_C.h>
+
+class WebKitBrowserWindow : public BrowserWindow {
+public:
+ static Ref<BrowserWindow> create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false, bool pageLoadTesting = false);
+
+private:
+ WebKitBrowserWindow(HWND mainWnd, HWND urlBarWnd);
+
+ HRESULT init() override;
+ HWND hwnd() override;
+
+ HRESULT loadHTMLString(const BSTR&) override;
+ HRESULT loadURL(const BSTR& url) override;
+ void navigateForwardOrBackward(UINT menuID) override;
+ void navigateToHistory(UINT menuID) override;
+ void setPreference(UINT menuID, bool enable) override;
+
+ void print() override;
+ void launchInspector() override;
+
+ _bstr_t userAgent() override;
+ void setUserAgent(UINT menuID) override;
+ void setUserAgent(_bstr_t&) override;
+
+ void showLayerTree() override;
+ void updateStatistics(HWND dialog) override;
+
+ void resetZoom() override;
+ void zoomIn() override;
+ void zoomOut() override;
+
+ static void didReceiveTitleForFrame(WKPageRef, WKStringRef, WKFrameRef, WKTypeRef, const void *);
+ static void didCommitLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void *);
+
+ WKRetainPtr<WKViewRef> m_view;
+ HWND m_hMainWnd { nullptr };
+ HWND m_urlBarWnd { nullptr };
+};
Modified: trunk/Tools/MiniBrowser/win/WinMain.cpp (232722 => 232723)
--- trunk/Tools/MiniBrowser/win/WinMain.cpp 2018-06-11 18:11:23 UTC (rev 232722)
+++ trunk/Tools/MiniBrowser/win/WinMain.cpp 2018-06-11 18:59:21 UTC (rev 232723)
@@ -65,7 +65,7 @@
::SetProcessDPIAware();
- auto& mainWindow = MainWindow::create().leakRef();
+ auto& mainWindow = MainWindow::create(MainWindow::BrowserWindowType::WebKitLegacy).leakRef();
HRESULT hr = mainWindow.init(hInst, usesLayeredWebView, pageLoadTesting);
if (FAILED(hr))
goto exit;