problem loading a raster image inside a SVG fragment loaded with XMLHttpRequest()

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

problem loading a raster image inside a SVG fragment loaded with XMLHttpRequest()

Andreas Neumann
Hi,

I have a problem loading a raster image which is loaded as part of a
SVG fragment which is added to the DOM using XMLHttpRequest() - I am
refering to http://www.carto.net/neumann/geovite/

Within the map navigation window there should appear a small relief
(http://www.carto.net/neumann/geovite/relief.jpg) - the SVG fragment
that contains the raster image is at
http://www.carto.net/neumann/geovite/referenceMap.svg - it works in
Batik and ASV (using the getURL equivalence)

After the script loaded the fragment, it correctly appears in the DOM
(I can see it in the DOM viewer FF extension) - any vector elements
that I added to the fragment for testing showed up, but the raster
image isn't displayed. I initially thought it might be a namespace
isssue - but I think I correctly declared the namespaces on the
fragment.

Any idea why the raster image does not show up?

If the example is too complex I will create a smaller example
illustrating the problem.

Thanks for any ideas,

Andreas

_______________________________________________
Mozilla-svg mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-svg
Reply | Threaded
Open this post in threaded view
|

Re: problem loading a raster image inside a SVG fragment loaded with XMLHttpRequest()

Boris Zbarsky
Andreas Neumann wrote:
> Any idea why the raster image does not show up?

Because images are not loaded for "data" documents (eg the ones XMLHttpRequest
produces) and nsSVGImageElement doesn't bother to try reloading the image when
its document changes.

It should be doing what nsHTMLImageElement does, which is attempting to load in
BindToTree (needed anyway for being anywhere close to working right with xml:base).

I suggest filing a bug on this.  ;)

-Boris
_______________________________________________
Mozilla-svg mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-svg
Reply | Threaded
Open this post in threaded view
|

Re: problem loading a raster image inside a SVG fragment loaded with XMLHttpRequest()

Jonathan Watt-2
In reply to this post by Andreas Neumann
Andreas Neumann wrote:
> Within the map navigation window there should appear a small relief
> (http://www.carto.net/neumann/geovite/relief.jpg) - the SVG fragment
> that contains the raster image is at
> http://www.carto.net/neumann/geovite/referenceMap.svg - it works in
> Batik and ASV (using the getURL equivalence)

Which JS file loads referenceMap.svg?
_______________________________________________
Mozilla-svg mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-svg
Reply | Threaded
Open this post in threaded view
|

Re: problem loading a raster image inside a SVG fragment loaded with XMLHttpRequest()

Andreas Neumann
Thanks, Boris and Jonathan for answering,

two script files are involved:

data loading is triggered in:
http://www.carto.net/neumann/geovite/initMap.js (lines 434 and 435)

the getXMLData() object resides in
http://www.carto.net/neumann/geovite/helper_functions.js (line 413ff)

after the data is received, the function refDataAppend() in initMap.js
(lines 495 ff) appends the data to the DOM.

I tested the getXMLData() method in other projects and it works for SVG
elements, excl. the image element I have a problem with.

------------

If this is actually a bug, I will create a simpler test case and file a
bug in bugzilla.

Andreas

_______________________________________________
Mozilla-svg mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-svg
Reply | Threaded
Open this post in threaded view
|

Re: problem loading a raster image inside a SVG fragment loaded with XMLHttpRequest()

Jonathan Watt-2
Andreas Neumann wrote:
> Thanks, Boris and Jonathan for answering,
>
> two script files are involved:
>
> data loading is triggered in:
> http://www.carto.net/neumann/geovite/initMap.js (lines 434 and 435)
>
> the getXMLData() object resides in
> http://www.carto.net/neumann/geovite/helper_functions.js (line 413ff)

Thanks.

> after the data is received, the function refDataAppend() in initMap.js
> (lines 495 ff) appends the data to the DOM.
>
> I tested the getXMLData() method in other projects and it works for SVG
> elements, excl. the image element I have a problem with.

You can work around this by forcing the image to be loaded by setting the
xlink:href attribute after the SVGImageElement has been inserted into the
document. Something like the following:

var XLink_NS = 'http://www.w3.org/1999/xlink';

function refDataAppend(node) {
        var refMapSVG = myMapApp.refMapDragger.myRefMap;
        refMapSVG.insertBefore(node,refMapSVG.firstChild.nextSibling);

        // Fx 1.5 doesn't load images for "data" documents (eg the ones
        // XMLHttpRequest produces), so force it to by setting xlink:href
        var image = refMapSVG.firstChild.nextSibling.firstChild.nextSibling;
        var url = image.getAttributeNS(XLink_NS, 'href');
        image.setAttributeNS(XLink_NS, 'href', url);
}

> If this is actually a bug, I will create a simpler test case and file a
> bug in bugzilla.

Yes, that would be great, thanks.

Jonathan
_______________________________________________
Mozilla-svg mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-svg
Reply | Threaded
Open this post in threaded view
|

Re: problem loading a raster image inside a SVG fragment loaded with XMLHttpRequest()

Boris Zbarsky
Jonathan Watt wrote:
>     var url = image.getAttributeNS(XLink_NS, 'href');
>     image.setAttributeNS(XLink_NS, 'href', url);

Er... that does something?  It shouldn't have any effect...

-Boris
_______________________________________________
Mozilla-svg mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-svg
Reply | Threaded
Open this post in threaded view
|

Re: problem loading a raster image inside a SVG fragment loaded with XMLHttpRequest()

Hugh Saalmans
Hi Guys,

I hit this in June - there's a bug that prevents the images from being
displayed when you've added image elements to the SVG DOM from an
XmlHttpRequest response.

https://bugzilla.mozilla.org/show_bug.cgi?id=296018

Cheers,
Hugh

_______________________________________________
Mozilla-svg mailing list
[hidden email]
http://mail.mozilla.org/listinfo/mozilla-svg