From 47c921e73e43e7417e90e5f48893789e66dabff7 Mon Sep 17 00:00:00 2001 From: Jeff Muizelaar Date: Fri, 12 Oct 2012 08:43:01 -0400 Subject: [PATCH] Bug 801061. Switch from imgIRequest to imgRequestProxy. r=joe This doesn't switch all of the users yet, but is a step in the right direction. --HG-- extra : rebase_source : 91b4fef3f67586179c119208d000cf7629e04963 --- .../base/public/nsContentCreatorFunctions.h | 4 +- content/base/public/nsContentUtils.h | 6 +- content/base/src/nsContentUtils.cpp | 10 +-- content/base/src/nsDocument.cpp | 3 +- content/base/src/nsGenConImageContent.cpp | 4 +- content/base/src/nsImageLoadingContent.cpp | 15 ++-- content/base/src/nsImageLoadingContent.h | 14 +-- .../html/content/src/nsHTMLImageElement.cpp | 2 +- .../html/content/src/nsHTMLInputElement.cpp | 1 + content/xbl/src/nsXBLResourceLoader.cpp | 4 +- .../browser/webBrowser/nsContextMenuInfo.cpp | 16 ++-- .../browser/webBrowser/nsContextMenuInfo.h | 5 +- image/public/imgILoader.idl | 30 +++---- image/src/Makefile.in | 1 + image/src/imgLoader.cpp | 87 +++++++++++++++---- image/src/imgLoader.h | 25 +++++- image/src/imgRequestProxy.cpp | 27 +++++- image/src/imgRequestProxy.h | 5 +- image/test/unit/async_load_tests.js | 10 +-- image/test/unit/test_private_channel.js | 4 +- layout/generic/nsBulletFrame.cpp | 3 +- layout/generic/nsBulletFrame.h | 4 +- layout/generic/nsImageFrame.cpp | 3 +- layout/generic/nsImageFrame.h | 7 +- layout/style/ImageLoader.cpp | 8 +- layout/style/nsCSSValue.cpp | 4 +- layout/style/nsCSSValue.h | 8 +- layout/style/nsRuleNode.cpp | 2 +- layout/style/nsStyleStruct.h | 19 ++-- layout/style/nsStyleStructInlines.h | 4 +- layout/xul/base/src/nsImageBoxFrame.cpp | 2 +- layout/xul/base/src/nsImageBoxFrame.h | 3 +- .../xul/base/src/tree/src/nsTreeBodyFrame.cpp | 4 +- toolkit/system/gnome/nsAlertsIconListener.cpp | 6 +- widget/cocoa/nsMenuItemIconX.h | 17 ++-- widget/cocoa/nsMenuItemIconX.mm | 2 +- 36 files changed, 242 insertions(+), 127 deletions(-) diff --git a/content/base/public/nsContentCreatorFunctions.h b/content/base/public/nsContentCreatorFunctions.h index 86f83ab8eb2e..051f167ff13d 100644 --- a/content/base/public/nsContentCreatorFunctions.h +++ b/content/base/public/nsContentCreatorFunctions.h @@ -18,7 +18,7 @@ class nsAString; class nsIContent; class nsINodeInfo; -class imgIRequest; +class imgRequestProxy; class nsNodeInfoManager; class nsGenericHTMLElement; @@ -95,6 +95,6 @@ NS_NewSVGElement(nsIContent** aResult, already_AddRefed aNodeInfo, nsresult NS_NewGenConImageContent(nsIContent** aResult, already_AddRefed aNodeInfo, - imgIRequest* aImageRequest); + imgRequestProxy* aImageRequest); #endif // nsContentCreatorFunctions_h__ diff --git a/content/base/public/nsContentUtils.h b/content/base/public/nsContentUtils.h index aed0db1ad902..010b1c1c8d33 100644 --- a/content/base/public/nsContentUtils.h +++ b/content/base/public/nsContentUtils.h @@ -63,7 +63,7 @@ class nsIIOService; class nsIURI; class imgIContainer; class imgINotificationObserver; -class imgIRequest; +class imgRequestProxy; class imgLoader; class imgICache; class nsIImageLoadingContent; @@ -640,7 +640,7 @@ public: nsIURI* aReferrer, imgINotificationObserver* aObserver, int32_t aLoadFlags, - imgIRequest** aRequest); + imgRequestProxy** aRequest); /** * Obtain an image loader that respects the given document/channel's privacy status. @@ -666,7 +666,7 @@ public: /** * Helper method to call imgIRequest::GetStaticRequest. */ - static already_AddRefed GetStaticRequest(imgIRequest* aRequest); + static already_AddRefed GetStaticRequest(imgRequestProxy* aRequest); /** * Method that decides whether a content node is draggable diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp index 8151de236711..b73ebd14dd7d 100644 --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp @@ -53,7 +53,7 @@ #include "nsIFormControl.h" #include "nsGkAtoms.h" #include "imgINotificationObserver.h" -#include "imgIRequest.h" +#include "imgRequestProxy.h" #include "imgIContainer.h" #include "imgLoader.h" #include "nsDocShellCID.h" @@ -2685,7 +2685,7 @@ nsresult nsContentUtils::LoadImage(nsIURI* aURI, nsIDocument* aLoadingDocument, nsIPrincipal* aLoadingPrincipal, nsIURI* aReferrer, imgINotificationObserver* aObserver, int32_t aLoadFlags, - imgIRequest** aRequest) + imgRequestProxy** aRequest) { NS_PRECONDITION(aURI, "Must have a URI"); NS_PRECONDITION(aLoadingDocument, "Must have a document"); @@ -2768,11 +2768,11 @@ nsContentUtils::GetImageFromContent(nsIImageLoadingContent* aContent, } //static -already_AddRefed -nsContentUtils::GetStaticRequest(imgIRequest* aRequest) +already_AddRefed +nsContentUtils::GetStaticRequest(imgRequestProxy* aRequest) { NS_ENSURE_TRUE(aRequest, nullptr); - nsCOMPtr retval; + nsRefPtr retval; aRequest->GetStaticRequest(getter_AddRefs(retval)); return retval.forget(); } diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 706d7f335cb3..ccf47140c824 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -171,6 +171,7 @@ #include "mozilla/Preferences.h" #include "imgILoader.h" +#include "imgRequestProxy.h" #include "nsWrapperCacheInlines.h" #include "nsSandboxFlags.h" #include "nsIAppsService.h" @@ -7468,7 +7469,7 @@ nsDocument::MaybePreLoadImage(nsIURI* uri, const nsAString &aCrossOriginAttr) } // Image not in cache - trigger preload - nsCOMPtr request; + nsRefPtr request; nsresult rv = nsContentUtils::LoadImage(uri, this, diff --git a/content/base/src/nsGenConImageContent.cpp b/content/base/src/nsGenConImageContent.cpp index 3e78c47fff99..14750c530c0a 100644 --- a/content/base/src/nsGenConImageContent.cpp +++ b/content/base/src/nsGenConImageContent.cpp @@ -29,7 +29,7 @@ public: AddStatesSilently(NS_EVENT_STATE_SUPPRESSED); } - nsresult Init(imgIRequest* aImageRequest) + nsresult Init(imgRequestProxy* aImageRequest) { // No need to notify, since we have no frame. return UseAsPrimaryRequest(aImageRequest, false); @@ -68,7 +68,7 @@ NS_IMPL_ISUPPORTS_INHERITED3(nsGenConImageContent, nsresult NS_NewGenConImageContent(nsIContent** aResult, already_AddRefed aNodeInfo, - imgIRequest* aImageRequest) + imgRequestProxy* aImageRequest) { NS_PRECONDITION(aImageRequest, "Must have request!"); nsGenConImageContent *it = new nsGenConImageContent(aNodeInfo); diff --git a/content/base/src/nsImageLoadingContent.cpp b/content/base/src/nsImageLoadingContent.cpp index 449798d0a2a6..8292e52f5768 100644 --- a/content/base/src/nsImageLoadingContent.cpp +++ b/content/base/src/nsImageLoadingContent.cpp @@ -23,6 +23,7 @@ #include "nsILoadGroup.h" #include "imgIContainer.h" #include "imgLoader.h" +#include "imgRequestProxy.h" #include "nsThreadUtils.h" #include "nsNetUtil.h" #include "nsAsyncDOMEvent.h" @@ -464,7 +465,7 @@ nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel, AutoStateChanger changer(this, true); // Do the load. - nsCOMPtr& req = PrepareNextRequest(); + nsRefPtr& req = PrepareNextRequest(); nsresult rv = nsContentUtils::GetImgLoaderForChannel(aChannel)-> LoadImageWithChannel(aChannel, this, doc, aListener, getter_AddRefs(req)); @@ -654,7 +655,7 @@ nsImageLoadingContent::LoadImage(nsIURI* aNewURI, } // Not blocked. Do the load. - nsCOMPtr& req = PrepareNextRequest(); + nsRefPtr& req = PrepareNextRequest(); nsresult rv; rv = nsContentUtils::LoadImage(aNewURI, aDocument, aDocument->NodePrincipal(), @@ -784,7 +785,7 @@ nsImageLoadingContent::CancelImageRequests(bool aNotify) } nsresult -nsImageLoadingContent::UseAsPrimaryRequest(imgIRequest* aRequest, +nsImageLoadingContent::UseAsPrimaryRequest(imgRequestProxy* aRequest, bool aNotify) { // Our state will change. Watch it. @@ -795,7 +796,7 @@ nsImageLoadingContent::UseAsPrimaryRequest(imgIRequest* aRequest, ClearCurrentRequest(NS_BINDING_ABORTED); // Clone the request we were given. - nsCOMPtr& req = PrepareNextRequest();; + nsRefPtr& req = PrepareNextRequest(); nsresult rv = aRequest->Clone(this, getter_AddRefs(req)); if (NS_SUCCEEDED(rv)) TrackImage(req); @@ -883,7 +884,7 @@ nsImageLoadingContent::FireEvent(const nsAString& aEventType) return NS_OK; } -nsCOMPtr& +nsRefPtr& nsImageLoadingContent::PrepareNextRequest() { // If we don't have a usable current request, get rid of any half-baked @@ -922,7 +923,7 @@ nsImageLoadingContent::SetBlockedRequest(nsIURI* aURI, int16_t aContentDecision) } } -nsCOMPtr& +nsRefPtr& nsImageLoadingContent::PrepareCurrentRequest() { // Blocked images go through SetBlockedRequest, which is a separate path. For @@ -940,7 +941,7 @@ nsImageLoadingContent::PrepareCurrentRequest() return mCurrentRequest; } -nsCOMPtr& +nsRefPtr& nsImageLoadingContent::PreparePendingRequest() { // Get rid of anything that was there previously. diff --git a/content/base/src/nsImageLoadingContent.h b/content/base/src/nsImageLoadingContent.h index a67e9a744cb7..3c07c9c3abdc 100644 --- a/content/base/src/nsImageLoadingContent.h +++ b/content/base/src/nsImageLoadingContent.h @@ -124,11 +124,11 @@ protected: /** * UseAsPrimaryRequest is called by subclasses when they have an existing - * imgIRequest that they want this nsImageLoadingContent to use. This may + * imgRequestProxy that they want this nsImageLoadingContent to use. This may * effectively be called instead of LoadImage or LoadImageWithChannel. * If aNotify is true, this method will notify on state changes. */ - nsresult UseAsPrimaryRequest(imgIRequest* aRequest, bool aNotify); + nsresult UseAsPrimaryRequest(imgRequestProxy* aRequest, bool aNotify); /** * Derived classes of nsImageLoadingContent MUST call @@ -255,7 +255,7 @@ protected: * "pending" until it becomes usable. Otherwise, this becomes the current * request. */ - nsCOMPtr& PrepareNextRequest(); + nsRefPtr& PrepareNextRequest(); /** * Called when we would normally call PrepareNextRequest(), but the request was @@ -270,8 +270,8 @@ protected: * Clear*Request(NS_BINDING_ABORTED) instead, since it passes a more appropriate * aReason than Prepare*Request() does (NS_ERROR_IMAGE_SRC_CHANGED). */ - nsCOMPtr& PrepareCurrentRequest(); - nsCOMPtr& PreparePendingRequest(); + nsRefPtr& PrepareCurrentRequest(); + nsRefPtr& PreparePendingRequest(); /** * Switch our pending request to be our current request. @@ -316,8 +316,8 @@ protected: nsresult UntrackImage(imgIRequest* aImage); /* MEMBERS */ - nsCOMPtr mCurrentRequest; - nsCOMPtr mPendingRequest; + nsRefPtr mCurrentRequest; + nsRefPtr mPendingRequest; uint32_t mCurrentRequestFlags; uint32_t mPendingRequestFlags; diff --git a/content/html/content/src/nsHTMLImageElement.cpp b/content/html/content/src/nsHTMLImageElement.cpp index a4a3dfd02154..662df8a02d07 100644 --- a/content/html/content/src/nsHTMLImageElement.cpp +++ b/content/html/content/src/nsHTMLImageElement.cpp @@ -28,8 +28,8 @@ #include "imgIContainer.h" #include "imgILoader.h" -#include "imgIRequest.h" #include "imgINotificationObserver.h" +#include "imgRequestProxy.h" #include "nsILoadGroup.h" diff --git a/content/html/content/src/nsHTMLInputElement.cpp b/content/html/content/src/nsHTMLInputElement.cpp index 85dfbc9149f1..967fddc1be0c 100644 --- a/content/html/content/src/nsHTMLInputElement.cpp +++ b/content/html/content/src/nsHTMLInputElement.cpp @@ -77,6 +77,7 @@ // input type=image #include "nsImageLoadingContent.h" +#include "imgRequestProxy.h" #include "mozAutoDocUpdate.h" #include "nsContentCreatorFunctions.h" diff --git a/content/xbl/src/nsXBLResourceLoader.cpp b/content/xbl/src/nsXBLResourceLoader.cpp index 7e35cb80cd31..38a471cad105 100644 --- a/content/xbl/src/nsXBLResourceLoader.cpp +++ b/content/xbl/src/nsXBLResourceLoader.cpp @@ -16,7 +16,7 @@ #include "nsXBLPrototypeResources.h" #include "nsIDocumentObserver.h" #include "imgILoader.h" -#include "imgIRequest.h" +#include "imgRequestProxy.h" #include "mozilla/css/Loader.h" #include "nsIURI.h" #include "nsNetUtil.h" @@ -102,7 +102,7 @@ nsXBLResourceLoader::LoadResources(bool* aResult) // Now kick off the image load... // Passing NULL for pretty much everything -- cause we don't care! // XXX: initialDocumentURI is NULL! - nsCOMPtr req; + nsRefPtr req; nsContentUtils::LoadImage(url, doc, docPrincipal, docURL, nullptr, nsIRequest::LOAD_BACKGROUND, getter_AddRefs(req)); diff --git a/embedding/browser/webBrowser/nsContextMenuInfo.cpp b/embedding/browser/webBrowser/nsContextMenuInfo.cpp index b923174246db..ef856ebdb57e 100644 --- a/embedding/browser/webBrowser/nsContextMenuInfo.cpp +++ b/embedding/browser/webBrowser/nsContextMenuInfo.cpp @@ -6,7 +6,7 @@ #include "nsContextMenuInfo.h" #include "nsIImageLoadingContent.h" -#include "imgILoader.h" +#include "imgLoader.h" #include "nsIDOMDocument.h" #include "nsIDOMHTMLDocument.h" #include "nsIDOMHTMLElement.h" @@ -26,6 +26,8 @@ #include "nsIChannelPolicy.h" #include "nsIContentSecurityPolicy.h" #include "nsIContentPolicy.h" +#include "nsAutoPtr.h" +#include "imgRequestProxy.h" //***************************************************************************** // class nsContextMenuInfo @@ -160,7 +162,7 @@ nsContextMenuInfo::GetBackgroundImageContainer(imgIContainer **aImageContainer) NS_ENSURE_ARG_POINTER(aImageContainer); NS_ENSURE_STATE(mDOMNode); - nsCOMPtr request; + nsRefPtr request; GetBackgroundImageRequest(mDOMNode, getter_AddRefs(request)); if (request) return request->GetImage(aImageContainer); @@ -175,7 +177,7 @@ nsContextMenuInfo::GetBackgroundImageSrc(nsIURI **aURI) NS_ENSURE_ARG_POINTER(aURI); NS_ENSURE_STATE(mDOMNode); - nsCOMPtr request; + nsRefPtr request; GetBackgroundImageRequest(mDOMNode, getter_AddRefs(request)); if (request) return request->GetURI(aURI); @@ -204,14 +206,14 @@ nsContextMenuInfo::HasBackgroundImage(nsIDOMNode * aDOMNode) { NS_ENSURE_TRUE(aDOMNode, false); - nsCOMPtr request; + nsRefPtr request; GetBackgroundImageRequest(aDOMNode, getter_AddRefs(request)); return (request != nullptr); } nsresult -nsContextMenuInfo::GetBackgroundImageRequest(nsIDOMNode *aDOMNode, imgIRequest **aRequest) +nsContextMenuInfo::GetBackgroundImageRequest(nsIDOMNode *aDOMNode, imgRequestProxy **aRequest) { NS_ENSURE_ARG(aDOMNode); @@ -246,7 +248,7 @@ nsContextMenuInfo::GetBackgroundImageRequest(nsIDOMNode *aDOMNode, imgIRequest * } nsresult -nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode *aDOMNode, imgIRequest **aRequest) +nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode *aDOMNode, imgRequestProxy **aRequest) { NS_ENSURE_ARG_POINTER(aDOMNode); @@ -301,7 +303,7 @@ nsContextMenuInfo::GetBackgroundImageRequestInternal(nsIDOMNode *aDOMNode, imgIR NS_NewURI(getter_AddRefs(bgUri), bgStringValue); NS_ENSURE_TRUE(bgUri, NS_ERROR_FAILURE); - nsCOMPtr il(do_CreateInstance("@mozilla.org/image/loader;1")); + nsRefPtr il = imgLoader::GetInstance(); NS_ENSURE_TRUE(il, NS_ERROR_FAILURE); return il->LoadImage(bgUri, nullptr, nullptr, principal, nullptr, diff --git a/embedding/browser/webBrowser/nsContextMenuInfo.h b/embedding/browser/webBrowser/nsContextMenuInfo.h index c24aa435eb9d..b35c53d083de 100644 --- a/embedding/browser/webBrowser/nsContextMenuInfo.h +++ b/embedding/browser/webBrowser/nsContextMenuInfo.h @@ -15,6 +15,7 @@ #include "imgIRequest.h" class ChromeContextMenuListener; +class imgRequestProxy; //***************************************************************************** // class nsContextMenuInfo @@ -50,10 +51,10 @@ private: bool HasBackgroundImage(nsIDOMNode *aDOMNode); nsresult GetBackgroundImageRequest(nsIDOMNode *aDOMNode, - imgIRequest **aRequest); + imgRequestProxy **aRequest); nsresult GetBackgroundImageRequestInternal(nsIDOMNode *aDOMNode, - imgIRequest **aRequest); + imgRequestProxy **aRequest); private: nsCOMPtr mMouseEvent; diff --git a/image/public/imgILoader.idl b/image/public/imgILoader.idl index e644bf0ea556..cf751632aae7 100644 --- a/image/public/imgILoader.idl +++ b/image/public/imgILoader.idl @@ -27,7 +27,7 @@ interface nsIChannelPolicy; * @version 0.3 * @see imagelib2 */ -[scriptable, builtinclass, uuid(278c4c8e-934f-4364-b49b-081cd8b1d595)] +[scriptable, builtinclass, uuid(c8126129-8dac-43cd-b1ba-3896fba2dd01)] interface imgILoader : nsISupports { // Extra flags to pass to loadImage if you want a load to use CORS @@ -54,16 +54,16 @@ interface imgILoader : nsISupports * make sure to Cancel() the resulting request before the observer * goes away. */ - imgIRequest loadImage(in nsIURI aURI, - in nsIURI aInitialDocumentURL, - in nsIURI aReferrerURI, - in nsIPrincipal aLoadingPrincipal, - in nsILoadGroup aLoadGroup, - in imgINotificationObserver aObserver, - in nsISupports aCX, - in nsLoadFlags aLoadFlags, - in nsISupports cacheKey, - in nsIChannelPolicy channelPolicy); + imgIRequest loadImageXPCOM(in nsIURI aURI, + in nsIURI aInitialDocumentURL, + in nsIURI aReferrerURI, + in nsIPrincipal aLoadingPrincipal, + in nsILoadGroup aLoadGroup, + in imgINotificationObserver aObserver, + in nsISupports aCX, + in nsLoadFlags aLoadFlags, + in nsISupports cacheKey, + in nsIChannelPolicy channelPolicy); /** * Start the load and decode of an image. @@ -82,8 +82,8 @@ interface imgILoader : nsISupports * reference cycles. This means that callers of loadImageWithChannel should * make sure to Cancel() the resulting request before the observer goes away. */ - imgIRequest loadImageWithChannel(in nsIChannel aChannel, - in imgINotificationObserver aObserver, - in nsISupports cx, - out nsIStreamListener aListener); + imgIRequest loadImageWithChannelXPCOM(in nsIChannel aChannel, + in imgINotificationObserver aObserver, + in nsISupports cx, + out nsIStreamListener aListener); }; diff --git a/image/src/Makefile.in b/image/src/Makefile.in index c7348c6f9112..189662404f56 100644 --- a/image/src/Makefile.in +++ b/image/src/Makefile.in @@ -21,6 +21,7 @@ FAIL_ON_WARNINGS = 1 EXPORTS = imgLoader.h \ imgRequest.h \ + imgRequestProxy.h \ $(NULL) CPPSRCS = \ diff --git a/image/src/imgLoader.cpp b/image/src/imgLoader.cpp index 01d1753331a5..c87934ef25ca 100644 --- a/image/src/imgLoader.cpp +++ b/image/src/imgLoader.cpp @@ -5,6 +5,7 @@ #include "mozilla/Attributes.h" #include "mozilla/Preferences.h" +#include "mozilla/ClearOnShutdown.h" #include "ImageLogging.h" #include "imgLoader.h" @@ -681,7 +682,7 @@ imgCacheQueue::const_iterator imgCacheQueue::end() const nsresult imgLoader::CreateNewProxyForRequest(imgRequest *aRequest, nsILoadGroup *aLoadGroup, imgINotificationObserver *aObserver, - nsLoadFlags aLoadFlags, imgIRequest **_retval) + nsLoadFlags aLoadFlags, imgRequestProxy **_retval) { LOG_SCOPE_WITH_PARAM(GetImgLog(), "imgLoader::CreateNewProxyForRequest", "imgRequest", aRequest); @@ -709,7 +710,7 @@ nsresult imgLoader::CreateNewProxyForRequest(imgRequest *aRequest, nsILoadGroup } // transfer reference to caller - *_retval = static_cast(proxyRequest); + *_retval = proxyRequest; return NS_OK; } @@ -787,6 +788,20 @@ imgLoader::imgLoader() sMemReporter->RegisterLoader(this); } +already_AddRefed +imgLoader::GetInstance() +{ + static StaticRefPtr singleton; + if (!singleton) { + singleton = imgLoader::Create(); + if (!singleton) + return nullptr; + ClearOnShutdown(&singleton); + } + nsRefPtr loader = singleton.get(); + return loader.forget(); +} + imgLoader::~imgLoader() { ClearChromeImageCache(); @@ -1159,7 +1174,7 @@ bool imgLoader::ValidateRequestWithNewChannel(imgRequest *request, imgINotificationObserver *aObserver, nsISupports *aCX, nsLoadFlags aLoadFlags, - imgIRequest **aProxyRequest, + imgRequestProxy **aProxyRequest, nsIChannelPolicy *aPolicy, nsIPrincipal* aLoadingPrincipal, int32_t aCORSMode) @@ -1173,8 +1188,8 @@ bool imgLoader::ValidateRequestWithNewChannel(imgRequest *request, // If we're currently in the middle of validating this request, just hand // back a proxy to it; the required work will be done for us. if (request->mValidator) { - rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver, aLoadFlags, - reinterpret_cast(aProxyRequest)); + rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver, + aLoadFlags, aProxyRequest); if (NS_FAILED(rv)) { return false; } @@ -1214,7 +1229,7 @@ bool imgLoader::ValidateRequestWithNewChannel(imgRequest *request, return false; } - nsCOMPtr req; + nsRefPtr req; rv = CreateNewProxyForRequest(request, aLoadGroup, aObserver, aLoadFlags, getter_AddRefs(req)); if (NS_FAILED(rv)) { @@ -1280,7 +1295,7 @@ bool imgLoader::ValidateEntry(imgCacheEntry *aEntry, nsISupports *aCX, nsLoadFlags aLoadFlags, bool aCanMakeNewChannel, - imgIRequest **aProxyRequest, + imgRequestProxy **aProxyRequest, nsIChannelPolicy *aPolicy, nsIPrincipal* aLoadingPrincipal, int32_t aCORSMode) @@ -1516,10 +1531,7 @@ nsresult imgLoader::EvictEntries(imgCacheQueue &aQueueToClear) nsIRequest::VALIDATE_NEVER | \ nsIRequest::VALIDATE_ONCE_PER_SESSION) - -/* imgIRequest loadImage(in nsIURI aURI, in nsIURI aInitialDocumentURL, in nsIURI aReferrerURI, in nsIPrincipal aLoadingPrincipal, in nsILoadGroup aLoadGroup, in imgINotificationObserver aObserver, in nsISupports aCX, in nsLoadFlags aLoadFlags, in nsISupports cacheKey, in nsIChannelPolicy channelPolicy); */ - -NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, +NS_IMETHODIMP imgLoader::LoadImageXPCOM(nsIURI *aURI, nsIURI *aInitialDocumentURI, nsIURI *aReferrerURI, nsIPrincipal* aLoadingPrincipal, @@ -1531,7 +1543,39 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, nsIChannelPolicy *aPolicy, imgIRequest **_retval) { - VerifyCacheSizes(); + imgRequestProxy *proxy; + nsresult result = LoadImage(aURI, + aInitialDocumentURI, + aReferrerURI, + aLoadingPrincipal, + aLoadGroup, + aObserver, + aCX, + aLoadFlags, + aCacheKey, + aPolicy, + &proxy); + *_retval = proxy; + return result; +} + + + +/* imgIRequest loadImage(in nsIURI aURI, in nsIURI aInitialDocumentURL, in nsIURI aReferrerURI, in nsIPrincipal aLoadingPrincipal, in nsILoadGroup aLoadGroup, in imgINotificationObserver aObserver, in nsISupports aCX, in nsLoadFlags aLoadFlags, in nsISupports cacheKey, in nsIChannelPolicy channelPolicy); */ + +nsresult imgLoader::LoadImage(nsIURI *aURI, + nsIURI *aInitialDocumentURI, + nsIURI *aReferrerURI, + nsIPrincipal* aLoadingPrincipal, + nsILoadGroup *aLoadGroup, + imgINotificationObserver *aObserver, + nsISupports *aCX, + nsLoadFlags aLoadFlags, + nsISupports *aCacheKey, + nsIChannelPolicy *aPolicy, + imgRequestProxy **_retval) +{ + VerifyCacheSizes(); NS_ASSERTION(aURI, "imgLoader::LoadImage -- NULL URI pointer"); @@ -1747,7 +1791,7 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, return rv; } - imgRequestProxy *proxy = static_cast(*_retval); + imgRequestProxy *proxy = *_retval; // Make sure that OnStatus/OnProgress calls have the right request set, if // we did create a channel here. @@ -1780,8 +1824,21 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, return NS_OK; } -/* imgIRequest loadImageWithChannel(in nsIChannel channel, in imgINotificationObserver aObserver, in nsISupports cx, out nsIStreamListener); */ -NS_IMETHODIMP imgLoader::LoadImageWithChannel(nsIChannel *channel, imgINotificationObserver *aObserver, nsISupports *aCX, nsIStreamListener **listener, imgIRequest **_retval) +/* imgIRequest loadImageWithChannelXPCOM(in nsIChannel channel, in imgINotificationObserver aObserver, in nsISupports cx, out nsIStreamListener); */ +NS_IMETHODIMP imgLoader::LoadImageWithChannelXPCOM(nsIChannel *channel, imgINotificationObserver *aObserver, nsISupports *aCX, nsIStreamListener **listener, imgIRequest **_retval) +{ + nsresult result; + imgRequestProxy* proxy; + result = LoadImageWithChannel(channel, + aObserver, + aCX, + listener, + &proxy); + *_retval = proxy; + return result; +} + +nsresult imgLoader::LoadImageWithChannel(nsIChannel *channel, imgINotificationObserver *aObserver, nsISupports *aCX, nsIStreamListener **listener, imgRequestProxy **_retval) { NS_ASSERTION(channel, "imgLoader::LoadImageWithChannel -- NULL channel pointer"); diff --git a/image/src/imgLoader.h b/image/src/imgLoader.h index 9106abbc5cb8..cb5c7278cccf 100644 --- a/image/src/imgLoader.h +++ b/image/src/imgLoader.h @@ -239,6 +239,25 @@ public: return static_cast(loader); } + static already_AddRefed GetInstance(); + + nsresult LoadImage(nsIURI *aURI, + nsIURI *aInitialDocumentURI, + nsIURI *aReferrerURI, + nsIPrincipal* aLoadingPrincipal, + nsILoadGroup *aLoadGroup, + imgINotificationObserver *aObserver, + nsISupports *aCX, + nsLoadFlags aLoadFlags, + nsISupports *aCacheKey, + nsIChannelPolicy *aPolicy, + imgRequestProxy **_retval); + nsresult LoadImageWithChannel(nsIChannel *channel, + imgINotificationObserver *aObserver, + nsISupports *aCX, + nsIStreamListener **listener, + imgRequestProxy **_retval); + static nsresult GetMimeTypeFromContent(const char* aContents, uint32_t aLength, nsACString& aContentType); // exported for use by mimei.cpp in libxul sdk builds static NS_EXPORT_(bool) SupportImageWithMimeType(const char* aMimeType); @@ -304,7 +323,7 @@ private: // methods nsILoadGroup *aLoadGroup, imgINotificationObserver *aObserver, nsISupports *aCX, nsLoadFlags aLoadFlags, bool aCanMakeNewChannel, - imgIRequest **aProxyRequest, + imgRequestProxy **aProxyRequest, nsIChannelPolicy *aPolicy, nsIPrincipal* aLoadingPrincipal, int32_t aCORSMode); @@ -315,14 +334,14 @@ private: // methods nsILoadGroup *aLoadGroup, imgINotificationObserver *aObserver, nsISupports *aCX, nsLoadFlags aLoadFlags, - imgIRequest **aProxyRequest, + imgRequestProxy **aProxyRequest, nsIChannelPolicy *aPolicy, nsIPrincipal* aLoadingPrincipal, int32_t aCORSMode); nsresult CreateNewProxyForRequest(imgRequest *aRequest, nsILoadGroup *aLoadGroup, imgINotificationObserver *aObserver, - nsLoadFlags aLoadFlags, imgIRequest **_retval); + nsLoadFlags aLoadFlags, imgRequestProxy **_retval); void ReadAcceptHeaderPref(); diff --git a/image/src/imgRequestProxy.cpp b/image/src/imgRequestProxy.cpp index 9d3856a0de88..0d99f4614291 100644 --- a/image/src/imgRequestProxy.cpp +++ b/image/src/imgRequestProxy.cpp @@ -552,13 +552,23 @@ imgRequestProxy* NewStaticProxy(imgRequestProxy* aThis) NS_IMETHODIMP imgRequestProxy::Clone(imgINotificationObserver* aObserver, imgIRequest** aClone) +{ + nsresult result; + imgRequestProxy* proxy; + result = Clone(aObserver, &proxy); + *aClone = proxy; + return result; +} + +nsresult imgRequestProxy::Clone(imgINotificationObserver* aObserver, + imgRequestProxy** aClone) { return PerformClone(aObserver, NewProxy, aClone); } nsresult imgRequestProxy::PerformClone(imgINotificationObserver* aObserver, imgRequestProxy* (aAllocFn)(imgRequestProxy*), - imgIRequest** aClone) + imgRequestProxy** aClone) { NS_PRECONDITION(aClone, "Null out param"); @@ -837,6 +847,15 @@ void imgRequestProxy::NullOutListener() NS_IMETHODIMP imgRequestProxy::GetStaticRequest(imgIRequest** aReturn) +{ + imgRequestProxy *proxy; + nsresult result = GetStaticRequest(&proxy); + *aReturn = proxy; + return result; +} + +nsresult +imgRequestProxy::GetStaticRequest(imgRequestProxy** aReturn) { *aReturn = nullptr; mozilla::image::Image* image = GetImage(); @@ -989,5 +1008,9 @@ NS_IMETHODIMP imgRequestProxyStatic::Clone(imgINotificationObserver* aObserver, imgIRequest** aClone) { - return PerformClone(aObserver, NewStaticProxy, aClone); + nsresult result; + imgRequestProxy* proxy; + result = PerformClone(aObserver, NewStaticProxy, &proxy); + *aClone = proxy; + return result; } diff --git a/image/src/imgRequestProxy.h b/image/src/imgRequestProxy.h index 52b138fdd3af..94897d8e3b51 100644 --- a/image/src/imgRequestProxy.h +++ b/image/src/imgRequestProxy.h @@ -103,6 +103,9 @@ public: // imgRequest::RemoveProxy void ClearAnimationConsumers(); + nsresult Clone(imgINotificationObserver* aObserver, imgRequestProxy** aClone); + nsresult GetStaticRequest(imgRequestProxy** aReturn); + protected: friend class imgStatusTracker; friend class imgStatusNotifyRunnable; @@ -176,7 +179,7 @@ protected: nsresult PerformClone(imgINotificationObserver* aObserver, imgRequestProxy* (aAllocFn)(imgRequestProxy*), - imgIRequest** aClone); + imgRequestProxy** aClone); public: NS_FORWARD_SAFE_NSITIMEDCHANNEL(TimedChannel()) diff --git a/image/test/unit/async_load_tests.js b/image/test/unit/async_load_tests.js index bbb77a0a4a81..71accd6c8a95 100644 --- a/image/test/unit/async_load_tests.js +++ b/image/test/unit/async_load_tests.js @@ -96,7 +96,7 @@ function checkSecondLoad() var listener = new ImageListener(checkClone, secondLoadDone); var outer = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools) .createScriptedObserver(listener); - requests.push(gCurrentLoader.loadImage(uri, null, null, null, null, outer, null, 0, null, null)); + requests.push(gCurrentLoader.loadImageXPCOM(uri, null, null, null, null, outer, null, 0, null, null)); listener.synchronous = false; } @@ -154,7 +154,7 @@ function checkSecondChannelLoad() var outer = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools) .createScriptedObserver(listener); var outlistener = {}; - requests.push(gCurrentLoader.loadImageWithChannel(channel, outer, null, outlistener)); + requests.push(gCurrentLoader.loadImageWithChannelXPCOM(channel, outer, null, outlistener)); channellistener.outputListener = outlistener.value; listener.synchronous = false; @@ -178,7 +178,7 @@ function run_loadImageWithChannel_tests() var outer = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools) .createScriptedObserver(listener); var outlistener = {}; - requests.push(gCurrentLoader.loadImageWithChannel(channel, outer, null, outlistener)); + requests.push(gCurrentLoader.loadImageWithChannelXPCOM(channel, outer, null, outlistener)); channellistener.outputListener = outlistener.value; listener.synchronous = false; @@ -198,7 +198,7 @@ function startImageCallback(otherCb) var listener2 = new ImageListener(null, function(foo, bar) { do_test_finished(); }); var outer = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools) .createScriptedObserver(listener2); - requests.push(gCurrentLoader.loadImage(uri, null, null, null, null, outer, null, 0, null, null)); + requests.push(gCurrentLoader.loadImageXPCOM(uri, null, null, null, null, outer, null, 0, null, null)); listener2.synchronous = false; // Now that we've started another load, chain to the callback. @@ -216,7 +216,7 @@ function run_test() var listener = new ImageListener(startImageCallback(checkClone), firstLoadDone); var outer = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools) .createScriptedObserver(listener); - var req = gCurrentLoader.loadImage(uri, null, null, null, null, outer, null, 0, null, null); + var req = gCurrentLoader.loadImageXPCOM(uri, null, null, null, null, outer, null, 0, null, null); requests.push(req); // Ensure that we don't cause any mayhem when we lock an image. diff --git a/image/test/unit/test_private_channel.js b/image/test/unit/test_private_channel.js index 9086aad7312b..b9a9cc464501 100644 --- a/image/test/unit/test_private_channel.js +++ b/image/test/unit/test_private_channel.js @@ -60,7 +60,7 @@ function setup_chan(path, isPrivate, callback) { var outer = Cc["@mozilla.org/image/tools;1"].getService(Ci.imgITools) .createScriptedObserver(listener); listeners.push(outer); - requests.push(loader.loadImageWithChannel(chan, outer, null, outlistener)); + requests.push(loader.loadImageWithChannelXPCOM(chan, outer, null, outlistener)); channelListener.outputListener = outlistener.value; listener.synchronous = false; } @@ -73,7 +73,7 @@ function loadImage(isPrivate, callback) { var loadGroup = Cc["@mozilla.org/network/load-group;1"].createInstance(Ci.nsILoadGroup); loadGroup.notificationCallbacks = new NotificationCallbacks(isPrivate); var loader = isPrivate ? gPrivateLoader : gPublicLoader; - requests.push(loader.loadImage(uri, null, null, null, loadGroup, outer, null, 0, null, null)); + requests.push(loader.loadImageXPCOM(uri, null, null, null, loadGroup, outer, null, 0, null, null)); listener.synchronous = false; } diff --git a/layout/generic/nsBulletFrame.cpp b/layout/generic/nsBulletFrame.cpp index fea4fb592094..6f99476e82ef 100644 --- a/layout/generic/nsBulletFrame.cpp +++ b/layout/generic/nsBulletFrame.cpp @@ -24,6 +24,7 @@ #include "imgILoader.h" #include "imgIContainer.h" +#include "imgRequestProxy.h" #include "nsIServiceManager.h" #include "nsIComponentManager.h" @@ -94,7 +95,7 @@ nsBulletFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) { nsFrame::DidSetStyleContext(aOldStyleContext); - imgIRequest *newRequest = GetStyleList()->GetListStyleImage(); + imgRequestProxy *newRequest = GetStyleList()->GetListStyleImage(); if (newRequest) { diff --git a/layout/generic/nsBulletFrame.h b/layout/generic/nsBulletFrame.h index c51a8e94c90a..bfd4fab8cb77 100644 --- a/layout/generic/nsBulletFrame.h +++ b/layout/generic/nsBulletFrame.h @@ -16,6 +16,8 @@ #include "imgIDecoderObserver.h" #include "imgINotificationObserver.h" +class imgRequestProxy; + #define BULLET_FRAME_IMAGE_LOADING NS_FRAME_STATE_BIT(63) #define BULLET_FRAME_HAS_FONT_INFLATION NS_FRAME_STATE_BIT(62) @@ -109,7 +111,7 @@ protected: void GetLoadGroup(nsPresContext *aPresContext, nsILoadGroup **aLoadGroup); nsMargin mPadding; - nsCOMPtr mImageRequest; + nsRefPtr mImageRequest; nsRefPtr mListener; nsSize mIntrinsicSize; diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 4bd1b57b5ae6..65317cffe8d3 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -53,6 +53,7 @@ #include "imgIContainer.h" #include "imgLoader.h" +#include "imgRequestProxy.h" #include "nsCSSFrameConstructor.h" #include "nsIDOMRange.h" @@ -1811,7 +1812,7 @@ nsImageFrame::GetIntrinsicImageSize(nsSize& aSize) nsresult nsImageFrame::LoadIcon(const nsAString& aSpec, nsPresContext *aPresContext, - imgIRequest** aRequest) + imgRequestProxy** aRequest) { nsresult rv = NS_OK; NS_PRECONDITION(!aSpec.IsEmpty(), "What happened??"); diff --git a/layout/generic/nsImageFrame.h b/layout/generic/nsImageFrame.h index e77b4de19785..ac243c758725 100644 --- a/layout/generic/nsImageFrame.h +++ b/layout/generic/nsImageFrame.h @@ -30,6 +30,7 @@ class nsPresContext; class nsImageFrame; class nsTransform2D; class nsImageLoadingContent; +class imgRequestProxy; namespace mozilla { namespace layers { @@ -298,7 +299,7 @@ private: // loading / broken images nsresult LoadIcons(nsPresContext *aPresContext); nsresult LoadIcon(const nsAString& aSpec, nsPresContext *aPresContext, - imgIRequest **aRequest); + imgRequestProxy **aRequest); class IconLoad MOZ_FINAL : public nsIObserver, public imgINotificationObserver { @@ -333,8 +334,8 @@ private: public: - nsCOMPtr mLoadingImage; - nsCOMPtr mBrokenImage; + nsRefPtr mLoadingImage; + nsRefPtr mBrokenImage; bool mPrefForceInlineAltText; bool mPrefShowPlaceholders; }; diff --git a/layout/style/ImageLoader.cpp b/layout/style/ImageLoader.cpp index e01095fbe578..021537ad0cc0 100644 --- a/layout/style/ImageLoader.cpp +++ b/layout/style/ImageLoader.cpp @@ -121,13 +121,13 @@ ImageLoader::MaybeRegisterCSSImage(ImageLoader::Image* aImage) return; } - imgIRequest* canonicalRequest = aImage->mRequests.GetWeak(nullptr); + imgRequestProxy* canonicalRequest = aImage->mRequests.GetWeak(nullptr); if (!canonicalRequest) { // The image was blocked or something. return; } - nsCOMPtr request; + nsRefPtr request; // Ignore errors here. If cloning fails for some reason we'll put a null // entry in the hash and we won't keep trying to clone. @@ -261,7 +261,7 @@ ImageLoader::LoadImage(nsIURI* aURI, nsIPrincipal* aOriginPrincipal, return; } - nsCOMPtr request; + nsRefPtr request; nsContentUtils::LoadImage(aURI, mDocument, aOriginPrincipal, aReferrer, nullptr, nsIRequest::LOAD_NORMAL, getter_AddRefs(request)); @@ -270,7 +270,7 @@ ImageLoader::LoadImage(nsIURI* aURI, nsIPrincipal* aOriginPrincipal, return; } - nsCOMPtr clonedRequest; + nsRefPtr clonedRequest; mInClone = true; nsresult rv = request->Clone(this, getter_AddRefs(clonedRequest)); mInClone = false; diff --git a/layout/style/nsCSSValue.cpp b/layout/style/nsCSSValue.cpp index 642e6f8b5a3e..84b9123e5053 100644 --- a/layout/style/nsCSSValue.cpp +++ b/layout/style/nsCSSValue.cpp @@ -244,7 +244,7 @@ double nsCSSValue::GetAngleValueInRadians() const } } -imgIRequest* nsCSSValue::GetImageValue(nsIDocument* aDocument) const +imgRequestProxy* nsCSSValue::GetImageValue(nsIDocument* aDocument) const { NS_ABORT_IF_FALSE(mUnit == eCSSUnit_Image, "not an Image value"); return mValue.mImage->mRequests.GetWeak(aDocument); @@ -1725,7 +1725,7 @@ css::ImageValue::ImageValue(nsIURI* aURI, nsStringBuffer* aString, } static PLDHashOperator -ClearRequestHashtable(nsISupports* aKey, nsCOMPtr& aValue, +ClearRequestHashtable(nsISupports* aKey, nsRefPtr& aValue, void* aClosure) { mozilla::css::ImageValue* image = diff --git a/layout/style/nsCSSValue.h b/layout/style/nsCSSValue.h index ee949a42f7aa..4fbd58d872f1 100644 --- a/layout/style/nsCSSValue.h +++ b/layout/style/nsCSSValue.h @@ -16,14 +16,14 @@ #include "nsCSSProperty.h" #include "nsColor.h" #include "nsCoord.h" -#include "nsInterfaceHashtable.h" +#include "nsRefPtrHashtable.h" #include "nsString.h" #include "nsStringBuffer.h" #include "nsTArray.h" #include "nsStyleConsts.h" #include "mozilla/FloatingPoint.h" -class imgIRequest; +class imgRequestProxy; class nsIDocument; class nsIPrincipal; class nsPresContext; @@ -125,7 +125,7 @@ struct ImageValue : public URLValue { // Inherit operator== from URLValue - nsInterfaceHashtable mRequests; + nsRefPtrHashtable mRequests; // Override AddRef and Release to not only log ourselves correctly, but // also so that we delete correctly without a virtual destructor @@ -454,7 +454,7 @@ public: // Not making this inline because that would force us to include // imgIRequest.h, which leads to REQUIRES hell, since this header is included // all over. - imgIRequest* GetImageValue(nsIDocument* aDocument) const; + imgRequestProxy* GetImageValue(nsIDocument* aDocument) const; nscoord GetFixedLength(nsPresContext* aPresContext) const; nscoord GetPixelLength() const; diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 380f16b62fb4..c0ce5e65f92e 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -65,7 +65,7 @@ using namespace mozilla::dom; if ((context_)->PresContext()->IsDynamic()) { \ method_(request_); \ } else { \ - nsCOMPtr req = nsContentUtils::GetStaticRequest(request_); \ + nsRefPtr req = nsContentUtils::GetStaticRequest(request_); \ method_(req); \ } diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 46caea6ba1ff..8f07e600e4f7 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -30,11 +30,10 @@ #include "nsCSSValue.h" #include "nsStyleTransformMatrix.h" #include "nsAlgorithm.h" -#include "imgIRequest.h" +#include "imgRequestProxy.h" #include "gfxRect.h" class nsIFrame; -class imgIRequest; class imgIContainer; struct nsCSSValueList; @@ -840,8 +839,8 @@ struct nsStyleBorder { } // These are defined in nsStyleStructInlines.h - inline void SetBorderImage(imgIRequest* aImage); - inline imgIRequest* GetBorderImage() const; + inline void SetBorderImage(imgRequestProxy* aImage); + inline imgRequestProxy* GetBorderImage() const; bool HasBorderImage() {return !!mBorderImageSource;} @@ -894,7 +893,7 @@ public: #endif protected: - nsCOMPtr mBorderImageSource; // [reset] + nsRefPtr mBorderImageSource; // [reset] public: nsStyleCorners mBorderRadius; // [reset] coord, percent @@ -1049,8 +1048,8 @@ struct nsStyleList { return NS_STYLE_HINT_FRAMECHANGE; } - imgIRequest* GetListStyleImage() const { return mListStyleImage; } - void SetListStyleImage(imgIRequest* aReq) + imgRequestProxy* GetListStyleImage() const { return mListStyleImage; } + void SetListStyleImage(imgRequestProxy* aReq) { if (mListStyleImage) mListStyleImage->UnlockImage(); @@ -1062,7 +1061,7 @@ struct nsStyleList { uint8_t mListStyleType; // [inherited] See nsStyleConsts.h uint8_t mListStylePosition; // [inherited] private: - nsCOMPtr mListStyleImage; // [inherited] + nsRefPtr mListStyleImage; // [inherited] nsStyleList& operator=(const nsStyleList& aOther) MOZ_DELETE; public: nsRect mImageRegion; // [inherited] the rect to use within an image @@ -1779,7 +1778,7 @@ struct nsStyleContentData { nsStyleContentType mType; union { PRUnichar *mString; - imgIRequest *mImage; + imgRequestProxy *mImage; nsCSSValue::Array* mCounters; } mContent; #ifdef DEBUG @@ -1804,7 +1803,7 @@ struct nsStyleContentData { void TrackImage(nsPresContext* aContext); void UntrackImage(nsPresContext* aContext); - void SetImage(imgIRequest* aRequest) + void SetImage(imgRequestProxy* aRequest) { NS_ABORT_IF_FALSE(!mImageTracked, "Setting a new image without untracking the old one!"); diff --git a/layout/style/nsStyleStructInlines.h b/layout/style/nsStyleStructInlines.h index c82c5135169c..0a245ecaa426 100644 --- a/layout/style/nsStyleStructInlines.h +++ b/layout/style/nsStyleStructInlines.h @@ -17,13 +17,13 @@ #include "imgIContainer.h" inline void -nsStyleBorder::SetBorderImage(imgIRequest* aImage) +nsStyleBorder::SetBorderImage(imgRequestProxy* aImage) { mBorderImageSource = aImage; mSubImages.Clear(); } -inline imgIRequest* +inline imgRequestProxy* nsStyleBorder::GetBorderImage() const { NS_ABORT_IF_FALSE(!mBorderImageSource || mImageTracked, diff --git a/layout/xul/base/src/nsImageBoxFrame.cpp b/layout/xul/base/src/nsImageBoxFrame.cpp index fdc2054f95b1..3e390c6421b3 100644 --- a/layout/xul/base/src/nsImageBoxFrame.cpp +++ b/layout/xul/base/src/nsImageBoxFrame.cpp @@ -250,7 +250,7 @@ nsImageBoxFrame::UpdateImage() if (!(appearance && nsBox::gTheme && nsBox::gTheme->ThemeSupportsWidget(nullptr, this, appearance))) { // get the list-style-image - imgIRequest *styleRequest = GetStyleList()->GetListStyleImage(); + imgRequestProxy *styleRequest = GetStyleList()->GetListStyleImage(); if (styleRequest) { styleRequest->Clone(mListener, getter_AddRefs(mImageRequest)); } diff --git a/layout/xul/base/src/nsImageBoxFrame.h b/layout/xul/base/src/nsImageBoxFrame.h index 28aff26a0137..7577ba5cb25d 100644 --- a/layout/xul/base/src/nsImageBoxFrame.h +++ b/layout/xul/base/src/nsImageBoxFrame.h @@ -13,6 +13,7 @@ #include "imgIContainer.h" #include "imgINotificationObserver.h" +class imgRequestProxy; class nsImageBoxFrame; class nsDisplayXULImage; @@ -110,7 +111,7 @@ private: // registered with the refresh driver. bool mRequestRegistered; - nsCOMPtr mImageRequest; + nsRefPtr mImageRequest; nsCOMPtr mListener; int32_t mLoadFlags; diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index d67eef1e29c2..5dc1bcae6757 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -2089,7 +2089,7 @@ nsTreeBodyFrame::GetImage(int32_t aRowIndex, nsTreeColumn* aCol, bool aUseContex nsAutoString imageSrc; mView->GetImageSrc(aRowIndex, aCol, imageSrc); - nsCOMPtr styleRequest; + nsRefPtr styleRequest; if (!aUseContext && !imageSrc.IsEmpty()) { aAllowImageRegions = false; } @@ -2147,7 +2147,7 @@ nsTreeBodyFrame::GetImage(int32_t aRowIndex, nsTreeColumn* aCol, bool aUseContex listener->AddCell(aRowIndex, aCol); nsCOMPtr imgNotificationObserver = listener; - nsCOMPtr imageRequest; + nsRefPtr imageRequest; if (styleRequest) { styleRequest->Clone(imgNotificationObserver, getter_AddRefs(imageRequest)); } else { diff --git a/toolkit/system/gnome/nsAlertsIconListener.cpp b/toolkit/system/gnome/nsAlertsIconListener.cpp index 9cb6b9df2ec0..68502bdd0c3d 100644 --- a/toolkit/system/gnome/nsAlertsIconListener.cpp +++ b/toolkit/system/gnome/nsAlertsIconListener.cpp @@ -200,9 +200,9 @@ nsAlertsIconListener::StartRequest(const nsAString & aImageUrl) if (!il) return ShowAlert(NULL); - return il->LoadImage(imageUri, nullptr, nullptr, nullptr, nullptr, this, - nullptr, nsIRequest::LOAD_NORMAL, nullptr, nullptr, - getter_AddRefs(mIconRequest)); + return il->LoadImageXPCOM(imageUri, nullptr, nullptr, nullptr, nullptr, this, + nullptr, nsIRequest::LOAD_NORMAL, nullptr, nullptr, + getter_AddRefs(mIconRequest)); } void diff --git a/widget/cocoa/nsMenuItemIconX.h b/widget/cocoa/nsMenuItemIconX.h index 87a49ed12efc..e43e3345cc8e 100644 --- a/widget/cocoa/nsMenuItemIconX.h +++ b/widget/cocoa/nsMenuItemIconX.h @@ -11,11 +11,12 @@ #define nsMenuItemIconX_h_ #include "nsCOMPtr.h" +#include "nsAutoPtr.h" #include "imgINotificationObserver.h" class nsIURI; class nsIContent; -class imgIRequest; +class imgRequestProxy; class nsMenuObjectX; #import @@ -53,13 +54,13 @@ public: protected: nsresult OnStopFrame(imgIRequest* aRequest); - nsCOMPtr mContent; - nsCOMPtr mIconRequest; - nsMenuObjectX* mMenuObject; // [weak] - nsIntRect mImageRegionRect; - bool mLoadedIcon; - bool mSetIcon; - NSMenuItem* mNativeMenuItem; // [weak] + nsCOMPtr mContent; + nsRefPtr mIconRequest; + nsMenuObjectX* mMenuObject; // [weak] + nsIntRect mImageRegionRect; + bool mLoadedIcon; + bool mSetIcon; + NSMenuItem* mNativeMenuItem; // [weak] }; #endif // nsMenuItemIconX_h_ diff --git a/widget/cocoa/nsMenuItemIconX.mm b/widget/cocoa/nsMenuItemIconX.mm index 885d4e7b7d3e..18b0c733e637 100644 --- a/widget/cocoa/nsMenuItemIconX.mm +++ b/widget/cocoa/nsMenuItemIconX.mm @@ -34,7 +34,7 @@ #include "nsToolkit.h" #include "nsNetUtil.h" #include "imgLoader.h" -#include "imgIRequest.h" +#include "imgRequestProxy.h" #include "nsMenuItemX.h" #include "gfxImageSurface.h" #include "imgIContainer.h"