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
--- 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">