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 763650 cfcc9043048d31e4dc575ee2e18653dca2bcead1
parent 763585 f5a845fcc239fe705e50a0686ba5ab2be6fa0c7f
push id101507
push userxquan@mozilla.com
push dateTue, 06 Mar 2018 11:29:24 +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
@@ -6786,21 +6786,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)
 {