Line data Source code
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 ChangeAttributeTransaction_h
7 : #define ChangeAttributeTransaction_h
8 :
9 : #include "mozilla/Attributes.h" // override
10 : #include "mozilla/EditTransactionBase.h" // base class
11 : #include "nsCOMPtr.h" // nsCOMPtr members
12 : #include "nsCycleCollectionParticipant.h" // NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED
13 : #include "nsISupportsImpl.h" // NS_DECL_ISUPPORTS_INHERITED
14 : #include "nsString.h" // nsString members
15 :
16 : class nsIAtom;
17 :
18 : namespace mozilla {
19 :
20 : namespace dom {
21 : class Element;
22 : } // namespace dom
23 :
24 : /**
25 : * A transaction that changes an attribute of a content node. This transaction
26 : * covers add, remove, and change attribute.
27 : */
28 : class ChangeAttributeTransaction final : public EditTransactionBase
29 : {
30 : public:
31 : /**
32 : * @param aElement the element whose attribute will be changed
33 : * @param aAttribute the name of the attribute to change
34 : * @param aValue the new value for aAttribute, or null to remove
35 : */
36 : ChangeAttributeTransaction(dom::Element& aElement,
37 : nsIAtom& aAttribute,
38 : const nsAString* aValue);
39 :
40 : NS_DECL_ISUPPORTS_INHERITED
41 0 : NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ChangeAttributeTransaction,
42 : EditTransactionBase)
43 :
44 : NS_DECL_EDITTRANSACTIONBASE
45 :
46 : NS_IMETHOD RedoTransaction() override;
47 :
48 : private:
49 : virtual ~ChangeAttributeTransaction();
50 :
51 : // The element to operate upon
52 : nsCOMPtr<dom::Element> mElement;
53 :
54 : // The attribute to change
55 : nsCOMPtr<nsIAtom> mAttribute;
56 :
57 : // The value to set the attribute to (ignored if mRemoveAttribute==true)
58 : nsString mValue;
59 :
60 : // True if the operation is to remove mAttribute from mElement
61 : bool mRemoveAttribute;
62 :
63 : // True if the mAttribute was set on mElement at the time of execution
64 : bool mAttributeWasSet;
65 :
66 : // The value to set the attribute to for undo
67 : nsString mUndoValue;
68 : };
69 :
70 : } // namespace mozilla
71 :
72 : #endif // #ifndef ChangeAttributeTransaction_h
|