зеркало из https://github.com/mozilla/gecko-dev.git
Bug 846078 part 2: Use MOZ_ASSERT instead of NS_ABORT_IF_FALSE in VectorImage.cpp. rs=seth
This commit is contained in:
Родитель
8d29f4dedf
Коммит
cbb3058c0c
|
@ -103,8 +103,8 @@ public:
|
||||||
: mDocument(aDocument)
|
: mDocument(aDocument)
|
||||||
, mImage(aImage)
|
, mImage(aImage)
|
||||||
{
|
{
|
||||||
NS_ABORT_IF_FALSE(mDocument, "Need an SVG document");
|
MOZ_ASSERT(mDocument, "Need an SVG document");
|
||||||
NS_ABORT_IF_FALSE(mImage, "Need an image");
|
MOZ_ASSERT(mImage, "Need an image");
|
||||||
|
|
||||||
mDocument->AddObserver(this);
|
mDocument->AddObserver(this);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ public:
|
||||||
|
|
||||||
void EndLoad(nsIDocument* aDocument) MOZ_OVERRIDE
|
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
|
// OnSVGDocumentParsed will release our owner's reference to us, so ensure
|
||||||
// we stick around long enough to complete our work.
|
// we stick around long enough to complete our work.
|
||||||
|
@ -132,7 +132,7 @@ public:
|
||||||
|
|
||||||
void Cancel()
|
void Cancel()
|
||||||
{
|
{
|
||||||
NS_ABORT_IF_FALSE(mDocument, "Duplicate call to Cancel");
|
MOZ_ASSERT(mDocument, "Duplicate call to Cancel");
|
||||||
if (mDocument) {
|
if (mDocument) {
|
||||||
mDocument->RemoveObserver(this);
|
mDocument->RemoveObserver(this);
|
||||||
mDocument = nullptr;
|
mDocument = nullptr;
|
||||||
|
@ -155,8 +155,8 @@ public:
|
||||||
: mDocument(aDocument)
|
: mDocument(aDocument)
|
||||||
, mImage(aImage)
|
, mImage(aImage)
|
||||||
{
|
{
|
||||||
NS_ABORT_IF_FALSE(mDocument, "Need an SVG document");
|
MOZ_ASSERT(mDocument, "Need an SVG document");
|
||||||
NS_ABORT_IF_FALSE(mImage, "Need an image");
|
MOZ_ASSERT(mImage, "Need an image");
|
||||||
|
|
||||||
mDocument->AddEventListener(NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"), this, true, false);
|
mDocument->AddEventListener(NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"), this, true, false);
|
||||||
mDocument->AddEventListener(NS_LITERAL_STRING("SVGAbort"), 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_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
|
// OnSVGDocumentLoaded/OnSVGDocumentError will release our owner's reference
|
||||||
// to us, so ensure we stick around long enough to complete our work.
|
// to us, so ensure we stick around long enough to complete our work.
|
||||||
|
@ -183,10 +183,10 @@ public:
|
||||||
|
|
||||||
nsAutoString eventType;
|
nsAutoString eventType;
|
||||||
aEvent->GetType(eventType);
|
aEvent->GetType(eventType);
|
||||||
NS_ABORT_IF_FALSE(eventType.EqualsLiteral("MozSVGAsImageDocumentLoad") ||
|
MOZ_ASSERT(eventType.EqualsLiteral("MozSVGAsImageDocumentLoad") ||
|
||||||
eventType.EqualsLiteral("SVGAbort") ||
|
eventType.EqualsLiteral("SVGAbort") ||
|
||||||
eventType.EqualsLiteral("SVGError"),
|
eventType.EqualsLiteral("SVGError"),
|
||||||
"Received unexpected event");
|
"Received unexpected event");
|
||||||
|
|
||||||
if (eventType.EqualsLiteral("MozSVGAsImageDocumentLoad")) {
|
if (eventType.EqualsLiteral("MozSVGAsImageDocumentLoad")) {
|
||||||
mImage->OnSVGDocumentLoaded();
|
mImage->OnSVGDocumentLoaded();
|
||||||
|
@ -199,7 +199,7 @@ public:
|
||||||
|
|
||||||
void Cancel()
|
void Cancel()
|
||||||
{
|
{
|
||||||
NS_ABORT_IF_FALSE(mDocument, "Duplicate call to Cancel");
|
MOZ_ASSERT(mDocument, "Duplicate call to Cancel");
|
||||||
if (mDocument) {
|
if (mDocument) {
|
||||||
mDocument->RemoveEventListener(NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"), this, true);
|
mDocument->RemoveEventListener(NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"), this, true);
|
||||||
mDocument->RemoveEventListener(NS_LITERAL_STRING("SVGAbort"), this, true);
|
mDocument->RemoveEventListener(NS_LITERAL_STRING("SVGAbort"), this, true);
|
||||||
|
@ -242,7 +242,7 @@ SVGDrawingCallback::operator()(gfxContext* aContext,
|
||||||
const gfxPattern::GraphicsFilter& aFilter,
|
const gfxPattern::GraphicsFilter& aFilter,
|
||||||
const gfxMatrix& aTransform)
|
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
|
// Get (& sanity-check) the helper-doc's presShell
|
||||||
nsCOMPtr<nsIPresShell> presShell;
|
nsCOMPtr<nsIPresShell> presShell;
|
||||||
|
@ -250,7 +250,7 @@ SVGDrawingCallback::operator()(gfxContext* aContext,
|
||||||
NS_WARNING("Unable to draw -- presShell lookup failed");
|
NS_WARNING("Unable to draw -- presShell lookup failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
NS_ABORT_IF_FALSE(presShell, "GetPresShell succeeded but returned null");
|
MOZ_ASSERT(presShell, "GetPresShell succeeded but returned null");
|
||||||
|
|
||||||
gfxContextAutoSaveRestore contextRestorer(aContext);
|
gfxContextAutoSaveRestore contextRestorer(aContext);
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ SVGDrawingCallback::operator()(gfxContext* aContext,
|
||||||
aContext->Multiply(gfxMatrix(aTransform).Invert());
|
aContext->Multiply(gfxMatrix(aTransform).Invert());
|
||||||
|
|
||||||
nsPresContext* presContext = presShell->GetPresContext();
|
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),
|
nsRect svgRect(presContext->DevPixelsToAppUnits(mViewport.x),
|
||||||
presContext->DevPixelsToAppUnits(mViewport.y),
|
presContext->DevPixelsToAppUnits(mViewport.y),
|
||||||
|
@ -319,10 +319,10 @@ VectorImage::Init(const char* aMimeType,
|
||||||
if (mIsInitialized)
|
if (mIsInitialized)
|
||||||
return NS_ERROR_ILLEGAL_VALUE;
|
return NS_ERROR_ILLEGAL_VALUE;
|
||||||
|
|
||||||
NS_ABORT_IF_FALSE(!mIsFullyLoaded && !mHaveAnimations &&
|
MOZ_ASSERT(!mIsFullyLoaded && !mHaveAnimations &&
|
||||||
!mHaveRestrictedRegion && !mError,
|
!mHaveRestrictedRegion && !mError,
|
||||||
"Flags unexpectedly set before initialization");
|
"Flags unexpectedly set before initialization");
|
||||||
NS_ABORT_IF_FALSE(!strcmp(aMimeType, IMAGE_SVG_XML), "Unexpected mimetype");
|
MOZ_ASSERT(!strcmp(aMimeType, IMAGE_SVG_XML), "Unexpected mimetype");
|
||||||
|
|
||||||
mIsInitialized = true;
|
mIsInitialized = true;
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -368,7 +368,7 @@ VectorImage::OnImageDataComplete(nsIRequest* aRequest,
|
||||||
nsresult aStatus,
|
nsresult aStatus,
|
||||||
bool aLastPart)
|
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
|
// 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.
|
||||||
|
@ -415,7 +415,7 @@ VectorImage::StartAnimation()
|
||||||
if (mError)
|
if (mError)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
NS_ABORT_IF_FALSE(ShouldAnimate(), "Should not animate!");
|
MOZ_ASSERT(ShouldAnimate(), "Should not animate!");
|
||||||
|
|
||||||
mSVGDocumentWrapper->StartAnimation();
|
mSVGDocumentWrapper->StartAnimation();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -427,8 +427,8 @@ VectorImage::StopAnimation()
|
||||||
if (mError)
|
if (mError)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
NS_ABORT_IF_FALSE(mIsFullyLoaded && mHaveAnimations,
|
MOZ_ASSERT(mIsFullyLoaded && mHaveAnimations,
|
||||||
"Should not have been animating!");
|
"Should not have been animating!");
|
||||||
|
|
||||||
mSVGDocumentWrapper->StopAnimation();
|
mSVGDocumentWrapper->StopAnimation();
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
|
@ -840,8 +840,8 @@ VectorImage::ResetAnimation()
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
VectorImage::OnStartRequest(nsIRequest* aRequest, nsISupports* aCtxt)
|
VectorImage::OnStartRequest(nsIRequest* aRequest, nsISupports* aCtxt)
|
||||||
{
|
{
|
||||||
NS_ABORT_IF_FALSE(!mSVGDocumentWrapper,
|
MOZ_ASSERT(!mSVGDocumentWrapper,
|
||||||
"Repeated call to OnStartRequest -- can this happen?");
|
"Repeated call to OnStartRequest -- can this happen?");
|
||||||
|
|
||||||
mSVGDocumentWrapper = new SVGDocumentWrapper();
|
mSVGDocumentWrapper = new SVGDocumentWrapper();
|
||||||
nsresult rv = mSVGDocumentWrapper->OnStartRequest(aRequest, aCtxt);
|
nsresult rv = mSVGDocumentWrapper->OnStartRequest(aRequest, aCtxt);
|
||||||
|
@ -887,8 +887,8 @@ VectorImage::OnStopRequest(nsIRequest* aRequest, nsISupports* aCtxt,
|
||||||
void
|
void
|
||||||
VectorImage::OnSVGDocumentParsed()
|
VectorImage::OnSVGDocumentParsed()
|
||||||
{
|
{
|
||||||
NS_ABORT_IF_FALSE(mParseCompleteListener, "Should have the parse complete listener");
|
MOZ_ASSERT(mParseCompleteListener, "Should have the parse complete listener");
|
||||||
NS_ABORT_IF_FALSE(mLoadEventListener, "Should have the load event listener");
|
MOZ_ASSERT(mLoadEventListener, "Should have the load event listener");
|
||||||
|
|
||||||
if (!mSVGDocumentWrapper->GetRootSVGElem()) {
|
if (!mSVGDocumentWrapper->GetRootSVGElem()) {
|
||||||
// This is an invalid SVG document. It may have failed to parse, or it may
|
// This is an invalid SVG document. It may have failed to parse, or it may
|
||||||
|
@ -915,10 +915,11 @@ VectorImage::CancelAllListeners()
|
||||||
void
|
void
|
||||||
VectorImage::OnSVGDocumentLoaded()
|
VectorImage::OnSVGDocumentLoaded()
|
||||||
{
|
{
|
||||||
NS_ABORT_IF_FALSE(mSVGDocumentWrapper->GetRootSVGElem(), "Should have parsed successfully");
|
MOZ_ASSERT(mSVGDocumentWrapper->GetRootSVGElem(),
|
||||||
NS_ABORT_IF_FALSE(!mIsFullyLoaded && !mHaveAnimations,
|
"Should have parsed successfully");
|
||||||
"These flags shouldn't get set until OnSVGDocumentLoaded. "
|
MOZ_ASSERT(!mIsFullyLoaded && !mHaveAnimations,
|
||||||
"Duplicate calls to OnSVGDocumentLoaded?");
|
"These flags shouldn't get set until OnSVGDocumentLoaded. "
|
||||||
|
"Duplicate calls to OnSVGDocumentLoaded?");
|
||||||
|
|
||||||
CancelAllListeners();
|
CancelAllListeners();
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче