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-14 21:02:45 +03:00
|
|
|
|
2016-07-07 08:56:53 +03:00
|
|
|
#ifndef DeleteRangeTransaction_h
|
|
|
|
#define DeleteRangeTransaction_h
|
1999-01-14 21:02:45 +03:00
|
|
|
|
2016-07-07 11:11:30 +03:00
|
|
|
#include "EditAggregateTransaction.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsID.h"
|
|
|
|
#include "nsIEditor.h"
|
|
|
|
#include "nsISupportsImpl.h"
|
2012-06-25 14:22:49 +04:00
|
|
|
#include "nsRange.h"
|
2012-07-13 10:33:42 +04:00
|
|
|
#include "nscore.h"
|
1999-01-14 21:02:45 +03:00
|
|
|
|
2012-07-13 10:33:42 +04:00
|
|
|
class nsINode;
|
1999-08-09 05:37:50 +04:00
|
|
|
|
2016-07-07 08:56:53 +03:00
|
|
|
namespace mozilla {
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
class EditorBase;
|
2016-06-24 09:01:40 +03:00
|
|
|
class RangeUpdater;
|
|
|
|
|
1999-01-14 21:02:45 +03:00
|
|
|
/**
|
|
|
|
* A transaction that deletes an entire range in the content tree
|
|
|
|
*/
|
2016-07-07 11:11:30 +03:00
|
|
|
class DeleteRangeTransaction final : public EditAggregateTransaction
|
1999-01-14 21:02:45 +03:00
|
|
|
{
|
|
|
|
public:
|
2016-07-07 08:56:53 +03:00
|
|
|
/**
|
|
|
|
* Initialize the transaction.
|
2016-07-08 07:10:13 +03:00
|
|
|
* @param aEditorBase The object providing basic editing operations.
|
2016-07-07 08:56:53 +03:00
|
|
|
* @param aRange The range to delete.
|
|
|
|
*/
|
2016-07-08 07:10:13 +03:00
|
|
|
nsresult Init(EditorBase* aEditorBase,
|
2012-06-25 14:22:49 +04:00
|
|
|
nsRange* aRange,
|
2016-06-24 09:01:40 +03:00
|
|
|
RangeUpdater* aRangeUpdater);
|
1999-01-21 04:51:09 +03:00
|
|
|
|
2016-07-07 08:56:53 +03:00
|
|
|
DeleteRangeTransaction();
|
1999-01-21 04:51:09 +03:00
|
|
|
|
2016-07-07 08:56:53 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeleteRangeTransaction,
|
2016-07-07 11:11:30 +03:00
|
|
|
EditAggregateTransaction)
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
|
2009-05-09 08:59:25 +04:00
|
|
|
|
2016-07-08 03:48:34 +03:00
|
|
|
NS_DECL_EDITTRANSACTIONBASE
|
1999-01-14 21:02:45 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD RedoTransaction() override;
|
1999-09-22 02:31:27 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void LastRelease() override
|
2013-07-09 21:30:58 +04:00
|
|
|
{
|
|
|
|
mRange = nullptr;
|
2016-07-07 11:11:30 +03:00
|
|
|
EditAggregateTransaction::LastRelease();
|
2013-07-09 21:30:58 +04:00
|
|
|
}
|
1999-01-21 04:51:09 +03:00
|
|
|
|
2016-07-07 08:56:53 +03:00
|
|
|
protected:
|
2012-06-25 14:22:49 +04:00
|
|
|
nsresult CreateTxnsToDeleteBetween(nsINode* aNode,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aStartOffset,
|
|
|
|
int32_t aEndOffset);
|
1999-01-21 04:51:09 +03:00
|
|
|
|
2012-06-25 14:22:49 +04:00
|
|
|
nsresult CreateTxnsToDeleteNodesBetween();
|
|
|
|
|
|
|
|
nsresult CreateTxnsToDeleteContent(nsINode* aParent,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aOffset,
|
2012-06-25 14:22:49 +04:00
|
|
|
nsIEditor::EDirection aAction);
|
1999-01-21 04:51:09 +03:00
|
|
|
|
2016-07-07 08:56:53 +03:00
|
|
|
// P1 in the range.
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<nsRange> mRange;
|
1999-03-09 22:22:48 +03:00
|
|
|
|
2016-07-07 08:56:53 +03:00
|
|
|
// The editor for this transaction.
|
2016-07-08 07:10:13 +03:00
|
|
|
EditorBase* mEditorBase;
|
1999-02-17 22:42:29 +03:00
|
|
|
|
2016-07-07 08:56:53 +03:00
|
|
|
// Range updater object.
|
2016-06-24 09:01:40 +03:00
|
|
|
RangeUpdater* mRangeUpdater;
|
1999-01-14 21:02:45 +03:00
|
|
|
};
|
|
|
|
|
2016-07-07 08:56:53 +03:00
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // #ifndef DeleteRangeTransaction_h
|