Bug 1906264 - masks and patterns should not display symbols r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D215796
This commit is contained in:
longsonr 2024-07-05 09:59:36 +00:00
Родитель 582d1ce8bf
Коммит 7aec7842f8
3 изменённых файлов: 37 добавлений и 3 удалений

Просмотреть файл

@ -432,7 +432,7 @@ static bool PaintMaskSurface(const PaintFramesParams& aParams,
const ComputedStyle* aSC,
const nsTArray<SVGMaskFrame*>& aMaskFrames,
const nsPoint& aOffsetToUserSpace) {
MOZ_ASSERT(aMaskFrames.Length() > 0);
MOZ_ASSERT(!aMaskFrames.IsEmpty());
MOZ_ASSERT(aMaskDT->GetFormat() == SurfaceFormat::A8);
MOZ_ASSERT(aOpacity == 1.0 || aMaskFrames.Length() == 1);
@ -508,13 +508,13 @@ static MaskPaintResult CreateAndPaintMaskSurface(
const nsTArray<SVGMaskFrame*>& aMaskFrames,
const nsPoint& aOffsetToUserSpace) {
const nsStyleSVGReset* svgReset = aSC->StyleSVGReset();
MOZ_ASSERT(aMaskFrames.Length() > 0);
MOZ_ASSERT(!aMaskFrames.IsEmpty());
MaskPaintResult paintResult;
gfxContext& ctx = aParams.ctx;
// Optimization for single SVG mask.
if (((aMaskFrames.Length() == 1) && aMaskFrames[0])) {
if (aMaskFrames.Length() == 1 && aMaskFrames[0]) {
gfxMatrix cssPxToDevPxMatrix =
SVGUtils::GetCSSPxToDevPxMatrix(aParams.frame);
paintResult.opacityApplied = true;

Просмотреть файл

@ -584,6 +584,9 @@ void SVGUtils::PaintFrameWithEffects(nsIFrame* aFrame, gfxContext& aContext,
if (!svg->HasValidDimensions()) {
return;
}
if (aFrame->IsSVGSymbolFrame() && !svg->IsInSVGUseShadowTree()) {
return;
}
}
/* SVG defines the following rendering model:

Просмотреть файл

@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mask behaviour when mask contains a symbol element</title>
<link rel="match" href="green-100x100.svg">
<link rel="help" href="https://drafts.fxtf.org/css-masking-1/#MaskElement">
<meta name="assert" content="A symbol in a mask should not be displayed">
</head>
<style>
html, body, svg {
padding: 0;
margin: 0;
}
</style>
<body>
<svg width="200" height="200">
<defs>
<mask id="aMask">
<symbol>
<rect x="0" y="0" width="100" height="100" fill="#ffffff"/>
</symbol>
</mask>
</defs>
<rect width="100" height="100" fill="green"/>
<foreignObject width="200" height="200" style="mask: url('#aMask');">
<div style="width: 200px; height: 200px; background: red;"></div>
</foreignObject>
</svg>
</body>
</html>