2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifndef ChangeAttributeTxn_h__
|
|
|
|
#define ChangeAttributeTxn_h__
|
|
|
|
|
|
|
|
#include "EditTxn.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2012-07-12 23:33:42 -07:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsISupportsImpl.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nscore.h"
|
|
|
|
|
2013-01-09 15:05:08 -08:00
|
|
|
class nsEditor;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
class Element;
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
2013-01-09 15:05:08 -08:00
|
|
|
* A transaction that changes an attribute of a content node.
|
2007-03-22 10:30:00 -07:00
|
|
|
* This transaction covers add, remove, and change attribute.
|
|
|
|
*/
|
|
|
|
class ChangeAttributeTxn : public EditTxn
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/** Initialize the transaction.
|
|
|
|
* @param aEditor the object providing core editing operations
|
|
|
|
* @param aNode the node whose attribute will be changed
|
|
|
|
* @param aAttribute the name of the attribute to change
|
|
|
|
* @param aValue the new value for aAttribute, if aRemoveAttribute is false
|
2011-10-17 07:59:28 -07:00
|
|
|
* @param aRemoveAttribute if true, remove aAttribute from aNode
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2013-01-09 15:05:08 -08:00
|
|
|
NS_IMETHOD Init(nsEditor *aEditor,
|
|
|
|
mozilla::dom::Element *aNode,
|
2007-03-22 10:30:00 -07:00
|
|
|
const nsAString& aAttribute,
|
|
|
|
const nsAString& aValue,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool aRemoveAttribute);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
ChangeAttributeTxn();
|
|
|
|
|
2011-02-19 14:18:37 -08:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2009-05-08 21:59:25 -07:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ChangeAttributeTxn, EditTxn)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
NS_DECL_EDITTXN
|
|
|
|
|
|
|
|
NS_IMETHOD RedoTransaction();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/** the editor that created this transaction */
|
2013-01-09 15:05:08 -08:00
|
|
|
nsEditor* mEditor;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/** the element to operate upon */
|
2013-01-09 15:05:08 -08:00
|
|
|
nsCOMPtr<mozilla::dom::Element> mElement;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/** the attribute to change */
|
|
|
|
nsString mAttribute;
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
/** the value to set the attribute to (ignored if mRemoveAttribute==true) */
|
2007-03-22 10:30:00 -07:00
|
|
|
nsString mValue;
|
|
|
|
|
|
|
|
/** the value to set the attribute to for undo */
|
|
|
|
nsString mUndoValue;
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
/** true if the mAttribute was set on mElement at the time of execution */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mAttributeWasSet;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
/** true if the operation is to remove mAttribute from mElement */
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mRemoveAttribute;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|