Bug 846078 part 2: Use MOZ_ASSERT instead of NS_ABORT_IF_FALSE in VectorImage.cpp. rs=seth

This commit is contained in:
Daniel Holbert 2013-02-28 22:45:00 -08:00
Родитель 8d29f4dedf
Коммит cbb3058c0c
1 изменённых файлов: 32 добавлений и 31 удалений

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

@ -103,8 +103,8 @@ public:
: mDocument(aDocument)
, mImage(aImage)
{
NS_ABORT_IF_FALSE(mDocument, "Need an SVG document");
NS_ABORT_IF_FALSE(mImage, "Need an image");
MOZ_ASSERT(mDocument, "Need an SVG document");
MOZ_ASSERT(mImage, "Need an image");
mDocument->AddObserver(this);
}
@ -121,7 +121,7 @@ public:
void EndLoad(nsIDocument* aDocument) MOZ_OVERRIDE
{
NS_ABORT_IF_FALSE(aDocument == mDocument, "Got EndLoad for wrong document?");
MOZ_ASSERT(aDocument == mDocument, "Got EndLoad for wrong document?");
// OnSVGDocumentParsed will release our owner's reference to us, so ensure
// we stick around long enough to complete our work.
@ -132,7 +132,7 @@ public:
void Cancel()
{
NS_ABORT_IF_FALSE(mDocument, "Duplicate call to Cancel");
MOZ_ASSERT(mDocument, "Duplicate call to Cancel");
if (mDocument) {
mDocument->RemoveObserver(this);
mDocument = nullptr;
@ -155,8 +155,8 @@ public:
: mDocument(aDocument)
, mImage(aImage)
{
NS_ABORT_IF_FALSE(mDocument, "Need an SVG document");
NS_ABORT_IF_FALSE(mImage, "Need an image");
MOZ_ASSERT(mDocument, "Need an SVG document");
MOZ_ASSERT(mImage, "Need an image");
mDocument->AddEventListener(NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"), this, true, false);
mDocument->AddEventListener(NS_LITERAL_STRING("SVGAbort"), this, true, false);
@ -175,7 +175,7 @@ public:
NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent) MOZ_OVERRIDE
{
NS_ABORT_IF_FALSE(mDocument, "Need an SVG document. Received multiple events?");
MOZ_ASSERT(mDocument, "Need an SVG document. Received multiple events?");
// OnSVGDocumentLoaded/OnSVGDocumentError will release our owner's reference
// to us, so ensure we stick around long enough to complete our work.
@ -183,10 +183,10 @@ public:
nsAutoString eventType;
aEvent->GetType(eventType);
NS_ABORT_IF_FALSE(eventType.EqualsLiteral("MozSVGAsImageDocumentLoad") ||
eventType.EqualsLiteral("SVGAbort") ||
eventType.EqualsLiteral("SVGError"),
"Received unexpected event");
MOZ_ASSERT(eventType.EqualsLiteral("MozSVGAsImageDocumentLoad") ||
eventType.EqualsLiteral("SVGAbort") ||
eventType.EqualsLiteral("SVGError"),
"Received unexpected event");
if (eventType.EqualsLiteral("MozSVGAsImageDocumentLoad")) {
mImage->OnSVGDocumentLoaded();
@ -199,7 +199,7 @@ public:
void Cancel()
{
NS_ABORT_IF_FALSE(mDocument, "Duplicate call to Cancel");
MOZ_ASSERT(mDocument, "Duplicate call to Cancel");
if (mDocument) {
mDocument->RemoveEventListener(NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"), this, true);
mDocument->RemoveEventListener(NS_LITERAL_STRING("SVGAbort"), this, true);
@ -242,7 +242,7 @@ SVGDrawingCallback::operator()(gfxContext* aContext,
const gfxPattern::GraphicsFilter& aFilter,
const gfxMatrix& aTransform)
{
NS_ABORT_IF_FALSE(mSVGDocumentWrapper, "need an SVGDocumentWrapper");
MOZ_ASSERT(mSVGDocumentWrapper, "need an SVGDocumentWrapper");
// Get (& sanity-check) the helper-doc's presShell
nsCOMPtr<nsIPresShell> presShell;
@ -250,7 +250,7 @@ SVGDrawingCallback::operator()(gfxContext* aContext,
NS_WARNING("Unable to draw -- presShell lookup failed");
return false;
}
NS_ABORT_IF_FALSE(presShell, "GetPresShell succeeded but returned null");
MOZ_ASSERT(presShell, "GetPresShell succeeded but returned null");
gfxContextAutoSaveRestore contextRestorer(aContext);
@ -263,7 +263,7 @@ SVGDrawingCallback::operator()(gfxContext* aContext,
aContext->Multiply(gfxMatrix(aTransform).Invert());
nsPresContext* presContext = presShell->GetPresContext();
NS_ABORT_IF_FALSE(presContext, "pres shell w/out pres context");
MOZ_ASSERT(presContext, "pres shell w/out pres context");
nsRect svgRect(presContext->DevPixelsToAppUnits(mViewport.x),
presContext->DevPixelsToAppUnits(mViewport.y),
@ -319,10 +319,10 @@ VectorImage::Init(const char* aMimeType,
if (mIsInitialized)
return NS_ERROR_ILLEGAL_VALUE;
NS_ABORT_IF_FALSE(!mIsFullyLoaded && !mHaveAnimations &&
!mHaveRestrictedRegion && !mError,
"Flags unexpectedly set before initialization");
NS_ABORT_IF_FALSE(!strcmp(aMimeType, IMAGE_SVG_XML), "Unexpected mimetype");
MOZ_ASSERT(!mIsFullyLoaded && !mHaveAnimations &&
!mHaveRestrictedRegion && !mError,
"Flags unexpectedly set before initialization");
MOZ_ASSERT(!strcmp(aMimeType, IMAGE_SVG_XML), "Unexpected mimetype");
mIsInitialized = true;
return NS_OK;
@ -368,7 +368,7 @@ VectorImage::OnImageDataComplete(nsIRequest* aRequest,
nsresult aStatus,
bool aLastPart)
{
NS_ABORT_IF_FALSE(mStopRequest.empty(), "Duplicate call to OnImageDataComplete?");
MOZ_ASSERT(mStopRequest.empty(), "Duplicate call to OnImageDataComplete?");
// Call our internal OnStopRequest method, which only talks to our embedded
// SVG document. This won't have any effect on our imgStatusTracker.
@ -415,7 +415,7 @@ VectorImage::StartAnimation()
if (mError)
return NS_ERROR_FAILURE;
NS_ABORT_IF_FALSE(ShouldAnimate(), "Should not animate!");
MOZ_ASSERT(ShouldAnimate(), "Should not animate!");
mSVGDocumentWrapper->StartAnimation();
return NS_OK;
@ -427,8 +427,8 @@ VectorImage::StopAnimation()
if (mError)
return NS_ERROR_FAILURE;
NS_ABORT_IF_FALSE(mIsFullyLoaded && mHaveAnimations,
"Should not have been animating!");
MOZ_ASSERT(mIsFullyLoaded && mHaveAnimations,
"Should not have been animating!");
mSVGDocumentWrapper->StopAnimation();
return NS_OK;
@ -840,8 +840,8 @@ VectorImage::ResetAnimation()
NS_IMETHODIMP
VectorImage::OnStartRequest(nsIRequest* aRequest, nsISupports* aCtxt)
{
NS_ABORT_IF_FALSE(!mSVGDocumentWrapper,
"Repeated call to OnStartRequest -- can this happen?");
MOZ_ASSERT(!mSVGDocumentWrapper,
"Repeated call to OnStartRequest -- can this happen?");
mSVGDocumentWrapper = new SVGDocumentWrapper();
nsresult rv = mSVGDocumentWrapper->OnStartRequest(aRequest, aCtxt);
@ -887,8 +887,8 @@ VectorImage::OnStopRequest(nsIRequest* aRequest, nsISupports* aCtxt,
void
VectorImage::OnSVGDocumentParsed()
{
NS_ABORT_IF_FALSE(mParseCompleteListener, "Should have the parse complete listener");
NS_ABORT_IF_FALSE(mLoadEventListener, "Should have the load event listener");
MOZ_ASSERT(mParseCompleteListener, "Should have the parse complete listener");
MOZ_ASSERT(mLoadEventListener, "Should have the load event listener");
if (!mSVGDocumentWrapper->GetRootSVGElem()) {
// This is an invalid SVG document. It may have failed to parse, or it may
@ -915,10 +915,11 @@ VectorImage::CancelAllListeners()
void
VectorImage::OnSVGDocumentLoaded()
{
NS_ABORT_IF_FALSE(mSVGDocumentWrapper->GetRootSVGElem(), "Should have parsed successfully");
NS_ABORT_IF_FALSE(!mIsFullyLoaded && !mHaveAnimations,
"These flags shouldn't get set until OnSVGDocumentLoaded. "
"Duplicate calls to OnSVGDocumentLoaded?");
MOZ_ASSERT(mSVGDocumentWrapper->GetRootSVGElem(),
"Should have parsed successfully");
MOZ_ASSERT(!mIsFullyLoaded && !mHaveAnimations,
"These flags shouldn't get set until OnSVGDocumentLoaded. "
"Duplicate calls to OnSVGDocumentLoaded?");
CancelAllListeners();