Bug 1262686 - Properly align awesomebar popup with window on RTL locales. r?mak draft
authorDrew Willcoxon <adw@mozilla.com>
Thu, 07 Apr 2016 11:51:33 -0700
changeset 348550 9b8fe41fa841927386e4d50cfe60be6a447558c6
parent 347957 061165ac1ff9e076ec51ea268878efa751173511
child 517871 208a7822c62747524c7ea9f7271da1f36a44270a
push id14849
push userdwillcoxon@mozilla.com
push dateThu, 07 Apr 2016 18:51:45 +0000
reviewersmak
bugs1262686
milestone48.0a1
Bug 1262686 - Properly align awesomebar popup with window on RTL locales. r?mak Tested with Force RTL. MozReview-Commit-ID: A8wfu5TcPWM
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);