WebKit Bugzilla
Attachment 341159 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
bug-185814-20180524112832.patch (text/plain), 28.28 KB, created by
Fujii Hironori
on 2018-05-23 19:28:33 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Fujii Hironori
Created:
2018-05-23 19:28:33 PDT
Size:
28.28 KB
patch
obsolete
>Subversion Revision: 232140 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 284a5c1c96a9f2a2a870f4446382f020ebda07c0..e4727ce6f8a7860e520a1a5847a72793d9c0c1c2 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,46 @@ >+2018-05-23 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-23 Roy Reapor <rreapor@apple.com> > > Use Helvetica on build.webkit.org webpages >diff --git a/Tools/MiniBrowser/win/CMakeLists.txt b/Tools/MiniBrowser/win/CMakeLists.txt >index b8956f8320c7b89426fd3adbb05998f34af90c3d..70e6d7ce56b3e88c1a0b575e13a7a34ec3d1fae0 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 11c6549f36838fb8c8bc9541605713cf30e3d3a2..cd280740dcabbfdce71a514d242c37ce44e7dd7d 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,10 +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 >@@ -70,34 +67,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 +88,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 +237,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 +279,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 +359,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 +471,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 +486,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 +539,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 0000000000000000000000000000000000000000..a20031c3b19a16796cb4bc1a5300b6f9ef4de928 >--- /dev/null >+++ b/Tools/MiniBrowser/win/MainWindow.cpp >@@ -0,0 +1,223 @@ >+/* >+ * 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 >+ >+constexpr size_t MAX_LOADSTRING = 100; >+TCHAR szTitle[MAX_LOADSTRING]; // The title bar text >+TCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name >+ >+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); >+ >+ATOM MainWindow::registerClass(HINSTANCE hInstance) >+{ >+ LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); >+ LoadString(hInstance, IDC_MINIBROWSER, szWindowClass, MAX_LOADSTRING); >+ >+ 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); >+} >+ >+bool MainWindow::init(HINSTANCE hInstance, bool usesLayeredWebView, bool pageLoadTesting) >+{ >+ m_hMainWnd = CreateWindow(szWindowClass, szTitle, 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 0000000000000000000000000000000000000000..ca8f2f359f0a25dabdf07fac7a77e2b784bd7b45 >--- /dev/null >+++ b/Tools/MiniBrowser/win/MainWindow.h >@@ -0,0 +1,49 @@ >+/* >+ * 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> >+ >+class MiniBrowser; >+ >+class MainWindow { >+public: >+ bool init(HINSTANCE hInstance, bool usesLayeredWebView = false, bool pageLoadTesting = false); >+ >+ void resizeSubViews(); >+ HWND hwnd() { return m_hMainWnd; } >+ MiniBrowser* browserWindow() { return m_browserWindow.get(); } >+ >+ static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); >+ static ATOM registerClass(HINSTANCE hInstance); >+ >+private: >+ HWND m_hMainWnd; >+ HWND m_hURLBarWnd; >+ HWND m_hBackButtonWnd; >+ HWND m_hForwardButtonWnd; >+ std::unique_ptr<MiniBrowser> m_browserWindow; >+}; >diff --git a/Tools/MiniBrowser/win/MiniBrowser.cpp b/Tools/MiniBrowser/win/MiniBrowser.cpp >index 749bf044a5ac7541938261e5e9d5700a9725db06..a161c58aff0315411728b7b703067b60b841dd29 100644 >--- a/Tools/MiniBrowser/win/MiniBrowser.cpp >+++ b/Tools/MiniBrowser/win/MiniBrowser.cpp >@@ -69,7 +69,7 @@ MiniBrowser::MiniBrowser(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView, b > { > } > >-HRESULT MiniBrowser::init(_bstr_t& requestedURL) >+HRESULT MiniBrowser::init() > { > updateDeviceScaleFactor(); > >@@ -135,7 +135,7 @@ HRESULT MiniBrowser::init(_bstr_t& requestedURL) > if (usesLayeredWebView()) > clientRect = { s_windowPosition.x, s_windowPosition.y, s_windowPosition.x + s_windowSize.cx, s_windowPosition.y + s_windowSize.cy }; > >- hr = prepareViews(m_hMainWnd, clientRect, requestedURL.GetBSTR()); >+ hr = prepareViews(m_hMainWnd, clientRect); > if (FAILED(hr)) > return hr; > >@@ -157,7 +157,7 @@ bool MiniBrowser::setCacheFolder() > return true; > } > >-HRESULT MiniBrowser::prepareViews(HWND mainWnd, const RECT& clientRect, const BSTR& requestedURL) >+HRESULT MiniBrowser::prepareViews(HWND mainWnd, const RECT& clientRect) > { > if (!m_webView) > return E_FAIL; >@@ -170,15 +170,6 @@ HRESULT MiniBrowser::prepareViews(HWND mainWnd, const RECT& clientRect, const BS > if (FAILED(hr)) > return hr; > >- if (!requestedURL) { >- IWebFramePtr frame; >- hr = m_webView->mainFrame(&frame.GetInterfacePtr()); >- if (FAILED(hr)) >- return hr; >- >- frame->loadHTMLString(_bstr_t(defaultHTML).GetBSTR(), 0); >- } >- > hr = m_webViewPrivate->setTransparent(m_useLayeredWebView); > if (FAILED(hr)) > return hr; >@@ -192,6 +183,17 @@ HRESULT MiniBrowser::prepareViews(HWND mainWnd, const RECT& clientRect, const BS > return hr; > } > >+HRESULT MiniBrowser::loadDefaultHTML() >+{ >+ IWebFramePtr frame; >+ HRESULT hr = m_webView->mainFrame(&frame.GetInterfacePtr()); >+ if (FAILED(hr)) >+ return hr; >+ >+ frame->loadHTMLString(_bstr_t(defaultHTML).GetBSTR(), 0); >+ return hr; >+} >+ > static WNDPROC gDefWebKitProc; > > static LRESULT CALLBACK viewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) >diff --git a/Tools/MiniBrowser/win/MiniBrowser.h b/Tools/MiniBrowser/win/MiniBrowser.h >index 4eb58c2b41dd2ef8c1f51774ae5eb886455e78c6..fbfc35cdda2a927764f25c2fb48f4cdb6d9f41c8 100644 >--- a/Tools/MiniBrowser/win/MiniBrowser.h >+++ b/Tools/MiniBrowser/win/MiniBrowser.h >@@ -49,9 +49,10 @@ class MiniBrowser { > public: > MiniBrowser(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false, bool pageLoadTesting = false); > >- HRESULT init(_bstr_t& requestedURL); >- HRESULT prepareViews(HWND mainWnd, const RECT& clientRect, const BSTR& requestedURL); >+ HRESULT init(); >+ HRESULT prepareViews(HWND mainWnd, const RECT& clientRect); > >+ HRESULT loadDefaultHTML(); > HRESULT loadURL(const BSTR& passedURL); > > void showLastVisitedSites(IWebView&); >diff --git a/Tools/MiniBrowser/win/WinMain.cpp b/Tools/MiniBrowser/win/WinMain.cpp >index 087e94df06822305f35c7517e78209d832452d04..4d5608358cefe5bcff1a7e8cc24ae304dfceaa39 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,10 +55,7 @@ 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); >+ MainWindow::registerClass(hInst); > > if (useFullDesktop) > computeFullDesktopFrame(); >@@ -72,47 +65,20 @@ 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(requestedURL); >+ 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)); > > if (requestedURL.length()) > loadURL(requestedURL.GetBSTR()); >+ else >+ gMiniBrowser->loadDefaultHTML(); > > #pragma warning(disable:4509) > >@@ -137,28 +103,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
Flags:
Hironori.Fujii
:
review-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185814
:
340833
|
341159
|
341266
|
341268
|
341442