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

[web] use typed SVG API#29481

Merged
yjbanov merged 1 commit intoflutter:mainfrom
yjbanov:typed-svg
Nov 23, 2021
Merged

[web] use typed SVG API#29481
yjbanov merged 1 commit intoflutter:mainfrom
yjbanov:typed-svg

Conversation

@yjbanov
Copy link
Contributor

@yjbanov yjbanov commented Nov 2, 2021

  • Use typed SVG API instead of SVG strings for compatibility with TrustedTypes.
  • Remove NullTreeSanitizer.

Fixes b/198428641

@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label Nov 2, 2021
@google-cla google-cla bot added the cla: yes label Nov 2, 2021
@yjbanov yjbanov force-pushed the typed-svg branch 2 times, most recently from 2aaa28e to 4055fc6 Compare November 2, 2021 19:57
@CaseyHillers CaseyHillers changed the base branch from master to main November 15, 2021 18:13
@yjbanov yjbanov force-pushed the typed-svg branch 2 times, most recently from 3b92e32 to 52793e1 Compare November 20, 2021 02:13
@yjbanov yjbanov changed the base branch from master to main November 20, 2021 02:15
@yjbanov yjbanov force-pushed the typed-svg branch 3 times, most recently from 0e52f39 to 6d59b23 Compare November 20, 2021 03:16
@yjbanov yjbanov marked this pull request as ready for review November 20, 2021 03:47
Copy link
Contributor

@harryterkelsen harryterkelsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines -479 to -485
/// Sanitizer used to convert const svg filter and clippath snippets to
/// SvgElement without sanitization.
class NullTreeSanitizer implements html.NodeTreeSanitizer {
@override
void sanitizeTree(html.Node node) {}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

const int SVG_FEBLEND_MODE_COLOR = 15;
const int SVG_FEBLEND_MODE_LUMINOSITY = 16;

// Source: https://osscs.corp.google.com/chromium/chromium/src/+/main:third_party/blink/renderer/platform/graphics/graphics_types.cc;l=55;drc=59bdabfb96e4c7a0de476b24c34ff197d1fa2ce4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this link accessible from outside Google?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Done.

Comment on lines 1220 to 1221
/// * https://osscs.corp.google.com/chromium/chromium/src/+/main:third_party/blink/renderer/platform/graphics/graphics_types.cc;l=55;drc=59bdabfb96e4c7a0de476b24c34ff197d1fa2ce4
/// * https://osscs.corp.google.com/chromium/chromium/src/+/main:third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.cc;l=725;drc=59bdabfb96e4c7a0de476b24c34ff197d1fa2ce4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

svgPath.setAttribute('fill', 'none');
} else if (paint.color != null) {
sb.write('fill="${colorToCssString(color)}" ');
svgPath.setAttribute('fill', '${colorToCssString(color)}');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
svgPath.setAttribute('fill', '${colorToCssString(color)}');
svgPath.setAttribute('fill', colorToCssString(color));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

sb.write('stroke="${colorToCssString(color)}" ');
sb.write('stroke-width="${paint.strokeWidth ?? 1.0}" ');
sb.write('fill="none" ');
svgPath.setAttribute('stroke', '${colorToCssString(color)}');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
svgPath.setAttribute('stroke', '${colorToCssString(color)}');
svgPath.setAttribute('stroke', colorToCssString(color));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants