Bug 1145167 - make imgIContainer::type getter infallible; r=seth
authorNathan Froyd <froydnj@mozilla.com>
Thu, 19 Mar 2015 10:12:52 -0400
changeset 263590 3c635dd1d624cfbdb4ae379a39d599ecc405168b
parent 263589 e246f0d09dbec63784667f55076df124a4904c25
child 263591 d74279a9b861d52f5de3679085a6711b8ecd6ab2
push id4718
push userraliiev@mozilla.com
push dateMon, 11 May 2015 18:39:53 +0000
treeherdermozilla-beta@c20c4ef55f08 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth
bugs1145167
milestone39.0a1
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 1145167 - make imgIContainer::type getter infallible; r=seth Rather than writing out a separate GetType() for every concrete imgIContainer, we can tag the attribute as [infallible] in the IDL file. The IDL code generator takes care of generating the correct GetType, leading to less code duplication.
image/public/imgIContainer.idl
image/src/DynamicImage.cpp
image/src/ImageWrapper.cpp
image/src/RasterImage.cpp
image/src/VectorImage.cpp
--- a/image/public/imgIContainer.idl
+++ b/image/public/imgIContainer.idl
@@ -111,17 +111,17 @@ native nsIntSizeByVal(nsIntSize);
 
 /**
  * imgIContainer is the interface that represents an image. It allows
  * access to frames as Thebes surfaces. It also allows drawing of images
  * onto Thebes contexts.
  *
  * Internally, imgIContainer also manages animation of images.
  */
-[scriptable, builtinclass, uuid(44fbd7d5-e417-4d31-ae4a-8ad61d07eb3c)]
+[scriptable, builtinclass, uuid(e3261ae7-4749-4cf6-bf06-59946233366f)]
 interface imgIContainer : nsISupports
 {
   /**
    * The width of the container rectangle.  In the case of any error,
    * zero is returned, and an exception will be thrown.
    */
   readonly attribute int32_t width;
 
@@ -168,22 +168,17 @@ interface imgIContainer : nsISupports
     * 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.
-   */
-  [noscript, notxpcom] uint16_t GetType();
+  [infallible] readonly attribute unsigned short type;
 
   /**
    * 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/image/src/DynamicImage.cpp
+++ b/image/src/DynamicImage.cpp
@@ -157,22 +157,16 @@ DynamicImage::GetOrientation()
 
 NS_IMETHODIMP
 DynamicImage::GetType(uint16_t* aType)
 {
   *aType = imgIContainer::TYPE_RASTER;
   return NS_OK;
 }
 
-NS_IMETHODIMP_(uint16_t)
-DynamicImage::GetType()
-{
-  return imgIContainer::TYPE_RASTER;
-}
-
 NS_IMETHODIMP
 DynamicImage::GetAnimated(bool* aAnimated)
 {
   *aAnimated = false;
   return NS_OK;
 }
 
 NS_IMETHODIMP_(TemporaryRef<SourceSurface>)
--- a/image/src/ImageWrapper.cpp
+++ b/image/src/ImageWrapper.cpp
@@ -162,22 +162,16 @@ ImageWrapper::GetOrientation()
 }
 
 NS_IMETHODIMP
 ImageWrapper::GetType(uint16_t* aType)
 {
   return mInnerImage->GetType(aType);
 }
 
-NS_IMETHODIMP_(uint16_t)
-ImageWrapper::GetType()
-{
-  return mInnerImage->GetType();
-}
-
 NS_IMETHODIMP
 ImageWrapper::GetAnimated(bool* aAnimated)
 {
   return mInnerImage->GetAnimated(aAnimated);
 }
 
 NS_IMETHODIMP_(TemporaryRef<SourceSurface>)
 ImageWrapper::GetFrame(uint32_t aWhichFrame,
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -444,28 +444,20 @@ RasterImage::GetOrientation()
 
 //******************************************************************************
 /* unsigned short GetType(); */
 NS_IMETHODIMP
 RasterImage::GetType(uint16_t *aType)
 {
   NS_ENSURE_ARG_POINTER(aType);
 
-  *aType = GetType();
+  *aType = imgIContainer::TYPE_RASTER;
   return NS_OK;
 }
 
-//******************************************************************************
-/* [noscript, notxpcom] uint16_t GetType(); */
-NS_IMETHODIMP_(uint16_t)
-RasterImage::GetType()
-{
-  return imgIContainer::TYPE_RASTER;
-}
-
 DrawableFrameRef
 RasterImage::LookupFrameInternal(uint32_t aFrameNum,
                                  const IntSize& aSize,
                                  uint32_t aFlags)
 {
   if (!mAnim) {
     NS_ASSERTION(aFrameNum == 0,
                  "Don't ask for a frame > 0 if we're not animated!");
--- a/image/src/VectorImage.cpp
+++ b/image/src/VectorImage.cpp
@@ -594,29 +594,21 @@ VectorImage::GetOrientation()
 
 //******************************************************************************
 /* readonly attribute unsigned short type; */
 NS_IMETHODIMP
 VectorImage::GetType(uint16_t* aType)
 {
   NS_ENSURE_ARG_POINTER(aType);
 
-  *aType = GetType();
+  *aType = imgIContainer::TYPE_VECTOR;
   return NS_OK;
 }
 
 //******************************************************************************
-/* [noscript, notxpcom] uint16_t GetType(); */
-NS_IMETHODIMP_(uint16_t)
-VectorImage::GetType()
-{
-  return imgIContainer::TYPE_VECTOR;
-}
-
-//******************************************************************************
 /* readonly attribute boolean animated; */
 NS_IMETHODIMP
 VectorImage::GetAnimated(bool* aAnimated)
 {
   if (mError || !mIsFullyLoaded)
     return NS_ERROR_FAILURE;
 
   *aAnimated = mSVGDocumentWrapper->IsAnimated();