diff --git a/editor/libeditor/EditorBase.cpp b/editor/libeditor/EditorBase.cpp index 5228c74f2201..b70aa1ec66af 100644 --- a/editor/libeditor/EditorBase.cpp +++ b/editor/libeditor/EditorBase.cpp @@ -1430,14 +1430,6 @@ EditorBase::CreateNode(nsAtom* aTag, AutoRules beginRulesSniffing(this, EditAction::createNode, nsIEditor::eNext); - if (!mActionListeners.IsEmpty()) { - AutoActionListenerArray listeners(mActionListeners); - for (auto& listener : listeners) { - listener->WillCreateNode(nsDependentAtomString(aTag), - GetAsDOMNode(pointToInsert.GetChild())); - } - } - nsCOMPtr ret; RefPtr transaction = @@ -1500,15 +1492,6 @@ EditorBase::InsertNode(nsIContent& aContentToInsert, AutoRules beginRulesSniffing(this, EditAction::insertNode, nsIEditor::eNext); - if (!mActionListeners.IsEmpty()) { - AutoActionListenerArray listeners(mActionListeners); - for (auto& listener : listeners) { - listener->WillInsertNode( - aContentToInsert.AsDOMNode(), - GetAsDOMNode(aPointToInsert.GetNextSiblingOfChild())); - } - } - RefPtr transaction = InsertNodeTransaction::Create(*this, aContentToInsert, aPointToInsert); nsresult rv = DoTransaction(transaction); @@ -1565,24 +1548,10 @@ 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() since the offset is always same as the length of new - // left node. - if (!mActionListeners.IsEmpty()) { - 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.GetContainerAsDOMNode(), - aStartOfRightNode.Offset()); - } - } else { - // XXX Unfortunately, storing offset of the split point in - // SplitNodeTransaction is necessary for now. We should fix this - // in a follow up bug. - Unused << aStartOfRightNode.Offset(); - } + // XXX Unfortunately, storing offset of the split point in + // SplitNodeTransaction is necessary for now. We should fix this + // in a follow up bug. + Unused << aStartOfRightNode.Offset(); RefPtr transaction = SplitNodeTransaction::Create(*this, aStartOfRightNode); @@ -1648,14 +1617,6 @@ EditorBase::JoinNodes(nsINode& aLeftNode, htmlEditRules->WillJoinNodes(aLeftNode, aRightNode); } - if (!mActionListeners.IsEmpty()) { - AutoActionListenerArray listeners(mActionListeners); - for (auto& listener : listeners) { - listener->WillJoinNodes(aLeftNode.AsDOMNode(), aRightNode.AsDOMNode(), - parent->AsDOMNode()); - } - } - nsresult rv = NS_OK; RefPtr transaction = JoinNodeTransaction::MaybeCreate(*this, aLeftNode, aRightNode); @@ -1707,14 +1668,6 @@ EditorBase::DeleteNode(nsINode* aNode) htmlEditRules->WillDeleteNode(aNode); } - // save node location for selection updating code. - if (!mActionListeners.IsEmpty()) { - AutoActionListenerArray listeners(mActionListeners); - for (auto& listener : listeners) { - listener->WillDeleteNode(aNode->AsDOMNode()); - } - } - RefPtr deleteNodeTransaction = DeleteNodeTransaction::MaybeCreate(*this, *aNode); nsresult rv = deleteNodeTransaction ? DoTransaction(deleteNodeTransaction) : @@ -2845,16 +2798,6 @@ EditorBase::InsertTextIntoTextNodeImpl(const nsAString& aStringToInsert, InsertTextTransaction::Create(*this, aStringToInsert, aTextNode, aOffset); } - // Let listeners know what's up - if (!mActionListeners.IsEmpty()) { - AutoActionListenerArray listeners(mActionListeners); - for (auto& listener : listeners) { - listener->WillInsertText( - static_cast(insertedTextNode->AsDOMNode()), - insertedOffset, aStringToInsert); - } - } - // XXX We may not need these view batches anymore. This is handled at a // higher level now I believe. BeginUpdateViewBatch(); @@ -2996,19 +2939,11 @@ EditorBase::SetTextImpl(Selection& aSelection, const nsAString& aString, nsIEditor::eNext); // Let listeners know what's up - if (!mActionListeners.IsEmpty()) { + if (!mActionListeners.IsEmpty() && length) { AutoActionListenerArray listeners(mActionListeners); for (auto& listener : listeners) { - if (length) { - listener->WillDeleteText( - static_cast(aCharData.AsDOMNode()), 0, - length); - } - if (!aString.IsEmpty()) { - listener->WillInsertText( - static_cast(aCharData.AsDOMNode()), 0, - aString); - } + listener->WillDeleteText( + static_cast(aCharData.AsDOMNode()), 0, length); } } @@ -4434,21 +4369,18 @@ EditorBase::DeleteSelectionImpl(EDirection aAction, } } - // Notify nsIEditActionListener::WillDelete[Selection|Text|Node] + // Notify nsIEditActionListener::WillDelete[Selection|Text] if (!mActionListeners.IsEmpty()) { - AutoActionListenerArray listeners(mActionListeners); if (!deleteNode) { + AutoActionListenerArray listeners(mActionListeners); for (auto& listener : listeners) { listener->WillDeleteSelection(selection); } } else if (deleteCharData) { + AutoActionListenerArray listeners(mActionListeners); for (auto& listener : listeners) { listener->WillDeleteText(deleteCharData, deleteCharOffset, 1); } - } else { - for (auto& listener : listeners) { - listener->WillDeleteNode(deleteNode->AsDOMNode()); - } } } diff --git a/editor/nsIEditActionListener.idl b/editor/nsIEditActionListener.idl index 7183ca2653ba..ede39180da2f 100644 --- a/editor/nsIEditActionListener.idl +++ b/editor/nsIEditActionListener.idl @@ -26,18 +26,8 @@ Editor Action Listener interface to outside world */ [scriptable, uuid(b22907b1-ee93-11d2-8d50-000064657374)] -interface nsIEditActionListener : nsISupports{ - - /** - * Called before the editor creates a node. - * @param aTag The tag name of the DOM Node to create. - * @param aNextSiblingOfNewNode The node which will be next sibling of - * new node. If the new node will be appended, - * this is null. - */ - void WillCreateNode(in DOMString aTag, - in nsIDOMNode aNextSiblingOfNewNode); - +interface nsIEditActionListener : nsISupports +{ /** * Called after the editor creates a node. * @param aTag The tag name of the DOM Node to create. @@ -48,16 +38,6 @@ interface nsIEditActionListener : nsISupports{ in nsIDOMNode aNewNode, in nsresult aResult); - /** - * Called before the editor inserts a node. - * @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 aNextSiblingOfNewNode); - /** * Called after the editor inserts a node. * @param aNode The DOM Node to insert. @@ -66,12 +46,6 @@ interface nsIEditActionListener : nsISupports{ void DidInsertNode(in nsIDOMNode aNode, in nsresult aResult); - /** - * Called before the editor deletes a node. - * @param aChild The node to delete - */ - void WillDeleteNode(in nsIDOMNode aChild); - /** * Called after the editor deletes a node. * @param aChild The node to delete @@ -79,15 +53,6 @@ interface nsIEditActionListener : nsISupports{ */ void DidDeleteNode(in nsIDOMNode aChild, in nsresult aResult); - /** - * Called before 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. - */ - void WillSplitNode(in nsIDOMNode aExistingRightNode, - in long aOffset); - /** * Called after the editor splits a node. * @param aExistingRightNode The node which was split. It will become the @@ -98,18 +63,6 @@ interface nsIEditActionListener : nsISupports{ void DidSplitNode(in nsIDOMNode aExistingRightNode, in nsIDOMNode aNewLeftNode); - /** - * Called before the editor joins 2 nodes. - * @param aLeftNode This node will be merged into the right node - * @param aRightNode The node that will be merged into. - * There is no requirement that the two nodes be of - * the same type. - * @param aParent The parent of aRightNode - */ - void WillJoinNodes(in nsIDOMNode aLeftNode, - in nsIDOMNode aRightNode, - in nsIDOMNode aParent); - /** * Called after the editor joins 2 nodes. * @param aLeftNode This node will be merged into the right node @@ -124,16 +77,6 @@ interface nsIEditActionListener : nsISupports{ in nsIDOMNode aParent, in nsresult aResult); - /** - * Called before the editor inserts text. - * @param aTextNode This node getting inserted text - * @param aOffset The offset in aTextNode to insert at. - * @param aString The string that gets inserted. - */ - void WillInsertText(in nsIDOMCharacterData aTextNode, - in long aOffset, - in DOMString aString); - /** * Called after the editor inserts text. * @param aTextNode This node getting inserted text diff --git a/editor/txtsvc/nsTextServicesDocument.cpp b/editor/txtsvc/nsTextServicesDocument.cpp index b0f91dc9185d..b2f9a3755274 100644 --- a/editor/txtsvc/nsTextServicesDocument.cpp +++ b/editor/txtsvc/nsTextServicesDocument.cpp @@ -3238,45 +3238,10 @@ nsTextServicesDocument::FindWordBounds(nsTArray *aOffsetTable, return NS_OK; } -NS_IMETHODIMP -nsTextServicesDocument::WillInsertNode(nsIDOMNode* aNode, - nsIDOMNode* aNextSiblingOfNewNode) -{ - return NS_OK; -} - -NS_IMETHODIMP -nsTextServicesDocument::WillDeleteNode(nsIDOMNode *aChild) -{ - return NS_OK; -} - -NS_IMETHODIMP -nsTextServicesDocument::WillSplitNode(nsIDOMNode *aExistingRightNode, - int32_t aOffset) -{ - return NS_OK; -} - -NS_IMETHODIMP -nsTextServicesDocument::WillJoinNodes(nsIDOMNode *aLeftNode, - nsIDOMNode *aRightNode, - nsIDOMNode *aParent) -{ - return NS_OK; -} - // ------------------------------- // stubs for unused listen methods // ------------------------------- -NS_IMETHODIMP -nsTextServicesDocument::WillCreateNode(const nsAString& aTag, - nsIDOMNode* aNextSiblingOfNewNode) -{ - return NS_OK; -} - NS_IMETHODIMP nsTextServicesDocument::DidCreateNode(const nsAString& aTag, nsIDOMNode* aNewNode, @@ -3286,37 +3251,39 @@ nsTextServicesDocument::DidCreateNode(const nsAString& aTag, } NS_IMETHODIMP -nsTextServicesDocument::WillInsertText(nsIDOMCharacterData *aTextNode, int32_t aOffset, const nsAString &aString) +nsTextServicesDocument::DidInsertText(nsIDOMCharacterData* aTextNode, + int32_t aOffset, + const nsAString& aString, + nsresult aResult) { return NS_OK; } NS_IMETHODIMP -nsTextServicesDocument::DidInsertText(nsIDOMCharacterData *aTextNode, int32_t aOffset, const nsAString &aString, nsresult aResult) +nsTextServicesDocument::WillDeleteText(nsIDOMCharacterData* aTextNode, + int32_t aOffset, + int32_t aLength) { return NS_OK; } NS_IMETHODIMP -nsTextServicesDocument::WillDeleteText(nsIDOMCharacterData *aTextNode, int32_t aOffset, int32_t aLength) +nsTextServicesDocument::DidDeleteText(nsIDOMCharacterData* aTextNode, + int32_t aOffset, + int32_t aLength, + nsresult aResult) { return NS_OK; } NS_IMETHODIMP -nsTextServicesDocument::DidDeleteText(nsIDOMCharacterData *aTextNode, int32_t aOffset, int32_t aLength, nsresult aResult) +nsTextServicesDocument::WillDeleteSelection(nsISelection* aSelection) { return NS_OK; } NS_IMETHODIMP -nsTextServicesDocument::WillDeleteSelection(nsISelection *aSelection) -{ - return NS_OK; -} - -NS_IMETHODIMP -nsTextServicesDocument::DidDeleteSelection(nsISelection *aSelection) +nsTextServicesDocument::DidDeleteSelection(nsISelection* aSelection) { return NS_OK; } diff --git a/editor/txtsvc/nsTextServicesDocument.h b/editor/txtsvc/nsTextServicesDocument.h index 18498fffc8b8..dd34a2ad18b3 100644 --- a/editor/txtsvc/nsTextServicesDocument.h +++ b/editor/txtsvc/nsTextServicesDocument.h @@ -91,37 +91,7 @@ public: NS_IMETHOD InsertText(const nsString *aText) override; /* nsIEditActionListener method implementations. */ - 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, - int32_t aOffset) 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, - nsIDOMNode *aParent, - nsresult aResult) override; - // these listen methods are unused: - NS_IMETHOD WillCreateNode(const nsAString& aTag, - nsIDOMNode* aNextSiblingOfNewNode) override; - NS_IMETHOD DidCreateNode(const nsAString& aTag, - nsIDOMNode* aNewNode, - nsresult aResult) override; - NS_IMETHOD WillInsertText(nsIDOMCharacterData *aTextNode, int32_t aOffset, const nsAString &aString) override; - NS_IMETHOD DidInsertText(nsIDOMCharacterData *aTextNode, int32_t aOffset, const nsAString &aString, nsresult aResult) override; - NS_IMETHOD WillDeleteText(nsIDOMCharacterData *aTextNode, int32_t aOffset, int32_t aLength) override; - NS_IMETHOD DidDeleteText(nsIDOMCharacterData *aTextNode, int32_t aOffset, int32_t aLength, nsresult aResult) override; - NS_IMETHOD WillDeleteSelection(nsISelection *aSelection) override; - NS_IMETHOD DidDeleteSelection(nsISelection *aSelection) override; + NS_DECL_NSIEDITACTIONLISTENER /* Helper functions */ static nsresult GetRangeEndPoints(nsRange* aRange, diff --git a/extensions/spellcheck/src/mozInlineSpellChecker.cpp b/extensions/spellcheck/src/mozInlineSpellChecker.cpp index 89cd8bc1d3d6..d84d526cb2f5 100644 --- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp +++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp @@ -1038,13 +1038,6 @@ mozInlineSpellChecker::IgnoreWords(const char16_t **aWordsToIgnore, return ScheduleSpellCheck(Move(status)); } -NS_IMETHODIMP -mozInlineSpellChecker::WillCreateNode(const nsAString& aTag, - nsIDOMNode* aNextSiblingOfNewNode) -{ - return NS_OK; -} - NS_IMETHODIMP mozInlineSpellChecker::DidCreateNode(const nsAString& aTag, nsIDOMNode* aNewNode, @@ -1053,13 +1046,6 @@ mozInlineSpellChecker::DidCreateNode(const nsAString& aTag, return NS_OK; } -NS_IMETHODIMP -mozInlineSpellChecker::WillInsertNode(nsIDOMNode* aNode, - nsIDOMNode* aNextSiblingOfNewNode) -{ - return NS_OK; -} - NS_IMETHODIMP mozInlineSpellChecker::DidInsertNode(nsIDOMNode* aNode, nsresult aResult) @@ -1067,19 +1053,9 @@ mozInlineSpellChecker::DidInsertNode(nsIDOMNode* aNode, return NS_OK; } -NS_IMETHODIMP mozInlineSpellChecker::WillDeleteNode(nsIDOMNode *aChild) -{ - return NS_OK; -} - -NS_IMETHODIMP mozInlineSpellChecker::DidDeleteNode(nsIDOMNode *aChild, nsresult aResult) -{ - return NS_OK; -} - NS_IMETHODIMP -mozInlineSpellChecker::WillSplitNode(nsIDOMNode* aExistingRightNode, - int32_t aOffset) +mozInlineSpellChecker::DidDeleteNode(nsIDOMNode* aChild, + nsresult aResult) { return NS_OK; } @@ -1091,44 +1067,49 @@ mozInlineSpellChecker::DidSplitNode(nsIDOMNode* aExistingRightNode, return SpellCheckBetweenNodes(aNewLeftNode, 0, aNewLeftNode, 0); } -NS_IMETHODIMP mozInlineSpellChecker::WillJoinNodes(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, nsIDOMNode *aParent) -{ - return NS_OK; -} - -NS_IMETHODIMP mozInlineSpellChecker::DidJoinNodes(nsIDOMNode *aLeftNode, nsIDOMNode *aRightNode, - nsIDOMNode *aParent, nsresult aResult) +NS_IMETHODIMP +mozInlineSpellChecker::DidJoinNodes(nsIDOMNode* aLeftNode, + nsIDOMNode* aRightNode, + nsIDOMNode* aParent, + nsresult aResult) { return SpellCheckBetweenNodes(aRightNode, 0, aRightNode, 0); } -NS_IMETHODIMP mozInlineSpellChecker::WillInsertText(nsIDOMCharacterData *aTextNode, int32_t aOffset, const nsAString & aString) +NS_IMETHODIMP +mozInlineSpellChecker::DidInsertText(nsIDOMCharacterData* aTextNode, + int32_t aOffset, + const nsAString& aString, + nsresult aResult) { return NS_OK; } -NS_IMETHODIMP mozInlineSpellChecker::DidInsertText(nsIDOMCharacterData *aTextNode, int32_t aOffset, - const nsAString & aString, nsresult aResult) +NS_IMETHODIMP +mozInlineSpellChecker::WillDeleteText(nsIDOMCharacterData* aTextNode, + int32_t aOffset, + int32_t aLength) { return NS_OK; } -NS_IMETHODIMP mozInlineSpellChecker::WillDeleteText(nsIDOMCharacterData *aTextNode, int32_t aOffset, int32_t aLength) +NS_IMETHODIMP +mozInlineSpellChecker::DidDeleteText(nsIDOMCharacterData* aTextNode, + int32_t aOffset, + int32_t aLength, + nsresult aResult) { return NS_OK; } -NS_IMETHODIMP mozInlineSpellChecker::DidDeleteText(nsIDOMCharacterData *aTextNode, int32_t aOffset, int32_t aLength, nsresult aResult) +NS_IMETHODIMP +mozInlineSpellChecker::WillDeleteSelection(nsISelection* aSelection) { return NS_OK; } -NS_IMETHODIMP mozInlineSpellChecker::WillDeleteSelection(nsISelection *aSelection) -{ - return NS_OK; -} - -NS_IMETHODIMP mozInlineSpellChecker::DidDeleteSelection(nsISelection *aSelection) +NS_IMETHODIMP +mozInlineSpellChecker::DidDeleteSelection(nsISelection* aSelection) { return NS_OK; }