mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1169680 - Don't merge image cache entries for blob URIs with different refs. r=tn
This commit is contained in:
parent
8321ec5336
commit
788e795e6e
@ -86,8 +86,10 @@ bool
|
||||
ImageCacheKey::operator==(const ImageCacheKey& aOther) const
|
||||
{
|
||||
if (mBlobSerial || aOther.mBlobSerial) {
|
||||
// If at least one of us has a blob serial, just compare those.
|
||||
return mBlobSerial == aOther.mBlobSerial;
|
||||
// If at least one of us has a blob serial, just compare the blob serial and
|
||||
// the ref portion of the URIs.
|
||||
return mBlobSerial == aOther.mBlobSerial &&
|
||||
mURI->HasSameRef(*aOther.mURI);
|
||||
}
|
||||
|
||||
// For non-blob URIs, compare the URIs.
|
||||
@ -109,8 +111,13 @@ ImageCacheKey::ComputeHash(ImageURL* aURI,
|
||||
|
||||
if (aBlobSerial) {
|
||||
// For blob URIs, we hash the serial number of the underlying blob, so that
|
||||
// different blob URIs which point to the same blob share a cache entry.
|
||||
return HashGeneric(*aBlobSerial);
|
||||
// different blob URIs which point to the same blob share a cache entry. We
|
||||
// also include the ref portion of the URI to support -moz-samplesize and
|
||||
// -moz-resolution, which require us to create different Image objects even
|
||||
// if the source data is the same.
|
||||
nsAutoCString ref;
|
||||
aURI->GetRef(ref);
|
||||
return HashGeneric(*aBlobSerial, HashString(ref));
|
||||
}
|
||||
|
||||
// For non-blob URIs, we hash the URI spec.
|
||||
|
@ -101,6 +101,11 @@ public:
|
||||
return mSpec == aOther.mSpec;
|
||||
}
|
||||
|
||||
bool HasSameRef(const ImageURL& aOther) const
|
||||
{
|
||||
return mRef == aOther.mRef;
|
||||
}
|
||||
|
||||
private:
|
||||
// Since this is a basic storage class, no duplication of spec parsing is
|
||||
// included in the functionality. Instead, the class depends upon the
|
||||
|
37
image/test/reftest/blob/blob-uri-with-ref-param-notref.html
Normal file
37
image/test/reftest/blob/blob-uri-with-ref-param-notref.html
Normal file
@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html class="reftest-wait">
|
||||
|
||||
<body>
|
||||
<img id="test">
|
||||
</body>
|
||||
|
||||
<script>
|
||||
var image = new Image;
|
||||
|
||||
image.onload = function() {
|
||||
// Create a canvas.
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = 100;
|
||||
canvas.height = 100;
|
||||
|
||||
// Draw the image into the canvas.
|
||||
var ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(image, 0, 0);
|
||||
|
||||
// Convert the image into a blob URI and use it as #test's src.
|
||||
canvas.toBlob(function(blob) {
|
||||
var uri = window.URL.createObjectURL(blob);
|
||||
uri += '#-moz-samplesize=8';
|
||||
document.getElementById('test').src = uri;
|
||||
|
||||
// Take the snapshot.
|
||||
document.documentElement.removeAttribute('class');
|
||||
}, 'image/jpeg', 0.99);
|
||||
}
|
||||
|
||||
// Start loading the image.
|
||||
image.src = 'image.png';
|
||||
</script>
|
||||
|
||||
</html>
|
36
image/test/reftest/blob/blob-uri-with-ref-param.html
Normal file
36
image/test/reftest/blob/blob-uri-with-ref-param.html
Normal file
@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html class="reftest-wait">
|
||||
|
||||
<body>
|
||||
<img id="test">
|
||||
</body>
|
||||
|
||||
<script>
|
||||
var image = new Image;
|
||||
|
||||
image.onload = function() {
|
||||
// Create a canvas.
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = 100;
|
||||
canvas.height = 100;
|
||||
|
||||
// Draw the image into the canvas.
|
||||
var ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(image, 0, 0);
|
||||
|
||||
// Convert the image into a blob URI and use it as #test's src.
|
||||
canvas.toBlob(function(blob) {
|
||||
var uri = window.URL.createObjectURL(blob);
|
||||
document.getElementById('test').src = uri;
|
||||
|
||||
// Take the snapshot.
|
||||
document.documentElement.removeAttribute('class');
|
||||
}, 'image/jpeg', 0.99);
|
||||
}
|
||||
|
||||
// Start loading the image.
|
||||
image.src = 'image.png';
|
||||
</script>
|
||||
|
||||
</html>
|
BIN
image/test/reftest/blob/image.png
Normal file
BIN
image/test/reftest/blob/image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 840 B |
7
image/test/reftest/blob/reftest.list
Normal file
7
image/test/reftest/blob/reftest.list
Normal file
@ -0,0 +1,7 @@
|
||||
# Blob URI tests
|
||||
|
||||
# Test that blob URIs don't get merged if they have different ref params.
|
||||
# (We run the test twice to check both cached and non-cached cases.)
|
||||
default-preferences pref(image.mozsamplesize.enabled,true)
|
||||
!= blob-uri-with-ref-param.html blob-uri-with-ref-param-notref.html
|
||||
!= blob-uri-with-ref-param.html blob-uri-with-ref-param-notref.html
|
@ -46,5 +46,8 @@ include color-management/reftest.list
|
||||
# Downscaling tests
|
||||
include downscaling/reftest.list
|
||||
|
||||
# Blob URI tests
|
||||
include blob/reftest.list
|
||||
|
||||
# Lossless encoders
|
||||
skip-if(Android||B2G) include encoders-lossless/reftest.list # bug 783621
|
||||
|
Loading…
Reference in New Issue
Block a user