Issue #2316 - Part 1: Use fallback element sizes for w/h-less SVG

Instead of completely failing the call, use the CSS specified intrinsic
default width/height of 300x150.
This commit is contained in:
Moonchild 2023-09-26 15:15:31 +02:00 committed by roytam1
commit af6a491bfe
2 changed files with 14 additions and 3 deletions

View file

@ -7172,10 +7172,17 @@ nsLayoutUtils::SurfaceFromElement(nsIImageLoadingContent* aElement,
imgWidth = element->Width();
imgHeight = element->Height();
} else {
// No size declared by SVG, so use the image container size.
// As stated in css-sizing-3 Intrinsic Sizes, use the fallback size
// of 300 x 150 for the width and height as-needed.
rv = imgContainer->GetWidth(&imgWidth);
nsresult rv2 = imgContainer->GetHeight(&imgHeight);
if (NS_FAILED(rv) || NS_FAILED(rv2))
return result;
if (NS_FAILED(rv)) {
imgWidth = REPLACED_ELEM_FALLBACK_PX_WIDTH;
}
rv = imgContainer->GetHeight(&imgHeight);
if (NS_FAILED(rv)) {
imgHeight = REPLACED_ELEM_FALLBACK_PX_HEIGHT;
}
}
result.mSize = IntSize(imgWidth, imgHeight);