From ea5b14c15d6c97b33f57be48ee7a2777cc006c0d Mon Sep 17 00:00:00 2001 From: longsonr Date: Tue, 15 Apr 2025 15:49:39 +0000 Subject: [PATCH] Bug 1960605 - Check outer svg dimensions are valid r=dholbert Differential Revision: https://phabricator.services.mozilla.com/D245570 --- dom/svg/SVGViewportElement.cpp | 10 +++------- dom/svg/SVGViewportElement.h | 2 -- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/dom/svg/SVGViewportElement.cpp b/dom/svg/SVGViewportElement.cpp index 4640593f6848..a2cea7677dae 100644 --- a/dom/svg/SVGViewportElement.cpp +++ b/dom/svg/SVGViewportElement.cpp @@ -256,18 +256,14 @@ gfxMatrix SVGViewportElement::ChildToUserSpaceTransform() const { return ThebesMatrix(viewBox); } -bool SVGViewportElement::AreWidthAndHeightUnsetOrPositive() const { +/* virtual */ +bool SVGViewportElement::HasValidDimensions() const { return (!mLengthAttributes[ATTR_WIDTH].IsExplicitlySet() || mLengthAttributes[ATTR_WIDTH].GetAnimValInSpecifiedUnits() > 0) && (!mLengthAttributes[ATTR_HEIGHT].IsExplicitlySet() || mLengthAttributes[ATTR_HEIGHT].GetAnimValInSpecifiedUnits() > 0); } -/* virtual */ -bool SVGViewportElement::HasValidDimensions() const { - return !IsInner() || AreWidthAndHeightUnsetOrPositive(); -} - SVGAnimatedViewBox* SVGViewportElement::GetAnimatedViewBox() { return &mViewBox; } @@ -284,7 +280,7 @@ bool SVGViewportElement::ShouldSynthesizeViewBox() const { // document (and lack an explicit viewBox), as long as our width & // height attributes wouldn't yield an empty synthesized viewbox. return IsRootSVGSVGElement() && OwnerDoc()->IsBeingUsedAsImage() && - AreWidthAndHeightUnsetOrPositive(); + HasValidDimensions(); } //---------------------------------------------------------------------- diff --git a/dom/svg/SVGViewportElement.h b/dom/svg/SVGViewportElement.h index 53b39406cf15..07323f24ae5d 100644 --- a/dom/svg/SVGViewportElement.h +++ b/dom/svg/SVGViewportElement.h @@ -129,8 +129,6 @@ class SVGViewportElement : public SVGGraphicsElement { return !GetParent() && IsInUncomposedDoc() && IsSVGElement(nsGkAtoms::svg); } - bool AreWidthAndHeightUnsetOrPositive() const; - /** * Returns the explicit or default preserveAspectRatio, unless we're * synthesizing a viewBox, in which case it returns the "none" value.