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

[web] Fix for firefox custom clipping #22182

Merged
merged 2 commits into from
Oct 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/web_ui/lib/src/engine/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,17 @@ String _pathToSvgClipPath(ui.Path path,
sb.write('<defs>');

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

sb.write('<path transform="scale($scaleX, $scaleY)" fill="#FFFFFF" d="');
if (browserEngine == BrowserEngine.firefox) {
// Firefox objectBoundingBox fails to scale to 1x1 units, instead use
// no clipPathUnits but write the path in target units.
sb.write('<clipPath id=$clipId>');
sb.write('<path fill="#FFFFFF" d="');
} else {
sb.write('<clipPath id=$clipId clipPathUnits="objectBoundingBox">');
sb.write('<path transform="scale($scaleX, $scaleY)" fill="#FFFFFF" d="');
}

pathToSvg(path as SurfacePath, sb, offsetX: offsetX, offsetY: offsetY);
sb.write('"></path></clipPath></defs></svg');
return sb.toString();
Expand Down