Enabled the frame loader to work without a specified frame. This is used for precaching images.

This commit is contained in:
vidur%netscape.com 1999-05-07 00:06:03 +00:00
Родитель 54fbff6c9a
Коммит 0e649a0395
3 изменённых файлов: 50 добавлений и 45 удалений

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

@ -646,15 +646,15 @@ nsPresContext::StartLoadImage(const nsString& aURL,
}
return NS_OK;
}
if (nsnull == aTargetFrame) {
return NS_ERROR_NULL_POINTER;
}
// Mark frame as having loaded an image
nsFrameState state;
aTargetFrame->GetFrameState(&state);
state |= NS_FRAME_HAS_LOADED_IMAGES;
aTargetFrame->SetFrameState(state);
// Allow for a null target frame argument (for precached images)
if (nsnull != aTargetFrame) {
// Mark frame as having loaded an image
nsFrameState state;
aTargetFrame->GetFrameState(&state);
state |= NS_FRAME_HAS_LOADED_IMAGES;
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).

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

@ -174,16 +174,18 @@ nsFrameImageLoader::Init(nsIPresContext* aPresContext,
desiredHeight = NSToCoordRound(mDesiredSize.height * t2p);
}
PerFrameData* pfd = new PerFrameData;
if (nsnull == pfd) {
return NS_ERROR_OUT_OF_MEMORY;
if (nsnull != aTargetFrame) {
PerFrameData* pfd = new PerFrameData;
if (nsnull == pfd) {
return NS_ERROR_OUT_OF_MEMORY;
}
pfd->mFrame = aTargetFrame;
pfd->mCallBack = aCallBack;
pfd->mClosure = aClosure;
pfd->mNext = mFrames;
pfd->mNeedSizeUpdate = PR_TRUE;
mFrames = pfd;
}
pfd->mFrame = aTargetFrame;
pfd->mCallBack = aCallBack;
pfd->mClosure = aClosure;
pfd->mNext = mFrames;
pfd->mNeedSizeUpdate = PR_TRUE;
mFrames = pfd;
// Start image load request
char* cp = aURL.ToNewCString();
@ -209,29 +211,32 @@ nsFrameImageLoader::AddFrame(nsIFrame* aFrame,
pfd = pfd->mNext;
}
pfd = new PerFrameData;
if (nsnull == pfd) {
return NS_ERROR_OUT_OF_MEMORY;
}
pfd->mFrame = aFrame;
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...
if (nsnull != aFrame) {
pfd = new PerFrameData;
if (nsnull == pfd) {
return NS_ERROR_OUT_OF_MEMORY;
}
pfd->mFrame = aFrame;
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: notify frame=%p status=%x\n",
this, pfd->mFrame, mImageLoadStatus);
printf("%p: AddFrame: notify frame=%p status=%x\n",
this, pfd->mFrame, mImageLoadStatus);
#endif
(*aCallBack)(mPresContext, this, pfd->mFrame, pfd->mClosure,
mImageLoadStatus);
pfd->mNeedSizeUpdate = PR_FALSE;
(*aCallBack)(mPresContext, this, pfd->mFrame, pfd->mClosure,
mImageLoadStatus);
pfd->mNeedSizeUpdate = PR_FALSE;
}
}
return NS_OK;
}

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

@ -646,15 +646,15 @@ nsPresContext::StartLoadImage(const nsString& aURL,
}
return NS_OK;
}
if (nsnull == aTargetFrame) {
return NS_ERROR_NULL_POINTER;
}
// Mark frame as having loaded an image
nsFrameState state;
aTargetFrame->GetFrameState(&state);
state |= NS_FRAME_HAS_LOADED_IMAGES;
aTargetFrame->SetFrameState(state);
// Allow for a null target frame argument (for precached images)
if (nsnull != aTargetFrame) {
// Mark frame as having loaded an image
nsFrameState state;
aTargetFrame->GetFrameState(&state);
state |= NS_FRAME_HAS_LOADED_IMAGES;
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).