Bug 1309652, use computed display when determining option display values, r=felipe

This commit is contained in:
Neil Deakin 2016-10-21 15:55:25 -04:00
parent f0a8b9eb69
commit 99a7eb889c
2 changed files with 13 additions and 9 deletions

View File

@ -42,18 +42,18 @@ const PAGECONTENT_SMALL =
"</select></body></html>";
const PAGECONTENT_SOMEHIDDEN =
"<html>" +
"<html><head><style>.hidden { display: none; }</style></head>" +
"<body><select id='one'>" +
" <option value='One' style='display: none;'>OneHidden</option>" +
" <option value='Two' style='display: none;'>TwoHidden</option>" +
" <option value='Two' class='hidden'>TwoHidden</option>" +
" <option value='Three'>ThreeVisible</option>" +
" <option value='Four'style='display: table;'>FourVisible</option>" +
" <option value='Five'>FiveVisible</option>" +
" <optgroup label='GroupHidden' style='display: none;'>" +
" <optgroup label='GroupHidden' class='hidden'>" +
" <option value='Four'>Six.OneHidden</option>" +
" <option value='Five' style='display: block;'>Six.TwoHidden</option>" +
" </optgroup>" +
" <option value='Six'>SevenVisible</option>" +
" <option value='Six' class='hidden' style='display: block;'>SevenVisible</option>" +
"</select></body></html>";
const PAGECONTENT_TRANSLATED =

View File

@ -87,7 +87,7 @@ this.SelectContentHelper.prototype = {
rect: rect,
options: this._buildOptionList(),
selectedIndex: this.element.selectedIndex,
direction: getComputedDirection(this.element)
direction: getComputedStyles(this.element).direction
});
gOpen = true;
},
@ -192,13 +192,15 @@ this.SelectContentHelper.prototype = {
}
function getComputedDirection(element) {
return element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue("direction");
function getComputedStyles(element) {
return element.ownerDocument.defaultView.getComputedStyle(element);
}
function buildOptionListForChildren(node) {
let result = [];
let win = node.ownerDocument.defaultView;
for (let child of node.children) {
let tagName = child.tagName.toUpperCase();
@ -214,15 +216,17 @@ function buildOptionListForChildren(node) {
textContent = "";
}
let cs = getComputedStyles(child);
let info = {
index: child.index,
tagName: tagName,
textContent: textContent,
disabled: child.disabled,
display: child.style.display,
display: cs.display,
// We need to do this for every option element as each one can have
// an individual style set for direction
textDirection: getComputedDirection(child),
textDirection: cs.direction,
tooltip: child.title,
// XXX this uses a highlight color when this is the selected element.
// We need to suppress such highlighting in the content process to get