Bug 1460940 - Remove nsIDOMDocument uses in netwerk/. r?bz draft
authorAdrian Wielgosik <adrian.wielgosik@gmail.com>
Fri, 11 May 2018 19:46:15 +0200
changeset 794810 e25edc1e446813bc82b9b0ee16bcc0d9ec320b24
parent 794809 27ea5437a9463c00f574220ba53922268769aefd
child 794811 808311cbaa76f9ce60ce8e671280c0f397e2c9b2
push id109776
push userbmo:adrian.wielgosik@gmail.com
push dateMon, 14 May 2018 13:49:41 +0000
reviewersbz
bugs1460940
milestone62.0a1
Bug 1460940 - Remove nsIDOMDocument uses in netwerk/. r?bz MozReview-Commit-ID: QkZ36LGoBx
dom/base/nsContentUtils.cpp
netwerk/base/LoadInfo.cpp
netwerk/base/nsChannelClassifier.cpp
netwerk/base/nsILoadInfo.idl
netwerk/protocol/http/HttpBaseChannel.cpp
netwerk/protocol/http/HttpChannelChild.cpp
netwerk/protocol/http/nsHttpChannel.cpp
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -10616,19 +10616,18 @@ nsContentUtils::HtmlObjectContentTypeFor
 
 /* static */ already_AddRefed<nsISerialEventTarget>
 nsContentUtils::GetEventTargetByLoadInfo(nsILoadInfo* aLoadInfo, TaskCategory aCategory)
 {
   if (NS_WARN_IF(!aLoadInfo)) {
     return nullptr;
   }
 
-  nsCOMPtr<nsIDOMDocument> domDoc;
-  aLoadInfo->GetLoadingDocument(getter_AddRefs(domDoc));
-  nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
+  nsCOMPtr<nsIDocument> doc;
+  aLoadInfo->GetLoadingDocument(getter_AddRefs(doc));
   nsCOMPtr<nsISerialEventTarget> target;
   if (doc) {
     if (DocGroup* group = doc->GetDocGroup()) {
       target = group->EventTargetFor(aCategory);
     }
   } else {
     // There's no document yet, but this might be a top-level load where we can
     // find a TabGroup.
--- a/netwerk/base/LoadInfo.cpp
+++ b/netwerk/base/LoadInfo.cpp
@@ -12,17 +12,16 @@
 #include "mozilla/dom/PerformanceStorage.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/dom/ToJSValue.h"
 #include "mozIThirdPartyUtil.h"
 #include "nsFrameLoader.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsIDocShell.h"
 #include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsIFrameLoaderOwner.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsISupportsImpl.h"
 #include "nsISupportsUtils.h"
 #include "nsContentUtils.h"
 #include "nsDocShell.h"
 #include "nsGlobalWindow.h"
 #include "nsMixedContentBlocker.h"
@@ -621,21 +620,21 @@ LoadInfo::GetSandboxedLoadingPrincipal(n
   MOZ_ASSERT(mSandboxedLoadingPrincipal);
 
   nsCOMPtr<nsIPrincipal> copy(mSandboxedLoadingPrincipal);
   copy.forget(aPrincipal);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-LoadInfo::GetLoadingDocument(nsIDOMDocument** aResult)
+LoadInfo::GetLoadingDocument(nsIDocument** aResult)
 {
   nsCOMPtr<nsINode> node = do_QueryReferent(mLoadingContext);
   if (node) {
-    nsCOMPtr<nsIDOMDocument> context = do_QueryInterface(node->OwnerDoc());
+    nsCOMPtr<nsIDocument> context = node->OwnerDoc();
     context.forget(aResult);
   }
   return NS_OK;
 }
 
 nsINode*
 LoadInfo::LoadingNode()
 {
--- a/netwerk/base/nsChannelClassifier.cpp
+++ b/netwerk/base/nsChannelClassifier.cpp
@@ -11,17 +11,16 @@
 #include "nsContentUtils.h"
 #include "nsIAddonPolicyService.h"
 #include "nsICacheEntry.h"
 #include "nsICachingChannel.h"
 #include "nsIChannel.h"
 #include "nsIClassOfService.h"
 #include "nsIDocShell.h"
 #include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsIHttpChannel.h"
 #include "nsIHttpChannelInternal.h"
 #include "nsIIOService.h"
 #include "nsIParentChannel.h"
 #include "nsIPermissionManager.h"
 #include "nsIPrivateBrowsingTrackingProtectionWhitelist.h"
 #include "nsIProtocolHandler.h"
 #include "nsIScriptError.h"
--- a/netwerk/base/nsILoadInfo.idl
+++ b/netwerk/base/nsILoadInfo.idl
@@ -3,21 +3,21 @@
  * 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 "nsIContentPolicy.idl"
 
 interface nsIChannel;
-interface nsIDOMDocument;
 interface nsINode;
 interface nsIPrincipal;
 interface nsIRedirectHistoryEntry;
 interface nsIURI;
+webidl Document;
 native LoadContextRef(already_AddRefed<nsISupports>);
 %{C++
 #include "nsTArray.h"
 #include "mozilla/BasePrincipal.h"
 #include "mozilla/LoadTainting.h"
 #include "mozilla/UniquePtr.h"
 #include "nsStringFwd.h"
 
@@ -331,17 +331,17 @@ interface nsILoadInfo : nsISupports
    * This is the ownerDocument of the LoadingNode. Unless the LoadingNode
    * is a Document, in which case the LoadingDocument is the same as the
    * LoadingNode.
    *
    * For top-level loads, and for loads originating from workers, the
    * LoadingDocument is null. When the LoadingDocument is not null, the
    * LoadingPrincipal is set to the principal of the LoadingDocument.
    */
-  readonly attribute nsIDOMDocument loadingDocument;
+  readonly attribute Document loadingDocument;
 
   /**
    * A C++-friendly version of loadingDocument (loadingNode).
    * This is the Node where the resulting resource will be used. I.e. it is
    * the Node which will get access to the result of the request. (Where
    * "get access to" might simply mean "embed" depending on the type of
    * resource that is loaded).
    *
--- a/netwerk/protocol/http/HttpBaseChannel.cpp
+++ b/netwerk/protocol/http/HttpBaseChannel.cpp
@@ -12,17 +12,16 @@
 
 #include "nsHttpHandler.h"
 #include "nsMimeTypes.h"
 #include "nsNetCID.h"
 #include "nsNetUtil.h"
 #include "nsReadableUtils.h"
 
 #include "nsICachingChannel.h"
-#include "nsIDOMDocument.h"
 #include "nsIPrincipal.h"
 #include "nsIScriptError.h"
 #include "nsISeekableStream.h"
 #include "nsIStorageStream.h"
 #include "nsITimedChannel.h"
 #include "nsIEncodedChannel.h"
 #include "nsIApplicationCacheChannel.h"
 #include "nsIMutableArray.h"
@@ -3355,19 +3354,18 @@ HttpBaseChannel::DoNotifyListener()
   // to the console later.  The LoadDocument() is pointing at the detached
   // document that started the navigation.  We want to show the reports on the
   // new document.  Otherwise the console is wiped and the user never sees
   // the information.
   if (!IsNavigation()) {
     if (mLoadGroup) {
       FlushConsoleReports(mLoadGroup);
     } else if (mLoadInfo) {
-      nsCOMPtr<nsIDOMDocument> dommyDoc;
-      mLoadInfo->GetLoadingDocument(getter_AddRefs(dommyDoc));
-      nsCOMPtr<nsIDocument> doc = do_QueryInterface(dommyDoc);
+      nsCOMPtr<nsIDocument> doc;
+      mLoadInfo->GetLoadingDocument(getter_AddRefs(doc));
       FlushConsoleReports(doc);
     }
   }
 }
 
 void
 HttpBaseChannel::AddCookiesToRequest()
 {
@@ -4239,23 +4237,18 @@ HttpBaseChannel::GetPerformanceStorage()
   }
 
   // If a custom performance storage is set, let's use it.
   mozilla::dom::PerformanceStorage* performanceStorage = mLoadInfo->GetPerformanceStorage();
   if (performanceStorage) {
     return performanceStorage;
   }
 
-  nsCOMPtr<nsIDOMDocument> domDocument;
-  mLoadInfo->GetLoadingDocument(getter_AddRefs(domDocument));
-  if (!domDocument) {
-    return nullptr;
-  }
-
-  nsCOMPtr<nsIDocument> loadingDocument = do_QueryInterface(domDocument);
+  nsCOMPtr<nsIDocument> loadingDocument;
+  mLoadInfo->GetLoadingDocument(getter_AddRefs(loadingDocument));
   if (!loadingDocument) {
     return nullptr;
   }
 
   // We only add to the document's performance object if it has the same
   // principal as the one triggering the load. This is to prevent navigations
   // triggered _by_ the iframe from showing up in the parent document's
   // performance entries if they have different origins.
--- a/netwerk/protocol/http/HttpChannelChild.cpp
+++ b/netwerk/protocol/http/HttpChannelChild.cpp
@@ -45,17 +45,16 @@
 #include "SerializedLoadContext.h"
 #include "nsInputStreamPump.h"
 #include "InterceptedChannel.h"
 #include "mozIThirdPartyUtil.h"
 #include "nsContentSecurityManager.h"
 #include "nsIDeprecationWarner.h"
 #include "nsICompressConvStats.h"
 #include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsIDOMWindowUtils.h"
 #include "nsIEventTarget.h"
 #include "nsRedirectHistoryEntry.h"
 #include "nsSocketTransportService2.h"
 #include "nsStreamUtils.h"
 #include "nsThreadUtils.h"
 #include "nsCORSListenerProxy.h"
 
--- a/netwerk/protocol/http/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/nsHttpChannel.cpp
@@ -91,17 +91,16 @@
 #include "AlternateServices.h"
 #include "InterceptedChannel.h"
 #include "nsIHttpPushListener.h"
 #include "nsIX509Cert.h"
 #include "ScopedNSSTypes.h"
 #include "NullPrincipal.h"
 #include "nsIDeprecationWarner.h"
 #include "nsIDocument.h"
-#include "nsIDOMDocument.h"
 #include "nsICompressConvStats.h"
 #include "nsCORSListenerProxy.h"
 #include "nsISocketProvider.h"
 #include "mozilla/extensions/StreamFilterParent.h"
 #include "mozilla/net/Predictor.h"
 #include "mozilla/MathAlgorithms.h"
 #include "CacheControlParser.h"
 #include "nsMixedContentBlocker.h"
@@ -1231,21 +1230,17 @@ void
 ReportTypeBlocking(nsIURI* aURI,
                    nsILoadInfo* aLoadInfo,
                    const char* aMessageName)
 {
     NS_ConvertUTF8toUTF16 specUTF16(aURI->GetSpecOrDefault());
     const char16_t* params[] = { specUTF16.get() };
     nsCOMPtr<nsIDocument> doc;
     if (aLoadInfo) {
-        nsCOMPtr<nsIDOMDocument> domDoc;
-        aLoadInfo->GetLoadingDocument(getter_AddRefs(domDoc));
-        if (domDoc) {
-            doc = do_QueryInterface(domDoc);
-        }
+        aLoadInfo->GetLoadingDocument(getter_AddRefs(doc));
     }
     nsContentUtils::ReportToConsole(nsIScriptError::errorFlag,
                                     NS_LITERAL_CSTRING("MIMEMISMATCH"),
                                     doc,
                                     nsContentUtils::eSECURITY_PROPERTIES,
                                     aMessageName,
                                     params, ArrayLength(params));
 }
@@ -1282,21 +1277,17 @@ ProcessXCTO(nsIURI* aURI, nsHttpResponse
     //    if it's not 'nosniff' then there is nothing to do here
     if (!contentTypeOptionsHeader.EqualsIgnoreCase("nosniff")) {
         // since we are getting here, the XCTO header was sent;
         // a non matching value most likely means a mistake happenend;
         // e.g. sending 'nosnif' instead of 'nosniff', let's log a warning.
         NS_ConvertUTF8toUTF16 char16_header(contentTypeOptionsHeader);
         const char16_t* params[] = { char16_header.get() };
         nsCOMPtr<nsIDocument> doc;
-        nsCOMPtr<nsIDOMDocument> domDoc;
-        aLoadInfo->GetLoadingDocument(getter_AddRefs(domDoc));
-        if (domDoc) {
-          doc = do_QueryInterface(domDoc);
-        }
+        aLoadInfo->GetLoadingDocument(getter_AddRefs(doc));
         nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
                                         NS_LITERAL_CSTRING("XCTO"),
                                         doc,
                                         nsContentUtils::eSECURITY_PROPERTIES,
                                         "XCTOHeaderValueMissing",
                                         params, ArrayLength(params));
         return NS_OK;
     }