[Win][MiniBrowser] Add a new BrowserWindow interface to abstract WK1 and WK2 BrowserWindow
https://bugs.webkit.org/show_bug.cgi?id=186421
Reviewed by Ryosuke Niwa.
This is the core patch to make MiniBrowser to support WK1 and WK2
windows (Bug 184770).
I will rename MiniBrowser class to WK1BrowserWindow in a follow-up
patch (Bug 184770 Comment 12).
* MiniBrowser/win/BrowserWindow.h: Added.
* MiniBrowser/win/MainWindow.cpp:
(MainWindow::WndProc):
* MiniBrowser/win/MainWindow.h:
(MainWindow::browserWindow const):
* MiniBrowser/win/MiniBrowser.cpp:
(MiniBrowser::create):
(MiniBrowser::navigateForwardOrBackward): Removed the unsed first argument hWnd.
(MiniBrowser::navigateToHistory): Ditto.
* MiniBrowser/win/MiniBrowser.h: Inherit BrowserWindow interface.
Make all other methods private and make delegates classes friends.
* MiniBrowser/win/PrintWebUIDelegate.cpp:
(PrintWebUIDelegate::createWebViewWithRequest):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@232616 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 9f29e82..185b40a 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,5 +1,32 @@
2018-06-07 Fujii Hironori <Hironori.Fujii@sony.com>
+ [Win][MiniBrowser] Add a new BrowserWindow interface to abstract WK1 and WK2 BrowserWindow
+ https://bugs.webkit.org/show_bug.cgi?id=186421
+
+ Reviewed by Ryosuke Niwa.
+
+ This is the core patch to make MiniBrowser to support WK1 and WK2
+ windows (Bug 184770).
+
+ I will rename MiniBrowser class to WK1BrowserWindow in a follow-up
+ patch (Bug 184770 Comment 12).
+
+ * MiniBrowser/win/BrowserWindow.h: Added.
+ * MiniBrowser/win/MainWindow.cpp:
+ (MainWindow::WndProc):
+ * MiniBrowser/win/MainWindow.h:
+ (MainWindow::browserWindow const):
+ * MiniBrowser/win/MiniBrowser.cpp:
+ (MiniBrowser::create):
+ (MiniBrowser::navigateForwardOrBackward): Removed the unsed first argument hWnd.
+ (MiniBrowser::navigateToHistory): Ditto.
+ * MiniBrowser/win/MiniBrowser.h: Inherit BrowserWindow interface.
+ Make all other methods private and make delegates classes friends.
+ * MiniBrowser/win/PrintWebUIDelegate.cpp:
+ (PrintWebUIDelegate::createWebViewWithRequest):
+
+2018-06-07 Fujii Hironori <Hironori.Fujii@sony.com>
+
[Win][MiniBrowser] MiniBrowser::updateDeviceScaleFactor should be a MainWindow's method
https://bugs.webkit.org/show_bug.cgi?id=186387
diff --git a/Tools/MiniBrowser/win/BrowserWindow.h b/Tools/MiniBrowser/win/BrowserWindow.h
new file mode 100644
index 0000000..9aeaec4
--- /dev/null
+++ b/Tools/MiniBrowser/win/BrowserWindow.h
@@ -0,0 +1,58 @@
+/*
+ * 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 <windows.h>
+#include <wtf/RefCounted.h>
+
+class BrowserWindow : public RefCounted<BrowserWindow> {
+public:
+ virtual ~BrowserWindow() { };
+
+ virtual HRESULT init() = 0;
+ virtual HWND hwnd() = 0;
+
+ virtual HRESULT loadHTMLString(const BSTR&) = 0;
+ virtual HRESULT loadURL(const BSTR& passedURL) = 0;
+ virtual void navigateForwardOrBackward(UINT menuID) = 0;
+ virtual void navigateToHistory(UINT menuID) = 0;
+ virtual void setPreference(UINT menuID, bool enable) = 0;
+ virtual bool usesLayeredWebView() const { return false; }
+
+ virtual void print() = 0;
+ virtual void launchInspector() = 0;
+
+ virtual _bstr_t userAgent() = 0;
+ virtual void setUserAgent(UINT menuID) = 0;
+ virtual void setUserAgent(_bstr_t& customUAString) = 0;
+
+ virtual void showLayerTree() = 0;
+ virtual void updateStatistics(HWND dialog) = 0;
+
+ virtual void resetZoom() = 0;
+ virtual void zoomIn() = 0;
+ virtual void zoomOut() = 0;
+};
diff --git a/Tools/MiniBrowser/win/MainWindow.cpp b/Tools/MiniBrowser/win/MainWindow.cpp
index b9aac7f..5ed23cf 100644
--- a/Tools/MiniBrowser/win/MainWindow.cpp
+++ b/Tools/MiniBrowser/win/MainWindow.cpp
@@ -163,7 +163,7 @@
return DefWindowProc(hWnd, message, wParam, lParam);
}
if (wmId >= IDM_HISTORY_LINK0 && wmId <= IDM_HISTORY_LINK9) {
- thisWindow->browserWindow()->navigateToHistory(hWnd, wmId);
+ thisWindow->browserWindow()->navigateToHistory(wmId);
break;
}
// Parse the menu selections:
@@ -191,7 +191,7 @@
break;
case IDM_HISTORY_BACKWARD:
case IDM_HISTORY_FORWARD:
- thisWindow->browserWindow()->navigateForwardOrBackward(hWnd, wmId);
+ thisWindow->browserWindow()->navigateForwardOrBackward(wmId);
break;
case IDM_UA_OTHER:
DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_USER_AGENT), hWnd, customUserAgentDialogProc, reinterpret_cast<LPARAM>(thisWindow.get()));
diff --git a/Tools/MiniBrowser/win/MainWindow.h b/Tools/MiniBrowser/win/MainWindow.h
index 2de4b47..4404d1c 100644
--- a/Tools/MiniBrowser/win/MainWindow.h
+++ b/Tools/MiniBrowser/win/MainWindow.h
@@ -39,7 +39,7 @@
void resizeSubViews();
HWND hwnd() const { return m_hMainWnd; }
- MiniBrowser* browserWindow() const { return m_browserWindow.get(); }
+ BrowserWindow* browserWindow() const { return m_browserWindow.get(); }
void loadURL(BSTR url);
@@ -62,5 +62,5 @@
HWND m_hForwardButtonWnd { nullptr };
HWND m_hCacheWnd { nullptr };
HGDIOBJ m_hURLBarFont { nullptr };
- RefPtr<MiniBrowser> m_browserWindow;
+ RefPtr<BrowserWindow> m_browserWindow;
};
diff --git a/Tools/MiniBrowser/win/MiniBrowser.cpp b/Tools/MiniBrowser/win/MiniBrowser.cpp
index 602ad6f..e967297 100644
--- a/Tools/MiniBrowser/win/MiniBrowser.cpp
+++ b/Tools/MiniBrowser/win/MiniBrowser.cpp
@@ -60,7 +60,7 @@
typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr;
-Ref<MiniBrowser> MiniBrowser::create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, bool pageLoadTesting)
+Ref<BrowserWindow> MiniBrowser::create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, bool pageLoadTesting)
{
return adoptRef(*new MiniBrowser(mainWnd, urlBarWnd, useLayeredWebView, pageLoadTesting));
}
@@ -430,7 +430,7 @@
m_inspector->show();
}
-void MiniBrowser::navigateForwardOrBackward(HWND hWnd, UINT menuID)
+void MiniBrowser::navigateForwardOrBackward(UINT menuID)
{
if (!m_webView)
return;
@@ -442,7 +442,7 @@
m_webView->goBack(&wentBackOrForward);
}
-void MiniBrowser::navigateToHistory(HWND hWnd, UINT menuID)
+void MiniBrowser::navigateToHistory(UINT menuID)
{
if (!m_webView)
return;
diff --git a/Tools/MiniBrowser/win/MiniBrowser.h b/Tools/MiniBrowser/win/MiniBrowser.h
index ec5428c..3633b28 100644
--- a/Tools/MiniBrowser/win/MiniBrowser.h
+++ b/Tools/MiniBrowser/win/MiniBrowser.h
@@ -24,12 +24,12 @@
*/
#pragma once
+#include "BrowserWindow.h"
#include "PageLoadTestClient.h"
#include <WebKitLegacy/WebKit.h>
#include <comip.h>
#include <memory>
#include <vector>
-#include <wtf/RefCounted.h>
typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr;
typedef _com_ptr_t<_com_IIID<IWebView, &__uuidof(IWebView)>> IWebViewPtr;
@@ -48,9 +48,17 @@
typedef _com_ptr_t<_com_IIID<IWebDownloadDelegate, &__uuidof(IWebDownloadDelegate)>> IWebDownloadDelegatePtr;
typedef _com_ptr_t<_com_IIID<IWebFramePrivate, &__uuidof(IWebFramePrivate)>> IWebFramePrivatePtr;
-class MiniBrowser : public RefCounted<MiniBrowser> {
+class MiniBrowser : public BrowserWindow {
public:
- static Ref<MiniBrowser> create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false, bool pageLoadTesting = false);
+ static Ref<BrowserWindow> create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false, bool pageLoadTesting = false);
+
+private:
+ friend class AccessibilityDelegate;
+ friend class MiniBrowserWebHost;
+ friend class PrintWebUIDelegate;
+ friend class WebDownloadDelegate;
+ friend class ResourceLoadDelegate;
+ friend class PageLoadTestClient;
ULONG AddRef();
ULONG Release();
@@ -63,8 +71,8 @@
void showLastVisitedSites(IWebView&);
void launchInspector();
- void navigateForwardOrBackward(HWND hWnd, UINT menuID);
- void navigateToHistory(HWND hWnd, UINT menuID);
+ void navigateForwardOrBackward(UINT menuID);
+ void navigateToHistory(UINT menuID);
void exitProgram();
bool seedInitialDefaultPreferences();
bool setToDefaultPreferences();
@@ -106,7 +114,6 @@
void updateStatistics(HWND dialog);
void setPreference(UINT menuID, bool enable);
-private:
MiniBrowser(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, bool pageLoadTesting);
void subclassForLayeredWindow();
bool setCacheFolder();
diff --git a/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp b/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp
index c7e6ddd..f4db4d2 100644
--- a/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp
+++ b/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp
@@ -29,9 +29,7 @@
#include "Common.h"
#include "MainWindow.h"
-#if USE(CF)
-#include <CoreFoundation/CoreFoundation.h>
-#endif
+#include "MiniBrowser.h"
#include <WebCore/COMPtr.h>
#include <WebKitLegacy/WebKitCOMAPI.h>
#include <comip.h>
@@ -41,6 +39,10 @@
#include <shlwapi.h>
#include <wininet.h>
+#if USE(CF)
+#include <CoreFoundation/CoreFoundation.h>
+#endif
+
static const int MARGIN = 20;
HRESULT PrintWebUIDelegate::runJavaScriptAlertPanelWithMessage(_In_opt_ IWebView*, _In_ BSTR message)
@@ -69,7 +71,8 @@
return E_FAIL;
ShowWindow(newWindow.hwnd(), SW_SHOW);
- *newWebView = newWindow.browserWindow()->webView();
+ auto& newBrowserWindow = *static_cast<MiniBrowser*>(newWindow.browserWindow());
+ *newWebView = newBrowserWindow.webView();
IWebFramePtr frame;
HRESULT hr;
hr = (*newWebView)->mainFrame(&frame.GetInterfacePtr());