Bug 1262686 - Properly align awesomebar popup with window on RTL locales. r?mak
MozReview-Commit-ID: GU4LFe6UxrD
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -1355,19 +1355,25 @@ file, You can obtain one at http://mozil
var rect = window.document.documentElement.getBoundingClientRect();
var width = rect.right - rect.left;
this.setAttribute("width", width);
// Adjust the direction of the autocomplete popup list based on the textbox direction, bug 649840
var popupDirection = aElement.ownerDocument.defaultView.getComputedStyle(aElement).direction;
this.style.direction = popupDirection;
- // Move left margin to the window border.
- let elementRect = aElement.getBoundingClientRect();
- this.style.marginLeft = "-" + (elementRect.left - rect.left) + "px";
+ // Make the popup's starting margin negaxtive so that the start of the
+ // popup aligns with the window border.
+ if (popupDirection == "rtl") {
+ let offset = elementRect.right - rect.right
+ this.style.marginRight = offset + "px";
+ } else {
+ let offset = rect.left - elementRect.left;
+ this.style.marginLeft = offset + "px";
+ }
// Position the popup below the navbar. To get the y-coordinate,
// which is an offset from the bottom of the input, subtract the
// bottom of the navbar from the buttom of the input.
let yOffset =
document.getElementById("nav-bar").getBoundingClientRect().bottom -
aInput.getBoundingClientRect().bottom;
this.openPopup(aElement, "after_start", 0, yOffset, false, false);