Closed Bug 575510 Opened 15 years ago Closed 14 years ago

importNode(svgnode) bug? hidden the SVG and wait one minute(more or less), then showing, the image and link will disappear, if do "document.importNode(svgRoot, true)" twice ,it will be OK

Categories

(Core :: SVG, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: no-sand, Unassigned)

Details

(Whiteboard: qawanted)

Attachments

(1 file)

User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; zh-CN; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 Build Identifier: Mozilla/5.0 <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>importNode(svgnode) bug Test</title> <script type="text/javascript"> // <![CDATA[ function loadSVG(canvas, data){ var doc = (new DOMParser()).parseFromString(data, 'text/xml'); var svgRoot = doc.documentElement; svgRoot = document.importNode(svgRoot, true); //if I do 'document.importNode(svgRoot, true)' twice ,it will be OK //svgRoot = document.importNode(svgRoot, true); canvas.appendChild(svgRoot); return svgRoot; } var data = '<svg boxid="null" width="485" height="400" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" zoomAndPan="disable" subnetworkId="defaultSubnetwork" twaverlicense="1" twaverinformation="Powered by TWaver" CSNID="null"><defs><path id="d_240" d="M16 16 L16 96 "/><path id="d_242" d="M96 16 L96 96 "/><image id="img_1" width="32" height="32" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAdCAYAAADCdc79AAAAbklEQVR42mNIS0v7P5gwA4h49uwZVkxIbvfu3VjxkiVLyJJDcRAuBfjkRo6DyMUgw6mJR9PQqINo4qD/DIY4HYQuNzIdNOiijGHOHJwOQpcbmQ4ajbLRKKOlgwZdCI1G2aiDRtvUo23q0TQ0ABgA4S43kYg9qoYAAAAASUVORK5CYII="/></defs><g font-family="SimSun" font-size="12" stroke-width="1" stroke-miterlimit="10" stroke-linejoin="round" stroke-linecap="butt" stroke-dashoffset="0" image-rendering="optimizeSpeed" transform="matrix(1, 0, 0, 1, 0, 0)"><rect x="0" y="0" width="100%" height="100%" fill="rgb(204,204,255)" CSNID="null"/><g id="11d1def534ea1be0:6af35c9d:1298157973c:-7ff4" elementResizable="true" elementClass="SubNetwork" bx="242" by="221" bwidth="87" bheight="44" bcolor="rgb(91,91,91)"><use xlink:href="#img_1" x="200" y="200"/></g><g id="11d1def534ea1be0:6af35c9d:1298157973c:-7ff1" elementMovable="false" elementClass="Link" link-expand="t" bx="16" by="56" bwidth="2" bheight="82" bcolor="rgb(91,91,91)"><use xlink:href="#d_240" visibility="hidden" pointer-events="none" fill="none" stroke="rgb(91,91,91)" stroke-width="6"/><use xlink:href="#d_240" fill="none" stroke="rgb(125,125,125)" stroke-width="4"/><use xlink:href="#d_240" fill="none" stroke="rgb(180,180,180)" stroke-width="3"/></g><g id="11d1def534ea1be0:6af35c9d:1298157973c:-7ff3" tooltip="node_0_0" bx="16" by="16" bwidth="34" bheight="34" bcolor="rgb(91,91,91)"><use xlink:href="#img_1" x="0" y="0"/><text fill="rgb(0,0,0)" x="-14" y="46" font-family="Lucida Grande" font-size="13" font-weight="normal">node_0_0</text></g><g id="11d1def534ea1be0:6af35c9d:1298157973c:-7ff2" tooltip="node_0_1" bx="16" by="96" bwidth="34" bheight="34" bcolor="rgb(91,91,91)"><use xlink:href="#img_1" x="0" y="80"/><text fill="rgb(0,0,0)" x="-14" y="126" font-family="Lucida Grande" font-size="13" font-weight="normal">node_0_1</text></g><g id="11d1def534ea1be0:6af35c9d:1298157973c:-7fee" elementMovable="false" elementClass="Link" link-expand="t" bx="96" by="56" bwidth="2" bheight="82" bcolor="rgb(91,91,91)"><use xlink:href="#d_242" visibility="hidden" pointer-events="none" fill="none" stroke="rgb(91,91,91)" stroke-width="6"/><use xlink:href="#d_242" fill="none" stroke="rgb(125,125,125)" stroke-width="4"/><use xlink:href="#d_242" fill="none" stroke="rgb(180,180,180)" stroke-width="3"/></g><g id="11d1def534ea1be0:6af35c9d:1298157973c:-7ff0" tooltip="node_1_0" bx="96" by="16" bwidth="34" bheight="34" bcolor="rgb(91,91,91)"><use xlink:href="#img_1" x="80" y="0"/><text fill="rgb(0,0,0)" x="66" y="46" font-family="Lucida Grande" font-size="13" font-weight="normal">node_1_0</text></g><g id="11d1def534ea1be0:6af35c9d:1298157973c:-7fef" tooltip="node_1_1" bx="96" by="96" bwidth="34" bheight="34" bcolor="rgb(91,91,91)"><use xlink:href="#img_1" x="80" y="80"/><text fill="rgb(0,0,0)" x="66" y="126" font-family="Lucida Grande" font-size="13" font-weight="normal">node_1_1</text></g></g><g pointer-events="none"/></svg>'; var canvas; function init(){ canvas = document.getElementById('left'); loadSVG(canvas, data); //do this ,because a other bug, //Bug 575210 - SVG <use xlink:href='#img_1' x='96' y='74'/> ,The Image does not appear for the first time, need reload the page, in firefox3.5 is OK setTimeout(function(){ canvas.removeChild(canvas.firstChild); loadSVG(canvas, data); }, 200); } function show(){ if(canvas.style.display != 'none'){ canvas.style.display = 'none'; }else{ canvas.style.display = null; } } // ]]></script> </head> <body onload = 'init();'> hidden the SVG and wait one minute(more or less), then showing, the image and link will disappear,<br /> if do "document.importNode(svgRoot, true)" twice ,it will be OK <div id='toolbar' style = 'position: relative; background-color: #EEEEEE; border: 1px solid #00FF00;' > <button onclick='show();'>show/hidden</button> </div> <div id='left' style='overflow : auto; position: absolute; top:65px; width : 500px; height : 300px; border: 1px solid #FF0000;' width='500px' ></div> </body> </html> Reproducible: Always Steps to Reproduce: 1. hidden the SVG 2. wait one minute(or more) 3. then showing 4. the image and link in SVG will disappear if do "document.importNode(svgRoot, true)" twice ,it will be OK
Can you use the attachment button above to attach your testcase rather than pasting it inline into the bug please?
Attached file importNode test
1. hidden the SVG 2. wait one minute(or more) 3. then showing 4. the image and link in SVG will disappear if do "document.importNode(svgRoot, true)" twice ,it will be OK
Why is this different to bug 575210. I.e. a <use> with an image is not displayed properly.
bug 575210 is only image not display for the first time, this problem is all image and path disappear only text left, and if I do "document.importNode(svgRoot, true)" twice ,it will be OK Steps to Reproduce: 1. hidden the SVG (click the 'Show/Hidden' button) 2. wait one minute(or more) 3. then showing (click the 'Show/Hidden' button) 4. the image and link in SVG will disappear I load SVG by this way: function loadSVG(canvas, data){ var doc = (new DOMParser()).parseFromString(data, 'text/xml'); var svgRoot = doc.documentElement; svgRoot = document.importNode(svgRoot, true); //if I do 'document.importNode(svgRoot, true)' twice ,it will be OK //svgRoot = document.importNode(svgRoot, true); canvas.appendChild(svgRoot); return svgRoot; } Show and hidden as follow: function show(){ if(canvas.style.display != 'none'){ canvas.style.display = 'none'; }else{ canvas.style.display = null; } }
This bug could really use a sane deobfuscated testcase... Ideally with the smallest SVG file that shows the problem.
Whiteboard: qawanted
I can see the bug in Firefox 7, but the testcase works for me, using: 10.0a1 (2011-10-02), so I'll mark the bug as worksforme.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: