|
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 ChangeAttributeTxn_h__ |
|
7 #define ChangeAttributeTxn_h__ |
|
8 |
|
9 #include "EditTxn.h" |
|
10 #include "nsCOMPtr.h" |
|
11 #include "nsCycleCollectionParticipant.h" |
|
12 #include "nsIDOMElement.h" |
|
13 #include "nsISupportsImpl.h" |
|
14 #include "nsString.h" |
|
15 #include "nscore.h" |
|
16 |
|
17 class nsIEditor; |
|
18 |
|
19 /** |
|
20 * A transaction that changes an attribute of a content node. |
|
21 * This transaction covers add, remove, and change attribute. |
|
22 */ |
|
23 class ChangeAttributeTxn : public EditTxn |
|
24 { |
|
25 public: |
|
26 /** Initialize the transaction. |
|
27 * @param aEditor the object providing core editing operations |
|
28 * @param aNode the node whose attribute will be changed |
|
29 * @param aAttribute the name of the attribute to change |
|
30 * @param aValue the new value for aAttribute, if aRemoveAttribute is false |
|
31 * @param aRemoveAttribute if true, remove aAttribute from aNode |
|
32 */ |
|
33 NS_IMETHOD Init(nsIEditor *aEditor, |
|
34 nsIDOMElement *aNode, |
|
35 const nsAString& aAttribute, |
|
36 const nsAString& aValue, |
|
37 bool aRemoveAttribute); |
|
38 |
|
39 ChangeAttributeTxn(); |
|
40 |
|
41 NS_DECL_ISUPPORTS_INHERITED |
|
42 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ChangeAttributeTxn, EditTxn) |
|
43 |
|
44 NS_DECL_EDITTXN |
|
45 |
|
46 NS_IMETHOD RedoTransaction(); |
|
47 |
|
48 protected: |
|
49 |
|
50 /** the editor that created this transaction */ |
|
51 nsIEditor* mEditor; |
|
52 |
|
53 /** the element to operate upon */ |
|
54 nsCOMPtr<nsIDOMElement> mElement; |
|
55 |
|
56 /** the attribute to change */ |
|
57 nsString mAttribute; |
|
58 |
|
59 /** the value to set the attribute to (ignored if mRemoveAttribute==true) */ |
|
60 nsString mValue; |
|
61 |
|
62 /** the value to set the attribute to for undo */ |
|
63 nsString mUndoValue; |
|
64 |
|
65 /** true if the mAttribute was set on mElement at the time of execution */ |
|
66 bool mAttributeWasSet; |
|
67 |
|
68 /** true if the operation is to remove mAttribute from mElement */ |
|
69 bool mRemoveAttribute; |
|
70 }; |
|
71 |
|
72 #endif |