зеркало из https://github.com/mozilla/gecko-dev.git
Merge backout of changeset 7f708623bf59 (from bug 322475, which made us construct all our image loaders at frame construction time) because of issues with propagation of backgrounds to the canvas (bug 460796).
This commit is contained in:
Коммит
255e82d38e
|
@ -129,7 +129,7 @@ CPPSRCS = \
|
|||
nsFrameManager.cpp \
|
||||
nsFrameTraversal.cpp \
|
||||
nsGenConList.cpp \
|
||||
nsImageLoadNotifier.cpp \
|
||||
nsImageLoader.cpp \
|
||||
nsLayoutDebugger.cpp \
|
||||
nsLayoutHistoryState.cpp \
|
||||
nsLayoutUtils.cpp \
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
/* class to notify frames of background image loads */
|
||||
|
||||
#include "nsImageLoadNotifier.h"
|
||||
#include "nsImageLoader.h"
|
||||
|
||||
#include "imgILoader.h"
|
||||
|
||||
|
@ -61,18 +61,17 @@
|
|||
// Paint forcing
|
||||
#include "prenv.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsImageLoadNotifier, imgIDecoderObserver, imgIContainerObserver)
|
||||
NS_IMPL_ISUPPORTS2(nsImageLoader, imgIDecoderObserver, imgIContainerObserver)
|
||||
|
||||
nsImageLoadNotifier::nsImageLoadNotifier(nsIFrame *aFrame,
|
||||
PRBool aReflowOnLoad,
|
||||
nsImageLoadNotifier *aNextLoader)
|
||||
nsImageLoader::nsImageLoader(nsIFrame *aFrame, PRBool aReflowOnLoad,
|
||||
nsImageLoader *aNextLoader)
|
||||
: mFrame(aFrame),
|
||||
mReflowOnLoad(aReflowOnLoad),
|
||||
mNextLoader(aNextLoader)
|
||||
{
|
||||
}
|
||||
|
||||
nsImageLoadNotifier::~nsImageLoadNotifier()
|
||||
nsImageLoader::~nsImageLoader()
|
||||
{
|
||||
mFrame = nsnull;
|
||||
|
||||
|
@ -81,13 +80,12 @@ nsImageLoadNotifier::~nsImageLoadNotifier()
|
|||
}
|
||||
}
|
||||
|
||||
/* static */ already_AddRefed<nsImageLoadNotifier>
|
||||
nsImageLoadNotifier::Create(nsIFrame *aFrame, imgIRequest *aRequest,
|
||||
PRBool aReflowOnLoad,
|
||||
nsImageLoadNotifier *aNextLoader)
|
||||
/* static */ already_AddRefed<nsImageLoader>
|
||||
nsImageLoader::Create(nsIFrame *aFrame, imgIRequest *aRequest,
|
||||
PRBool aReflowOnLoad, nsImageLoader *aNextLoader)
|
||||
{
|
||||
nsRefPtr<nsImageLoadNotifier> loader =
|
||||
new nsImageLoadNotifier(aFrame, aReflowOnLoad, aNextLoader);
|
||||
nsRefPtr<nsImageLoader> loader =
|
||||
new nsImageLoader(aFrame, aReflowOnLoad, aNextLoader);
|
||||
|
||||
loader->Load(aRequest);
|
||||
|
||||
|
@ -95,13 +93,13 @@ nsImageLoadNotifier::Create(nsIFrame *aFrame, imgIRequest *aRequest,
|
|||
}
|
||||
|
||||
void
|
||||
nsImageLoadNotifier::Destroy()
|
||||
nsImageLoader::Destroy()
|
||||
{
|
||||
// Destroy the chain with only one level of recursion.
|
||||
nsRefPtr<nsImageLoadNotifier> list = mNextLoader;
|
||||
nsRefPtr<nsImageLoader> list = mNextLoader;
|
||||
mNextLoader = nsnull;
|
||||
while (list) {
|
||||
nsRefPtr<nsImageLoadNotifier> todestroy = list;
|
||||
nsRefPtr<nsImageLoader> todestroy = list;
|
||||
list = todestroy->mNextLoader;
|
||||
todestroy->mNextLoader = nsnull;
|
||||
todestroy->Destroy();
|
||||
|
@ -117,7 +115,7 @@ nsImageLoadNotifier::Destroy()
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsImageLoadNotifier::Load(imgIRequest *aImage)
|
||||
nsImageLoader::Load(imgIRequest *aImage)
|
||||
{
|
||||
NS_ASSERTION(!mRequest, "can't reuse image loaders");
|
||||
|
||||
|
@ -138,7 +136,7 @@ nsImageLoadNotifier::Load(imgIRequest *aImage)
|
|||
|
||||
|
||||
|
||||
NS_IMETHODIMP nsImageLoadNotifier::OnStartContainer(imgIRequest *aRequest,
|
||||
NS_IMETHODIMP nsImageLoader::OnStartContainer(imgIRequest *aRequest,
|
||||
imgIContainer *aImage)
|
||||
{
|
||||
if (aImage)
|
||||
|
@ -155,7 +153,7 @@ NS_IMETHODIMP nsImageLoadNotifier::OnStartContainer(imgIRequest *aRequest,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoadNotifier::OnStopFrame(imgIRequest *aRequest,
|
||||
NS_IMETHODIMP nsImageLoader::OnStopFrame(imgIRequest *aRequest,
|
||||
gfxIImageFrame *aFrame)
|
||||
{
|
||||
if (!mFrame)
|
||||
|
@ -183,7 +181,7 @@ NS_IMETHODIMP nsImageLoadNotifier::OnStopFrame(imgIRequest *aRequest,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImageLoadNotifier::FrameChanged(imgIContainer *aContainer,
|
||||
NS_IMETHODIMP nsImageLoader::FrameChanged(imgIContainer *aContainer,
|
||||
gfxIImageFrame *newframe,
|
||||
nsRect * dirtyRect)
|
||||
{
|
||||
|
@ -209,7 +207,7 @@ NS_IMETHODIMP nsImageLoadNotifier::FrameChanged(imgIContainer *aContainer,
|
|||
|
||||
|
||||
void
|
||||
nsImageLoadNotifier::RedrawDirtyFrame(const nsRect* aDamageRect)
|
||||
nsImageLoader::RedrawDirtyFrame(const nsRect* aDamageRect)
|
||||
{
|
||||
if (mReflowOnLoad) {
|
||||
nsIPresShell *shell = mFrame->PresContext()->GetPresShell();
|
|
@ -54,17 +54,17 @@ class nsIURI;
|
|||
*
|
||||
* Each frame's image loaders form a linked list.
|
||||
*/
|
||||
class nsImageLoadNotifier : public nsStubImageDecoderObserver
|
||||
class nsImageLoader : public nsStubImageDecoderObserver
|
||||
{
|
||||
private:
|
||||
nsImageLoadNotifier(nsIFrame *aFrame, PRBool aReflowOnLoad,
|
||||
nsImageLoadNotifier *aNextLoader);
|
||||
virtual ~nsImageLoadNotifier();
|
||||
nsImageLoader(nsIFrame *aFrame, PRBool aReflowOnLoad,
|
||||
nsImageLoader *aNextLoader);
|
||||
virtual ~nsImageLoader();
|
||||
|
||||
public:
|
||||
static already_AddRefed<nsImageLoadNotifier>
|
||||
static already_AddRefed<nsImageLoader>
|
||||
Create(nsIFrame *aFrame, imgIRequest *aRequest,
|
||||
PRBool aReflowOnLoad, nsImageLoadNotifier *aNextLoader);
|
||||
PRBool aReflowOnLoad, nsImageLoader *aNextLoader);
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
void Destroy();
|
||||
|
||||
imgIRequest *GetRequest() { return mRequest; }
|
||||
nsImageLoadNotifier *GetNextLoader() { return mNextLoader; }
|
||||
nsImageLoader *GetNextLoader() { return mNextLoader; }
|
||||
|
||||
private:
|
||||
nsresult Load(imgIRequest *aImage);
|
||||
|
@ -94,5 +94,5 @@ private:
|
|||
nsIFrame *mFrame;
|
||||
nsCOMPtr<imgIRequest> mRequest;
|
||||
PRBool mReflowOnLoad;
|
||||
nsRefPtr<nsImageLoadNotifier> mNextLoader;
|
||||
nsRefPtr<nsImageLoader> mNextLoader;
|
||||
};
|
|
@ -49,7 +49,7 @@
|
|||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIFocusController.h"
|
||||
#include "nsStyleSet.h"
|
||||
#include "nsImageLoadNotifier.h"
|
||||
#include "nsImageLoader.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
|
@ -151,7 +151,7 @@ IsVisualCharset(const nsCString& aCharset)
|
|||
|
||||
|
||||
static PLDHashOperator
|
||||
destroy_notifiers(const void * aKey, nsRefPtr<nsImageLoadNotifier>& aData, void* closure)
|
||||
destroy_loads(const void * aKey, nsRefPtr<nsImageLoader>& aData, void* closure)
|
||||
{
|
||||
aData->Destroy();
|
||||
return PL_DHASH_NEXT;
|
||||
|
@ -232,7 +232,7 @@ nsPresContext::nsPresContext(nsIDocument* aDocument, nsPresContextType aType)
|
|||
|
||||
nsPresContext::~nsPresContext()
|
||||
{
|
||||
mImageNotifiers.Enumerate(destroy_notifiers, nsnull);
|
||||
mImageLoaders.Enumerate(destroy_loads, nsnull);
|
||||
|
||||
NS_PRECONDITION(!mShell, "Presshell forgot to clear our mShell pointer");
|
||||
SetShell(nsnull);
|
||||
|
@ -300,7 +300,7 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(nsPresContext)
|
|||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsPresContext)
|
||||
|
||||
static PLDHashOperator
|
||||
TraverseImageNotifier(const void * aKey, nsRefPtr<nsImageLoadNotifier>& aData,
|
||||
TraverseImageLoader(const void * aKey, nsRefPtr<nsImageLoader>& aData,
|
||||
void* aClosure)
|
||||
{
|
||||
nsCycleCollectionTraversalCallback *cb =
|
||||
|
@ -318,7 +318,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsPresContext)
|
|||
// NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mLookAndFeel); // a service
|
||||
// NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(mLangGroup); // an atom
|
||||
|
||||
tmp->mImageNotifiers.Enumerate(TraverseImageNotifier, &cb);
|
||||
tmp->mImageLoaders.Enumerate(TraverseImageLoader, &cb);
|
||||
|
||||
// NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mTheme); // a service
|
||||
// NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mLangService); // a service
|
||||
|
@ -340,8 +340,8 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsPresContext)
|
|||
// NS_RELEASE(tmp->mLookAndFeel); // a service
|
||||
// NS_RELEASE(tmp->mLangGroup); // an atom
|
||||
|
||||
tmp->mImageNotifiers.Enumerate(destroy_notifiers, nsnull);
|
||||
tmp->mImageNotifiers.Clear();
|
||||
tmp->mImageLoaders.Enumerate(destroy_loads, nsnull);
|
||||
tmp->mImageLoaders.Clear();
|
||||
|
||||
// NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTheme); // a service
|
||||
// NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mLangService); // a service
|
||||
|
@ -814,7 +814,7 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
|
|||
mDeviceContext->FlushFontCache();
|
||||
mCurAppUnitsPerDevPixel = AppUnitsPerDevPixel();
|
||||
|
||||
if (!mImageNotifiers.Init())
|
||||
if (!mImageLoaders.Init())
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
// Get the look and feel service here; default colors will be initialized
|
||||
|
@ -1026,9 +1026,9 @@ static void SetImgAnimModeOnImgReq(imgIRequest* aImgReq, PRUint16 aMode)
|
|||
|
||||
// Enumeration call back for HashTable
|
||||
static PLDHashOperator
|
||||
set_animation_mode(const void * aKey, nsRefPtr<nsImageLoadNotifier>& aData, void* closure)
|
||||
set_animation_mode(const void * aKey, nsRefPtr<nsImageLoader>& aData, void* closure)
|
||||
{
|
||||
for (nsImageLoadNotifier *loader = aData; loader;
|
||||
for (nsImageLoader *loader = aData; loader;
|
||||
loader = loader->GetNextLoader()) {
|
||||
imgIRequest* imgReq = loader->GetRequest();
|
||||
SetImgAnimModeOnImgReq(imgReq, (PRUint16)NS_PTR_TO_INT32(closure));
|
||||
|
@ -1070,7 +1070,7 @@ nsPresContext::SetImageAnimationModeInternal(PRUint16 aMode)
|
|||
|
||||
// This hash table contains a list of background images
|
||||
// so iterate over it and set the mode
|
||||
mImageNotifiers.Enumerate(set_animation_mode, NS_INT32_TO_PTR(aMode));
|
||||
mImageLoaders.Enumerate(set_animation_mode, NS_INT32_TO_PTR(aMode));
|
||||
|
||||
// Now walk the content tree and set the animation mode
|
||||
// on all the images
|
||||
|
@ -1168,26 +1168,26 @@ nsPresContext::SetFullZoom(float aZoom)
|
|||
}
|
||||
|
||||
void
|
||||
nsPresContext::SetImageNotifiers(nsIFrame* aTargetFrame,
|
||||
nsImageLoadNotifier* aImageNotifiers)
|
||||
nsPresContext::SetImageLoaders(nsIFrame* aTargetFrame,
|
||||
nsImageLoader* aImageLoaders)
|
||||
{
|
||||
nsRefPtr<nsImageLoadNotifier> oldNotifiers;
|
||||
mImageNotifiers.Get(aTargetFrame, getter_AddRefs(oldNotifiers));
|
||||
nsRefPtr<nsImageLoader> oldLoaders;
|
||||
mImageLoaders.Get(aTargetFrame, getter_AddRefs(oldLoaders));
|
||||
|
||||
if (aImageNotifiers) {
|
||||
mImageNotifiers.Put(aTargetFrame, aImageNotifiers);
|
||||
} else if (oldNotifiers) {
|
||||
mImageNotifiers.Remove(aTargetFrame);
|
||||
if (aImageLoaders) {
|
||||
mImageLoaders.Put(aTargetFrame, aImageLoaders);
|
||||
} else if (oldLoaders) {
|
||||
mImageLoaders.Remove(aTargetFrame);
|
||||
}
|
||||
|
||||
if (oldNotifiers)
|
||||
oldNotifiers->Destroy();
|
||||
if (oldLoaders)
|
||||
oldLoaders->Destroy();
|
||||
}
|
||||
|
||||
void
|
||||
nsPresContext::StopImagesFor(nsIFrame* aTargetFrame)
|
||||
{
|
||||
SetImageNotifiers(aTargetFrame, nsnull);
|
||||
SetImageLoaders(aTargetFrame, nsnull);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
#include "gfxRect.h"
|
||||
#include "nsRegion.h"
|
||||
|
||||
class nsImageLoadNotifier;
|
||||
class nsImageLoader;
|
||||
#ifdef IBMBIDI
|
||||
class nsBidiPresUtils;
|
||||
#endif // IBMBIDI
|
||||
|
@ -364,8 +364,8 @@ public:
|
|||
* aImage loads, where aImage is its background image. Only a single
|
||||
* image will be tracked per frame.
|
||||
*/
|
||||
NS_HIDDEN_(void) SetImageNotifiers(nsIFrame* aTargetFrame,
|
||||
nsImageLoadNotifier* aImageNotifiers);
|
||||
NS_HIDDEN_(void) SetImageLoaders(nsIFrame* aTargetFrame,
|
||||
nsImageLoader* aImageLoaders);
|
||||
|
||||
/**
|
||||
* This method is called when a frame is being destroyed to
|
||||
|
@ -764,7 +764,7 @@ protected:
|
|||
nsILinkHandler* mLinkHandler; // [WEAK]
|
||||
nsIAtom* mLangGroup; // [STRONG]
|
||||
|
||||
nsRefPtrHashtable<nsVoidPtrHashKey, nsImageLoadNotifier> mImageNotifiers;
|
||||
nsRefPtrHashtable<nsVoidPtrHashKey, nsImageLoader> mImageLoaders;
|
||||
|
||||
nsWeakPtr mContainer;
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
#include "nsBoxLayoutState.h"
|
||||
#include "nsBlockFrame.h"
|
||||
#include "nsDisplayList.h"
|
||||
#include "nsImageLoadNotifier.h"
|
||||
#include "nsImageLoader.h"
|
||||
|
||||
#ifdef MOZ_SVG
|
||||
#include "nsSVGIntegrationUtils.h"
|
||||
|
@ -556,24 +556,24 @@ nsFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
|
|||
{
|
||||
// Ensure that this frame gets invalidates (and, in the case of some
|
||||
// 'border-image's, reflows) when images that affect it load.
|
||||
nsRefPtr<nsImageLoadNotifier> notifierChain;
|
||||
nsRefPtr<nsImageLoader> loaderChain;
|
||||
|
||||
const nsStyleBackground *background = GetStyleBackground();
|
||||
imgIRequest *newBackgroundImage = background->mBackgroundImage;
|
||||
if (newBackgroundImage) {
|
||||
notifierChain = nsImageLoadNotifier::Create(this, newBackgroundImage,
|
||||
PR_FALSE, notifierChain);
|
||||
loaderChain = nsImageLoader::Create(this, newBackgroundImage,
|
||||
PR_FALSE, loaderChain);
|
||||
}
|
||||
|
||||
const nsStyleBorder *border = GetStyleBorder();
|
||||
imgIRequest *newBorderImage = border->GetBorderImage();
|
||||
if (newBorderImage) {
|
||||
notifierChain = nsImageLoadNotifier::Create(this, newBorderImage,
|
||||
loaderChain = nsImageLoader::Create(this, newBorderImage,
|
||||
border->ImageBorderDiffers(),
|
||||
notifierChain);
|
||||
loaderChain);
|
||||
}
|
||||
|
||||
PresContext()->SetImageNotifiers(this, notifierChain);
|
||||
PresContext()->SetImageLoaders(this, loaderChain);
|
||||
}
|
||||
|
||||
/* virtual */ nsMargin
|
||||
|
|
Загрузка…
Ссылка в новой задаче