Bug 1262686 - Properly align awesomebar popup with window on RTL locales. r?mak draft
authorDrew Willcoxon <adw@mozilla.com>
Thu, 07 Apr 2016 11:50:40 -0700
changeset 348549 4c3893bb7d6a4ef356d60fcac5a9a970a912d076
parent 348543 8c75daafd6f17deadbad8b51bdc11e38fc1b5b4d
child 517870 0fd462b8d70d49580f0228e1f91ffc00a6090225
push id14848
push userdwillcoxon@mozilla.com
push dateThu, 07 Apr 2016 18:50:49 +0000
reviewersmak
bugs1262686
milestone48.0a1
Bug 1262686 - Properly align awesomebar popup with window on RTL locales. r?mak MozReview-Commit-ID: GU4LFe6UxrD
browser/base/content/urlbarBindings.xml
--- 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);