Skip to content

Commit 37b2a5a

Browse files
Constellationaperezdc
authored andcommitted
REGRESSION (269500@main Safari 17.5): Masked Curved Line Rendering Issue https://bugs.webkit.org/show_bug.cgi?id=277624 rdar://133251058 Reviewed by Cameron McCormack. SVG mask implementation is incorrectly mixing repaint rect and bounding box. We workaround the issue by passing RepaintRectCalculation::Accurate to enforce child renderers to compute bounding boxes. But the right implementation should distinguish repaint rect and bounding box as repaint rect is just used for invalidation. * LayoutTests/svg/masking/masker-mixing-repaint-rect-and-bounding-box-expected.html: Added. * LayoutTests/svg/masking/masker-mixing-repaint-rect-and-bounding-box.html: Added. * Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp: (WebCore::RenderSVGResourceMasker::applyMask): * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceGradient.cpp: (WebCore::createMaskAndSwapContextForTextGradient): (WebCore::clipToTextMask): * Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceMasker.cpp: (WebCore::LegacyRenderSVGResourceMasker::applyResource): Canonical link: https://commits.webkit.org/282651@main Canonical link: https://commits.webkit.org/282416.60@webkitglib/2.46
1 parent 13903c3 commit 37b2a5a

File tree

5 files changed

+48
-4
lines changed

5 files changed

+48
-4
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<style>
2+
.line {
3+
overflow: visible;
4+
stroke: red;
5+
}
6+
</style>
7+
8+
<svg class="line" style="top: 50px; left: 50px;">
9+
<g>
10+
<path
11+
d="M3,440.1129 C191,-140.0679 270,-141.36806 240,436.2124"
12+
stroke-linecap="butt" stroke-width="8" fill="none"
13+
/>
14+
</g>
15+
</svg>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<meta name="fuzzy" content="maxDifference=0-70; totalPixels=0-401" />
2+
<style>
3+
.line {
4+
overflow: visible;
5+
stroke: red;
6+
}
7+
</style>
8+
9+
<svg class="line" style="top: 50px; left: 50px;">
10+
<defs>
11+
<mask id="__id121" maskUnits="userSpaceOnUse" x="-8" y="-8" width="266" height="457">
12+
<rect x="-8" y="-8" width="266" height="457" fill="white"/>
13+
</mask>
14+
</defs>
15+
<g>
16+
<path mask="url(#__id121)"
17+
d="M3,440.1129 C191,-140.0679 270,-141.36806 240,436.2124"
18+
stroke-linecap="butt" stroke-width="8" fill="none"
19+
/>
20+
</g>
21+
</svg>

Source/WebCore/rendering/svg/RenderSVGResourceMasker.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ void RenderSVGResourceMasker::applyMask(PaintInfo& paintInfo, const RenderLayerM
9797
if (!coordinateSystemOriginTranslation.isZero())
9898
context.translate(coordinateSystemOriginTranslation);
9999

100-
auto repaintBoundingBox = targetRenderer.repaintRectInLocalCoordinates();
100+
// FIXME: This needs to be bounding box and should not use repaint rect.
101+
// https://bugs.webkit.org/show_bug.cgi?id=278551
102+
auto repaintBoundingBox = targetRenderer.repaintRectInLocalCoordinates(RepaintRectCalculation::Accurate);
101103
auto absoluteTransform = context.getCTM(GraphicsContext::DefinitelyIncludeDeviceScale);
102104

103105
auto maskColorSpace = DestinationColorSpace::SRGB();

Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceGradient.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ static inline bool createMaskAndSwapContextForTextGradient(GraphicsContext*& con
6363
ASSERT(textRootBlock);
6464

6565
AffineTransform absoluteTransform = SVGRenderingContext::calculateTransformationToOutermostCoordinateSystem(*textRootBlock);
66-
FloatRect repaintRect = textRootBlock->repaintRectInLocalCoordinates();
66+
// FIXME: This needs to be bounding box and should not use repaint rect.
67+
// https://bugs.webkit.org/show_bug.cgi?id=278551
68+
FloatRect repaintRect = textRootBlock->repaintRectInLocalCoordinates(RepaintRectCalculation::Accurate);
6769

6870
// Ignore 2D rotation, as it doesn't affect the size of the mask.
6971
FloatSize scale(absoluteTransform.xScale(), absoluteTransform.yScale());
@@ -90,7 +92,9 @@ static inline AffineTransform clipToTextMask(GraphicsContext& context, RefPtr<Im
9092

9193
AffineTransform absoluteTransform = SVGRenderingContext::calculateTransformationToOutermostCoordinateSystem(*textRootBlock);
9294

93-
targetRect = textRootBlock->repaintRectInLocalCoordinates();
95+
// FIXME: This needs to be bounding box and should not use repaint rect.
96+
// https://bugs.webkit.org/show_bug.cgi?id=278551
97+
targetRect = textRootBlock->repaintRectInLocalCoordinates(RepaintRectCalculation::Accurate);
9498

9599
// Ignore 2D rotation, as it doesn't affect the size of the mask.
96100
FloatSize scale(absoluteTransform.xScale(), absoluteTransform.yScale());

Source/WebCore/rendering/svg/legacy/LegacyRenderSVGResourceMasker.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ auto LegacyRenderSVGResourceMasker::applyResource(RenderElement& renderer, const
6868

6969
MaskerData* maskerData = m_masker.get(renderer);
7070
AffineTransform absoluteTransform = SVGRenderingContext::calculateTransformationToOutermostCoordinateSystem(renderer);
71-
FloatRect repaintRect = renderer.repaintRectInLocalCoordinates();
71+
// FIXME: This needs to be bounding box and should not use repaint rect.
72+
// https://bugs.webkit.org/show_bug.cgi?id=278551
73+
FloatRect repaintRect = renderer.repaintRectInLocalCoordinates(RepaintRectCalculation::Accurate);
7274

7375
// Ignore 2D rotation, as it doesn't affect the size of the mask.
7476
FloatSize scale(absoluteTransform.xScale(), absoluteTransform.yScale());

0 commit comments

Comments
 (0)