From 3774e91cf064aed9af78ff855463ef0891d842e2 Mon Sep 17 00:00:00 2001 From: Khushil Mistry Date: Fri, 13 Sep 2019 18:01:02 +0200 Subject: [PATCH] Bug 1581090 - remove EdInputImage.xul and related JS and DTD files from compose directory. r=mkmelin --- .../compose/content/ComposerCommands.js | 24 --- .../compose/content/dialogs/EdInputImage.js | 189 ------------------ .../compose/content/dialogs/EdInputImage.xul | 104 ---------- .../compose/content/messengercompose.xul | 1 - mail/components/compose/jar.mn | 2 - .../EditorInputProperties.dtd | 50 ----- mail/locales/jar.mn | 1 - 7 files changed, 371 deletions(-) delete mode 100644 mail/components/compose/content/dialogs/EdInputImage.js delete mode 100644 mail/components/compose/content/dialogs/EdInputImage.xul delete mode 100644 mail/locales/en-US/chrome/messenger/messengercompose/EditorInputProperties.dtd diff --git a/mail/components/compose/content/ComposerCommands.js b/mail/components/compose/content/ComposerCommands.js index 4f36446e6c..203f8dd289 100644 --- a/mail/components/compose/content/ComposerCommands.js +++ b/mail/components/compose/content/ComposerCommands.js @@ -47,7 +47,6 @@ function SetupHTMLEditorCommands() { ); commandTable.registerCommand("cmd_editLink", nsEditLinkCommand); - commandTable.registerCommand("cmd_inputimage", nsInputImageCommand); commandTable.registerCommand("cmd_isindex", nsIsIndexCommand); commandTable.registerCommand("cmd_image", nsImageCommand); commandTable.registerCommand("cmd_hline", nsHLineCommand); @@ -2637,23 +2636,6 @@ var nsValidateCommand = { }, }; -var nsInputImageCommand = { - isCommandEnabled(aCommand, dummy) { - return IsDocumentEditable() && IsEditingRenderedHTML(); - }, - - getCommandStateParams(aCommand, aParams, aRefCon) {}, - doCommandParams(aCommand, aParams, aRefCon) {}, - - doCommand(aCommand) { - window.openDialog( - "chrome://messenger/content/messengercompose/EdInputImage.xul", - "_blank", - "chrome,close,titlebar,modal" - ); - }, -}; - var nsIsIndexCommand = { isCommandEnabled(aCommand, dummy) { return IsDocumentEditable() && IsEditingRenderedHTML(); @@ -2928,12 +2910,6 @@ var nsObjectPropertiesCommand = { case "hr": goDoCommand("cmd_hline"); break; - case "input": - var type = element.getAttribute("type"); - if (type && type.toLowerCase() == "image") { - goDoCommand("cmd_inputimage"); - } - break; case "table": EditorInsertOrEditTable(false); break; diff --git a/mail/components/compose/content/dialogs/EdInputImage.js b/mail/components/compose/content/dialogs/EdInputImage.js deleted file mode 100644 index 860ae1428c..0000000000 --- a/mail/components/compose/content/dialogs/EdInputImage.js +++ /dev/null @@ -1,189 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* import-globals-from ../editorUtilities.js */ -/* import-globals-from EdDialogCommon.js */ -/* import-globals-from EdImageDialog.js */ - -// dialog initialization code - -document.addEventListener("dialogaccept", onAccept); -document.addEventListener("dialogcancel", onCancel); - -function Startup() { - var editor = GetCurrentEditor(); - if (!editor) { - window.close(); - return; - } - - gDialog = { - inputName: document.getElementById("InputName"), - inputDisabled: document.getElementById("InputDisabled"), - inputTabIndex: document.getElementById("InputTabIndex"), - }; - - ImageStartup(); - - // Get a single selected input element - var tagName = "input"; - try { - imageElement = editor.getSelectedElement(tagName); - } catch (e) {} - - if (imageElement) { - // We found an element and don't need to insert one - gInsertNewImage = false; - } else { - gInsertNewImage = true; - - // We don't have an element selected, - // so create one with default attributes - try { - imageElement = editor.createElementWithDefaults(tagName); - } catch (e) {} - - if (!imageElement) { - dump("Failed to get selected element or create a new one!\n"); - window.close(); - return; - } - var imgElement; - try { - imgElement = editor.getSelectedElement("img"); - } catch (e) {} - - if (imgElement) { - // We found an image element, convert it to an input type="image" - var attributes = [ - "src", - "alt", - "width", - "height", - "hspace", - "vspace", - "border", - "align", - "usemap", - "ismap", - ]; - for (let i in attributes) { - imageElement.setAttribute( - attributes[i], - imgElement.getAttribute(attributes[i]) - ); - } - } - } - - // Make a copy to use for AdvancedEdit - globalElement = imageElement.cloneNode(false); - - // We only need to test for this once per dialog load - gHaveDocumentUrl = GetDocumentBaseUrl(); - - InitDialog(); - - // Save initial source URL - gOriginalSrc = gDialog.srcInput.value; - - // By default turn constrain on, but both width and height must be in pixels - gDialog.constrainCheckbox.checked = - gDialog.widthUnitsMenulist.selectedIndex == 0 && - gDialog.heightUnitsMenulist.selectedIndex == 0; - - SetTextboxFocus(gDialog.inputName); - - SetWindowLocation(); -} - -function InitDialog() { - InitImage(); - gDialog.inputName.value = globalElement.getAttribute("name"); - gDialog.inputDisabled.setAttribute( - "checked", - globalElement.hasAttribute("disabled") - ); - gDialog.inputTabIndex.value = globalElement.getAttribute("tabindex"); -} - -function ValidateData() { - if (!ValidateImage()) { - return false; - } - if (gDialog.inputName.value) { - globalElement.setAttribute("name", gDialog.inputName.value); - } else { - globalElement.removeAttribute("name"); - } - if (gDialog.inputTabIndex.value) { - globalElement.setAttribute("tabindex", gDialog.inputTabIndex.value); - } else { - globalElement.removeAttribute("tabindex"); - } - if (gDialog.inputDisabled.checked) { - globalElement.setAttribute("disabled", ""); - } else { - globalElement.removeAttribute("disabled"); - } - globalElement.setAttribute("type", "image"); - return true; -} - -function onAccept(event) { - // Show alt text error only once - // (we don't initialize doAltTextError=true - // so Advanced edit button dialog doesn't trigger that error message) - // Use this now (default = false) so Advanced Edit button dialog doesn't trigger error message - gDoAltTextError = true; - - if (ValidateData()) { - var editor = GetCurrentEditor(); - editor.beginTransaction(); - - try { - if (gRemoveImageMap) { - globalElement.removeAttribute("usemap"); - if (gImageMap) { - editor.deleteNode(gImageMap); - gInsertNewIMap = true; - gImageMap = null; - } - } else if (gImageMap) { - // Assign to map if there is one - var mapName = gImageMap.getAttribute("name"); - if (mapName != "") { - globalElement.setAttribute("usemap", "#" + mapName); - if (globalElement.getAttribute("border") == "") { - globalElement.setAttribute("border", 0); - } - } - } - - if (gInsertNewImage) { - // 'true' means delete the selection before inserting - // in case were are converting an image to an input type="image" - editor.insertElementAtSelection(imageElement, true); - } - editor.cloneAttributes(imageElement, globalElement); - - // If document is empty, the map element won't insert, - // so always insert the image element first - if (gImageMap && gInsertNewIMap) { - // Insert the ImageMap element at beginning of document - var body = editor.rootElement; - editor.setShouldTxnSetSelection(false); - editor.insertNode(gImageMap, body, 0); - editor.setShouldTxnSetSelection(true); - } - } catch (e) {} - - editor.endTransaction(); - - SaveWindowLocation(); - - return; - } - event.preventDefault(); -} diff --git a/mail/components/compose/content/dialogs/EdInputImage.xul b/mail/components/compose/content/dialogs/EdInputImage.xul deleted file mode 100644 index ce7d4870af..0000000000 --- a/mail/components/compose/content/dialogs/EdInputImage.xul +++ /dev/null @@ -1,104 +0,0 @@ - -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - - - - - -%edInputProperties; - -%edImageProperties; - -%composeEditorOverlayDTD; - -%edDialogOverlay; -]> - - - -