Bug 1417400 - Get rid of nsIContentFilter. r?masayuki
m-c, c-c and bluegriffon don't use this interface. So we should remove this.
MozReview-Commit-ID: 92VwGKlrOw5
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -12,17 +12,16 @@
#include "mozilla/StyleSheet.h"
#include "mozilla/TextEditor.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/File.h"
#include "nsAttrName.h"
#include "nsCOMPtr.h"
-#include "nsIContentFilter.h"
#include "nsICSSLoaderObserver.h"
#include "nsIDocumentObserver.h"
#include "nsIDOMElement.h"
#include "nsIDOMEventListener.h"
#include "nsIEditorMailSupport.h"
#include "nsIEditorStyleSheets.h"
#include "nsIEditorUtils.h"
#include "nsIEditRules.h"
@@ -644,27 +643,16 @@ protected:
int32_t aIndex,
nsIDOMDocument* aSourceDoc,
nsIDOMNode* aDestinationNode,
int32_t aDestOffset,
bool aDoDeleteSelection) override;
bool HavePrivateHTMLFlavor(nsIClipboard* clipboard );
nsresult ParseCFHTML(nsCString& aCfhtml, char16_t** aStuffToPaste,
char16_t** aCfcontext);
- nsresult DoContentFilterCallback(const nsAString& aFlavor,
- nsIDOMDocument* aSourceDoc,
- bool aWillDeleteSelection,
- nsIDOMNode** aFragmentAsNode,
- nsIDOMNode** aFragStartNode,
- int32_t* aFragStartOffset,
- nsIDOMNode** aFragEndNode,
- int32_t* aFragEndOffset,
- nsIDOMNode** aTargetNode,
- int32_t* aTargetOffset,
- bool* aDoContinue);
bool IsInLink(nsIDOMNode* aNode, nsCOMPtr<nsIDOMNode>* outLink = nullptr);
nsresult StripFormattingNodes(nsIContent& aNode, bool aOnlyList = false);
nsresult CreateDOMFragmentFromPaste(const nsAString& aInputString,
const nsAString& aContextStr,
const nsAString& aInfoStr,
nsCOMPtr<nsIDOMNode>* outFragNode,
nsCOMPtr<nsIDOMNode>* outStartNode,
@@ -919,18 +907,16 @@ protected:
* AutoSelectionSetterAfterTableEdit stack-based object to
* insure we reset the caret in a table-editing method.
*/
void SetSelectionAfterTableEdit(nsIDOMElement* aTable,
int32_t aRow, int32_t aCol,
int32_t aDirection, bool aSelected);
protected:
- nsTArray<OwningNonNull<nsIContentFilter>> mContentFilters;
-
RefPtr<TypeInState> mTypeInState;
bool mCRInParagraphCreatesParagraph;
bool mCSSAware;
UniquePtr<CSSEditUtils> mCSSEditUtils;
// Used by GetFirstSelectedCell and GetNextSelectedCell
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -30,17 +30,16 @@
#include "nsIScriptError.h"
#include "nsContentUtils.h"
#include "nsDebug.h"
#include "nsDependentSubstring.h"
#include "nsError.h"
#include "nsGkAtoms.h"
#include "nsIClipboard.h"
#include "nsIContent.h"
-#include "nsIContentFilter.h"
#include "nsIDOMComment.h"
#include "nsIDOMDocument.h"
#include "nsIDOMDocumentFragment.h"
#include "nsIDOMElement.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMNode.h"
#include "nsIDocument.h"
#include "nsIEditRules.h"
@@ -221,30 +220,16 @@ HTMLEditor::DoInsertHTMLWithContext(cons
if (!targetNode || !IsEditable(targetNode)) {
return NS_ERROR_FAILURE;
}
} else {
targetNode = aDestNode;
targetOffset = aDestOffset;
}
- bool doContinue = true;
-
- rv = DoContentFilterCallback(aFlavor, aSourceDoc, aDeleteSelection,
- (nsIDOMNode **)address_of(fragmentAsNode),
- (nsIDOMNode **)address_of(streamStartParent),
- &streamStartOffset,
- (nsIDOMNode **)address_of(streamEndParent),
- &streamEndOffset,
- (nsIDOMNode **)address_of(targetNode),
- &targetOffset, &doContinue);
-
- NS_ENSURE_SUCCESS(rv, rv);
- NS_ENSURE_TRUE(doContinue, NS_OK);
-
// if we have a destination / target node, we want to insert there
// rather than in place of the selection
// ignore aDeleteSelection here if no aDestNode since deletion will
// also occur later; this block is intended to cover the various
// scenarios where we are dropping in an editor (and may want to delete
// the selection before collapsing the selection in the new destination)
if (aDestNode) {
if (aDeleteSelection) {
@@ -664,68 +649,16 @@ HTMLEditor::DoInsertHTMLWithContext(cons
}
}
}
}
return rules->DidDoAction(selection, &ruleInfo, rv);
}
-NS_IMETHODIMP
-HTMLEditor::AddInsertionListener(nsIContentFilter* aListener)
-{
- NS_ENSURE_TRUE(aListener, NS_ERROR_NULL_POINTER);
-
- // don't let a listener be added more than once
- if (!mContentFilters.Contains(aListener)) {
- mContentFilters.AppendElement(*aListener);
- }
-
- return NS_OK;
-}
-
-NS_IMETHODIMP
-HTMLEditor::RemoveInsertionListener(nsIContentFilter* aListener)
-{
- NS_ENSURE_TRUE(aListener, NS_ERROR_FAILURE);
-
- mContentFilters.RemoveElement(aListener);
-
- return NS_OK;
-}
-
-nsresult
-HTMLEditor::DoContentFilterCallback(const nsAString& aFlavor,
- nsIDOMDocument* sourceDoc,
- bool aWillDeleteSelection,
- nsIDOMNode** aFragmentAsNode,
- nsIDOMNode** aFragStartNode,
- int32_t* aFragStartOffset,
- nsIDOMNode** aFragEndNode,
- int32_t* aFragEndOffset,
- nsIDOMNode** aTargetNode,
- int32_t* aTargetOffset,
- bool* aDoContinue)
-{
- *aDoContinue = true;
-
- for (auto& listener : mContentFilters) {
- if (!*aDoContinue) {
- break;
- }
- listener->NotifyOfInsertion(aFlavor, nullptr, sourceDoc,
- aWillDeleteSelection, aFragmentAsNode,
- aFragStartNode, aFragStartOffset,
- aFragEndNode, aFragEndOffset, aTargetNode,
- aTargetOffset, aDoContinue);
- }
-
- return NS_OK;
-}
-
bool
HTMLEditor::IsInLink(nsIDOMNode* aNode,
nsCOMPtr<nsIDOMNode>* outLink)
{
NS_ENSURE_TRUE(aNode, false);
if (outLink) {
*outLink = nullptr;
}
--- a/editor/moz.build
+++ b/editor/moz.build
@@ -7,17 +7,16 @@
DIRS += [
'txtsvc',
'libeditor',
'txmgr',
'composer',
]
XPIDL_SOURCES += [
- 'nsIContentFilter.idl',
'nsIDocumentStateListener.idl',
'nsIEditActionListener.idl',
'nsIEditor.idl',
'nsIEditorMailSupport.idl',
'nsIEditorObserver.idl',
'nsIEditorSpellCheck.idl',
'nsIEditorStyleSheets.idl',
'nsIEditorUtils.idl',
deleted file mode 100644
--- a/editor/nsIContentFilter.idl
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsISupports.idl"
-#include "domstubs.idl"
-
-interface nsIURL;
-
-[scriptable, uuid(c18c49a8-62f0-4045-9884-4aa91e388f14)]
-interface nsIContentFilter : nsISupports
-{
- /**
- * This notification occurs in an editor during these events:
- * * open of document (once rendered in window but before editable)
- * * paste from clipboard
- * * drop from mouse
- * * insertion of html (such as with "cmd_insertHTML")
- * It provides a hook so the above actions can be canceled or the data
- * can be modified (using standard DOM APIs) or left untouched. The data
- * that results (if any) from all filter callbacks is what will be used
- * for transaction purposes (undo/redo) except for the open event.
- *
- * The willDeleteSelection parameter is offered for filters who want to
- * handle the insertion themselves and need to handle drag/drop correctly.
- * The flag is true when the editor intends to delete the selection.
- *
- * Callers who want to cancel all insertion can simply set
- * continueWithInsertion to PR_FALSE and return.
- * Note: If cancellation occurs during the "open" event, the editor will
- * still be available but will be empty.
- *
- * Callers who want to allow insertion of the data with no changes
- * can simply set continueWithInsertion to PR_TRUE and return.
- *
- * Callers who want to modify the content (docFragment) being inserted are
- * responsible for updating contentStartNode, contentStartOffset,
- * contentEndNode, and contentEndOffset (if necessary).
- * Callers are responsible for freeing and addref'ing if they want to
- * completely replace any of the DOM nodes passed in.
- *
- * The location where insertion will occur should be considered an
- * approximation since the editor may need to adjust it if it deletes
- * the selection as part of the event and later determines that insertion
- * point is an empty container which should also be removed (or in other
- * scenarios such as -moz-user-select:none).
- *
- * In some scenarios the selection will be deleted. If callers choose
- * to adjust the insertion point, they should be careful that the insertion
- * point is not in the current selection.
- *
- * The contentStartNode and contentEndNode are not necessarily
- * immediate children of the docFragment. Any nodes outside of the range
- * set by contentStartNode and contentEndNode are for context from the
- * source document.
- *
- * @param mimeType the mimetype used for retrieving data
- * @param contentSourceURL location where docFragment came from
- * @param sourceDocument document where content came from (can be null)
- * @param willDeleteSelection tells hook if selection will/should be deleted
- * @param docFragment fragment of node to be inserted
- * @param contentStartNode node under which content to be inserted begins
- * @param contentStartOffset start offset within contentStartNode
- * @param contentEndNode node under which content to be inserted ends
- * @param contentEndOffset ending offset withing contentEndNode
- * @param insertionPointNode location where insertion will occur
- * @param insertionPointOffset offset within node where insertion occurs
- * @param continueWithInsertion flag to cancel insertion (if desired)
- */
-
- void notifyOfInsertion(in AString mimeType,
- in nsIURL contentSourceURL,
- in nsIDOMDocument sourceDocument,
- in boolean willDeleteSelection,
- inout nsIDOMNode docFragment,
- inout nsIDOMNode contentStartNode,
- inout long contentStartOffset,
- inout nsIDOMNode contentEndNode,
- inout long contentEndOffset,
- inout nsIDOMNode insertionPointNode,
- inout long insertionPointOffset,
- out boolean continueWithInsertion);
-
-};
--- a/editor/nsIHTMLEditor.idl
+++ b/editor/nsIHTMLEditor.idl
@@ -4,17 +4,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "domstubs.idl"
interface nsIContent;
interface nsIArray;
interface nsISelection;
-interface nsIContentFilter;
%{C++
namespace mozilla {
namespace dom {
class Element;
}
}
%}
@@ -450,28 +449,16 @@ interface nsIHTMLEditor : nsISupports
* A boolean which is true is the HTMLEditor has been instantiated
* with CSS knowledge and if the CSS pref is currently checked
*
* @return true if CSS handled and enabled
*/
attribute boolean isCSSEnabled;
/**
- * Add listener for insertion override
- * @param inFilter function which callers want called during insertion
- */
- void addInsertionListener(in nsIContentFilter inFilter);
-
- /**
- * Remove listener for insertion override
- * @param inFilter function which callers do not want called during insertion
- */
- void removeInsertionListener(in nsIContentFilter inFilter);
-
- /**
* returns the deepest container of the selection
* @return a DOM Element
*/
nsIDOMElement getSelectionContainer();
/**
* Checks if the anonymous nodes created by the HTML editor have to be
* refreshed or hidden depending on a possible new state of the selection