editor/libeditor/base/ChangeAttributeTxn.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/base/ChangeAttributeTxn.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef ChangeAttributeTxn_h__
    1.10 +#define ChangeAttributeTxn_h__
    1.11 +
    1.12 +#include "EditTxn.h"
    1.13 +#include "nsCOMPtr.h"
    1.14 +#include "nsCycleCollectionParticipant.h"
    1.15 +#include "nsIDOMElement.h"
    1.16 +#include "nsISupportsImpl.h"
    1.17 +#include "nsString.h"
    1.18 +#include "nscore.h"
    1.19 +
    1.20 +class nsIEditor;
    1.21 +
    1.22 +/**
    1.23 + * A transaction that changes an attribute of a content node. 
    1.24 + * This transaction covers add, remove, and change attribute.
    1.25 + */
    1.26 +class ChangeAttributeTxn : public EditTxn
    1.27 +{
    1.28 +public:
    1.29 +  /** Initialize the transaction.
    1.30 +    * @param aEditor the object providing core editing operations
    1.31 +    * @param aNode   the node whose attribute will be changed
    1.32 +    * @param aAttribute the name of the attribute to change
    1.33 +    * @param aValue     the new value for aAttribute, if aRemoveAttribute is false
    1.34 +    * @param aRemoveAttribute if true, remove aAttribute from aNode
    1.35 +    */
    1.36 +  NS_IMETHOD Init(nsIEditor      *aEditor,
    1.37 +                  nsIDOMElement  *aNode,
    1.38 +                  const nsAString& aAttribute,
    1.39 +                  const nsAString& aValue,
    1.40 +                  bool aRemoveAttribute);
    1.41 +
    1.42 +  ChangeAttributeTxn();
    1.43 +
    1.44 +  NS_DECL_ISUPPORTS_INHERITED
    1.45 +  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(ChangeAttributeTxn, EditTxn)
    1.46 +
    1.47 +  NS_DECL_EDITTXN
    1.48 +
    1.49 +  NS_IMETHOD RedoTransaction();
    1.50 +
    1.51 +protected:
    1.52 +
    1.53 +  /** the editor that created this transaction */
    1.54 +  nsIEditor*  mEditor;
    1.55 +  
    1.56 +  /** the element to operate upon */
    1.57 +  nsCOMPtr<nsIDOMElement> mElement;
    1.58 +  
    1.59 +  /** the attribute to change */
    1.60 +  nsString mAttribute;
    1.61 +
    1.62 +  /** the value to set the attribute to (ignored if mRemoveAttribute==true) */
    1.63 +  nsString mValue;
    1.64 +
    1.65 +  /** the value to set the attribute to for undo */
    1.66 +  nsString mUndoValue;
    1.67 +
    1.68 +  /** true if the mAttribute was set on mElement at the time of execution */
    1.69 +  bool     mAttributeWasSet;
    1.70 +
    1.71 +  /** true if the operation is to remove mAttribute from mElement */
    1.72 +  bool     mRemoveAttribute;
    1.73 +};
    1.74 +
    1.75 +#endif

mercurial