WebKit Bugzilla
Attachment 339914 Details for
Bug 185460
: [Win][MiniBrowser] Add a separate WndProc for the layered window
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-185460-20180509110158.patch (text/plain), 9.68 KB, created by
Fujii Hironori
on 2018-05-08 19:02:00 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Fujii Hironori
Created:
2018-05-08 19:02:00 PDT
Size:
9.68 KB
patch
obsolete
>Subversion Revision: 231482 >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 2f11cca080a23888aa0c0aeb6ff5c67e5e42219b..056863ab5efd70ac63b1680a760498a8e1532e01 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,31 @@ >+2018-05-08 Fujii Hironori <Hironori.Fujii@sony.com> >+ >+ [Win][MiniBrowser] Add a separate WndProc for the layered window >+ https://bugs.webkit.org/show_bug.cgi?id=185460 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ All WK1 related code should be moved into MiniBrowser for the >+ preparation of Bug 184770. >+ >+ The layered window was using WndProc of the main window. The >+ layered window is specific only for WK1. the main window will be >+ shared among WK1 and WK2. >+ >+ This change add a new WndProc for the layer window. >+ >+ * MiniBrowser/win/Common.cpp: >+ (WndProc): Removed code for the layered windows. >+ (subclassForLayeredWindow): Moved into MiniBrowser.cpp. >+ * MiniBrowser/win/MiniBrowser.cpp: >+ (MiniBrowser::prepareViews): Removed the fourth argument `viewHwnd`. >+ (viewWndProc): New WndProc for the layered windows. >+ (MiniBrowser::subclassForLayeredWindow): Moved from Common.cpp. >+ * MiniBrowser/win/MiniBrowser.h: >+ (MiniBrowser::hwnd): >+ * MiniBrowser/win/WinMain.cpp: >+ (wWinMain): Added m_viewWnd. >+ > 2018-05-07 Chris Dumez <cdumez@apple.com> > > Unreviewed, fix issue with running Speedometer PerfTest after r231450. >diff --git a/Tools/MiniBrowser/win/Common.cpp b/Tools/MiniBrowser/win/Common.cpp >index bb7a354aecf98422034169d8f1d815e9020a12cb..4bc41b96bb00a0635ab8f73c6a18ec340d2b59f5 100644 >--- a/Tools/MiniBrowser/win/Common.cpp >+++ b/Tools/MiniBrowser/win/Common.cpp >@@ -132,18 +132,6 @@ static void resizeSubViews() > ::SendMessage(hURLBarWnd, static_cast<UINT>(WM_SETFONT), reinterpret_cast<WPARAM>(gMiniBrowser->urlBarFont()), TRUE); > } > >-static void subclassForLayeredWindow() >-{ >- hMainWnd = gViewWindow; >-#if defined _M_AMD64 || defined _WIN64 >- DefWebKitProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtr(hMainWnd, GWLP_WNDPROC)); >- ::SetWindowLongPtr(hMainWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(WndProc)); >-#else >- DefWebKitProc = reinterpret_cast<WNDPROC>(::GetWindowLong(hMainWnd, GWL_WNDPROC)); >- ::SetWindowLong(hMainWnd, GWL_WNDPROC, reinterpret_cast<LONG_PTR>(WndProc)); >-#endif >-} >- > static void computeFullDesktopFrame() > { > RECT desktop; >@@ -435,26 +423,7 @@ static const int dragBarHeight = 30; > > LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) > { >- WNDPROC parentProc = (gMiniBrowser) ? (gMiniBrowser->usesLayeredWebView() ? DefWebKitProc : DefWindowProc) : DefWindowProc; >- > switch (message) { >- case WM_NCHITTEST: >- if (gMiniBrowser && gMiniBrowser->usesLayeredWebView()) { >- RECT window; >- ::GetWindowRect(hWnd, &window); >- // For testing our transparent window, we need a region to use as a handle for >- // dragging. The right way to do this would be to query the web view to see what's >- // under the mouse. However, for testing purposes we just use an arbitrary >- // 30 logical pixel band at the top of the view as an arbitrary gripping location. >- // >- // When we are within this bad, return HT_CAPTION to tell Windows we want to >- // treat this region as if it were the title bar on a normal window. >- int y = HIWORD(lParam); >- float scaledDragBarHeightFactor = dragBarHeight * gMiniBrowser->deviceScaleFactor(); >- if ((y > window.top) && (y < window.top + scaledDragBarHeightFactor)) >- return HTCAPTION; >- } >- return CallWindowProc(parentProc, hWnd, message, wParam, lParam); > case WM_COMMAND: { > int wmId = LOWORD(wParam); > int wmEvent = HIWORD(wParam); >@@ -513,7 +482,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) > break; > default: > if (!ToggleMenuItem(hWnd, wmId)) >- return CallWindowProc(parentProc, hWnd, message, wParam, lParam); >+ return DefWindowProc(hWnd, message, wParam, lParam); > } > } > break; >@@ -524,17 +493,17 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) > PostQuitMessage(0); > break; > case WM_SIZE: >- if (!gMiniBrowser || !gMiniBrowser->hasWebView() || gMiniBrowser->usesLayeredWebView()) >- return CallWindowProc(parentProc, hWnd, message, wParam, lParam); >+ if (!gMiniBrowser || !gMiniBrowser->hasWebView()) >+ return DefWindowProc(hWnd, message, wParam, lParam); > > resizeSubViews(); > break; > case WM_DPICHANGED: > if (gMiniBrowser) > gMiniBrowser->updateDeviceScaleFactor(); >- return CallWindowProc(parentProc, hWnd, message, wParam, lParam); >+ return DefWindowProc(hWnd, message, wParam, lParam); > default: >- return CallWindowProc(parentProc, hWnd, message, wParam, lParam); >+ return DefWindowProc(hWnd, message, wParam, lParam); > } > > return 0; >diff --git a/Tools/MiniBrowser/win/MiniBrowser.cpp b/Tools/MiniBrowser/win/MiniBrowser.cpp >index ffbc98f8140f9daf54132e3360264451a2e31ce5..35df2d8bb33399a0943dec5423ebf9dfc62550ca 100644 >--- a/Tools/MiniBrowser/win/MiniBrowser.cpp >+++ b/Tools/MiniBrowser/win/MiniBrowser.cpp >@@ -88,7 +88,7 @@ HRESULT MiniBrowser::init() > return hr; > } > >-HRESULT MiniBrowser::prepareViews(HWND mainWnd, const RECT& clientRect, const BSTR& requestedURL, HWND& viewHwnd) >+HRESULT MiniBrowser::prepareViews(HWND mainWnd, const RECT& clientRect, const BSTR& requestedURL) > { > if (!m_webView) > return E_FAIL; >@@ -118,11 +118,46 @@ HRESULT MiniBrowser::prepareViews(HWND mainWnd, const RECT& clientRect, const BS > if (FAILED(hr)) > return hr; > >- hr = m_webViewPrivate->viewWindow(&viewHwnd); >+ hr = m_webViewPrivate->viewWindow(&m_viewWnd); > > return hr; > } > >+static WNDPROC gDefWebKitProc; >+ >+static LRESULT CALLBACK viewWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) >+{ >+ switch (message) { >+ case WM_NCHITTEST: >+ constexpr int dragBarHeight = 30; >+ RECT window; >+ ::GetWindowRect(hWnd, &window); >+ // For testing our transparent window, we need a region to use as a handle for >+ // dragging. The right way to do this would be to query the web view to see what's >+ // under the mouse. However, for testing purposes we just use an arbitrary >+ // 30 logical pixel band at the top of the view as an arbitrary gripping location. >+ // >+ // When we are within this bad, return HT_CAPTION to tell Windows we want to >+ // treat this region as if it were the title bar on a normal window. >+ int y = HIWORD(lParam); >+ float scaledDragBarHeightFactor = dragBarHeight * WebCore::deviceScaleFactorForWindow(hWnd); >+ if ((y > window.top) && (y < window.top + scaledDragBarHeightFactor)) >+ return HTCAPTION; >+ } >+ return CallWindowProc(gDefWebKitProc, hWnd, message, wParam, lParam); >+} >+ >+void MiniBrowser::subclassForLayeredWindow() >+{ >+#if defined _M_AMD64 || defined _WIN64 >+ gDefWebKitProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtr(m_viewWnd, GWLP_WNDPROC)); >+ ::SetWindowLongPtr(m_viewWnd, GWLP_WNDPROC, reinterpret_cast<LONG_PTR>(viewWndProc)); >+#else >+ gDefWebKitProc = reinterpret_cast<WNDPROC>(::GetWindowLong(m_viewWnd, GWL_WNDPROC)); >+ ::SetWindowLong(m_viewWnd, GWL_WNDPROC, reinterpret_cast<LONG_PTR>(viewWndProc)); >+#endif >+} >+ > HRESULT MiniBrowser::setFrameLoadDelegate(IWebFrameLoadDelegate* frameLoadDelegate) > { > m_frameLoadDelegate = frameLoadDelegate; >diff --git a/Tools/MiniBrowser/win/MiniBrowser.h b/Tools/MiniBrowser/win/MiniBrowser.h >index a7032f4f5bc7d60e7a993d62f560ea78e6d61419..450c866c92eb63c337681a644e2cf4ae4405ada3 100644 >--- a/Tools/MiniBrowser/win/MiniBrowser.h >+++ b/Tools/MiniBrowser/win/MiniBrowser.h >@@ -50,7 +50,7 @@ public: > MiniBrowser(HWND mainWnd, HWND urlBarWnd, bool useLayeredWebView = false, bool pageLoadTesting = false); > > HRESULT init(); >- HRESULT prepareViews(HWND mainWnd, const RECT& clientRect, const BSTR& requestedURL, HWND& viewWnd); >+ HRESULT prepareViews(HWND mainWnd, const RECT& clientRect, const BSTR& requestedURL); > > HRESULT loadURL(const BSTR& passedURL); > >@@ -97,6 +97,8 @@ public: > void updateDeviceScaleFactor(); > > HGDIOBJ urlBarFont() { return m_hURLBarFont; } >+ HWND hwnd() { return m_viewWnd; } >+ void subclassForLayeredWindow(); > > private: > void generateFontForScaleFactor(float); >@@ -125,6 +127,7 @@ private: > HWND m_hMainWnd { nullptr }; > HWND m_hURLBarWnd { nullptr }; > HGDIOBJ m_hURLBarFont { nullptr }; >+ HWND m_viewWnd { nullptr }; > > float m_deviceScaleFactor { 1.0f }; > bool m_useLayeredWebView; >diff --git a/Tools/MiniBrowser/win/WinMain.cpp b/Tools/MiniBrowser/win/WinMain.cpp >index 0594bcbe5408a2934d33159ce6a2f5bddbc70f42..8b83a1777cf5ca6ef3584f3c6015f65976cc84da 100644 >--- a/Tools/MiniBrowser/win/WinMain.cpp >+++ b/Tools/MiniBrowser/win/WinMain.cpp >@@ -157,12 +157,13 @@ int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, > if (FAILED(hr)) > goto exit; > >- hr = gMiniBrowser->prepareViews(hMainWnd, clientRect, requestedURL.GetBSTR(), gViewWindow); >- if (FAILED(hr) || !gViewWindow) >+ hr = gMiniBrowser->prepareViews(hMainWnd, clientRect, requestedURL.GetBSTR()); >+ if (FAILED(hr)) > goto exit; >+ gViewWindow = gMiniBrowser->hwnd(); > > if (gMiniBrowser->usesLayeredWebView()) >- subclassForLayeredWindow(); >+ gMiniBrowser->subclassForLayeredWindow(); > > resizeSubViews(); >
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 185460
: 339914 |
339966