michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef AggregatePlaceholderTxn_h__ michael@0: #define AggregatePlaceholderTxn_h__ michael@0: michael@0: #include "EditAggregateTxn.h" michael@0: #include "nsEditorUtils.h" michael@0: #include "nsIAbsorbingTransaction.h" michael@0: #include "nsIDOMNode.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsWeakPtr.h" michael@0: #include "nsWeakReference.h" michael@0: #include "nsAutoPtr.h" michael@0: michael@0: class nsHTMLEditor; michael@0: class IMETextTxn; michael@0: michael@0: /** michael@0: * An aggregate transaction that knows how to absorb all subsequent michael@0: * transactions with the same name. This transaction does not "Do" anything. michael@0: * But it absorbs other transactions via merge, and can undo/redo the michael@0: * transactions it has absorbed. michael@0: */ michael@0: michael@0: class PlaceholderTxn : public EditAggregateTxn, michael@0: public nsIAbsorbingTransaction, michael@0: public nsSupportsWeakReference michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: michael@0: PlaceholderTxn(); michael@0: michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PlaceholderTxn, EditAggregateTxn) michael@0: // ------------ EditAggregateTxn ----------------------- michael@0: michael@0: NS_DECL_EDITTXN michael@0: michael@0: NS_IMETHOD RedoTransaction(); michael@0: NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge); michael@0: michael@0: // ------------ nsIAbsorbingTransaction ----------------------- michael@0: michael@0: NS_IMETHOD Init(nsIAtom* aName, nsSelectionState* aSelState, michael@0: nsEditor* aEditor); michael@0: michael@0: NS_IMETHOD GetTxnName(nsIAtom **aName); michael@0: michael@0: NS_IMETHOD StartSelectionEquals(nsSelectionState *aSelState, bool *aResult); michael@0: michael@0: NS_IMETHOD EndPlaceHolderBatch(); michael@0: michael@0: NS_IMETHOD ForwardEndBatchTo(nsIAbsorbingTransaction *aForwardingAddress); michael@0: michael@0: NS_IMETHOD Commit(); michael@0: michael@0: NS_IMETHOD RememberEndingSelection(); michael@0: michael@0: protected: michael@0: michael@0: /** the presentation shell, which we'll need to get the selection */ michael@0: bool mAbsorb; // do we auto absorb any and all transaction? michael@0: nsWeakPtr mForwarding; michael@0: IMETextTxn *mIMETextTxn; // first IME txn in this placeholder - used for IME merging michael@0: // non-owning for now - can't nsCOMPtr it due to broken transaction interfaces michael@0: bool mCommitted; // do we stop auto absorbing any matching placeholder txns? michael@0: // these next two members store the state of the selection in a safe way. michael@0: // selection at the start of the txn is stored, as is the selection at the end. michael@0: // This is so that UndoTransaction() and RedoTransaction() can restore the michael@0: // selection properly. michael@0: nsAutoPtr mStartSel; // use a pointer because this is constructed before we exist michael@0: nsSelectionState mEndSel; michael@0: nsEditor* mEditor; /** the editor for this transaction */ michael@0: }; michael@0: michael@0: michael@0: #endif