Bug 1960605 - Check outer svg dimensions are valid r=dholbert

Differential Revision: https://phabricator.services.mozilla.com/D245570
This commit is contained in:
longsonr
2025-04-15 15:49:39 +00:00
parent ed01a1d8b2
commit ea5b14c15d
2 changed files with 3 additions and 9 deletions

View File

@@ -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();
}
//----------------------------------------------------------------------

View File

@@ -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.