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 ChangeAttributeTxn_h__ michael@0: #define ChangeAttributeTxn_h__ michael@0: michael@0: #include "EditTxn.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: #include "nsIDOMElement.h" michael@0: #include "nsISupportsImpl.h" michael@0: #include "nsString.h" michael@0: #include "nscore.h" michael@0: michael@0: class nsIEditor; michael@0: michael@0: /** michael@0: * A transaction that changes an attribute of a content node. michael@0: * This transaction covers add, remove, and change attribute. michael@0: */ michael@0: class ChangeAttributeTxn : public EditTxn michael@0: { michael@0: public: michael@0: /** Initialize the transaction. michael@0: * @param aEditor the object providing core editing operations michael@0: * @param aNode the node whose attribute will be changed michael@0: * @param aAttribute the name of the attribute to change michael@0: * @param aValue the new value for aAttribute, if aRemoveAttribute is false michael@0: * @param aRemoveAttribute if true, remove aAttribute from aNode michael@0: */ michael@0: NS_IMETHOD Init(nsIEditor *aEditor, michael@0: nsIDOMElement *aNode, michael@0: const nsAString& aAttribute, michael@0: const nsAString& aValue, michael@0: bool aRemoveAttribute); michael@0: michael@0: ChangeAttributeTxn(); michael@0: michael@0: NS_DECL_ISUPPORTS_INHERITED michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ChangeAttributeTxn, EditTxn) michael@0: michael@0: NS_DECL_EDITTXN michael@0: michael@0: NS_IMETHOD RedoTransaction(); michael@0: michael@0: protected: michael@0: michael@0: /** the editor that created this transaction */ michael@0: nsIEditor* mEditor; michael@0: michael@0: /** the element to operate upon */ michael@0: nsCOMPtr mElement; michael@0: michael@0: /** the attribute to change */ michael@0: nsString mAttribute; michael@0: michael@0: /** the value to set the attribute to (ignored if mRemoveAttribute==true) */ michael@0: nsString mValue; michael@0: michael@0: /** the value to set the attribute to for undo */ michael@0: nsString mUndoValue; michael@0: michael@0: /** true if the mAttribute was set on mElement at the time of execution */ michael@0: bool mAttributeWasSet; michael@0: michael@0: /** true if the operation is to remove mAttribute from mElement */ michael@0: bool mRemoveAttribute; michael@0: }; michael@0: michael@0: #endif