2001-09-26 02:53:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04: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/. */
|
1999-01-06 23:30:13 +03:00
|
|
|
|
2016-07-07 08:12:30 +03:00
|
|
|
#ifndef ChangeAttributeTransaction_h
|
|
|
|
#define ChangeAttributeTransaction_h
|
1999-01-06 23:30:13 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
#include "mozilla/Attributes.h" // override
|
2016-07-08 08:03:31 +03:00
|
|
|
#include "mozilla/EditTransactionBase.h" // base class
|
2014-08-29 15:43:23 +04:00
|
|
|
#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-13 10:33:42 +04:00
|
|
|
|
2014-08-29 15:43:23 +04:00
|
|
|
class nsIAtom;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2016-07-07 08:12:30 +03:00
|
|
|
namespace dom {
|
2014-08-29 15:43:23 +04:00
|
|
|
class Element;
|
2016-07-07 08:12:30 +03:00
|
|
|
} // namespace dom
|
1999-01-06 23:30:13 +03:00
|
|
|
|
|
|
|
/**
|
2014-08-29 15:43:23 +04:00
|
|
|
* A transaction that changes an attribute of a content node. This transaction
|
|
|
|
* covers add, remove, and change attribute.
|
1999-01-06 23:30:13 +03:00
|
|
|
*/
|
2016-07-08 03:48:34 +03:00
|
|
|
class ChangeAttributeTransaction final : public EditTransactionBase
|
1999-01-06 23:30:13 +03:00
|
|
|
{
|
|
|
|
public:
|
2016-07-07 08:12:30 +03:00
|
|
|
/**
|
|
|
|
* @param aElement the element whose attribute will be changed
|
|
|
|
* @param aAttribute the name of the attribute to change
|
|
|
|
* @param aValue the new value for aAttribute, or null to remove
|
|
|
|
*/
|
|
|
|
ChangeAttributeTransaction(dom::Element& aElement,
|
|
|
|
nsIAtom& aAttribute,
|
|
|
|
const nsAString* aValue);
|
1999-01-21 04:51:09 +03:00
|
|
|
|
2011-02-20 01:18:37 +03:00
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2016-07-08 03:48:34 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ChangeAttributeTransaction,
|
|
|
|
EditTransactionBase)
|
1999-01-06 23:30:13 +03:00
|
|
|
|
2016-07-08 03:48:34 +03:00
|
|
|
NS_DECL_EDITTRANSACTIONBASE
|
1999-01-06 23:30:13 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD RedoTransaction() override;
|
1999-09-22 02:31:27 +04:00
|
|
|
|
2014-08-29 15:43:23 +04:00
|
|
|
private:
|
2016-07-07 08:12:30 +03:00
|
|
|
virtual ~ChangeAttributeTransaction();
|
1999-01-21 04:51:09 +03:00
|
|
|
|
2016-07-07 08:12:30 +03:00
|
|
|
// The element to operate upon
|
|
|
|
nsCOMPtr<dom::Element> mElement;
|
2014-08-29 15:43:23 +04:00
|
|
|
|
2016-07-07 08:12:30 +03:00
|
|
|
// The attribute to change
|
2014-08-29 15:43:23 +04:00
|
|
|
nsCOMPtr<nsIAtom> mAttribute;
|
1999-01-07 04:02:16 +03:00
|
|
|
|
2016-07-07 08:12:30 +03:00
|
|
|
// The value to set the attribute to (ignored if mRemoveAttribute==true)
|
1999-01-06 23:30:13 +03:00
|
|
|
nsString mValue;
|
1999-01-07 04:02:16 +03:00
|
|
|
|
2016-07-07 08:12:30 +03:00
|
|
|
// True if the operation is to remove mAttribute from mElement
|
2014-08-29 15:43:23 +04:00
|
|
|
bool mRemoveAttribute;
|
1999-01-07 04:02:16 +03:00
|
|
|
|
2016-07-07 08:12:30 +03:00
|
|
|
// True if the mAttribute was set on mElement at the time of execution
|
2014-08-29 15:43:23 +04:00
|
|
|
bool mAttributeWasSet;
|
1999-01-07 04:02:16 +03:00
|
|
|
|
2016-07-07 08:12:30 +03:00
|
|
|
// The value to set the attribute to for undo
|
2014-08-29 15:43:23 +04:00
|
|
|
nsString mUndoValue;
|
1999-01-06 23:30:13 +03:00
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace mozilla
|
2014-08-29 15:43:23 +04:00
|
|
|
|
2016-07-07 08:12:30 +03:00
|
|
|
#endif // #ifndef ChangeAttributeTransaction_h
|