WebKit Bugzilla
Attachment 341268 Details for
Bug 185814
: [Win][MiniBrowser] Add MainWindow class
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
Bug185814.patch (text/plain), 25.14 KB, created by
Fujii Hironori
on 2018-05-25 03:13:40 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Fujii Hironori
Created:
2018-05-25 03:13:40 PDT
Size:
25.14 KB
patch
obsolete
>diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 3c9a907dba2..4d22f7405cd 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,46 @@ >+2018-05-25 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ [Win][MiniBrowser] Add MainWindow class >+ https://bugs.webkit.org/show_bug.cgi?id=185814 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This is a sub task of Bug 184770. Added a new class MainWindow to >+ represent the main window which will be shared among WK1 and WK2. >+ >+ This change is partial so that it's easy to review this patch. >+ I'll move more functions into MainWindow.cpp, and remove more >+ global variables in forthcoming patches. >+ >+ * MiniBrowser/win/CMakeLists.txt: Added MainWindow.cpp. >+ * MiniBrowser/win/Common.cpp: Removed MainWindow related global >+ variables hMainWnd, hURLBarWnd, hBackButtonWnd and >+ hForwardButtonWnd. Added a new global variable gMainWindow. >+ (WndProc): Moved to MainWindow.cpp. >+ (resizeSubViews): Ditto. >+ (ToggleMenuFlag): Removed static to be called from MainWindow.cpp. >+ (ToggleMenuItem): Ditto. >+ (CustomUserAgent): Follow the global variables removal. >+ (DisplayAuthDialog): Ditto. >+ (loadURL): Ditto. >+ (WndProc): Renamed to MainWindow::WndProc. >+ * MiniBrowser/win/MainWindow.cpp: Added. >+ (MainWindow::registerClass): Renamed from MyRegisterClass of WinMain.cpp. >+ (MainWindow::init): Extracted MainWindow initialization code from wWinMain. >+ (MainWindow::resizeSubViews): Moved from Common.cpp. >+ (MainWindow::WndProc): Ditto. >+ * MiniBrowser/win/MainWindow.h: Added. >+ (MainWindow::hwnd): >+ (MainWindow::browserWindow): >+ * MiniBrowser/win/MiniBrowser.cpp: >+ (MiniBrowser::init): >+ (MiniBrowser::prepareViews): Extract some code into MiniBrowser::loadDefaultHTML. >+ (MiniBrowser::loadDefaultHTML): Extracted from MiniBrowser::prepareViews. >+ * MiniBrowser/win/MiniBrowser.h: >+ * MiniBrowser/win/WinMain.cpp: >+ (wWinMain): Extracted MainWindow initialization code into MainWindow::init. >+ (MyRegisterClass): Moved to MainWindow.cpp. >+ > 2018-05-25 Fujii Hironori <Hironori.Fujii@sony.com> > > [Win][MiniBrowser] Remove URL argument of MiniBrowser::init >diff --git a/Tools/MiniBrowser/win/CMakeLists.txt b/Tools/MiniBrowser/win/CMakeLists.txt >index b8956f8320c..70e6d7ce56b 100644 >--- a/Tools/MiniBrowser/win/CMakeLists.txt >+++ b/Tools/MiniBrowser/win/CMakeLists.txt >@@ -8,6 +8,7 @@ set(MiniBrowser_INCLUDE_DIRECTORIES > set(MiniBrowser_SOURCES > AccessibilityDelegate.cpp > DOMDefaultImpl.cpp >+ MainWindow.cpp > PageLoadTestClient.cpp > PrintWebUIDelegate.cpp > ResourceLoadDelegate.cpp >diff --git a/Tools/MiniBrowser/win/Common.cpp b/Tools/MiniBrowser/win/Common.cpp >index 11c6549f368..3ed7e39e656 100644 >--- a/Tools/MiniBrowser/win/Common.cpp >+++ b/Tools/MiniBrowser/win/Common.cpp >@@ -27,6 +27,7 @@ > */ > > #include "DOMDefaultImpl.h" >+#include "MainWindow.h" > #include "MiniBrowser.h" > #include "MiniBrowserReplace.h" > #include <WebKitLegacy/WebKitCOMAPI.h> >@@ -55,12 +56,6 @@ > #include <vector> > #include <wininet.h> > >-#define MAX_LOADSTRING 100 >-#define URLBAR_HEIGHT 24 >-#define CONTROLBUTTON_WIDTH 24 >- >-static const int maxHistorySize = 10; >- > #ifndef WM_DPICHANGED > #define WM_DPICHANGED 0x02E0 > #endif >@@ -70,34 +65,18 @@ typedef _com_ptr_t<_com_IIID<IWebMutableURLRequest, &__uuidof(IWebMutableURLRequ > > // Global Variables: > HINSTANCE hInst; >-HWND hMainWnd; >-HWND hURLBarWnd; >-HGDIOBJ hURLFont; >-HWND hBackButtonWnd; >-HWND hForwardButtonWnd; > HWND hCacheWnd; > WNDPROC DefEditProc = nullptr; > WNDPROC DefButtonProc = nullptr; >-WNDPROC DefWebKitProc = nullptr; >-HWND gViewWindow = 0; >+ >+MainWindow* gMainWindow = nullptr; > MiniBrowser* gMiniBrowser = nullptr; >-TCHAR szTitle[MAX_LOADSTRING]; // The title bar text >-TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name > > // Support moving the transparent window > POINT s_windowPosition = { 100, 100 }; > SIZE s_windowSize = { 500, 200 }; > > // Forward declarations of functions included in this code module: >-ATOM MyRegisterClass(HINSTANCE hInstance); >-LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); >-INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); >-INT_PTR CALLBACK CustomUserAgent(HWND, UINT, WPARAM, LPARAM); >-LRESULT CALLBACK EditProc(HWND, UINT, WPARAM, LPARAM); >-LRESULT CALLBACK BackButtonProc(HWND, UINT, WPARAM, LPARAM); >-LRESULT CALLBACK ForwardButtonProc(HWND, UINT, WPARAM, LPARAM); >-LRESULT CALLBACK ReloadButtonProc(HWND, UINT, WPARAM, LPARAM); >-INT_PTR CALLBACK Caches(HWND, UINT, WPARAM, LPARAM); > INT_PTR CALLBACK AuthDialogProc(HWND, UINT, WPARAM, LPARAM); > > static void loadURL(BSTR urlBStr); >@@ -107,27 +86,6 @@ namespace WebCore { > float deviceScaleFactorForWindow(HWND); > } > >-static void resizeSubViews() >-{ >- float scaleFactor = WebCore::deviceScaleFactorForWindow(hMainWnd); >- >- RECT rcClient; >- GetClientRect(hMainWnd, &rcClient); >- >- int height = scaleFactor * URLBAR_HEIGHT; >- int width = scaleFactor * CONTROLBUTTON_WIDTH; >- >- MoveWindow(hBackButtonWnd, 0, 0, width, height, TRUE); >- MoveWindow(hForwardButtonWnd, width, 0, width, height, TRUE); >- MoveWindow(hURLBarWnd, width * 2, 0, rcClient.right, height, TRUE); >- >- ::SendMessage(hURLBarWnd, static_cast<UINT>(WM_SETFONT), reinterpret_cast<WPARAM>(gMiniBrowser->urlBarFont()), TRUE); >- >- if (gMiniBrowser->usesLayeredWebView() || !gViewWindow) >- return; >- MoveWindow(gViewWindow, 0, height, rcClient.right, rcClient.bottom - height, TRUE); >-} >- > static void computeFullDesktopFrame() > { > RECT desktop; >@@ -277,7 +235,7 @@ void PrintView(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) > ::DeleteDC(printDC); > } > >-static void ToggleMenuFlag(HWND hWnd, UINT menuID) >+void ToggleMenuFlag(HWND hWnd, UINT menuID) > { > HMENU menu = ::GetMenu(hWnd); > >@@ -319,7 +277,7 @@ static void turnOffOtherUserAgents(HMENU menu) > } > } > >-static bool ToggleMenuItem(HWND hWnd, UINT menuID) >+bool ToggleMenuItem(HWND hWnd, UINT menuID) > { > if (!gMiniBrowser) > return false; >@@ -399,96 +357,6 @@ static bool ToggleMenuItem(HWND hWnd, UINT menuID) > return true; > } > >-static const int dragBarHeight = 30; >- >-LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) >-{ >- switch (message) { >- case WM_COMMAND: { >- int wmId = LOWORD(wParam); >- int wmEvent = HIWORD(wParam); >- if (wmId >= IDM_HISTORY_LINK0 && wmId <= IDM_HISTORY_LINK9) { >- if (gMiniBrowser) >- gMiniBrowser->navigateToHistory(hWnd, wmId); >- break; >- } >- // Parse the menu selections: >- switch (wmId) { >- case IDM_ABOUT: >- DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); >- break; >- case IDM_EXIT: >- DestroyWindow(hWnd); >- break; >- case IDM_PRINT: >- PrintView(hWnd, message, wParam, lParam); >- break; >- case IDM_WEB_INSPECTOR: >- if (gMiniBrowser) >- gMiniBrowser->launchInspector(); >- break; >- case IDM_CACHES: >- if (!::IsWindow(hCacheWnd)) { >- hCacheWnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_CACHES), hWnd, Caches); >- ::ShowWindow(hCacheWnd, SW_SHOW); >- } >- break; >- case IDM_HISTORY_BACKWARD: >- case IDM_HISTORY_FORWARD: >- if (gMiniBrowser) >- gMiniBrowser->navigateForwardOrBackward(hWnd, wmId); >- break; >- case IDM_UA_OTHER: >- if (wmEvent) >- ToggleMenuItem(hWnd, wmId); >- else >- DialogBox(hInst, MAKEINTRESOURCE(IDD_USER_AGENT), hWnd, CustomUserAgent); >- break; >- case IDM_ACTUAL_SIZE: >- if (gMiniBrowser) >- gMiniBrowser->resetZoom(); >- break; >- case IDM_ZOOM_IN: >- if (gMiniBrowser) >- gMiniBrowser->zoomIn(); >- break; >- case IDM_ZOOM_OUT: >- if (gMiniBrowser) >- gMiniBrowser->zoomOut(); >- break; >- case IDM_SHOW_LAYER_TREE: >- if (gMiniBrowser) >- gMiniBrowser->showLayerTree(); >- break; >- default: >- if (!ToggleMenuItem(hWnd, wmId)) >- return DefWindowProc(hWnd, message, wParam, lParam); >- } >- } >- break; >- case WM_DESTROY: >-#if USE(CF) >- CFRunLoopStop(CFRunLoopGetMain()); >-#endif >- PostQuitMessage(0); >- break; >- case WM_SIZE: >- if (!gMiniBrowser || !gMiniBrowser->hasWebView()) >- return DefWindowProc(hWnd, message, wParam, lParam); >- >- resizeSubViews(); >- break; >- case WM_DPICHANGED: >- if (gMiniBrowser) >- gMiniBrowser->updateDeviceScaleFactor(); >- return DefWindowProc(hWnd, message, wParam, lParam); >- default: >- return DefWindowProc(hWnd, message, wParam, lParam); >- } >- >- return 0; >-} >- > LRESULT CALLBACK EditProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) > { > switch (message) { >@@ -601,7 +469,7 @@ INT_PTR CALLBACK CustomUserAgent(HWND hDlg, UINT message, WPARAM wParam, LPARAM > _bstr_t bstr(buffer); > if (bstr.length()) { > gMiniBrowser->setUserAgent(bstr); >- ::PostMessage(hMainWnd, static_cast<UINT>(WM_COMMAND), MAKELPARAM(IDM_UA_OTHER, 1), 0); >+ ::PostMessage(gMainWindow->hwnd(), static_cast<UINT>(WM_COMMAND), MAKELPARAM(IDM_UA_OTHER, 1), 0); > } > } > >@@ -616,7 +484,7 @@ INT_PTR CALLBACK CustomUserAgent(HWND hDlg, UINT message, WPARAM wParam, LPARAM > > HRESULT DisplayAuthDialog(std::wstring& username, std::wstring& password) > { >- auto result = DialogBox(hInst, MAKEINTRESOURCE(IDD_AUTH), hMainWnd, AuthDialogProc); >+ auto result = DialogBox(hInst, MAKEINTRESOURCE(IDD_AUTH), gMainWindow->hwnd(), AuthDialogProc); > if (!result) > return E_FAIL; > >@@ -669,7 +537,7 @@ static void loadURL(BSTR passedURL) > if (FAILED(gMiniBrowser->loadURL(passedURL))) > return; > >- SetFocus(gViewWindow); >+ SetFocus(gMiniBrowser->hwnd()); > } > > static void setWindowText(HWND dialog, UINT field, _bstr_t value) >diff --git a/Tools/MiniBrowser/win/MainWindow.cpp b/Tools/MiniBrowser/win/MainWindow.cpp >new file mode 100644 >index 00000000000..30a118432de >--- /dev/null >+++ b/Tools/MiniBrowser/win/MainWindow.cpp >@@ -0,0 +1,235 @@ >+/* >+ * 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 "MainWindow.h" >+#include "MiniBrowser.h" >+#include "MiniBrowserLibResource.h" >+ >+namespace WebCore { >+float deviceScaleFactorForWindow(HWND); >+} >+ >+#define URLBAR_HEIGHT 24 >+#define CONTROLBUTTON_WIDTH 24 >+ >+extern MainWindow* gMainWindow; >+extern MiniBrowser* gMiniBrowser; >+extern WNDPROC DefEditProc; >+extern WNDPROC DefButtonProc; >+extern HINSTANCE hInst; >+extern HWND hCacheWnd; >+ >+LRESULT CALLBACK EditProc(HWND, UINT, WPARAM, LPARAM); >+LRESULT CALLBACK BackButtonProc(HWND, UINT, WPARAM, LPARAM); >+LRESULT CALLBACK ForwardButtonProc(HWND, UINT, WPARAM, LPARAM); >+LRESULT CALLBACK ReloadButtonProc(HWND, UINT, WPARAM, LPARAM); >+INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM); >+INT_PTR CALLBACK CustomUserAgent(HWND, UINT, WPARAM, LPARAM); >+INT_PTR CALLBACK Caches(HWND, UINT, WPARAM, LPARAM); >+INT_PTR CALLBACK AuthDialogProc(HWND, UINT, WPARAM, LPARAM); >+void PrintView(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); >+bool ToggleMenuItem(HWND hWnd, UINT menuID); >+ >+std::wstring MainWindow::s_windowClass; >+ >+static std::wstring loadString(int id) >+{ >+ constexpr size_t length = 100; >+ wchar_t buff[length]; >+ LoadString(hInst, IDC_MINIBROWSER, buff, length); >+ return buff; >+} >+ >+void MainWindow::registerClass(HINSTANCE hInstance) >+{ >+ static bool initialized = false; >+ if (initialized) >+ return; >+ initialized = true; >+ >+ s_windowClass = loadString(IDC_MINIBROWSER); >+ >+ WNDCLASSEX wcex; >+ wcex.cbSize = sizeof(WNDCLASSEX); >+ wcex.style = CS_HREDRAW | CS_VREDRAW; >+ wcex.lpfnWndProc = WndProc; >+ wcex.cbClsExtra = 0; >+ wcex.cbWndExtra = 0; >+ wcex.hInstance = hInstance; >+ wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MINIBROWSER)); >+ wcex.hCursor = LoadCursor(0, IDC_ARROW); >+ wcex.hbrBackground = 0; >+ wcex.lpszMenuName = MAKEINTRESOURCE(IDC_MINIBROWSER); >+ wcex.lpszClassName = s_windowClass.c_str(); >+ wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); >+ >+ RegisterClassEx(&wcex); >+} >+ >+bool MainWindow::init(HINSTANCE hInstance, bool usesLayeredWebView, bool pageLoadTesting) >+{ >+ registerClass(hInstance); >+ >+ auto title = loadString(IDS_APP_TITLE); >+ >+ m_hMainWnd = CreateWindow(s_windowClass.c_str(), title.c_str(), WS_OVERLAPPEDWINDOW, >+ CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, 0, hInstance, 0); >+ >+ if (!m_hMainWnd) >+ return false; >+ >+ float scaleFactor = WebCore::deviceScaleFactorForWindow(nullptr); >+ m_hBackButtonWnd = CreateWindow(L"BUTTON", L"<", WS_CHILD | WS_VISIBLE | BS_TEXT, 0, 0, 0, 0, m_hMainWnd, 0, hInstance, 0); >+ m_hForwardButtonWnd = CreateWindow(L"BUTTON", L">", WS_CHILD | WS_VISIBLE | BS_TEXT, scaleFactor * CONTROLBUTTON_WIDTH, 0, 0, 0, m_hMainWnd, 0, hInstance, 0); >+ m_hURLBarWnd = CreateWindow(L"EDIT", 0, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOVSCROLL, scaleFactor * CONTROLBUTTON_WIDTH * 2, 0, 0, 0, m_hMainWnd, 0, hInstance, 0); >+ >+ DefEditProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC)); >+ DefButtonProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(m_hBackButtonWnd, GWLP_WNDPROC)); >+ SetWindowLongPtr(m_hURLBarWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(EditProc)); >+ SetWindowLongPtr(m_hBackButtonWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(BackButtonProc)); >+ SetWindowLongPtr(m_hForwardButtonWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(ForwardButtonProc)); >+ >+ SetFocus(m_hURLBarWnd); >+ >+ m_browserWindow = std::make_unique<MiniBrowser>(m_hMainWnd, m_hURLBarWnd, usesLayeredWebView, pageLoadTesting); >+ if (!m_browserWindow) >+ return false; >+ HRESULT hr = m_browserWindow->init(); >+ if (FAILED(hr)) >+ return false; >+ >+ resizeSubViews(); >+ return true; >+} >+ >+void MainWindow::resizeSubViews() >+{ >+ float scaleFactor = WebCore::deviceScaleFactorForWindow(m_hMainWnd); >+ >+ RECT rcClient; >+ GetClientRect(m_hMainWnd, &rcClient); >+ >+ int height = scaleFactor * URLBAR_HEIGHT; >+ int width = scaleFactor * CONTROLBUTTON_WIDTH; >+ >+ MoveWindow(m_hBackButtonWnd, 0, 0, width, height, TRUE); >+ MoveWindow(m_hForwardButtonWnd, width, 0, width, height, TRUE); >+ MoveWindow(m_hURLBarWnd, width * 2, 0, rcClient.right, height, TRUE); >+ >+ ::SendMessage(m_hURLBarWnd, static_cast<UINT>(WM_SETFONT), reinterpret_cast<WPARAM>(m_browserWindow->urlBarFont()), TRUE); >+ >+ if (m_browserWindow->usesLayeredWebView() || !m_browserWindow->hwnd()) >+ return; >+ MoveWindow(m_browserWindow->hwnd(), 0, height, rcClient.right, rcClient.bottom - height, TRUE); >+} >+ >+LRESULT CALLBACK MainWindow::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) >+{ >+ switch (message) { >+ case WM_COMMAND: { >+ int wmId = LOWORD(wParam); >+ int wmEvent = HIWORD(wParam); >+ if (wmId >= IDM_HISTORY_LINK0 && wmId <= IDM_HISTORY_LINK9) { >+ if (gMiniBrowser) >+ gMiniBrowser->navigateToHistory(hWnd, wmId); >+ break; >+ } >+ // Parse the menu selections: >+ switch (wmId) { >+ case IDM_ABOUT: >+ DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); >+ break; >+ case IDM_EXIT: >+ DestroyWindow(hWnd); >+ break; >+ case IDM_PRINT: >+ PrintView(hWnd, message, wParam, lParam); >+ break; >+ case IDM_WEB_INSPECTOR: >+ if (gMiniBrowser) >+ gMiniBrowser->launchInspector(); >+ break; >+ case IDM_CACHES: >+ if (!::IsWindow(hCacheWnd)) { >+ hCacheWnd = CreateDialog(hInst, MAKEINTRESOURCE(IDD_CACHES), hWnd, Caches); >+ ::ShowWindow(hCacheWnd, SW_SHOW); >+ } >+ break; >+ case IDM_HISTORY_BACKWARD: >+ case IDM_HISTORY_FORWARD: >+ if (gMiniBrowser) >+ gMiniBrowser->navigateForwardOrBackward(hWnd, wmId); >+ break; >+ case IDM_UA_OTHER: >+ if (wmEvent) >+ ToggleMenuItem(hWnd, wmId); >+ else >+ DialogBox(hInst, MAKEINTRESOURCE(IDD_USER_AGENT), hWnd, CustomUserAgent); >+ break; >+ case IDM_ACTUAL_SIZE: >+ if (gMiniBrowser) >+ gMiniBrowser->resetZoom(); >+ break; >+ case IDM_ZOOM_IN: >+ if (gMiniBrowser) >+ gMiniBrowser->zoomIn(); >+ break; >+ case IDM_ZOOM_OUT: >+ if (gMiniBrowser) >+ gMiniBrowser->zoomOut(); >+ break; >+ case IDM_SHOW_LAYER_TREE: >+ if (gMiniBrowser) >+ gMiniBrowser->showLayerTree(); >+ break; >+ default: >+ if (!ToggleMenuItem(hWnd, wmId)) >+ return DefWindowProc(hWnd, message, wParam, lParam); >+ } >+ } >+ break; >+ case WM_DESTROY: >+#if USE(CF) >+ CFRunLoopStop(CFRunLoopGetMain()); >+#endif >+ PostQuitMessage(0); >+ break; >+ case WM_SIZE: >+ if (!gMiniBrowser || !gMiniBrowser->hasWebView()) >+ return DefWindowProc(hWnd, message, wParam, lParam); >+ >+ gMainWindow->resizeSubViews(); >+ break; >+ case WM_DPICHANGED: >+ if (gMiniBrowser) >+ gMiniBrowser->updateDeviceScaleFactor(); >+ return DefWindowProc(hWnd, message, wParam, lParam); >+ default: >+ return DefWindowProc(hWnd, message, wParam, lParam); >+ } >+ >+ return 0; >+} >diff --git a/Tools/MiniBrowser/win/MainWindow.h b/Tools/MiniBrowser/win/MainWindow.h >new file mode 100644 >index 00000000000..2423da7505f >--- /dev/null >+++ b/Tools/MiniBrowser/win/MainWindow.h >@@ -0,0 +1,51 @@ >+/* >+ * 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 <memory> >+#include <string> >+ >+class MiniBrowser; >+ >+class MainWindow { >+public: >+ bool init(HINSTANCE hInstance, bool usesLayeredWebView = false, bool pageLoadTesting = false); >+ >+ void resizeSubViews(); >+ HWND hwnd() const { return m_hMainWnd; } >+ MiniBrowser* browserWindow() const { return m_browserWindow.get(); } >+ >+private: >+ static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); >+ static void registerClass(HINSTANCE hInstance); >+ static std::wstring s_windowClass; >+ >+ HWND m_hMainWnd { nullptr }; >+ HWND m_hURLBarWnd { nullptr }; >+ HWND m_hBackButtonWnd { nullptr }; >+ HWND m_hForwardButtonWnd { nullptr }; >+ std::unique_ptr<MiniBrowser> m_browserWindow; >+}; >diff --git a/Tools/MiniBrowser/win/WinMain.cpp b/Tools/MiniBrowser/win/WinMain.cpp >index 781d54a231e..cd971f0aa17 100644 >--- a/Tools/MiniBrowser/win/WinMain.cpp >+++ b/Tools/MiniBrowser/win/WinMain.cpp >@@ -32,10 +32,6 @@ > #include "MiniBrowserLibResource.h" > #include "Common.cpp" > >-namespace WebCore { >-float deviceScaleFactorForWindow(HWND); >-} >- > int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpstrCmdLine, _In_ int nCmdShow) > { > #ifdef _CRTDBG_MAP_ALLOC >@@ -59,11 +55,6 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, > > parseCommandLine(usesLayeredWebView, useFullDesktop, pageLoadTesting, requestedURL); > >- // Initialize global strings >- LoadString(hInst, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); >- LoadString(hInst, IDC_MINIBROWSER, szWindowClass, MAX_LOADSTRING); >- MyRegisterClass(hInst); >- > if (useFullDesktop) > computeFullDesktopFrame(); > >@@ -72,42 +63,13 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, > > ::SetProcessDPIAware(); > >- float scaleFactor = WebCore::deviceScaleFactorForWindow(nullptr); >- >- hMainWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, >- CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, 0, 0, hInst, 0); >- >- if (!hMainWnd) >- return FALSE; >- >- hBackButtonWnd = CreateWindow(L"BUTTON", L"<", WS_CHILD | WS_VISIBLE | BS_TEXT, 0, 0, 0, 0, hMainWnd, 0, hInst, 0); >- hForwardButtonWnd = CreateWindow(L"BUTTON", L">", WS_CHILD | WS_VISIBLE | BS_TEXT, scaleFactor * CONTROLBUTTON_WIDTH, 0, 0, 0, hMainWnd, 0, hInst, 0); >- hURLBarWnd = CreateWindow(L"EDIT", 0, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOVSCROLL, scaleFactor * CONTROLBUTTON_WIDTH * 2, 0, 0, 0, hMainWnd, 0, hInst, 0); >- >- ShowWindow(hMainWnd, nCmdShow); >- UpdateWindow(hMainWnd); >- >- DefEditProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(hURLBarWnd, GWLP_WNDPROC)); >- DefButtonProc = reinterpret_cast<WNDPROC>(GetWindowLongPtr(hBackButtonWnd, GWLP_WNDPROC)); >- SetWindowLongPtr(hURLBarWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(EditProc)); >- SetWindowLongPtr(hBackButtonWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(BackButtonProc)); >- SetWindowLongPtr(hForwardButtonWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(ForwardButtonProc)); >- >- SetFocus(hURLBarWnd); >- >- gMiniBrowser = new MiniBrowser(hMainWnd, hURLBarWnd, usesLayeredWebView, pageLoadTesting); >- if (!gMiniBrowser) >- goto exit; >- HRESULT hr = gMiniBrowser->init(); >+ gMainWindow = new MainWindow(); >+ HRESULT hr = gMainWindow->init(hInst, usesLayeredWebView, pageLoadTesting); > if (FAILED(hr)) > goto exit; > >- gViewWindow = gMiniBrowser->hwnd(); >- >- resizeSubViews(); >- >- ShowWindow(gViewWindow, nCmdShow); >- UpdateWindow(gViewWindow); >+ gMiniBrowser = gMainWindow->browserWindow(); >+ ShowWindow(gMainWindow->hwnd(), nCmdShow); > > hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDC_MINIBROWSER)); > >@@ -139,28 +101,5 @@ exit: > // Shut down COM. > OleUninitialize(); > >- delete gMiniBrowser; >- > return static_cast<int>(msg.wParam); > } >- >-ATOM MyRegisterClass(HINSTANCE hInstance) >-{ >- WNDCLASSEX wcex; >- >- wcex.cbSize = sizeof(WNDCLASSEX); >- >- wcex.style = CS_HREDRAW | CS_VREDRAW; >- wcex.lpfnWndProc = WndProc; >- wcex.cbClsExtra = 0; >- wcex.cbWndExtra = 0; >- wcex.hInstance = hInstance; >- wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MINIBROWSER)); >- wcex.hCursor = LoadCursor(0, IDC_ARROW); >- wcex.hbrBackground = 0; >- wcex.lpszMenuName = MAKEINTRESOURCE(IDC_MINIBROWSER); >- wcex.lpszClassName = szWindowClass; >- wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL)); >- >- return RegisterClassEx(&wcex); >-}
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 185814
:
340833
|
341159
|
341266
|
341268
|
341442