Suggested DOM Interface additions

The following are brief discussions of a few fairly simple additions to the SVG DOM that would life a whole lot easier. 

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

interface SVGTextContentElement {
float computeTextLength(DOMString string);
float getHeight();

}

computeStringLength would allow the length of an arbitrary string to be calculated for the current rendering for the element.  This would support text wrapping by eliminating the need to actually set
the content (with a display refresh) and then call getComputedTextLength possibly repeatedly to adjust the content to fit a particular bounding box.  This method is similar to
java.awt.FontMetrics.stringLength(String).

getHeight would return the standard height of the font similar to java.awt.FontMetrics.getHeight()

getLeading(), getAscent() and getDescent() might also be useful, but not essential.

These methods would support implementation of line wrapping of text or resizing of boxes in script.  Without these methods either the script must update the text content and use
getComputedTextLength() to determine rendered size of the text and then refresh the text appropriately to fit or the script has to have hardcoded knowledge about the font size which would effectively
prevent using CSS to pick fonts, font size, etc.

Alternatively, something like:

Rect getExtentOfString(DOMString);

-----------

interface SVGLocatable {
SVGPoint createPointFromClientCoordinates(long clientX,long clientY);
//  or
SVGPoint createPointFromScreenCoordinates(long screenX,long screenY);
}

This would create a SVGPoint in the element's user coordinates from the client (or screen) coordinates obtained from a MouseEvent.  It will be a common usage to want to reposition or resize an SVG
shape based on user interaction.

The idea is to support something like:

void moveCircle(circle, evt) {
	point = circle.createPointFromClientCoordinates(evt.clientX,evt.clientY);
	circle.cx = point.x;
	circle.cy = point.y;
}

It appears that you could do this by using the getCTM or getScreenCTM method, inverting the matrix and then applying the translate() method, however it would be good to have a method to support this
specific use.

Received on Thursday, 1 March 2001 15:05:07 UTC