Bug 1443371 - Remove unused View Source message listeners. r=bdahl
authorJ. Ryan Stinnett <jryans@gmail.com>
Tue, 06 Mar 2018 08:06:25 -0600
changeset 461782 b98a010be06f6de1bbe43fb047dadd0e9bf523eb
parent 461781 76c828bf2d0332ff25672569ae4b7c68d6fbe9c4
child 461783 3cee5c02db0a065f081989d3e0514563aac355ab
push id1683
push usersfraser@mozilla.com
push dateThu, 26 Apr 2018 16:43:40 +0000
treeherdermozilla-release@5af6cb21869d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbdahl
bugs1443371, 1418403
milestone60.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 1443371 - Remove unused View Source message listeners. r=bdahl After bug 1418403, there are some left over message listeners in View Source that are unused. MozReview-Commit-ID: v5WACzJEA6
toolkit/components/viewsource/content/viewSource-content.js
--- a/toolkit/components/viewsource/content/viewSource-content.js
+++ b/toolkit/components/viewsource/content/viewSource-content.js
@@ -32,22 +32,18 @@ var global = this;
 var ViewSourceContent = {
   /**
    * 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",
     "ViewSource:GoToLine",
-    "ViewSource:ToggleWrapping",
-    "ViewSource:ToggleSyntaxHighlighting",
-    "ViewSource:SetCharacterSet",
   ],
 
   /**
    * 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,
@@ -99,41 +95,27 @@ var ViewSourceContent = {
    * 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) {
       return;
     }
     let data = msg.data;
-    let objects = msg.objects;
     switch (msg.name) {
       case "ViewSource:LoadSource":
         this.viewSource(data.URL, data.outerWindowID, data.lineNumber,
                         data.shouldWrap);
         break;
-      case "ViewSource:LoadSourceDeprecated":
-        this.viewSourceDeprecated(data.URL, objects.pageDescriptor, data.lineNumber,
-                                  data.forcedCharSet);
-        break;
       case "ViewSource:LoadSourceWithSelection":
         this.viewSourceWithSelection(data.URL, data.drawSelection, data.baseURI);
         break;
       case "ViewSource:GoToLine":
         this.goToLine(data.lineNumber);
         break;
-      case "ViewSource:ToggleWrapping":
-        this.toggleWrapping();
-        break;
-      case "ViewSource:ToggleSyntaxHighlighting":
-        this.toggleSyntaxHighlighting();
-        break;
-      case "ViewSource:SetCharacterSet":
-        this.setCharacterSet(data.charset, data.doPageLoad);
-        break;
     }
   },
 
   /**
    * Any events should get handled here, and should get dispatched to
    * a specific function for the event type.
    */
   handleEvent(event) {
@@ -219,43 +201,16 @@ var ViewSourceContent = {
       forcedCharSet = utils.docCharsetIsForced ? doc.characterSet
                                                : null;
     }
 
     this.loadSource(URL, pageDescriptor, lineNumber, forcedCharSet);
   },
 
   /**
-   * Called when the parent is using the deprecated API for viewSource.xul.
-   * This function will throw if it's called on a remote browser.
-   *
-   * @param URL (required)
-   *        The URL string of the source to be shown.
-   * @param pageDescriptor (optional)
-   *        The currentDescriptor off of an nsIWebPageDescriptor, in the
-   *        event that the caller wants to try to load the source out of
-   *        the network cache.
-   * @param lineNumber (optional)
-   *        The line number to focus as soon as the source has finished
-   *        loading.
-   * @param forcedCharSet (optional)
-   *        The document character set to use instead of the default one.
-   */
-  viewSourceDeprecated(URL, pageDescriptor, lineNumber, forcedCharSet) {
-    // This should not be called if this frame script is running
-    // in a content process!
-    if (Services.appinfo.processType != Services.appinfo.PROCESS_TYPE_DEFAULT) {
-      throw new Error("ViewSource deprecated API should not be used with " +
-                      "remote browsers.");
-    }
-
-    this.loadSource(URL, pageDescriptor, lineNumber, forcedCharSet);
-  },
-
-  /**
    * Common utility function used by both the current and deprecated APIs
    * for loading source.
    *
    * @param URL (required)
    *        The URL string of the source to be shown.
    * @param pageDescriptor (optional)
    *        The currentDescriptor off of an nsIWebPageDescriptor, in the
    *        event that the caller wants to try to load the source out of
@@ -630,47 +585,16 @@ var ViewSourceContent = {
    */
   toggleSyntaxHighlighting() {
     let body = content.document.body;
     let state = body.classList.toggle("highlight");
     sendAsyncMessage("ViewSource:StoreSyntaxHighlighting", { state });
   },
 
   /**
-   * Called when the parent has changed the character set to view the
-   * source with.
-   *
-   * @param charset
-   *        The character set to use.
-   * @param doPageLoad
-   *        Whether or not we should reload the page ourselves with the
-   *        nsIWebPageDescriptor. Part of a workaround for bug 136322.
-   */
-  setCharacterSet(charset, doPageLoad) {
-    docShell.charset = charset;
-    if (doPageLoad) {
-      this.reload();
-    }
-  },
-
-  /**
-   * Reloads the content.
-   */
-  reload() {
-    let pageLoader = docShell.QueryInterface(Ci.nsIWebPageDescriptor);
-    try {
-      pageLoader.loadPage(pageLoader.currentDescriptor,
-                          Ci.nsIWebPageDescriptor.DISPLAY_NORMAL);
-    } catch (e) {
-      let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
-      webNav.reload(Ci.nsIWebNavigation.LOAD_FLAGS_NONE);
-    }
-  },
-
-  /**
    * 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) {