From 17684ebc83ffe6edba1e4dc4397be16b0668f108 Mon Sep 17 00:00:00 2001
From: "timeless%mozdev.org"
Date: Tue, 23 Nov 2004 18:58:14 +0000
Subject: [PATCH] Bug 179621 Inspector should use Editor's TransactionManager
model patch by ajvincent@gmail.com r=roc sr=roc
---
.../inspector/resources/content/inspector.xml | 148 ++++++++++++++----
.../inspector/resources/content/utils.js | 30 ++++
2 files changed, 149 insertions(+), 29 deletions(-)
diff --git a/extensions/inspector/resources/content/inspector.xml b/extensions/inspector/resources/content/inspector.xml
index ae64c3360f7d..263e6aa2fb52 100644
--- a/extensions/inspector/resources/content/inspector.xml
+++ b/extensions/inspector/resources/content/inspector.xml
@@ -130,9 +130,13 @@
var enabled;
if (aCommand == "cmdEditUndo")
enabled = this.mCommandPtr >= 0;
- else if (aCommand == "cmdEditRedo")
+ else if (aCommand == "cmdEditRedo") {
enabled = this.mCommandPtr+1 < this.mCommandStack.length;
- else {
+ if (!enabled && (this.mCommandPtr > -1)) {
+ var lastCmd = this.mCommandStack[this.mCommandPtr];
+ enabled = ((lastCmd instanceof nsITransactionManager) && (lastCmd.numberOfRedoItems > 0));
+ }
+ } else {
if (this.focusedPanel && this.focusedPanel.viewer) {
enabled = this.focusedPanel.viewer.isCommandEnabled(aCommand);
}
@@ -178,6 +182,14 @@
]]>
= 0) {
var command = this.mCommandStack[this.mCommandPtr];
- --this.mCommandPtr;
-
- //try {
- command.undoCommand();
- /*} catch (ex) {
- dump("Unable to successfully undo command.\n");
- return;
- }*/
+ if ((command instanceof nsITransactionManager) && (command.numberOfUndoItems > 0)) {
+ command.undoTransaction();
+ if (command.numberOfUndoItems == 0) {
+ --this.mCommandPtr;
+ }
+ } else {
+ --this.mCommandPtr;
+ //try {
+ command.undoCommand();
+ /*} catch (ex) {
+ dump("Unable to successfully undo command.\n");
+ return;
+ }*/
+ }
this.updateCommand("cmdEditUndo");
this.updateCommand("cmdEditRedo");
@@ -267,14 +305,27 @@
= -1) {
- ++this.mCommandPtr;
- var command = this.mCommandStack[this.mCommandPtr];
- try {
- command.doCommand();
- } catch (ex) {
- dump("Unable to successfully redo command.\n");
- return;
+ if (!((command instanceof nsITransactionManager)&&(command.numberOfRedoItems > 0))) {
+ ++this.mCommandPtr;
+ command = this.mCommandStack[this.mCommandPtr];
+ }
+
+ if ((command instanceof nsITransactionManager)&&(command.numberOfRedoItems > 0)) {
+ command.redoTransaction();
+ } else {
+ try {
+ command.doCommand();
+ } catch (ex) {
+ dump("Unable to successfully redo command.\n");
+ return;
+ }
}
this.updateCommand("cmdEditUndo");
this.updateCommand("cmdEditRedo");
@@ -285,9 +336,48 @@
1) {
+ constructor.prototype.txnType = arguments[1];
+ } else {
+ constructor.prototype.txnType = "standard";
+ }
+ if (arguments.length > 2) {
+ constructor.prototype.isTransient = arguments[2];
+ } else {
+ constructor.prototype.isTransient = false;
+ }
+}
+ConvertCommandToTxn.txnQueryInterface = function(theUID, theResult) {
+ if (theUID == Components.interfaces.nsITransaction || theUID == Components.interfaces.nsISupports) {
+ return this;
+ }
+ return null;
+}
+ConvertCommandToTxn.txnMerge = function() {
+ return false;
+}