Bug 1524510 - Freeze quantum bar results when the user interacts with them. r=mak
authorDão Gottwald <dao@mozilla.com>
Fri, 29 Mar 2019 14:53:52 +0000
changeset 466770 a1cfb4874e277b523330f3595ac138897b49f41a
parent 466769 e167bde187233dd07c27e4a94f651d4bb83ee2f5
child 466771 028c0eff90a7ad121827f45040699bbca433c5e7
push id35780
push useropoprus@mozilla.com
push dateFri, 29 Mar 2019 21:53:01 +0000
treeherdermozilla-central@414f37afbe07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1524510
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1524510 - Freeze quantum bar results when the user interacts with them. r=mak Differential Revision: https://phabricator.services.mozilla.com/D25222
browser/components/urlbar/UrlbarController.jsm
browser/components/urlbar/UrlbarView.jsm
--- a/browser/components/urlbar/UrlbarController.jsm
+++ b/browser/components/urlbar/UrlbarController.jsm
@@ -110,26 +110,27 @@ class UrlbarController {
   /**
    * Cancels an in-progress query. Note, queries may continue running if they
    * can't be cancelled.
    *
    * @param {UrlbarUtils.CANCEL_REASON} [reason]
    *   The reason the query was cancelled.
    */
   cancelQuery(reason) {
-    if (!this._lastQueryContext) {
+    if (!this._lastQueryContext ||
+        this._lastQueryContext._cancelled) {
       return;
     }
 
     TelemetryStopwatch.cancel(TELEMETRY_1ST_RESULT, this._lastQueryContext);
     TelemetryStopwatch.cancel(TELEMETRY_6_FIRST_RESULTS, this._lastQueryContext);
 
     this.manager.cancelQuery(this._lastQueryContext);
+    this._lastQueryContext._cancelled = true;
     this._notify("onQueryCancelled", this._lastQueryContext);
-    delete this._lastQueryContext;
 
     if (reason == UrlbarUtils.CANCEL_REASON.BLUR &&
         ExtensionSearchHandler.hasActiveInputSession()) {
       ExtensionSearchHandler.handleInputCancelled();
     }
   }
 
   /**
--- a/browser/components/urlbar/UrlbarView.jsm
+++ b/browser/components/urlbar/UrlbarView.jsm
@@ -31,18 +31,18 @@ class UrlbarView {
     this.panel = input.panel;
     this.controller = input.controller;
     this.document = this.panel.ownerDocument;
     this.window = this.document.defaultView;
 
     this._mainContainer = this.panel.querySelector(".urlbarView-body-inner");
     this._rows = this.panel.querySelector("#urlbarView-results");
 
+    this._rows.addEventListener("mousedown", this);
     this._rows.addEventListener("mouseup", this);
-    this._rows.addEventListener("mousedown", this);
 
     // For the horizontal fade-out effect, set the overflow attribute on result
     // rows when they overflow.
     this._rows.addEventListener("overflow", this);
     this._rows.addEventListener("underflow", this);
 
     this.panel.addEventListener("popupshowing", this);
     this.panel.addEventListener("popupshown", this);
@@ -135,16 +135,19 @@ class UrlbarView {
    *   Set to true to select the previous item. By default the next item
    *   will be selected.
    */
   selectBy(amount, {reverse = false} = {}) {
     if (!this.isOpen) {
       throw new Error("UrlbarView: Cannot select an item if the view isn't open.");
     }
 
+    // Freeze results as the user is interacting with them.
+    this.controller.cancelQuery();
+
     let row = this._selected;
 
     if (!row) {
       this._selectItem(reverse ? this._rows.lastElementChild :
                                  this._rows.firstElementChild);
       return;
     }