Bug 1460940 - Remove nsIDOMDocument uses in uriloader/. r?bz
MozReview-Commit-ID: LnXwludmiAn
--- a/dom/base/nsContentSink.cpp
+++ b/dom/base/nsContentSink.cpp
@@ -1196,19 +1196,18 @@ nsContentSink::ProcessOfflineManifest(co
{
case CACHE_SELECTION_NONE:
break;
case CACHE_SELECTION_UPDATE: {
nsCOMPtr<nsIOfflineCacheUpdateService> updateService =
do_GetService(NS_OFFLINECACHEUPDATESERVICE_CONTRACTID);
if (updateService) {
- nsCOMPtr<nsIDOMDocument> domdoc = do_QueryInterface(mDocument);
updateService->ScheduleOnDocumentStop(manifestURI, mDocumentURI,
- mDocument->NodePrincipal(), domdoc);
+ mDocument->NodePrincipal(), mDocument);
}
break;
}
case CACHE_SELECTION_RELOAD: {
// This situation occurs only for toplevel documents, see bottom
// of SelectDocAppCache method.
// The document has been loaded from a different offline cache group than
// the manifest it refers to, i.e. this is a foreign entry, mark it as such
--- a/uriloader/base/nsDocLoader.cpp
+++ b/uriloader/base/nsDocLoader.cpp
@@ -26,17 +26,16 @@
#include "nsIDOMWindow.h"
#include "nsIStringBundle.h"
#include "nsIScriptSecurityManager.h"
#include "nsITransport.h"
#include "nsISocketTransport.h"
#include "nsIDocShell.h"
-#include "nsIDOMDocument.h"
#include "nsIDocument.h"
#include "nsPresContext.h"
#include "nsIAsyncVerifyRedirectCallback.h"
using mozilla::DebugOnly;
using mozilla::LogLevel;
static NS_DEFINE_CID(kThisImplCID, NS_THIS_DOCLOADER_IMPL_CID);
@@ -679,18 +678,17 @@ void nsDocLoader::DocLoaderIsEmpty(bool
return;
}
NS_ASSERTION(!mIsFlushingLayout, "Someone screwed up");
NS_ASSERTION(mDocumentRequest, "No Document Request!");
// The load group for this DocumentLoader is idle. Flush if we need to.
if (aFlushLayout && !mDontFlushLayout) {
- nsCOMPtr<nsIDOMDocument> domDoc = do_GetInterface(GetAsSupports(this));
- nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
+ nsCOMPtr<nsIDocument> doc = do_GetInterface(GetAsSupports(this));
if (doc) {
// We start loads from style resolution, so we need to flush out style
// no matter what. If we have user fonts, we also need to flush layout,
// since the reflow is what starts font loads.
mozilla::FlushType flushType = mozilla::FlushType::Style;
// Be safe in case this presshell is in teardown now
nsPresContext* presContext = doc->GetPresContext();
if (presContext && presContext->GetUserFontSet()) {
--- a/uriloader/prefetch/OfflineCacheUpdateChild.cpp
+++ b/uriloader/prefetch/OfflineCacheUpdateChild.cpp
@@ -100,47 +100,46 @@ OfflineCacheUpdateChild::GatherObservers
}
for (int32_t i = 0; i < mObservers.Count(); i++) {
aObservers.AppendObject(mObservers[i]);
}
}
void
-OfflineCacheUpdateChild::SetDocument(nsIDOMDocument *aDocument)
+OfflineCacheUpdateChild::SetDocument(nsIDocument *aDocument)
{
// The design is one document for one cache update on the content process.
NS_ASSERTION(!mDocument, "Setting more then a single document on a child offline cache update");
LOG(("Document %p added to update child %p", aDocument, this));
// Add document only if it was not loaded from an offline cache.
// If it were loaded from an offline cache then it has already
// been associated with it and must not be again cached as
// implicit (which are the reasons we collect documents here).
- nsCOMPtr<nsIDocument> document = do_QueryInterface(aDocument);
- if (!document)
+ if (!aDocument)
return;
- nsIChannel* channel = document->GetChannel();
+ nsIChannel* channel = aDocument->GetChannel();
nsCOMPtr<nsIApplicationCacheChannel> appCacheChannel =
do_QueryInterface(channel);
if (!appCacheChannel)
return;
bool loadedFromAppCache;
appCacheChannel->GetLoadedFromApplicationCache(&loadedFromAppCache);
if (loadedFromAppCache)
return;
mDocument = aDocument;
}
nsresult
-OfflineCacheUpdateChild::AssociateDocument(nsIDOMDocument *aDocument,
+OfflineCacheUpdateChild::AssociateDocument(nsIDocument *aDocument,
nsIApplicationCache *aApplicationCache)
{
// Check that the document that requested this update was
// previously associated with an application cache. If not, it
// should be associated with the new one.
nsCOMPtr<nsIApplicationCacheContainer> container =
do_QueryInterface(aDocument);
if (!container)
@@ -170,17 +169,17 @@ OfflineCacheUpdateChild::AssociateDocume
//-----------------------------------------------------------------------------
// OfflineCacheUpdateChild::nsIOfflineCacheUpdate
//-----------------------------------------------------------------------------
NS_IMETHODIMP
OfflineCacheUpdateChild::Init(nsIURI *aManifestURI,
nsIURI *aDocumentURI,
nsIPrincipal *aLoadingPrincipal,
- nsIDOMDocument *aDocument,
+ nsIDocument *aDocument,
nsIFile *aCustomProfileDir)
{
nsresult rv;
// Make sure the service has been initialized
nsOfflineCacheUpdateService* service =
nsOfflineCacheUpdateService::EnsureService();
if (!service)
--- a/uriloader/prefetch/OfflineCacheUpdateChild.h
+++ b/uriloader/prefetch/OfflineCacheUpdateChild.h
@@ -6,17 +6,17 @@
#ifndef nsOfflineCacheUpdateChild_h
#define nsOfflineCacheUpdateChild_h
#include "mozilla/docshell/POfflineCacheUpdateChild.h"
#include "nsIOfflineCacheUpdate.h"
#include "nsCOMArray.h"
#include "nsCOMPtr.h"
-#include "nsIDOMDocument.h"
+#include "nsIDocument.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsIURI.h"
#include "nsString.h"
#include "nsWeakReference.h"
class nsPIDOMWindowInner;
@@ -40,22 +40,22 @@ public:
const nsCString& cacheClientId) override;
virtual mozilla::ipc::IPCResult
RecvFinish(const bool& succeeded,
const bool& isUpgrade) override;
explicit OfflineCacheUpdateChild(nsPIDOMWindowInner* aWindow);
- void SetDocument(nsIDOMDocument *aDocument);
+ void SetDocument(nsIDocument *aDocument);
private:
~OfflineCacheUpdateChild();
- nsresult AssociateDocument(nsIDOMDocument *aDocument,
+ nsresult AssociateDocument(nsIDocument *aDocument,
nsIApplicationCache *aApplicationCache);
void GatherObservers(nsCOMArray<nsIOfflineCacheUpdateObserver> &aObservers);
nsresult Finish();
enum {
STATE_UNINITIALIZED,
STATE_INITIALIZED,
STATE_CHECKING,
@@ -74,17 +74,17 @@ private:
nsCOMPtr<nsIObserverService> mObserverService;
/* Clients watching this update for changes */
nsCOMArray<nsIWeakReference> mWeakObservers;
nsCOMArray<nsIOfflineCacheUpdateObserver> mObservers;
/* Document that requested this update */
- nsCOMPtr<nsIDOMDocument> mDocument;
+ nsCOMPtr<nsIDocument> mDocument;
/* Keep reference to the window that owns this update to call the
parent offline cache update construcor */
nsCOMPtr<nsPIDOMWindowInner> mWindow;
uint64_t mByteProgress;
};
--- a/uriloader/prefetch/OfflineCacheUpdateGlue.cpp
+++ b/uriloader/prefetch/OfflineCacheUpdateGlue.cpp
@@ -93,17 +93,17 @@ OfflineCacheUpdateGlue::Schedule()
return mUpdate->Schedule();
}
NS_IMETHODIMP
OfflineCacheUpdateGlue::Init(nsIURI *aManifestURI,
nsIURI *aDocumentURI,
nsIPrincipal* aLoadingPrincipal,
- nsIDOMDocument *aDocument,
+ nsIDocument *aDocument,
nsIFile *aCustomProfileDir)
{
nsresult rv;
nsAutoCString originSuffix;
rv = aLoadingPrincipal->GetOriginSuffix(originSuffix);
NS_ENSURE_SUCCESS(rv, rv);
@@ -129,33 +129,32 @@ OfflineCacheUpdateGlue::Init(nsIURI *aMa
return NS_OK;
}
return mUpdate->Init(aManifestURI, aDocumentURI, aLoadingPrincipal, nullptr,
aCustomProfileDir);
}
void
-OfflineCacheUpdateGlue::SetDocument(nsIDOMDocument *aDocument)
+OfflineCacheUpdateGlue::SetDocument(nsIDocument *aDocument)
{
// The design is one document for one cache update on the content process.
NS_ASSERTION(!mDocument,
"Setting more then a single document on an instance of OfflineCacheUpdateGlue");
LOG(("Document %p added to update glue %p", aDocument, this));
// Add document only if it was not loaded from an offline cache.
// If it were loaded from an offline cache then it has already
// been associated with it and must not be again cached as
// implicit (which are the reasons we collect documents here).
- nsCOMPtr<nsIDocument> document = do_QueryInterface(aDocument);
- if (!document)
+ if (!aDocument)
return;
- nsIChannel* channel = document->GetChannel();
+ nsIChannel* channel = aDocument->GetChannel();
nsCOMPtr<nsIApplicationCacheChannel> appCacheChannel =
do_QueryInterface(channel);
if (!appCacheChannel)
return;
bool loadedFromAppCache;
appCacheChannel->GetLoadedFromApplicationCache(&loadedFromAppCache);
if (loadedFromAppCache)
--- a/uriloader/prefetch/OfflineCacheUpdateGlue.h
+++ b/uriloader/prefetch/OfflineCacheUpdateGlue.h
@@ -48,33 +48,33 @@ private:
nsIOfflineCacheUpdate* EnsureUpdate();
public:
NS_ADJUSTED_FORWARD_NSIOFFLINECACHEUPDATE(EnsureUpdate())
NS_IMETHOD Schedule(void) override;
NS_IMETHOD Init(nsIURI *aManifestURI,
nsIURI *aDocumentURI,
nsIPrincipal* aLoadingPrincipal,
- nsIDOMDocument *aDocument,
+ nsIDocument *aDocument,
nsIFile *aCustomProfileDir) override;
NS_DECL_NSIOFFLINECACHEUPDATEOBSERVER
OfflineCacheUpdateGlue();
- void SetDocument(nsIDOMDocument *aDocument);
+ void SetDocument(nsIDocument *aDocument);
private:
~OfflineCacheUpdateGlue();
RefPtr<nsOfflineCacheUpdate> mUpdate;
bool mCoalesced;
/* Document that requested this update */
- nsCOMPtr<nsIDOMDocument> mDocument;
+ nsCOMPtr<nsIDocument> mDocument;
nsCOMPtr<nsIURI> mDocumentURI;
nsCOMPtr<nsIPrincipal> mLoadingPrincipal;
};
} // namespace docshell
} // namespace mozilla
#endif
--- a/uriloader/prefetch/nsIOfflineCacheUpdate.idl
+++ b/uriloader/prefetch/nsIOfflineCacheUpdate.idl
@@ -3,23 +3,23 @@
* 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"
interface mozIDOMWindow;
interface nsIURI;
interface nsIDOMNode;
-interface nsIDOMDocument;
interface nsIOfflineCacheUpdate;
interface nsIPrincipal;
interface nsIPrefBranch;
interface nsIApplicationCache;
interface nsIFile;
interface nsIObserver;
+webidl Document;
[scriptable, uuid(47360d57-8ef4-4a5d-8865-1a27a739ad1a)]
interface nsIOfflineCacheUpdateObserver : nsISupports {
const unsigned long STATE_ERROR = 1;
const unsigned long STATE_CHECKING = 2;
const unsigned long STATE_NOUPDATE = 3;
const unsigned long STATE_OBSOLETE = 4;
const unsigned long STATE_DOWNLOADING = 5;
@@ -102,17 +102,17 @@ interface nsIOfflineCacheUpdate : nsISup
* @param aDocumentURI
* The page that is requesting the update.
* @param aLoadingPrincipal
* The principal of the page that is requesting the update.
*/
void init(in nsIURI aManifestURI,
in nsIURI aDocumentURI,
in nsIPrincipal aLoadingPrincipal,
- in nsIDOMDocument aDocument,
+ in Document aDocument,
[optional] in nsIFile aCustomProfileDir);
/**
* Initialize the update for partial processing.
*
* @param aManifestURI
* The manifest URI of the related cache.
* @param aClientID
@@ -235,17 +235,17 @@ interface nsIOfflineCacheUpdateService :
/**
* Schedule a cache update for a manifest when the document finishes
* loading.
*/
void scheduleOnDocumentStop(in nsIURI aManifestURI,
in nsIURI aDocumentURI,
in nsIPrincipal aLoadingPrincipal,
- in nsIDOMDocument aDocument);
+ in Document aDocument);
/**
* Schedule a check to see if an update is available.
*
* This will not update or make any changes to the appcache.
* It only notifies the observer to indicate whether the manifest has
* changed on the server (or not): a changed manifest means that an
* update is available.
--- a/uriloader/prefetch/nsOfflineCacheUpdate.cpp
+++ b/uriloader/prefetch/nsOfflineCacheUpdate.cpp
@@ -1284,17 +1284,17 @@ nsOfflineCacheUpdate::InitInternal(nsIUR
return NS_OK;
}
nsresult
nsOfflineCacheUpdate::Init(nsIURI *aManifestURI,
nsIURI *aDocumentURI,
nsIPrincipal* aLoadingPrincipal,
- nsIDOMDocument *aDocument,
+ nsIDocument *aDocument,
nsIFile *aCustomProfileDir)
{
nsresult rv;
// Make sure the service has been initialized
nsOfflineCacheUpdateService* service =
nsOfflineCacheUpdateService::EnsureService();
if (!service)
--- a/uriloader/prefetch/nsOfflineCacheUpdate.h
+++ b/uriloader/prefetch/nsOfflineCacheUpdate.h
@@ -7,17 +7,16 @@
#define nsOfflineCacheUpdate_h__
#include "nsIOfflineCacheUpdate.h"
#include "nsAutoPtr.h"
#include "nsCOMArray.h"
#include "nsCOMPtr.h"
#include "nsIChannelEventSink.h"
-#include "nsIDOMDocument.h"
#include "nsIDOMNode.h"
#include "nsIInterfaceRequestor.h"
#include "nsIMutableArray.h"
#include "nsIObserver.h"
#include "nsIObserverService.h"
#include "nsIApplicationCache.h"
#include "nsIRequestObserver.h"
#include "nsIRunnable.h"
@@ -338,17 +337,17 @@ public:
nsresult FindUpdate(nsIURI *aManifestURI,
nsACString const &aOriginSuffix,
nsIFile *aCustomProfileDir,
nsOfflineCacheUpdate **aUpdate);
nsresult Schedule(nsIURI *aManifestURI,
nsIURI *aDocumentURI,
nsIPrincipal* aLoadingPrincipal,
- nsIDOMDocument *aDocument,
+ nsIDocument *aDocument,
nsPIDOMWindowInner* aWindow,
nsIFile* aCustomProfileDir,
nsIOfflineCacheUpdate **aUpdate);
virtual nsresult UpdateFinished(nsOfflineCacheUpdate *aUpdate) override;
/**
* Returns the singleton nsOfflineCacheUpdateService without an addref, or
--- a/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
+++ b/uriloader/prefetch/nsOfflineCacheUpdateService.cpp
@@ -96,17 +96,17 @@ class nsOfflineCachePendingUpdate final
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIWEBPROGRESSLISTENER
nsOfflineCachePendingUpdate(nsOfflineCacheUpdateService *aService,
nsIURI *aManifestURI,
nsIURI *aDocumentURI,
nsIPrincipal* aLoadingPrincipal,
- nsIDOMDocument *aDocument)
+ nsIDocument *aDocument)
: mService(aService)
, mManifestURI(aManifestURI)
, mDocumentURI(aDocumentURI)
, mLoadingPrincipal(aLoadingPrincipal)
, mDidReleaseThis(false)
{
mDocument = do_GetWeakReference(aDocument);
}
@@ -146,17 +146,17 @@ NS_IMETHODIMP
nsOfflineCachePendingUpdate::OnStateChange(nsIWebProgress* aWebProgress,
nsIRequest *aRequest,
uint32_t progressStateFlags,
nsresult aStatus)
{
if (mDidReleaseThis) {
return NS_OK;
}
- nsCOMPtr<nsIDOMDocument> updateDoc = do_QueryReferent(mDocument);
+ nsCOMPtr<nsIDocument> updateDoc = do_QueryReferent(mDocument);
if (!updateDoc) {
// The document that scheduled this update has gone away,
// we don't need to listen anymore.
aWebProgress->RemoveProgressListener(this);
MOZ_ASSERT(!mDidReleaseThis);
mDidReleaseThis = true;
NS_RELEASE_THIS();
return NS_OK;
@@ -339,23 +339,22 @@ nsOfflineCacheUpdateService::ScheduleUpd
return NS_OK;
}
NS_IMETHODIMP
nsOfflineCacheUpdateService::ScheduleOnDocumentStop(nsIURI *aManifestURI,
nsIURI *aDocumentURI,
nsIPrincipal* aLoadingPrincipal,
- nsIDOMDocument *aDocument)
+ nsIDocument *aDocument)
{
LOG(("nsOfflineCacheUpdateService::ScheduleOnDocumentStop [%p, manifestURI=%p, documentURI=%p doc=%p]",
this, aManifestURI, aDocumentURI, aDocument));
- nsCOMPtr<nsIDocument> doc = do_QueryInterface(aDocument);
- nsCOMPtr<nsIWebProgress> progress = do_QueryInterface(doc->GetContainer());
+ nsCOMPtr<nsIWebProgress> progress = do_QueryInterface(aDocument->GetContainer());
NS_ENSURE_TRUE(progress, NS_ERROR_INVALID_ARG);
// Proceed with cache update
RefPtr<nsOfflineCachePendingUpdate> update =
new nsOfflineCachePendingUpdate(this, aManifestURI, aDocumentURI,
aLoadingPrincipal, aDocument);
NS_ENSURE_TRUE(update, NS_ERROR_OUT_OF_MEMORY);
@@ -483,17 +482,17 @@ nsOfflineCacheUpdateService::FindUpdate(
return NS_ERROR_NOT_AVAILABLE;
}
nsresult
nsOfflineCacheUpdateService::Schedule(nsIURI *aManifestURI,
nsIURI *aDocumentURI,
nsIPrincipal* aLoadingPrincipal,
- nsIDOMDocument *aDocument,
+ nsIDocument *aDocument,
nsPIDOMWindowInner* aWindow,
nsIFile* aCustomProfileDir,
nsIOfflineCacheUpdate **aUpdate)
{
nsCOMPtr<nsIOfflineCacheUpdate> update;
if (GeckoProcessType_Default != XRE_GetProcessType()) {
update = new OfflineCacheUpdateChild(aWindow);
}