W3C home > Mailing lists > Public > www-svg@w3.org > January 2006

Re: [SVGMobile12] SVGT12-207: Conformance to uDOM

From: Jeff Schiller <codedread@gmail.com>
Date: Tue, 3 Jan 2006 12:17:54 -0600
Message-ID: <da131fde0601031017o47a3621eofc31b5fa6e46fc31@mail.gmail.com>
To: Ian Hickson <ian@hixie.ch>, www-svg@w3.org

On 1/3/06, Ian Hickson <ian@hixie.ch> wrote:
> On Tue, 3 Jan 2006, Jeff Schiller wrote:
> > >
> > > In addition, please make it clear that implementations that include
> > > full DOM Level 3 Core and DOM Level 2 Style implementations do not
> > > have to implement the "trait" APIs, since they are redundant with the
> > > aforementioned specs.
> >
> > It's likely that I'm not understanding you correctly, but don't the
> > trait APIs provide significant advantage over the aforementioned specs?
> > Specifically dealing with "native" data types and computed values
> > instead of strings that require additional processing/computation?
>
> Not insofar as I can tell. Could you give an example of trait use that
> wouldn't be better handled by existing DOM technologies?
>
> --

Ian, I guess what I'm saying is that I'm not an expert in existing DOM
technologies or EcmaScript, so I was hoping you (or others) could shed
some light for me.  From what I understand though, here it is (and
this may not be perfect SVG, but to give the idea):

<svg ...>
<g xml:id="button" fill="rgb(200,0,0)">
  <rect xml:id="shadow" x="7" y="7" width="5" height="5" fill="grey" />
  <rect xml:id="buttonSurface" fill="inherit" x="5" y="5" width="5" height="5"/>
</g>
</svg>

With uDOM:

function highlightButton(bHighlight) {
  var nHighlight = (bHighlight ? : 20 : -20);
  var ele = document.getElementById("buttonSurface");
  var color = ele.getRGBColorTraitNS(null, "fill");
  color.red += nHighlight;
  color.green += nHighlight;
  color.blue += nHighlight;
  ele.setRGBColorTraitNS(null, "fill", color);
}

With existing DOM:

function highlightButton(bHighlight) {
  var nHighlight = (bHighlight ? : 20 : -20);
  var ele = document.getElementById("buttonSurface");

  // walk up the tree until we get the actual fill color string
  // realistically this would probably be more complicated than what I've shown
  var colorStr = "inherit";
  while( (colorStr = ele.getAttributeNS(null, "fill")) == "inherit") {
ele = ele.parentNode; }

  // parse the string to extract red, green, blue substrings
  // realistically it would be more complicated than what I've shown,
you'd have to
  // handle varying color formats ("#rrggbb", "#RGB", "rgb(r,g,b)", etc)
  var splitArr = colorStr.split(",");
  var red = parseInt( splitArr[0].substr(4) ) + nHighlight;
  var green = parseInt( splitArr[1] ) + nHighlight;
  var blue = parseInt( splitArr[2] ) + nHighlight;

  ele.setAttributeNS(null, "fill", "rgb(" + red + "," + green + "," +
blue + ")");
}

Anyway, I hope to be proven wrong so that I can use more efficient and
existing DOM technologies today instead of all this parsing of DOM
strings and walking of the DOM tree or waiting for SVGT 1.2...

Thanks,
Jeff
Received on Tuesday, 3 January 2006 18:18:04 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:33 GMT