Bug 1584808 - remove unused functions from ComposerCommands.js and editor.js. r=mkmelin
authorKhushil Mistry <khushil324@gmail.com>
Mon, 21 Oct 2019 11:24:38 +0200
changeset 37201 b65ea98044afd29e3161c05f2d762ef5ee9e58d2
parent 37200 caa4039d835ac06a1e65a1b23f6951c92a7e3c73
child 37202 1edda72532b435446b2a07bcb54f62039ebf506d
push id395
push userclokep@gmail.com
push dateMon, 02 Dec 2019 19:38:57 +0000
reviewersmkmelin
bugs1584808
Bug 1584808 - remove unused functions from ComposerCommands.js and editor.js. r=mkmelin
mail/components/compose/content/ComposerCommands.js
mail/components/compose/content/dialogs/EdDialogCommon.js
mail/components/compose/content/editor.js
mail/components/compose/content/editorUtilities.js
mail/components/compose/content/messengercompose.xul
--- a/mail/components/compose/content/ComposerCommands.js
+++ b/mail/components/compose/content/ComposerCommands.js
@@ -29,30 +29,24 @@ function SetupHTMLEditorCommands() {
 
   commandTable.registerCommand("cmd_renderedHTMLEnabler", nsDummyHTMLCommand);
 
   commandTable.registerCommand("cmd_listProperties", nsListPropertiesCommand);
   commandTable.registerCommand("cmd_colorProperties", nsColorPropertiesCommand);
   commandTable.registerCommand("cmd_increaseFontStep", nsIncreaseFontCommand);
   commandTable.registerCommand("cmd_decreaseFontStep", nsDecreaseFontCommand);
   commandTable.registerCommand(
-    "cmd_advancedProperties",
-    nsAdvancedPropertiesCommand
-  );
-  commandTable.registerCommand(
     "cmd_objectProperties",
     nsObjectPropertiesCommand
   );
   commandTable.registerCommand(
     "cmd_removeNamedAnchors",
     nsRemoveNamedAnchorsCommand
   );
-  commandTable.registerCommand("cmd_editLink", nsEditLinkCommand);
-
-  commandTable.registerCommand("cmd_isindex", nsIsIndexCommand);
+
   commandTable.registerCommand("cmd_image", nsImageCommand);
   commandTable.registerCommand("cmd_hline", nsHLineCommand);
   commandTable.registerCommand("cmd_link", nsLinkCommand);
   commandTable.registerCommand("cmd_anchor", nsAnchorCommand);
   commandTable.registerCommand(
     "cmd_insertHTMLWithDialog",
     nsInsertHTMLWithDialogCommand
   );
@@ -107,52 +101,46 @@ function SetupHTMLEditorCommands() {
     nsDeleteTableCellContentsCommand
   );
   commandTable.registerCommand("cmd_JoinTableCells", nsJoinTableCellsCommand);
   commandTable.registerCommand("cmd_SplitTableCell", nsSplitTableCellCommand);
   commandTable.registerCommand(
     "cmd_TableOrCellColor",
     nsTableOrCellColorCommand
   );
-  commandTable.registerCommand("cmd_NormalizeTable", nsNormalizeTableCommand);
   commandTable.registerCommand("cmd_smiley", nsSetSmiley);
   commandTable.registerCommand("cmd_ConvertToTable", nsConvertToTable);
 }
 
 function SetupTextEditorCommands() {
   var commandTable = GetComposerCommandTable();
   if (!commandTable) {
     return;
   }
-
   // dump("Registering plain text editor commands\n");
 
   commandTable.registerCommand("cmd_findReplace", nsFindReplaceCommand);
   commandTable.registerCommand("cmd_find", nsFindCommand);
   commandTable.registerCommand("cmd_findNext", nsFindAgainCommand);
   commandTable.registerCommand("cmd_findPrev", nsFindAgainCommand);
   commandTable.registerCommand("cmd_rewrap", nsRewrapCommand);
   commandTable.registerCommand("cmd_spelling", nsSpellingCommand);
-  commandTable.registerCommand("cmd_validate", nsValidateCommand);
   commandTable.registerCommand("cmd_insertChars", nsInsertCharsCommand);
 }
 
 function SetupComposerWindowCommands() {
   // Don't need to do this if already done
   if (gComposerWindowControllerID) {
     return;
   }
 
   // Create a command controller and register commands
   //   specific to Web Composer window (file-related commands, HTML Source...)
   //   We can't use the composer controller created on the content window else
   //     we can't process commands when in HTMLSource editor
-  // IMPORTANT: For each of these commands, the doCommand method
-  //            must first call SetEditMode(gPreviousNonSourceDisplayMode);
-  //            to go from HTML Source mode to any other edit mode
 
   var windowControllers = window.controllers;
 
   if (!windowControllers) {
     return;
   }
 
   var commandTable;
@@ -183,43 +171,20 @@ function SetupComposerWindowCommands() {
     dump("Failed to get interface for nsIControllerCommandManager\n");
     return;
   }
 
   // File-related commands
   commandTable.registerCommand("cmd_open", nsOpenCommand);
   commandTable.registerCommand("cmd_save", nsSaveCommand);
   commandTable.registerCommand("cmd_saveAs", nsSaveAsCommand);
-  commandTable.registerCommand("cmd_exportToText", nsExportToTextCommand);
-  commandTable.registerCommand("cmd_publish", nsPublishCommand);
-  commandTable.registerCommand("cmd_publishAs", nsPublishAsCommand);
-  commandTable.registerCommand("cmd_publishSettings", nsPublishSettingsCommand);
-  commandTable.registerCommand("cmd_revert", nsRevertCommand);
-  commandTable.registerCommand("cmd_openRemote", nsOpenRemoteCommand);
-  commandTable.registerCommand("cmd_preview", nsPreviewCommand);
-  commandTable.registerCommand("cmd_editSendPage", nsSendPageCommand);
   commandTable.registerCommand("cmd_print", nsPrintCommand);
   commandTable.registerCommand("cmd_printpreview", nsPrintPreviewCommand);
   commandTable.registerCommand("cmd_printSetup", nsPrintSetupCommand);
   commandTable.registerCommand("cmd_close", nsCloseCommand);
-  commandTable.registerCommand("cmd_preferences", nsPreferencesCommand);
-
-  // Edit Mode commands
-  if (GetCurrentEditorType() == "html") {
-    commandTable.registerCommand("cmd_NormalMode", nsNormalModeCommand);
-    commandTable.registerCommand("cmd_AllTagsMode", nsAllTagsModeCommand);
-    commandTable.registerCommand("cmd_HTMLSourceMode", nsHTMLSourceModeCommand);
-    commandTable.registerCommand("cmd_PreviewMode", nsPreviewModeCommand);
-    commandTable.registerCommand("cmd_FinishHTMLSource", nsFinishHTMLSource);
-    commandTable.registerCommand("cmd_CancelHTMLSource", nsCancelHTMLSource);
-    commandTable.registerCommand(
-      "cmd_updateStructToolbar",
-      nsUpdateStructToolbarCommand
-    );
-  }
 
   windowControllers.insertControllerAt(0, editorController);
 
   // Store the controller ID so we can be sure to get the right one later
   gComposerWindowControllerID = windowControllers.getControllerId(
     editorController
   );
 }
@@ -298,23 +263,19 @@ function goUpdateCommandState(command) {
         break;
 
       case "cmd_paragraphState":
       case "cmd_align":
       case "cmd_highlight":
       case "cmd_backgroundColor":
       case "cmd_fontColor":
       case "cmd_fontFace":
-      case "cmd_fontSize":
-      case "cmd_absPos":
         pokeMultiStateUI(command, params);
         break;
 
-      case "cmd_decreaseZIndex":
-      case "cmd_increaseZIndex":
       case "cmd_indent":
       case "cmd_outdent":
       case "cmd_increaseFont":
       case "cmd_decreaseFont":
       case "cmd_increaseFontStep":
       case "cmd_decreaseFontStep":
       case "cmd_removeStyles":
       case "cmd_smiley":
@@ -354,17 +315,16 @@ function goDoCommandParams(command, para
 
         // the following two lines should be removed when we implement observers
         if (params) {
           controller.getCommandStateWithParams(command, params);
         }
       } else {
         controller.doCommand(command);
       }
-      ResetStructToolbar();
     }
   } catch (e) {
     Cu.reportError(e);
   }
 }
 
 /**
  * Update the UI to reflect setting a given state for a command.
@@ -407,18 +367,16 @@ function pokeStyleUI(uiID, desiredState)
 
 function doStyleUICommand(cmdStr) {
   try {
     var cmdParams = newCommandParams();
     goDoCommandParams(cmdStr, cmdParams);
     if (cmdParams) {
       pokeStyleUI(cmdStr, cmdParams.getBooleanValue("state_all"));
     }
-
-    ResetStructToolbar();
   } catch (e) {}
 }
 
 // Copied from jsmime.js.
 function stringToTypedArray(buffer) {
   var typedarray = new Uint8Array(buffer.length);
   for (var i = 0; i < buffer.length; i++) {
     typedarray[i] = buffer.charCodeAt(i);
@@ -490,18 +448,16 @@ function doStatefulCommand(commandID, ne
     if (!cmdParams) {
       return;
     }
 
     cmdParams.setStringValue("state_attribute", newState);
     goDoCommandParams(commandID, cmdParams);
 
     pokeMultiStateUI(commandID, cmdParams);
-
-    ResetStructToolbar();
   } catch (e) {
     dump("error thrown in doStatefulCommand: " + e + "\n");
   }
 }
 
 function PrintObject(obj) {
   dump("-----" + obj + "------\n");
   var names = "";
@@ -571,29 +527,16 @@ var nsOpenCommand = {
       if (fp.fileURL.spec) {
         SaveFilePickerDirectory(fp, fileType);
         editPage(fp.fileURL.spec, fileType);
       }
     });
   },
 };
 
-// STRUCTURE TOOLBAR
-//
-var nsUpdateStructToolbarCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    UpdateStructToolbar();
-    return true;
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-  doCommand(aCommand) {},
-};
-
 // ******* File output commands and utilities ******** //
 var nsSaveCommand = {
   isCommandEnabled(aCommand, dummy) {
     // Always allow saving when editing a remote document,
     //  otherwise the document modified state would prevent that
     //  when you first open a remote file.
     try {
       var docUrl = GetDocumentUrl();
@@ -610,19 +553,16 @@ var nsSaveCommand = {
   },
 
   getCommandStateParams(aCommand, aParams, aRefCon) {},
   doCommandParams(aCommand, aParams, aRefCon) {},
 
   doCommand(aCommand) {
     var editor = GetCurrentEditor();
     if (editor) {
-      if (IsHTMLEditor()) {
-        SetEditMode(gPreviousNonSourceDisplayMode);
-      }
       SaveDocument(
         IsUrlAboutBlank(GetDocumentUrl()),
         false,
         editor.contentsMIMEType
       );
     }
   },
 };
@@ -633,149 +573,21 @@ var nsSaveAsCommand = {
   },
 
   getCommandStateParams(aCommand, aParams, aRefCon) {},
   doCommandParams(aCommand, aParams, aRefCon) {},
 
   doCommand(aCommand) {
     var editor = GetCurrentEditor();
     if (editor) {
-      if (IsHTMLEditor()) {
-        SetEditMode(gPreviousNonSourceDisplayMode);
-      }
       SaveDocument(true, false, editor.contentsMIMEType);
     }
   },
 };
 
-var nsExportToTextCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    return IsDocumentEditable();
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    if (GetCurrentEditor()) {
-      SetEditMode(gPreviousNonSourceDisplayMode);
-      SaveDocument(true, true, "text/plain");
-    }
-  },
-};
-
-var nsPublishCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    if (IsDocumentEditable()) {
-      // Always allow publishing when editing a local document,
-      //  otherwise the document modified state would prevent that
-      //  when you first open any local file.
-      try {
-        var docUrl = GetDocumentUrl();
-        return (
-          IsDocumentModified() ||
-          IsHTMLSourceChanged() ||
-          IsUrlAboutBlank(docUrl) ||
-          GetScheme(docUrl) == "file"
-        );
-      } catch (e) {
-        return false;
-      }
-    }
-    return false;
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    if (GetCurrentEditor()) {
-      let docUrl = GetDocumentUrl();
-      let filename = GetFilename(docUrl);
-      let publishData;
-
-      // First check pref to always show publish dialog
-      let showPublishDialog = Services.prefs.getBoolPref(
-        "editor.always_show_publish_dialog"
-      );
-
-      if (!showPublishDialog && filename) {
-        // Try to get publish data from the document url
-        publishData = CreatePublishDataFromUrl(docUrl);
-
-        // If none, use default publishing site? Need a pref for this
-        // if (!publishData)
-        //  publishData = GetPublishDataFromSiteName(GetDefaultPublishSiteName(), filename);
-      }
-
-      if (showPublishDialog || !publishData) {
-        // Show the publish dialog
-        publishData = {};
-        window.ok = false;
-        let oldTitle = GetDocumentTitle();
-        window.openDialog(
-          "chrome://messenger/content/messengercompose/EditorPublish.xul",
-          "_blank",
-          "chrome,close,titlebar,modal",
-          "",
-          "",
-          publishData
-        );
-        if (GetDocumentTitle() != oldTitle) {
-          UpdateWindowTitle();
-        }
-
-        if (!window.ok) {
-          return false;
-        }
-      }
-      if (publishData) {
-        SetEditMode(gPreviousNonSourceDisplayMode);
-        return Publish(publishData);
-      }
-    }
-    return false;
-  },
-};
-
-var nsPublishAsCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    return IsDocumentEditable();
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    if (GetCurrentEditor()) {
-      SetEditMode(gPreviousNonSourceDisplayMode);
-
-      window.ok = false;
-      var publishData = {};
-      var oldTitle = GetDocumentTitle();
-      window.openDialog(
-        "chrome://messenger/content/messengercompose/EditorPublish.xul",
-        "_blank",
-        "chrome,close,titlebar,modal",
-        "",
-        "",
-        publishData
-      );
-      if (GetDocumentTitle() != oldTitle) {
-        UpdateWindowTitle();
-      }
-
-      if (window.ok) {
-        return Publish(publishData);
-      }
-    }
-    return false;
-  },
-};
-
 // ------- output utilities   ----- //
 
 // returns a fileExtension string
 function GetExtensionBasedOnMimeType(aMIMEType) {
   try {
     var mimeService = null;
     mimeService = Cc["@mozilla.org/mime;1"].getService(Ci.nsIMIMEService);
 
@@ -1289,20 +1101,17 @@ var gEditorOutputProgressListener = {
               Services.io.newURI(docUrl, editor.documentCharacterSet)
             );
 
             UpdateWindowTitle();
 
             // this should cause notification to listeners that doc has changed
             editor.resetModificationCount();
 
-            // Set UI based on whether we're editing a remote or local url
-            // Why is urlstring undefined?
-            /* eslint-disable-next-line no-undef */
-            SetSaveAndPublishUI(urlstring);
+            goUpdateCommand("cmd_save");
           } catch (e) {}
 
           // Save publishData to prefs
           if (gPublishData) {
             if (gPublishData.savePublishData) {
               // We published successfully, so we can safely
               //  save docDir and otherDir to prefs
               gPublishData.saveDirs = true;
@@ -1961,17 +1770,17 @@ async function SaveDocument(aSaveAs, aSa
       UpdateWindowTitle();
 
       if (!aSaveCopy) {
         editor.resetModificationCount();
       }
       // this should cause notification to listeners that document has changed
 
       // Set UI based on whether we're editing a remote or local url
-      SetSaveAndPublishUI(urlstring);
+      goUpdateCommand("cmd_save");
     } catch (e) {}
   } else {
     Services.prompt.alert(
       window,
       GetString("SaveDocument"),
       GetString("SaveFileFailed")
     );
   }
@@ -2209,102 +2018,31 @@ function GetDocUrlFromPublishData(publis
 
   if (GetScheme(url) == "ftp") {
     url = InsertUsernameIntoUrl(url, publishData.username);
   }
 
   return url;
 }
 
-function SetSaveAndPublishUI(urlstring) {
-  // Be sure enabled state of toolbar buttons are correct
-  goUpdateCommand("cmd_save");
-  goUpdateCommand("cmd_publish");
-}
-
 function SetDocumentEditable(isDocEditable) {
   var editor = GetCurrentEditor();
   if (editor && editor.document) {
     try {
       var flags = editor.flags;
       editor.flags = isDocEditable
         ? (flags &= ~nsIPlaintextEditor.eEditorReadonlyMask)
         : flags | nsIPlaintextEditor.eEditorReadonlyMask;
     } catch (e) {}
 
     // update all commands
     window.updateCommands("create");
   }
 }
 
-// ****** end of save / publish **********//
-
-var nsPublishSettingsCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    return IsDocumentEditable();
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    if (GetCurrentEditor()) {
-      // Launch Publish Settings dialog
-
-      window.ok = window.openDialog(
-        "chrome://messenger/content/messengercompose/EditorPublishSettings.xul",
-        "_blank",
-        "chrome,close,titlebar,modal",
-        ""
-      );
-      return window.ok;
-    }
-    return false;
-  },
-};
-
-var nsRevertCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    return (
-      IsDocumentEditable() &&
-      IsDocumentModified() &&
-      !IsUrlAboutBlank(GetDocumentUrl())
-    );
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    // Confirm with the user to abandon current changes
-    // Put the page title in the message string
-    let title = GetDocumentTitle();
-    let msg = GetString("AbandonChanges").replace(/%title%/, title);
-
-    let result = Services.prompt.confirmEx(
-      window,
-      GetString("RevertCaption"),
-      msg,
-      Services.prompt.BUTTON_TITLE_REVERT * Services.prompt.BUTTON_POS_0 +
-        Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1,
-      null,
-      null,
-      null,
-      null,
-      { value: 0 }
-    );
-
-    // Reload page if first button (Revert) was pressed
-    if (result == 0) {
-      CancelHTMLSource();
-      EditorLoadUrl(GetDocumentUrl());
-    }
-  },
-};
-
 var nsCloseCommand = {
   isCommandEnabled(aCommand, dummy) {
     return GetCurrentEditor() != null;
   },
 
   getCommandStateParams(aCommand, aParams, aRefCon) {},
   doCommandParams(aCommand, aParams, aRefCon) {},
 
@@ -2327,171 +2065,25 @@ async function CloseWindow() {
         .QueryInterface(Ci.nsIDocShellTreeItem)
         .treeOwner.QueryInterface(Ci.nsIInterfaceRequestor)
         .getInterface(Ci.nsIBaseWindow);
       basewin.destroy();
     } catch (e) {}
   }
 }
 
-var nsOpenRemoteCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    // We can always do this.
-    return true;
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    var params = { action: "2", url: "" };
-    openDialog(
-      "chrome://communicator/content/openLocation.xul",
-      "_blank",
-      "chrome,modal,titlebar",
-      params
-    );
-    var win = getTopWin();
-    switch (params.action) {
-      case "0": // current window
-        win.focus();
-        win.loadURI(params.url, null, null, true);
-        break;
-      case "1": // new window
-        openDialog(
-          getBrowserURL(),
-          "_blank",
-          "all,dialog=no",
-          params.url,
-          null,
-          null,
-          null,
-          true
-        );
-        break;
-      case "2": // edit
-        editPage(params.url);
-        break;
-      case "3": // new tab
-        win.focus();
-        var browser = win.getBrowser();
-        browser.selectedTab = browser.addTab(params.url, {
-          allowThirdPartyFixup: true,
-        });
-        break;
-      case "4": // private
-        openNewPrivateWith(params.url);
-        break;
-      default:
-        break;
-    }
-  },
-};
-
-var nsPreviewCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    return (
-      IsDocumentEditable() &&
-      IsHTMLEditor() &&
-      (DocumentHasBeenSaved() || IsDocumentModified())
-    );
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  async doCommand(aCommand) {
-    // Don't continue if user canceled during prompt for saving
-    // DocumentHasBeenSaved will test if we have a URL and suppress "Don't Save" button if not
-    if (!(await CheckAndSaveDocument("cmd_preview", DocumentHasBeenSaved()))) {
-      return;
-    }
-
-    // Check if we saved again just in case?
-    if (DocumentHasBeenSaved()) {
-      let browser;
-      try {
-        // Find a browser with this URL
-        let enumerator = Services.wm.getEnumerator("navigator:browser");
-
-        var documentURI = GetDocumentUrl();
-        while (enumerator.hasMoreElements()) {
-          browser = enumerator.getNext();
-          if (
-            browser &&
-            !browser.closed &&
-            documentURI == browser.getBrowser().currentURI.spec
-          ) {
-            break;
-          }
-
-          browser = null;
-        }
-      } catch (ex) {}
-
-      // If none found, open a new browser
-      if (!browser) {
-        browser = window.openDialog(
-          getBrowserURL(),
-          "_blank",
-          "chrome,all,dialog=no",
-          documentURI
-        );
-      } else {
-        try {
-          browser.BrowserReloadSkipCache();
-          browser.focus();
-        } catch (ex) {}
-      }
-    }
-  },
-};
-
-var nsSendPageCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    return (
-      IsDocumentEditable() && (DocumentHasBeenSaved() || IsDocumentModified())
-    );
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  async doCommand(aCommand) {
-    // Don't continue if user canceled during prompt for saving
-    // DocumentHasBeenSaved will test if we have a URL and suppress "Don't Save" button if not
-    if (
-      !(await CheckAndSaveDocument("cmd_editSendPage", DocumentHasBeenSaved()))
-    ) {
-      return;
-    }
-
-    // Check if we saved again just in case?
-    if (DocumentHasBeenSaved()) {
-      // Launch Messenger Composer window with current page as contents
-      try {
-        openComposeWindow(GetDocumentUrl(), GetDocumentTitle());
-      } catch (ex) {
-        dump("Cannot Send Page: " + ex + "\n");
-      }
-    }
-  },
-};
-
 var nsPrintCommand = {
   isCommandEnabled(aCommand, dummy) {
     return true; // we can always do this
   },
 
   getCommandStateParams(aCommand, aParams, aRefCon) {},
   doCommandParams(aCommand, aParams, aRefCon) {},
 
   doCommand(aCommand) {
-    // In editor.js
-    SetEditMode(gPreviousNonSourceDisplayMode);
     try {
       let browser = GetCurrentEditorElement();
       PrintUtils.printWindow(browser.outerWindowID, browser);
     } catch (e) {}
   },
 };
 
 var nsPrintPreviewCommand = {
@@ -2499,35 +2091,31 @@ var nsPrintPreviewCommand = {
     // We can always do this.
     return true;
   },
 
   getCommandStateParams(aCommand, aParams, aRefCon) {},
   doCommandParams(aCommand, aParams, aRefCon) {},
 
   doCommand(aCommand) {
-    // In editor.js
-    SetEditMode(gPreviousNonSourceDisplayMode);
     try {
       PrintUtils.printPreview(PrintPreviewListener);
     } catch (e) {}
   },
 };
 
 var nsPrintSetupCommand = {
   isCommandEnabled(aCommand, dummy) {
     return true; // we can always do this
   },
 
   getCommandStateParams(aCommand, aParams, aRefCon) {},
   doCommandParams(aCommand, aParams, aRefCon) {},
 
   doCommand(aCommand) {
-    // In editor.js
-    SetEditMode(gPreviousNonSourceDisplayMode);
     PrintUtils.showPageSetup();
   },
 };
 
 var nsFindReplaceCommand = {
   isCommandEnabled(aCommand, editorElement) {
     return editorElement.getEditor(editorElement.contentWindow) != null;
   },
@@ -2616,93 +2204,16 @@ var nsSpellingCommand = {
         false,
         skipBlockQuotes,
         true
       );
     } catch (ex) {}
   },
 };
 
-// Validate using http://validator.w3.org/file-upload.html
-var URL2Validate;
-var nsValidateCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    return GetCurrentEditor() != null;
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  async doCommand(aCommand) {
-    // If the document hasn't been modified,
-    // then just validate the current url.
-    if (IsDocumentModified() || IsHTMLSourceChanged()) {
-      if (!(await CheckAndSaveDocument("cmd_validate", false))) {
-        return;
-      }
-
-      // Check if we saved again just in case?
-      if (!DocumentHasBeenSaved()) {
-        // user hit cancel?
-        return;
-      }
-    }
-
-    URL2Validate = GetDocumentUrl();
-    // See if it's a file:
-    var ifile;
-    try {
-      var fileHandler = GetFileProtocolHandler();
-      ifile = fileHandler.getFileFromURLSpec(URL2Validate);
-      // nsIFile throws an exception if it's not a file url
-    } catch (e) {
-      ifile = null;
-    }
-    if (ifile) {
-      URL2Validate = ifile.path;
-      var vwin = window.open(
-        "http://validator.w3.org/file-upload.html",
-        "EditorValidate"
-      );
-      // Window loads asynchronously, so pass control to the load listener:
-      vwin.addEventListener("load", this.validateFilePageLoaded);
-    } else {
-      window.open(
-        `http://validator.w3.org/check?uri=${URL2Validate}&doctype=Inline`,
-        "EditorValidate"
-      );
-      // This does the validation, no need to wait for page loaded.
-    }
-  },
-  validateFilePageLoaded(event) {
-    event.target.forms[0].uploaded_file.value = URL2Validate;
-  },
-};
-
-var nsIsIndexCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    return IsDocumentEditable() && IsEditingRenderedHTML();
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    try {
-      var editor = GetCurrentEditor();
-      var isindexElement = editor.createElementWithDefaults("isindex");
-      isindexElement.setAttribute(
-        "prompt",
-        editor.outputToString("text/plain", kOutputSelectionOnly)
-      );
-      editor.insertElementAtSelection(isindexElement, true);
-    } catch (e) {}
-  },
-};
-
 var nsImageCommand = {
   isCommandEnabled(aCommand, dummy) {
     return IsDocumentEditable() && IsEditingRenderedHTML();
   },
 
   getCommandStateParams(aCommand, aParams, aRefCon) {},
   doCommandParams(aCommand, aParams, aRefCon) {},
 
@@ -3098,33 +2609,16 @@ function doAdvancedProperties(element) {
       "_blank",
       "chrome,close,titlebar,modal,resizable=yes",
       "",
       element
     );
   }
 }
 
-var nsAdvancedPropertiesCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    return IsDocumentEditable() && IsEditingRenderedHTML();
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    // Launch AdvancedEdit dialog for the selected element
-    try {
-      var element = GetCurrentEditor().getSelectedElement("");
-      doAdvancedProperties(element);
-    } catch (e) {}
-  },
-};
-
 var nsColorPropertiesCommand = {
   isCommandEnabled(aCommand, dummy) {
     return IsDocumentEditable() && IsEditingRenderedHTML();
   },
 
   getCommandStateParams(aCommand, aParams, aRefCon) {},
   doCommandParams(aCommand, aParams, aRefCon) {},
 
@@ -3193,88 +2687,16 @@ var nsRemoveNamedAnchorsCommand = {
   doCommandParams(aCommand, aParams, aRefCon) {},
 
   doCommand(aCommand) {
     EditorRemoveTextProperty("name", "");
     window.content.focus();
   },
 };
 
-var nsEditLinkCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    // Not really used -- this command is only in context menu, and we do enabling there
-    return IsDocumentEditable() && IsEditingRenderedHTML();
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    try {
-      var element = GetCurrentEditor().getSelectedElement("href");
-      if (element) {
-        editPage(element.href);
-      }
-    } catch (e) {}
-    window.content.focus();
-  },
-};
-
-var nsNormalModeCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    return IsHTMLEditor() && IsDocumentEditable();
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    SetEditMode(kDisplayModeNormal);
-  },
-};
-
-var nsAllTagsModeCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    return IsDocumentEditable() && IsHTMLEditor();
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    SetEditMode(kDisplayModeAllTags);
-  },
-};
-
-var nsHTMLSourceModeCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    return IsDocumentEditable() && IsHTMLEditor();
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    SetEditMode(kDisplayModeSource);
-  },
-};
-
-var nsPreviewModeCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    return IsDocumentEditable() && IsHTMLEditor();
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    SetEditMode(kDisplayModePreview);
-  },
-};
-
 var nsInsertOrEditTableCommand = {
   isCommandEnabled(aCommand, dummy) {
     return IsDocumentEditable() && IsEditingRenderedHTML();
   },
 
   getCommandStateParams(aCommand, aParams, aRefCon) {},
   doCommandParams(aCommand, aParams, aRefCon) {},
 
@@ -3594,33 +3016,16 @@ var nsDeleteTableCellContentsCommand = {
   doCommand(aCommand) {
     try {
       GetCurrentTableEditor().deleteTableCellContents();
     } catch (e) {}
     window.content.focus();
   },
 };
 
-var nsNormalizeTableCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    return IsInTable();
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    // Use nullptr to let editor find table enclosing current selection
-    try {
-      GetCurrentTableEditor().normalizeTable(null);
-    } catch (e) {}
-    window.content.focus();
-  },
-};
-
 var nsJoinTableCellsCommand = {
   isCommandEnabled(aCommand, dummy) {
     if (IsDocumentEditable() && IsEditingRenderedHTML()) {
       try {
         var editor = GetCurrentTableEditor();
         var tagNameObj = { value: "" };
         var countObj = { value: 0 };
         var cell = editor.getSelectedOrParentTableElement(tagNameObj, countObj);
@@ -3728,57 +3133,16 @@ var nsTableOrCellColorCommand = {
   getCommandStateParams(aCommand, aParams, aRefCon) {},
   doCommandParams(aCommand, aParams, aRefCon) {},
 
   doCommand(aCommand) {
     EditorSelectColor("TableOrCell");
   },
 };
 
-var nsPreferencesCommand = {
-  isCommandEnabled(aCommand, dummy) {
-    return true;
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    goPreferences("composer_pane");
-  },
-};
-
-var nsFinishHTMLSource = {
-  isCommandEnabled(aCommand, dummy) {
-    return true;
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    // In editor.js
-    SetEditMode(gPreviousNonSourceDisplayMode);
-  },
-};
-
-var nsCancelHTMLSource = {
-  isCommandEnabled(aCommand, dummy) {
-    return true;
-  },
-
-  getCommandStateParams(aCommand, aParams, aRefCon) {},
-  doCommandParams(aCommand, aParams, aRefCon) {},
-
-  doCommand(aCommand) {
-    // In editor.js
-    CancelHTMLSource();
-  },
-};
-
 var nsConvertToTable = {
   isCommandEnabled(aCommand, dummy) {
     if (IsDocumentEditable() && IsEditingRenderedHTML()) {
       var selection;
       try {
         selection = GetCurrentEditor().selection;
       } catch (e) {}
 
--- a/mail/components/compose/content/dialogs/EdDialogCommon.js
+++ b/mail/components/compose/content/dialogs/EdDialogCommon.js
@@ -356,35 +356,16 @@ function setColorWell(ColorWellID, color
     } else {
       colorWell.removeAttribute("default");
       // Use setAttribute so colorwell can be a XUL element, such as button
       colorWell.setAttribute("style", "background-color:" + color);
     }
   }
 }
 
-function getColorAndSetColorWell(ColorPickerID, ColorWellID) {
-  var color = getColor(ColorPickerID);
-  setColorWell(ColorWellID, color);
-  return color;
-}
-
-function InitMoreFewer() {
-  // Set SeeMore bool to the OPPOSITE of the current state,
-  //   which is automatically saved by using the 'persist="more"'
-  //   attribute on the gDialog.MoreFewerButton button
-  //   onMoreFewer will toggle it and redraw the dialog
-  SeeMore = gDialog.MoreFewerButton.getAttribute("more") != "1";
-  onMoreFewer();
-  gDialog.MoreFewerButton.setAttribute(
-    "accesskey",
-    GetString("PropertiesAccessKey")
-  );
-}
-
 function onMoreFewer() {
   if (SeeMore) {
     gDialog.MoreSection.collapsed = true;
     gDialog.MoreFewerButton.setAttribute("more", "0");
     gDialog.MoreFewerButton.setAttribute("label", GetString("MoreProperties"));
     SeeMore = false;
   } else {
     gDialog.MoreSection.collapsed = false;
@@ -441,104 +422,16 @@ function GetLocalFileURL(filterType) {
         return;
       }
       SaveFilePickerDirectory(fp, fileType);
       resolve(fp.fileURL.spec);
     });
   });
 }
 
-function GetMetaElementByAttribute(name, value) {
-  if (name) {
-    name = name.toLowerCase();
-    let editor = GetCurrentEditor();
-    try {
-      return editor.document.querySelector(
-        "meta[" + name + '="' + value + '"]'
-      );
-    } catch (e) {}
-  }
-  return null;
-}
-
-function CreateMetaElementWithAttribute(name, value) {
-  let editor = GetCurrentEditor();
-  try {
-    let metaElement = editor.createElementWithDefaults("meta");
-    if (name) {
-      metaElement.setAttribute(name, value);
-    }
-    return metaElement;
-  } catch (e) {}
-  return null;
-}
-
-// Change "content" attribute on a META element,
-//   or delete entire element it if content is empty
-// This uses undoable editor transactions
-function SetMetaElementContent(metaElement, content, insertNew, prepend) {
-  if (metaElement) {
-    var editor = GetCurrentEditor();
-    try {
-      if (!content || content == "") {
-        if (!insertNew) {
-          editor.deleteNode(metaElement);
-        }
-      } else if (insertNew) {
-        metaElement.setAttribute("content", content);
-        if (prepend) {
-          PrependHeadElement(metaElement);
-        } else {
-          AppendHeadElement(metaElement);
-        }
-      } else {
-        editor.setAttribute(metaElement, "content", content);
-      }
-    } catch (e) {}
-  }
-}
-
-function GetHeadElement() {
-  var editor = GetCurrentEditor();
-  try {
-    return editor.document.querySelector("head");
-  } catch (e) {}
-
-  return null;
-}
-
-function PrependHeadElement(element) {
-  var head = GetHeadElement();
-  if (head) {
-    var editor = GetCurrentEditor();
-    try {
-      // Use editor's undoable transaction
-      // Last param "true" says "don't change the selection"
-      editor.insertNode(element, head, 0, true);
-    } catch (e) {}
-  }
-}
-
-function AppendHeadElement(element) {
-  var head = GetHeadElement();
-  if (head) {
-    var position = 0;
-    if (head.hasChildNodes()) {
-      position = head.childNodes.length;
-    }
-
-    var editor = GetCurrentEditor();
-    try {
-      // Use editor's undoable transaction
-      // Last param "true" says "don't change the selection"
-      editor.insertNode(element, head, position, true);
-    } catch (e) {}
-  }
-}
-
 function SetWindowLocation() {
   gLocation = document.getElementById("location");
   if (gLocation) {
     window.screenX = Math.max(
       0,
       Math.min(
         window.opener.screenX + Number(gLocation.getAttribute("offsetX")),
         screen.availWidth - window.outerWidth
@@ -673,233 +566,16 @@ var NotAnInlineParent = [
   "table",
   "tbody",
   "tfoot",
   "thead",
   "tr",
   "ul",
 ];
 
-function nodeIsBreak(editor, node) {
-  // XXX This doesn't work because .localName is lowercase (see bug 1306060).
-  return !node || node.localName == "BR" || editor.nodeIsBlock(node);
-}
-
-function InsertElementAroundSelection(element) {
-  var editor = GetCurrentEditor();
-  editor.beginTransaction();
-
-  try {
-    // First get the selection as a single range
-    var range, start, end, offset;
-    var count = editor.selection.rangeCount;
-    if (count == 1) {
-      range = editor.selection.getRangeAt(0).cloneRange();
-    } else {
-      range = editor.document.createRange();
-      start = editor.selection.getRangeAt(0);
-      range.setStart(start.startContainer, start.startOffset);
-      end = editor.selection.getRangeAt(--count);
-      range.setEnd(end.endContainer, end.endOffset);
-    }
-
-    // Flatten the selection to child nodes of the common ancestor
-    while (range.startContainer != range.commonAncestorContainer) {
-      range.setStartBefore(range.startContainer);
-    }
-    while (range.endContainer != range.commonAncestorContainer) {
-      range.setEndAfter(range.endContainer);
-    }
-
-    if (editor.nodeIsBlock(element)) {
-      // Block element parent must be a valid block
-      while (!IsBlockParent.includes(range.commonAncestorContainer.localName)) {
-        range.selectNode(range.commonAncestorContainer);
-      }
-    } else if (!nodeIsBreak(editor, range.commonAncestorContainer)) {
-      // Fail if we're not inserting a block (use setInlineProperty instead)
-      return false;
-    } else if (
-      NotAnInlineParent.includes(range.commonAncestorContainer.localName)
-    ) {
-      // Inline element parent must not be an invalid block
-      do {
-        range.selectNode(range.commonAncestorContainer);
-      } while (
-        NotAnInlineParent.includes(range.commonAncestorContainer.localName)
-      );
-    } else {
-      // Further insert block check
-      for (var i = range.startOffset; ; i++) {
-        if (i == range.endOffset) {
-          return false;
-        } else if (
-          nodeIsBreak(editor, range.commonAncestorContainer.childNodes[i])
-        ) {
-          break;
-        }
-      }
-    }
-
-    // The range may be contained by body text, which should all be selected.
-    offset = range.startOffset;
-    start = range.startContainer.childNodes[offset];
-    if (!nodeIsBreak(editor, start)) {
-      while (!nodeIsBreak(editor, start.previousSibling)) {
-        start = start.previousSibling;
-        offset--;
-      }
-    }
-    end = range.endContainer.childNodes[range.endOffset];
-    if (end && !nodeIsBreak(editor, end.previousSibling)) {
-      while (!nodeIsBreak(editor, end)) {
-        end = end.nextSibling;
-      }
-    }
-
-    // Now insert the node
-    editor.insertNode(element, range.commonAncestorContainer, offset, true);
-    offset = element.childNodes.length;
-    if (!editor.nodeIsBlock(element)) {
-      editor.setShouldTxnSetSelection(false);
-    }
-
-    // Move all the old child nodes to the element
-    var empty = true;
-    while (start != end) {
-      var next = start.nextSibling;
-      editor.deleteNode(start);
-      editor.insertNode(start, element, element.childNodes.length);
-      empty = false;
-      start = next;
-    }
-    if (!editor.nodeIsBlock(element)) {
-      editor.setShouldTxnSetSelection(true);
-    } else {
-      // Also move a trailing <br>
-      // XXX This doesn't work because .localName is lowercase (see bug 1306060).
-      if (start && start.localName == "BR") {
-        editor.deleteNode(start);
-        editor.insertNode(start, element, element.childNodes.length);
-        empty = false;
-      }
-      // Still nothing? Insert a <br> so the node is not empty
-      if (empty) {
-        editor.insertNode(
-          editor.createElementWithDefaults("br"),
-          element,
-          element.childNodes.length
-        );
-      }
-
-      // Hack to set the selection just inside the element
-      editor.insertNode(editor.document.createTextNode(""), element, offset);
-    }
-  } finally {
-    editor.endTransaction();
-  }
-
-  return true;
-}
-
-function nodeIsBlank(node) {
-  return node && node.nodeType == Node.TEXT_NODE && !/\S/.test(node.data);
-}
-
-function nodeBeginsBlock(editor, node) {
-  while (nodeIsBlank(node)) {
-    node = node.nextSibling;
-  }
-  return nodeIsBreak(editor, node);
-}
-
-function nodeEndsBlock(editor, node) {
-  while (nodeIsBlank(node)) {
-    node = node.previousSibling;
-  }
-  return nodeIsBreak(editor, node);
-}
-
-// C++ function isn't exposed to JS :-(
-function RemoveBlockContainer(element) {
-  var editor = GetCurrentEditor();
-  editor.beginTransaction();
-
-  try {
-    var range = editor.document.createRange();
-    range.selectNode(element);
-    var offset = range.startOffset;
-    var parent = element.parentNode;
-
-    // May need to insert a break after the removed element
-    if (
-      !nodeBeginsBlock(editor, element.nextSibling) &&
-      !nodeEndsBlock(editor, element.lastChild)
-    ) {
-      editor.insertNode(
-        editor.createElementWithDefaults("br"),
-        parent,
-        range.endOffset
-      );
-    }
-
-    // May need to insert a break before the removed element, or if it was empty
-    if (
-      !nodeEndsBlock(editor, element.previousSibling) &&
-      !nodeBeginsBlock(editor, element.firstChild || element.nextSibling)
-    ) {
-      editor.insertNode(
-        editor.createElementWithDefaults("br"),
-        parent,
-        offset++
-      );
-    }
-
-    // Now remove the element
-    editor.deleteNode(element);
-
-    // Need to copy the contained nodes?
-    for (var i = 0; i < element.childNodes.length; i++) {
-      editor.insertNode(
-        element.childNodes[i].cloneNode(true),
-        parent,
-        offset++
-      );
-    }
-  } finally {
-    editor.endTransaction();
-  }
-}
-
-// C++ function isn't exposed to JS :-(
-function RemoveContainer(element) {
-  var editor = GetCurrentEditor();
-  editor.beginTransaction();
-
-  try {
-    var range = editor.document.createRange();
-    var parent = element.parentNode;
-    // Allow for automatic joining of text nodes
-    // so we can't delete the container yet
-    // so we need to copy the contained nodes
-    for (var i = 0; i < element.childNodes.length; i++) {
-      range.selectNode(element);
-      editor.insertNode(
-        element.childNodes[i].cloneNode(true),
-        parent,
-        range.startOffset
-      );
-    }
-    // Now remove the element
-    editor.deleteNode(element);
-  } finally {
-    editor.endTransaction();
-  }
-}
-
 function FillLinkMenulist(linkMenulist, headingsArray) {
   var menupopup = linkMenulist.firstElementChild;
   var editor = GetCurrentEditor();
   try {
     var treeWalker = editor.document.createTreeWalker(
       editor.document,
       1,
       null,
--- a/mail/components/compose/content/editor.js
+++ b/mail/components/compose/content/editor.js
@@ -92,126 +92,19 @@ var gFontSizeNames = [
   "medium",
   "large",
   "x-large",
   "xx-large",
 ];
 
 var nsIFilePicker = Ci.nsIFilePicker;
 
-var kEditorToolbarPrefs = "editor.toolbars.showbutton.";
 var kUseCssPref = "editor.use_css";
 var kCRInParagraphsPref = "editor.CR_creates_new_p";
 
-function ShowHideToolbarSeparators(toolbar) {
-  // Make sure the toolbar actually exists.
-  if (!toolbar) {
-    return;
-  }
-  var children = toolbar.children;
-  var separator = null;
-  var hideSeparator = true;
-  for (var i = 0; children[i].localName != "spacer"; i++) {
-    if (children[i].localName == "toolbarseparator") {
-      if (separator) {
-        separator.hidden = true;
-      }
-      separator = children[i];
-    } else if (!children[i].hidden) {
-      if (separator) {
-        separator.hidden = hideSeparator;
-      }
-      separator = null;
-      hideSeparator = false;
-    }
-  }
-}
-
-function ShowHideToolbarButtons() {
-  let array = Services.prefs.getChildList(kEditorToolbarPrefs);
-  for (let i in array) {
-    let prefName = array[i];
-    let id = prefName.substr(kEditorToolbarPrefs.length);
-    let button =
-      document.getElementById(id + "Button") ||
-      document.getElementById(id + "-button");
-    if (button) {
-      button.hidden = !Services.prefs.getBoolPref(prefName);
-    }
-  }
-  ShowHideToolbarSeparators(document.getElementById("EditToolbar"));
-  ShowHideToolbarSeparators(document.getElementById("FormatToolbar"));
-}
-
-function nsPrefListener(prefName) {
-  this.startup(prefName);
-}
-
-// implements nsIObserver
-nsPrefListener.prototype = {
-  domain: "",
-  startup(prefName) {
-    this.domain = prefName;
-    try {
-      Services.prefs.addObserver(this.domain, this);
-    } catch (ex) {
-      dump("Failed to observe prefs: " + ex + "\n");
-    }
-  },
-  shutdown() {
-    try {
-      Services.prefs.removeObserver(this.domain, this);
-    } catch (ex) {
-      dump("Failed to remove pref observers: " + ex + "\n");
-    }
-  },
-  observe(subject, topic, prefName) {
-    if (!IsHTMLEditor()) {
-      return;
-    }
-    // verify that we're changing a button pref
-    if (topic != "nsPref:changed") {
-      return;
-    }
-
-    let editor = GetCurrentEditor();
-    if (prefName == kUseCssPref) {
-      let cmd = document.getElementById("cmd_highlight");
-      if (cmd) {
-        let useCSS = Services.prefs.getBoolPref(prefName);
-
-        if (useCSS && editor) {
-          let mixedObj = {};
-          let state = editor.getHighlightColorState(mixedObj);
-          cmd.setAttribute("state", state);
-          cmd.collapsed = false;
-        } else {
-          cmd.setAttribute("state", "transparent");
-          cmd.collapsed = true;
-        }
-
-        if (editor) {
-          editor.isCSSEnabled = useCSS;
-        }
-      }
-    } else if (prefName.startsWith(kEditorToolbarPrefs)) {
-      let id = prefName.substr(kEditorToolbarPrefs.length) + "Button";
-      let button = document.getElementById(id);
-      if (button) {
-        button.hidden = !Services.prefs.getBoolPref(prefName);
-        ShowHideToolbarSeparators(button.parentNode);
-      }
-    } else if (editor && prefName == kCRInParagraphsPref) {
-      editor.returnInParagraphCreatesNewParagraph = Services.prefs.getBoolPref(
-        prefName
-      );
-    }
-  },
-};
-
 const gSourceTextListener = {
   NotifyDocumentCreated() {},
   NotifyDocumentWillBeDestroyed() {},
   NotifyDocumentStateChanged(isChanged) {
     window.updateCommands("save");
   },
 };
 
@@ -312,102 +205,16 @@ var gEditorDocumentObserver = {
 
           //  and extra styles for showing anchors, table borders, smileys, etc
           editor.addOverrideStyleSheet(kNormalStyleSheet);
 
           // remove contenteditable stylesheets if they were applied by the
           // editingSession
           editor.removeOverrideStyleSheet(kContentEditableStyleSheet);
         } catch (e) {}
-
-        // Things for just the Web Composer application
-        if (IsWebComposer()) {
-          InlineSpellCheckerUI.init(editor);
-          document
-            .getElementById("menu_inlineSpellCheck")
-            .setAttribute("disabled", !InlineSpellCheckerUI.canSpellCheck);
-
-          editor.returnInParagraphCreatesNewParagraph = Services.prefs.getBoolPref(
-            kCRInParagraphsPref
-          );
-
-          // Set focus to content window if not a mail composer
-          // Race conditions prevent us from setting focus here
-          //   when loading a url into blank window
-          setTimeout(SetFocusOnStartup, 0);
-
-          // Call EditorSetDefaultPrefsAndDoctype first so it gets the default author before initing toolbars
-          editor.enableUndo(false);
-          EditorSetDefaultPrefsAndDoctype();
-          editor.resetModificationCount();
-          editor.enableUndo(true);
-
-          // We may load a text document into an html editor,
-          //   so be sure editortype is set correctly
-          // XXX We really should use the "real" plaintext editor for this!
-          if (editor.contentsMIMEType == "text/plain") {
-            try {
-              GetCurrentEditorElement().editortype = "text";
-            } catch (e) {
-              dump(e) + "\n";
-            }
-
-            // Hide or disable UI not used for plaintext editing
-            HideItem("FormatToolbar");
-            HideItem("EditModeToolbar");
-            HideItem("formatMenu");
-            HideItem("tableMenu");
-            HideItem("menu_validate");
-            HideItem("sep_validate");
-            HideItem("previewButton");
-            HideItem("imageButton");
-            HideItem("linkButton");
-            HideItem("namedAnchorButton");
-            HideItem("hlineButton");
-            HideItem("tableButton");
-
-            HideItem("fileExportToText");
-            HideItem("previewInBrowser");
-
-            /* XXX When paste actually converts formatted rich text to pretty formatted plain text
-       and pasteNoFormatting is fixed to paste the text without formatting (what paste
-       currently does), then this item shouldn't be hidden: */
-            HideItem("menu_pasteNoFormatting");
-
-            HideItem("cmd_viewFormatToolbar");
-            HideItem("cmd_viewEditModeToolbar");
-
-            HideItem("viewSep1");
-            HideItem("viewNormalMode");
-            HideItem("viewAllTagsMode");
-            HideItem("viewSourceMode");
-            HideItem("viewPreviewMode");
-
-            HideItem("structSpacer");
-
-            // Hide everything in "Insert" except for "Symbols"
-            let menuPopupChildren = document.querySelectorAll(
-              '[id="insertMenuPopup"] > :not(#insertChars)'
-            );
-            for (let i = 0; i < menuPopupChildren.length; i++) {
-              menuPopupChildren.item(i).hidden = true;
-            }
-          }
-
-          // Set window title
-          UpdateWindowTitle();
-
-          // We must wait until document is created to get proper Url
-          // (Windows may load with local file paths)
-          SetSaveAndPublishUI(GetDocumentUrl());
-
-          // Start in "Normal" edit mode
-          SetDisplayMode(kDisplayModeNormal);
-        }
-
         // Add mouse click watcher if right type of editor
         if (IsHTMLEditor()) {
           // Force color widgets to update
           onFontColorChange();
           onBackgroundColorChange();
         }
         break;
 
@@ -542,32 +349,16 @@ function EditorSharedStartup() {
 
 function SafeSetAttribute(nodeID, attributeName, attributeValue) {
   var theNode = document.getElementById(nodeID);
   if (theNode) {
     theNode.setAttribute(attributeName, attributeValue);
   }
 }
 
-function DocumentHasBeenSaved() {
-  var fileurl = "";
-  try {
-    fileurl = GetDocumentUrl();
-  } catch (e) {
-    return false;
-  }
-
-  if (!fileurl || IsUrlAboutBlank(fileurl)) {
-    return false;
-  }
-
-  // We have a file URL already
-  return true;
-}
-
 async function CheckAndSaveDocument(command, allowDontSave) {
   var document;
   try {
     // if we don't have an editor or an document, bail
     var editor = GetCurrentEditor();
     document = editor.document;
     if (!document) {
       return true;
@@ -579,123 +370,74 @@ async function CheckAndSaveDocument(comm
   if (!IsDocumentModified() && !IsHTMLSourceChanged()) {
     return true;
   }
 
   // call window.focus, since we need to pop up a dialog
   // and therefore need to be visible (to prevent user confusion)
   top.document.commandDispatcher.focusedWindow.focus();
 
-  var scheme = GetScheme(GetDocumentUrl());
-  var doPublish = scheme && scheme != "file";
-
   var strID;
   switch (command) {
     case "cmd_close":
       strID = "BeforeClosing";
       break;
-    case "cmd_preview":
-      strID = "BeforePreview";
-      break;
-    case "cmd_editSendPage":
-      strID = "SendPageReason";
-      break;
-    case "cmd_validate":
-      strID = "BeforeValidate";
-      break;
   }
 
   var reasonToSave = strID ? GetString(strID) : "";
 
   var title = document.title || GetString("untitledDefaultFilename");
 
-  var dialogTitle = GetString(doPublish ? "PublishPage" : "SaveDocument");
-  var dialogMsg = GetString(doPublish ? "PublishPrompt" : "SaveFilePrompt");
+  var dialogTitle = GetString("SaveDocument");
+  var dialogMsg = GetString("SaveFilePrompt");
   dialogMsg = dialogMsg
     .replace(/%title%/, title)
     .replace(/%reason%/, reasonToSave);
 
   let result = { value: 0 };
   let promptFlags =
     Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1;
   let button1Title = null;
   let button3Title = null;
 
-  if (doPublish) {
-    promptFlags +=
-      Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0;
-    button1Title = GetString("Publish");
-    button3Title = GetString("DontPublish");
-  } else {
-    promptFlags +=
-      Services.prompt.BUTTON_TITLE_SAVE * Services.prompt.BUTTON_POS_0;
-  }
+  promptFlags +=
+    Services.prompt.BUTTON_TITLE_SAVE * Services.prompt.BUTTON_POS_0;
 
   // If allowing "Don't..." button, add that
   if (allowDontSave) {
-    promptFlags += doPublish
-      ? Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_2
-      : Services.prompt.BUTTON_TITLE_DONT_SAVE * Services.prompt.BUTTON_POS_2;
+    promptFlags +=
+      Services.prompt.BUTTON_TITLE_DONT_SAVE * Services.prompt.BUTTON_POS_2;
   }
 
   result = Services.prompt.confirmEx(
     window,
     dialogTitle,
     dialogMsg,
     promptFlags,
     button1Title,
     null,
     button3Title,
     null,
     { value: 0 }
   );
 
   if (result == 0) {
-    // Save, but first finish HTML source mode
-    SetEditMode(gPreviousNonSourceDisplayMode);
-    if (doPublish) {
-      // We save the command the user wanted to do in a global
-      // and return as if user canceled because publishing is asynchronous
-      // This command will be fired when publishing finishes
-      gCommandAfterPublishing = command;
-      goDoCommand("cmd_publish");
-      return false;
-    }
-
     // Save to local disk
     return SaveDocument(false, false, editor.contentsMIMEType);
   }
 
   if (result == 2) {
     // "Don't Save"
     return true;
   }
 
   // Default or result == 1 (Cancel)
   return false;
 }
 
-// --------------------------- View menu ---------------------------
-
-function EditorSetCharacterSet(aEvent) {
-  try {
-    var editor = GetCurrentEditor();
-    if (aEvent.target.hasAttribute("charset")) {
-      editor.documentCharacterSet = aEvent.target.getAttribute("charset");
-    }
-    var docUrl = GetDocumentUrl();
-    if (!IsUrlAboutBlank(docUrl)) {
-      // reloading the document will reverse any changes to the META charset,
-      // we need to put them back in, which is achieved by a dedicated listener
-      editor.addDocumentStateListener(DocumentReloadListener);
-      EditorLoadUrl(docUrl);
-    }
-  } catch (e) {}
-}
-
 // --------------------------- Text style ---------------------------
 
 function onParagraphFormatChange(paraMenuList, commandID) {
   if (!paraMenuList) {
     return;
   }
 
   var commandNode = document.getElementById(commandID);
@@ -912,67 +654,16 @@ function onFontFaceChange(fontFaceMenuLi
     foundFont = createFontFaceMenuitem(fontLabel, editorFont, menuPopup);
     foundFont.setAttribute("used", "true");
     usedFontsSep.hidden = false;
     menuPopup.insertBefore(foundFont, usedFontsSep);
   }
   fontFaceMenuList.selectedItem = foundFont;
 }
 
-/**
- * Clears the used fonts list from all the font face menulists.
- */
-function ClearUsedFonts() {
-  let userFontSeps = document.querySelectorAll(
-    "menuseparator.fontFaceMenuAfterDefaultFonts"
-  );
-  for (let userFontSep of userFontSeps) {
-    while (true) {
-      let nextNode = userFontSep.nextElementSibling;
-      if (nextNode.tagName != "menuseparator") {
-        nextNode.remove();
-      } else if (nextNode.classList.contains("fontFaceMenuAfterUsedFonts")) {
-        nextNode.hidden = true;
-        break;
-      }
-    }
-  }
-}
-
-function EditorSelectFontSize() {
-  var select = document.getElementById("FontSizeSelect");
-  if (select) {
-    if (select.selectedIndex == -1) {
-      return;
-    }
-
-    EditorSetFontSize(gFontSizeNames[select.selectedIndex]);
-  }
-}
-
-function onFontSizeChange(fontSizeMenulist, commandID) {
-  // If we don't match anything, set to "0 (normal)"
-  var newIndex = 2;
-  var size = fontSizeMenulist.getAttribute("size");
-  if (size == "mixed") {
-    // No single type selected
-    newIndex = -1;
-  } else {
-    for (var i = 0; i < gFontSizeNames.length; i++) {
-      if (gFontSizeNames[i] == size) {
-        newIndex = i;
-        break;
-      }
-    }
-  }
-  if (fontSizeMenulist.selectedIndex != newIndex) {
-    fontSizeMenulist.selectedIndex = newIndex;
-  }
-}
-
 function EditorSetFontSize(size) {
   if (size == "0" || size == "normal" || size == "medium") {
     EditorRemoveTextProperty("font", "size");
     // Also remove big and small,
     //  else it will seem like size isn't changing correctly
     EditorRemoveTextProperty("small", "");
     EditorRemoveTextProperty("big", "");
   } else {
@@ -1269,20 +960,16 @@ function initFontSizeMenu(menuPopup, ful
       menuPopup.lastElementChild.setAttribute("label", "HTML: " + htmlInfo);
       menuPopup.lastElementChild.setAttribute("checked", true);
     } else {
       menuPopup.lastElementChild.hidden = true;
     }
   }
 }
 
-function onHighlightColorChange() {
-  ChangeButtonColor("cmd_highlight", "HighlightColorButton", "transparent");
-}
-
 function onFontColorChange() {
   ChangeButtonColor("cmd_fontColor", "TextColorButton", gDefaultTextColor);
 }
 
 function onBackgroundColorChange() {
   ChangeButtonColor(
     "cmd_backgroundColor",
     "BackgroundColorButton",
@@ -1422,23 +1109,16 @@ function GetBackgroundElementWithColor()
         );
       }
       gColorObj.PageColor = gColorObj.BackgroundColor;
     }
   }
   return element;
 }
 
-function SetSmiley(smileyText) {
-  try {
-    GetCurrentEditor().insertText(smileyText);
-    gContentWindow.focus();
-  } catch (e) {}
-}
-
 /* eslint-disable complexity */
 function EditorSelectColor(colorType, mouseEvent) {
   var editor = GetCurrentEditor();
   if (!editor || !gColorObj) {
     return;
   }
 
   // Shift + mouse click automatically applies last color, if available
@@ -1705,34 +1385,16 @@ function EditorDblClick(event) {
       ].includes(element.nodeName.toLowerCase())
     ) {
       goDoCommand("cmd_objectProperties");
       event.preventDefault();
     }
   }
 }
 
-function EditorClick(event) {
-  // For Web Composer: In Show All Tags Mode,
-  // single click selects entire element,
-  //  except for body and table elements
-  if (gEditorDisplayMode == kDisplayModeAllTags) {
-    try {
-      // We check event.explicitOriginalTarget here because .target will never
-      // be a textnode (bug 193689)
-      var element = event.explicitOriginalTarget;
-      var name = element.localName;
-      if (!["body", "caption", "table", "td", "th", "tr"].includes(name)) {
-        GetCurrentEditor().selectElement(event.explicitOriginalTarget);
-        event.preventDefault();
-      }
-    } catch (e) {}
-  }
-}
-
 /* TODO: We need an oncreate hook to do enabling/disabling for the
         Format menu. There should be code like this for the
         object-specific "Properties" item
 */
 // For property dialogs, we want the selected element,
 //  but will accept a parent link, list, or table cell if inside one
 function GetObjectForProperties() {
   var editor = GetCurrentEditor();
@@ -1795,299 +1457,16 @@ function GetObjectForProperties() {
         return node;
       }
     }
     node = node.parentNode;
   }
   return null;
 }
 
-function SetEditMode(mode) {
-  if (!IsHTMLEditor()) {
-    return;
-  }
-
-  var bodyElement = GetBodyElement();
-  if (!bodyElement) {
-    dump("SetEditMode: We don't have a body node!\n");
-    return;
-  }
-
-  // must have editor if here!
-  var editor = GetCurrentEditor();
-  var inlineSpellCheckItem = document.getElementById("menu_inlineSpellCheck");
-
-  // Switch the UI mode before inserting contents
-  //   so user can't type in source window while new window is being filled
-  var previousMode = gEditorDisplayMode;
-  if (!SetDisplayMode(mode)) {
-    return;
-  }
-
-  if (mode == kDisplayModeSource) {
-    // Display the DOCTYPE as a non-editable string above edit area
-    var domdoc;
-    try {
-      domdoc = editor.document;
-    } catch (e) {
-      dump(e + "\n");
-    }
-    if (domdoc) {
-      var doctypeNode = document.getElementById("doctype-text");
-      var dt = domdoc.doctype;
-      if (doctypeNode) {
-        if (dt) {
-          doctypeNode.collapsed = false;
-          var doctypeText = "<!DOCTYPE " + domdoc.doctype.name;
-          if (dt.publicId) {
-            doctypeText += ' PUBLIC "' + domdoc.doctype.publicId;
-          }
-          if (dt.systemId) {
-            doctypeText += ' "' + dt.systemId;
-          }
-          doctypeText += '">';
-          doctypeNode.setAttribute("value", doctypeText);
-        } else {
-          doctypeNode.collapsed = true;
-        }
-      }
-    }
-    // Get the entire document's source string
-
-    var flags =
-      editor.documentCharacterSet == "ISO-8859-1"
-        ? kOutputEncodeLatin1Entities
-        : kOutputEncodeBasicEntities;
-    try {
-      let encodeEntity = Services.prefs.getCharPref("editor.encode_entity");
-      switch (encodeEntity) {
-        case "basic":
-          flags = kOutputEncodeBasicEntities;
-          break;
-        case "latin1":
-          flags = kOutputEncodeLatin1Entities;
-          break;
-        case "html":
-          flags = kOutputEncodeHTMLEntities;
-          break;
-        case "none":
-          flags = 0;
-          break;
-      }
-    } catch (e) {}
-
-    if (Services.prefs.getBoolPref("editor.prettyprint")) {
-      flags |= kOutputFormatted;
-    }
-
-    flags |= kOutputLFLineBreak;
-    var source = editor.outputToString(editor.contentsMIMEType, flags);
-    var start = source.search(/<html/i);
-    if (start == -1) {
-      start = 0;
-    }
-    gSourceTextEditor.insertText(source.slice(start));
-    gSourceTextEditor.resetModificationCount();
-    gSourceTextEditor.addDocumentStateListener(gSourceTextListener);
-    gSourceTextEditor.enableUndo(true);
-    gSourceContentWindow.commandManager.addCommandObserver(
-      gSourceTextObserver,
-      "cmd_undo"
-    );
-    gSourceContentWindow.contentWindow.focus();
-    goDoCommand("cmd_moveTop");
-  } else if (previousMode == kDisplayModeSource) {
-    // Only rebuild document if a change was made in source window
-    if (IsHTMLSourceChanged()) {
-      // Disable spell checking when rebuilding source
-      InlineSpellCheckerUI.enabled = false;
-      inlineSpellCheckItem.removeAttribute("checked");
-
-      // Reduce the undo count so we don't use too much memory
-      //   during multiple uses of source window
-      //   (reinserting entire doc caches all nodes)
-      try {
-        editor.transactionManager.maxTransactionCount = 1;
-      } catch (e) {}
-
-      editor.beginTransaction();
-      try {
-        // We are coming from edit source mode,
-        //   so transfer that back into the document
-        source = gSourceTextEditor
-          .outputToString(kTextMimeType, kOutputLFLineBreak)
-          .trim();
-        if (editor.contentsMIMEType != kXHTMLMimeType) {
-          editor.rebuildDocumentFromSource(source);
-        } else {
-          /* eslint-disable-next-line no-unsanitized/method */
-          var fragment = editor.document
-            .createRange()
-            .createContextualFragment(source);
-          editor.enableUndo(false);
-          GetBodyElement().remove();
-          editor.document.replaceChild(
-            fragment.firstChild,
-            editor.document.documentElement
-          );
-          editor.enableUndo(true);
-        }
-
-        // Get the text for the <title> from the newly-parsed document
-        // (must do this for proper conversion of "escaped" characters)
-        let titleNode = editor.document.querySelector("title");
-        SetDocumentTitle(titleNode ? titleNode.textContent : "");
-      } catch (ex) {
-        dump(ex);
-      }
-      editor.endTransaction();
-
-      // Restore unlimited undo count
-      try {
-        editor.transactionManager.maxTransactionCount = -1;
-      } catch (e) {}
-    }
-
-    // Clear out the string buffers
-    gSourceContentWindow.commandManager.removeCommandObserver(
-      gSourceTextObserver,
-      "cmd_undo"
-    );
-    gSourceTextEditor.removeDocumentStateListener(gSourceTextListener);
-    gSourceTextEditor.enableUndo(false);
-    gSourceTextEditor.selectAll();
-    gSourceTextEditor.deleteSelection(
-      gSourceTextEditor.eNone,
-      gSourceTextEditor.eStrip
-    );
-    gSourceTextEditor.resetModificationCount();
-
-    gContentWindow.focus();
-    // goDoCommand("cmd_moveTop");
-  }
-
-  switch (mode) {
-    case kDisplayModePreview:
-      // Disable spell checking when previewing
-      InlineSpellCheckerUI.enabled = false;
-      inlineSpellCheckItem.removeAttribute("checked");
-    // fall through
-    case kDisplayModeSource:
-      inlineSpellCheckItem.setAttribute("disabled", "true");
-      break;
-    default:
-      inlineSpellCheckItem.setAttribute(
-        "disabled",
-        !InlineSpellCheckerUI.canSpellCheck
-      );
-      break;
-  }
-}
-
-function CancelHTMLSource() {
-  // Don't convert source text back into the DOM document
-  gSourceTextEditor.resetModificationCount();
-  SetDisplayMode(gPreviousNonSourceDisplayMode);
-}
-
-function SetDisplayMode(mode) {
-  if (!IsHTMLEditor()) {
-    return false;
-  }
-
-  // Already in requested mode:
-  //  return false to indicate we didn't switch
-  if (mode == gEditorDisplayMode) {
-    return false;
-  }
-
-  var previousMode = gEditorDisplayMode;
-  gEditorDisplayMode = mode;
-
-  ResetStructToolbar();
-  if (mode == kDisplayModeSource) {
-    // Switch to the sourceWindow (second in the deck)
-    gContentWindowDeck.selectedIndex = 1;
-
-    // Hide the formatting toolbar if not already hidden
-    gFormatToolbarHidden = gFormatToolbar.hidden;
-    gFormatToolbar.hidden = true;
-    gViewFormatToolbar.hidden = true;
-
-    gSourceContentWindow.contentWindow.focus();
-  } else {
-    // Save the last non-source mode so we can cancel source editing easily
-    gPreviousNonSourceDisplayMode = mode;
-
-    // Load/unload appropriate override style sheet
-    try {
-      var editor = GetCurrentEditor();
-      editor.QueryInterface(nsIEditorStyleSheets);
-      editor instanceof Ci.nsIHTMLObjectResizer;
-
-      switch (mode) {
-        case kDisplayModePreview:
-          // Disable all extra "edit mode" style sheets
-          editor.enableStyleSheet(kNormalStyleSheet, false);
-          editor.enableStyleSheet(kAllTagsStyleSheet, false);
-          editor.objectResizingEnabled = true;
-          break;
-
-        case kDisplayModeNormal:
-          editor.addOverrideStyleSheet(kNormalStyleSheet);
-          // Disable ShowAllTags mode
-          editor.enableStyleSheet(kAllTagsStyleSheet, false);
-          editor.objectResizingEnabled = true;
-          break;
-
-        case kDisplayModeAllTags:
-          editor.addOverrideStyleSheet(kNormalStyleSheet);
-          editor.addOverrideStyleSheet(kAllTagsStyleSheet);
-          // don't allow resizing in AllTags mode because the visible tags
-          // change the computed size of images and tables...
-          if (editor.resizedObject) {
-            editor.hideResizers();
-          }
-          editor.objectResizingEnabled = false;
-          break;
-      }
-    } catch (e) {}
-
-    // Switch to the normal editor (first in the deck)
-    gContentWindowDeck.selectedIndex = 0;
-
-    // Restore menus and toolbars
-    gFormatToolbar.hidden = gFormatToolbarHidden;
-    gViewFormatToolbar.hidden = false;
-
-    gContentWindow.focus();
-  }
-
-  // update commands to disable or re-enable stuff
-  window.updateCommands("mode_switch");
-
-  // Set the selected tab at bottom of window:
-  // (Note: Setting "selectedIndex = mode" won't redraw tabs when menu is used.)
-  document.getElementById(
-    "EditModeTabs"
-  ).selectedItem = document.getElementById(kDisplayModeTabIDS[mode]);
-
-  // Uncheck previous menuitem and set new check since toolbar may have been used
-  if (previousMode >= 0) {
-    document
-      .getElementById(kDisplayModeMenuIDs[previousMode])
-      .setAttribute("checked", "false");
-  }
-  document
-    .getElementById(kDisplayModeMenuIDs[mode])
-    .setAttribute("checked", "true");
-
-  return true;
-}
-
 function UpdateWindowTitle() {
   try {
     var filename = "";
     var windowTitle = "";
     var title = GetDocumentTitle();
 
     // Append just the 'leaf' filename to the Doc. Title for the window caption
     var docUrl = GetDocumentUrl();
@@ -2550,59 +1929,16 @@ function GetBodyElement() {
     return GetCurrentEditor().rootElement;
   } catch (ex) {
     dump("no body tag found?!\n");
     //  better have one, how can we blow things up here?
   }
   return null;
 }
 
-// --------------------------- Logging stuff ---------------------------
-
-function EditorGetNodeFromOffsets(offsets) {
-  var node = null;
-  try {
-    node = GetCurrentEditor().document;
-
-    for (var i = 0; i < offsets.length; i++) {
-      node = node.childNodes[offsets[i]];
-    }
-  } catch (e) {}
-  return node;
-}
-
-function EditorSetSelectionFromOffsets(selRanges) {
-  try {
-    var editor = GetCurrentEditor();
-    var selection = editor.selection;
-    selection.removeAllRanges();
-
-    var rangeArr, start, end, node, offset;
-    for (var i = 0; i < selRanges.length; i++) {
-      rangeArr = selRanges[i];
-      start = rangeArr[0];
-      end = rangeArr[1];
-
-      var range = editor.document.createRange();
-
-      node = EditorGetNodeFromOffsets(start[0]);
-      offset = start[1];
-
-      range.setStart(node, offset);
-
-      node = EditorGetNodeFromOffsets(end[0]);
-      offset = end[1];
-
-      range.setEnd(node, offset);
-
-      selection.addRange(range);
-    }
-  } catch (e) {}
-}
-
 // --------------------------------------------------------------------
 function initFontStyleMenu(menuPopup) {
   for (var i = 0; i < menuPopup.children.length; i++) {
     var menuItem = menuPopup.children[i];
     var theStyle = menuItem.getAttribute("state");
     if (theStyle) {
       menuItem.setAttribute("checked", theStyle);
     }
@@ -2611,44 +1947,16 @@ function initFontStyleMenu(menuPopup) {
 
 // --------------------------------------------------------------------
 function onButtonUpdate(button, commmandID) {
   var commandNode = document.getElementById(commmandID);
   var state = commandNode.getAttribute("state");
   button.checked = state == "true";
 }
 
-// --------------------------------------------------------------------
-function onStateButtonUpdate(button, commmandID, onState) {
-  var commandNode = document.getElementById(commmandID);
-  var state = commandNode.getAttribute("state");
-
-  button.checked = state == onState;
-}
-
-// --------------------------- Status calls ---------------------------
-function getColorAndSetColorWell(ColorPickerID, ColorWellID) {
-  var colorWell;
-  if (ColorWellID) {
-    colorWell = document.getElementById(ColorWellID);
-  }
-
-  var colorPicker = document.getElementById(ColorPickerID);
-  if (colorPicker) {
-    // Extract color from colorPicker and assign to colorWell.
-    var color = colorPicker.getAttribute("color");
-
-    if (colorWell && color) {
-      // Use setAttribute so colorwell can be a XUL element, such as button
-      colorWell.setAttribute("style", "background-color: " + color);
-    }
-  }
-  return color;
-}
-
 // -----------------------------------------------------------------------------------
 function IsSpellCheckerInstalled() {
   return true; // Always installed.
 }
 
 // -----------------------------------------------------------------------------------
 function IsFindInstalled() {
   return (
@@ -2840,17 +2148,16 @@ function goUpdateTableMenuItems(commands
         commandID == "cmd_JoinTableCells" ||
         commandID == "cmd_SplitTableCell" ||
         commandID == "cmd_ConvertToTable"
       ) {
         // Call the update method in the command class
         goUpdateCommand(commandID);
       } else if (
         commandID == "cmd_DeleteTable" ||
-        commandID == "cmd_NormalizeTable" ||
         commandID == "cmd_editTable" ||
         commandID == "cmd_TableOrCellColor" ||
         commandID == "cmd_SelectTable"
       ) {
         // Directly set with the values calculated here
         goSetCommandEnabled(commandID, enabledIfTable);
       } else {
         goSetCommandEnabled(commandID, enabled);
@@ -3157,247 +2464,16 @@ function SwitchInsertCharToAnotherEditor
         return;
       }
     }
     // Didn't find another editor - close the dialog
     window.InsertCharWindow.close();
   }
 }
 
-function ResetStructToolbar() {
-  gLastFocusNode = null;
-  UpdateStructToolbar();
-}
-
-function newCommandListener(element) {
-  return function() {
-    return SelectFocusNodeAncestor(element);
-  };
-}
-
-function newContextmenuListener(button, element) {
-  /* globals InitStructBarContextMenu */ // SeaMonkey only.
-  return function() {
-    return InitStructBarContextMenu(button, element);
-  };
-}
-
-function UpdateStructToolbar() {
-  var editor = GetCurrentEditor();
-  if (!editor) {
-    return;
-  }
-
-  var mixed = GetSelectionContainer();
-  if (!mixed) {
-    return;
-  }
-  var element = mixed.node;
-  var oneElementSelected = mixed.oneElementSelected;
-
-  if (!element) {
-    return;
-  }
-
-  if (
-    element == gLastFocusNode &&
-    oneElementSelected == gLastFocusNodeWasSelected
-  ) {
-    return;
-  }
-
-  gLastFocusNode = element;
-  gLastFocusNodeWasSelected = mixed.oneElementSelected;
-
-  var toolbar = document.getElementById("structToolbar");
-  if (!toolbar) {
-    return;
-  }
-  // We need to leave the <label> to flex the buttons to the left.
-  for (let node of toolbar.querySelectorAll("toolbarbutton")) {
-    node.remove();
-  }
-
-  toolbar.removeAttribute("label");
-
-  if (IsInHTMLSourceMode()) {
-    // we have destroyed the contents of the status bar and are
-    // about to recreate it ; but we don't want to do that in
-    // Source mode
-    return;
-  }
-
-  var tag, button;
-  var bodyElement = GetBodyElement();
-  var isFocusNode = true;
-  var tmp;
-  do {
-    tag = element.nodeName.toLowerCase();
-
-    button = document.createXULElement("toolbarbutton");
-    button.setAttribute("label", "<" + tag + ">");
-    button.setAttribute("value", tag);
-    button.setAttribute("context", "structToolbarContext");
-    button.className = "struct-button";
-
-    toolbar.insertBefore(button, toolbar.firstElementChild);
-
-    button.addEventListener("command", newCommandListener(element));
-
-    button.addEventListener(
-      "contextmenu",
-      newContextmenuListener(button, element)
-    );
-
-    if (isFocusNode && oneElementSelected) {
-      button.setAttribute("checked", "true");
-      isFocusNode = false;
-    }
-
-    tmp = element;
-    element = element.parentNode;
-  } while (tmp != bodyElement);
-}
-
-function SelectFocusNodeAncestor(element) {
-  var editor = GetCurrentEditor();
-  if (editor) {
-    if (element == GetBodyElement()) {
-      editor.selectAll();
-    } else {
-      editor.selectElement(element);
-    }
-  }
-  ResetStructToolbar();
-}
-
-function GetSelectionContainer() {
-  var editor = GetCurrentEditor();
-  if (!editor) {
-    return null;
-  }
-
-  var selection;
-  try {
-    selection = editor.selection;
-    if (!selection) {
-      return null;
-    }
-  } catch (e) {
-    return null;
-  }
-
-  var result = { oneElementSelected: false };
-
-  if (selection.isCollapsed) {
-    result.node = selection.focusNode;
-  } else {
-    var rangeCount = selection.rangeCount;
-    if (rangeCount == 1) {
-      result.node = editor.getSelectedElement("");
-      var range = selection.getRangeAt(0);
-
-      // check for a weird case : when we select a piece of text inside
-      // a text node and apply an inline style to it, the selection starts
-      // at the end of the text node preceding the style and ends after the
-      // last char of the style. Assume the style element is selected for
-      // user's pleasure
-      if (
-        !result.node &&
-        range.startContainer.nodeType == Node.TEXT_NODE &&
-        range.startOffset == range.startContainer.length &&
-        range.endContainer.nodeType == Node.TEXT_NODE &&
-        range.endOffset == range.endContainer.length &&
-        range.endContainer.nextElementSibling == null &&
-        range.startContainer.nextElementSibling == range.endContainer.parentNode
-      ) {
-        result.node = range.endContainer.parentNode;
-      }
-
-      if (!result.node) {
-        // let's rely on the common ancestor of the selection
-        result.node = range.commonAncestorContainer;
-      } else {
-        result.oneElementSelected = true;
-      }
-    } else {
-      // assume table cells !
-      var i,
-        container = null;
-      for (i = 0; i < rangeCount; i++) {
-        range = selection.getRangeAt(i);
-        if (!container) {
-          container = range.startContainer;
-        } else if (container != range.startContainer) {
-          // all table cells don't belong to same row so let's
-          // select the parent of all rows
-          result.node = container.parentNode;
-          break;
-        }
-        result.node = container;
-      }
-    }
-  }
-
-  // make sure we have an element here
-  while (result.node.nodeType != Node.ELEMENT_NODE) {
-    result.node = result.node.parentNode;
-  }
-
-  // and make sure the element is not a special editor node like
-  // the <br> we insert in blank lines
-  // and don't select anonymous content !!! (fix for bug 190279)
-  while (
-    result.node.hasAttribute("_moz_editor_bogus_node") ||
-    editor.isAnonymousElement(result.node)
-  ) {
-    result.node = result.node.parentNode;
-  }
-
-  return result;
-}
-
-function FillInHTMLTooltipEditor(tooltip) {
-  const XLinkNS = "http://www.w3.org/1999/xlink";
-  var tooltipText = null;
-  var node;
-  if (IsInPreviewMode()) {
-    for (node = document.tooltipNode; node; node = node.parentNode) {
-      if (node.nodeType == Node.ELEMENT_NODE) {
-        tooltipText = node.getAttributeNS(XLinkNS, "title");
-        if (tooltipText && /\S/.test(tooltipText)) {
-          tooltip.setAttribute("label", tooltipText);
-          return true;
-        }
-        tooltipText = node.getAttribute("title");
-        if (tooltipText && /\S/.test(tooltipText)) {
-          tooltip.setAttribute("label", tooltipText);
-          return true;
-        }
-      }
-    }
-  } else {
-    for (node = document.tooltipNode; node; node = node.parentNode) {
-      if (
-        ChromeUtils.getClassName(node) === "HTMLImageElement" ||
-        ChromeUtils.getClassName(node) === "HTMLInputElement"
-      ) {
-        tooltipText = node.getAttribute("src");
-      } else if (ChromeUtils.getClassName(node) === "HTMLAnchorElement") {
-        tooltipText = node.getAttribute("href") || node.getAttribute("name");
-      }
-      if (tooltipText) {
-        tooltip.setAttribute("label", tooltipText);
-        return true;
-      }
-    }
-  }
-  return false;
-}
-
 function UpdateTOC() {
   window.openDialog(
     "chrome://messenger/content/messengercompose/EdInsertTOC.xul",
     "_blank",
     "chrome,close,modal,titlebar"
   );
   window.content.focus();
 }
--- a/mail/components/compose/content/editorUtilities.js
+++ b/mail/components/compose/content/editorUtilities.js
@@ -265,29 +265,21 @@ function IsHTMLEditor() {
 function PageIsEmptyAndUntouched() {
   return IsDocumentEmpty() && !IsDocumentModified() && !IsHTMLSourceChanged();
 }
 
 function IsInHTMLSourceMode() {
   return gEditorDisplayMode == kDisplayModeSource;
 }
 
-function IsInPreviewMode() {
-  return gEditorDisplayMode == kDisplayModePreview;
-}
-
 // are we editing HTML (i.e. neither in HTML source mode, nor editing a text file)
 function IsEditingRenderedHTML() {
   return IsHTMLEditor() && !IsInHTMLSourceMode();
 }
 
-function IsWebComposer() {
-  return document.documentElement.id == "editorWindow";
-}
-
 function IsDocumentEditable() {
   try {
     return GetCurrentEditor().isDocumentEditable;
   } catch (e) {}
   return false;
 }
 
 function IsDocumentEmpty() {
--- a/mail/components/compose/content/messengercompose.xul
+++ b/mail/components/compose/content/messengercompose.xul
@@ -134,40 +134,35 @@
     <command id="cmd_listProperties" oncommand="goDoCommand('cmd_listProperties')"/>
     <command id="cmd_colorProperties" oncommand="goDoCommand('cmd_colorProperties')"/>
 
     <command id="cmd_link" oncommand="goDoCommand('cmd_link')"/>
     <command id="cmd_anchor" oncommand="goDoCommand('cmd_anchor')"/>
     <command id="cmd_image" oncommand="goDoCommand('cmd_image')"/>
     <command id="cmd_hline" oncommand="goDoCommand('cmd_hline')"/>
     <command id="cmd_table" oncommand="goDoCommand('cmd_table')"/>
-    <command id="cmd_isindex" oncommand="goDoCommand('cmd_isindex')"/>
     <command id="cmd_objectProperties" oncommand="goDoCommand('cmd_objectProperties')"/>
     <command id="cmd_insertChars" oncommand="goDoCommand('cmd_insertChars')" label="&insertCharsCmd.label;"/>
     <command id="cmd_insertHTMLWithDialog" oncommand="goDoCommand('cmd_insertHTMLWithDialog')" label="&insertHTMLCmd.label;"/>
     <command id="cmd_insertMathWithDialog" oncommand="goDoCommand('cmd_insertMathWithDialog')" label="&insertMathCmd.label;"/>
 
     <command id="cmd_insertBreak" oncommand="goDoCommand('cmd_insertBreak')"/>
     <command id="cmd_insertBreakAll" oncommand="goDoCommand('cmd_insertBreakAll')"/>
 
-    <!-- only used in context popup menu -->
-    <command id="cmd_editLink" oncommand="goDoCommand('cmd_editLink')"/>
-
     <!-- dummy command used just to disable things in non-HTML modes -->
     <command id="cmd_renderedHTMLEnabler"/>
   </commandset>
 
   <!-- edit menu commands. These get updated by code in globalOverlay.js -->
   <commandset id="composerEditMenuItems"
           commandupdater="true"
           events="create, mode_switch"
           oncommandupdate="goUpdateComposerMenuItems(this)">
     <command id="cmd_pasteNoFormatting" oncommand="goDoCommand('cmd_pasteNoFormatting')"
              label="&pasteNoFormatting.label;" accesskey="&pasteNoFormatting.accesskey;"/>
-    <command id="cmd_preferences" oncommand="goDoCommand('cmd_preferences')"/>
     <command id="cmd_findReplace" oncommand="goDoCommand('cmd_findReplace')"/>
     <command id="cmd_find" oncommand="goDoCommand('cmd_find')"/>
     <command id="cmd_findNext" oncommand="goDoCommand('cmd_findNext');"/>
     <command id="cmd_findPrev" oncommand="goDoCommand('cmd_findPrev');"/>
     <command id="cmd_spelling" oncommand="goDoCommand('cmd_spelling')"/>
     <command id="cmd_pasteQuote" oncommand="goDoCommand('cmd_pasteQuote')" label="&pasteAsQuotationCmd.label;"/>
   </commandset>
 
@@ -206,25 +201,18 @@
     <command id="cmd_paragraphState" state="" oncommand="doStatefulCommand('cmd_paragraphState', event.target.value)"/>
     <command id="cmd_fontFace" state="" oncommand="doStatefulCommand('cmd_fontFace', event.target.value)"/>
 
     <!-- No "oncommand", use EditorSelectColor() to bring up color dialog -->
     <command id="cmd_fontColor" state="" disabled="false"/>
     <command id="cmd_backgroundColor" state="" disabled="false"/>
     <command id="cmd_highlight" state="transparent" oncommand="EditorSelectColor('Highlight', event);"/>
 
-    <command id="cmd_fontSize" oncommand="goDoCommand('cmd_fontSize')"/>
     <command id="cmd_align" state=""/>
 
-    <command id="cmd_absPos" state="" oncommand="goDoCommand('cmd_absPos')"/>
-    <command id="cmd_increaseZIndex" state="" oncommand="goDoCommand('cmd_increaseZIndex')"/>
-    <command id="cmd_decreaseZIndex" state="" oncommand="goDoCommand('cmd_decreaseZIndex')"/>
-
-    <command id="cmd_advancedProperties" oncommand="goDoCommand('cmd_advancedProperties')"/>
-
     <command id="cmd_increaseFontStep" oncommand="goDoCommand('cmd_increaseFontStep')"/>
     <command id="cmd_decreaseFontStep" oncommand="goDoCommand('cmd_decreaseFontStep')"/>
 
     <command id="cmd_removeStyles" oncommand="goDoCommand('cmd_removeStyles')"/>
     <command id="cmd_removeLinks" oncommand="goDoCommand('cmd_removeLinks')"/>
     <command id="cmd_removeNamedAnchors" oncommand="goDoCommand('cmd_removeNamedAnchors')"/>
   </commandset>
 
@@ -245,17 +233,16 @@
     <command id="cmd_InsertColumnAfter" oncommand="goDoCommand('cmd_InsertColumnAfter')"/>
     <command id="cmd_InsertCellBefore" oncommand="goDoCommand('cmd_InsertCellBefore')"/>
     <command id="cmd_InsertCellAfter" oncommand="goDoCommand('cmd_InsertCellAfter')"/>
     <command id="cmd_DeleteTable" oncommand="goDoCommand('cmd_DeleteTable')"/>
     <command id="cmd_DeleteRow" oncommand="goDoCommand('cmd_DeleteRow')"/>
     <command id="cmd_DeleteColumn" oncommand="goDoCommand('cmd_DeleteColumn')"/>
     <command id="cmd_DeleteCell" oncommand="goDoCommand('cmd_DeleteCell')"/>
     <command id="cmd_DeleteCellContents" oncommand="goDoCommand('cmd_DeleteCellContents')"/>
-    <command id="cmd_NormalizeTable" oncommand="goDoCommand('cmd_NormalizeTable')"/>
     <command id="cmd_JoinTableCells" oncommand="goDoCommand('cmd_JoinTableCells')"/>
     <command id="cmd_SplitTableCell" oncommand="goDoCommand('cmd_SplitTableCell')"/>
     <command id="cmd_ConvertToTable" oncommand="goDoCommand('cmd_ConvertToTable')"/>
     <command id="cmd_TableOrCellColor" oncommand="goDoCommand('cmd_TableOrCellColor')"/>
     <command id="cmd_editTable" oncommand="goDoCommand('cmd_editTable')"/>
   </commandset>
 
   <!-- commands updated only when the menu gets created -->