Bug 1460940 - Remove nsIDOMDocument uses in editor/. r?bz
MozReview-Commit-ID: 8doC9drkrG9
--- a/editor/libeditor/EditorBase.cpp
+++ b/editor/libeditor/EditorBase.cpp
@@ -69,17 +69,16 @@
#include "nsFocusManager.h" // for nsFocusManager
#include "nsFrameSelection.h" // for nsFrameSelection
#include "nsGenericHTMLElement.h" // for nsGenericHTMLElement
#include "nsGkAtoms.h" // for nsGkAtoms, nsGkAtoms::dir
#include "nsIAbsorbingTransaction.h" // for nsIAbsorbingTransaction
#include "nsAtom.h" // for nsAtom
#include "nsIContent.h" // for nsIContent
#include "nsIDocument.h" // for nsIDocument
-#include "nsIDOMDocument.h" // for nsIDOMDocument
#include "nsIDOMEventListener.h" // for nsIDOMEventListener
#include "nsIDOMNode.h" // for nsIDOMNode, etc.
#include "nsIDocumentStateListener.h" // for nsIDocumentStateListener
#include "nsIEditActionListener.h" // for nsIEditActionListener
#include "nsIEditorObserver.h" // for nsIEditorObserver
#include "nsIEditorSpellCheck.h" // for nsIEditorSpellCheck
#include "nsIFrame.h" // for nsIFrame
#include "nsIHTMLDocument.h" // for nsIHTMLDocument
@@ -649,27 +648,20 @@ EditorBase::GetIsDocumentEditable(bool*
{
NS_ENSURE_ARG_POINTER(aIsDocumentEditable);
nsCOMPtr<nsIDocument> doc = GetDocument();
*aIsDocumentEditable = doc && IsModifiable();
return NS_OK;
}
-already_AddRefed<nsIDOMDocument>
-EditorBase::GetDOMDocument()
-{
- nsCOMPtr<nsIDOMDocument> domDocument = do_QueryInterface(mDocument);
- return domDocument.forget();
-}
-
NS_IMETHODIMP
-EditorBase::GetDocument(nsIDOMDocument** aDoc)
-{
- *aDoc = GetDOMDocument().take();
+EditorBase::GetDocument(nsIDocument** aDoc)
+{
+ NS_IF_ADDREF(*aDoc = mDocument);
return *aDoc ? NS_OK : NS_ERROR_NOT_INITIALIZED;
}
already_AddRefed<nsIWidget>
EditorBase::GetWidget()
{
nsCOMPtr<nsIPresShell> ps = GetPresShell();
NS_ENSURE_TRUE(ps, nullptr);
--- a/editor/libeditor/EditorBase.h
+++ b/editor/libeditor/EditorBase.h
@@ -34,17 +34,16 @@
#include "nsString.h" // for nsCString
#include "nsTArray.h" // for nsTArray and nsAutoTArray
#include "nsWeakReference.h" // for nsSupportsWeakReference
#include "nscore.h" // for nsresult, nsAString, etc.
class mozInlineSpellChecker;
class nsAtom;
class nsIContent;
-class nsIDOMDocument;
class nsIDOMNode;
class nsIDocumentStateListener;
class nsIEditActionListener;
class nsIEditorObserver;
class nsINode;
class nsIPresShell;
class nsISupports;
class nsITransaction;
@@ -234,17 +233,16 @@ public:
*/
virtual nsresult Init(nsIDocument& doc,
Element* aRoot,
nsISelectionController* aSelCon,
uint32_t aFlags,
const nsAString& aInitialValue);
bool IsInitialized() const { return !!mDocument; }
- already_AddRefed<nsIDOMDocument> GetDOMDocument();
nsIDocument* GetDocument() const { return mDocument; }
nsIPresShell* GetPresShell() const
{
return mDocument ? mDocument->GetShell() : nullptr;
}
nsPresContext* GetPresContext() const
{
nsIPresShell* presShell = GetPresShell();
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -22,17 +22,16 @@
#include "HTMLEditRules.h"
#include "HTMLEditUtils.h"
#include "HTMLURIRefObject.h"
#include "StyleSheetTransactions.h"
#include "TextEditUtils.h"
#include "TypeInState.h"
#include "nsHTMLDocument.h"
-#include "nsIDOMDocument.h"
#include "nsIDocumentInlines.h"
#include "nsISelectionController.h"
#include "nsILinkHandler.h"
#include "nsIInlineSpellChecker.h"
#include "mozilla/css/Loader.h"
#include "nsIContent.h"
--- a/editor/libeditor/HTMLEditor.h
+++ b/editor/libeditor/HTMLEditor.h
@@ -33,17 +33,16 @@
#include "nsPoint.h"
#include "nsStubMutationObserver.h"
#include "nsTArray.h"
class nsDocumentFragment;
class nsHTMLDocument;
class nsITransferable;
class nsIClipboard;
-class nsIDOMDocument;
class nsILinkHandler;
class nsTableWrapperFrame;
class nsIDOMRange;
class nsRange;
namespace mozilla {
class AutoSelectionSetterAfterTableEdit;
class HTMLEditorEventListener;
--- a/editor/libeditor/HTMLEditorDataTransfer.cpp
+++ b/editor/libeditor/HTMLEditorDataTransfer.cpp
@@ -33,17 +33,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 "nsIDOMDocument.h"
#include "nsIDOMNode.h"
#include "nsIDocument.h"
#include "nsIFile.h"
#include "nsIInputStream.h"
#include "nsIMIMEService.h"
#include "nsNameSpaceManager.h"
#include "nsINode.h"
#include "nsIParserUtils.h"
@@ -172,25 +171,24 @@ HTMLEditor::InsertHTML(const nsAString&
nullptr, nullptr, 0, true, true, false);
}
NS_IMETHODIMP
HTMLEditor::InsertHTMLWithContext(const nsAString& aInputString,
const nsAString& aContextStr,
const nsAString& aInfoStr,
const nsAString& aFlavor,
- nsIDOMDocument* aSourceDoc,
+ nsIDocument* aSourceDoc,
nsIDOMNode* aDestNode,
int32_t aDestOffset,
bool aDeleteSelection)
{
- nsCOMPtr<nsIDocument> sourceDoc = do_QueryInterface(aSourceDoc);
nsCOMPtr<nsINode> destNode = do_QueryInterface(aDestNode);
return DoInsertHTMLWithContext(aInputString, aContextStr, aInfoStr,
- aFlavor, sourceDoc, destNode, aDestOffset,
+ aFlavor, aSourceDoc, destNode, aDestOffset,
aDeleteSelection,
/* trusted input */ true,
/* clear style */ false);
}
nsresult
HTMLEditor::DoInsertHTMLWithContext(const nsAString& aInputString,
const nsAString& aContextStr,
--- a/editor/nsIEditor.idl
+++ b/editor/nsIEditor.idl
@@ -14,16 +14,17 @@ interface nsIDocumentStateListener;
interface nsIOutputStream;
interface nsITransactionManager;
interface nsITransaction;
interface nsIEditorObserver;
interface nsIEditActionListener;
interface nsIInlineSpellChecker;
interface nsITransferable;
+webidl Document;
webidl Element;
webidl Selection;
%{C++
namespace mozilla {
class EditorBase;
class HTMLEditor;
class TextEditor;
@@ -79,17 +80,17 @@ interface nsIEditor : nsISupports
readonly attribute boolean isDocumentEditable;
/** Returns true if the current selection anchor is editable */
readonly attribute boolean isSelectionEditable;
/**
* the DOM Document this editor is associated with, refcounted.
*/
- readonly attribute nsIDOMDocument document;
+ readonly attribute Document document;
/** the body element, i.e. the root of the editable document.
*/
readonly attribute Element rootElement;
/**
* the selection controller for the current presentation, refcounted.
*/
--- a/editor/nsIHTMLEditor.idl
+++ b/editor/nsIHTMLEditor.idl
@@ -4,16 +4,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
#include "domstubs.idl"
interface nsIContent;
interface nsIArray;
+webidl Document;
webidl Element;
webidl Node;
webidl Selection;
[scriptable, builtinclass, uuid(87ee993e-985f-4a43-a974-0d9512da2fb0)]
interface nsIHTMLEditor : nsISupports
{
%{C++
@@ -164,17 +165,17 @@ interface nsIHTMLEditor : nsISupports
* @param aDestinationOffset used with aDestNode to determine insert location
* @param aDeleteSelection used with aDestNode during drag&drop
* @param aCollapseSelection used with aDestNode during drag&drop
*/
void insertHTMLWithContext(in AString aInputString,
in AString aContextStr,
in AString aInfoStr,
in AString aFlavor,
- in nsIDOMDocument aSourceDoc,
+ in Document aSourceDoc,
in nsIDOMNode aDestinationNode,
in long aDestinationOffset,
in boolean aDeleteSelection);
/**
* Insert an element, which may have child nodes, at the selection
* Used primarily to insert a new element for various insert element dialogs,