summaryrefslogtreecommitdiffstats
path: root/layout/svg/nsSVGOuterSVGFrame.cpp
diff options
context:
space:
mode:
authorAndy <webmaster@RealityRipple.com>2020-07-31 13:01:18 -0700
committerMoonchild <moonchild@palemoon.org>2020-08-07 21:27:29 +0000
commit3266e0976ff055aefa49b664966229bbb89d1009 (patch)
tree41603b23ec1667a191fe0714d72a2d2649d77125 /layout/svg/nsSVGOuterSVGFrame.cpp
parent4433519ae8b7e1cc14e217c3e20d8bca3f9cf2f2 (diff)
downloadUXP-3266e0976ff055aefa49b664966229bbb89d1009.tar
UXP-3266e0976ff055aefa49b664966229bbb89d1009.tar.gz
UXP-3266e0976ff055aefa49b664966229bbb89d1009.tar.lz
UXP-3266e0976ff055aefa49b664966229bbb89d1009.tar.xz
UXP-3266e0976ff055aefa49b664966229bbb89d1009.zip
Issue #1619 - Convert Intrinsic Ratio to Float
https://bugzilla.mozilla.org/show_bug.cgi?id=1547792 Aspect Ratio handling simplified by using floating point integers: - Multiplication of value (or inverse value) to a known side for Scaling - No unequal equal values such as "4/3" vs "8/6" vs "20/15" - Truly "Empty" aspect ratios, even if one dimension is not 0
Diffstat (limited to 'layout/svg/nsSVGOuterSVGFrame.cpp')
-rw-r--r--layout/svg/nsSVGOuterSVGFrame.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/layout/svg/nsSVGOuterSVGFrame.cpp b/layout/svg/nsSVGOuterSVGFrame.cpp
index 16dfc2b37..d8cd2cb77 100644
--- a/layout/svg/nsSVGOuterSVGFrame.cpp
+++ b/layout/svg/nsSVGOuterSVGFrame.cpp
@@ -232,28 +232,38 @@ nsSVGOuterSVGFrame::GetIntrinsicSize()
return intrinsicSize;
}
-/* virtual */ nsSize
+/* virtual */ AspectRatio
nsSVGOuterSVGFrame::GetIntrinsicRatio()
{
+ // 2020-07-14 (RealityRipple) Firefox Uses a new IsReplacedAndContainSize(this)
+ // function call [Line 96-99 on trunk].
+/*
+ static inline bool IsReplacedAndContainSize(const nsSVGOuterSVGFrame* aFrame) {
+ return aFrame->GetContent->GetParent() &&
+ aFrame->StyleDisplay()->IsContainSize();
+ }
+ */
+ // but since contain: size doesn't exist in Pale Moon yet...
+/*
+ if (IsReplacedAndContainSize(this)) {
+ 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 +277,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();