editor/libeditor/base/PlaceholderTxn.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 #ifndef AggregatePlaceholderTxn_h__
michael@0 7 #define AggregatePlaceholderTxn_h__
michael@0 8
michael@0 9 #include "EditAggregateTxn.h"
michael@0 10 #include "nsEditorUtils.h"
michael@0 11 #include "nsIAbsorbingTransaction.h"
michael@0 12 #include "nsIDOMNode.h"
michael@0 13 #include "nsCOMPtr.h"
michael@0 14 #include "nsWeakPtr.h"
michael@0 15 #include "nsWeakReference.h"
michael@0 16 #include "nsAutoPtr.h"
michael@0 17
michael@0 18 class nsHTMLEditor;
michael@0 19 class IMETextTxn;
michael@0 20
michael@0 21 /**
michael@0 22 * An aggregate transaction that knows how to absorb all subsequent
michael@0 23 * transactions with the same name. This transaction does not "Do" anything.
michael@0 24 * But it absorbs other transactions via merge, and can undo/redo the
michael@0 25 * transactions it has absorbed.
michael@0 26 */
michael@0 27
michael@0 28 class PlaceholderTxn : public EditAggregateTxn,
michael@0 29 public nsIAbsorbingTransaction,
michael@0 30 public nsSupportsWeakReference
michael@0 31 {
michael@0 32 public:
michael@0 33 NS_DECL_ISUPPORTS_INHERITED
michael@0 34
michael@0 35 PlaceholderTxn();
michael@0 36
michael@0 37 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PlaceholderTxn, EditAggregateTxn)
michael@0 38 // ------------ EditAggregateTxn -----------------------
michael@0 39
michael@0 40 NS_DECL_EDITTXN
michael@0 41
michael@0 42 NS_IMETHOD RedoTransaction();
michael@0 43 NS_IMETHOD Merge(nsITransaction *aTransaction, bool *aDidMerge);
michael@0 44
michael@0 45 // ------------ nsIAbsorbingTransaction -----------------------
michael@0 46
michael@0 47 NS_IMETHOD Init(nsIAtom* aName, nsSelectionState* aSelState,
michael@0 48 nsEditor* aEditor);
michael@0 49
michael@0 50 NS_IMETHOD GetTxnName(nsIAtom **aName);
michael@0 51
michael@0 52 NS_IMETHOD StartSelectionEquals(nsSelectionState *aSelState, bool *aResult);
michael@0 53
michael@0 54 NS_IMETHOD EndPlaceHolderBatch();
michael@0 55
michael@0 56 NS_IMETHOD ForwardEndBatchTo(nsIAbsorbingTransaction *aForwardingAddress);
michael@0 57
michael@0 58 NS_IMETHOD Commit();
michael@0 59
michael@0 60 NS_IMETHOD RememberEndingSelection();
michael@0 61
michael@0 62 protected:
michael@0 63
michael@0 64 /** the presentation shell, which we'll need to get the selection */
michael@0 65 bool mAbsorb; // do we auto absorb any and all transaction?
michael@0 66 nsWeakPtr mForwarding;
michael@0 67 IMETextTxn *mIMETextTxn; // first IME txn in this placeholder - used for IME merging
michael@0 68 // non-owning for now - can't nsCOMPtr it due to broken transaction interfaces
michael@0 69 bool mCommitted; // do we stop auto absorbing any matching placeholder txns?
michael@0 70 // these next two members store the state of the selection in a safe way.
michael@0 71 // selection at the start of the txn is stored, as is the selection at the end.
michael@0 72 // This is so that UndoTransaction() and RedoTransaction() can restore the
michael@0 73 // selection properly.
michael@0 74 nsAutoPtr<nsSelectionState> mStartSel; // use a pointer because this is constructed before we exist
michael@0 75 nsSelectionState mEndSel;
michael@0 76 nsEditor* mEditor; /** the editor for this transaction */
michael@0 77 };
michael@0 78
michael@0 79
michael@0 80 #endif

mercurial