Bug 1408125 - part 3: Redesign nsIEditActionListener::(Will|Did)InsertNode() r=m_kato

Although nsIEditActionListener::WillInsertNode() nobody implements actually,
we should remove it in a follow up bug.

nsIEditActionListener::DidInsertNode() is implemented only by HTMLEditRules.
So, if we make it not use nsIEditActionListener, we can remove it too.
However, keep it for now.

On the other hand, they don't need to receive index of the insertion point.
WillInsertNode() needs next sibling of the insert point, but DidInsertNode()
needs nothing because listener can compute it with new inserted node.

MozReview-Commit-ID: GiTKkVyZJlN

--HG--
extra : rebase_source : 9ee38c28217d25d1a3f79b0b458c7b2121350a76
This commit is contained in:
Masayuki Nakano 2017-11-28 21:26:10 +09:00
Родитель 8496023596
Коммит f6e37d5fe3
7 изменённых файлов: 27 добавлений и 48 удалений

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

@ -1501,9 +1501,9 @@ EditorBase::InsertNode(nsIContent& aContentToInsert,
{
AutoActionListenerArray listeners(mActionListeners);
for (auto& listener : listeners) {
listener->WillInsertNode(aContentToInsert.AsDOMNode(),
aPointToInsert.Container()->AsDOMNode(),
aPointToInsert.Offset());
listener->WillInsertNode(
aContentToInsert.AsDOMNode(),
GetAsDOMNode(aPointToInsert.GetNextSiblingOfChildAtOffset()));
}
}
@ -1517,10 +1517,7 @@ EditorBase::InsertNode(nsIContent& aContentToInsert,
{
AutoActionListenerArray listeners(mActionListeners);
for (auto& listener : listeners) {
listener->DidInsertNode(aContentToInsert.AsDOMNode(),
aPointToInsert.Container()->AsDOMNode(),
aPointToInsert.Offset(),
rv);
listener->DidInsertNode(aContentToInsert.AsDOMNode(), rv);
}
}

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

@ -8743,16 +8743,13 @@ HTMLEditRules::DidCreateNode(const nsAString& aTag,
NS_IMETHODIMP
HTMLEditRules::WillInsertNode(nsIDOMNode* aNode,
nsIDOMNode* aParent,
int32_t aPosition)
nsIDOMNode* aNextSiblingOfNewNode)
{
return NS_OK;
}
NS_IMETHODIMP
HTMLEditRules::DidInsertNode(nsIDOMNode* aNode,
nsIDOMNode* aParent,
int32_t aPosition,
nsresult aResult)
{
if (!mListenerEnabled) {

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

@ -111,10 +111,9 @@ public:
nsIDOMNode* aNextSiblingOfNewNode) override;
NS_IMETHOD DidCreateNode(const nsAString& aTag, nsIDOMNode* aNewNode,
nsresult aResult) override;
NS_IMETHOD WillInsertNode(nsIDOMNode* aNode, nsIDOMNode* aParent,
int32_t aPosition) override;
NS_IMETHOD DidInsertNode(nsIDOMNode* aNode, nsIDOMNode* aParent,
int32_t aPosition, nsresult aResult) override;
NS_IMETHOD WillInsertNode(nsIDOMNode* aNode,
nsIDOMNode* aNextSiblingOfNewNode) override;
NS_IMETHOD DidInsertNode(nsIDOMNode* aNode, nsresult aResult) override;
NS_IMETHOD WillDeleteNode(nsIDOMNode* aChild) override;
NS_IMETHOD DidDeleteNode(nsIDOMNode* aChild, nsresult aResult) override;
NS_IMETHOD WillSplitNode(nsIDOMNode* aExistingRightNode,

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

@ -50,29 +50,21 @@ interface nsIEditActionListener : nsISupports{
/**
* Called before the editor inserts a node.
* @param aNode The DOM Node to insert.
* @param aParent The node to insert the new object into
* @param aPosition The place in aParent to insert the new node
* 0=first child, 1=second child, etc.
* any number > number of current children = last child
* @param aNode The DOM Node to insert.
* @param aNextSiblingOfNewNode The node which will be next sibling of
* new node. If the new node will be appended,
* this is null.
*/
void WillInsertNode(in nsIDOMNode aNode,
in nsIDOMNode aParent,
in long aPosition);
in nsIDOMNode aNextSiblingOfNewNode);
/**
* Called after the editor inserts a node.
* @param aNode The DOM Node to insert.
* @param aParent The node to insert the new object into
* @param aPosition The place in aParent to insert the new node
* 0=first child, 1=second child, etc.
* any number > number of current children = last child
* @param aResult The result of the insert node operation.
*/
void DidInsertNode(in nsIDOMNode aNode,
in nsIDOMNode aParent,
in long aPosition,
in nsresult aResult);
in nsresult aResult);
/**
* Called before the editor deletes a node.

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

@ -1499,10 +1499,8 @@ nsTextServicesDocument::InsertText(const nsString *aText)
}
NS_IMETHODIMP
nsTextServicesDocument::DidInsertNode(nsIDOMNode *aNode,
nsIDOMNode *aParent,
int32_t aPosition,
nsresult aResult)
nsTextServicesDocument::DidInsertNode(nsIDOMNode* aNode,
nsresult aResult)
{
return NS_OK;
}
@ -3241,9 +3239,8 @@ nsTextServicesDocument::FindWordBounds(nsTArray<OffsetEntry*> *aOffsetTable,
}
NS_IMETHODIMP
nsTextServicesDocument::WillInsertNode(nsIDOMNode *aNode,
nsIDOMNode *aParent,
int32_t aPosition)
nsTextServicesDocument::WillInsertNode(nsIDOMNode* aNode,
nsIDOMNode* aNextSiblingOfNewNode)
{
return NS_OK;
}

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

@ -91,13 +91,9 @@ public:
NS_IMETHOD InsertText(const nsString *aText) override;
/* nsIEditActionListener method implementations. */
NS_IMETHOD WillInsertNode(nsIDOMNode *aNode,
nsIDOMNode *aParent,
int32_t aPosition) override;
NS_IMETHOD DidInsertNode(nsIDOMNode *aNode,
nsIDOMNode *aParent,
int32_t aPosition,
nsresult aResult) override;
NS_IMETHOD WillInsertNode(nsIDOMNode* aNode,
nsIDOMNode* aNextSiblingOfNewNode) override;
NS_IMETHOD DidInsertNode(nsIDOMNode* aNode, nsresult aResult) override;
NS_IMETHOD WillDeleteNode(nsIDOMNode *aChild) override;
NS_IMETHOD DidDeleteNode(nsIDOMNode *aChild, nsresult aResult) override;

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

@ -1054,16 +1054,17 @@ mozInlineSpellChecker::DidCreateNode(const nsAString& aTag,
return NS_OK;
}
NS_IMETHODIMP mozInlineSpellChecker::WillInsertNode(nsIDOMNode *aNode, nsIDOMNode *aParent,
int32_t aPosition)
NS_IMETHODIMP
mozInlineSpellChecker::WillInsertNode(nsIDOMNode* aNode,
nsIDOMNode* aNextSiblingOfNewNode)
{
return NS_OK;
}
NS_IMETHODIMP mozInlineSpellChecker::DidInsertNode(nsIDOMNode *aNode, nsIDOMNode *aParent,
int32_t aPosition, nsresult aResult)
NS_IMETHODIMP
mozInlineSpellChecker::DidInsertNode(nsIDOMNode* aNode,
nsresult aResult)
{
return NS_OK;
}