Bug 1345946 - Part 1. Make SVG masks, gradients and patterns use the frame bounds when applied to outer-<svg>.
MozReview-Commit-ID: H6AravwRd2i
--- a/layout/svg/nsSVGGradientFrame.cpp
+++ b/layout/svg/nsSVGGradientFrame.cpp
@@ -139,17 +139,20 @@ nsSVGGradientFrame::GetGradientTransform
uint16_t gradientUnits = GetGradientUnits();
if (gradientUnits != SVG_UNIT_TYPE_USERSPACEONUSE) {
NS_ASSERTION(gradientUnits == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX,
"Unknown gradientUnits type");
// objectBoundingBox is the default anyway
gfxRect bbox =
- aOverrideBounds ? *aOverrideBounds : nsSVGUtils::GetBBox(aSource);
+ aOverrideBounds
+ ? *aOverrideBounds
+ : nsSVGUtils::GetBBox(aSource, nsSVGUtils::eUseFrameBoundsForOuterSVG |
+ nsSVGUtils::eBBoxIncludeFillGeometry);
bboxMatrix =
gfxMatrix(bbox.Width(), 0, 0, bbox.Height(), bbox.X(), bbox.Y());
}
const nsSVGAnimatedTransformList* animTransformList =
GetGradientTransformList(mContent);
if (!animTransformList)
return bboxMatrix;
--- a/layout/svg/nsSVGMaskFrame.cpp
+++ b/layout/svg/nsSVGMaskFrame.cpp
@@ -335,17 +335,20 @@ gfxRect
nsSVGMaskFrame::GetMaskArea(nsIFrame* aMaskedFrame)
{
SVGMaskElement *maskElem = static_cast<SVGMaskElement*>(mContent);
uint16_t units =
maskElem->mEnumAttributes[SVGMaskElement::MASKUNITS].GetAnimValue();
gfxRect bbox;
if (units == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
- bbox = nsSVGUtils::GetBBox(aMaskedFrame);
+ bbox =
+ nsSVGUtils::GetBBox(aMaskedFrame,
+ nsSVGUtils::eUseFrameBoundsForOuterSVG |
+ nsSVGUtils::eBBoxIncludeFillGeometry);
}
// Bounds in the user space of aMaskedFrame
gfxRect maskArea = nsSVGUtils::GetRelativeRect(units,
&maskElem->mLengthAttributes[SVGMaskElement::ATTR_X],
bbox, aMaskedFrame);
return maskArea;
--- a/layout/svg/nsSVGPatternFrame.cpp
+++ b/layout/svg/nsSVGPatternFrame.cpp
@@ -207,17 +207,21 @@ static nsresult
GetTargetGeometry(gfxRect *aBBox,
const nsSVGViewBox &aViewBox,
uint16_t aPatternContentUnits,
uint16_t aPatternUnits,
nsIFrame *aTarget,
const Matrix &aContextMatrix,
const gfxRect *aOverrideBounds)
{
- *aBBox = aOverrideBounds ? *aOverrideBounds : nsSVGUtils::GetBBox(aTarget);
+ *aBBox =
+ aOverrideBounds
+ ? *aOverrideBounds
+ : nsSVGUtils::GetBBox(aTarget, nsSVGUtils::eUseFrameBoundsForOuterSVG |
+ nsSVGUtils::eBBoxIncludeFillGeometry);
// Sanity check
if (IncludeBBoxScale(aViewBox, aPatternContentUnits, aPatternUnits) &&
(aBBox->Width() <= 0 || aBBox->Height() <= 0)) {
return NS_ERROR_FAILURE;
}
// OK, now fix up the bounding box to reflect user coordinates