W3C home > Mailing lists > Public > www-svg@w3.org > March 2001

Suggested DOM Interface additions

From: Arnold, Curt <Curt.Arnold@hyprotech.com>
Date: Thu, 1 Mar 2001 13:01:04 -0700
Message-ID: <B2C1451A181BD411B88A00E018C1C19C08AAD5@THOR>
To: "'www-svg@w3.org'" <www-svg@w3.org>
Cc: "'svg-developers@egroups.com'" <svg-developers@egroups.com>
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

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

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:46:50 UTC