Better fix for SVG rendering issues when redrawing complex graphics. Thanks tschaub for the investigation and the original patch which pointed me into the right direction. r=tschaub (pullup #2101)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@9405 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2009-05-21 22:02:05 +00:00
parent 52a4d4f8cc
commit 2bf02bda35

View File

@@ -291,23 +291,28 @@ OpenLayers.Renderer.SVG = OpenLayers.Class(OpenLayers.Renderer.Elements, {
var href = "#" + id; var href = "#" + id;
pos = this.getPosition(node); pos = this.getPosition(node);
widthFactor = this.symbolSize[id] / size; widthFactor = this.symbolSize[id] / size;
// Only set the href if it is different from the current one.
// This is a workaround for strange rendering behavior in FF3. // remove the node from the dom before we modify it. This
if (node.getAttributeNS(this.xlinkns, "href") != href) { // prevents various rendering issues in Safari and FF
node.setAttributeNS(this.xlinkns, "href", href); var parent = node.parentNode;
} else if (size != parseFloat(node.getAttributeNS(null, "width"))) { var nextSibling = node.nextSibling;
// hide the element (and force a reflow so it really gets if(parent) {
// hidden. This workaround is needed for Safari. parent.removeChild(node);
node.style.visibility = "hidden";
this.container.scrollLeft = this.container.scrollLeft;
} }
node.setAttributeNS(this.xlinkns, "href", href);
node.setAttributeNS(null, "width", size); node.setAttributeNS(null, "width", size);
node.setAttributeNS(null, "height", size); node.setAttributeNS(null, "height", size);
node.setAttributeNS(null, "x", pos.x - offset); node.setAttributeNS(null, "x", pos.x - offset);
node.setAttributeNS(null, "y", pos.y - offset); node.setAttributeNS(null, "y", pos.y - offset);
// set the visibility back to normal (after the Safari
// workaround above) // now that the node has all its new properties, insert it
node.style.visibility = ""; // back into the dom where it was
if(nextSibling) {
parent.insertBefore(node, nextSibling);
} else if(parent) {
parent.appendChild(node);
}
} else { } else {
node.setAttributeNS(null, "r", style.pointRadius); node.setAttributeNS(null, "r", style.pointRadius);
} }