Bug 1128156, set the maximum height of the select popup to exactly 20 rows, r=mconley

This commit is contained in:
Neil Deakin 2016-07-25 09:08:34 -04:00
Родитель 4bcffaf35a
Коммит c28d438340
3 изменённых файлов: 21 добавлений и 2 удалений

Просмотреть файл

@ -1042,7 +1042,6 @@ toolbarpaletteitem[place="palette"] > #downloads-button[indicator] > #downloads-
/* Combobox dropdown renderer */ /* Combobox dropdown renderer */
#ContentSelectDropdown > menupopup { #ContentSelectDropdown > menupopup {
max-height: 350px;
/* The menupopup itself should always be rendered LTR to ensure the scrollbar aligns with /* The menupopup itself should always be rendered LTR to ensure the scrollbar aligns with
* the dropdown arrow on the dropdown widget. If a menuitem is RTL, its style will be set accordingly */ * the dropdown arrow on the dropdown widget. If a menuitem is RTL, its style will be set accordingly */
direction: ltr; direction: ltr;

Просмотреть файл

@ -8,6 +8,9 @@ this.EXPORTED_SYMBOLS = [
"SelectParentHelper" "SelectParentHelper"
]; ];
// Maximum number of rows to display in the select dropdown.
const MAX_ROWS = 20;
var currentBrowser = null; var currentBrowser = null;
var currentMenulist = null; var currentMenulist = null;
var currentZoom = 1; var currentZoom = 1;
@ -27,6 +30,19 @@ this.SelectParentHelper = {
this._registerListeners(browser, menulist.menupopup); this._registerListeners(browser, menulist.menupopup);
let win = browser.ownerDocument.defaultView; let win = browser.ownerDocument.defaultView;
// Set the maximum height to show exactly MAX_ROWS items.
let firstItem = menulist.getItemAtIndex(0);
if (firstItem) {
let itemHeight = firstItem.getBoundingClientRect().height;
// Include the padding and border on the popup.
let cs = win.getComputedStyle(menulist.menupopup);
let bpHeight = parseFloat(cs.borderTopWidth) + parseFloat(cs.borderBottomWidth) +
parseFloat(cs.paddingTop) + parseFloat(cs.paddingBottom);
menulist.menupopup.style.maxHeight = (itemHeight * MAX_ROWS + bpHeight) + "px";
}
let constraintRect = browser.getBoundingClientRect(); let constraintRect = browser.getBoundingClientRect();
constraintRect = new win.DOMRect(constraintRect.left + win.mozInnerScreenX, constraintRect = new win.DOMRect(constraintRect.left + win.mozInnerScreenX,
constraintRect.top + win.mozInnerScreenY, constraintRect.top + win.mozInnerScreenY,

Просмотреть файл

@ -133,6 +133,10 @@ menulist[editable="true"] > menupopup {
-moz-appearance: none; -moz-appearance: none;
} }
menulist[editable="true"] > menupopup > .popup-internal-box { menulist > menupopup > .popup-internal-box {
padding: 0; padding: 0;
} }
menulist:not([editable="true"]) > menupopup {
padding: 4px 0;
}