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__
|
|
|
|
|
2014-08-29 04:43:23 -07:00
|
|
|
#include "EditTxn.h" // base class
|
|
|
|
#include "mozilla/Attributes.h" // MOZ_OVERRIDE
|
|
|
|
#include "nsCOMPtr.h" // nsCOMPtr members
|
|
|
|
#include "nsCycleCollectionParticipant.h" // NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED
|
|
|
|
#include "nsISupportsImpl.h" // NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
#include "nsString.h" // nsString members
|
2012-07-12 23:33:42 -07:00
|
|
|
|
2014-08-29 04:43:23 -07:00
|
|
|
class nsIAtom;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
|
|
|
class Element;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
2014-08-29 04:43:23 -07:00
|
|
|
* A transaction that changes an attribute of a content node. This transaction
|
|
|
|
* covers add, remove, and change attribute.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
|
|
|
class ChangeAttributeTxn : public EditTxn
|
|
|
|
{
|
|
|
|
public:
|
2014-08-29 04:43:23 -07:00
|
|
|
/** @param aElement the element whose attribute will be changed
|
2007-03-22 10:30:00 -07:00
|
|
|
* @param aAttribute the name of the attribute to change
|
2014-08-29 04:43:23 -07:00
|
|
|
* @param aValue the new value for aAttribute, or null to remove
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2014-08-29 04:43:23 -07:00
|
|
|
ChangeAttributeTxn(Element& aElement, nsIAtom& aAttribute,
|
|
|
|
const nsAString* aValue);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
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
|
|
|
|
|
2014-08-29 04:43:23 -07:00
|
|
|
NS_IMETHOD RedoTransaction() MOZ_OVERRIDE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-08-29 04:43:23 -07:00
|
|
|
private:
|
2014-07-08 14:23:18 -07:00
|
|
|
virtual ~ChangeAttributeTxn();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-08-29 04:43:23 -07:00
|
|
|
/** The element to operate upon */
|
|
|
|
nsCOMPtr<Element> mElement;
|
|
|
|
|
|
|
|
/** The attribute to change */
|
|
|
|
nsCOMPtr<nsIAtom> mAttribute;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-08-29 04:43:23 -07:00
|
|
|
/** The value to set the attribute to (ignored if mRemoveAttribute==true) */
|
2007-03-22 10:30:00 -07:00
|
|
|
nsString mValue;
|
|
|
|
|
2014-08-29 04:43:23 -07:00
|
|
|
/** True if the operation is to remove mAttribute from mElement */
|
|
|
|
bool mRemoveAttribute;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-08-29 04:43:23 -07:00
|
|
|
/** True if the mAttribute was set on mElement at the time of execution */
|
|
|
|
bool mAttributeWasSet;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2014-08-29 04:43:23 -07:00
|
|
|
/** The value to set the attribute to for undo */
|
|
|
|
nsString mUndoValue;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
2014-08-29 04:43:23 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|