From 13ac81c2e248224dea5b6da685116861345ed33b Mon Sep 17 00:00:00 2001 From: Jared Wein Date: Wed, 11 Feb 2015 15:13:36 -0500 Subject: [PATCH] Bug 1044597 - Limit the minimum size of subdialogs in the in-content preferences. r=Gijs --- .../preferences/in-content/subdialogs.js | 22 ++++++++++++++----- .../in-content/tests/browser_subdialogs.js | 4 ++-- .../in-content/tests/subdialog.xul | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/browser/components/preferences/in-content/subdialogs.js b/browser/components/preferences/in-content/subdialogs.js index 62c67ea51857..614d3319568b 100644 --- a/browser/components/preferences/in-content/subdialogs.js +++ b/browser/components/preferences/in-content/subdialogs.js @@ -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,22 @@ 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.scrollWidth; + let frameHeight = docEl.scrollHeight; + let boxVerticalBorder = 2 * parseFloat(getComputedStyle(this._box).borderTopWidth); + let boxHorizontalBorder = 2 * parseFloat(getComputedStyle(this._box).borderLeftWidth); + + this._frame.style.width = frameWidth + "px"; + this._frame.style.height = frameHeight + "px"; + this._box.style.minHeight = (boxVerticalBorder + groupBoxTitleHeight + boxVerticalPadding + frameHeight) + "px"; + this._box.style.minWidth = (boxHorizontalBorder + boxHorizontalPadding + frameWidth) + "px"; this._overlay.style.visibility = "visible"; this._frame.focus(); diff --git a/browser/components/preferences/in-content/tests/browser_subdialogs.js b/browser/components/preferences/in-content/tests/browser_subdialogs.js index 0e7284fa6344..cea481477b3a 100644 --- a/browser/components/preferences/in-content/tests/browser_subdialogs.js +++ b/browser/components/preferences/in-content/tests/browser_subdialogs.js @@ -141,8 +141,8 @@ let gTests = [{ (aEvent) => dialogClosingCallback(deferredClose, aEvent)); let dialog = yield dialogPromise; - ise(content.gSubDialog._frame.style.width, "32em", "Width should be set on the frame from the dialog"); - ise(content.gSubDialog._frame.style.height, "40em", "Height should be set on the frame from the dialog"); + ise(content.gSubDialog._frame.style.width, "528px", "Width should be set on the frame from the dialog"); + ise(content.gSubDialog._frame.style.height, "280px", "Height should be set on the frame from the dialog"); content.gSubDialog.close(); yield deferredClose.promise; diff --git a/browser/components/preferences/in-content/tests/subdialog.xul b/browser/components/preferences/in-content/tests/subdialog.xul index 398c9ca9fb75..15a3b3d105a2 100644 --- a/browser/components/preferences/in-content/tests/subdialog.xul +++ b/browser/components/preferences/in-content/tests/subdialog.xul @@ -7,7 +7,7 @@