From fff55359ea90e96f2bb80d48780aa4f40f228128 Mon Sep 17 00:00:00 2001 From: Adrian Wielgosik Date: Fri, 11 May 2018 19:46:15 +0200 Subject: [PATCH] Bug 1460940 - Remove nsIDOMDocument uses in image/. r=bz MozReview-Commit-ID: HUiegmeFLo4 --HG-- extra : rebase_source : cd6453dc5d708fc5cdc75114d163ea2389423d55 --- dom/base/nsContentUtils.cpp | 3 +-- image/imgICache.idl | 7 ++++--- image/imgITools.idl | 7 ++++--- image/imgLoader.cpp | 20 ++++++++------------ image/imgTools.cpp | 8 +++----- 5 files changed, 20 insertions(+), 25 deletions(-) diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index dfbfc25518ad..43ce9d985444 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -3643,8 +3643,7 @@ nsContentUtils::IsImageInCache(nsIURI* aURI, nsIDocument* aDocument) // If something unexpected happened we return false, otherwise if props // is set, the image is cached and we return true nsCOMPtr props; - nsCOMPtr domDoc = do_QueryInterface(aDocument); - nsresult rv = cache->FindEntryProperties(aURI, domDoc, getter_AddRefs(props)); + nsresult rv = cache->FindEntryProperties(aURI, aDocument, getter_AddRefs(props)); return (NS_SUCCEEDED(rv) && props); } diff --git a/image/imgICache.idl b/image/imgICache.idl index e67691399065..b4782dfb375e 100644 --- a/image/imgICache.idl +++ b/image/imgICache.idl @@ -8,10 +8,11 @@ interface imgIRequest; interface nsIDocument; -interface nsIDOMDocument; interface nsIProperties; interface nsIURI; +webidl Document; + /** * imgICache interface * @@ -38,7 +39,7 @@ interface imgICache : nsISupports * @throws NS_ERROR_NOT_AVAILABLE if \a uri was unable to be removed from * the cache. */ - [noscript] void removeEntry(in nsIURI uri, [optional] in nsIDOMDocument doc); + [noscript] void removeEntry(in nsIURI uri, [optional] in Document doc); /** * Find Properties @@ -57,7 +58,7 @@ interface imgICache : nsISupports */ [must_use] nsIProperties findEntryProperties(in nsIURI uri, - [optional] in nsIDOMDocument doc); + [optional] in Document doc); /** * Make this cache instance respect private browsing notifications. This diff --git a/image/imgITools.idl b/image/imgITools.idl index b82417f0c7af..5013869c8a2c 100644 --- a/image/imgITools.idl +++ b/image/imgITools.idl @@ -11,11 +11,12 @@ interface nsIInputStream; interface imgIContainer; interface imgILoader; interface imgICache; -interface nsIDOMDocument; interface imgIScriptedNotificationObserver; interface imgINotificationObserver; interface imgIContainerCallback; +webidl Document; + [scriptable, builtinclass, uuid(4c2383a4-931c-484d-8c4a-973590f66e3f)] interface imgITools : nsISupports { @@ -118,7 +119,7 @@ interface imgITools : nsISupports * @param doc * A document. Must not be null. */ - imgILoader getImgLoaderForDocument(in nsIDOMDocument doc); + imgILoader getImgLoaderForDocument(in Document doc); /** * getImgLoaderForDocument @@ -130,7 +131,7 @@ interface imgITools : nsISupports * when there is no way to obtain a relevant document for * the current context in which a cache is desired. */ - imgICache getImgCacheForDocument(in nsIDOMDocument doc); + imgICache getImgCacheForDocument(in Document doc); /** * encodeCroppedImage diff --git a/image/imgLoader.cpp b/image/imgLoader.cpp index 29fe75153191..2554f77a1e10 100644 --- a/image/imgLoader.cpp +++ b/image/imgLoader.cpp @@ -61,7 +61,6 @@ #include "nsIHttpChannelInternal.h" #include "nsILoadContext.h" #include "nsILoadGroupChild.h" -#include "nsIDOMDocument.h" #include "nsIDocShell.h" using namespace mozilla; @@ -1472,20 +1471,19 @@ imgLoader::ClearCache(bool chrome) NS_IMETHODIMP imgLoader::RemoveEntry(nsIURI* aURI, - nsIDOMDocument* aDOMDoc) + nsIDocument* aDoc) { - nsCOMPtr doc = do_QueryInterface(aDOMDoc); if (aURI) { OriginAttributes attrs; - if (doc) { - nsCOMPtr principal = doc->NodePrincipal(); + if (aDoc) { + nsCOMPtr principal = aDoc->NodePrincipal(); if (principal) { attrs = principal->OriginAttributesRef(); } } nsresult rv = NS_OK; - ImageCacheKey key(aURI, attrs, doc, rv); + ImageCacheKey key(aURI, attrs, aDoc, rv); if (NS_SUCCEEDED(rv) && RemoveFromCache(key)) { return NS_OK; } @@ -1495,23 +1493,21 @@ imgLoader::RemoveEntry(nsIURI* aURI, NS_IMETHODIMP imgLoader::FindEntryProperties(nsIURI* uri, - nsIDOMDocument* aDOMDoc, + nsIDocument* aDoc, nsIProperties** _retval) { *_retval = nullptr; - nsCOMPtr doc = do_QueryInterface(aDOMDoc); - OriginAttributes attrs; - if (doc) { - nsCOMPtr principal = doc->NodePrincipal(); + if (aDoc) { + nsCOMPtr principal = aDoc->NodePrincipal(); if (principal) { attrs = principal->OriginAttributesRef(); } } nsresult rv; - ImageCacheKey key(uri, attrs, doc, rv); + ImageCacheKey key(uri, attrs, aDoc, rv); NS_ENSURE_SUCCESS(rv, rv); imgCacheTable& cache = GetCache(key); diff --git a/image/imgTools.cpp b/image/imgTools.cpp index b47edeca16fd..50f3ac5cf514 100644 --- a/image/imgTools.cpp +++ b/image/imgTools.cpp @@ -13,7 +13,6 @@ #include "mozilla/RefPtr.h" #include "nsCOMPtr.h" #include "nsIDocument.h" -#include "nsIDOMDocument.h" #include "nsError.h" #include "imgLoader.h" #include "imgICache.h" @@ -527,15 +526,14 @@ imgTools::CreateScriptedObserver(imgIScriptedNotificationObserver* aInner, } NS_IMETHODIMP -imgTools::GetImgLoaderForDocument(nsIDOMDocument* aDoc, imgILoader** aLoader) +imgTools::GetImgLoaderForDocument(nsIDocument* aDoc, imgILoader** aLoader) { - nsCOMPtr doc = do_QueryInterface(aDoc); - NS_IF_ADDREF(*aLoader = nsContentUtils::GetImgLoaderForDocument(doc)); + NS_IF_ADDREF(*aLoader = nsContentUtils::GetImgLoaderForDocument(aDoc)); return NS_OK; } NS_IMETHODIMP -imgTools::GetImgCacheForDocument(nsIDOMDocument* aDoc, imgICache** aCache) +imgTools::GetImgCacheForDocument(nsIDocument* aDoc, imgICache** aCache) { nsCOMPtr loader; nsresult rv = GetImgLoaderForDocument(aDoc, getter_AddRefs(loader));