Bug 1044597 - Limit the minimum size of subdialogs in the in-content preferences. r=Gijs

--HG--
extra : rebase_source : 2c9b643cb479a6acc3320013c606de514d261113
This commit is contained in:
Jared Wein 2015-02-11 15:13:36 -05:00
parent 1a5df4259f
commit 3cd924f0c9

View File

@ -92,6 +92,8 @@ let gSubDialog = {
// 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
@ -144,12 +146,26 @@ let gSubDialog = {
// 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 groupBoxTitle = document.getAnonymousElementByAttribute(this._box, "class", "groupbox-title");
let groupBoxTitleHeight = groupBoxTitle.clientHeight +
parseFloat(getComputedStyle(groupBoxTitle).borderBottomWidth);
this._frame.style.width = docEl.style.width || docEl.scrollWidth + "px";
this._frame.style.height = docEl.style.height || (docEl.scrollHeight + paddingBottom) + "px";
let groupBoxBody = document.getAnonymousElementByAttribute(this._box, "class", "groupbox-body");
let boxVerticalPadding = 2 * parseFloat(getComputedStyle(groupBoxBody).paddingTop);
let boxHorizontalPadding = 2 * parseFloat(getComputedStyle(groupBoxBody).paddingLeft);
let frameWidth = docEl.style.width || docEl.scrollWidth + "px";
let frameHeight = docEl.style.height || docEl.scrollHeight + "px";
let boxVerticalBorder = 2 * parseFloat(getComputedStyle(this._box).borderTopWidth);
let boxHorizontalBorder = 2 * parseFloat(getComputedStyle(this._box).borderLeftWidth);
this._frame.style.width = frameWidth;
this._frame.style.height = frameHeight;
this._box.style.minHeight = "calc(" +
(boxVerticalBorder + groupBoxTitleHeight + boxVerticalPadding) +
"px + " + frameHeight + ")";
this._box.style.minWidth = "calc(" +
(boxHorizontalBorder + boxHorizontalPadding) +
"px + " + frameWidth + ")";
this._overlay.style.visibility = "visible";
this._frame.focus();