Bug 1416372 - Remove remaining references to the view source statusbar;r=jryans
authorBrian Grinstead <bgrinstead@mozilla.com>
Tue, 21 Nov 2017 08:40:55 -0800
changeset 437548 ab0a609b4db5a5e9d99f48c37106f850ff4f2e6a
parent 437547 328ee69ec1bcee488c43abdbc102b98fa15fea29
child 437549 6f1d7b316594b2b28a164c12ada66ef2a09f47f9
push id117
push userfmarier@mozilla.com
push dateTue, 28 Nov 2017 20:17:16 +0000
reviewersjryans
bugs1416372
milestone59.0a1
Bug 1416372 - Remove remaining references to the view source statusbar;r=jryans MozReview-Commit-ID: HQcRAo5eTKk
toolkit/components/viewsource/content/viewSource-content.js
toolkit/components/viewsource/content/viewSource.js
toolkit/locales/en-US/chrome/global/viewSource.properties
--- a/toolkit/components/viewsource/content/viewSource-content.js
+++ b/toolkit/components/viewsource/content/viewSource-content.js
@@ -26,22 +26,16 @@ const MARK_SELECTION_END = "\uFDEF";
 var global = this;
 
 /**
  * ViewSourceContent should be loaded in the <xul:browser> of the
  * view source window, and initialized as soon as it has loaded.
  */
 var ViewSourceContent = {
   /**
-   * We'll act as an nsISelectionListener as well so that we can send
-   * updates to the view source window's status bar.
-   */
-  QueryInterface: XPCOMUtils.generateQI([Ci.nsISelectionListener]),
-
-  /**
    * These are the messages that ViewSourceContent is prepared to listen
    * for. If you need ViewSourceContent to handle more messages, add them
    * here.
    */
   messages: [
     "ViewSource:LoadSource",
     "ViewSource:LoadSourceDeprecated",
     "ViewSource:LoadSourceWithSelection",
@@ -53,26 +47,16 @@ var ViewSourceContent = {
 
   /**
    * When showing selection source, chrome will construct a page fragment to
    * show, and then instruct content to draw a selection after load.  This is
    * set true when there is a pending request to draw selection.
    */
   needsDrawSelection: false,
 
-  /**
-   * ViewSourceContent is attached as an nsISelectionListener on pageshow,
-   * and removed on pagehide. When the initial about:blank is transitioned
-   * away from, a pagehide is fired without us having attached ourselves
-   * first. We use this boolean to keep track of whether or not we're
-   * attached, so we don't attempt to remove our listener when it's not
-   * yet there (which throws).
-   */
-  selectionListenerAttached: false,
-
   get isViewSource() {
     let uri = content.document.documentURI;
     return uri.startsWith("view-source:") ||
            (uri.startsWith("data:") && uri.includes("MathML"));
   },
 
   get isAboutBlank() {
     let uri = content.document.documentURI;
@@ -104,21 +88,16 @@ var ViewSourceContent = {
     });
 
     removeEventListener("pagehide", this, true);
     removeEventListener("pageshow", this, true);
     removeEventListener("click", this);
     removeEventListener("unload", this);
 
     Services.els.removeSystemEventListener(global, "contextmenu", this, false);
-
-    // Cancel any pending toolbar updates.
-    if (this.updateStatusTask) {
-      this.updateStatusTask.disarm();
-    }
   },
 
   /**
    * Anything added to the messages array will get handled here, and should
    * get dispatched to a specific function for the message name.
    */
   receiveMessage(msg) {
     if (!this.isViewSource && !this.isAboutBlank) {
@@ -389,22 +368,16 @@ var ViewSourceContent = {
 
   /**
    * Handler for the pageshow event.
    *
    * @param event
    *        The pageshow event being handled.
    */
   onPageShow(event) {
-    let selection = content.getSelection();
-    if (selection) {
-      selection.QueryInterface(Ci.nsISelectionPrivate)
-               .addSelectionListener(this);
-      this.selectionListenerAttached = true;
-    }
     content.focus();
 
     // If we need to draw the selection, wait until an actual view source page
     // has loaded, instead of about:blank.
     if (this.needsDrawSelection &&
         content.document.documentURI.startsWith("view-source:")) {
       this.needsDrawSelection = false;
       this.drawSelection();
@@ -419,25 +392,16 @@ var ViewSourceContent = {
 
   /**
    * Handler for the pagehide event.
    *
    * @param event
    *        The pagehide event being handled.
    */
   onPageHide(event) {
-    // The initial about:blank will fire pagehide before we
-    // ever set a selectionListener, so we have a boolean around
-    // to keep track of when the listener is attached.
-    if (this.selectionListenerAttached) {
-      content.getSelection()
-             .QueryInterface(Ci.nsISelectionPrivate)
-             .removeSelectionListener(this);
-      this.selectionListenerAttached = false;
-    }
     sendAsyncMessage("ViewSource:SourceUnloaded");
   },
 
   onContextMenu(event) {
     let node = event.target;
 
     let result = {
       isEmail: false,
@@ -697,53 +661,16 @@ var ViewSourceContent = {
                           Ci.nsIWebPageDescriptor.DISPLAY_NORMAL);
     } catch (e) {
       let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
       webNav.reload(Ci.nsIWebNavigation.LOAD_FLAGS_NONE);
     }
   },
 
   /**
-   * A reference to a DeferredTask that is armed every time the
-   * selection changes.
-   */
-  updateStatusTask: null,
-
-  /**
-   * Called once the DeferredTask fires. Sends a message up to the
-   * parent to update the status bar text.
-   */
-  updateStatus() {
-    let selection = content.getSelection();
-
-    if (!selection.focusNode) {
-      sendAsyncMessage("ViewSource:UpdateStatus", { label: "" });
-      return;
-    }
-    if (selection.focusNode.nodeType != Ci.nsIDOMNode.TEXT_NODE) {
-      return;
-    }
-
-    let selCon = this.selectionController;
-    selCon.setDisplaySelection(Ci.nsISelectionController.SELECTION_ON);
-    selCon.setCaretVisibilityDuringSelection(true);
-
-    let interlinePosition = selection.QueryInterface(Ci.nsISelectionPrivate)
-                                     .interlinePosition;
-
-    let result = {};
-    this.findLocation(null, -1,
-        selection.focusNode, selection.focusOffset, interlinePosition, result);
-
-    let label = this.bundle.formatStringFromName("statusBarLineCol",
-                                                 [result.line, result.col], 2);
-    sendAsyncMessage("ViewSource:UpdateStatus", { label });
-  },
-
-  /**
    * Loads a view source selection showing the given view-source url and
    * highlight the selection.
    *
    * @param uri view-source uri to show
    * @param drawSelection true to highlight the selection
    * @param baseURI base URI of the original document
    */
   viewSourceWithSelection(uri, drawSelection, baseURI) {
@@ -755,35 +682,16 @@ var ViewSourceContent = {
     let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
     webNav.loadURIWithOptions(uri, loadFlags,
                               null, referrerPolicy, // referrer
                               null, null, // postData, headers
                               Services.io.newURI(baseURI));
   },
 
   /**
-   * nsISelectionListener
-   */
-
-  /**
-   * Gets called every time the selection is changed. Coalesces frequent
-   * changes, and calls updateStatus after 100ms of no selection change
-   * activity.
-   */
-  notifySelectionChanged(doc, sel, reason) {
-    if (!this.updateStatusTask) {
-      this.updateStatusTask = new DeferredTask(() => {
-        this.updateStatus();
-      }, 100);
-    }
-
-    this.updateStatusTask.arm();
-  },
-
-  /**
    * Using special markers left in the serialized source, this helper makes the
    * underlying markup of the selected fragment to automatically appear as
    * selected on the inflated view-source DOM.
    */
   drawSelection() {
     content.document.title =
       this.bundle.GetStringFromName("viewSelectionSourceTitle");
 
--- a/toolkit/components/viewsource/content/viewSource.js
+++ b/toolkit/components/viewsource/content/viewSource.js
@@ -75,17 +75,16 @@ ViewSourceChrome.prototype = {
    * will automatically have ViewSourceChrome listen for those messages,
    * and remove the listeners on teardown.
    */
   messages: ViewSourceBrowser.prototype.messages.concat([
     "ViewSource:SourceLoaded",
     "ViewSource:SourceUnloaded",
     "ViewSource:Close",
     "ViewSource:OpenURL",
-    "ViewSource:UpdateStatus",
     "ViewSource:ContextMenuOpening",
   ]),
 
   /**
    * This called via ViewSourceBrowser's constructor.  This should be called as
    * soon as the script loads.  When this function executes, we can assume the
    * DOM content has not yet loaded.
    */
@@ -155,19 +154,16 @@ ViewSourceChrome.prototype = {
         this.onSourceUnloaded();
         break;
       case "ViewSource:Close":
         this.close();
         break;
       case "ViewSource:OpenURL":
         this.openURL(data.URL);
         break;
-      case "ViewSource:UpdateStatus":
-        this.updateStatus(data.label);
-        break;
       case "ViewSource:ContextMenuOpening":
         this.onContextMenuOpening(data.isLink, data.isEmail, data.href);
         if (this.browser.isRemoteBrowser) {
           this.openContextMenu(data.screenX, data.screenY);
         }
         break;
     }
   },
@@ -601,40 +597,16 @@ ViewSourceChrome.prototype = {
     if (this.webNav.canGoForward) {
       forwardBroadcaster.removeAttribute("disabled");
     } else {
       forwardBroadcaster.setAttribute("disabled", "true");
     }
   },
 
   /**
-   * Updates the status displayed in the status bar of the view source window.
-   *
-   * @param label
-   *        The string to be displayed in the statusbar-lin-col element.
-   */
-  updateStatus(label) {
-    let statusBarField = document.getElementById("statusbar-line-col");
-    if (statusBarField) {
-      statusBarField.label = label;
-    }
-  },
-
-  /**
-   * Called when the frame script reports that a line was successfully gotten
-   * to.
-   *
-   * @param lineNumber
-   *        The line number that we successfully got to.
-   */
-  onGoToLineSuccess(lineNumber) {
-    ViewSourceBrowser.prototype.onGoToLineSuccess.call(this, lineNumber);
-  },
-
-  /**
    * Reloads the browser, bypassing the network cache.
    */
   reload() {
     this.browser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY |
                                  Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE);
   },
 
   /**
--- a/toolkit/locales/en-US/chrome/global/viewSource.properties
+++ b/toolkit/locales/en-US/chrome/global/viewSource.properties
@@ -3,16 +3,15 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 goToLineTitle     = Go to line
 goToLineText      = Enter line number
 invalidInputTitle = Invalid input
 invalidInputText  = The line number entered is invalid.
 outOfRangeTitle   = Line not found
 outOfRangeText    = The specified line was not found.
-statusBarLineCol  = Line %1$S, Col %2$S
 viewSelectionSourceTitle = DOM Source of Selection
 viewMathMLSourceTitle    = DOM Source of MathML
 
 context_goToLine_label        = Go to Lineā€¦
 context_goToLine_accesskey    = L
 context_wrapLongLines_label   = Wrap Long Lines
 context_highlightSyntax_label = Syntax Highlighting