Commit 8fbc96ca authored by Kathleen Brade's avatar Kathleen Brade Committed by Georg Koppen
Browse files

fixup! Bug 22542: Security Settings window too small on macOS 10.12

Automatically adjust the height of the Security Settings window so that
no scrollbar is needed. Also, add 100 pixels to the width and increase
maxheight and maxwidth to give users more flexibility when they choose to
manually resize the window.
parent 8af90b32
......@@ -42,10 +42,7 @@ function torbutton_init_security_ui() {
getIntPref("extensions.torbutton.security_slider")));
torbutton_set_custom(getBoolPref("extensions.torbutton.security_custom"));
// Show a scrollbar for the description text if one is needed.
// To avoid bug 21330, we set the overflow=auto style here instead
// of directly in the XUL.
document.getElementById("descBox").style.overflow = "auto";
setTimeout(adjustDialogSize, 0);
};
// Write the two prefs from the current settings.
......@@ -54,3 +51,44 @@ function torbutton_save_security_settings() {
sliderPositionToPrefSetting(state.slider));
setBoolPref("extensions.torbutton.security_custom", state.custom);
};
// Increase the height of this window so that a vertical scrollbar is not
// needed on the description box.
function adjustDialogSize() {
try {
// Find the height required by the tallest description element.
let descHeight = 0;
let descs = descNames.map(name => document.getElementById(name));
descs.forEach(elem => {
let origCollapsed = elem.collapsed;
elem.collapsed = false;
let h = elem.scrollHeight;
elem.collapsed = origCollapsed;
if (h > descHeight)
descHeight = h;
});
// Cap the height (just in case).
const kMaxDescriptionHeight = 550;
if (descHeight > kMaxDescriptionHeight)
descHeight = kMaxDescriptionHeight;
// Increase the height of the description container if it is too short.
let boxElem = document.getElementById("descBox");
if (boxElem.clientHeight < descHeight) {
boxElem.setAttribute("height", descHeight);
// Resize the XUL window to account for the new description height. In
// order for sizeToContent() to work correctly, it seems that we must
// remove the height attribute from the dialog (that attribute is added
// after a user manually resizes the window).
document.documentElement.removeAttribute("height");
sizeToContent();
}
} catch (e) {}
// Show a scrollbar for the description text if one is needed.
// To avoid bug 21330, we set the overflow=auto style here instead
// of directly in the XUL.
document.getElementById("descBox").style.overflow = "auto";
}
......@@ -13,11 +13,11 @@
onload="torbutton_init_security_ui()"
align="stretch"
pack="center"
maxheight="350"
maxheight="600"
minwidth="400"
maxwidth="600"
maxwidth="800"
ondialogaccept="torbutton_save_security_settings()"
width="400" >
width="500" >
<script type="application/x-javascript" src="torbutton_util.js"/>
<script type="application/x-javascript" src="preferences.js"/>
......@@ -26,7 +26,7 @@
<caption label="&torbutton.prefs.sec_caption;"/>
<hbox id="torbutton_slider_settings" flex="1" align="stretch" hidden="false">
<vbox>
<hbox height="220">
<hbox flex="1" minheight="220">
<vbox>
<scale id="torbutton_sec_slider" flex="1" min="1" max="3"
movetoclick="true" orient="vertical"
......@@ -57,7 +57,7 @@
</vbox>
</hbox>
</vbox>
<vbox id="descBox" flex="1" width="400" style="overflow: hidden;">
<vbox id="descBox" flex="1" style="overflow: hidden;">
<vbox id="desc_high" collapsed="true">
<description
class="slider-text-size, slider-text-weight">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment