Bug 1443392 - Send resize event when FRAMECHANGED flag is set even if the window isn't resized. r?jimm draft
authorXidorn Quan <me@upsuper.org>
Tue, 06 Mar 2018 17:47:15 +1100
changeset 765767 88e2d0799562a8ffe35d871565c916cd532aa2a3
parent 765749 7edd06cf51e91fa4ce8029b9f2da353293ac38d2
child 765768 193a3dfba70c873c6b580d216c2816af2247df89
push id102161
push userbmo:emilio@crisal.io
push dateSat, 10 Mar 2018 07:39:34 +0000
reviewersjimm
bugs1443392
milestone60.0a1
Bug 1443392 - Send resize event when FRAMECHANGED flag is set even if the window isn't resized. r?jimm MozReview-Commit-ID: 9wpiFr9Tw9c
widget/windows/nsWindow.cpp
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -6785,21 +6785,34 @@ void nsWindow::OnWindowPosChanged(WINDOW
 
     // If a maximized window is resized, recalculate the non-client margins.
     if (mSizeMode == nsSizeMode_Maximized) {
       if (UpdateNonClientMargins(nsSizeMode_Maximized, true)) {
         // gecko resize event already sent by UpdateNonClientMargins.
         return;
       }
     }
-
-    // Recalculate the width and height based on the client area for gecko events.
-    LayoutDeviceIntSize clientSize(newWidth, newHeight);
+  }
+
+  // Notify the widget listener for size change of client area for gecko
+  // events. This needs to be done when either window size is changed,
+  // or window frame is changed. They may not happen together.
+  // However, we don't invoke that for popup when window frame changes,
+  // because popups may trigger frame change before size change via
+  // {Set,Clear}ThemeRegion they invoke in Resize. That would make the
+  // code below call OnResize with a wrong client size first, which can
+  // lead to flickerling for some popups.
+  if (!(wp->flags & SWP_NOSIZE) ||
+      ((wp->flags & SWP_FRAMECHANGED) && !IsPopup())) {
+    RECT r;
+    LayoutDeviceIntSize clientSize;
     if (::GetClientRect(mWnd, &r)) {
       clientSize = WinUtils::ToIntRect(r).Size();
+    } else {
+      clientSize = mBounds.Size();
     }
     // Send a gecko resize event
     OnResize(clientSize);
   }
 }
 
 void nsWindow::OnWindowPosChanging(LPWINDOWPOS& info)
 {