WebKit Bugzilla
Attachment 342132 Details for
Bug 186263
: [Win][MiniBrowser] Support multiple windows properly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186263-20180607162156.patch (text/plain), 27.65 KB, created by
Fujii Hironori
on 2018-06-07 00:21:57 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Fujii Hironori
Created:
2018-06-07 00:21:57 PDT
Size:
27.65 KB
patch
obsolete
>Subversion Revision: 232574 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 95329ffd6887a11a90cb634768ae9274cc51efcd..e2d4218a522218307bc074ab12f4547ca44e6c51 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,72 @@ >+2018-06-07 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ [Win][MiniBrowser] Support multiple windows properly >+ https://bugs.webkit.org/show_bug.cgi?id=186263 >+ >+ Reviewed by Ryosuke Niwa. >+ >+ The current implementation of >+ PrintWebUIDelegate::createWebViewWithRequest is wrong. It is using >+ CreateProcess to open a new window, and doesn't return the new >+ instance of IWebView. As the result, for example, window.close >+ doesn't work as expected. >+ >+ In this change, a new MainWindow is created and return the >+ IWebView in PrintWebUIDelegate::createWebViewWithRequest. >+ >+ In addition to it, this change unifies the lifetime of MiniBrowser >+ and its delegates AccessibilityDelegate, PrintWebUIDelegate, >+ ResourceLoadDelegate and WebDownloadDelegate in order to keep >+ MiniBrowser alive as long as the delegates live. Because the >+ window of webview keeps references of such delegates and accesses >+ those after MiniBrowser destruction. >+ >+ * MiniBrowser/win/MainWindow.h: Added s_numInstances class member >+ to count the number of instance to close the application. Do not >+ use unique_ptr for m_browserWindow because it has ref count now. >+ * MiniBrowser/win/MainWindow.cpp: >+ (MainWindow::MainWindow): Increment s_numInstances. >+ (MainWindow::~MainWindow): Decrement s_numInstances. >+ (MainWindow::create): >+ (MainWindow::init): >+ (MainWindow::WndProc): Rename thiz to thisWindow. Keep this >+ instance alive during this function by using RefPtr<MainWindow>. >+ Deref the MainWindow instance on WM_DESTROY. Quit the application >+ when the last MainWindow is closed. >+ (MainWindow::cachesDialogProc): Rename thiz to thisWindow. >+ (MainWindow::customUserAgentDialogProc): Ditto. >+ * MiniBrowser/win/MiniBrowser.h: Added declarations AddRef and Release. >+ * MiniBrowser/win/MiniBrowser.cpp: >+ (MiniBrowser::create): >+ (MiniBrowser::AddRef): >+ (MiniBrowser::Release): >+ (MiniBrowser::init): Passes this to the constructors of delegates. >+ * MiniBrowser/win/AccessibilityDelegate.cpp: >+ (AccessibilityDelegate::AddRef): Delegate to MiniBrowser. >+ (AccessibilityDelegate::Release): Ditto. >+ * MiniBrowser/win/AccessibilityDelegate.h: Removed m_refCount. >+ (AccessibilityDelegate::AccessibilityDelegate): >+ * MiniBrowser/win/MiniBrowserWebHost.cpp: >+ (MiniBrowserWebHost::AddRef): Delegate to MiniBrowser. >+ (MiniBrowserWebHost::Release): Ditto. >+ * MiniBrowser/win/MiniBrowserWebHost.h: Removed m_refCount. >+ * MiniBrowser/win/PrintWebUIDelegate.cpp: >+ (PrintWebUIDelegate::createWebViewWithRequest): Create a new >+ MainWindow and return the IWebView. >+ (PrintWebUIDelegate::AddRef): Delegate to MiniBrowser. >+ (PrintWebUIDelegate::Release): Ditto. >+ * MiniBrowser/win/PrintWebUIDelegate.h: Removed m_refCount. >+ (PrintWebUIDelegate::PrintWebUIDelegate): >+ * MiniBrowser/win/ResourceLoadDelegate.cpp: >+ (ResourceLoadDelegate::AddRef): Delegate to MiniBrowser. >+ (ResourceLoadDelegate::Release): Ditto. >+ * MiniBrowser/win/ResourceLoadDelegate.h: Removed m_refCount. >+ * MiniBrowser/win/WebDownloadDelegate.cpp: >+ (WebDownloadDelegate::WebDownloadDelegate): >+ (WebDownloadDelegate::AddRef): Delegate to MiniBrowser. >+ (WebDownloadDelegate::Release): Ditto. >+ * MiniBrowser/win/WebDownloadDelegate.h: Removed m_refCount. >+ > 2018-06-06 Fujii Hironori <Hironori.Fujii@sony.com> > > [Win][MiniBrowser] Remove gMainWindow global variable >diff --git a/Tools/MiniBrowser/win/AccessibilityDelegate.cpp b/Tools/MiniBrowser/win/AccessibilityDelegate.cpp >index ce8a9a6e9a8458e63a1f2a3242dce0934f7d6db2..ae68b4272cf89cc46ad64db7fe5fb4a7fe0f8273 100644 >--- a/Tools/MiniBrowser/win/AccessibilityDelegate.cpp >+++ b/Tools/MiniBrowser/win/AccessibilityDelegate.cpp >@@ -26,6 +26,7 @@ > #include "stdafx.h" > #include "AccessibilityDelegate.h" > >+#include "MiniBrowser.h" > #include <WebKitLegacy/WebKitCOMAPI.h> > #include <commctrl.h> > #include <commdlg.h> >@@ -52,16 +53,12 @@ HRESULT AccessibilityDelegate::QueryInterface(_In_ REFIID riid, _COM_Outptr_ voi > > ULONG AccessibilityDelegate::AddRef() > { >- return ++m_refCount; >+ return m_client.AddRef(); > } > > ULONG AccessibilityDelegate::Release() > { >- ULONG newRef = --m_refCount; >- if (!newRef) >- delete this; >- >- return newRef; >+ return m_client.Release(); > } > > HRESULT AccessibilityDelegate::fireFrameLoadStartedEvents() >diff --git a/Tools/MiniBrowser/win/AccessibilityDelegate.h b/Tools/MiniBrowser/win/AccessibilityDelegate.h >index 39cdbe2052d1dd7f52b7ca4da1c1151071c4f6fc..78db286dba3c588ceac3ec92a183e07bbf54ceb5 100644 >--- a/Tools/MiniBrowser/win/AccessibilityDelegate.h >+++ b/Tools/MiniBrowser/win/AccessibilityDelegate.h >@@ -28,9 +28,12 @@ > > #include <WebKitLegacy/WebKit.h> > >+class MiniBrowser; >+ > class AccessibilityDelegate : public IAccessibilityDelegate { > public: >- AccessibilityDelegate() { } >+ AccessibilityDelegate(MiniBrowser& client) >+ : m_client(client) { } > virtual HRESULT STDMETHODCALLTYPE QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject); > virtual ULONG STDMETHODCALLTYPE AddRef(); > virtual ULONG STDMETHODCALLTYPE Release(); >@@ -38,7 +41,7 @@ public: > virtual HRESULT STDMETHODCALLTYPE fireFrameLoadStartedEvents(); > virtual HRESULT STDMETHODCALLTYPE fireFrameLoadFinishedEvents(); > private: >- int m_refCount { 1 }; >+ MiniBrowser& m_client; > }; > > #endif >diff --git a/Tools/MiniBrowser/win/MainWindow.cpp b/Tools/MiniBrowser/win/MainWindow.cpp >index cd8c53039029a54e953eda55cbfc134c5e01be71..51831a31dc45b8fc5e2c57be6187c76a3da1abf4 100644 >--- a/Tools/MiniBrowser/win/MainWindow.cpp >+++ b/Tools/MiniBrowser/win/MainWindow.cpp >@@ -27,7 +27,6 @@ > #include "MainWindow.h" > > #include "Common.h" >-#include "MiniBrowser.h" > #include "MiniBrowserLibResource.h" > > namespace WebCore { >@@ -42,6 +41,7 @@ static LRESULT CALLBACK EditProc(HWND, UINT, WPARAM, LPARAM); > static INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); > > std::wstring MainWindow::s_windowClass; >+size_t MainWindow::s_numInstances; > > static std::wstring loadString(int id) > { >@@ -77,6 +77,21 @@ void MainWindow::registerClass(HINSTANCE hInstance) > RegisterClassEx(&wcex); > } > >+MainWindow::MainWindow() >+{ >+ s_numInstances++; >+} >+ >+MainWindow::~MainWindow() >+{ >+ s_numInstances--; >+} >+ >+Ref<MainWindow> MainWindow::create() >+{ >+ return adoptRef(*new MainWindow()); >+} >+ > bool MainWindow::init(HINSTANCE hInstance, bool usesLayeredWebView, bool pageLoadTesting) > { > registerClass(hInstance); >@@ -97,7 +112,7 @@ bool MainWindow::init(HINSTANCE hInstance, bool usesLayeredWebView, bool pageLoa > DefEditProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC)); > SetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(EditProc)); > >- m_browserWindow = std::make_unique<MiniBrowser>(m_hMainWnd, m_hURLBarWnd, usesLayeredWebView, pageLoadTesting); >+ m_browserWindow = MiniBrowser::create(m_hMainWnd, m_hURLBarWnd, usesLayeredWebView, pageLoadTesting); > if (!m_browserWindow) > return false; > HRESULT hr = m_browserWindow->init(); >@@ -133,7 +148,7 @@ void MainWindow::resizeSubViews() > > LRESULT CALLBACK MainWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) > { >- MainWindow& thiz = *reinterpret_cast<MainWindow*>(GetWindowLongPtr(hWnd, GWLP_USERDATA)); >+ RefPtr<MainWindow> thisWindow = reinterpret_cast<MainWindow*>(GetWindowLongPtr(hWnd, GWLP_USERDATA)); > switch (message) { > case WM_CREATE: > SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(reinterpret_cast<LPCREATESTRUCT>(lParam)->lpCreateParams)); >@@ -149,13 +164,13 @@ LRESULT CALLBACK MainWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPA > return DefWindowProc(hWnd, message, wParam, lParam); > } > if (wmId >= IDM_HISTORY_LINK0 && wmId <= IDM_HISTORY_LINK9) { >- thiz.browserWindow()->navigateToHistory(hWnd, wmId); >+ thisWindow->browserWindow()->navigateToHistory(hWnd, wmId); > break; > } > // Parse the menu selections: > switch (wmId) { > case IDC_URL_BAR: >- thiz.onURLBarEnter(); >+ thisWindow->onURLBarEnter(); > break; > case IDM_ABOUT: > DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); >@@ -164,53 +179,57 @@ LRESULT CALLBACK MainWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPA > DestroyWindow(hWnd); > break; > case IDM_PRINT: >- thiz.browserWindow()->print(); >+ thisWindow->browserWindow()->print(); > break; > case IDM_WEB_INSPECTOR: >- thiz.browserWindow()->launchInspector(); >+ thisWindow->browserWindow()->launchInspector(); > break; > case IDM_CACHES: >- if (!::IsWindow(thiz.m_hCacheWnd)) { >- thiz.m_hCacheWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CACHES), hWnd, cachesDialogProc, reinterpret_cast<LPARAM>(&thiz)); >- ::ShowWindow(thiz.m_hCacheWnd, SW_SHOW); >+ if (!::IsWindow(thisWindow->m_hCacheWnd)) { >+ thisWindow->m_hCacheWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CACHES), hWnd, cachesDialogProc, reinterpret_cast<LPARAM>(thisWindow.get())); >+ ::ShowWindow(thisWindow->m_hCacheWnd, SW_SHOW); > } > break; > case IDM_HISTORY_BACKWARD: > case IDM_HISTORY_FORWARD: >- thiz.browserWindow()->navigateForwardOrBackward(hWnd, wmId); >+ thisWindow->browserWindow()->navigateForwardOrBackward(hWnd, wmId); > break; > case IDM_UA_OTHER: >- DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_USER_AGENT), hWnd, customUserAgentDialogProc, reinterpret_cast<LPARAM>(&thiz)); >+ DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_USER_AGENT), hWnd, customUserAgentDialogProc, reinterpret_cast<LPARAM>(thisWindow.get())); > break; > case IDM_ACTUAL_SIZE: >- thiz.browserWindow()->resetZoom(); >+ thisWindow->browserWindow()->resetZoom(); > break; > case IDM_ZOOM_IN: >- thiz.browserWindow()->zoomIn(); >+ thisWindow->browserWindow()->zoomIn(); > break; > case IDM_ZOOM_OUT: >- thiz.browserWindow()->zoomOut(); >+ thisWindow->browserWindow()->zoomOut(); > break; > case IDM_SHOW_LAYER_TREE: >- thiz.browserWindow()->showLayerTree(); >+ thisWindow->browserWindow()->showLayerTree(); > break; > default: >- if (!thiz.toggleMenuItem(wmId)) >+ if (!thisWindow->toggleMenuItem(wmId)) > return DefWindowProc(hWnd, message, wParam, lParam); > } > } > break; > case WM_DESTROY: >+ SetWindowLongPtr(hWnd, GWLP_USERDATA, 0); >+ thisWindow->deref(); >+ if (s_numInstances > 1) >+ return 0; > #if USE(CF) > CFRunLoopStop(CFRunLoopGetMain()); > #endif > PostQuitMessage(0); > break; > case WM_SIZE: >- thiz.resizeSubViews(); >+ thisWindow->resizeSubViews(); > break; > case WM_DPICHANGED: >- thiz.browserWindow()->updateDeviceScaleFactor(); >+ thisWindow->browserWindow()->updateDeviceScaleFactor(); > return DefWindowProc(hWnd, message, wParam, lParam); > default: > return DefWindowProc(hWnd, message, wParam, lParam); >@@ -316,7 +335,7 @@ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) > > INT_PTR CALLBACK MainWindow::cachesDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) > { >- MainWindow& thiz = *reinterpret_cast<MainWindow*>(GetWindowLongPtr(hDlg, DWLP_USER)); >+ MainWindow& thisWindow = *reinterpret_cast<MainWindow*>(GetWindowLongPtr(hDlg, DWLP_USER)); > switch (message) { > case WM_INITDIALOG: > SetWindowLongPtr(hDlg, DWLP_USER, lParam); >@@ -327,7 +346,7 @@ INT_PTR CALLBACK MainWindow::cachesDialogProc(HWND hDlg, UINT message, WPARAM wP > if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { > ::KillTimer(hDlg, IDT_UPDATE_STATS); > ::DestroyWindow(hDlg); >- thiz.m_hCacheWnd = 0; >+ thisWindow.m_hCacheWnd = 0; > return (INT_PTR)TRUE; > } > break; >@@ -337,7 +356,7 @@ INT_PTR CALLBACK MainWindow::cachesDialogProc(HWND hDlg, UINT message, WPARAM wP > return (INT_PTR)TRUE; > > case WM_PAINT: >- thiz.browserWindow()->updateStatistics(hDlg); >+ thisWindow.browserWindow()->updateStatistics(hDlg); > break; > } > >@@ -346,14 +365,14 @@ INT_PTR CALLBACK MainWindow::cachesDialogProc(HWND hDlg, UINT message, WPARAM wP > > INT_PTR CALLBACK MainWindow::customUserAgentDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) > { >- MainWindow& thiz = *reinterpret_cast<MainWindow*>(GetWindowLongPtr(hDlg, DWLP_USER)); >+ MainWindow& thisWindow = *reinterpret_cast<MainWindow*>(GetWindowLongPtr(hDlg, DWLP_USER)); > switch (message) { > case WM_INITDIALOG: { >- MainWindow& thiz = *reinterpret_cast<MainWindow*>(lParam); >+ MainWindow& thisWindow = *reinterpret_cast<MainWindow*>(lParam); > SetWindowLongPtr(hDlg, DWLP_USER, lParam); > HWND edit = ::GetDlgItem(hDlg, IDC_USER_AGENT_INPUT); > _bstr_t userAgent; >- userAgent = thiz.browserWindow()->userAgent(); >+ userAgent = thisWindow.browserWindow()->userAgent(); > > ::SetWindowText(edit, static_cast<LPCTSTR>(userAgent)); > return (INT_PTR)TRUE; >@@ -369,8 +388,8 @@ INT_PTR CALLBACK MainWindow::customUserAgentDialogProc(HWND hDlg, UINT message, > > _bstr_t bstr(buffer); > if (bstr.length()) { >- thiz.browserWindow()->setUserAgent(bstr); >- thiz.toggleMenuItem(IDM_UA_OTHER); >+ thisWindow.browserWindow()->setUserAgent(bstr); >+ thisWindow.toggleMenuItem(IDM_UA_OTHER); > } > } > >diff --git a/Tools/MiniBrowser/win/MainWindow.h b/Tools/MiniBrowser/win/MainWindow.h >index 0ec4eee25f906a67261ecaa13676aa430b9e87d7..81d8dd018c3c2f8993a8c718f9a5416acb7231c6 100644 >--- a/Tools/MiniBrowser/win/MainWindow.h >+++ b/Tools/MiniBrowser/win/MainWindow.h >@@ -25,13 +25,16 @@ > > #pragma once > >+#include "MiniBrowser.h" > #include <memory> > #include <string> >+#include <wtf/RefPtr.h> > >-class MiniBrowser; >- >-class MainWindow { >+class MainWindow : public RefCounted<MainWindow> { > public: >+ static Ref<MainWindow> create(); >+ >+ ~MainWindow(); > bool init(HINSTANCE hInstance, bool usesLayeredWebView = false, bool pageLoadTesting = false); > > void resizeSubViews(); >@@ -46,7 +49,9 @@ private: > static INT_PTR CALLBACK cachesDialogProc(HWND, UINT, WPARAM, LPARAM); > static void registerClass(HINSTANCE hInstance); > static std::wstring s_windowClass; >+ static size_t s_numInstances; > >+ MainWindow(); > bool toggleMenuItem(UINT menuID); > void onURLBarEnter(); > >@@ -55,5 +60,5 @@ private: > HWND m_hBackButtonWnd { nullptr }; > HWND m_hForwardButtonWnd { nullptr }; > HWND m_hCacheWnd { nullptr }; >- std::unique_ptr<MiniBrowser> m_browserWindow; >+ RefPtr<MiniBrowser> m_browserWindow; > }; >diff --git a/Tools/MiniBrowser/win/MiniBrowser.cpp b/Tools/MiniBrowser/win/MiniBrowser.cpp >index 96ec3eac5fb28848fa1755c8350bc15a9241faef..c57815b94225b217090f7cadb7c3d97928ce2c18 100644 >--- a/Tools/MiniBrowser/win/MiniBrowser.cpp >+++ b/Tools/MiniBrowser/win/MiniBrowser.cpp >@@ -60,6 +60,11 @@ static const int maxHistorySize = 10; > > typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequest)>> IWebMutableURLRequestPtr; > >+Ref<MiniBrowser> MiniBrowser::create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, bool pageLoadTesting) >+{ >+ return adoptRef(*new MiniBrowser(mainWnd, urlBarWnd, useLayeredWebView, pageLoadTesting)); >+} >+ > MiniBrowser::MiniBrowser(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, bool pageLoadTesting) > : m_hMainWnd(mainWnd) > , m_hURLBarWnd(urlBarWnd) >@@ -68,6 +73,19 @@ MiniBrowser::MiniBrowser(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, b > { > } > >+ULONG MiniBrowser::AddRef() >+{ >+ ref(); >+ return refCount(); >+} >+ >+ULONG MiniBrowser::Release() >+{ >+ auto count = refCount(); >+ deref(); >+ return --count; >+} >+ > HRESULT MiniBrowser::init() > { > updateDeviceScaleFactor(); >@@ -111,11 +129,11 @@ HRESULT MiniBrowser::init() > if (FAILED(hr)) > return hr; > >- hr = setUIDelegate(new PrintWebUIDelegate()); >+ hr = setUIDelegate(new PrintWebUIDelegate(*this)); > if (FAILED (hr)) > return hr; > >- hr = setAccessibilityDelegate(new AccessibilityDelegate()); >+ hr = setAccessibilityDelegate(new AccessibilityDelegate(*this)); > if (FAILED (hr)) > return hr; > >@@ -124,7 +142,7 @@ HRESULT MiniBrowser::init() > return hr; > > IWebDownloadDelegatePtr downloadDelegate; >- downloadDelegate.Attach(new WebDownloadDelegate()); >+ downloadDelegate.Attach(new WebDownloadDelegate(*this)); > hr = setDownloadDelegate(downloadDelegate); > if (FAILED(hr)) > return hr; >diff --git a/Tools/MiniBrowser/win/MiniBrowser.h b/Tools/MiniBrowser/win/MiniBrowser.h >index e86ad6b3554a0552c8498e5a02719475b145a128..5ecf71600a5178d41e4b564a163410382a60ec3e 100644 >--- a/Tools/MiniBrowser/win/MiniBrowser.h >+++ b/Tools/MiniBrowser/win/MiniBrowser.h >@@ -29,6 +29,7 @@ > #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; >@@ -47,9 +48,12 @@ typedef _com_ptr_t<_com_IIID<IWebResourceLoadDelegate, &__uuidof(IWebResourceLoa > typedef _com_ptr_t<_com_IIID<IWebDownloadDelegate, &__uuidof(IWebDownloadDelegate)>> IWebDownloadDelegatePtr; > typedef _com_ptr_t<_com_IIID<IWebFramePrivate, &__uuidof(IWebFramePrivate)>> IWebFramePrivatePtr; > >-class MiniBrowser { >+class MiniBrowser : public RefCounted<MiniBrowser> { > public: >- MiniBrowser(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false, bool pageLoadTesting = false); >+ static Ref<MiniBrowser> create(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false, bool pageLoadTesting = false); >+ >+ ULONG AddRef(); >+ ULONG Release(); > > HRESULT init(); > HRESULT prepareViews(HWND mainWnd, const RECT& clientRect); >@@ -107,6 +111,7 @@ public: > void setPreference(UINT menuID, bool enable); > > private: >+ MiniBrowser(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, bool pageLoadTesting); > void subclassForLayeredWindow(); > void generateFontForScaleFactor(float); > bool setCacheFolder(); >diff --git a/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp b/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp >index 115e7a467a72aab9503d30a2da2f07297ba4d453..2b79174400d995f23dfd4b410491909bb3c648bf 100644 >--- a/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp >+++ b/Tools/MiniBrowser/win/MiniBrowserWebHost.cpp >@@ -130,16 +130,12 @@ HRESULT MiniBrowserWebHost::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** > > ULONG MiniBrowserWebHost::AddRef() > { >- return ++m_refCount; >+ return m_client->AddRef(); > } > > ULONG MiniBrowserWebHost::Release() > { >- ULONG newRef = --m_refCount; >- if (!newRef) >- delete(this); >- >- return newRef; >+ return m_client->Release(); > } > > typedef _com_ptr_t<_com_IIID<IDOMDocument, &__uuidof(IDOMDocument)>> IDOMDocumentPtr; >diff --git a/Tools/MiniBrowser/win/MiniBrowserWebHost.h b/Tools/MiniBrowser/win/MiniBrowserWebHost.h >index a7c33045d2d18f5282d72accfca0ba8e82b3296c..3cfedbb45f1d0a98caea3741ecb45cc229b1c5f6 100644 >--- a/Tools/MiniBrowser/win/MiniBrowserWebHost.h >+++ b/Tools/MiniBrowser/win/MiniBrowserWebHost.h >@@ -80,6 +80,5 @@ private: > HWND m_hURLBarWnd { 0 }; > HGDIOBJ m_URLBarFont { 0 }; > HGDIOBJ m_oldFont { 0 }; >- ULONG m_refCount { 1 }; > MiniBrowser* m_client { nullptr }; > }; >diff --git a/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp b/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp >index 99ca5ffce9cf4cfba0d52a5748ab253246ff5f9f..c7e6ddd8524b4379a8fd33ff8114e046b69eee46 100644 >--- a/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp >+++ b/Tools/MiniBrowser/win/PrintWebUIDelegate.cpp >@@ -27,6 +27,8 @@ > #include "stdafx.h" > #include "PrintWebUIDelegate.h" > >+#include "Common.h" >+#include "MainWindow.h" > #if USE(CF) > #include <CoreFoundation/CoreFoundation.h> > #endif >@@ -61,26 +63,21 @@ HRESULT PrintWebUIDelegate::createWebViewWithRequest(_In_opt_ IWebView*, _In_opt > if (!request) > return E_POINTER; > >- TCHAR executablePath[MAX_PATH]; >- DWORD length = ::GetModuleFileName(GetModuleHandle(0), executablePath, ARRAYSIZE(executablePath)); >- if (!length) >+ auto& newWindow = MainWindow::create().leakRef(); >+ bool ok = newWindow.init(hInst); >+ if (!ok) > return E_FAIL; >+ ShowWindow(newWindow.hwnd(), SW_SHOW); > >- _bstr_t url; >- HRESULT hr = request->URL(&url.GetBSTR()); >+ *newWebView = newWindow.browserWindow()->webView(); >+ IWebFramePtr frame; >+ HRESULT hr; >+ hr = (*newWebView)->mainFrame(&frame.GetInterfacePtr()); > if (FAILED(hr)) >- return E_FAIL; >- >- if (!url) >- return S_OK; >- >- std::wstring command = std::wstring(L"\"") + executablePath + L"\" " + (const wchar_t*)url; >- >- PROCESS_INFORMATION processInformation; >- STARTUPINFOW startupInfo; >- memset(&startupInfo, 0, sizeof(startupInfo)); >- if (!::CreateProcessW(0, (LPWSTR)command.c_str(), 0, 0, 0, 0, 0, 0, &startupInfo, &processInformation)) >- return E_FAIL; >+ return hr; >+ hr = frame->loadRequest(request); >+ if (FAILED(hr)) >+ return hr; > > return S_OK; > } >@@ -151,16 +148,12 @@ HRESULT PrintWebUIDelegate::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** > > ULONG PrintWebUIDelegate::AddRef() > { >- return ++m_refCount; >+ return m_client.AddRef(); > } > > ULONG PrintWebUIDelegate::Release() > { >- ULONG newRef = --m_refCount; >- if (!newRef) >- delete this; >- >- return newRef; >+ return m_client.Release(); > } > > typedef _com_ptr_t<_com_IIID<IWebFrame, &__uuidof(IWebFrame)>> IWebFramePtr; >diff --git a/Tools/MiniBrowser/win/PrintWebUIDelegate.h b/Tools/MiniBrowser/win/PrintWebUIDelegate.h >index b5d80c7a19d94d1a722b99a40048abf47cc2e762..097e139addd8f4ee5cd7c6bb34df14d781aa448b 100644 >--- a/Tools/MiniBrowser/win/PrintWebUIDelegate.h >+++ b/Tools/MiniBrowser/win/PrintWebUIDelegate.h >@@ -29,9 +29,12 @@ > > #include <WebKitLegacy/WebKit.h> > >+class MiniBrowser; >+ > class PrintWebUIDelegate : public IWebUIDelegate { > public: >- PrintWebUIDelegate() { } >+ PrintWebUIDelegate(MiniBrowser& client) >+ : m_client(client) { } > > // IUnknown > virtual HRESULT STDMETHODCALLTYPE QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject); >@@ -103,7 +106,7 @@ public: > virtual HRESULT STDMETHODCALLTYPE paintCustomScrollCorner(_In_opt_ IWebView*, _In_ HDC, RECT) { return E_NOTIMPL; } > > private: >- int m_refCount { 1 }; >+ MiniBrowser& m_client; > HWND m_modalDialogParent { nullptr }; > }; > >diff --git a/Tools/MiniBrowser/win/ResourceLoadDelegate.cpp b/Tools/MiniBrowser/win/ResourceLoadDelegate.cpp >index 13bae3d2512e5901626b6d6152ab786f407726ac..a1d13ce09e35358f6f4266caad43c9d09a92221e 100644 >--- a/Tools/MiniBrowser/win/ResourceLoadDelegate.cpp >+++ b/Tools/MiniBrowser/win/ResourceLoadDelegate.cpp >@@ -56,16 +56,12 @@ HRESULT ResourceLoadDelegate::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void > > ULONG ResourceLoadDelegate::AddRef() > { >- return ++m_refCount; >+ return m_client->AddRef(); > } > > ULONG ResourceLoadDelegate::Release() > { >- ULONG newRef = --m_refCount; >- if (!newRef) >- delete this; >- >- return newRef; >+ return m_client->Release(); > } > > HRESULT ResourceLoadDelegate::identifierForInitialRequest(_In_opt_ IWebView*, _In_opt_ IWebURLRequest*, _In_opt_ IWebDataSource*, unsigned long identifier) >diff --git a/Tools/MiniBrowser/win/ResourceLoadDelegate.h b/Tools/MiniBrowser/win/ResourceLoadDelegate.h >index b56c6fe9cfa1447af9bd2ca2e22de2cbfdca8546..3f07f6a080a75a256020f40da4a256c1d37cd79e 100644 >--- a/Tools/MiniBrowser/win/ResourceLoadDelegate.h >+++ b/Tools/MiniBrowser/win/ResourceLoadDelegate.h >@@ -53,7 +53,6 @@ public: > > private: > MiniBrowser* m_client; >- int m_refCount { 1 }; > }; > > #endif // ResourceLoadDelegate >diff --git a/Tools/MiniBrowser/win/WebDownloadDelegate.cpp b/Tools/MiniBrowser/win/WebDownloadDelegate.cpp >index 702f176fdcc9a3a3717fe5d0f1154821cf3cf71e..d1a0dfacfeec9cca8cc278d90fc112705e299a0c 100644 >--- a/Tools/MiniBrowser/win/WebDownloadDelegate.cpp >+++ b/Tools/MiniBrowser/win/WebDownloadDelegate.cpp >@@ -28,9 +28,11 @@ > #include "stdafx.h" > #include "WebDownloadDelegate.h" > >+#include "MiniBrowser.h" > #include <shlobj.h> > >-WebDownloadDelegate::WebDownloadDelegate() >+WebDownloadDelegate::WebDownloadDelegate(MiniBrowser& client) >+ : m_client(client) > { > } > >@@ -57,17 +59,12 @@ HRESULT WebDownloadDelegate::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void* > > ULONG WebDownloadDelegate::AddRef() > { >- m_refCount++; >- return m_refCount; >+ return m_client.AddRef(); > } > > ULONG WebDownloadDelegate::Release() > { >- m_refCount--; >- int refCount = m_refCount; >- if (!refCount) >- delete this; >- return refCount; >+ return m_client.Release(); > } > > HRESULT WebDownloadDelegate::decideDestinationWithSuggestedFilename(_In_opt_ IWebDownload* download, _In_ BSTR filename) >diff --git a/Tools/MiniBrowser/win/WebDownloadDelegate.h b/Tools/MiniBrowser/win/WebDownloadDelegate.h >index 289c40b60578b34a1775753064152d6e5c100c09..787dd8a9ce8adee06abaf932b3954d65bd008ca7 100644 >--- a/Tools/MiniBrowser/win/WebDownloadDelegate.h >+++ b/Tools/MiniBrowser/win/WebDownloadDelegate.h >@@ -29,9 +29,11 @@ > #include <WebKitLegacy/WebKit.h> > #include <WebKitLegacy/WebKitCOMAPI.h> > >+class MiniBrowser; >+ > class WebDownloadDelegate : public IWebDownloadDelegate { > public: >- WebDownloadDelegate(); >+ WebDownloadDelegate(MiniBrowser& client); > virtual ~WebDownloadDelegate(); > > virtual HRESULT STDMETHODCALLTYPE QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject); >@@ -52,7 +54,7 @@ public: > virtual HRESULT STDMETHODCALLTYPE didFinish(_In_opt_ IWebDownload*); > > private: >- int m_refCount { 1 }; >+ MiniBrowser& m_client; > }; > > #endif >diff --git a/Tools/MiniBrowser/win/WinMain.cpp b/Tools/MiniBrowser/win/WinMain.cpp >index 337f3ba6e1821ed04ff5a06517eba2e332dcfb5b..1bc09c35645b94cb8f8894745a7896979fc91818 100644 >--- a/Tools/MiniBrowser/win/WinMain.cpp >+++ b/Tools/MiniBrowser/win/WinMain.cpp >@@ -65,19 +65,19 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, > > ::SetProcessDPIAware(); > >- auto mainWindow = new MainWindow(); >- HRESULT hr = mainWindow->init(hInst, usesLayeredWebView, pageLoadTesting); >+ auto& mainWindow = MainWindow::create().leakRef(); >+ HRESULT hr = mainWindow.init(hInst, usesLayeredWebView, pageLoadTesting); > if (FAILED(hr)) > goto exit; > >- ShowWindow(mainWindow->hwnd(), nCmdShow); >+ ShowWindow(mainWindow.hwnd(), nCmdShow); > > hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDC_MINIBROWSER)); > > if (requestedURL.length()) >- mainWindow->loadURL(requestedURL.GetBSTR()); >+ mainWindow.loadURL(requestedURL.GetBSTR()); > else >- mainWindow->browserWindow()->loadHTMLString(_bstr_t(defaultHTML).GetBSTR()); >+ mainWindow.browserWindow()->loadHTMLString(_bstr_t(defaultHTML).GetBSTR()); > > #pragma warning(disable:4509) >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186263
:
341896
|
341897
|
341905
|
342031
|
342034
| 342132