Title: [231658] trunk/Tools
Revision
231658
Author
[email protected]
Date
2018-05-10 13:54:12 -0700 (Thu, 10 May 2018)

Log Message

[Win][MiniBrowser] Add a separate WndProc for the layered window
https://bugs.webkit.org/show_bug.cgi?id=185460

Reviewed by Brent Fulgham.

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.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (231657 => 231658)


--- trunk/Tools/ChangeLog	2018-05-10 20:43:14 UTC (rev 231657)
+++ trunk/Tools/ChangeLog	2018-05-10 20:54:12 UTC (rev 231658)
@@ -1,3 +1,31 @@
+2018-05-10  Fujii Hironori  <[email protected]>
+
+        [Win][MiniBrowser] Add a separate WndProc for the layered window
+        https://bugs.webkit.org/show_bug.cgi?id=185460
+
+        Reviewed by Brent Fulgham.
+
+        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-10  Stephan Szabo  <[email protected]>
 
         Support --verbose in run-_javascript_core-tests

Modified: trunk/Tools/MiniBrowser/win/Common.cpp (231657 => 231658)


--- trunk/Tools/MiniBrowser/win/Common.cpp	2018-05-10 20:43:14 UTC (rev 231657)
+++ trunk/Tools/MiniBrowser/win/Common.cpp	2018-05-10 20:54:12 UTC (rev 231658)
@@ -132,18 +132,6 @@
     ::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 @@
 
 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 @@
             break;
         default:
             if (!ToggleMenuItem(hWnd, wmId))
-                return CallWindowProc(parentProc, hWnd, message, wParam, lParam);
+                return DefWindowProc(hWnd, message, wParam, lParam);
         }
         }
         break;
@@ -524,8 +493,8 @@
         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;
@@ -532,9 +501,9 @@
     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;

Modified: trunk/Tools/MiniBrowser/win/MiniBrowser.cpp (231657 => 231658)


--- trunk/Tools/MiniBrowser/win/MiniBrowser.cpp	2018-05-10 20:43:14 UTC (rev 231657)
+++ trunk/Tools/MiniBrowser/win/MiniBrowser.cpp	2018-05-10 20:54:12 UTC (rev 231658)
@@ -88,7 +88,7 @@
     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 @@
     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;

Modified: trunk/Tools/MiniBrowser/win/MiniBrowser.h (231657 => 231658)


--- trunk/Tools/MiniBrowser/win/MiniBrowser.h	2018-05-10 20:43:14 UTC (rev 231657)
+++ trunk/Tools/MiniBrowser/win/MiniBrowser.h	2018-05-10 20:54:12 UTC (rev 231658)
@@ -50,7 +50,7 @@
     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 @@
     void updateDeviceScaleFactor();
 
     HGDIOBJ urlBarFont() { return m_hURLBarFont; }
+    HWND hwnd() { return m_viewWnd; }
+    void subclassForLayeredWindow();
 
 private:
     void generateFontForScaleFactor(float);
@@ -125,6 +127,7 @@
     HWND m_hMainWnd { nullptr };
     HWND m_hURLBarWnd { nullptr };
     HGDIOBJ m_hURLBarFont { nullptr };
+    HWND m_viewWnd { nullptr };
 
     float m_deviceScaleFactor { 1.0f };
     bool m_useLayeredWebView;

Modified: trunk/Tools/MiniBrowser/win/WinMain.cpp (231657 => 231658)


--- trunk/Tools/MiniBrowser/win/WinMain.cpp	2018-05-10 20:43:14 UTC (rev 231657)
+++ trunk/Tools/MiniBrowser/win/WinMain.cpp	2018-05-10 20:54:12 UTC (rev 231658)
@@ -157,12 +157,13 @@
     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();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to