Bug 1044597 - Limit the minimum size of subdialogs in the in-content preferences. r=Gijs
☠☠ backed out by 9c5e1c119b2d ☠ ☠
authorJared Wein <jwein@mozilla.com>
Sun, 08 Feb 2015 23:04:43 -0500
changeset 241746 c6aca5f18fdf9cdb065470f6250acbf4255c03a6
parent 241745 8f8af8afd1a6447087d1f985e633d95963e2ebdc
child 241747 d19066b865019c7a047d5b1a1df570b56068c641
push id619
push usercliu@mozilla.com
push dateMon, 09 Feb 2015 21:57:21 +0000
reviewersGijs
bugs1044597
milestone38.0a1
Bug 1044597 - Limit the minimum size of subdialogs in the in-content preferences. r=Gijs
browser/components/preferences/in-content/subdialogs.js
--- a/browser/components/preferences/in-content/subdialogs.js
+++ b/browser/components/preferences/in-content/subdialogs.js
@@ -87,16 +87,18 @@ let gSubDialog = {
     }
 
     this._overlay.style.visibility = "";
     // Clear the sizing inline styles.
     this._frame.removeAttribute("style");
     // Clear the sizing attributes
     this._box.removeAttribute("width");
     this._box.removeAttribute("height");
+    this._box.style.removeProperty("min-height");
+    this._box.style.removeProperty("min-width");
 
     setTimeout(() => {
       // Unload the dialog after the event listeners run so that the load of about:blank isn't
       // cancelled by the ESC <key>.
       this._frame.loadURI("about:blank");
     }, 0);
   },
 
@@ -141,18 +143,25 @@ let gSubDialog = {
     if (aEvent.target.contentWindow.location == "about:blank")
       return;
 
     // Do this on load to wait for the CSS to load and apply before calculating the size.
     let docEl = this._frame.contentDocument.documentElement;
 
     // padding-bottom doesn't seem to be included in the scrollHeight of the document element in XUL
     // so add it ourselves.
-    let paddingBottom = parseFloat(this._frame.contentWindow.getComputedStyle(docEl).paddingBottom);
+    let frameVerticalPadding = 2 * parseFloat(this._frame.contentWindow.getComputedStyle(docEl).paddingTop);
+    let frameHorizontalPadding = 2 * parseFloat(this._frame.contentWindow.getComputedStyle(docEl).paddingLeft);
+    let frameWidth = parseFloat(docEl.style.width) || docEl.scrollWidth;
+    let frameHeight = parseFloat(docEl.style.height) || (docEl.scrollHeight + frameVerticalPadding);
+    let boxVerticalBorder = 2 * parseFloat(getComputedStyle(this._box).borderTopWidth);
+    let boxHorizontalBorder = 2 * parseFloat(getComputedStyle(this._box).borderLeftWidth);
 
-    this._frame.style.width = docEl.style.width || docEl.scrollWidth + "px";
-    this._frame.style.height = docEl.style.height || (docEl.scrollHeight + paddingBottom) + "px";
+    this._frame.style.width = frameWidth + "px";
+    this._frame.style.height = frameHeight + "px";
+    this._box.style.minHeight = (boxVerticalBorder + this._box.clientHeight) + "px";
+    this._box.style.minWidth = (boxHorizontalBorder + frameHorizontalPadding + this._box.clientWidth) + "px";
 
     this._overlay.style.visibility = "visible";
     this._frame.focus();
     this._overlay.style.opacity = ""; // XXX: focus hack continued from _onContentLoaded
   },
 };