Bug 682688 - FF6 Fix for moz-icon invalid generated icons. r=joe
authorBrian R. Bondy <netzen@gmail.com>
Tue, 30 Aug 2011 01:44:04 -0400
changeset 76211 d48ac4bbb8e608cd0ef9a949f144eb7b95069c22
parent 76210 9e28008d9d1f2221334cf5906835257445620565
child 76212 80a4a3d420eae52fb54d65d0be8e1f76678e17a6
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersjoe
bugs682688
milestone9.0a1
Bug 682688 - FF6 Fix for moz-icon invalid generated icons. r=joe
modules/libpr0n/decoders/icon/win/nsIconChannel.cpp
--- a/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp
+++ b/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp
@@ -447,20 +447,25 @@ static int GetColorTableSize(BITMAPINFOH
     if (aHeader->biClrUsed > 0 && aHeader->biClrUsed <= maxEntries)
       colorTableSize = aHeader->biClrUsed * sizeof(RGBQUAD);
     else if (aHeader->biClrUsed == 0)
       colorTableSize = maxEntries * sizeof(RGBQUAD);
     break;
   }
   case 16:
   case 32:
-    if (aHeader->biCompression == BI_RGB)
+    // If we have BI_BITFIELDS compression, we would normally need 3 DWORDS for
+    // the bitfields mask which would be stored in the color table; However, 
+    // we instead force the bitmap to request data of type BI_RGB so the color
+    // table should be of size 0.  
+    // Setting aHeader->biCompression = BI_RGB forces the later call to 
+    // GetDIBits to return to us BI_RGB data.
+    if (aHeader->biCompression == BI_BITFIELDS)
+      aHeader->biCompression = BI_RGB;
       colorTableSize = 0;
-    else if (aHeader->biCompression == BI_BITFIELDS)
-      colorTableSize = 3 * sizeof(DWORD);
     break;
   case 24:
     colorTableSize = 0;
     break;
   }
 
   if (colorTableSize < 0)
     NS_WARNING("Unable to figure out the color table size for this bitmap");