SVG Tiny 1.2 - 20060810 – 20080912

A The SVG Micro DOM (uDOM)

Contents

A.1 Introduction

During the later stages of development of the SVG Mobile 1.1 specification [ SVGM11 ] it became obvious that there was a requirement to subset the SVG and XML DOM in order to reduce the burden on implementations. SVGT SVG Tiny 1.2 adds new features to the uDOM, allowing for as much necessary functionality as possible, still being suitable for SVG Tiny implementations.

Furthermore, it should be possible to implement the uDOM on devices that support SVG Tiny 1.1 although, in this case, the scripting would be external to the SVG document (since SVG Tiny 1.1 does not support inline scripting).

The goal of the uDOM definition is to provide an API that allows access to initial and computed attribute and property values, to reduce the number of interfaces compared to the traditional SVG DOM, to reduce run-time memory footprint using necessary features of the core XML DOM, as well as the most useful SVG features (such as transformation matrices). A subset of the uDOM (corresponding to SVG Tiny 1.1) is already successfully implemented by various implementations of JSR-226 . One JSR 226: Scalable 2D Vector Graphics API for J2ME ,compatibility with which is another goal of the uDOM is [ JSR226 ].

The uDOM makes normative reference to keep compatibility with DOM Level 2 Events ([ DOM2EVENTS ]), and informative reference to DOM Level 3 Events ([ DOM3EVENTS ]). A minimal subset of DOM Level 3 Events was included in the JSR-226 uDOM subset. to specify functionality as currently implemented on mobile devices, since DOM Level 3 Events was not yet a Recommendation at the time of publication. It is anticipated that DOM Level 3 Events may change to reflect the needs of the current Web environment, and any conflicting changes will supersede the functionality specified here for later SVG specifications.

The IDL definition for the uDOM is provided.

A.1 Introduction

This appendix consists of the following parts:

A.2 Overview of the SVG uDOM

The following sections provides an informative overview of the SVG uDOM's key features and constraints.

Note: Like other W3C DOM definitions, the SVG uDOM is programming-language independent. Although this appendix only contain contains ECMAScript and Java tm language examples, the SVG uDOM is compatible with other programming languages.

A.2.1 Document Access access

The SVG uDOM offers access to a Document object which is the root for accessing other features. The way the Document object becomes available depends on the usage context. One way to gain access to the Document object is to implement the EventListenerInitializer2 interface. The SVG Tiny user agent will invoke the implementation's initializeEventListeners method once the programming logic has been loaded and is ready to bind to the document. The Document object is sometimes accessible through other means, for example as the global document variable in ECMAScript.

A.2.2 Tree Navigation navigation

SVG uDOM only allows navigation of the element nodes in the DOM tree. Two options are available for navigating the hierarchy of elements:

The ElementTraversal interface provides firstElementChild , lastElementChild , previousElementSibling and nextElementSibling , which are particularly suitable for constrained devices. These traversal mechanisms skip over intervening nodes between element nodes, such as text nodes which might only contain spaces, tabs and newlines.

A.2.3 Element Creation creation

SVG uDOM allows creation of new Element s.

Example: Element creation (Java)
String svgNS = "http://www.w3.org/2000/svg";
Element myRect = document.createElementNS(svgNS, "rect");

A.2.4 Element Insertion insertion

Element insertion is the ability to insert new elements to a document tree.

SVG uDOM allows the insertion of an Element .

Example: Element insertion (ECMAScript)
var svgNS = "http://www.w3.org/2000/svg";
// Create a new <rect> element
var myRect = document.createElementNS(svgNS, "rect");
// Set the various <rect> properties before appending
...
// Add element to the root of the document
var svgRoot = document.documentElement;
svgRoot.appendChild(myRect);
// Create a new <ellipse> element
var myEllipse = document.createElementNS(svgNS, "ellipse");
// Set the various <ellipse> properties before insertion
...
// Insert the ellipse before the rectangle
svgRoot.insertBefore(myEllipse, myRect);

A.2.5 Element Removal removal

Element removal is the ability to remove an element from a document tree. SVG uDOM allows removal of Element s.

Example: Element removal (ECMAScript)
var myRect = ...; // See Element creation
var myGroup = document.getElementById("myGroup");
myGroup.appendChild(myRect);
...
myGroup.removeChild(myRect);

A.2.6 Attribute and Property Access property access

SVGT SVG Tiny 1.2 uDOM supports two ways of accessing XML attributes and CSS properties; the standard way via getAttributeNS and setAttributeNS on the Element interface and via a new concept called Traits .

A trait is the typed value (e.g. a number, not just a string), associated with an element by an XML attribute or a CSS property. The trait facilities in the SVG uDOM allow for strongly-typed access to certain attribute and property values. For example, there is a getFloatTrait(...) method for getting an attribute or property value directly as a float . This contrasts the getAttributeNS method which always returns a string. The trait facilities in the SVG uDOM are available on the TraitAccess interface.

Example: Trait Access (Java)
float width = myRect.getFloatTrait('width');
width += 10;
myRect.setFloatTrait('width', width);

An important difference between getTraitNS (and all other variants of getTrait methods) and getAttributeNS is that getTraitNS returns the computed attribute value but getAttributeNS returns the specified attribute value (which might not exactly match the original specified value due to the possibility of user agent value normalization as described in Attribute Normalization ).

Example: Difference between traits and getAttributeNS (Java)
<g fill="red"></g>

<g fill="red">
<rect id="r1" x="1" y="1" width="5" height="5"/>
<rect id="r2" fill="inherit" x="1" y="1" width="5" height="5"/>
</g>

r1.getTraitNS(null, "fill") returns "red" (or equivalent normalized form, see Attribute/Property Normalization ).
r2.getTraitNS(null, "fill") returns "red" (or equivalent normalized form, see Attribute/Property Normalization ).
r1.getAttributeNS(null, "fill") returns "".
r2.getAttributeNS(null, "fill") returns "inherit".

A trait may be animated. To access the animated value, use getPresentationTrait .

A.2.7 Event Listener Registration listener registration and Removal removal

Event Listener Registration and Removal is the ability to add and remove new event listeners from a Document . SVG uDOM allows adding and removing EventListener s.

Example: Event Listeners (Java)
class MyEventListener implements EventListener {
    public void handleEvent(Event evt) {
        // Do whatever is needed here
    }
}
...
EventListener l = new MyEventListener();
SVGElement myRect = (SVGElement)document.getElementById("myRect");
//Listen to click events, during the bubbling phase
myRect.addEventListenerNS("http://www.w3.org/2001/xml-events", "click", l, false, null);

myRect.addEventListener("click", l, false);

...
// Remove the click listener
myRect.removeEventListenerNS("http://www.w3.org/2001/xml-events","click", l, false);

myRect.removeEventListener("click", l, false);

A.2.8 Animation

SVG uDOM allows code to start or end timed elements (i.e. elements implementing SVGTimedElement ).

Example: animation (ECMAScript)
var animateColor = document.getElementById("myAnimation");
// Start the animation 2.5 seconds from now.
animateColor.beginElementAt(2.5);

A.2.9 Java package naming

The SVG uDOM will use uses the same Java package names as the upcoming SVG 1.2 Full DOM (e.g. org.w3c.dom,org.w3c.dom.events, org.w3c.dom.svg). org.w3c.dom ,org.w3c.dom.events ,org.w3c.dom.svg ). This allows Java applications which restrict themselves to the features in the SVG uDOM to also run in implementations that support the SVG 1.2 Full DOM.

A.3 Conforming to the SVG uDOM

This section and all the following are normative. Conforming SVG User AgentsViewers must support all constants, attributes and methods of all the interfaces defined in the SVG uDOM unless an interface explicitly allows for exceptions to this rule.

A.3.1 Attribute/Property Normalization Float values

The SVG uDOM uses IEEE-754 single precision floating point values to represent float values in the IDL [ IEEE-754 ]. While such values support a number of non-finite values — a set of NaN (Not a Number) values and positive & negative infinity — these values are never used by the uDOM. Thus, unless otherwise specified in the prose for an operation or attribute, a DOMException with error code NOT_SUPPORTED_ERR must be thrown if a non-finite value is passed as an operation argument, or assigned to an attribute, whose type is float ,or if a list of floating point values containing a non-finite value is passed as an operation argument, or assigned to an attribute, whose type is sequence<float> .

In addition, none of the operations or attributes in the uDOM distinguish between positive and negative zero. A negative zero must be treated as a positive zero when passed as an operation argument, or assigned to an attribute, whose type is float or sequence<float> .

Operations and attributes in the uDOM will never return a non-finite or negative zero value from an operation or attribute.

A.3.2 Attribute/property normalization

A viewer implementing the uDOM is allowed to return normalized attribute values (defined in DOM 3 ) from getAttributeNS and the various getTrait methods ( getTrait , getTraitNS , getFloatTrait , ...) and getPresentationTrait methods ( getPresentationTrait , getPresentationTraitNS , getFloatPresentationTrait , ...). Following is a list of possible attribute normalizations:

Color normalization
"red" may be returned as "rgb(255,0,0)" , "#ff0000" , or other semantically identical form.
 
Out-of-range normalization
Values that are only of relevance within a certain range may be returned as a value clamped to that range. E.g. fill-opacity="1.3" may be returned as "1" .
 
Numerical precision
"3.0" may be returned as "3" , "3.00" or other semantically identical form.
 
Whitespace normalization
" 3.0 " may be returned as "3.0" . Whitespace normalization also includes unquoted font names in the css font-family property: Font family names containing whitespace should be quoted. If quoting is omitted, any whitespace characters before and after the font name may be ignored and any sequence of whitespace characters inside the font name may be converted to a single space.
 
font-weight normalization
"normal" may be returned as "400" , "bold" may be returned as "700" .
 
Transform normalization
Any transform value may be returned as the corresponding matrix. E.g. "scale(2,2)" may be returned as "matrix(2,0,0,2,0,0)" , and "scale(2,2) translate(10,5) rotate(45)" may be returned as "matrix(1.4142, 1.4142, -2.5857, 1.4142, 20, 10)" .
 
Path normalization
The full set of 'd' / 'path' commands may be mapped down on a smaller set of commands.
 
Display normalization
All possible 'display' values may be mapped to 'none' , 'inline' or 'inherit' since they cover all the possible 'display' outputs for a pure SVGT1.2 SVG Tiny 1.2 viewer. E.g. "block" may be returned as "inline" . For viewers in multiple namespaces, e.g. a CDF viewer, the different 'display' properties are of importance and therefore an SVGT1.2 SVG Tiny 1.2 viewer intended for use in a multiple namespace environment is strongly recommended to keep the full range of 'display' values. Float Values 'display' All float values in the SVG uDOM are in IEEE-754 binary floating-point arithmetic. This means that in addition to numerical values (e.g. 8 , 42.23 ), values that cannot be converted to a numerical equivalent (e.g. strings like "100%" or "auto" ) shall be represented as the special value NaN (Not a Number). More specifically, the SVG uDOM uses a Signalling NaN, which means that in addition to representing this value as NaN , an exception shall be raised. values.

A.3.2 A.3.3 Text Content Access content access

In the SVG uDOM, there are two alternative ways to access an element's textual content. Text access via the TraitAccess interface is available on all SVGElement s. This was available in the SVG Tiny 1.1 uDOM (used in the JSR-226 JSR 226 specification) specification [ JSR226 ]) and is still available in order to keep backward compability. The SVG Tiny 1.2 uDOM specification introduces the textContent attribute on the Node interface as a more generic text access mechanism.

To access or set the text string value for an element via traits you invoke getTrait() or setTrait() on that element and pass #text as the name of the trait you want to get or set. For example, MyTextElement.setTrait("#text", "Hello"); Text access via the #text mechanism must be supported on Text Content text content , 'desc' , 'title' and 'metadata' elements. Text access to other elements defined within this specification (see list of elements ) is not supported and an implementation should ignore any text on these elements.

The result of getting and setting text content via the #text mechanism is exactly the same as when using the textContent attribute. Therefore the user should be aware of the fact that styling by child 'tspan' elements (i.e. 'tspan' elements that are children of the element which text content is retrieved) will be lost if a text string is retrieved from an element and then set back again.

The #text trait is included for compatibility with the JSR-226 JSR 226 specification [ JSR226] . It is recommended that where compatibility with JSR-226 JSR 226 implementations is not required content developers use textContent instead as it is more generally applicable and supports better compatibility with DOM Level 3 Core [ DOM3 ].

A.4 Module: dom

A.4.1 DOMException

Exceptions An exception that occurred due to a DOM operation, as defined by in the relevant Fundamental Interfaces: Core Module section of DOM Level 3 Core ([ DOM3 ], section . 1.4). Note that since the SVG uDOM is a subset of DOM Level 3 Core Core, some of the exception codes defined for this exception may never occur (e.g. INUSE_ATTRIBUTE_ERR, VALIDATION_ERR). (such as INUSE_ATTRIBUTE_ERR ,and VALIDATION_ERR ). However, in the interest of facilitating implementations that support both the uDOM and the complete DOM Level 3 Core Core, none of the exception codes are removed.
IDL Definition
exception DOMException
{
        unsigned short code;
};
// ExceptionCode
const unsigned short      INDEX_SIZE_ERR                 = 1;
const unsigned short      DOMSTRING_SIZE_ERR             = 2;
const unsigned short      HIERARCHY_REQUEST_ERR          = 3;
const unsigned short      WRONG_DOCUMENT_ERR             = 4;
const unsigned short      INVALID_CHARACTER_ERR          = 5;
const unsigned short      NO_DATA_ALLOWED_ERR            = 6;
const unsigned short      NO_MODIFICATION_ALLOWED_ERR    = 7;
const unsigned short      NOT_FOUND_ERR                  = 8;
const unsigned short      NOT_SUPPORTED_ERR              = 9;
const unsigned short      INUSE_ATTRIBUTE_ERR            = 10;
const unsigned short      INVALID_STATE_ERR              = 11;
const unsigned short      SYNTAX_ERR                     = 12;
const unsigned short      INVALID_MODIFICATION_ERR       = 13;
const unsigned short      NAMESPACE_ERR                  = 14;
const unsigned short      INVALID_ACCESS_ERR             = 15;
const unsigned short      VALIDATION_ERR                 = 16;
const unsigned short      TYPE_MISMATCH_ERR              = 17;
Constants
INDEX_SIZE_ERR
See definition INDEX_SIZE_ERR .
DOMSTRING_SIZE_ERR
See definition DOMSTRING_SIZE_ERR .
HIERARCHY_REQUEST_ERR
See definition HIERARCHY_REQUEST_ERR .
WRONG_DOCUMENT_ERR
See definition WRONG_DOCUMENT_ERR .
INVALID_CHARACTER_ERR
See definition INVALID_CHARACTER_ERR .
NO_DATA_ALLOWED_ERR
See definition NO_DATA_ALLOWED_ERR .
NO_MODIFICATION_ALLOWED_ERR
See definition NO_MODIFICATION_ALLOWED_ERR .
NOT_FOUND_ERR
See definition NOT_FOUND_ERR .
NOT_SUPPORTED_ERR
See definition NOT_SUPPORTED_ERR .
INUSE_ATTRIBUTE_ERR
See definition INUSE_ATTRIBUTE_ERR .
INVALID_STATE_ERR
See definition INVALID_STATE_ERR .
SYNTAX_ERR
See definition SYNTAX_ERR .
INVALID_MODIFICATION_ERR
See definition INVALID_MODIFICATION_ERR .
NAMESPACE_ERR
See definition NAMESPACE_ERR .
INVALID_ACCESS_ERR
See definition INVALID_ACCESS_ERR .
VALIDATION_ERR
See definition VALIDATION_ERR .
TYPE_MISMATCH_ERR
See definition TYPE_MISMATCH_ERR .
No defined attributes
No defined methods

A.4.2 Node

The Node interface describes generic nodes in an SVG document tree.

This interface is a subset of the Node interface defined in DOM Level 3 Core . Node types that must be supported in the uDOM are Element nodes and Document nodes.

This subset does not support the NodeType and DocumentPosition definition groups, since the nodeType field and the compareDocumentPosition are not members of the subsetted interface.

Concerning textContent , there is no requirement to create a Text node on setting since this subset has no interface representing Text nodes. However, the behaviour of textContent must be as if the Text node described in the the definition of textContent had indeed been created.

An alternate way of accessing text content on elements defined within the SVG specification is via the getTrait("#text") syntax.

IDL Definition
interface Node
{
        readonly attribute DOMString namespaceURI;
        readonly attribute DOMString localName;
        readonly attribute Node parentNode;
        readonly attribute Document ownerDocument;
        attribute DOMString textContent;
        Node appendChild(in Node newChild) 
                raises(DOMException);
        Node insertBefore(in Node newChild, in Node refChild) 
                raises(DOMException);
        Node removeChild(in Node oldChild) 
                raises(DOMException);
        Node cloneNode(in boolean deep);
};
No defined constants
Attributes
namespaceURI
See namespaceURI .
localName
See localName .
parentNode
See parentNode .
ownerDocument
See ownerDocument .
textContent
See textContent .
Methods
appendChild
See appendChild .
insertBefore
See insertBefore .
removeChild
See removeChild .
cloneNode
See cloneNode .

A.4.3 Element

The Element interface describes generic elements in an SVG document tree.

This interface is a subset of the Element interface defined in DOM Level 3 Core .

Concerning setAttributeNS , there is no requirement to take the prefix into account since neither the prefix field nor the Attr interface are supported.

IDL Definition
interface Element : Node

interface Element : Node, ElementTraversal

{
        DOMString getAttributeNS(in DOMString namespaceURI, in DOMString localName) 
                raises(DOMException);
        void setAttributeNS(in DOMString namespaceURI, in DOMString qualifiedName, in DOMString value) 
                raises(DOMException);
  DOMString getAttribute(in DOMString name);
        void setAttribute(in DOMString name, in DOMString value) 
                raises(DOMException);

};
No defined constants
No defined attributes
Methods
getAttributeNS
See getAttributeNS .
setAttributeNS
See setAttributeNS .
getAttribute
See getAttribute .
setAttribute
See setAttribute .

A.4.4 Document

The Document interface represents XML documents.

This interface is a subset of the Document interface defined in DOM Level 3 Core .

IDL Definition
interface Document : Node
{
  readonly attribute DOMImplementation implementation;

        Element createElementNS(in DOMString namespaceURI, in DOMString qualifiedName) 
                raises(DOMException);
        readonly attribute Element documentElement;
        Element getElementById(in DOMString elementId);
};
No defined constants
Attributes
implementation See implementation documentElement
See documentElement .
Methods
createElementNS
See createElementNS .
getElementById
See getElementById .

A.4.5 ElementTraversal

This interface provides a way to traverse elements in the uDOM tree. It is needed mainly because SVG Tiny uDOM does not expose character data nodes. Each element in the SVG Tiny document tree implements this interface, including elements in foreign namespaces. For the normative definition of this interface see the ElementTraversal specification [ ElementTraversal ]; it is only repeated informatively below.
IDL Definition

interface ElementTraversal
{
        readonly attribute Element firstElementChild;
        readonly attribute Element lastElementChild;
        readonly attribute Element nextElementSibling;
        readonly attribute Element previousElementSibling;
        readonly attribute unsigned long childElementCount;
};

No defined constants
Attributes
firstElementChild
See firstElementChild .
lastElementChild
See lastElementChild .
nextElementSibling
See nextElementSibling .
previousElementSibling
See previousElementSibling .
childElementCount
See childElementCount .
No defined methods
A.4.5

A.4.6 DOMImplementation Window

This is a subset of the de facto standard Window interface that many browsers implement. See Window Object 1.0 and The DOMImplementation default view in HTML 5 for ongoing standardization efforts in this area at the time of writing [ WINDOW ,HTML5 ]. The Window interface provides methods described here includes only a single attribute, which can be used to access a parent Window object, if any.

The Window interface must be implemented by the object that represents the default view of the document ([ DOM2VIEWS ], section 1.1). This object also implements AbstractView .Thus, in the ECMAScript language binding, the global script object implements Window .The Window object for performing operations a document can also be obtained through DocumentView::defaultView .

IDL Definition

interface Window
{
        readonly attribute Window parent;
};

No defined constants
Attributes
parent

The Window object that are independent is the parent view of this document's default view. If the Window has no notion of parent (e.g. if the document is displayed as the top level document in a viewer), then the value of this attribute is null .

No defined methods

A.5 Module: views

SVG Tiny 1.2 requires complete DOM Level 2 Views support, which includes the AbstractView and and the DocumentView interfaces [ DOM2VIEWS ].

The SVG Tiny 1.2 uDOM does not provide access to any particular instance views of the document other than the default view. The default view is accessible through DocumentView::defaultView .Note that the default view is required to also implement the SVGGlobal interface. In the ECMAScript language binding, the global script object model. must also be the object that represents the default view.

A.5.1 AbstractView

This interface is a subset copy of the DOMImplementation AbstractView interface defined in from DOM Level 3 Core . 2 Views ([ DOM2VIEWS ], section 1.2), and must be implemented by the object that represents the the default view of the document. In the ECMAScript language binding, the global script object must implement this interface.

IDL Definition
interface DOMImplementation

interface AbstractView

{
  readonly attribute DocumentView document;

};
No defined constants
No defined attributes Attributes
document
The document that this SVGGlobal is associated with, as a DocumentView .Note that this object is also a Document .See AbstractView::document in DOM Level 2 Views ([ DOM2VIEWS ], section 1.2).
No defined methods

A.5.2 DocumentView

This interface is a copy of the DocumentView interface from DOM Level 2 Views ([ DOM2VIEWS ], section 1.2), and must be implemented by all Document objects.

IDL Definition

interface DocumentView
{
        readonly attribute AbstractView defaultView;
};

No defined constants
Attributes
defaultView
The default AbstractView for this Document ,or null if none available. The value of this attribute is the SVGGlobal object associated with the document. See DocumentView::defaultView in DOM Level 2 Views ([ DOM2VIEWS ], section 1.2).
No defined methods

A.5 A.6 Module: events

A.5.1 A.6.1 EventTarget

The EventTarget interface is implemented by objects that can notify listeners about events and allows registration and removal of EventListener objects.

This interface is a subset of the EventTarget interface defined in DOM Level 3 2 Events . ([ DOM2EVENTS ], section 1.3.1).

Please note that SVG Tiny 1.2 user-agents are not required to support the capture phase, conformant SVG Tiny 1.2 content must not make use of it. If an attempt to specify event operations on the capture phase is made an SVG Tiny user-agent that does not support it must ignore them as if addEventListener had not been called.

As indicated in the DOM Level 2 Events definition for EventTarget ,this interface is implemented by all Node s.

Refer to the DOM Events Level 3 2 specification [ DOM2EVENTS ] or the XML Events [ XML-EVENTS ] specification introduction for an explanation of the SVG event flow and the meaning of event targets, event current target, bubble and capture.

IDL Definition
interface EventTarget
{
        void addEventListener(in DOMString type, in EventListener listener, in boolean useCapture);
        void removeEventListener(in DOMString type, in EventListener listener, in boolean useCapture);
  void addEventListenerNS(in DOMString namespaceURI, in DOMString type, in EventListener listener, 
                                in boolean useCapture, in DOMObject evtGroup);
        void removeEventListenerNS(in DOMString namespaceURI, in DOMString type, in EventListener listener, 
                                   in boolean useCapture);

};
No defined constants
No defined attributes
Methods
addEventListener
See addEventListener .
removeEventListener
See removeEventListener addEventListenerNS See addEventListenerNS removeEventListenerNS See removeEventListenerNS .

A.5.2 A.6.2 EventListener

The EventListener interface is the primary way for handling events. Users implement the it and register their event listener on an EventTarget .

This interface is identical to the EventListener interface defined in DOM Level 3 2 Events . ([ DOM2EVENTS ], section 1.3.1).

IDL Definition
interface EventListener
{
        void handleEvent(in Event evt);
};
No defined constants
No defined attributes
Methods
handleEvent
See handleEvent .

A.5.3 A.6.3 Event

The Event interface is used to provide contextual information about an event to the handler processing the event.

This interface is a subset of the Event interface defined in DOM Level 3 2 Events . ([ DOM2EVENTS ,section 1.4), with one addition: the defaultPrevented attribute. This subset does not support the PhaseType definition group.

For a list of supported event types see the Supported Events Complete list of supported events section of the Interactivity chapter.

IDL Definition
interface Event
{
        readonly attribute EventTarget target;
        readonly attribute EventTarget currentTarget;
        readonly attribute DOMString type;
  readonly attribute DOMString namespaceURI;

        readonly attribute boolean cancelable;
        readonly attribute boolean defaultPrevented;
        void stopPropagation();
        void preventDefault();
};
No defined constants
Attributes
target
See target .
currentTarget
See currentTarget .
type
See type namespaceURI See namespaceURI .
cancelable
See cancelable .
defaultPrevented
See Used to indicate whether defaultPrevented Event.preventDefault() has been called for this event.
Methods
stopPropagation
See stopPropagation .
preventDefault
See preventDefault .

A.5.4 A.6.4 MouseEvent

Event that provides specific contextual information associated with pointing device events.

Event types that are MouseEvent s: click , mousedown , mouseup , mouseover , mousemove , mouseout , WheelEvent .

This interface is a subset of the MouseEvent interface defined in DOM Level 3 2 Events . ([ DOM2EVENTS ,section 1.6.2).

IDL Definition
interface MouseEvent : UIEvent
{
        readonly attribute long screenX;
        readonly attribute long screenY;
        readonly attribute long clientX;
        readonly attribute long clientY;
        readonly attribute unsigned short button;
};
No defined constants
Attributes
screenX
See screenX .
screenY
See screenY .
clientX
See clientX .
clientY
See clientY .
button
See button .
No defined methods
A.5.5

A.6.5 WheelEvent MouseWheelEvent

Many devices today have a rotational input method, such as the wheel on a Event that provides specific contextual information associated with mouse or the "jog dial" of a phone or PDA. wheel events.

The SVGMousewheel event is triggered when the user rotates the rotational input device. Listeners for this event may only be attached to the Element Event node types that is the Document are MouseWheelEvent node's documentElement s: mousewheel . If a listener for this event is attached to another node in the document, the user agent must not trigger it when the event occurs.

Event type that This interface is a WheelEvent : subset of the MouseWheelEvent interface defined in DOM Level 3 Events ,and inherits attributes from the MouseEvent interface defined in SVGMousewheel DOM Level 2 Events . ([ DOM2EVENTS ,section 1.6.2).

IDL Definition
interface WheelEvent : MouseEvent

interface MouseWheelEvent : MouseEvent

{
        readonly attribute long wheelDelta;
};
No defined constants
Attributes
wheelDelta
Indicates the number of "clicks" The distance the wheel has been rotated. rotated around the y-axis. A positive value indicates shall indicate that the wheel has been rotated away from the user (or on vertically-aligned devices or in a right-hand left-hand manner on horizontally aligned devices) devices, and a negative value indicates shall indicate that the wheel has been rotated towards the user (or on vertically-aligned devices or in a left-hand right-hand manner on horizontally aligned devices). A "click" is defined to be a unit horizontally-aligned devices. The default value of rotation. On some devices this is a finite physical step. On devices with smooth rotation, a "click" becomes the smallest measurable amount of rotation. delta attribute shall be 0.
No defined methods

A.5.6 A.6.6 TextEvent

Event type that is a TextEvent : textInput .

This interface is a subset of the TextEvent interface defined in DOM Level 3 Events .

IDL Definition
interface TextEvent : UIEvent
{
        readonly attribute DOMString data;
};
No defined constants
Attributes
data
See data holds the value of the characters generated by the character device. This may be a single Unicode character or a non-empty sequence of Unicode characters [ Unicode ]. Characters should be normalized as defined by the Unicode normalization form NFC ,defined in [ UAX #15 ]. This attribute cannot be null or contain an empty string.
No defined methods

A.5.7 A.6.7 KeyboardEvent

Provides specific contextual information associated with keyboard devices. Each KeyboardEvent references a key using an identifier.

Event types that are KeyboardEvents : keydown , keyup .

This interface is a subset of the KeyboardEvent interface defined in DOM Level 3 Events .

IDL Definition
interface KeyboardEvent : UIEvent
{
        readonly attribute DOMString keyIdentifier;
};
No defined constants
Attributes
keyIdentifier
See keyIdentifier holds the identifier of the key. The key identifiers are defined in the " Key identifiers set ". Implementations that are unable to identify a key must use the key identifier "Unidentified" .
No defined methods

A.5.8 A.6.8 UIEvent

The UIEvent interface provides specific contextual information associated with User Interface events.

Event types that are UIEvents : DOMFocusIn , DOMFocusOut , DOMActivate , MouseEvent , TextEvent , KeyboardEvent ,

This interface is a subset of the UIEvent interface defined in DOM Level 3 2 Events . ([ DOM2EVENTS ,section 1.6.1).

IDL Definition
interface UIEvent : Event
{
        readonly attribute long detail;
};
No defined constants
Attributes
detail
See detail .
No defined methods

A.5.9 A.6.9 ProgressEvent

The ProgressEvents defined here are intended to be a subset of the ProgressEvents defined in [ PROGRESSEVENTS ].

Many resources, such as raster images, movies and complex SVG content can take a substantial amount of time to download. In some use cases the author would prefer to delay the display of content or the beginning of an animation until the entire content of a file has been downloaded. In other cases, the author may wish to give the viewer some feedback that a download is in progress (e.g. a loading progress screen).

The ProgressEvent occurs when the user agent makes progress loading a resource (local or external) (external) referenced by an xlink:href 'xlink:href' attribute.

The user agent must dispatch a ProgressEvent at the beginning of a load operation (i.e. just before starting to access the resource). This event is of type SVGPreload loadstart .

The user agent must dispatch a ProgressEvent at the end of a load operation (i.e. after load is complete and the user agent is ready to render the corresponding resource). This event is of type SVGPostload loadend .

The user agent may dispatch ProgressEvent s between the SVGPreload loadstart event and the SVGPostload loadend events. Such events are of type SVGLoadProgress progress .

Event types that are ProgressEvents : SVGLoadProgress progress , SVGPreload loadstart , SVGPostload loadend .

IDL Definition
interface ProgressEvent : Event
{
        readonly attribute boolean lengthComputable;
        readonly attribute unsigned long loaded;
        readonly attribute unsigned long total;
};
No defined constants
Attributes
lengthComputable
If false the total number of bytes (total) cannot be computed and the value of total should be ignored. This might occur if the size of the downloaded resource is unknown or if the data has already arrived.
loaded
Specifies the number of bytes downloaded since the beginning of the download. This value is ignored for a SVGPreload loadstart or SVGPostload loadend event.
total
Specifies the expected total number of bytes expected in a load operation. For a SVGLoadProgress progress event, it should specify the total number of bytes expected.
No defined methods
Example: ProgressEvent
<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny"
xmlns:xlink="http://www.w3.org/1999/xlink">
<script type="application/ecmascript"><![CDATA[
function showImage(imageHref) {
var image = document.getElementById('myImage');
image.setTraitNS("http://www.w3.org/1999/xlink", "href", imageHref);
}
function imageLoadStart (evt) {
progressBar.setFloatTrait("width", 0);
var loadingAnimation = document.getElementById('loadingAnimation');
loadingAnimation.beginElement();
}

<svg xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink"
     xmlns:ev="http://www.w3.org/2001/xml-events"
     version="1.2" baseProfile="tiny" width="300" height="430">

function imageLoadProgress (evt) {
if ( evt.lengthComputable )
{
var progressBar = document.getElementById('progressBar');
progressBar.setFloatTrait("width", 100*(evt.loaded/evt.total));
progressBar.setTrait( "visibility", "visible" );
}
}

  <script><![CDATA[
    function showImage(imageHref) {
      var image = document.getElementById('myImage');
      image.setTraitNS("http://www.w3.org/1999/xlink", "href", imageHref);
    }

function imageLoadComplete (evt) {
var progressBar = document.getElementById('progressBar');
progressBar.setTrait( "visibility", "hidden" );
var loadingAnimation = document.getElementById('loadingAnimation');
loadingAnimation.endElement();
}

    function imageLoadStart(evt) {
      var progressBar = document.getElementById('progressBar');
      var loadingAnimation = document.getElementById('loadingAnimation');
      progressBar.setFloatTrait("width", 0);
      loadingAnimation.beginElement();
    }

]]></script>

    function imageLoadProgress(evt) {
      if (evt.lengthComputable) {
        var progressBar = document.getElementById('progressBar');
        progressBar.setFloatTrait("width", 100 * (evt.loaded / evt.total));
        progressBar.setTrait("display", "inline");
      }
    }

<image xml:id="myImage" xlink:href="imageA.png" width="300" height="400">
<handler type="application/ecmascript" ev:event="preload">
imageLoadStart(evt);
</handler>

    function imageLoadComplete(evt) {
      var progressBar = document.getElementById('progressBar');
      var loadingAnimation = document.getElementById('loadingAnimation');
      progressBar.setTrait("display", "none");
      loadingAnimation.endElement();
    }
  ]]></script>

<handler type="application/ecmascript" ev:event="loadProgress">
imageLoadProgress(evt);
</handler>

  <image xml:id="myImage" xlink:href="imageA.png" width="300" height="400">
    <handler ev:event="loadstart">
      imageLoadStart(evt);
    </handler>

<handler type="application/ecmascript" ev:event="postload">
imageLoadComplete(evt);
</handler>
</image>

    <handler ev:event="progress">
      imageLoadProgress(evt);
    </handler>

<rect width="120" height="30" y="400">
<handler type="application/ecmascript" ev:event="click">
showImage('imageB.png');
</handler>
</rect>

    <handler ev:event="loadend">
      imageLoadComplete(evt);
    </handler>
  </image>

<animate xml:id="loadingAnimation" ... />

  <rect rx="4" x="50" y="400" width="200" height="30" cursor="pointer">
    <handler ev:event="click">
      showImage('imageB.png');
    </handler>
  </rect>
  <text x="150" y="420" font-size="15" fill="white" text-anchor="middle"
        text-decoration="underline" pointer-events="none">
    Load other image
  </text>

<rect visibility="hidden" xml:id="progressBar" ... />

  <g display="none">
    <rect x="100" y="300" height="10" width="100" fill="black"/>
    <rect xml:id="progressBar" x="100" y="300" width="50" height="10" fill="lime"/>
  </g>
  <text x="150" y="330" font-size="15" text-anchor="middle" display="none">
    Loading...
    <animate xml:id="loadingAnimation" attributeName="display"
             begin="indefinite" dur="2s" repeatDur="indefinite"
             calcMode="discrete" values="inline; none"/>
  </text>

</svg>
A.5.10 ConnectionEvent

A.7 Module: smil

The ConnectionEvent This interface is used to represent all events that may occur during the processing a subset of connections, as described in the Connection ElementTimeControl interface. These events represent not only data received through a connection, but also the establishment and closing of a connection, as well as error conditions that may occur. Event interface defined in SMIL Animation types that are ConnectionEvents : SVGConnectionConnected , SVGConnectionDataSent , SVGConnectionDataReceived , SVGConnectionClosed , SVGConnectionError . [ SMILANIM ].

IDL Definition interface ConnectionEvent : Event { const unsigned short NO_ERR = 0; const unsigned short NETWORK_ERR = 1; readonly attribute unsigned short errorCode; readonly attribute sequence<octet> receivedData; }; Constants NO_ERR WhenContains a connection event is dispatched and does not represent an error, its errorCode field is set to this value so that it can be distinguishedsingle subsetted interface from error related events. NETWORK_ERR When an error occurs during the lifetime of a connection, an event is dispatched with its errorCode field set to this value. Attributes errorCode When an event indicating that an error has occurred is dispatched, this field contains the corresponding error constant. In all other situations this field is set to NO_ERR. receivedData When an event indicating that data has been successfully received is dispatched, this field contains the sequence of octets that represents that data. In all other situations this field is null . No defined methods A.6 Module: smilSMIL APIs.

A.6.1 A.7.1 ElementTimeControl

This interface defines common methods for elements which define animation behaviors compatible with SMIL ( Timed Elements and the svg 'svg' element).
IDL Definition
interface ElementTimeControl
{
        void beginElementAt(in float offset);
        void beginElement();
        void endElementAt(in float offset);
        void endElement();
};
No defined constants
No defined attributes
Methods
beginElementAt
Creates a begin instance time for the current time plus or minus the passed offset. The new instance time is added to the begin instance times list .
Parameters
in float offset The offset in seconds at which to begin the element.
No Return value
No Exceptions
beginElement
Creates a begin instance time for the current time. The new instance time is added to the begin instance times list . This is equivalent to beginElementAt(0) .
No Parameters
No Return value
No Exceptions
endElementAt
Creates an end instance time for the current time plus or minus the passed offset. The new instance time is added to the end instance times list .
Parameters
in float offset The offset in seconds at which to end the element.
No Return value
No Exceptions
endElement
Creates an end instance time for the current time. The new instance time is added to the end instance times list . This is equivalent to endElementAt(0) .
No Parameters
No Return value
No Exceptions
A.7 Module: global A.7.1

A.7.2 Global TimeEvent

The Global interface

TimeEvent is designed to be the parent an interface for language specific window objects. It is currently defined used to be empty. IDL Definition interface Global { }; No defined constants No defined attributes No defined methods A.7.2 GlobalException An exception thrown provide contextual information for problems occurring with methods events fired by animations in the global space. IDL Definition exception GlobalException { unsigned short code; }; // ExceptionCode const unsigned short NOT_CONNECTED_ERR = 1; const unsigned short ENCODING_ERR = 2; const unsigned short DENIED_ERR = 3; const unsigned short UNKNOWN_ERR = 4; Constants NOT_CONNECTED_ERR Occurs when one attempts to send data over a closed connection, or a connection fails to be established. ENCODING_ERR Occurs when encoding or decoding a string fails. DENIED_ERR Occurs when the user-agent refuses to perform document. It is a requested task, for instance for security reasons. UNKNOWN_ERR Occurs when an error subset of an unknown nature happens. No defined attributes No defined methods the A.7.3 Connection TimeEvent The Connection interface provides an API for socket-level communication. The socket must be set up to use the TCP protocol. A Connection object is created using the SVGGlobal interface method createConnection() . Since it inherits from the EventTarget interface, it is possible to register event listeners on the Connection interface defined in order to handle the various types of ConnectionEvent that are dispatched during the processing of connections. After a connection has been established the Connection object must dispatch a ConnectionEvent with the type SVGConnectionConnected to event handlers registered on that Connection object. After data has been successfully sent, the Connection object must dispatch a ConnectionEvent with the type SVGConnectionDataSent to event handlers registered on that Connection object. The event is dispatched exactly once for each call to send() SMIL Animation .

When data has been received, the Connection object must dispatch a ConnectionEvent with the type SVGConnectionDataReceived to event handlers registered on that Connection Event object. In the circumstance that the connection is closed fired by any peer, a ConnectionEvent with the type SVGConnectionClosed must be dispatched to event handlers registered on that Connection object. all Timed Elements .

If an error occurs, a ConnectionEvent with the type SVGConnectionError Event must be dispatched to event handlers registered on types that Connection object. This must cause the connection to be closed. Data must be sent and received over the connection as a binary stream of octets. The connect() and send() methods work asynchronously (non-blocking). Multiple calls to send() can be made in sequence without waiting for the SVGConnectionDataSent event to have been dispatched. Each set of data must be queued and sent, in FIFO order, by the UA. Each are TimeEvents :send() beginEvent will result in a , SVGConnectionDataSent endEvent event except when an error occurs. A user-agent may arbitrary limit the size of the queue of events that it can hold at any one time. Should more events require to be queued than the user-agent's limit a GlobalException of type DENIED_ERR must be raised, the entirety of the queue discarded, and the connection closed. The , send() repeatEvent method must raise an GlobalException of type NOT_CONNECTED_ERR exception if the connection is not open at the time the call is made. All other errors are treated asynchronously, in the form of connectionError events. .

IDL Definition
interface Connection : EventTarget

interface TimeEvent : Event

{
  readonly attribute boolean connected;
        void connect(in DOMString host, in unsigned short port) 
                raises(GlobalException);
        void send(in sequence<octet> data) 
                raises(GlobalException);
        void close();

  readonly attribute long detail;

};
No defined constants
Attributes
connected This boolean field will be true if a connection is currently open, and false otherwise. Methods connect Cause a connection to be open to the provided host and port, where the host may be either a domain name or an IP address. If the connection fails to be established, a GlobalException of type NOT_CONNECTED_ERR must be raised. Once the connection is established, the connected field must be set to true . For security reasons, user-agents are strongly encouraged to restrict the ways in which a connection can be established both for both host and ports. If the user-agent elects to deny the connection based on these restrictions, a GlobalException of type DENIED_ERR must be raised. Parameters in DOMString host A domain name or IP address that the TCP connection is to be established to. in unsigned short port The port to which the TCP connection is being established. No Return value Exceptions GlobalException NOT_CONNECTED_ERR: Raised if the connection fails. send This method sends the data over the connection. It transmits a sequence of octets without modifying it in any way. A string can be transmitted after having been converted to a sequence of octets using the stringToBinary method on the SVGGlobal interface. Parameters in sequence<octet> data data The data to send. No Return value Exceptions GlobalException NOT_CONNECTED_ERR: Raised if the connection is not open when send is called. close detail
This method causes the connection to be closed. It is asynchronous and any data queued for transmission using the send() method but not yet successfully transmitted must be sent before the connection is effectively closed. However, any call to send() occurring after close() has been called will raise an exception as if the connection had already been closed, and the connected field must be set to false immediately. No Parameters No Return value No Exceptions description provided.
A.7.4 Timer The Timer interface provides an API for scheduling a one time or repetitive event. A Timer object is always either in the running (attribute running is true ) or waiting (attribute running is false ) state. After each interval of the timer, an Event of type SVGTimer is triggered. SVGTimer events are triggered only when the timer is in the running state. The SVGTimer event is limited to the target phase. Since Timer is an EventTarget , EventListeners can be registered on it using addEventListener with SVGTimer as the event type. Event listeners can access their corresponding Timer object through the event object's target property. Timer instances are created using the createTimer method of the SVGGlobal interface. IDL Definition interface Timer : events::EventTarget { attribute long delay; attribute long repeatInterval; readonly attribute boolean running; void start(); void stop(); };
No defined constants Attributes delay This attribute specifies the time remaining in milliseconds until the next event is fired. When the Timer is in the running state this attribute is dynamically updated to reflect the remaining time in the current interval. When the Timer is waiting the delay reflects the time that remained when stopped. Getting the delay attribute returns the current value, i.e. a snapshot value of the remaining delay. After delay period has passed while the object is in the running state, the Timer object will trigger an Event of type SVGTimer . The delay will then be updated with the repeatInterval value and a new count down will start. Setting the delay resets the current interval to the new value. If this attribute is 0 , it means that the event will be triggered as soon as possible. Assigning a negative value is equivalent to calling the stop() method. The initial value is set through the initialInterval parameter in the createTimer method on the SVGGlobal interface, and defines the first interval of the Timer . repeatInterval This attribute specifies in milliseconds the interval for each repeat of the Timer , i.e. each timer interval subsequent to the initial interval. The initial value of this attribute is set through the repeatInterval parameter in the createTimer method on the SVGGlobal interface. Assigning a negative value disables the repetitive triggering of the event making it a one time timer which triggers an event after the delay . running Timer state. Value is true if the timer is running, false if the timer is waiting. Note that the repeatInterval and delay properties can be non-negative if the timer is stopped (but if delay is negative, the timer is stopped). Methods methods
start Changes the Timer state into running . If the timer is already in the running state, it has no effect. Initially the timer is waiting , and must be started with this method. If the timer delay had a negative value when started, for example if the time had been stopped by setting the delay to a negative value, the delay value is reset to repeatInterval when the this method is called. No Parameters No Return value
No Exceptions stop Changes the Timer state into waiting . If the timer is already in the waiting state, calling this method has no effect. No Parameters No Return value No Exceptions

A.8 Module: svg

A.8.1 SVGException

An exception thrown for SVG-specific errors.

This interface is identical to SVGException interface defined in SVG 1.1 .

IDL Definition
exception SVGException
{
        unsigned short code;
};
// ExceptionCode
const unsigned short SVG_WRONG_TYPE_ERR         = 0;
const unsigned short SVG_INVALID_VALUE_ERR      = 1;
const unsigned short SVG_MATRIX_NOT_INVERTABLE  = 2;
Constants
SVG_WRONG_TYPE_ERR
See definition .
SVG_INVALID_VALUE_ERR
See definition .
SVG_MATRIX_NOT_INVERTABLE
See definition .
No defined attributes
No defined methods

A.8.2 SVGDocument

IDL Definition
interface SVGDocument : Document, EventTarget
{
  readonly attribute SVGGlobal global;

};
No defined constants
Attributes No defined attributes
global Access to the SVGGlobal object.
No defined methods

A.8.3 SVGElementInstance

For each 'use' element, the uDOM represents the referenced content with a shadow tree of SVGElementInstance objects.

This interface is a subset of the SVGElementInstance interface defined in SVG 1.1 .

IDL Definition
interface SVGElementInstance : EventTarget
{
        readonly attribute SVGElement correspondingElement;
        readonly attribute SVGElement correspondingUseElement;
};
No defined constants
Attributes
correspondingElement
See correspondingElement .
correspondingUseElement
See correspondingUseElement .
No defined methods
Example: ECMAScript usage of the SVGElementInstance interface.
In this example, three 'use' elements use the same 'rect' element. Each 'use' has different 'fill' properties that are inherited down to the used 'rect'. The result is three 'rect' elements with different 'fill' colors. Clicking one of these three 'rect' elements will cause a fourth 'rect' to change color to match the clicked one. Worth noticing is that if the original 'rect' had not been in the 'defs' element the script would go into error when the original 'rect' is clicked. This is because the 'currentTarget' attribute would return an 'SVGElement' that doesn't have the 'correspondingUseElement' attribute.
<svg version="1.2" baseProfile="tiny" width="640" height="480"
viewBox="0 0 640 480" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:ev="http://www.w3.org/2001/xml-events">
<defs>
<rect xml:id="r1" width="90" height="65"/>
</defs>

    <svg version="1.2" baseProfile="tiny" width="640" height="480"
    viewBox="0 0 640 480" xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink"
    xmlns:ev="http://www.w3.org/2001/xml-events">
        <defs>
            <rect xml:id="r1" width="90" height="65"/>
        </defs>

<use xlink:href="#r1" x="50" y="200" fill="red"/>
<use xlink:href="#r1" x="250" y="200" fill="blue"/>
<use xlink:href="#r1" x="450" y="200" fill="green"/>

        <use xlink:href="#r1" x="50" y="200" fill="red"/>
        <use xlink:href="#r1" x="250" y="200" fill="blue"/>
        <use xlink:href="#r1" x="450" y="200" fill="green"/>

<rect xml:id="r2" x="250" y="50" width="90" height="65"/>

        <rect xml:id="r2" x="250" y="50" width="90" height="65"/>

<ev:listener observer="r1" event="ev:click" handler="#handler"/>

        <ev:listener observer="r1" event="ev:click" handler="#handler"/>

<handler xml:id="handler" type="application/ecmascript">changeColor(evt);</handler>

        <handler xml:id="handler" type="application/ecmascript">changeColor(evt);</handler>

<script type="application/ecmascript">
<![CDATA[
var target = document.getElementById("r2");

        <script type="application/ecmascript">
            <![CDATA[
                var target = document.getElementById("r2");

function changeColor(evt)
{
var useElement = evt.currentTarget.correspondingUseElement;
target.setRGBColorTrait("fill", useElement.getRGBColorTrait("fill"));
}
]]>
</script>

                function changeColor(evt)
                {
                    var useElement = evt.currentTarget.correspondingUseElement;
                    target.setRGBColorTrait("fill", useElement.getRGBColorTrait("fill"));
                }
             ]]>
        </script>

</svg>

A.8.4 SVGSVGElement

This interface represents the 'svg' element in the (SVG) document tree.

User Agent Transforms

The uDOM attributes currentScale , currentRotate and currentTranslate are combined to form a user agent transformation which is applied at the outermost level on the SVG document (i.e. outside the 'svg' element) if "magnification" is enabled (i.e. 'zoomAndPan' attribute is set to magnify ). Their values can potentially be modified through user-agent specific UI. User agent transformation can be obtained by multiplying the matrix

[currentScale 0 currentTranslate.x] [cos(currentRotate) -sin(currentRotate 0] [ 0 currentScale currentTranslate.y] by [sin(currentRotate) cos(currentRotate) 0] [ 0 0 1 ] [ 0 0 1]
 [currentScale      0       currentTranslate.x]         [cos(currentRotate) -sin(currentRotate 0]
 [     0      currentScale  currentTranslate.y]  by     [sin(currentRotate) cos(currentRotate) 0]
 [     0            0               1         ]         [         0                  0         1]

i.e. (translate, then scale, then rotate the coordinate system). The reference point for scale and rotate operations is the origin (0, 0).

IDL Definition
interface SVGSVGElement : SVGLocatableElement, SVGTimedElement
{
        const unsigned short NAV_AUTO           = 1;
        const unsigned short NAV_NEXT           = 2;
        const unsigned short NAV_PREV           = 3;
        const unsigned short NAV_UP             = 4;
        const unsigned short NAV_UP_RIGHT       = 5;
        const unsigned short NAV_RIGHT          = 6;
        const unsigned short NAV_DOWN_RIGHT     = 7;
        const unsigned short NAV_DOWN           = 8;
        const unsigned short NAV_DOWN_LEFT      = 9;
        const unsigned short NAV_LEFT           = 10;
        const unsigned short NAV_UP_LEFT        = 11;
        attribute float currentScale;
        attribute float currentRotate;
        readonly attribute SVGPoint currentTranslate;
        readonly attribute SVGRect viewport;
        float getCurrentTime();
  void setCurrentTime( in float seconds );

  void setCurrentTime(in float seconds);

        SVGMatrix createSVGMatrixComponents(in float a, in float b, in float c, in float d, in float e, 
                                            in float f);
        SVGRect createSVGRect();
  SVGPoint createSVGPoint();

        SVGPath createSVGPath();
  SVGRGBColor createSVGRGBColor(in long red, in long green, in long blue) 

  SVGRGBColor createSVGRGBColor(in float red, in float green, in float blue) 

                raises(SVGException);
        void moveFocus(in unsigned short motionType) 
                raises(DOMException);
  void setFocus(in DOMObject object) 

  void setFocus(in EventTarget theObject) 

                raises(DOMException);
        EventTarget getCurrentFocusedObject();
};
Constants
NAV_AUTO
Indicates that focus must move to the next focusable object according to the User Agent's user agent's own algorithm.
NAV_NEXT
Indicates that focus must move to the next focusable object according to current nav-next value.
NAV_PREV
Indicates that focus must move to the previous focusable object according to current nav-prev value.
NAV_UP
Indicates a request that focus must move in the given direction.
NAV_UP_RIGHT
Indicates a request that focus must move in the given direction.
NAV_RIGHT
Indicates a request that focus must move in the given direction.
NAV_DOWN_RIGHT
Indicates a request that focus must move in the given direction.
NAV_DOWN
Indicates a request that focus must move in the given direction.
NAV_DOWN_LEFT
Indicates a request that focus must move in the given direction.
NAV_LEFT
Indicates a request that focus must move in the given direction.
NAV_UP_LEFT
Indicates a request that focus must move in the given direction.
Attributes
currentScale
On read : read: Returns the current user agent scale (zoom) coefficient. The initial value for currentScale is 1.
On write : write: Sets the current user agent scale (zoom) coefficient.
Exceptions No exceptions
DOMException INVALID_ACCESS_ERR: Raised if the scale value is set to zero.
currentRotate
On read : read: Returns the current user agent rotation angle in degrees. The initial value for currentRotate is 0.
On write : write: Sets the current user agent rotate coefficient in degrees.
currentTranslate
Current user agent translation used for scrolling or panning (The returned SVGPoint object is "live" and setting its x and y components will change the user agent's translation). The initial values for currentTranslate is SVGPoint(0,0) .
viewport

The position and size of the viewport (implicit or explicit) that corresponds to this 'svg' element. When the user agent is actually rendering the content, then the position and size values represent the actual values when rendering.

If this SVG document is embedded as part of another document (e.g., via the HTML 'object' element), then the position and size are unitless values in the coordinate system of the parent document. (If the parent uses CSS or XSL layout, then unitless values represent pixel units for the current CSS or XSL viewport, as described in the CSS2 specification.) If the parent element does not have a coordinate system, then the user agent should provide reasonable default values for this attribute.

For stand-alone SVG documents, both 'x' and 'y' must be zero, the 'width' must be the width of the viewport which the host environment provides to the SVG user agent into which it can render its content, and the 'height' must be the height of the viewport, with all values expressed in the pixel coordinate system from the host environment, preferably such that this pixel coordinate system matches the same pixel coordinate system presented to HTML and matches the model for pixel coordinates described in the CSS2 specification.
Note that "pixel coordinate systems" are host-specific. Two possible approaches that hosts might use for pixel coordinate systems are actual device pixels or (particularly for high-resolution devices) pseudo device pixels which exactly match SVG and CSS's "px" coordinates.

The object itself and its contents are both readonly. A DOMException with error code NO_MODIFICATION_ALLOWED_ERR is raised if attempt is made to modify it. The returned SVGRect object is "live", i.e. its x , y , width , height is automatically updated if viewport size or position changes.

Methods
getCurrentTime

Returns the document time in seconds.

If getCurrentTime is called before the document timeline has begun (for example, by script running in a 'script' element before the rootmost svg element 's load event is dispatched, when 'playbackOrder' is set to 'onLoad' ), then 0 is returned.

Return value
float The current document time ,in seconds, or 0 if the document timeline has not yet begun.
No parameters
No Exceptions
setCurrentTime

Sets the document time (in seconds). This API is required to support seeking forwards and backwards in the timeline. After a seek, animation continues to play (forwards) from the new time. If seconds is negative, then the document will seek to time 0s.

If setCurrentTime is called before the document timeline has begun (for example, by script running in a 'script' element before the rootmost svg element 's load event is dispatched, when 'playbackOrder' is set to 'onLoad' ), then the value of seconds in the most recent invocation of the method gives the time that the document time will be seeked to once the document timeline has begun.

Parameters
in float seconds The document time to seek to, in seconds.
No return value
No Exceptions
createSVGMatrixComponents
Creates a new SVGMatrix object. This object can be used to modify the value of traits which are compatible with the SVGMatrix type using the setMatrixTrait method. The internal representation of the matrix is as follows:
[ a c e ] [ b d f ] [ 0 0 1 ]
  [  a  c  e  ]
  [  b  d  f  ]
  [  0  0  1  ]

Parameters
in float a The 'a' component of the matrix to be set.
in float b The 'b' component of the matrix to be set.
in float c The 'c' component of the matrix to be set.
in float d The 'd' component of the matrix to be set.
in float e The 'e' component of the matrix to be set.
in float f The 'f' component of the matrix to be set.
Return value
SVGMatrix The created SVGMatrix object.
No Exceptions
createSVGRect
Creates a new SVGRect object. This object can be used to modify the value of traits which are compatible with the SVGRect type using the setRectTrait method. The initial values for x , y , width , height of this new SVGRect are zero.
No Parameters
Return value
SVGRect The created SVGRect .
No Exceptions
createSVGPoint
Creates a new SVGPoint object. The initial values for x and y of this new SVGPoint are zero.
No Parameters
Return value
SVGPoint The created SVGPoint .
No Exceptions
createSVGPath
Creates a new SVGPath object. This object can be used to modify the value of traits which are compatible with the SVGPath type using the setPathTrait method.
No Parameters
Return value
SVGPath The created SVGPath .
No Exceptions
createSVGRGBColor
Creates a new SVGRGBColor object. This object can be used to modify the value of traits which are compatible with the SVGRGBColor type using the setRGBColorTrait method. The parameters are floats, one per color component. 0.0 represents zero intensity and 255.0 represents full intensity of a given color component. Colors originally in the rgb(%,%,%) syntax may have fractional components. Out of gamut colors may have component values less than 0.0 or greater than 255.0.
Parameters
in float red The red component of the SVGRGBColor .
in float green The green component of the SVGRGBColor .
in float blue The blue component of the SVGRGBColor .
Return value
SVGRGBColor The created SVGRGBColor .
No Exceptions
moveFocus
Moves current focus to a different object based on the value of motionType . The User Agent user agent must take into account the currently focused object in the document in order to find the new focused object.
If this method succeeds :
  • A DOMFocusOut event must be dispatched which has the previously focused object as the event target.
  • After that, a DOMFocusIn event must dispatched which has the the new focused object as the event target.
A reference to the new focused object can be obtained using the EventTarget interface of the generated DOMFocusIn event.
Refer to the navigation section to see how navigation is managed. The behavior for this method must be the same as if an equivalent move was done by the end user (using joystick or TAB keys) and not by scripting.
Whenever the method fails (i.e. a DOMException is raised), focus must stay on the currently focused object and no DOMFocusOut / DOMFocusIn event is dispatched.
Note: For stand-alone SVG documents, the User Agent user agent must always have a currently focused object. At the beginning, the SVGDocument has focus.
Parameters
in short motionType The type of motion.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERROR: NOT_SUPPORTED_ERR: Raised if the requested motion type is not supported (i.e. not one of the interface constants).
DOMException
INVALID_ACCESS_ERR: Raised if the currently focused object doesn't have a nav-* navigation attribute value corresponding to the requested motion type. For instance, if a moveFocus(NAV_UP) is called on an element which has no 'nav-up' attribute.
DOMException
INVALID_STATE_ERR: Raised if the currently focused object has a nav-* navigation attribute value corresponding to the requested motion type but the target indicated in this attribute can not be found or is not a focusable object. For instance, if a moveFocus(NAV_UP) is called on an object which has a 'nav-up' attribute but the value of this attribute references an element which is not focusable.
setFocus
A request to put the focus on the given object.
If this method succeeds:
  • A DOMFocusOut event must be dispatched which has the previously focused object as the event target.
  • After that, a DOMFocusIn event must be dispatched which has the the new focused object as the event target.
A reference to the new focused object can be obtained using the EventTarget interface of the generated DOMFocusIn event.
Whenever the method fails (i.e. a DOMException is raised), focus must stay on the currently focused object and no DOMFocusOut / DOMFocusIn event is dispatched.
Note: For stand-alone SVG documents, the User Agent user agent must always have a currently focused object. At the beginning, the SVGDocument has focus.
Parameters
in DOMObject EventTarget object theObject The object which should receive focus.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERROR: NOT_SUPPORTED_ERR: Raised if the in parameter is not a Node or SVGElementInstance ,or if the requested element is not focusable (i.e. its ' 'focusable' attribute does not evaluate to true ).
getCurrentFocusedObject
Returns a reference to the object which has the focus. This returns an EventTarget .
No Parameters
Return value
EventTarget object The currently focused object.
No Exceptions

A.8.5 SVGRGBColor

This interface represents an SVGRGBColor datatype made up of red, green, and blue components. It can be used to read properties that store color values ( getRGBColorTrait ) such as 'fill' , 'stroke' , and 'color' .
IDL Definition
interface SVGRGBColor
{
        attribute unsigned long red;
        attribute unsigned long green;
        attribute unsigned long blue;
};
No defined constants
Attributes
red
Returns the red component of the SVGRGBColor .
green
Returns the green component of the SVGRGBColor .
blue
Returns the blue component of the SVGRGBColor .
No defined methods

A.8.6 SVGRect

This interface represents an SVGRect datatype, consisting of a minimum X, minimum Y, width and height values.

This interface is identical to SVGRect interface defined in SVG 1.1 .

IDL Definition
interface SVGRect
{
        attribute float x;
        attribute float y;
        attribute float width;
        attribute float height;
};
No defined constants
Attributes
x
See x .
y
See y .
width
See width .
height
See height .
No defined methods

A.8.7 SVGPoint

Represents an SVGPoint datatype, identified by its x and y components.

This interface is a subset of the identical to SVGPoint interface defined in SVG 1.1 .

IDL Definition
interface SVGPoint
{
        attribute float x;
        attribute float y;
  SVGPoint matrixTransform(in SVGMatrix matrix);

};
No defined constants
Attributes
x
See x .
y
See y .
No defined methods Methods
matrixTransform
See matrixTransform .

A.8.8 SVGPath

This interface represents an SVGPath datatype used to define the path geometry.

Path data created or modified using this interface must be normalized as per the rules given in Path Normalization . However, path data that is just queried need not be normalized.

IDL Definition
interface SVGPath
{
        const unsigned short MOVE_TO = 77;
        const unsigned short LINE_TO = 76;
        const unsigned short CURVE_TO = 67;
        const unsigned short QUAD_TO = 81;
        const unsigned short CLOSE = 90;
        readonly attribute unsigned long numberOfSegments;
        unsigned short getSegment(in unsigned long cmdIndex) 
                raises(DOMException);
        float getSegmentParam(in unsigned long cmdIndex, in unsigned long paramIndex) 
                raises(DOMException);
        void moveTo(in float x, in float y);
        void lineTo(in float x, in float y);
        void quadTo(in float x1, in float y1, in float x2, in float y2);
        void curveTo(in float x1, in float y1, in float x2, in float y2, in float x3, in float y3);
        void close();
};
Constants
MOVE_TO
Numeric value is Unicode value of the letter 'M'.
LINE_TO
Numeric value is Unicode value of the letter 'L'.
CURVE_TO
Numeric value is Unicode value of the letter 'C'.
QUAD_TO
Numeric value is Unicode value of the letter 'Q'.
CLOSE
Numeric value is Unicode value of the letter 'Z'.
Attributes
numberOfSegments
Return number of segments in this path.
Methods
getSegment
Returns segment command by zero-based command index.
Parameters
in unsigned long cmdIndex The command index for the segment command to retrieve.
Return value
unsigned short The segment command. One of MOVE_TO , LINE_TO , CURVE_TO , QUAD_TO or CLOSE
Exceptions
DOMException
INDEX_SIZE_ERR: Raised if segment index is out of bounds or param index is out of bounds for this segment's type.
getSegmentParam
Returns segment parameter by zero-based command index and zero-based parameter index.
Parameters
in float unsigned long cmdIndex The command index for the segment command.
in float unsigned long paramIndex The parameter index to retrieve.
Return value
float The segment parameter.
Exceptions
DOMException
INDEX_SIZE_ERR: Raised if segment index out of bounds or param index out of bounds for this segment's type.
moveTo
Appends an 'M' (absolute move) segment to the path with the specified coordinates.
Parameters
in float x The x-axis coordinate for the specified point.
in float y The y-axis coordinate for the specified point.
No Return value
No Exceptions
lineTo
Appends an 'L' (absolute line) segment to the path with the specified coordinates.
Parameters
in float x The x-axis coordinate for the specified point.
in float y The y-axis coordinate for the specified point.
No Return value
No Exceptions
quadTo
Appends a 'Q' (absolute quadratic curve) segment to the path.
Parameters
in float x1 The x-axis coordinate of the first control point.
in float y1 The y-axis coordinate of the first control point.
in float x2 The x-axis coordinate of the final end point.
in float y2 The y-axis coordinate of the final end point.
No Return value
No Exceptions
curveTo
Appends a 'C' (absolute cubic curve) segment to the path.
Parameters
in float x1 The x-axis coordinate of the first control point.
in float y1 The y-axis coordinate of the first control point.
in float x2 The x-axis coordinate of the second end point.
in float y2 The y-axis coordinate of the second end point.
in float x3 The x-axis coordinate of the final end point.
in float y3 The y-axis coordinate of the final end point.
No Return value
No Exceptions
close
Appends a 'z' (close path) segment to the path.

A.8.9 SVGMatrix

This interface represents an SVGMatrix datatype, identified by an affine transform. It can be used to read and modify the values of the 'transform' attribute.
Note: The mTranslate , inverse , mMultiply , mScale and mRotate methods in this interface mutate the SVGMatrix object and return a reference to the SVGMatrix instance itself, after performing the necessary matrix operation.

This matrix transforms source coordinates (x, y) into destination coordinates (x', y') by considering them to be a column vector and multiplying the coordinate vector by the matrix according to the following process:

[ x' ] [ a c e ] [ x ] [ a.x + c.y + e ] [ y' ] = [ b d f ] [ y ] = [ b.x + d.y + f ] [ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ]
    [ x' ]    [  a  c  e  ]   [ x ]    [ a.x + c.y + e ]
    [ y' ] =  [  b  d  f  ]   [ y ] =  [ b.x + d.y + f ]
    [ 1  ]    [  0  0  1  ]   [ 1 ]    [        1      ]

IDL Definition
interface SVGMatrix
{
        float getComponent(in unsigned long index) 
                raises(DOMException);
        SVGMatrix mMultiply(in SVGMatrix secondMatrix);
        SVGMatrix inverse() 
                raises(SVGException);
        SVGMatrix mTranslate(in float x, in float y);
        SVGMatrix mScale(in float scaleFactor);
        SVGMatrix mRotate(in float angle);
};
No defined constants
No defined attributes
Methods
getComponent
Returns a component of the matrix by the component's zero-based index. getComponent(0) is a, getComponent(1) is b, etc.
Parameters
in unsigned long index The index of the matrix component to retrieve.
Return value
float The matrix component.
Exceptions
DOMException
INDEX_SIZE_ERR: Raised if the index is invalid.
mMultiply
Performs matrix multiplication. This matrix is post-multiplied by another matrix, returning the resulting current matrix.
Parameters
in SVGMatrix secondMatrix The matrix to post-multiply with.
Return value
SVGMatrix The resulting current matrix.
No Exceptions
inverse
Returns a new instance of SVGMatrix containing the inverse of the current matrix.
No Parameters
Return value
SVGMatrix The inverse of the current matrix.
Exceptions
SVGException
SVG_MATRIX_NOT_INVERTABLE: Raised when determinant of this matrix is zero.
mTranslate
Post-multiplies a translation transformation on the current matrix and returns the resulting current matrix. This is equivalent to calling mMultiply(T) , where T is an SVGMatrix object represented by the following matrix: [ 1 0 x ] [ 0 1 y ] [ 0 0 1 ]
        [   1    0    x  ]
        [   0    1    y  ]
        [   0    0    1  ]

Parameters
in float x The distance by which coordinates are translated in the X axis direction.
in float y The distance by which coordinates are translated in the Y axis direction.
Return value
SVGMatrix The resulting current matrix.
No Exceptions
mScale
Post-multiplies a uniform scale transformation on the current matrix and returns the resulting current matrix. This is equivalent to calling mMultiply(S) , where S is an SVGMatrix object represented by the following matrix: [ scaleFactor 0 0 ] [ 0 scaleFactor 0 ] [ 0 0 1 ]
        [   scaleFactor      0          0   ]
        [   0          scaleFactor      0   ]
        [   0                0          1   ]

Parameters
in float scaleFactor The factor by which coordinates are scaled along the X and Y axis.
Return value
SVGMatrix The resulting current matrix.
No Exceptions
mRotate
Post-multiplies a rotation transformation on the current matrix and returns the resulting current matrix. This is equivalent to calling mMultiply(R) , where R is an SVGMatrix object represented by the following matrix: [ cos(angle) -sin(angle) 0 ] [ sin(angle) cos(angle) 0 ] [ 0 0 1 ]
    [ cos(angle) -sin(angle) 0 ]
    [ sin(angle)  cos(angle) 0 ]
    [ 0           0          1 ]

Parameters
in float angle The angle of rotation in degrees.
Return value
SVGMatrix The resulting current matrix.
No Exceptions

A.8.10 SVGLocatable

Interface for getting information about the location of elements.
IDL Definition
interface SVGLocatable
{
        SVGRect   getBBox();
        SVGMatrix getScreenCTM();
        SVGRect   getScreenBBox();
};
No defined constants
No defined attributes
Methods
getBBox
Returns the bounding box of the element. Note: null is returned if this element is not hooked into the document tree.
No Parameters
Return value
SVGRect The bounding box . The returned object is a copy of the current bounding box value and will not change if the corresponding bounding box changes.
No Exceptions
getScreenCTM
Returns the transformation matrix from current user units to the initial viewport coordinate system. DOM MouseEvent clientX and clientY coordinates are in the initial viewport coordinate system. Note that null is returned if this element is not hooked into the document tree. This method would have been more aptly named as getClientCTM , but the name getScreenCTM is kept for historical reasons. Also note that getScreenCTM reflects a snapshot of the current animated state, i.e. if one or several transforms that affect the element that getScreenCTM is called upon are animated then the returned transformation matrix reflects the current state of each such animated transform when calculating the returned matrix.
No Parameters
Return value
SVGMatrix The transformation matrix. The returned object is a copy of the current screen CTM value and will not change if the corresponding screen CTM changes.
No Exceptions
getScreenBBox
Returns the bounding box of the element in screen coordinate space. The box coordinates are in the initial viewport coordinate system, which is connected to the current user coordinate space by the matrix returned by the SVGLocatable::getScreenCTM method. Note: null is returned if this element is not hooked into the document tree.
No Parameters
Return value
SVGRect The bounding box in screen coordinate space. The returned object is a copy of the current screen bounding box value and will not change if the corresponding screen bounding box changes.
No Exceptions

The following examples further clarify the behavior of the getBBox() method. The examples have a short explanation, an SVG fragment and are followed by a set of bounding box values which have the following format:

[elementId] : {x, y, width, height} | {null}


where x, y, width and height define the values of the SVGRect object's returned from a getBBox call on the element with the specified id. There are a few cases where the bounding box may be null (see example 6).

Example #1: Simple groups and bounds
This first example shows the values returned by the getBBox method for various simple basic shapes and groups. In particular, it shows that the transform, on an element, does not change the value of its user space bounding box.
<g xml:id="group1" transform="translate(10, 20)" fill="red">
<rect xml:id="rect1" transform="scale(2)" x="10" y="10" width="50" height="50"/>
<rect xml:id="rect2" x="10" y="10" width="100" height="100"/>
<g xml:id="group2" transform="translate(10, 20)">
<rect xml:id="rect3" x="0" y="10" width="150" height="50"/>
<circle xml:id="circle1" cx="20" cy="20" r="100" />
</g>

    <rect xml:id="rect1" transform="scale(2)" x="10" y="10" width="50" height="50"/>
    <rect xml:id="rect2" x="10" y="10" width="100" height="100"/>
    <g xml:id="group2" transform="translate(10, 20)">
        <rect xml:id="rect3" x="0" y="10" width="150" height="50"/>
        <circle xml:id="circle1" cx="20" cy="20" r="100" />
    </g>

</g>

Result:
[group1] : {-70.0, -60.0, 230.0, 200.0}
[rect1] : {10.0, 10.0, 50.0, 50.0}
[rect2] : {10.0, 10.0, 100.0, 100.0}
[group2] : {-80.0, -80.0, 230.0, 200.0}
[rect3] : {0.0, 10.0, 150.0, 50.0}
[circle1] : {-80.0, -80.0, 200.0, 200.0}


Example #2: Bounding box on zero width or height rectangle
This example illustrates that the bounding box on elements is based on the element's geometry coordinates. For example, the bounding box on a zero-width rectangle is defined (see below), even though the rectangle is not rendered.
<g xml:id="group1" transform="translate(10, 20)" fill="red">
<rect xml:id="rect2" x="10" y="10" width="400" height="0"/>
<g xml:id="group2" transform="translate(10, 20)">
<rect xml:id="rect3" x="0" y="10" width="150" height="50"/>
</g>

    <rect xml:id="rect2" x="10" y="10" width="400" height="0"/>
    <g xml:id="group2" transform="translate(10, 20)">
        <rect xml:id="rect3" x="0" y="10" width="150" height="50"/>
    </g>

</g>

Result:
[group1] : {10.0, 10.0, 400.0, 70.0}
[rect2] : {10.0, 10.0, 400.0, 0.0}
[group2] : {0.0, 10.0, 150.0, 50.0}
[rect3] : {0.0, 10.0, 150.0, 50.0}


Example #3: Bounding Box on zero radius ellipses.
This is another example of how bounding boxes are based on the element's geometry. Here, the bounding box of an ellipse with a zero x-axis radius is still defined, even though the ellipse is not rendered.
<svg xml:id="mySVG" version="1.2" baseProfile="tiny" width="10" height="20">
<g xml:id="group1" transform="translate(10, 20)" fill="red">
<rect xml:id="rect1" x="10" y="10" width="100" height="100"/>
<ellipse xml:id="ellipse1" cx="20" cy="20" rx="0" ry="70" />
</g>

    <g xml:id="group1" transform="translate(10, 20)" fill="red">
        <rect xml:id="rect1" x="10" y="10" width="100" height="100"/>
        <ellipse xml:id="ellipse1" cx="20" cy="20" rx="0" ry="70" />
    </g>

</svg>

Result:
[mySVG] : {20.0, -30.0, 100.0, 160.0}
[group1] : {10.0, -50.0, 100.0, 160.0}
[rect1] : {10.0, 10.0, 100.0, 100.0}
[ellipse1] : {20.0, -50.0, 0.0, 140.0}


Example #4: Viewports do not clip bounding boxes
This example shows that no matter what the viewport is on the root SVG element, the bounding boxes, based on the geometry, are still defined. Here, even though the root svg has a zero width, the bounding boxes for the root itself and its children is precisely defined.
<svg xml:id="mySVG" version="1.2" baseProfile="tiny" width="0" height="50">
<g xml:id="group1" transform="translate(10, 20)" fill="red" >
<rect xml:id="rect1" x="10" y="10" width="50" height="50"/>
<g xml:id="group2" transform="translate(10, 20)">
<rect xml:id="rect2" x="0" y="10" width="150" height="0"/>
<circle xml:id="circle1" cx="20" cy="20" r="500"/>
</g>
</g>

    <g xml:id="group1" transform="translate(10, 20)" fill="red" >
        <rect xml:id="rect1" x="10" y="10" width="50" height="50"/>
        <g xml:id="group2" transform="translate(10, 20)">
            <rect xml:id="rect2" x="0" y="10" width="150" height="0"/>
            <circle xml:id="circle1" cx="20" cy="20" r="500"/>
        </g>
    </g>

</svg>

Result:
[mySVG] : {-460.0, -440.0, 1000.0, 1000.0}
[group1] : {-470.0, -460.0, 1000.0, 1000.0}
[rect1] : {10.0, 10.0, 50.0, 50.0}
[group2] : {-480.0, -480.0, 1000.0, 1000.0}
[rect2] : {0.0, 10.0, 150.0, 0.0}
[circle1] : {-480.0, -480.0, 1000.0, 1000.0}


Example #5: getBBox on <use>
This example shows that the bounding box for a 'use' element accounts for the x and y attributes defined on the element, just like the x and y attributes impact the bounding box computation on a 'rect' or on an 'image' element.
<svg version="1.2" baseProfile="tiny">
<defs>
<rect xml:id="myRect" x="0" y="0" width="60" height="40"/>
</defs>
<use xml:id="myUse" xlink:href="#myRect" x="-30" y="-20"/>

    <defs>
        <rect xml:id="myRect" x="0" y="0" width="60" height="40"/>
    </defs>
    <use xml:id="myUse" xlink:href="#myRect" x="-30" y="-20"/>

</svg>

Result:
[myRect] : {0.0, 0.0, 60.0, 40.0}
[myUse] : {-30.0, -20.0, 60.0, 40.0}


Example #6: Empty group
This example shows that the bounding box for an empty group is null. By the same token, the bounding box of a 'path' with an empty SVGPath (i.e. one with no path commands, which may happen after creating a new 'path' element with a createElementNS call) is also null .
<g xml:id="emptyG"/>

Result:
[emptyG] : {null}


Example #7: Impact of display='none' and visibility='hidden'
This example shows how the bounding box of children with display='none' are not accounted for in the computation of their parent's bounding box. This reflects the definition of the 'display' property and its impact on rendering and bounding box computation. The example also shows that elements with a 'hidden' 'visibility' still contribute to their parent's bounding box computation.
<g xml:id="g1">
<g xml:id="g1.1.display.none" display="none">
<rect xml:id="rect1" x="10" y="10" width="40" height="40"/>
</g>
<rect xml:id="rect2.visibility.hidden" visibility="hidden" x="30" y="60" width="10" height="20"/>

    <g xml:id="g1.1.display.none" display="none">
        <rect xml:id="rect1" x="10" y="10" width="40" height="40"/>
    </g>
    <rect xml:id="rect2.visibility.hidden" visibility="hidden" x="30" y="60" width="10" height="20"/>

</g>

Result:
[g1] : {30.0, 60.0, 10.0, 20.0}
[g1.1.display.none] : {10.0, 10.0, 40.0, 40.0}
[rect1] : {10.0, 10.0, 40.0, 40.0} [rec2.visibility.hidden]
[rect2.visibility.hidden] : {30.0, 60.0, 10.0, 20.0}


Example #8: Concatenating bounding boxes in the container's user space
This example shows how the concatenation and computation of bounding boxes for container element happens in the container's user space.
<g xml:id="g1">
<line xml:id="line1" x2="100" y2="100" transform="rotate(-45)"/>

    <line xml:id="line1" x2="100" y2="100" transform="rotate(-45)"/>

</g>

Result:
[g1] : {0.0, 0.0, 141.42136, 0}
[line1] : {0.0, 0.0, 100.0, 100.0}


Example #9: No influence of stroke-width
This example illustrates that stroking has no impact on the computation of bounding boxes.
<g>
<line xml:id="thickLine" stroke-width="10" x2="100" y2="0"/>

    <line xml:id="thickLine" stroke-width="10" x2="100" y2="0"/>

</g>

Result:
[thickLine] : {0.0, 0.0, 100.0, 0.0}


Example #10: No influence of viewBox
This example illustrates that the viewBox has no impact on the computation of bounding boxes.
<svg xml:id="rootSvg" version="1.2" baseProfile="tiny" width="500" height="300" viewBox="0 0 200 100">
<rect x="-100" y="-200" width="500" height="100"/>

    <rect x="-100" y="-200" width="500" height="100"/>

</svg>

Result:
[rootSVG] : {-100, -200, 500, 100}

Example #11: Impact of elements which are not in the rendering tree
This example illustrates that elements which are not in the rendering tree have no impact on the computation of bounding boxes.

        <g xml:id="g1">
          <linearGradient xml:id="MyGradient"/>
            <stop offset="0.05" stop-color="#F60"/>
            <stop offset="0.95" stop-color="#FF6"/>
          </linearGradient>
        </g>

Result:
[g1] : {null}

A.8.11 SVGLocatableElement

This interface represents an element that has a physical location on the screen.

This interface is implemented by: 'rect' , 'circle' , 'ellipse' , 'line' , 'path' , 'use' , 'image' , 'text' , 'textArea' , 'tspan' , 'svg' , 'a' , 'video' , 'animation' , 'switch' , 'foreignObject' , 'polygon' , 'polyline' and 'g' .

IDL Definition
interface SVGLocatableElement : SVGElement, SVGLocatable
{
};
No defined constants
No defined attributes
No defined methods

A.8.12 TraitAccess

Trait manipulation interface. This interface is used to read and manipulate the value of "traits" associated with an SVGElement . Each trait corresponds to an attribute or property, which is parsed and understood by the element and in most cases animatable. Unlike attributes, each element has a well-defined set of traits and attempting to access an undefined unsupported trait may must throw an exception. Also unlike attributes traits are typed and their values are normalized; for instance SVG 'path' specification is parsed and all path commands are converted to their absolute variants, it is not possible to say through the value of the trait if a path command was absolute or relative. When getting and setting trait values, accessor of the correct type must be used or exception will be thrown.

For a trait corresponding to a property, the computed value is used: if the value of a given property is not specified on that element, then for inherited properties the value on the parent is used. For non-inherited values, or on the root element, the initial value of the property is used.

For a trait corresponding to a non-property attribute, if the attribute is inherited (eg xml:lang) the value of the parent is used. If the attribute is not inherited, or on the root element, the default lacuna value for the attribute is used, if known. If not known (for example, for an unknown attribute, or a known attribute with no specified default), 'null' is returned.

Note that when using the TraitAccess interface for getting traits on elements outside of the tree, e.g. on elements just created or removed, what values are returned is user agent dependent.

The different getTrait methods ( getTrait , getTraitNS , getFloatTrait , ...) return base values (i.e. before animation is applied), and this is true for both static and animated content. Note however that if the attribute is inherited from an animated parent value, it will inherit the animated value. The different getPresentationTrait methods ( getPresentationTrait , getPresentationTraitNS , getFloatPresentationTrait , ...) return either the current animated value if the given trait is currently being animated (per the SMIL specification ) or the base value if the given trait is not currently being animated. Not all attributes are accessible by traits - see the table of supported attributes .

Setting a trait value has the same effect as changing a corresponding attribute, but trait setters can operate on typed values. The value which is modified is always a base value. For inheritable traits the trait value can always be set to 'inherit' inherit (but querying the value will always return the actual inherited value as explained above).

Note about invalid/unsupported trait values: There are two situations where the various trait setter methods (such as setTrait , setFloatTrait or setPathTrait methods) consider a value invalid and throw a DOMException with the INVALID_ACCESS_ERR code. The first situation is when the trait value is invalid with regards to its definition (for example, trying to set the 'stroke-linejoin' trait to 'foo' would cause this exception). The trait methods will consider the value to be invalid if its it is in error .

The second situation is when the trait value is invalid with regards to animations currently applied to the trait. The value is considered invalid because it would put the animation, and therefore the document, in an error state. For example, if a 'path' element has animations on its 'd' attribute, trying to change the 'd' attribute to a value incompatible with the animations will cause the exception to happen.

User Agents must implement the trait setter methods such that trait values which represent unsupported values result in a DOMException with the NOT_SUPPORTED_ERR code. For example, trying to set the 'stroke-linejoin' trait to 'foo' would cause this exception.
IDL Definition
interface TraitAccess
{
        DOMString getTrait(in DOMString name) 
                raises(DOMException);
        DOMString getTraitNS(in DOMString namespaceURI, in DOMString name) 
                raises(DOMException);
        float getFloatTrait(in DOMString name) 
                raises(DOMException);
  sequence<float> getFloatListTrait(in DOMString name) 
                raises(DOMException);

        SVGMatrix getMatrixTrait(in DOMString name) 
                raises(DOMException);
        SVGRect getRectTrait(in DOMString name) 
                raises(DOMException);
        SVGPath getPathTrait(in DOMString name) 
                raises(DOMException);
        SVGRGBColor getRGBColorTrait(in DOMString name) 
                raises(DOMException);
        DOMString getPresentationTrait(in DOMString name) 
                raises(DOMException);
        DOMString getPresentationTraitNS(in DOMString namespaceURI, in DOMString name) 
                raises(DOMException);
        float getFloatPresentationTrait(in DOMString name) 
                raises(DOMException);
  sequence<float> getFloatListPresentationTrait(in DOMString name) 
                raises(DOMException);

        SVGMatrix getMatrixPresentationTrait(in DOMString name) 
                raises(DOMException);
        SVGRect getRectPresentationTrait(in DOMString name) 
                raises(DOMException);
        SVGPath getPathPresentationTrait(in DOMString name) 
                raises(DOMException);
        SVGRGBColor getRGBColorPresentationTrait(in DOMString name) 
                raises(DOMException);
        void setTrait(in DOMString name, in DOMString value) 
                raises(DOMException);
        void setTraitNS(in DOMString namespaceURI, in DOMString name, in DOMString value) 
                raises(DOMException);
        void setFloatTrait(in DOMString name, in float value) 
                raises(DOMException);
  void setFloatListTrait(in DOMString name, in sequence<float> value) 
                raises(DOMException);

        void setMatrixTrait(in DOMString name, in SVGMatrix matrix) 
                raises(DOMException);
        void setRectTrait(in DOMString name, in SVGRect rect) 
                raises(DOMException);
        void setPathTrait(in DOMString name, in SVGPath path) 
                raises(DOMException);
        void setRGBColorTrait(in DOMString name, in SVGRGBColor color) 
                raises(DOMException);
};
No defined constants
No defined attributes
Methods
getTrait
Returns the trait value (possibly normalized ) as a DOMString . In SVG Tiny only certain traits can be obtained as a DOMString value. Syntax of the returned DOMString matches the syntax of the corresponding attribute. This element method is exactly equivalent to getTraitNS with namespaceURI set to null .
Parameters
in DOMString name The name of the trait to retrieve.
Return value
DOMString The trait value.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to a DOMString (SVG Tiny only).
getTraitNS
Same as getTrait , but for namespaced traits. Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString namespaceURI The namespace of the trait to retrieve.
in DOMString name The name of the trait to retrieve.
Return value
DOMString The trait value.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to a DOMString (SVG Tiny only).
getFloatTrait
Get the trait value as a float . Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
float The trait value as a float .
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value is returned as a non-numeric float (e.g. (for example, when calling NaN getFloatTrait("width") ). on a root SVG element whose width attribute uses a percentage)).
getFloatListTrait
Get the trait value as a sequence<float> .Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
sequence<float> The trait value as a sequence<float> .
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to a sequence<float> .
getMatrixTrait
Returns the trait value as an SVGMatrix . The returned object is a copy of the actual trait value and will not change if the corresponding trait changes. Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGMatrix The trait value as an SVGMatrix .
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGMatrix .
getRectTrait
Returns the trait value as an SVGRect . The returned object is a copy of the actual trait value and will not change if the corresponding trait changes. If the actual trait value is not an SVGRect, i.e. 'none', this method will return null .Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGRect The trait value as an SVGRect .
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGRect .
getPathTrait
Returns the trait value as an SVGPath . The returned object is a copy of the actual trait value and will not change if the corresponding trait changes. Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGPath The trait value as an SVGPath .
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGPath .
getRGBColorTrait
Returns the trait value as an SVGRGBColor . The returned object is a copy of the trait value and will not change if the corresponding trait changes. If the actual trait value is not an SVGRGBColor , i.e. 'none' or a link to a paint server (e.g. to a gradient or a solid-color), this method must raise return null .Parameter name must be a DOMException with error code TYPE_MISMATCH_ERR. non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGRGBColor The trait value as an SVGRGBColor .
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGRGBColor .
getPresentationTrait
Returns the trait presentation value as a DOMString . In SVG Tiny only certain traits can be obtained as a DOMString value. Syntax of the returned DOMString matches the syntax of the corresponding attribute. This element method is exactly equivalent to getPresentationTraitNS with namespaceURI set to null .
Parameters
in DOMString name The name of the trait to retrieve.
Return value
DOMString The trait presentation value.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to a DOMString (SVG Tiny only).
getPresentationTraitNS
Same as getPresentationTrait , but for namespaced traits. The parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString namespaceURI The namespace of the trait to retrieve.
in DOMString name The name of the trait to retrieve.
Return value
DOMString The trait presentation value.
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to a DOMString (SVG Tiny only).
getFloatPresentationTrait
Get the trait presentation value as a float . Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
float The trait presentation value as a float .
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value is returned as a non-numeric float (e.g. (for example, when calling NaN getFloatTrait("width") ). on a root SVG element whose width attribute uses a percentage)).
getFloatListPresentationTrait
Get the trait presentation value as a sequence<float> .Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
sequence<float> The trait presentation value as a sequence<float> .
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to a sequence<float> .
getMatrixPresentationTrait
Returns the trait presentation value as an SVGMatrix . The returned object is a copy of the actual trait value and will not change if the corresponding trait changes or as animation continue to affect the trait presentation value. Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGMatrix The trait presentation value as an SVGMatrix .
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGMatrix .
getRectPresentationTrait
Returns the trait presentation value as an SVGRect . The returned object is a copy of the actual trait value and will not change if the corresponding trait changes or as animation continue to affect the trait presentation value. If the actual trait value is not an SVGRect, i.e. 'none', this method will return null .Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGRect The trait presentation value as an SVGRect .
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGRect .
getPathPresentationTrait
Returns the trait presentation value as an SVGPath . The returned object is a copy of the actual trait value and will not change if the corresponding trait changes or as animation continue to affect the trait presentation value. Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGPath The trait presentation value as an SVGPath .
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGPath .
getRGBColorPresentationTrait
Returns the trait presentation value as an SVGRGBColor . The returned object is a copy of the trait value and will not change if the corresponding trait changes or as animation continue to affect the trait presentation value. If the actual trait presentation value is not an RGBColor (i.e. "none"), SVGRGBColor ,i.e. 'none' or a link to a paint server (e.g. to a gradient or a solid-color), this method will must return null . Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to retrieve.
Return value
SVGRGBColor The trait presentation value as an SVGRGBColor .
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or null .
DOMException
TYPE_MISMATCH_ERR: Raised if requested trait's computed value cannot be converted to an SVGRGBColor .
setTrait
Set the trait value as a DOMString . In SVG Tiny only certain traits can be set through a DOMString value. The syntax of the DOMString that should be given as a value must be the same as syntax of the corresponding XML attribute value. Exactly equivalent to setTraitNS with the namespaceURI attribute set to null .
Parameters
in DOMString name The name of the trait to be set.
in DOMString value The value of the trait.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or an attempt has been made to set an unsupported value. element.
DOMException
TYPE_MISMATCH_ERR: Raised if the requested trait's value cannot be specified as a DOMString .
DOMException
INVALID_ACCESS_ERR: Raised if the input value is an invalid value for the given trait or null is specified.
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised if attempt is made to change a readonly trait.
setTraitNS
Same as setTrait , but for namespaced traits. The parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString namespaceURI The namespace of the trait to be set.
in DOMString name The name of the trait to be set.
in DOMString value The value of the trait.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element or an attempt has been made to set an unsupported value. element.
DOMException
TYPE_MISMATCH_ERR: Raised if the requested trait's value cannot be specified as a DOMString .
DOMException
INVALID_ACCESS_ERR: Raised if the input value is an invalid value for the given trait or null is specified. This error is also thrown when the 'use' element is hooked into the document tree and the the value of 'xlink:href' is set invalid.
DOMException
NO_MODIFICATION_ALLOWED_ERR: Raised if attempt is made to change a readonly trait.
setFloatTrait
Set the trait value as a float . Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to be set.
in float value The value of the trait.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element.
DOMException
TYPE_MISMATCH_ERR: Raised if the requested trait's value cannot be specified as a numeric float (e.g. NaN ).
DOMException
INVALID_ACCESS_ERR: Raised if the input value is an invalid value for the given trait or null is specified.
setFloatListTrait
Set the trait value as a sequence<float> .Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to be set.
in sequence<float> value The value of the trait.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element.
DOMException
TYPE_MISMATCH_ERR: Raised if the requested trait's value cannot be specified as a sequence<float>).
DOMException
INVALID_ACCESS_ERR: Raised if the input value is an invalid value for the given trait or null is specified.
setMatrixTrait
Set the trait value as an SVGMatrix . Values in SVGMatrix are copied in the trait so subsequent changes to the given SVGMatrix have no effect on the value of the trait. Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to be set.
in SVGMatrix value The value of the trait.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element.
DOMException
TYPE_MISMATCH_ERR: Raised if the requested trait's value cannot be specified as an SVGMatrix .
DOMException
INVALID_ACCESS_ERR: Raised if the input value is null .
setRectTrait
Set the trait value as an SVGRect . Values in SVGRect are copied in the trait so subsequent changes to the given SVGRect have no effect on the value of the trait. Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to be set.
in SVGRect value The value of the trait.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element.
DOMException
TYPE_MISMATCH_ERR: Raised if the requested trait's value cannot be specified as an SVGRect .
DOMException
INVALID_ACCESS_ERR: Raised if the input value is an invalid value for the given trait or null is specified. An SVGRect is invalid if the width or height values are set to negative.. negative.
setPathTrait
Set the trait value as an SVGPath . Values in SVGPath are copied in the trait so subsequent changes to the given SVGPath have no effect on the value of the trait. Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to be set.
in SVGPath value The value of the trait.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element.
DOMException
TYPE_MISMATCH_ERR: Raised if the requested trait's value cannot be specified as an SVGPath .
DOMException
INVALID_ACCESS_ERR: Raised if the input value is an invalid value for the given trait or null is specified. An SVGPath is invalid if it begins with any segment other than MOVE_TO segment.
Note: An empty SVGPath is still a valid value.
setRGBColorTrait
Set the trait value as an SVGRGBColor . Values in SVGRGBColor are copied in the trait so subsequent changes to the given SVGRGBColor have no effect on the value of the trait. Parameter name must be a non-qualified trait name, i.e. without prefix.
Parameters
in DOMString name The name of the trait to be set.
in SVGRGBColor value The value of the trait.
No Return value
Exceptions
DOMException
NOT_SUPPORTED_ERR: Raised if the requested trait is not supported on this element.
DOMException
TYPE_MISMATCH_ERR: Raised if the requested trait's value cannot be specified as an SVGRGBColor .
DOMException
INVALID_ACCESS_ERR: Raised if the input value is null .

Traits supported in this specification, SVG Tiny 1.2 uDOM

Trait access is not required on all of the SVG Tiny attributes and properties . The table below shows the attributes and properties that SVG Tiny DOM 1.2 implementations must support trait access to. Each attribute row lists the allowed getter and setter(s). The 'Default 'Lacuna Values' column specifies the default lacuna values that must be used for each attribute or property. If a 'Default 'Lacuna Values' column entry is empty, there is no default lacuna value . Unless explicitly stated in the 'Comments' column, a supported attribute is accessible on all elements it can belong to. See the attribute section for a list of attributes and which elements they belong to.

Implementations that support multiple versions of svg must allow trait access to the most extensive set and support the types supported by each trait in the most extensive set. However, content relying on traits or trait types available in future versions may not work in all conformant SVG Tiny 1.2 uDOM implementations.

For 'required' attributes, there are two cases:

The User Agent user agent must raise a NOT_SUPPORTED_ERR whenever there is an attempt to use trait methods for traits which are not supported by the UA.

Note: For some of the attributes and data types additional rules apply. These rules are defined below the table.

Note: In the table below:

-See RGB access rule . -See RGB access rule . -See RGB access rule . "text" getTrait("#text") ["text content"] setTrait("#text", "text content") -See RGB access rule .
Attribute Trait Target Trait Getter
[Return Value]
Trait Setter
[Argument Value]
Default Lacuna Values Comments
Element text content accumulate getTrait ("#text")
[The element text content]
setTrait ("#text", ...)
[New element text content]
See Text Content Access .
accumulate , attribute getTrait ("accumulate")
[none | sum]
setTrait ("accumulate", ...)
[none | sum]
none "none"
additive , attribute getTrait ("additive")
[replace | sum]
setTrait ("additive", ...)
[replace | sum]
replace "replace"
attributeName , attribute getTrait setTrait ("attributeName") setTrait ("attributeName", ...)
audio-level , property getFloatTrait [value >= 0 && ("audio-level")
[0 ≤ value <= 1]
setFloatTrait [value >= 0 && ("audio-level", ...)
[0 ≤ value <= 1]

setTrait ("audio-level", ...)
[inherit]
1.0f 1.0
baseProfile , attribute getTrait ("baseProfile") setTrait ("baseProfile", ...) "tiny" "none"
begin , attribute N/A setTrait setTrait ("begin", ...)
calcMode , attribute getTrait ("calcMode")
[discrete | linear | paced | spline]
setTrait ("calcMode", ...)
[discrete | linear | paced | spline] linear (except for animateMotion)
paced (for animateMotion)
"paced" when accessed on an 'animateMotion' element, "linear" otherwise
color , property getRGBColorTrait [SVGRGBColor] ("color")
[null, SVGRGBColor ]
getTrait [SVGRGBColor]
setRGBColorTrait [SVGRGBColor] ("color, ...")
setTrait ("color", ...)
[inherit | SVGRGBColor] <color> ]
rgb(0,0,0)
cx , attribute getFloatTrait ("cx") setFloatTrait ("cx", ...) 0.0f 0.5 when accessed on a 'radialGradient' element, 0.0 otherwise
cy , attribute getFloatTrait ("cy") setFloatTrait ("cy", ...) 0.0f 0.5 when accessed on a 'radialGradient' element, 0.0 otherwise
d , attribute getPathTrait [SVGPath] ("d") setPathTrait [SVGPath] ("d", ...) REQUIRED(Empty SVGPath) An SVGPath object with no path segments See Accessing rules for path attributes .
display , property getTrait ("display")
[inline | none ] none]
setTrait ("display", ...)
[inline | none | inherit ] inherit]
"inline" -See See Display access rule Accessing rules for 'display' property .
dur , attribute N/A setTrait setTrait ("dur", ...)
editable , attribute getTrait ("editable")
[simple | none]
setTrait ("editable, ...)
[simple | none]
"none"
end , attribute N/A setTrait ("end", ...)
fill , property getRGBColorTrait [SVGRGBColor] ("fill")
[null, SVGRGBColor ]

getTrait ("fill")
[none | SVGRGBColor] <color> | <system paint> | IRI]
setRGBColorTrait [SVGRGBColor] ("fill", ...)
setTrait ("fill", ...)
[none | currentColor | inherit IRI | SVGRGBColor] rgb(0,0,0) -See RGB access rule . -Attribute defining the fill-color. fill <color> getTrait[freeze | remove] setTrait[freeze <system paint> | remove] inherit]
"remove" rgb(0,0,0) -Attribute defining There are no trait accessors for the fill behavior of a smil animation element. element 'fill' attribute.
fill-opacity , property getFloatTrait [value >= 0 && ("fill-opacity")
[0 ≤ value <= 1]
setFloatTrait [value >= 0 && ("fill-opacity", ...)
[0 ≤ value <= 1]

setTrait ("fill-opacity", ...)
[inherit]
setTrait[inherit] 1.0f
1.0
fill-rule , property getTrait ("fill-rule")
[nonzero | evenodd]
setTrait ("fill-rule", ...)
[nonzero | evenodd | inherit]
"nonzero"
focusable , attribute getTrait ("focusable")
[true | false]
setTrait ("focusable", ...)
[true | false | auto]
"auto"
focusHighlight , attribute nav-right getTrait ("focusHighlight")
[auto | none]
getTrait setTrait ("focusHighlight", ...)
[auto | url( <Local IRI Reference> none]
"auto"
font-family , property getTrait ) | self] ("font-family") setTrait [url( <Local IRI Reference> ) | auto ("font-family", ...)
[ <font-family-value> | self] inherit]
"auto" User agent specific See Accessing rules for font properties .
nav-next font-size , property getFloatTrait ("font-size")
[ value ≥ 0]
getTrait [auto setFloatTrait ("font-size", ...)
[ value ≥ 0]

setTrait ("font-size", ...)
[xx-small | url( <Local IRI Reference> x-small | small | medium | large | x-large | xx-large | larger | smaller | inherit]
User agent specific
font-style , property getTrait ) ("font-style")
[normal | self] italic | oblique]
setTrait [url( <Local IRI Reference> ) ("font-style", ...)
[normal | auto italic | self] oblique | inherit]
"auto" "normal" See Accessing rules for font properties .
nav-up font-weight , property getTrait [auto | url( <Local IRI Reference> ) ("font-weight")
[100 | self] 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900]
setTrait [url( <Local IRI Reference> ) ("font-weight", ...)
[normal | auto bold | self] bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | inherit]
"auto" "normal" See Accessing rules for font properties .
nav-up-right from , attribute N/A setTrait ("from", ...)
gradientUnits , attribute getTrait [auto | url( <Local IRI Reference> ) ("gradientUnits")
[userSpaceOnUse | self] objectBoundingBox]
setTrait [url( <Local IRI Reference> ) | auto ("gradientUnits", ...)
[userSpaceOnUse | self] objectBoundingBox]
"auto" "objectBoundingBox"
height , attribute nav-up-left getFloatTrait ("height")
[ value ≥ 0]

getTrait [auto | url( <Local IRI Reference> ) | self] ("height")
["auto"]
setFloatTrait ("height", ...)
[ value ≥ 0]

setTrait [url( <Local IRI Reference> ) | auto | self] ("height", ...)
["auto"]
"auto" when accessed on a 'textArea' element, 0.0 otherwise See Accessing rules for 'width' and 'height' attributes .
id , attribute getTrait ("id") setTrait ("id", ...)
nav-prev keyPoints , attribute N/A setTrait ("keyPoints", ...)
getTrait [auto | url( <Local IRI Reference> keySplines , attribute N/A setTrait ) | self] ("keySplines", ...)
keyTimes , attribute N/A setTrait [url( <Local IRI Reference> ) | auto | self] ("keyTimes", ...)
"auto" max , attribute N/A setTrait ("max", ...)
nav-down min , attribute N/A setTrait ("min", ...)
nav-right , attribute getTrait ("nav-right")
[auto | self | url( <Local IRI Reference> ) | self] )]
setTrait [url( ("nav-right", ...)
[auto | self | url( <Local IRI Reference> ) | auto | self] )]
"auto"
nav-next , attribute nav-down-right getTrait ("nav-next")
[auto | self | url( <Local IRI Reference> ) | self] )]
setTrait [url( ("nav-next", ...)
[auto | self | url( <Local IRI Reference> ) | auto | self] )]
"auto"
nav-up , attribute nav-down-left getTrait ("nav-up")
[auto | self | url( <Local IRI Reference> ) | self] )]
setTrait [url( ("nav-up", ...)
[auto | self | url( <Local IRI Reference> ) | auto | self] )]
"auto"
nav-up-right , attribute nav-left getTrait ("nav-up-right")
[auto | self | url( <Local IRI Reference> ) | self] )]
setTrait [url( ("nav-up-right", ...)
[auto | self | url( <Local IRI Reference> ) | auto | self] )]
"auto"
nav-up-left , attribute focusHighlight getTrait [auto| none] ("nav-up-left")
[auto | self | url( <Local IRI Reference> )]
setTrait [auto| none] ("nav-up-left", ...)
[auto | self | url( <Local IRI Reference> )]
"auto"
nav-prev , attribute font-family getTrait [the font-family computed value listed in the same syntax as the font-family property] setTrait [same syntax as font-family attribute] User-Agent ("nav-prev") font-size
[auto | self | url( <Local IRI Reference> )]
getFloatTrait [value >= 0] setFloatTrait [value >= 0] setTrait [inherit | xx-small | x-small | small | medium | large | x-large | xx-large ("nav-prev", ...)
[auto | larger self | smaller] url( <Local IRI Reference> )]
User-Agent "auto"
nav-down , attribute font-style getTrait [normal ("nav-down")
[auto | italic self | oblique ] url( <Local IRI Reference> )]
setTrait [normal | italic ("nav-down", ...)
[auto | oblique self | inherit] url( <Local IRI Reference> )]
"normal" "auto"
nav-down-right , attribute font-weight getTrait [100 | 200 | 300 | 400 | 500 | 600 | 700 ("nav-down-right")
[auto | 800 self | 900 ] url( <Local IRI Reference> )]
setTrait [normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 ("nav-down-right", ...)
[auto | 900 self | inherit] url( <Local IRI Reference> )]
"normal" "auto"
nav-down-left , attribute gradientUnits getTrait [userSpaceOnUse ("nav-down-left")
[auto | objectBoundingBox] setTrait [userSpaceOnUse self | objectBoundingBox] "objectBoundingBox" url( <Local IRI Reference> )]
height setTrait ("nav-down-left", ...)
[auto | self | url( <Local IRI Reference> )]
getFloatTrait [value >= 0] setFloatTrait [value >= 0] "auto"
REQUIRED(0.0f) nav-left , attribute If the height is specified as a percentage or unit value (only possible for the 'svg' getTrait 'height' ("nav-left")
[auto | self | url( <Local IRI Reference> ), a DOMException with error code TYPE_MISMATCH_ERR is raised since the requested trait's computed value is returned as a non-numeric float value (e.g. NaN). )]
id setTrait ("nav-left", ...)
[auto | self | url( <Local IRI Reference> )]
getTrait setTrait "auto"
offset , attribute keyPoints getFloatTrait ("offset") N/A setTrait
[0 ≤ value ≤ 1]
keySplines setFloatTrait ("offset", ...) N/A setTrait
[0 ≤ value ≤ 1]
opacity , property keyTimes getFloatTrait ("opacity") N/A setTrait
[0 ≤ value ≤ 1]
max setFloatTrait ("opacity", ...) N/A
[0 ≤ value ≤ 1]

setTrait ("opacity", ...)
[inherit]
min N/A setTrait path , attribute getPathTrait ("path") offset getFloatTrait[value >= 0 && value <= 1] setFloatTrait[value >= 0 && value <= 1] setPathTrait ("path", ...) opacity getFloatTrait [value >= 0 && value <= 1] An SVGPath object with no path segments setFloatTrait [value >= 0 && value <= 1] setTrait[inherit] See Accessing rules for path attributes .
points , attribute path getFloatListTrait ("points") getPathTrait [SVGPath] setPathTrait [SVGPath] REQUIRED(Empty SVGPath) setFloatListTrait ("points", ...)
r , attribute getFloatTrait ("r")
[ value >= 0]
setFloatTrait [value >= ("r", ...)
[ value 0]
REQUIRED (0.0f) 0.5 when accessed on a 'radialGradient' element, 0.0 otherwise
repeatCount , attribute N/A setTrait setTrait ("repeatCount", ...)
repeatDur , attribute N/A setTrait setTrait ("repeatDur", ...)
restart , attribute getTrait ("restart")
[always | whenNotActive | never]
setTrait ("restart", ...)
[always | whenNotActive | never]
always "always"
rx , attribute getFloatTrait [value >= ("rx")
[ value 0]
setFloatTrait [value >= ("rx", ...)
[ value 0]
0.0f 0.0
ry , attribute getFloatTrait [value >= ("ry")
[ value 0]
setFloatTrait [value >= ("ry", ...)
[ value 0]
0.0f 0.0
snapshotTime , attribute getFloatTrait [value >= ("snapshotTime")
[ value 0]
setFloatTrait [value >= ("snapshotTime", ...)
[ value 0]
0.0f 0.0
solid-color , property getRGBColorTrait [SVGRGBColor] ("solid-color")
[null, SVGRGBColor ]
getTrait [SVGRGBColor]
setRGBColorTrait [SVGRGBColor] ("solid-color", ...)
setTrait [SVGRGBColor ("solid-color", ...)
[ <color> | inherit]
rgb(0,0,0)
solid-opacity , property getFloatTrait [value >= 0 && ("solid-opacity")
[0 ≤ value <= 1]
setFloatTrait [value >= 0 && ("solid-opacity", ...)
[0 ≤ value <= 1]

setTrait ("solid-opacity")
[inherit]
1.0f
stop-color , property getRGBColorTrait [SVGRGBColor] ("stop-color")
[null, SVGRGBColor ]

getTrait ("stop-color")
[none | SVGRGBColor] <color> ]
setRGBColorTrait [SVGRGBColor] ("stop-color", ...) setTrait(none
setTrait ("stop-color")
[none | currentColor | inherit <color> | SVGRGBColor] inherit]
rgb(0,0,0)
stop-opacity , property getFloatTrait [value >= 0 && ("stop-opacity")
[0 ≤ value <= 1]
setFloatTrait [value >= 0 && ("stop-opacity", ...)
[0 ≤ value <= 1]

setTrait ("stop-opacity", ...)
[inherit]
setTrait[inherit]
1.0f
stroke , property getRGBColorTrait [SVGRGBColor] ("stroke")
[null, SVGRGBColor ]

getTrait ("stroke")
[none | SVGRGBColor] <color> | <system paint> | IRI]
setRGBColorTrait [SVGRGBColor] ("stroke", ...)
setTrait ("stroke", ...)
[none | currentColor | inherit IRI | SVGRGBColor] <color> | <system paint> | inherit]
"none"
-See RGB access rule . stroke-dasharray , property getFloatListTrait ("stroke-dasharray")
getTrait ("stroke-dasharray")
[none, inherit]
setFloatListTrait ("stroke-dasharray", ...)
setTrait ("stroke-dasharray", ...)
[none, inherit]
"none"
stroke-dashoffset , property getFloatTrait ("stroke-dashoffset") setFloatTrait ("stroke-dashoffset", ...)

setTrait ("stroke-dashoffset", ...)
[inherit]
setFloatTrait
0.0f 0.0
stroke-linecap , property getTrait ("stroke-linecap")
[butt | round | square]
setTrait ("stroke-linecap", ...)
[butt | round | square | inherit]
"butt"
stroke-linejoin , property getTrait ("stroke-linejoin")
[miter | round | bevel ] bevel]
setTrait ("stroke-linejoin", ...)
[miter | round | bevel | inherit]
"miter"
stroke-miterlimit , property getFloatTrait ("stroke-miterlimit")
[ value >= 1]
setTrait [inherit] setFloatTrait [value >= ("stroke-miterlimit")
[ value 1]

setTrait ("stroke-miterlimit", ...)
[inherit]
4.0f 4.0
stroke-opacity , property getFloatTrait [value >= 0 && ("stroke-opacity")
[0 ≤ value <= 1]
setFloatTrait [value >= 0 && ("stroke-opacity", ...)
[0 ≤ value <= 1]

setTrait ("stroke-opacity", ...)
[inherit]
setTrait[inherit] 1.0f
1.0
stroke-width , property getFloatTrait [value >= ("stroke-width")
[ value 0]
setTrait [inherit] setFloatTrait [value >= ("stroke-width", ...)
[ value 0]

setTrait ("stroke-width", ...)
[inherit]
1.0f 1.0
target , attribute getTrait setTrait "_self" ("target") setTrait ("target", ...) -See Text Node Access for details. "_self"
text-anchor , property getTrait ("text-anchor")
[start | middle | end]
setTrait ("text-anchor", ...)
[start | middle | end | inherit ] inherit]
"start"
to , attribute N/A setTrait ("to", ...)
transform , attribute getMatrixTrait [SVGMatrix] ("transform")
getTrait ("transform")
setMatrixTrait [SVGMatrix] ("transform", ...)
setTrait ("transform", ...)
Identity matrix (1,0,0,1,0,0) -See Transform access rule See Accessing rules for 'transform' attribute .
type , attribute For animateTransform: getTrait ("type")
[translate | scale | rotate | skewX | skewY]
For animateTransform: setTrait ("type", ...)
[translate | scale | rotate | skewX | skewY]
These are the trait accessors for the 'type' attribute on the 'animateTransform' element. There are no trait accessors for the 'type' attribute on the 'audio' , 'handler' ,'image' ,'script' and 'video' elements.
values , attribute N/A setTrait setTrait ("values", ...)
vector-effect , property getTrait ("vector-effect")
[none | non-scaling-stroke]
setTrait ("vector-effect", ...)
[none | non-scaling-stroke | inherit]
"none"
version , attribute getTrait ("version") setTrait ("version", ...) "1.2" User-Agent
viewBox , attribute getRectTrait [null, SVGRect] ("viewBox")
[ null | SVGRect ]
setRectTrait [SVGRect] ("viewBox", ...)
setTrait ("viewBox", ...)
[none]
null If the actual trait value is not an SVGRect 'viewBox' (i.e. "none"), attribute has the value 'none' , the getRectTrait method will return null .
viewport-fill , property getRGBColorTrait [SVGRGBColor] ("viewport-fill")
[null, SVGRGBColor ]

getTrait ("viewport-fill")
[none | SVGRGBColor] <color> ]
setRGBColorTrait [SVGRGBColor] ("viewport-fill", ...)
setTrait ("viewport-fill", ...)
[none | currentColor | SVGRGBColor <color> | inherit]
"none"
viewport-fill-opacity , property getFloatTrait [value >= 0 && ("viewport-fill-opacity")
[0 ≤ value <= 1]
setFloatTrait [value >= 0 && ("viewport-fill-opacity", ...)
[0 ≤ value <= 1]

setTrait ("viewport-fill-opacity", ...)
[inherit]
1.0f 1.0
visibility , property getTrait ("visibility")
[visible | hidden]
setTrait ("visibility", ...)
[visible | hidden | inherit]
"visible"
width , attribute getFloatTrait ("width")
[ value >= 0]

getTrait ("width")
["auto"]
setFloatTrait ("width", ...)
[ value >= 0]

setTrait ("width", ...)
["auto" ]
REQUIRED (0.0f) If the width is specified as "auto" when accessed on a percentage or unit value (only possible for the 'svg' 'textArea' element, 0.0 otherwise See Accessing rules for 'width' ), a DOMException with error code TYPE_MISMATCH_ERR is raised since the requested trait's computed value is returned as a non-numeric float value (e.g. NaN). and 'height' attributes .
x , attribute getFloatTrait ("x")

getFloatListTrait ("x") (array of x-values not supported)
setFloatTrait ("x", ...)

setFloatListTrait ("x", ...) (array of x-values not supported)
0.0f 0.0 See Accessing rules for 'x' and 'y' attributes .
x1 , attribute getFloatTrait ("x1") setFloatTrait ("x1", ...) 0.0f 0.0
x2 , attribute getFloatTrait ("x2") setFloatTrait ("x2", ...) 0.0f 1.0 when accessed on a 'linearGradient' element, 0.0 otherwise
xlink:href , attribute getTraitNS [absolute IRI or null getTraitNS ("http://www.w3.org/1999/xlink", "href") ]
[absolute IRI]
setTraitNS ("http://www.w3.org/1999/xlink", "href", ...) ""
y , attribute getFloatTrait ("y")

getFloatListTrait ("y") (array of y-values not supported)
setFloatTrait ("y", ...)

setFloatListTrait ("y", ...) (array of y-values not supported)
0.0f 0.0 See Accessing rules for 'x' and 'y' attributes .
y1 , attribute getFloatTrait ("y1") setFloatTrait ("y1", ...) 0.0f 0.0
y2 , attribute getFloatTrait ("y2") setFloatTrait ("y2", ...) 0.0f 0.0
zoomAndPan , attribute getTrait ("zoomAndPan")
[disable | magnify]
setTrait ("zoomAndPan", ...)
[disable | magnify]
"magnify"

A.8.13 Additional accessing rules

Accessing rules for RGBColorTrait The getRGBColorTrait is used to get the SVGRGBColor color. If the actual trait value is not an SVGRGBColor , i.e. 'none' or a paint server (e.g. a gradient , system paint, or solid-color ), this method must raise a DOMException with error code TYPE_MISMATCH_ERR and getTrait should be used instead. setTrait must be used to set a color type that is not an SVGRGBColor .

Accessing rules for 'transform' attribute

The 'transform' attribute in SVGT1.2 SVG Tiny 1.2 can have three types of values. The "normal" transformation list (e.g. scale, translate, rotate, matrix etc), the newly introduced 'ref(svg)' type or 'none' . getMatrixTrait returns the current evaluated matrix in all cases. If the user needs to know that the 'transform' attribute value was a 'ref' or a 'none' getTrait must be used. By using setTrait the user can set the 'transform' attribute to 'ref(svg)' or 'none' .

Accessing rules for 'display' property

Due to backward compatibility reasons the 'display' values accessible via the trait mechanism are limited to 'none' and 'inline' , all other values are translated into 'none' or 'inline' . (For a list of all possible 'display' values, see Controlling visibility .) If other 'display' values are of interest, e.g. the user want to set display to 'block' , the more generic getAttributeNS / setAttributeNS must be used. Note however that an SVGT1.2 SVG Tiny 1.2 user agent is allowed to normalize its attribute data as described in Display Normalization .

Accessing rules for animation and font related elements

The following rule applies to SMIL-animation SMIL animation elements ( 'animate' , 'animateTransform' , 'animateColor' , 'animateMotion' , 'set' ) and font element with its children ( 'font' , 'font-face' , 'missing-glyph' , 'glyph' , 'hkern' , 'font-face-src' , 'font-face-uri' , 'discard' ).

These elements can be inserted and removed from the tree but they cannot be modified using the TraitAccess methods once inserted into the tree. Manipulating animations while they are in If an attempt is made to do so, the uDOM tree TraitAccess method will throw a DOMException with code NOT_SUPPORTED_ERR. Modifying the element using the setAttribute and possibly active would result in undefined behaviour. This may also setAttributeNS methods of the Element interface will change the document, but will have an no effect on past resolved times. the animation.

This restriction means that if the author wishes to add animations via script, the element attributes of the animation elements must be modified when it is not attached to before being inserted into the tree. A similar reasoning applies to the different font elements, modifying them while attached to the tree might lead to unpredictable result. Following The following is an example of adding an animation to the tree including document, setting the properties relevant attributes prior to insertion.

Example: Animating via the uDOM
<svg version="1.2" baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" xml:id="svg-root"
width="100%" height="100%" viewBox="0 0 480 360">
<rect xml:id="myRect" fill="green" x="10" y="10" width="200" height="100" stroke="black" stroke-width="2"/>

      width="100%" height="100%" viewBox="0 0 480 360">
    <rect xml:id="myRect" fill="green" x="10" y="10" width="200" height="100" stroke="black" stroke-width="2"/>

</svg>
A script (java) such as the following Java code might be used to add an animation to the rectangle:
SVGElement newAnimate = (SVGElement)document.createElementNS(svgNS, "animate");
newAnimate.setTrait("attributeName", "fill");
newAnimate.setTrait("from", "red");
newAnimate.setTrait("to", "blue");
newAnimate.setTrait("dur", "5");
newAnimate.setTrait("repeatCount", "10");
Element myRect = document.getElementById("myRect");
myRect.appendChild(newAnimate);
A.8.14 ElementTraversal

Accessing rules for 'x' This interface provides a way to traverse elements in the uDOM tree. It and 'y' attributes

If getFloatTrait is needed mainly because SVG Tiny uDOM does not expose character data nodes. Each element in the SVG Tiny document tree implements this interface. This applies used to elements in retrieve the foreign namespaces as well. IDL Definition interface ElementTraversal { readonly attribute Element firstElementChild; readonly attribute Element lastElementChild; readonly attribute Element nextElementSibling; readonly attribute Element previousElementSibling; }; No defined constants Attributes firstElementChild value of the 'x' Returns or 'y' attribute on a 'text' element, where the first child element node of attribute value has more than one <coordinate> ,a DOMException with error code TYPE_MISMATCH_ERR must be raised. When the attribute value has only one coordinate, this element. is the value returned by null getFloatTrait .

If getFloatListTrait if this element has no child elements. lastElementChild last child element node of this element. or null setFloatListTrait if this element has no child elements. nextElementSibling are used on elements other than a 'text' Returns the next sibling element node of this element. element, a DOMException with error code TYPE_MISMATCH_ERR must be raised.

Accessing rules for 'width' and 'height' attributes

If null getFloatTrait if this element has no element sibling nodes that come after this one in is used to retrieve the document tree. previousElementSibling value of the 'width' previous sibling element node or 'height' attribute on an 'svg' element, where the value is specified as a percentage or unit value, a DOMException with error code TYPE_MISMATCH_ERR must be raised .

Accessing rules for font properties

If trait accessors are used to get or set the 'font-family' ,'font-style' or 'font-weight' properties on a 'font-face' element, a DOMException with error code NOT_SUPPORTED_ERR must be raised.

Accessing rules for path attributes

If the getPathTrait method is used to get an SVGPath and the path attribute had an error at some point the returned SVGPath must contain a valid SVGPath containing all valid path segments up till the point of this element. the error.

Accessing rules for multimedia elements

The following rule applies to multimedia elements ( 'audio' ,'video' ,'animation' ).

SVG Timing attributes cannot be modified using the TraitAccess methods once inserted into the tree. If an attempt is made to do so, the TraitAccess method will throw a DOMException with code NOT_SUPPORTED_ERR. Modifying these attributes using the null setAttribute if this element has and setAttributeNS methods of the Element interface will change the document, but will have no element sibling nodes that come before this one in effect on the document tree. No defined methods element.

A.8.15 A.8.14 SVGElement

This interface represents an SVG element in the document tree. It provides methods to traverse elements in the uDOM tree and allows setting and getting the id 'id' of an element.
Note: See the definition of id and xml:id for the rules of how to treat id and 'id' xml:id and . 'xml:id' .

IDL Definition
interface SVGElement : Element, EventTarget, TraitAccess, ElementTraversal

interface SVGElement : Element, EventTarget, TraitAccess

{
        attribute DOMString id;
};
No defined constants
Attributes
id
On read : read: Returns the element's xml:id (or id) attribute according to the rules defined in the Structure chapter , null if no id specified.
On write : write: Sets the element's id and xml:id attribute according to the rules defined in the Structure chapter .
No defined methods

A.8.16 A.8.15 SVGTimedElement

This interface represents an SVGTimedElement which is implemented by Timed Elements and the svg 'svg' element.
IDL Definition
interface SVGTimedElement : SVGElement, smil::ElementTimeControl
{
        void pauseElement();
        void resumeElement();
        readonly attribute boolean isPaused;
};
No defined constants
Attributes
isPaused
true if the animation Timed Element is paused. false otherwise. See Paused element and the active duration .
Note: An element that is stopped (has reached the end of its active duration) is not paused.
Methods
pauseElement
Pauses the timed element. See Paused element and the active duration .
No Parameters
No Return value
No Exceptions
resumeElement
Resumes the timed element. See Paused element and the active duration .
No Parameters
No Return value
No Exceptions

A.8.16 SVGAnimationElement

This interface is implemented by the following SMIL animation elements: 'animate' ,'animateTransform' ,'animateColor' ,'animateMotion' ,'set' .It is included for historical reasons and has been deprecated. Note that this interface is unrelated to the new 'animation' element.

IDL Definition

interface SVGAnimationElement : SVGTimedElement
{
};

No defined constants
No defined attributes
No defined methods

A.8.17 SVGVisualMediaElement

This interface represents a media element that is visual, i.e. has a physical location on the screen.
This interface is implemented by: 'animation' and 'video' .
IDL Definition
interface SVGVisualMediaElement : SVGLocatableElement, SVGTimedElement
{
};
No defined constants
No defined attributes
No defined methods

A.8.18 EventListenerInitializer2 SVGTimer

EventListenerInitializer2 The SVGTimer allows event listeners to be initialized. In typical usage with Java, interface provides an API for scheduling a 'script' one time or repetitive event. A SVGTimer element references a JAR file which contains a manifest entry ( object is always either in the running (attribute running is SVG-Handler-Class true ) which identifies or waiting (attribute running is false ) state. After each interval of the class responsible for creating timer, an Event of type SVGTimer is triggered.

SVGTimer events are triggered only when the timer is in the running state. The SVGTimer event listeners. Further information about EventListenerInitializer2 is limited to the target phase. Since SVGTimer is an EventTarget ,EventListeners can be found in registered on it using addEventListener with SVGTimer as the Scripting chapter . event type. Event listeners can access their corresponding SVGTimer object through the event object's target property.

Note: Script code must not invoke the EventListenerInitializer2 SVGTimer methods directly (they are instances are only called by the User Agent implementation during created using the parsing or execution of 'script' , 'listener' or 'handler' createTimer elements). User Agents must prevent user scripts from invoking method of the methods. SVGGlobal interface.

IDL Definition
interface EventListenerInitializer2

interface SVGTimer : events::EventTarget

{
  void initializeEventListeners( in Element scriptElement );
        EventListener createEventListener( in Element handlerElement );

  attribute long delay;
        attribute long repeatInterval;
        readonly attribute boolean running;
        void start();
        void stop();

};
No defined constants
No defined attributes Methods Attributes
initializeEventListeners delay
For each 'script' element, at load

This attribute specifies the time for that element, remaining in milliseconds until the user agent finds next event is fired. When the appropriate object which implements SVGTimer is in the EventListenerInitializer2 interface. (For Java, it running state this attribute is dynamically updated to reflect the class identified by remaining time in the SVG-Handler-Class manifest entry). The user agent then invokes current interval. When the SVGTimer is initializeEventListeners waiting method, which allows the scripting code to register event listeners. Parameters in Element scriptElement The 'script' element which has been loaded. No Return value No Exceptions createEventListener For each <handler> element, at load delay reflects the time for that element, remained when stopped. Getting the user agent finds delay attribute returns the appropriate object which implements current value, i.e. a snapshot value of the EventListenerInitializer2 interface. (For Java, it remaining delay. After delay period has passed while the object is in the class identified by running state, the SVG-Handler-Class manifest entry). SVGTimer object will trigger an Event of type SVGTimer . The user agent delay will then invokes be updated with the createEventListener repeatInterval method, which allows value and a new count down will start. Setting the scripting code delay resets the current interval to register an appropriate event listener. This method returns the event listener that will handle events. The user agent must register new value. If this event listener with attribute is 0 ,it means that the event target identified by will be triggered as soon as possible. Assigning a negative value is equivalent to calling the 'handler' element. Parameters in stop() Element handlerElement method. The 'handler' element which has been loaded. Return initial value is set through the initialInterval parameter in the createTimer EventListener The created EventListener . method on the SVGGlobal interface, and defines the first interval of the SVGTimer .

No Exceptions repeatInterval

Example #1: The usage This attribute specifies in milliseconds the interval for each repeat of java together with the 'script' element The example rely on SVGTimer ,i.e. each timer interval subsequent to the fact initial interval. The initial value of this attribute is set through the 'exclasses.jar' JAR file contains a MANIFEST repeatInterval file with parameter in the following entry: SVG-Handler-Class: org.example.SVGHandler createTimer Given the following SVG document: <svg xmlns:svg="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 500 500"> <script type="application/java-archive" xlink:href="exclasses.jar"/> <rect xml:id="therect" x="0" y="0" width="100" height="100"/> </svg> Given that the SVGHandler implementation available in method on the 'exclasses.jar' SVGGlobal JAR file is interface. Assigning a negative value disables the following: package org.example; import org.w3c.dom.*; import org.w3c.dom.svg.*; public class SVGHandler implements EventListenerInitializer2 { public void initializeEventListeners (Element scriptElement) { Document document = scriptElement.getOwnerDocument(); EventTarget rect = (EventTarget) document.getElementById("therect"); rect.addEventListenerNS("http://www.w3.org/2001/xml-events", "click", new SVGHandler(), null, false, null); } public EventListener createEventListener (Element handlerElement) {} } An instance repetitive triggering of "SVGHandler" listener will be called when the event making it a 'click' one time timer which triggers an event will occur on after the 'rect' element. Example #2: The usage of java together with the 'handler' element delay .

running

The example rely on the fact the 'exclasses.jar' JAR file contains a SVGTimer state. Value is MANIFEST true file with if the following entry: timer is running, SVG-Handler-Class: org.example.SVGHandler false Given the following SVG document: <svg xmlns:svg="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 500 500" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:exns="http://example.org/exNS"> <script xml:id="init" type="application/java-archive" xlink:href="exclasses.jar"/> <rect xml:id="therect" x="0" y="0" width="100" height="100"> <handler type="application/java" ev:event="click" xlink:href="#init" exns:listenerClass="SVGHandler"/> </rect> </svg> Given that the SVGHandler implementation available in if the 'exclasses.jar' JAR file timer is waiting. Note that the following: package org.example; import org.w3c.dom.*; import org.w3c.dom.svg.*; public class SVGHandler implements EventListenerInitializer2 { public void initializeEventListeners (Element scriptElement) {} public EventListener createEventListener (Element handlerElement) { EventListener listenerInstance = null; try { String listenerClass = handlerElement.getAttributeNS("http://example.org/exNS", "listenerClass"); listenerInstance = Class.forName(listenerClass).newInstance(); } catch (Exception e) {} return listenerInstance; } } An instance of "SVGHandler" listener will be called when a 'click' repeatInterval event will occur on the 'rect' element. What and createEventListener delay does is totally in the hand of the developer, the listener instance properties can be hardcoded or fully configured from information put on non-negative if the 'handler' element as shown here. timer is stopped (but if delay is negative, the timer is stopped).

A.8.19 TimeEvent
Methods
start

This interface is the SVG hosted version of Changes the TimeEvent SVGTimer interface defined in smil animation state into running . Event that If the timer is fired by all Timed Elements . Event types that are TimeEvents : already in the running state, it has no effect. Initially the timer is beginEvent waiting , and must be started with this method. If the timer endEvent delay , had a negative value when started, for example if the time had been stopped by setting the delay to a negative value, the delay value is reset to repeatEvent repeatInterval . when the this method is called.

IDL Definition
No Parameters
interface TimeEvent : Event { readonly attribute long detail; };
No defined constants Return value
Attributes No Exceptions
detail stop
Specifies detailed information about the TimeEvent , the information depends on

Changes the type of event. For beginEvent SVGTimer and state into endEvent waiting . If the detail field timer is not used. For repeatEvent already in the waiting state, calling this method has no effect.

detail No Parameters field contains the current repeat iteration.
No defined methods Return value
No Exceptions

A.8.20 A.8.19 SVGGlobal

The majority of Many scripted SVG documents in existence make use of the functions on a browser specific Window interface. SVGT SVG Tiny 1.2 specifies an SVGGlobal interface, taking into account the de-facto on which some of these de facto standard that already exists, functions are defined, as well as adding the some functions for new features present defines in SVGT 1.2. this specification. The SVGGlobal inherits from the Global interface, which is currently defined to be empty. The Global interface is designed to must be implemented by the parent interface for language specific window objects. In scripting implementations, object that represents the methods and attributes defined by default view of the Global document ([ DOM2VIEWS ], section 1.1). This object are normally part of also implements AbstractView .Thus, in the ECMAScript language binding, the global execution context. Interface script object implements SVGGlobal .The SVGGlobal provides a global object for scripts embedded in an SVG document. a document can also be obtained through DocumentView::defaultView .

IDL Definition
interface SVGGlobal : Global, EventListenerInitializer2

interface SVGGlobal

{
  Connection createConnection();
        Timer createTimer(in long initialInterval, in long repeatInterval) 
                raises(GlobalException);

  SVGTimer createTimer(in long initialInterval, in long repeatInterval);

        void gotoLocation(in DOMString newIRI);
  readonly attribute Document document;
        readonly attribute Global parent;
        DOMString binaryToString(in sequence<octet> octets, in DOMString encoding) 
                raises(GlobalException);
        sequence<octet> stringToBinary(in DOMString data, in DOMString encoding) 
                raises(GlobalException);

        void getURL(in DOMString iri, in AsyncStatusCallback callback);
        void postURL(in DOMString iri, in DOMString data, in AsyncStatusCallback callback, 
                     in DOMString type, in DOMString encoding);
        Node parseXML(in DOMString data, in Document contextDoc);
};
No defined constants
Attributes No defined attributes
document The Document that this SVGGlobal operates on. parent The Global context of this document's parent. If the document has no notion of parent (e.g. when the document is displayed in a stand-alone viewer) the parent is null .
Methods
createConnection Creates a Connection object. No Parameters Return value Connection The created Connection . No Exceptions createTimer
Creates a Timer SVGTimer with the provided initialInterval and repeatInterval. The Timer SVGTimer will initially be in the waiting state.
Parameters
in long initialInterval Specifies the first interval in milliseconds for a repetitive Timer SVGTimer , i.e. sets the initial value of the delay attribute on Timer. SVGTimer. Or in the case the Timer SVGTimer is not repetitive it specifies the interval for the one time timer. This parameter corresponds to the delay attribute on the Timer. SVGTimer. Setting this parameter with a negative value will create a Timer SVGTimer which is in the waiting state.
in long repeatInterval Specifies the time interval on which the Timer SVGTimer repeats subsequent to the initial interval. A negative value will make the Timer SVGTimer a one time timer.
Return value
Timer SVGTimer The created Timer SVGTimer .
Exceptions No exceptions
GlobalException DENIED_ERR: Raised if the values for the parameters initialInterval and repeatInterval are not given.
gotoLocation
Requests that the user agent traverse a link to the given IRI . The result of the traversal must be identical to the traversal caused by an 'a' hyperlink with the 'target' attribute set to '_replace' . The difference is that the 'a' hyperlink is activated on user interaction but gotoLocation is activated from script. If the IRI is invalid or unresolvable, the current document remains loaded. "" means that the current document is reloaded. The current document location is the IRI of the Document object pointed to by the SVGGlobal.document field. Relative IRI references are resolved based on the current base IRI of the current document. The current document is discarded, reloaded, and reparsed. The timeline is restarted and a new load event is fired. Note: For HTTP, a pragma:no-cache is not issued and thus a fresh copy from the server is not forced if there is a cache.
Parameters
in DOMString newIRI The IRI to be traversed.
No Return value
No Exceptions
binaryToString Given a sequence of octets such as can be obtained through a Connection object and a character encoding identifier, this method returns the string produced by interpreting the sequence of octets using that character encoding. Both the UTF-8 and UTF-16 (BE and LE) encodings must be supported, implementations may support other encodings as well. Parameters in sequence<octet> data A character encoding identifier. The values "UTF-8", "UTF-16", "ISO-10646-UCS-2", and "ISO-10646-UCS-4" should be used for the various encodings and transformations of Unicode / ISO/IEC 10646. It is recommended that character encodings registered (as charsets) with the Internet Assigned Numbers Authority, other than those just listed, be referred to using their registered names; other encodings should use names starting with an "x-" prefix. in DOMString encoding A character encoding identifier. Return value DOMString The string resulting from decoding the sequence of octets. Exceptions GlobalException ENCODING_ERR: Raised if it is impossible to decode the given sequence of octets with the provided encoding (e.g. because of poorly formed data). stringToBinary Given a string and a character encoding identifier, this method returns a sequence of octets representing the string encoded using the specified encoding as can be used to transmit data using the Connection interface. Both the UTF-8 and UTF-16 (BE and LE) encodings must be supported, implementations may support other encodings as well. Parameters in DOMString data A string to be encoded using the specified encoding. in DOMString encoding A character encoding identifier. The values "UTF-8", "UTF-16", "ISO-10646-UCS-2", and "ISO-10646-UCS-4" should be used for the various encodings and transformations of Unicode / ISO/IEC 10646. It is recommended that character encodings registered (as charsets) with the Internet Assigned Numbers Authority, other than those just listed, be referred to using their registered names; other encodings should use names starting with an "x-" prefix. Return value sequence<octet> The sequence of octets resulting from encoding the string. Exceptions GlobalException ENCODING_ERR: Raised if it is impossible to encode the given string with the provided encoding (e.g. because the target encoding cannot capture all characters in the string). getURL

Given an IRI and an AsyncStatusCallback object on which to operate call a callback, callback function, this method will attempt to fetch the resource at that IRI. If the IRI using uses the HTTP GET method. Once the request has been completed the callback is called as described in or HTTPS scheme, the AsyncStatusCallback interface. HTTP GET method will be used. Implementations may support other schemes, but are not required to.

Processing requirements

This method call must take place asynchronously. When called, control returns immediately to the calling context, and once the request is completed the callback is called. Multiple calls to this method must be executed in FIFO order.

User-agents User agents are required to support the gzip content coding for HTTP requests and must decode it such content before passing it on to the callback. User-agents User agents are not required to support gzip encoding content that they send, though they are encouraged to. Cookies should be supported so that state can be maintained across requests. User Agents agents may provide the user with means to interact with the request (e.g. to enter authentication information) but is are not required to.

It is important to note that for security reasons, user-agents user agents are strongly encouraged to restrict these requests by origin. When enforcing such restrictions, the callback is called immediately with its AsyncURLStatus object's success field set to false and other fields set to null . Redirection responses (3xx HTTP status codes) must not be exposed through the API but rather they must be processed internally according to the HTTP specification.

Parameters
in DOMString iri The IRI of the resource that is being requested.
in AsyncStatusCallback callback The object on which the callback will be called upon completion of the request.
No return value
No exceptions
postURL

Given an IRI , data to be transmitted, an AsyncStatusCallback object on which to operate call a callback, callback function, a media type, and a content coding, this method will send post the data to the specified IRI as the body of an HTTP POST request using the requested media type and content coding. User agents must support postURL being invoked with an HTTP or HTTPS IRI, but may support other IRI schemes if they indicate protocols that are functionally compatible with HTTP. Once the request has been completed the callback is called invoked as described in the AsyncStatusCallback interface. If postURL is invoked with an IRI that does not support posting content, or which does not post content in a manner compatible with HTTP, a DOMException with code NOT_SUPPORTED_ERR must be thrown.

Processing requirements are the same as for getURL , with the following notes and additions.

  • The data passed in does not get any HTML form encoding applied to it, so that applications that wish to transmit content corresponding to what an HTML form would must produce the encoding themselves
  • When the content type parameter is set then the Content-Type header of the request must be set accordingly. If the syntax of the content type parameter does not match that of a media type, it must be ignored. If this parameter is not specified, then it must default to text/plain .
  • When the encoding parameter is set then the User Agent user agent must encode the submitted data with that HTTP content coding and set the Content-Encoding header accordingly, if it supports it. If it does not support it, then it must ignore it, must not set the Content-Encoding header, and must transmit the data with no encoding. The only required content coding is identity .
Parameters
in DOMString iri The IRI of the resource that is being requested.
in DOMString data The data that will be the body of the POST request.
in AsyncStatusCallback callback The object on which the callback will be called upon completion of the request.
in DOMString type The content type of the POST request.
in DOMString encoding The encoding of the POST request.
No return value
No exceptions
parseXML

Given a string and a Document object, parse the string as an XML document and return a Node representing it. If the XML in the string is not well-formed according to either XML 1.0 or XML 1.1 or not namespace-well-formed according to Namespaces in XML 1.0 or Namespaces in XML 1.1 respectively, this method must return a null value.

When parsing the input string, the contextDoc parameter is used only for setting the ownerDocument field in the parsed nodes.

If during parsing a 'script' element is encountered, it must not be executed at that time. Script execution is deferred until the returned Document (or applicable parts thereof) is inserted into the contextDoc document.

There is no requirement to load any external resources, e.g. external entities, stylesheets, scripts, raster images, video, audio etc, for the parsing to complete. XSL stylesheets must not be applied.

If the contextDoc parameter is defined, this method returns an Element object the ownerDocument field of which must be set to be the provided Document object. In effect when the contextDoc parameter is specified the processing must be equivalent to applying the following steps:

  1. parsing the XML into a Document
  2. retrieving its documentElement element
  3. calling importNode on the Document object passed to parseXML with the Element from the previous step as its first parameter and the deep parameter set to true . (Please note that importNode is part of DOM 3 Core but not of the uDOM. It is mentioned here to indicate that the effect must be as if importNode had been used, but not to require that it be supported in implementations)
  4. return the result of the last step
Parameters
in DOMString data The data that is to be parsed as XML.
in Document contextDoc The Document object in the context of which to perform the parsing.
Return value
Node A Node (either a Document or an Element ) representing the content that was parsed.
Exceptions
DOMException
INVALID_CHARACTER_ERR: Raised if one of the parsed XML names is not an XML name according to the XML version in use specified in the Document.xmlVersion attribute of the contextDoc . document.
Example gotoLocation: primary.svg references a group in resource.svg which calls gotoLocation. The result is that primary.svg is replaced by somewhere.svg. Third file, anchor.svg, is showing the similar behavior using an anchor element. Activating the "click me" text will replace anchor.svg by somewhere.svg.

primary.svg

<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny"
xmlns:xlink="http://www.w3.org/1999/xlink">

  xmlns:xlink="http://www.w3.org/1999/xlink">

<use xlink:href="resource.svg#g"/>
</svg>

resource.svg

<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny"
xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="g">
<script type="application/ecmascript">
gotoLocation("somewhere.svg");
</script>
</g>

  xmlns:xlink="http://www.w3.org/1999/xlink">
    <g id="g">
    <script type="application/ecmascript">
      gotoLocation("somewhere.svg");
    </script>
    </g>

</svg>

anchor.svg

<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny"
xmlns:xlink="http://www.w3.org/1999/xlink">
<a xlink:href="somewhere.svg" target="_replace"><text>Click me!</text></a>

  xmlns:xlink="http://www.w3.org/1999/xlink">
    <a xlink:href="somewhere.svg" target="_replace"><text>Click me!</text></a>

</svg>

A.8.21 A.8.20 AsyncStatusCallback

This interface is implemented by code that intends to process content retrieved through getURL or postURL , both of which take an instance of this interface as a parameter, and call its parameter. The operationComplete method of the object implementing this interface is called upon completion of the request.

IDL Definition
interface AsyncStatusCallback
{
        void operationComplete(in AsyncURLStatus status);
};
No defined constants
No defined attributes
Methods
operationComplete

This method is implemented by code in order to be notified of the result of HTTP requests. fetching a resource using getURL or postURL . Upon request completion, it receives completion of the request, the method is called with an AsyncURLStatus object that captures holds the details of what was returned. resource contents and information about the request.

Parameters
in AsyncURLStatus status An object representing the HTTP response.
No return value
No exceptions

A.8.22 A.8.21 AsyncURLStatus

This interface captures several aspects of an HTTP response in order to be passed to the operationComplete method upon completion of an HTTP request.

IDL Definition
interface AsyncURLStatus
{
        readonly attribute boolean success;
  readonly attribute DOMString co

  readonly attribute DOMString contentType;
        readonly attribute DOMString content;
};

No defined constants
Attributes
success

A boolean field indicating whether the request succeeded or not.

For HTTP requests with response status codes in the 200 range, this attribute must be set to true, and for status codes in the 400 and 500 ranges it must be set to false. Status codes in the 100 range must be ignored and those in the 300 range must be processed as indicated in getURL 's processing requirements.

When fetching non-HTTP resources, this attribute must be set to true if the resource was successfully retrieved in full, and false otherwise.

contentType

A string containing the media type of the response.

For HTTP requests, this attribute must be set to the value of the Content-Type HTTP header. If there was no Content-Type header, the attribute must be set to null .

When fetching non-HTTP resources, this attribute must be set to null .

content

A string containing the contents of the fetched resource.

If the resource is not a valid sequence of characters (as interpreted according to the media type and other headers for an HTTP request, or as appropriate for non-HTTP resources), then this attribute must be set to null.

For HTTP requests, if the media type of the response body was in the text/* hierarchy and specified a charset parameter, then the text must be converted into the host programming language's native form if the encoding is supported. If the encoding is not supported, the value of this field must be null .The only required encodings are UTF-8 and UTF-16 (BE and LE). If the HTTP response body had one or more content codings applied to it then it must be fully decoded before setting this field. If the HTTP response status code was an error code but carried a body, the content of that body must still be exposed.

No defined methods

A.8.22 EventListenerInitializer2

The EventListenerInitializer2 interface is used to provide a way for scripts written in languages that do not have a concept of a "global object" to initialize its event listeners. Specifically, it is used for Java event listeners, but this general approach is suggested for other such scripting languages. See the description of the 'script' element for details on how the object implementing EventListenerInitializer2 is discovered and used.

IDL Definition

interface EventListenerInitializer2
{
        void initializeEventListeners(in Element scriptElement);
        EventListener createEventListener(in Element handlerElement);
};

No defined constants
No defined attributes
Methods
initializeEventListeners

Invoked to indicate that the script given by the specified 'script' element should be executed.

Parameters
in Element scriptElement The 'script' element that identifies the script to execute.
No Return value
No Exceptions
createEventListener

Invoked to obtain an EventListener that corresponds to the specified 'handler' element.

Parameters
in Element handlerElement The 'handler' element for which a corresponding EventListener is to be returned.
Return value
EventListener The EventListener .
No Exceptions