Bug 1801397. Render questionable 1x1 gifs with no image data like other clients. r=aosmond
Differential Revision: https://phabricator.services.mozilla.com/D162450
This commit is contained in:
@@ -150,6 +150,22 @@ bool nsGIFDecoder2::CheckForTransparency(const OrientedIntRect& aFrameRect) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is a bit of a hack. Some sites will use a 1x1 gif that includes no
|
||||||
|
// header information indicating it is transparent, no palette, and no image
|
||||||
|
// data at all (so no pixels get written) to represent a transparent pixel
|
||||||
|
// using the absolute least number of bytes. Generally things are setup to
|
||||||
|
// detect transparency without decoding the image data. So to detect this kind
|
||||||
|
// of transparency without decoing the image data we would have to assume
|
||||||
|
// every gif is transparent, which we would like to avoid. Changing things so
|
||||||
|
// that we can detect transparency at any point of decoding is a bigger change
|
||||||
|
// and not worth it for one questionable 1x1 gif. Using this "trick" for
|
||||||
|
// anything but 1x1 transparent spacer gifs doesn't make sense, so it's
|
||||||
|
// reasonable to target 1x1 gifs just for this.
|
||||||
|
if (mGIFStruct.screen_width == 1 && mGIFStruct.screen_height == 1) {
|
||||||
|
PostHasTransparency();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (mGIFStruct.images_decoded > 0) {
|
if (mGIFStruct.images_decoded > 0) {
|
||||||
return false; // We only care about first frame padding below.
|
return false; // We only care about first frame padding below.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -923,7 +923,8 @@ ImageTestCase DownscaledTransparentICOWithANDMaskTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImageTestCase TruncatedSmallGIFTestCase() {
|
ImageTestCase TruncatedSmallGIFTestCase() {
|
||||||
return ImageTestCase("green-1x1-truncated.gif", "image/gif", IntSize(1, 1));
|
return ImageTestCase("green-1x1-truncated.gif", "image/gif", IntSize(1, 1),
|
||||||
|
TEST_CASE_IS_TRANSPARENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageTestCase LargeICOWithBMPTestCase() {
|
ImageTestCase LargeICOWithBMPTestCase() {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ function* testFiles() {
|
|||||||
// PNGs and GIFs may be transparent or not.
|
// PNGs and GIFs may be transparent or not.
|
||||||
yield ["red.png", false];
|
yield ["red.png", false];
|
||||||
yield ["transparent.png", true];
|
yield ["transparent.png", true];
|
||||||
yield ["red.gif", false];
|
yield ["animated-gif-finalframe.gif", false];
|
||||||
yield ["transparent.gif", true];
|
yield ["transparent.gif", true];
|
||||||
|
|
||||||
// GIFs with padding on the first frame are always transparent.
|
// GIFs with padding on the first frame are always transparent.
|
||||||
|
|||||||
11
image/test/reftest/gif/one-pixel-no-image-data-ref.html
Normal file
11
image/test/reftest/gif/one-pixel-no-image-data-ref.html
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<style>
|
||||||
|
html{
|
||||||
|
background-color:black;
|
||||||
|
}
|
||||||
|
div {
|
||||||
|
width: 200px;
|
||||||
|
height: 200px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div></div>
|
||||||
11
image/test/reftest/gif/one-pixel-no-image-data.html
Normal file
11
image/test/reftest/gif/one-pixel-no-image-data.html
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<style>
|
||||||
|
html{
|
||||||
|
background-color:black;
|
||||||
|
}
|
||||||
|
div {
|
||||||
|
width: 200px;
|
||||||
|
height: 200px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div style="background-image:url(data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=)"></div>
|
||||||
@@ -27,3 +27,6 @@ fuzzy-if(Android,0-1,0-8) == tile-transform.html tile-transform-ref.html
|
|||||||
|
|
||||||
# Bug 1234077
|
# Bug 1234077
|
||||||
== truncated-framerect.html truncated-framerect-ref.html
|
== truncated-framerect.html truncated-framerect-ref.html
|
||||||
|
|
||||||
|
# Bug 1801397
|
||||||
|
== one-pixel-no-image-data.html one-pixel-no-image-data-ref.html
|
||||||
|
|||||||
Reference in New Issue
Block a user