fix for bug#30852.(nsbeta2+). Image reloads not using necko reload attributes. pnunn.

rev:neeti; and tested on win/mac/linux.
This commit is contained in:
pnunn%netscape.com 2000-07-20 01:52:35 +00:00
Родитель a9988fbc1f
Коммит 38ed05f47f
18 изменённых файлов: 180 добавлений и 106 удалений

Просмотреть файл

@ -224,12 +224,17 @@ nsImageDocument::StartImageLoad(nsIURI* aURL, nsIStreamListener*& aListener)
nsIImageGroup* group = nsnull;
cx->GetImageGroup(&group);
if (nsnull != group) {
char* spec;
(void)aURL->GetSpec(&spec);
nsIStreamListener* listener = nsnull;
rv = group->GetImageFromStream(spec, nsnull, nsnull,
0, 0, 0,
mImageRequest, listener);
//set flag to indicate view-image needs to use imgcache
group->SetImgLoadAttributes(nsImageLoadFlags_kSticky);
nsCRT::free(spec);
aListener = listener;
NS_RELEASE(group);
@ -238,6 +243,7 @@ nsImageDocument::StartImageLoad(nsIURI* aURL, nsIStreamListener*& aListener)
NS_RELEASE(shell);
}
// Finally, start the layout going
StartLayout();

Просмотреть файл

@ -44,6 +44,7 @@ class nsILoadGroup;
/** Don't load if image cache misses. */
#define nsImageLoadFlags_kOnlyFromCache 0x08
// IID for the nsIImageGroup interface
#define NS_IIMAGEGROUP_IID \
{ 0xbe927e40, 0xaeaa, 0x11d1, \
@ -131,6 +132,10 @@ public:
* are interrupted.
*/
virtual void Interrupt(void) = 0;
NS_IMETHOD SetImgLoadAttributes(PRUint32 a_grouploading_attribs)=0;
NS_IMETHOD GetImgLoadAttributes(PRUint32 *a_grouploading_attribs)=0;
};
/// Factory method for creating an image group

Просмотреть файл

@ -73,12 +73,19 @@ public:
IL_GroupContext *GetGroupContext() { return mGroupContext; }
nsVoidArray *GetObservers() { return mObservers; }
NS_IMETHOD SetImgLoadAttributes(PRUint32 a_grouploading_attribs);
NS_IMETHOD GetImgLoadAttributes(PRUint32 *a_grouploading_attribs);
nsIImageManager *mManager;
IL_GroupContext *mGroupContext;
nsVoidArray *mObservers;
nsIDeviceContext *mDeviceContext;
ilINetContext* mNetContext;
nsIStreamListener** mListenerRequest;
//ptn
PRUint32 m_grouploading_attribs;
};
ImageGroupImpl::ImageGroupImpl(nsIImageManager *aManager)
@ -152,6 +159,9 @@ static void ns_observer_proc (XP_Observable aSource,
}
}
static PRBool
ReconnectHack(void* arg, nsIStreamListener* aListener)
{
@ -260,7 +270,14 @@ ImageGroupImpl::GetImage(const char* aUrl,
if (nsnull != image_req) {
nsresult result;
// Ask the image request object to get the image.
// Ask the image request object to get the image.
PRUint32 groupload_attrib = 0;
GetImgLoadAttributes(&groupload_attrib);
if(!aFlags)
aFlags = groupload_attrib;
mListenerRequest = nsnull;
result = image_req->Init(mGroupContext, aUrl, aObserver, aBackgroundColor,
aWidth, aHeight, aFlags, mNetContext);
@ -296,6 +313,14 @@ ImageGroupImpl::GetImageFromStream(const char* aUrl,
// Ask the image request object to get the image.
nsIStreamListener* listener = nsnull;
mListenerRequest = &listener;
PRUint32 groupload_attrib = 0;
GetImgLoadAttributes(&groupload_attrib);
if(!aFlags)
aFlags = groupload_attrib;
result = image_req->Init(mGroupContext, aUrl, aObserver, aBackgroundColor,
aWidth, aHeight, aFlags, mNetContext);
aListenerResult = listener;
@ -320,6 +345,19 @@ ImageGroupImpl::Interrupt(void)
}
}
NS_IMETHODIMP
ImageGroupImpl::SetImgLoadAttributes(PRUint32 a_grouploading_attribs){
m_grouploading_attribs = a_grouploading_attribs;
return NS_OK;
}
NS_IMETHODIMP
ImageGroupImpl::GetImgLoadAttributes(PRUint32 *a_grouploading_attribs){
*a_grouploading_attribs = m_grouploading_attribs;
return NS_OK;
}
extern "C" NS_GFX_(nsresult)
NS_NewImageGroup(nsIImageGroup **aInstancePtrResult)
{

Просмотреть файл

@ -59,7 +59,7 @@ class ImageConsumer;
class ImageNetContextImpl : public ilINetContext {
public:
ImageNetContextImpl(NET_ReloadMethod aReloadPolicy,
ImageNetContextImpl(ImgCachePolicy aReloadPolicy,
nsISupports * aLoadContext,
nsReconnectCB aReconnectCallback,
void* aReconnectArg);
@ -69,8 +69,8 @@ public:
virtual ilINetContext* Clone();
virtual NET_ReloadMethod GetReloadPolicy();
virtual NET_ReloadMethod SetReloadPolicy(NET_ReloadMethod ReloadPolicy);
virtual ImgCachePolicy GetReloadPolicy();
virtual ImgCachePolicy SetReloadPolicy(ImgCachePolicy ReloadPolicy);
virtual void AddReferer(ilIURL *aUrl);
@ -78,7 +78,7 @@ public:
virtual void Interrupt();
virtual ilIURL* CreateURL(const char *aUrl,
NET_ReloadMethod aReloadMethod);
ImgCachePolicy aReloadMethod);
virtual PRBool IsLocalFileURL(char *aAddress);
#ifdef NU_CACHE
@ -89,14 +89,14 @@ public:
virtual PRBool IsURLInDiskCache(ilIURL *aUrl);
#endif
virtual int GetURL (ilIURL * aUrl, NET_ReloadMethod aLoadMethod,
virtual int GetURL (ilIURL * aUrl, ImgCachePolicy aLoadMethod,
ilINetReader *aReader);
nsresult RequestDone(ImageConsumer *aConsumer, nsIChannel* channel,
nsISupports* ctxt, nsresult status, const PRUnichar* aMsg);
nsVoidArray *mRequests;
NET_ReloadMethod mReloadPolicy;
ImgCachePolicy mReloadPolicy;
nsWeakPtr mLoadContext;
nsReconnectCB mReconnectCallback;
void* mReconnectArg;
@ -565,7 +565,7 @@ ImageConsumer::~ImageConsumer()
NS_IF_RELEASE(mUserContext);
}
ImageNetContextImpl::ImageNetContextImpl(NET_ReloadMethod aReloadPolicy,
ImageNetContextImpl::ImageNetContextImpl(ImgCachePolicy aReloadPolicy,
nsISupports * aLoadContext,
nsReconnectCB aReconnectCallback,
void* aReconnectArg)
@ -613,14 +613,14 @@ ImageNetContextImpl::Clone()
}
}
NET_ReloadMethod
ImgCachePolicy
ImageNetContextImpl::GetReloadPolicy()
{
return mReloadPolicy;
}
NET_ReloadMethod
ImageNetContextImpl::SetReloadPolicy(NET_ReloadMethod reloadpolicy)
ImgCachePolicy
ImageNetContextImpl::SetReloadPolicy(ImgCachePolicy reloadpolicy)
{
mReloadPolicy=reloadpolicy;
return mReloadPolicy;
@ -645,7 +645,7 @@ ImageNetContextImpl::Interrupt()
ilIURL*
ImageNetContextImpl::CreateURL(const char *aURL,
NET_ReloadMethod aReloadMethod)
ImgCachePolicy aReloadMethod)
{
ilIURL *url;
@ -693,7 +693,7 @@ ImageNetContextImpl::IsURLInDiskCache(ilIURL *aUrl)
int
ImageNetContextImpl::GetURL (ilIURL * aURL,
NET_ReloadMethod aLoadMethod,
ImgCachePolicy aLoadMethod,
ilINetReader *aReader)
{
NS_PRECONDITION(nsnull != aURL, "null URL");
@ -754,34 +754,30 @@ ImageNetContextImpl::GetURL (ilIURL * aURL,
}
}
if (aURL->GetBackgroundLoad()) {
(void)channel->SetLoadAttributes(nsIChannel::LOAD_BACKGROUND);
}
nsLoadFlags flags;
rv = channel->GetLoadAttributes(&flags);
if (NS_FAILED(rv)) return rv;
if (aURL->GetBackgroundLoad()) {
(void)channel->SetLoadAttributes(nsIChannel::LOAD_BACKGROUND | flags);
}
switch(aLoadMethod){
case IMG_CACHE_ONLY:
/* shouldn't get here, but don't fail if you do. Just fall to the next case. */
case IMG_NTWK_SERVER:
case USE_IMG_CACHE:
(void)channel->SetLoadAttributes((nsIChannel::VALIDATE_NEVER) | flags);
break;
case TV_IMG_NTWK_SERVER:
case TV_NTWK_SERVER_ONLY:
case DONT_USE_IMG_CACHE:
(void)channel->SetLoadAttributes((nsIChannel::FORCE_VALIDATION) | flags);
break;
case SERVER_ONLY:
(void)channel->SetLoadAttributes((nsIChannel::FORCE_RELOAD) | flags);
case SYNTH_IMGDOC_NEEDS_IMG_CACHE:
break;
default:
break;
}
nsCOMPtr<nsISupports> window (do_QueryInterface(NS_STATIC_CAST(nsIStreamListener *, ic)));
// let's try uri dispatching...
@ -828,12 +824,38 @@ NS_NewImageNetContext(ilINetContext **aInstancePtrResult,
nsReconnectCB aReconnectCallback,
void* aReconnectArg)
{
PRUint32 necko_attribs;
ImgCachePolicy imglib_attribs = USE_IMG_CACHE;
NS_PRECONDITION(nsnull != aInstancePtrResult, "null ptr");
if (nsnull == aInstancePtrResult) {
return NS_ERROR_NULL_POINTER;
}
ilINetContext *cx = new ImageNetContextImpl(IMG_NTWK_SERVER,
if(aLoadContext){
nsCOMPtr<nsISupports> loadContext (do_QueryReferent(NS_GetWeakReference(aLoadContext)));
nsCOMPtr<nsILoadGroup> group (do_GetInterface(loadContext));
nsresult rv = group->GetDefaultLoadAttributes(&necko_attribs);
/*
Need code to check freshness of necko cache.
nsCOMPtr<nsIChannel> defLoadChannel;
if (NS_SUCCEEDED(group->GetDefaultLoadChannel(
getter_AddRefs(defLoadChannel))) && defLoadChannel)
defLoadChannel->CheckCacheFresh(&isFresh);
Modify code below to work w/r to freshness of necko cache.
*/
if((nsIChannel::FORCE_VALIDATION & necko_attribs)||
(nsIChannel::VALIDATE_ALWAYS & necko_attribs) ||
(nsIChannel::INHIBIT_PERSISTENT_CACHING & necko_attribs)||
(nsIChannel::FORCE_RELOAD & necko_attribs))
imglib_attribs = DONT_USE_IMG_CACHE;
}
ilINetContext *cx = new ImageNetContextImpl( imglib_attribs,
aLoadContext,
aReconnectCallback,
aReconnectArg);
@ -842,4 +864,6 @@ NS_NewImageNetContext(ilINetContext **aInstancePtrResult,
}
return cx->QueryInterface(kIImageNetContextIID, (void **) aInstancePtrResult);
}

Просмотреть файл

@ -46,21 +46,21 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
class ImageNetContextSyncImpl : public ilINetContext {
public:
ImageNetContextSyncImpl(NET_ReloadMethod aReloadPolicy);
ImageNetContextSyncImpl(ImgCachePolicy aReloadPolicy);
virtual ~ImageNetContextSyncImpl();
NS_DECL_ISUPPORTS
virtual ilINetContext* Clone();
virtual NET_ReloadMethod GetReloadPolicy();
virtual ImgCachePolicy GetReloadPolicy();
virtual void AddReferer(ilIURL* aUrl);
virtual void Interrupt();
virtual ilIURL* CreateURL(const char* aUrl,
NET_ReloadMethod aReloadMethod);
ImgCachePolicy aReloadMethod);
virtual PRBool IsLocalFileURL(char* aAddress);
#ifdef NU_CACHE
@ -72,13 +72,13 @@ public:
#endif /* NU_CACHE */
virtual int GetURL(ilIURL* aUrl,
NET_ReloadMethod aLoadMethod,
ImgCachePolicy aLoadMethod,
ilINetReader* aReader);
NET_ReloadMethod mReloadPolicy;
ImgCachePolicy mReloadPolicy;
};
ImageNetContextSyncImpl::ImageNetContextSyncImpl(NET_ReloadMethod aReloadPolicy)
ImageNetContextSyncImpl::ImageNetContextSyncImpl(ImgCachePolicy aReloadPolicy)
{
NS_INIT_REFCNT();
mReloadPolicy = aReloadPolicy;
@ -102,7 +102,7 @@ ImageNetContextSyncImpl::Clone()
return nsnull;
}
NET_ReloadMethod
ImgCachePolicy
ImageNetContextSyncImpl::GetReloadPolicy()
{
return mReloadPolicy;
@ -120,7 +120,7 @@ ImageNetContextSyncImpl::Interrupt()
ilIURL*
ImageNetContextSyncImpl::CreateURL(const char* aURL,
NET_ReloadMethod aReloadMethod)
ImgCachePolicy aReloadMethod)
{
ilIURL *url;
@ -164,7 +164,7 @@ ImageNetContextSyncImpl::IsURLInDiskCache(ilIURL *aUrl)
int
ImageNetContextSyncImpl::GetURL(ilIURL* aURL,
NET_ReloadMethod aLoadMethod,
ImgCachePolicy aLoadMethod,
ilINetReader* aReader)
{
NS_PRECONDITION(nsnull != aURL, "null URL");
@ -294,7 +294,8 @@ nsresult NS_NewImageNetContextSync(ilINetContext **aInstancePtrResult)
return NS_ERROR_NULL_POINTER;
}
ilINetContext *cx = new ImageNetContextSyncImpl(IMG_NTWK_SERVER);
//Note default of USE_IMG_CACHE used.
ilINetContext *cx = new ImageNetContextSyncImpl(USE_IMG_CACHE);
if (cx == nsnull) {
return NS_ERROR_OUT_OF_MEMORY;
}

Просмотреть файл

@ -224,12 +224,17 @@ nsImageDocument::StartImageLoad(nsIURI* aURL, nsIStreamListener*& aListener)
nsIImageGroup* group = nsnull;
cx->GetImageGroup(&group);
if (nsnull != group) {
char* spec;
(void)aURL->GetSpec(&spec);
nsIStreamListener* listener = nsnull;
rv = group->GetImageFromStream(spec, nsnull, nsnull,
0, 0, 0,
mImageRequest, listener);
//set flag to indicate view-image needs to use imgcache
group->SetImgLoadAttributes(nsImageLoadFlags_kSticky);
nsCRT::free(spec);
aListener = listener;
NS_RELEASE(group);
@ -238,6 +243,7 @@ nsImageDocument::StartImageLoad(nsIURI* aURL, nsIStreamListener*& aListener)
NS_RELEASE(shell);
}
// Finally, start the layout going
StartLayout();

Просмотреть файл

@ -28,7 +28,6 @@
#define _DUMMY_NC_H
#include "prtypes.h"
#include "net.h"
typedef void* IL_NetContext;

Просмотреть файл

@ -25,7 +25,6 @@
#include <stdio.h>
#include "nsISupports.h"
#include "ntypes.h"
// IID for the ilINetContext interface
#define IL_INETCONTEXT_IID \
@ -42,14 +41,14 @@ public:
virtual ilINetContext* Clone()=0;
virtual NET_ReloadMethod GetReloadPolicy()=0;
virtual ImgCachePolicy GetReloadPolicy()=0;
virtual void AddReferer(ilIURL *aUrl)=0;
virtual void Interrupt()=0;
virtual ilIURL* CreateURL(const char *aUrl,
NET_ReloadMethod aReloadMethod)=0;
ImgCachePolicy aReloadMethod)=0;
virtual PRBool IsLocalFileURL(char *aAddress)=0;
@ -61,7 +60,7 @@ public:
virtual PRBool IsURLInDiskCache(ilIURL *aUrl)=0;
#endif /* NU_CACHE */
virtual int GetURL (ilIURL * aUrl, NET_ReloadMethod aLoadMethod,
virtual int GetURL (ilIURL * aUrl, ImgCachePolicy aLoadMethod,
ilINetReader *aReader)=0;
};

Просмотреть файл

@ -25,7 +25,7 @@
#include <stdio.h>
#include "nsISupports.h"
#include "ntypes.h"
// IID for the ilINetReader interface
#define IL_INETREADER_IID \

Просмотреть файл

@ -25,7 +25,7 @@
#include <stdio.h>
#include "nsISupports.h"
#include "ntypes.h"
// IID for the ilIURL interface
#define IL_IURL_IID \

Просмотреть файл

@ -22,7 +22,7 @@
/* -*- Mode: C; tab-width: 4 -*-
* il_types.h --- Image library data types and structures.
* $Id: il_types.h,v 3.5 1999/11/13 22:37:34 cls%seawood.org Exp $
* $Id: il_types.h,v 3.6 2000/07/20 01:49:58 pnunn%netscape.com Exp $
*/
@ -52,6 +52,16 @@
#define IL_BYPASS_CACHE 0x04 /* Don't get image out of image cache. */
#define IL_ONLY_FROM_CACHE 0x08 /* Don't load if image cache misses. */
typedef enum
{
USE_IMG_CACHE, /* use imgcache */
DONT_USE_IMG_CACHE, /* dont use imgcache AND if found in imgcache delete entry */
SYNTH_IMGDOC_NEEDS_IMG_CACHE /* needed for view-image/image doc */
} ImgCachePolicy;
/* A rectangle structure. */
typedef struct _IL_Rect {
PRUint16 x_origin;

Просмотреть файл

@ -22,7 +22,7 @@
/* if.h --- Top-level image library internal routines
*
* $Id: if_struct.h,v 1.10 2000/05/18 22:17:48 pnunn%netscape.com Exp $
* $Id: if_struct.h,v 1.11 2000/07/20 01:51:00 pnunn%netscape.com Exp $
*/
#ifndef _if_h
@ -43,9 +43,6 @@
#include "nsIImgDecoder.h"
#include "ntypes.h" /* typedefs for commonly used Netscape data
structures */
typedef struct _IL_GroupContext IL_GroupContext;
typedef struct _IL_ImageReq IL_ImageReq;
typedef struct il_context_list il_context_list;
@ -153,7 +150,7 @@ enum icstate {
/* Force memory cache to be flushed ? */
#define FORCE_RELOAD(reload_method) \
(((reload_method)==NET_NORMAL_RELOAD) || ((reload_method)==NET_SUPER_RELOAD))
(reload_method = DONT_USE_IMG_CACHE)
/* Simple list of image contexts. */
struct il_context_list {

Просмотреть файл

@ -23,7 +23,7 @@
/* -*- Mode: C; tab-width: 4 -*-
* il.h --- Exported image library interface
*
* $Id: il.h,v 1.3 1999/11/06 03:31:23 dmose%mozilla.org Exp $
* $Id: il.h,v 1.4 2000/07/20 01:51:20 pnunn%netscape.com Exp $
*/
@ -34,7 +34,6 @@
#ifndef _IL_H
#define _IL_H
#include "ntypes.h"
/* attr values */
#define IL_ATTR_RDONLY 0

Просмотреть файл

@ -1043,11 +1043,6 @@ IL_StreamFirstWrite(il_container *ic, const unsigned char *str, int32 len)
}
}
/* Grab the URL's expiration date */
if (ic->url)
ic->expires = ic->url->GetExpires();
/* if our mime sniffer can recognize what's in the
data stream and it is one of our std vanilla types.
Check to see if it matches the mimetype sent by creator.
@ -1494,8 +1489,8 @@ il_image_complete(il_container *ic)
ILTRACE(1,("il: loop %s", ic->url_address));
if(ic->net_cx){ //ptn test
netRequest = ic->net_cx->CreateURL(ic->fetch_url, IMG_NTWK_SERVER);
if(ic->net_cx){
netRequest = ic->net_cx->CreateURL(ic->fetch_url, USE_IMG_CACHE);
if (!netRequest) { /* OOM */
il_container_complete(ic);
break;
@ -1558,7 +1553,7 @@ il_image_complete(il_container *ic)
/* using lclient insures we are using an active image request */
(void) ic->lclient->net_cx->GetURL(ic->url, IMG_NTWK_SERVER, reader);
(void) ic->lclient->net_cx->GetURL(ic->url, USE_IMG_CACHE, reader);
/* Release reader, GetURL will keep a ref to it. */
NS_RELEASE(reader);
@ -1688,10 +1683,11 @@ il_hash(const char *ubuf)
}
return h;
}
#if 0
#define IL_LAST_ICON 62
/* Extra factor of 7 is to account for duplications between
mc-icons and ns-icons */
static PRUint32 il_icon_table[(IL_LAST_ICON + 7) * 2];
static void
@ -1876,6 +1872,7 @@ il_internal_image(const char *image_url)
}
return 0;
}
#endif
/* block certain hosts from loading images */
PRBool il_PermitLoad(const char * image_url, nsIImageRequestObserver * aObserver) {
@ -1995,16 +1992,20 @@ IL_GetImage(const char* image_url,
}
ilINetContext *net_cx = (ilINetContext *)opaque_cx;
NET_ReloadMethod cache_reload_policy = net_cx->GetReloadPolicy();
ImgCachePolicy cache_reload_policy = net_cx->GetReloadPolicy();
ilIURL *url = NULL;
IL_ImageReq *image_req;
ilINetReader *reader;
il_container *ic = NULL;
ilINetReader *reader;
il_container *ic = NULL;
int req_depth = img_cx->color_space->pixmap_depth;
int err;
int is_view_image;
int err;
int is_view_image = PR_FALSE;
if(flags == IL_STICKY)
is_view_image = PR_TRUE;
/* Create a new instance for this image request. */
image_req = PR_NEWZAP(IL_ImageReq);
@ -2020,7 +2021,7 @@ IL_GetImage(const char* image_url,
* handle on this backup net context.
*/
image_req->net_cx = net_cx->Clone();
if (!image_req->net_cx) {
if (!image_req->net_cx) {
PR_FREEIF(image_req);
return NULL;
}
@ -2037,27 +2038,9 @@ IL_GetImage(const char* image_url,
return image_req;
}
/* Check for any special internal-use URLs */
if (*image_url == 'i' ||
!PL_strncmp(image_url, "/mc-", 4) ||
!PL_strncmp(image_url, "/ns-", 4))
{
PRUint32 icon;
/* A built-in icon ? */
icon = il_internal_image(image_url);
if (icon)
{
ILTRACE(4,("il: internal icon %d", icon));
/* XXXM12N In response to this notification, layout should set
lo_image->image_attr->attrmask |= LO_ATTR_INTERNAL_IMAGE; */
il_icon_notify(image_req, icon, IL_INTERNAL_IMAGE);
return image_req;
}
}
if(is_view_image)
cache_reload_policy = SYNTH_IMGDOC_NEEDS_IMG_CACHE;
ic = il_get_container(img_cx, cache_reload_policy, image_url,
background_color, img_cx->dither_mode, req_depth,
@ -2075,7 +2058,8 @@ IL_GetImage(const char* image_url,
/* Give the client a handle into the imagelib world. */
image_req->ic = ic;
is_view_image = PR_FALSE;
if (!il_add_client(img_cx, ic, image_req, is_view_image))
{

Просмотреть файл

@ -22,7 +22,7 @@
/* if.h --- Top-level image library internal routines
*
* $Id: if.h,v 3.20 2000/05/18 22:17:02 pnunn%netscape.com Exp $
* $Id: if.h,v 3.21 2000/07/20 01:51:46 pnunn%netscape.com Exp $
*/
#ifndef _if_h
@ -41,9 +41,6 @@
#include "prlong.h"
#include "nsIPresContext.h"
#include "ntypes.h" /* typedefs for commonly used Netscape data
structures */
typedef struct _IL_GroupContext IL_GroupContext;
typedef struct _IL_ImageReq IL_ImageReq;
typedef struct il_context_list il_context_list;
@ -115,7 +112,7 @@ extern PRLogModuleInfo *il_log_module;
#endif
#define MIN(x, y) ((x) < (y) ? (x) : (y))
//ptn test
/* Conversion of imglib errors to XPCOM errors */
#define NS_CONVERT_ERROR_CODE(e) \
(NS_ERROR_GENERATE((e) ? NS_ERROR_SEVERITY_ERROR : NS_ERROR_SEVERITY_SUCCESS, NS_ERROR_MODULE_IMGLIB, (e) & 0xFFFF))
@ -163,7 +160,7 @@ enum icstate {
/* Force memory cache to be flushed ? */
#define FORCE_RELOAD(reload_method) \
(reload_method > IMG_NTWK_SERVER)
(reload_method = DONT_USE_IMG_CACHE)
/* Simple list of image contexts. */
struct il_context_list {
@ -432,7 +429,7 @@ extern void il_abort_reconnect(void);
then create and return a new container. */
extern il_container
*il_get_container(IL_GroupContext *image_context,
NET_ReloadMethod reload_cache_policy,
ImgCachePolicy reload_cache_policy,
const char *image_url,
IL_IRGB *background_color,
IL_DitherMode dither_mode,

Просмотреть файл

@ -23,13 +23,12 @@
/* -*- Mode: C; tab-width: 4 -*-
* il_util.c Colormap and colorspace utilities.
*
* $Id: il_util.cpp,v 3.7 1999/11/13 22:37:41 cls%seawood.org Exp $
* $Id: il_util.cpp,v 3.8 2000/07/20 01:52:02 pnunn%netscape.com Exp $
*/
#include "nsCRT.h"
#include "ntypes.h" /* typedefs for commonly used Netscape data
structures. */
#include "prtypes.h"
#include "prmem.h"

Просмотреть файл

@ -35,6 +35,9 @@
#include "nsCRT.h"
#include "xpcompat.h" //temporary, for timers
/* Note that default cache size is set in
src/gfx/nsImageManager.cpp, ~line 62.
*/
static PRUint32 image_cache_size;
static PRUint32 max_cache_items = 192;
@ -84,6 +87,7 @@ ImgDCallbk::CreateInstance(const nsCID &aClass,
if (NS_FAILED(res)) {
*ppv = NULL;
delete imgdcb;
ic->imgdcb = NULL;
}
return res;
}
@ -407,7 +411,7 @@ il_addtocache(il_container *ic);
il_container *
il_get_container(IL_GroupContext *img_cx,
NET_ReloadMethod cache_reload_policy,
ImgCachePolicy cache_reload_policy,
const char *image_url,
IL_IRGB *background_color,
IL_DitherMode dither_mode,
@ -416,7 +420,7 @@ il_get_container(IL_GroupContext *img_cx,
int req_height) /* Target height requested by client. */
{
PRUint32 urlhash, hash;
il_container *ic;
il_container *ic=NULL;
urlhash = hash = il_hash(image_url);
@ -429,7 +433,8 @@ il_get_container(IL_GroupContext *img_cx,
/* Check the cache */
ic = il_find_in_cache(img_cx->display_type, hash, image_url,
background_color, req_depth, req_width, req_height);
if (ic) {
/* This ic is being destroyed. Need a new one */
@ -444,7 +449,7 @@ il_get_container(IL_GroupContext *img_cx,
/* 2) Their namespace crosses document boundaries, so caching */
/* could result in incorrect behavior. */
else if(cache_reload_policy > IMG_NTWK_SERVER){
else if(cache_reload_policy == DONT_USE_IMG_CACHE){
/* Don't use old copy and purge it from cache.*/
if (!ic->is_in_use) {
il_removefromcache(ic);
@ -565,8 +570,9 @@ il_get_container(IL_GroupContext *img_cx,
imgdcb->SetContainer(ic);
ic->imgdcb = imgdcb;
}
il_addtocache(ic);
ic->is_in_use = PR_TRUE;
return ic;
@ -715,7 +721,9 @@ il_removefromcache(il_container *ic)
il_cache.items--;
PR_ASSERT(il_cache.items >= 0);
}
return ic;
}
void
@ -982,7 +990,7 @@ il_delete_client(il_container *ic, IL_ImageReq *image_req)
ic->img_cx = ic->clients->img_cx;
/* The container's net context may be about to become invalid, so
give the container a different one which is known to be valid. */
if ((ic->net_cx )&&(ic->net_cx == net_cx)) //ptn test
if ((ic->net_cx )&&(ic->net_cx == net_cx))
{
NS_RELEASE(ic->net_cx);
ic->net_cx = ic->clients->net_cx->Clone();
@ -1063,7 +1071,7 @@ IL_DestroyImage(IL_ImageReq *image_req)
{
IL_GroupContext *img_cx;
PRBool client_deleted;
il_container *ic, *ic2, *ic2_next;
il_container *ic, *ic2 = NULL, *ic2_next = NULL;
il_container_list *ic_list;
/* Check for a NULL request. */

Просмотреть файл

@ -431,6 +431,8 @@ nsLoadGroup::AddChannel(nsIChannel *channel, nsISupports* ctxt)
rv = channel->GetLoadAttributes(&flags);
if (NS_FAILED(rv)) return rv;
SetDefaultLoadAttributes(flags);
//
// Add the channel to the list of active channels...
//