Bug 1168691 - Preserve the text direction for the select element itself r=mconley

This commit is contained in:
George Wright 2015-07-13 22:03:51 -04:00
parent ea1fb17fdc
commit d9c58c62bb
2 changed files with 8 additions and 3 deletions

View File

@ -315,6 +315,7 @@
}
let menulist = document.getElementById(this.getAttribute("selectmenulist"));
menulist.menupopup.style.direction = data.direction;
this._selectParentHelper.populate(menulist, data.options, data.selectedIndex, this._fullZoom);
this._selectParentHelper.open(this, menulist, data.rect);
break;

View File

@ -46,7 +46,8 @@ this.SelectContentHelper.prototype = {
this.global.sendAsyncMessage("Forms:ShowDropDown", {
rect: rect,
options: this._buildOptionList(),
selectedIndex: this.element.selectedIndex
selectedIndex: this.element.selectedIndex,
direction: getComputedDirection(this.element)
});
},
@ -87,9 +88,12 @@ this.SelectContentHelper.prototype = {
}
function getComputedDirection(element) {
return element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue("direction");
}
function buildOptionListForChildren(node) {
let result = [];
let win = node.ownerDocument.defaultView;
for (let child of node.children) {
let tagName = child.tagName.toUpperCase();
@ -111,7 +115,7 @@ function buildOptionListForChildren(node) {
disabled: child.disabled,
// We need to do this for every option element as each one can have
// an individual style set for direction
textDirection: win.getComputedStyle(child).getPropertyValue("direction"),
textDirection: getComputedDirection(child),
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