summaryrefslogtreecommitdiffstats
path: root/layout/svg/nsSVGOuterSVGFrame.cpp
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-08-31 05:54:39 +0000
committerMoonchild <moonchild@palemoon.org>2020-08-31 05:54:39 +0000
commita6f632714fcb1be3dd00b0fc76fbf6bfc693155b (patch)
treeb04c82f9af4a0d288a6d4350d774ad8fe6dac903 /layout/svg/nsSVGOuterSVGFrame.cpp
parent2ed0607c747b21cadaf7401d4ba706097578e74d (diff)
parentb28effe2ea93e43e362f7ce263d23b55adcb6da7 (diff)
downloadUXP-a6f632714fcb1be3dd00b0fc76fbf6bfc693155b.tar
UXP-a6f632714fcb1be3dd00b0fc76fbf6bfc693155b.tar.gz
UXP-a6f632714fcb1be3dd00b0fc76fbf6bfc693155b.tar.lz
UXP-a6f632714fcb1be3dd00b0fc76fbf6bfc693155b.tar.xz
UXP-a6f632714fcb1be3dd00b0fc76fbf6bfc693155b.zip
Merge branch 'redwood' into releaseRELBASE_20200831
Diffstat (limited to 'layout/svg/nsSVGOuterSVGFrame.cpp')
-rw-r--r--layout/svg/nsSVGOuterSVGFrame.cpp38
1 files changed, 15 insertions, 23 deletions
diff --git a/layout/svg/nsSVGOuterSVGFrame.cpp b/layout/svg/nsSVGOuterSVGFrame.cpp
index 16dfc2b37..3f68245e2 100644
--- a/layout/svg/nsSVGOuterSVGFrame.cpp
+++ b/layout/svg/nsSVGOuterSVGFrame.cpp
@@ -232,28 +232,30 @@ nsSVGOuterSVGFrame::GetIntrinsicSize()
return intrinsicSize;
}
-/* virtual */ nsSize
+/* virtual */ AspectRatio
nsSVGOuterSVGFrame::GetIntrinsicRatio()
-{
+{
+ // When 'contain: size' is implemented, make sure to check for it.
+/*
+ if (this->GetContent->GetParent() && this->StyleDisplay()->IsContainSize()) {
+ return AspectRatio();
+ }
+ */
+
// We only have an intrinsic size/ratio if our width and height attributes
// are both specified and set to non-percentage values, or we have a viewBox
// rect: http://www.w3.org/TR/SVGMobile12/coords.html#IntrinsicSizing
+ // Unfortunately we have to return the ratio as two nscoords whereas what
+ // we have are two floats. Using app units allows for some floating point
+ // values to work but really small or large numbers will fail.
SVGSVGElement *content = static_cast<SVGSVGElement*>(mContent);
nsSVGLength2 &width = content->mLengthAttributes[SVGSVGElement::ATTR_WIDTH];
nsSVGLength2 &height = content->mLengthAttributes[SVGSVGElement::ATTR_HEIGHT];
if (!width.IsPercentage() && !height.IsPercentage()) {
- nsSize ratio(
- nsPresContext::CSSPixelsToAppUnits(width.GetAnimValue(content)),
- nsPresContext::CSSPixelsToAppUnits(height.GetAnimValue(content)));
- if (ratio.width < 0) {
- ratio.width = 0;
- }
- if (ratio.height < 0) {
- ratio.height = 0;
- }
- return ratio;
+ return AspectRatio::FromSize(width.GetAnimValue(content),
+ height.GetAnimValue(content));
}
SVGViewElement* viewElement = content->GetCurrentViewElement();
@@ -267,17 +269,7 @@ nsSVGOuterSVGFrame::GetIntrinsicRatio()
}
if (viewbox) {
- float viewBoxWidth = viewbox->width;
- float viewBoxHeight = viewbox->height;
-
- if (viewBoxWidth < 0.0f) {
- viewBoxWidth = 0.0f;
- }
- if (viewBoxHeight < 0.0f) {
- viewBoxHeight = 0.0f;
- }
- return nsSize(nsPresContext::CSSPixelsToAppUnits(viewBoxWidth),
- nsPresContext::CSSPixelsToAppUnits(viewBoxHeight));
+ return AspectRatio::FromSize(viewbox->width, viewbox->height);
}
return nsSVGDisplayContainerFrame::GetIntrinsicRatio();