зеркало из https://github.com/mozilla/gecko-dev.git
fixing bug 78690. removing old imagelib. r=jst sr=waterson
This commit is contained in:
Родитель
c63a539773
Коммит
1e20984ef0
|
@ -608,8 +608,6 @@ sub BuildClientDist()
|
|||
#LIBIMAGE
|
||||
InstallFromManifest(":mozilla:modules:libimg:png:MANIFEST", "$distdirectory:libimg:");
|
||||
InstallFromManifest(":mozilla:modules:libimg:src:MANIFEST", "$distdirectory:libimg:");
|
||||
InstallFromManifest(":mozilla:modules:libimg:public:MANIFEST", "$distdirectory:libimg:");
|
||||
InstallFromManifest(":mozilla:modules:libimg:public_com:MANIFEST", "$distdirectory:libimg:");
|
||||
|
||||
if ($main::options{useimg2}) {
|
||||
#GFX2
|
||||
|
@ -1322,16 +1320,11 @@ sub BuildImglibProjects()
|
|||
|
||||
BuildOneProject(":mozilla:jpeg:macbuild:JPEG.mcp", "JPEG$D.o", 0, 0, 0);
|
||||
BuildOneProject(":mozilla:modules:libimg:macbuild:png.mcp", "png$D.o", 0, 0, 0);
|
||||
BuildOneProject(":mozilla:modules:libimg:macbuild:libimg.mcp", "libimg$D.shlb", 1, $main::ALIAS_SYM_FILES, 0);
|
||||
BuildOneProject(":mozilla:modules:libimg:macbuild:gifdecoder.mcp", "gifdecoder$D.shlb", 1, $main::ALIAS_SYM_FILES, 1);
|
||||
BuildOneProject(":mozilla:modules:libimg:macbuild:pngdecoder.mcp", "pngdecoder$D.shlb", 1, $main::ALIAS_SYM_FILES, 1);
|
||||
BuildOneProject(":mozilla:modules:libimg:macbuild:jpgdecoder.mcp", "jpgdecoder$D.shlb", 1, $main::ALIAS_SYM_FILES, 1);
|
||||
|
||||
# MNG
|
||||
if ($main::options{mng})
|
||||
{
|
||||
BuildOneProject(":mozilla:modules:libimg:macbuild:mng.mcp", "mng$D.o", 0, 0, 0);
|
||||
BuildOneProject(":mozilla:modules:libimg:macbuild:mngdecoder.mcp", "mngdecoder$D.shlb", 1, $main::ALIAS_SYM_FILES, 1);
|
||||
}
|
||||
|
||||
EndBuildModule("imglib");
|
||||
|
|
|
@ -80,7 +80,6 @@
|
|||
#include "nsIResProtocolHandler.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsIImageManager.h"
|
||||
#include "nsIBindingManager.h"
|
||||
#include "prio.h"
|
||||
#include "nsInt64.h"
|
||||
|
@ -105,7 +104,6 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
|||
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID);
|
||||
static NS_DEFINE_CID(kImageManagerCID, NS_IMAGEMANAGER_CID);
|
||||
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
|
||||
|
@ -1136,16 +1134,9 @@ nsresult nsChromeRegistry::FlushCaches()
|
|||
if (NS_SUCCEEDED(rv) && xulCache) {
|
||||
xulCache->Flush();
|
||||
}
|
||||
|
||||
// Flush the old image cache.
|
||||
nsCOMPtr<nsIImageManager> imageManager =
|
||||
do_GetService(kImageManagerCID, &rv);
|
||||
if (imageManager)
|
||||
rv = imageManager->FlushCache(1);
|
||||
|
||||
// Flush the new imagelib image chrome cache.
|
||||
nsCOMPtr<imgICache> imageCache =
|
||||
do_GetService("@mozilla.org/image/cache;1", &rv);
|
||||
nsCOMPtr<imgICache> imageCache(do_GetService("@mozilla.org/image/cache;1", &rv));
|
||||
if (NS_SUCCEEDED(rv) && imageCache) {
|
||||
imageCache->ClearCache(PR_TRUE);
|
||||
}
|
||||
|
|
|
@ -31,9 +31,6 @@
|
|||
#include "nsIDocumentViewer.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
|
||||
#include "nsIImageGroup.h"
|
||||
#include "nsIImageObserver.h"
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
@ -363,8 +360,7 @@ private:
|
|||
class DocumentViewerImpl : public nsIDocumentViewer,
|
||||
public nsIContentViewerEdit,
|
||||
public nsIContentViewerFile,
|
||||
public nsIMarkupDocumentViewer,
|
||||
public nsIImageGroupObserver
|
||||
public nsIMarkupDocumentViewer
|
||||
{
|
||||
friend class nsDocViewerSelectionListener;
|
||||
|
||||
|
@ -402,10 +398,6 @@ public:
|
|||
void* aClosure);
|
||||
nsresult CallChildren(CallChildFunc aFunc, void* aClosure);
|
||||
|
||||
// nsIImageGroupObserver interface
|
||||
virtual void Notify(nsIImageGroup *aImageGroup,
|
||||
nsImageGroupNotification aNotificationType);
|
||||
|
||||
// Printing Methods
|
||||
PRBool PrintPage(nsIPresContext* aPresContext,nsIPrintOptions* aPrintOptions,PrintObject* aPOect);
|
||||
PRBool DonePrintingPages(PrintObject* aPO);
|
||||
|
@ -844,12 +836,6 @@ DocumentViewerImpl::~DocumentViewerImpl()
|
|||
if (mPresContext) {
|
||||
mPresContext->SetContainer(nsnull);
|
||||
mPresContext->SetLinkHandler(nsnull);
|
||||
// XXX This is only needed because bg images have not been
|
||||
// converted to the new image lib. Once pav does this, we
|
||||
// can just remove this code. Right now it is only here
|
||||
// for background images.
|
||||
// stop everything but the chrome.
|
||||
mPresContext->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1235,15 +1221,6 @@ DocumentViewerImpl::Stop(void)
|
|||
if (!mLoaded && mPresShell) {
|
||||
// Well, we might as well paint what we have so far.
|
||||
mPresShell->UnsuppressPainting();
|
||||
|
||||
if (mPresContext) {
|
||||
// XXX This is only needed because bg images have not been
|
||||
// converted to the new image lib. Once pav does this, we
|
||||
// can just remove this code. Right now it is only here
|
||||
// for background images.
|
||||
// stop everything but the chrome.
|
||||
mPresContext->Stop(PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -3684,58 +3661,6 @@ DocumentViewerImpl::PrintDocContent(PrintObject* aPO, nsresult& aStatus)
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
void DocumentViewerImpl::Notify(nsIImageGroup *aImageGroup,
|
||||
nsImageGroupNotification aNotificationType)
|
||||
{
|
||||
//
|
||||
// Image are being loaded... Set the flag to delay printing until
|
||||
// all images are loaded.
|
||||
//
|
||||
if (aNotificationType == nsImageGroupNotification_kStartedLoading) {
|
||||
mIsPrinting = PR_TRUE;
|
||||
}
|
||||
//
|
||||
// All the images have been loaded, so the document is ready to print.
|
||||
//
|
||||
// However, at this point we are unable to release the resources that
|
||||
// were allocated for printing... This is because ImgLib resources will
|
||||
// be deleted and *this* is an ImgLib notification routine. So, fire an
|
||||
// event to do the actual printing.
|
||||
//
|
||||
else if(aNotificationType == nsImageGroupNotification_kFinishedLoading) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
|
||||
// Get the event queue of the current thread...
|
||||
nsCOMPtr<nsIEventQueueService> eventQService =
|
||||
do_GetService(kEventQueueService, &rv);
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(eventQ));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
PRStatus status;
|
||||
PLEvent *event = new PLEvent;
|
||||
|
||||
if (!event) return;
|
||||
|
||||
//
|
||||
// AddRef this because it is being placed in the PLEvent struct.
|
||||
// It will be Released when DestroyPLEvent is called...
|
||||
//
|
||||
NS_ADDREF_THIS();
|
||||
PL_InitEvent(event,
|
||||
this,
|
||||
(PLHandleEventProc) DocumentViewerImpl::HandlePLEvent,
|
||||
(PLDestroyEventProc) DocumentViewerImpl::DestroyPLEvent);
|
||||
|
||||
status = eventQ->PostEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
DocumentViewerImpl::SetEnableRendering(PRBool aOn)
|
||||
{
|
||||
|
@ -3992,15 +3917,6 @@ nsresult DocumentViewerImpl::DocumentReadyForPrinting()
|
|||
|
||||
webContainer = do_QueryInterface(mContainer);
|
||||
if(webContainer) {
|
||||
//
|
||||
// Remove ourselves as an image group observer...
|
||||
//
|
||||
nsCOMPtr<nsIImageGroup> imageGroup;
|
||||
mPrt->mPrintPC->GetImageGroup(getter_AddRefs(imageGroup));
|
||||
if (imageGroup) {
|
||||
imageGroup->RemoveObserver(this);
|
||||
}
|
||||
|
||||
//
|
||||
// Send the document to the printer...
|
||||
//
|
||||
|
@ -4530,12 +4446,6 @@ nsresult rv;
|
|||
mPrt->mPrintVM->SetRootView(mPrt->mPrintView);
|
||||
mPrt->mPrintPS->Init(mDocument,mPrt->mPrintPC,mPrt->mPrintVM,mPrt->mPrintSS);
|
||||
|
||||
nsCOMPtr<nsIImageGroup> imageGroup;
|
||||
mPrt->mPrintPC->GetImageGroup(getter_AddRefs(imageGroup));
|
||||
if (imageGroup) {
|
||||
imageGroup->AddObserver(this);
|
||||
}
|
||||
|
||||
mPrt->mPrintPS->InitialReflow(width,height);
|
||||
|
||||
#ifdef DEBUG_dcone
|
||||
|
|
|
@ -30,18 +30,14 @@
|
|||
#include "nsIWidget.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIImageGroup.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIImageRequest.h"
|
||||
#include "nsFont.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsIImage.h"
|
||||
#include "prprf.h"
|
||||
|
||||
// CIDs
|
||||
static NS_DEFINE_IID(kChildCID, NS_CHILD_CID);
|
||||
static NS_DEFINE_IID(kIImageObserverIID, NS_IIMAGEREQUESTOBSERVER_IID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
// Static variables
|
||||
|
@ -55,9 +51,7 @@ const PRUint32 kThrobFrequency = 66; // animation frequency in milliseconds
|
|||
//*****************************************************************************
|
||||
|
||||
CThrobber::CThrobber() :
|
||||
mImages(nsnull),
|
||||
mNumImages(2), mCompletedImages(0), mRunning(false),
|
||||
mImageGroup(nsnull)
|
||||
mNumImages(2), mCompletedImages(0), mRunning(false)
|
||||
{
|
||||
NS_INIT_REFCNT(); // caller must add ref as normal
|
||||
|
||||
|
@ -67,9 +61,7 @@ CThrobber::CThrobber() :
|
|||
|
||||
CThrobber::CThrobber(LStream* inStream) :
|
||||
LControl(inStream),
|
||||
mImages(nsnull),
|
||||
mNumImages(2), mCompletedImages(0), mRunning(false),
|
||||
mImageGroup(nsnull)
|
||||
mNumImages(2), mCompletedImages(0), mRunning(false)
|
||||
{
|
||||
mRefCnt = 1; // PowerPlant is making us, and it sure isn't going to do an AddRef.
|
||||
|
||||
|
@ -95,8 +87,10 @@ CThrobber::~CThrobber()
|
|||
RemoveThrobber(this);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(CThrobber, kIImageObserverIID)
|
||||
NS_IMPL_ISUPPORTS0(CThrobber)
|
||||
|
||||
|
||||
#if 0
|
||||
void CThrobber::Notify(nsIImageRequest *aImageRequest,
|
||||
nsIImage *aImage,
|
||||
nsImageNotification aNotificationType,
|
||||
|
@ -121,7 +115,8 @@ void CThrobber::NotifyError(nsIImageRequest *aImageRequest,
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
void CThrobber::FinishCreateSelf()
|
||||
{
|
||||
CBrowserWindow *ourWindow = dynamic_cast<CBrowserWindow*>(LWindow::FetchWindowObject(GetMacPort()));
|
||||
|
@ -166,6 +161,7 @@ void CThrobber::HideSelf()
|
|||
|
||||
void CThrobber::DrawSelf()
|
||||
{
|
||||
#if 0
|
||||
// Draw directly with the rendering context instead of passing an
|
||||
// update event through nsMacMessageSink. By the time this routine is
|
||||
// called, PowerPlant has taken care of the location, z order, and clipping
|
||||
|
@ -193,6 +189,7 @@ void CThrobber::DrawSelf()
|
|||
cx->DrawImage(img, 0, 0);
|
||||
NS_RELEASE(img);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -249,8 +246,9 @@ void CThrobber::AdjustFrame(Boolean inRefresh)
|
|||
|
||||
NS_METHOD CThrobber::LoadImages()
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
#if 0
|
||||
mImages = new vector<nsIImageRequest*>(mNumImages, nsnull);
|
||||
if (nsnull == mImages) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -291,6 +289,7 @@ NS_METHOD CThrobber::LoadImages()
|
|||
}
|
||||
|
||||
mWidget->Invalidate(PR_TRUE);
|
||||
#endif
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -302,6 +301,7 @@ void CThrobber::DestroyImages()
|
|||
mTimer->Cancel();
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (mImageGroup)
|
||||
{
|
||||
mImageGroup->Interrupt();
|
||||
|
@ -318,6 +318,7 @@ void CThrobber::DestroyImages()
|
|||
delete mImages;
|
||||
mImages = nsnull;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CThrobber::Tick()
|
||||
|
|
|
@ -37,20 +37,18 @@
|
|||
#include "nsGUIEvent.h"
|
||||
#endif
|
||||
|
||||
#include "nsITimer.h"
|
||||
|
||||
#include "nsString.h"
|
||||
#include "nsIImageObserver.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
class nsIWidget;
|
||||
class nsIImageGroup;
|
||||
class nsITimer;
|
||||
class nsIImageRequest;
|
||||
|
||||
class CThrobber : public LControl,
|
||||
public nsIImageRequestObserver
|
||||
public nsISupports
|
||||
{
|
||||
public:
|
||||
enum { class_ID = FOUR_CHAR_CODE('Thrb') };
|
||||
|
@ -62,16 +60,6 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIImageRequestObserver
|
||||
virtual void Notify(nsIImageRequest *aImageRequest,
|
||||
nsIImage *aImage,
|
||||
nsImageNotification aNotificationType,
|
||||
PRInt32 aParam1, PRInt32 aParam2,
|
||||
void *aParam3);
|
||||
|
||||
virtual void NotifyError(nsIImageRequest *aImageRequest,
|
||||
nsImageError aErrorType);
|
||||
|
||||
// CThrobber
|
||||
virtual void FinishCreateSelf();
|
||||
virtual void ShowSelf();
|
||||
|
@ -101,10 +89,9 @@ public:
|
|||
char mDefImageURL[256], mAnimImageURL[256];
|
||||
|
||||
nsCOMPtr<nsIWidget> mWidget;
|
||||
vector<nsIImageRequest*> *mImages;
|
||||
// vector<nsIImageRequest*> *mImages;
|
||||
bool mRunning;
|
||||
SInt32 mNumImages, mCompletedImages;
|
||||
nsIImageGroup *mImageGroup;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
|
||||
static map<nsIWidget*, CThrobber*> mgThrobberMap;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
// Helper Classes
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsStyleCoord.h"
|
||||
#include "nsSize.h"
|
||||
#include "nsHTMLReflowState.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
|
Двоичные данные
gfx/macbuild/gfx.mcp
Двоичные данные
gfx/macbuild/gfx.mcp
Двоичный файл не отображается.
|
@ -14,10 +14,6 @@ nsMargin.h
|
|||
nsTransform2D.h
|
||||
nsIRenderingContext.h
|
||||
nsIFontMetrics.h
|
||||
nsIImageManager.h
|
||||
nsIImageGroup.h
|
||||
nsIImageRequest.h
|
||||
nsIImageObserver.h
|
||||
nsIDeviceContext.h
|
||||
nsIImage.h
|
||||
nsIBlender.h
|
||||
|
|
|
@ -43,10 +43,6 @@ EXPORTS = \
|
|||
nsIRenderingContext.h \
|
||||
nsRenderingContextImpl.h \
|
||||
nsIFontMetrics.h \
|
||||
nsIImageManager.h \
|
||||
nsIImageGroup.h \
|
||||
nsIImageRequest.h \
|
||||
nsIImageObserver.h \
|
||||
nsIDeviceContext.h \
|
||||
nsIImage.h \
|
||||
nsIBlender.h \
|
||||
|
|
|
@ -36,10 +36,6 @@ EXPORTS = \
|
|||
nsIRenderingContext.h \
|
||||
nsRenderingContextImpl.h \
|
||||
nsIFontMetrics.h \
|
||||
nsIImageManager.h \
|
||||
nsIImageGroup.h \
|
||||
nsIImageRequest.h \
|
||||
nsIImageObserver.h \
|
||||
nsIDeviceContext.h \
|
||||
nsIImage.h \
|
||||
nsIBlender.h \
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsIDeviceContextSpec.h"
|
||||
#include "libimg.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIAtom.h"
|
||||
#include "nsIStringBundle.h"
|
||||
|
@ -99,8 +98,6 @@ public:
|
|||
|
||||
NS_IMETHOD GetGammaTable(PRUint8 *&aGammaTable);
|
||||
|
||||
NS_IMETHOD LoadIconImage(PRInt32 aId, nsIImage*& aImage);
|
||||
|
||||
NS_IMETHOD FirstExistingFont(const nsFont& aFont, nsString& aFaceName);
|
||||
|
||||
NS_IMETHOD GetLocalFontName(const nsString& aFaceName, nsString& aLocalName,
|
||||
|
@ -112,10 +109,6 @@ public:
|
|||
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth);
|
||||
|
||||
NS_IMETHOD GetILColorSpace(IL_ColorSpace*& aColorSpace);
|
||||
|
||||
NS_IMETHOD GetPaletteInfo(nsPaletteInfo&);
|
||||
|
||||
static nsresult GetLocalizedString(nsIStringBundle* aStrBundle, const char* aKey, nsString& oVal);
|
||||
static nsresult GetLocalizedBundle(const char * aPropFileName, nsIStringBundle** aStrBundle);
|
||||
|
||||
|
@ -141,10 +134,7 @@ protected:
|
|||
float mTextZoom;
|
||||
float mGammaValue;
|
||||
PRUint8 *mGammaTable;
|
||||
IL_GroupContext* mIconImageGroup;
|
||||
nsIImageRequest* mIcons[NS_NUMBER_OF_ICONS];
|
||||
nsHashtable* mFontAliasTable;
|
||||
IL_ColorSpace* mColorSpace;
|
||||
float mCPixelScale;
|
||||
|
||||
public:
|
||||
|
|
|
@ -48,14 +48,6 @@ typedef void * nsNativeDeviceContext;
|
|||
//a cross platform way of specifying a native palette handle
|
||||
typedef void * nsPalette;
|
||||
|
||||
//structure used to return information about a device's palette capabilities
|
||||
struct nsPaletteInfo {
|
||||
PRPackedBool isPaletteDevice;
|
||||
PRUint16 sizePalette; // number of entries in the palette
|
||||
PRUint16 numReserved; // number of reserved palette entries
|
||||
nsPalette palette; // native palette handle
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
@ -110,19 +102,6 @@ struct nsPaletteInfo {
|
|||
nsFont * mFont;
|
||||
} SystemAttrStruct;
|
||||
|
||||
/**
|
||||
* Constants identifying pre-defined icons.
|
||||
* @see #LoadIcon()
|
||||
*/
|
||||
#define NS_ICON_LOADING_IMAGE 0
|
||||
#define NS_ICON_BROKEN_IMAGE 1
|
||||
#define NS_NUMBER_OF_ICONS 2
|
||||
|
||||
// XXX This is gross, but don't include libimg.h, because it includes ni_pixmap.h
|
||||
// which includes xp_core.h which includes windows.h
|
||||
struct _NI_ColorSpace;
|
||||
typedef _NI_ColorSpace NI_ColorSpace;
|
||||
typedef NI_ColorSpace IL_ColorSpace;
|
||||
|
||||
class nsIDeviceContext : public nsISupports
|
||||
{
|
||||
|
@ -307,11 +286,6 @@ public:
|
|||
//XXX the return from this really needs to be ref counted somehow. MMP
|
||||
NS_IMETHOD GetGammaTable(PRUint8 *&aGammaTable) = 0;
|
||||
|
||||
//load the specified icon. this is a blocking call that does not return
|
||||
//until the icon is loaded.
|
||||
//release the image when you're done
|
||||
NS_IMETHOD LoadIconImage(PRInt32 aId, nsIImage*& aImage) = 0;
|
||||
|
||||
/**
|
||||
* Check to see if a particular named font exists.
|
||||
* @param aFontName character string of font face name
|
||||
|
@ -335,19 +309,6 @@ public:
|
|||
*/
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth) = 0;
|
||||
|
||||
/**
|
||||
* Return the image lib color space that's appropriate for this rendering
|
||||
* context.
|
||||
*
|
||||
* You must call IL_ReleaseSystemSpace() when you're done using the color space.
|
||||
*/
|
||||
NS_IMETHOD GetILColorSpace(IL_ColorSpace*& aColorSpace) = 0;
|
||||
|
||||
/**
|
||||
* Returns information about the device's palette capabilities.
|
||||
*/
|
||||
NS_IMETHOD GetPaletteInfo(nsPaletteInfo&) = 0;
|
||||
|
||||
/**
|
||||
* Returns Platform specific pixel value for an RGB value
|
||||
*/
|
||||
|
|
|
@ -225,7 +225,12 @@ public:
|
|||
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
|
||||
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0;
|
||||
|
||||
#ifdef USE_IMG2
|
||||
|
||||
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aSXOffset, PRInt32 aSYOffset,
|
||||
const nsRect &aTileRect) = 0;
|
||||
|
||||
/**
|
||||
* BitBlit the entire (no cropping) nsIImage to another nsImage, the source and dest can be scaled
|
||||
* @update - saari 03/08/01
|
||||
|
@ -237,7 +242,6 @@ public:
|
|||
* @return if TRUE, no errors
|
||||
*/
|
||||
NS_IMETHOD DrawToImage(nsIImage* aDstImage, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set the alpha level for the image
|
||||
|
|
|
@ -673,21 +673,6 @@ public:
|
|||
*/
|
||||
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)=0;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Copy an image to the RenderingContext in a tiled manner
|
||||
* @param aImage image to copy
|
||||
* @param aX0 starting x
|
||||
* @param aY0 starting y
|
||||
* @param aX1 ending x
|
||||
* @param aY1 ending y
|
||||
* @param aWidth tile width
|
||||
* @param aHeight tile height
|
||||
*/
|
||||
NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1,
|
||||
nscoord aWidth,nscoord aHeight) = 0;
|
||||
|
||||
/**
|
||||
* Draw a path.. given a point array. The Path currently supported is a Quadratic
|
||||
* Bezier curve
|
||||
|
@ -724,17 +709,6 @@ public:
|
|||
//~~~
|
||||
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd) = 0;
|
||||
|
||||
/**
|
||||
* Copy an image to the RenderingContext in a tiled manner
|
||||
* @param aImage image to copy
|
||||
* @param aSrcXOffset x offset inside the source image to begin tiling from
|
||||
* @param aSrcYOffset y offset inside the source image to begin tiling from
|
||||
* @param aTileRect area to tile
|
||||
*/
|
||||
NS_IMETHOD DrawTile(nsIImage *aImage, nscoord aSrcXOffset,
|
||||
nscoord aSrcYOffset, const nsRect &aTileRect) = 0;
|
||||
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
/**
|
||||
* Returns bounding metrics (in app units) of an 8-bit character string
|
||||
|
|
|
@ -52,14 +52,6 @@ public:
|
|||
|
||||
|
||||
// CLASS METHODS
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 03/29/00 dwc
|
||||
*/
|
||||
NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1,
|
||||
nscoord aWidth,nscoord aHeight);
|
||||
NS_IMETHOD DrawTile(nsIImage *aImage, nscoord aSrcXOffset,
|
||||
nscoord aSrcYOffset, const nsRect &aTileRect);
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 03/29/00 dwc
|
||||
|
|
|
@ -30,7 +30,7 @@ MODULE = layout
|
|||
EXPORTS = nsFontList.h
|
||||
LIBRARY_NAME = gkgfx
|
||||
EXPORT_LIBRARY = 1
|
||||
REQUIRES = xpcom string img widget util locale view necko pref timer uriloader gfx2 imglib2 intl mimetype
|
||||
REQUIRES = xpcom string widget util dom locale view necko pref timer uriloader gfx2 imglib2 intl mimetype
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
|
||||
DIRS =
|
||||
|
@ -79,15 +79,7 @@ CPPSRCS = \
|
|||
nsDeviceContext.cpp \
|
||||
nsFont.cpp \
|
||||
nsFontList.cpp \
|
||||
nsImageGroup.cpp \
|
||||
nsImageManager.cpp \
|
||||
nsImageNetContextAsync.cpp \
|
||||
nsImageNetContextSync.cpp \
|
||||
nsImageRenderer.cpp \
|
||||
nsRenderingContextImpl.cpp \
|
||||
nsImageRequest.cpp \
|
||||
nsImageSystemServices.cpp \
|
||||
nsImageURL.cpp \
|
||||
nsRect.cpp \
|
||||
nsTransform2D.cpp \
|
||||
nsScriptableRegion.cpp \
|
||||
|
@ -107,7 +99,6 @@ CPPSRCS += imgScaler.cpp
|
|||
endif
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DIST)/lib/libimg_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/libmozutil_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ LIBRARY_NAME = gfx_gtk
|
|||
EXPORT_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
MODULE_NAME = nsGfxGTKModule
|
||||
REQUIRES = xpcom string img widget view util dom pref uconv unicharutil windowwatcher locale intl
|
||||
REQUIRES = xpcom string widget view util dom pref uconv unicharutil windowwatcher locale intl
|
||||
|
||||
CSRCS = nsPrintdGTK.c
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "nspr.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "il_util.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
#include "nsDeviceContextGTK.h"
|
||||
|
@ -69,10 +68,6 @@ nsDeviceContextGTK::nsDeviceContextGTK()
|
|||
mTwipsToPixels = 1.0;
|
||||
mPixelsToTwips = 1.0;
|
||||
mDepth = 0 ;
|
||||
mPaletteInfo.isPaletteDevice = PR_FALSE;
|
||||
mPaletteInfo.sizePalette = 0;
|
||||
mPaletteInfo.numReserved = 0;
|
||||
mPaletteInfo.palette = NULL;
|
||||
mNumCells = 0;
|
||||
|
||||
mWidthFloat = 0.0f;
|
||||
|
|
|
@ -85,7 +85,6 @@ protected:
|
|||
private:
|
||||
PRUint32 mDepth;
|
||||
PRBool mWriteable;
|
||||
nsPaletteInfo mPaletteInfo;
|
||||
PRUint32 mNumCells;
|
||||
PRInt16 mScrollbarHeight;
|
||||
PRInt16 mScrollbarWidth;
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "nsDeviceContextSpecFactoryG.h"
|
||||
#include "nsScreenManagerGtk.h"
|
||||
#include "nsScriptableRegion.h"
|
||||
#include "nsIImageManager.h"
|
||||
#include "nsDeviceContextGTK.h"
|
||||
#include "nsImageGTK.h"
|
||||
#include "nsPrintOptionsGTK.h"
|
||||
|
@ -98,26 +97,6 @@ static NS_IMETHODIMP nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID
|
|||
return rv;
|
||||
}
|
||||
|
||||
static nsresult nsImageManagerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if ( !aResult )
|
||||
{
|
||||
rv = NS_ERROR_NULL_POINTER;
|
||||
return rv;
|
||||
}
|
||||
*aResult = nsnull;
|
||||
if (aOuter)
|
||||
{
|
||||
rv = NS_ERROR_NO_AGGREGATION;
|
||||
return rv;
|
||||
}
|
||||
// this will return an image manager with a count of 1
|
||||
rv = NS_NewImageManager((nsIImageManager **)aResult);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "Gtk Font Metrics",
|
||||
|
@ -164,11 +143,6 @@ static nsModuleComponentInfo components[] =
|
|||
// "@mozilla.org/gfx/device_context_spec_factory/gtk;1",
|
||||
"@mozilla.org/gfx/devicecontextspecfactory;1",
|
||||
nsDeviceContextSpecFactoryGTKConstructor },
|
||||
{ "Image Manager",
|
||||
NS_IMAGEMANAGER_CID,
|
||||
// "@mozilla.org/gfx/image_manager;1",
|
||||
"@mozilla.org/gfx/imagemanager;1",
|
||||
nsImageManagerConstructor },
|
||||
{ "Print Options",
|
||||
NS_PRINTOPTIONS_CID,
|
||||
// "@mozilla.org/gfx/printoptions;1",
|
||||
|
|
|
@ -531,7 +531,8 @@ void nsRenderingContextGTK::UpdateGC()
|
|||
gcCache = new nsGCCache();
|
||||
if (!gcCache) return;
|
||||
}
|
||||
mGC = gcCache->GetGC(mSurface->GetDrawable(),
|
||||
|
||||
mGC = gcCache->GetGC(mSurface->GetDrawable(),
|
||||
&values,
|
||||
valuesMask,
|
||||
rgn);
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include <Fonts.h>
|
||||
#include <Resources.h>
|
||||
#include <MacWindows.h>
|
||||
#include "il_util.h"
|
||||
#include <FixMath.h>
|
||||
#include "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
@ -443,49 +442,6 @@ NS_IMETHODIMP nsDeviceContextMac :: ConvertPixel(nscolor aColor, PRUint32 & aPix
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/9/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextMac::CreateILColorSpace(IL_ColorSpace*& aColorSpace)
|
||||
{
|
||||
nsresult result = NS_OK;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/9/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextMac::GetILColorSpace(IL_ColorSpace*& aColorSpace)
|
||||
{
|
||||
|
||||
if (nsnull == mColorSpace) {
|
||||
IL_RGBBits colorRGBBits;
|
||||
|
||||
// Default is to create a 32-bit color space
|
||||
colorRGBBits.red_shift = 16;
|
||||
colorRGBBits.red_bits = 8;
|
||||
colorRGBBits.green_shift = 8;
|
||||
colorRGBBits.green_bits = 8;
|
||||
colorRGBBits.blue_shift = 0;
|
||||
colorRGBBits.blue_bits = 8;
|
||||
|
||||
mColorSpace = IL_CreateTrueColorSpace(&colorRGBBits, 32);
|
||||
if (nsnull == mColorSpace) {
|
||||
aColorSpace = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
NS_POSTCONDITION(nsnull != mColorSpace, "null color space");
|
||||
aColorSpace = mColorSpace;
|
||||
IL_AddRefToColorSpace(aColorSpace);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
|
|
|
@ -53,8 +53,6 @@ public:
|
|||
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
|
||||
|
||||
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
|
||||
NS_IMETHOD CreateILColorSpace(IL_ColorSpace*& aColorSpace);
|
||||
NS_IMETHODIMP GetILColorSpace(IL_ColorSpace*& aColorSpace);
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth);
|
||||
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
#include "nsDeviceContextMac.h"
|
||||
#include "nsRegionMac.h"
|
||||
#include "nsScriptableRegion.h"
|
||||
#include "nsIImageManager.h"
|
||||
#if TARGET_CARBON
|
||||
#include "nsDeviceContextSpecX.h"
|
||||
#else
|
||||
|
@ -54,7 +53,6 @@ static NS_DEFINE_IID(kCRegion, NS_REGION_CID);
|
|||
static NS_DEFINE_IID(kCScriptableRegion, NS_SCRIPTABLE_REGION_CID);
|
||||
static NS_DEFINE_IID(kCDeviceContextSpec, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
static NS_DEFINE_IID(kCDeviceContextSpecFactory, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID);
|
||||
static NS_DEFINE_IID(kImageManagerImpl, NS_IMAGEMANAGER_CID);
|
||||
static NS_DEFINE_IID(kCBlender, NS_BLENDER_CID);
|
||||
static NS_DEFINE_IID(kCScreenManager, NS_SCREENMANAGER_CID);
|
||||
static NS_DEFINE_IID(kCPrintOptions, NS_PRINTOPTIONS_CID);
|
||||
|
@ -145,13 +143,6 @@ nsresult nsGfxFactoryMac::CreateInstance(nsISupports *aOuter,
|
|||
else if (mClassID.Equals(kCDeviceContextSpecFactory)) {
|
||||
NS_NEWXPCOM(inst, nsDeviceContextSpecFactoryMac);
|
||||
}
|
||||
else if (mClassID.Equals(kImageManagerImpl))
|
||||
{
|
||||
nsCOMPtr<nsIImageManager> iManager;
|
||||
nsresult res = NS_NewImageManager(getter_AddRefs(iManager));
|
||||
if (NS_FAILED(res)) return res;
|
||||
return iManager->QueryInterface(aIID, aResult);
|
||||
}
|
||||
else if (mClassID.Equals(kCFontEnumerator)) {
|
||||
nsFontEnumeratorMac* fe;
|
||||
NS_NEWXPCOM(fe, nsFontEnumeratorMac);
|
||||
|
|
|
@ -812,4 +812,45 @@ nsImageMac::GetPixMap ( PixMap** aPixMap )
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageMac::DrawTile(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aSXOffset, PRInt32 aSYOffset,
|
||||
const nsRect &aTileRect)
|
||||
{
|
||||
// XXX this code below is quite slow. need to make it faster
|
||||
PRInt32
|
||||
validX = 0,
|
||||
validY = 0,
|
||||
validWidth = mWidth,
|
||||
validHeight = mHeight;
|
||||
|
||||
// limit the image rectangle to the size of the image data which
|
||||
// has been validated.
|
||||
if (mDecodedY2 < mHeight) {
|
||||
validHeight = mDecodedY2 - mDecodedY1;
|
||||
}
|
||||
if (mDecodedX2 < mWidth) {
|
||||
validWidth = mDecodedX2 - mDecodedX1;
|
||||
}
|
||||
if (mDecodedY1 > 0) {
|
||||
validHeight -= mDecodedY1;
|
||||
validY = mDecodedY1;
|
||||
}
|
||||
if (mDecodedX1 > 0) {
|
||||
validWidth -= mDecodedX1;
|
||||
validX = mDecodedX1;
|
||||
}
|
||||
|
||||
PRInt32 aY0 = aTileRect.y - aSYOffset,
|
||||
aX0 = aTileRect.x - aSXOffset,
|
||||
aY1 = aTileRect.y + aTileRect.height,
|
||||
aX1 = aTileRect.x + aTileRect.width;
|
||||
|
||||
for (PRInt32 y = aY0; y < aY1; y += mHeight)
|
||||
for (PRInt32 x = aX0; x < aX1; x += mWidth)
|
||||
Draw(aContext, aSurface,
|
||||
0, 0, PR_MIN(validWidth, aX1-x), PR_MIN(validHeight, aY1-y),
|
||||
x, y, PR_MIN(validWidth, aX1-x), PR_MIN(validHeight, aY1-y));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -78,6 +78,11 @@ public:
|
|||
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
||||
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
|
||||
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
|
||||
|
||||
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aSXOffset, PRInt32 aSYOffset,
|
||||
const nsRect &aTileRect);
|
||||
#ifdef USE_IMG2
|
||||
NS_IMETHOD DrawToImage(nsIImage* aDstImage, nscoord aDX, nscoord aDY,
|
||||
nscoord aDWidth, nscoord aDHeight);
|
||||
|
|
|
@ -34,26 +34,19 @@ EXPORT_LIBRARY=1
|
|||
DEFINES=-D_IMPL_NS_GFX -DWIN32_LEAN_AND_MEAN
|
||||
|
||||
CPPSRCS=nsColor.cpp nsColorNames.cpp nsFont.cpp nsFontList.cpp \
|
||||
nsImageGroup.cpp nsImageManager.cpp nsImageNetContextAsync.cpp \
|
||||
nsImageRenderer.cpp nsImageRequest.cpp nsImageSystemServices.cpp \
|
||||
nsImageURL.cpp nsRect.cpp nsTransform2D.cpp nsBlender.cpp \
|
||||
nsDeviceContext.cpp nsImageNetContextSync.cpp nsScriptableRegion.cpp nsPrintOptionsImpl.cpp
|
||||
nsRect.cpp nsTransform2D.cpp nsBlender.cpp \
|
||||
nsDeviceContext.cpp nsScriptableRegion.cpp nsPrintOptionsImpl.cpp
|
||||
|
||||
CPP_OBJS=.\$(OBJDIR)\nsColor.obj .\$(OBJDIR)\nsColorNames.obj \
|
||||
.\$(OBJDIR)\nsFont.obj .\$(OBJDIR)\nsFontList.obj \
|
||||
.\$(OBJDIR)\nsImageGroup.obj .\$(OBJDIR)\nsImageManager.obj \
|
||||
.\$(OBJDIR)\nsImageNetContextAsync.obj .\$(OBJDIR)\nsImageRenderer.obj \
|
||||
.\$(OBJDIR)\nsImageRequest.obj .\$(OBJDIR)\nsImageSystemServices.obj \
|
||||
.\$(OBJDIR)\nsImageURL.obj .\$(OBJDIR)\nsRect.obj \
|
||||
.\$(OBJDIR)\nsTransform2D.obj \
|
||||
.\$(OBJDIR)\nsRect.obj .\$(OBJDIR)\nsTransform2D.obj \
|
||||
.\$(OBJDIR)\nsDeviceContext.obj \
|
||||
.\$(OBJDIR)\nsImageNetContextSync.obj \
|
||||
.\$(OBJDIR)\nsBlender.obj \
|
||||
.\$(OBJDIR)\nsRenderingContextImpl.obj\
|
||||
.\$(OBJDIR)\nsScriptableRegion.obj\
|
||||
.\$(OBJDIR)\nsPrintOptionsImpl.obj
|
||||
|
||||
LINCS=-I$(PUBLIC)\util -I$(PUBLIC)\img \
|
||||
LINCS=-I$(PUBLIC)\util \
|
||||
-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \
|
||||
!ifdef NECKO
|
||||
-I$(PUBLIC)\necko \
|
||||
|
@ -68,7 +61,6 @@ LCFLAGS = \
|
|||
$(NULL)
|
||||
|
||||
LLIBS= \
|
||||
$(DIST)\lib\img32$(VERSION_NUMBER).lib \
|
||||
$(DIST)\lib\util.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(LIBNSPR)
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#include "nsBlender.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "il_util.h"
|
||||
#include "nsCRT.h"
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
@ -243,6 +242,7 @@ nsresult nsBlender::Blend(PRUint8 *aSrcBits, PRInt32 aSrcStride,
|
|||
|
||||
case 8:
|
||||
{
|
||||
#if 0
|
||||
IL_ColorSpace *thespace = nsnull;
|
||||
|
||||
if ((result = mContext->GetILColorSpace(thespace)) == NS_OK) {
|
||||
|
@ -251,6 +251,7 @@ nsresult nsBlender::Blend(PRUint8 *aSrcBits, PRInt32 aSrcStride,
|
|||
nsHighQual);
|
||||
IL_ReleaseColorSpace(thespace);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -651,6 +652,7 @@ nsBlender::Do8Blend(float aOpacity, PRInt32 aNumlines, PRInt32 aNumbytes,
|
|||
PRInt32 aSLSpan, PRInt32 aDLSpan, IL_ColorSpace *aColorMap,
|
||||
nsBlendQuality aBlendQuality)
|
||||
{
|
||||
#if 0
|
||||
PRUint32 r,g,b,r1,g1,b1,i;
|
||||
PRUint8 *d1,*d2,*s1,*s2;
|
||||
PRInt32 x,y,val1,val2,numlines;
|
||||
|
@ -756,6 +758,7 @@ NI_RGB *map;
|
|||
|
||||
delete[] distbuffer;
|
||||
delete[] invermap;
|
||||
#endif
|
||||
}
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#define nsBlender_h___
|
||||
|
||||
#include "nsIBlender.h"
|
||||
#include "il_types.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
|
@ -35,6 +34,8 @@ typedef enum
|
|||
nsHighQual
|
||||
} nsBlendQuality;
|
||||
|
||||
class IL_ColorSpace;
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Blender interface
|
||||
|
|
|
@ -32,10 +32,7 @@
|
|||
#include "nsFont.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsImageNet.h"
|
||||
#include "nsImageRequest.h"
|
||||
#include "nsIImageGroup.h"
|
||||
#include "il_util.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsILanguageAtomService.h"
|
||||
|
@ -69,12 +66,7 @@ DeviceContextImpl :: DeviceContextImpl()
|
|||
mZoom = 1.0f;
|
||||
mTextZoom = 1.0f;
|
||||
mWidget = nsnull;
|
||||
mIconImageGroup = nsnull;
|
||||
for (PRInt32 i = 0; i < NS_NUMBER_OF_ICONS; i++) {
|
||||
mIcons[i] = nsnull;
|
||||
}
|
||||
mFontAliasTable = nsnull;
|
||||
mColorSpace = nsnull;
|
||||
}
|
||||
|
||||
static PRBool PR_CALLBACK DeleteValue(nsHashKey* aKey, void* aValue, void* closure)
|
||||
|
@ -97,26 +89,10 @@ DeviceContextImpl :: ~DeviceContextImpl()
|
|||
mGammaTable = nsnull;
|
||||
}
|
||||
|
||||
for (PRInt32 i = 0; i < NS_NUMBER_OF_ICONS; i++) {
|
||||
NS_IF_RELEASE(mIcons[i]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroy the GroupContext after releasing the ImageRequests
|
||||
* since IL_DestroyGroupContext(...) will destroy any IL_ImageReq
|
||||
* for the context. These are the same IL_ImgReq being referenced
|
||||
* by mIcons[...]
|
||||
*/
|
||||
IL_DestroyGroupContext(mIconImageGroup);
|
||||
|
||||
if (nsnull != mFontAliasTable) {
|
||||
mFontAliasTable->Enumerate(DeleteValue);
|
||||
delete mFontAliasTable;
|
||||
}
|
||||
|
||||
if (nsnull != mColorSpace) {
|
||||
IL_ReleaseColorSpace(mColorSpace);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeviceContextImpl :: Init(nsNativeWidget aWidget)
|
||||
|
@ -357,108 +333,6 @@ NS_IMETHODIMP DeviceContextImpl::GetDepth(PRUint32& aDepth)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult DeviceContextImpl::CreateIconILGroupContext()
|
||||
{
|
||||
ilIImageRenderer* renderer;
|
||||
nsresult result;
|
||||
|
||||
// Create an image renderer
|
||||
result = NS_NewImageRenderer(&renderer);
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Create an image group context. The image renderer code expects the
|
||||
// display_context to be a pointer to a device context
|
||||
mIconImageGroup = IL_NewGroupContext((void*)this, renderer);
|
||||
if (nsnull == mIconImageGroup) {
|
||||
NS_RELEASE(renderer);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// Initialize the image group context.
|
||||
IL_ColorSpace* colorSpace;
|
||||
result = GetILColorSpace(colorSpace);
|
||||
if (NS_FAILED(result)) {
|
||||
NS_RELEASE(renderer);
|
||||
IL_DestroyGroupContext(mIconImageGroup);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Icon loading is synchronous, so don't waste time with progressive display
|
||||
IL_DisplayData displayData;
|
||||
displayData.dither_mode = IL_Auto;
|
||||
displayData.color_space = colorSpace;
|
||||
displayData.progressive_display = PR_FALSE;
|
||||
IL_SetDisplayMode(mIconImageGroup, IL_COLOR_SPACE | IL_DITHER_MODE, &displayData);
|
||||
IL_ReleaseColorSpace(colorSpace);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeviceContextImpl::LoadIconImage(PRInt32 aId, nsIImage*& aImage)
|
||||
{
|
||||
nsresult result;
|
||||
|
||||
// Initialize out parameter
|
||||
aImage = nsnull;
|
||||
|
||||
// Make sure the icon number is valid
|
||||
if ((aId < 0) || (aId >= NS_NUMBER_OF_ICONS)) {
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
// See if the icon is already loaded
|
||||
if (nsnull != mIcons[aId]) {
|
||||
aImage = mIcons[aId]->GetImage();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Make sure we have an image group context
|
||||
if (nsnull == mIconImageGroup) {
|
||||
result = CreateIconILGroupContext();
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// Build the URL string
|
||||
char url[128];
|
||||
sprintf(url, "resource:/res/gfx/icon_%d.gif", aId);
|
||||
|
||||
// Use a sync net context
|
||||
nsCOMPtr<ilINetContext> netContext;
|
||||
result = NS_NewImageNetContextSync(getter_AddRefs(netContext));
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Create an image request object which will do the actual load
|
||||
ImageRequestImpl* imageReq = new ImageRequestImpl();
|
||||
if (nsnull == imageReq) {
|
||||
result = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
} else {
|
||||
// addref so it has nonzero refcount
|
||||
NS_ADDREF(imageReq);
|
||||
|
||||
// Load the image
|
||||
result = imageReq->Init(mIconImageGroup, url, nsnull, nsnull, 0, 0,
|
||||
nsImageLoadFlags_kHighPriority, netContext);
|
||||
aImage = imageReq->GetImage();
|
||||
if(!aImage) {
|
||||
// XXX This happens more often than just when out of memory.
|
||||
NS_RELEASE(imageReq);
|
||||
return NS_ERROR_OUT_OF_MEMORY; //ptn some error msg
|
||||
}
|
||||
|
||||
// Keep the image request object around and avoid reloading the image
|
||||
mIcons[aId] = imageReq; // owns reference from addref above
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
struct FontEnumData {
|
||||
FontEnumData(nsIDeviceContext* aDC, nsString& aFaceName)
|
||||
: mDC(aDC), mFaceName(aFaceName)
|
||||
|
@ -632,41 +506,6 @@ NS_IMETHODIMP DeviceContextImpl :: FlushFontCache(void)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeviceContextImpl::GetILColorSpace(IL_ColorSpace*& aColorSpace)
|
||||
{
|
||||
if (nsnull == mColorSpace) {
|
||||
IL_RGBBits colorRGBBits;
|
||||
|
||||
// Default is to create a 24-bit color space
|
||||
colorRGBBits.red_shift = 16;
|
||||
colorRGBBits.red_bits = 8;
|
||||
colorRGBBits.green_shift = 8;
|
||||
colorRGBBits.green_bits = 8;
|
||||
colorRGBBits.blue_shift = 0;
|
||||
colorRGBBits.blue_bits = 8;
|
||||
|
||||
mColorSpace = IL_CreateTrueColorSpace(&colorRGBBits, 24);
|
||||
if (nsnull == mColorSpace) {
|
||||
aColorSpace = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
NS_POSTCONDITION(nsnull != mColorSpace, "null color space");
|
||||
aColorSpace = mColorSpace;
|
||||
IL_AddRefToColorSpace(aColorSpace);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP DeviceContextImpl::GetPaletteInfo(nsPaletteInfo& aPaletteInfo)
|
||||
{
|
||||
aPaletteInfo.isPaletteDevice = PR_FALSE;
|
||||
aPaletteInfo.sizePalette = 0;
|
||||
aPaletteInfo.numReserved = 0;
|
||||
aPaletteInfo.palette = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Return localized bundle for resource strings
|
||||
nsresult
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "nsIImage.h"
|
||||
#include "nsTransform2D.h"
|
||||
#include <stdlib.h>
|
||||
#include "il_util.h"
|
||||
|
||||
|
||||
const nsPoint *gPts;
|
||||
|
@ -56,6 +55,8 @@ nsRenderingContextImpl :: ~nsRenderingContextImpl()
|
|||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 3/29/00 dwc
|
||||
|
@ -151,6 +152,7 @@ nsTransform2D *theTransform;
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextImpl::DrawTile(nsIImage *aImage, nscoord aSrcXOffset,
|
||||
nscoord aSrcYOffset,
|
||||
|
@ -159,6 +161,10 @@ nsRenderingContextImpl::DrawTile(nsIImage *aImage, nscoord aSrcXOffset,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 3/29/00 dwc
|
||||
|
@ -747,7 +753,26 @@ NS_IMETHODIMP nsRenderingContextImpl::DrawScaledImage(imgIContainer *aImage, con
|
|||
/* [noscript] void drawTile (in imgIContainer aImage, in nscoord aXOffset, in nscoord aYOffset, [const] in nsRect aTargetRect); */
|
||||
NS_IMETHODIMP nsRenderingContextImpl::DrawTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, const nsRect * aTargetRect)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
nsRect dr(*aTargetRect);
|
||||
nsRect so(0, 0, aXOffset, aYOffset);
|
||||
|
||||
mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
|
||||
|
||||
// i want one of these...
|
||||
mTranMatrix->TransformCoord(&so.x, &so.y, &so.width, &so.height);
|
||||
|
||||
nsCOMPtr<gfxIImageFrame> iframe;
|
||||
aImage->GetCurrentFrame(getter_AddRefs(iframe));
|
||||
if (!iframe) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIImage> img(do_GetInterface(iframe));
|
||||
if (!img) return NS_ERROR_FAILURE;
|
||||
|
||||
nsIDrawingSurface *surface = nsnull;
|
||||
GetDrawingSurface((void**)&surface);
|
||||
if (!surface) return NS_ERROR_FAILURE;
|
||||
|
||||
return img->DrawTile(*this, surface, so.width, so.height, dr);
|
||||
}
|
||||
|
||||
/* [noscript] void drawScaledTile (in imgIContainer aImage, in nscoord aXOffset, in nscoord aYOffset, in nscoord aTileWidth, in nscoord aTileHeight, [const] in nsRect aTargetRect); */
|
||||
|
|
|
@ -31,8 +31,8 @@ LIBRARY_NAME = gfxps
|
|||
EXPORT_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
MODULE_NAME = nsGfxPSModule
|
||||
EXTRA_DSO_LIBS = img_s mozutil_s
|
||||
REQUIRES = xpcom string img widget util pref uconv view gfx2 necko imglib2 intl
|
||||
EXTRA_DSO_LIBS = mozutil_s
|
||||
REQUIRES = xpcom string widget util pref uconv view gfx2 necko imglib2 intl
|
||||
EXTRA_DSO_LIBS += gkgfx
|
||||
|
||||
CSRCS = font_metrics.c
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "nsRenderingContextPS.h"
|
||||
#include "nsString.h"
|
||||
#include "nsFontMetricsPS.h"
|
||||
#include "il_util.h"
|
||||
#include "nsPostScriptObj.h"
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
|
||||
|
@ -162,55 +161,6 @@ NS_IMETHODIMP nsDeviceContextPS::GetDepth(PRUint32& aDepth)
|
|||
return(1); // postscript is 1 bit
|
||||
}
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextPS::GetILColorSpace(IL_ColorSpace*& aColorSpace)
|
||||
{
|
||||
#ifdef NOTNOW
|
||||
if (nsnull == mColorSpace) {
|
||||
mColorSpace = IL_CreateGreyScaleColorSpace(1, 1);
|
||||
|
||||
if (nsnull == mColorSpace) {
|
||||
aColorSpace = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the color space
|
||||
aColorSpace = mColorSpace;
|
||||
IL_AddRefToColorSpace(aColorSpace);
|
||||
#endif
|
||||
|
||||
if(nsnull==mColorSpace) {
|
||||
IL_RGBBits colorRGBBits;
|
||||
|
||||
// Create a 24-bit color space
|
||||
colorRGBBits.red_shift = 16;
|
||||
colorRGBBits.red_bits = 8;
|
||||
colorRGBBits.green_shift = 8;
|
||||
colorRGBBits.green_bits = 8;
|
||||
colorRGBBits.blue_shift = 0;
|
||||
colorRGBBits.blue_bits = 8;
|
||||
|
||||
mColorSpace = IL_CreateTrueColorSpace(&colorRGBBits, 24);
|
||||
|
||||
if (nsnull == mColorSpace) {
|
||||
aColorSpace = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Return the color space
|
||||
aColorSpace = mColorSpace;
|
||||
IL_AddRefToColorSpace(aColorSpace);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
|
|
|
@ -64,7 +64,6 @@ public:
|
|||
|
||||
|
||||
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
|
||||
NS_IMETHODIMP GetILColorSpace(IL_ColorSpace*& aColorSpace);
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth);
|
||||
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "nsRenderingContextPS.h"
|
||||
#include "nsFontMetricsPS.h"
|
||||
#include <math.h>
|
||||
#include "libimg.h"
|
||||
#include "nsDeviceContextPS.h"
|
||||
#include "nsPostScriptObj.h"
|
||||
#include "nsIRegion.h"
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "nsIImage.h"
|
||||
#include "nsTransform2D.h"
|
||||
#include <stdlib.h>
|
||||
#include "il_util.h"
|
||||
|
||||
|
||||
const nsPoint *gPts;
|
||||
|
@ -56,6 +55,8 @@ nsRenderingContextImpl :: ~nsRenderingContextImpl()
|
|||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 3/29/00 dwc
|
||||
|
@ -151,6 +152,7 @@ nsTransform2D *theTransform;
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextImpl::DrawTile(nsIImage *aImage, nscoord aSrcXOffset,
|
||||
nscoord aSrcYOffset,
|
||||
|
@ -159,6 +161,10 @@ nsRenderingContextImpl::DrawTile(nsIImage *aImage, nscoord aSrcXOffset,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 3/29/00 dwc
|
||||
|
@ -747,7 +753,26 @@ NS_IMETHODIMP nsRenderingContextImpl::DrawScaledImage(imgIContainer *aImage, con
|
|||
/* [noscript] void drawTile (in imgIContainer aImage, in nscoord aXOffset, in nscoord aYOffset, [const] in nsRect aTargetRect); */
|
||||
NS_IMETHODIMP nsRenderingContextImpl::DrawTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset, const nsRect * aTargetRect)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
nsRect dr(*aTargetRect);
|
||||
nsRect so(0, 0, aXOffset, aYOffset);
|
||||
|
||||
mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
|
||||
|
||||
// i want one of these...
|
||||
mTranMatrix->TransformCoord(&so.x, &so.y, &so.width, &so.height);
|
||||
|
||||
nsCOMPtr<gfxIImageFrame> iframe;
|
||||
aImage->GetCurrentFrame(getter_AddRefs(iframe));
|
||||
if (!iframe) return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIImage> img(do_GetInterface(iframe));
|
||||
if (!img) return NS_ERROR_FAILURE;
|
||||
|
||||
nsIDrawingSurface *surface = nsnull;
|
||||
GetDrawingSurface((void**)&surface);
|
||||
if (!surface) return NS_ERROR_FAILURE;
|
||||
|
||||
return img->DrawTile(*this, surface, so.width, so.height, dr);
|
||||
}
|
||||
|
||||
/* [noscript] void drawScaledTile (in imgIContainer aImage, in nscoord aXOffset, in nscoord aYOffset, in nscoord aTileWidth, in nscoord aTileHeight, [const] in nsRect aTargetRect); */
|
||||
|
|
|
@ -74,7 +74,6 @@ LLIBS = \
|
|||
$(DIST)\lib\gkgfx.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\util.lib \
|
||||
$(DIST)\lib\img32$(VERSION_NUMBER).lib \
|
||||
$(DIST)\lib\timer_s.lib \
|
||||
!if defined(NGLAYOUT_DDRAW)
|
||||
$(NGLAYOUT_DDRAW)\lib\ddraw.lib \
|
||||
|
@ -88,9 +87,7 @@ WIN_LIBS= \
|
|||
!endif
|
||||
comdlg32.lib
|
||||
|
||||
LLFLAGS = $(LLFLAGS) \
|
||||
/INCLUDE:_NS_NewImageManager@4
|
||||
|
||||
LLFLAGS = $(LLFLAGS)
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
install::
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "nsDeviceContextWin.h"
|
||||
#include "nsRenderingContextWin.h"
|
||||
#include "nsDeviceContextSpecWin.h"
|
||||
#include "il_util.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
@ -51,10 +50,6 @@ nsDeviceContextWin :: nsDeviceContextWin()
|
|||
: DeviceContextImpl()
|
||||
{
|
||||
mSurface = NULL;
|
||||
mPaletteInfo.isPaletteDevice = PR_FALSE;
|
||||
mPaletteInfo.sizePalette = 0;
|
||||
mPaletteInfo.numReserved = 0;
|
||||
mPaletteInfo.palette = NULL;
|
||||
mDC = NULL;
|
||||
mPixelScale = 1.0f;
|
||||
mWidth = -1;
|
||||
|
@ -82,9 +77,6 @@ nsDeviceContextWin :: ~nsDeviceContextWin()
|
|||
NS_IF_RELEASE(surf); //this clears the surf pointer...
|
||||
mSurface = nsnull;
|
||||
|
||||
if (NULL != mPaletteInfo.palette)
|
||||
::DeleteObject((HPALETTE)mPaletteInfo.palette);
|
||||
|
||||
if (NULL != mDC)
|
||||
{
|
||||
::DeleteDC(mDC);
|
||||
|
@ -147,9 +139,6 @@ void nsDeviceContextWin :: CommonInit(HDC aDC)
|
|||
mPixelsToTwips = 1.0f / mTwipsToPixels;
|
||||
|
||||
mDepth = (PRUint32)::GetDeviceCaps(aDC, BITSPIXEL);
|
||||
mPaletteInfo.isPaletteDevice = RC_PALETTE == (rasterCaps & RC_PALETTE);
|
||||
mPaletteInfo.sizePalette = (PRUint8)::GetDeviceCaps(aDC, SIZEPALETTE);
|
||||
mPaletteInfo.numReserved = (PRUint8)::GetDeviceCaps(aDC, NUMRESERVED);
|
||||
|
||||
mWidth = ::GetDeviceCaps(aDC, HORZRES);
|
||||
mHeight = ::GetDeviceCaps(aDC, VERTRES);
|
||||
|
@ -626,103 +615,6 @@ NS_IMETHODIMP nsDeviceContextWin::GetDepth(PRUint32& aDepth)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin::GetILColorSpace(IL_ColorSpace*& aColorSpace)
|
||||
{
|
||||
if (nsnull == mColorSpace) {
|
||||
// See if we're dealing with an 8-bit palette device
|
||||
if ((8 == mDepth) && mPaletteInfo.isPaletteDevice) {
|
||||
// Create a color cube. We want to use DIB_PAL_COLORS because it's faster
|
||||
// than DIB_RGB_COLORS, so make sure the indexes match that of the
|
||||
// GDI physical palette
|
||||
//
|
||||
// Note: the image library doesn't use the reserved colors, so it doesn't
|
||||
// matter what they're set to...
|
||||
IL_RGB reserved[10];
|
||||
memset(reserved, 0, sizeof(reserved));
|
||||
IL_ColorMap* colorMap = IL_NewCubeColorMap(reserved, 10, COLOR_CUBE_SIZE + 10);
|
||||
if (nsnull == colorMap) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
// Create a pseudo color space
|
||||
mColorSpace = IL_CreatePseudoColorSpace(colorMap, 8, 8);
|
||||
|
||||
} else {
|
||||
IL_RGBBits colorRGBBits;
|
||||
|
||||
// Create a 24-bit color space
|
||||
colorRGBBits.red_shift = 16;
|
||||
colorRGBBits.red_bits = 8;
|
||||
colorRGBBits.green_shift = 8;
|
||||
colorRGBBits.green_bits = 8;
|
||||
colorRGBBits.blue_shift = 0;
|
||||
colorRGBBits.blue_bits = 8;
|
||||
|
||||
mColorSpace = IL_CreateTrueColorSpace(&colorRGBBits, 24);
|
||||
}
|
||||
|
||||
if (nsnull == mColorSpace) {
|
||||
aColorSpace = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the color space
|
||||
aColorSpace = mColorSpace;
|
||||
IL_AddRefToColorSpace(aColorSpace);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin::GetPaletteInfo(nsPaletteInfo& aPaletteInfo)
|
||||
{
|
||||
aPaletteInfo.isPaletteDevice = mPaletteInfo.isPaletteDevice;
|
||||
aPaletteInfo.sizePalette = mPaletteInfo.sizePalette;
|
||||
aPaletteInfo.numReserved = mPaletteInfo.numReserved;
|
||||
|
||||
if (NULL == mPaletteInfo.palette) {
|
||||
IL_ColorSpace* colorSpace;
|
||||
GetILColorSpace(colorSpace);
|
||||
|
||||
if (NI_PseudoColor == colorSpace->type) {
|
||||
// Create a logical palette
|
||||
BYTE tmp[sizeof(LOGPALETTE) + ((COLOR_CUBE_SIZE + 20) * sizeof(PALETTEENTRY))];
|
||||
LPLOGPALETTE logPal = (LPLOGPALETTE)tmp;
|
||||
|
||||
logPal->palVersion = 0x300;
|
||||
logPal->palNumEntries = COLOR_CUBE_SIZE + 20;
|
||||
|
||||
// Initialize it from the default Windows palette
|
||||
HPALETTE hDefaultPalette = (HPALETTE)::GetStockObject(DEFAULT_PALETTE);
|
||||
|
||||
// First ten system colors
|
||||
::GetPaletteEntries(hDefaultPalette, 0, 10, logPal->palPalEntry);
|
||||
|
||||
// Last ten system colors
|
||||
::GetPaletteEntries(hDefaultPalette, 10, 10, &logPal->palPalEntry[COLOR_CUBE_SIZE + 10]);
|
||||
|
||||
// Now set the color cube entries.
|
||||
PALETTEENTRY* entry = &logPal->palPalEntry[10];
|
||||
NI_RGB* map = colorSpace->cmap.map + 10;
|
||||
for (PRInt32 i = 0; i < COLOR_CUBE_SIZE; i++) {
|
||||
entry->peRed = map->red;
|
||||
entry->peGreen = map->green;
|
||||
entry->peBlue = map->blue;
|
||||
entry->peFlags = 0;
|
||||
|
||||
entry++;
|
||||
map++;
|
||||
}
|
||||
|
||||
// Create a GDI palette
|
||||
mPaletteInfo.palette = ::CreatePalette(logPal);
|
||||
}
|
||||
|
||||
IL_ReleaseColorSpace(colorSpace);
|
||||
}
|
||||
|
||||
aPaletteInfo.palette = mPaletteInfo.palette;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextWin :: ConvertPixel(nscolor aColor, PRUint32 & aPixel)
|
||||
{
|
||||
|
|
|
@ -56,10 +56,6 @@ public:
|
|||
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth);
|
||||
|
||||
NS_IMETHOD GetILColorSpace(IL_ColorSpace*& aColorSpace);
|
||||
|
||||
NS_IMETHOD GetPaletteInfo(nsPaletteInfo&);
|
||||
|
||||
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
|
||||
|
||||
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
|
||||
|
@ -93,7 +89,6 @@ protected:
|
|||
|
||||
nsDrawingSurface mSurface;
|
||||
PRUint32 mDepth; // bit depth of device
|
||||
nsPaletteInfo mPaletteInfo;
|
||||
float mPixelScale;
|
||||
PRInt32 mWidth;
|
||||
PRInt32 mHeight;
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "nsDeviceContextSpecWin.h"
|
||||
#include "nsDeviceContextSpecFactoryW.h"
|
||||
#include "nsScriptableRegion.h"
|
||||
#include "nsIImageManager.h"
|
||||
#include "nsScreenManagerWin.h"
|
||||
#include "nsPrintOptionsWin.h"
|
||||
#include "nsFontList.h"
|
||||
|
@ -49,7 +48,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsDrawingSurfaceWin)
|
|||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecWin)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryWin)
|
||||
//NS_GENERIC_FACTORY_CONSTRUCTOR(nsScriptableRegion)
|
||||
//NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageManagerImpl)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsWin)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorWin)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList)
|
||||
|
@ -151,24 +149,6 @@ nsScriptableRegionConstructor(nsISupports* aOuter, REFNSIID aIID, void** aResult
|
|||
return rv;
|
||||
}
|
||||
|
||||
static NS_IMETHODIMP
|
||||
nsImageManagerImplConstructor(nsISupports* aOuter, REFNSIID aIID, void** aResult)
|
||||
{
|
||||
*aResult = nsnull;
|
||||
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIImageManager> result;
|
||||
rv = NS_NewImageManager(getter_AddRefs(result));
|
||||
|
||||
if (result)
|
||||
rv = result->QueryInterface(aIID, aResult);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "nsFontMetricsWin",
|
||||
|
@ -221,11 +201,6 @@ static nsModuleComponentInfo components[] =
|
|||
"@mozilla.org/gfx/region;1",
|
||||
nsScriptableRegionConstructor },
|
||||
|
||||
{ "nsImageManagerImpl",
|
||||
NS_IMAGEMANAGER_CID,
|
||||
"@mozilla.org/gfx/imagemanager;1",
|
||||
nsImageManagerImplConstructor },
|
||||
|
||||
{ "nsPrintOptionsWin",
|
||||
NS_PRINTOPTIONS_CID,
|
||||
"@mozilla.org/gfx/printoptions;1",
|
||||
|
|
|
@ -629,11 +629,45 @@ NS_IMETHODIMP nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface
|
|||
* See documentation in nsIRenderingContext.h
|
||||
* @update 3/16/00 dwc
|
||||
*/
|
||||
PRBool
|
||||
nsImageWin::DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
||||
nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1,
|
||||
nscoord aWidth, nscoord aHeight)
|
||||
NS_IMETHODIMP nsImageWin::DrawTile(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aSXOffset, PRInt32 aSYOffset,
|
||||
const nsRect &aTileRect)
|
||||
{
|
||||
PRInt32
|
||||
validX = 0,
|
||||
validY = 0,
|
||||
validWidth = mBHead->biWidth,
|
||||
validHeight = mBHead->biHeight;
|
||||
|
||||
// limit the image rectangle to the size of the image data which
|
||||
// has been validated.
|
||||
if (mDecodedY2 < mBHead->biHeight) {
|
||||
validHeight = mDecodedY2 - mDecodedY1;
|
||||
}
|
||||
if (mDecodedX2 < mBHead->biWidth) {
|
||||
validWidth = mDecodedX2 - mDecodedX1;
|
||||
}
|
||||
if (mDecodedY1 > 0) {
|
||||
validHeight -= mDecodedY1;
|
||||
validY = mDecodedY1;
|
||||
}
|
||||
if (mDecodedX1 > 0) {
|
||||
validWidth -= mDecodedX1;
|
||||
validX = mDecodedX1;
|
||||
}
|
||||
|
||||
PRInt32 aY0 = aTileRect.y - aSYOffset,
|
||||
aX0 = aTileRect.x - aSXOffset,
|
||||
aY1 = aTileRect.y + aTileRect.height,
|
||||
aX1 = aTileRect.x + aTileRect.width;
|
||||
|
||||
nscoord aWidth = mBHead->biWidth;
|
||||
nscoord aHeight = mBHead->biHeight;
|
||||
|
||||
nscoord tileWidth = aTileRect.width;
|
||||
nscoord tileHeight = aTileRect.height;
|
||||
|
||||
nsRect destRect,srcRect,tvrect;
|
||||
HDC TheHDC,offDC,maskDC;
|
||||
PRInt32 x,y,width,height,canRaster,TileBufferWidth,TileBufferHeight;
|
||||
|
@ -650,7 +684,9 @@ nsImageWin::DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
|||
|| (aWidth>MAX_BUFFER_WIDTH) || (aHeight>MAX_BUFFER_HEIGHT)){
|
||||
for(y=aY0;y<aY1;y+=aHeight){
|
||||
for(x=aX0;x<aX1;x+=aWidth){
|
||||
this->Draw(aContext,aSurface,x,y,aWidth,aHeight);
|
||||
Draw(aContext, aSurface,
|
||||
0, 0, PR_MIN(validWidth, aX1-x), PR_MIN(validHeight, aY1-y),
|
||||
x, y, PR_MIN(validWidth, aX1-x), PR_MIN(validHeight, aY1-y));
|
||||
}
|
||||
}
|
||||
return(PR_TRUE);
|
||||
|
@ -670,16 +706,16 @@ nsImageWin::DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
|||
return (PR_FALSE);
|
||||
}
|
||||
|
||||
if (aWidth < tvrect.width){
|
||||
if (tileWidth < tvrect.width){
|
||||
TileBufferWidth = MAX_BUFFER_WIDTH;
|
||||
} else {
|
||||
TileBufferWidth = aWidth;
|
||||
TileBufferWidth = tileWidth;
|
||||
}
|
||||
|
||||
if (aHeight < tvrect.height){
|
||||
if (tileHeight < tvrect.height){
|
||||
TileBufferHeight = MAX_BUFFER_HEIGHT;
|
||||
} else {
|
||||
TileBufferHeight = aHeight;
|
||||
TileBufferHeight = tileHeight;
|
||||
}
|
||||
|
||||
tileBits = ::CreateCompatibleBitmap(TheHDC, TileBufferWidth,TileBufferHeight);
|
||||
|
@ -769,7 +805,7 @@ nsImageWin::DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
|||
::DeleteObject(tileBits);
|
||||
::DeleteObject(offDC);
|
||||
|
||||
return (PR_TRUE);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
|
|
@ -103,17 +103,11 @@ public:
|
|||
virtual PRInt32 GetAlphaHeight() {return mAlphaHeight;}
|
||||
virtual PRInt32 GetAlphaLineStride(){ return mARowBytes; }
|
||||
|
||||
/**
|
||||
* Draw a tiled version of the bitmap
|
||||
* @update - dwc 3/30/00
|
||||
* @param aSurface the surface to blit to
|
||||
* @param aX The destination horizontal location
|
||||
* @param aY The destination vertical location
|
||||
* @param aWidth The destination width of the pixelmap
|
||||
* @param aHeight The destination height of the pixelmap
|
||||
* @return if TRUE, no errors
|
||||
*/
|
||||
PRBool DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1,nscoord aWidth,nscoord aHeight);
|
||||
|
||||
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aSXOffset, PRInt32 aSYOffset,
|
||||
const nsRect &aTileRect);
|
||||
|
||||
/**
|
||||
* Draw a tiled version of the bitmap, but use the windows specific highly optimized PatBlt
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "nsFontMetricsWin.h"
|
||||
#include "nsRegionWin.h"
|
||||
#include <math.h>
|
||||
#include "libimg.h"
|
||||
#include "nsDeviceContextWin.h"
|
||||
#include "prprf.h"
|
||||
#include "nsDrawingSurfaceWin.h"
|
||||
|
@ -464,17 +463,6 @@ nsresult nsRenderingContextWin :: SetupDC(HDC aOldDC, HDC aNewDC)
|
|||
::SelectClipRgn(aNewDC, pstate->mClipRegion);
|
||||
#endif
|
||||
|
||||
// If this is a palette device, then select and realize the palette
|
||||
nsPaletteInfo palInfo;
|
||||
mContext->GetPaletteInfo(palInfo);
|
||||
|
||||
if (palInfo.isPaletteDevice && palInfo.palette)
|
||||
{
|
||||
// Select the palette in the background
|
||||
::SelectPalette(aNewDC, (HPALETTE)palInfo.palette, PR_FALSE);
|
||||
::RealizePalette(aNewDC);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -501,7 +489,6 @@ NS_IMETHODIMP nsRenderingContextWin :: LockDrawingSurface(PRInt32 aX, PRInt32 aY
|
|||
PRInt32 *aWidthBytes, PRUint32 aFlags)
|
||||
{
|
||||
PRBool destructive;
|
||||
nsPaletteInfo palInfo;
|
||||
|
||||
PushState();
|
||||
|
||||
|
@ -519,13 +506,6 @@ NS_IMETHODIMP nsRenderingContextWin :: LockDrawingSurface(PRInt32 aX, PRInt32 aY
|
|||
|
||||
if (nsnull != mOrigSolidPen)
|
||||
mCurrPen = (HPEN)::SelectObject(mDC, mOrigSolidPen);
|
||||
|
||||
mContext->GetPaletteInfo(palInfo);
|
||||
if(palInfo.isPaletteDevice && palInfo.palette){
|
||||
::SelectPalette(mDC,(HPALETTE)palInfo.palette,PR_FALSE);
|
||||
::RealizePalette(mDC);
|
||||
::UpdateColors(mDC);
|
||||
}
|
||||
}
|
||||
|
||||
mSurface->ReleaseDC();
|
||||
|
@ -2579,40 +2559,6 @@ NS_IMETHODIMP nsRenderingContextWin :: DrawImage(nsIImage *aImage, const nsRect&
|
|||
}
|
||||
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 3/16/00 dwc
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextWin::DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1,
|
||||
nscoord aWidth,nscoord aHeight)
|
||||
{
|
||||
nscoord orgX,orgY,orgWidth,orgHeight;
|
||||
PRBool didtile = FALSE;
|
||||
|
||||
// convert output platform, but no translation.. just scale
|
||||
orgX = aX0;
|
||||
orgY = aY0;
|
||||
orgWidth = aX1 - aX0;
|
||||
orgHeight = aY1 - aY0;
|
||||
mTranMatrix->TransformCoord(&aX0,&aY0,&aWidth,&aHeight);
|
||||
mTranMatrix->TransformCoord(&orgX,&orgY,&orgWidth,&orgHeight);
|
||||
aX1 = aX0 + orgWidth;
|
||||
aY1 = aY0 + orgHeight;
|
||||
|
||||
if ( PR_TRUE==CanTile(aWidth,aHeight) ) {
|
||||
didtile = ((nsImageWin*)aImage)->PatBltTile(*this,mSurface,aX0,aY0,aX1,aY1,aWidth,aHeight);
|
||||
}
|
||||
|
||||
if (PR_FALSE ==didtile){
|
||||
// rely on the slower tiler supported in nsRenderingContextWin.. don't have
|
||||
// to use xplatform which is really slow (slowest is the only one that supports transparency
|
||||
didtile = ((nsImageWin*)aImage)->DrawTile(*this,mSurface,aX0,aY0,aX1,aY1,aWidth,aHeight);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIRenderingContext.h
|
||||
* @update 3/16/00 dwc
|
||||
|
@ -2682,19 +2628,6 @@ NS_IMETHODIMP nsRenderingContextWin :: CopyOffScreenBits(nsDrawingSurface aSrcSu
|
|||
::DeleteObject(tregion);
|
||||
}
|
||||
|
||||
// If there's a palette make sure it's selected.
|
||||
// XXX This doesn't seem like the best place to be doing this...
|
||||
|
||||
nsPaletteInfo palInfo;
|
||||
|
||||
mContext->GetPaletteInfo(palInfo);
|
||||
|
||||
if (palInfo.isPaletteDevice && palInfo.palette){
|
||||
::SelectPalette(destdc, (HPALETTE)palInfo.palette, PR_FALSE);
|
||||
::RealizePalette(destdc);
|
||||
::UpdateColors(destdc);
|
||||
}
|
||||
|
||||
if (aCopyFlags & NS_COPYBITS_XFORM_SOURCE_VALUES)
|
||||
mTranMatrix->TransformCoord(&x, &y);
|
||||
|
||||
|
|
|
@ -174,10 +174,6 @@ public:
|
|||
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect);
|
||||
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
|
||||
|
||||
NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoord aX1,nscoord aY1,
|
||||
nscoord aWidth,nscoord aHeight);
|
||||
|
||||
|
||||
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
|
||||
const nsRect &aDestBounds, PRUint32 aCopyFlags);
|
||||
//~~~
|
||||
|
|
|
@ -79,7 +79,6 @@ protected:
|
|||
|
||||
private:
|
||||
void CommonInit(void);
|
||||
nsPaletteInfo mPaletteInfo;
|
||||
PRBool mWriteable;
|
||||
PRUint32 mNumCells;
|
||||
nsDrawingSurface mSurface;
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include "nsIDeviceContext.h"
|
||||
#include "nsIDeviceContextSpecXPrint.h"
|
||||
#include "nsString.h"
|
||||
#include "il_util.h"
|
||||
#include "nspr.h"
|
||||
#include "nsXPrintContext.h"
|
||||
|
||||
|
@ -189,53 +188,6 @@ NS_IMETHODIMP nsDeviceContextXp :: GetDrawingSurface(nsIRenderingContext &aConte
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
*/
|
||||
NS_IMETHODIMP nsDeviceContextXp::GetILColorSpace(IL_ColorSpace*& aColorSpace)
|
||||
{
|
||||
#ifdef NOTNOW
|
||||
if (nsnull == mColorSpace) {
|
||||
mColorSpace = IL_CreateGreyScaleColorSpace(1, 1);
|
||||
|
||||
if (nsnull == mColorSpace) {
|
||||
aColorSpace = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the color space
|
||||
aColorSpace = mColorSpace;
|
||||
IL_AddRefToColorSpace(aColorSpace);
|
||||
#endif /* NOTNOW */
|
||||
|
||||
if(!mColorSpace) {
|
||||
IL_RGBBits colorRGBBits;
|
||||
|
||||
// Create a 24-bit color space
|
||||
colorRGBBits.red_shift = 16;
|
||||
colorRGBBits.red_bits = 8;
|
||||
colorRGBBits.green_shift = 8;
|
||||
colorRGBBits.green_bits = 8;
|
||||
colorRGBBits.blue_shift = 0;
|
||||
colorRGBBits.blue_bits = 8;
|
||||
|
||||
mColorSpace = IL_CreateTrueColorSpace(&colorRGBBits, 24);
|
||||
|
||||
if (nsnull == mColorSpace) {
|
||||
aColorSpace = nsnull;
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Return the color space
|
||||
aColorSpace = mColorSpace;
|
||||
IL_AddRefToColorSpace(aColorSpace);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsIDeviceContext.h
|
||||
* @update 12/21/98 dwc
|
||||
|
|
|
@ -62,7 +62,6 @@ public:
|
|||
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
|
||||
|
||||
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
|
||||
NS_IMETHODIMP GetILColorSpace(IL_ColorSpace*& aColorSpace);
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth);
|
||||
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
|
||||
|
||||
|
|
|
@ -21,9 +21,6 @@
|
|||
|
||||
DEPTH=..\..
|
||||
|
||||
|
||||
DIRS = btest
|
||||
|
||||
MAKE_OBJ_TYPE = EXE
|
||||
PROG1 = .\$(OBJDIR)\TestRect.exe
|
||||
PROG2 = .\$(OBJDIR)\TestColorNames.exe
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "nsRect.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIFrameImageLoader.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsIScrollableView.h"
|
||||
|
@ -40,7 +39,8 @@
|
|||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
|
||||
#include "imgIRequest.h"
|
||||
#include "imgIContainer.h"
|
||||
|
||||
#define BORDER_FULL 0 //entire side
|
||||
#define BORDER_INSIDE 1 //inside half
|
||||
|
@ -2149,7 +2149,51 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
nsStyleCoord bordStyleRadius[4];
|
||||
PRInt16 borderRadii[4],i;
|
||||
|
||||
if (0 < aColor.mBackgroundImage.Length()) {
|
||||
|
||||
// if there is no background image, try a color.
|
||||
if (aColor.mBackgroundImage.IsEmpty()) {
|
||||
// See if there's a background color specified. The background color
|
||||
// is rendered over the 'border' 'padding' and 'content' areas
|
||||
if (!transparentBG) {
|
||||
// get the radius for our border
|
||||
aBorder.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
|
||||
aBorder.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
|
||||
aBorder.mBorderRadius.GetBottom(bordStyleRadius[2]); //bottomright
|
||||
aBorder.mBorderRadius.GetLeft(bordStyleRadius[3]); //bottomleft
|
||||
|
||||
for(i=0;i<4;i++) {
|
||||
borderRadii[i] = 0;
|
||||
switch ( bordStyleRadius[i].GetUnit()) {
|
||||
case eStyleUnit_Inherit:
|
||||
break;
|
||||
case eStyleUnit_Percent:
|
||||
percent = bordStyleRadius[i].GetPercentValue();
|
||||
borderRadii[i] = (nscoord)(percent * aBorderArea.width);
|
||||
break;
|
||||
case eStyleUnit_Coord:
|
||||
borderRadii[i] = bordStyleRadius[i].GetCoordValue();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// rounded version of the border
|
||||
for(i=0;i<4;i++){
|
||||
if (borderRadii[i] > 0){
|
||||
PaintRoundedBackground(aPresContext,aRenderingContext,aForFrame,aDirtyRect,
|
||||
aBorderArea,aColor,aDX,aDY,borderRadii);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
aRenderingContext.SetColor(aColor.mBackgroundColor);
|
||||
aRenderingContext.FillRect(aBorderArea);
|
||||
}
|
||||
} else {
|
||||
// we have a background image
|
||||
|
||||
|
||||
// get the frame for the background image load to complete in
|
||||
// - this may be different than the frame we are rendering
|
||||
|
@ -2159,31 +2203,34 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
NS_ASSERTION(pBGFrame, "Background Frame must be set by GetFrameForBackgroundUpdate");
|
||||
|
||||
// Lookup the image
|
||||
nsSize imageSize;
|
||||
nsCOMPtr<nsIImage> image;
|
||||
nsIFrameImageLoader* loader = nsnull;
|
||||
nsresult rv = aPresContext->StartLoadImage(aColor.mBackgroundImage,
|
||||
transparentBG
|
||||
? nsnull
|
||||
: &aColor.mBackgroundColor,
|
||||
nsnull,
|
||||
pBGFrame,
|
||||
nsnull, nsnull,
|
||||
pBGFrame, &loader);
|
||||
if ((NS_OK != rv) || (nsnull == loader) ||
|
||||
(loader->GetImage(getter_AddRefs(image)), (!image))) {
|
||||
NS_IF_RELEASE(loader);
|
||||
// Redraw will happen later
|
||||
if (!transparentBG) {
|
||||
// The background color is rendered over the 'border' 'padding' and
|
||||
// 'content' areas
|
||||
aRenderingContext.SetColor(aColor.mBackgroundColor);
|
||||
aRenderingContext.FillRect(aBorderArea);
|
||||
}
|
||||
nsCOMPtr<imgIRequest> req;
|
||||
nsresult rv = aPresContext->LoadImage(aColor.mBackgroundImage, pBGFrame, getter_AddRefs(req));
|
||||
|
||||
PRUint32 status = imgIRequest::STATUS_ERROR;
|
||||
if (req)
|
||||
req->GetImageStatus(&status);
|
||||
|
||||
if (NS_FAILED(rv) || !req || !(status & imgIRequest::STATUS_SIZE_AVAILABLE)) {
|
||||
// The background color is rendered over the 'border' 'padding' and
|
||||
// 'content' areas
|
||||
aRenderingContext.SetColor(aColor.mBackgroundColor);
|
||||
aRenderingContext.FillRect(aBorderArea);
|
||||
return;
|
||||
}
|
||||
loader->GetSize(imageSize);
|
||||
NS_RELEASE(loader);
|
||||
|
||||
nsSize imageSize;
|
||||
nsCOMPtr<imgIContainer> image;
|
||||
req->GetImage(getter_AddRefs(image));
|
||||
|
||||
image->GetWidth(&imageSize.width);
|
||||
image->GetHeight(&imageSize.height);
|
||||
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
imageSize.width = NSIntPixelsToTwips(imageSize.width, p2t);
|
||||
imageSize.height = NSIntPixelsToTwips(imageSize.height, p2t);
|
||||
|
||||
req = nsnull;
|
||||
|
||||
// Background images are tiled over the 'content' and 'padding' areas
|
||||
// only (not the 'border' area)
|
||||
|
@ -2489,166 +2536,22 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
y1 = y0 + tileHeight;
|
||||
}
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
||||
// Take the intersection again to paint only the required area
|
||||
nsRect tileRect(x0,y0,(x1-x0),(y1-y0));
|
||||
nsRect drawRect;
|
||||
if (drawRect.IntersectRect(tileRect, dirtyRect)) {
|
||||
PRInt32 xOffset = drawRect.x - x0,
|
||||
yOffset = drawRect.y - y0;
|
||||
aRenderingContext.DrawTile(image,xOffset,yOffset,drawRect);
|
||||
aRenderingContext.DrawTile(image,xOffset,yOffset,&drawRect);
|
||||
}
|
||||
#else
|
||||
aRenderingContext.DrawTile(image,x0,y0,x1,y1,tileWidth,tileHeight);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef DOTILE
|
||||
nsIDrawingSurface *theSurface,*ts=nsnull;
|
||||
nsRect srcRect,destRect,vrect,tvrect;
|
||||
nscoord x,y;
|
||||
PRInt32 flag = NS_COPYBITS_TO_BACK_BUFFER | NS_COPYBITS_XFORM_DEST_VALUES;
|
||||
PRUint32 dsFlag = NS_CREATEDRAWINGSURFACE_SHORTLIVED;
|
||||
float t2p,app2dev;
|
||||
PRBool clip,hasMask;
|
||||
nsTransform2D *theTransform;
|
||||
nsIDeviceContext *theDevContext;
|
||||
|
||||
|
||||
aRenderingContext.GetDrawingSurface((void**)&theSurface);
|
||||
aPresContext->GetVisibleArea(srcRect);
|
||||
tvrect.SetRect(0,0,x1-x0,y1-y0);
|
||||
aPresContext->GetTwipsToPixels(&t2p);
|
||||
|
||||
// check to see if the background image has a mask
|
||||
hasMask = image->GetHasAlphaMask();
|
||||
|
||||
if(!hasMask && ((tileWidth<(tvrect.width/16)) || (tileHeight<(tvrect.height/16)))) {
|
||||
//tvrect.width /=4;
|
||||
//tvrect.height /=4;
|
||||
|
||||
tvrect.width = ((tvrect.width)/tileWidth); //total x number of tiles
|
||||
tvrect.width *=tileWidth;
|
||||
|
||||
tvrect.height = ((tvrect.height)/tileHeight); //total y number of tiles
|
||||
tvrect.height *=tileHeight;
|
||||
|
||||
// create a new drawing surface... using pixels as the size
|
||||
vrect.height = (nscoord)(tvrect.height * t2p);
|
||||
vrect.width = (nscoord)(tvrect.width * t2p);
|
||||
aRenderingContext.CreateDrawingSurface(&vrect,dsFlag,(nsDrawingSurface&)ts);
|
||||
}
|
||||
|
||||
// did we need to create an offscreen drawing surface because the image was so small
|
||||
if(!hasMask && (nsnull != ts) ) {
|
||||
aRenderingContext.SelectOffScreenDrawingSurface(ts);
|
||||
|
||||
// create a bigger tile in our new drawingsurface
|
||||
// XXX pushing state to fix clipping problem, need to look into why the clip is set here
|
||||
aRenderingContext.PushState();
|
||||
aRenderingContext.GetCurrentTransform(theTransform);
|
||||
aRenderingContext.GetDeviceContext(theDevContext);
|
||||
theDevContext->GetAppUnitsToDevUnits(app2dev);
|
||||
NS_RELEASE(theDevContext);
|
||||
theTransform->SetToIdentity();
|
||||
theTransform->AddScale(app2dev, app2dev);
|
||||
|
||||
// XXX this #ifdef needs to go away when we are sure that this works on windows and mac
|
||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
||||
srcRect.SetRect(0,0,tvrect.width,tvrect.height);
|
||||
aRenderingContext.SetClipRect(srcRect, nsClipCombine_kReplace, clip);
|
||||
#endif
|
||||
|
||||
// copy the initial image to our buffer, this takes twips and converts to pixels..
|
||||
// which is what the image is in
|
||||
aRenderingContext.DrawImage(image,0,0,tileWidth,tileHeight);
|
||||
|
||||
// duplicate the image in the upperleft corner to fill up the nsDrawingSurface
|
||||
srcRect.SetRect(0,0,tileWidth,tileHeight);
|
||||
TileImage(aRenderingContext,ts,srcRect,tvrect.width,tvrect.height);
|
||||
|
||||
// setting back the clip from the background clip push
|
||||
aRenderingContext.PopState(clip);
|
||||
|
||||
// set back to the old drawingsurface
|
||||
aRenderingContext.SelectOffScreenDrawingSurface((void**)theSurface);
|
||||
|
||||
// now duplicate our tile into the background
|
||||
destRect = srcRect;
|
||||
for(y=y0;y<y1;y+=tvrect.height){
|
||||
for(x=x0;x<x1;x+=tvrect.width){
|
||||
destRect.x = x;
|
||||
destRect.y = y;
|
||||
aRenderingContext.CopyOffScreenBits(ts,0,0,destRect,flag);
|
||||
}
|
||||
}
|
||||
|
||||
aRenderingContext.DestroyDrawingSurface(ts);
|
||||
} else {
|
||||
// slow blitting, one tile at a time....
|
||||
for(y=y0;y<y1;y+=tileHeight){
|
||||
for(x=x0;x<x1;x+=tileWidth){
|
||||
aRenderingContext.DrawImage(image,x,y,tileWidth,tileHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//#define NOTNOW
|
||||
#ifdef NOTNOW
|
||||
nscoord x,y;
|
||||
for(y=y0;y<y1;y+=tileHeight){
|
||||
for(x=x0;x<x1;x+=tileWidth){
|
||||
aRenderingContext.DrawImage(image,x,y,tileWidth,tileHeight);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(XP_UNIX) && !defined(XP_BEOS)
|
||||
// Restore clipping
|
||||
aRenderingContext.PopState(clipState);
|
||||
#endif
|
||||
} else {
|
||||
// See if there's a background color specified. The background color
|
||||
// is rendered over the 'border' 'padding' and 'content' areas
|
||||
if (!transparentBG) {
|
||||
// get the radius for our border
|
||||
aBorder.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
|
||||
aBorder.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
|
||||
aBorder.mBorderRadius.GetBottom(bordStyleRadius[2]); //bottomright
|
||||
aBorder.mBorderRadius.GetLeft(bordStyleRadius[3]); //bottomleft
|
||||
|
||||
for(i=0;i<4;i++) {
|
||||
borderRadii[i] = 0;
|
||||
switch ( bordStyleRadius[i].GetUnit()) {
|
||||
case eStyleUnit_Inherit:
|
||||
break;
|
||||
case eStyleUnit_Percent:
|
||||
percent = bordStyleRadius[i].GetPercentValue();
|
||||
borderRadii[i] = (nscoord)(percent * aBorderArea.width);
|
||||
break;
|
||||
case eStyleUnit_Coord:
|
||||
borderRadii[i] = bordStyleRadius[i].GetCoordValue();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// rounded version of the border
|
||||
for(i=0;i<4;i++){
|
||||
if (borderRadii[i] > 0){
|
||||
PaintRoundedBackground(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,aColor,aDX,aDY,borderRadii);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
aRenderingContext.SetColor(aColor.mBackgroundColor);
|
||||
aRenderingContext.FillRect(aBorderArea);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
|
|
@ -31,9 +31,6 @@
|
|||
#include "nsIDocumentViewer.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
|
||||
#include "nsIImageGroup.h"
|
||||
#include "nsIImageObserver.h"
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
|
@ -363,8 +360,7 @@ private:
|
|||
class DocumentViewerImpl : public nsIDocumentViewer,
|
||||
public nsIContentViewerEdit,
|
||||
public nsIContentViewerFile,
|
||||
public nsIMarkupDocumentViewer,
|
||||
public nsIImageGroupObserver
|
||||
public nsIMarkupDocumentViewer
|
||||
{
|
||||
friend class nsDocViewerSelectionListener;
|
||||
|
||||
|
@ -402,10 +398,6 @@ public:
|
|||
void* aClosure);
|
||||
nsresult CallChildren(CallChildFunc aFunc, void* aClosure);
|
||||
|
||||
// nsIImageGroupObserver interface
|
||||
virtual void Notify(nsIImageGroup *aImageGroup,
|
||||
nsImageGroupNotification aNotificationType);
|
||||
|
||||
// Printing Methods
|
||||
PRBool PrintPage(nsIPresContext* aPresContext,nsIPrintOptions* aPrintOptions,PrintObject* aPOect);
|
||||
PRBool DonePrintingPages(PrintObject* aPO);
|
||||
|
@ -844,12 +836,6 @@ DocumentViewerImpl::~DocumentViewerImpl()
|
|||
if (mPresContext) {
|
||||
mPresContext->SetContainer(nsnull);
|
||||
mPresContext->SetLinkHandler(nsnull);
|
||||
// XXX This is only needed because bg images have not been
|
||||
// converted to the new image lib. Once pav does this, we
|
||||
// can just remove this code. Right now it is only here
|
||||
// for background images.
|
||||
// stop everything but the chrome.
|
||||
mPresContext->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1235,15 +1221,6 @@ DocumentViewerImpl::Stop(void)
|
|||
if (!mLoaded && mPresShell) {
|
||||
// Well, we might as well paint what we have so far.
|
||||
mPresShell->UnsuppressPainting();
|
||||
|
||||
if (mPresContext) {
|
||||
// XXX This is only needed because bg images have not been
|
||||
// converted to the new image lib. Once pav does this, we
|
||||
// can just remove this code. Right now it is only here
|
||||
// for background images.
|
||||
// stop everything but the chrome.
|
||||
mPresContext->Stop(PR_FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -3684,58 +3661,6 @@ DocumentViewerImpl::PrintDocContent(PrintObject* aPO, nsresult& aStatus)
|
|||
return PR_FALSE;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------
|
||||
void DocumentViewerImpl::Notify(nsIImageGroup *aImageGroup,
|
||||
nsImageGroupNotification aNotificationType)
|
||||
{
|
||||
//
|
||||
// Image are being loaded... Set the flag to delay printing until
|
||||
// all images are loaded.
|
||||
//
|
||||
if (aNotificationType == nsImageGroupNotification_kStartedLoading) {
|
||||
mIsPrinting = PR_TRUE;
|
||||
}
|
||||
//
|
||||
// All the images have been loaded, so the document is ready to print.
|
||||
//
|
||||
// However, at this point we are unable to release the resources that
|
||||
// were allocated for printing... This is because ImgLib resources will
|
||||
// be deleted and *this* is an ImgLib notification routine. So, fire an
|
||||
// event to do the actual printing.
|
||||
//
|
||||
else if(aNotificationType == nsImageGroupNotification_kFinishedLoading) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIEventQueue> eventQ;
|
||||
|
||||
// Get the event queue of the current thread...
|
||||
nsCOMPtr<nsIEventQueueService> eventQService =
|
||||
do_GetService(kEventQueueService, &rv);
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD,
|
||||
getter_AddRefs(eventQ));
|
||||
if (NS_FAILED(rv)) return;
|
||||
|
||||
PRStatus status;
|
||||
PLEvent *event = new PLEvent;
|
||||
|
||||
if (!event) return;
|
||||
|
||||
//
|
||||
// AddRef this because it is being placed in the PLEvent struct.
|
||||
// It will be Released when DestroyPLEvent is called...
|
||||
//
|
||||
NS_ADDREF_THIS();
|
||||
PL_InitEvent(event,
|
||||
this,
|
||||
(PLHandleEventProc) DocumentViewerImpl::HandlePLEvent,
|
||||
(PLDestroyEventProc) DocumentViewerImpl::DestroyPLEvent);
|
||||
|
||||
status = eventQ->PostEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
DocumentViewerImpl::SetEnableRendering(PRBool aOn)
|
||||
{
|
||||
|
@ -3992,15 +3917,6 @@ nsresult DocumentViewerImpl::DocumentReadyForPrinting()
|
|||
|
||||
webContainer = do_QueryInterface(mContainer);
|
||||
if(webContainer) {
|
||||
//
|
||||
// Remove ourselves as an image group observer...
|
||||
//
|
||||
nsCOMPtr<nsIImageGroup> imageGroup;
|
||||
mPrt->mPrintPC->GetImageGroup(getter_AddRefs(imageGroup));
|
||||
if (imageGroup) {
|
||||
imageGroup->RemoveObserver(this);
|
||||
}
|
||||
|
||||
//
|
||||
// Send the document to the printer...
|
||||
//
|
||||
|
@ -4530,12 +4446,6 @@ nsresult rv;
|
|||
mPrt->mPrintVM->SetRootView(mPrt->mPrintView);
|
||||
mPrt->mPrintPS->Init(mDocument,mPrt->mPrintPC,mPrt->mPrintVM,mPrt->mPrintSS);
|
||||
|
||||
nsCOMPtr<nsIImageGroup> imageGroup;
|
||||
mPrt->mPrintPC->GetImageGroup(getter_AddRefs(imageGroup));
|
||||
if (imageGroup) {
|
||||
imageGroup->AddObserver(this);
|
||||
}
|
||||
|
||||
mPrt->mPrintPS->InitialReflow(width,height);
|
||||
|
||||
#ifdef DEBUG_dcone
|
||||
|
|
|
@ -1696,7 +1696,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext,
|
|||
if(oldColor->mBackgroundImage.Length() > 0 &&
|
||||
oldColor->mBackgroundImage != newColor->mBackgroundImage ){
|
||||
// stop the image loading for the frame, the image has changed
|
||||
aPresContext->StopAllLoadImagesFor(aFrame, aFrame);
|
||||
aPresContext->StopImagesFor(aFrame);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1911,7 +1911,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext,
|
|||
if(oldColor.mBackgroundImage.Length() > 0 &&
|
||||
oldColor.mBackgroundImage != newColor.mBackgroundImage ){
|
||||
// stop the image loading for the frame, the image has changed
|
||||
aPresContext->StopAllLoadImagesFor(aFrame, aFrame);
|
||||
aPresContext->StopImagesFor(aFrame);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -0,0 +1,259 @@
|
|||
/* -*- 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 "nsImageLoader.h"
|
||||
|
||||
#include "imgILoader.h"
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
#include "nsIHTMLContent.h"
|
||||
|
||||
#include "nsIViewManager.h"
|
||||
|
||||
#include "nsIStyleContext.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsImageLoader, imgIDecoderObserver, imgIContainerObserver)
|
||||
|
||||
nsImageLoader::nsImageLoader() :
|
||||
mFrame(nsnull), mPresContext(nsnull)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsImageLoader::~nsImageLoader()
|
||||
{
|
||||
mFrame = nsnull;
|
||||
mPresContext = nsnull;
|
||||
|
||||
if (mRequest) {
|
||||
mRequest->Cancel(NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsImageLoader::Init(nsIFrame *aFrame, nsIPresContext *aPresContext)
|
||||
{
|
||||
mFrame = aFrame;
|
||||
mPresContext = aPresContext;
|
||||
}
|
||||
|
||||
void
|
||||
nsImageLoader::Destroy()
|
||||
{
|
||||
mFrame = nsnull;
|
||||
mPresContext = nsnull;
|
||||
|
||||
if (mRequest) {
|
||||
mRequest->Cancel(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
mRequest = nsnull;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsImageLoader::Load(const nsAReadableString &aURI)
|
||||
{
|
||||
if (!mFrame)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = mPresContext->GetShell(getter_AddRefs(shell));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
rv = shell->GetDocument(getter_AddRefs(doc));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Get the document's loadgroup
|
||||
doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
|
||||
doc->GetBaseURL(*getter_AddRefs(baseURI));
|
||||
|
||||
NS_NewURI(getter_AddRefs(uri), aURI, baseURI);
|
||||
|
||||
if (mRequest) {
|
||||
nsCOMPtr<nsIURI> oldURI;
|
||||
mRequest->GetURI(getter_AddRefs(oldURI));
|
||||
PRBool eq = PR_FALSE;
|
||||
uri->Equals(oldURI, &eq);
|
||||
if (eq) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return il->LoadImage(uri, loadGroup, NS_STATIC_CAST(imgIDecoderObserver *, this),
|
||||
nsnull, nsIRequest::LOAD_BACKGROUND, getter_AddRefs(mRequest));
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::OnStartDecode(imgIRequest *aRequest, nsISupports *aContext)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::OnStartContainer(imgIRequest *aRequest, nsISupports *aContext, imgIContainer *aImage)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::OnStartFrame(imgIRequest *aRequest, nsISupports *aContext, gfxIImageFrame *aFrame)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::OnDataAvailable(imgIRequest *aRequest, nsISupports *aContext, gfxIImageFrame *aFrame, const nsRect *aRect)
|
||||
{
|
||||
if (!mFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsRect r(*aRect);
|
||||
|
||||
float p2t;
|
||||
mPresContext->GetPixelsToTwips(&p2t);
|
||||
r.x = NSIntPixelsToTwips(r.x, p2t);
|
||||
r.y = NSIntPixelsToTwips(r.y, p2t);
|
||||
r.width = NSIntPixelsToTwips(r.width, p2t);
|
||||
r.height = NSIntPixelsToTwips(r.height, p2t);
|
||||
|
||||
RedrawDirtyFrame(&r);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::OnStopFrame(imgIRequest *aRequest, nsISupports *aContext, gfxIImageFrame *aFrame)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::OnStopContainer(imgIRequest *aRequest, nsISupports *aContext, imgIContainer *aImage)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::OnStopDecode(imgIRequest *aRequest, nsISupports *aContext, nsresult status, const PRUnichar *statusArg)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::FrameChanged(imgIContainer *aContainer, nsISupports *aContext, gfxIImageFrame *newframe, nsRect * dirtyRect)
|
||||
{
|
||||
if (!mFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsRect r(*dirtyRect);
|
||||
|
||||
float p2t;
|
||||
mPresContext->GetPixelsToTwips(&p2t);
|
||||
r.x = NSIntPixelsToTwips(r.x, p2t);
|
||||
r.y = NSIntPixelsToTwips(r.y, p2t);
|
||||
r.width = NSIntPixelsToTwips(r.width, p2t);
|
||||
r.height = NSIntPixelsToTwips(r.height, p2t);
|
||||
|
||||
RedrawDirtyFrame(&r);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsImageLoader::RedrawDirtyFrame(const nsRect* aDamageRect)
|
||||
{
|
||||
// Determine damaged area and tell view manager to redraw it
|
||||
nsPoint offset;
|
||||
nsRect bounds;
|
||||
nsIView* view;
|
||||
|
||||
// NOTE: It is not sufficient to invalidate only the size of the image:
|
||||
// the image may be tiled!
|
||||
// The best option is to call into the frame, however lacking this
|
||||
// we have to at least invalidate the frame's bounds, hence
|
||||
// as long as we have a frame we'll use its size.
|
||||
//
|
||||
|
||||
// Invalidate the entire frame
|
||||
// XXX We really only need to invalidate the client area of the frame...
|
||||
mFrame->GetRect(bounds);
|
||||
bounds.x = bounds.y = 0;
|
||||
|
||||
// XXX this should be ok, but there is some crappy ass bug causing it not to work
|
||||
// XXX seems related to the "body fixup rule" dealing with the canvas and body frames...
|
||||
#if 0
|
||||
// Invalidate the entire frame only if the frame has a tiled background
|
||||
// image, otherwise just invalidate the intersection of the frame's bounds
|
||||
// with the damaged rect.
|
||||
nsCOMPtr<nsIStyleContext> styleContext;
|
||||
mFrame->GetStyleContext(getter_AddRefs(styleContext));
|
||||
const nsStyleBackground* bg = (const nsStyleBackground*)styleContext->GetStyleData(eStyleStruct_Background);
|
||||
|
||||
if ((bg->mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE) ||
|
||||
(bg->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT) ||
|
||||
(bg->mBackgroundRepeat == NS_STYLE_BG_REPEAT_OFF)) {
|
||||
// The frame does not have a background image so we are free
|
||||
// to invalidate only the intersection of the damage rect and
|
||||
// the frame's bounds.
|
||||
|
||||
if (aDamageRect) {
|
||||
bounds.IntersectRect(*aDamageRect, bounds);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
if ((bounds.width > 0) && (bounds.height > 0)) {
|
||||
|
||||
// XXX We should tell the frame the damage area and let it invalidate
|
||||
// itself. Add some API calls to nsIFrame to allow a caller to invalidate
|
||||
// parts of the frame...
|
||||
mFrame->GetView(mPresContext, &view);
|
||||
if (!view) {
|
||||
mFrame->GetOffsetFromView(mPresContext, offset, &view);
|
||||
bounds.x += offset.x;
|
||||
bounds.y += offset.y;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIViewManager> vm = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
rv = view->GetViewManager(*getter_AddRefs(vm));
|
||||
if (NS_SUCCEEDED(rv) && vm) {
|
||||
vm->UpdateView(view, bounds, NS_VMREFRESH_NO_SYNC);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/* -*- 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 "imgIDecoderObserver.h"
|
||||
|
||||
class nsIPresContext;
|
||||
class nsIFrame;
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
#include "imgIRequest.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsImageLoader : public imgIDecoderObserver
|
||||
{
|
||||
public:
|
||||
nsImageLoader();
|
||||
virtual ~nsImageLoader();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_IMGIDECODEROBSERVER
|
||||
NS_DECL_IMGICONTAINEROBSERVER
|
||||
|
||||
void Init(nsIFrame *aFrame, nsIPresContext *aPresContext);
|
||||
nsresult Load(const nsAReadableString &aURI);
|
||||
|
||||
void Destroy();
|
||||
|
||||
nsIFrame *GetFrame() { return mFrame; }
|
||||
void GetRequest(imgIRequest **aRequest) { *aRequest = mRequest; NS_IF_ADDREF(*aRequest); }
|
||||
|
||||
private:
|
||||
void RedrawDirtyFrame(const nsRect* aDamageRect);
|
||||
|
||||
private:
|
||||
nsIFrame *mFrame;
|
||||
nsIPresContext *mPresContext;
|
||||
nsCOMPtr<imgIRequest> mRequest;
|
||||
};
|
|
@ -27,9 +27,8 @@
|
|||
#include "nsILinkHandler.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIStyleSet.h"
|
||||
#include "nsFrameImageLoader.h"
|
||||
#include "nsIFrameManager.h"
|
||||
#include "nsIImageGroup.h"
|
||||
#include "nsImageLoader.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
|
@ -96,6 +95,15 @@ IsVisualCharset(const nsAutoString& aCharset)
|
|||
}
|
||||
#endif // IBMBIDI
|
||||
|
||||
|
||||
static PRBool destroy_loads(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
nsISupports *sup = NS_REINTERPRET_CAST(nsISupports*, aData);
|
||||
nsImageLoader *loader = NS_REINTERPRET_CAST(nsImageLoader*, sup);
|
||||
loader->Destroy();
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
#include "nsContentCID.h"
|
||||
static NS_DEFINE_CID(kEventStateManagerCID, NS_EVENTSTATEMANAGER_CID);
|
||||
|
@ -121,7 +129,7 @@ nsPresContext::nsPresContext()
|
|||
|
||||
mStopped = PR_FALSE;
|
||||
mStopChrome = PR_TRUE;
|
||||
|
||||
|
||||
mShell = nsnull;
|
||||
|
||||
mDefaultColor = NS_RGB(0x00, 0x00, 0x00);
|
||||
|
@ -161,6 +169,8 @@ nsPresContext::nsPresContext()
|
|||
|
||||
nsPresContext::~nsPresContext()
|
||||
{
|
||||
mImageLoaders.Enumerate(destroy_loads);
|
||||
|
||||
if (mShell) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
mShell->GetDocument(getter_AddRefs(doc));
|
||||
|
@ -171,14 +181,6 @@ nsPresContext::~nsPresContext()
|
|||
|
||||
mShell = nsnull;
|
||||
|
||||
Stop();
|
||||
|
||||
if (mImageGroup) {
|
||||
// Interrupt any loading images. This also stops all looping
|
||||
// image animations.
|
||||
mImageGroup->Interrupt();
|
||||
}
|
||||
|
||||
if (mEventManager)
|
||||
mEventManager->SetPresContext(nsnull); // unclear if this is needed, but can't hurt
|
||||
|
||||
|
@ -1168,60 +1170,30 @@ nsPresContext::GetDeviceContext(nsIDeviceContext** aResult) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetImageGroup(nsIImageGroup** aResult)
|
||||
nsPresContext::LoadImage(const nsString& aURL,
|
||||
nsIFrame* aTargetFrame,
|
||||
imgIRequest **aRequest)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
||||
if (nsnull == aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
// look and see if we have a loader for the target frame.
|
||||
|
||||
if (!mImageGroup) {
|
||||
// Create image group
|
||||
nsresult rv = NS_NewImageGroup(getter_AddRefs(mImageGroup));
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
nsVoidKey key(aTargetFrame);
|
||||
nsImageLoader *loader = NS_REINTERPRET_CAST(nsImageLoader*, mImageLoaders.Get(&key)); // addrefs
|
||||
|
||||
// Initialize the image group
|
||||
nsCOMPtr<nsIURIContentListener> loadHandler (do_GetInterface(mContainer, &rv));
|
||||
if (NS_SUCCEEDED(rv) && loadHandler)
|
||||
{
|
||||
nsCOMPtr<nsISupports> loadContext;
|
||||
loadHandler->GetLoadCookie(getter_AddRefs(loadContext));
|
||||
rv = mImageGroup->Init(mDeviceContext, loadContext);
|
||||
}
|
||||
if (!loader) {
|
||||
nsImageLoader *newLoader = new nsImageLoader();
|
||||
if (!newLoader)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
NS_ADDREF(newLoader); // new
|
||||
|
||||
*aResult = mImageGroup;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
newLoader->QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(sup));
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::StartLoadImage(const nsString& aURL,
|
||||
const nscolor* aBackgroundColor,
|
||||
const nsSize* aDesiredSize,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsIFrameImageLoaderCB aCallBack,
|
||||
void* aClosure,
|
||||
void* aKey,
|
||||
nsIFrameImageLoader** aResult)
|
||||
{
|
||||
if (mStopped) {
|
||||
// if we are stopped and the image is not chrome
|
||||
// don't load.
|
||||
// If we are chrome don't load if we
|
||||
// were told to stop chrome
|
||||
if (!aURL.EqualsWithConversion("chrome:", PR_TRUE, 7) || mStopChrome) {
|
||||
if (aResult) {
|
||||
*aResult = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
loader = NS_REINTERPRET_CAST(nsImageLoader*, sup.get());
|
||||
|
||||
loader->Init(aTargetFrame, this);
|
||||
|
||||
mImageLoaders.Put(&key, sup);
|
||||
}
|
||||
|
||||
// Allow for a null target frame argument (for precached images)
|
||||
|
@ -1233,173 +1205,32 @@ nsPresContext::StartLoadImage(const nsString& aURL,
|
|||
aTargetFrame->SetFrameState(state);
|
||||
}
|
||||
|
||||
// Lookup image request in our loaders array (maybe the load request
|
||||
// has already been made for that url at the desired size).
|
||||
PRInt32 i, n = mImageLoaders.Count();
|
||||
nsIFrameImageLoader* loader;
|
||||
for (i = 0; i < n; i++) {
|
||||
PRBool same;
|
||||
loader = (nsIFrameImageLoader*) mImageLoaders.ElementAt(i);
|
||||
loader->IsSameImageRequest(aURL, aBackgroundColor, aDesiredSize, &same);
|
||||
if (same) {
|
||||
// This is pretty sick, but because we can get a notification
|
||||
// *before* the caller has returned we have to store into
|
||||
// aResult before calling the AddFrame method.
|
||||
if (aResult) {
|
||||
NS_ADDREF(loader);
|
||||
*aResult = loader;
|
||||
}
|
||||
loader->Load(aURL);
|
||||
|
||||
// Add frame to list of interested frames for this loader
|
||||
loader->AddFrame(aTargetFrame, aCallBack, aClosure, aKey);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Check with the content-policy things to make sure this load is permitted.
|
||||
PRBool shouldLoad = PR_TRUE; // default permit
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
if (aTargetFrame &&
|
||||
NS_SUCCEEDED(aTargetFrame->GetContent(getter_AddRefs(content)))) {
|
||||
element = do_QueryInterface(content);
|
||||
}
|
||||
loader->GetRequest(aRequest);
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION(0, "was expecting a URI");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
rv = mShell->GetDocument(getter_AddRefs(document));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_RELEASE(loader);
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalScript;
|
||||
rv = document->GetScriptGlobalObject(getter_AddRefs(globalScript));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWin(do_QueryInterface(globalScript));
|
||||
|
||||
if (NS_SUCCEEDED(NS_CheckContentLoadPolicy(nsIContentPolicy::IMAGE,
|
||||
uri, element, domWin, &shouldLoad))
|
||||
&& !shouldLoad) {
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::StopImagesFor(nsIFrame* aTargetFrame)
|
||||
{
|
||||
nsVoidKey key(aTargetFrame);
|
||||
nsImageLoader *loader = NS_REINTERPRET_CAST(nsImageLoader*, mImageLoaders.Get(&key)); // addrefs
|
||||
|
||||
// Create image group if needed
|
||||
if (!mImageGroup) {
|
||||
nsCOMPtr<nsIImageGroup> group;
|
||||
rv = GetImageGroup(getter_AddRefs(group)); // sets mImageGroup as side effect
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// We haven't seen that image before. Create a new loader and
|
||||
// start it going.
|
||||
rv = NS_NewFrameImageLoader(&loader);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
mImageLoaders.AppendElement(loader);
|
||||
|
||||
// This is pretty sick, but because we can get a notification
|
||||
// *before* the caller has returned we have to store into aResult
|
||||
// before calling the loaders init method.
|
||||
if (aResult) {
|
||||
*aResult = loader;
|
||||
NS_ADDREF(loader);
|
||||
}
|
||||
|
||||
rv = loader->Init(this, mImageGroup, aURL, aBackgroundColor, aDesiredSize,
|
||||
aTargetFrame, mImageAnimationMode, aCallBack, aClosure,
|
||||
aKey);
|
||||
if (NS_OK != rv) {
|
||||
mImageLoaders.RemoveElement(loader);
|
||||
loader->StopImageLoad();
|
||||
if (loader) {
|
||||
loader->Destroy();
|
||||
NS_RELEASE(loader);
|
||||
|
||||
// Undo premature store of reslut
|
||||
if (aResult) {
|
||||
*aResult = nsnull;
|
||||
NS_RELEASE(loader);
|
||||
}
|
||||
return rv;
|
||||
mImageLoaders.Remove(&key);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::Stop(PRBool aStopChrome)
|
||||
{
|
||||
mStopChrome = aStopChrome;
|
||||
PRInt32 n = mImageLoaders.Count();
|
||||
for (PRInt32 i = n-1; i >= 0; i--) {
|
||||
nsIFrameImageLoader* loader;
|
||||
loader = (nsIFrameImageLoader*) mImageLoaders.ElementAt(i);
|
||||
if (NS_SUCCEEDED(loader->StopImageLoad(aStopChrome))) {
|
||||
mImageLoaders.RemoveElementAt(i);
|
||||
NS_RELEASE(loader);
|
||||
}
|
||||
}
|
||||
|
||||
mStopped = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::StopLoadImage(void* aKey, nsIFrameImageLoader* aLoader)
|
||||
{
|
||||
PRInt32 i, n = mImageLoaders.Count();
|
||||
nsIFrameImageLoader* loader;
|
||||
for (i = 0; i < n; i++) {
|
||||
loader = (nsIFrameImageLoader*) mImageLoaders.ElementAt(i);
|
||||
if (loader == aLoader) {
|
||||
// Remove frame from list of interested frames for this loader
|
||||
loader->RemoveFrame(aKey);
|
||||
|
||||
// If loader is no longer loading for anybody and its safe to
|
||||
// nuke it, nuke it.
|
||||
PRBool safe;
|
||||
loader->SafeToDestroy(&safe);
|
||||
if (safe) {
|
||||
loader->StopImageLoad();
|
||||
NS_RELEASE(loader);
|
||||
mImageLoaders.RemoveElementAt(i);
|
||||
n--;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::StopAllLoadImagesFor(nsIFrame* aTargetFrame, void *aKey)
|
||||
{
|
||||
nsFrameState state;
|
||||
aTargetFrame->GetFrameState(&state);
|
||||
if (NS_FRAME_HAS_LOADED_IMAGES & state) {
|
||||
nsIFrameImageLoader* loader;
|
||||
PRInt32 i, n = mImageLoaders.Count();
|
||||
for (i = 0; i < n; i++) {
|
||||
PRBool safe;
|
||||
loader = (nsIFrameImageLoader*) mImageLoaders.ElementAt(i);
|
||||
loader->RemoveFrame(aKey);
|
||||
loader->SafeToDestroy(&safe);
|
||||
if (safe) {
|
||||
loader->StopImageLoad();
|
||||
NS_RELEASE(loader);
|
||||
mImageLoaders.RemoveElementAt(i);
|
||||
n--;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::SetLinkHandler(nsILinkHandler* aHandler)
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsIFrameImageLoader.h"
|
||||
#include "nsAWritableString.h"
|
||||
#ifdef IBMBIDI
|
||||
class nsBidiPresUtils;
|
||||
|
@ -36,13 +35,14 @@ class nsBidiPresUtils;
|
|||
struct nsFont;
|
||||
struct nsRect;
|
||||
|
||||
class imgIRequest;
|
||||
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIDeviceContext;
|
||||
class nsIFontMetrics;
|
||||
class nsIFrame;
|
||||
class nsIImage;
|
||||
class nsIImageGroup;
|
||||
class nsILinkHandler;
|
||||
class nsIPresShell;
|
||||
class nsIPref;
|
||||
|
@ -88,6 +88,13 @@ enum nsLanguageSpecificTransformType {
|
|||
eLanguageSpecificTransformType_Korean
|
||||
};
|
||||
|
||||
|
||||
enum nsImageAnimation {
|
||||
eImageAnimation_Normal = 0, // looping controlled by image
|
||||
eImageAnimation_None = 1, // don't loop; just show first frame
|
||||
eImageAnimation_LoopOnce = 2 // loop just once
|
||||
};
|
||||
|
||||
// supported values for cached bool types
|
||||
const PRUint32 kPresContext_UseDocumentColors = 0x01;
|
||||
const PRUint32 kPresContext_UseDocumentFonts = 0x02;
|
||||
|
@ -104,12 +111,6 @@ public:
|
|||
*/
|
||||
NS_IMETHOD Init(nsIDeviceContext* aDeviceContext) = 0;
|
||||
|
||||
/**
|
||||
* Stop the presentation in preperation for destruction.
|
||||
* @param aStopChrome PR_TRUE to stop chrome as well.
|
||||
*/
|
||||
NS_IMETHOD Stop(PRBool aStopChrome = PR_TRUE) = 0;
|
||||
|
||||
/**
|
||||
* Set the presentation shell that this context is bound to.
|
||||
* A presentation context may only be bound to a single shell.
|
||||
|
@ -277,42 +278,22 @@ public:
|
|||
NS_IMETHOD SetDefaultLinkColor(nscolor aColor) = 0;
|
||||
NS_IMETHOD SetDefaultVisitedLinkColor(nscolor aColor) = 0;
|
||||
|
||||
NS_IMETHOD GetImageGroup(nsIImageGroup** aGroupResult) = 0;
|
||||
|
||||
/**
|
||||
* Load an image for the target frame. This call can be made
|
||||
* repeated with only a single image ever being loaded. If
|
||||
* aNeedSizeUpdate is PR_TRUE, then when the image's size is
|
||||
* determined the target frame will be reflowed (via a
|
||||
* ContentChanged notification on the presentation shell). When the
|
||||
* repeated with only a single image ever being loaded. When the
|
||||
* image's data is ready for rendering the target frame's Paint()
|
||||
* method will be invoked (via the ViewManager) so that the
|
||||
* appropriate damage repair is done.
|
||||
*
|
||||
* @param aBackgroundColor - If the background color is NULL, a mask
|
||||
* will be generated for transparent images. If the background
|
||||
* color is non-NULL, it indicates the RGB value to be folded
|
||||
* into the transparent areas of the image and no mask is created.
|
||||
*/
|
||||
NS_IMETHOD StartLoadImage(const nsString& aURL,
|
||||
const nscolor* aBackgroundColor,
|
||||
const nsSize* aDesiredSize,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsIFrameImageLoaderCB aCallBack,
|
||||
void* aClosure,
|
||||
void* aKey,
|
||||
nsIFrameImageLoader** aResult) = 0;
|
||||
NS_IMETHOD LoadImage(const nsString& aURL,
|
||||
nsIFrame* aTargetFrame,
|
||||
imgIRequest **aRequest) = 0;
|
||||
|
||||
/**
|
||||
* Stop a specific image load being done on behalf of the argument frame.
|
||||
* This method is called when a frame is being destroyed to
|
||||
* ensure that the image load gets disassociated from the prescontext
|
||||
*/
|
||||
NS_IMETHOD StopLoadImage(void* aKey,
|
||||
nsIFrameImageLoader* aLoader) = 0;
|
||||
|
||||
/**
|
||||
* Stop any image loading being done on behalf of the argument frame.
|
||||
*/
|
||||
NS_IMETHOD StopAllLoadImagesFor(nsIFrame* aTargetFrame, void* aKey) = 0;
|
||||
NS_IMETHOD StopImagesFor(nsIFrame* aTargetFrame) = 0;
|
||||
|
||||
NS_IMETHOD SetContainer(nsISupports* aContainer) = 0;
|
||||
|
||||
|
|
|
@ -6698,7 +6698,6 @@ PresShell::VerifyIncrementalReflow()
|
|||
}
|
||||
}
|
||||
|
||||
cx->Stop();
|
||||
cx->SetContainer(nsnull);
|
||||
NS_RELEASE(cx);
|
||||
sh->EndObservingDocument();
|
||||
|
|
|
@ -10,7 +10,6 @@ nsICaret.h
|
|||
nsIFocusTracker.h
|
||||
nsIFrame.h
|
||||
nsIFrameDebug.h
|
||||
nsIFrameImageLoader.h
|
||||
nsIFrameManager.h
|
||||
nsIFrameSelection.h
|
||||
nsIFrameUtil.h
|
||||
|
|
|
@ -41,7 +41,6 @@ nsIImageFrame.h \
|
|||
nsIObjectFrame.h \
|
||||
nsIFrameTraversal.h \
|
||||
nsIFrameDebug.h \
|
||||
nsIFrameImageLoader.h \
|
||||
nsIFrameManager.h \
|
||||
nsIIndependentSelection.h \
|
||||
nsILayoutDebugger.h \
|
||||
|
|
|
@ -34,7 +34,6 @@ EXPORTS = \
|
|||
nsIImageFrame.h \
|
||||
nsIFrameTraversal.h \
|
||||
nsIFrameDebug.h \
|
||||
nsIFrameImageLoader.h \
|
||||
nsIFrameManager.h \
|
||||
nsIIndependentSelection.h \
|
||||
nsILayoutDebugger.h \
|
||||
|
|
|
@ -1,114 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsIFrameImageLoader_h___
|
||||
#define nsIFrameImageLoader_h___
|
||||
|
||||
#include "nslayout.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsColor.h"
|
||||
|
||||
class nsIFrame;
|
||||
class nsIImage;
|
||||
class nsIImageGroup;
|
||||
class nsIPresContext;
|
||||
class nsString;
|
||||
struct nsSize;
|
||||
|
||||
/* a6cf90ec-15b3-11d2-932e-00805f8add32 */
|
||||
#define NS_IFRAME_IMAGE_LOADER_IID \
|
||||
{ 0xa6cf90ec, 0x15b3, 0x11d2,{0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32}}
|
||||
|
||||
enum nsImageAnimation {
|
||||
eImageAnimation_Normal = 0, // looping controlled by image
|
||||
eImageAnimation_None = 1, // don't loop; just show first frame
|
||||
eImageAnimation_LoopOnce = 2 // loop just once
|
||||
};
|
||||
|
||||
// Type of callback function used during image loading. The frame
|
||||
// image loader will invoke this callback as notifications occur from
|
||||
// the image library.
|
||||
class nsIFrameImageLoader;
|
||||
typedef nsresult (*nsIFrameImageLoaderCB)(nsIPresContext* aPresContext,
|
||||
nsIFrameImageLoader* aLoader,
|
||||
nsIFrame* aFrame,
|
||||
void* aClosure,
|
||||
PRUint32 aStatus);
|
||||
|
||||
/**
|
||||
* Abstract interface for frame image loaders. Frame image loaders
|
||||
* know how to respond to nsIImageRequestObserver notifications and
|
||||
* generate the appropriate rendering/reflow operation for a target
|
||||
* frame.
|
||||
*/
|
||||
class nsIFrameImageLoader : public nsISupports {
|
||||
public:
|
||||
static const nsIID& GetIID() {static nsIID iid = NS_IFRAME_IMAGE_LOADER_IID; return iid;}
|
||||
|
||||
NS_IMETHOD Init(nsIPresContext* aPresContext,
|
||||
nsIImageGroup* aGroup,
|
||||
const nsString& aURL,
|
||||
const nscolor* aBackgroundColor,
|
||||
const nsSize* aDesiredSize,
|
||||
nsIFrame* aFrame,
|
||||
nsImageAnimation aAnimationMode,
|
||||
nsIFrameImageLoaderCB aCallBack,
|
||||
void* aClosure, void* aKey) = 0;
|
||||
|
||||
NS_IMETHOD StopImageLoad(PRBool aStopChrome = PR_TRUE) = 0;
|
||||
|
||||
NS_IMETHOD AbortImageLoad() = 0;
|
||||
|
||||
NS_IMETHOD IsSameImageRequest(const nsString& aURL,
|
||||
const nscolor* aBackgroundColor,
|
||||
const nsSize* aDesiredSize,
|
||||
PRBool* aResult) = 0;
|
||||
|
||||
NS_IMETHOD AddFrame(nsIFrame* aFrame, nsIFrameImageLoaderCB aCallBack,
|
||||
void* aClosure, void* aKey) = 0;
|
||||
|
||||
NS_IMETHOD RemoveFrame(void* aKey) = 0;
|
||||
|
||||
NS_IMETHOD SafeToDestroy(PRBool* aResult) = 0;
|
||||
|
||||
NS_IMETHOD GetURL(nsString& aResult) = 0;
|
||||
NS_IMETHOD GetPresContext(nsIPresContext** aPresContext) = 0;
|
||||
|
||||
NS_IMETHOD GetImage(nsIImage** aResult) = 0;
|
||||
|
||||
// Return the size of the image, in twips
|
||||
NS_IMETHOD GetSize(nsSize& aResult) = 0;
|
||||
|
||||
NS_IMETHOD GetImageLoadStatus(PRUint32* aLoadStatus) = 0;
|
||||
|
||||
// Return the intrinsic (or natural) size of the image, in twips.
|
||||
// Returns 0,0 if the dimensions are unknown
|
||||
NS_IMETHOD GetIntrinsicSize(nsSize& aResult) = 0;
|
||||
NS_IMETHOD GetNaturalImageSize(PRUint32* naturalWidth, PRUint32 *naturalHeight) = 0;
|
||||
};
|
||||
|
||||
// Image load status bit values
|
||||
#define NS_IMAGE_LOAD_STATUS_NONE 0x0
|
||||
#define NS_IMAGE_LOAD_STATUS_SIZE_AVAILABLE 0x1
|
||||
#define NS_IMAGE_LOAD_STATUS_IMAGE_READY 0x2
|
||||
#define NS_IMAGE_LOAD_STATUS_ERROR 0x4
|
||||
|
||||
#endif /* nsIFrameImageLoader_h___ */
|
|
@ -27,7 +27,6 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsIFrameImageLoader.h"
|
||||
#include "nsAWritableString.h"
|
||||
#ifdef IBMBIDI
|
||||
class nsBidiPresUtils;
|
||||
|
@ -36,13 +35,14 @@ class nsBidiPresUtils;
|
|||
struct nsFont;
|
||||
struct nsRect;
|
||||
|
||||
class imgIRequest;
|
||||
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIDeviceContext;
|
||||
class nsIFontMetrics;
|
||||
class nsIFrame;
|
||||
class nsIImage;
|
||||
class nsIImageGroup;
|
||||
class nsILinkHandler;
|
||||
class nsIPresShell;
|
||||
class nsIPref;
|
||||
|
@ -88,6 +88,13 @@ enum nsLanguageSpecificTransformType {
|
|||
eLanguageSpecificTransformType_Korean
|
||||
};
|
||||
|
||||
|
||||
enum nsImageAnimation {
|
||||
eImageAnimation_Normal = 0, // looping controlled by image
|
||||
eImageAnimation_None = 1, // don't loop; just show first frame
|
||||
eImageAnimation_LoopOnce = 2 // loop just once
|
||||
};
|
||||
|
||||
// supported values for cached bool types
|
||||
const PRUint32 kPresContext_UseDocumentColors = 0x01;
|
||||
const PRUint32 kPresContext_UseDocumentFonts = 0x02;
|
||||
|
@ -104,12 +111,6 @@ public:
|
|||
*/
|
||||
NS_IMETHOD Init(nsIDeviceContext* aDeviceContext) = 0;
|
||||
|
||||
/**
|
||||
* Stop the presentation in preperation for destruction.
|
||||
* @param aStopChrome PR_TRUE to stop chrome as well.
|
||||
*/
|
||||
NS_IMETHOD Stop(PRBool aStopChrome = PR_TRUE) = 0;
|
||||
|
||||
/**
|
||||
* Set the presentation shell that this context is bound to.
|
||||
* A presentation context may only be bound to a single shell.
|
||||
|
@ -277,42 +278,22 @@ public:
|
|||
NS_IMETHOD SetDefaultLinkColor(nscolor aColor) = 0;
|
||||
NS_IMETHOD SetDefaultVisitedLinkColor(nscolor aColor) = 0;
|
||||
|
||||
NS_IMETHOD GetImageGroup(nsIImageGroup** aGroupResult) = 0;
|
||||
|
||||
/**
|
||||
* Load an image for the target frame. This call can be made
|
||||
* repeated with only a single image ever being loaded. If
|
||||
* aNeedSizeUpdate is PR_TRUE, then when the image's size is
|
||||
* determined the target frame will be reflowed (via a
|
||||
* ContentChanged notification on the presentation shell). When the
|
||||
* repeated with only a single image ever being loaded. When the
|
||||
* image's data is ready for rendering the target frame's Paint()
|
||||
* method will be invoked (via the ViewManager) so that the
|
||||
* appropriate damage repair is done.
|
||||
*
|
||||
* @param aBackgroundColor - If the background color is NULL, a mask
|
||||
* will be generated for transparent images. If the background
|
||||
* color is non-NULL, it indicates the RGB value to be folded
|
||||
* into the transparent areas of the image and no mask is created.
|
||||
*/
|
||||
NS_IMETHOD StartLoadImage(const nsString& aURL,
|
||||
const nscolor* aBackgroundColor,
|
||||
const nsSize* aDesiredSize,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsIFrameImageLoaderCB aCallBack,
|
||||
void* aClosure,
|
||||
void* aKey,
|
||||
nsIFrameImageLoader** aResult) = 0;
|
||||
NS_IMETHOD LoadImage(const nsString& aURL,
|
||||
nsIFrame* aTargetFrame,
|
||||
imgIRequest **aRequest) = 0;
|
||||
|
||||
/**
|
||||
* Stop a specific image load being done on behalf of the argument frame.
|
||||
* This method is called when a frame is being destroyed to
|
||||
* ensure that the image load gets disassociated from the prescontext
|
||||
*/
|
||||
NS_IMETHOD StopLoadImage(void* aKey,
|
||||
nsIFrameImageLoader* aLoader) = 0;
|
||||
|
||||
/**
|
||||
* Stop any image loading being done on behalf of the argument frame.
|
||||
*/
|
||||
NS_IMETHOD StopAllLoadImagesFor(nsIFrame* aTargetFrame, void* aKey) = 0;
|
||||
NS_IMETHOD StopImagesFor(nsIFrame* aTargetFrame) = 0;
|
||||
|
||||
NS_IMETHOD SetContainer(nsISupports* aContainer) = 0;
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsColor.h"
|
||||
#include "nsCoord.h"
|
||||
#include "nsIFrameImageLoader.h"
|
||||
#include "nsAWritableString.h"
|
||||
#ifdef IBMBIDI
|
||||
class nsBidiPresUtils;
|
||||
|
@ -36,13 +35,14 @@ class nsBidiPresUtils;
|
|||
struct nsFont;
|
||||
struct nsRect;
|
||||
|
||||
class imgIRequest;
|
||||
|
||||
class nsIContent;
|
||||
class nsIDocument;
|
||||
class nsIDeviceContext;
|
||||
class nsIFontMetrics;
|
||||
class nsIFrame;
|
||||
class nsIImage;
|
||||
class nsIImageGroup;
|
||||
class nsILinkHandler;
|
||||
class nsIPresShell;
|
||||
class nsIPref;
|
||||
|
@ -88,6 +88,13 @@ enum nsLanguageSpecificTransformType {
|
|||
eLanguageSpecificTransformType_Korean
|
||||
};
|
||||
|
||||
|
||||
enum nsImageAnimation {
|
||||
eImageAnimation_Normal = 0, // looping controlled by image
|
||||
eImageAnimation_None = 1, // don't loop; just show first frame
|
||||
eImageAnimation_LoopOnce = 2 // loop just once
|
||||
};
|
||||
|
||||
// supported values for cached bool types
|
||||
const PRUint32 kPresContext_UseDocumentColors = 0x01;
|
||||
const PRUint32 kPresContext_UseDocumentFonts = 0x02;
|
||||
|
@ -104,12 +111,6 @@ public:
|
|||
*/
|
||||
NS_IMETHOD Init(nsIDeviceContext* aDeviceContext) = 0;
|
||||
|
||||
/**
|
||||
* Stop the presentation in preperation for destruction.
|
||||
* @param aStopChrome PR_TRUE to stop chrome as well.
|
||||
*/
|
||||
NS_IMETHOD Stop(PRBool aStopChrome = PR_TRUE) = 0;
|
||||
|
||||
/**
|
||||
* Set the presentation shell that this context is bound to.
|
||||
* A presentation context may only be bound to a single shell.
|
||||
|
@ -277,42 +278,22 @@ public:
|
|||
NS_IMETHOD SetDefaultLinkColor(nscolor aColor) = 0;
|
||||
NS_IMETHOD SetDefaultVisitedLinkColor(nscolor aColor) = 0;
|
||||
|
||||
NS_IMETHOD GetImageGroup(nsIImageGroup** aGroupResult) = 0;
|
||||
|
||||
/**
|
||||
* Load an image for the target frame. This call can be made
|
||||
* repeated with only a single image ever being loaded. If
|
||||
* aNeedSizeUpdate is PR_TRUE, then when the image's size is
|
||||
* determined the target frame will be reflowed (via a
|
||||
* ContentChanged notification on the presentation shell). When the
|
||||
* repeated with only a single image ever being loaded. When the
|
||||
* image's data is ready for rendering the target frame's Paint()
|
||||
* method will be invoked (via the ViewManager) so that the
|
||||
* appropriate damage repair is done.
|
||||
*
|
||||
* @param aBackgroundColor - If the background color is NULL, a mask
|
||||
* will be generated for transparent images. If the background
|
||||
* color is non-NULL, it indicates the RGB value to be folded
|
||||
* into the transparent areas of the image and no mask is created.
|
||||
*/
|
||||
NS_IMETHOD StartLoadImage(const nsString& aURL,
|
||||
const nscolor* aBackgroundColor,
|
||||
const nsSize* aDesiredSize,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsIFrameImageLoaderCB aCallBack,
|
||||
void* aClosure,
|
||||
void* aKey,
|
||||
nsIFrameImageLoader** aResult) = 0;
|
||||
NS_IMETHOD LoadImage(const nsString& aURL,
|
||||
nsIFrame* aTargetFrame,
|
||||
imgIRequest **aRequest) = 0;
|
||||
|
||||
/**
|
||||
* Stop a specific image load being done on behalf of the argument frame.
|
||||
* This method is called when a frame is being destroyed to
|
||||
* ensure that the image load gets disassociated from the prescontext
|
||||
*/
|
||||
NS_IMETHOD StopLoadImage(void* aKey,
|
||||
nsIFrameImageLoader* aLoader) = 0;
|
||||
|
||||
/**
|
||||
* Stop any image loading being done on behalf of the argument frame.
|
||||
*/
|
||||
NS_IMETHOD StopAllLoadImagesFor(nsIFrame* aTargetFrame, void* aKey) = 0;
|
||||
NS_IMETHOD StopImagesFor(nsIFrame* aTargetFrame) = 0;
|
||||
|
||||
NS_IMETHOD SetContainer(nsISupports* aContainer) = 0;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ CPPSRCS = \
|
|||
nsAutoCopy.cpp \
|
||||
nsCaret.cpp \
|
||||
nsCopySupport.cpp \
|
||||
nsFrameImageLoader.cpp \
|
||||
nsImageLoader.cpp \
|
||||
nsFrameList.cpp \
|
||||
nsFrameTraversal.cpp \
|
||||
nsFrameUtil.cpp \
|
||||
|
|
|
@ -31,7 +31,7 @@ DEFINES = $(DEFINES) -DXP_NEW_SELECTION
|
|||
CPPSRCS = \
|
||||
nsAutoCopy.cpp \
|
||||
nsCopySupport.cpp \
|
||||
nsFrameImageLoader.cpp \
|
||||
nsImageLoader.cpp \
|
||||
nsFrameList.cpp \
|
||||
nsFrameTraversal.cpp \
|
||||
nsFrameUtil.cpp \
|
||||
|
@ -55,7 +55,7 @@ MODULE=raptor
|
|||
CPP_OBJS= \
|
||||
.\$(OBJDIR)\nsAutoCopy.obj \
|
||||
.\$(OBJDIR)\nsCopySupport.obj \
|
||||
.\$(OBJDIR)\nsFrameImageLoader.obj \
|
||||
.\$(OBJDIR)\nsImageLoader.obj \
|
||||
.\$(OBJDIR)\nsFrameList.obj \
|
||||
.\$(OBJDIR)\nsFrameTraversal.obj \
|
||||
.\$(OBJDIR)\nsFrameUtil.obj \
|
||||
|
|
|
@ -1,655 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#include "nsFrameImageLoader.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIImage.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIImageGroup.h"
|
||||
#include "nsIImageRequest.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
#undef NOISY_IMAGE_LOADING
|
||||
#else
|
||||
#undef NOISY_IMAGE_LOADING
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
NS_LAYOUT nsresult
|
||||
NS_NewFrameImageLoader(nsIFrameImageLoader** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult, "null ptr");
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsFrameImageLoader* it = new nsFrameImageLoader();
|
||||
if (!it) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
return it->QueryInterface(NS_GET_IID(nsIFrameImageLoader), (void**) aResult);
|
||||
}
|
||||
|
||||
nsFrameImageLoader::nsFrameImageLoader()
|
||||
: mPresContext(nsnull),
|
||||
mImageRequest(nsnull),
|
||||
mImage(nsnull),
|
||||
mHaveBackgroundColor(PR_FALSE),
|
||||
mHaveDesiredSize(PR_FALSE),
|
||||
mBackgroundColor(0),
|
||||
mDesiredSize(0, 0),
|
||||
mImageLoadStatus(NS_IMAGE_LOAD_STATUS_NONE),
|
||||
mImageLoadError( nsImageError(-1) ),
|
||||
mNotifyLockCount(0),
|
||||
mFrames(nsnull),
|
||||
mCurNotifiedFrame(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsFrameImageLoader::~nsFrameImageLoader()
|
||||
{
|
||||
for (PerFrameData *next, *pfd = mFrames; pfd; pfd = next) {
|
||||
next = pfd->mNext;
|
||||
delete pfd;
|
||||
}
|
||||
NS_IF_RELEASE(mImageRequest);
|
||||
NS_IF_RELEASE(mPresContext);
|
||||
NS_IF_RELEASE(mImage);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsFrameImageLoader)
|
||||
NS_IMPL_RELEASE(nsFrameImageLoader)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameImageLoader::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (!aInstancePtr) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIFrameImageLoader))) {
|
||||
nsIFrameImageLoader* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIImageRequestObserver))) {
|
||||
nsIImageRequestObserver* tmp = this;
|
||||
*aInstancePtr = (void*) tmp;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
nsIFrameImageLoader* tmp1 = this;
|
||||
nsISupports* tmp2 = tmp1;
|
||||
*aInstancePtr = (void*) tmp2;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameImageLoader::Init(nsIPresContext* aPresContext,
|
||||
nsIImageGroup* aGroup,
|
||||
const nsString& aURL,
|
||||
const nscolor* aBackgroundColor,
|
||||
const nsSize* aDesiredSize,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsImageAnimation aAnimationMode,
|
||||
nsIFrameImageLoaderCB aCallBack,
|
||||
void* aClosure,
|
||||
void* aKey)
|
||||
{
|
||||
NS_PRECONDITION(aPresContext, "null ptr");
|
||||
if (!aPresContext) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
NS_PRECONDITION(!mPresContext, "double init");
|
||||
if (mPresContext) {
|
||||
return NS_ERROR_ALREADY_INITIALIZED;
|
||||
}
|
||||
|
||||
mPresContext = aPresContext;
|
||||
NS_IF_ADDREF(aPresContext);
|
||||
mURL = aURL;
|
||||
if (aBackgroundColor) {
|
||||
mHaveBackgroundColor = PR_TRUE;
|
||||
mBackgroundColor = *aBackgroundColor;
|
||||
}
|
||||
|
||||
// Computed desired size, in pixels
|
||||
nscoord desiredWidth = 0;
|
||||
nscoord desiredHeight = 0;
|
||||
if (aDesiredSize) {
|
||||
mHaveDesiredSize = PR_TRUE;
|
||||
mDesiredSize = *aDesiredSize;
|
||||
|
||||
float t2p,devScale;
|
||||
nsIDeviceContext *theDC;
|
||||
|
||||
aPresContext->GetTwipsToPixels(&t2p);
|
||||
aPresContext->GetDeviceContext(&theDC);
|
||||
theDC->GetCanonicalPixelScale(devScale);
|
||||
NS_RELEASE(theDC);
|
||||
|
||||
desiredWidth = NSToCoordRound((mDesiredSize.width * t2p)/devScale);
|
||||
desiredHeight = NSToCoordRound((mDesiredSize.height * t2p)/devScale);
|
||||
}
|
||||
|
||||
if (aTargetFrame || aCallBack) {
|
||||
PerFrameData* pfd = new PerFrameData;
|
||||
if (!pfd) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
pfd->mFrame = aTargetFrame;
|
||||
pfd->mKey = aKey;
|
||||
pfd->mCallBack = aCallBack;
|
||||
pfd->mClosure = aClosure;
|
||||
pfd->mNext = mFrames;
|
||||
pfd->mNeedSizeUpdate = aTargetFrame ? PR_TRUE : PR_FALSE;
|
||||
mFrames = pfd;
|
||||
}
|
||||
|
||||
// Start image load request
|
||||
char* cp = aURL.ToNewUTF8String();
|
||||
|
||||
|
||||
mImageRequest = aGroup->GetImage(cp, this, aBackgroundColor,
|
||||
desiredWidth, desiredHeight, 0);
|
||||
|
||||
nsCRT::free(cp);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameImageLoader::AddFrame(nsIFrame* aFrame,
|
||||
nsIFrameImageLoaderCB aCallBack,
|
||||
void* aClosure,
|
||||
void* aKey)
|
||||
{
|
||||
PerFrameData* pfd;
|
||||
for (pfd = mFrames; pfd; pfd = pfd->mNext)
|
||||
if (pfd->mKey == aKey) {
|
||||
pfd->mCallBack = aCallBack;
|
||||
pfd->mClosure = aClosure;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
pfd = new PerFrameData;
|
||||
if (!pfd) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
pfd->mFrame = aFrame;
|
||||
pfd->mKey = aKey;
|
||||
pfd->mCallBack = aCallBack;
|
||||
pfd->mClosure = aClosure;
|
||||
pfd->mNext = mFrames;
|
||||
pfd->mNeedSizeUpdate = PR_TRUE;
|
||||
mFrames = pfd;
|
||||
if (aCallBack && mPresContext &&
|
||||
((NS_IMAGE_LOAD_STATUS_SIZE_AVAILABLE |
|
||||
NS_IMAGE_LOAD_STATUS_ERROR) & mImageLoadStatus)) {
|
||||
// Fire notification callback right away so that caller doesn't
|
||||
// miss it...
|
||||
#ifdef NOISY_IMAGE_LOADING
|
||||
printf("%p: AddFrame %p: notify frame=%p status=%x\n",
|
||||
this, pfd, pfd->mFrame, mImageLoadStatus);
|
||||
#endif
|
||||
(*aCallBack)(mPresContext, this, pfd->mFrame, pfd->mClosure,
|
||||
mImageLoadStatus);
|
||||
pfd->mNeedSizeUpdate = PR_FALSE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameImageLoader::RemoveFrame(void* aKey)
|
||||
{
|
||||
PerFrameData** pfdp;
|
||||
PerFrameData* pfd;
|
||||
for (pfdp = &mFrames; (pfd = *pfdp); pfdp = &pfd->mNext)
|
||||
if (pfd->mKey == aKey) {
|
||||
*pfdp = pfd->mNext;
|
||||
if (pfd == mCurNotifiedFrame)
|
||||
mCurNotifiedFrame = pfd->mNext;
|
||||
delete pfd;
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameImageLoader::StopImageLoad(PRBool aStopChrome)
|
||||
{
|
||||
// don't stop chrome
|
||||
if (!aStopChrome) {
|
||||
if (mURL.EqualsWithConversion("chrome:", PR_TRUE, 7))
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef NOISY_IMAGE_LOADING
|
||||
printf(" %p: stopping ", this);
|
||||
fputs(mURL, stdout);
|
||||
printf("\n");
|
||||
#endif
|
||||
if (mImageRequest) {
|
||||
// can't kill the image request if we're in the middle of a notification
|
||||
if (mNotifyLockCount) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mImageRequest->RemoveObserver(this);
|
||||
NS_RELEASE(mImageRequest);
|
||||
}
|
||||
NS_IF_RELEASE(mPresContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameImageLoader::AbortImageLoad()
|
||||
{
|
||||
if (mImageRequest) {
|
||||
mImageRequest->Interrupt();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameImageLoader::IsSameImageRequest(const nsString& aURL,
|
||||
const nscolor* aBackgroundColor,
|
||||
const nsSize* aDesiredSize,
|
||||
PRBool* aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult, "null ptr");
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
// URL's must match (XXX: not quite right; need real comparison here...)
|
||||
if (!aURL.Equals(mURL)) {
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// XXX Temporary fix to deal with the case of animated
|
||||
// images that are preloaded. If we've completed the image
|
||||
// and there aren't any frames associated with it, then we
|
||||
// interrupted the load of the image. The good things is that
|
||||
// the image is still in the image cache. The bad thing is that
|
||||
// we don't share the image loader.
|
||||
if (!mFrames && (mImageLoadStatus & NS_IMAGE_LOAD_STATUS_IMAGE_READY)) {
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Background colors must match
|
||||
if (aBackgroundColor) {
|
||||
if (!mHaveBackgroundColor) {
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
if (mBackgroundColor != *aBackgroundColor) {
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else if (mHaveBackgroundColor) {
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Desired sizes must match
|
||||
if (aDesiredSize) {
|
||||
if (!mHaveDesiredSize) {
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
if ((mDesiredSize.width != aDesiredSize->width) ||
|
||||
(mDesiredSize.height != aDesiredSize->height)) {
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
else if (mHaveDesiredSize) {
|
||||
*aResult = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
*aResult = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameImageLoader::SafeToDestroy(PRBool* aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult, "null ptr");
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
*aResult = PR_FALSE;
|
||||
if (!mFrames && !mNotifyLockCount) {
|
||||
*aResult = PR_TRUE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameImageLoader::GetURL(nsString& aResult)
|
||||
{
|
||||
aResult = mURL;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameImageLoader::GetPresContext(nsIPresContext** aPresContext)
|
||||
{
|
||||
NS_IF_ADDREF(*aPresContext = mPresContext);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameImageLoader::GetImage(nsIImage** aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult, "null ptr");
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aResult = mImage;
|
||||
NS_IF_ADDREF(mImage);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Return the size of the image, in twips
|
||||
NS_IMETHODIMP
|
||||
nsFrameImageLoader::GetSize(nsSize& aResult)
|
||||
{
|
||||
aResult = mDesiredSize;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameImageLoader::GetImageLoadStatus(PRUint32* aResult)
|
||||
{
|
||||
NS_PRECONDITION(aResult, "null ptr");
|
||||
if (!aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aResult = mImageLoadStatus;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameImageLoader::GetIntrinsicSize(nsSize& aResult)
|
||||
{
|
||||
if (mImageRequest) {
|
||||
PRUint32 width = 0, height = 0;
|
||||
float p2t;
|
||||
|
||||
mPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
aResult.width = NSIntPixelsToTwips(width, p2t);
|
||||
aResult.height = NSIntPixelsToTwips(height, p2t);
|
||||
} else {
|
||||
aResult.SizeTo(0, 0);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFrameImageLoader::GetNaturalImageSize(PRUint32* naturalWidth,
|
||||
PRUint32 *naturalHeight)
|
||||
{
|
||||
if(mImage){
|
||||
*naturalWidth = mImage->GetNaturalWidth();
|
||||
*naturalHeight = mImage->GetNaturalHeight();
|
||||
}else{
|
||||
*naturalWidth = 0;
|
||||
*naturalHeight = 0;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsFrameImageLoader::Notify(nsIImageRequest *aImageRequest,
|
||||
nsIImage *aImage,
|
||||
nsImageNotification aNotificationType,
|
||||
PRInt32 aParam1, PRInt32 aParam2,
|
||||
void *aParam3)
|
||||
{
|
||||
nsIView* view;
|
||||
nsRect damageRect;
|
||||
float p2t;
|
||||
const nsRect* changeRect;
|
||||
PerFrameData* pfd;
|
||||
|
||||
if (!mPresContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
mNotifyLockCount++;
|
||||
|
||||
#ifdef NOISY_IMAGE_LOADING
|
||||
printf("%p: loading ", this);
|
||||
fputs(mURL, stdout);
|
||||
printf(" notification=%d params=%d,%d,%p\n", aNotificationType,
|
||||
aParam1, aParam2, aParam3);
|
||||
#endif
|
||||
switch (aNotificationType) {
|
||||
case nsImageNotification_kDimensions:
|
||||
mPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
mDesiredSize.width = NSIntPixelsToTwips(aParam1, p2t);
|
||||
mDesiredSize.height = NSIntPixelsToTwips(aParam2, p2t);
|
||||
mImageLoadStatus |= NS_IMAGE_LOAD_STATUS_SIZE_AVAILABLE;
|
||||
NotifyFrames(PR_TRUE);
|
||||
break;
|
||||
|
||||
case nsImageNotification_kPixmapUpdate:
|
||||
if (!mImage && aImage) {
|
||||
mImage = aImage;
|
||||
NS_ADDREF(aImage);
|
||||
}
|
||||
mImageLoadStatus |= NS_IMAGE_LOAD_STATUS_IMAGE_READY;
|
||||
|
||||
// Convert the rect from pixels to twips
|
||||
// Note the 1 pixel inflation of the damage rect
|
||||
// to account for off by 1 pixel rounding errors.
|
||||
mPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
changeRect = (const nsRect*) aParam3;
|
||||
damageRect.x = NSIntPixelsToTwips(changeRect->x, p2t);
|
||||
damageRect.y = NSIntPixelsToTwips((changeRect->y - 1), p2t);
|
||||
damageRect.width = NSIntPixelsToTwips(changeRect->width, p2t);
|
||||
damageRect.height = NSIntPixelsToTwips((changeRect->height + 1), p2t);
|
||||
DamageRepairFrames(&damageRect);
|
||||
break;
|
||||
|
||||
case nsImageNotification_kImageComplete:
|
||||
// XXX Temporary fix to deal with the case of animated
|
||||
// images that are preloaded. If there are no frames
|
||||
// registered, then stop loading this image.
|
||||
if (!mFrames) {
|
||||
AbortImageLoad();
|
||||
}
|
||||
if (!mImage && aImage) {
|
||||
mImage = aImage;
|
||||
NS_ADDREF(aImage);
|
||||
mImageLoadStatus |= NS_IMAGE_LOAD_STATUS_IMAGE_READY;
|
||||
DamageRepairFrames(nsnull);
|
||||
}
|
||||
NotifyFrames(PR_FALSE);
|
||||
break;
|
||||
|
||||
case nsImageNotification_kFrameComplete:
|
||||
// New frame of a GIF animation
|
||||
// XXX Image library sends this for all images, and not just for animated
|
||||
// images. You bastards. It's a waste to re-draw the image if it's not an
|
||||
// animated image, but unfortunately we don't currently have a way to tell
|
||||
// whether the image is animated
|
||||
if (mImage) {
|
||||
DamageRepairFrames(nsnull);
|
||||
}
|
||||
break;
|
||||
|
||||
case nsImageNotification_kIsTransparent:
|
||||
// Mark the frame's view as having transparent areas
|
||||
// XXX this is pretty vile; change this so that we set another frame status
|
||||
// bit and then pass on a notification *or* lets just start passing on the
|
||||
// notifications directly to the frames and eliminate all of this code.
|
||||
for (pfd = mFrames; pfd; pfd = pfd->mNext)
|
||||
if (pfd->mFrame) {
|
||||
pfd->mFrame->GetView(mPresContext, &view);
|
||||
if (view) {
|
||||
view->SetContentTransparency(PR_TRUE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case nsImageNotification_kAborted:
|
||||
// Treat this like an error
|
||||
mImageLoadError = nsImageError_kNoData;
|
||||
mImageLoadStatus |= NS_IMAGE_LOAD_STATUS_ERROR;
|
||||
NotifyFrames(PR_FALSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
mNotifyLockCount--;
|
||||
}
|
||||
|
||||
void
|
||||
nsFrameImageLoader::NotifyError(nsIImageRequest *aImageRequest,
|
||||
nsImageError aErrorType)
|
||||
{
|
||||
mNotifyLockCount++;
|
||||
|
||||
mImageLoadError = aErrorType;
|
||||
mImageLoadStatus |= NS_IMAGE_LOAD_STATUS_ERROR;
|
||||
NotifyFrames(PR_FALSE);
|
||||
|
||||
mNotifyLockCount--;
|
||||
}
|
||||
|
||||
void
|
||||
nsFrameImageLoader::NotifyFrames(PRBool aIsSizeUpdate)
|
||||
{
|
||||
mCurNotifiedFrame = mFrames;
|
||||
PerFrameData* pfd; // Initialized on the next line
|
||||
while ((pfd = mCurNotifiedFrame)) {
|
||||
if (!aIsSizeUpdate || pfd->mNeedSizeUpdate) {
|
||||
if (pfd->mCallBack) {
|
||||
#ifdef NOISY_IMAGE_LOADING
|
||||
printf(" notify pfd = %p frame=%p status=%x\n", pfd, pfd->mFrame,
|
||||
mImageLoadStatus);
|
||||
#endif
|
||||
(*pfd->mCallBack)(mPresContext, this, pfd->mFrame, pfd->mClosure,
|
||||
mImageLoadStatus);
|
||||
if (pfd != mCurNotifiedFrame) {
|
||||
continue; //pfd has been deleted in the callback, don't chain to next
|
||||
}
|
||||
}
|
||||
if (aIsSizeUpdate) {
|
||||
pfd->mNeedSizeUpdate = PR_FALSE;
|
||||
}
|
||||
}
|
||||
mCurNotifiedFrame = pfd->mNext;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsFrameImageLoader::DamageRepairFrames(const nsRect* aDamageRect)
|
||||
{
|
||||
// Determine damaged area and tell view manager to redraw it
|
||||
nsPoint offset;
|
||||
nsRect bounds;
|
||||
nsIView* view;
|
||||
|
||||
for (PerFrameData* pfd = mFrames; pfd; pfd = pfd->mNext) {
|
||||
nsIFrame* frame = pfd->mFrame;
|
||||
|
||||
if (frame) {
|
||||
// NOTE: It is not sufficient to invalidate only the size of the image:
|
||||
// the image may be tiled!
|
||||
// The best option is to call into the frame, however lacking this
|
||||
// we have to at least invalidate the frame's bounds, hence
|
||||
// as long as we have a frame we'll use its size.
|
||||
//
|
||||
// XXX - Add a NotifyImageLoaded to nsIFrame and call that, passing the
|
||||
// damage rect (image size)
|
||||
|
||||
// Invalidate the entire frame
|
||||
// XXX We really only need to invalidate the client area of the frame...
|
||||
frame->GetRect(bounds);
|
||||
bounds.x = bounds.y = 0;
|
||||
|
||||
// Invalidate the entire frame only if the frame has a tiled background
|
||||
// image, otherwise just invalidate the intersection of the frame's bounds
|
||||
// with the damaged rect.
|
||||
|
||||
nsCOMPtr<nsIStyleContext> styleContext;
|
||||
frame->GetStyleContext(getter_AddRefs(styleContext));
|
||||
const nsStyleBackground* color = (const nsStyleBackground*)
|
||||
styleContext->GetStyleData(eStyleStruct_Background);
|
||||
|
||||
if ((color->mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE) ||
|
||||
(color->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT) ||
|
||||
(color->mBackgroundRepeat == NS_STYLE_BG_REPEAT_OFF)) {
|
||||
// The frame does not have a background image so we are free
|
||||
// to invalidate only the intersection of the damage rect and
|
||||
// the frame's bounds.
|
||||
|
||||
if (aDamageRect) {
|
||||
bounds.IntersectRect(*aDamageRect, bounds);
|
||||
}
|
||||
}
|
||||
|
||||
if ((bounds.width > 0) && (bounds.height > 0)) {
|
||||
|
||||
// XXX We should tell the frame the damage area and let it invalidate
|
||||
// itself. Add some API calls to nsIFrame to allow a caller to invalidate
|
||||
// parts of the frame...
|
||||
frame->GetView(mPresContext, &view);
|
||||
if (!view) {
|
||||
frame->GetOffsetFromView(mPresContext, offset, &view);
|
||||
bounds.x += offset.x;
|
||||
bounds.y += offset.y;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIViewManager> vm = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
rv = view->GetViewManager(*getter_AddRefs(vm));
|
||||
if (NS_SUCCEEDED(rv) && vm) {
|
||||
vm->UpdateView(view, bounds, NS_VMREFRESH_NO_SYNC);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape 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/NPL/
|
||||
*
|
||||
* 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) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
#ifndef nsFrameImageLoader_h___
|
||||
#define nsFrameImageLoader_h___
|
||||
|
||||
#include "nsSize.h"
|
||||
#include "nsString.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsIFrameImageLoader.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIImageObserver.h"
|
||||
|
||||
struct nsRect;
|
||||
|
||||
/**
|
||||
* An image loader for frame's.
|
||||
*/
|
||||
class nsFrameImageLoader : public nsIFrameImageLoader,
|
||||
public nsIImageRequestObserver
|
||||
{
|
||||
public:
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIImageRequestObserver
|
||||
virtual void Notify(nsIImageRequest *aImageRequest,
|
||||
nsIImage *aImage,
|
||||
nsImageNotification aNotificationType,
|
||||
PRInt32 aParam1, PRInt32 aParam2,
|
||||
void *aParam3);
|
||||
virtual void NotifyError(nsIImageRequest *aImageRequest,
|
||||
nsImageError aErrorType);
|
||||
|
||||
// nsFrameImageLoader API
|
||||
NS_IMETHOD Init(nsIPresContext* aPresContext,
|
||||
nsIImageGroup* aGroup,
|
||||
const nsString& aURL,
|
||||
const nscolor* aBackgroundColor,
|
||||
const nsSize* aDesiredSize,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsImageAnimation aAnimationMode,
|
||||
nsIFrameImageLoaderCB aCallBack,
|
||||
void* aClosure, void* aKey);
|
||||
|
||||
NS_IMETHOD StopImageLoad(PRBool aStopChrome = PR_TRUE);
|
||||
|
||||
NS_IMETHOD AbortImageLoad();
|
||||
|
||||
NS_IMETHOD IsSameImageRequest(const nsString& aURL,
|
||||
const nscolor* aBackgroundColor,
|
||||
const nsSize* aDesiredSize,
|
||||
PRBool* aResult);
|
||||
|
||||
NS_IMETHOD AddFrame(nsIFrame* aFrame, nsIFrameImageLoaderCB aCallBack,
|
||||
void* aClosure, void* aKey);
|
||||
|
||||
NS_IMETHOD RemoveFrame(void* aKey);
|
||||
|
||||
// See if its safe to destroy this image loader. Its safe if there
|
||||
// are no more frames using the loader and we aren't in the middle
|
||||
// of processing a callback.
|
||||
NS_IMETHOD SafeToDestroy(PRBool* aResult);
|
||||
|
||||
NS_IMETHOD GetURL(nsString& aResult);
|
||||
NS_IMETHOD GetPresContext(nsIPresContext** aPresContext);
|
||||
|
||||
NS_IMETHOD GetImage(nsIImage** aResult);
|
||||
|
||||
// Return the size of the image, in twips
|
||||
NS_IMETHOD GetSize(nsSize& aResult);
|
||||
|
||||
NS_IMETHOD GetImageLoadStatus(PRUint32* aLoadStatus);
|
||||
|
||||
NS_IMETHOD GetIntrinsicSize(nsSize& aResult);
|
||||
|
||||
NS_IMETHOD GetNaturalImageSize(PRUint32* naturalWidth,
|
||||
PRUint32 *naturalHeight);
|
||||
|
||||
|
||||
protected:
|
||||
nsFrameImageLoader();
|
||||
virtual ~nsFrameImageLoader();
|
||||
|
||||
void DamageRepairFrames(const nsRect* aDamageRect);
|
||||
|
||||
void NotifyFrames(PRBool aIsSizeUpdate);
|
||||
|
||||
nsIPresContext* mPresContext;
|
||||
nsIImageRequest* mImageRequest;
|
||||
nsIImage* mImage;
|
||||
|
||||
PRPackedBool mHaveBackgroundColor;
|
||||
PRPackedBool mHaveDesiredSize;
|
||||
nsString mURL;
|
||||
nscolor mBackgroundColor;
|
||||
nsSize mDesiredSize;
|
||||
|
||||
nsSize mImageSize;
|
||||
|
||||
PRUint32 mImageLoadStatus;
|
||||
nsImageError mImageLoadError;
|
||||
|
||||
PRInt32 mNotifyLockCount;
|
||||
|
||||
struct PerFrameData {
|
||||
PerFrameData* mNext;
|
||||
nsIFrame* mFrame;
|
||||
nsIFrameImageLoaderCB mCallBack;
|
||||
void* mClosure;
|
||||
void* mKey;
|
||||
PRBool mNeedSizeUpdate;
|
||||
};
|
||||
PerFrameData* mFrames;
|
||||
PerFrameData* mCurNotifiedFrame;
|
||||
friend NS_LAYOUT nsresult NS_NewFrameImageLoader(nsIFrameImageLoader**);
|
||||
};
|
||||
|
||||
extern NS_LAYOUT nsresult
|
||||
NS_NewFrameImageLoader(nsIFrameImageLoader** aInstancePtrResult);
|
||||
|
||||
#endif /* nsFrameImageLoader_h___ */
|
|
@ -0,0 +1,259 @@
|
|||
/* -*- 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 "nsImageLoader.h"
|
||||
|
||||
#include "imgILoader.h"
|
||||
|
||||
#include "nsIURI.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
|
||||
#include "nsIHTMLContent.h"
|
||||
|
||||
#include "nsIViewManager.h"
|
||||
|
||||
#include "nsIStyleContext.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsImageLoader, imgIDecoderObserver, imgIContainerObserver)
|
||||
|
||||
nsImageLoader::nsImageLoader() :
|
||||
mFrame(nsnull), mPresContext(nsnull)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsImageLoader::~nsImageLoader()
|
||||
{
|
||||
mFrame = nsnull;
|
||||
mPresContext = nsnull;
|
||||
|
||||
if (mRequest) {
|
||||
mRequest->Cancel(NS_ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsImageLoader::Init(nsIFrame *aFrame, nsIPresContext *aPresContext)
|
||||
{
|
||||
mFrame = aFrame;
|
||||
mPresContext = aPresContext;
|
||||
}
|
||||
|
||||
void
|
||||
nsImageLoader::Destroy()
|
||||
{
|
||||
mFrame = nsnull;
|
||||
mPresContext = nsnull;
|
||||
|
||||
if (mRequest) {
|
||||
mRequest->Cancel(NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
mRequest = nsnull;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsImageLoader::Load(const nsAReadableString &aURI)
|
||||
{
|
||||
if (!mFrame)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = mPresContext->GetShell(getter_AddRefs(shell));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
rv = shell->GetDocument(getter_AddRefs(doc));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Get the document's loadgroup
|
||||
doc->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
|
||||
doc->GetBaseURL(*getter_AddRefs(baseURI));
|
||||
|
||||
NS_NewURI(getter_AddRefs(uri), aURI, baseURI);
|
||||
|
||||
if (mRequest) {
|
||||
nsCOMPtr<nsIURI> oldURI;
|
||||
mRequest->GetURI(getter_AddRefs(oldURI));
|
||||
PRBool eq = PR_FALSE;
|
||||
uri->Equals(oldURI, &eq);
|
||||
if (eq) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return il->LoadImage(uri, loadGroup, NS_STATIC_CAST(imgIDecoderObserver *, this),
|
||||
nsnull, nsIRequest::LOAD_BACKGROUND, getter_AddRefs(mRequest));
|
||||
}
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::OnStartDecode(imgIRequest *aRequest, nsISupports *aContext)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::OnStartContainer(imgIRequest *aRequest, nsISupports *aContext, imgIContainer *aImage)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::OnStartFrame(imgIRequest *aRequest, nsISupports *aContext, gfxIImageFrame *aFrame)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::OnDataAvailable(imgIRequest *aRequest, nsISupports *aContext, gfxIImageFrame *aFrame, const nsRect *aRect)
|
||||
{
|
||||
if (!mFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsRect r(*aRect);
|
||||
|
||||
float p2t;
|
||||
mPresContext->GetPixelsToTwips(&p2t);
|
||||
r.x = NSIntPixelsToTwips(r.x, p2t);
|
||||
r.y = NSIntPixelsToTwips(r.y, p2t);
|
||||
r.width = NSIntPixelsToTwips(r.width, p2t);
|
||||
r.height = NSIntPixelsToTwips(r.height, p2t);
|
||||
|
||||
RedrawDirtyFrame(&r);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::OnStopFrame(imgIRequest *aRequest, nsISupports *aContext, gfxIImageFrame *aFrame)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::OnStopContainer(imgIRequest *aRequest, nsISupports *aContext, imgIContainer *aImage)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::OnStopDecode(imgIRequest *aRequest, nsISupports *aContext, nsresult status, const PRUnichar *statusArg)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoader::FrameChanged(imgIContainer *aContainer, nsISupports *aContext, gfxIImageFrame *newframe, nsRect * dirtyRect)
|
||||
{
|
||||
if (!mFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsRect r(*dirtyRect);
|
||||
|
||||
float p2t;
|
||||
mPresContext->GetPixelsToTwips(&p2t);
|
||||
r.x = NSIntPixelsToTwips(r.x, p2t);
|
||||
r.y = NSIntPixelsToTwips(r.y, p2t);
|
||||
r.width = NSIntPixelsToTwips(r.width, p2t);
|
||||
r.height = NSIntPixelsToTwips(r.height, p2t);
|
||||
|
||||
RedrawDirtyFrame(&r);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsImageLoader::RedrawDirtyFrame(const nsRect* aDamageRect)
|
||||
{
|
||||
// Determine damaged area and tell view manager to redraw it
|
||||
nsPoint offset;
|
||||
nsRect bounds;
|
||||
nsIView* view;
|
||||
|
||||
// NOTE: It is not sufficient to invalidate only the size of the image:
|
||||
// the image may be tiled!
|
||||
// The best option is to call into the frame, however lacking this
|
||||
// we have to at least invalidate the frame's bounds, hence
|
||||
// as long as we have a frame we'll use its size.
|
||||
//
|
||||
|
||||
// Invalidate the entire frame
|
||||
// XXX We really only need to invalidate the client area of the frame...
|
||||
mFrame->GetRect(bounds);
|
||||
bounds.x = bounds.y = 0;
|
||||
|
||||
// XXX this should be ok, but there is some crappy ass bug causing it not to work
|
||||
// XXX seems related to the "body fixup rule" dealing with the canvas and body frames...
|
||||
#if 0
|
||||
// Invalidate the entire frame only if the frame has a tiled background
|
||||
// image, otherwise just invalidate the intersection of the frame's bounds
|
||||
// with the damaged rect.
|
||||
nsCOMPtr<nsIStyleContext> styleContext;
|
||||
mFrame->GetStyleContext(getter_AddRefs(styleContext));
|
||||
const nsStyleBackground* bg = (const nsStyleBackground*)styleContext->GetStyleData(eStyleStruct_Background);
|
||||
|
||||
if ((bg->mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE) ||
|
||||
(bg->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT) ||
|
||||
(bg->mBackgroundRepeat == NS_STYLE_BG_REPEAT_OFF)) {
|
||||
// The frame does not have a background image so we are free
|
||||
// to invalidate only the intersection of the damage rect and
|
||||
// the frame's bounds.
|
||||
|
||||
if (aDamageRect) {
|
||||
bounds.IntersectRect(*aDamageRect, bounds);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
if ((bounds.width > 0) && (bounds.height > 0)) {
|
||||
|
||||
// XXX We should tell the frame the damage area and let it invalidate
|
||||
// itself. Add some API calls to nsIFrame to allow a caller to invalidate
|
||||
// parts of the frame...
|
||||
mFrame->GetView(mPresContext, &view);
|
||||
if (!view) {
|
||||
mFrame->GetOffsetFromView(mPresContext, offset, &view);
|
||||
bounds.x += offset.x;
|
||||
bounds.y += offset.y;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIViewManager> vm = nsnull;
|
||||
nsresult rv = NS_OK;
|
||||
rv = view->GetViewManager(*getter_AddRefs(vm));
|
||||
if (NS_SUCCEEDED(rv) && vm) {
|
||||
vm->UpdateView(view, bounds, NS_VMREFRESH_NO_SYNC);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
/* -*- 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 "imgIDecoderObserver.h"
|
||||
|
||||
class nsIPresContext;
|
||||
class nsIFrame;
|
||||
|
||||
#include "nsString.h"
|
||||
|
||||
#include "imgIRequest.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsImageLoader : public imgIDecoderObserver
|
||||
{
|
||||
public:
|
||||
nsImageLoader();
|
||||
virtual ~nsImageLoader();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_IMGIDECODEROBSERVER
|
||||
NS_DECL_IMGICONTAINEROBSERVER
|
||||
|
||||
void Init(nsIFrame *aFrame, nsIPresContext *aPresContext);
|
||||
nsresult Load(const nsAReadableString &aURI);
|
||||
|
||||
void Destroy();
|
||||
|
||||
nsIFrame *GetFrame() { return mFrame; }
|
||||
void GetRequest(imgIRequest **aRequest) { *aRequest = mRequest; NS_IF_ADDREF(*aRequest); }
|
||||
|
||||
private:
|
||||
void RedrawDirtyFrame(const nsRect* aDamageRect);
|
||||
|
||||
private:
|
||||
nsIFrame *mFrame;
|
||||
nsIPresContext *mPresContext;
|
||||
nsCOMPtr<imgIRequest> mRequest;
|
||||
};
|
|
@ -27,9 +27,8 @@
|
|||
#include "nsILinkHandler.h"
|
||||
#include "nsIDocShellTreeItem.h"
|
||||
#include "nsIStyleSet.h"
|
||||
#include "nsFrameImageLoader.h"
|
||||
#include "nsIFrameManager.h"
|
||||
#include "nsIImageGroup.h"
|
||||
#include "nsImageLoader.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
|
@ -96,6 +95,15 @@ IsVisualCharset(const nsAutoString& aCharset)
|
|||
}
|
||||
#endif // IBMBIDI
|
||||
|
||||
|
||||
static PRBool destroy_loads(nsHashKey *aKey, void *aData, void* closure)
|
||||
{
|
||||
nsISupports *sup = NS_REINTERPRET_CAST(nsISupports*, aData);
|
||||
nsImageLoader *loader = NS_REINTERPRET_CAST(nsImageLoader*, sup);
|
||||
loader->Destroy();
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
#include "nsContentCID.h"
|
||||
static NS_DEFINE_CID(kEventStateManagerCID, NS_EVENTSTATEMANAGER_CID);
|
||||
|
@ -121,7 +129,7 @@ nsPresContext::nsPresContext()
|
|||
|
||||
mStopped = PR_FALSE;
|
||||
mStopChrome = PR_TRUE;
|
||||
|
||||
|
||||
mShell = nsnull;
|
||||
|
||||
mDefaultColor = NS_RGB(0x00, 0x00, 0x00);
|
||||
|
@ -161,6 +169,8 @@ nsPresContext::nsPresContext()
|
|||
|
||||
nsPresContext::~nsPresContext()
|
||||
{
|
||||
mImageLoaders.Enumerate(destroy_loads);
|
||||
|
||||
if (mShell) {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
mShell->GetDocument(getter_AddRefs(doc));
|
||||
|
@ -171,14 +181,6 @@ nsPresContext::~nsPresContext()
|
|||
|
||||
mShell = nsnull;
|
||||
|
||||
Stop();
|
||||
|
||||
if (mImageGroup) {
|
||||
// Interrupt any loading images. This also stops all looping
|
||||
// image animations.
|
||||
mImageGroup->Interrupt();
|
||||
}
|
||||
|
||||
if (mEventManager)
|
||||
mEventManager->SetPresContext(nsnull); // unclear if this is needed, but can't hurt
|
||||
|
||||
|
@ -1168,60 +1170,30 @@ nsPresContext::GetDeviceContext(nsIDeviceContext** aResult) const
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetImageGroup(nsIImageGroup** aResult)
|
||||
nsPresContext::LoadImage(const nsString& aURL,
|
||||
nsIFrame* aTargetFrame,
|
||||
imgIRequest **aRequest)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aResult, "null ptr");
|
||||
if (nsnull == aResult) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
// look and see if we have a loader for the target frame.
|
||||
|
||||
if (!mImageGroup) {
|
||||
// Create image group
|
||||
nsresult rv = NS_NewImageGroup(getter_AddRefs(mImageGroup));
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
nsVoidKey key(aTargetFrame);
|
||||
nsImageLoader *loader = NS_REINTERPRET_CAST(nsImageLoader*, mImageLoaders.Get(&key)); // addrefs
|
||||
|
||||
// Initialize the image group
|
||||
nsCOMPtr<nsIURIContentListener> loadHandler (do_GetInterface(mContainer, &rv));
|
||||
if (NS_SUCCEEDED(rv) && loadHandler)
|
||||
{
|
||||
nsCOMPtr<nsISupports> loadContext;
|
||||
loadHandler->GetLoadCookie(getter_AddRefs(loadContext));
|
||||
rv = mImageGroup->Init(mDeviceContext, loadContext);
|
||||
}
|
||||
if (!loader) {
|
||||
nsImageLoader *newLoader = new nsImageLoader();
|
||||
if (!newLoader)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
NS_ADDREF(newLoader); // new
|
||||
|
||||
*aResult = mImageGroup;
|
||||
NS_IF_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsISupports> sup;
|
||||
newLoader->QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(sup));
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::StartLoadImage(const nsString& aURL,
|
||||
const nscolor* aBackgroundColor,
|
||||
const nsSize* aDesiredSize,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsIFrameImageLoaderCB aCallBack,
|
||||
void* aClosure,
|
||||
void* aKey,
|
||||
nsIFrameImageLoader** aResult)
|
||||
{
|
||||
if (mStopped) {
|
||||
// if we are stopped and the image is not chrome
|
||||
// don't load.
|
||||
// If we are chrome don't load if we
|
||||
// were told to stop chrome
|
||||
if (!aURL.EqualsWithConversion("chrome:", PR_TRUE, 7) || mStopChrome) {
|
||||
if (aResult) {
|
||||
*aResult = nsnull;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
loader = NS_REINTERPRET_CAST(nsImageLoader*, sup.get());
|
||||
|
||||
loader->Init(aTargetFrame, this);
|
||||
|
||||
mImageLoaders.Put(&key, sup);
|
||||
}
|
||||
|
||||
// Allow for a null target frame argument (for precached images)
|
||||
|
@ -1233,173 +1205,32 @@ nsPresContext::StartLoadImage(const nsString& aURL,
|
|||
aTargetFrame->SetFrameState(state);
|
||||
}
|
||||
|
||||
// Lookup image request in our loaders array (maybe the load request
|
||||
// has already been made for that url at the desired size).
|
||||
PRInt32 i, n = mImageLoaders.Count();
|
||||
nsIFrameImageLoader* loader;
|
||||
for (i = 0; i < n; i++) {
|
||||
PRBool same;
|
||||
loader = (nsIFrameImageLoader*) mImageLoaders.ElementAt(i);
|
||||
loader->IsSameImageRequest(aURL, aBackgroundColor, aDesiredSize, &same);
|
||||
if (same) {
|
||||
// This is pretty sick, but because we can get a notification
|
||||
// *before* the caller has returned we have to store into
|
||||
// aResult before calling the AddFrame method.
|
||||
if (aResult) {
|
||||
NS_ADDREF(loader);
|
||||
*aResult = loader;
|
||||
}
|
||||
loader->Load(aURL);
|
||||
|
||||
// Add frame to list of interested frames for this loader
|
||||
loader->AddFrame(aTargetFrame, aCallBack, aClosure, aKey);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Check with the content-policy things to make sure this load is permitted.
|
||||
PRBool shouldLoad = PR_TRUE; // default permit
|
||||
nsCOMPtr<nsIContent> content;
|
||||
nsCOMPtr<nsIDOMElement> element;
|
||||
if (aTargetFrame &&
|
||||
NS_SUCCEEDED(aTargetFrame->GetContent(getter_AddRefs(content)))) {
|
||||
element = do_QueryInterface(content);
|
||||
}
|
||||
loader->GetRequest(aRequest);
|
||||
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ASSERTION(0, "was expecting a URI");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocument> document;
|
||||
rv = mShell->GetDocument(getter_AddRefs(document));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
NS_RELEASE(loader);
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalScript;
|
||||
rv = document->GetScriptGlobalObject(getter_AddRefs(globalScript));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMWindow> domWin(do_QueryInterface(globalScript));
|
||||
|
||||
if (NS_SUCCEEDED(NS_CheckContentLoadPolicy(nsIContentPolicy::IMAGE,
|
||||
uri, element, domWin, &shouldLoad))
|
||||
&& !shouldLoad) {
|
||||
return NS_OK;
|
||||
}
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::StopImagesFor(nsIFrame* aTargetFrame)
|
||||
{
|
||||
nsVoidKey key(aTargetFrame);
|
||||
nsImageLoader *loader = NS_REINTERPRET_CAST(nsImageLoader*, mImageLoaders.Get(&key)); // addrefs
|
||||
|
||||
// Create image group if needed
|
||||
if (!mImageGroup) {
|
||||
nsCOMPtr<nsIImageGroup> group;
|
||||
rv = GetImageGroup(getter_AddRefs(group)); // sets mImageGroup as side effect
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// We haven't seen that image before. Create a new loader and
|
||||
// start it going.
|
||||
rv = NS_NewFrameImageLoader(&loader);
|
||||
if (NS_OK != rv) {
|
||||
return rv;
|
||||
}
|
||||
mImageLoaders.AppendElement(loader);
|
||||
|
||||
// This is pretty sick, but because we can get a notification
|
||||
// *before* the caller has returned we have to store into aResult
|
||||
// before calling the loaders init method.
|
||||
if (aResult) {
|
||||
*aResult = loader;
|
||||
NS_ADDREF(loader);
|
||||
}
|
||||
|
||||
rv = loader->Init(this, mImageGroup, aURL, aBackgroundColor, aDesiredSize,
|
||||
aTargetFrame, mImageAnimationMode, aCallBack, aClosure,
|
||||
aKey);
|
||||
if (NS_OK != rv) {
|
||||
mImageLoaders.RemoveElement(loader);
|
||||
loader->StopImageLoad();
|
||||
if (loader) {
|
||||
loader->Destroy();
|
||||
NS_RELEASE(loader);
|
||||
|
||||
// Undo premature store of reslut
|
||||
if (aResult) {
|
||||
*aResult = nsnull;
|
||||
NS_RELEASE(loader);
|
||||
}
|
||||
return rv;
|
||||
mImageLoaders.Remove(&key);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::Stop(PRBool aStopChrome)
|
||||
{
|
||||
mStopChrome = aStopChrome;
|
||||
PRInt32 n = mImageLoaders.Count();
|
||||
for (PRInt32 i = n-1; i >= 0; i--) {
|
||||
nsIFrameImageLoader* loader;
|
||||
loader = (nsIFrameImageLoader*) mImageLoaders.ElementAt(i);
|
||||
if (NS_SUCCEEDED(loader->StopImageLoad(aStopChrome))) {
|
||||
mImageLoaders.RemoveElementAt(i);
|
||||
NS_RELEASE(loader);
|
||||
}
|
||||
}
|
||||
|
||||
mStopped = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::StopLoadImage(void* aKey, nsIFrameImageLoader* aLoader)
|
||||
{
|
||||
PRInt32 i, n = mImageLoaders.Count();
|
||||
nsIFrameImageLoader* loader;
|
||||
for (i = 0; i < n; i++) {
|
||||
loader = (nsIFrameImageLoader*) mImageLoaders.ElementAt(i);
|
||||
if (loader == aLoader) {
|
||||
// Remove frame from list of interested frames for this loader
|
||||
loader->RemoveFrame(aKey);
|
||||
|
||||
// If loader is no longer loading for anybody and its safe to
|
||||
// nuke it, nuke it.
|
||||
PRBool safe;
|
||||
loader->SafeToDestroy(&safe);
|
||||
if (safe) {
|
||||
loader->StopImageLoad();
|
||||
NS_RELEASE(loader);
|
||||
mImageLoaders.RemoveElementAt(i);
|
||||
n--;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::StopAllLoadImagesFor(nsIFrame* aTargetFrame, void *aKey)
|
||||
{
|
||||
nsFrameState state;
|
||||
aTargetFrame->GetFrameState(&state);
|
||||
if (NS_FRAME_HAS_LOADED_IMAGES & state) {
|
||||
nsIFrameImageLoader* loader;
|
||||
PRInt32 i, n = mImageLoaders.Count();
|
||||
for (i = 0; i < n; i++) {
|
||||
PRBool safe;
|
||||
loader = (nsIFrameImageLoader*) mImageLoaders.ElementAt(i);
|
||||
loader->RemoveFrame(aKey);
|
||||
loader->SafeToDestroy(&safe);
|
||||
if (safe) {
|
||||
loader->StopImageLoad();
|
||||
NS_RELEASE(loader);
|
||||
mImageLoaders.RemoveElementAt(i);
|
||||
n--;
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::SetLinkHandler(nsILinkHandler* aHandler)
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "nsFont.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIImageGroup.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsILanguageAtomService.h"
|
||||
|
@ -41,6 +40,8 @@
|
|||
#include "nsIUBidiUtils.h"
|
||||
#endif
|
||||
|
||||
#include "nsHashtable.h"
|
||||
|
||||
// Base class for concrete presentation context classes
|
||||
class nsPresContext : public nsIPresContext, public nsIObserver {
|
||||
public:
|
||||
|
@ -51,7 +52,6 @@ public:
|
|||
|
||||
// nsIPresContext methods
|
||||
NS_IMETHOD Init(nsIDeviceContext* aDeviceContext);
|
||||
NS_IMETHOD Stop(PRBool aStopChrome = PR_TRUE);
|
||||
NS_IMETHOD SetShell(nsIPresShell* aShell);
|
||||
NS_IMETHOD GetShell(nsIPresShell** aResult);
|
||||
NS_IMETHOD GetCompatibilityMode(nsCompatibility* aModeResult);
|
||||
|
@ -122,17 +122,11 @@ public:
|
|||
NS_IMETHOD SetDefaultLinkColor(nscolor aColor);
|
||||
NS_IMETHOD SetDefaultVisitedLinkColor(nscolor aColor);
|
||||
|
||||
NS_IMETHOD GetImageGroup(nsIImageGroup** aGroupResult);
|
||||
NS_IMETHOD StartLoadImage(const nsString& aURL,
|
||||
const nscolor* aBackgroundColor,
|
||||
const nsSize* aDesiredSize,
|
||||
nsIFrame* aTargetFrame,
|
||||
nsIFrameImageLoaderCB aCallBack,
|
||||
void* aClosure,
|
||||
void* aKey,
|
||||
nsIFrameImageLoader** aResult);
|
||||
NS_IMETHOD StopLoadImage(void* aKey, nsIFrameImageLoader* aLoader);
|
||||
NS_IMETHOD StopAllLoadImagesFor(nsIFrame* aTargetFrame, void* aKey);
|
||||
NS_IMETHOD LoadImage(const nsString& aURL,
|
||||
nsIFrame* aTargetFrame,
|
||||
imgIRequest **aRequest);
|
||||
|
||||
NS_IMETHOD StopImagesFor(nsIFrame* aTargetFrame);
|
||||
NS_IMETHOD SetContainer(nsISupports* aContainer);
|
||||
NS_IMETHOD GetContainer(nsISupports** aResult);
|
||||
NS_IMETHOD SetLinkHandler(nsILinkHandler* aHandler);
|
||||
|
@ -199,7 +193,6 @@ protected:
|
|||
nsCOMPtr<nsILanguageAtomService> mLangService;
|
||||
nsCOMPtr<nsILanguageAtom> mLanguage;
|
||||
nsLanguageSpecificTransformType mLanguageSpecificTransformType;
|
||||
nsCOMPtr<nsIImageGroup> mImageGroup;
|
||||
nsILinkHandler* mLinkHandler; // [WEAK]
|
||||
nsISupports* mContainer; // [WEAK]
|
||||
nsCOMPtr<nsILookAndFeel> mLookAndFeel;
|
||||
|
@ -223,7 +216,9 @@ protected:
|
|||
nscoord mDefaultBackgroundImageOffsetX;
|
||||
nscoord mDefaultBackgroundImageOffsetY;
|
||||
PRUint8 mDefaultBackgroundImageAttachment;
|
||||
nsVoidArray mImageLoaders;
|
||||
|
||||
nsSupportsHashtable mImageLoaders;
|
||||
|
||||
nsCOMPtr<nsIEventStateManager> mEventManager;
|
||||
nsCOMPtr<nsIURI> mBaseURL;
|
||||
nsCompatibility mCompatibilityMode;
|
||||
|
|
|
@ -33,14 +33,44 @@
|
|||
#include "nsIDocument.h"
|
||||
#include "nsIReflowCommand.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "prprf.h"
|
||||
#include "nsIImage.h"
|
||||
#ifdef IBMBIDI
|
||||
#include "nsBidiPresUtils.h"
|
||||
#endif // IBMBIDI
|
||||
|
||||
#include "imgILoader.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "imgIDecoderObserver.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
|
||||
class nsBulletListener : public imgIDecoderObserver
|
||||
{
|
||||
public:
|
||||
nsBulletListener();
|
||||
virtual ~nsBulletListener();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_IMGIDECODEROBSERVER
|
||||
NS_DECL_IMGICONTAINEROBSERVER
|
||||
|
||||
void SetFrame(nsBulletFrame *frame) { mFrame = frame; }
|
||||
|
||||
private:
|
||||
nsBulletFrame *mFrame;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
nsBulletFrame::nsBulletFrame()
|
||||
{
|
||||
}
|
||||
|
@ -53,7 +83,13 @@ NS_IMETHODIMP
|
|||
nsBulletFrame::Destroy(nsIPresContext* aPresContext)
|
||||
{
|
||||
// Stop image loading first
|
||||
mImageLoader.StopAllLoadImages(aPresContext);
|
||||
if (mImageRequest) {
|
||||
mImageRequest->Cancel(NS_ERROR_FAILURE);
|
||||
mImageRequest = nsnull;
|
||||
}
|
||||
|
||||
if (mListener)
|
||||
NS_REINTERPRET_CAST(nsBulletListener*, mListener.get())->SetFrame(nsnull);
|
||||
|
||||
// Let base class do the rest
|
||||
return nsFrame::Destroy(aPresContext);
|
||||
|
@ -66,29 +102,36 @@ nsBulletFrame::Init(nsIPresContext* aPresContext,
|
|||
nsIStyleContext* aContext,
|
||||
nsIFrame* aPrevInFlow)
|
||||
{
|
||||
nsresult rv = nsFrame::Init(aPresContext, aContent, aParent,
|
||||
aContext, aPrevInFlow);
|
||||
nsresult rv = nsFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
||||
|
||||
nsIURI* baseURL = nsnull;
|
||||
nsIHTMLContent* htmlContent;
|
||||
rv = mContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
htmlContent->GetBaseURL(baseURL);
|
||||
NS_RELEASE(htmlContent);
|
||||
}
|
||||
else {
|
||||
nsIDocument* doc;
|
||||
rv = mContent->GetDocument(doc);
|
||||
if (NS_SUCCEEDED(rv) && doc) {
|
||||
doc->GetBaseURL(baseURL);
|
||||
NS_RELEASE(doc);
|
||||
const nsStyleList* myList = (const nsStyleList*)mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
|
||||
if (!myList->mListStyleImage.IsEmpty()) {
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
GetBaseURI(getter_AddRefs(baseURI));
|
||||
|
||||
nsCOMPtr<nsIURI> imgURI;
|
||||
NS_NewURI(getter_AddRefs(imgURI), myList->mListStyleImage, baseURI);
|
||||
|
||||
if (!mListener) {
|
||||
nsBulletListener *listener;
|
||||
NS_NEWXPCOM(listener, nsBulletListener);
|
||||
NS_ADDREF(listener);
|
||||
listener->SetFrame(this);
|
||||
listener->QueryInterface(NS_GET_IID(imgIDecoderObserver), getter_AddRefs(mListener));
|
||||
NS_ASSERTION(mListener, "queryinterface for the listener failed");
|
||||
NS_RELEASE(listener);
|
||||
}
|
||||
|
||||
il->LoadImage(imgURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, getter_AddRefs(mImageRequest));
|
||||
}
|
||||
const nsStyleList* myList = (const nsStyleList*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
mImageLoader.Init(this, UpdateBulletCB, this,
|
||||
baseURL, myList->mListStyleImage);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -123,27 +166,29 @@ nsBulletFrame::Paint(nsIPresContext* aPresContext,
|
|||
|
||||
PRBool isVisible;
|
||||
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && isVisible) {
|
||||
const nsStyleList* myList =
|
||||
(const nsStyleList*)mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
const nsStyleList* myList = (const nsStyleList*)mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
PRUint8 listStyleType = myList->mListStyleType;
|
||||
|
||||
if (myList->mListStyleImage.Length() > 0) {
|
||||
nsCOMPtr<nsIImage> image = dont_AddRef(mImageLoader.GetImage());
|
||||
if (image) {
|
||||
if (!mImageLoader.GetLoadImageFailed()) {
|
||||
if (myList->mListStyleImage.Length() > 0 && mImageRequest) {
|
||||
PRUint32 status;
|
||||
mImageRequest->GetImageStatus(&status);
|
||||
if (status & imgIRequest::STATUS_LOAD_COMPLETE) {
|
||||
nsCOMPtr<imgIContainer> imageCon;
|
||||
mImageRequest->GetImage(getter_AddRefs(imageCon));
|
||||
if (imageCon) {
|
||||
nsRect innerArea(mPadding.left, mPadding.top,
|
||||
mRect.width - (mPadding.left + mPadding.right),
|
||||
mRect.height - (mPadding.top + mPadding.bottom));
|
||||
aRenderingContext.DrawImage(image, innerArea);
|
||||
nsPoint p(innerArea.x, innerArea.y);
|
||||
innerArea.x = innerArea.y = 0;
|
||||
aRenderingContext.DrawImage(imageCon, &innerArea, &p);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const nsStyleFont* myFont =
|
||||
(const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font);
|
||||
const nsStyleColor* myColor =
|
||||
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
const nsStyleFont* myFont = (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font);
|
||||
const nsStyleColor* myColor = (const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
|
||||
nsCOMPtr<nsIFontMetrics> fm;
|
||||
aRenderingContext.SetColor(myColor->mColor);
|
||||
|
@ -1047,58 +1092,107 @@ nsBulletFrame::GetListItemText(nsIPresContext* aCX,
|
|||
|
||||
#define MIN_BULLET_SIZE 5 // from laytext.c
|
||||
|
||||
nsresult
|
||||
nsBulletFrame::UpdateBulletCB(nsIPresContext* aPresContext,
|
||||
nsHTMLImageLoader* aLoader,
|
||||
nsIFrame* aFrame,
|
||||
void* aClosure,
|
||||
PRUint32 aStatus)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if ((NS_IMAGE_LOAD_STATUS_SIZE_AVAILABLE|NS_IMAGE_LOAD_STATUS_ERROR)
|
||||
& aStatus) {
|
||||
// Now that the size is available (or an error occurred), trigger
|
||||
// a reflow of the bullet frame.
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
rv = aPresContext->GetShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv) && shell) {
|
||||
nsIFrame* parent;
|
||||
aFrame->GetParent(&parent);
|
||||
if (parent) {
|
||||
// Reflow the first child of the parent not the bullet frame.
|
||||
// The bullet frame is not in a line list so marking it dirty
|
||||
// has no effect. The reflowing of the bullet frame is done
|
||||
// indirectly.
|
||||
nsIFrame* frame = nsnull;
|
||||
parent->FirstChild(aPresContext, nsnull, &frame);
|
||||
if (nsnull != frame) {
|
||||
nsFrameState state;
|
||||
frame->GetFrameState(&state);
|
||||
state |= NS_FRAME_IS_DIRTY;
|
||||
frame->SetFrameState(state);
|
||||
parent->ReflowDirtyChild(shell, frame);
|
||||
} else {
|
||||
NS_ASSERTION(0, "No frame to mark dirty for bullet frame.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(0, "No parent to pass the reflow request up to.");
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
#define MINMAX(_value,_min,_max) \
|
||||
((_value) < (_min) \
|
||||
? (_min) \
|
||||
: ((_value) > (_max) \
|
||||
? (_max) \
|
||||
: (_value)))
|
||||
|
||||
|
||||
void
|
||||
nsBulletFrame::GetDesiredSize(nsIPresContext* aCX,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aMetrics)
|
||||
{
|
||||
const nsStyleList* myList =
|
||||
(const nsStyleList*)mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
const nsStyleList* myList = (const nsStyleList*)mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
nscoord ascent;
|
||||
|
||||
if (myList->mListStyleImage.Length() > 0) {
|
||||
if (!myList->mListStyleImage.IsEmpty()) {
|
||||
nscoord widthConstraint = NS_INTRINSICSIZE;
|
||||
nscoord heightConstraint = NS_INTRINSICSIZE;
|
||||
PRBool fixedContentWidth = PR_FALSE;
|
||||
PRBool fixedContentHeight = PR_FALSE;
|
||||
|
||||
nscoord minWidth, maxWidth, minHeight, maxHeight;
|
||||
|
||||
// Determine whether the image has fixed content width
|
||||
widthConstraint = aReflowState.mComputedWidth;
|
||||
minWidth = aReflowState.mComputedMinWidth;
|
||||
maxWidth = aReflowState.mComputedMaxWidth;
|
||||
if (widthConstraint != NS_INTRINSICSIZE) {
|
||||
fixedContentWidth = PR_TRUE;
|
||||
}
|
||||
|
||||
// Determine whether the image has fixed content height
|
||||
heightConstraint = aReflowState.mComputedHeight;
|
||||
minHeight = aReflowState.mComputedMinHeight;
|
||||
maxHeight = aReflowState.mComputedMaxHeight;
|
||||
if (heightConstraint != NS_UNCONSTRAINEDSIZE) {
|
||||
fixedContentHeight = PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool haveComputedSize = PR_FALSE;
|
||||
PRBool needIntrinsicImageSize = PR_FALSE;
|
||||
|
||||
nscoord newWidth=0, newHeight=0;
|
||||
if (fixedContentWidth) {
|
||||
newWidth = MINMAX(widthConstraint, minWidth, maxWidth);
|
||||
if (fixedContentHeight) {
|
||||
newHeight = MINMAX(heightConstraint, minHeight, maxHeight);
|
||||
haveComputedSize = PR_TRUE;
|
||||
} else {
|
||||
// We have a width, and an auto height. Compute height from
|
||||
// width once we have the intrinsic image size.
|
||||
if (mIntrinsicSize.height != 0) {
|
||||
newHeight = (mIntrinsicSize.height * newWidth) / mIntrinsicSize.width;
|
||||
haveComputedSize = PR_TRUE;
|
||||
} else {
|
||||
newHeight = 0;
|
||||
needIntrinsicImageSize = PR_TRUE;
|
||||
}
|
||||
}
|
||||
} else if (fixedContentHeight) {
|
||||
// We have a height, and an auto width. Compute width from height
|
||||
// once we have the intrinsic image size.
|
||||
newHeight = MINMAX(heightConstraint, minHeight, maxHeight);
|
||||
if (mIntrinsicSize.width != 0) {
|
||||
newWidth = (mIntrinsicSize.width * newHeight) / mIntrinsicSize.height;
|
||||
haveComputedSize = PR_TRUE;
|
||||
} else {
|
||||
newWidth = 0;
|
||||
needIntrinsicImageSize = PR_TRUE;
|
||||
}
|
||||
} else {
|
||||
// auto size the image
|
||||
if (mIntrinsicSize.width == 0 && mIntrinsicSize.height == 0)
|
||||
needIntrinsicImageSize = PR_TRUE;
|
||||
else
|
||||
haveComputedSize = PR_TRUE;
|
||||
|
||||
newWidth = mIntrinsicSize.width;
|
||||
newHeight = mIntrinsicSize.height;
|
||||
}
|
||||
|
||||
mComputedSize.width = newWidth;
|
||||
mComputedSize.height = newHeight;
|
||||
|
||||
#if 0 // don't do scaled images in bullets
|
||||
if (mComputedSize == mIntrinsicSize) {
|
||||
mTransform.SetToIdentity();
|
||||
} else {
|
||||
if (mComputedSize.width != 0 && mComputedSize.height != 0) {
|
||||
mTransform.SetToScale(float(mIntrinsicSize.width) / float(mComputedSize.width),
|
||||
float(mIntrinsicSize.height) / float(mComputedSize.height));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
aMetrics.width = mComputedSize.width;
|
||||
aMetrics.height = mComputedSize.height;
|
||||
|
||||
#if 0
|
||||
mImageLoader.GetDesiredSize(aCX, &aReflowState, aMetrics);
|
||||
if (!mImageLoader.GetLoadImageFailed()) {
|
||||
nsHTMLContainerFrame::CreateViewForFrame(aCX, this, mStyleContext, nsnull,
|
||||
|
@ -1107,6 +1201,14 @@ nsBulletFrame::GetDesiredSize(nsIPresContext* aCX,
|
|||
aMetrics.descent = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
aMetrics.ascent = aMetrics.height;
|
||||
aMetrics.descent = 0;
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
const nsStyleFont* myFont =
|
||||
|
@ -1214,20 +1316,59 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
|
|||
if (eReflowReason_Incremental == aReflowState.reason) {
|
||||
nsIReflowCommand::ReflowType type;
|
||||
aReflowState.reflowCommand->GetType(type);
|
||||
|
||||
/* if the style changed, see if we need to load a new url */
|
||||
if (nsIReflowCommand::StyleChanged == type) {
|
||||
// Reload the image, maybe...
|
||||
nsAutoString oldImageURL;
|
||||
mImageLoader.GetURLSpec(oldImageURL);
|
||||
const nsStyleList* myList = (const nsStyleList*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
if (myList->mListStyleImage != oldImageURL) {
|
||||
mImageLoader.UpdateURLSpec(aPresContext, myList->mListStyleImage);
|
||||
// XXX - invlidate here is fragile as our parent can choose to change our size
|
||||
// however currently the parent accepts our size so this works.
|
||||
// Also, it might be better to invalidate when the image has actually loaded
|
||||
// instead of when we request the image to load...
|
||||
// This, however, works as it is currently used (bug 8862 is fixed)
|
||||
Invalidate(aPresContext, nsRect(0, 0, mRect.width, mRect.height));
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
GetBaseURI(getter_AddRefs(baseURI));
|
||||
|
||||
const nsStyleList* myList = (const nsStyleList*)mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
|
||||
if (!myList->mListStyleImage.IsEmpty()) {
|
||||
|
||||
if (!mListener) {
|
||||
nsBulletListener *listener;
|
||||
NS_NEWXPCOM(listener, nsBulletListener);
|
||||
NS_ADDREF(listener);
|
||||
listener->SetFrame(this);
|
||||
listener->QueryInterface(NS_GET_IID(imgIDecoderObserver), getter_AddRefs(mListener));
|
||||
NS_ASSERTION(mListener, "queryinterface for the listener failed");
|
||||
NS_RELEASE(listener);
|
||||
}
|
||||
|
||||
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
NS_NewURI(getter_AddRefs(newURI), myList->mListStyleImage, baseURI);
|
||||
|
||||
PRBool needNewRequest = PR_TRUE;
|
||||
|
||||
if (mImageRequest) {
|
||||
// Reload the image, maybe...
|
||||
nsCOMPtr<nsIURI> oldURI;
|
||||
mImageRequest->GetURI(getter_AddRefs(oldURI));
|
||||
if (oldURI) {
|
||||
PRBool same;
|
||||
newURI->Equals(oldURI, &same);
|
||||
if (same) {
|
||||
needNewRequest = PR_FALSE;
|
||||
} else {
|
||||
mImageRequest->Cancel(NS_ERROR_FAILURE);
|
||||
mImageRequest = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needNewRequest) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
|
||||
|
||||
il->LoadImage(newURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, getter_AddRefs(mImageRequest));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1250,3 +1391,244 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
|
|||
aStatus = NS_FRAME_COMPLETE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsBulletFrame::OnStartContainer(imgIRequest *aRequest, nsIPresContext *aPresContext, imgIContainer *aImage)
|
||||
{
|
||||
if (!aImage) return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nscoord w, h;
|
||||
aImage->GetWidth(&w);
|
||||
aImage->GetHeight(&h);
|
||||
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
|
||||
nsSize newsize(NSIntPixelsToTwips(w, p2t), NSIntPixelsToTwips(h, p2t));
|
||||
|
||||
if (mIntrinsicSize != newsize) {
|
||||
mIntrinsicSize = newsize;
|
||||
|
||||
// Now that the size is available (or an error occurred), trigger
|
||||
// a reflow of the bullet frame.
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = aPresContext->GetShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv) && shell) {
|
||||
NS_ASSERTION(mParent, "No parent to pass the reflow request up to.");
|
||||
if (mParent) {
|
||||
// Reflow the first child of the parent not the bullet frame.
|
||||
// The bullet frame is not in a line list so marking it dirty
|
||||
// has no effect. The reflowing of the bullet frame is done
|
||||
// indirectly.
|
||||
nsIFrame* frame = nsnull;
|
||||
mParent->FirstChild(aPresContext, nsnull, &frame);
|
||||
NS_ASSERTION(frame, "No frame to mark dirty for bullet frame.");
|
||||
if (frame) {
|
||||
nsFrameState state;
|
||||
frame->GetFrameState(&state);
|
||||
state |= NS_FRAME_IS_DIRTY;
|
||||
frame->SetFrameState(state);
|
||||
mParent->ReflowDirtyChild(shell, frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletFrame::OnDataAvailable(imgIRequest *aRequest, nsIPresContext *aPresContext, gfxIImageFrame *aFrame, const nsRect *aRect)
|
||||
{
|
||||
if (!aRect) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsRect r(*aRect);
|
||||
|
||||
/* XXX Why do we subtract 1 here? The rect is (for example): (0, 0, 600, 1)..
|
||||
Why do we have to make y -1?
|
||||
*/
|
||||
|
||||
// The y coordinate of aRect is passed as a scanline where the first scanline is given
|
||||
// a value of 1. We need to convert this to the nsFrames coordinate space by subtracting
|
||||
// 1.
|
||||
r.y -= 1;
|
||||
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
r.x = NSIntPixelsToTwips(r.x, p2t);
|
||||
r.y = NSIntPixelsToTwips(r.y, p2t);
|
||||
r.width = NSIntPixelsToTwips(r.width, p2t);
|
||||
r.height = NSIntPixelsToTwips(r.height, p2t);
|
||||
|
||||
Invalidate(aPresContext, r, PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletFrame::OnStopDecode(imgIRequest *aRequest, nsIPresContext *aPresContext, nsresult aStatus, const PRUnichar *aStatusArg)
|
||||
{
|
||||
// XXX should the bulletframe do anything if the image failed to load?
|
||||
// it didn't in the old code...
|
||||
#if 0
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||
|
||||
|
||||
if (NS_FAILED(aStatus)) {
|
||||
// We failed to load the image. Notify the pres shell
|
||||
if (NS_FAILED(aStatus) && (mImageRequest == aRequest || !mImageRequest)) {
|
||||
imageFailed = PR_TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletFrame::FrameChanged(imgIContainer *aContainer, nsIPresContext *aPresContext, gfxIImageFrame *aNewFrame, nsRect *aDirtyRect)
|
||||
{
|
||||
nsRect r(*aDirtyRect);
|
||||
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
r.x = NSIntPixelsToTwips(r.x, p2t);
|
||||
r.y = NSIntPixelsToTwips(r.y, p2t);
|
||||
r.width = NSIntPixelsToTwips(r.width, p2t);
|
||||
r.height = NSIntPixelsToTwips(r.height, p2t);
|
||||
|
||||
Invalidate(aPresContext, r, PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
nsBulletFrame::GetBaseURI(nsIURI **aURI)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aURI, "null OUT parameter pointer");
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsCOMPtr<nsIHTMLContent> htmlContent(do_QueryInterface(mContent, &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
htmlContent->GetBaseURL(*getter_AddRefs(baseURI));
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
rv = mContent->GetDocument(*getter_AddRefs(doc));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
doc->GetBaseURL(*getter_AddRefs(baseURI));
|
||||
}
|
||||
}
|
||||
*aURI = baseURI;
|
||||
NS_IF_ADDREF(*aURI);
|
||||
}
|
||||
|
||||
void
|
||||
nsBulletFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGroup)
|
||||
{
|
||||
if (!aPresContext)
|
||||
return;
|
||||
|
||||
NS_PRECONDITION(nsnull != aLoadGroup, "null OUT parameter pointer");
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
aPresContext->GetShell(getter_AddRefs(shell));
|
||||
|
||||
if (!shell)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
shell->GetDocument(getter_AddRefs(doc));
|
||||
if (!doc)
|
||||
return;
|
||||
|
||||
doc->GetDocumentLoadGroup(aLoadGroup);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsBulletListener, imgIDecoderObserver, imgIContainerObserver)
|
||||
|
||||
nsBulletListener::nsBulletListener() :
|
||||
mFrame(nsnull)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsBulletListener::~nsBulletListener()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::OnStartDecode(imgIRequest *aRequest, nsISupports *aContext)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::OnStartContainer(imgIRequest *aRequest, nsISupports *aContext, imgIContainer *aImage)
|
||||
{
|
||||
if (!mFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPresContext> pc(do_QueryInterface(aContext));
|
||||
|
||||
NS_ASSERTION(pc, "not a pres context!");
|
||||
|
||||
return mFrame->OnStartContainer(aRequest, pc, aImage);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::OnStartFrame(imgIRequest *aRequest, nsISupports *aContext, gfxIImageFrame *aFrame)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::OnDataAvailable(imgIRequest *aRequest, nsISupports *aContext, gfxIImageFrame *aFrame, const nsRect *aRect)
|
||||
{
|
||||
if (!mFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPresContext> pc(do_QueryInterface(aContext));
|
||||
|
||||
NS_ASSERTION(pc, "not a pres context!");
|
||||
|
||||
return mFrame->OnDataAvailable(aRequest, pc, aFrame, aRect);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::OnStopFrame(imgIRequest *aRequest, nsISupports *aContext, gfxIImageFrame *aFrame)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::OnStopContainer(imgIRequest *aRequest, nsISupports *aContext, imgIContainer *aImage)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::OnStopDecode(imgIRequest *aRequest, nsISupports *aContext, nsresult status, const PRUnichar *statusArg)
|
||||
{
|
||||
if (!mFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPresContext> pc(do_QueryInterface(aContext));
|
||||
|
||||
NS_ASSERTION(pc, "not a pres context!");
|
||||
|
||||
return mFrame->OnStopDecode(aRequest, pc, status, statusArg);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::FrameChanged(imgIContainer *aContainer, nsISupports *aContext, gfxIImageFrame *newframe, nsRect * dirtyRect)
|
||||
{
|
||||
if (!mFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPresContext> pc(do_QueryInterface(aContext));
|
||||
|
||||
NS_ASSERTION(pc, "not a pres context!");
|
||||
|
||||
return mFrame->FrameChanged(aContainer, pc, newframe, dirtyRect);
|
||||
}
|
||||
|
|
|
@ -23,9 +23,12 @@
|
|||
#define nsBulletFrame_h___
|
||||
|
||||
#include "nsFrame.h"
|
||||
#include "nsHTMLImageLoader.h"
|
||||
#include "nsIStyleContext.h"
|
||||
|
||||
#include "imgIRequest.h"
|
||||
#include "imgIDecoderObserver.h"
|
||||
class gfxIImageFrame;
|
||||
|
||||
/**
|
||||
* A simple class that manages the layout and rendering of html bullets.
|
||||
* This class also supports the CSS list-style properties.
|
||||
|
@ -60,6 +63,12 @@ public:
|
|||
// nsBulletFrame
|
||||
PRInt32 SetListItemOrdinal(PRInt32 aNextOrdinal, PRBool* aChanged);
|
||||
|
||||
|
||||
NS_IMETHOD OnStartContainer(imgIRequest *aRequest, nsIPresContext *aCX, imgIContainer *aImage);
|
||||
NS_IMETHOD OnDataAvailable(imgIRequest *aRequest, nsIPresContext *aCX, gfxIImageFrame *aFrame, const nsRect * rect);
|
||||
NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsIPresContext *aCX, nsresult aStatus, const PRUnichar *aStatusArg);
|
||||
NS_IMETHOD FrameChanged(imgIContainer *aContainer, nsIPresContext *aCX, gfxIImageFrame *aNewframe, nsRect *aDirtyRect);
|
||||
|
||||
protected:
|
||||
void GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
|
@ -69,15 +78,16 @@ protected:
|
|||
const nsStyleList& aStyleList,
|
||||
nsString& aResult);
|
||||
|
||||
static nsresult UpdateBulletCB(nsIPresContext* aPresContext,
|
||||
nsHTMLImageLoader* aLoader,
|
||||
nsIFrame* aFrame,
|
||||
void* aClosure,
|
||||
PRUint32 aStatus);
|
||||
void GetBaseURI(nsIURI **aURI);
|
||||
void GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGroup);
|
||||
|
||||
PRInt32 mOrdinal;
|
||||
nsMargin mPadding;
|
||||
nsHTMLImageLoader mImageLoader;
|
||||
nsCOMPtr<imgIRequest> mImageRequest;
|
||||
nsCOMPtr<imgIDecoderObserver> mListener;
|
||||
|
||||
nsSize mIntrinsicSize;
|
||||
nsSize mComputedSize;
|
||||
};
|
||||
|
||||
#endif /* nsBulletFrame_h___ */
|
||||
|
|
|
@ -436,7 +436,7 @@ nsFrame::Destroy(nsIPresContext* aPresContext)
|
|||
|
||||
//XXX Why is this done in nsFrame instead of some frame class
|
||||
// that actually loads images?
|
||||
aPresContext->StopAllLoadImagesFor(this, this);
|
||||
aPresContext->StopImagesFor(this);
|
||||
|
||||
if (view) {
|
||||
// Break association between view and frame
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "nsString.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIFrameImageLoader.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsIImage.h"
|
||||
|
@ -975,10 +974,12 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
|||
// indicating the status
|
||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
|
||||
!mInitialLoadCompleted) {
|
||||
DisplayAltFeedback(aPresContext, aRenderingContext,
|
||||
DisplayAltFeedback(aPresContext, aRenderingContext, 0);
|
||||
#ifndef USE_IMG2
|
||||
(loadStatus & imgIRequest::STATUS_ERROR)
|
||||
? NS_ICON_BROKEN_IMAGE
|
||||
: NS_ICON_LOADING_IMAGE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -43,7 +43,7 @@ struct nsSize;
|
|||
|
||||
class nsImageFrame;
|
||||
|
||||
class nsImageListener : imgIDecoderObserver
|
||||
class nsImageListener : public imgIDecoderObserver
|
||||
{
|
||||
public:
|
||||
nsImageListener(nsImageFrame *aFrame);
|
||||
|
|
|
@ -49,7 +49,6 @@ CPPSRCS = \
|
|||
nsHTMLContainerFrame.cpp \
|
||||
nsHTMLIIDs.cpp \
|
||||
nsHTMLFrame.cpp \
|
||||
nsHTMLImageLoader.cpp \
|
||||
nsHTMLReflowCommand.cpp \
|
||||
nsHTMLReflowState.cpp \
|
||||
nsImageFrame.cpp \
|
||||
|
|
|
@ -60,7 +60,6 @@ CPPSRCS= \
|
|||
nsHTMLContainerFrame.cpp \
|
||||
nsHTMLIIDs.cpp \
|
||||
nsHTMLFrame.cpp \
|
||||
nsHTMLImageLoader.cpp \
|
||||
nsHTMLReflowCommand.cpp \
|
||||
nsHTMLReflowState.cpp \
|
||||
nsImageFrame.cpp \
|
||||
|
@ -105,7 +104,6 @@ CPP_OBJS= \
|
|||
.\$(OBJDIR)\nsHRFrame.obj \
|
||||
.\$(OBJDIR)\nsHTMLContainerFrame.obj \
|
||||
.\$(OBJDIR)\nsHTMLFrame.obj \
|
||||
.\$(OBJDIR)\nsHTMLImageLoader.obj \
|
||||
.\$(OBJDIR)\nsHTMLIIDs.obj \
|
||||
.\$(OBJDIR)\nsHTMLReflowCommand.obj \
|
||||
.\$(OBJDIR)\nsHTMLReflowState.obj \
|
||||
|
|
|
@ -33,14 +33,44 @@
|
|||
#include "nsIDocument.h"
|
||||
#include "nsIReflowCommand.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsLayoutAtoms.h"
|
||||
#include "prprf.h"
|
||||
#include "nsIImage.h"
|
||||
#ifdef IBMBIDI
|
||||
#include "nsBidiPresUtils.h"
|
||||
#endif // IBMBIDI
|
||||
|
||||
#include "imgILoader.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "imgIDecoderObserver.h"
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
|
||||
|
||||
class nsBulletListener : public imgIDecoderObserver
|
||||
{
|
||||
public:
|
||||
nsBulletListener();
|
||||
virtual ~nsBulletListener();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_IMGIDECODEROBSERVER
|
||||
NS_DECL_IMGICONTAINEROBSERVER
|
||||
|
||||
void SetFrame(nsBulletFrame *frame) { mFrame = frame; }
|
||||
|
||||
private:
|
||||
nsBulletFrame *mFrame;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
nsBulletFrame::nsBulletFrame()
|
||||
{
|
||||
}
|
||||
|
@ -53,7 +83,13 @@ NS_IMETHODIMP
|
|||
nsBulletFrame::Destroy(nsIPresContext* aPresContext)
|
||||
{
|
||||
// Stop image loading first
|
||||
mImageLoader.StopAllLoadImages(aPresContext);
|
||||
if (mImageRequest) {
|
||||
mImageRequest->Cancel(NS_ERROR_FAILURE);
|
||||
mImageRequest = nsnull;
|
||||
}
|
||||
|
||||
if (mListener)
|
||||
NS_REINTERPRET_CAST(nsBulletListener*, mListener.get())->SetFrame(nsnull);
|
||||
|
||||
// Let base class do the rest
|
||||
return nsFrame::Destroy(aPresContext);
|
||||
|
@ -66,29 +102,36 @@ nsBulletFrame::Init(nsIPresContext* aPresContext,
|
|||
nsIStyleContext* aContext,
|
||||
nsIFrame* aPrevInFlow)
|
||||
{
|
||||
nsresult rv = nsFrame::Init(aPresContext, aContent, aParent,
|
||||
aContext, aPrevInFlow);
|
||||
nsresult rv = nsFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
||||
|
||||
nsIURI* baseURL = nsnull;
|
||||
nsIHTMLContent* htmlContent;
|
||||
rv = mContent->QueryInterface(kIHTMLContentIID, (void**)&htmlContent);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
htmlContent->GetBaseURL(baseURL);
|
||||
NS_RELEASE(htmlContent);
|
||||
}
|
||||
else {
|
||||
nsIDocument* doc;
|
||||
rv = mContent->GetDocument(doc);
|
||||
if (NS_SUCCEEDED(rv) && doc) {
|
||||
doc->GetBaseURL(baseURL);
|
||||
NS_RELEASE(doc);
|
||||
const nsStyleList* myList = (const nsStyleList*)mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
|
||||
if (!myList->mListStyleImage.IsEmpty()) {
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
|
||||
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
GetBaseURI(getter_AddRefs(baseURI));
|
||||
|
||||
nsCOMPtr<nsIURI> imgURI;
|
||||
NS_NewURI(getter_AddRefs(imgURI), myList->mListStyleImage, baseURI);
|
||||
|
||||
if (!mListener) {
|
||||
nsBulletListener *listener;
|
||||
NS_NEWXPCOM(listener, nsBulletListener);
|
||||
NS_ADDREF(listener);
|
||||
listener->SetFrame(this);
|
||||
listener->QueryInterface(NS_GET_IID(imgIDecoderObserver), getter_AddRefs(mListener));
|
||||
NS_ASSERTION(mListener, "queryinterface for the listener failed");
|
||||
NS_RELEASE(listener);
|
||||
}
|
||||
|
||||
il->LoadImage(imgURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, getter_AddRefs(mImageRequest));
|
||||
}
|
||||
const nsStyleList* myList = (const nsStyleList*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
mImageLoader.Init(this, UpdateBulletCB, this,
|
||||
baseURL, myList->mListStyleImage);
|
||||
NS_IF_RELEASE(baseURL);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -123,27 +166,29 @@ nsBulletFrame::Paint(nsIPresContext* aPresContext,
|
|||
|
||||
PRBool isVisible;
|
||||
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) && isVisible) {
|
||||
const nsStyleList* myList =
|
||||
(const nsStyleList*)mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
const nsStyleList* myList = (const nsStyleList*)mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
PRUint8 listStyleType = myList->mListStyleType;
|
||||
|
||||
if (myList->mListStyleImage.Length() > 0) {
|
||||
nsCOMPtr<nsIImage> image = dont_AddRef(mImageLoader.GetImage());
|
||||
if (image) {
|
||||
if (!mImageLoader.GetLoadImageFailed()) {
|
||||
if (myList->mListStyleImage.Length() > 0 && mImageRequest) {
|
||||
PRUint32 status;
|
||||
mImageRequest->GetImageStatus(&status);
|
||||
if (status & imgIRequest::STATUS_LOAD_COMPLETE) {
|
||||
nsCOMPtr<imgIContainer> imageCon;
|
||||
mImageRequest->GetImage(getter_AddRefs(imageCon));
|
||||
if (imageCon) {
|
||||
nsRect innerArea(mPadding.left, mPadding.top,
|
||||
mRect.width - (mPadding.left + mPadding.right),
|
||||
mRect.height - (mPadding.top + mPadding.bottom));
|
||||
aRenderingContext.DrawImage(image, innerArea);
|
||||
nsPoint p(innerArea.x, innerArea.y);
|
||||
innerArea.x = innerArea.y = 0;
|
||||
aRenderingContext.DrawImage(imageCon, &innerArea, &p);
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const nsStyleFont* myFont =
|
||||
(const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font);
|
||||
const nsStyleColor* myColor =
|
||||
(const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
const nsStyleFont* myFont = (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font);
|
||||
const nsStyleColor* myColor = (const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color);
|
||||
|
||||
nsCOMPtr<nsIFontMetrics> fm;
|
||||
aRenderingContext.SetColor(myColor->mColor);
|
||||
|
@ -1047,58 +1092,107 @@ nsBulletFrame::GetListItemText(nsIPresContext* aCX,
|
|||
|
||||
#define MIN_BULLET_SIZE 5 // from laytext.c
|
||||
|
||||
nsresult
|
||||
nsBulletFrame::UpdateBulletCB(nsIPresContext* aPresContext,
|
||||
nsHTMLImageLoader* aLoader,
|
||||
nsIFrame* aFrame,
|
||||
void* aClosure,
|
||||
PRUint32 aStatus)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if ((NS_IMAGE_LOAD_STATUS_SIZE_AVAILABLE|NS_IMAGE_LOAD_STATUS_ERROR)
|
||||
& aStatus) {
|
||||
// Now that the size is available (or an error occurred), trigger
|
||||
// a reflow of the bullet frame.
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
rv = aPresContext->GetShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv) && shell) {
|
||||
nsIFrame* parent;
|
||||
aFrame->GetParent(&parent);
|
||||
if (parent) {
|
||||
// Reflow the first child of the parent not the bullet frame.
|
||||
// The bullet frame is not in a line list so marking it dirty
|
||||
// has no effect. The reflowing of the bullet frame is done
|
||||
// indirectly.
|
||||
nsIFrame* frame = nsnull;
|
||||
parent->FirstChild(aPresContext, nsnull, &frame);
|
||||
if (nsnull != frame) {
|
||||
nsFrameState state;
|
||||
frame->GetFrameState(&state);
|
||||
state |= NS_FRAME_IS_DIRTY;
|
||||
frame->SetFrameState(state);
|
||||
parent->ReflowDirtyChild(shell, frame);
|
||||
} else {
|
||||
NS_ASSERTION(0, "No frame to mark dirty for bullet frame.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
NS_ASSERTION(0, "No parent to pass the reflow request up to.");
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
#define MINMAX(_value,_min,_max) \
|
||||
((_value) < (_min) \
|
||||
? (_min) \
|
||||
: ((_value) > (_max) \
|
||||
? (_max) \
|
||||
: (_value)))
|
||||
|
||||
|
||||
void
|
||||
nsBulletFrame::GetDesiredSize(nsIPresContext* aCX,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
nsHTMLReflowMetrics& aMetrics)
|
||||
{
|
||||
const nsStyleList* myList =
|
||||
(const nsStyleList*)mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
const nsStyleList* myList = (const nsStyleList*)mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
nscoord ascent;
|
||||
|
||||
if (myList->mListStyleImage.Length() > 0) {
|
||||
if (!myList->mListStyleImage.IsEmpty()) {
|
||||
nscoord widthConstraint = NS_INTRINSICSIZE;
|
||||
nscoord heightConstraint = NS_INTRINSICSIZE;
|
||||
PRBool fixedContentWidth = PR_FALSE;
|
||||
PRBool fixedContentHeight = PR_FALSE;
|
||||
|
||||
nscoord minWidth, maxWidth, minHeight, maxHeight;
|
||||
|
||||
// Determine whether the image has fixed content width
|
||||
widthConstraint = aReflowState.mComputedWidth;
|
||||
minWidth = aReflowState.mComputedMinWidth;
|
||||
maxWidth = aReflowState.mComputedMaxWidth;
|
||||
if (widthConstraint != NS_INTRINSICSIZE) {
|
||||
fixedContentWidth = PR_TRUE;
|
||||
}
|
||||
|
||||
// Determine whether the image has fixed content height
|
||||
heightConstraint = aReflowState.mComputedHeight;
|
||||
minHeight = aReflowState.mComputedMinHeight;
|
||||
maxHeight = aReflowState.mComputedMaxHeight;
|
||||
if (heightConstraint != NS_UNCONSTRAINEDSIZE) {
|
||||
fixedContentHeight = PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool haveComputedSize = PR_FALSE;
|
||||
PRBool needIntrinsicImageSize = PR_FALSE;
|
||||
|
||||
nscoord newWidth=0, newHeight=0;
|
||||
if (fixedContentWidth) {
|
||||
newWidth = MINMAX(widthConstraint, minWidth, maxWidth);
|
||||
if (fixedContentHeight) {
|
||||
newHeight = MINMAX(heightConstraint, minHeight, maxHeight);
|
||||
haveComputedSize = PR_TRUE;
|
||||
} else {
|
||||
// We have a width, and an auto height. Compute height from
|
||||
// width once we have the intrinsic image size.
|
||||
if (mIntrinsicSize.height != 0) {
|
||||
newHeight = (mIntrinsicSize.height * newWidth) / mIntrinsicSize.width;
|
||||
haveComputedSize = PR_TRUE;
|
||||
} else {
|
||||
newHeight = 0;
|
||||
needIntrinsicImageSize = PR_TRUE;
|
||||
}
|
||||
}
|
||||
} else if (fixedContentHeight) {
|
||||
// We have a height, and an auto width. Compute width from height
|
||||
// once we have the intrinsic image size.
|
||||
newHeight = MINMAX(heightConstraint, minHeight, maxHeight);
|
||||
if (mIntrinsicSize.width != 0) {
|
||||
newWidth = (mIntrinsicSize.width * newHeight) / mIntrinsicSize.height;
|
||||
haveComputedSize = PR_TRUE;
|
||||
} else {
|
||||
newWidth = 0;
|
||||
needIntrinsicImageSize = PR_TRUE;
|
||||
}
|
||||
} else {
|
||||
// auto size the image
|
||||
if (mIntrinsicSize.width == 0 && mIntrinsicSize.height == 0)
|
||||
needIntrinsicImageSize = PR_TRUE;
|
||||
else
|
||||
haveComputedSize = PR_TRUE;
|
||||
|
||||
newWidth = mIntrinsicSize.width;
|
||||
newHeight = mIntrinsicSize.height;
|
||||
}
|
||||
|
||||
mComputedSize.width = newWidth;
|
||||
mComputedSize.height = newHeight;
|
||||
|
||||
#if 0 // don't do scaled images in bullets
|
||||
if (mComputedSize == mIntrinsicSize) {
|
||||
mTransform.SetToIdentity();
|
||||
} else {
|
||||
if (mComputedSize.width != 0 && mComputedSize.height != 0) {
|
||||
mTransform.SetToScale(float(mIntrinsicSize.width) / float(mComputedSize.width),
|
||||
float(mIntrinsicSize.height) / float(mComputedSize.height));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
aMetrics.width = mComputedSize.width;
|
||||
aMetrics.height = mComputedSize.height;
|
||||
|
||||
#if 0
|
||||
mImageLoader.GetDesiredSize(aCX, &aReflowState, aMetrics);
|
||||
if (!mImageLoader.GetLoadImageFailed()) {
|
||||
nsHTMLContainerFrame::CreateViewForFrame(aCX, this, mStyleContext, nsnull,
|
||||
|
@ -1107,6 +1201,14 @@ nsBulletFrame::GetDesiredSize(nsIPresContext* aCX,
|
|||
aMetrics.descent = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
aMetrics.ascent = aMetrics.height;
|
||||
aMetrics.descent = 0;
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
const nsStyleFont* myFont =
|
||||
|
@ -1214,20 +1316,59 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
|
|||
if (eReflowReason_Incremental == aReflowState.reason) {
|
||||
nsIReflowCommand::ReflowType type;
|
||||
aReflowState.reflowCommand->GetType(type);
|
||||
|
||||
/* if the style changed, see if we need to load a new url */
|
||||
if (nsIReflowCommand::StyleChanged == type) {
|
||||
// Reload the image, maybe...
|
||||
nsAutoString oldImageURL;
|
||||
mImageLoader.GetURLSpec(oldImageURL);
|
||||
const nsStyleList* myList = (const nsStyleList*)
|
||||
mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
if (myList->mListStyleImage != oldImageURL) {
|
||||
mImageLoader.UpdateURLSpec(aPresContext, myList->mListStyleImage);
|
||||
// XXX - invlidate here is fragile as our parent can choose to change our size
|
||||
// however currently the parent accepts our size so this works.
|
||||
// Also, it might be better to invalidate when the image has actually loaded
|
||||
// instead of when we request the image to load...
|
||||
// This, however, works as it is currently used (bug 8862 is fixed)
|
||||
Invalidate(aPresContext, nsRect(0, 0, mRect.width, mRect.height));
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
GetBaseURI(getter_AddRefs(baseURI));
|
||||
|
||||
const nsStyleList* myList = (const nsStyleList*)mStyleContext->GetStyleData(eStyleStruct_List);
|
||||
|
||||
if (!myList->mListStyleImage.IsEmpty()) {
|
||||
|
||||
if (!mListener) {
|
||||
nsBulletListener *listener;
|
||||
NS_NEWXPCOM(listener, nsBulletListener);
|
||||
NS_ADDREF(listener);
|
||||
listener->SetFrame(this);
|
||||
listener->QueryInterface(NS_GET_IID(imgIDecoderObserver), getter_AddRefs(mListener));
|
||||
NS_ASSERTION(mListener, "queryinterface for the listener failed");
|
||||
NS_RELEASE(listener);
|
||||
}
|
||||
|
||||
|
||||
nsCOMPtr<nsIURI> newURI;
|
||||
NS_NewURI(getter_AddRefs(newURI), myList->mListStyleImage, baseURI);
|
||||
|
||||
PRBool needNewRequest = PR_TRUE;
|
||||
|
||||
if (mImageRequest) {
|
||||
// Reload the image, maybe...
|
||||
nsCOMPtr<nsIURI> oldURI;
|
||||
mImageRequest->GetURI(getter_AddRefs(oldURI));
|
||||
if (oldURI) {
|
||||
PRBool same;
|
||||
newURI->Equals(oldURI, &same);
|
||||
if (same) {
|
||||
needNewRequest = PR_FALSE;
|
||||
} else {
|
||||
mImageRequest->Cancel(NS_ERROR_FAILURE);
|
||||
mImageRequest = nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (needNewRequest) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
GetLoadGroup(aPresContext, getter_AddRefs(loadGroup));
|
||||
|
||||
il->LoadImage(newURI, loadGroup, mListener, aPresContext, nsIRequest::LOAD_NORMAL, getter_AddRefs(mImageRequest));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1250,3 +1391,244 @@ nsBulletFrame::Reflow(nsIPresContext* aPresContext,
|
|||
aStatus = NS_FRAME_COMPLETE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsBulletFrame::OnStartContainer(imgIRequest *aRequest, nsIPresContext *aPresContext, imgIContainer *aImage)
|
||||
{
|
||||
if (!aImage) return NS_ERROR_INVALID_ARG;
|
||||
|
||||
nscoord w, h;
|
||||
aImage->GetWidth(&w);
|
||||
aImage->GetHeight(&h);
|
||||
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
|
||||
nsSize newsize(NSIntPixelsToTwips(w, p2t), NSIntPixelsToTwips(h, p2t));
|
||||
|
||||
if (mIntrinsicSize != newsize) {
|
||||
mIntrinsicSize = newsize;
|
||||
|
||||
// Now that the size is available (or an error occurred), trigger
|
||||
// a reflow of the bullet frame.
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
nsresult rv = aPresContext->GetShell(getter_AddRefs(shell));
|
||||
if (NS_SUCCEEDED(rv) && shell) {
|
||||
NS_ASSERTION(mParent, "No parent to pass the reflow request up to.");
|
||||
if (mParent) {
|
||||
// Reflow the first child of the parent not the bullet frame.
|
||||
// The bullet frame is not in a line list so marking it dirty
|
||||
// has no effect. The reflowing of the bullet frame is done
|
||||
// indirectly.
|
||||
nsIFrame* frame = nsnull;
|
||||
mParent->FirstChild(aPresContext, nsnull, &frame);
|
||||
NS_ASSERTION(frame, "No frame to mark dirty for bullet frame.");
|
||||
if (frame) {
|
||||
nsFrameState state;
|
||||
frame->GetFrameState(&state);
|
||||
state |= NS_FRAME_IS_DIRTY;
|
||||
frame->SetFrameState(state);
|
||||
mParent->ReflowDirtyChild(shell, frame);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletFrame::OnDataAvailable(imgIRequest *aRequest, nsIPresContext *aPresContext, gfxIImageFrame *aFrame, const nsRect *aRect)
|
||||
{
|
||||
if (!aRect) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsRect r(*aRect);
|
||||
|
||||
/* XXX Why do we subtract 1 here? The rect is (for example): (0, 0, 600, 1)..
|
||||
Why do we have to make y -1?
|
||||
*/
|
||||
|
||||
// The y coordinate of aRect is passed as a scanline where the first scanline is given
|
||||
// a value of 1. We need to convert this to the nsFrames coordinate space by subtracting
|
||||
// 1.
|
||||
r.y -= 1;
|
||||
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
r.x = NSIntPixelsToTwips(r.x, p2t);
|
||||
r.y = NSIntPixelsToTwips(r.y, p2t);
|
||||
r.width = NSIntPixelsToTwips(r.width, p2t);
|
||||
r.height = NSIntPixelsToTwips(r.height, p2t);
|
||||
|
||||
Invalidate(aPresContext, r, PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletFrame::OnStopDecode(imgIRequest *aRequest, nsIPresContext *aPresContext, nsresult aStatus, const PRUnichar *aStatusArg)
|
||||
{
|
||||
// XXX should the bulletframe do anything if the image failed to load?
|
||||
// it didn't in the old code...
|
||||
#if 0
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
aPresContext->GetShell(getter_AddRefs(presShell));
|
||||
|
||||
|
||||
if (NS_FAILED(aStatus)) {
|
||||
// We failed to load the image. Notify the pres shell
|
||||
if (NS_FAILED(aStatus) && (mImageRequest == aRequest || !mImageRequest)) {
|
||||
imageFailed = PR_TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletFrame::FrameChanged(imgIContainer *aContainer, nsIPresContext *aPresContext, gfxIImageFrame *aNewFrame, nsRect *aDirtyRect)
|
||||
{
|
||||
nsRect r(*aDirtyRect);
|
||||
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
r.x = NSIntPixelsToTwips(r.x, p2t);
|
||||
r.y = NSIntPixelsToTwips(r.y, p2t);
|
||||
r.width = NSIntPixelsToTwips(r.width, p2t);
|
||||
r.height = NSIntPixelsToTwips(r.height, p2t);
|
||||
|
||||
Invalidate(aPresContext, r, PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
nsBulletFrame::GetBaseURI(nsIURI **aURI)
|
||||
{
|
||||
NS_PRECONDITION(nsnull != aURI, "null OUT parameter pointer");
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
nsCOMPtr<nsIHTMLContent> htmlContent(do_QueryInterface(mContent, &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
htmlContent->GetBaseURL(*getter_AddRefs(baseURI));
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
rv = mContent->GetDocument(*getter_AddRefs(doc));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
doc->GetBaseURL(*getter_AddRefs(baseURI));
|
||||
}
|
||||
}
|
||||
*aURI = baseURI;
|
||||
NS_IF_ADDREF(*aURI);
|
||||
}
|
||||
|
||||
void
|
||||
nsBulletFrame::GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGroup)
|
||||
{
|
||||
if (!aPresContext)
|
||||
return;
|
||||
|
||||
NS_PRECONDITION(nsnull != aLoadGroup, "null OUT parameter pointer");
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell;
|
||||
aPresContext->GetShell(getter_AddRefs(shell));
|
||||
|
||||
if (!shell)
|
||||
return;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
shell->GetDocument(getter_AddRefs(doc));
|
||||
if (!doc)
|
||||
return;
|
||||
|
||||
doc->GetDocumentLoadGroup(aLoadGroup);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsBulletListener, imgIDecoderObserver, imgIContainerObserver)
|
||||
|
||||
nsBulletListener::nsBulletListener() :
|
||||
mFrame(nsnull)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsBulletListener::~nsBulletListener()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::OnStartDecode(imgIRequest *aRequest, nsISupports *aContext)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::OnStartContainer(imgIRequest *aRequest, nsISupports *aContext, imgIContainer *aImage)
|
||||
{
|
||||
if (!mFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPresContext> pc(do_QueryInterface(aContext));
|
||||
|
||||
NS_ASSERTION(pc, "not a pres context!");
|
||||
|
||||
return mFrame->OnStartContainer(aRequest, pc, aImage);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::OnStartFrame(imgIRequest *aRequest, nsISupports *aContext, gfxIImageFrame *aFrame)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::OnDataAvailable(imgIRequest *aRequest, nsISupports *aContext, gfxIImageFrame *aFrame, const nsRect *aRect)
|
||||
{
|
||||
if (!mFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPresContext> pc(do_QueryInterface(aContext));
|
||||
|
||||
NS_ASSERTION(pc, "not a pres context!");
|
||||
|
||||
return mFrame->OnDataAvailable(aRequest, pc, aFrame, aRect);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::OnStopFrame(imgIRequest *aRequest, nsISupports *aContext, gfxIImageFrame *aFrame)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::OnStopContainer(imgIRequest *aRequest, nsISupports *aContext, imgIContainer *aImage)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::OnStopDecode(imgIRequest *aRequest, nsISupports *aContext, nsresult status, const PRUnichar *statusArg)
|
||||
{
|
||||
if (!mFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPresContext> pc(do_QueryInterface(aContext));
|
||||
|
||||
NS_ASSERTION(pc, "not a pres context!");
|
||||
|
||||
return mFrame->OnStopDecode(aRequest, pc, status, statusArg);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsBulletListener::FrameChanged(imgIContainer *aContainer, nsISupports *aContext, gfxIImageFrame *newframe, nsRect * dirtyRect)
|
||||
{
|
||||
if (!mFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCOMPtr<nsIPresContext> pc(do_QueryInterface(aContext));
|
||||
|
||||
NS_ASSERTION(pc, "not a pres context!");
|
||||
|
||||
return mFrame->FrameChanged(aContainer, pc, newframe, dirtyRect);
|
||||
}
|
||||
|
|
|
@ -23,9 +23,12 @@
|
|||
#define nsBulletFrame_h___
|
||||
|
||||
#include "nsFrame.h"
|
||||
#include "nsHTMLImageLoader.h"
|
||||
#include "nsIStyleContext.h"
|
||||
|
||||
#include "imgIRequest.h"
|
||||
#include "imgIDecoderObserver.h"
|
||||
class gfxIImageFrame;
|
||||
|
||||
/**
|
||||
* A simple class that manages the layout and rendering of html bullets.
|
||||
* This class also supports the CSS list-style properties.
|
||||
|
@ -60,6 +63,12 @@ public:
|
|||
// nsBulletFrame
|
||||
PRInt32 SetListItemOrdinal(PRInt32 aNextOrdinal, PRBool* aChanged);
|
||||
|
||||
|
||||
NS_IMETHOD OnStartContainer(imgIRequest *aRequest, nsIPresContext *aCX, imgIContainer *aImage);
|
||||
NS_IMETHOD OnDataAvailable(imgIRequest *aRequest, nsIPresContext *aCX, gfxIImageFrame *aFrame, const nsRect * rect);
|
||||
NS_IMETHOD OnStopDecode(imgIRequest *aRequest, nsIPresContext *aCX, nsresult aStatus, const PRUnichar *aStatusArg);
|
||||
NS_IMETHOD FrameChanged(imgIContainer *aContainer, nsIPresContext *aCX, gfxIImageFrame *aNewframe, nsRect *aDirtyRect);
|
||||
|
||||
protected:
|
||||
void GetDesiredSize(nsIPresContext* aPresContext,
|
||||
const nsHTMLReflowState& aReflowState,
|
||||
|
@ -69,15 +78,16 @@ protected:
|
|||
const nsStyleList& aStyleList,
|
||||
nsString& aResult);
|
||||
|
||||
static nsresult UpdateBulletCB(nsIPresContext* aPresContext,
|
||||
nsHTMLImageLoader* aLoader,
|
||||
nsIFrame* aFrame,
|
||||
void* aClosure,
|
||||
PRUint32 aStatus);
|
||||
void GetBaseURI(nsIURI **aURI);
|
||||
void GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **aLoadGroup);
|
||||
|
||||
PRInt32 mOrdinal;
|
||||
nsMargin mPadding;
|
||||
nsHTMLImageLoader mImageLoader;
|
||||
nsCOMPtr<imgIRequest> mImageRequest;
|
||||
nsCOMPtr<imgIDecoderObserver> mListener;
|
||||
|
||||
nsSize mIntrinsicSize;
|
||||
nsSize mComputedSize;
|
||||
};
|
||||
|
||||
#endif /* nsBulletFrame_h___ */
|
||||
|
|
|
@ -436,7 +436,7 @@ nsFrame::Destroy(nsIPresContext* aPresContext)
|
|||
|
||||
//XXX Why is this done in nsFrame instead of some frame class
|
||||
// that actually loads images?
|
||||
aPresContext->StopAllLoadImagesFor(this, this);
|
||||
aPresContext->StopImagesFor(this);
|
||||
|
||||
if (view) {
|
||||
// Break association between view and frame
|
||||
|
|
|
@ -1696,7 +1696,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext,
|
|||
if(oldColor->mBackgroundImage.Length() > 0 &&
|
||||
oldColor->mBackgroundImage != newColor->mBackgroundImage ){
|
||||
// stop the image loading for the frame, the image has changed
|
||||
aPresContext->StopAllLoadImagesFor(aFrame, aFrame);
|
||||
aPresContext->StopImagesFor(aFrame);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1911,7 +1911,7 @@ FrameManager::ReResolveStyleContext(nsIPresContext* aPresContext,
|
|||
if(oldColor.mBackgroundImage.Length() > 0 &&
|
||||
oldColor.mBackgroundImage != newColor.mBackgroundImage ){
|
||||
// stop the image loading for the frame, the image has changed
|
||||
aPresContext->StopAllLoadImagesFor(aFrame, aFrame);
|
||||
aPresContext->StopImagesFor(aFrame);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include "nsString.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIFrameImageLoader.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsHTMLIIDs.h"
|
||||
#include "nsIImage.h"
|
||||
|
@ -975,10 +974,12 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
|
|||
// indicating the status
|
||||
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
|
||||
!mInitialLoadCompleted) {
|
||||
DisplayAltFeedback(aPresContext, aRenderingContext,
|
||||
DisplayAltFeedback(aPresContext, aRenderingContext, 0);
|
||||
#ifndef USE_IMG2
|
||||
(loadStatus & imgIRequest::STATUS_ERROR)
|
||||
? NS_ICON_BROKEN_IMAGE
|
||||
: NS_ICON_LOADING_IMAGE);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -43,7 +43,7 @@ struct nsSize;
|
|||
|
||||
class nsImageFrame;
|
||||
|
||||
class nsImageListener : imgIDecoderObserver
|
||||
class nsImageListener : public imgIDecoderObserver
|
||||
{
|
||||
public:
|
||||
nsImageListener(nsImageFrame *aFrame);
|
||||
|
|
|
@ -6698,7 +6698,6 @@ PresShell::VerifyIncrementalReflow()
|
|||
}
|
||||
}
|
||||
|
||||
cx->Stop();
|
||||
cx->SetContainer(nsnull);
|
||||
NS_RELEASE(cx);
|
||||
sh->EndObservingDocument();
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
#include "nsRect.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIFrameImageLoader.h"
|
||||
#include "nsIStyleContext.h"
|
||||
#include "nsStyleUtil.h"
|
||||
#include "nsIScrollableView.h"
|
||||
|
@ -40,7 +39,8 @@
|
|||
#include "nsHTMLAtoms.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
|
||||
#include "imgIRequest.h"
|
||||
#include "imgIContainer.h"
|
||||
|
||||
#define BORDER_FULL 0 //entire side
|
||||
#define BORDER_INSIDE 1 //inside half
|
||||
|
@ -2149,7 +2149,51 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
nsStyleCoord bordStyleRadius[4];
|
||||
PRInt16 borderRadii[4],i;
|
||||
|
||||
if (0 < aColor.mBackgroundImage.Length()) {
|
||||
|
||||
// if there is no background image, try a color.
|
||||
if (aColor.mBackgroundImage.IsEmpty()) {
|
||||
// See if there's a background color specified. The background color
|
||||
// is rendered over the 'border' 'padding' and 'content' areas
|
||||
if (!transparentBG) {
|
||||
// get the radius for our border
|
||||
aBorder.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
|
||||
aBorder.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
|
||||
aBorder.mBorderRadius.GetBottom(bordStyleRadius[2]); //bottomright
|
||||
aBorder.mBorderRadius.GetLeft(bordStyleRadius[3]); //bottomleft
|
||||
|
||||
for(i=0;i<4;i++) {
|
||||
borderRadii[i] = 0;
|
||||
switch ( bordStyleRadius[i].GetUnit()) {
|
||||
case eStyleUnit_Inherit:
|
||||
break;
|
||||
case eStyleUnit_Percent:
|
||||
percent = bordStyleRadius[i].GetPercentValue();
|
||||
borderRadii[i] = (nscoord)(percent * aBorderArea.width);
|
||||
break;
|
||||
case eStyleUnit_Coord:
|
||||
borderRadii[i] = bordStyleRadius[i].GetCoordValue();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// rounded version of the border
|
||||
for(i=0;i<4;i++){
|
||||
if (borderRadii[i] > 0){
|
||||
PaintRoundedBackground(aPresContext,aRenderingContext,aForFrame,aDirtyRect,
|
||||
aBorderArea,aColor,aDX,aDY,borderRadii);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
aRenderingContext.SetColor(aColor.mBackgroundColor);
|
||||
aRenderingContext.FillRect(aBorderArea);
|
||||
}
|
||||
} else {
|
||||
// we have a background image
|
||||
|
||||
|
||||
// get the frame for the background image load to complete in
|
||||
// - this may be different than the frame we are rendering
|
||||
|
@ -2159,31 +2203,34 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
NS_ASSERTION(pBGFrame, "Background Frame must be set by GetFrameForBackgroundUpdate");
|
||||
|
||||
// Lookup the image
|
||||
nsSize imageSize;
|
||||
nsCOMPtr<nsIImage> image;
|
||||
nsIFrameImageLoader* loader = nsnull;
|
||||
nsresult rv = aPresContext->StartLoadImage(aColor.mBackgroundImage,
|
||||
transparentBG
|
||||
? nsnull
|
||||
: &aColor.mBackgroundColor,
|
||||
nsnull,
|
||||
pBGFrame,
|
||||
nsnull, nsnull,
|
||||
pBGFrame, &loader);
|
||||
if ((NS_OK != rv) || (nsnull == loader) ||
|
||||
(loader->GetImage(getter_AddRefs(image)), (!image))) {
|
||||
NS_IF_RELEASE(loader);
|
||||
// Redraw will happen later
|
||||
if (!transparentBG) {
|
||||
// The background color is rendered over the 'border' 'padding' and
|
||||
// 'content' areas
|
||||
aRenderingContext.SetColor(aColor.mBackgroundColor);
|
||||
aRenderingContext.FillRect(aBorderArea);
|
||||
}
|
||||
nsCOMPtr<imgIRequest> req;
|
||||
nsresult rv = aPresContext->LoadImage(aColor.mBackgroundImage, pBGFrame, getter_AddRefs(req));
|
||||
|
||||
PRUint32 status = imgIRequest::STATUS_ERROR;
|
||||
if (req)
|
||||
req->GetImageStatus(&status);
|
||||
|
||||
if (NS_FAILED(rv) || !req || !(status & imgIRequest::STATUS_SIZE_AVAILABLE)) {
|
||||
// The background color is rendered over the 'border' 'padding' and
|
||||
// 'content' areas
|
||||
aRenderingContext.SetColor(aColor.mBackgroundColor);
|
||||
aRenderingContext.FillRect(aBorderArea);
|
||||
return;
|
||||
}
|
||||
loader->GetSize(imageSize);
|
||||
NS_RELEASE(loader);
|
||||
|
||||
nsSize imageSize;
|
||||
nsCOMPtr<imgIContainer> image;
|
||||
req->GetImage(getter_AddRefs(image));
|
||||
|
||||
image->GetWidth(&imageSize.width);
|
||||
image->GetHeight(&imageSize.height);
|
||||
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
imageSize.width = NSIntPixelsToTwips(imageSize.width, p2t);
|
||||
imageSize.height = NSIntPixelsToTwips(imageSize.height, p2t);
|
||||
|
||||
req = nsnull;
|
||||
|
||||
// Background images are tiled over the 'content' and 'padding' areas
|
||||
// only (not the 'border' area)
|
||||
|
@ -2489,166 +2536,22 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
y1 = y0 + tileHeight;
|
||||
}
|
||||
|
||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
||||
// Take the intersection again to paint only the required area
|
||||
nsRect tileRect(x0,y0,(x1-x0),(y1-y0));
|
||||
nsRect drawRect;
|
||||
if (drawRect.IntersectRect(tileRect, dirtyRect)) {
|
||||
PRInt32 xOffset = drawRect.x - x0,
|
||||
yOffset = drawRect.y - y0;
|
||||
aRenderingContext.DrawTile(image,xOffset,yOffset,drawRect);
|
||||
aRenderingContext.DrawTile(image,xOffset,yOffset,&drawRect);
|
||||
}
|
||||
#else
|
||||
aRenderingContext.DrawTile(image,x0,y0,x1,y1,tileWidth,tileHeight);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef DOTILE
|
||||
nsIDrawingSurface *theSurface,*ts=nsnull;
|
||||
nsRect srcRect,destRect,vrect,tvrect;
|
||||
nscoord x,y;
|
||||
PRInt32 flag = NS_COPYBITS_TO_BACK_BUFFER | NS_COPYBITS_XFORM_DEST_VALUES;
|
||||
PRUint32 dsFlag = NS_CREATEDRAWINGSURFACE_SHORTLIVED;
|
||||
float t2p,app2dev;
|
||||
PRBool clip,hasMask;
|
||||
nsTransform2D *theTransform;
|
||||
nsIDeviceContext *theDevContext;
|
||||
|
||||
|
||||
aRenderingContext.GetDrawingSurface((void**)&theSurface);
|
||||
aPresContext->GetVisibleArea(srcRect);
|
||||
tvrect.SetRect(0,0,x1-x0,y1-y0);
|
||||
aPresContext->GetTwipsToPixels(&t2p);
|
||||
|
||||
// check to see if the background image has a mask
|
||||
hasMask = image->GetHasAlphaMask();
|
||||
|
||||
if(!hasMask && ((tileWidth<(tvrect.width/16)) || (tileHeight<(tvrect.height/16)))) {
|
||||
//tvrect.width /=4;
|
||||
//tvrect.height /=4;
|
||||
|
||||
tvrect.width = ((tvrect.width)/tileWidth); //total x number of tiles
|
||||
tvrect.width *=tileWidth;
|
||||
|
||||
tvrect.height = ((tvrect.height)/tileHeight); //total y number of tiles
|
||||
tvrect.height *=tileHeight;
|
||||
|
||||
// create a new drawing surface... using pixels as the size
|
||||
vrect.height = (nscoord)(tvrect.height * t2p);
|
||||
vrect.width = (nscoord)(tvrect.width * t2p);
|
||||
aRenderingContext.CreateDrawingSurface(&vrect,dsFlag,(nsDrawingSurface&)ts);
|
||||
}
|
||||
|
||||
// did we need to create an offscreen drawing surface because the image was so small
|
||||
if(!hasMask && (nsnull != ts) ) {
|
||||
aRenderingContext.SelectOffScreenDrawingSurface(ts);
|
||||
|
||||
// create a bigger tile in our new drawingsurface
|
||||
// XXX pushing state to fix clipping problem, need to look into why the clip is set here
|
||||
aRenderingContext.PushState();
|
||||
aRenderingContext.GetCurrentTransform(theTransform);
|
||||
aRenderingContext.GetDeviceContext(theDevContext);
|
||||
theDevContext->GetAppUnitsToDevUnits(app2dev);
|
||||
NS_RELEASE(theDevContext);
|
||||
theTransform->SetToIdentity();
|
||||
theTransform->AddScale(app2dev, app2dev);
|
||||
|
||||
// XXX this #ifdef needs to go away when we are sure that this works on windows and mac
|
||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
||||
srcRect.SetRect(0,0,tvrect.width,tvrect.height);
|
||||
aRenderingContext.SetClipRect(srcRect, nsClipCombine_kReplace, clip);
|
||||
#endif
|
||||
|
||||
// copy the initial image to our buffer, this takes twips and converts to pixels..
|
||||
// which is what the image is in
|
||||
aRenderingContext.DrawImage(image,0,0,tileWidth,tileHeight);
|
||||
|
||||
// duplicate the image in the upperleft corner to fill up the nsDrawingSurface
|
||||
srcRect.SetRect(0,0,tileWidth,tileHeight);
|
||||
TileImage(aRenderingContext,ts,srcRect,tvrect.width,tvrect.height);
|
||||
|
||||
// setting back the clip from the background clip push
|
||||
aRenderingContext.PopState(clip);
|
||||
|
||||
// set back to the old drawingsurface
|
||||
aRenderingContext.SelectOffScreenDrawingSurface((void**)theSurface);
|
||||
|
||||
// now duplicate our tile into the background
|
||||
destRect = srcRect;
|
||||
for(y=y0;y<y1;y+=tvrect.height){
|
||||
for(x=x0;x<x1;x+=tvrect.width){
|
||||
destRect.x = x;
|
||||
destRect.y = y;
|
||||
aRenderingContext.CopyOffScreenBits(ts,0,0,destRect,flag);
|
||||
}
|
||||
}
|
||||
|
||||
aRenderingContext.DestroyDrawingSurface(ts);
|
||||
} else {
|
||||
// slow blitting, one tile at a time....
|
||||
for(y=y0;y<y1;y+=tileHeight){
|
||||
for(x=x0;x<x1;x+=tileWidth){
|
||||
aRenderingContext.DrawImage(image,x,y,tileWidth,tileHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//#define NOTNOW
|
||||
#ifdef NOTNOW
|
||||
nscoord x,y;
|
||||
for(y=y0;y<y1;y+=tileHeight){
|
||||
for(x=x0;x<x1;x+=tileWidth){
|
||||
aRenderingContext.DrawImage(image,x,y,tileWidth,tileHeight);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(XP_UNIX) && !defined(XP_BEOS)
|
||||
// Restore clipping
|
||||
aRenderingContext.PopState(clipState);
|
||||
#endif
|
||||
} else {
|
||||
// See if there's a background color specified. The background color
|
||||
// is rendered over the 'border' 'padding' and 'content' areas
|
||||
if (!transparentBG) {
|
||||
// get the radius for our border
|
||||
aBorder.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
|
||||
aBorder.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
|
||||
aBorder.mBorderRadius.GetBottom(bordStyleRadius[2]); //bottomright
|
||||
aBorder.mBorderRadius.GetLeft(bordStyleRadius[3]); //bottomleft
|
||||
|
||||
for(i=0;i<4;i++) {
|
||||
borderRadii[i] = 0;
|
||||
switch ( bordStyleRadius[i].GetUnit()) {
|
||||
case eStyleUnit_Inherit:
|
||||
break;
|
||||
case eStyleUnit_Percent:
|
||||
percent = bordStyleRadius[i].GetPercentValue();
|
||||
borderRadii[i] = (nscoord)(percent * aBorderArea.width);
|
||||
break;
|
||||
case eStyleUnit_Coord:
|
||||
borderRadii[i] = bordStyleRadius[i].GetCoordValue();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// rounded version of the border
|
||||
for(i=0;i<4;i++){
|
||||
if (borderRadii[i] > 0){
|
||||
PaintRoundedBackground(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,aColor,aDX,aDY,borderRadii);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
aRenderingContext.SetColor(aColor.mBackgroundColor);
|
||||
aRenderingContext.FillRect(aBorderArea);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
|
|
@ -62,7 +62,6 @@ LLIBS= \
|
|||
$(DIST)\lib\layoutsvgbase_s.lib \
|
||||
$(DIST)\lib\layoutsvgcontent_s.lib \
|
||||
!endif
|
||||
$(DIST)\lib\img32$(VERSION_NUMBER).lib \
|
||||
$(DIST)\lib\util.lib \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\timer_s.lib \
|
||||
|
|
Двоичные данные
layout/macbuild/layout.mcp
Двоичные данные
layout/macbuild/layout.mcp
Двоичный файл не отображается.
|
@ -82,21 +82,6 @@
|
|||
|
||||
#define ONLOAD_CALLED_TOO_EARLY 1
|
||||
|
||||
nsresult
|
||||
nsImageBoxFrame::UpdateImageFrame(nsIPresContext* aPresContext,
|
||||
nsHTMLImageLoader* aLoader,
|
||||
nsIFrame* aFrame,
|
||||
void* aClosure,
|
||||
PRUint32 aStatus)
|
||||
{
|
||||
if (NS_IMAGE_LOAD_STATUS_SIZE_AVAILABLE & aStatus) {
|
||||
nsImageBoxFrame* us = (nsImageBoxFrame*)aFrame;
|
||||
nsBoxLayoutState state(aPresContext);
|
||||
us->MarkDirty(state);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// NS_NewToolbarFrame
|
||||
//
|
||||
|
|
|
@ -22,10 +22,8 @@
|
|||
#ifndef nsImageBoxFrame_h___
|
||||
#define nsImageBoxFrame_h___
|
||||
|
||||
#include "nsHTMLImageLoader.h"
|
||||
#include "nsLeafBoxFrame.h"
|
||||
|
||||
#ifdef USE_IMG2
|
||||
#include "imgILoader.h"
|
||||
#include "imgIRequest.h"
|
||||
#include "imgIContainer.h"
|
||||
|
@ -48,7 +46,6 @@ public:
|
|||
private:
|
||||
nsImageBoxFrame *mFrame;
|
||||
};
|
||||
#endif
|
||||
|
||||
class nsImageBoxFrame : public nsLeafBoxFrame
|
||||
{
|
||||
|
@ -92,8 +89,6 @@ public:
|
|||
const nsRect& aDirtyRect,
|
||||
nsFramePaintLayer aWhichLayer);
|
||||
|
||||
|
||||
#ifdef USE_IMG2
|
||||
NS_IMETHOD OnStartDecode(imgIRequest *request, nsIPresContext *cx);
|
||||
NS_IMETHOD OnStartContainer(imgIRequest *request, nsIPresContext *cx, imgIContainer *image);
|
||||
NS_IMETHOD OnStartFrame(imgIRequest *request, nsIPresContext *cx, gfxIImageFrame *frame);
|
||||
|
@ -102,9 +97,6 @@ public:
|
|||
NS_IMETHOD OnStopContainer(imgIRequest *request, nsIPresContext *cx, imgIContainer *image);
|
||||
NS_IMETHOD OnStopDecode(imgIRequest *request, nsIPresContext *cx, nsresult status, const PRUnichar *statusArg);
|
||||
NS_IMETHOD FrameChanged(imgIContainer *container, nsIPresContext *cx, gfxIImageFrame *newframe, nsRect * dirtyRect);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
virtual ~nsImageBoxFrame();
|
||||
protected:
|
||||
|
@ -119,32 +111,20 @@ protected:
|
|||
|
||||
nsImageBoxFrame(nsIPresShell* aShell);
|
||||
|
||||
static nsresult UpdateImageFrame(nsIPresContext* aPresContext,
|
||||
nsHTMLImageLoader* aLoader,
|
||||
nsIFrame* aFrame,
|
||||
void* aClosure,
|
||||
PRUint32 aStatus);
|
||||
|
||||
void GetImageSource(nsString& aResult);
|
||||
|
||||
void GetBaseURI(nsIURI **uri);
|
||||
|
||||
#ifdef USE_IMG2
|
||||
void GetLoadGroup(nsIPresContext *aPresContext, nsILoadGroup **group);
|
||||
#endif
|
||||
|
||||
virtual void GetImageSize(nsIPresContext* aPresContext);
|
||||
|
||||
private:
|
||||
|
||||
#ifdef USE_IMG2
|
||||
nsCOMPtr<imgIRequest> mImageRequest;
|
||||
nsCOMPtr<imgIDecoderObserver> mListener;
|
||||
|
||||
nsSize mIntrinsicSize;
|
||||
#else
|
||||
nsHTMLImageLoader mImageLoader;
|
||||
#endif
|
||||
|
||||
PRBool mSizeFrozen;
|
||||
nsSize mImageSize;
|
||||
|
|
|
@ -26,7 +26,7 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = $(PNGDIR) $(MNGDIR) public public_com src gifcom pngcom mngcom jpgcom
|
||||
DIRS = $(PNGDIR) $(MNGDIR)
|
||||
|
||||
ifndef MOZ_NATIVE_PNG
|
||||
PNGDIR = png
|
||||
|
|
|
@ -20,9 +20,9 @@
|
|||
|
||||
DEPTH=..\..
|
||||
|
||||
DIRS = public src public_com png pngcom jpgcom gifcom \
|
||||
DIRS = png \
|
||||
!if !defined(MOZ_DISABLE_MNG)
|
||||
mng mngcom \
|
||||
mng \
|
||||
!endif
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -80,7 +80,6 @@
|
|||
#include "nsIResProtocolHandler.h"
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsIImageManager.h"
|
||||
#include "nsIBindingManager.h"
|
||||
#include "prio.h"
|
||||
#include "nsInt64.h"
|
||||
|
@ -105,7 +104,6 @@ static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
|||
static NS_DEFINE_CID(kRDFXMLDataSourceCID, NS_RDFXMLDATASOURCE_CID);
|
||||
static NS_DEFINE_CID(kRDFContainerUtilsCID, NS_RDFCONTAINERUTILS_CID);
|
||||
static NS_DEFINE_CID(kCSSLoaderCID, NS_CSS_LOADER_CID);
|
||||
static NS_DEFINE_CID(kImageManagerCID, NS_IMAGEMANAGER_CID);
|
||||
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
|
||||
|
@ -1136,16 +1134,9 @@ nsresult nsChromeRegistry::FlushCaches()
|
|||
if (NS_SUCCEEDED(rv) && xulCache) {
|
||||
xulCache->Flush();
|
||||
}
|
||||
|
||||
// Flush the old image cache.
|
||||
nsCOMPtr<nsIImageManager> imageManager =
|
||||
do_GetService(kImageManagerCID, &rv);
|
||||
if (imageManager)
|
||||
rv = imageManager->FlushCache(1);
|
||||
|
||||
// Flush the new imagelib image chrome cache.
|
||||
nsCOMPtr<imgICache> imageCache =
|
||||
do_GetService("@mozilla.org/image/cache;1", &rv);
|
||||
nsCOMPtr<imgICache> imageCache(do_GetService("@mozilla.org/image/cache;1", &rv));
|
||||
if (NS_SUCCEEDED(rv) && imageCache) {
|
||||
imageCache->ClearCache(PR_TRUE);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,6 @@
|
|||
DEPTH=..\..
|
||||
|
||||
|
||||
DIRS= viewer imgtest ComFactory
|
||||
DIRS= viewer ComFactory
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "nsIWidget.h"
|
||||
#include "nsITextWidget.h"
|
||||
#include "nsIButton.h"
|
||||
#include "nsIImageGroup.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIURL.h"
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
#include "nsIWidget.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsIImageGroup.h"
|
||||
#include "nsIImageObserver.h"
|
||||
#include "nsIImageRequest.h"
|
||||
#include "nsFont.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIFontMetrics.h"
|
||||
|
@ -106,6 +103,8 @@ nsThrobber::HandleThrobberEvent(nsGUIEvent *aEvent)
|
|||
{
|
||||
case NS_PAINT:
|
||||
{
|
||||
#if 0
|
||||
|
||||
nsPaintEvent *pe = (nsPaintEvent *)aEvent;
|
||||
nsIRenderingContext *cx = pe->renderingContext;
|
||||
nsRect bounds;
|
||||
|
@ -156,7 +155,7 @@ nsThrobber::HandleThrobberEvent(nsGUIEvent *aEvent)
|
|||
cx->DrawImage(img, 1, 1);
|
||||
NS_RELEASE(img);
|
||||
}
|
||||
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -213,7 +212,7 @@ nsThrobber::Destroy()
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsThrobber, nsIImageRequestObserver)
|
||||
NS_IMPL_ISUPPORTS0(nsThrobber)
|
||||
|
||||
nsresult
|
||||
nsThrobber::Init(nsIWidget* aParent, const nsRect& aBounds, const nsString& aFileNameMask, PRInt32 aNumImages)
|
||||
|
@ -269,6 +268,7 @@ nsThrobber::Stop()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
nsThrobber::Notify(nsIImageRequest *aImageRequest,
|
||||
nsIImage *aImage,
|
||||
|
@ -292,6 +292,7 @@ nsThrobber::NotifyError(nsIImageRequest *aImageRequest,
|
|||
nsImageError aErrorType)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
nsThrobber::ThrobTimerCallback(nsITimer *aTimer, void *aClosure)
|
||||
|
@ -326,6 +327,7 @@ nsThrobber::Tick()
|
|||
nsresult
|
||||
nsThrobber::LoadThrobberImages(const nsString& aFileNameMask, PRInt32 aNumImages)
|
||||
{
|
||||
#if 0
|
||||
nsresult rv;
|
||||
char url[2000];
|
||||
|
||||
|
@ -367,6 +369,9 @@ nsThrobber::LoadThrobberImages(const nsString& aFileNameMask, PRInt32 aNumImages
|
|||
mWidget->Invalidate(PR_TRUE);
|
||||
|
||||
return rv;
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -376,6 +381,7 @@ nsThrobber::DestroyThrobberImages()
|
|||
mTimer->Cancel();
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (mImageGroup) {
|
||||
mImageGroup->Interrupt();
|
||||
for (PRInt32 cnt = 0; cnt < mNumImages; cnt++) {
|
||||
|
@ -389,4 +395,5 @@ nsThrobber::DestroyThrobberImages()
|
|||
delete mImages;
|
||||
mImages = nsnull;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
#ifndef nsThrobber_h___
|
||||
#define nsThrobber_h___
|
||||
|
||||
#include "nsIImageObserver.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsCRT.h"
|
||||
|
@ -32,7 +31,8 @@
|
|||
class nsIImageGroup;
|
||||
struct nsRect;
|
||||
|
||||
class nsThrobber : public nsIImageRequestObserver {
|
||||
class nsThrobber : public nsISupports
|
||||
{
|
||||
public:
|
||||
static nsThrobber* NewThrobber();
|
||||
|
||||
|
@ -40,6 +40,7 @@ public:
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
#if 0
|
||||
// nsIImageRequestObserver
|
||||
virtual void Notify(nsIImageRequest *aImageRequest,
|
||||
nsIImage *aImage,
|
||||
|
@ -49,6 +50,7 @@ public:
|
|||
|
||||
virtual void NotifyError(nsIImageRequest *aImageRequest,
|
||||
nsImageError aErrorType);
|
||||
#endif
|
||||
|
||||
// nsThrobber
|
||||
nsresult Init(nsIWidget* aParent, const nsRect& aBounds,
|
||||
|
@ -77,7 +79,7 @@ protected:
|
|||
nsVoidArray* mImages;
|
||||
PRInt32 mNumImages;
|
||||
PRInt32 mIndex;
|
||||
nsIImageGroup* mImageGroup;
|
||||
// nsIImageGroup* mImageGroup;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
PRBool mRunning;
|
||||
PRUint32 mCompletedImages;
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "nsBrowserWindow.h"
|
||||
#include "nsGtkMenu.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIImageManager.h"
|
||||
#include "nsIThread.h"
|
||||
#include "plevent.h"
|
||||
#include "prinit.h"
|
||||
|
|
|
@ -31,15 +31,12 @@
|
|||
#include "nsIEventQueue.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIImageManager.h"
|
||||
#include "nsGfxCIID.h"
|
||||
|
||||
// Class IDs...
|
||||
static NS_DEFINE_CID(kEventQueueCID, NS_EVENTQUEUE_CID);
|
||||
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
static NS_DEFINE_IID(kImageManagerCID, NS_IMAGEMANAGER_CID);
|
||||
|
||||
static nsMacNSPREventQueueHandler* gEventQueueHandler = nsnull;
|
||||
|
||||
//
|
||||
|
@ -345,18 +342,6 @@ OSErr nsMacMemoryCushion::Init(Size bufferSize, Size reserveSize)
|
|||
|
||||
void nsMacMemoryCushion::RepeatAction(const EventRecord &aMacEvent)
|
||||
{
|
||||
if (!RecoverMemoryBuffer(kMemoryBufferSize))
|
||||
{
|
||||
// NS_ASSERTION(0, "Failed to recallocate memory buffer. Flushing caches");
|
||||
// until imglib implements nsIMemoryPressureObserver (bug 46337)
|
||||
// manually flush the imglib cache here
|
||||
nsCOMPtr<nsIImageManager> imageManager = do_GetService(kImageManagerCID);
|
||||
if (imageManager)
|
||||
{
|
||||
imageManager->FlushCache(1); // flush everything
|
||||
}
|
||||
}
|
||||
|
||||
if (!RecoverMemoryReserve(kMemoryReserveSize))
|
||||
{
|
||||
// NS_ASSERTION(0, "Failed to recallocate memory reserve. Flushing caches");
|
||||
|
|
|
@ -452,7 +452,6 @@ nsWindow::nsWindow() : nsBaseWidget(), mRootAccessible(NULL)
|
|||
mBackground = ::GetSysColor(COLOR_BTNFACE);
|
||||
mBrush = ::CreateSolidBrush(NSRGB_2_COLOREF(mBackground));
|
||||
mForeground = ::GetSysColor(COLOR_WINDOWTEXT);
|
||||
mPalette = NULL;
|
||||
mIsShiftDown = PR_FALSE;
|
||||
mIsControlDown = PR_FALSE;
|
||||
mIsAltDown = PR_FALSE;
|
||||
|
@ -2165,6 +2164,7 @@ void nsWindow::FreeNativeData(void * data, PRUint32 aDataType)
|
|||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsWindow::SetColorMap(nsColorMap *aColorMap)
|
||||
{
|
||||
#if 0
|
||||
if (mPalette != NULL) {
|
||||
::DeleteObject(mPalette);
|
||||
}
|
||||
|
@ -2172,17 +2172,17 @@ NS_METHOD nsWindow::SetColorMap(nsColorMap *aColorMap)
|
|||
PRUint8 *map = aColorMap->Index;
|
||||
LPLOGPALETTE pLogPal = (LPLOGPALETTE) new char[2 * sizeof(WORD) +
|
||||
aColorMap->NumColors * sizeof(PALETTEENTRY)];
|
||||
pLogPal->palVersion = 0x300;
|
||||
pLogPal->palNumEntries = aColorMap->NumColors;
|
||||
for(int i = 0; i < aColorMap->NumColors; i++)
|
||||
pLogPal->palVersion = 0x300;
|
||||
pLogPal->palNumEntries = aColorMap->NumColors;
|
||||
for(int i = 0; i < aColorMap->NumColors; i++)
|
||||
{
|
||||
pLogPal->palPalEntry[i].peRed = *map++;
|
||||
pLogPal->palPalEntry[i].peGreen = *map++;
|
||||
pLogPal->palPalEntry[i].peBlue = *map++;
|
||||
pLogPal->palPalEntry[i].peFlags = 0;
|
||||
}
|
||||
mPalette = ::CreatePalette(pLogPal);
|
||||
delete pLogPal;
|
||||
pLogPal->palPalEntry[i].peRed = *map++;
|
||||
pLogPal->palPalEntry[i].peGreen = *map++;
|
||||
pLogPal->palPalEntry[i].peBlue = *map++;
|
||||
pLogPal->palPalEntry[i].peFlags = 0;
|
||||
}
|
||||
mPalette = ::CreatePalette(pLogPal);
|
||||
delete pLogPal;
|
||||
|
||||
NS_ASSERTION(mPalette != NULL, "Null palette");
|
||||
if (mPalette != NULL) {
|
||||
|
@ -2192,6 +2192,7 @@ NS_METHOD nsWindow::SetColorMap(nsColorMap *aColorMap)
|
|||
::SelectPalette(hDC, hOldPalette, TRUE);
|
||||
::ReleaseDC(mWnd, hDC);
|
||||
}
|
||||
#endif
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -2923,7 +2924,6 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
|||
static UINT vkKeyCached = 0; // caches VK code fon WM_KEYDOWN
|
||||
PRBool result = PR_FALSE; // call the default nsWindow proc
|
||||
static PRBool getWheelInfo = PR_TRUE;
|
||||
nsPaletteInfo palInfo;
|
||||
*aRetValue = 0;
|
||||
PRBool isMozWindowTakingFocus = PR_TRUE;
|
||||
|
||||
|
@ -3473,6 +3473,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
|||
// fall thru...
|
||||
|
||||
case WM_QUERYNEWPALETTE: // this window is about to become active
|
||||
#if 0
|
||||
mContext->GetPaletteInfo(palInfo);
|
||||
if (palInfo.isPaletteDevice && palInfo.palette) {
|
||||
HDC hDC = ::GetDC(mWnd);
|
||||
|
@ -3491,6 +3492,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
|
|||
*aRetValue = TRUE;
|
||||
}
|
||||
result = PR_TRUE;
|
||||
#endif
|
||||
break;
|
||||
|
||||
case WM_INPUTLANGCHANGEREQUEST:
|
||||
|
@ -3939,10 +3941,13 @@ void nsWindow::OnDestroy()
|
|||
VERIFY(::DeleteObject(mBrush));
|
||||
mBrush = NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (mPalette) {
|
||||
VERIFY(::DeleteObject(mPalette));
|
||||
mPalette = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
// if we were in the middle of deferred window positioning then
|
||||
// free the memory for the multiple-window position structure
|
||||
|
|
|
@ -399,7 +399,9 @@ protected:
|
|||
PRBool mIsTopWidgetWindow;
|
||||
nsPoint mLastPoint;
|
||||
HWND mWnd;
|
||||
#if 0
|
||||
HPALETTE mPalette;
|
||||
#endif
|
||||
WNDPROC mPrevWndProc;
|
||||
|
||||
PRBool mHas3DBorder;
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче