Bug 1333345 - Part 3: Consolidate maybeCanonizeURL/handleEnter calls into handleEnterNow. r?mak draft
authorChris Peterson <cpeterson@mozilla.com>
Mon, 30 Jan 2017 23:16:37 -0800
changeset 490298 af4b624b55fd39b85830e962f69a80c78c3aa5d9
parent 490297 de586d7787feee2fa430fffe23f733ca43a2ec29
child 490299 77b150b4a0fe1897694887dc2e56274aa909ba0a
push id47057
push usercpeterson@mozilla.com
push dateTue, 28 Feb 2017 02:48:55 +0000
reviewersmak
bugs1333345
milestone54.0a1
Bug 1333345 - Part 3: Consolidate maybeCanonizeURL/handleEnter calls into handleEnterNow. r?mak This refactoring simplifies the search string code to be fixed in the next commit and should not introduce any functional change. MozReview-Commit-ID: 5mcdDNMtwYE
browser/base/content/urlbarBindings.xml
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -680,16 +680,25 @@ file, You can obtain one at http://mozil
           } else {
             url = url + suffix;
           }
 
           this.popup.overrideValue = "http://www." + url;
         ]]></body>
       </method>
 
+      <method name="handleEnterNow">
+        <parameter name="aTriggeringEvent"/>
+        <parameter name="aURL"/>
+        <body><![CDATA[
+          this.maybeCanonizeURL(aTriggeringEvent, aURL);
+          return this.mController.handleEnter(false, aTriggeringEvent);
+        ]]></body>
+      </method>
+
       <field name="_contentIsCropped">false</field>
 
       <method name="_initURLTooltip">
         <body><![CDATA[
           if (this.focused || !this._contentIsCropped)
             return;
           this.inputField.setAttribute("tooltiptext", this.value);
         ]]></body>
@@ -1145,18 +1154,17 @@ file, You can obtain one at http://mozil
           // Note this is also used to detect if we should perform a delayed
           // handleEnter, in such a case it won't have been cleared.
           this.handleEnterInstance = {
             searchString: this.mController.searchString,
             event
           };
 
           if (this.popup.selectedIndex != 0 || this.gotResultForCurrentQuery) {
-            this.maybeCanonizeURL(event, this.value);
-            let rv = this.mController.handleEnter(false, event);
+            let rv = this.handleEnterNow(event, this.value);
             this.handleEnterInstance = null;
             return rv;
           }
 
           return true;
         ]]></body>
       </method>
 
@@ -1819,24 +1827,24 @@ file, You can obtain one at http://mozil
             }
 
             this.input.gotResultForCurrentQuery = true;
 
             // Check if we should perform a delayed handleEnter.
             if (this.input.handleEnterInstance) {
               let instance = this.input.handleEnterInstance;
               this.input.handleEnterInstance = null;
+
               // Don't handle this immediately or we could cause a recursive
               // loop where the controller sets popupOpen and re-enters here.
               setTimeout(() => {
                 // Safety check: handle only if the search string didn't change.
                 let { event, searchString } = instance;
                 if (this.input.mController.searchString == searchString) {
-                  this.input.maybeCanonizeURL(event, searchString);
-                  this.input.mController.handleEnter(false, event);
+                  this.input.handleEnterNow(event, searchString);
                 }
               }, 0);
             }
           ]]>
         </body>
       </method>
 
       <method name="_onSearchBegin">