WebKit Bugzilla
Attachment 342124 Details for
Bug 186378
: [Win][MiniBrowser] Remove gMainWindow global variable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-186378-20180607151947.patch (text/plain), 9.52 KB, created by
Fujii Hironori
on 2018-06-06 23:19:48 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Fujii Hironori
Created:
2018-06-06 23:19:48 PDT
Size:
9.52 KB
patch
obsolete
>Subversion Revision: 232566 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 58ce70fd8cbfcb06eb79d674bffefed51d71b2df..f00f5eca12f7b2a8eb3cce19f911998eef65e537 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,33 @@ >+2018-06-06 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ [Win][MiniBrowser] Remove gMainWindow global variable >+ https://bugs.webkit.org/show_bug.cgi?id=186378 >+ >+ Reviewed by Ryosuke Niwa. >+ >+ I'm going to support multiple MainWindow in Bug 186263. It should >+ not be assumed that MainWindow has only one instance. gMainWindow >+ is used only in DisplayAuthDialog. >+ >+ * MiniBrowser/win/Common.cpp: >+ (authDialogProc): Use DWLP_USER to store the dialog data. >+ (displayAuthDialog): Moved and renamed from >+ MainWindow::displayAuthDialog. Use DialogBoxParam instead of >+ DialogBox to pass a data pointer. Do not return S_OK if >+ DialogBoxParam returns -1. Take a HWND argument as the parent >+ window. >+ (DisplayAuthDialog): Deleted. >+ * MiniBrowser/win/Common.h: >+ * MiniBrowser/win/MainWindow.cpp: >+ (authDialogProc): Moved to Common.cpp. >+ (MainWindow::displayAuthDialog): Ditto. >+ * MiniBrowser/win/MainWindow.h: >+ * MiniBrowser/win/ResourceLoadDelegate.cpp: >+ (ResourceLoadDelegate::didReceiveAuthenticationChallenge): >+ * MiniBrowser/win/WinMain.cpp: >+ (wWinMain): Added a local variable mainWindow instead of using >+ gMainWindow. >+ > 2018-06-06 Antoine Quint <graouts@apple.com> > > Rename color-filter to -apple-color-filter and do not expose it to Web content >diff --git a/Tools/MiniBrowser/win/Common.cpp b/Tools/MiniBrowser/win/Common.cpp >index 4c27824c5f97292589fcb80be9c8bd8b2a0fb4ce..fa25f542d357cc38b2ba4f1d23ec9e36e504e1eb 100644 >--- a/Tools/MiniBrowser/win/Common.cpp >+++ b/Tools/MiniBrowser/win/Common.cpp >@@ -29,13 +29,14 @@ > #include "stdafx.h" > #include "Common.h" > >+#include "MiniBrowserLibResource.h" > #include "MiniBrowserReplace.h" > #include <dbghelp.h> > #include <shlobj.h> >+#include <wtf/StdLibExtras.h> > > // Global Variables: > HINSTANCE hInst; >-MainWindow* gMainWindow = nullptr; > > // Support moving the transparent window > POINT s_windowPosition = { 100, 100 }; >@@ -118,9 +119,50 @@ void createCrashReport(EXCEPTION_POINTERS* exceptionPointers) > } > } > >-HRESULT DisplayAuthDialog(std::wstring& username, std::wstring& password) >+struct AuthDialogData { >+ std::wstring& username; >+ std::wstring& password; >+}; >+ >+static INT_PTR CALLBACK authDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >+{ >+ AuthDialogData& data = *reinterpret_cast<AuthDialogData*>(GetWindowLongPtr(hDlg, DWLP_USER)); >+ switch (message) { >+ case WM_INITDIALOG: >+ SetWindowLongPtr(hDlg, DWLP_USER, lParam); >+ return TRUE; >+ >+ case WM_COMMAND: { >+ int wmId = LOWORD(wParam); >+ switch (wmId) { >+ case IDOK: { >+ TCHAR str[256]; >+ int strLen = GetWindowText(GetDlgItem(hDlg, IDC_AUTH_USER), str, WTF_ARRAY_LENGTH(str)-1); >+ str[strLen] = 0; >+ data.username = str; >+ >+ strLen = GetWindowText(GetDlgItem(hDlg, IDC_AUTH_PASSWORD), str, WTF_ARRAY_LENGTH(str)-1); >+ str[strLen] = 0; >+ data.password = str; >+ >+ EndDialog(hDlg, true); >+ return TRUE; >+ } >+ case IDCANCEL: >+ EndDialog(hDlg, false); >+ return TRUE; >+ } >+ break; >+ } >+ } >+ return FALSE; >+} >+ >+HRESULT displayAuthDialog(HWND hwnd, std::wstring& username, std::wstring& password) > { >- return gMainWindow->displayAuthDialog(username, password); >+ AuthDialogData data { username, password }; >+ auto result = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_AUTH), hwnd, authDialogProc, reinterpret_cast<LPARAM>(&data)); >+ return result > 0 ? S_OK : E_FAIL; > } > > void parseCommandLine(bool& usesLayeredWebView, bool& useFullDesktop, bool& pageLoadTesting, _bstr_t& requestedURL) >diff --git a/Tools/MiniBrowser/win/Common.h b/Tools/MiniBrowser/win/Common.h >index 6663d2586e50024e522cb7fa933a8a93868f3bb1..4ea12738cdc5d25a51cd43ba2421f8749dae951b 100644 >--- a/Tools/MiniBrowser/win/Common.h >+++ b/Tools/MiniBrowser/win/Common.h >@@ -33,8 +33,8 @@ void computeFullDesktopFrame(); > bool getAppDataFolder(_bstr_t& directory); > void parseCommandLine(bool& usesLayeredWebView, bool& useFullDesktop, bool& pageLoadTesting, _bstr_t& requestedURL); > void createCrashReport(EXCEPTION_POINTERS*); >+HRESULT displayAuthDialog(HWND, std::wstring& username, std::wstring& password); > > extern HINSTANCE hInst; >-extern MainWindow* gMainWindow; > extern POINT s_windowPosition; > extern SIZE s_windowSize; >diff --git a/Tools/MiniBrowser/win/MainWindow.cpp b/Tools/MiniBrowser/win/MainWindow.cpp >index 87a477cf44d8ae67674e82df343b757d3835b547..cd8c53039029a54e953eda55cbfc134c5e01be71 100644 >--- a/Tools/MiniBrowser/win/MainWindow.cpp >+++ b/Tools/MiniBrowser/win/MainWindow.cpp >@@ -383,56 +383,6 @@ INT_PTR CALLBACK MainWindow::customUserAgentDialogProc(HWND hDlg, UINT message, > return (INT_PTR)FALSE; > } > >-static INT_PTR CALLBACK authDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) >-{ >- switch (message) { >- case WM_INITDIALOG: { >- HWND edit = ::GetDlgItem(hDlg, IDC_AUTH_USER); >- ::SetWindowText(edit, static_cast<LPCTSTR>(L"")); >- >- edit = ::GetDlgItem(hDlg, IDC_AUTH_PASSWORD); >- ::SetWindowText(edit, static_cast<LPCTSTR>(L"")); >- return (INT_PTR)TRUE; >- } >- >- case WM_COMMAND: >- if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { >- INT_PTR result { }; >- >- if (LOWORD(wParam) == IDOK) { >- TCHAR user[256]; >- int strLen = ::GetWindowText(::GetDlgItem(hDlg, IDC_AUTH_USER), user, 256); >- user[strLen] = 0; >- >- TCHAR pass[256]; >- strLen = ::GetWindowText(::GetDlgItem(hDlg, IDC_AUTH_PASSWORD), pass, 256); >- pass[strLen] = 0; >- >- result = reinterpret_cast<INT_PTR>(new std::pair<std::wstring, std::wstring>(user, pass)); >- } >- >- ::EndDialog(hDlg, result); >- return (INT_PTR)TRUE; >- } >- break; >- } >- return (INT_PTR)FALSE; >-} >- >-HRESULT MainWindow::displayAuthDialog(std::wstring& username, std::wstring& password) >-{ >- auto result = DialogBox(hInst, MAKEINTRESOURCE(IDD_AUTH), hwnd(), authDialogProc); >- if (!result) >- return E_FAIL; >- >- auto pair = reinterpret_cast<std::pair<std::wstring, std::wstring>*>(result); >- username = pair->first; >- password = pair->second; >- delete pair; >- >- return S_OK; >-} >- > void MainWindow::loadURL(BSTR url) > { > if (FAILED(m_browserWindow->loadURL(url))) >diff --git a/Tools/MiniBrowser/win/MainWindow.h b/Tools/MiniBrowser/win/MainWindow.h >index 1c88eded38485cfdad0d80d5049a0461235ff9f0..0ec4eee25f906a67261ecaa13676aa430b9e87d7 100644 >--- a/Tools/MiniBrowser/win/MainWindow.h >+++ b/Tools/MiniBrowser/win/MainWindow.h >@@ -39,7 +39,6 @@ public: > MiniBrowser* browserWindow() const { return m_browserWindow.get(); } > > void loadURL(BSTR url); >- HRESULT displayAuthDialog(std::wstring& username, std::wstring& password); > > private: > static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); >diff --git a/Tools/MiniBrowser/win/ResourceLoadDelegate.cpp b/Tools/MiniBrowser/win/ResourceLoadDelegate.cpp >index 9153bc8cf44298223840765128f73cfd09cedd9e..13bae3d2512e5901626b6d6152ab786f407726ac 100644 >--- a/Tools/MiniBrowser/win/ResourceLoadDelegate.cpp >+++ b/Tools/MiniBrowser/win/ResourceLoadDelegate.cpp >@@ -25,6 +25,7 @@ > #include "stdafx.h" > #include "ResourceLoadDelegate.h" > >+#include "Common.h" > #include "MiniBrowser.h" > #include "PageLoadTestClient.h" > #include <WebCore/COMPtr.h> >@@ -37,8 +38,6 @@ > #include <string> > #include <wininet.h> > >-extern HRESULT DisplayAuthDialog(std::wstring& username, std::wstring& password); >- > HRESULT ResourceLoadDelegate::QueryInterface(_In_ REFIID riid, _COM_Outptr_ void** ppvObject) > { > if (!ppvObject) >@@ -94,7 +93,7 @@ HRESULT ResourceLoadDelegate::didReceiveAuthenticationChallenge(_In_opt_ IWebVie > return E_FAIL; > > std::wstring username, password; >- if (DisplayAuthDialog(username, password) != S_OK) >+ if (displayAuthDialog(m_client->hwnd(), username, password) != S_OK) > return E_FAIL; > > COMPtr<IWebURLCredential> credential; >diff --git a/Tools/MiniBrowser/win/WinMain.cpp b/Tools/MiniBrowser/win/WinMain.cpp >index fb93a5b3c804a5413647931bb034ecbd997b996e..337f3ba6e1821ed04ff5a06517eba2e332dcfb5b 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(); > >- gMainWindow = new MainWindow(); >- HRESULT hr = gMainWindow->init(hInst, usesLayeredWebView, pageLoadTesting); >+ auto mainWindow = new MainWindow(); >+ HRESULT hr = mainWindow->init(hInst, usesLayeredWebView, pageLoadTesting); > if (FAILED(hr)) > goto exit; > >- ShowWindow(gMainWindow->hwnd(), nCmdShow); >+ ShowWindow(mainWindow->hwnd(), nCmdShow); > > hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDC_MINIBROWSER)); > > if (requestedURL.length()) >- gMainWindow->loadURL(requestedURL.GetBSTR()); >+ mainWindow->loadURL(requestedURL.GetBSTR()); > else >- gMainWindow->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 186378
:
342107
| 342124