Bug 1385745 Part 2 - Make SVG clip-path with basic-shape respect box-decoration-break. r?cjku
MozReview-Commit-ID: 4pJnxSy6GQO
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -9529,16 +9529,17 @@ ComputeSVGReferenceRect(nsIFrame* aFrame
return r;
}
static nsRect
ComputeHTMLReferenceRect(nsIFrame* aFrame,
StyleGeometryBox aGeometryBox)
{
nsRect r;
+ const nsStyleSVGReset* style = aFrame->StyleSVGReset();
// For elements with associated CSS layout box, the used value for fill-box,
// stroke-box and view-box is border-box.
switch (aGeometryBox) {
case StyleGeometryBox::ContentBox:
r = aFrame->GetContentRectRelativeToSelf();
break;
case StyleGeometryBox::PaddingBox:
@@ -9547,17 +9548,30 @@ ComputeHTMLReferenceRect(nsIFrame* aFram
case StyleGeometryBox::MarginBox:
r = aFrame->GetMarginRectRelativeToSelf();
break;
case StyleGeometryBox::NoBox:
case StyleGeometryBox::BorderBox:
case StyleGeometryBox::FillBox:
case StyleGeometryBox::StrokeBox:
case StyleGeometryBox::ViewBox:
- r = aFrame->GetRectRelativeToSelf();
+ if (style->HasClipPath() || style->HasMask()) {
+ bool shouldUseUnion = true;
+ if (aFrame->StyleBorder()->mBoxDecorationBreak == StyleBoxDecorationBreak::Clone) {
+ shouldUseUnion = false;
+ }
+ gfxRect bbox = nsSVGUtils::GetBBox(aFrame,
+ nsSVGUtils::eUseFrameBoundsForOuterSVG |
+ nsSVGUtils::eBBoxIncludeFill,
+ nullptr,
+ shouldUseUnion);
+ r = nsLayoutUtils::RoundGfxRectToAppRect(bbox, AppUnitsPerCSSPixel());
+ } else {
+ r = aFrame->GetRectRelativeToSelf();
+ }
break;
default:
MOZ_ASSERT_UNREACHABLE("unknown StyleGeometryBox type");
r = aFrame->GetRectRelativeToSelf();
break;
}
return r;