Bug 1259492 - Ensure window position is constrained to the screen after it has been sized properly in nsXULWindow::OnChromeLoaded. r=emk a=ritu
authorJonathan Kew <jkew@mozilla.com>
Thu, 24 Mar 2016 17:08:19 +0000
changeset 323671 8e9a6e6cbacd7f8c2be068acb0b59a8b175eb244
parent 323670 a9fd59d20ca17eb27c1096c8cc582463a54d06bd
child 323672 a7237024906d361f662608fada22618bfe8360c8
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemk, ritu
bugs1259492
milestone47.0a2
Bug 1259492 - Ensure window position is constrained to the screen after it has been sized properly in nsXULWindow::OnChromeLoaded. r=emk a=ritu
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);