Bug 1102048 (Part 09, Image) - Make image/src files comply with the Mozilla Coding Style Guide. r=seth

This commit is contained in:
Glenn Randers-Pehrson 2015-03-25 19:36:00 -07:00
parent e9092c97e8
commit e14eea766e
2 changed files with 25 additions and 23 deletions

View File

@ -21,51 +21,50 @@ ImageResource::ImageResource(ImageURL* aURI) :
mInitialized(false), mInitialized(false),
mAnimating(false), mAnimating(false),
mError(false) mError(false)
{ { }
}
// Translates a mimetype into a concrete decoder // Translates a mimetype into a concrete decoder
Image::eDecoderType Image::eDecoderType
Image::GetDecoderType(const char *aMimeType) Image::GetDecoderType(const char* aMimeType)
{ {
// By default we don't know // By default we don't know
eDecoderType rv = eDecoderType_unknown; eDecoderType rv = eDecoderType_unknown;
// PNG // PNG
if (!strcmp(aMimeType, IMAGE_PNG)) if (!strcmp(aMimeType, IMAGE_PNG)) {
rv = eDecoderType_png; rv = eDecoderType_png;
else if (!strcmp(aMimeType, IMAGE_X_PNG))
} else if (!strcmp(aMimeType, IMAGE_X_PNG)) {
rv = eDecoderType_png; rv = eDecoderType_png;
// GIF // GIF
else if (!strcmp(aMimeType, IMAGE_GIF)) } else if (!strcmp(aMimeType, IMAGE_GIF)) {
rv = eDecoderType_gif; rv = eDecoderType_gif;
// JPEG // JPEG
else if (!strcmp(aMimeType, IMAGE_JPEG)) } else if (!strcmp(aMimeType, IMAGE_JPEG)) {
rv = eDecoderType_jpeg; rv = eDecoderType_jpeg;
else if (!strcmp(aMimeType, IMAGE_PJPEG)) } else if (!strcmp(aMimeType, IMAGE_PJPEG)) {
rv = eDecoderType_jpeg; rv = eDecoderType_jpeg;
else if (!strcmp(aMimeType, IMAGE_JPG)) } else if (!strcmp(aMimeType, IMAGE_JPG)) {
rv = eDecoderType_jpeg; rv = eDecoderType_jpeg;
// BMP // BMP
else if (!strcmp(aMimeType, IMAGE_BMP)) } else if (!strcmp(aMimeType, IMAGE_BMP)) {
rv = eDecoderType_bmp; rv = eDecoderType_bmp;
else if (!strcmp(aMimeType, IMAGE_BMP_MS)) } else if (!strcmp(aMimeType, IMAGE_BMP_MS)) {
rv = eDecoderType_bmp; rv = eDecoderType_bmp;
// ICO // ICO
else if (!strcmp(aMimeType, IMAGE_ICO)) } else if (!strcmp(aMimeType, IMAGE_ICO)) {
rv = eDecoderType_ico; rv = eDecoderType_ico;
else if (!strcmp(aMimeType, IMAGE_ICO_MS)) } else if (!strcmp(aMimeType, IMAGE_ICO_MS)) {
rv = eDecoderType_ico; rv = eDecoderType_ico;
// Icon // Icon
else if (!strcmp(aMimeType, IMAGE_ICON_MS)) } else if (!strcmp(aMimeType, IMAGE_ICON_MS)) {
rv = eDecoderType_icon; rv = eDecoderType_icon;
}
return rv; return rv;
} }
@ -83,15 +82,17 @@ ImageResource::DecrementAnimationConsumers()
{ {
MOZ_ASSERT(NS_IsMainThread(), "Main thread only to encourage serialization " MOZ_ASSERT(NS_IsMainThread(), "Main thread only to encourage serialization "
"with IncrementAnimationConsumers"); "with IncrementAnimationConsumers");
MOZ_ASSERT(mAnimationConsumers >= 1, "Invalid no. of animation consumers!"); MOZ_ASSERT(mAnimationConsumers >= 1,
"Invalid no. of animation consumers!");
mAnimationConsumers--; mAnimationConsumers--;
} }
nsresult nsresult
ImageResource::GetAnimationModeInternal(uint16_t* aAnimationMode) ImageResource::GetAnimationModeInternal(uint16_t* aAnimationMode)
{ {
if (mError) if (mError) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
}
NS_ENSURE_ARG_POINTER(aAnimationMode); NS_ENSURE_ARG_POINTER(aAnimationMode);
@ -102,8 +103,9 @@ ImageResource::GetAnimationModeInternal(uint16_t* aAnimationMode)
nsresult nsresult
ImageResource::SetAnimationModeInternal(uint16_t aAnimationMode) ImageResource::SetAnimationModeInternal(uint16_t aAnimationMode)
{ {
if (mError) if (mError) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
}
NS_ASSERTION(aAnimationMode == kNormalAnimMode || NS_ASSERTION(aAnimationMode == kNormalAnimMode ||
aAnimationMode == kDontAnimMode || aAnimationMode == kDontAnimMode ||

View File

@ -3,8 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MOZILLA_IMAGELIB_IMAGE_H_ #ifndef mozilla_image_src_Image_h
#define MOZILLA_IMAGELIB_IMAGE_H_ #define mozilla_image_src_Image_h
#include "mozilla/MemoryReporting.h" #include "mozilla/MemoryReporting.h"
#include "mozilla/TimeStamp.h" #include "mozilla/TimeStamp.h"
@ -81,7 +81,7 @@ public:
* ensure that something reasonable is always returned. * ensure that something reasonable is always returned.
*/ */
virtual size_t SizeOfSourceWithComputedFallback( virtual size_t SizeOfSourceWithComputedFallback(
MallocSizeOf aMallocSizeOf) const = 0; MallocSizeOf aMallocSizeOf) const = 0;
/** /**
* The size, in bytes, occupied by the image's decoded data. * The size, in bytes, occupied by the image's decoded data.
@ -235,4 +235,4 @@ protected:
} // namespace image } // namespace image
} // namespace mozilla } // namespace mozilla
#endif // MOZILLA_IMAGELIB_IMAGE_H_ #endif // mozilla_image_src_Image_h