From d9c58c62bbd769e61821249e7bff379e6d15596b Mon Sep 17 00:00:00 2001 From: George Wright Date: Mon, 13 Jul 2015 22:03:51 -0400 Subject: [PATCH] Bug 1168691 - Preserve the text direction for the select element itself r=mconley --- toolkit/content/widgets/remote-browser.xml | 1 + toolkit/modules/SelectContentHelper.jsm | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/toolkit/content/widgets/remote-browser.xml b/toolkit/content/widgets/remote-browser.xml index 65e2174bc77b..2d26842e390e 100644 --- a/toolkit/content/widgets/remote-browser.xml +++ b/toolkit/content/widgets/remote-browser.xml @@ -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; diff --git a/toolkit/modules/SelectContentHelper.jsm b/toolkit/modules/SelectContentHelper.jsm index a2a54839ba4b..533798df5025 100644 --- a/toolkit/modules/SelectContentHelper.jsm +++ b/toolkit/modules/SelectContentHelper.jsm @@ -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