add some needed flag-checking.
authorDaniel Holbert <dholbert@cs.stanford.edu>
Mon, 10 May 2010 13:51:34 -0700
changeset 1564 5e6ad66a2f960a196f7e33da34ee5d4f90b246d5
parent 1563 59d52fa39c2301c76f3375015eae69abe992fe1a
child 1565 666b312593ec40fa36be974dd5108de6314388df
push id1261
push userdholbert@mozilla.com
push dateMon, 10 May 2010 20:51:38 +0000
add some needed flag-checking.
svg_images
--- a/svg_images
+++ b/svg_images
@@ -178,17 +178,17 @@ new file mode 100644
 +# LOCAL_INCLUDES += -I$(topsrcdir)/modules/libpr0n/src
 +
 +include $(topsrcdir)/config/rules.mk
 +
 diff --git a/modules/libpr0n/decoders/svg/nsSVGDecoder.cpp b/modules/libpr0n/decoders/svg/nsSVGDecoder.cpp
 new file mode 100644
 --- /dev/null
 +++ b/modules/libpr0n/decoders/svg/nsSVGDecoder.cpp
-@@ -0,0 +1,153 @@
+@@ -0,0 +1,162 @@
 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 +/* ***** BEGIN LICENSE BLOCK *****
 + * Version: MPL 1.1/GPL 2.0/LGPL 2.1
 + *
 + * The contents of this file are subject to the Mozilla Public License Version
 + * 1.1 (the "License"); you may not use this file except in compliance with
 + * the License. You may obtain a copy of the License at
 + * http://www.mozilla.org/MPL/
@@ -271,29 +271,35 @@ new file mode 100644
 +
 +  return NS_OK;
 +}
 +
 +/* void close (); */
 +NS_IMETHODIMP
 +nsSVGDecoder::Close(PRUint32 aFlags)
 +{
-+  nsIntRect frameRect(0, 0, TMP_IMG_WIDTH, TMP_IMG_HEIGHT);
-+  mImage->FrameUpdated(0, frameRect);
++  // Based on Close impl in nsICODecoder
++  if (!(mFlags & imgIDecoder::DECODER_FLAG_HEADERONLY) &&
++      !(aFlags & CLOSE_FLAG_DONTNOTIFY)) {
++    nsIntRect frameRect(0, 0, TMP_IMG_WIDTH, TMP_IMG_HEIGHT);
++    mImage->FrameUpdated(0, frameRect);
 +
-+  // From nsICODecoder
-+  if (mObserver) {
-+    mObserver->OnDataAvailable(nsnull, PR_TRUE, &frameRect);
-+    mObserver->OnStopFrame(nsnull, 0);
++    if (mObserver) {
++      mObserver->OnDataAvailable(nsnull, PR_TRUE, &frameRect);
++      mObserver->OnStopFrame(nsnull, 0);
++    }
++
++    mImage->DecodingComplete();
++
++    if (mObserver) {
++      mObserver->OnStopContainer(nsnull, 0);
++      mObserver->OnStopDecode(nsnull, NS_OK, nsnull);
++    }
 +  }
-+  mImage->DecodingComplete();
-+  if (mObserver) {
-+    mObserver->OnStopContainer(nsnull, 0);
-+    mObserver->OnStopDecode(nsnull, NS_OK, nsnull);
-+  }
++
 +  mImage = nsnull;
 +  return NS_OK;
 +}
 +
 +/* void flush (); */
 +NS_IMETHODIMP
 +nsSVGDecoder::Flush()
 +{
@@ -308,16 +314,19 @@ new file mode 100644
 +  *aDecoded++ = GFX_PACKED_PIXEL(aAlpha, aRed, aGreen, aBlue);
 +}
 +
 +
 +NS_IMETHODIMP
 +nsSVGDecoder::Write(const char *aBuffer, PRUint32 aCount)
 +{
 +  // XXXdholbert TESTING
++  if (mFlags & imgIDecoder::DECODER_FLAG_HEADERONLY)
++    return NS_OK; // Not supposed to actually draw anything.
++
 +  if (!mHaveWrittenData) {
 +    PRUint32* imgDataPtr = nsnull;
 +    PRUint32 imgDataLength;
 +
 +    mImage->SetSize(TMP_IMG_WIDTH, TMP_IMG_HEIGHT);
 +    if (mObserver) {
 +      mObserver->OnStartContainer(nsnull, mImage);
 +    }