Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit efc549b

Browse files
committed
Bug 1642209 - Fix filtering of masked content r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D186528
1 parent c4da81d commit efc549b

File tree

4 files changed

+37
-10
lines changed

4 files changed

+37
-10
lines changed

layout/svg/FilterInstance.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ static UniquePtr<UserSpaceMetrics> UserSpaceMetricsForFrame(nsIFrame* aFrame) {
6464
void FilterInstance::PaintFilteredFrame(
6565
nsIFrame* aFilteredFrame, Span<const StyleFilter> aFilterChain,
6666
gfxContext* aCtx, const SVGFilterPaintCallback& aPaintCallback,
67-
const nsRegion* aDirtyArea, imgDrawingParams& aImgParams, float aOpacity) {
67+
const nsRegion* aDirtyArea, imgDrawingParams& aImgParams, float aOpacity,
68+
const gfxRect* aOverrideBBox) {
6869
UniquePtr<UserSpaceMetrics> metrics =
6970
UserSpaceMetricsForFrame(aFilteredFrame);
7071

@@ -89,7 +90,7 @@ void FilterInstance::PaintFilteredFrame(
8990
FilterInstance instance(aFilteredFrame, aFilteredFrame->GetContent(),
9091
*metrics, aFilterChain, /* InputIsTainted */ true,
9192
aPaintCallback, scaleMatrixInDevUnits, aDirtyArea,
92-
nullptr, nullptr, nullptr);
93+
nullptr, nullptr, aOverrideBBox);
9394
if (instance.IsInitialized()) {
9495
// Pull scale vector out of aCtx's transform, put all scale factors, which
9596
// includes css and css-to-dev-px scale, into scaleMatrixInDevUnits.

layout/svg/FilterInstance.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,11 @@ class FilterInstance {
8989
* frame space (i.e. relative to its origin, the top-left corner of its
9090
* border box).
9191
*/
92-
static void PaintFilteredFrame(nsIFrame* aFilteredFrame,
93-
Span<const StyleFilter> aFilterChain,
94-
gfxContext* aCtx,
95-
const SVGFilterPaintCallback& aPaintCallback,
96-
const nsRegion* aDirtyArea,
97-
imgDrawingParams& aImgParams,
98-
float aOpacity = 1.0f);
92+
static void PaintFilteredFrame(
93+
nsIFrame* aFilteredFrame, Span<const StyleFilter> aFilterChain,
94+
gfxContext* aCtx, const SVGFilterPaintCallback& aPaintCallback,
95+
const nsRegion* aDirtyArea, imgDrawingParams& aImgParams,
96+
float aOpacity = 1.0f, const gfxRect* aOverrideBBox = nullptr);
9997

10098
/**
10199
* Returns the post-filter area that could be dirtied when the given

layout/svg/SVGUtils.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -725,9 +725,14 @@ void SVGUtils::PaintFrameWithEffects(nsIFrame* aFrame, gfxContext& aContext,
725725
: aTransform,
726726
aImgParams);
727727
};
728+
// If we're masking a userSpaceOnUse mask we may need to include the
729+
// stroke too. Err on the side of caution and include it always.
730+
gfxRect bbox = GetBBox(aFrame, SVGUtils::eUseFrameBoundsForOuterSVG |
731+
SVGUtils::eBBoxIncludeFillGeometry |
732+
SVGUtils::eBBoxIncludeStroke);
728733
FilterInstance::PaintFilteredFrame(
729734
aFrame, aFrame->StyleEffects()->mFilters.AsSpan(), target, callback,
730-
nullptr, aImgParams);
735+
nullptr, aImgParams, 1.0f, &bbox);
731736
} else {
732737
svgFrame->PaintSVG(*target, aTransform, aImgParams);
733738
}
Lines changed: 23 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)