Bug 1460940 - Remove nsIDOMDocument uses in image/. r=bz

MozReview-Commit-ID: HUiegmeFLo4

--HG--
extra : rebase_source : cd6453dc5d708fc5cdc75114d163ea2389423d55
This commit is contained in:
Adrian Wielgosik 2018-05-11 19:46:15 +02:00
parent f5e05d1158
commit fff55359ea
5 changed files with 20 additions and 25 deletions

View File

@ -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<nsIProperties> props;
nsCOMPtr<nsIDOMDocument> 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);
}

View File

@ -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

View File

@ -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

View File

@ -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<nsIDocument> doc = do_QueryInterface(aDOMDoc);
if (aURI) {
OriginAttributes attrs;
if (doc) {
nsCOMPtr<nsIPrincipal> principal = doc->NodePrincipal();
if (aDoc) {
nsCOMPtr<nsIPrincipal> 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<nsIDocument> doc = do_QueryInterface(aDOMDoc);
OriginAttributes attrs;
if (doc) {
nsCOMPtr<nsIPrincipal> principal = doc->NodePrincipal();
if (aDoc) {
nsCOMPtr<nsIPrincipal> 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);

View File

@ -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<nsIDocument> 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<imgILoader> loader;
nsresult rv = GetImgLoaderForDocument(aDoc, getter_AddRefs(loader));