Bug 1446332 - Remove const nsI* from tabbrowser.js. r?gijs draft
authorDão Gottwald <dao@mozilla.com>
Fri, 16 Mar 2018 12:28:37 +0100
changeset 768512 ba33d0907b28dfd09f352edd0e6f51da03fc4daa
parent 768480 9cd8e03d9e472f07041be3cd80cc95a8194f91a5
push id102888
push userdgottwald@mozilla.com
push dateFri, 16 Mar 2018 11:30:52 +0000
reviewersgijs
bugs1446332
milestone61.0a1
Bug 1446332 - Remove const nsI* from tabbrowser.js. r?gijs MozReview-Commit-ID: XZuOy5yJo6
browser/base/content/tabbrowser.js
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -1020,34 +1020,33 @@ window._gBrowser = {
       // (2) Call the current browser's unselectedTabHover() with false
       //     to dispatch an event.
       newTab.finishUnselectedTabHoverTimer();
       newBrowser.unselectedTabHover(false);
     }
 
     // If the new tab is busy, and our current state is not busy, then
     // we need to fire a start to all progress listeners.
-    const nsIWebProgressListener = Ci.nsIWebProgressListener;
     if (newTab.hasAttribute("busy") && !this.mIsBusy) {
       this.mIsBusy = true;
       this._callProgressListeners(null, "onStateChange",
                                   [webProgress, null,
-                                  nsIWebProgressListener.STATE_START |
-                                  nsIWebProgressListener.STATE_IS_NETWORK, 0],
+                                   Ci.nsIWebProgressListener.STATE_START |
+                                   Ci.nsIWebProgressListener.STATE_IS_NETWORK, 0],
                                   true, false);
     }
 
     // If the new tab is not busy, and our current state is busy, then
     // we need to fire a stop to all progress listeners.
     if (!newTab.hasAttribute("busy") && this.mIsBusy) {
       this.mIsBusy = false;
       this._callProgressListeners(null, "onStateChange",
                                   [webProgress, null,
-                                  nsIWebProgressListener.STATE_STOP |
-                                  nsIWebProgressListener.STATE_IS_NETWORK, 0],
+                                   Ci.nsIWebProgressListener.STATE_STOP |
+                                   Ci.nsIWebProgressListener.STATE_IS_NETWORK, 0],
                                   true, false);
     }
 
     // TabSelect events are suppressed during preview mode to avoid confusing extensions and other bits of code
     // that might rely upon the other changes suppressed.
     // Focus is suppressed in the event that the main browser window is minimized - focusing a tab would restore the window
     if (!this._previewMode) {
       // We've selected the new tab, so go ahead and notify listeners.
@@ -3952,23 +3951,20 @@ window._gBrowser = {
           filter.removeProgressListener(listener);
           listener.destroy();
         }
 
         this._tabFilters.delete(tab);
         this._tabListeners.delete(tab);
       }
     }
-    const nsIEventListenerService =
-      Ci.nsIEventListenerService;
-    let els = Cc["@mozilla.org/eventlistenerservice;1"]
-      .getService(nsIEventListenerService);
-    els.removeSystemEventListener(document, "keydown", this, false);
+
+    Services.els.removeSystemEventListener(document, "keydown", this, false);
     if (AppConstants.platform == "macosx") {
-      els.removeSystemEventListener(document, "keypress", this, false);
+      Services.els.removeSystemEventListener(document, "keypress", this, false);
     }
     window.removeEventListener("sizemodechange", this);
     window.removeEventListener("occlusionstatechange", this);
 
     if (gMultiProcessBrowser) {
       let messageManager = window.getGroupMessageManager("browsers");
       messageManager.removeMessageListener("DOMTitleChanged", this);
       window.messageManager.removeMessageListener("contextmenu", this);
@@ -4246,18 +4242,17 @@ class TabProgressListener {
 
   _isForInitialAboutBlank(aWebProgress, aStateFlags, aLocation) {
     if (!this.mBlank || !aWebProgress.isTopLevel) {
       return false;
     }
 
     // If the state has STATE_STOP, and no requests were in flight, then this
     // must be the initial "stop" for the initial about:blank document.
-    const nsIWebProgressListener = Ci.nsIWebProgressListener;
-    if (aStateFlags & nsIWebProgressListener.STATE_STOP &&
+    if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
         this.mRequestCount == 0 &&
         !aLocation) {
       return true;
     }
 
     let location = aLocation ? aLocation.spec : "";
     return location == "about:blank";
   }
@@ -4285,55 +4280,53 @@ class TabProgressListener {
       aMaxTotalProgress);
   }
 
   /* eslint-disable complexity */
   onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
     if (!aRequest)
       return;
 
-    const nsIWebProgressListener = Ci.nsIWebProgressListener;
-    const nsIChannel = Ci.nsIChannel;
     let location, originalLocation;
     try {
-      aRequest.QueryInterface(nsIChannel);
+      aRequest.QueryInterface(Ci.nsIChannel);
       location = aRequest.URI;
       originalLocation = aRequest.originalURI;
     } catch (ex) {}
 
     let ignoreBlank = this._isForInitialAboutBlank(aWebProgress, aStateFlags,
       location);
 
     // If we were ignoring some messages about the initial about:blank, and we
     // got the STATE_STOP for it, we'll want to pay attention to those messages
     // from here forward. Similarly, if we conclude that this state change
     // is one that we shouldn't be ignoring, then stop ignoring.
     if ((ignoreBlank &&
-        aStateFlags & nsIWebProgressListener.STATE_STOP &&
-        aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) ||
+         aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
+         aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) ||
         !ignoreBlank && this.mBlank) {
       this.mBlank = false;
     }
 
-    if (aStateFlags & nsIWebProgressListener.STATE_START) {
+    if (aStateFlags & Ci.nsIWebProgressListener.STATE_START) {
       this.mRequestCount++;
-    } else if (aStateFlags & nsIWebProgressListener.STATE_STOP) {
+    } else if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP) {
       const NS_ERROR_UNKNOWN_HOST = 2152398878;
       if (--this.mRequestCount > 0 && aStatus == NS_ERROR_UNKNOWN_HOST) {
         // to prevent bug 235825: wait for the request handled
         // by the automatic keyword resolver
         return;
       }
       // since we (try to) only handle STATE_STOP of the last request,
       // the count of open requests should now be 0
       this.mRequestCount = 0;
     }
 
-    if (aStateFlags & nsIWebProgressListener.STATE_START &&
-        aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
+    if (aStateFlags & Ci.nsIWebProgressListener.STATE_START &&
+        aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
       if (aWebProgress.isTopLevel) {
         // Need to use originalLocation rather than location because things
         // like about:home and about:privatebrowsing arrive with nsIRequest
         // pointing to their resolved jar: or file: URIs.
         if (!(originalLocation && gInitialPages.includes(originalLocation.spec) &&
             originalLocation != "about:blank" &&
             this.mBrowser.initialPageLoadedFromURLBar != originalLocation.spec &&
             this.mBrowser.currentURI && this.mBrowser.currentURI.spec == "about:blank")) {
@@ -4351,17 +4344,17 @@ class TabProgressListener {
           this.mBrowser.urlbarChangeTracker.startedLoad();
         }
         delete this.mBrowser.initialPageLoadedFromURLBar;
         // If the browser is loading it must not be crashed anymore
         this.mTab.removeAttribute("crashed");
       }
 
       if (this._shouldShowProgress(aRequest)) {
-        if (!(aStateFlags & nsIWebProgressListener.STATE_RESTORING) &&
+        if (!(aStateFlags & Ci.nsIWebProgressListener.STATE_RESTORING) &&
             aWebProgress && aWebProgress.isTopLevel) {
           this.mTab.setAttribute("busy", "true");
           this.mTab._notselectedsinceload = !this.mTab.selected;
           SchedulePressure.startMonitoring(window, {
             highPressureFn() {
               // Only switch back to the SVG loading indicator after getting
               // three consecutive low pressure callbacks. Used to prevent
               // switching quickly between the SVG and APNG loading indicators.
@@ -4388,18 +4381,18 @@ class TabProgressListener {
           });
           gBrowser.syncThrobberAnimations(this.mTab);
         }
 
         if (this.mTab.selected) {
           gBrowser.mIsBusy = true;
         }
       }
-    } else if (aStateFlags & nsIWebProgressListener.STATE_STOP &&
-               aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
+    } else if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
+               aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) {
 
       if (this.mTab.hasAttribute("busy")) {
         this.mTab.removeAttribute("busy");
         if (!document.querySelector(".tabbrowser-tab[busy]")) {
           SchedulePressure.stopMonitoring(window);
           gBrowser.tabContainer.removeAttribute("schedulepressure");
         }
 
@@ -4473,18 +4466,19 @@ class TabProgressListener {
                                   [aWebProgress, aRequest, aStateFlags, aStatus],
                                   true, false);
     }
 
     this._callProgressListeners("onStateChange",
                                 [aWebProgress, aRequest, aStateFlags, aStatus],
                                 false);
 
-    if (aStateFlags & (nsIWebProgressListener.STATE_START |
-        nsIWebProgressListener.STATE_STOP)) {
+    if (aStateFlags &
+        (Ci.nsIWebProgressListener.STATE_START |
+         Ci.nsIWebProgressListener.STATE_STOP)) {
       // reset cached temporary values at beginning and end
       this.mMessage = "";
       this.mTotalProgress = 0;
     }
     this.mStateFlags = aStateFlags;
     this.mStatus = aStatus;
   }
   /* eslint-enable complexity */