Bug 1413181 - part 4: Redesign nsIEditActionListener::DidSplitNode() r=m_kato

nsIEditActionListner::DidSplitNode() takes 4 arguments, the right node,
old offset in the old right node before splitting, the new left node and
nsresult.

Computing offset for this doesn't make sense because it's always same as
the length of the left node.  Additionally, nobody currently use nsersult.
So, we can get rid of it now.

Fortunately, nobody including comm-central and BlueGriffon implements
WillSplitNode().  So, we can get rid of it.  However, removing interface
method should be done in a follow up bug.  So, we can remove offset computation
in EditorBase::SplitNode() completely in the future.

MozReview-Commit-ID: JWj34SjBNJh

--HG--
extra : rebase_source : f0e1ed0e466dc8217c1a0ab1722790883a7efd1f
This commit is contained in:
Masayuki Nakano 2017-11-13 23:52:16 +09:00
Родитель 070ede0cf4
Коммит 11db05dbea
7 изменённых файлов: 24 добавлений и 35 удалений

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

@ -1546,11 +1546,14 @@ EditorBase::SplitNode(const EditorRawDOMPoint& aStartOfRightNode,
AutoRules beginRulesSniffing(this, EditAction::splitNode, nsIEditor::eNext);
// Different from CreateNode(), we need offset at start of right node only
// for WillSplitNode() and DidSplitNoe() since the offset is always same as
// the length of new left node.
// for WillSplitNode() since the offset is always same as the length of new
// left node.
{
AutoActionListenerArray listeners(mActionListeners);
for (auto& listener : listeners) {
// XXX Unfortunately, we need to compute offset here because the container
// may be a data node like text node. However, nobody implements this
// method actually. So, we should get rid of this in a follow up bug.
listener->WillSplitNode(aStartOfRightNode.Container()->AsDOMNode(),
aStartOfRightNode.Offset());
}
@ -1566,18 +1569,14 @@ EditorBase::SplitNode(const EditorRawDOMPoint& aStartOfRightNode,
mRangeUpdater.SelAdjSplitNode(*aStartOfRightNode.Container()->AsContent(),
newNode);
nsresult rv = aError.StealNSResult();
{
AutoActionListenerArray listeners(mActionListeners);
for (auto& listener : listeners) {
listener->DidSplitNode(aStartOfRightNode.Container()->AsDOMNode(),
aStartOfRightNode.Offset(),
GetAsDOMNode(newNode), rv);
GetAsDOMNode(newNode));
}
}
// Note: result might be a success code, so we can't use Throw() to
// set it on aResult.
aError = rv;
if (NS_WARN_IF(aError.Failed())) {
return nullptr;
}

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

@ -8679,9 +8679,7 @@ HTMLEditRules::WillSplitNode(nsIDOMNode* aExistingRightNode,
NS_IMETHODIMP
HTMLEditRules::DidSplitNode(nsIDOMNode* aExistingRightNode,
int32_t aOffset,
nsIDOMNode* aNewLeftNode,
nsresult aResult)
nsIDOMNode* aNewLeftNode)
{
if (!mListenerEnabled) {
return NS_OK;

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

@ -118,8 +118,8 @@ public:
NS_IMETHOD DidDeleteNode(nsIDOMNode* aChild, nsresult aResult) override;
NS_IMETHOD WillSplitNode(nsIDOMNode* aExistingRightNode,
int32_t aOffset) override;
NS_IMETHOD DidSplitNode(nsIDOMNode* aExistingRightNode, int32_t aOffset,
nsIDOMNode* aNewLeftNode, nsresult aResult) override;
NS_IMETHOD DidSplitNode(nsIDOMNode* aExistingRightNode,
nsIDOMNode* aNewLeftNode) override;
NS_IMETHOD WillJoinNodes(nsIDOMNode* aLeftNode, nsIDOMNode* aRightNode,
nsIDOMNode* aParent) override;
NS_IMETHOD DidJoinNodes(nsIDOMNode* aLeftNode, nsIDOMNode* aRightNode,

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

@ -98,14 +98,13 @@ interface nsIEditActionListener : nsISupports{
/**
* Called after the editor splits a node.
* @param aExistingRightNode the node to split. It will become the new node's next sibling.
* @param aOffset the offset of aExistingRightNode's content|children to do the split at
* @param aNewLeftNode [OUT] the new node resulting from the split, becomes aExistingRightNode's previous sibling.
* @param aExistingRightNode The node which was split. It will become the
* next sibling of the new left node.
* @param aNewLeftNode The new node resulting from the split, becomes
* the previous sibling of aExistingRightNode.
*/
void DidSplitNode(in nsIDOMNode aExistingRightNode,
in long aOffset,
in nsIDOMNode aNewLeftNode,
in nsresult aResult);
in nsIDOMNode aNewLeftNode);
/**
* Called before the editor joins 2 nodes.

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

@ -1620,15 +1620,9 @@ nsTextServicesDocument::DidDeleteNode(nsIDOMNode *aChild, nsresult aResult)
}
NS_IMETHODIMP
nsTextServicesDocument::DidSplitNode(nsIDOMNode *aExistingRightNode,
int32_t aOffset,
nsIDOMNode *aNewLeftNode,
nsresult aResult)
nsTextServicesDocument::DidSplitNode(nsIDOMNode* aExistingRightNode,
nsIDOMNode* aNewLeftNode)
{
//**** KDEBUG ****
// printf("** SplitNode: 0x%.8x %d 0x%.8x\n", aExistingRightNode, aOffset, aNewLeftNode);
// fflush(stdout);
//**** KDEBUG ****
return NS_OK;
}

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

@ -105,10 +105,8 @@ public:
NS_IMETHOD WillSplitNode(nsIDOMNode * aExistingRightNode,
int32_t aOffset) override;
NS_IMETHOD DidSplitNode(nsIDOMNode *aExistingRightNode,
int32_t aOffset,
nsIDOMNode *aNewLeftNode,
nsresult aResult) override;
NS_IMETHOD DidSplitNode(nsIDOMNode* aExistingRightNode,
nsIDOMNode* aNewLeftNode) override;
NS_IMETHOD WillJoinNodes(nsIDOMNode *aLeftNode,
nsIDOMNode *aRightNode,

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

@ -1092,15 +1092,16 @@ NS_IMETHODIMP mozInlineSpellChecker::DidDeleteNode(nsIDOMNode *aChild, nsresult
return NS_OK;
}
NS_IMETHODIMP mozInlineSpellChecker::WillSplitNode(nsIDOMNode *aExistingRightNode, int32_t aOffset)
NS_IMETHODIMP
mozInlineSpellChecker::WillSplitNode(nsIDOMNode* aExistingRightNode,
int32_t aOffset)
{
return NS_OK;
}
NS_IMETHODIMP
mozInlineSpellChecker::DidSplitNode(nsIDOMNode *aExistingRightNode,
int32_t aOffset,
nsIDOMNode *aNewLeftNode, nsresult aResult)
mozInlineSpellChecker::DidSplitNode(nsIDOMNode* aExistingRightNode,
nsIDOMNode* aNewLeftNode)
{
return SpellCheckBetweenNodes(aNewLeftNode, 0, aNewLeftNode, 0);
}