Back out changeset 501d38d3892c (Bug 733553) for causing crashes in xpcshell tests.

This commit is contained in:
Joe Drew 2012-05-08 21:59:30 -04:00
parent f0ae8a3bd4
commit adeb871cdd
13 changed files with 33 additions and 84 deletions

View File

@ -278,7 +278,8 @@ nsBMPDecoder::WriteInternal(const char* aBuffer, PRUint32 aCount)
// Post our size to the superclass
PostSize(mBIH.width, real_height);
if (HasError()) {
// Setting the size led to an error.
// Setting the size lead to an error; this can happen when for example
// a multipart channel sends an image of a different size.
return;
}

View File

@ -920,7 +920,8 @@ nsGIFDecoder2::WriteInternal(const char *aBuffer, PRUint32 aCount)
// Create the image container with the right size.
BeginGIF();
if (HasError()) {
// Setting the size led to an error.
// Setting the size lead to an error; this can happen when for example
// a multipart channel sends an image of a different size.
mGIFStruct.state = gif_error;
return;
}

View File

@ -101,7 +101,8 @@ nsIconDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount)
// Post our size to the superclass
PostSize(mWidth, mHeight);
if (HasError()) {
// Setting the size led to an error.
// Setting the size lead to an error; this can happen when for example
// a multipart channel sends an image of a different size.
mState = iconStateFinished;
return;
}

View File

@ -263,7 +263,8 @@ nsJPEGDecoder::WriteInternal(const char *aBuffer, PRUint32 aCount)
// Post our size to the superclass
PostSize(mInfo.image_width, mInfo.image_height);
if (HasError()) {
// Setting the size led to an error.
// Setting the size lead to an error; this can happen when for example
// a multipart channel sends an image of a different size.
mState = JPEG_ERROR;
return;
}

View File

@ -519,7 +519,8 @@ nsPNGDecoder::info_callback(png_structp png_ptr, png_infop info_ptr)
// Post our size to the superclass
decoder->PostSize(width, height);
if (decoder->HasError()) {
// Setting the size led to an error.
// Setting the size lead to an error; this can happen when for example
// a multipart channel sends an image of a different size.
longjmp(png_jmpbuf(decoder->mPNG), 1);
}

View File

@ -52,7 +52,7 @@ interface nsIPrincipal;
* @version 0.1
* @see imagelib2
*/
[scriptable, uuid(a5a785a8-9881-11e1-aaff-001fbc092072)]
[scriptable, uuid(d35a9adb-8328-4b64-b06f-72a165acd080)]
interface imgIRequest : nsIRequest
{
/**
@ -132,11 +132,6 @@ interface imgIRequest : nsIRequest
*/
readonly attribute nsIPrincipal imagePrincipal;
/**
* Whether the request is multipart (ie, multipart/x-mixed-replace)
*/
readonly attribute bool multipart;
/**
* CORS modes images can be loaded with.
*

View File

@ -343,7 +343,7 @@ RasterImage::AdvanceFrame(TimeStamp aTime, nsIntRect* aDirtyRect)
// If we don't have a decoder, we know we've got everything we're going to
// get. If we do, we only display fully-downloaded frames; everything else
// gets delayed.
bool haveFullNextFrame = (mMultipart && mBytesDecoded == 0) || !mDecoder ||
bool haveFullNextFrame = !mDecoder ||
nextFrameIndex < mDecoder->GetCompleteFrameCount();
// If we're done decoding the next frame, go ahead and display it now and
@ -1135,9 +1135,14 @@ RasterImage::SetSize(PRInt32 aWidth, PRInt32 aHeight)
return NS_ERROR_INVALID_ARG;
// if we already have a size, check the new size against the old one
if (!mMultipart && mHasSize &&
if (mHasSize &&
((aWidth != mSize.width) || (aHeight != mSize.height))) {
NS_WARNING("Image changed size on redecode! This should not happen!");
// Alter the warning depending on whether the channel is multipart
if (!mMultipart)
NS_WARNING("Image changed size on redecode! This should not happen!");
else
NS_WARNING("Multipart channel sent an image of a different size");
// Make the decoder aware of the error so that it doesn't try to call
// FinishInternal during ShutdownDecoder.
@ -1209,14 +1214,10 @@ RasterImage::EnsureFrame(PRUint32 aFrameNum, PRInt32 aX, PRInt32 aY,
}
}
// Not reusable, so replace the frame directly.
DeleteImgFrame(aFrameNum);
mFrames.RemoveElementAt(aFrameNum);
nsAutoPtr<imgFrame> newFrame(new imgFrame());
nsresult rv = newFrame->Init(aX, aY, aWidth, aHeight, aFormat, aPaletteDepth);
NS_ENSURE_SUCCESS(rv, rv);
return InternalAddFrameHelper(aFrameNum, newFrame.forget(), imageData,
imageLength, paletteData, paletteLength);
return InternalAddFrame(aFrameNum, aX, aY, aWidth, aHeight, aFormat,
aPaletteDepth, imageData, imageLength,
paletteData, paletteLength);
}
nsresult
@ -1489,31 +1490,6 @@ RasterImage::AddSourceData(const char *aBuffer, PRUint32 aCount)
// This call should come straight from necko - no reentrancy allowed
NS_ABORT_IF_FALSE(!mInDecoder, "Re-entrant call to AddSourceData!");
// Starting a new part's frames, let's clean up before we add any
// This needs to happen just before we start getting EnsureFrame() call(s),
// so that there's no gap for anything to miss us.
if (mBytesDecoded == 0) {
// Our previous state may have been animated, so let's clean up
bool wasAnimating = mAnimating;
if (mAnimating) {
StopAnimation();
mAnimating = false;
}
mAnimationFinished = false;
if (mAnim) {
delete mAnim;
mAnim = nsnull;
}
// If there's only one frame, this could cause flickering
int old_frame_count = mFrames.Length();
if (old_frame_count > 1) {
for (int i = 0; i < old_frame_count; ++i) {
DeleteImgFrame(i);
}
mFrames.Clear();
}
}
// If we're not storing source data, write it directly to the decoder
if (!StoringSourceData()) {
rv = WriteToDecoder(aBuffer, aCount);
@ -1643,7 +1619,7 @@ RasterImage::SourceDataComplete()
}
nsresult
RasterImage::NewSourceData(const char* aMimeType)
RasterImage::NewSourceData()
{
nsresult rv;
@ -1678,8 +1654,6 @@ RasterImage::NewSourceData(const char* aMimeType)
mDecoded = false;
mHasSourceData = false;
mSourceDataMimeType.Assign(aMimeType);
// We're decode-on-load here. Open up a new decoder just like what happens when
// we call Init() for decode-on-load images.
rv = InitDecoder(/* aDoSizeDecode = */ false);

View File

@ -304,7 +304,7 @@ public:
nsresult SourceDataComplete();
/* Called for multipart images when there's a new source image to add. */
nsresult NewSourceData(const char *aMimeType);
nsresult NewSourceData();
/**
* A hint of the number of bytes of source data that the image contains. If

View File

@ -768,19 +768,14 @@ NS_IMETHODIMP imgRequest::OnStartRequest(nsIRequest *aRequest, nsISupports *ctxt
// If we're multipart, and our image is initialized, fix things up for another round
if (mIsMultiPartChannel && mImage) {
// Update the content type for this new part
nsCOMPtr<nsIChannel> partChan(do_QueryInterface(aRequest));
partChan->GetContentType(mContentType);
if (mContentType.EqualsLiteral(SVG_MIMETYPE) ||
mImage->GetType() == imgIContainer::TYPE_VECTOR) {
// mImage won't be reusable due to format change or a new SVG part
// Reset the tracker and forget that we have data for OnDataAvailable to
// treat its next call as a fresh image.
mStatusTracker = new imgStatusTracker(nsnull);
mGotData = false;
} else if (mImage->GetType() == imgIContainer::TYPE_RASTER) {
if (mImage->GetType() == imgIContainer::TYPE_RASTER) {
// Inform the RasterImage that we have new source data
static_cast<RasterImage*>(mImage.get())->NewSourceData(mContentType.get());
static_cast<RasterImage*>(mImage.get())->NewSourceData();
} else { // imageType == imgIContainer::TYPE_VECTOR
nsCOMPtr<nsIStreamListener> imageAsStream = do_QueryInterface(mImage);
NS_ABORT_IF_FALSE(imageAsStream,
"SVG-typed Image failed QI to nsIStreamListener");
imageAsStream->OnStartRequest(aRequest, ctxt);
}
}

View File

@ -131,8 +131,6 @@ public:
// wins.
static void SetCacheValidation(imgCacheEntry* aEntry, nsIRequest* aRequest);
bool GetMultipart() const { return mIsMultiPartChannel; }
// The CORS mode for which we loaded this image.
PRInt32 GetCORSMode() const { return mCORSMode; }

View File

@ -558,17 +558,6 @@ NS_IMETHODIMP imgRequestProxy::GetImagePrincipal(nsIPrincipal **aPrincipal)
return NS_OK;
}
/* readonly attribute bool multipart; */
NS_IMETHODIMP imgRequestProxy::GetMultipart(bool *aMultipart)
{
if (!mOwner)
return NS_ERROR_FAILURE;
*aMultipart = mOwner->GetMultipart();
return NS_OK;
}
/* readonly attribute PRInt32 CORSMode; */
NS_IMETHODIMP imgRequestProxy::GetCORSMode(PRInt32* aCorsMode)
{
@ -706,10 +695,6 @@ void imgRequestProxy::OnStopContainer(imgIContainer *image)
nsCOMPtr<imgIDecoderObserver> kungFuDeathGrip(mListener);
mListener->OnStopContainer(this, image);
}
// Multipart needs reset for next OnStartContainer
if (mOwner->GetMultipart())
mSentStartContainer = false;
}
void imgRequestProxy::OnStopDecode(nsresult status, const PRUnichar *statusArg)

View File

@ -253,7 +253,7 @@ private:
bool mDeferNotifications;
// We only want to send OnStartContainer once for each proxy, but we might
// get multiple OnStartContainer calls.
// get multiple OnStartContainer calls (e.g. from multipart/x-mixed-replace).
bool mSentStartContainer;
};

View File

@ -652,10 +652,7 @@ nsImageFrame::OnStopDecode(imgIRequest *aRequest,
return NS_ERROR_FAILURE;
}
bool multipart = false;
aRequest->GetMultipart(&multipart);
if (loadType == nsIImageLoadingContent::PENDING_REQUEST || multipart) {
if (loadType == nsIImageLoadingContent::PENDING_REQUEST) {
NotifyNewCurrentRequest(aRequest, aStatus);
}