Bug 1211344 - Stop setting various window attributes when they are not in 'persist' attribute. r=enndeakin, a=lizzard
☠☠ backed out by 6ee2ce4e485f ☠ ☠
authorXidorn Quan <quanxunzhen@gmail.com>
Fri, 09 Oct 2015 11:35:09 +1100
changeset 296379 2fbc5d0584e4797a21b232a26f95f0fc3bceca04
parent 296378 228866eb07ab001458dacbe16d35010303cbb344
child 296380 d77a1a7bc476beb2a42d8db7b9e53441338a0cd0
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin, lizzard
bugs1211344
milestone43.0a2
Bug 1211344 - Stop setting various window attributes when they are not in 'persist' attribute. r=enndeakin, a=lizzard
xpfe/appshell/nsXULWindow.cpp
--- a/xpfe/appshell/nsXULWindow.cpp
+++ b/xpfe/appshell/nsXULWindow.cpp
@@ -1437,16 +1437,19 @@ void nsXULWindow::SaveAttributes()
     return;
   }
 
   nsCOMPtr<dom::Element> docShellElement = GetWindowDOMElement();
   if (!docShellElement) {
     return;
   }
 
+  nsAutoString persistString;
+  docShellElement->GetAttribute(PERSIST_ATTRIBUTE, persistString);
+
   // get our size, position and mode to persist
   nsIntRect rect;
   bool gotRestoredBounds = NS_SUCCEEDED(mWindow->GetRestoredBounds(rect));
 
   CSSToLayoutDeviceScale scale = mWindow->GetDefaultScale();
 
   // make our position relative to our parent, if any
   nsCOMPtr<nsIBaseWindow> parent(do_QueryReferent(mParentWindow));
@@ -1459,55 +1462,62 @@ void nsXULWindow::SaveAttributes()
   }
 
   char                        sizeBuf[10];
   nsAutoString                sizeString;
 
   ErrorResult rv;
   // (only for size elements which are persisted)
   if ((mPersistentAttributesDirty & PAD_POSITION) && gotRestoredBounds) {
-    PR_snprintf(sizeBuf, sizeof(sizeBuf), "%d", NSToIntRound(rect.x / scale.scale));
-    sizeString.AssignWithConversion(sizeBuf);
-    docShellElement->SetAttribute(SCREENX_ATTRIBUTE, sizeString, rv);
-
-    PR_snprintf(sizeBuf, sizeof(sizeBuf), "%d", NSToIntRound(rect.y / scale.scale));
-    sizeString.AssignWithConversion(sizeBuf);
-    docShellElement->SetAttribute(SCREENY_ATTRIBUTE, sizeString, rv);
+    if (persistString.Find("screenX") >= 0) {
+      PR_snprintf(sizeBuf, sizeof(sizeBuf), "%d", NSToIntRound(rect.x / scale.scale));
+      sizeString.AssignWithConversion(sizeBuf);
+      docShellElement->SetAttribute(SCREENX_ATTRIBUTE, sizeString, rv);
+    }
+    if (persistString.Find("screenY") >= 0) {
+      PR_snprintf(sizeBuf, sizeof(sizeBuf), "%d", NSToIntRound(rect.y / scale.scale));
+      sizeString.AssignWithConversion(sizeBuf);
+      docShellElement->SetAttribute(SCREENY_ATTRIBUTE, sizeString, rv);
+    }
   }
 
   if ((mPersistentAttributesDirty & PAD_SIZE) && gotRestoredBounds) {
-    PR_snprintf(sizeBuf, sizeof(sizeBuf), "%d", NSToIntRound(rect.width / scale.scale));
-    sizeString.AssignWithConversion(sizeBuf);
-    docShellElement->SetAttribute(WIDTH_ATTRIBUTE, sizeString, rv);
-
-    PR_snprintf(sizeBuf, sizeof(sizeBuf), "%d", NSToIntRound(rect.height / scale.scale));
-    sizeString.AssignWithConversion(sizeBuf);
-    docShellElement->SetAttribute(HEIGHT_ATTRIBUTE, sizeString, rv);
+    if (persistString.Find("width") >= 0) {
+      PR_snprintf(sizeBuf, sizeof(sizeBuf), "%d", NSToIntRound(rect.width / scale.scale));
+      sizeString.AssignWithConversion(sizeBuf);
+      docShellElement->SetAttribute(WIDTH_ATTRIBUTE, sizeString, rv);
+    }
+    if (persistString.Find("height") >= 0) {
+      PR_snprintf(sizeBuf, sizeof(sizeBuf), "%d", NSToIntRound(rect.height / scale.scale));
+      sizeString.AssignWithConversion(sizeBuf);
+      docShellElement->SetAttribute(HEIGHT_ATTRIBUTE, sizeString, rv);
+    }
   }
 
   if (mPersistentAttributesDirty & PAD_MISC) {
     nsSizeMode sizeMode = mWindow->SizeMode();
 
     if (sizeMode != nsSizeMode_Minimized) {
       if (sizeMode == nsSizeMode_Maximized)
         sizeString.Assign(SIZEMODE_MAXIMIZED);
       else if (sizeMode == nsSizeMode_Fullscreen)
         sizeString.Assign(SIZEMODE_FULLSCREEN);
       else
         sizeString.Assign(SIZEMODE_NORMAL);
       docShellElement->SetAttribute(MODE_ATTRIBUTE, sizeString, rv);
     }
-
-    uint32_t zLevel;
-    nsCOMPtr<nsIWindowMediator> mediator(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
-    if (mediator) {
-      mediator->GetZLevel(this, &zLevel);
-      PR_snprintf(sizeBuf, sizeof(sizeBuf), "%lu", (unsigned long)zLevel);
-      sizeString.AssignWithConversion(sizeBuf);
-      docShellElement->SetAttribute(ZLEVEL_ATTRIBUTE, sizeString, rv);
+    if (persistString.Find("zlevel") >= 0) {
+      uint32_t zLevel;
+      nsCOMPtr<nsIWindowMediator> mediator(do_GetService(NS_WINDOWMEDIATOR_CONTRACTID));
+      if (mediator) {
+        mediator->GetZLevel(this, &zLevel);
+        PR_snprintf(sizeBuf, sizeof(sizeBuf), "%lu", (unsigned long)zLevel);
+        sizeString.AssignWithConversion(sizeBuf);
+        docShellElement->SetAttribute(ZLEVEL_ATTRIBUTE, sizeString, rv);
+      }
     }
   }
 
   mPersistentAttributesDirty = 0;
 }
 
 NS_IMETHODIMP nsXULWindow::GetWindowDOMWindow(nsIDOMWindow** aDOMWindow)
 {