to make safe and // easy to implement "Undo" an unknown number of transactions (including 0), // "above" beginBatch and endBatch. Otherwise,implementing Undo that way // head to dataloss: for example, if no changes were done in the // edit-item panel, the last transaction on the undo stack would be the // initial createItem transaction, or even worse, the batched editing of // some other item. // DO NOT MOVE this to the window scope, that would leak (bug 490068)! this.doTransaction({ doTransaction: function() { }, undoTransaction: function() { }, redoTransaction: function() { }, isTransient: false, merge: function() { return false; } }); }, endBatch: function() this.mTransactionManager.endBatch(), doTransaction: function placesTxn_doTransaction(txn) { this.mTransactionManager.doTransaction(txn); this._updateCommands(); }, undoTransaction: function placesTxn_undoTransaction() { this.mTransactionManager.undoTransaction(); this._updateCommands(); }, redoTransaction: function placesTxn_redoTransaction() { this.mTransactionManager.redoTransaction(); this._updateCommands(); }, clear: function() this.mTransactionManager.clear(), get numberOfUndoItems() { return this.mTransactionManager.numberOfUndoItems; }, get numberOfRedoItems() { return this.mTransactionManager.numberOfRedoItems; }, get maxTransactionCount() { return this.mTransactionManager.maxTransactionCount; }, set maxTransactionCount(val) { return this.mTransactionManager.maxTransactionCount = val; }, peekUndoStack: function() this.mTransactionManager.peekUndoStack(), peekRedoStack: function() this.mTransactionManager.peekRedoStack(), getUndoStack: function() this.mTransactionManager.getUndoStack(), getRedoStack: function() this.mTransactionManager.getRedoStack(), AddListener: function(l) this.mTransactionManager.AddListener(l), RemoveListener: function(l) this.mTransactionManager.RemoveListener(l) }; /** * Method and utility stubs for Places Edit Transactions */ function placesBaseTransaction() { } placesBaseTransaction.prototype = { // for child-transactions get wrappedJSObject() { return this; }, // nsITransaction redoTransaction: function PBT_redoTransaction() { throw Cr.NS_ERROR_NOT_IMPLEMENTED; }, get isTransient() { return false; }, merge: function mergeFunc(transaction) { return false; }, // nsISupports QueryInterface: XPCOMUtils.generateQI([Ci.nsITransaction]), }; function placesAggregateTransactions(name, transactions) { this._transactions = transactions; this._name = name; this.container = -1; this.redoTransaction = this.doTransaction; // Check child transactions number. We will batch if we have more than // MIN_TRANSACTIONS_FOR_BATCH total number of transactions. var countTransactions = function(aTransactions, aTxnCount) { for (let i = 0; i < aTransacti