# HG changeset patch # User wycc # Date 1300991515 -28800 # Node ID 2ebb07ee455ee87f8a0b16ad167adb112839fb9f # Parent 98ea7146cef322062632e1d747a87c560808f500 Fix the issue that we put the wrong entry for the groupMap for svg:g element. Use clone_from_subtree for the svg:use tag. diff -r 98ea7146cef3 -r 2ebb07ee455e nodejs/svg.js --- a/nodejs/svg.js Fri Mar 25 02:03:17 2011 +0800 +++ b/nodejs/svg.js Fri Mar 25 02:31:55 2011 +0800 @@ -1108,8 +1108,8 @@ this._set_bbox(n, coord); // Set the group map only it is not defined before. The group might be // redefined by the svg:use tag - if (this._groupMap[n.name()]==null) - this._groupMap[n.name()] = n; + if (this._groupMap[group_id]==undefined) + this._groupMap[group_id] = n; make_mbnames(this.mb_rt, n, coord); return coord; @@ -1157,36 +1157,7 @@ sys.puts("Can not find object "+attr.value()); return; } - nodes = n.childNodes(); - for(k in nodes) { - var c = nodes[k].name(); - var attr = nodes[k].attr('id'); - var id; - if (attr) { - id = attr.value(); - } - if (c == "g") { - this.parseGroup(accu,coord, id, nodes[k]); - } else if (c == "path") { - this.parsePath(accu,coord, id, nodes[k]); - } else if (c == "text") { - this.parseText(accu,coord, id, nodes[k]); - } else if (c == "rect") { - this.parseRect(accu_matrix,coord, id, nodes[k]); - } else if (c == "image") { - this.parseImage(accu_matrix,coord, id, nodes[k]); - } else if (c == "use") { - this.parseUse(accu_matrix,coord, id, nodes[k]); - } - attr = nodes[k].attr('duplicate-src'); - if (attr == null) continue; - id = attr.value(); - try { - this.mbnames[id].target = coord; - } catch(e) { - sys.puts("id "+id+" is not defined"); - } - } + coord.clone_from_subtree(n.coord); } if (root.center.x > coord.center.x) root.center.x = coord.center.x; @@ -1265,14 +1236,14 @@ if (tcoord.center.y > ny) tcoord.center.y = ny; var img = this.mb_rt.image_new(x,y,w,h); + sys.puts('----'+ref); var img_data = ldr.load(ref); try { - sys.puts('----'+ref); var paint = this.mb_rt.paint_image_new(img_data); paint.fill(img); } catch(e) { sys.puts(e); - sys.puts("Can not load image "+ref); + sys.puts("--Can not load image "+ref); } tcoord.add_shape(img);