Bug 1044597 - Limit the minimum size of subdialogs in the in-content preferences. r=Gijs
--- 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
},
};