Bug 1205027 - Only size <img> to broken-image size if it's actually broken. r=dholbert

This commit is contained in:
Masatoshi Kimura 2016-06-03 07:05:46 +09:00
parent 79dc92e0be
commit 107cbffdc0
7 changed files with 140 additions and 10 deletions

View File

@ -27,7 +27,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=995943
SimpleTest.waitForExplicitFinish();
SimpleTest.requestCompleteLog();
if (navigator.userAgent.indexOf("Mac OS X 10.10") != -1)
SimpleTest.expectAssertions(5); // See bug 1067022
SimpleTest.expectAssertions(6, 9); // See bug 1067022
else if (Services.appinfo.OS == "WINNT")
SimpleTest.expectAssertions(0, 1); // See bug 1067022

View File

@ -22,6 +22,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=758258
var Ci = Components.interfaces;
SimpleTest.waitForExplicitFinish();
if (navigator.userAgent.indexOf("Mac OS X 10.10") != -1) {
SimpleTest.expectAssertions(0, 4);
}
/*
* gData is an array of objects. Each object represents a test case.

View File

@ -790,15 +790,30 @@ nsImageFrame::EnsureIntrinsicSizeAndRatio()
} else {
// image request is null or image size not known, probably an
// invalid image specified
// - make the image big enough for the icon (it may not be
// used if inline alt expansion is used instead)
if (!(GetStateBits() & NS_FRAME_GENERATED_CONTENT)) {
nscoord edgeLengthToUse =
nsPresContext::CSSPixelsToAppUnits(
ICON_SIZE + (2 * (ICON_PADDING + ALT_BORDER_WIDTH)));
mIntrinsicSize.width.SetCoordValue(edgeLengthToUse);
mIntrinsicSize.height.SetCoordValue(edgeLengthToUse);
mIntrinsicRatio.SizeTo(1, 1);
bool imageBroken = false;
// check for broken images. valid null images (eg. img src="") are
// not considered broken because they have no image requests
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
if (imageLoader) {
nsCOMPtr<imgIRequest> currentRequest;
imageLoader->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
getter_AddRefs(currentRequest));
uint32_t imageStatus;
imageBroken =
currentRequest &&
NS_SUCCEEDED(currentRequest->GetImageStatus(&imageStatus)) &&
(imageStatus & imgIRequest::STATUS_ERROR);
}
// invalid image specified. make the image big enough for the "broken" icon
if (imageBroken) {
nscoord edgeLengthToUse =
nsPresContext::CSSPixelsToAppUnits(
ICON_SIZE + (2 * (ICON_PADDING + ALT_BORDER_WIDTH)));
mIntrinsicSize.width.SetCoordValue(edgeLengthToUse);
mIntrinsicSize.height.SetCoordValue(edgeLengthToUse);
mIntrinsicRatio.SizeTo(1, 1);
}
}
}
}

View File

@ -0,0 +1,45 @@
"use strict";
const Cc = Components.classes;
const Ci = Components.interfaces;
const IMG_BYTES = atob(
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAA" +
"DUlEQVQImWNgY2P7DwABOgESJhRQtgAAAABJRU5ErkJggg==");
function handleRequest(request, response) {
response.processAsync();
getObjectState("context", function(obj) {
let ctx;
if (obj == null) {
ctx = {
QueryInterface: function(iid) {
if (iid.equals(Components.interfaces.nsISupports))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
}
};
ctx.wrappedJSObject = ctx;
ctx.promise = new Promise(resolve => {
ctx.resolve = resolve;
});
setObjectState("context", ctx);
} else {
ctx = obj.wrappedJSObject;
}
Promise.resolve(ctx).then(next);
});
function next(ctx) {
if (request.queryString.indexOf("continue") >= 0) {
ctx.resolve();
}
ctx.promise.then(() => {
response.setHeader("Content-Type", "image/png");
response.write(IMG_BYTES);
response.finish();
});
}
}

View File

@ -14,6 +14,7 @@ support-files =
file_Dolske.png
file_IconTestServer.sjs
file_LoadingImageReference.png
file_SlowImage.sjs
bug1174521.html
[test_bug240933.html]
@ -106,6 +107,7 @@ skip-if = os=='win'
[test_image_selection_2.html]
[test_invalidate_during_plugin_paint.html]
skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android' # b2g(plugins not supported) b2g-debug(plugins not supported) b2g-desktop(plugins not supported)
[test_intrinsic_size_on_loading.html]
[test_movement_by_characters.html]
[test_movement_by_words.html]
# Disable the caret movement by word test on Linux because the shortcut keys

View File

@ -0,0 +1,53 @@
<!DOCTYPE html>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1205027
-->
<head>
<title>Test for images intrinsic size while load is pending</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style>
body { margin: 0; }
img { display: block; }
</style>
<script>
SimpleTest.waitForExplicitFinish();
var initialOffsetTop;
var finalOffsetTop;
function report() {
finalOffsetTop = marker.offsetTop;
is(initialOffsetTop, 0, "initial offsetTop: " + initialOffsetTop);
is(finalOffsetTop, 8, "final offsetTop: " + finalOffsetTop);
ok(initialOffsetTop < finalOffsetTop, "offsetTop should get larger.");
SimpleTest.finish();
}
function fail() {
ok(false, "image loading should not fail.");
}
</script>
</head>
<body onload="report();">
<!-- Bunch of tiny images: -->
<img src="file_SlowImage.sjs" onerror="fail();">
<img src="file_SlowImage.sjs" onerror="fail();">
<img src="file_SlowImage.sjs" onerror="fail();">
<img src="file_SlowImage.sjs" onerror="fail();">
<img src="file_SlowImage.sjs" onerror="fail();">
<img src="file_SlowImage.sjs" onerror="fail();">
<img src="file_SlowImage.sjs" onerror="fail();">
<img src="file_SlowImage.sjs" onerror="fail();">
<div id="marker">Marker div</div>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1205027">Mozilla Bug 1205027</a>
<script>
initialOffsetTop = marker.offsetTop;
// prompt the sjs "server" to proceed to serve data to our <img> elements
var img = new Image();
img.onerror = fail;
img.src = "file_SlowImage.sjs?continue";
</script>
</body>
</html>

View File

@ -172,7 +172,19 @@
if not debug and (os == "win") and (version == "10.0.10240") and (processor == "x86_64") and (bits == 64): TIMEOUT
[loading image <video poster>]
expected: FAIL
expected:
if not debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86") and (bits == 32): FAIL
if not debug and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86_64") and (bits == 64): FAIL
if not debug and (os == "win") and (version == "5.1.2600") and (processor == "x86") and (bits == 32): TIMEOUT
if not debug and (os == "win") and (version == "6.1.7601") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and (os == "win") and (version == "6.1.7601") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and (os == "win") and (version == "5.1.2600") and (processor == "x86") and (bits == 32): TIMEOUT
if debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86") and (bits == 32): FAIL
if debug and (os == "win") and (version == "6.2.9200") and (processor == "x86_64") and (bits == 64): TIMEOUT
if debug and (os == "linux") and (version == "Ubuntu 12.04") and (processor == "x86_64") and (bits == 64): FAIL
if debug and (os == "win") and (version == "10.0.10240") and (processor == "x86_64") and (bits == 64): TIMEOUT
if not debug and (os == "win") and (version == "10.0.10240") and (processor == "x86_64") and (bits == 64): TIMEOUT
[loading video <video>]
expected: