--- a/dom/base/DOMImplementation.cpp
+++ b/dom/base/DOMImplementation.cpp
@@ -5,17 +5,16 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/DOMImplementation.h"
#include "mozilla/ContentEvents.h"
#include "mozilla/dom/DOMImplementationBinding.h"
#include "nsContentCreatorFunctions.h"
#include "nsContentUtils.h"
-#include "nsIDOMDocument.h"
#include "mozilla/dom/DocumentType.h"
#include "nsTextNode.h"
namespace mozilla {
namespace dom {
// QueryInterface implementation for DOMImplementation
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMImplementation)
@@ -86,30 +85,29 @@ DOMImplementation::CreateDocument(const
}
}
nsCOMPtr<nsIGlobalObject> scriptHandlingObject =
do_QueryReferent(mScriptObject);
NS_ENSURE_STATE(!mScriptObject || scriptHandlingObject);
- nsCOMPtr<nsIDOMDocument> document;
+ nsCOMPtr<nsIDocument> doc;
- rv = NS_NewDOMDocument(getter_AddRefs(document),
+ rv = NS_NewDOMDocument(getter_AddRefs(doc),
aNamespaceURI, aQualifiedName, aDoctype,
mDocumentURI, mBaseURI,
mOwner->NodePrincipal(),
true, scriptHandlingObject,
DocumentFlavorLegacyGuess);
NS_ENSURE_SUCCESS(rv, rv);
// When DOMImplementation's createDocument method is invoked with
// namespace set to HTML Namespace use the registry of the associated
// document to the new instance.
- nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);
if (aNamespaceURI.EqualsLiteral("http://www.w3.org/1999/xhtml")) {
doc->SetContentType(NS_LITERAL_STRING("application/xhtml+xml"));
} else if (aNamespaceURI.EqualsLiteral("http://www.w3.org/2000/svg")) {
doc->SetContentType(NS_LITERAL_STRING("image/svg+xml"));
} else {
doc->SetContentType(NS_LITERAL_STRING("application/xml"));
}
@@ -148,25 +146,24 @@ DOMImplementation::CreateHTMLDocument(co
EmptyString(), // aSystemId
VoidString()); // aInternalSubset
nsCOMPtr<nsIGlobalObject> scriptHandlingObject =
do_QueryReferent(mScriptObject);
NS_ENSURE_STATE(!mScriptObject || scriptHandlingObject);
- nsCOMPtr<nsIDOMDocument> document;
- nsresult rv = NS_NewDOMDocument(getter_AddRefs(document),
+ nsCOMPtr<nsIDocument> doc;
+ nsresult rv = NS_NewDOMDocument(getter_AddRefs(doc),
EmptyString(), EmptyString(),
doctype, mDocumentURI, mBaseURI,
mOwner->NodePrincipal(),
true, scriptHandlingObject,
DocumentFlavorLegacyGuess);
NS_ENSURE_SUCCESS(rv, rv);
- nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);
nsCOMPtr<Element> root = doc->CreateElem(NS_LITERAL_STRING("html"), nullptr,
kNameSpaceID_XHTML);
rv = doc->AppendChildTo(root, false);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<Element> head = doc->CreateElem(NS_LITERAL_STRING("head"), nullptr,
kNameSpaceID_XHTML);
--- a/dom/base/DOMParser.cpp
+++ b/dom/base/DOMParser.cpp
@@ -1,17 +1,16 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "mozilla/dom/DOMParser.h"
-#include "nsIDOMDocument.h"
#include "nsNetUtil.h"
#include "nsDOMString.h"
#include "MainThreadUtils.h"
#include "nsIStreamListener.h"
#include "nsStringStream.h"
#include "nsIScriptError.h"
#include "nsIScriptSecurityManager.h"
#include "nsCRT.h"
@@ -304,20 +303,19 @@ DOMParser::SetUpDocument(DocumentFlavor
// off of nsIScriptGlobalObject, but that's a yak to shave another day.
nsCOMPtr<nsIScriptGlobalObject> scriptHandlingObject =
do_QueryInterface(mOwner);
// Try to inherit a style backend.
NS_ASSERTION(mPrincipal, "Must have principal by now");
NS_ASSERTION(mDocumentURI, "Must have document URI by now");
- nsCOMPtr<nsIDOMDocument> domDoc;
- nsresult rv = NS_NewDOMDocument(getter_AddRefs(domDoc), EmptyString(), EmptyString(),
+ nsCOMPtr<nsIDocument> doc;
+ nsresult rv = NS_NewDOMDocument(getter_AddRefs(doc), EmptyString(), EmptyString(),
nullptr, mDocumentURI, mBaseURI, mPrincipal,
true, scriptHandlingObject, aFlavor);
if (NS_WARN_IF(NS_FAILED(rv))) {
aRv.Throw(rv);
return nullptr;
}
- nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
return doc.forget();
}
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -5202,30 +5202,30 @@ nsresult
nsContentUtils::ConvertToPlainText(const nsAString& aSourceBuffer,
nsAString& aResultBuffer,
uint32_t aFlags,
uint32_t aWrapCol)
{
nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), "about:blank");
nsCOMPtr<nsIPrincipal> principal = NullPrincipal::CreateWithoutOriginAttributes();
- nsCOMPtr<nsIDOMDocument> domDocument;
- nsresult rv = NS_NewDOMDocument(getter_AddRefs(domDocument),
+ nsCOMPtr<nsIDocument> document;
+ nsresult rv = NS_NewDOMDocument(getter_AddRefs(document),
EmptyString(),
EmptyString(),
nullptr,
uri,
uri,
principal,
true,
nullptr,
DocumentFlavorHTML);
NS_ENSURE_SUCCESS(rv, rv);
- nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
+ nsCOMPtr<nsIDOMDocument> domDocument = do_QueryInterface(document);
rv = nsContentUtils::ParseDocumentHTML(aSourceBuffer, document,
!(aFlags & nsIDocumentEncoder::OutputNoScriptContent));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIDocumentEncoder> encoder = do_CreateInstance(
"@mozilla.org/layout/documentEncoder;1?type=text/plain");
rv = encoder->Init(domDocument, NS_LITERAL_STRING("text/plain"), aFlags);
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -9244,30 +9244,30 @@ nsIDocument::GetCurrentContentSink()
nsIDocument*
nsIDocument::GetTemplateContentsOwner()
{
if (!mTemplateContentsOwner) {
bool hasHadScriptObject = true;
nsIScriptGlobalObject* scriptObject =
GetScriptHandlingObject(hasHadScriptObject);
- nsCOMPtr<nsIDOMDocument> domDocument;
- nsresult rv = NS_NewDOMDocument(getter_AddRefs(domDocument),
+ nsCOMPtr<nsIDocument> document;
+ nsresult rv = NS_NewDOMDocument(getter_AddRefs(document),
EmptyString(), // aNamespaceURI
EmptyString(), // aQualifiedName
nullptr, // aDoctype
nsIDocument::GetDocumentURI(),
nsIDocument::GetDocBaseURI(),
NodePrincipal(),
true, // aLoadedAsData
scriptObject, // aEventObject
DocumentFlavorHTML);
NS_ENSURE_SUCCESS(rv, nullptr);
- mTemplateContentsOwner = do_QueryInterface(domDocument);
+ mTemplateContentsOwner = document;
NS_ENSURE_TRUE(mTemplateContentsOwner, nullptr);
nsDocument* doc = static_cast<nsDocument*>(mTemplateContentsOwner.get());
if (!scriptObject) {
mTemplateContentsOwner->SetScopeObject(GetScopeObject());
}
@@ -11898,34 +11898,33 @@ nsIDocument::Constructor(const GlobalObj
nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), "about:blank");
if (!uri) {
rv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}
- nsCOMPtr<nsIDOMDocument> document;
+ nsCOMPtr<nsIDocument> doc;
nsresult res =
- NS_NewDOMDocument(getter_AddRefs(document),
+ NS_NewDOMDocument(getter_AddRefs(doc),
VoidString(),
EmptyString(),
nullptr,
uri,
uri,
prin->GetPrincipal(),
true,
global,
DocumentFlavorPlain);
if (NS_FAILED(res)) {
rv.Throw(res);
return nullptr;
}
- nsCOMPtr<nsIDocument> doc = do_QueryInterface(document);
doc->SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE);
return doc.forget();
}
XPathExpression*
nsIDocument::CreateExpression(const nsAString& aExpression,
XPathNSResolver* aResolver,
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -4572,31 +4572,31 @@ NS_NewImageDocument(nsIDocument** aInsta
nsresult
NS_NewVideoDocument(nsIDocument** aInstancePtrResult);
// Note: it's the caller's responsibility to create or get aPrincipal as needed
// -- this method will not attempt to get a principal based on aDocumentURI.
// Also, both aDocumentURI and aBaseURI must not be null.
nsresult
-NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
+NS_NewDOMDocument(nsIDocument** aInstancePtrResult,
const nsAString& aNamespaceURI,
const nsAString& aQualifiedName,
mozilla::dom::DocumentType* aDoctype,
nsIURI* aDocumentURI,
nsIURI* aBaseURI,
nsIPrincipal* aPrincipal,
bool aLoadedAsData,
nsIGlobalObject* aEventObject,
DocumentFlavor aFlavor);
// This is used only for xbl documents created from the startup cache.
// Non-cached documents are created in the same manner as xml documents.
nsresult
-NS_NewXBLDocument(nsIDOMDocument** aInstancePtrResult,
+NS_NewXBLDocument(nsIDocument** aInstancePtrResult,
nsIURI* aDocumentURI,
nsIURI* aBaseURI,
nsIPrincipal* aPrincipal);
nsresult
NS_NewPluginDocument(nsIDocument** aInstancePtrResult);
inline nsIDocument*
--- a/dom/xbl/nsXBLDocumentInfo.cpp
+++ b/dom/xbl/nsXBLDocumentInfo.cpp
@@ -6,17 +6,16 @@
#include "mozilla/DebugOnly.h"
#include "nsXBLDocumentInfo.h"
#include "nsIDocument.h"
#include "nsXBLPrototypeBinding.h"
#include "nsIScriptObjectPrincipal.h"
#include "nsIScriptContext.h"
-#include "nsIDOMDocument.h"
#include "jsapi.h"
#include "jsfriendapi.h"
#include "nsIURI.h"
#include "nsIConsoleService.h"
#include "nsIScriptError.h"
#include "nsIChromeRegistry.h"
#include "nsIPrincipal.h"
#include "nsJSPrincipals.h"
@@ -222,23 +221,20 @@ nsXBLDocumentInfo::ReadPrototypeBindings
startupCache->InvalidateCache();
return NS_ERROR_NOT_AVAILABLE;
}
nsCOMPtr<nsIPrincipal> principal;
nsContentUtils::GetSecurityManager()->
GetSystemPrincipal(getter_AddRefs(principal));
- nsCOMPtr<nsIDOMDocument> domdoc;
- rv = NS_NewXBLDocument(getter_AddRefs(domdoc), aURI, nullptr, principal);
+ nsCOMPtr<nsIDocument> doc;
+ rv = NS_NewXBLDocument(getter_AddRefs(doc), aURI, nullptr, principal);
NS_ENSURE_SUCCESS(rv, rv);
- nsCOMPtr<nsIDocument> doc = do_QueryInterface(domdoc);
- NS_ASSERTION(doc, "Must have a document!");
-
RefPtr<nsXBLDocumentInfo> docInfo = new nsXBLDocumentInfo(doc);
while (1) {
uint8_t flags;
nsresult rv = stream->Read8(&flags);
NS_ENSURE_SUCCESS(rv, rv);
if (flags == XBLBinding_Serialize_NoMoreBindings)
break;
--- a/dom/xhr/XMLHttpRequestMainThread.cpp
+++ b/dom/xhr/XMLHttpRequestMainThread.cpp
@@ -27,17 +27,16 @@
#include "mozilla/dom/PromiseNativeHandler.h"
#include "mozilla/Encoding.h"
#include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h"
#include "mozilla/EventStateManager.h"
#include "mozilla/LoadInfo.h"
#include "mozilla/LoadContext.h"
#include "mozilla/MemoryReporting.h"
-#include "nsIDOMDocument.h"
#include "mozilla/dom/ProgressEvent.h"
#include "nsIJARChannel.h"
#include "nsIJARURI.h"
#include "nsLayoutCID.h"
#include "nsReadableUtils.h"
#include "nsIURI.h"
#include "nsIURIMutator.h"
@@ -1997,31 +1996,29 @@ XMLHttpRequestMainThread::OnStartRequest
// have been killed already.
if (NS_WARN_IF(NS_FAILED(CheckInnerWindowCorrectness()))) {
return NS_ERROR_DOM_INVALID_STATE_XHR_HAS_INVALID_CONTEXT;
}
}
// Create an empty document from it.
const nsAString& emptyStr = EmptyString();
- nsCOMPtr<nsIDOMDocument> responseDoc;
nsIGlobalObject* global = DOMEventTargetHelper::GetParentObject();
nsCOMPtr<nsIPrincipal> requestingPrincipal;
rv = nsContentUtils::GetSecurityManager()->
GetChannelResultPrincipal(channel, getter_AddRefs(requestingPrincipal));
NS_ENSURE_SUCCESS(rv, rv);
- rv = NS_NewDOMDocument(getter_AddRefs(responseDoc),
+ rv = NS_NewDOMDocument(getter_AddRefs(mResponseXML),
emptyStr, emptyStr, nullptr, docURI,
baseURI, requestingPrincipal, true, global,
mIsHtml ? DocumentFlavorHTML :
DocumentFlavorLegacyGuess);
NS_ENSURE_SUCCESS(rv, rv);
- mResponseXML = do_QueryInterface(responseDoc);
mResponseXML->SetChromeXHRDocURI(chromeXHRDocURI);
mResponseXML->SetChromeXHRDocBaseURI(chromeXHRDocBaseURI);
// suppress parsing failure messages to console for statuses which
// can have empty bodies (see bug 884693).
IgnoredErrorResult rv2;
uint32_t responseStatus = GetStatus(rv2);
if (!rv2.Failed() &&
--- a/dom/xml/XMLDocument.cpp
+++ b/dom/xml/XMLDocument.cpp
@@ -53,17 +53,17 @@ using namespace mozilla;
using namespace mozilla::dom;
// ==================================================================
// =
// ==================================================================
nsresult
-NS_NewDOMDocument(nsIDOMDocument** aInstancePtrResult,
+NS_NewDOMDocument(nsIDocument** aInstancePtrResult,
const nsAString& aNamespaceURI,
const nsAString& aQualifiedName,
DocumentType* aDoctype,
nsIURI* aDocumentURI,
nsIURI* aBaseURI,
nsIPrincipal* aPrincipal,
bool aLoadedAsData,
nsIGlobalObject* aEventObject,
@@ -179,18 +179,17 @@ NS_NewDOMDocument(nsIDOMDocument** aInst
// exception (which it can) and we're neither propagating the
// error out nor unconditionally suppressing it.
result.WouldReportJSException();
if (NS_WARN_IF(result.Failed())) {
return result.StealNSResult();
}
}
- *aInstancePtrResult = doc;
- NS_ADDREF(*aInstancePtrResult);
+ d.forget(aInstancePtrResult);
return NS_OK;
}
nsresult
NS_NewXMLDocument(nsIDocument** aInstancePtrResult, bool aLoadedAsData,
bool aIsPlainDocument)
{
@@ -206,36 +205,36 @@ NS_NewXMLDocument(nsIDocument** aInstanc
doc->SetLoadedAsData(aLoadedAsData);
doc->mIsPlainDocument = aIsPlainDocument;
doc.forget(aInstancePtrResult);
return NS_OK;
}
nsresult
-NS_NewXBLDocument(nsIDOMDocument** aInstancePtrResult,
+NS_NewXBLDocument(nsIDocument** aInstancePtrResult,
nsIURI* aDocumentURI,
nsIURI* aBaseURI,
nsIPrincipal* aPrincipal)
{
nsresult rv = NS_NewDOMDocument(aInstancePtrResult,
NS_LITERAL_STRING("http://www.mozilla.org/xbl"),
NS_LITERAL_STRING("bindings"), nullptr,
aDocumentURI, aBaseURI, aPrincipal, false,
nullptr, DocumentFlavorLegacyGuess);
NS_ENSURE_SUCCESS(rv, rv);
- nsCOMPtr<nsIDocument> idoc = do_QueryInterface(*aInstancePtrResult);
+ nsIDocument* idoc = *aInstancePtrResult;
// XBL documents must allow XUL and XBL elements in them but the usual check
// only checks if the document is loaded in the system principal which is
// sometimes not the case.
idoc->ForceEnableXULXBL();
- nsDocument* doc = static_cast<nsDocument*>(idoc.get());
+ nsDocument* doc = static_cast<nsDocument*>(idoc);
doc->SetLoadedAsInteractiveData(true);
doc->SetReadyStateInternal(nsIDocument::READYSTATE_COMPLETE);
return NS_OK;
}
namespace mozilla {
namespace dom {
--- a/gfx/thebes/gfxSVGGlyphs.cpp
+++ b/gfx/thebes/gfxSVGGlyphs.cpp
@@ -1,17 +1,16 @@
/* 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 "gfxSVGGlyphs.h"
#include "mozilla/SVGContextPaint.h"
#include "nsError.h"
-#include "nsIDOMDocument.h"
#include "nsString.h"
#include "nsIDocument.h"
#include "nsICategoryManager.h"
#include "nsIDocumentLoaderFactory.h"
#include "nsIContentViewer.h"
#include "nsIStreamListener.h"
#include "nsServiceManagerUtils.h"
#include "nsIPresShell.h"
@@ -356,32 +355,27 @@ gfxSVGGlyphsDocument::ParseDocument(cons
nullptr,
mSVGGlyphsDocumentURI);
rv = NS_NewURI(getter_AddRefs(uri), mSVGGlyphsDocumentURI);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrincipal> principal = NullPrincipal::CreateWithoutOriginAttributes();
- nsCOMPtr<nsIDOMDocument> domDoc;
- rv = NS_NewDOMDocument(getter_AddRefs(domDoc),
+ nsCOMPtr<nsIDocument> document;
+ rv = NS_NewDOMDocument(getter_AddRefs(document),
EmptyString(), // aNamespaceURI
EmptyString(), // aQualifiedName
nullptr, // aDoctype
uri, uri, principal,
false, // aLoadedAsData
nullptr, // aEventObject
DocumentFlavorSVG);
NS_ENSURE_SUCCESS(rv, rv);
- nsCOMPtr<nsIDocument> document(do_QueryInterface(domDoc));
- if (!document) {
- return NS_ERROR_FAILURE;
- }
-
nsCOMPtr<nsIChannel> channel;
rv = NS_NewInputStreamChannel(getter_AddRefs(channel),
uri,
nullptr, //aStream
principal,
nsILoadInfo::SEC_FORCE_INHERIT_PRINCIPAL,
nsIContentPolicy::TYPE_OTHER,
SVG_CONTENT_TYPE,
--- a/parser/html/nsParserUtils.cpp
+++ b/parser/html/nsParserUtils.cpp
@@ -14,17 +14,16 @@
#include "nsContentCID.h"
#include "nsContentUtils.h"
#include "nsEscape.h"
#include "nsHTMLParts.h"
#include "nsHtml5Module.h"
#include "nsIComponentManager.h"
#include "nsIContent.h"
#include "nsIContentSink.h"
-#include "nsIDOMDocument.h"
#include "nsIDOMNode.h"
#include "nsIDTD.h"
#include "nsIDocument.h"
#include "nsIDocumentEncoder.h"
#include "nsIFragmentContentSink.h"
#include "nsIParser.h"
#include "nsIScriptableUnescapeHTML.h"
#include "nsISupportsPrimitives.h"
@@ -64,30 +63,29 @@ nsParserUtils::Unescape(const nsAString&
NS_IMETHODIMP
nsParserUtils::Sanitize(const nsAString& aFromStr,
uint32_t aFlags,
nsAString& aToStr)
{
nsCOMPtr<nsIURI> uri;
NS_NewURI(getter_AddRefs(uri), "about:blank");
nsCOMPtr<nsIPrincipal> principal = NullPrincipal::CreateWithoutOriginAttributes();
- nsCOMPtr<nsIDOMDocument> domDocument;
- nsresult rv = NS_NewDOMDocument(getter_AddRefs(domDocument),
+ nsCOMPtr<nsIDocument> document;
+ nsresult rv = NS_NewDOMDocument(getter_AddRefs(document),
EmptyString(),
EmptyString(),
nullptr,
uri,
uri,
principal,
true,
nullptr,
DocumentFlavorHTML);
NS_ENSURE_SUCCESS(rv, rv);
- nsCOMPtr<nsIDocument> document = do_QueryInterface(domDocument);
rv = nsContentUtils::ParseDocumentHTML(aFromStr, document, false);
NS_ENSURE_SUCCESS(rv, rv);
nsTreeSanitizer sanitizer(aFlags);
sanitizer.Sanitize(document);
nsCOMPtr<nsIDocumentEncoder> encoder =
do_CreateInstance(NS_DOC_ENCODER_CONTRACTID_BASE "text/html");