Bug 1262783 - Properly handle overflow/underflow for awesomebar items that are completely reused. r?mak draft
authorDrew Willcoxon <adw@mozilla.com>
Thu, 07 Apr 2016 12:27:55 -0700
changeset 348555 ed853b3e87681acdff7664757212d625080d7618
parent 347957 061165ac1ff9e076ec51ea268878efa751173511
child 517875 7da95f5d03d15fc06ac105a02fcb067e6fcc9e1c
push id14853
push userdwillcoxon@mozilla.com
push dateThu, 07 Apr 2016 19:28:23 +0000
reviewersmak
bugs1262783
milestone48.0a1
Bug 1262783 - Properly handle overflow/underflow for awesomebar items that are completely reused. r?mak The problem happens for items that are completely reused when the popup is rebuilt. In that case _adjustAcItem isn't called, so max-widths aren't removed and over/underflow isn't handled. MozReview-Commit-ID: 1TzMvzSRJlP
toolkit/content/widgets/autocomplete.xml
--- a/toolkit/content/widgets/autocomplete.xml
+++ b/toolkit/content/widgets/autocomplete.xml
@@ -1244,16 +1244,17 @@ extends="chrome://global/content/binding
               // due to new results, but only when: the item is the same, *OR*
               // we are about to replace the currently mouse-selected item, to
               // avoid surprising the user.
               let iface = Components.interfaces.nsIAutoCompletePopup;
               if (item.getAttribute("text") == trimmedSearchString &&
                   invalidateReason == iface.INVALIDATE_REASON_NEW_RESULT &&
                   (item.getAttribute("url") == url ||
                    this.richlistbox.mouseSelectedIndex === this._currentIndex)) {
+                item.handleOverUnderflow();
                 item.collapsed = false;
                 this._currentIndex++;
                 continue;
               }
             }
             else {
               // need to create a new item
               item = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "richlistitem");
@@ -1798,20 +1799,17 @@ extends="chrome://global/content/binding
           return this._textToSubURI.unEscapeURIForUI("UTF-8", url);
           ]]>
         </body>
       </method>
 
       <method name="_adjustAcItem">
         <body>
           <![CDATA[
-          this._titleText.style.removeProperty("max-width");
-          this._tagsText.style.removeProperty("max-width");
-          this._urlText.style.removeProperty("max-width");
-          this._actionText.style.removeProperty("max-width");
+          this._removeMaxWidths();
 
           let title = this.getAttribute("title");
 
           let displayUrl;
           let originalUrl = this.getAttribute("url");
           let emphasiseUrl = true;
 
           let type = this.getAttribute("type");
@@ -1985,16 +1983,27 @@ extends="chrome://global/content/binding
 
           if (this._inOverflow) {
             this._handleOverflow();
           }
           ]]>
         </body>
       </method>
 
+      <method name="_removeMaxWidths">
+        <body>
+          <![CDATA[
+          this._titleText.style.removeProperty("max-width");
+          this._tagsText.style.removeProperty("max-width");
+          this._urlText.style.removeProperty("max-width");
+          this._actionText.style.removeProperty("max-width");
+          ]]>
+        </body>
+      </method>
+
       <!-- This method truncates the displayed strings as necessary. -->
       <method name="_handleOverflow">
         <body><![CDATA[
           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);
@@ -2052,16 +2061,25 @@ extends="chrome://global/content/binding
               itemWidth * (1 - titleTagsPct)
             );
             this._urlText.style.maxWidth = urlActionMaxWidth + "px";
             this._actionText.style.maxWidth = urlActionMaxWidth + "px";
           }
         ]]></body>
       </method>
 
+      <method name="handleOverUnderflow">
+        <body>
+          <![CDATA[
+          this._removeMaxWidths();
+          this._handleOverflow();
+          ]]>
+        </body>
+      </method>
+
       <method name="_parseActionUrl">
         <parameter name="aUrl"/>
         <body><![CDATA[
           if (!aUrl.startsWith("moz-action:"))
             return null;
 
           // URL is in the format moz-action:ACTION,PARAMS
           // Where PARAMS is a JSON encoded object.