Bug 1425412 - part 3: Create CreateElementTransaction::Create() and remove EditorBase::CreateTxnForCreateElement() r=m_kato

EditorBase::CreateTxnForCreateElement() just hides what it does. Let's make
the caller what it does with creating CreateElementTransaction::Create().

MozReview-Commit-ID: DYcfQV6KiUZ

--HG--
extra : rebase_source : d3f31b8db92bd3b2af464c66e064dd7b21018960
This commit is contained in:
Masayuki Nakano 2017-12-15 17:54:10 +09:00
Родитель 1623a99bae
Коммит 7443737c19
4 изменённых файлов: 24 добавлений и 33 удалений

Просмотреть файл

@ -32,6 +32,16 @@ namespace mozilla {
using namespace dom;
already_AddRefed<CreateElementTransaction>
CreateElementTransaction::Create(EditorBase& aEditorBase,
nsAtom& aTag,
const EditorRawDOMPoint& aPointToInsert)
{
RefPtr<CreateElementTransaction> transaction =
new CreateElementTransaction(aEditorBase, aTag, aPointToInsert);
return transaction.forget();
}
CreateElementTransaction::CreateElementTransaction(
EditorBase& aEditorBase,
nsAtom& aTag,

Просмотреть файл

@ -28,19 +28,27 @@ class Element;
class CreateElementTransaction final : public EditTransactionBase
{
protected:
CreateElementTransaction(EditorBase& aEditorBase,
nsAtom& aTag,
const EditorRawDOMPoint& aPointToInsert);
public:
/**
* Initialize the transaction.
* @param aEditorBase The provider of basic editing functionality.
* Create a transaction for creating a new child node of the container of
* aPointToInsert of type aTag.
*
* @param aEditorBase The editor which manages the transaction.
* @param aTag The tag (P, HR, TABLE, etc.) for the new element.
* @param aPointToInsert The new node will be inserted before the child at
* aPointToInsert. If this refers end of the container
* or after, the new node will be appended to the
* container.
*/
CreateElementTransaction(EditorBase& aEditorBase,
nsAtom& aTag,
const EditorRawDOMPoint& aPointToInsert);
static already_AddRefed<CreateElementTransaction>
Create(EditorBase& aEditorBase,
nsAtom& aTag,
const EditorRawDOMPoint& aPointToInsert);
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(CreateElementTransaction,

Просмотреть файл

@ -1441,7 +1441,7 @@ EditorBase::CreateNode(nsAtom* aTag,
nsCOMPtr<Element> ret;
RefPtr<CreateElementTransaction> transaction =
CreateTxnForCreateElement(*aTag, pointToInsert);
CreateElementTransaction::Create(*this, *aTag, pointToInsert);
nsresult rv = DoTransaction(transaction);
if (NS_SUCCEEDED(rv)) {
ret = transaction->GetNewNode();
@ -4632,16 +4632,6 @@ EditorBase::CreateTxnForRemoveAttribute(Element& aElement,
return transaction.forget();
}
already_AddRefed<CreateElementTransaction>
EditorBase::CreateTxnForCreateElement(nsAtom& aTag,
const EditorRawDOMPoint& aPointToInsert)
{
RefPtr<CreateElementTransaction> transaction =
new CreateElementTransaction(*this, aTag, aPointToInsert);
return transaction.forget();
}
already_AddRefed<DeleteNodeTransaction>
EditorBase::CreateTxnForDeleteNode(nsINode* aNode)
{

Просмотреть файл

@ -518,23 +518,6 @@ protected:
already_AddRefed<ChangeAttributeTransaction>
CreateTxnForRemoveAttribute(Element& aElement, nsAtom& aAttribute);
/**
* Create a transaction for creating a new child node of the container of
* aPointToInsert of type aTag.
*
* @param aTag The element name to create.
* @param aPointToInsert The insertion point of new element. If this refers
* end of the container or after, the transaction
* will append the element to the container.
* Otherwise, will insert the element before the
* child node referred by this.
* @return A CreateElementTransaction which was initialized
* with the arguments.
*/
already_AddRefed<CreateElementTransaction>
CreateTxnForCreateElement(nsAtom& aTag,
const EditorRawDOMPoint& aPointToInsert);
/**
* Create an element node whose name is aTag at before aPointToInsert. When
* this succeed to create an element node, this sets aPointToInsert to the