editor/libeditor/base/DeleteRangeTxn.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/editor/libeditor/base/DeleteRangeTxn.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,75 @@
     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 DeleteRangeTxn_h__
    1.10 +#define DeleteRangeTxn_h__
    1.11 +
    1.12 +#include "EditAggregateTxn.h"
    1.13 +#include "EditTxn.h"
    1.14 +#include "nsAutoPtr.h"
    1.15 +#include "nsCycleCollectionParticipant.h"
    1.16 +#include "nsID.h"
    1.17 +#include "nsIEditor.h"
    1.18 +#include "nsISupportsImpl.h"
    1.19 +#include "nsRange.h"
    1.20 +#include "nscore.h"
    1.21 +
    1.22 +class nsEditor;
    1.23 +class nsINode;
    1.24 +class nsRangeUpdater;
    1.25 +
    1.26 +/**
    1.27 + * A transaction that deletes an entire range in the content tree
    1.28 + */
    1.29 +class DeleteRangeTxn : public EditAggregateTxn
    1.30 +{
    1.31 +public:
    1.32 +  /** initialize the transaction.
    1.33 +    * @param aEditor the object providing basic editing operations
    1.34 +    * @param aRange  the range to delete
    1.35 +    */
    1.36 +  nsresult Init(nsEditor* aEditor,
    1.37 +                nsRange* aRange,
    1.38 +                nsRangeUpdater* aRangeUpdater);
    1.39 +
    1.40 +  DeleteRangeTxn();
    1.41 +
    1.42 +  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeleteRangeTxn, EditAggregateTxn)
    1.43 +  NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr);
    1.44 +
    1.45 +  NS_DECL_EDITTXN
    1.46 +
    1.47 +  NS_IMETHOD RedoTransaction();
    1.48 +
    1.49 +  virtual void LastRelease()
    1.50 +  {
    1.51 +    mRange = nullptr;
    1.52 +    EditAggregateTxn::LastRelease();
    1.53 +  }
    1.54 +protected:
    1.55 +
    1.56 +  nsresult CreateTxnsToDeleteBetween(nsINode* aNode,
    1.57 +                                     int32_t aStartOffset,
    1.58 +                                     int32_t aEndOffset);
    1.59 +
    1.60 +  nsresult CreateTxnsToDeleteNodesBetween();
    1.61 +
    1.62 +  nsresult CreateTxnsToDeleteContent(nsINode* aParent,
    1.63 +                                     int32_t aOffset,
    1.64 +                                     nsIEditor::EDirection aAction);
    1.65 +
    1.66 +protected:
    1.67 +
    1.68 +  /** p1 in the range */
    1.69 +  nsRefPtr<nsRange> mRange;
    1.70 +
    1.71 +  /** the editor for this transaction */
    1.72 +  nsEditor* mEditor;
    1.73 +
    1.74 +  /** range updater object */
    1.75 +  nsRangeUpdater* mRangeUpdater;
    1.76 +};
    1.77 +
    1.78 +#endif

mercurial