Bug 1259492 - Ensure window position is constrained to the screen after it has been sized properly in nsXULWindow::OnChromeLoaded. r=emk
authorJonathan Kew <jkew@mozilla.com>
Thu, 24 Mar 2016 17:08:19 +0000
changeset 290279 8ef8befd63b90b867ae27ab1b58758180dad0fc3
parent 290278 8b9681467229710ffc1ccd6596f24d1ef9ce9877
child 290280 1c8b633d485f1ef077e8942591865ac9ffb95717
push id30117
push userryanvm@gmail.com
push dateFri, 25 Mar 2016 15:36:00 +0000
treeherdermozilla-central@b45ee3e065b7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk
bugs1259492
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1259492 - Ensure window position is constrained to the screen after it has been sized properly in nsXULWindow::OnChromeLoaded. r=emk
xpfe/appshell/nsXULWindow.cpp
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -1075,26 +1075,30 @@ void nsXULWindow::OnChromeLoaded()
         nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
         docShellAsItem->GetTreeOwner(getter_AddRefs(treeOwner));
         if (treeOwner) {
           // GetContentSize can fail, so initialise |width| and |height| to be
           // on the safe side.
           int32_t width = 0, height = 0;
           if (NS_SUCCEEDED(cv->GetContentSize(&width, &height))) {
             treeOwner->SizeShellTo(docShellAsItem, width, height);
-            // Now that we know the window's final size, we can re-do its
-            // positioning so that it is properly constrained to the screen.
-            if (positionSet) {
-              LoadPositionFromXUL(width, height);
-            }
+            // Update specified size for the final LoadPositionFromXUL call.
+            specWidth = width;
+            specHeight = height;
           }
         }
       }
     }
 
+    // Now that we have set the window's final size, we can re-do its
+    // positioning so that it is properly constrained to the screen.
+    if (positionSet) {
+      LoadPositionFromXUL(specWidth, specHeight);
+    }
+
     LoadMiscPersistentAttributesFromXUL();
 
     if (mCenterAfterLoad && !positionSet) {
       Center(parentWindow, parentWindow ? false : true, false);
     }
 
     if (mShowAfterLoad) {
       SetVisibility(true);