зеркало из https://github.com/mozilla/pjs.git
lets do imgIRequest instead of lpIImageRequest
This commit is contained in:
Родитель
971968616c
Коммит
40ae3ada73
|
@ -56,8 +56,8 @@ nsGIFDecoder2::~nsGIFDecoder2(void)
|
|||
//******************************************************************************
|
||||
|
||||
//******************************************************************************
|
||||
/* void init (in lpIImageRequest aRequest); */
|
||||
NS_IMETHODIMP nsGIFDecoder2::Init(lpIImageRequest *aRequest)
|
||||
/* void init (in imgIRequest aRequest); */
|
||||
NS_IMETHODIMP nsGIFDecoder2::Init(imgIRequest *aRequest)
|
||||
{
|
||||
mImageRequest = aRequest;
|
||||
mObserver = do_QueryInterface(aRequest); // we're holding 2 strong refs to the request.
|
||||
|
@ -87,8 +87,8 @@ NS_IMETHODIMP nsGIFDecoder2::Init(lpIImageRequest *aRequest)
|
|||
}
|
||||
|
||||
//******************************************************************************
|
||||
/* readonly attribute lpIImageRequest request; */
|
||||
NS_IMETHODIMP nsGIFDecoder2::GetRequest(lpIImageRequest * *aRequest)
|
||||
/* readonly attribute imgIRequest request; */
|
||||
NS_IMETHODIMP nsGIFDecoder2::GetRequest(imgIRequest * *aRequest)
|
||||
{
|
||||
*aRequest = mImageRequest;
|
||||
NS_IF_ADDREF(*aRequest);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "gfxIImageContainer.h"
|
||||
#include "nsIImageDecoderObserver.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "lpIImageRequest.h"
|
||||
#include "imgIRequest.h"
|
||||
|
||||
#include "GIF2.h"
|
||||
|
||||
|
@ -60,7 +60,7 @@ public:
|
|||
|
||||
nsCOMPtr<gfxIImageContainer> mImageContainer;
|
||||
nsCOMPtr<gfxIImageFrame> mImageFrame;
|
||||
nsCOMPtr<lpIImageRequest> mImageRequest;
|
||||
nsCOMPtr<imgIRequest> mImageRequest;
|
||||
nsCOMPtr<nsIImageDecoderObserver> mObserver; // this is just qi'd from mRequest for speed
|
||||
|
||||
gif_struct mGIFStruct;
|
||||
|
|
|
@ -80,8 +80,8 @@ nsJPEGDecoder::~nsJPEGDecoder()
|
|||
|
||||
/** nsIImageDecoder methods **/
|
||||
|
||||
/* void init (in lpIImageRequest aRequest); */
|
||||
NS_IMETHODIMP nsJPEGDecoder::Init(lpIImageRequest *aRequest)
|
||||
/* void init (in imgIRequest aRequest); */
|
||||
NS_IMETHODIMP nsJPEGDecoder::Init(imgIRequest *aRequest)
|
||||
{
|
||||
mRequest = aRequest;
|
||||
mObserver = do_QueryInterface(mRequest);
|
||||
|
@ -144,8 +144,8 @@ NS_IMETHODIMP nsJPEGDecoder::Init(lpIImageRequest *aRequest)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute lpIImageRequest request; */
|
||||
NS_IMETHODIMP nsJPEGDecoder::GetRequest(lpIImageRequest * *aRequest)
|
||||
/* readonly attribute imgIRequest request; */
|
||||
NS_IMETHODIMP nsJPEGDecoder::GetRequest(imgIRequest * *aRequest)
|
||||
{
|
||||
*aRequest = mRequest;
|
||||
NS_ADDREF(*aRequest);
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "gfxIImageContainer.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "nsIImageDecoderObserver.h"
|
||||
#include "lpIImageRequest.h"
|
||||
#include "imgIRequest.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIPipe.h"
|
||||
|
||||
|
@ -85,7 +85,7 @@ protected:
|
|||
public:
|
||||
nsCOMPtr<gfxIImageContainer> mImage;
|
||||
nsCOMPtr<gfxIImageFrame> mFrame;
|
||||
nsCOMPtr<lpIImageRequest> mRequest;
|
||||
nsCOMPtr<imgIRequest> mRequest;
|
||||
|
||||
nsCOMPtr<nsIImageDecoderObserver> mObserver;
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@ nsPNGDecoder::~nsPNGDecoder()
|
|||
|
||||
/** nsIImageDecoder methods **/
|
||||
|
||||
/* void init (in lpIImageRequest aRequest); */
|
||||
NS_IMETHODIMP nsPNGDecoder::Init(lpIImageRequest *aRequest)
|
||||
/* void init (in imgIRequest aRequest); */
|
||||
NS_IMETHODIMP nsPNGDecoder::Init(imgIRequest *aRequest)
|
||||
{
|
||||
mRequest = aRequest;
|
||||
mObserver = do_QueryInterface(aRequest); // we're holding 2 strong refs to the request.
|
||||
|
@ -104,8 +104,8 @@ NS_IMETHODIMP nsPNGDecoder::Init(lpIImageRequest *aRequest)
|
|||
}
|
||||
|
||||
|
||||
/* readonly attribute lpIImageRequest request; */
|
||||
NS_IMETHODIMP nsPNGDecoder::GetRequest(lpIImageRequest * *aRequest)
|
||||
/* readonly attribute imgIRequest request; */
|
||||
NS_IMETHODIMP nsPNGDecoder::GetRequest(imgIRequest * *aRequest)
|
||||
{
|
||||
*aRequest = mRequest;
|
||||
NS_ADDREF(*aRequest);
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#include "gfxIImageContainer.h"
|
||||
#include "nsIImageDecoderObserver.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "lpIImageRequest.h"
|
||||
#include "imgIRequest.h"
|
||||
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -69,7 +69,7 @@ end_callback(png_structp png_ptr, png_infop info_ptr);
|
|||
public:
|
||||
nsCOMPtr<gfxIImageContainer> mImage;
|
||||
nsCOMPtr<gfxIImageFrame> mFrame;
|
||||
nsCOMPtr<lpIImageRequest> mRequest;
|
||||
nsCOMPtr<imgIRequest> mRequest;
|
||||
nsCOMPtr<nsIImageDecoderObserver> mObserver; // this is just qi'd from mRequest for speed
|
||||
|
||||
png_structp mPNG;
|
||||
|
|
|
@ -55,8 +55,8 @@ nsPPMDecoder::~nsPPMDecoder()
|
|||
|
||||
/** nsIImageDecoder methods **/
|
||||
|
||||
/* void init (in lpIImageRequest aRequest); */
|
||||
NS_IMETHODIMP nsPPMDecoder::Init(lpIImageRequest *aRequest)
|
||||
/* void init (in imgIRequest aRequest); */
|
||||
NS_IMETHODIMP nsPPMDecoder::Init(imgIRequest *aRequest)
|
||||
{
|
||||
mRequest = aRequest;
|
||||
|
||||
|
@ -71,8 +71,8 @@ NS_IMETHODIMP nsPPMDecoder::Init(lpIImageRequest *aRequest)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute lpIImageRequest request; */
|
||||
NS_IMETHODIMP nsPPMDecoder::GetRequest(lpIImageRequest * *aRequest)
|
||||
/* readonly attribute imgIRequest request; */
|
||||
NS_IMETHODIMP nsPPMDecoder::GetRequest(imgIRequest * *aRequest)
|
||||
{
|
||||
*aRequest = mRequest;
|
||||
NS_ADDREF(*aRequest);
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "gfxIImageContainer.h"
|
||||
#include "nsIImageDecoderObserver.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "lpIImageRequest.h"
|
||||
#include "imgIRequest.h"
|
||||
|
||||
#define NS_PPMDECODER_CID \
|
||||
{ /* e90bfa06-1dd1-11b2-8217-f38fe5d431a2 */ \
|
||||
|
@ -54,7 +54,7 @@ public:
|
|||
private:
|
||||
nsCOMPtr<gfxIImageContainer> mImage;
|
||||
nsCOMPtr<gfxIImageFrame> mFrame;
|
||||
nsCOMPtr<lpIImageRequest> mRequest;
|
||||
nsCOMPtr<imgIRequest> mRequest;
|
||||
nsCOMPtr<nsIImageDecoderObserver> mObserver; // this is just qi'd from mRequest for speed
|
||||
|
||||
PRUint32 mDataReceived;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
nsIImageDecoder.idl
|
||||
nsIImageDecoderObserver.idl
|
||||
nsIImageLoader.idl
|
||||
lpIImageRequest.idl
|
||||
imgIRequest.idl
|
||||
|
|
|
@ -31,7 +31,7 @@ MODULE = imglib2
|
|||
XPIDLSRCS = nsIImageDecoder.idl \
|
||||
nsIImageDecoderObserver.idl \
|
||||
nsIImageLoader.idl \
|
||||
lpIImageRequest.idl
|
||||
imgIRequest.idl
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface gfxIImageContainer;
|
||||
|
||||
/**
|
||||
* lpIImageRequest interface
|
||||
*
|
||||
* @author Stuart Parmenter <pavlov@netscape.com>
|
||||
* @version 0.1
|
||||
* @see imagelib2
|
||||
*/
|
||||
[scriptable, uuid(ccf705f6-1dd1-11b2-82ef-e18eccf7f7ec)]
|
||||
interface lpIImageRequest : nsISupports
|
||||
{
|
||||
void cancel(in nsresult status);
|
||||
|
||||
/**
|
||||
* the image container...
|
||||
* @return the image object associated with the request.
|
||||
* @attention NEED DOCS
|
||||
*/
|
||||
readonly attribute gfxIImageContainer image;
|
||||
|
||||
/**
|
||||
* Bits set in the return value from imageStatus
|
||||
* @name statusflags
|
||||
*/
|
||||
//@{
|
||||
const long STATUS_NONE = 0x0;
|
||||
const long STATUS_SIZE_AVAILABLE = 0x1;
|
||||
const long STATUS_LOAD_COMPLETE = 0x2;
|
||||
const long STATUS_ERROR = 0x4;
|
||||
//@}
|
||||
|
||||
/**
|
||||
* something
|
||||
* @attention NEED DOCS
|
||||
*/
|
||||
readonly attribute unsigned long imageStatus;
|
||||
};
|
|
@ -31,7 +31,7 @@ XPIDLSRCS = \
|
|||
.\nsIImageDecoder.idl \
|
||||
.\nsIImageDecoderObserver.idl \
|
||||
.\nsIImageLoader.idl \
|
||||
.\lpIImageRequest.idl \
|
||||
.\imgIRequest.idl \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIOutputStream.idl"
|
||||
#include "gfxtypes.idl"
|
||||
|
||||
interface lpIImageRequest;
|
||||
|
||||
/**
|
||||
* nsIImageDecoder interface
|
||||
*
|
||||
* @author Stuart Parmenter <pavlov@netscape.com>
|
||||
* @version 0.1
|
||||
* @see imagelib2
|
||||
*/
|
||||
[scriptable, uuid(9eebf43a-1dd1-11b2-953e-f1782f4cbad3)]
|
||||
interface nsIImageDecoder : nsIOutputStream
|
||||
{
|
||||
/**
|
||||
* Initalize an image decoder.
|
||||
* @param aRequest the request that owns the decoder.
|
||||
*
|
||||
* @note The decode should QI \a aRequest to an nsIImageDecoderObserver
|
||||
* and should send decoder notifications to the request.
|
||||
* The decoder should always pass NULL as the first two parameters to
|
||||
* all of the nsIImageDecoderObserver APIs.
|
||||
*/
|
||||
void init(in lpIImageRequest aRequest);
|
||||
|
||||
/// allows access to the nsIImage we have to put bits in to.
|
||||
readonly attribute lpIImageRequest request;
|
||||
};
|
|
@ -1,81 +0,0 @@
|
|||
/** -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#include "gfxIImageContainerObserver.idl"
|
||||
#include "gfxtypes.idl"
|
||||
|
||||
interface lpIImageRequest;
|
||||
interface gfxIImageContainer;
|
||||
interface gfxIImageFrame;
|
||||
|
||||
%{C++
|
||||
#include "nsRect.h"
|
||||
%}
|
||||
|
||||
/**
|
||||
* nsIImageDecoderObserver interface
|
||||
*
|
||||
* @author Stuart Parmenter <pavlov@netscape.com>
|
||||
* @version 0.1
|
||||
* @see imagelib2
|
||||
*/
|
||||
[scriptable, uuid(350163d2-1dd2-11b2-9e69-89959ecec1f3)]
|
||||
interface nsIImageDecoderObserver : gfxIImageContainerObserver
|
||||
{
|
||||
/**
|
||||
* called as soon as the image begins getting decoded
|
||||
*/
|
||||
void onStartDecode(in lpIImageRequest request, in nsISupports cx);
|
||||
|
||||
/**
|
||||
* called once the image has been inited and therefore has a width and height
|
||||
*/
|
||||
void onStartContainer(in lpIImageRequest request, in nsISupports cx, in gfxIImageContainer image);
|
||||
|
||||
/**
|
||||
* called when each frame is created
|
||||
*/
|
||||
void onStartFrame(in lpIImageRequest request, in nsISupports cx, in gfxIImageFrame frame);
|
||||
|
||||
/**
|
||||
* called when some part of the frame has new data in it
|
||||
*/
|
||||
[noscript] void onDataAvailable(in lpIImageRequest request, in nsISupports cx, in gfxIImageFrame frame, [const] in nsRect rect);
|
||||
|
||||
/**
|
||||
* called when a frame is finished decoding
|
||||
*/
|
||||
void onStopFrame(in lpIImageRequest request, in nsISupports cx, in gfxIImageFrame frame);
|
||||
|
||||
/**
|
||||
* probably not needed. called right before onStopDecode
|
||||
*/
|
||||
void onStopContainer(in lpIImageRequest request, in nsISupports cx, in gfxIImageContainer image);
|
||||
|
||||
/**
|
||||
* called when the decoder is dying off
|
||||
*/
|
||||
void onStopDecode(in lpIImageRequest request, in nsISupports cx,
|
||||
in nsresult status, in wstring statusArg);
|
||||
|
||||
};
|
|
@ -1,65 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "gfxtypes.idl"
|
||||
|
||||
interface nsIImageDecoderObserver;
|
||||
interface lpIImageRequest;
|
||||
interface nsISimpleEnumerator;
|
||||
interface nsIStreamListener;
|
||||
interface nsIURI;
|
||||
interface nsIChannel;
|
||||
|
||||
/**
|
||||
* nsIImageLoader interface
|
||||
*
|
||||
* @author Stuart Parmenter <pavlov@netscape.com>
|
||||
* @version 0.1
|
||||
* @see imagelib2
|
||||
*/
|
||||
[scriptable, uuid(4c8cf1e0-1dd2-11b2-aff9-c51cdbfcb6da)]
|
||||
interface nsIImageLoader : nsISupports
|
||||
{
|
||||
/**
|
||||
* Start the load and decode of an image.
|
||||
* @param uri the URI to load
|
||||
* @param aObserver the observer
|
||||
* @param cx some random data
|
||||
*/
|
||||
lpIImageRequest loadImage(in nsIURI uri, in nsIImageDecoderObserver aObserver, in nsISupports cx);
|
||||
|
||||
/**
|
||||
* Start the load and decode of an image.
|
||||
* @param uri the URI to load
|
||||
* @param aObserver the observer
|
||||
* @param cx some random data
|
||||
*/
|
||||
lpIImageRequest loadImageWithChannel(in nsIChannel aChannel, in nsIImageDecoderObserver aObserver, in nsISupports cx, out nsIStreamListener aListener);
|
||||
|
||||
/**
|
||||
* Returns the channels contained directly in this group.
|
||||
* @note Enumerator element type: lpIImageRequest.
|
||||
*/
|
||||
readonly attribute nsISimpleEnumerator requests;
|
||||
};
|
|
@ -67,16 +67,16 @@ ImageCache::~ImageCache()
|
|||
/* destructor code */
|
||||
}
|
||||
|
||||
PRBool ImageCache::Put(nsIURI *aKey, nsImageRequest *request)
|
||||
PRBool ImageCache::Put(nsIURI *aKey, imgRequest *request)
|
||||
{
|
||||
nsIURIKey key(aKey);
|
||||
return mCache.Put(&key, NS_STATIC_CAST(lpIImageRequest*, request));
|
||||
return mCache.Put(&key, NS_STATIC_CAST(imgIRequest*, request));
|
||||
}
|
||||
|
||||
PRBool ImageCache::Get(nsIURI *aKey, nsImageRequest **request)
|
||||
PRBool ImageCache::Get(nsIURI *aKey, imgRequest **request)
|
||||
{
|
||||
nsIURIKey key(aKey);
|
||||
nsImageRequest *sup = NS_REINTERPRET_CAST(nsImageRequest*, NS_STATIC_CAST(lpIImageRequest*, mCache.Get(&key))); // this addrefs
|
||||
imgRequest *sup = NS_REINTERPRET_CAST(imgRequest*, NS_STATIC_CAST(imgIRequest*, mCache.Get(&key))); // this addrefs
|
||||
|
||||
if (sup) {
|
||||
*request = sup;
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#define ImageCache_h__
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsImageRequest.h"
|
||||
#include "imgRequest.h"
|
||||
|
||||
|
||||
#define IMAGE_CACHE_CID \
|
||||
|
@ -43,8 +43,8 @@ public:
|
|||
~ImageCache();
|
||||
|
||||
/* additional members */
|
||||
static PRBool Put(nsIURI *aKey, nsImageRequest *request);
|
||||
static PRBool Get(nsIURI *aKey, nsImageRequest **request);
|
||||
static PRBool Put(nsIURI *aKey, imgRequest *request);
|
||||
static PRBool Get(nsIURI *aKey, imgRequest **request);
|
||||
static PRBool Remove(nsIURI *aKey);
|
||||
|
||||
private:
|
||||
|
|
|
@ -33,8 +33,8 @@ IS_COMPONENT = 1
|
|||
CPPSRCS = ImageCache.cpp \
|
||||
nsImageFactory.cpp \
|
||||
nsImageLoader.cpp \
|
||||
nsImageRequest.cpp \
|
||||
nsImageRequestProxy.cpp
|
||||
imgRequest.cpp \
|
||||
imgRequestProxy.cpp
|
||||
|
||||
EXTRA_DSO_LDOPTS = \
|
||||
$(MOZ_COMPONENT_LIBS) \
|
||||
|
|
|
@ -0,0 +1,341 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#include "imgRequest.h"
|
||||
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIImageLoader.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
#include "ImageCache.h"
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS5(imgRequest, imgIRequest,
|
||||
nsIImageDecoderObserver, gfxIImageContainerObserver,
|
||||
nsIStreamListener, nsIStreamObserver)
|
||||
|
||||
imgRequest::imgRequest() :
|
||||
mObservers(0), mProcessing(PR_TRUE), mStatus(imgIRequest::STATUS_NONE), mState(0)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
imgRequest::~imgRequest()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
|
||||
nsresult imgRequest::Init(nsIChannel *aChannel)
|
||||
{
|
||||
// XXX we should save off the thread we are getting called on here so that we can proxy all calls to mDecoder to it.
|
||||
|
||||
NS_ASSERTION(!mImage, "imgRequest::Init -- Multiple calls to init");
|
||||
NS_ASSERTION(aChannel, "imgRequest::Init -- No channel");
|
||||
|
||||
mChannel = aChannel;
|
||||
|
||||
// XXX do not init the image here. this has to be done from the image decoder.
|
||||
mImage = do_CreateInstance("@mozilla.org/gfx/image;2");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult imgRequest::AddObserver(nsIImageDecoderObserver *observer)
|
||||
{
|
||||
mObservers.AppendElement(NS_STATIC_CAST(void*, observer));
|
||||
|
||||
if (mState & onStartDecode)
|
||||
observer->OnStartDecode(nsnull, nsnull);
|
||||
if (mState & onStartContainer)
|
||||
observer->OnStartContainer(nsnull, nsnull, mImage);
|
||||
|
||||
// XXX send the decoded rect in here
|
||||
|
||||
if (mState & onStopContainer)
|
||||
observer->OnStopContainer(nsnull, nsnull, mImage);
|
||||
if (mState & onStopDecode)
|
||||
observer->OnStopDecode(nsnull, nsnull, NS_OK, nsnull);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult imgRequest::RemoveObserver(nsIImageDecoderObserver *observer, nsresult status)
|
||||
{
|
||||
mObservers.RemoveElement(NS_STATIC_CAST(void*, observer));
|
||||
|
||||
if ((mObservers.Count() == 0) && mChannel && mProcessing) {
|
||||
mChannel->Cancel(status);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** imgIRequest methods **/
|
||||
|
||||
|
||||
/* void cancel (in nsresult status); */
|
||||
NS_IMETHODIMP imgRequest::Cancel(nsresult status)
|
||||
{
|
||||
// XXX this method should not ever get called
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
if (mChannel && mProcessing) {
|
||||
rv = mChannel->Cancel(status);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* readonly attribute nsIImage image; */
|
||||
NS_IMETHODIMP imgRequest::GetImage(gfxIImageContainer * *aImage)
|
||||
{
|
||||
*aImage = mImage;
|
||||
NS_IF_ADDREF(*aImage);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long imageStatus; */
|
||||
NS_IMETHODIMP imgRequest::GetImageStatus(PRUint32 *aStatus)
|
||||
{
|
||||
*aStatus = mStatus;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** gfxIImageContainerObserver methods **/
|
||||
|
||||
/* [noscript] void frameChanged (in gfxIImageContainer container, in nsISupports cx, in gfxIImageFrame newframe, in nsRect dirtyRect); */
|
||||
NS_IMETHODIMP imgRequest::FrameChanged(gfxIImageContainer *container, nsISupports *cx, gfxIImageFrame *newframe, nsRect * dirtyRect)
|
||||
{
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->FrameChanged(container, cx, newframe, dirtyRect);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** nsIImageDecoderObserver methods **/
|
||||
|
||||
/* void onStartDecode (in imgIRequest request, in nsISupports cx); */
|
||||
NS_IMETHODIMP imgRequest::OnStartDecode(imgIRequest *request, nsISupports *cx)
|
||||
{
|
||||
mState |= onStartDecode;
|
||||
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->OnStartDecode(request, cx);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStartContainer (in imgIRequest request, in nsISupports cx, in gfxIImageContainer image); */
|
||||
NS_IMETHODIMP imgRequest::OnStartContainer(imgIRequest *request, nsISupports *cx, gfxIImageContainer *image)
|
||||
{
|
||||
mState |= onStartContainer;
|
||||
|
||||
mStatus |= imgIRequest::STATUS_SIZE_AVAILABLE;
|
||||
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->OnStartContainer(request, cx, image);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStartFrame (in imgIRequest request, in nsISupports cx, in gfxIImageFrame frame); */
|
||||
NS_IMETHODIMP imgRequest::OnStartFrame(imgIRequest *request, nsISupports *cx, gfxIImageFrame *frame)
|
||||
{
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->OnStartFrame(request, cx, frame);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [noscript] void onDataAvailable (in imgIRequest request, in nsISupports cx, in gfxIImageFrame frame, [const] in nsRect rect); */
|
||||
NS_IMETHODIMP imgRequest::OnDataAvailable(imgIRequest *request, nsISupports *cx, gfxIImageFrame *frame, const nsRect * rect)
|
||||
{
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->OnDataAvailable(request, cx, frame, rect);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStopFrame (in imgIRequest request, in nsISupports cx, in gfxIImageFrame frame); */
|
||||
NS_IMETHODIMP imgRequest::OnStopFrame(imgIRequest *request, nsISupports *cx, gfxIImageFrame *frame)
|
||||
{
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->OnStopFrame(request, cx, frame);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStopContainer (in imgIRequest request, in nsISupports cx, in gfxIImageContainer image); */
|
||||
NS_IMETHODIMP imgRequest::OnStopContainer(imgIRequest *request, nsISupports *cx, gfxIImageContainer *image)
|
||||
{
|
||||
mState |= onStopContainer;
|
||||
|
||||
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->OnStopContainer(request, cx, image);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStopDecode (in imgIRequest request, in nsISupports cx, in nsresult status, in wstring statusArg); */
|
||||
NS_IMETHODIMP imgRequest::OnStopDecode(imgIRequest *request, nsISupports *cx, nsresult status, const PRUnichar *statusArg)
|
||||
{
|
||||
mState |= onStopDecode;
|
||||
|
||||
if (NS_FAILED(status))
|
||||
mStatus = imgIRequest::STATUS_ERROR;
|
||||
|
||||
PRInt32 i = -1;
|
||||
PRInt32 count = mObservers.Count();
|
||||
|
||||
while (++i < count) {
|
||||
nsIImageDecoderObserver *ob = NS_STATIC_CAST(nsIImageDecoderObserver*, mObservers[i]);
|
||||
if (ob) ob->OnStopDecode(request, cx, status, statusArg);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** nsIStreamObserver methods **/
|
||||
|
||||
/* void onStartRequest (in nsIChannel channel, in nsISupports ctxt); */
|
||||
NS_IMETHODIMP imgRequest::OnStartRequest(nsIChannel *channel, nsISupports *ctxt)
|
||||
{
|
||||
NS_ASSERTION(!mDecoder, "imgRequest::OnStartRequest -- we already have a decoder");
|
||||
|
||||
nsXPIDLCString contentType;
|
||||
channel->GetContentType(getter_Copies(contentType));
|
||||
printf("content type is %s\n", contentType.get());
|
||||
|
||||
nsCAutoString conid("@mozilla.org/image/decoder;2?type=");
|
||||
conid += contentType.get();
|
||||
|
||||
mDecoder = do_CreateInstance(conid);
|
||||
|
||||
if (!mDecoder) {
|
||||
// no image decoder for this mimetype :(
|
||||
channel->Cancel(NS_BINDING_ABORTED);
|
||||
|
||||
// XXX notify the person that owns us now that wants the gfxIImageContainer off of us?
|
||||
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mDecoder->Init(NS_STATIC_CAST(imgIRequest*, this));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStopRequest (in nsIChannel channel, in nsISupports ctxt, in nsresult status, in wstring statusArg); */
|
||||
NS_IMETHODIMP imgRequest::OnStopRequest(nsIChannel *channel, nsISupports *ctxt, nsresult status, const PRUnichar *statusArg)
|
||||
{
|
||||
NS_ASSERTION(mChannel || mProcessing, "imgRequest::OnStopRequest -- received multiple OnStopRequest");
|
||||
|
||||
mProcessing = PR_FALSE;
|
||||
|
||||
// if we failed, we should remove ourself from the cache
|
||||
if (NS_FAILED(status)) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
channel->GetURI(getter_AddRefs(uri));
|
||||
ImageCache::Remove(uri);
|
||||
}
|
||||
|
||||
mChannel = nsnull; // we no longer need the channel
|
||||
|
||||
if (!mDecoder) return NS_ERROR_FAILURE;
|
||||
|
||||
mDecoder->Close();
|
||||
|
||||
mDecoder = nsnull; // release the decoder so that it can rest peacefully ;)
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** nsIStreamListener methods **/
|
||||
|
||||
/* void onDataAvailable (in nsIChannel channel, in nsISupports ctxt, in nsIInputStream inStr, in unsigned long sourceOffset, in unsigned long count); */
|
||||
NS_IMETHODIMP imgRequest::OnDataAvailable(nsIChannel *channel, nsISupports *ctxt, nsIInputStream *inStr, PRUint32 sourceOffset, PRUint32 count)
|
||||
{
|
||||
if (!mDecoder) {
|
||||
NS_ASSERTION(mDecoder, "imgRequest::OnDataAvailable -- no decoder");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PRUint32 wrote;
|
||||
return mDecoder->WriteFrom(inStr, count, &wrote);
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#ifndef imgRequest_h__
|
||||
#define imgRequest_h__
|
||||
|
||||
#include "imgIRequest.h"
|
||||
|
||||
#include "nsIRunnable.h"
|
||||
|
||||
#include "nsIChannel.h"
|
||||
#include "gfxIImageContainer.h"
|
||||
#include "nsIImageDecoder.h"
|
||||
#include "nsIImageDecoderObserver.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
#define NS_IMAGEREQUEST_CID \
|
||||
{ /* 9f733dd6-1dd1-11b2-8cdf-effb70d1ea71 */ \
|
||||
0x9f733dd6, \
|
||||
0x1dd1, \
|
||||
0x11b2, \
|
||||
{0x8c, 0xdf, 0xef, 0xfb, 0x70, 0xd1, 0xea, 0x71} \
|
||||
}
|
||||
|
||||
|
||||
enum {
|
||||
onStartDecode = 0x1,
|
||||
onStartContainer = 0x2,
|
||||
onStopContainer = 0x4,
|
||||
onStopDecode = 0x8
|
||||
};
|
||||
|
||||
class imgRequest : public imgIRequest,
|
||||
public nsIImageDecoderObserver,
|
||||
public nsIStreamListener
|
||||
{
|
||||
public:
|
||||
imgRequest();
|
||||
virtual ~imgRequest();
|
||||
|
||||
/* additional members */
|
||||
nsresult Init(nsIChannel *aChannel);
|
||||
nsresult AddObserver(nsIImageDecoderObserver *observer);
|
||||
nsresult RemoveObserver(nsIImageDecoderObserver *observer, nsresult status);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_IMGIREQUEST
|
||||
NS_DECL_GFXIIMAGECONTAINEROBSERVER
|
||||
NS_DECL_NSIIMAGEDECODEROBSERVER
|
||||
NS_DECL_NSISTREAMLISTENER
|
||||
NS_DECL_NSISTREAMOBSERVER
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
nsCOMPtr<gfxIImageContainer> mImage;
|
||||
nsCOMPtr<nsIImageDecoder> mDecoder;
|
||||
|
||||
nsVoidArray mObservers;
|
||||
|
||||
PRBool mProcessing;
|
||||
PRUint32 mStatus;
|
||||
PRUint32 mState;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,171 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#include "imgRequestProxy.h"
|
||||
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIImageLoader.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "imgRequest.h"
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsIChannel.h"
|
||||
|
||||
#include "nspr.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS3(imgRequestProxy, imgIRequest, nsIImageDecoderObserver, gfxIImageContainerObserver)
|
||||
|
||||
imgRequestProxy::imgRequestProxy()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
}
|
||||
|
||||
imgRequestProxy::~imgRequestProxy()
|
||||
{
|
||||
/* destructor code */
|
||||
NS_REINTERPRET_CAST(imgRequest*, mOwner.get())->RemoveObserver(this, NS_ERROR_FAILURE); // XXX bogus result value
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult imgRequestProxy::Init(imgRequest *request, nsIImageDecoderObserver *aObserver, nsISupports *cx)
|
||||
{
|
||||
PR_ASSERT(request);
|
||||
|
||||
mOwner = NS_STATIC_CAST(imgIRequest*, request);
|
||||
|
||||
mObserver = aObserver;
|
||||
// XXX we should save off the thread we are getting called on here so that we can proxy all calls to mDecoder to it.
|
||||
|
||||
mContext = cx;
|
||||
|
||||
request->AddObserver(this);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* void cancel (in nsresult status); */
|
||||
NS_IMETHODIMP imgRequestProxy::Cancel(nsresult status)
|
||||
{
|
||||
return NS_REINTERPRET_CAST(imgRequest*, mOwner.get())->RemoveObserver(this, status);
|
||||
}
|
||||
|
||||
/* readonly attribute nsIImage image; */
|
||||
NS_IMETHODIMP imgRequestProxy::GetImage(gfxIImageContainer * *aImage)
|
||||
{
|
||||
return mOwner->GetImage(aImage);
|
||||
}
|
||||
|
||||
/* readonly attribute unsigned long imageStatus; */
|
||||
NS_IMETHODIMP imgRequestProxy::GetImageStatus(PRUint32 *aStatus)
|
||||
{
|
||||
return mOwner->GetImageStatus(aStatus);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** gfxIImageContainerObserver methods **/
|
||||
|
||||
/* [noscript] void frameChanged (in gfxIImageContainer container, in nsISupports cx, in gfxIImageFrame newframe, in nsRect dirtyRect); */
|
||||
NS_IMETHODIMP imgRequestProxy::FrameChanged(gfxIImageContainer *container, nsISupports *cx, gfxIImageFrame *newframe, nsRect * dirtyRect)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->FrameChanged(container, mContext, newframe, dirtyRect);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** nsIImageDecoderObserver methods **/
|
||||
|
||||
/* void onStartDecode (in imgIRequest request, in nsISupports cx); */
|
||||
NS_IMETHODIMP imgRequestProxy::OnStartDecode(imgIRequest *request, nsISupports *cx)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->OnStartDecode(this, mContext);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStartContainer (in imgIRequest request, in nsISupports cx, in gfxIImageContainer image); */
|
||||
NS_IMETHODIMP imgRequestProxy::OnStartContainer(imgIRequest *request, nsISupports *cx, gfxIImageContainer *image)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->OnStartContainer(this, mContext, image);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStartFrame (in imgIRequest request, in nsISupports cx, in gfxIImageFrame frame); */
|
||||
NS_IMETHODIMP imgRequestProxy::OnStartFrame(imgIRequest *request, nsISupports *cx, gfxIImageFrame *frame)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->OnStartFrame(this, mContext, frame);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* [noscript] void onDataAvailable (in imgIRequest request, in nsISupports cx, in gfxIImageFrame frame, [const] in nsRect rect); */
|
||||
NS_IMETHODIMP imgRequestProxy::OnDataAvailable(imgIRequest *request, nsISupports *cx, gfxIImageFrame *frame, const nsRect * rect)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->OnDataAvailable(this, mContext, frame, rect);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStopFrame (in imgIRequest request, in nsISupports cx, in gfxIImageFrame frame); */
|
||||
NS_IMETHODIMP imgRequestProxy::OnStopFrame(imgIRequest *request, nsISupports *cx, gfxIImageFrame *frame)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->OnStopFrame(this, mContext, frame);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStopContainer (in imgIRequest request, in nsISupports cx, in gfxIImageContainer image); */
|
||||
NS_IMETHODIMP imgRequestProxy::OnStopContainer(imgIRequest *request, nsISupports *cx, gfxIImageContainer *image)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->OnStopContainer(this, mContext, image);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* void onStopDecode (in imgIRequest request, in nsISupports cx, in nsresult status, in wstring statusArg); */
|
||||
NS_IMETHODIMP imgRequestProxy::OnStopDecode(imgIRequest *request, nsISupports *cx, nsresult status, const PRUnichar *statusArg)
|
||||
{
|
||||
if (mObserver)
|
||||
mObserver->OnStopDecode(this, mContext, status, statusArg);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
*/
|
||||
|
||||
#include "imgRequest.h"
|
||||
#include "nsIImageDecoderObserver.h"
|
||||
|
||||
#include "gfxIImageContainer.h"
|
||||
#include "nsIImageDecoder.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#define NS_IMAGEREQUESTPROXY_CID \
|
||||
{ /* 20557898-1dd2-11b2-8f65-9c462ee2bc95 */ \
|
||||
0x20557898, \
|
||||
0x1dd2, \
|
||||
0x11b2, \
|
||||
{0x8f, 0x65, 0x9c, 0x46, 0x2e, 0xe2, 0xbc, 0x95} \
|
||||
}
|
||||
|
||||
class imgRequestProxy : public imgIRequest,
|
||||
public nsIImageDecoderObserver
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_IMGIREQUEST
|
||||
NS_DECL_NSIIMAGEDECODEROBSERVER
|
||||
NS_DECL_GFXIIMAGECONTAINEROBSERVER
|
||||
|
||||
imgRequestProxy();
|
||||
virtual ~imgRequestProxy();
|
||||
|
||||
/* additional members */
|
||||
nsresult Init(imgRequest *request, nsIImageDecoderObserver *aObserver, nsISupports *cx);
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIImageDecoderObserver> mObserver;
|
||||
|
||||
nsCOMPtr<nsISupports> mContext;
|
||||
|
||||
nsCOMPtr<imgIRequest> mOwner;
|
||||
};
|
|
@ -32,8 +32,8 @@ MAKE_OBJ_TYPE = DLL
|
|||
OBJS = \
|
||||
.\$(OBJDIR)\ImageCache.obj \
|
||||
.\$(OBJDIR)\nsImageLoader.obj \
|
||||
.\$(OBJDIR)\nsImageRequest.obj \
|
||||
.\$(OBJDIR)\nsImageRequestProxy.obj \
|
||||
.\$(OBJDIR)\imgRequest.obj \
|
||||
.\$(OBJDIR)\imgRequestProxy.obj \
|
||||
.\$(OBJDIR)\nsImageFactory.obj \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -25,14 +25,14 @@
|
|||
#include "nsIModule.h"
|
||||
|
||||
#include "nsImageLoader.h"
|
||||
#include "nsImageRequest.h"
|
||||
#include "nsImageRequestProxy.h"
|
||||
#include "imgRequest.h"
|
||||
#include "imgRequestProxy.h"
|
||||
|
||||
// objects that just require generic constructors
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageLoader)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageRequest)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageRequestProxy)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(imgRequest)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(imgRequestProxy)
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
|
@ -43,11 +43,11 @@ static nsModuleComponentInfo components[] =
|
|||
{ "image request",
|
||||
NS_IMAGEREQUEST_CID,
|
||||
"@mozilla.org/image/request/real;1",
|
||||
nsImageRequestConstructor, },
|
||||
imgRequestConstructor, },
|
||||
{ "image request proxy",
|
||||
NS_IMAGEREQUESTPROXY_CID,
|
||||
"@mozilla.org/image/request/proxy;1",
|
||||
nsImageRequestProxyConstructor, },
|
||||
imgRequestProxyConstructor, },
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE("nsImageLib2Module", components)
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include "nsImageLoader.h"
|
||||
|
||||
#include "lpIImageRequest.h"
|
||||
#include "imgIRequest.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
|
@ -33,8 +33,8 @@
|
|||
#include "nsIStreamListener.h"
|
||||
#include "nsIURI.h"
|
||||
|
||||
#include "nsImageRequest.h"
|
||||
#include "nsImageRequestProxy.h"
|
||||
#include "imgRequest.h"
|
||||
#include "imgRequestProxy.h"
|
||||
|
||||
#include "ImageCache.h"
|
||||
|
||||
|
@ -72,12 +72,12 @@ nsImageLoader::~nsImageLoader()
|
|||
#endif
|
||||
}
|
||||
|
||||
/* lpIImageRequest loadImage (in nsIURI uri, in nsIImageDecoderObserver aObserver, in nsISupports cx); */
|
||||
NS_IMETHODIMP nsImageLoader::LoadImage(nsIURI *aURI, nsIImageDecoderObserver *aObserver, nsISupports *cx, lpIImageRequest **_retval)
|
||||
/* imgIRequest loadImage (in nsIURI uri, in nsIImageDecoderObserver aObserver, in nsISupports cx); */
|
||||
NS_IMETHODIMP nsImageLoader::LoadImage(nsIURI *aURI, nsIImageDecoderObserver *aObserver, nsISupports *cx, imgIRequest **_retval)
|
||||
{
|
||||
NS_ASSERTION(aURI, "nsImageLoader::LoadImage -- NULL URI pointer");
|
||||
|
||||
nsImageRequest *imgRequest = nsnull;
|
||||
imgRequest *imgRequest = nsnull;
|
||||
|
||||
ImageCache::Get(aURI, &imgRequest); // addrefs
|
||||
if (!imgRequest) {
|
||||
|
@ -94,8 +94,8 @@ NS_IMETHODIMP nsImageLoader::LoadImage(nsIURI *aURI, nsIImageDecoderObserver *aO
|
|||
// XXX do we need to SetOwner here?
|
||||
newChannel->SetOwner(this); // the channel is now holding a strong ref to 'this'
|
||||
|
||||
nsCOMPtr<lpIImageRequest> req(do_CreateInstance(kImageRequestCID));
|
||||
imgRequest = NS_REINTERPRET_CAST(nsImageRequest*, req.get());
|
||||
nsCOMPtr<imgIRequest> req(do_CreateInstance(kImageRequestCID));
|
||||
imgRequest = NS_REINTERPRET_CAST(imgRequest*, req.get());
|
||||
NS_ADDREF(imgRequest);
|
||||
|
||||
imgRequest->Init(newChannel);
|
||||
|
@ -105,9 +105,9 @@ NS_IMETHODIMP nsImageLoader::LoadImage(nsIURI *aURI, nsIImageDecoderObserver *aO
|
|||
newChannel->AsyncRead(NS_STATIC_CAST(nsIStreamListener *, imgRequest), cx); // XXX are we calling this too early?
|
||||
}
|
||||
|
||||
nsCOMPtr<lpIImageRequest> proxyRequest(do_CreateInstance(kImageRequestProxyCID));
|
||||
nsCOMPtr<imgIRequest> proxyRequest(do_CreateInstance(kImageRequestProxyCID));
|
||||
// init adds itself to imgRequest's list of observers
|
||||
NS_REINTERPRET_CAST(nsImageRequestProxy*, proxyRequest.get())->Init(imgRequest, aObserver, cx);
|
||||
NS_REINTERPRET_CAST(imgRequestProxy*, proxyRequest.get())->Init(imgRequest, aObserver, cx);
|
||||
|
||||
NS_RELEASE(imgRequest);
|
||||
|
||||
|
@ -117,12 +117,12 @@ NS_IMETHODIMP nsImageLoader::LoadImage(nsIURI *aURI, nsIImageDecoderObserver *aO
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/* lpIImageRequest loadImageWithChannel(in nsIChannel, in nsIImageDecoderObserver aObserver, in nsISupports cx, out nsIStreamListener); */
|
||||
NS_IMETHODIMP nsImageLoader::LoadImageWithChannel(nsIChannel *channel, nsIImageDecoderObserver *aObserver, nsISupports *cx, nsIStreamListener **listener, lpIImageRequest **_retval)
|
||||
/* imgIRequest loadImageWithChannel(in nsIChannel, in nsIImageDecoderObserver aObserver, in nsISupports cx, out nsIStreamListener); */
|
||||
NS_IMETHODIMP nsImageLoader::LoadImageWithChannel(nsIChannel *channel, nsIImageDecoderObserver *aObserver, nsISupports *cx, nsIStreamListener **listener, imgIRequest **_retval)
|
||||
{
|
||||
NS_ASSERTION(channel, "nsImageLoader::LoadImageWithChannel -- NULL channel pointer");
|
||||
|
||||
nsImageRequest *imgRequest = nsnull;
|
||||
imgRequest *imgRequest = nsnull;
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
channel->GetURI(getter_AddRefs(uri));
|
||||
|
@ -142,9 +142,9 @@ NS_IMETHODIMP nsImageLoader::LoadImageWithChannel(nsIChannel *channel, nsIImageD
|
|||
nsAutoLock lock(mLock); // lock when we are adding things to the cache
|
||||
#endif
|
||||
|
||||
nsCOMPtr<lpIImageRequest> req(do_CreateInstance(kImageRequestCID));
|
||||
nsCOMPtr<imgIRequest> req(do_CreateInstance(kImageRequestCID));
|
||||
|
||||
imgRequest = NS_REINTERPRET_CAST(nsImageRequest*, req.get());
|
||||
imgRequest = NS_REINTERPRET_CAST(imgRequest*, req.get());
|
||||
NS_ADDREF(imgRequest);
|
||||
|
||||
imgRequest->Init(channel);
|
||||
|
@ -155,10 +155,10 @@ NS_IMETHODIMP nsImageLoader::LoadImageWithChannel(nsIChannel *channel, nsIImageD
|
|||
NS_IF_ADDREF(*listener);
|
||||
}
|
||||
|
||||
nsCOMPtr<lpIImageRequest> proxyRequest(do_CreateInstance(kImageRequestProxyCID));
|
||||
nsCOMPtr<imgIRequest> proxyRequest(do_CreateInstance(kImageRequestProxyCID));
|
||||
|
||||
// init adds itself to imgRequest's list of observers
|
||||
NS_REINTERPRET_CAST(nsImageRequestProxy*, proxyRequest.get())->Init(imgRequest, aObserver, cx);
|
||||
NS_REINTERPRET_CAST(imgRequestProxy*, proxyRequest.get())->Init(imgRequest, aObserver, cx);
|
||||
|
||||
NS_RELEASE(imgRequest);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче