2014-11-02 15:04:13 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
2016-07-07 10:59:55 +03:00
|
|
|
#ifndef SplitNodeTransaction_h
|
|
|
|
#define SplitNodeTransaction_h
|
2014-11-02 15:04:13 +03:00
|
|
|
|
2016-07-08 08:03:31 +03:00
|
|
|
#include "mozilla/EditTransactionBase.h" // for EditTxn, etc
|
2014-11-02 15:04:13 +03:00
|
|
|
#include "nsCOMPtr.h" // for nsCOMPtr
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
#include "nscore.h" // for NS_IMETHOD
|
|
|
|
|
|
|
|
class nsIContent;
|
2014-12-02 08:06:55 +03:00
|
|
|
class nsINode;
|
2014-11-02 15:04:13 +03:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
class EditorBase;
|
|
|
|
|
2014-11-02 15:04:13 +03:00
|
|
|
/**
|
|
|
|
* A transaction that splits a node into two identical nodes, with the children
|
|
|
|
* divided between the new nodes.
|
|
|
|
*/
|
2016-07-08 03:48:34 +03:00
|
|
|
class SplitNodeTransaction final : public EditTransactionBase
|
2014-11-02 15:04:13 +03:00
|
|
|
{
|
|
|
|
public:
|
2016-07-07 10:59:55 +03:00
|
|
|
/**
|
2016-07-08 07:10:13 +03:00
|
|
|
* @param aEditorBase The provider of core editing operations
|
|
|
|
* @param aNode The node to split
|
|
|
|
* @param aOffset The location within aNode to do the split. aOffset may
|
|
|
|
* refer to children of aNode, or content of aNode. The
|
|
|
|
* left node will have child|content 0..aOffset-1.
|
2016-07-07 10:59:55 +03:00
|
|
|
*/
|
2016-07-08 07:10:13 +03:00
|
|
|
SplitNodeTransaction(EditorBase& aEditorBase, nsIContent& aNode,
|
|
|
|
int32_t aOffset);
|
2014-11-02 15:04:13 +03:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2016-07-08 03:48:34 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SplitNodeTransaction,
|
|
|
|
EditTransactionBase)
|
2014-11-02 15:04:13 +03:00
|
|
|
|
2016-07-08 03:48:34 +03:00
|
|
|
NS_DECL_EDITTRANSACTIONBASE
|
2014-11-02 15:04:13 +03:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
NS_IMETHOD RedoTransaction() override;
|
2014-11-02 15:04:13 +03:00
|
|
|
|
|
|
|
nsIContent* GetNewNode();
|
|
|
|
|
|
|
|
protected:
|
2016-07-07 10:59:55 +03:00
|
|
|
virtual ~SplitNodeTransaction();
|
2014-11-02 15:04:13 +03:00
|
|
|
|
2016-07-08 07:10:13 +03:00
|
|
|
EditorBase& mEditorBase;
|
2014-11-02 15:04:13 +03:00
|
|
|
|
2016-07-07 10:59:55 +03:00
|
|
|
// The node to operate upon.
|
2014-11-02 15:04:13 +03:00
|
|
|
nsCOMPtr<nsIContent> mExistingRightNode;
|
|
|
|
|
2016-07-07 10:59:55 +03:00
|
|
|
// The offset into mExistingRightNode where its children are split. mOffset
|
|
|
|
// is the index of the first child in the right node. -1 means the new node
|
|
|
|
// gets no children.
|
2014-11-02 15:04:13 +03:00
|
|
|
int32_t mOffset;
|
|
|
|
|
2016-07-07 10:59:55 +03:00
|
|
|
// The node we create when splitting mExistingRightNode.
|
2014-11-02 15:04:13 +03:00
|
|
|
nsCOMPtr<nsIContent> mNewLeftNode;
|
|
|
|
|
2016-07-07 10:59:55 +03:00
|
|
|
// The parent shared by mExistingRightNode and mNewLeftNode.
|
2014-11-02 15:04:13 +03:00
|
|
|
nsCOMPtr<nsINode> mParent;
|
|
|
|
};
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace mozilla
|
2014-11-02 15:04:13 +03:00
|
|
|
|
2016-07-07 10:59:55 +03:00
|
|
|
#endif // #ifndef SplitNodeTransaction_h
|