From 460155a53743c0f8a137c3fd8e490b0293c213e7 Mon Sep 17 00:00:00 2001 From: "pavlov%netscape.com" Date: Thu, 9 Aug 2001 20:22:39 +0000 Subject: [PATCH] fixing bug 78690. removing old imagelib. r=jst sr=waterson git-svn-id: svn://10.0.0.236/trunk@100670 18797224-902f-48f8-a5cc-f745e15eee43 --- .../mac/build_scripts/MozillaBuildList.pm | 7 - mozilla/chrome/src/nsChromeRegistry.cpp | 11 +- mozilla/content/base/src/nsDocumentViewer.cpp | 92 +-- .../browser/powerplant/source/CThrobber.cpp | 27 +- .../browser/powerplant/source/CThrobber.h | 21 +- .../webBrowser/nsDocShellTreeOwner.cpp | 1 + mozilla/gfx/macbuild/gfx.mcp | Bin 154704 -> 154704 bytes mozilla/gfx/public/MANIFEST | 4 - mozilla/gfx/public/Makefile.in | 4 - mozilla/gfx/public/makefile.win | 4 - mozilla/gfx/public/nsDeviceContext.h | 10 - mozilla/gfx/public/nsIDeviceContext.h | 39 -- mozilla/gfx/public/nsIImage.h | 8 +- mozilla/gfx/public/nsIRenderingContext.h | 26 - mozilla/gfx/public/nsRenderingContextImpl.h | 8 - mozilla/gfx/src/Makefile.in | 11 +- mozilla/gfx/src/gtk/Makefile.in | 2 +- mozilla/gfx/src/gtk/nsDeviceContextGTK.cpp | 5 - mozilla/gfx/src/gtk/nsDeviceContextGTK.h | 1 - mozilla/gfx/src/gtk/nsGfxFactoryGTK.cpp | 26 - mozilla/gfx/src/gtk/nsRenderingContextGTK.cpp | 3 +- mozilla/gfx/src/mac/nsDeviceContextMac.cpp | 44 -- mozilla/gfx/src/mac/nsDeviceContextMac.h | 2 - mozilla/gfx/src/mac/nsGfxFactoryMac.cpp | 9 - mozilla/gfx/src/mac/nsImageMac.cpp | 41 ++ mozilla/gfx/src/mac/nsImageMac.h | 5 + mozilla/gfx/src/makefile.win | 16 +- mozilla/gfx/src/nsBlender.cpp | 5 +- mozilla/gfx/src/nsBlender.h | 3 +- mozilla/gfx/src/nsDeviceContext.cpp | 163 +---- mozilla/gfx/src/nsRenderingContextImpl.cpp | 29 +- mozilla/gfx/src/ps/Makefile.in | 4 +- mozilla/gfx/src/ps/nsDeviceContextPS.cpp | 50 -- mozilla/gfx/src/ps/nsDeviceContextPS.h | 1 - mozilla/gfx/src/ps/nsRenderingContextPS.cpp | 1 - .../gfx/src/shared/nsRenderingContextImpl.cpp | 29 +- mozilla/gfx/src/windows/makefile.win | 5 +- .../gfx/src/windows/nsDeviceContextWin.cpp | 108 --- mozilla/gfx/src/windows/nsDeviceContextWin.h | 5 - mozilla/gfx/src/windows/nsGfxFactoryWin.cpp | 25 - mozilla/gfx/src/windows/nsImageWin.cpp | 56 +- mozilla/gfx/src/windows/nsImageWin.h | 16 +- .../gfx/src/windows/nsRenderingContextWin.cpp | 67 -- .../gfx/src/windows/nsRenderingContextWin.h | 4 - mozilla/gfx/src/xlib/nsDeviceContextXlib.h | 1 - mozilla/gfx/src/xprint/nsDeviceContextXP.cpp | 48 -- mozilla/gfx/src/xprint/nsDeviceContextXP.h | 1 - mozilla/gfx/tests/makefile.win | 3 - mozilla/layout/base/nsCSSRendering.cpp | 247 ++----- mozilla/layout/base/nsDocumentViewer.cpp | 92 +-- mozilla/layout/base/nsFrameManager.cpp | 4 +- mozilla/layout/base/nsImageLoader.cpp | 259 +++++++ mozilla/layout/base/nsImageLoader.h | 59 ++ mozilla/layout/base/nsPresContext.cpp | 259 ++----- mozilla/layout/base/nsPresContext.h | 51 +- mozilla/layout/base/nsPresShell.cpp | 1 - mozilla/layout/base/public/MANIFEST | 1 - mozilla/layout/base/public/Makefile.in | 1 - mozilla/layout/base/public/makefile.win | 1 - .../layout/base/public/nsIFrameImageLoader.h | 114 --- mozilla/layout/base/public/nsIPresContext.h | 51 +- mozilla/layout/base/public/nsPresContext.h | 51 +- mozilla/layout/base/src/Makefile.in | 2 +- mozilla/layout/base/src/makefile.win | 4 +- .../layout/base/src/nsFrameImageLoader.cpp | 655 ------------------ mozilla/layout/base/src/nsFrameImageLoader.h | 140 ---- mozilla/layout/base/src/nsImageLoader.cpp | 259 +++++++ mozilla/layout/base/src/nsImageLoader.h | 59 ++ mozilla/layout/base/src/nsPresContext.cpp | 259 ++----- mozilla/layout/base/src/nsPresContext.h | 25 +- mozilla/layout/generic/nsBulletFrame.cpp | 562 ++++++++++++--- mozilla/layout/generic/nsBulletFrame.h | 24 +- mozilla/layout/generic/nsFrame.cpp | 2 +- mozilla/layout/generic/nsImageFrame.cpp | 5 +- mozilla/layout/generic/nsImageFrame.h | 2 +- mozilla/layout/html/base/src/Makefile.in | 1 - mozilla/layout/html/base/src/makefile.win | 2 - .../layout/html/base/src/nsBulletFrame.cpp | 562 ++++++++++++--- mozilla/layout/html/base/src/nsBulletFrame.h | 24 +- mozilla/layout/html/base/src/nsFrame.cpp | 2 +- .../layout/html/base/src/nsFrameManager.cpp | 4 +- mozilla/layout/html/base/src/nsImageFrame.cpp | 5 +- mozilla/layout/html/base/src/nsImageFrame.h | 2 +- mozilla/layout/html/base/src/nsPresShell.cpp | 1 - .../layout/html/style/src/nsCSSRendering.cpp | 247 ++----- mozilla/layout/html/tests/makefile.win | 1 - mozilla/layout/macbuild/layout.mcp | Bin 141237 -> 141237 bytes .../layout/xul/base/src/nsImageBoxFrame.cpp | 15 - mozilla/layout/xul/base/src/nsImageBoxFrame.h | 20 - mozilla/modules/libimg/Makefile.in | 2 +- mozilla/modules/libimg/makefile.win | 4 +- mozilla/rdf/chrome/src/nsChromeRegistry.cpp | 11 +- mozilla/webshell/tests/makefile.win | 2 +- .../webshell/tests/viewer/nsBrowserWindow.cpp | 1 - mozilla/webshell/tests/viewer/nsThrobber.cpp | 17 +- mozilla/webshell/tests/viewer/nsThrobber.h | 8 +- .../tests/viewer/unix/gtk/nsGtkMain.cpp | 1 - mozilla/widget/src/mac/nsToolkit.cpp | 15 - mozilla/widget/src/windows/nsWindow.cpp | 29 +- mozilla/widget/src/windows/nsWindow.h | 2 + mozilla/xpinstall/packager/packages-mac | 5 - mozilla/xpinstall/packager/packages-unix | 4 - mozilla/xpinstall/packager/packages-win | 5 - 103 files changed, 2167 insertions(+), 3065 deletions(-) create mode 100644 mozilla/layout/base/nsImageLoader.cpp create mode 100644 mozilla/layout/base/nsImageLoader.h delete mode 100644 mozilla/layout/base/public/nsIFrameImageLoader.h delete mode 100644 mozilla/layout/base/src/nsFrameImageLoader.cpp delete mode 100644 mozilla/layout/base/src/nsFrameImageLoader.h create mode 100644 mozilla/layout/base/src/nsImageLoader.cpp create mode 100644 mozilla/layout/base/src/nsImageLoader.h diff --git a/mozilla/build/mac/build_scripts/MozillaBuildList.pm b/mozilla/build/mac/build_scripts/MozillaBuildList.pm index 77e7b606a51..b7276af35f4 100644 --- a/mozilla/build/mac/build_scripts/MozillaBuildList.pm +++ b/mozilla/build/mac/build_scripts/MozillaBuildList.pm @@ -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"); diff --git a/mozilla/chrome/src/nsChromeRegistry.cpp b/mozilla/chrome/src/nsChromeRegistry.cpp index 87b4db110b4..78f371a0f2a 100644 --- a/mozilla/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/chrome/src/nsChromeRegistry.cpp @@ -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 imageManager = - do_GetService(kImageManagerCID, &rv); - if (imageManager) - rv = imageManager->FlushCache(1); // Flush the new imagelib image chrome cache. - nsCOMPtr imageCache = - do_GetService("@mozilla.org/image/cache;1", &rv); + nsCOMPtr imageCache(do_GetService("@mozilla.org/image/cache;1", &rv)); if (NS_SUCCEEDED(rv) && imageCache) { imageCache->ClearCache(PR_TRUE); } diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index 11e758c7189..0a1d397667d 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -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 eventQ; - - // Get the event queue of the current thread... - nsCOMPtr 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 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 imageGroup; - mPrt->mPrintPC->GetImageGroup(getter_AddRefs(imageGroup)); - if (imageGroup) { - imageGroup->AddObserver(this); - } - mPrt->mPrintPS->InitialReflow(width,height); #ifdef DEBUG_dcone diff --git a/mozilla/embedding/browser/powerplant/source/CThrobber.cpp b/mozilla/embedding/browser/powerplant/source/CThrobber.cpp index a857b9d2517..92ac083441e 100644 --- a/mozilla/embedding/browser/powerplant/source/CThrobber.cpp +++ b/mozilla/embedding/browser/powerplant/source/CThrobber.cpp @@ -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(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(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() diff --git a/mozilla/embedding/browser/powerplant/source/CThrobber.h b/mozilla/embedding/browser/powerplant/source/CThrobber.h index 8c3b1ab9cc4..a11a339a02e 100644 --- a/mozilla/embedding/browser/powerplant/source/CThrobber.h +++ b/mozilla/embedding/browser/powerplant/source/CThrobber.h @@ -37,20 +37,18 @@ #include "nsGUIEvent.h" #endif +#include "nsITimer.h" + #include "nsString.h" -#include "nsIImageObserver.h" #include #include 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 mWidget; - vector *mImages; +// vector *mImages; bool mRunning; SInt32 mNumImages, mCompletedImages; - nsIImageGroup *mImageGroup; nsCOMPtr mTimer; static map mgThrobberMap; diff --git a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index e73b157c514..0b4d26130ad 100644 --- a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -31,6 +31,7 @@ // Helper Classes #include "nsIGenericFactory.h" #include "nsStyleCoord.h" +#include "nsSize.h" #include "nsHTMLReflowState.h" #include "nsIServiceManager.h" #include "nsXPIDLString.h" diff --git a/mozilla/gfx/macbuild/gfx.mcp b/mozilla/gfx/macbuild/gfx.mcp index cd3cc85053d0bfaae60c68139d3605d26e7f61aa..eab2263c0a057be6794f8bcec182d4cd0af14a70 100644 GIT binary patch delta 1421 zcmb`GUq}=|9LINN@2_5Y=N~*h?al(dBr*y!5mCdtD@Z#lMM)$QGorxsf-vv`A1uX7 z@At4mK3ETF9dgMAYe{s4mDGa=aVZ2o)I%Ed5cKELX#4Hm_z;-+;KFAQt zPwK;y`uit|DUaj0LKPM&j%J|p#PcMF6zlL-k7y7rl7J*4I}ii11=)%uAx6Z6BqJ&C z+gSz`E*seeO)i`0XRm=-$>6lJc{5f*Y;v8*Cu*3wSdpuC9zNpGa^y4fC+0ck`IsTU z-EP1sq$xGD7Mj{^Uc520AelLxIh8pfZW3kw!W?@Ie)u<5Uy7S1vU-U57xOdb73PO% zFV2KKVZk!{V`{Je=Ru8hej#uZRZSdC7eCzu!=iJZ`z?Tf{TIM(1-Yu01||;h!tK(s#MAW zf_qNOX1+Lu?3ET;NvaAuqv>gjIy{t!5Ah=bBnU5}R#=KwW$8F-S%XX^6OC^R&I$!( z#4U}M5i=1!mXjH2u7Wst;cF$aZ=jH{pSMM54&WH?0?HVcaWW!(7$+Ba!9Iaw{J)T} zOTjQHm+Gr%Dl!&*3s>hhEEBG1`H#O Kv9P>>8u>qy6kApR delta 1533 zcmZXTZ)jU(6o=pQ-rOYB)-^C)+HSQjFuS2!hZHAs-6l(_;JS31!%;tMAe)pq++t-^ zYWHE3VO`L^;Ke_XxP)Xjj;`F{&8)giyANWa6ocCrXTQifbxzt0xHX%g23vVtV8=yAx7(GVnsr(jtLfsE-SDE~3^+vB(9qwFX zhBRNBe_ziEArAH7v;TQ{P2YL9RDJD@o(*>{7K`r|5d1~z{ij!XcDMc{gdTK)3(u5- zABx5E9ZrzjS_-Zgi?cfs+#|EF?Pr&76aIR;2X7uBTcAzm#B*+~eZeK@CKv`$FalyA z4iX>?`nKY3{2W+-F~7Pj>EoDU7|AUS93!kyG$WK8vzP*eP~~JZchNz@Zur%->x zbsF`zcCDHRy7esDg58?O2O3D9LjS9CJoL_I`hpO0rEwbn$y_)1k*4;X=`)tbsoT7D z=6iDH_;8e3yqMA+q}cU{_TC z-OJ{Qk2SL9yQof6lhaL`7d^NN5CtP32I3$Ak{|`rAOprgRxM4JuA+7(Z2I$$zgD#Z zoK{wVrm_Mwl@*|=tN_jO3XEqvsA>n+dmU801S7efs<&Vr+dCyqV-l? zh>pCvJW@a}&lAwg!vys5BmuoVMnHF-iSQ^zoI9}MqqMbh0RiKe3?5MDS-=ehthc|Q z*EK6VPM%NcwDt0Cd6Xz;GetGC(mSurface->GetDrawable(), + + mGC = gcCache->GetGC(mSurface->GetDrawable(), &values, valuesMask, rgn); diff --git a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp index b22cec59f22..a44f4b73788 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp +++ b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp @@ -40,7 +40,6 @@ #include #include #include -#include "il_util.h" #include #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 diff --git a/mozilla/gfx/src/mac/nsDeviceContextMac.h b/mozilla/gfx/src/mac/nsDeviceContextMac.h index 8893383a5f4..3544d535e93 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextMac.h +++ b/mozilla/gfx/src/mac/nsDeviceContextMac.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); diff --git a/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp b/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp index ec0dc1fcc50..b169f8df8be 100644 --- a/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp +++ b/mozilla/gfx/src/mac/nsGfxFactoryMac.cpp @@ -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 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); diff --git a/mozilla/gfx/src/mac/nsImageMac.cpp b/mozilla/gfx/src/mac/nsImageMac.cpp index ca5ae40322f..0e58f14001f 100644 --- a/mozilla/gfx/src/mac/nsImageMac.cpp +++ b/mozilla/gfx/src/mac/nsImageMac.cpp @@ -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; +} diff --git a/mozilla/gfx/src/mac/nsImageMac.h b/mozilla/gfx/src/mac/nsImageMac.h index f9c10911d0e..d41769954f5 100644 --- a/mozilla/gfx/src/mac/nsImageMac.h +++ b/mozilla/gfx/src/mac/nsImageMac.h @@ -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); diff --git a/mozilla/gfx/src/makefile.win b/mozilla/gfx/src/makefile.win index 094d1d7a033..95a42f62501 100644 --- a/mozilla/gfx/src/makefile.win +++ b/mozilla/gfx/src/makefile.win @@ -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) diff --git a/mozilla/gfx/src/nsBlender.cpp b/mozilla/gfx/src/nsBlender.cpp index 341bcba7c7d..c684c035a87 100644 --- a/mozilla/gfx/src/nsBlender.cpp +++ b/mozilla/gfx/src/nsBlender.cpp @@ -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 } //------------------------------------------------------------ diff --git a/mozilla/gfx/src/nsBlender.h b/mozilla/gfx/src/nsBlender.h index dd89bb05416..987b7017ce9 100644 --- a/mozilla/gfx/src/nsBlender.h +++ b/mozilla/gfx/src/nsBlender.h @@ -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 diff --git a/mozilla/gfx/src/nsDeviceContext.cpp b/mozilla/gfx/src/nsDeviceContext.cpp index 39155d4d75a..1732648102c 100644 --- a/mozilla/gfx/src/nsDeviceContext.cpp +++ b/mozilla/gfx/src/nsDeviceContext.cpp @@ -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 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 diff --git a/mozilla/gfx/src/nsRenderingContextImpl.cpp b/mozilla/gfx/src/nsRenderingContextImpl.cpp index a269196acca..515df4d5d5c 100644 --- a/mozilla/gfx/src/nsRenderingContextImpl.cpp +++ b/mozilla/gfx/src/nsRenderingContextImpl.cpp @@ -25,7 +25,6 @@ #include "nsIImage.h" #include "nsTransform2D.h" #include -#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 iframe; + aImage->GetCurrentFrame(getter_AddRefs(iframe)); + if (!iframe) return NS_ERROR_FAILURE; + + nsCOMPtr 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); */ diff --git a/mozilla/gfx/src/ps/Makefile.in b/mozilla/gfx/src/ps/Makefile.in index ca2771cd18b..abbf2b06dbf 100644 --- a/mozilla/gfx/src/ps/Makefile.in +++ b/mozilla/gfx/src/ps/Makefile.in @@ -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 diff --git a/mozilla/gfx/src/ps/nsDeviceContextPS.cpp b/mozilla/gfx/src/ps/nsDeviceContextPS.cpp index 48d36757654..f7719b17a96 100644 --- a/mozilla/gfx/src/ps/nsDeviceContextPS.cpp +++ b/mozilla/gfx/src/ps/nsDeviceContextPS.cpp @@ -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 diff --git a/mozilla/gfx/src/ps/nsDeviceContextPS.h b/mozilla/gfx/src/ps/nsDeviceContextPS.h index 134249b3d3a..0d8c980a3a9 100644 --- a/mozilla/gfx/src/ps/nsDeviceContextPS.h +++ b/mozilla/gfx/src/ps/nsDeviceContextPS.h @@ -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); diff --git a/mozilla/gfx/src/ps/nsRenderingContextPS.cpp b/mozilla/gfx/src/ps/nsRenderingContextPS.cpp index 3ab74e03493..7423e2f6d3c 100644 --- a/mozilla/gfx/src/ps/nsRenderingContextPS.cpp +++ b/mozilla/gfx/src/ps/nsRenderingContextPS.cpp @@ -23,7 +23,6 @@ #include "nsRenderingContextPS.h" #include "nsFontMetricsPS.h" #include -#include "libimg.h" #include "nsDeviceContextPS.h" #include "nsPostScriptObj.h" #include "nsIRegion.h" diff --git a/mozilla/gfx/src/shared/nsRenderingContextImpl.cpp b/mozilla/gfx/src/shared/nsRenderingContextImpl.cpp index a269196acca..515df4d5d5c 100644 --- a/mozilla/gfx/src/shared/nsRenderingContextImpl.cpp +++ b/mozilla/gfx/src/shared/nsRenderingContextImpl.cpp @@ -25,7 +25,6 @@ #include "nsIImage.h" #include "nsTransform2D.h" #include -#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 iframe; + aImage->GetCurrentFrame(getter_AddRefs(iframe)); + if (!iframe) return NS_ERROR_FAILURE; + + nsCOMPtr 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); */ diff --git a/mozilla/gfx/src/windows/makefile.win b/mozilla/gfx/src/windows/makefile.win index c64b4477999..2be8e8495c4 100644 --- a/mozilla/gfx/src/windows/makefile.win +++ b/mozilla/gfx/src/windows/makefile.win @@ -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:: diff --git a/mozilla/gfx/src/windows/nsDeviceContextWin.cpp b/mozilla/gfx/src/windows/nsDeviceContextWin.cpp index 5981abdb701..8186f763f8f 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextWin.cpp +++ b/mozilla/gfx/src/windows/nsDeviceContextWin.cpp @@ -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) { diff --git a/mozilla/gfx/src/windows/nsDeviceContextWin.h b/mozilla/gfx/src/windows/nsDeviceContextWin.h index 52999c46879..87d9386ed21 100644 --- a/mozilla/gfx/src/windows/nsDeviceContextWin.h +++ b/mozilla/gfx/src/windows/nsDeviceContextWin.h @@ -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; diff --git a/mozilla/gfx/src/windows/nsGfxFactoryWin.cpp b/mozilla/gfx/src/windows/nsGfxFactoryWin.cpp index a123a2e20ea..42cfde0df88 100644 --- a/mozilla/gfx/src/windows/nsGfxFactoryWin.cpp +++ b/mozilla/gfx/src/windows/nsGfxFactoryWin.cpp @@ -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 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", diff --git a/mozilla/gfx/src/windows/nsImageWin.cpp b/mozilla/gfx/src/windows/nsImageWin.cpp index c1433088cfd..eb0a246eee1 100644 --- a/mozilla/gfx/src/windows/nsImageWin.cpp +++ b/mozilla/gfx/src/windows/nsImageWin.cpp @@ -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;yDraw(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; } /** --------------------------------------------------- diff --git a/mozilla/gfx/src/windows/nsImageWin.h b/mozilla/gfx/src/windows/nsImageWin.h index 35a0cee733d..111b1eda16b 100644 --- a/mozilla/gfx/src/windows/nsImageWin.h +++ b/mozilla/gfx/src/windows/nsImageWin.h @@ -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 diff --git a/mozilla/gfx/src/windows/nsRenderingContextWin.cpp b/mozilla/gfx/src/windows/nsRenderingContextWin.cpp index 494b16a86a0..b67fa4092f8 100644 --- a/mozilla/gfx/src/windows/nsRenderingContextWin.cpp +++ b/mozilla/gfx/src/windows/nsRenderingContextWin.cpp @@ -25,7 +25,6 @@ #include "nsFontMetricsWin.h" #include "nsRegionWin.h" #include -#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); diff --git a/mozilla/gfx/src/windows/nsRenderingContextWin.h b/mozilla/gfx/src/windows/nsRenderingContextWin.h index c25197c7c32..7fd4b224efe 100644 --- a/mozilla/gfx/src/windows/nsRenderingContextWin.h +++ b/mozilla/gfx/src/windows/nsRenderingContextWin.h @@ -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); //~~~ diff --git a/mozilla/gfx/src/xlib/nsDeviceContextXlib.h b/mozilla/gfx/src/xlib/nsDeviceContextXlib.h index 6b1a36760cf..b28d226e02f 100644 --- a/mozilla/gfx/src/xlib/nsDeviceContextXlib.h +++ b/mozilla/gfx/src/xlib/nsDeviceContextXlib.h @@ -79,7 +79,6 @@ protected: private: void CommonInit(void); - nsPaletteInfo mPaletteInfo; PRBool mWriteable; PRUint32 mNumCells; nsDrawingSurface mSurface; diff --git a/mozilla/gfx/src/xprint/nsDeviceContextXP.cpp b/mozilla/gfx/src/xprint/nsDeviceContextXP.cpp index 4c03db4f3e6..6b4d10659f2 100644 --- a/mozilla/gfx/src/xprint/nsDeviceContextXP.cpp +++ b/mozilla/gfx/src/xprint/nsDeviceContextXP.cpp @@ -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 diff --git a/mozilla/gfx/src/xprint/nsDeviceContextXP.h b/mozilla/gfx/src/xprint/nsDeviceContextXP.h index 944783a86f3..14ccc1e5338 100644 --- a/mozilla/gfx/src/xprint/nsDeviceContextXP.h +++ b/mozilla/gfx/src/xprint/nsDeviceContextXP.h @@ -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); diff --git a/mozilla/gfx/tests/makefile.win b/mozilla/gfx/tests/makefile.win index dc96d6bf9d8..8749184e358 100644 --- a/mozilla/gfx/tests/makefile.win +++ b/mozilla/gfx/tests/makefile.win @@ -21,9 +21,6 @@ DEPTH=..\.. - -DIRS = btest - MAKE_OBJ_TYPE = EXE PROG1 = .\$(OBJDIR)\TestRect.exe PROG2 = .\$(OBJDIR)\TestColorNames.exe diff --git a/mozilla/layout/base/nsCSSRendering.cpp b/mozilla/layout/base/nsCSSRendering.cpp index 88e0fde0b5b..f0342414d1a 100644 --- a/mozilla/layout/base/nsCSSRendering.cpp +++ b/mozilla/layout/base/nsCSSRendering.cpp @@ -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 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 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 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 0){ - PaintRoundedBackground(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,aColor,aDX,aDY,borderRadii); - return; - } - } - - aRenderingContext.SetColor(aColor.mBackgroundColor); - aRenderingContext.FillRect(aBorderArea); - } } + } /** --------------------------------------------------- diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index 11e758c7189..0a1d397667d 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -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 eventQ; - - // Get the event queue of the current thread... - nsCOMPtr 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 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 imageGroup; - mPrt->mPrintPC->GetImageGroup(getter_AddRefs(imageGroup)); - if (imageGroup) { - imageGroup->AddObserver(this); - } - mPrt->mPrintPS->InitialReflow(width,height); #ifdef DEBUG_dcone diff --git a/mozilla/layout/base/nsFrameManager.cpp b/mozilla/layout/base/nsFrameManager.cpp index c82f7702de4..cd702303aa8 100644 --- a/mozilla/layout/base/nsFrameManager.cpp +++ b/mozilla/layout/base/nsFrameManager.cpp @@ -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 { diff --git a/mozilla/layout/base/nsImageLoader.cpp b/mozilla/layout/base/nsImageLoader.cpp new file mode 100644 index 00000000000..716160704c0 --- /dev/null +++ b/mozilla/layout/base/nsImageLoader.cpp @@ -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 + */ + +#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 loadGroup; + nsCOMPtr uri; + nsCOMPtr baseURI; + + nsCOMPtr shell; + nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr 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 oldURI; + mRequest->GetURI(getter_AddRefs(oldURI)); + PRBool eq = PR_FALSE; + uri->Equals(oldURI, &eq); + if (eq) { + return NS_OK; + } + } + + nsCOMPtr 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 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 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); + } + } + +} diff --git a/mozilla/layout/base/nsImageLoader.h b/mozilla/layout/base/nsImageLoader.h new file mode 100644 index 00000000000..bc72251db43 --- /dev/null +++ b/mozilla/layout/base/nsImageLoader.h @@ -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 + */ + +#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 mRequest; +}; diff --git a/mozilla/layout/base/nsPresContext.cpp b/mozilla/layout/base/nsPresContext.cpp index afa2b2faf3e..13d3e97355e 100644 --- a/mozilla/layout/base/nsPresContext.cpp +++ b/mozilla/layout/base/nsPresContext.cpp @@ -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 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 loadHandler (do_GetInterface(mContainer, &rv)); - if (NS_SUCCEEDED(rv) && loadHandler) - { - nsCOMPtr 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 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 content; - nsCOMPtr element; - if (aTargetFrame && - NS_SUCCEEDED(aTargetFrame->GetContent(getter_AddRefs(content)))) { - element = do_QueryInterface(content); - } + loader->GetRequest(aRequest); - nsCOMPtr uri; - nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL); - if (NS_FAILED(rv)) { - NS_ASSERTION(0, "was expecting a URI"); - return NS_OK; - } - - nsCOMPtr document; - rv = mShell->GetDocument(getter_AddRefs(document)); - if (NS_FAILED(rv)) return rv; + NS_RELEASE(loader); - nsCOMPtr globalScript; - rv = document->GetScriptGlobalObject(getter_AddRefs(globalScript)); - if (NS_FAILED(rv)) return rv; + return NS_OK; +} - nsCOMPtr 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 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) diff --git a/mozilla/layout/base/nsPresContext.h b/mozilla/layout/base/nsPresContext.h index 42284a95d06..a5a5b16b81d 100644 --- a/mozilla/layout/base/nsPresContext.h +++ b/mozilla/layout/base/nsPresContext.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; diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index c322d030772..12578c04192 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -6698,7 +6698,6 @@ PresShell::VerifyIncrementalReflow() } } - cx->Stop(); cx->SetContainer(nsnull); NS_RELEASE(cx); sh->EndObservingDocument(); diff --git a/mozilla/layout/base/public/MANIFEST b/mozilla/layout/base/public/MANIFEST index 123c1970f01..92f23f2112c 100644 --- a/mozilla/layout/base/public/MANIFEST +++ b/mozilla/layout/base/public/MANIFEST @@ -10,7 +10,6 @@ nsICaret.h nsIFocusTracker.h nsIFrame.h nsIFrameDebug.h -nsIFrameImageLoader.h nsIFrameManager.h nsIFrameSelection.h nsIFrameUtil.h diff --git a/mozilla/layout/base/public/Makefile.in b/mozilla/layout/base/public/Makefile.in index 599d8dad896..fadab5c8ba6 100644 --- a/mozilla/layout/base/public/Makefile.in +++ b/mozilla/layout/base/public/Makefile.in @@ -41,7 +41,6 @@ nsIImageFrame.h \ nsIObjectFrame.h \ nsIFrameTraversal.h \ nsIFrameDebug.h \ -nsIFrameImageLoader.h \ nsIFrameManager.h \ nsIIndependentSelection.h \ nsILayoutDebugger.h \ diff --git a/mozilla/layout/base/public/makefile.win b/mozilla/layout/base/public/makefile.win index 28f1c593969..85be1c18fff 100644 --- a/mozilla/layout/base/public/makefile.win +++ b/mozilla/layout/base/public/makefile.win @@ -34,7 +34,6 @@ EXPORTS = \ nsIImageFrame.h \ nsIFrameTraversal.h \ nsIFrameDebug.h \ - nsIFrameImageLoader.h \ nsIFrameManager.h \ nsIIndependentSelection.h \ nsILayoutDebugger.h \ diff --git a/mozilla/layout/base/public/nsIFrameImageLoader.h b/mozilla/layout/base/public/nsIFrameImageLoader.h deleted file mode 100644 index 026600230dd..00000000000 --- a/mozilla/layout/base/public/nsIFrameImageLoader.h +++ /dev/null @@ -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___ */ diff --git a/mozilla/layout/base/public/nsIPresContext.h b/mozilla/layout/base/public/nsIPresContext.h index 42284a95d06..a5a5b16b81d 100644 --- a/mozilla/layout/base/public/nsIPresContext.h +++ b/mozilla/layout/base/public/nsIPresContext.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; diff --git a/mozilla/layout/base/public/nsPresContext.h b/mozilla/layout/base/public/nsPresContext.h index 42284a95d06..a5a5b16b81d 100644 --- a/mozilla/layout/base/public/nsPresContext.h +++ b/mozilla/layout/base/public/nsPresContext.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; diff --git a/mozilla/layout/base/src/Makefile.in b/mozilla/layout/base/src/Makefile.in index 7c329207a77..5f125ab510f 100644 --- a/mozilla/layout/base/src/Makefile.in +++ b/mozilla/layout/base/src/Makefile.in @@ -34,7 +34,7 @@ CPPSRCS = \ nsAutoCopy.cpp \ nsCaret.cpp \ nsCopySupport.cpp \ - nsFrameImageLoader.cpp \ + nsImageLoader.cpp \ nsFrameList.cpp \ nsFrameTraversal.cpp \ nsFrameUtil.cpp \ diff --git a/mozilla/layout/base/src/makefile.win b/mozilla/layout/base/src/makefile.win index 5cd154f01f6..72393f0df23 100644 --- a/mozilla/layout/base/src/makefile.win +++ b/mozilla/layout/base/src/makefile.win @@ -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 \ diff --git a/mozilla/layout/base/src/nsFrameImageLoader.cpp b/mozilla/layout/base/src/nsFrameImageLoader.cpp deleted file mode 100644 index 7699cf50052..00000000000 --- a/mozilla/layout/base/src/nsFrameImageLoader.cpp +++ /dev/null @@ -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 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 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); - } - } - } - } -} diff --git a/mozilla/layout/base/src/nsFrameImageLoader.h b/mozilla/layout/base/src/nsFrameImageLoader.h deleted file mode 100644 index 4afe77f836e..00000000000 --- a/mozilla/layout/base/src/nsFrameImageLoader.h +++ /dev/null @@ -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___ */ diff --git a/mozilla/layout/base/src/nsImageLoader.cpp b/mozilla/layout/base/src/nsImageLoader.cpp new file mode 100644 index 00000000000..716160704c0 --- /dev/null +++ b/mozilla/layout/base/src/nsImageLoader.cpp @@ -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 + */ + +#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 loadGroup; + nsCOMPtr uri; + nsCOMPtr baseURI; + + nsCOMPtr shell; + nsresult rv = mPresContext->GetShell(getter_AddRefs(shell)); + if (NS_FAILED(rv)) return rv; + + nsCOMPtr 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 oldURI; + mRequest->GetURI(getter_AddRefs(oldURI)); + PRBool eq = PR_FALSE; + uri->Equals(oldURI, &eq); + if (eq) { + return NS_OK; + } + } + + nsCOMPtr 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 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 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); + } + } + +} diff --git a/mozilla/layout/base/src/nsImageLoader.h b/mozilla/layout/base/src/nsImageLoader.h new file mode 100644 index 00000000000..bc72251db43 --- /dev/null +++ b/mozilla/layout/base/src/nsImageLoader.h @@ -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 + */ + +#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 mRequest; +}; diff --git a/mozilla/layout/base/src/nsPresContext.cpp b/mozilla/layout/base/src/nsPresContext.cpp index afa2b2faf3e..13d3e97355e 100644 --- a/mozilla/layout/base/src/nsPresContext.cpp +++ b/mozilla/layout/base/src/nsPresContext.cpp @@ -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 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 loadHandler (do_GetInterface(mContainer, &rv)); - if (NS_SUCCEEDED(rv) && loadHandler) - { - nsCOMPtr 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 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 content; - nsCOMPtr element; - if (aTargetFrame && - NS_SUCCEEDED(aTargetFrame->GetContent(getter_AddRefs(content)))) { - element = do_QueryInterface(content); - } + loader->GetRequest(aRequest); - nsCOMPtr uri; - nsresult rv = NS_NewURI(getter_AddRefs(uri), aURL); - if (NS_FAILED(rv)) { - NS_ASSERTION(0, "was expecting a URI"); - return NS_OK; - } - - nsCOMPtr document; - rv = mShell->GetDocument(getter_AddRefs(document)); - if (NS_FAILED(rv)) return rv; + NS_RELEASE(loader); - nsCOMPtr globalScript; - rv = document->GetScriptGlobalObject(getter_AddRefs(globalScript)); - if (NS_FAILED(rv)) return rv; + return NS_OK; +} - nsCOMPtr 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 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) diff --git a/mozilla/layout/base/src/nsPresContext.h b/mozilla/layout/base/src/nsPresContext.h index afb295d46c7..2e80c414bdf 100644 --- a/mozilla/layout/base/src/nsPresContext.h +++ b/mozilla/layout/base/src/nsPresContext.h @@ -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 mLangService; nsCOMPtr mLanguage; nsLanguageSpecificTransformType mLanguageSpecificTransformType; - nsCOMPtr mImageGroup; nsILinkHandler* mLinkHandler; // [WEAK] nsISupports* mContainer; // [WEAK] nsCOMPtr mLookAndFeel; @@ -223,7 +216,9 @@ protected: nscoord mDefaultBackgroundImageOffsetX; nscoord mDefaultBackgroundImageOffsetY; PRUint8 mDefaultBackgroundImageAttachment; - nsVoidArray mImageLoaders; + + nsSupportsHashtable mImageLoaders; + nsCOMPtr mEventManager; nsCOMPtr mBaseURL; nsCompatibility mCompatibilityMode; diff --git a/mozilla/layout/generic/nsBulletFrame.cpp b/mozilla/layout/generic/nsBulletFrame.cpp index 8d53f47e8a7..82270e0cda1 100644 --- a/mozilla/layout/generic/nsBulletFrame.cpp +++ b/mozilla/layout/generic/nsBulletFrame.cpp @@ -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 il(do_GetService("@mozilla.org/image/loader;1", &rv)); + if (NS_FAILED(rv)) + return rv; + + nsCOMPtr loadGroup; + GetLoadGroup(aPresContext, getter_AddRefs(loadGroup)); + + nsCOMPtr baseURI; + GetBaseURI(getter_AddRefs(baseURI)); + + nsCOMPtr 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 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 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 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 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 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 newURI; + NS_NewURI(getter_AddRefs(newURI), myList->mListStyleImage, baseURI); + + PRBool needNewRequest = PR_TRUE; + + if (mImageRequest) { + // Reload the image, maybe... + nsCOMPtr 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 il(do_GetService("@mozilla.org/image/loader;1", &rv)); + if (NS_FAILED(rv)) + return rv; + + nsCOMPtr 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 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 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 baseURI; + nsCOMPtr htmlContent(do_QueryInterface(mContent, &rv)); + if (NS_SUCCEEDED(rv)) { + htmlContent->GetBaseURL(*getter_AddRefs(baseURI)); + } + else { + nsCOMPtr 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 shell; + aPresContext->GetShell(getter_AddRefs(shell)); + + if (!shell) + return; + + nsCOMPtr 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 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 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 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 pc(do_QueryInterface(aContext)); + + NS_ASSERTION(pc, "not a pres context!"); + + return mFrame->FrameChanged(aContainer, pc, newframe, dirtyRect); +} diff --git a/mozilla/layout/generic/nsBulletFrame.h b/mozilla/layout/generic/nsBulletFrame.h index ea795719932..e95fbb7ca65 100644 --- a/mozilla/layout/generic/nsBulletFrame.h +++ b/mozilla/layout/generic/nsBulletFrame.h @@ -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 mImageRequest; + nsCOMPtr mListener; + + nsSize mIntrinsicSize; + nsSize mComputedSize; }; #endif /* nsBulletFrame_h___ */ diff --git a/mozilla/layout/generic/nsFrame.cpp b/mozilla/layout/generic/nsFrame.cpp index 4e4b79cd9f0..8509f9b74a8 100644 --- a/mozilla/layout/generic/nsFrame.cpp +++ b/mozilla/layout/generic/nsFrame.cpp @@ -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 diff --git a/mozilla/layout/generic/nsImageFrame.cpp b/mozilla/layout/generic/nsImageFrame.cpp index 413220debdd..286167846d0 100644 --- a/mozilla/layout/generic/nsImageFrame.cpp +++ b/mozilla/layout/generic/nsImageFrame.cpp @@ -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 { diff --git a/mozilla/layout/generic/nsImageFrame.h b/mozilla/layout/generic/nsImageFrame.h index 31d849d0414..be625cd51c2 100644 --- a/mozilla/layout/generic/nsImageFrame.h +++ b/mozilla/layout/generic/nsImageFrame.h @@ -43,7 +43,7 @@ struct nsSize; class nsImageFrame; -class nsImageListener : imgIDecoderObserver +class nsImageListener : public imgIDecoderObserver { public: nsImageListener(nsImageFrame *aFrame); diff --git a/mozilla/layout/html/base/src/Makefile.in b/mozilla/layout/html/base/src/Makefile.in index fb81b1e94ca..0bac42cc4bf 100644 --- a/mozilla/layout/html/base/src/Makefile.in +++ b/mozilla/layout/html/base/src/Makefile.in @@ -49,7 +49,6 @@ CPPSRCS = \ nsHTMLContainerFrame.cpp \ nsHTMLIIDs.cpp \ nsHTMLFrame.cpp \ - nsHTMLImageLoader.cpp \ nsHTMLReflowCommand.cpp \ nsHTMLReflowState.cpp \ nsImageFrame.cpp \ diff --git a/mozilla/layout/html/base/src/makefile.win b/mozilla/layout/html/base/src/makefile.win index e9112e5fcb8..f89c5dab330 100644 --- a/mozilla/layout/html/base/src/makefile.win +++ b/mozilla/layout/html/base/src/makefile.win @@ -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 \ diff --git a/mozilla/layout/html/base/src/nsBulletFrame.cpp b/mozilla/layout/html/base/src/nsBulletFrame.cpp index 8d53f47e8a7..82270e0cda1 100644 --- a/mozilla/layout/html/base/src/nsBulletFrame.cpp +++ b/mozilla/layout/html/base/src/nsBulletFrame.cpp @@ -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 il(do_GetService("@mozilla.org/image/loader;1", &rv)); + if (NS_FAILED(rv)) + return rv; + + nsCOMPtr loadGroup; + GetLoadGroup(aPresContext, getter_AddRefs(loadGroup)); + + nsCOMPtr baseURI; + GetBaseURI(getter_AddRefs(baseURI)); + + nsCOMPtr 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 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 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 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 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 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 newURI; + NS_NewURI(getter_AddRefs(newURI), myList->mListStyleImage, baseURI); + + PRBool needNewRequest = PR_TRUE; + + if (mImageRequest) { + // Reload the image, maybe... + nsCOMPtr 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 il(do_GetService("@mozilla.org/image/loader;1", &rv)); + if (NS_FAILED(rv)) + return rv; + + nsCOMPtr 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 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 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 baseURI; + nsCOMPtr htmlContent(do_QueryInterface(mContent, &rv)); + if (NS_SUCCEEDED(rv)) { + htmlContent->GetBaseURL(*getter_AddRefs(baseURI)); + } + else { + nsCOMPtr 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 shell; + aPresContext->GetShell(getter_AddRefs(shell)); + + if (!shell) + return; + + nsCOMPtr 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 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 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 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 pc(do_QueryInterface(aContext)); + + NS_ASSERTION(pc, "not a pres context!"); + + return mFrame->FrameChanged(aContainer, pc, newframe, dirtyRect); +} diff --git a/mozilla/layout/html/base/src/nsBulletFrame.h b/mozilla/layout/html/base/src/nsBulletFrame.h index ea795719932..e95fbb7ca65 100644 --- a/mozilla/layout/html/base/src/nsBulletFrame.h +++ b/mozilla/layout/html/base/src/nsBulletFrame.h @@ -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 mImageRequest; + nsCOMPtr mListener; + + nsSize mIntrinsicSize; + nsSize mComputedSize; }; #endif /* nsBulletFrame_h___ */ diff --git a/mozilla/layout/html/base/src/nsFrame.cpp b/mozilla/layout/html/base/src/nsFrame.cpp index 4e4b79cd9f0..8509f9b74a8 100644 --- a/mozilla/layout/html/base/src/nsFrame.cpp +++ b/mozilla/layout/html/base/src/nsFrame.cpp @@ -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 diff --git a/mozilla/layout/html/base/src/nsFrameManager.cpp b/mozilla/layout/html/base/src/nsFrameManager.cpp index c82f7702de4..cd702303aa8 100644 --- a/mozilla/layout/html/base/src/nsFrameManager.cpp +++ b/mozilla/layout/html/base/src/nsFrameManager.cpp @@ -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 { diff --git a/mozilla/layout/html/base/src/nsImageFrame.cpp b/mozilla/layout/html/base/src/nsImageFrame.cpp index 413220debdd..286167846d0 100644 --- a/mozilla/layout/html/base/src/nsImageFrame.cpp +++ b/mozilla/layout/html/base/src/nsImageFrame.cpp @@ -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 { diff --git a/mozilla/layout/html/base/src/nsImageFrame.h b/mozilla/layout/html/base/src/nsImageFrame.h index 31d849d0414..be625cd51c2 100644 --- a/mozilla/layout/html/base/src/nsImageFrame.h +++ b/mozilla/layout/html/base/src/nsImageFrame.h @@ -43,7 +43,7 @@ struct nsSize; class nsImageFrame; -class nsImageListener : imgIDecoderObserver +class nsImageListener : public imgIDecoderObserver { public: nsImageListener(nsImageFrame *aFrame); diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index c322d030772..12578c04192 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -6698,7 +6698,6 @@ PresShell::VerifyIncrementalReflow() } } - cx->Stop(); cx->SetContainer(nsnull); NS_RELEASE(cx); sh->EndObservingDocument(); diff --git a/mozilla/layout/html/style/src/nsCSSRendering.cpp b/mozilla/layout/html/style/src/nsCSSRendering.cpp index 88e0fde0b5b..f0342414d1a 100644 --- a/mozilla/layout/html/style/src/nsCSSRendering.cpp +++ b/mozilla/layout/html/style/src/nsCSSRendering.cpp @@ -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 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 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 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 0){ - PaintRoundedBackground(aPresContext,aRenderingContext,aForFrame,aDirtyRect,aBorderArea,aColor,aDX,aDY,borderRadii); - return; - } - } - - aRenderingContext.SetColor(aColor.mBackgroundColor); - aRenderingContext.FillRect(aBorderArea); - } } + } /** --------------------------------------------------- diff --git a/mozilla/layout/html/tests/makefile.win b/mozilla/layout/html/tests/makefile.win index 7fa4d6a047e..514520c70f3 100644 --- a/mozilla/layout/html/tests/makefile.win +++ b/mozilla/layout/html/tests/makefile.win @@ -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 \ diff --git a/mozilla/layout/macbuild/layout.mcp b/mozilla/layout/macbuild/layout.mcp index 4d0b82ede9c6bd2e41e77936d59cb9ead21d8359..fdadd54750698c0462c289e7b8f8954c7c4eaef9 100644 GIT binary patch delta 684 zcmbu7-%FEG7{||Z-o5*g&I(-n@v3d86(w8qM(oE$xT3+JL?=WyGaS2!scncC5lFSx zDhhXkQ*GFd5n7mXlH-M$d0_^DN_bav)ty*Gu3v^dZZG`cMzgP2x(3ca)jXAK>{ea8mWjUV=X<2XfP1+veVF1{Rs0X20RQz@uRl(rz##Q z?qV1k&l#JOTMdK9F0nIR&rRWMA0h3tqB2TNrf_(5b2GIpTC=}^*}Ltf;7%TcpCG)w zBPObZ#Y+DlRlJ?CDB|Nllfmi6b~9o@wjsNbGQ`7tDW5fmlO17*gPl)l>V2FZFwX_M z7<#h-Vko@|>~^LBY)ocywgCg7mys(-8o7>SMC`^X0Kbqo&mR4+@7=0%?m7_+9mmqo zx|1aqJXK+QfmrP6;5uja5mZlaozk6Y=2n#SHSUQGKcXsuQ6 XDF!bzYFFT{T&bbkDf*L}E*bv*QFGx_Nf+B)M z?L}?6%EVUm!Qur4E!(o95Mv1{M5rh}+2WJ0ril0S!8vXJ0|$OH-#5$7u&`qjp0Nqf zlhx4J#+a67Z2bwwHZaoU87G*rsyFRaCxi{DrNbm1>XdY*C8;?6kwM8IFNa}WN3Qw2 zXzv_#U%UH_vCUI5c!0afR2bX7P3|1{3&K2R&NbGSsqqJ7JoCUUKXp}&oUO~Z1+OMQ zpG)cCfN{Tzed+_Iauy*z<2=m;*|ijG;M8Z-9qn=H}7h*X}=RuqvPbEqn)H+ z?vxh!4#L2qxTD=3*GpMCp4G^I`De9urdH#g8t0 zUjs>T@aH8QsD+Sp{hEE!?%yM?)siBd<~ci{a^oa@5u6O&(O(z?3&0rDQ)KM6MaCLx9eFWkn*^?ao|J_XU({EV05V5!Rne-0|+<{_7H rhCas~blRBp^Rha%fLnenM!1cc2#=|S^}NKPUww@7I;VcI_&e7>P$;g5 diff --git a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp index d03ab67eefd..0888d523428 100644 --- a/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp +++ b/mozilla/layout/xul/base/src/nsImageBoxFrame.cpp @@ -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 // diff --git a/mozilla/layout/xul/base/src/nsImageBoxFrame.h b/mozilla/layout/xul/base/src/nsImageBoxFrame.h index 7c1030835ef..9eb5b208916 100644 --- a/mozilla/layout/xul/base/src/nsImageBoxFrame.h +++ b/mozilla/layout/xul/base/src/nsImageBoxFrame.h @@ -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 mImageRequest; nsCOMPtr mListener; nsSize mIntrinsicSize; -#else - nsHTMLImageLoader mImageLoader; -#endif PRBool mSizeFrozen; nsSize mImageSize; diff --git a/mozilla/modules/libimg/Makefile.in b/mozilla/modules/libimg/Makefile.in index df14a46feff..866b0e1d5aa 100644 --- a/mozilla/modules/libimg/Makefile.in +++ b/mozilla/modules/libimg/Makefile.in @@ -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 diff --git a/mozilla/modules/libimg/makefile.win b/mozilla/modules/libimg/makefile.win index 190053d42b1..a8d3ad81de2 100644 --- a/mozilla/modules/libimg/makefile.win +++ b/mozilla/modules/libimg/makefile.win @@ -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) diff --git a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp index 87b4db110b4..78f371a0f2a 100644 --- a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp @@ -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 imageManager = - do_GetService(kImageManagerCID, &rv); - if (imageManager) - rv = imageManager->FlushCache(1); // Flush the new imagelib image chrome cache. - nsCOMPtr imageCache = - do_GetService("@mozilla.org/image/cache;1", &rv); + nsCOMPtr imageCache(do_GetService("@mozilla.org/image/cache;1", &rv)); if (NS_SUCCEEDED(rv) && imageCache) { imageCache->ClearCache(PR_TRUE); } diff --git a/mozilla/webshell/tests/makefile.win b/mozilla/webshell/tests/makefile.win index a8df819ad63..f2baae73cc3 100644 --- a/mozilla/webshell/tests/makefile.win +++ b/mozilla/webshell/tests/makefile.win @@ -22,6 +22,6 @@ DEPTH=..\.. -DIRS= viewer imgtest ComFactory +DIRS= viewer ComFactory include <$(DEPTH)\config\rules.mak> diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index cb87d8907ef..a3adedf5e4b 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -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" diff --git a/mozilla/webshell/tests/viewer/nsThrobber.cpp b/mozilla/webshell/tests/viewer/nsThrobber.cpp index 96974830c00..b254b2bd3d1 100644 --- a/mozilla/webshell/tests/viewer/nsThrobber.cpp +++ b/mozilla/webshell/tests/viewer/nsThrobber.cpp @@ -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 } diff --git a/mozilla/webshell/tests/viewer/nsThrobber.h b/mozilla/webshell/tests/viewer/nsThrobber.h index fd61bb8874d..353592b1abc 100644 --- a/mozilla/webshell/tests/viewer/nsThrobber.h +++ b/mozilla/webshell/tests/viewer/nsThrobber.h @@ -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 mTimer; PRBool mRunning; PRUint32 mCompletedImages; diff --git a/mozilla/webshell/tests/viewer/unix/gtk/nsGtkMain.cpp b/mozilla/webshell/tests/viewer/unix/gtk/nsGtkMain.cpp index 38839484c79..d86d93e11d7 100644 --- a/mozilla/webshell/tests/viewer/unix/gtk/nsGtkMain.cpp +++ b/mozilla/webshell/tests/viewer/unix/gtk/nsGtkMain.cpp @@ -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" diff --git a/mozilla/widget/src/mac/nsToolkit.cpp b/mozilla/widget/src/mac/nsToolkit.cpp index 6527314e9e7..579a0882844 100644 --- a/mozilla/widget/src/mac/nsToolkit.cpp +++ b/mozilla/widget/src/mac/nsToolkit.cpp @@ -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 imageManager = do_GetService(kImageManagerCID); - if (imageManager) - { - imageManager->FlushCache(1); // flush everything - } - } - if (!RecoverMemoryReserve(kMemoryReserveSize)) { // NS_ASSERTION(0, "Failed to recallocate memory reserve. Flushing caches"); diff --git a/mozilla/widget/src/windows/nsWindow.cpp b/mozilla/widget/src/windows/nsWindow.cpp index dc57ca8b865..feeafde60be 100644 --- a/mozilla/widget/src/windows/nsWindow.cpp +++ b/mozilla/widget/src/windows/nsWindow.cpp @@ -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 diff --git a/mozilla/widget/src/windows/nsWindow.h b/mozilla/widget/src/windows/nsWindow.h index 81f05cd3ea2..a9cb657a770 100644 --- a/mozilla/widget/src/windows/nsWindow.h +++ b/mozilla/widget/src/windows/nsWindow.h @@ -399,7 +399,9 @@ protected: PRBool mIsTopWidgetWindow; nsPoint mLastPoint; HWND mWnd; +#if 0 HPALETTE mPalette; +#endif WNDPROC mPrevWndProc; PRBool mHas3DBorder; diff --git a/mozilla/xpinstall/packager/packages-mac b/mozilla/xpinstall/packager/packages-mac index 17cb0650854..ea8d3389195 100644 --- a/mozilla/xpinstall/packager/packages-mac +++ b/mozilla/xpinstall/packager/packages-mac @@ -62,7 +62,6 @@ viewer:Plug-ins:MRJPlugin.jar viewer:Plug-ins:Default Plug-in viewer:Essential Files:gfx.shlb -viewer:Essential Files:libimg.shlb viewer:Essential Files:libutil.shlb viewer:Essential Files:RaptorShell.shlb viewer:Essential Files:widget.shlb @@ -104,10 +103,8 @@ viewer:Components:EditorTxmgr.shlb viewer:Components:EmbedComponents.xpt viewer:Components:EmbedComponents.shlb viewer:Components:FindComponent.shlb -viewer:Components:gifdecoder.shlb viewer:Components:history.xpt viewer:Components:htmlparser.shlb -viewer:Components:jpgdecoder.shlb viewer:Components:JSLoader.shlb viewer:Components:jsconsole-clhandler.js viewer:Components:jsurl.shlb @@ -120,7 +117,6 @@ viewer:Components:libpref.shlb viewer:Components:libpref.xpt viewer:Components:libutil.xpt viewer:Components:lwbrk.shlb -viewer:Components:mngdecoder.shlb viewer:Components:Mork.shlb viewer:Components:mozBrowser.shlb viewer:Components:mozBrowser.xpt @@ -136,7 +132,6 @@ viewer:Components:pipnss.xpt viewer:Components:PIPPKI.shlb viewer:Components:pippki.xpt viewer:Components:plugin.shlb -viewer:Components:pngdecoder.shlb viewer:Components:prefm.shlb viewer:Components:prefm.xpt viewer:Components:profile.shlb diff --git a/mozilla/xpinstall/packager/packages-unix b/mozilla/xpinstall/packager/packages-unix index 8b576126c31..507e099ff51 100644 --- a/mozilla/xpinstall/packager/packages-unix +++ b/mozilla/xpinstall/packager/packages-unix @@ -121,11 +121,7 @@ bin/components/libmozbrwsr.so bin/components/libmozfind.so bin/components/libmozucth.so bin/components/libmozxfer.so -bin/components/libnsgif.so -bin/components/libnsjpg.so bin/components/libnslocale.so -bin/components/libnsmng.so -bin/components/libnspng.so bin/components/liboji.so bin/components/libpref.so bin/components/libprofile.so diff --git a/mozilla/xpinstall/packager/packages-win b/mozilla/xpinstall/packager/packages-win index 06706bc3ebb..3357bb03c37 100644 --- a/mozilla/xpinstall/packager/packages-win +++ b/mozilla/xpinstall/packager/packages-win @@ -56,7 +56,6 @@ bin\components\ucharuti.dll bin\gkgfx.dll bin\components\gkgfxwin.dll bin\components\gkwidget.dll -bin\img3250.dll bin\jpeg3250.dll bin\jsj3250.dll bin\mozilla.exe @@ -165,11 +164,7 @@ bin\components\necko_ftp.xpt bin\components\necko_http.xpt bin\components\necko_jar.xpt bin\components\necko_res.xpt -bin\components\nsgif.dll -bin\components\nsjpg.dll bin\components\nslocale.dll -bin\components\nsmng.dll -bin\components\nspng.dll bin\components\nsprefm.dll bin\components\nsSidebar.js bin\components\oji.dll