Bug 154772 Tooltip for address bar should show complete current URL r=Neil SEA_2_26_1_RELBRANCH
authorPhilip Chee <philip.chee@gmail.com>
Sun, 22 Sep 2013 23:07:05 +0800
branchSEA_2_26_1_RELBRANCH
changeset 31055 b8059a5e7a4b908d530835b451cb96b8159f6488
parent 31054 6d24ad7fb02785d90e464f713c45737c399e3674
child 31056 f226cb234deb230217bce7a9d907cda0976ad9af
push id1
push userclokep@gmail.com
push dateMon, 07 May 2018 22:45:56 +0000
treeherdercomm-esr60@57eacde5ef40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil
bugs154772
Bug 154772 Tooltip for address bar should show complete current URL r=Neil a=Callek for CLOSED TREE
suite/browser/navigator.xul
suite/browser/urlbarBindings.xml
--- a/suite/browser/navigator.xul
+++ b/suite/browser/navigator.xul
@@ -258,17 +258,17 @@
                    class="chromeclass-location nav-bar-class"
                    title="&locationBar.title;">
         <textbox id="urlbar" class="chromeclass-location uri-element" flex="1"
                  type="autocomplete" autocompletesearch="history file"
                  timeout="50" maxrows="6"
                  enablehistory="true" accesskey="&locationBar.accesskey;"
                  defaultSearchEngine="true" tabscrolling="true"
                  showcommentcolumn="true"
-                 inputtooltiptext="&locationBar.tooltip;"
+                 placeholder="&locationBar.tooltip;"
                  newlines="stripsurroundingwhitespace"
                  aria-label="&locationBar.title;"
                  oninput="gBrowser.userTypedValue = this.value;"
                  ontextentered="return handleURLBarCommand(eventParam, domEvent);"
                  ontextreverted="return handleURLBarRevert();"
                  onfocus="URLBarFocusHandler(event);"
                  onmousedown="URLBarMouseDownHandler(event);"
                  onclick="URLBarClickHandler(event);">
--- a/suite/browser/urlbarBindings.xml
+++ b/suite/browser/urlbarBindings.xml
@@ -20,21 +20,23 @@
   <binding id="urlbar" extends="chrome://global/content/autocomplete.xml#autocomplete">
     <content sizetopopup="pref">
       <xul:hbox class="autocomplete-textbox-container" flex="1">
         <xul:hbox class="urlbar-security-level" flex="1" align="center" xbl:inherits="level">
           <children includes="image|deck|stack|box">
             <xul:image class="autocomplete-icon" allowevents="true"/>
           </children>
 
-          <xul:hbox class="textbox-input-box paste-and-go" flex="1" xbl:inherits="context,tooltiptext=inputtooltiptext">
+          <xul:hbox class="textbox-input-box paste-and-go" flex="1" tooltip="_child" xbl:inherits="context">
             <children/>
             <html:input anonid="input" class="autocomplete-textbox textbox-input"
                         allowevents="true"
-                        xbl:inherits="tooltiptext=inputtooltiptext,value,type,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey,mozactionhint,userAction"/>
+                        xbl:inherits="value,type,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey,mozactionhint,userAction"/>
+            <xul:tooltip anonid="tooltip"
+                         onpopupshowing="document.getBindingParent(this)._showTooltip(event);"/>
           </xul:hbox>
           <children includes="hbox"/>
         </xul:hbox>
       </xul:hbox>
 
       <xul:dropmarker class="autocomplete-history-dropmarker" allowevents="true"
                       xbl:inherits="open" anonid="historydropmarker"/>
 
@@ -42,28 +44,32 @@
         <xul:panel type="autocomplete" anonid="popup"
                    ignorekeys="true" noautofocus="true" level="top"
                    xbl:inherits="for=id,nomatch"/>
       </xul:popupset>
 
       <children includes="menupopup"/>
     </content>
 
-    <implementation>
+    <implementation implements="nsIDOMEventListener">
       <constructor><![CDATA[
         this.mPrefs.addObserver("browser.urlbar", this.mPrefObserver, false);
 
         this.updatePref("browser.urlbar.showPopup");
         this.updatePref("browser.urlbar.autoFill");
         this.updatePref("browser.urlbar.showSearch");
         this.updatePref("browser.urlbar.formatting.enabled");
         this.inputField.controllers.insertControllerAt(0, this._editItemsController);
+        this.inputField.addEventListener("overflow", this, false);
+        this.inputField.addEventListener("underflow", this, false);
       ]]></constructor>
 
       <destructor><![CDATA[
+        this.inputField.removeEventListener("underflow", this, false);
+        this.inputField.removeEventListener("overflow", this, false);
         this.inputField.controllers.removeController(this._editItemsController);
         this.mPrefs.removeObserver("browser.urlbar", this.mPrefObserver);
       ]]></destructor>
 
       <field name="mPrefs">
         var svc = Components.classes["@mozilla.org/preferences-service;1"]
                             .getService(Components.interfaces.nsIPrefService);
         svc.getBranch(null);
@@ -91,16 +97,45 @@
             this.minResultsForPopup = this.mPrefs.getBoolPref(aPref) ?  0 : 1;
           } else if (aPref == "browser.urlbar.formatting.enabled") {
             this._formattingEnabled = this.mPrefs.getBoolPref(aPref);
             this._formatValue(this._formattingEnabled && !this.focused);
           }
         ]]></body>
       </method>
 
+      <field name="_overflowing">false</field>
+
+      <method name="handleEvent">
+        <parameter name="aEvent"/>
+        <body><![CDATA[
+          switch (aEvent.type) {
+            case "overflow":
+              this._overflowing = true;
+              break;
+            case "underflow":
+              this._overflowing = false;
+              break;
+          }
+        ]]></body>
+      </method>
+
+      <method name="_showTooltip">
+        <parameter name="aEvent"/>
+        <body><![CDATA[
+          var tooltip = aEvent.target;
+          if (this._overflowing)
+            tooltip.label = this.value;
+          else if (this.value)
+            tooltip.label = this.placeholder;
+          else
+            aEvent.preventDefault();
+        ]]></body>
+      </method>
+
       <field name="_formattingEnabled">true</field>
 
       <method name="_formatValue">
         <parameter name="formattingEnabled"/>
         <body><![CDATA[
           if (!this.editor)
             return;