From 1c68ec21a314de83addf1b96106ebdcef634540e Mon Sep 17 00:00:00 2001 From: zhuyifei Date: Thu, 11 Apr 2024 17:56:26 +0800 Subject: [PATCH] fix: svg res work error in tag --- webf/lib/src/svg/svg_render_object_builder.dart | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/webf/lib/src/svg/svg_render_object_builder.dart b/webf/lib/src/svg/svg_render_object_builder.dart index e86be57fbb..be82fcacfd 100644 --- a/webf/lib/src/svg/svg_render_object_builder.dart +++ b/webf/lib/src/svg/svg_render_object_builder.dart @@ -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; @@ -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); @@ -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!; }