Bug 1062335 - Loop panel size increases after switching themes. r=mixedpuppy
authorJared Wein <jwein@mozilla.com>
Mon, 20 Oct 2014 11:49:20 -0400
changeset 211353 7b9007ba3e17dafadbbb4f2e489eea46b22f7146
parent 211352 eb04720f22904c027dd6bdef2868a3e48bd4a6c5
child 211354 aa6ed82c6aa46a88d57e018fe01256a206f71e16
push id50691
push userkwierso@gmail.com
push dateTue, 21 Oct 2014 02:08:21 +0000
treeherdermozilla-inbound@0808729b24e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1062335
milestone36.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 1062335 - Loop panel size increases after switching themes. r=mixedpuppy
browser/modules/PanelFrame.jsm
browser/modules/Social.jsm
--- a/browser/modules/PanelFrame.jsm
+++ b/browser/modules/PanelFrame.jsm
@@ -45,17 +45,17 @@ let PanelFrameInternal = {
    * @param {String} aSize The initial size of the panel (width and height are the same
    *                       if specified).
    */
   _attachNotificatonPanel: function(aWindow, aParent, aButton, aType, aOrigin, aSrc, aSize) {
     aParent.hidden = false;
     let notificationFrameId = aOrigin ? aType + "-status-" + aOrigin : aType;
     let frame = aWindow.document.getElementById(notificationFrameId);
 
-    // If the button was customized to a new location, we we'll destroy the
+    // If the button was customized to a new location, destroy the
     // iframe and start fresh.
     if (frame && frame.parentNode != aParent) {
       SharedFrame.forgetGroup(frame.id);
       frame.parentNode.removeChild(frame);
       frame = null;
     }
 
     if (!frame) {
@@ -152,28 +152,28 @@ let PanelFrame = {
         dynamicResizer.stop();
       notificationFrame.docShell.isActive = false;
       dispatchPanelEvent(aType + "FrameHide");
     });
 
     panel.addEventListener("popupshown", function onpopupshown() {
       panel.removeEventListener("popupshown", onpopupshown);
       SharedFrame.setOwner(notificationFrameId, notificationFrame);
-      // This attribute is needed on both the button and the
-      // containing toolbaritem since the buttons on OS X have
-      // moz-appearance:none, while their container gets
-      // moz-appearance:toolbarbutton due to the way that toolbar buttons
-      // get combined on OS X.
       let initFrameShow = () => {
         notificationFrame.docShell.isActive = true;
         notificationFrame.docShell.isAppTab = true;
         if (dynamicResizer)
           dynamicResizer.start(panel, notificationFrame);
         dispatchPanelEvent(aType + "FrameShow");
       };
+      // This attribute is needed on both the button and the
+      // containing toolbaritem since the buttons on OS X have
+      // moz-appearance:none, while their container gets
+      // moz-appearance:toolbarbutton due to the way that toolbar buttons
+      // get combined on OS X.
       anchorBtn.setAttribute("open", "true");
       if (notificationFrame.contentDocument &&
           notificationFrame.contentDocument.readyState == "complete") {
         initFrameShow();
       } else {
         // first time load, wait for load and dispatch after load
         notificationFrame.addEventListener("load", function panelBrowserOnload(e) {
           notificationFrame.removeEventListener("load", panelBrowserOnload, true);
--- a/browser/modules/Social.jsm
+++ b/browser/modules/Social.jsm
@@ -416,23 +416,27 @@ function sizeSocialPanelToContent(panel,
   // if the panel is preloaded prior to being shown, cs will be null.  in that
   // case use the minimum size for the panel until it is shown.
   if (cs) {
     let computedHeight = parseInt(cs.marginTop) + body.offsetHeight + parseInt(cs.marginBottom);
     height = Math.max(computedHeight, height);
     let computedWidth = parseInt(cs.marginLeft) + body.offsetWidth + parseInt(cs.marginRight);
     width = Math.max(computedWidth, width);
   }
-  // add extra space the panel needs if any
-  width += panel.boxObject.width - iframe.boxObject.width;
-  height += panel.boxObject.height - iframe.boxObject.height;
+
+  // only add the extra space if the iframe has been loaded
+  if (iframe.boxObject.width && iframe.boxObject.height) {
+    // add extra space the panel needs if any
+    width += panel.boxObject.width - iframe.boxObject.width;
+    height += panel.boxObject.height - iframe.boxObject.height;
+  }
 
   // when size is computed, we want to be sure changes are "significant" since
   // some sites will resize when the iframe is resized by a small amount, making
-  // the panel slowely shrink to some minimum.
+  // the panel slowly shrink to some minimum.
   if (Math.abs(panel.boxObject.width - width) > 2 || Math.abs(panel.boxObject.height - height) > 2) {
     panel.sizeTo(width, height);
   }
 }
 
 function DynamicResizeWatcher() {
   this._mutationObserver = null;
 }