Skip to content

Commit

Permalink
fix: svg res work error in <img> tag
Browse files Browse the repository at this point in the history
  • Loading branch information
yifei8 committed Apr 11, 2024
1 parent bcffdf3 commit 48b3d85
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions webf/lib/src/svg/svg_render_object_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ class SVGRenderBoxBuilder {
.toDartString(length: element.original_tag.length)
.toUpperCase();
final renderBox = getSVGRenderBox(tagName);

if (renderBox == null) {
return false;
}
final attributes = element.attributes;
for (int i = 0; i < attributes.length; i++) {
final attr = attributes.data[i] as Pointer<NativeGumboAttribute>;
Expand All @@ -99,7 +101,7 @@ class SVGRenderBoxBuilder {
return rootRenderObject as RenderBoxModel;
}

RenderBoxModel getSVGRenderBox(String tagName) {
RenderBoxModel? getSVGRenderBox(String tagName) {
final Constructor = svgElementsRegistry[tagName];
if (Constructor != null) {
final element = Constructor(null);
Expand All @@ -110,6 +112,14 @@ class SVGRenderBoxBuilder {
}
element.tagName = tagName;
element.namespaceURI = SVG_ELEMENT_URI;
/// These tags are only for setting properties and do not need to participate in time rendering.
/// Such tags do not require renderBoxModel.
if (tagName == TAG_DEFS ||
tagName == TAG_LINEAR_GRADIENT ||
tagName == TAG_STOP ||
tagName == TAG_CLIP_PATH) {
return null;
}
element.createRenderer();
return element.renderBoxModel!;
}
Expand Down

0 comments on commit 48b3d85

Please sign in to comment.