summaryrefslogtreecommitdiff
path: root/layout
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2023-09-26 15:15:31 +0200
committerMoonchild <moonchild@palemoon.org>2023-09-26 15:15:31 +0200
commit8b4aae99b42f6258e1c05a235981522a484532d4 (patch)
tree3697687bba4e21d17ecce9b63334a5d403ae834f /layout
parent8775eedca5f850a04b9e3e0b95f31f3942fa519e (diff)
downloaduxp-8b4aae99b42f6258e1c05a235981522a484532d4.tar.gz
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.
Diffstat (limited to 'layout')
-rw-r--r--layout/base/LayoutConstants.h4
-rw-r--r--layout/base/nsLayoutUtils.cpp13
2 files changed, 14 insertions, 3 deletions
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 2e51655a0c..4d4b4eab62 100644
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -7164,10 +7164,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);