Bug 584841 patch 8: Add method imgIContainer::GetImageType to distinguish Raster vs Vector Images. r=bholley sr=vlad a=blocking
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 13 Aug 2010 21:09:49 -0700
changeset 50552 3d1f9740a61a04870fc7e1b1ee6b7cfea9329dba
parent 50551 1893ccde199ec4b047a8e3e9c57a9b29b686dc54
child 50553 205795b2962a27572df753003a849d27c537ee5e
push id15072
push userdholbert@mozilla.com
push dateSat, 14 Aug 2010 04:11:44 +0000
treeherdermozilla-central@eccba2835f01 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley, vlad, blocking
bugs584841
milestone2.0b4pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 584841 patch 8: Add method imgIContainer::GetImageType to distinguish Raster vs Vector Images. r=bholley sr=vlad a=blocking
modules/libpr0n/public/imgIContainer.idl
modules/libpr0n/src/RasterImage.cpp
modules/libpr0n/src/RasterImage.h
--- a/modules/libpr0n/public/imgIContainer.idl
+++ b/modules/libpr0n/public/imgIContainer.idl
@@ -80,16 +80,35 @@ interface imgIContainer : nsISupports
   readonly attribute PRInt32 width;
 
   /**
    * The height of the container rectangle.
    */
   readonly attribute PRInt32 height;
 
   /**
+    * Enumerated values for the 'type' attribute (below).
+    */
+  const unsigned short TYPE_RASTER = 0;
+  const unsigned short TYPE_VECTOR = 1;
+
+  /**
+   * The type of this image (one of the TYPE_* values above).
+   */
+  readonly attribute unsigned short type;
+
+  /**
+   * Direct C++ accessor for 'type' attribute, for convenience.
+   */
+%{C++
+  virtual PRUint16 GetType() = 0;
+%}
+
+
+  /**
    * Whether this image is animated. You can only be guaranteed that querying
    * this will not throw if STATUS_DECODE_COMPLETE is set on the imgIRequest.
    *
    * @throws NS_ERROR_NOT_AVAILABLE if the animated state cannot be determined.
    */
   readonly attribute boolean animated;
 
   /**
--- a/modules/libpr0n/src/RasterImage.cpp
+++ b/modules/libpr0n/src/RasterImage.cpp
@@ -374,16 +374,27 @@ RasterImage::GetHeight(PRInt32 *aHeight)
 
   if (mError)
     return NS_ERROR_FAILURE;
 
   *aHeight = mSize.height;
   return NS_OK;
 }
 
+//******************************************************************************
+/* unsigned short GetType(); */
+NS_IMETHODIMP
+RasterImage::GetType(PRUint16 *aType)
+{
+  NS_ENSURE_ARG_POINTER(aType);
+
+  *aType = imgIContainer::TYPE_RASTER;
+  return NS_OK;
+}
+
 imgFrame*
 RasterImage::GetImgFrame(PRUint32 framenum)
 {
   nsresult rv = WantDecodedFrames();
   CONTAINER_ENSURE_TRUE(NS_SUCCEEDED(rv), nsnull);
 
   if (!mAnim) {
     NS_ASSERTION(framenum == 0, "Don't ask for a frame > 0 if we're not animated!");
--- a/modules/libpr0n/src/RasterImage.h
+++ b/modules/libpr0n/src/RasterImage.h
@@ -153,16 +153,19 @@ public:
   NS_DECL_ISUPPORTS
   NS_DECL_IMGICONTAINER
   NS_DECL_NSITIMERCALLBACK
   NS_DECL_NSIPROPERTIES
 
   RasterImage();
   virtual ~RasterImage();
 
+  // C++-only version of imgIContainer::GetType, for convenience
+  virtual PRUint16 GetType() { return imgIContainer::TYPE_RASTER; }
+
   static NS_METHOD WriteToContainer(nsIInputStream* in, void* closure,
                                     const char* fromRawSegment,
                                     PRUint32 toOffset, PRUint32 count,
                                     PRUint32 *writeCount);
 
   PRUint32 GetDecodedDataSize();
   PRUint32 GetSourceDataSize();