diff --git a/layout/base/LayoutConstants.h b/layout/base/LayoutConstants.h index d624a1a196..08cae5f12a 100644 --- a/layout/base/LayoutConstants.h +++ b/layout/base/LayoutConstants.h @@ -26,5 +26,9 @@ #define NS_INTRINSIC_WIDTH_UNKNOWN nscoord_MIN +// The fallback size of width is 300px and the aspect-ratio is 2:1, based on the +// spec definition in CSS2 section 10.3.2 +#define REPLACED_ELEM_FALLBACK_PX_WIDTH 300 +#define REPLACED_ELEM_FALLBACK_PX_HEIGHT 150 #endif // LayoutConstants_h___ diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index fbf0a04792..2c974074fc 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -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);