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

Commit fd94c86

Browse files
authored
Fix for firefox custom clipping (#22182)
1 parent f81bc37 commit fd94c86

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/web_ui/lib/src/engine/util.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,17 @@ String _pathToSvgClipPath(ui.Path path,
333333
sb.write('<defs>');
334334

335335
final String clipId = 'svgClip$_clipIdCounter';
336-
sb.write('<clipPath id=$clipId clipPathUnits="objectBoundingBox">');
337336

338-
sb.write('<path transform="scale($scaleX, $scaleY)" fill="#FFFFFF" d="');
337+
if (browserEngine == BrowserEngine.firefox) {
338+
// Firefox objectBoundingBox fails to scale to 1x1 units, instead use
339+
// no clipPathUnits but write the path in target units.
340+
sb.write('<clipPath id=$clipId>');
341+
sb.write('<path fill="#FFFFFF" d="');
342+
} else {
343+
sb.write('<clipPath id=$clipId clipPathUnits="objectBoundingBox">');
344+
sb.write('<path transform="scale($scaleX, $scaleY)" fill="#FFFFFF" d="');
345+
}
346+
339347
pathToSvg(path as SurfacePath, sb, offsetX: offsetX, offsetY: offsetY);
340348
sb.write('"></path></clipPath></defs></svg');
341349
return sb.toString();

0 commit comments

Comments
 (0)