Be a little smarter about handling the mess that is broken images. Only look

for a frame if we've had a frame at some point in the past; this should keep us
from calling GetPrimaryFrameFor quite so much during pageload.  Bug 225848,
r+sr=jst
This commit is contained in:
bzbarsky%mit.edu 2003-11-16 07:34:25 +00:00
Родитель 9a7c8f026b
Коммит 54e4d504ae
4 изменённых файлов: 15 добавлений и 3 удалений

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

@ -74,7 +74,8 @@ nsIIOService* nsImageLoadingContent::sIOService = nsnull;
nsImageLoadingContent::nsImageLoadingContent()
: mObserverList(nsnull),
mLoadingEnabled(PR_TRUE),
mImageIsBlocked(PR_FALSE)
mImageIsBlocked(PR_FALSE),
mHaveHadObserver(PR_FALSE)
{
if (!sImgLoader)
mLoadingEnabled = PR_FALSE;
@ -243,6 +244,8 @@ nsImageLoadingContent::AddObserver(imgIDecoderObserver* aObserver)
{
NS_ENSURE_ARG_POINTER(aObserver);
mHaveHadObserver = PR_TRUE;
if (!mObserverList.mObserver) {
mObserverList.mObserver = aObserver;
// Don't touch the linking of the list!
@ -429,8 +432,10 @@ nsImageLoadingContent::ImageURIChanged(const nsACString& aNewURI)
// It may be that one of our frames has replaced itself with alt text... This
// would only have happened if our mCurrentRequest had issues, and we would
// have set it to null by now in that case. Have to save that information
// here, since LoadImage may clobber the value of mCurrentRequest.
PRBool mayNeedReframe = !mCurrentRequest;
// here, since LoadImage may clobber the value of mCurrentRequest. On the
// other hand, if we've never had an observer, we know there aren't any frames
// that have changed to alt text on us yet.
PRBool mayNeedReframe = mHaveHadObserver && !mCurrentRequest;
// XXXbz using "documentURI" for the initialDocumentURI is not quite
// right, but the best we can do here...

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

@ -177,6 +177,7 @@ private:
PRPackedBool mLoadingEnabled;
PRPackedBool mImageIsBlocked;
PRPackedBool mHaveHadObserver;
};
#endif // nsImageLoadingContent_h__

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

@ -307,6 +307,9 @@ nsImageFrame::Init(nsIPresContext* aPresContext,
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(aContent);
NS_ENSURE_TRUE(imageLoader, NS_ERROR_UNEXPECTED);
// XXXbz this call _has_ to happen before we decide we won't be rendering the
// image, just in case -- this lets the image loading content know someone
// cares.
imageLoader->AddObserver(mListener);
LoadIcons(aPresContext);

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

@ -307,6 +307,9 @@ nsImageFrame::Init(nsIPresContext* aPresContext,
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(aContent);
NS_ENSURE_TRUE(imageLoader, NS_ERROR_UNEXPECTED);
// XXXbz this call _has_ to happen before we decide we won't be rendering the
// image, just in case -- this lets the image loading content know someone
// cares.
imageLoader->AddObserver(mListener);
LoadIcons(aPresContext);