Bug 1448199 part 1 - Allow window to show earlier when sizemode is changed before window turned visible. r=jimm draft
authorXidorn Quan <me@upsuper.org>
Wed, 21 Mar 2018 16:05:51 +1100
changeset 772526 5ce2c751618347f8b0844f1bb68051fb515ee993
parent 772311 1873bee259daf65865b2db64d89b316b440d0211
child 772527 2f798cf2b37bbaa6d8d7fa596c79fe47efcff3e8
push id103943
push userxquan@mozilla.com
push dateMon, 26 Mar 2018 11:17:55 +0000
reviewersjimm
bugs1448199
milestone61.0a1
Bug 1448199 part 1 - Allow window to show earlier when sizemode is changed before window turned visible. r=jimm This would show a blank window at an earlier time before other stuff are ready. It saves us from an extra resize reflow which otherwise would happen because the window is resized only when it's shown. MozReview-Commit-ID: CNH6rpMmkYW
widget/windows/nsWindow.cpp
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -2092,46 +2092,48 @@ nsWindow::SetSizeMode(nsSizeMode aMode)
   // (This is needed to prevent problems when calling window.minimize(), which
   // calls us directly, and then the OS triggers another call to us.)
   if (aMode == mSizeMode)
     return;
 
   // save the requested state
   mLastSizeMode = mSizeMode;
   nsBaseWidget::SetSizeMode(aMode);
+
+  int mode;
+  switch (aMode) {
+    case nsSizeMode_Fullscreen :
+      mode = SW_SHOW;
+      break;
+
+    case nsSizeMode_Maximized :
+      mode = SW_MAXIMIZE;
+      break;
+
+    case nsSizeMode_Minimized :
+      mode = SW_MINIMIZE;
+      break;
+
+    default :
+      mode = SW_RESTORE;
+  }
+
+  // Don't call ::ShowWindow if we're trying to "restore" a window that is
+  // already in a normal state.  Prevents a bug where snapping to one side
+  // of the screen and then minimizing would cause Windows to forget our
+  // window's correct restored position/size.
+  if(!(GetCurrentShowCmd(mWnd) == SW_SHOWNORMAL && mode == SW_RESTORE)) {
+    ::ShowWindow(mWnd, mode);
+  }
+
   if (mIsVisible) {
-    int mode;
-
-    switch (aMode) {
-      case nsSizeMode_Fullscreen :
-        mode = SW_SHOW;
-        break;
-
-      case nsSizeMode_Maximized :
-        mode = SW_MAXIMIZE;
-        break;
-
-      case nsSizeMode_Minimized :
-        mode = SW_MINIMIZE;
-        break;
-
-      default :
-        mode = SW_RESTORE;
-    }
-
-    // Don't call ::ShowWindow if we're trying to "restore" a window that is
-    // already in a normal state.  Prevents a bug where snapping to one side
-    // of the screen and then minimizing would cause Windows to forget our
-    // window's correct restored position/size.
-    if(!(GetCurrentShowCmd(mWnd) == SW_SHOWNORMAL && mode == SW_RESTORE)) {
-      ::ShowWindow(mWnd, mode);
-    }
     // we activate here to ensure that the right child window is focused
-    if (mode == SW_MAXIMIZE || mode == SW_SHOW)
+    if (mode == SW_MAXIMIZE || mode == SW_SHOW) {
       DispatchFocusToTopLevelWindow(true);
+    }
   }
 }
 
 void
 nsWindow::SuppressAnimation(bool aSuppress)
 {
   DWORD dwAttribute = aSuppress ? TRUE : FALSE;
   DwmSetWindowAttribute(mWnd, DWMWA_TRANSITIONS_FORCEDISABLED,