WebKit Bugzilla
Attachment 342031 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-20180606135910.patch (text/plain), 23.03 KB, created by
Fujii Hironori
on 2018-06-05 21:59:11 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Fujii Hironori
Created:
2018-06-05 21:59:11 PDT
Size:
23.03 KB
patch
obsolete
>Subversion Revision: 232531 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 12c5454781639265ea37f876868a26045b15da87..1c4806410abe1083467d4a825296398d71228d09 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,67 @@ >+2018-06-05 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ [Win][MiniBrowser] Support multiple windows properly >+ https://bugs.webkit.org/show_bug.cgi?id=186263 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ 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::init): >+ (MainWindow::WndProc): Keep this instance alive by using >+ RefPtr<MainWindow>. Deref the MainWindow instance on WM_DESTROY. >+ Quit the application when the last MainWindow is closed. >+ * MiniBrowser/win/MiniBrowser.h: Added declarations AddRef and Release. >+ * MiniBrowser/win/MiniBrowser.cpp: >+ (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-05 Wenson Hsieh <wenson_hsieh@apple.com> > > DataInteractionTests ContentEditableToTextarea and ContentEditableToContentEditable are failing on recent iOS 12 >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 87a477cf44d8ae67674e82df343b757d3835b547..1dcd31c7b62f206e35fe964819d6c4009731ecd6 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,16 @@ void MainWindow::registerClass(HINSTANCE hInstance) > RegisterClassEx(&wcex); > } > >+MainWindow::MainWindow() >+{ >+ s_numInstances++; >+} >+ >+MainWindow::~MainWindow() >+{ >+ s_numInstances--; >+} >+ > bool MainWindow::init(HINSTANCE hInstance, bool usesLayeredWebView, bool pageLoadTesting) > { > registerClass(hInstance); >@@ -97,7 +107,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 = adoptRef(new MiniBrowser(m_hMainWnd, m_hURLBarWnd, usesLayeredWebView, pageLoadTesting)); > if (!m_browserWindow) > return false; > HRESULT hr = m_browserWindow->init(); >@@ -133,7 +143,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> thiz = 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 +159,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); >+ thiz->browserWindow()->navigateToHistory(hWnd, wmId); > break; > } > // Parse the menu selections: > switch (wmId) { > case IDC_URL_BAR: >- thiz.onURLBarEnter(); >+ thiz->onURLBarEnter(); > break; > case IDM_ABOUT: > DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); >@@ -164,53 +174,57 @@ LRESULT CALLBACK MainWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPA > DestroyWindow(hWnd); > break; > case IDM_PRINT: >- thiz.browserWindow()->print(); >+ thiz->browserWindow()->print(); > break; > case IDM_WEB_INSPECTOR: >- thiz.browserWindow()->launchInspector(); >+ thiz->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(thiz->m_hCacheWnd)) { >+ thiz->m_hCacheWnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CACHES), hWnd, cachesDialogProc, reinterpret_cast<LPARAM>(&thiz)); >+ ::ShowWindow(thiz->m_hCacheWnd, SW_SHOW); > } > break; > case IDM_HISTORY_BACKWARD: > case IDM_HISTORY_FORWARD: >- thiz.browserWindow()->navigateForwardOrBackward(hWnd, wmId); >+ thiz->browserWindow()->navigateForwardOrBackward(hWnd, wmId); > break; > case IDM_UA_OTHER: > DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_USER_AGENT), hWnd, customUserAgentDialogProc, reinterpret_cast<LPARAM>(&thiz)); > break; > case IDM_ACTUAL_SIZE: >- thiz.browserWindow()->resetZoom(); >+ thiz->browserWindow()->resetZoom(); > break; > case IDM_ZOOM_IN: >- thiz.browserWindow()->zoomIn(); >+ thiz->browserWindow()->zoomIn(); > break; > case IDM_ZOOM_OUT: >- thiz.browserWindow()->zoomOut(); >+ thiz->browserWindow()->zoomOut(); > break; > case IDM_SHOW_LAYER_TREE: >- thiz.browserWindow()->showLayerTree(); >+ thiz->browserWindow()->showLayerTree(); > break; > default: >- if (!thiz.toggleMenuItem(wmId)) >+ if (!thiz->toggleMenuItem(wmId)) > return DefWindowProc(hWnd, message, wParam, lParam); > } > } > break; > case WM_DESTROY: >+ SetWindowLongPtr(hWnd, GWLP_USERDATA, 0); >+ thiz->deref(); >+ if (s_numInstances > 1) >+ return 0; > #if USE(CF) > CFRunLoopStop(CFRunLoopGetMain()); > #endif > PostQuitMessage(0); > break; > case WM_SIZE: >- thiz.resizeSubViews(); >+ thiz->resizeSubViews(); > break; > case WM_DPICHANGED: >- thiz.browserWindow()->updateDeviceScaleFactor(); >+ thiz->browserWindow()->updateDeviceScaleFactor(); > return DefWindowProc(hWnd, message, wParam, lParam); > default: > return DefWindowProc(hWnd, message, wParam, lParam); >diff --git a/Tools/MiniBrowser/win/MainWindow.h b/Tools/MiniBrowser/win/MainWindow.h >index 1c88eded38485cfdad0d80d5049a0461235ff9f0..efa37786109836a9d2c2942f85f705433cf66725 100644 >--- a/Tools/MiniBrowser/win/MainWindow.h >+++ b/Tools/MiniBrowser/win/MainWindow.h >@@ -25,13 +25,15 @@ > > #pragma once > >+#include "MiniBrowser.h" > #include <memory> > #include <string> >+#include <wtf/RefPtr.h> > >-class MiniBrowser; >- >-class MainWindow { >+class MainWindow : public RefCounted<MainWindow> { > public: >+ MainWindow(); >+ ~MainWindow(); > bool init(HINSTANCE hInstance, bool usesLayeredWebView = false, bool pageLoadTesting = false); > > void resizeSubViews(); >@@ -47,6 +49,7 @@ 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; > > bool toggleMenuItem(UINT menuID); > void onURLBarEnter(); >@@ -56,5 +59,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..2c181d6fb26e305c288b967fb53e8e8019d4ae60 100644 >--- a/Tools/MiniBrowser/win/MiniBrowser.cpp >+++ b/Tools/MiniBrowser/win/MiniBrowser.cpp >@@ -68,6 +68,19 @@ MiniBrowser::MiniBrowser(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, b > { > } > >+ULONG MiniBrowser::AddRef() >+{ >+ ref(); >+ return refCount(); >+} >+ >+ULONG MiniBrowser::Release() >+{ >+ auto c = refCount(); >+ deref(); >+ return --c; >+} >+ > HRESULT MiniBrowser::init() > { > updateDeviceScaleFactor(); >@@ -111,11 +124,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 +137,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..b7dcebe3461ef0c6a56eb547f7378c1296ecf868 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,10 +48,13 @@ 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); > >+ ULONG AddRef(); >+ ULONG Release(); >+ > HRESULT init(); > HRESULT prepareViews(HWND mainWnd, const RECT& clientRect); > >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..192cc165efb7640b1fa732e381aa1fd2c420f335 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) >+ MainWindow* newWindow = adoptRef(new MainWindow()).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 9153bc8cf44298223840765128f73cfd09cedd9e..7bafa7a9f9f6493b341b614d056955a00cb7a2e5 100644 >--- a/Tools/MiniBrowser/win/ResourceLoadDelegate.cpp >+++ b/Tools/MiniBrowser/win/ResourceLoadDelegate.cpp >@@ -57,16 +57,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 fb93a5b3c804a5413647931bb034ecbd997b996e..27f51e9db969ad3d4b6ef984b7dedcdabf2869c5 100644 >--- a/Tools/MiniBrowser/win/WinMain.cpp >+++ b/Tools/MiniBrowser/win/WinMain.cpp >@@ -65,7 +65,7 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, > > ::SetProcessDPIAware(); > >- gMainWindow = new MainWindow(); >+ gMainWindow = adoptRef(new MainWindow()).leakRef(); > HRESULT hr = gMainWindow->init(hInst, usesLayeredWebView, pageLoadTesting); > if (FAILED(hr)) > goto exit;
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