Friday, 28 July 2006

SVG implementations and DOM support (Continued)

Now, what seems a fairly innocuous method turns out to be really rather important. The method I'm talking about is getComputedStyle().

Depending upon the client your running this could be a method of the window object (HTML browsers) or more officially it is a method of the document's defaultView. An example:


initialValue = contextNode.ownerDocument.defaultView.
getComputedStyle(contextNode, '').
getPropertyValue('visibility');


The above example gets the current value of the visibility style property of the context node. If you stop short and just get the computed style object, you will receive yards and yards of style properties that play a part in the styling of the context node. Which is great if, for example, you are creating a debugging tool like FireBug for the FireFox browser. Which I might add is seriously cool and if you don't have it then your missing-out.

Now there are a number of uses you can put getComputedStyle() to, one example is when creating a JavaScript implementation of the Synchronized Multimedia Integration Language (SMIL). You need it when setting-up the initial values of style properties you are about to animate.

There are some other ideas that I've had that could use this in relation to SVG. But , guess what?
The Adobe SVG Viewer 3 doesn't support getComputedStyle().

Grrrrrr!

3 comments:

  1. Can't you use a different SVG viewer then? Opera, Batik, Firefox, Webkit, etc.

    ReplyDelete
  2. Oh I most certainly will use a different viewer for one of the things I plan to do. However, what with getComputedStyle() being so useful, I felt it worth pointing-out this as a fundamental flaw in ASV3 (Adobe SVG Viewer 3) that has otherwise been the flagship SVG viewer.
    This kind-of short coming is reminiscent of the early (D)HTML browser wars. Now that web browsers are more or less on an even playing field I'd hate to see the lessons learnt there being lost on the SVG community. Up until I encountered this problem I was feeling confident, but now only time will tell.

    ReplyDelete
  3. I feel the whole idea of standards is better understood these days.
    There are however still some problems, but they seem to get fixed quicker.
    The community can help, by providing feedback.
    Direct feedback to viewer implementors, and preferably with workaround to the community

    ReplyDelete