SVG in Mozilla

News / Latest Builds / Samples and Screenshots / Source Code / FAQ


News

13th September 2001

12th September 2001

06th September 2001

I was quite busy recently with moving house, trying to finish off our Mozilla-based CrocodileMaths, etc., so unfortunately it's been a while since the last update. Quite a few things have happened in the last few weeks:

20th July 2001

19th July 2001

16th July 2001

8th June 2001

11th May


Latest Builds

If you are hosting a build for any platform, please let me know!

SVG samples and screenshots

If you've got the patched browser, these should all work directly from this webpage. In IE you'll just see the source code. You can click on the thumbnail to get a screenshot.
polygons1.xml Simple stroked and filled regular polygons. Modified W3 sample
polygons2.xml Basically the same as the polygons1 sample, but made dynamic with the CSS :hover pseudo-class.
polygons3.xml Polygons with transparency and CSS :hover pseudo-classes and attribute selectors. Illustrates a Libart redraw bug.
opacity1.xml Dynamically constructed polygons with script animation and CSS-determined opacity (:hover)
opacity2.xml Two overlapping polygons with dynamic CSS-determined opacity and stroke.
dom1.xml Script-based animation of a triangle by direct manipulation of DOM properties (as opposed to attributes).
dom2.xml Illustration of the SVGTransformList and SVGTransform DOM interfaces. Note that the SVGTransformList::Consolidate() function is not implemented yet, so clicking the Consolidate-button has no effect.
circles1.xml Simple stroked and filled circle. (Modified W3 sample)
circles2.xml Filled circles with :hover-dependent opacity
lion.xml A lion made up of polygons. Nicked from Steve Bowen's site
butterfly.xml Butterfly made up of cubic splines. Taken from JASC's WebDraw
events1.xml Demonstrates simple mousedown event handlers on svg elements.
events2.xml Drag an SVG circle around on the screen.
circles3.xml Essentially the same as circles2.xml, but with a background image (using <foreignObject>).
Note: This sample is not valid svg! The <foreignObject>-tag is used in a way not allowed by the svg dtd.
tiger.xml The famous tiger, made from cubic spline <path>s
xbl1.xml Interactively moveable transparent XBL/SVG triangles. CSS: xbl1-bindings.css, XBL: xbl1-bindings.xml
xbl2.xml Same as xbl1.xml but with a background image. CSS: xbl1-bindings.css, XBL: xbl1-bindings.xml.
Note: This sample is not valid svg! The <foreignObject>-tag is used in a way not allowed by the svg dtd.
xbl-shapes.xml Moveable/Resizeable XBL/SVG triangles and cubic splines. CSS: xbl-shape-bindings.css, XBL: xbl-shape-bindings.xml
foreign1.xml HTML and XUL mixed with SVG using <foreignObject>.
Note: This sample is not valid svg! The <foreignObject>-tag is used in a way not allowed by the svg dtd.
style1.xml Very simple example of changing style attribute through JS.
paths1.xml Examples of <path>s with l, L, h, H, v and V commands.
Note: This sample is not valid svg! The <foreignObject>-tag is used in a way not allowed by the svg dtd.
paths2.xml Examples of <path>s with c, C, s and S commands.
Note: This sample is not valid svg! The <foreignObject>-tag is used in a way not allowed by the svg dtd.
paths3.xml Examples of <path>s with elliptical arc segments (a, A commands). Adapted from a W3 sample.
Note: This sample is not valid svg! The <foreignObject>-tag is used in a way not allowed by the svg dtd.
arcs1.xml Ellipses built using <path>s, generated by script.
chem1.xml A structural diagram 'stolen' with permission from Henry S. Rzepa's and Peter Murray-Rust's Chemical Examples of SVG and CML (Chemical Markup Language)
chem2.xml chem1.xml + 8x zoom
adrenalin.xml
diazepam.xml
glutamate.xml
mols3.xml
These samples are CML (chemical markup language) files, made to render using XBL and SVG. The original files are from www.xml-cml.org. Implementation files: cml.css and cml-bindings.xml.
line01.xml Examples of <line> elements with different stroke-linecap styles and stroke-widths.
rect01.xml
rect02.xml
Examples of <rect> elements.
ellipse01.xml Examples of <ellipse> elements.
xbl-shapes2.xml Interactive shapes, same as xbl-shapes, but with different 'stroke-dasharray' styles applied. Note that currently the dasharray needs to be enclosed in inverted commas. This needs to be fixed. CSS: xbl-shape-bindings.css, XBL: xbl-shape-bindings.xml
skew01.xml Examples of skew transformations.
quadbezier01.xml Examples of the quadratic bezier path commands. (Modified w3c sample by Daniele Nicolodi.)
linestroke.xml Illustration of the different stroking styles for lines. Sample by Andrea Salmasso.

Old Screenshots


Source code

I have filed a bug on getting the SVG code into cvs.mozilla.org. There (bug #80142) you can find discussions about the svg code and dependent bugs. Now that Bradley has put all the code on a cvs branch in the mozilla.org repository, the patches attached to that bug aren't up to date anymore. If you are interested in getting and building the source, you can check it out from cvs directly. The branch tag is 'SVG_20010721_BRANCH'. This is a mini-branch, so not all files are tagged and you need to ensure you pull the HEAD-revision when a file is not tagged. The best way to do this is to checkout a branch version of client.m(a)k :
cvs checkout -r SVG_20010721_BRANCH mozilla/client.m(a)k
and let client.m(a)k do the pull.

Building Mozilla with SVG is unfortunatley still somewhat complicated, since in addition to the source code you need to apply several patches and you need to install a recent (and in the case of windows and mac: patched) version of libart. I will post instructions here soon.



FAQ

What is working so far?
Is this some sort of rival project to the official Mozilla SVG project?
No, this code was written with the intention of going into the official Mozilla SVG project. As far as I am aware, there is no other Mozilla SVG development going on at the moment. The official Mozilla SVG project homepage can be found here.
When will this code go into the Mozilla CVS repository?
Well - we have made it onto a branch in mozilla.org's cvs repository! As for getting the code onto the main trunk, it'll still need to be reviewed and there are some other issues that need to be sorted out. E.g. our rendering library (libart) is not licensed under the MPL.
You can follow the progress by cc'ing yourself to the bugzilla bug #80142.
Does it run on platform XY?
In principle, the code should be cross-platform. Libart (the rendering library we use) is known to work under Linux and Windows and Macintosh. Again, in principle it should be easy to port to other platforms.
At the moment we have Windows, Macintosh and Linux builds.
If you think you can get this code compiled on some exotic platform, then please give me a shout.
Why are you writing this code?
Here at Crocodile Clips we are actually developing a future product based on Mozilla! This product will need some basic SVG support, about as much as I have implemented so far. So from here on, anything I'll do will be purely for fun and in my spare time.
Why are you using Libart as the rendering backend?
I chose Libart because
When running the interactive samples I experience redraw problems. I see rectangular gaps in areas that should be completely filled. Why is that?
I am pretty sure that it is a libart bug. When a polygon has no intersections with the redraw area it doesn't seem to get rendered. On the plus side, this bug shows nicely that the microtile invalidation code is doing what it is supposed to :-)
Apparently this bug has now been fixed, and we're justing waiting for it to feed into libart cvs!
Why doesn't my svg file render in the patched browser?
This could be for a whole range of reasons:

13.09.2001 alex fritze
Validated & fixed by Steve Bowen. Thanks Steve!