Bug 1175371 - Make VectorImage wait to deliver LOAD_COMPLETE until its size is available. r=dholbert

This commit is contained in:
Seth Fowler 2015-06-18 14:48:41 -07:00
parent 53313cd80f
commit cd531287f5
2 changed files with 41 additions and 15 deletions

View File

@ -415,13 +415,18 @@ VectorImage::OnImageDataComplete(nsIRequest* aRequest,
if (NS_FAILED(aStatus)) {
finalStatus = aStatus;
}
Progress loadProgress = LoadCompleteProgress(aLastPart, mError, finalStatus);
// Actually fire OnStopRequest.
if (mProgressTracker) {
mProgressTracker->SyncNotifyProgress(LoadCompleteProgress(aLastPart,
mError,
finalStatus));
if (mIsFullyLoaded || mError) {
// Our document is loaded, so we're ready to notify now.
mProgressTracker->SyncNotifyProgress(loadProgress);
} else {
// Record our progress so far; we'll actually send the notifications in
// OnSVGDocumentLoaded or OnSVGDocumentError.
mLoadProgress = Some(loadProgress);
}
return finalStatus;
}
@ -1175,12 +1180,19 @@ VectorImage::OnSVGDocumentLoaded()
// Tell *our* observers that we're done loading.
if (mProgressTracker) {
mProgressTracker->SyncNotifyProgress(FLAG_SIZE_AVAILABLE |
FLAG_HAS_TRANSPARENCY |
FLAG_FRAME_COMPLETE |
FLAG_DECODE_COMPLETE |
FLAG_ONLOAD_UNBLOCKED,
GetMaxSizedIntRect());
Progress progress = FLAG_SIZE_AVAILABLE |
FLAG_HAS_TRANSPARENCY |
FLAG_FRAME_COMPLETE |
FLAG_DECODE_COMPLETE |
FLAG_ONLOAD_UNBLOCKED;
// Merge in any saved progress from OnImageDataComplete.
if (mLoadProgress) {
progress |= *mLoadProgress;
mLoadProgress = Nothing();
}
mProgressTracker->SyncNotifyProgress(progress, GetMaxSizedIntRect());
}
EvaluateAnimation();
@ -1197,10 +1209,18 @@ VectorImage::OnSVGDocumentError()
mError = true;
if (mProgressTracker) {
// Unblock page load.
mProgressTracker->SyncNotifyProgress(FLAG_DECODE_COMPLETE |
FLAG_ONLOAD_UNBLOCKED |
FLAG_HAS_ERROR);
// Notify observers about the error and unblock page load.
Progress progress = FLAG_DECODE_COMPLETE |
FLAG_ONLOAD_UNBLOCKED |
FLAG_HAS_ERROR;
// Merge in any saved progress from OnImageDataComplete.
if (mLoadProgress) {
progress |= *mLoadProgress;
mLoadProgress = Nothing();
}
mProgressTracker->SyncNotifyProgress(progress);
}
}

View File

@ -100,6 +100,12 @@ private:
/// Count of locks on this image (roughly correlated to visible instances).
uint32_t mLockCount;
// Stored result from the Necko load of the image, which we save in
// OnImageDataComplete if the underlying SVG document isn't loaded. If we save
// this, we actually notify this progress (and clear this value) in
// OnSVGDocumentLoaded or OnSVGDocumentError.
Maybe<Progress> mLoadProgress;
bool mIsInitialized; // Have we been initialized?
bool mDiscardable; // Are we discardable?
bool mIsFullyLoaded; // Has the SVG document finished