Bug 1263674 - Fix awesomebar popup truncation in RTL. r=mak
authorDrew Willcoxon <adw@mozilla.com>
Tue, 12 Apr 2016 09:57:10 -0700
changeset 292796 882c541a3be3147236faf215589f297aa1fa9ad3
parent 292795 870749af34d8e7a0c41bd4dc8a67e5f244ac1b83
child 292797 c285601ae929fd934182191288fe8d733ff0aee3
push id18655
push userdwillcoxon@mozilla.com
push dateTue, 12 Apr 2016 16:58:31 +0000
treeherderfx-team@c285601ae929 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1263674
milestone48.0a1
Bug 1263674 - Fix awesomebar popup truncation in RTL. r=mak MozReview-Commit-ID: 7mOGrcQPFmn
toolkit/content/widgets/autocomplete.xml
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -1997,31 +1997,33 @@ extends="chrome://global/content/binding
           this._actionText.style.removeProperty("max-width");
           ]]>
         </body>
       </method>
 
       <!-- This method truncates the displayed strings as necessary. -->
       <method name="_handleOverflow">
         <body><![CDATA[
+          let itemRect = this.parentNode.getBoundingClientRect();
           let titleRect = this._titleText.getBoundingClientRect();
           let tagsRect = this._tagsText.getBoundingClientRect();
           let urlRect = this._urlText.getBoundingClientRect();
           let actionRect = this._actionText.getBoundingClientRect();
           let urlActionWidth = Math.max(urlRect.width, actionRect.width);
 
           // Total width for the title and URL/action is the width of the item
           // minus the start of the title text minus a little extra padding.
-          // This extra padding amount is basically arbitrary but balances out
-          // the listbox's padding on the left side.
+          // This extra padding amount is basically arbitrary but keeps the text
+          // from getting too close to the popup's edge.
           let extraPadding = 30;
-          let itemWidth =
-            this.parentNode.getBoundingClientRect().width -
-            this._titleText.getBoundingClientRect().left -
-            extraPadding;
+          let dir =
+            this.ownerDocument.defaultView.getComputedStyle(this).direction;
+          let titleStart = dir == "rtl" ? itemRect.right - titleRect.right
+                                        : titleRect.left - itemRect.left;
+          let itemWidth = itemRect.width - titleStart - extraPadding;
 
           if (this._tags.hasAttribute("empty")) {
             // The tags box is not displayed in this case.
             tagsRect.width = 0;
           }
 
           let titleTagsWidth = titleRect.width + tagsRect.width;
           if (titleTagsWidth + urlActionWidth > itemWidth) {