Bug 1102048 (Part 24, decoders) - Make image/src files comply with the Mozilla Coding Style Guide. r=seth
authorGlenn Randers-Pehrson <glennrp+bmo@gmail.com>
Sun, 05 Apr 2015 16:22:00 -0700
changeset 267891 ca348a8a0639662d4cbe1ea2e0b10544f0092a1f
parent 267890 01b7b5041919516c58b07ed6494677c5aecf281c
child 267892 3888d638471522c96bfb27973a5a9f4bfbbbbdb6
push id4830
push userjlund@mozilla.com
push dateMon, 29 Jun 2015 20:18:48 +0000
treeherdermozilla-beta@4c2175bb0420 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersseth
bugs1102048
milestone40.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 1102048 (Part 24, decoders) - Make image/src files comply with the Mozilla Coding Style Guide. r=seth
image/decoders/EXIF.h
image/decoders/GIF2.h
image/decoders/iccjpeg.c
image/decoders/iccjpeg.h
image/decoders/nsBMPDecoder.h
image/decoders/nsGIFDecoder2.cpp
image/decoders/nsGIFDecoder2.h
image/decoders/nsICODecoder.h
image/decoders/nsIconDecoder.h
image/decoders/nsJPEGDecoder.cpp
image/decoders/nsJPEGDecoder.h
image/decoders/nsPNGDecoder.h
--- a/image/decoders/EXIF.h
+++ b/image/decoders/EXIF.h
@@ -1,15 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
-#ifndef MOZILLA_IMAGELIB_EXIF_H
-#define MOZILLA_IMAGELIB_EXIF_H
+#ifndef mozilla_image_decoders_EXIF_h
+#define mozilla_image_decoders_EXIF_h
 
 #include <stdint.h>
 #include "nsDebug.h"
 
 #include "Orientation.h"
 
 namespace mozilla {
 namespace image {
@@ -67,9 +67,9 @@ private:
   uint32_t       mLength;
   uint32_t       mRemainingLength;
   ByteOrder      mByteOrder;
 };
 
 } // namespace image
 } // namespace mozilla
 
-#endif // MOZILLA_IMAGELIB_EXIF_H
+#endif // mozilla_image_decoders_EXIF_h
--- a/image/decoders/GIF2.h
+++ b/image/decoders/GIF2.h
@@ -1,15 +1,15 @@
 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
-#ifndef GIF2_H
-#define GIF2_H
+#ifndef mozilla_image_decoders_GIF2_H
+#define mozilla_image_decoders_GIF2_H
 
 #define MAX_LZW_BITS          12
 #define MAX_BITS            4097 // 2^MAX_LZW_BITS+1
 #define MAX_COLORS           256
 #define MIN_HOLD_SIZE        256
 
 enum { GIF_TRAILER                     = 0x3B }; // ';'
 enum { GIF_IMAGE_SEPARATOR             = 0x2C }; // ','
@@ -101,10 +101,10 @@ typedef struct gif_struct {
     uint8_t*  hold;                        // Accumulation buffer
     uint32_t  global_colormap[MAX_COLORS]; // Default colormap if local not
                                            //   supplied
     uint8_t   suffix[MAX_BITS];            // LZW decoding tables
     uint8_t   stack[MAX_BITS];             // Base of LZW decoder stack
 
 } gif_struct;
 
-#endif // GIF2_H
+#endif // mozilla_image_decoders_GIF2_H
 
--- a/image/decoders/iccjpeg.c
+++ b/image/decoders/iccjpeg.c
@@ -117,18 +117,19 @@ read_icc_profile (j_decompress_ptr cinfo
 
   *icc_data_ptr = NULL;                   /* avoid confusion if FALSE return */
   *icc_data_len = 0;
 
   /* This first pass over the saved markers discovers whether there are
    * any ICC markers and verifies the consistency of the marker numbering.
    */
 
-  for (seq_no = 1; seq_no <= MAX_SEQ_NO; seq_no++)
+  for (seq_no = 1; seq_no <= MAX_SEQ_NO; seq_no++) {
     marker_present[seq_no] = 0;
+  }
 
   for (marker = cinfo->marker_list; marker != NULL; marker = marker->next) {
     if (marker_is_icc(marker)) {
       if (num_markers == 0) {
         num_markers = GETJOCTET(marker->data[13]);
       } else if (num_markers != GETJOCTET(marker->data[13])) {
         return FALSE;  /* inconsistent num_markers fields */
       }
--- a/image/decoders/iccjpeg.h
+++ b/image/decoders/iccjpeg.h
@@ -15,18 +15,18 @@
  * This code depends on new features added to the IJG JPEG library as of
  * IJG release 6b; it will not compile or work with older IJG versions.
  *
  * NOTE: this code would need surgery to work on 16-bit-int machines
  * with ICC profiles exceeding 64K bytes in size.  See iccprofile.c
  * for details.
  */
 
-#ifndef ICCJPEG_H
-#define ICCJPEG_H
+#ifndef mozilla_image_decoders_iccjpeg_h
+#define mozilla_image_decoders_iccjpeg_h
 
 #include <stdio.h>  /* needed to define "FILE", "NULL" */
 #include "jpeglib.h"
 
 /*
  * Reading a JPEG file that may contain an ICC profile requires two steps:
  *
  * 1. After jpeg_create_decompress() but before jpeg_read_header(),
@@ -59,9 +59,9 @@ extern void setup_read_icc_profile JPP((
  * IJG library's memory allocator, so that the data would be freed implicitly
  * at jpeg_finish_decompress() time.  But it seems likely that many apps
  * will prefer to have the data stick around after decompression finishes.)
  */
 
 extern boolean read_icc_profile JPP((j_decompress_ptr cinfo,
                                      JOCTET** icc_data_ptr,
                                      unsigned int* icc_data_len));
-#endif // ICCJPEG_H
+#endif // mozilla_image_decoders_iccjpeg_h
--- a/image/decoders/nsBMPDecoder.h
+++ b/image/decoders/nsBMPDecoder.h
@@ -1,16 +1,16 @@
 /* vim:set tw=80 expandtab softtabstop=4 ts=4 sw=4: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 
-#ifndef nsBMPDecoder_h
-#define nsBMPDecoder_h
+#ifndef mozilla_image_decoders_nsBMPDecoder_h
+#define mozilla_image_decoders_nsBMPDecoder_h
 
 #include "BMPFileHeaders.h"
 #include "Decoder.h"
 #include "gfxColor.h"
 #include "nsAutoPtr.h"
 
 namespace mozilla {
 namespace image {
@@ -109,41 +109,43 @@ private:
 
     // Whether the 4th byte alpha data was found to be non zero and hence used.
     bool mHaveAlphaData;
 };
 
 /// Sets the pixel data in aDecoded to the given values.
 /// @param aDecoded pointer to pixel to be set, will be incremented to point to
 /// the next pixel.
-static inline void SetPixel(uint32_t*& aDecoded, uint8_t aRed, uint8_t aGreen,
-                            uint8_t aBlue, uint8_t aAlpha = 0xFF)
+static inline void
+SetPixel(uint32_t*& aDecoded, uint8_t aRed, uint8_t aGreen,
+         uint8_t aBlue, uint8_t aAlpha = 0xFF)
 {
     *aDecoded++ = gfxPackedPixel(aAlpha, aRed, aGreen, aBlue);
 }
 
-static inline void SetPixel(uint32_t*& aDecoded, uint8_t idx, colorTable*
-                            aColors)
+static inline void
+SetPixel(uint32_t*& aDecoded, uint8_t idx, colorTable* aColors)
 {
     SetPixel(aDecoded, aColors[idx].red, aColors[idx].green, aColors[idx].blue);
 }
 
 /// Sets two (or one if aCount = 1) pixels
 /// @param aDecoded where the data is stored. Will be moved 4 resp 8 bytes
 /// depending on whether one or two pixels are written.
 /// @param aData The values for the two pixels
 /// @param aCount Current count. Is decremented by one or two.
-inline void Set4BitPixel(uint32_t*& aDecoded, uint8_t aData,
-                         uint32_t& aCount, colorTable* aColors)
+inline void
+Set4BitPixel(uint32_t*& aDecoded, uint8_t aData, uint32_t& aCount,
+             colorTable* aColors)
 {
     uint8_t idx = aData >> 4;
     SetPixel(aDecoded, idx, aColors);
     if (--aCount > 0) {
         idx = aData & 0xF;
         SetPixel(aDecoded, idx, aColors);
         --aCount;
     }
 }
 
 } // namespace image
 } // namespace mozilla
 
-#endif // nsBMPDecoder_h
+#endif // mozilla_image_decoders_nsBMPDecoder_h
--- a/image/decoders/nsGIFDecoder2.cpp
+++ b/image/decoders/nsGIFDecoder2.cpp
@@ -536,17 +536,19 @@ ConvertColormap(uint32_t* aColormap, uin
   // Convert from the GIF's RGB format to the Cairo format.
   // Work from end to begin, because of the in-place expansion
   uint8_t* from = ((uint8_t*)aColormap) + 3 * aColors;
   uint32_t* to = aColormap + aColors;
 
   // Convert color entries to Cairo format
 
   // set up for loops below
-  if (!aColors) return;
+  if (!aColors) {
+    return;
+  }
   uint32_t c = aColors;
 
   // copy as bytes until source pointer is 32-bit-aligned
   // NB: can't use 32-bit reads, they might read off the end of the buffer
   for (; (NS_PTR_TO_UINT32(from) & 0x3) && c; --c) {
     from -= 3;
     *--to = gfxPackedPixel(0xFF, from[0], from[1], from[2]);
   }
@@ -652,18 +654,19 @@ nsGIFDecoder2::WriteInternal(const char*
 
       mGIFStruct.avail = clear_code + 2;
       mGIFStruct.oldcode = -1;
       mGIFStruct.codesize = mGIFStruct.datasize + 1;
       mGIFStruct.codemask = (1 << mGIFStruct.codesize) - 1;
       mGIFStruct.datum = mGIFStruct.bits = 0;
 
       // init the tables
-      for (int i = 0; i < clear_code; i++)
+      for (int i = 0; i < clear_code; i++) {
         mGIFStruct.suffix[i] = i;
+      }
 
       mGIFStruct.stackp = mGIFStruct.stack;
 
       GETN(1, gif_sub_block);
     }
     break;
 
     // All GIF files begin with "GIF87a" or "GIF89a"
@@ -697,17 +700,17 @@ nsGIFDecoder2::WriteInternal(const char*
       }
 
       // screen_bgcolor is not used
       //mGIFStruct.screen_bgcolor = q[5];
       // q[6] = Pixel Aspect Ratio
       //   Not used
       //   float aspect = (float)((q[6] + 15) / 64.0);
 
-      if (q[4] & 0x80) { // global map
+      if (q[4] & 0x80) {
         // Get the global colormap
         const uint32_t size = (3 << mGIFStruct.global_colormap_depth);
         if (len < size) {
           // Use 'hold' pattern to get the global colormap
           GETN(size, gif_global_colormap);
           break;
         }
         // Copy everything, go to colormap state to do CMS correction
@@ -852,20 +855,21 @@ nsGIFDecoder2::WriteInternal(const char*
     case gif_consume_comment:
       GETN(1, gif_comment_extension);
       break;
 
     case gif_application_extension:
       // Check for netscape application extension
       if (mGIFStruct.bytes_to_consume == 11 &&
           (!strncmp((char*)q, "NETSCAPE2.0", 11) ||
-           !strncmp((char*)q, "ANIMEXTS1.0", 11)))
+           !strncmp((char*)q, "ANIMEXTS1.0", 11))) {
         GETN(1, gif_netscape_extension_block);
-      else
+      } else {
         GETN(1, gif_consume_block);
+      }
       break;
 
     // Netscape-specific GIF extension: animation looping
     case gif_netscape_extension_block:
       if (*q) {
         // We might need to consume 3 bytes in
         // gif_consume_netscape_extension, so make sure we have at least that.
         GETN(std::max(3, static_cast<int>(*q)), gif_consume_netscape_extension);
--- a/image/decoders/nsGIFDecoder2.h
+++ b/image/decoders/nsGIFDecoder2.h
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
-#ifndef nsGIFDecoder2_h
-#define nsGIFDecoder2_h
+#ifndef mozilla_image_decoders_nsGIFDecoder2_h
+#define mozilla_image_decoders_nsGIFDecoder2_h
 
 #include "Decoder.h"
 
 #include "GIF2.h"
 #include "nsCOMPtr.h"
 
 namespace mozilla {
 namespace image {
@@ -64,9 +64,9 @@ private:
   bool mSawTransparency;
 
   gif_struct mGIFStruct;
 };
 
 } // namespace image
 } // namespace mozilla
 
-#endif // nsGIFDecoder2_h
+#endif // mozilla_image_decoders_nsGIFDecoder2_h
--- a/image/decoders/nsICODecoder.h
+++ b/image/decoders/nsICODecoder.h
@@ -1,16 +1,16 @@
 /* vim:set tw=80 expandtab softtabstop=4 ts=4 sw=4: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
 
-#ifndef nsICODecoder_h
-#define nsICODecoder_h
+#ifndef mozilla_image_decoders_nsICODecoder_h
+#define mozilla_image_decoders_nsICODecoder_h
 
 #include "nsAutoPtr.h"
 #include "Decoder.h"
 #include "imgFrame.h"
 #include "nsBMPDecoder.h"
 #include "nsPNGDecoder.h"
 #include "ICOFileHeaders.h"
 
@@ -51,29 +51,29 @@ private:
   // Returns true if there are no errors.
   bool WriteToContainedDecoder(const char* aBuffer, uint32_t aCount);
 
   // Processes a single dir entry of the icon resource
   void ProcessDirEntry(IconDirEntry& aTarget);
   // Sets the hotspot property of if we have a cursor
   void SetHotSpotIfCursor();
   // Creates a bitmap file header buffer, returns true if successful
-  bool FillBitmapFileHeaderBuffer(int8_t *bfh);
+  bool FillBitmapFileHeaderBuffer(int8_t* bfh);
   // Fixes the ICO height to match that of the BIH.
   // and also fixes the BIH height to be /2 of what it was.
   // See definition for explanation.
   // Returns false if invalid information is contained within.
-  bool FixBitmapHeight(int8_t *bih);
+  bool FixBitmapHeight(int8_t* bih);
   // Fixes the ICO width to match that of the BIH.
   // Returns false if invalid information is contained within.
-  bool FixBitmapWidth(int8_t *bih);
+  bool FixBitmapWidth(int8_t* bih);
   // Extract bitmap info header size count from BMP information header
-  int32_t ExtractBIHSizeFromBitmap(int8_t *bih);
+  int32_t ExtractBIHSizeFromBitmap(int8_t* bih);
   // Extract bit count from BMP information header
-  int32_t ExtractBPPFromBitmap(int8_t *bih);
+  int32_t ExtractBPPFromBitmap(int8_t* bih);
   // Calculates the row size in bytes for the AND mask table
   uint32_t CalcAlphaRowSize();
   // Obtains the number of colors from the BPP, mBPP must be filled in
   uint16_t GetNumColors();
 
   uint16_t mBPP; // Stores the images BPP
   uint32_t mPos; // Keeps track of the position we have decoded up until
   uint16_t mNumIcons; // Stores the number of icons in the ICO file
@@ -96,9 +96,9 @@ private:
   bool mIsCursor;
   // Stores whether or not the contained resource is a PNG
   bool mIsPNG;
 };
 
 } // namespace image
 } // namespace mozilla
 
-#endif // nsICODecoder_h
+#endif // mozilla_image_decoders_nsICODecoder_h
--- a/image/decoders/nsIconDecoder.h
+++ b/image/decoders/nsIconDecoder.h
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
-#ifndef nsIconDecoder_h
-#define nsIconDecoder_h
+#ifndef mozilla_image_decoders_nsIconDecoder_h
+#define mozilla_image_decoders_nsIconDecoder_h
 
 #include "Decoder.h"
 
 #include "nsCOMPtr.h"
 
 namespace mozilla {
 namespace image {
 class RasterImage;
@@ -54,9 +54,9 @@ enum {
   iconStateHaveHeight = 1,
   iconStateReadPixels = 2,
   iconStateFinished   = 3
 };
 
 } // namespace image
 } // namespace mozilla
 
-#endif // nsIconDecoder_h
+#endif // mozilla_image_decoders_nsIconDecoder_h
--- a/image/decoders/nsJPEGDecoder.cpp
+++ b/image/decoders/nsJPEGDecoder.cpp
@@ -185,18 +185,19 @@ nsJPEGDecoder::InitInternal()
   // Setup callback functions.
   mSourceMgr.init_source = init_source;
   mSourceMgr.fill_input_buffer = fill_input_buffer;
   mSourceMgr.skip_input_data = skip_input_data;
   mSourceMgr.resync_to_restart = jpeg_resync_to_restart;
   mSourceMgr.term_source = term_source;
 
   // Record app markers for ICC data
-  for (uint32_t m = 0; m < 16; m++)
+  for (uint32_t m = 0; m < 16; m++) {
     jpeg_save_markers(&mInfo, JPEG_APP0 + m, 0xFFFF);
+  }
 }
 
 void
 nsJPEGDecoder::FinishInternal()
 {
   // If we're not in any sort of error case, force our state to JPEG_DONE.
   if ((mState != JPEG_DONE && mState != JPEG_SINK_NON_JPEG_TRAILER) &&
       (mState != JPEG_ERROR) &&
--- a/image/decoders/nsJPEGDecoder.h
+++ b/image/decoders/nsJPEGDecoder.h
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
-#ifndef nsJPEGDecoder_h
-#define nsJPEGDecoder_h
+#ifndef mozilla_image_decoders_nsJPEGDecoder_h
+#define mozilla_image_decoders_nsJPEGDecoder_h
 
 #include "RasterImage.h"
 // On Windows systems, RasterImage.h brings in 'windows.h', which defines INT32.
 // But the jpeg decoder has its own definition of INT32. To avoid build issues,
 // we need to undefine the version from 'windows.h'.
 #undef INT32
 
 #include "Decoder.h"
@@ -98,9 +98,9 @@ public:
   const Decoder::DecodeStyle mDecodeStyle;
 
   uint32_t mCMSMode;
 };
 
 } // namespace image
 } // namespace mozilla
 
-#endif // nsJPEGDecoder_h
+#endif // mozilla_image_decoders_nsJPEGDecoder_h
--- a/image/decoders/nsPNGDecoder.h
+++ b/image/decoders/nsPNGDecoder.h
@@ -1,16 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  *
  * This Source Code Form is subject to the terms of the Mozilla Public
  * 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/. */
 
-#ifndef nsPNGDecoder_h
-#define nsPNGDecoder_h
+#ifndef mozilla_image_decoders_nsPNGDecoder_h
+#define mozilla_image_decoders_nsPNGDecoder_h
 
 #include "Decoder.h"
 
 #include "gfxTypes.h"
 
 #include "nsCOMPtr.h"
 
 #include "png.h"
@@ -124,9 +124,9 @@ public:
   // This is defined in the PNG spec as an invariant. We use it to
   // do manual validation without libpng.
   static const uint8_t pngSignatureBytes[];
 };
 
 } // namespace image
 } // namespace mozilla
 
-#endif // nsPNGDecoder_h
+#endif // mozilla_image_decoders_nsPNGDecoder_h