summaryrefslogtreecommitdiffstats
path: root/layout/svg
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-08-03 11:04:41 +0200
committerGitHub <noreply@github.com>2020-08-03 11:04:41 +0200
commit2e1c5dafc6d0795b7b73223e734bb5771948688b (patch)
treee35cf37eb6d2466363ea6887d08536eff8ee2e4a /layout/svg
parent02bd56c442d777daa2b94cf3962430e1d81b6811 (diff)
parenta90b8d98e859ae71c74f2a8cb78b24899d879185 (diff)
downloadUXP-2e1c5dafc6d0795b7b73223e734bb5771948688b.tar
UXP-2e1c5dafc6d0795b7b73223e734bb5771948688b.tar.gz
UXP-2e1c5dafc6d0795b7b73223e734bb5771948688b.tar.lz
UXP-2e1c5dafc6d0795b7b73223e734bb5771948688b.tar.xz
UXP-2e1c5dafc6d0795b7b73223e734bb5771948688b.zip
Merge pull request #1622 from RealityRipple/master
Convert Intrinsic Ratio from nsSize to Float
Diffstat (limited to 'layout/svg')
-rw-r--r--layout/svg/nsSVGOuterSVGFrame.cpp44
-rw-r--r--layout/svg/nsSVGOuterSVGFrame.h2
2 files changed, 23 insertions, 23 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();
diff --git a/layout/svg/nsSVGOuterSVGFrame.h b/layout/svg/nsSVGOuterSVGFrame.h
index ee59b7d1c..4705b6ebe 100644
--- a/layout/svg/nsSVGOuterSVGFrame.h
+++ b/layout/svg/nsSVGOuterSVGFrame.h
@@ -42,7 +42,7 @@ public:
virtual nscoord GetPrefISize(nsRenderingContext *aRenderingContext) override;
virtual mozilla::IntrinsicSize GetIntrinsicSize() override;
- virtual nsSize GetIntrinsicRatio() override;
+ virtual mozilla::AspectRatio GetIntrinsicRatio() override;
virtual mozilla::LogicalSize
ComputeSize(nsRenderingContext *aRenderingContext,