|
@@ -0,0 +1,259 @@
|
|
|
|
+# HG changeset patch
|
|
|
|
+# User Masayuki Nakano <masayuki@d-toybox.com>
|
|
|
|
+# Date 1666394157 -32400
|
|
|
|
+# Sat Oct 22 08:15:57 2022 +0900
|
|
|
|
+# Node ID 45657f44c0ee1499193db749f2959ef8227578a6
|
|
|
|
+# Parent d266139e07df9cc8cac0426dae8ba157f7261d5f
|
|
|
|
+Bug 1792764 - Make comm-central stop using `nsIEditor.transactionManager` since it'll be removed
|
|
|
|
+
|
|
|
|
+`nsIEditor.transactionManager` will be removed soon and its user is now only
|
|
|
|
+SeaMonkey which want it to clear undo/redo transactions of editors. For doing
|
|
|
|
+that, we can use `nsIEditor.clearUndoRedo()` now.
|
|
|
|
+
|
|
|
|
+Note that the purpose of `ExecuteJSTransactionViaTxmgr()` will be invalid
|
|
|
|
+after `nsIEditor.transactionManager` is removed. Therefore, this patch removes
|
|
|
|
+it and the UI to run it too.
|
|
|
|
+
|
|
|
|
+diff --git a/suite/components/bindings/textbox.xml b/suite/components/bindings/textbox.xml
|
|
|
|
+--- a/suite/components/bindings/textbox.xml
|
|
|
|
++++ b/suite/components/bindings/textbox.xml
|
|
|
|
+@@ -91,21 +91,21 @@
|
|
|
|
+ }
|
|
|
|
+ return this.mEditor;
|
|
|
|
+ ]]></getter>
|
|
|
|
+ </property>
|
|
|
|
+
|
|
|
|
+ <method name="reset">
|
|
|
|
+ <body><![CDATA[
|
|
|
|
+ this.value = this.defaultValue;
|
|
|
|
+- try {
|
|
|
|
+- this.editor.transactionManager.clear();
|
|
|
|
+- return true;
|
|
|
|
+- } catch (e) {}
|
|
|
|
+- return false;
|
|
|
|
++ if (!this.editor) {
|
|
|
|
++ return false;
|
|
|
|
++ }
|
|
|
|
++ this.editor.clearUndoRedo();
|
|
|
|
++ return true;
|
|
|
|
+ ]]></body>
|
|
|
|
+ </method>
|
|
|
|
+
|
|
|
|
+ <method name="select">
|
|
|
|
+ <body>
|
|
|
|
+ this.inputField.select();
|
|
|
|
+ </body>
|
|
|
|
+ </method>
|
|
|
|
+diff --git a/suite/components/places/content/editBookmarkOverlay.js b/suite/components/places/content/editBookmarkOverlay.js
|
|
|
|
+--- a/suite/components/places/content/editBookmarkOverlay.js
|
|
|
|
++++ b/suite/components/places/content/editBookmarkOverlay.js
|
|
|
|
+@@ -353,33 +353,18 @@ var gEditItemOverlay = {
|
|
|
|
+ }
|
|
|
|
+ return this._paneInfo._cachedCommonTags = [...commonTags];
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ _initTextField(aElement, aValue) {
|
|
|
|
+ if (aElement.value != aValue) {
|
|
|
|
+ aElement.value = aValue;
|
|
|
|
+
|
|
|
|
+- // Clear the editor's undo stack
|
|
|
|
+- let transactionManager;
|
|
|
|
+- try {
|
|
|
|
+- transactionManager = aElement.editor.transactionManager;
|
|
|
|
+- } catch (e) {
|
|
|
|
+- // When retrieving the transaction manager, editor may be null resulting
|
|
|
|
+- // in a TypeError. Additionally, the transaction manager may not
|
|
|
|
+- // exist yet, which causes access to it to throw NS_ERROR_FAILURE.
|
|
|
|
+- // In either event, the transaction manager doesn't exist it, so we
|
|
|
|
+- // don't need to worry about clearing it.
|
|
|
|
+- if (!(e instanceof TypeError) && e.result != Cr.NS_ERROR_FAILURE) {
|
|
|
|
+- throw e;
|
|
|
|
+- }
|
|
|
|
+- }
|
|
|
|
+- if (transactionManager) {
|
|
|
|
+- transactionManager.clear();
|
|
|
|
+- }
|
|
|
|
++ // Clear the editor's undo stack, but note that editor may be null here.
|
|
|
|
++ aElement.editor?.clearUndoRedo();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Appends a menu-item representing a bookmarks folder to a menu-popup.
|
|
|
|
+ * @param aMenupopup
|
|
|
|
+ * The popup to which the menu-item should be added.
|
|
|
|
+ * @param aFolderId
|
|
|
|
+diff --git a/suite/editor/base/content/ComposerCommands.js b/suite/editor/base/content/ComposerCommands.js
|
|
|
|
+--- a/suite/editor/base/content/ComposerCommands.js
|
|
|
|
++++ b/suite/editor/base/content/ComposerCommands.js
|
|
|
|
+@@ -1229,17 +1229,17 @@ var gEditorOutputProgressListener = {
|
|
|
|
+
|
|
|
|
+ // Restore original document to undo image src url adjustments
|
|
|
|
+ if (gRestoreDocumentSource) {
|
|
|
|
+ try {
|
|
|
|
+ editor.rebuildDocumentFromSource(gRestoreDocumentSource);
|
|
|
|
+
|
|
|
|
+ // Clear transaction cache since we just did a potentially
|
|
|
|
+ // very large insert and this will eat up memory
|
|
|
|
+- editor.transactionManager.clear();
|
|
|
|
++ editor.clearUndoRedo();
|
|
|
|
+ } catch (e) {}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Notify progress dialog that we're finished
|
|
|
|
+ // and keep open to show error
|
|
|
|
+ gProgressDialog.SetProgressFinished(null, 0);
|
|
|
|
+
|
|
|
|
+ // We don't want to change location or reset mod count, etc.
|
|
|
|
+diff --git a/suite/editor/base/content/editor.js b/suite/editor/base/content/editor.js
|
|
|
|
+--- a/suite/editor/base/content/editor.js
|
|
|
|
++++ b/suite/editor/base/content/editor.js
|
|
|
|
+@@ -1846,56 +1846,54 @@ function SetEditMode(mode) {
|
|
|
|
+ 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.clearUndoRedo();
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
++ editor.rebuildDocumentFromSource(source); // This is undoable
|
|
|
|
+ } 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);
|
|
|
|
++ // We touched the DOM tree without transaction here so that we broke
|
|
|
|
++ // undoable transactions. However, we cleared all undoable things
|
|
|
|
++ // above. Therefore nothing must be in the undo stack.
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 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);
|
|
|
|
+ }
|
|
|
|
++ // If the MIME type is kXHTMLMimeType, we don't put any undoable
|
|
|
|
++ // transaction. Then, this endTransaction() call does not allow to
|
|
|
|
++ // live empty transaction. Therefore, the unnecessary empty transaction
|
|
|
|
++ // will be cleared here automatically.
|
|
|
|
+ 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);
|
|
|
|
+diff --git a/suite/extensions/debugQA/content/debugQAEditorOverlay.js b/suite/extensions/debugQA/content/debugQAEditorOverlay.js
|
|
|
|
+--- a/suite/extensions/debugQA/content/debugQAEditorOverlay.js
|
|
|
|
++++ b/suite/extensions/debugQA/content/debugQAEditorOverlay.js
|
|
|
|
+@@ -173,37 +173,16 @@ sampleJSTransaction.prototype = {
|
|
|
|
+
|
|
|
|
+ if (childList.length == 0 || offset >= childList.length)
|
|
|
|
+ container.appendChild(node);
|
|
|
|
+ else
|
|
|
|
+ container.insertBefore(node, childList.item(offset));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+-function ExecuteJSTransactionViaTxmgr()
|
|
|
|
+-{
|
|
|
|
+- try {
|
|
|
|
+- var editor = GetCurrentEditor();
|
|
|
|
+- var txmgr = editor.transactionManager;
|
|
|
|
+- txmgr = txmgr.QueryInterface(Ci.nsITransactionManager);
|
|
|
|
+-
|
|
|
|
+- var selection = editor.selection;
|
|
|
|
+- var range = selection.getRangeAt(0);
|
|
|
|
+-
|
|
|
|
+- var txn = new sampleJSTransaction();
|
|
|
|
+-
|
|
|
|
+- txn.mContainer = range.startContainer;
|
|
|
|
+- txn.mOffset = range.startOffset;
|
|
|
|
+-
|
|
|
|
+- txmgr.doTransaction(txn);
|
|
|
|
+- } catch (e) {
|
|
|
|
+- dump("ExecuteJSTransactionViaTxmgr() failed!");
|
|
|
|
+- }
|
|
|
|
+-}
|
|
|
|
+-
|
|
|
|
+ function ExecuteJSTransactionViaEditor()
|
|
|
|
+ {
|
|
|
|
+ try {
|
|
|
|
+ var editor = GetCurrentEditor();
|
|
|
|
+
|
|
|
|
+ var selection = editor.selection;
|
|
|
|
+ var range = selection.getRangeAt(0);
|
|
|
|
+
|
|
|
|
+diff --git a/suite/extensions/debugQA/content/debugQAEditorOverlay.xul b/suite/extensions/debugQA/content/debugQAEditorOverlay.xul
|
|
|
|
+--- a/suite/extensions/debugQA/content/debugQAEditorOverlay.xul
|
|
|
|
++++ b/suite/extensions/debugQA/content/debugQAEditorOverlay.xul
|
|
|
|
+@@ -29,18 +29,16 @@
|
|
|
|
+ <menuitem label="&insertTextCmd.label;"
|
|
|
|
+ oncommand="EditorInsertText('All good things come to those who wait. ')"/>
|
|
|
|
+ <menuseparator/>
|
|
|
|
+ <menuitem label="&testSelectionCmd.label;"
|
|
|
|
+ oncommand="EditorTestSelection()"/>
|
|
|
|
+ <menuitem label="&testDocumentCmd.label;"
|
|
|
|
+ oncommand="EditorTestDocument()"/>
|
|
|
|
+ <menuseparator/>
|
|
|
|
+- <menuitem label="&executeJSTransactionViaTxmgr.label;"
|
|
|
|
+- oncommand="ExecuteJSTransactionViaTxmgr()"/>
|
|
|
|
+ <menuitem label="&executeJSTransactionViaEditor.label;"
|
|
|
|
+ oncommand="ExecuteJSTransactionViaEditor()"/>
|
|
|
|
+ <menuseparator/>
|
|
|
|
+ <menuitem label="&setFocusCmd.label;"
|
|
|
|
+ oncommand="window.focus()"/>
|
|
|
|
+ </menupopup>
|
|
|
|
+ </menu>
|
|
|
|
+ </menubar>
|
|
|
|
+diff --git a/suite/extensions/debugQA/locales/en-US/debugQAEditorOverlay.dtd b/suite/extensions/debugQA/locales/en-US/debugQAEditorOverlay.dtd
|
|
|
|
+--- a/suite/extensions/debugQA/locales/en-US/debugQAEditorOverlay.dtd
|
|
|
|
++++ b/suite/extensions/debugQA/locales/en-US/debugQAEditorOverlay.dtd
|
|
|
|
+@@ -11,16 +11,15 @@
|
|
|
|
+ <!ENTITY debugMenu.label "Debug">
|
|
|
|
+ <!ENTITY newEditorTestPage.label "Composer with Test Page">
|
|
|
|
+ <!ENTITY textEditorCmd.label "Plaintext Editor">
|
|
|
|
+ <!ENTITY outputTextCmd.label "Output Text">
|
|
|
|
+ <!ENTITY outputHTMLCmd.label "Output HTML">
|
|
|
|
+ <!ENTITY insertTextCmd.label "Insert Text">
|
|
|
|
+ <!ENTITY testSelectionCmd.label "Test Selection">
|
|
|
|
+ <!ENTITY testDocumentCmd.label "Test Document">
|
|
|
|
+-<!ENTITY executeJSTransactionViaTxmgr.label "Execute JS Transaction Via Transaction Manager">
|
|
|
|
+ <!ENTITY executeJSTransactionViaEditor.label "Execute JS Transaction Via Editor">
|
|
|
|
+ <!ENTITY setFocusCmd.label "Set Focus">
|
|
|
|
+
|
|
|
|
+ <!-- Text editor values -->
|
|
|
|
+ <!ENTITY textEditorWindow.titlemodifier "Text Editor">
|
|
|
|
+
|
|
|
|
+ <!ENTITY statusText.label "Done loading page">
|