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