зеркало из https://github.com/mozilla/gecko-dev.git
Added a nsIURLGroup to image URL creation. This allows the URLs to be loaded via the same document loader and use the same load attributes...
This commit is contained in:
Родитель
a426451caf
Коммит
31b8dfe190
|
@ -29,6 +29,7 @@ class nsIImageRequestObserver;
|
|||
class nsIImageRequest;
|
||||
class nsIDeviceContext;
|
||||
class nsIStreamListener;
|
||||
class nsIURLGroup;
|
||||
|
||||
/** For important images, like backdrops. */
|
||||
#define nsImageLoadFlags_kHighPriority 0x01
|
||||
|
@ -56,7 +57,8 @@ public:
|
|||
* Initialize an image group with a device context. All images
|
||||
* in this group will be decoded for the specified device context.
|
||||
*/
|
||||
virtual nsresult Init(nsIDeviceContext *aDeviceContext) = 0;
|
||||
virtual nsresult Init(nsIDeviceContext *aDeviceContext,
|
||||
nsIURLGroup* aURLGroup) = 0;
|
||||
|
||||
/**
|
||||
* Add an observers to be informed of image group notifications.
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "il_util.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIURLGroup.h"
|
||||
|
||||
static NS_DEFINE_IID(kIImageGroupIID, NS_IIMAGEGROUP_IID);
|
||||
|
||||
|
@ -43,7 +44,7 @@ public:
|
|||
ImageGroupImpl(nsIImageManager *aManager);
|
||||
~ImageGroupImpl();
|
||||
|
||||
nsresult Init(nsIDeviceContext *aDeviceContext);
|
||||
nsresult Init(nsIDeviceContext *aDeviceContext, nsIURLGroup* aURLGroup);
|
||||
|
||||
void* operator new(size_t sz) {
|
||||
void* rv = new char[sz];
|
||||
|
@ -81,6 +82,7 @@ public:
|
|||
nsIDeviceContext *mDeviceContext;
|
||||
ilINetContext* mNetContext;
|
||||
nsIStreamListener** mListenerRequest;
|
||||
nsIURLGroup* mURLGroup;
|
||||
};
|
||||
|
||||
ImageGroupImpl::ImageGroupImpl(nsIImageManager *aManager)
|
||||
|
@ -113,6 +115,7 @@ ImageGroupImpl::~ImageGroupImpl()
|
|||
|
||||
NS_IF_RELEASE(mManager);
|
||||
NS_IF_RELEASE(mNetContext);
|
||||
NS_IF_RELEASE(mURLGroup);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(ImageGroupImpl, kIImageGroupIID)
|
||||
|
@ -130,7 +133,7 @@ ReconnectHack(void* arg, nsIStreamListener* aListener)
|
|||
}
|
||||
|
||||
nsresult
|
||||
ImageGroupImpl::Init(nsIDeviceContext *aDeviceContext)
|
||||
ImageGroupImpl::Init(nsIDeviceContext *aDeviceContext, nsIURLGroup* aURLGroup)
|
||||
{
|
||||
ilIImageRenderer *renderer;
|
||||
nsresult result;
|
||||
|
@ -145,8 +148,11 @@ ImageGroupImpl::Init(nsIDeviceContext *aDeviceContext)
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
mURLGroup = aURLGroup;
|
||||
NS_IF_ADDREF(mURLGroup);
|
||||
|
||||
// Create an async net context
|
||||
result = NS_NewImageNetContext(&mNetContext, ReconnectHack, this);
|
||||
result = NS_NewImageNetContext(&mNetContext, mURLGroup, ReconnectHack, this);
|
||||
if (NS_OK != result) {
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -23,14 +23,19 @@
|
|||
#include "nscore.h"
|
||||
|
||||
class nsIStreamListener;
|
||||
class nsIURLGroup;
|
||||
typedef PRBool (*nsReconnectCB)(void* arg, nsIStreamListener* aListener);
|
||||
|
||||
extern "C" NS_GFX_(nsresult)
|
||||
NS_NewImageNetContext(ilINetContext **aInstancePtrResult,
|
||||
nsIURLGroup* aURLGroup,
|
||||
nsReconnectCB aReconnectCallback,
|
||||
void* aReconnectArg);
|
||||
|
||||
extern "C" NS_GFX_(nsresult) NS_NewImageURL(ilIURL **aInstancePtrResult, const char *aURL);
|
||||
extern "C" NS_GFX_(nsresult)
|
||||
NS_NewImageURL(ilIURL **aInstancePtrResult,
|
||||
const char *aURL,
|
||||
nsIURLGroup* aURLGroup);
|
||||
|
||||
extern "C" NS_GFX_(nsresult) NS_NewImageRenderer(ilIImageRenderer **aInstancePtrResult);
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "nsIStreamListener.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIURLGroup.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsString.h"
|
||||
|
@ -42,6 +43,7 @@ class ImageConsumer;
|
|||
class ImageNetContextImpl : public ilINetContext {
|
||||
public:
|
||||
ImageNetContextImpl(NET_ReloadMethod aReloadPolicy,
|
||||
nsIURLGroup* aURLGroup,
|
||||
nsReconnectCB aReconnectCallback,
|
||||
void* aReconnectArg);
|
||||
~ImageNetContextImpl();
|
||||
|
@ -72,6 +74,7 @@ public:
|
|||
|
||||
nsVoidArray *mRequests;
|
||||
NET_ReloadMethod mReloadPolicy;
|
||||
nsIURLGroup* mURLGroup;
|
||||
nsReconnectCB mReconnectCallback;
|
||||
void* mReconnectArg;
|
||||
};
|
||||
|
@ -333,11 +336,14 @@ ImageConsumer::~ImageConsumer()
|
|||
}
|
||||
|
||||
ImageNetContextImpl::ImageNetContextImpl(NET_ReloadMethod aReloadPolicy,
|
||||
nsIURLGroup* aURLGroup,
|
||||
nsReconnectCB aReconnectCallback,
|
||||
void* aReconnectArg)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mRequests = nsnull;
|
||||
mURLGroup = aURLGroup;
|
||||
NS_IF_ADDREF(mURLGroup);
|
||||
mReloadPolicy = aReloadPolicy;
|
||||
mReconnectCallback = aReconnectCallback;
|
||||
mReconnectArg = aReconnectArg;
|
||||
|
@ -354,6 +360,7 @@ ImageNetContextImpl::~ImageNetContextImpl()
|
|||
}
|
||||
delete mRequests;
|
||||
}
|
||||
NS_IF_RELEASE(mURLGroup);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(ImageNetContextImpl, kIImageNetContextIID)
|
||||
|
@ -363,7 +370,7 @@ ImageNetContextImpl::Clone()
|
|||
{
|
||||
ilINetContext *cx;
|
||||
|
||||
if (NS_NewImageNetContext(&cx, mReconnectCallback, mReconnectArg) == NS_OK) {
|
||||
if (NS_NewImageNetContext(&cx, mURLGroup, mReconnectCallback, mReconnectArg) == NS_OK) {
|
||||
return cx;
|
||||
}
|
||||
else {
|
||||
|
@ -400,7 +407,7 @@ ImageNetContextImpl::CreateURL(const char *aURL,
|
|||
{
|
||||
ilIURL *url;
|
||||
|
||||
if (NS_NewImageURL(&url, aURL) == NS_OK) {
|
||||
if (NS_NewImageURL(&url, aURL, mURLGroup) == NS_OK) {
|
||||
return url;
|
||||
}
|
||||
else {
|
||||
|
@ -490,6 +497,7 @@ ImageNetContextImpl::RequestDone(ImageConsumer *aConsumer)
|
|||
|
||||
extern "C" NS_GFX_(nsresult)
|
||||
NS_NewImageNetContext(ilINetContext **aInstancePtrResult,
|
||||
nsIURLGroup* aURLGroup,
|
||||
nsReconnectCB aReconnectCallback,
|
||||
void* aReconnectArg)
|
||||
{
|
||||
|
@ -499,6 +507,7 @@ NS_NewImageNetContext(ilINetContext **aInstancePtrResult,
|
|||
}
|
||||
|
||||
ilINetContext *cx = new ImageNetContextImpl(NET_NORMAL_RELOAD,
|
||||
aURLGroup,
|
||||
aReconnectCallback,
|
||||
aReconnectArg);
|
||||
if (cx == nsnull) {
|
||||
|
|
|
@ -111,7 +111,7 @@ ImageNetContextSyncImpl::CreateURL(const char* aURL,
|
|||
{
|
||||
ilIURL *url;
|
||||
|
||||
if (NS_NewImageURL(&url, aURL) == NS_OK) {
|
||||
if (NS_NewImageURL(&url, aURL, nsnull) == NS_OK) {
|
||||
return url;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "ilINetReader.h"
|
||||
#include "ilIURL.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIURLGroup.h"
|
||||
#include "nsString.h"
|
||||
#include "il_strm.h"
|
||||
|
||||
|
@ -30,7 +31,7 @@ static NS_DEFINE_IID(kIImageURLIID, IL_IURL_IID);
|
|||
|
||||
class ImageURLImpl : public ilIURL {
|
||||
public:
|
||||
ImageURLImpl(const char *aURL);
|
||||
ImageURLImpl(const char *aURL, nsIURLGroup* aURLGroup);
|
||||
~ImageURLImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -56,22 +57,21 @@ private:
|
|||
ilINetReader *mReader;
|
||||
};
|
||||
|
||||
ImageURLImpl::ImageURLImpl(const char *aURL)
|
||||
ImageURLImpl::ImageURLImpl(const char *aURL, nsIURLGroup* aURLGroup)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
NS_NewURL(&mURL, aURL);
|
||||
if (nsnull != aURLGroup) {
|
||||
aURLGroup->CreateURL(&mURL, nsnull, aURL, nsnull);
|
||||
} else {
|
||||
NS_NewURL(&mURL, nsnull, aURL);
|
||||
}
|
||||
mReader = nsnull;
|
||||
}
|
||||
|
||||
ImageURLImpl::~ImageURLImpl()
|
||||
{
|
||||
if (mURL != nsnull) {
|
||||
NS_RELEASE(mURL);
|
||||
}
|
||||
|
||||
if (mReader != nsnull) {
|
||||
NS_RELEASE(mReader);
|
||||
}
|
||||
NS_IF_RELEASE(mURL);
|
||||
NS_IF_RELEASE(mReader);
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -117,25 +117,19 @@ nsrefcnt ImageURLImpl::Release(void)
|
|||
void
|
||||
ImageURLImpl::SetReader(ilINetReader *aReader)
|
||||
{
|
||||
if (mReader != nsnull) {
|
||||
NS_RELEASE(mReader);
|
||||
}
|
||||
NS_IF_RELEASE(mReader);
|
||||
|
||||
mReader = aReader;
|
||||
mReader = aReader;
|
||||
|
||||
if (mReader != nsnull) {
|
||||
NS_ADDREF(mReader);
|
||||
}
|
||||
NS_IF_ADDREF(mReader);
|
||||
}
|
||||
|
||||
ilINetReader *
|
||||
ImageURLImpl::GetReader()
|
||||
{
|
||||
if (mReader != nsnull) {
|
||||
NS_ADDREF(mReader);
|
||||
}
|
||||
NS_IF_ADDREF(mReader);
|
||||
|
||||
return mReader;
|
||||
return mReader;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -178,14 +172,15 @@ ImageURLImpl::SetOwnerId(int aOwnerId)
|
|||
}
|
||||
|
||||
extern "C" NS_GFX_(nsresult)
|
||||
NS_NewImageURL(ilIURL **aInstancePtrResult, const char *aURL)
|
||||
NS_NewImageURL(ilIURL **aInstancePtrResult, const char *aURL,
|
||||
nsIURLGroup* aURLGroup)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
|
||||
if (nsnull == aInstancePtrResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
ilIURL *url = new ImageURLImpl(aURL);
|
||||
ilIURL *url = new ImageURLImpl(aURL, aURLGroup);
|
||||
if (url == nsnull) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче