SVG 1.2 Comment: 3.7 The traitDef element

Hi WG.

How are SVGLength traits resolved with regards to relative units?  For
example, with a text element, ems are resolved using that text element's
computed font-size property.

  <text x="1em" y="100" font-size="20">Some text</text>

That 1em will resolve to a different number of user units if the
font-size is changed.  Do sXBL elements just use the inherited font-size
of the containing element?

Similarly for percentage values: will these values be resolved in the
same way that percentage lengths created with createSVGLength (that is,
ones with no context) are, in the context of the current viewport?

I think it would make sense to be able to specify whether a trait is a
horizontal or vertical length, so that percentages can be resolved
usefully.  A width and height trait for a custom element would be very
common, I'd imagine.  Without a mechanism for specifying whether a
length is horizontal or vertical, handling traits with percentage values
will be cumbersome.

One way to accomplish this would be to allow two new schema datatype
URIs:

  http://www.w3.org/2000/svg#SVGLength-Horizontal
  http://www.w3.org/2000/svg#SVGLength-Vertical

which would allow the user agent to perform the relevant conversion
between percentage values and user units.  A plain SVGLength could use
the viewport percentage calculation used for SVGLength objects with no
context (sqrt((actual-width)**2 + (actual-height)**2))/sqrt(2)).

I also reiterate my desire to be able to construct SVGLength objects
with a context and direction, so that relative units can be resolved in
all the same ways that length properties on SVG elements can be.  This
could be accomplished with two additional attributes and some extra
constants on the SVGLength object:

  const unsigned short SVG_LENGTHDIRECTION_UNKNOWN = 0;
  const unsigned short SVG_LENGTHDIRECTION_HORIZONTAL = 1;
  const unsigned short SVG_LENGTHDIRECTION_VERTICAL = 2;
  attribute unsigned short direction;
  	// raises DOMException on setting
  attribute SVGStylable context;
  	// raises DOMException on setting

This context element would provide the font-size used for resolving em
and ex units, and a viewport for resolving percentage values.  When
resolving percentage values, the direction attribute would be heeded.
(Although SVGStylable doesn't give access to the nearestViewportElement,
all elements that implement SVGStylable also implement SVGLocatable,
anyway.)

An exception would be raised if the direction or context attributes were
modified for SVGLength objects that are associated with particular SVG
elements (for example, a rect's x.baseVal object).

Perhaps the newValueSpecifiedUnits method could be modified (or
complemented with a different method) that would set the direction and
context, too.

Cameron

-- 
Cameron McCormack
|  Web: http://mcc.id.au/
|  ICQ: 26955922

Received on Tuesday, 2 November 2004 03:54:02 UTC