Bug 1448689 - fix setting charset and remove wrapping and highlight options in 'View Source'. r=aceman a=jorgk
authorJorg K <jorgk@jorgk.com>
Mon, 26 Mar 2018 00:44:12 +0200
changeset 31335 3a4f54410a545bb3303d7e73aeecd89972a07bba
parent 31334 e5edad8a84687a03acfb6ae36a7bd38c5bd10f20
child 31336 0d6ed7a480beb8c00dc7b573f967265d433847d4
push id383
push userclokep@gmail.com
push dateMon, 07 May 2018 21:52:48 +0000
reviewersaceman, jorgk
bugs1448689
Bug 1448689 - fix setting charset and remove wrapping and highlight options in 'View Source'. r=aceman a=jorgk
common/src/viewSource.js
common/src/viewSource.xul
--- a/common/src/viewSource.js
+++ b/common/src/viewSource.js
@@ -319,16 +319,17 @@ ViewSourceChrome.prototype = {
 
     return undefined;
   },
 
   /**
    * This is the deprecated API for viewSource.xul, for old-timer consumers.
    * This API might eventually go away.
    */
+  // NOT WORKING ANYMORE AFTER REMOVAL OF THE "ViewSource:LoadSourceDeprecated" MESSAGE IN BUG 1443371.
   _loadViewSourceDeprecated(aArguments) {
     Deprecated.warning("The arguments you're passing to viewSource.xul " +
                        "are using an out-of-date API.",
                        "https://developer.mozilla.org/en-US/Add-ons/Code_snippets/View_Source_for_XUL_Applications");
     // Parse the 'arguments' supplied with the dialog.
     //    arg[0] - URL string.
     //    arg[1] - Charset value in the form 'charset=xxx'.
     //    arg[2] - Page descriptor used to load content from the cache.
@@ -430,29 +431,19 @@ ViewSourceChrome.prototype = {
    * Called by clicks on a menu populated by CharsetMenu.jsm to
    * change the selected character set.
    *
    * @param event
    *        The click event on a character set menuitem.
    */
   onSetCharacterSet(event) {
     if (event.target.hasAttribute("charset")) {
-      let charset = event.target.getAttribute("charset");
-
-      // If we don't have history enabled, we have to do a reload in order to
-      // show the character set change. See bug 136322.
-      this.sendAsyncMessage("ViewSource:SetCharacterSet", {
-        charset,
-        doPageLoad: this.historyEnabled,
-      });
-
-      if (!this.historyEnabled) {
-        this.browser
-            .reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
-      }
+      this.browser.docShell.charset = event.target.getAttribute("charset");
+      this.browser
+          .reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
     }
   },
 
   /**
    * Called from the frame script when the context menu is about to
    * open. This tells ViewSourceChrome things about the item that
    * the context menu is being opened on. This should be called before
    * the popupshowing event handler fires.
@@ -607,24 +598,26 @@ ViewSourceChrome.prototype = {
    */
   close() {
     window.close();
   },
 
   /**
    * Called when the user clicks on the "Wrap Long Lines" menu item.
    */
+  // NOT WORKING ANYMORE AFTER REMOVAL OF THIS MESSAGE IN BUG 1443371.
   toggleWrapping() {
     this.shouldWrap = !this.shouldWrap;
     this.sendAsyncMessage("ViewSource:ToggleWrapping");
   },
 
   /**
    * Called when the user clicks on the "Syntax Highlighting" menu item.
    */
+  // NOT WORKING ANYMORE AFTER REMOVAL OF THIS MESSAGE IN BUG 1443371.
   toggleSyntaxHighlighting() {
     this.shouldHighlight = !this.shouldHighlight;
     this.sendAsyncMessage("ViewSource:ToggleSyntaxHighlighting");
   },
 
   /**
    * Updates the "remote" attribute of the view source browser. This
    * will remove the browser from the DOM, and then re-add it in the
--- a/common/src/viewSource.xul
+++ b/common/src/viewSource.xul
@@ -51,18 +51,20 @@
   <command id="cmd_findPrevious"
            oncommand="document.getElementById('FindToolbar').onFindAgainCommand(true);"/>
 #ifdef XP_MACOSX
   <command id="cmd_findSelection"
            oncommand="document.getElementById('FindToolbar').onFindSelectionCommand();"/>
 #endif
   <command id="cmd_reload" oncommand="viewSourceChrome.reload();"/>
   <command id="cmd_goToLine" oncommand="viewSourceChrome.promptAndGoToLine();" disabled="true"/>
+#ifdef MOZ_SUITE
   <command id="cmd_highlightSyntax" oncommand="viewSourceChrome.toggleSyntaxHighlighting();"/>
   <command id="cmd_wrapLongLines" oncommand="viewSourceChrome.toggleWrapping();"/>
+#endif
   <command id="cmd_textZoomReduce" oncommand="ZoomManager.reduce();"/>
   <command id="cmd_textZoomEnlarge" oncommand="ZoomManager.enlarge();"/>
   <command id="cmd_textZoomReset" oncommand="ZoomManager.reset();"/>
 
   <command id="Browser:Back" oncommand="viewSourceChrome.goBack()" observes="viewSourceNavigation"/>
   <command id="Browser:Forward" oncommand="viewSourceChrome.goForward()" observes="viewSourceNavigation"/>
 
   <broadcaster id="viewSourceNavigation"/>
@@ -225,21 +227,23 @@
           <menu id="charsetMenu"
                 label="&charsetMenu2.label;"
                 accesskey="&charsetMenu2.accesskey;"
                 oncommand="viewSourceChrome.onSetCharacterSet(event);"
                 onpopupshowing="CharsetMenu.build(event.target);
                                 CharsetMenu.update(event.target, content.document.characterSet);">
             <menupopup/>
           </menu>
+#ifdef MOZ_SUITE
           <menuseparator/>
           <menuitem id="menu_wrapLongLines" type="checkbox" command="cmd_wrapLongLines"
                     label="&menu_wrapLongLines.title;" accesskey="&menu_wrapLongLines.accesskey;"/>
           <menuitem type="checkbox" id="menu_highlightSyntax" command="cmd_highlightSyntax"
                     label="&menu_highlightSyntax.label;" accesskey="&menu_highlightSyntax.accesskey;"/>
+#endif
         </menupopup>
       </menu>
     </menubar>
   </toolbox>
 
   <vbox id="appcontent" flex="1">
 
     <browser id="content" type="content" name="content" src="about:blank" flex="1"