2014-11-02 12:04:13 +00: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 07:59:55 +00:00
|
|
|
#ifndef SplitNodeTransaction_h
|
|
|
|
#define SplitNodeTransaction_h
|
2014-11-02 12:04:13 +00:00
|
|
|
|
|
|
|
#include "EditTxn.h" // for EditTxn, NS_DECL_EDITTXN
|
|
|
|
#include "nsCOMPtr.h" // for nsCOMPtr
|
|
|
|
#include "nsCycleCollectionParticipant.h"
|
|
|
|
#include "nsISupportsImpl.h" // for NS_DECL_ISUPPORTS_INHERITED
|
|
|
|
#include "nscore.h" // for NS_IMETHOD
|
|
|
|
|
|
|
|
class nsEditor;
|
|
|
|
class nsIContent;
|
2014-12-02 05:06:55 +00:00
|
|
|
class nsINode;
|
2014-11-02 12:04:13 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A transaction that splits a node into two identical nodes, with the children
|
|
|
|
* divided between the new nodes.
|
|
|
|
*/
|
2016-07-07 07:59:55 +00:00
|
|
|
class SplitNodeTransaction final : public EditTxn
|
2014-11-02 12:04:13 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-07-07 07:59:55 +00:00
|
|
|
/**
|
|
|
|
* @param aEditor 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.
|
|
|
|
*/
|
|
|
|
SplitNodeTransaction(nsEditor& aEditor, nsIContent& aNode, int32_t aOffset);
|
2014-11-02 12:04:13 +00:00
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2016-07-07 07:59:55 +00:00
|
|
|
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SplitNodeTransaction, EditTxn)
|
2014-11-02 12:04:13 +00:00
|
|
|
|
|
|
|
NS_DECL_EDITTXN
|
|
|
|
|
2015-03-21 16:28:04 +00:00
|
|
|
NS_IMETHOD RedoTransaction() override;
|
2014-11-02 12:04:13 +00:00
|
|
|
|
|
|
|
nsIContent* GetNewNode();
|
|
|
|
|
|
|
|
protected:
|
2016-07-07 07:59:55 +00:00
|
|
|
virtual ~SplitNodeTransaction();
|
2014-11-02 12:04:13 +00:00
|
|
|
|
|
|
|
nsEditor& mEditor;
|
|
|
|
|
2016-07-07 07:59:55 +00:00
|
|
|
// The node to operate upon.
|
2014-11-02 12:04:13 +00:00
|
|
|
nsCOMPtr<nsIContent> mExistingRightNode;
|
|
|
|
|
2016-07-07 07:59:55 +00: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 12:04:13 +00:00
|
|
|
int32_t mOffset;
|
|
|
|
|
2016-07-07 07:59:55 +00:00
|
|
|
// The node we create when splitting mExistingRightNode.
|
2014-11-02 12:04:13 +00:00
|
|
|
nsCOMPtr<nsIContent> mNewLeftNode;
|
|
|
|
|
2016-07-07 07:59:55 +00:00
|
|
|
// The parent shared by mExistingRightNode and mNewLeftNode.
|
2014-11-02 12:04:13 +00:00
|
|
|
nsCOMPtr<nsINode> mParent;
|
|
|
|
};
|
|
|
|
|
2015-07-13 15:25:42 +00:00
|
|
|
} // namespace mozilla
|
2014-11-02 12:04:13 +00:00
|
|
|
|
2016-07-07 07:59:55 +00:00
|
|
|
#endif // #ifndef SplitNodeTransaction_h
|