From 11db05dbea7d01e1da18bc62054d925d2377a39a Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Mon, 13 Nov 2017 23:52:16 +0900 Subject: [PATCH] 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 --- editor/libeditor/EditorBase.cpp | 15 +++++++-------- editor/libeditor/HTMLEditRules.cpp | 4 +--- editor/libeditor/HTMLEditRules.h | 4 ++-- editor/nsIEditActionListener.idl | 11 +++++------ editor/txtsvc/nsTextServicesDocument.cpp | 10 ++-------- editor/txtsvc/nsTextServicesDocument.h | 6 ++---- .../spellcheck/src/mozInlineSpellChecker.cpp | 9 +++++---- 7 files changed, 24 insertions(+), 35 deletions(-) diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index a19e32c51747..9b62c2950e96 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -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; } diff --git a/editor/libeditor/HTMLEditRules.cpp b/editor/libeditor/HTMLEditRules.cpp index 7be0017e6f10..0b1bddacbf45 100644 --- a/editor/libeditor/HTMLEditRules.cpp +++ b/editor/libeditor/HTMLEditRules.cpp @@ -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; diff --git a/editor/libeditor/HTMLEditRules.h b/editor/libeditor/HTMLEditRules.h index 4fce64d2a1c5..99debebb236a 100644 --- a/editor/libeditor/HTMLEditRules.h +++ b/editor/libeditor/HTMLEditRules.h @@ -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, diff --git a/editor/nsIEditActionListener.idl b/editor/nsIEditActionListener.idl index 8c88c8833efc..edeb079a6d81 100644 --- a/editor/nsIEditActionListener.idl +++ b/editor/nsIEditActionListener.idl @@ -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. diff --git a/editor/txtsvc/nsTextServicesDocument.cpp b/editor/txtsvc/nsTextServicesDocument.cpp index cab0f821efc7..c367c45e379d 100644 --- a/editor/txtsvc/nsTextServicesDocument.cpp +++ b/editor/txtsvc/nsTextServicesDocument.cpp @@ -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; } diff --git a/editor/txtsvc/nsTextServicesDocument.h b/editor/txtsvc/nsTextServicesDocument.h index b84f1e2ad5ad..aa0a92803785 100644 --- a/editor/txtsvc/nsTextServicesDocument.h +++ b/editor/txtsvc/nsTextServicesDocument.h @@ -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, diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.cpp b/extensions/spellcheck/src/mozInlineSpellChecker.cpp index 8f78cec70330..177e1a15dbf6 100644 --- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp +++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp @@ -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); }