Bug 1325080 - Always synchronously decode image size. r=tnikkel

MozReview-Commit-ID: LYNLjwy1kAy

--HG--
extra : rebase_source : 7d5d4b4f90efb4cb461828e3222e948f70a9d1fe
This commit is contained in:
Kevin Hsieh 2017-08-07 13:54:11 -07:00
parent 66ab173459
commit d113ce52dc
3 changed files with 41 additions and 0 deletions

View File

@ -74,6 +74,9 @@ ComputeImageFlags(ImageURL* uri, const nsCString& aMimeType, bool isMultiPart)
if (isMultiPart) {
imageFlags |= Image::INIT_FLAG_TRANSIENT;
}
imageFlags |= Image::INIT_FLAG_SYNC_LOAD;
// Always synchronously decode metadata (including size) so as to avoid
// unnecessary reflows.
return imageFlags;
}

View File

@ -125,6 +125,7 @@ skip-if = true # disabled - See bug 579139
skip-if = os == 'android'
[test_bug1180105.html]
[test_bug1217571.html]
[test_bug1325080.html]
[test_bullet_animation.html]
skip-if = os == 'android'
[test_changeOfSource.html]

View File

@ -0,0 +1,37 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1325080
-->
<head>
<title>Test for Bug 1325080</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1325080">Mozilla Bug 1325080</a>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 1325080 **/
SimpleTest.waitForExplicitFinish();
function createImage() {
// This function's code comes from the Acid3 test #72
document.open();
document.write('<!DOCTYPE html><head><style>img { height: 10px; }</style></head><body><img src="data:image/gif;base64,R0lGODlhAQABAID%2FAMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw%3D%3D" alt="alt-text"></body>');
document.close();
}
window.onload = function() {
createImage();
SimpleTest.executeSoon(() => {
ok(document.images[0].height == 10, "Style should set height of image.");
SimpleTest.finish();
});
}
</script>
</pre>
</body>
</html>