Bug 847630 - Stop deferring OnStopRequest in VectorImage. r=joe

This commit is contained in:
Seth Fowler 2013-03-10 14:04:29 -07:00
parent fc4a9e9406
commit 7dab612a47
2 changed files with 2 additions and 46 deletions

View File

@ -368,8 +368,6 @@ VectorImage::OnImageDataComplete(nsIRequest* aRequest,
nsresult aStatus, nsresult aStatus,
bool aLastPart) bool aLastPart)
{ {
MOZ_ASSERT(mStopRequest.empty(), "Duplicate call to OnImageDataComplete?");
// Call our internal OnStopRequest method, which only talks to our embedded // Call our internal OnStopRequest method, which only talks to our embedded
// SVG document. This won't have any effect on our imgStatusTracker. // SVG document. This won't have any effect on our imgStatusTracker.
nsresult finalStatus = OnStopRequest(aRequest, aContext, aStatus); nsresult finalStatus = OnStopRequest(aRequest, aContext, aStatus);
@ -378,18 +376,8 @@ VectorImage::OnImageDataComplete(nsIRequest* aRequest,
if (NS_FAILED(aStatus)) if (NS_FAILED(aStatus))
finalStatus = aStatus; finalStatus = aStatus;
// If there's an error already, we need to fire OnStopRequest on our // Actually fire OnStopRequest.
// imgStatusTracker immediately. We might not get another chance. GetStatusTracker().OnStopRequest(aLastPart, finalStatus);
if (mError || NS_FAILED(finalStatus)) {
GetStatusTracker().OnStopRequest(aLastPart, finalStatus);
return finalStatus;
}
// Otherwise, we record the parameters we'll use to call OnStopRequest, and
// return. We'll actually call it in OnSVGDocumentLoaded or
// OnSVGDocumentError.
mStopRequest.construct(aLastPart, finalStatus);
return finalStatus; return finalStatus;
} }
@ -922,13 +910,6 @@ VectorImage::OnSVGDocumentLoaded()
observer->OnStartContainer(); // Signal that width/height are available. observer->OnStartContainer(); // Signal that width/height are available.
observer->FrameChanged(&nsIntRect::GetMaxSizedIntRect()); observer->FrameChanged(&nsIntRect::GetMaxSizedIntRect());
observer->OnStopFrame(); observer->OnStopFrame();
if (!mStopRequest.empty()) {
GetStatusTracker().OnStopRequest(mStopRequest.ref().lastPart,
mStopRequest.ref().status);
mStopRequest.destroy();
}
observer->OnStopDecode(NS_OK); // Unblock page load. observer->OnStopDecode(NS_OK); // Unblock page load.
} }
@ -946,14 +927,6 @@ VectorImage::OnSVGDocumentError()
mError = true; mError = true;
if (mStatusTracker) { if (mStatusTracker) {
if (!mStopRequest.empty()) {
nsresult status = NS_FAILED(mStopRequest.ref().status)
? mStopRequest.ref().status
: NS_ERROR_FAILURE;
GetStatusTracker().OnStopRequest(mStopRequest.ref().lastPart, status);
mStopRequest.destroy();
}
// Unblock page load. // Unblock page load.
mStatusTracker->GetDecoderObserver()->OnStopDecode(NS_ERROR_FAILURE); mStatusTracker->GetDecoderObserver()->OnStopDecode(NS_ERROR_FAILURE);
} }

View File

@ -79,28 +79,11 @@ protected:
private: private:
void CancelAllListeners(); void CancelAllListeners();
// A private structure used for storing the arguments to
// imgStatusTracker::OnStopRequest until we're ready to call it.
struct StopRequest
{
StopRequest(bool aLastPart = true, nsresult aStatus = NS_OK)
: lastPart(aLastPart)
, status(aStatus)
{ }
bool lastPart;
nsresult status;
};
nsRefPtr<SVGDocumentWrapper> mSVGDocumentWrapper; nsRefPtr<SVGDocumentWrapper> mSVGDocumentWrapper;
nsRefPtr<SVGRootRenderingObserver> mRenderingObserver; nsRefPtr<SVGRootRenderingObserver> mRenderingObserver;
nsRefPtr<SVGLoadEventListener> mLoadEventListener; nsRefPtr<SVGLoadEventListener> mLoadEventListener;
nsRefPtr<SVGParseCompleteListener> mParseCompleteListener; nsRefPtr<SVGParseCompleteListener> mParseCompleteListener;
// If we need to fire OnStopRequest, this stores the parameters we got when
// OnImageDataComplete was called.
Maybe<StopRequest> mStopRequest;
nsIntRect mRestrictedRegion; // If we were created by nsIntRect mRestrictedRegion; // If we were created by
// ExtractFrame, this is the region // ExtractFrame, this is the region
// that we're restricted to using. // that we're restricted to using.