Movatterモバイル変換


[0]ホーム

URL:


Chapter 4: Basic Data Types and Interfaces

4.1. Definitions

initial value

The initial value of an attribute or property is the value used when that attribute or property is not specified, or when it has aninvalid value. This value is to be used for the purposes of rendering, calculatinganimation values, and when accessing the attribute or property via DOM interfaces.

invalid value
An invalid value specified for aproperty, either in a style sheet or apresentation attribute, is one that is either not allowed according to the grammar defining the property's values, or is allowed by the grammar but subsequently disallowed in prose. A CSS declaration with an invalid value is ignored; seeDeclarations and properties ([CSS2], section 4.1.8).

4.2. Attribute syntax

In this specification, attributes are defined with an attribute definitiontable, which looks like this:

NameValueInitial valueAnimatable
exampleattr<length> | nonenoneyes

In the Value column is a description of the attribute's syntax. There aresix methods for describing an attribute's syntax:

  1. Using theCSS Value Definition Syntax [css-values]. This is the notation used to define the syntax for most attributes in this specification and is the default.
  2. By reference to anEBNF symbol defined in this or another specification [xml]. For external definitions, this is indicated by[EBNF] appearing in the Value column.
  3. By reference to anABNF symbol defined in another specification [rfc5234]. This is indicated by[ABNF] appearing in the Value column.
  4. As a URL as defined by theURL Standard [URL]. This is indicated by[URL] appearing in the Value column.
  5. As a type as defined by theHTML Standard [HTML]. This is indicated by[HTML] appearing in the Value column.
  6. In prose, below the attibute definition table. This is indicated by the text "(see below)" appearing in the Value column.
SVG 2 Requirement:Consider relaxing case sensitivity of presentation attribute values.
Resolution:We will make property values case insensitivity.
Purpose:To align presentation attribute syntax parsing with parsing of the corresponding CSS property.
Owner:Cameron (ACTION-3276)
Status:Done

When apresentation attributedefined using the CSS Value Definition Syntax is parsed, this is done asfollows:

  1. Letvalue be the value of the attribute.
  2. Letgrammar be the grammar given in the attribute definition table's Value column.
  3. Replace all instances of<length> ingrammar with [<length> |<number>].
  4. Replace all instances of<length-percentage> ingrammar with [<length-percentage> |<number>].
  5. Replace all instances of<angle> ingrammar with [<angle> |<number>].
  6. Return the result ofparsingvalue withgrammar.

The insertion of the<number> symbols allows forunitless length and angles to be used in presentation attribute whiledisallowing them in corresponding property values.

Note that allpresentation attributes, since they aredefined by reference to their corresponding CSS properties, are defined usingthe CSS Value Definition Syntax.

When any other attribute defined using the CSS ValueDefinition Syntax is parsed, this is done byparsing theattribute's value according to the grammar given in attribute definitiontable.

Note that this allows CSS comments and escapes to be usedin such attributes. For example, a value of'10\px/**/'would successfully parse as'10px' inthe‘x’ presentation attribute of therect element.

When an attribute defined as a URL is parsed, this isdone by invoking theURL parser withthe attribute's value asinput and the document's URL asbase [URL].

The Initial value column gives theinitial value for the attribute.When an attribute fails to parse according to the specified CSS Value Definition Syntax,ABNF or EBNF grammar, or if parsing according to the URL Standardor by the prose describing how to parse the attribute indicates failure,the attribute is assumed to have been specified as the giveninitial value.

The initial value of apresentation attribute is its corresponding property's initial value. Since the use of aninvalid value in apresentation attribute will be treated as if the initial value was specified, this value can override values that come from lower priority style sheet rules, such as those from the user agent style sheet.

For example, although the user agent style sheet sets the value of theoverflow property tohidden forsvg elements, specifying an invalid presentation attribute such asoverflow="invalid" will result in a rule settingoverflow tovisible, overriding the user agent style sheet value.

The Animatable column indicates whether the attribute can be animated usinganimation elements as defined in theSVG Animation module.

4.2.1. Real number precision

Unless stated otherwise, numeric values in SVG attributes and inproperties that are defined to have an effect on SVG elements mustsupport at least all finite single-precision values supported by the hostarchitecture.

It is recommended that higher precision floating pointstorage and computation be performed on operations such ascoordinate system transformations to provide the bestpossible precision and to prevent round-off errors.

conforming SVG viewersare required to perform numerical computation in accordance with theirconformance class, as described inConformance Criteria.

4.2.2. Clamping values which are restricted to a particular range

Some numeric attribute and property values have restricted ranges.Other values will be restricted by the capabilities of the device.If not otherwise specified,the user agent shall defer any out-of-range error checking untilas late as possible in the rendering process.This is particularly important for device limitations,as compound operationsmight produce intermediate values which are out-of-range butfinal values which are within range.

4.3. SVG DOM overview

ConformingSVG viewers orSVG interpretersthat supportscript executionmust implement SVG DOM interfaces as defined throughout this specification,with the specific requirements and dependencies listed in this section.

SVG 2 Requirement:Improve the DOM.
Resolution:We will generally improve the SVG DOM for SVG 2.
Purpose:Help authors use the SVG DOM by making it less Java-oriented.
Owner:Cameron (ACTION-3273)
Note:SeeSVG 2 DOM Wiki page.
SVG 2 Requirement:Improve the SVG path DOM APIs.
Resolution:We will improve the SVG path DOM APIs in SVG 2.
Purpose:Clean up SVGPathSegList interface, and possibly share an API with Canvas.
Owner:Cameron (no action)

4.3.1. Dependencies for SVG DOM support

The SVG DOM is defined in terms ofWeb IDLinterfaces. All IDL fragments in this specification must be interpreted asrequired forconforming IDL fragments,as described in the Web IDL specification. [WebIDL]

The SVG DOM builds upon a number of DOM specifications. In particular:

4.3.2. Naming conventions

The SVG DOM follows similar naming conventions to HTML and DOM standards([HTML], [DOM]).

All names are defined as one or more English wordsconcatenated together to form a single string. Property ormethod names start with the initial keyword in lowercase, andeach subsequent word starts with a capital letter. For example,a property that returns document meta information such as thedate the file was created might be named "fileDateCreated".

Interface names defined in this specification nearly all start with "SVG".Interfaces that represent the DOMElement objectfor an SVG-namespaced element follow the formatSVGElementNameElement, whereElementNameis the element's tag name with the initial letter capitalized.SoSVGRadialGradientElement is the interface for anradialGradient element.

An exception to this casing convention isSVGSVGElement,in which the entire tag name is capitalized.

4.3.3. Elements in the SVG DOM

Any SVG software that is required to support the SVG DOMmust enhance the DOM elements created forSVG document fragmentsas follows:

TheSVGUnknownElement interface is "at risk".

InThe‘rect’ element,theSVGRectElement interface is identified. This means that everyElement object whose namespace URI is "http://www.w3.org/2000/svg"and whose local name is "rect" must also implementSVGRectElement.

4.3.4. Reflecting content attributes in the DOM

Many SVG DOM properties (IDL attributes)reflect a content attribute or propertyon the corresponding element,meaning that content and IDL attributes represent the same underlying data.For example,theSVGAnimatedLengthry in anSVGRectElementreflects thery presentation attribute on the associatedrect element.

The way this reflection is done depends on the type of the IDL attribute:

This relationship is live, and values must be synchronized(following the rules inSynchronizing reflected values)when either the attribute or its reflected property is modified.

If the attribute hasn't been specified explicitly in the document markup,the reflected object is nonetheless intialized upon access,to the attribute's inital value.If the attribute's initial value is(none),the object is initialized as defined inReflecting an empty initial value.This newly constructed object does not generate an attribute on the element untilit is modified for the first time. Modifications made to the correspondingattribute are immediately reflected in the object.

IflineElement.x1.baseVal is accessed(wherelineElement is an instance ofSVGLineElement)and thex1 attribute was not specified in the document, thereturnedSVGLength object would represent the value0 user units,because the initial value for the attribute is0.

4.3.5. Synchronizing reflected values

Whenever a reflected content attribute's base value changes,then the reflecting object must besynchronized,immediately after the value changed, by running the following steps:

  1. If the reflecting object is alist interface object, then run the steps forsynchronizing a list interface object.
  2. Otherwise, update the object's value to be the base value of the reflected content attribute (using the attribute'sinitial value if it is not present or invalid).

    This will, for example, update thevalue of anSVGLength object.

When areflected content attribute is to bereserialized, optionally using aspecific value, the following steps must be performed:

  1. Letvalue be the specific value given, or the value of the content attribute's reflecting IDL attribute if a specific value was not provided.
  2. Depending onvalue's type:
    SVGAnimatedBoolean
    SVGAnimatedNumber
    SVGAnimatedLength
    SVGAnimatedAngle
    SVGAnimatedRect
    SVGAnimatedString
    SVGAnimatedNumberList
    SVGAnimatedLengthList
    SVGAnimatedTransformList
    Reserialize the content attribute usingvalue's baseVal member.
    SVGAnimatedEnumeration
    1. Letnumber be the value ofvalue's baseVal member.
    2. Letkeyword be the content attribute's keyword value corresponding tonumber, or the empty string ifnumber is 0.

      This means that if the enumeration value is set to the "unknown" value, the content attribute will be set to the empty string.

    3. Set the content attribute tokeyword.
    boolean
    Set the content attribute to "true" ifvalue is true, and "false" otherwise.
    float
    double
    Set the content attribute to an implementation specific string that, if parsed as a<number> using CSS syntax, would return the number value closest tovalue, given the implementation's supportedreal number precision.
    SVGLength
    Set the content attribute to the value that would be returned from gettingvalue'svalueAsString member.
    SVGAngle
    Set the content attribute to the value that would be returned from gettingvalue'svalueAsString member.
    DOMRect
    1. Letcomponents be a list of four values, being the values of thex,y,width andheight members ofvalue.
    2. Letserialized components be a list of four strings, where each is an implementation specific string that, if parsed as a<number> using CSS syntax, would return the number value closest to the corresponding value incomponents, given the implementation's supportedreal number precision.
    3. Set the content attribute to a string consisting of the strings inserialized components joined and separated by single U+0020 SPACE characters.
    DOMString
    Set the content attribute tovalue.
    SVGNumberList
    SVGLengthList
    SVGPointList
    SVGTransformList
    SVGStringList
    1. Letelements be the list of values invalue.

      The values will beSVGNumber,SVGLength,DOMPoint orSVGTransform objects, orDOMString values, depending onvalue's type.

    2. Letserialized elements be a list of strings, where each string is formed based on the corresponding value inelements and its type:
      anSVGNumber object
      The string is an implementation specific string that, if parsed as a<number> using CSS syntax, would return the number value closest to theSVGNumber object'svalue member, given the implementation's supportedreal number precision.
      anSVGLength object
      The string is the value that would be returned from getting the value'svalueAsString member.
      aDOMPoint object
      The string value is computed as follows:
      1. Letstring be an empty string.
      2. Letx andy be the values of theDOMPoint object's x and y coordinates, respectively.
      3. Append tostring an implementation specific string that, if parsed as<number> using CSS syntax, would return the number value closest tox, given the implementation's supportedreal number precision.
      4. Append a single U+002C COMMA character tostring.
      5. Append tostring an implementation specific string that, if parsed as<number> using CSS syntax, would return the number value closest toy, given the implementation's supportedreal number precision.
      6. The string isstring.
      aSVGTransform object
      The string is theserialization of theSVGTransform object'smatrix object.
      aDOMString
      The string is theDOMString's value itself.
    3. Set the content attribute to a string consisting of the strings inserialized elements joined and separated by single U+0020 SPACE characters.

4.3.6. Reflecting an empty initial value

When initializing an SVG DOM attribute thatreflects a null or empty initial value,then the property must be initialized according to its data type,as defined in this section.This occurs only if there is no explicit value for the reflected content attribute,and the initial value in the attribute's definition table is(none).

If an interface is not listed below that meansthat the object initialization shall be done using the values for theobjects that the interface contains, e.g.,anSVGAnimatedString consists of twoDOMString members,while aDOMRect consists of manydoubles.

DOMString
Initialized as the empty string ("").
float
long
short
Any othernumeric type defined in WebIDL
Initialized as0.
boolean
Initialized asfalse.
SVGLength
Initialized as0 user units (SVG_LENGTHTYPE_NUMBER).
SVGLengthList
SVGNumberList
SVGPointList
SVGStringList
SVGTransformList
Initialized as the empty list.
SVGAngle
Initialized as0 in unspecified units (SVG_ANGLETYPE_UNSPECIFIED).
SVGZoomAndPan
Initialized as0 (SVG_ZOOMANDPAN_UNKNOWN).
SVGPreserveAspectRatio
Initialized as'xMidYMid meet'.

IftextElement.dx.baseVal is accessed(wheretextElement is an instance ofSVGTextElement)and thedx attribute was not specified in the document, thereturnedSVGLengthList object would be empty.

4.3.7. Invalid values

If a script sets areflected DOM attributeto aninvalid value for the content attribute (e.g.,a negative number for an attribute that requires a non-negativenumber or an out-of-range value for an enumeration), unlessthis specification indicates otherwise, no exception shall beraised on setting, but the given document fragment shall becometechnicallyin error as described inError processing.

Many browsers currently throw errors for out-of-range enumeration values, or explicitly setting an enumeration to the UNKNOWN value. SeeShould setting an enum IDL to an invalid value throw an error? on GitHub for discussion.

4.4. DOM interfaces for SVG elements

4.4.1. Interface SVGElement

All of the SVG DOM interfaces that correspond directly to elements in theSVG language (such as theSVGPathElement interface for thepath element) derive from theSVGElement interface.

The CSSOM specificationaugmentsSVGElement with a style IDL attribute, so that thestyleattribute can be accessed in the same way as on HTML elements.

[Exposed=Window]interfaceSVGElement :Element {  [SameObject] readonly attributeSVGAnimatedStringclassName;  readonly attributeSVGSVGElement?ownerSVGElement;  readonly attributeSVGElement?viewportElement;};SVGElement includesGlobalEventHandlers;SVGElement includesDocumentAndElementEventHandlers;SVGElement includesSVGElementInstance;SVGElement includesHTMLOrSVGElement;

TheclassName IDL attributereflects theclass attribute.

This attribute is deprecated and may be removed in afuture version of this specification. Authors are advised to useElement.classList intead.

TheclassNameattribute onSVGElement overrides the correspond attribute onElement, following the WebIDL rules forinheritance.

TheownerSVGElement IDL attributerepresents the nearest ancestorsvg element. On gettingownerSVGElement,the nearest ancestorsvg element is returned; if the currentelement is theoutermost svg element, then null is returned.

TheviewportElement IDL attributerepresents the element that provides the SVG viewport for the current element. On gettingviewport,the nearest ancestor element that establishes an SVG viewport is returned; if the currentelement is theoutermost svg element, then null is returned.

4.4.2. Interface SVGGraphicsElement

SVG 2 Requirement:Detect if a mouse event is on the fill or stroke of a shape.
Resolution:SVG 2 will make it easier to detect if an mouse event is on the stroke or fill of an element.
Purpose:To allow authors to discriminate between pointer events on the fill and stroke of an element without having to duplicate the element
Owner:Cameron (ACTION-3279)
Status:Done.

TheSVGGraphicsElement interface represents SVG elements whose primary purposeis to directly render graphics into a group.

dictionarySVGBoundingBoxOptions {  boolean fill = true;  boolean stroke = false;  boolean markers = false;  boolean clipped = false;};interfaceSVGGraphicsElement :SVGElement {  [SameObject] readonly attributeSVGAnimatedTransformListtransform;DOMRectgetBBox(optionalSVGBoundingBoxOptions options);DOMMatrix?getCTM();DOMMatrix?getScreenCTM();};SVGGraphicsElement includesSVGTests;

Thetransform IDL attributereflects the computed value of thetransform property and itscorresponding‘transform’ presentation attribute.

ThegetBBox method is usedto compute the bounding box of the current element. When the getBBox(options)method is called, thebounding box algorithmis invoked for the current element,withfill,stroke,markersandclipped members of theoptions dictionary argumentused to control which parts of the element are included in the bounding box,using the element's user coordinate system as the coordinate system to return thebounding box in. A newly createdDOMRect object that defines thecomputed bounding box is returned.

ThegetCTM method is used toget the matrix that transforms the current element's coordinate system toits SVG viewport's coordinate system. When getCTM() is called, the followingsteps are run:

  1. If the current element is not in the document, then return null.
  2. Letctm be a matrix determined based on what the current element is:
    the current element is theoutermost svg element
    ctm is a matrix that transforms the coordinate space of thesvg (including itstransform property) to the coordinate space of the document's viewport. The matrix includes the transforms produced by theviewBox andpreserveAspectRatio attributes, thetransform property, and any transform due tocurrentScale andcurrentTranslate properties on theSVGSVGElement.
    any other element
    ctm is a matrix that transforms the coordinate space of the current element (including itstransform property) to the coordinate space of its closest ancestor viewport-establishing element (also including itstransform property).
  3. Return a newly created,detachedDOMMatrix object that represents the same matrix asctm.

ThegetScreenCTM methodis used to get the matrix that transforms the current element's coordinatesystem to the coordinate system of the SVG viewport for the SVG document fragment.When getScreenCTM() is called, the following steps are run:

  1. If the current element is not in the document, then return null.
  2. Letctm be a matrix that transforms the coordinate space of the current element (including itstransform property) to the coordinate space of the document's viewport.

    This will include:

  3. Return a newly created,detachedDOMMatrix object that represents the same matrix asctm.

This method would have been more aptly named asgetClientCTM,but the namegetScreenCTM is kept for historical reasons.

4.4.3. Interface SVGGeometryElement

InterfaceSVGGeometryElement represents SVG elements whose renderingis defined by geometry with anequivalent path,and which can be filled and stroked.This includes paths and the basic shapes.

[Exposed=Window]interfaceSVGGeometryElement :SVGGraphicsElement {  [SameObject] readonly attributeSVGAnimatedNumberpathLength;  boolean isPointInFill(optionalDOMPointInit point);  boolean isPointInStroke(optionalDOMPointInit point);  floatgetTotalLength();DOMPointgetPointAtLength(float distance);};

TheisPointInFill method,when invoked, must return true if the point given bypoint passed to the method,in the coordinate space of an element, is inside the intended path as determined by the windingrule indicated by thefill-rule property of an element; and must return false otherwise.Open subpaths must be implicitly closed when computing the area inside the path, without affectingthe actual subpaths. Points on the path itself must be considered to be inside the path.The returned value is independent of any visual CSS property butfill-ruleIf either of thex ory properties onpoint are infinite or NaN,then the method must return false.

isPointInFill takes the windingrule indicated by thefill-rule property of an element even if the element is a childof aclipPath element.

isPointInFill is alignedwith theisPointInPath method on theCanvasDrawPath mixin as much as the SVG contextallows it to be.

TheisPointInStroke method,when invoked, must return true if the point given bypoint passed to the method,in the coordinate space of an element, is in or on the outline path of an applied stroke onan element; and must return false otherwise.The outline path must take the stroke propertiesstroke-width,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-dasharrayandstroke-dashoffset of an element into account.The returned value is independent of any visual CSS property but the listed stroke properties.If either of thex ory properties onpoint are infinite or NaN,then the method must return false.

isPointInStroke is alignedwith theisPointInPath method on theCanvasDrawPath mixin as much as the SVGcontextallows it to be.

ThepathLength IDL attributereflects thepathLength content attribute.

ThegetTotalLength methodis used to compute the length of the path. When getTotalLength()is called, the user agent's computed value for the total length of the path,in user units, is returned.

The user agent's computed path length does not take thepathLength attribute into account.

ThegetPointAtLength methodis used to return the point at a given distance along the path. WhengetPointAtLength(distance) is called, the following steps are run:

  1. Letlength be the user agent's computed value for the total length of the path, in user units.

    As withgetTotalLength, this does not take into account thepathLength attribute.

  2. Clampdistance to [0,length].
  3. Let (x,y) be the point on the path at distancedistance.
  4. Return a newly created,detachedDOMPoint object representing the point (x,y).

4.5. DOM interfaces for basic data types

4.5.1. Interface SVGNumber

TheSVGNumber interface is used primarily to represent a<number>value that is a part of anSVGNumberList. IndividualSVGNumberobjects can also be created by script.

AnSVGNumber object can be designated asread only,which means that attempts to modify the object will result in an exceptionbeing thrown, as described below.SVGNumber objects reflected through the animVal IDL attribute are alwaysread only.

AnSVGNumber object can beassociatedwith a particular element. The associated element is used todetermine which element's content attribute to update if the objectreflectsan attribute. Unless otherwise described, anSVGNumber object is notassociated with any element.

EverySVGNumber object operates in one of twomodes. It can:

  1. reflect an element of the base value of areflected animatable attribute (being exposed through the methods on thebaseVal member of anSVGAnimatedNumberList),
  2. be detached, which is the case forSVGNumber objects created withcreateSVGNumber.

AnSVGNumber object maintains an internal number value,which is called itsvalue.

[Exposed=Window]interfaceSVGNumber {  attribute floatvalue;};

Thevalue IDL attributerepresents the number. On gettingvalue,theSVGNumber'svalue is returned.

On settingvalue, the followingsteps are run:

  1. If theSVGNumber isread only, thenthrow aNoModificationAllowedError.
  2. Set theSVGNumber'svalue to the value being assigned to thevalue member.
  3. If theSVGNumberreflects an element of the base value of areflected attribute, thenreserialize the reflected attribute.

4.5.2. Interface SVGLength

TheSVGLength interface is used to represent a value thatcan be a<length>,<percentage> or<number> value.

AnSVGLength object can be designated asread only,which means that attempts to modify the object will result in an exceptionbeing thrown, as described below.SVGLength objects reflected through the animVal IDL attribute are alwaysread only.

AnSVGLength object can beassociatedwith a particular element, as well as being designated with adirectionality:horizontal, vertical or unspecified. The associated element and the directionality of thelength are used to resolve percentage values to user units and is also used todetermine which element's content attribute to update if the objectreflectsan attribute. Unless otherwisedescribed, anSVGLength object is not associated with any element andhas unspecified directionality.

EverySVGLength object operates in one offour modes. It can:

  1. reflect the base value of areflected animatable attribute (being exposed through thebaseVal member of anSVGAnimatedLength),
  2. reflect a presentation attribute value (such as bySVGRectElement.width.baseVal),
  3. reflect an element of the base value of areflected animatable attribute (being exposed through the methods on thebaseVal member of anSVGAnimatedLengthList), or
  4. be detached, which is the case forSVGLength objects created withcreateSVGLength.

AnSVGLength object maintains an internal<length> or<percentage> or<number> value, which is called itsvalue.

[Exposed=Window]interfaceSVGLength {  // Length Unit Types  const unsigned shortSVG_LENGTHTYPE_UNKNOWN = 0;  const unsigned shortSVG_LENGTHTYPE_NUMBER = 1;  const unsigned shortSVG_LENGTHTYPE_PERCENTAGE = 2;  const unsigned shortSVG_LENGTHTYPE_EMS = 3;  const unsigned shortSVG_LENGTHTYPE_EXS = 4;  const unsigned shortSVG_LENGTHTYPE_PX = 5;  const unsigned shortSVG_LENGTHTYPE_CM = 6;  const unsigned shortSVG_LENGTHTYPE_MM = 7;  const unsigned shortSVG_LENGTHTYPE_IN = 8;  const unsigned shortSVG_LENGTHTYPE_PT = 9;  const unsigned shortSVG_LENGTHTYPE_PC = 10;  readonly attribute unsigned shortunitType;           attribute floatvalue;           attribute floatvalueInSpecifiedUnits;           attribute DOMStringvalueAsString;  voidnewValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits);  voidconvertToSpecifiedUnits(unsigned short unitType);};

The numeric length unit type constants defined onSVGLength are usedto represent the type of anSVGLength'svalue.Their meanings are as follows:

ConstantMeaning
SVG_LENGTHTYPE_NUMBERA unitless<number> interpreted as a value inpx.
SVG_LENGTHTYPE_PERCENTAGEA<percentage>.
SVG_LENGTHTYPE_EMSA<length> with anem unit.
SVG_LENGTHTYPE_EXSA<length> with anex unit.
SVG_LENGTHTYPE_PXA<length> with apx unit.
SVG_LENGTHTYPE_CMA<length> with acm unit.
SVG_LENGTHTYPE_MMA<length> with amm unit.
SVG_LENGTHTYPE_INA<length> with anin unit.
SVG_LENGTHTYPE_PTA<length> with apt unit.
SVG_LENGTHTYPE_PCA<length> with apc unit.
SVG_LENGTHTYPE_UNKNOWNSome other type of value.

The use of numeric length unit type constants is an anti-pattern andnew constant values will not be introduced for any other units or length types supported bySVGLength. If other types of lengths are supported and used, theSVGLengthuses theSVG_LENGTHTYPE_UNKNOWNunit type. See below for details on how the other properties of anSVGLengthoperate with these types of lengths.

TheunitType IDL attribute representsthe type of value that theSVGLength'svalue is.On gettingunitType, the following stepsare run:

  1. If theSVGLength'svalue is a unitless<number>, a<percentage>, or a<length> with anem,ex,px,cm,mm,in,pt orpc unit, then return the corresponding constant value from the length unit type table above.
  2. Otherwise, returnSVG_LENGTHTYPE_UNKNOWN.

    For example, for a<length> with ach unit or one that has a non-scalar value such ascalc(),SVG_LENGTHTYPE_UNKNOWN would be returned.

Thevalue IDL attribute representstheSVGLength'svalue in user units.On gettingvalue, the following stepsare run:

  1. Letvalue be theSVGLength'svalue.
  2. Ifvalue is a<number>, return that number.
  3. Letviewport size be a basis to resolve percentages against, based on theSVGLength'sassociated element anddirectionality:
    has noassociated element
    size is 100
    has anassociated element and horizontaldirectionality
    size is the width of theassociated element's SVG viewport
    has anassociated element and verticaldirectionality
    size is the height of theassociated element's SVG viewport
    has anassociated element and unspecifieddirectionality
    size is the length of theassociated element's SVG viewport diagonal (seeUnits)
  4. Letfont size be a basis to resolve font size values against, based on theSVGLength'sassociated element:
    has noassociated element
    font size is the absolute length of the initial value of thefont-size property
    has anassociated element
    size is the computed value of theassociated element'sfont-size property
  5. Return the result of convertingvalue to an absolute length, usingviewport size andfont size as percentage and font size bases. If the conversion is not possible due to the lack of anassociated element, return 0.

On settingvalue, the following stepsare run:

  1. If theSVGLength object isread only, thenthrow aNoModificationAllowedError.
  2. Letvalue be the value being assigned tovalue.
  3. Set theSVGLength'svalue to a<number> whose value isvalue.
  4. If theSVGLengthreflects the base value of areflected attribute,reflects a presentation attribute, orreflects an element of the base value of areflected attribute, thenreserialize the reflected attribute.

ThevalueInSpecifiedUnits IDL attribute representsthe numeric factor of theSVGLength'svalue.On gettingvalueInSpecifiedUnits, the following stepsare run:

  1. Letvalue be theSVGLength'svalue.
  2. Ifvalue is a<number>, return that number.
  3. Otherwise, ifvalue is a<percentage> or any scalar<length> value, return the numeric factor before its unit.
  4. Otherwise, return 0.

    ThusvalueInSpecifiedUnits would return 12 for both'12%' and12em, but 0 would be returned for non-scalar values likecalc(12px + 5%).

On settingvalueInSpecifiedUnits, the following stepsare run:

  1. If theSVGLength object isread only, thenthrow aNoModificationAllowedError.
  2. Letvalue be the value being assigned tovalueInSpecifiedUnits.
  3. If theSVGLength'svalue is a<number>, then update its value tovalue.
  4. Otherwise, if theSVGLength'svalue is a<percentage> or a scalar-valued<length>, then update its numeric factor tovalue.
  5. Otherwise, theSVGLength'svalue is of some other type. Set it to a<number> whose value isvalue.
  6. If theSVGLengthreflects the base value of areflected attribute orreflects an element of the base value of areflected attribute, thenreserialize the reflected attribute.

ThevalueAsString IDL attribute representstheSVGLength'svalue as a string.On gettingvalueAsString, the following stepsare run:

  1. Letvalue be theSVGLength'svalue.
  2. Letstring be an empty string.
  3. Ifvalue is a<number>,<percentage> or scalar<length> value, then:
    1. Letfactor bevalue's numeric factor, if it is a<percentage> or<length>, orvalue itself it is a<number>.
    2. Append tostring an implementation specific string that, if parsed as a<number> using CSS syntax, would return the number value closest tofactor, given the implementation's supportedreal number precision.
    3. Ifvalue is a<percentage> then append tostring a single U+0025 PERCENT SIGN character.
    4. Otherwise, ifvalue is a<length>, then append tostring the canonical spelling ofvalue's unit.
    5. Returnstring.
  4. Otherwise, return an implementation specific string that, if parsed as a<length>, would return the closest length value tovalue, given the implementation's supportedreal number precision.

On settingvalueAsString, the following stepsare run:

  1. If theSVGLength object isread only, thenthrow aNoModificationAllowedError.
  2. Letvalue be the value being assigned tovalueAsString.
  3. Parsevalue using the CSS syntax [<number> |<length> |<percentage> ].
  4. If parsing failed, thenthrow aSyntaxError.
  5. Otherwise, parsing succeeded. SetSVGLength'svalue to the parsed value.
  6. If theSVGLengthreflects the base value of areflected attribute orreflects an element of the base value of areflected attribute, thenreserialize the reflected attribute.

ThenewValueSpecifiedUnitsmethod is used to set theSVGLength's value in a typed manner. WhennewValueSpecifiedUnits(unitType, valueInSpecifiedUnits) is called, the followingsteps are run:

  1. If theSVGLength object isread only, thenthrow aNoModificationAllowedError.
  2. IfunitType isSVG_LENGTHTYPE_UNKNOWN or is a value that does not appear in the length unit type table above, thenthrow aNotSupportedError.
  3. SetSVGLength'svalue depending on the value ofunitType:
    SVG_LENGTHTYPE_NUMBER
    a<number> whose value isvalueInSpecifiedUnits
    SVG_LENGTHTYPE_PERCENTAGE
    a<percentage> whose numeric factor isvalueInSpecifiedUnits
    anything else
    a<length> whose numeric factor isvalueInSpecifiedUnits and whose unit is as indicated by the length unit type table above
  4. If theSVGLengthreflects the base value of areflected attribute orreflects an element of the base value of areflected attribute, thenreserialize the reflected attribute.

TheconvertToSpecifiedUnitsmethod is used to convert theSVGLength's value to a specific type.When convertToSpecifiedUnits(unitType) is called, the following steps are run:

  1. If theSVGLength object isread only, thenthrow aNoModificationAllowedError.
  2. IfunitType isSVG_LENGTHTYPE_UNKNOWN or is a value that does not appear in the length unit type table above, thenthrow aNotSupportedError.
  3. Letabsolute be the value that would be returned from thevalue member.
  4. IfunitType isSVG_LENGTHTYPE_NUMBER, then:
    1. Set theSVGLength'svalue to a<number> whose value isabsolute.
  5. Otherwise, ifunitType isSVG_LENGTHTYPE_PERCENTAGE, then:
    1. Letviewport size be a basis to resolve percentages against, based on theSVGLength'sassociated element anddirectionality:
      has noassociated element
      size is 100
      has anassociated element and horizontaldirectionality
      size is the width of theassociated element's SVG viewport
      has anassociated element and verticaldirectionality
      size is the height of theassociated element's SVG viewport
      has anassociated element and unspecifieddirectionality
      size is the length of theassociated element's SVG viewport diagonal (seeUnits)
    2. Set theSVGLength'svalue to the result of convertingabsolute to a<percentage>, usingviewport size as the percentage basis.
  6. Otherwise, ifunitType isSVG_LENGTHTYPE_EMS orSVG_LENGTHTYPE_EXS, then:
    1. Letfont size be a basis to resolve font size values against, based on theSVGLength'sassociated element:
      has noassociated element
      font size is the absolute length of the initial value of thefont-size property
      has anassociated element
      size is the computed value of theassociated element'sfont-size property
    2. Set theSVGLength'svalue to the result of convertingabsolute to a<length> with anem orex unit (depending onunitType), usingfont size as thefont-size basis.
  7. Otherwise:
    1. Set theSVGLength'svalue to the result of convertingabsolute to a<length> with the unit found by looking upunitType in the length unit type table above.
  8. If theSVGLengthreflects the base value of areflected attribute orreflects an element of the base value of areflected attribute, thenreserialize the reflected attribute.

4.5.3. Interface SVGAngle

TheSVGAngle interface is used to represent a value thatcan be an<angle> or<number> value.

AnSVGAngle object can be designated asread only,which means that attempts to modify the object will result in an exceptionbeing thrown, as described below. AnSVGAngle reflected through theanimVal attribute is alwaysread only.

AnSVGAngle object can beassociatedwith a particular element. The associated element is used todetermine which element's content attribute to update if the objectreflectsan attribute. Unless otherwise described, anSVGAngle object is notassociated with any element.

EverySVGAngle object operates in one oftwo modes. It can:

  1. reflect the base value of areflected animatable attribute (being exposed through thebaseVal member of anSVGAnimatedAngle),
  2. be detached, which is the case forSVGAngle objects created withcreateSVGAngle.

AnSVGAngle object maintains an internal<angle> or<number> value, which is called itsvalue.

[Exposed=Window]interfaceSVGAngle {  // Angle Unit Types  const unsigned shortSVG_ANGLETYPE_UNKNOWN = 0;  const unsigned shortSVG_ANGLETYPE_UNSPECIFIED = 1;  const unsigned shortSVG_ANGLETYPE_DEG = 2;  const unsigned shortSVG_ANGLETYPE_RAD = 3;  const unsigned shortSVG_ANGLETYPE_GRAD = 4;  readonly attribute unsigned shortunitType;           attribute floatvalue;           attribute floatvalueInSpecifiedUnits;           attribute DOMStringvalueAsString;  voidnewValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits);  voidconvertToSpecifiedUnits(unsigned short unitType);};

The numeric angle unit type constants defined onSVGAngle are usedto represent the type of anSVGAngle'svalue.Their meanings are as follows:

ConstantMeaning
SVG_ANGLETYPE_UNSPECIFIEDA unitless<number> interpreted as a value in degrees.
SVG_ANGLETYPE_DEGAn<angle> with adeg unit.
SVG_ANGLETYPE_RADAn<angle> with arad unit.
SVG_ANGLETYPE_GRADAn<angle> with agrad unit.
SVG_ANGLETYPE_UNKNOWNSome other type of value.

The use of numeric angle unit type constants is an anti-pattern andnew constant values will not be introduced for any other units or angle types supported bySVGAngle. If other types of angles are supported and used, theSVGAngleuses theSVG_ANGLETYPE_UNKNOWNunit type. See below for details on how the other properties of anSVGAngleoperate with these types of angles.

TheunitType IDL attribute representsthe type of value that theSVGAngle'svalue is.On gettingunitType, the following stepsare run:

  1. If theSVGAngle'svalue is a unitless<number> or a<length> with adeg,rad orgrad unit, then return the corresponding constant value from the angle unit type table above.
  2. Otherwise, returnSVG_ANGLETYPE_UNKNOWN.

    For example, for an<angle> with aturn unit,SVG_ANGLETYPE_UNKNOWN would be returned.

Thevalue IDL attribute representstheSVGAngle'svalue in degrees.On gettingvalue, the following stepsare run:

  1. Letvalue be theSVGAngle'svalue.
  2. Ifvalue is a<number>, return that number.
  3. Return the result of convertingvalue to an angle in degrees.

On settingvalue, the following stepsare run:

  1. If theSVGAngle object isread only, thenthrow aNoModificationAllowedError.
  2. Letvalue be the value being assigned tovalue.
  3. Set theSVGAngle'svalue to a<number> whose value isvalue.
  4. If theSVGAnglereflects the base value of areflected attribute, thenreserialize the reflected attribute.

ThevalueInSpecifiedUnits IDL attribute representsthe numeric factor of theSVGAngle'svalue.On gettingvalueInSpecifiedUnits, the following stepsare run:

  1. Letvalue be theSVGAngle'svalue.
  2. Ifvalue is a<number>, return that number.
  3. Otherwise,value is an<angle> value. Return the numeric factor before its unit.

On settingvalueInSpecifiedUnits, the following stepsare run:

  1. If theSVGAngle object isread only, thenthrow aNoModificationAllowedError.
  2. Letvalue be the value being assigned tovalueInSpecifiedUnits.
  3. If theSVGAngle'svalue is a<number>, then update its value tovalue.
  4. Otherwise, if theSVGAngle'svalue is an<angle>, then update its numeric factor tovalue.
  5. If theSVGAnglereflects the base value of areflected attribute orreflects an element of the base value of areflected attribute, thenreserialize the reflected attribute.

ThevalueAsString IDL attribute representstheSVGAngle'svalue as a string.On gettingvalueAsString, the following stepsare run:

  1. Letvalue be theSVGAngle'svalue.
  2. Letstring be an empty string.
  3. Letfactor bevalue's numeric factor, if it is an<angle>, orvalue itself it is a<number>.
  4. Append tostring an implementation specific string that, if parsed as a<number> using CSS syntax, would return the number value closest tofactor, given the implementation's supportedreal number precision.
  5. Ifvalue is an<angle>, then append tostring the canonical spelling ofvalue's unit.
  6. Returnstring.

On settingvalueAsString, the following stepsare run:

  1. If theSVGAngle object isread only, thenthrow aNoModificationAllowedError.
  2. Letvalue be the value being assigned tovalueAsString.
  3. Parsevalue using the CSS syntax [<number> |<angle> ].
  4. If parsing failed, thenthrow aSyntaxError.
  5. Otherwise, parsing succeeded. SetSVGAngle'svalue to the parsed value.
  6. If theSVGAnglereflects the base value of areflected attribute orreflects an element of the base value of areflected attribute, thenreserialize the reflected attribute.

ThenewValueSpecifiedUnitsmethod is used to set theSVGAngle's value in a typed manner. WhennewValueSpecifiedUnits(unitType, valueInSpecifiedUnits) is called, the followingsteps are run:

  1. If theSVGAngle object isread only, thenthrow aNoModificationAllowedError.
  2. IfunitType isSVG_ANGLETYPE_UNKNOWN or is a value that does not appear in the angle unit type table above, thenthrow aNotSupportedError.
  3. SetSVGAngle'svalue depending on the value ofunitType:
    SVG_ANGLETYPE_UNSPECIFIED
    a<number> whose value isvalueInSpecifiedUnits
    anything else
    an<angle> whose numeric factor isvalueInSpecifiedUnits and whose unit is as indicated by the angle unit type table above
  4. If theSVGAnglereflects the base value of areflected attribute orreflects an element of the base value of areflected attribute, thenreserialize the reflected attribute.

TheconvertToSpecifiedUnitsmethod is used to convert theSVGAngle's value to a specific type.When convertToSpecifiedUnits(unitType) is called, the following steps are run:

  1. If theSVGAngle object isread only, thenthrow aNoModificationAllowedError.
  2. IfunitType isSVG_ANGLETYPE_UNKNOWN or is a value that does not appear in the angle unit type table above, thenthrow aNotSupportedError.
  3. Letdegrees be the value that would be returned from thevalue member.
  4. IfunitType isSVG_ANGLETYPE_UNSPECIFIED, then:
    1. Set theSVGAngle'svalue to a<number> whose value isdegrees.
  5. Otherwise:
    1. Set theSVGAngle'svalue to the result of convertingdegrees to an<angle> with the unit found by looking upunitType in the angle unit type table above.
  6. If theSVGAnglereflects the base value of areflected attribute orreflects an element of the base value of areflected attribute, thenreserialize the reflected attribute.

4.5.4. List interfaces

SVG 2 Requirement:Make the SVGList* interfaces a bit more like other lists/arrays.
Resolution:Add array style indexing and .length and .item to svg list types.
Purpose:To align with other array types (e.g. NodeList). Already implemented in Opera and Firefox.
Owner:Erik (ACTION-2975)
Status:Done

Some SVG attributes contain lists of values, and to represent these valuesthere are a number of SVG DOMlist interfaces, onefor each required element type –SVGNumberList,SVGLengthList,SVGPointList,SVGTransformList andSVGStringList.The first four are used to represent the base andanimated components ofSVGAnimatedNumberList,SVGAnimatedLengthList,SVGAnimatedPoints andSVGTransformList objects,while the fifth,SVGStringList, is used toreflect afew unanimated attributes that take a list of strings.

Mostlist interfaces take the following form:

interfaceSVGNameList {  readonly attribute unsigned longlength;  readonly attribute unsigned longnumberOfItems;  voidclear();Typeinitialize(Type newItem);  getterTypegetItem(unsigned long index);TypeinsertItemBefore(Type newItem, unsigned long index);TypereplaceItem(Type newItem, unsigned long index);TyperemoveItem(unsigned long index);TypeappendItem(Type newItem);setter void (unsigned long index,Type newItem);};

whereName is a descriptive name for the list element's("Number", "Length", "Point", "Transform" or "String") andType is the IDL type of thelist's elements (SVGNumber,SVGLength,DOMPoint,SVGTransform orDOMString).

TheSVGTransformList interface takes the above form but hastwo additional methods on it.

Alllist interface objects apart fromSVGTransformListreflect the base value of a reflected contentattribute.SVGTransformList objects reflect a presentationattribute (‘transform’,gradientTransform orpatternTransform).Alllist interface objects are associated with a particular element.UnlikeSVGLength and similar objects, there are no "detached"list interface objects.

Alist interface object maintains an internal list of elements,which is referred to in the text below simply as "the list".The IDL attributes and methods are used to inspect and manipulate elementsof the list. The list can also be changed in response tochanges to the reflected content attribute and to animation ofthe content attribute (or, forSVGTransformList objects,in response to changes to the computed value of thetransformproperty).

Alist interface object can be designated asread only, which means that attempts to modify the object will resultin an exception being thrown, as described below.list interface objectsreflected through the animVal IDL attribute are alwaysread only.

Alist interface objectissynchronized by runningthe following steps:

  1. Letvalue be the base value of the reflected content attribute (using the attribute'sinitial value if it is not present or invalid).
  2. Letlength be the number of items in the list.
  3. Letnew length be the number of values invalue. Ifvalue is the keywordnone (as supported by thetransform property),new length is 0.
  4. If the list element type isSVGNumber,SVGLength,DOMPoint orSVGTransform, then:
    1. Iflength >new length, then:
      1. Detach each object in the list at an index greater than or equal tonew length.
      2. Truncate the list to lengthnew length.
      3. Setlength tonew length.
    2. Whilelength <new length:
      1. Letitem be a newly created object of the list element type.
      2. Attachitem to thislist interface object.
      3. Appenditem to the list.
      4. Setlength tolength + 1.
    3. Letindex be 0.
    4. Whileindex <length:
      1. Letitem be the object in the list at indexindex.
      2. Letv be the value invalue at indexindex.
      3. Setitem's value tov.
      4. Ifitem is anSVGTransform object, then set the components of itsmatrix object to match the new transform function value.
      5. Setindex toindex + 1.
  5. Otherwise, the list element type isDOMString:
    1. Replace the list with a new list consisting of the values invalue.

Whenever a list element object is to bedetached,the following steps are run, depending on the list element type:

SVGNumber
Set theSVGNumber to no longer beassociated with any element. If theSVGNumber isread only, set it to be no longer read only.
SVGLength
Set theSVGLength to no longer beassociated with any element. If theSVGLength isread only, set it to be no longer read only. Set theSVGLength to have unspecifieddirectionality.
DOMPoint
Set theDOMPoint to no longer beassociated with any element. If theDOMPoint isread only, set it to be no longer read only.
SVGTransform
Set theSVGTransform to no longer beassociated with any element. If theSVGTransform isread only, set it to be no longer read only.
DOMString
Nothing is done.

Whenever a list element object is to beattached,the following steps are run, depending on the list element type:

SVGNumber
Associate theSVGNumber with the element that thelist interface object is associated with. Additionally, depending on which IDL attribute thelist interface object is reflected through:
baseVal
Set theSVGNumber toreflect an element of the base value.
animVal
Set theSVGNumber toreflect an element of the base value.
SVGLength
Associate theSVGLength with the element that thelist interface object is associated with and set itsdirectionality to that specified by the attribute being reflected. Additionally, depending on which IDL attribute thelist interface object is reflected through:
baseVal
Set theSVGLength toreflect an element of the base value.
animVal
Set theSVGLength toreflect an element of the base value. Set theSVGLength to beread only.
DOMPoint
Associate theDOMPoint with the element that thelist interface object is associated with. Additionally, depending on which IDL attribute thelist interface object is reflected through:
baseVal
Set theDOMPoint toreflect an element of the base value.
animVal
Set theDOMPoint toreflect an element of the base value.
SVGTransform
Associate theSVGTransform with the element that thelist interface object is associated with. Set theSVGTransform toreflect an element of a presentation attribute value.
DOMString
Nothing is done.

Thesupported property indicesof alist interface object is the set of all non-negative integersless than the length of the list.

Thelength andnumberOfItems IDL attributesrepresents the length of the list, and on getting simply returnthe length of the list.

Theclear method is used toremove all items in the list. When clear() is called, the following steps are run:

  1. If the list isread only, thenthrow aNoModificationAllowedError.
  2. Detach and then remove all elements in the list.
  3. If the listreflects an attribute, or represents the base value of an object thatreflects an attribute, thenreserialize the reflected attribute.

Theinitialize methodis used to clear the list and add a single, specified value to it.When initialize(newItem) is called, the following steps are run:

  1. If the list isread only, thenthrow aNoModificationAllowedError.
  2. Detach and then remove all elements in the list.
  3. IfnewItem is an object type, andnewItem is not a detached object, then setnewItem to be a newly created object of the same type asnewItem and which has the same (number or length) value.
  4. AttachnewItem to thelist interface object.
  5. AppendnewItem to this list.
  6. If the listreflects an attribute, or represents the base value of an object thatreflects an attribute, thenreserialize the reflected attribute.
  7. ReturnnewItem.

ThegetItem method is usedto get an item from the list at the specified position. WhengetItem(index) is called, the following steps are run:

  1. Ifindex is greater than or equal to the length of the list, thenthrow anIndexSizeError.
  2. Return the element in the list at positionindex.

    Note that if the list's element type is an object type, such asSVGLength, then a reference to that object and not a copy of it is returned.

TheinsertItemBeforemethod is used to insert an element into the list at a specific position.When insertItemBefore(newItem,index) is called,the following steps are run:

  1. If the list isread only, thenthrow aNoModificationAllowedError.
  2. IfnewItem is an object type, andnewItem is not a detached object, then setnewItem to be a newly created object of the same type asnewItem and which has the same (number or length) value.
  3. Ifindex is greater than the length of the list, then setindex to be the list length.
  4. InsertnewItem into the list at indexindex.
  5. AttachnewItem to thelist interface object.
  6. If the listreflects an attribute, or represents the base value of an object thatreflects an attribute, thenreserialize the reflected attribute.
  7. ReturnnewItem.

ThereplaceItem methodis used to replace an existing item in the list with a new item.When replaceItem(newItem,index) is called, thefollowing steps are run:

  1. If the list isread only, thenthrow aNoModificationAllowedError.
  2. Ifindex is greater than or equal to the length of the list, thenthrow anIndexSizeError.
  3. IfnewItem is an object type, andnewItem is not a detached object, then setnewItem to be a newly created object of the same type asnewItem and which has the same (number or length) value.
  4. Detach the element in the list at indexindex.
  5. Replace the element in the list at indexindex withnewItem.
  6. AttachnewItem to thelist interface object.
  7. If the listreflects an attribute, or represents the base value of an object thatreflects an attribute, thenreserialize the reflected attribute.
  8. ReturnnewItem.

TheremoveItem methodis used to remove an item from the list. When removeItem(index)is called, the following steps are run:

  1. If the list isread only, thenthrow aNoModificationAllowedError.
  2. Ifindex is greater than or equal to the length of the list, thenthrow anIndexSizeError with code.
  3. Letitem be the list element at indexindex.
  4. Detachitem.
  5. Remove the list element at indexindex.
  6. Returnitem.

TheappendItem methodis used to append an item to the end of the list. When appendItem(newItem)is called, the following steps are run:

  1. If the list isread only, thenthrow aNoModificationAllowedError.
  2. IfnewItem is an object type, andnewItem is not a detached object, then setnewItem to be a newly created object of the same type asnewItem and which has the same (number or length) value.
  3. Letindex be the length of the list.
  4. AppendnewItem to the end of the list.
  5. AttachnewItem to thelist interface object.
  6. If the listreflects an attribute, or represents the base value of an object thatreflects an attribute, thenreserialize the reflected attribute.
  7. ReturnnewItem.

The behavior of theindexed property setteris the same as that for thereplaceItemmethod.

4.5.5. Interface SVGNumberList

TheSVGNumberList interface is alist interface whoseelements areSVGNumber objects. AnSVGNumberList objectrepresents a list of numbers.

[Exposed=Window]interfaceSVGNumberList {  readonly attribute unsigned longlength;  readonly attribute unsigned longnumberOfItems;  voidclear();SVGNumberinitialize(SVGNumber newItem);  getterSVGNumbergetItem(unsigned long index);SVGNumberinsertItemBefore(SVGNumber newItem, unsigned long index);SVGNumberreplaceItem(SVGNumber newItem, unsigned long index);SVGNumberremoveItem(unsigned long index);SVGNumberappendItem(SVGNumber newItem);setter void (unsigned long index,SVGNumber newItem);};

The behavior of all of the interface members ofSVGNumberList aredefined in theList interfaces section above.

4.5.6. Interface SVGLengthList

TheSVGLengthList interface is alist interface whoseelements areSVGLength objects. AnSVGLengthList objectrepresents a list of lengths.

[Exposed=Window]interfaceSVGLengthList {  readonly attribute unsigned longlength;  readonly attribute unsigned longnumberOfItems;  voidclear();SVGLengthinitialize(SVGLength newItem);  getterSVGLengthgetItem(unsigned long index);SVGLengthinsertItemBefore(SVGLength newItem, unsigned long index);SVGLengthreplaceItem(SVGLength newItem, unsigned long index);SVGLengthremoveItem(unsigned long index);SVGLengthappendItem(SVGLength newItem);setter void (unsigned long index,SVGLength newItem);};

The behavior of all of the interface members ofSVGLengthList aredefined in theList interfaces section above.

4.5.7. Interface SVGStringList

TheSVGStringList interface is alist interface whoseelements areDOMString values. AnSVGStringList objectrepresents a list of strings.

[Exposed=Window]interfaceSVGStringList {  readonly attribute unsigned longlength;  readonly attribute unsigned longnumberOfItems;  voidclear();  DOMStringinitialize(DOMString newItem);  getter DOMStringgetItem(unsigned long index);  DOMStringinsertItemBefore(DOMString newItem, unsigned long index);  DOMStringreplaceItem(DOMString newItem, unsigned long index);  DOMStringremoveItem(unsigned long index);  DOMStringappendItem(DOMString newItem);setter void (unsigned long index, DOMString newItem);};

The behavior of all of the interface members ofSVGStringList aredefined in theList interfaces section above.

4.6. DOM interfaces for reflecting animatable SVG attributes

The following interfaces are used to represent the reflected value of animatable content attributes. They each consist of two component objects, representing the same data:baseVal andanimVal. ThebaseVal (base value) object is modifiable, to update the corresponding attribute value.

In SVG 1.1, theanimVal attribute of the SVG DOM interfaces represented the current animated value of the reflected attribute. In this version of SVG,animVal no longer representes the current animated value and is instead an alias ofbaseVal.

4.6.1. Interface SVGAnimatedBoolean

AnSVGAnimatedBoolean object is used toreflect ananimatable attribute that takes a boolean value.

[Exposed=Window]interfaceSVGAnimatedBoolean {           attribute booleanbaseVal;  readonly attribute booleananimVal;};

ThebaseVal andanimVal IDL attributesboth represent the current non-animated value of the reflected attribute.On gettingbaseValoranimVal,the following steps are run:

  1. Letvalue be the value of the reflected attribute, or the empty string if it is not present.
  2. Ifvalue is not "true" or "false", then setvalue to the reflected attribute'sinitial value.
  3. Return true ifvalue is "true", and false otherwise.

On settingbaseVal,the reflected attribute is set to "true" if the value is true, and "false"otherwise.

4.6.2. Interface SVGAnimatedEnumeration

AnSVGAnimatedEnumeration object is used toreflectan animatable attribute that takes a keyword value (such asthemethod attribute ontextPath) or to reflectthe type of value that an animatable attribute has (doneonly by theorientTypeIDL attribute for themarker element'sorient attribute).

[Exposed=Window]interfaceSVGAnimatedEnumeration {           attribute unsigned shortbaseVal;  readonly attribute unsigned shortanimVal;};

ForSVGAnimatedEnumeration objects thatreflect ananimatable attribute that takes only a keyword value, thebaseVal andanimVal IDL attributesrepresents the current non-animated value of the reflected attribute.FororientType,they represent the type of the current non-animated value of thereflectedorient attribute. On gettingbaseVal oranimVal, thefollowing steps are run:

  1. Letvalue be the value of the reflected attribute (using the attribute'sinitial value if it is not present or invalid).
  2. Return thenumeric type value forvalue, according to the reflecting IDL attribute's definition.

On settingbaseVal,the following steps are run:

  1. Letvalue be the value being assigned tobaseVal.
  2. Ifvalue is 0 or is not thenumeric type value for any value of the reflected attribute, then set the reflected attribute to the empty string.
  3. Otherwise, if the reflecting IDL attribute isorientType andvalue isSVG_MARKER_ORIENT_ANGLE, then set the reflected attribute to the string "0".
  4. Otherwise,value is thenumeric type value for a specific, single keyword value for the reflected attribute. Set the reflected attribute to that value.

4.6.3. Interface SVGAnimatedInteger

AnSVGAnimatedInteger object is used toreflect ananimatable attribute that takes an integer value (such asnumOctaves onfeTurbulence). It is alsoused to reflect one part of an animatable attribute that takesan integer followed by an optional second integer (such asorder onfeConvolveMatrix).

ThisSVGAnimatedInteger interfaceis not used in this specification, however theFilter Effectsspecification has a number of uses of it.

[Exposed=Window]interfaceSVGAnimatedInteger {           attribute longbaseVal;  readonly attribute longanimVal;};

ForSVGAnimatedInteger objects thatreflectan animatable attribute that takes a single integer value, thebaseVal andanimVal IDL attributesrepresent the current non-animated value of the reflected attribute.For those that reflect one integer of an attribute that takes aninteger followed by an optional second integer, they represent thecurrent non-animated value of one of the two integers. On gettingbaseVal oranimVal, thefollowing steps are run:

  1. Letvalue be the value of the reflected attribute (using the attribute'sinitial value if it is not present or invalid).
  2. If the reflected attribute is defined to take an integer followed by an optional second integer, then:
    1. If thisSVGAnimatedInteger object reflects the first integer, then return the first value invalue.
    2. Otherwise, thisSVGAnimatedInteger object reflects the second integer. Return the second value invalue if it has been explicitly specified, and if not, return the implicit value as described in the definition of the attribute.

      For example, the definition oforder says that the implicit second integer is the same as the explicit first integer.

  3. Otherwise, the reflected attribute is defined to take a single integer value. Returnvalue.

On settingbaseVal,the following steps are run:

  1. Letvalue be the value being assigned tobaseVal.
  2. Letnew be a list of integers.
  3. If the reflected attribute is defined to take an integer followed by an optional second integer, then:
    1. Letcurrent be the value of the reflected attribute (using the attribute'sinitial value if it is not present or invalid).
    2. Letfirst be the first integer incurrent.
    3. Letsecond be the second integer incurrent if it has been explicitly specified, and if not, the implicit value as described in the definition of the attribute.
    4. If thisSVGAnimatedInteger object reflects the first integer, then setfirst tovalue. Otherwise, setsecond tovalue.
    5. Appendfirst tonew.
    6. Appendsecond tonew.
  4. Otherwise, the reflected attribute is defined to take a single integer value. Appendvalue tonew.
  5. Set the content attribute to a string consisting of each integer innew serialized to an implementation specific string that, if parsed as an<number> using CSS syntax, would return that integer, joined and separated by a single U+0020 SPACE character.

4.6.4. Interface SVGAnimatedNumber

AnSVGAnimatedNumber object is used toreflect ananimatable attribute that takes a number value (such aspathLength onpath). It is alsoused to reflect one part of an animatable attribute that takesan number followed by an optional second number (such askernelUnitLength onfeDiffuseLighting).

[Exposed=Window]interfaceSVGAnimatedNumber {           attribute floatbaseVal;  readonly attribute floatanimVal;};

ForSVGAnimatedNumber objects thatreflectan animatable attribute that takes a single number value, thebaseVal andanimVal IDL attributesrepresent the current non-animated value of the reflected attribute.For those that reflect one number of an attribute that takes anumber followed by an optional second number, they represent thecurrent non-animated value of one of the two numbers. On gettingbaseVal oranimVal, thefollowing steps are run:

  1. Letvalue be the value of the reflected attribute (using the attribute'sinitial value if it is not present or invalid).
  2. If the reflected attribute is defined to take an number followed by an optional second number, then:
    1. If thisSVGAnimatedNumber object reflects the first number, then return the first value invalue.
    2. Otherwise, thisSVGAnimatedNumber object reflects the second number. Return the second value invalue if it has been explicitly specified, and if not, return the implicit value as described in the definition of the attribute.

      For example, the definition ofkernelUnitLength says that the implicit second number is the same as the explicit first number.

  3. Otherwise, the reflected attribute is defined to take a single number value. Returnvalue.

On settingbaseVal,the following steps are run:

  1. Letvalue be the value being assigned tobaseVal.
  2. Letnew be a list of numbers.
  3. If the reflected attribute is defined to take an number followed by an optional second number, then:
    1. Letcurrent be the value of the reflected attribute (using the attribute'sinitial value if it is not present or invalid).
    2. Letfirst be the first number incurrent.
    3. Letsecond be the second number incurrent if it has been explicitly specified, and if not, the implicit value as described in the definition of the attribute.
    4. If thisSVGAnimatedNumber object reflects the first number, then setfirst tovalue. Otherwise, setsecond tovalue.
    5. Appendfirst tonew.
    6. Appendsecond tonew.
  4. Otherwise, the reflected attribute is defined to take a single number value. Appendvalue tonew.
  5. Set the content attribute to a string consisting of each number innew serialized to an implementation specific string that, if parsed as an<number> using CSS syntax, would return the value closest to the number (given the implementation's supportedPrecisionreal number precision), joined and separated by a single U+0020 SPACE character.

4.6.5. Interface SVGAnimatedLength

AnSVGAnimatedLength object is used toreflect either(a) an animatable attribute that takes a<length>,<percentage> or<number> value, or (b) aCSS property that takes one of these values and its correspondingpresentation attribute.

[Exposed=Window]interfaceSVGAnimatedLength {  [SameObject] readonly attributeSVGLengthbaseVal;  [SameObject] readonly attributeSVGLengthanimVal;};

ThebaseVal andanimVal IDL attributesrepresent the current value of the reflected content attribute.On gettingbaseVal oranimVal,anSVGLength object is returned that:

4.6.6. Interface SVGAnimatedAngle

AnSVGAnimatedAngle object is used toreflectthe<angle> value of the animatedorientattribute onmarker, through theorientAngleIDL attribute.

[Exposed=Window]interfaceSVGAnimatedAngle {  [SameObject] readonly attributeSVGAnglebaseVal;  [SameObject] readonly attributeSVGAngleanimVal;};

ThebaseVal andanimVal IDL attributes representthe current non-animated<angle> value of thereflectedorient attribute. On gettingbaseVal oranimVal, anSVGAngle object is returned that:

4.6.7. Interface SVGAnimatedString

AnSVGAnimatedString object is used toreflect ananimatable attribute that takes a string value. It can optionallybe defined to additionally reflect a second, deprecated attribute.

[Exposed=Window]interfaceSVGAnimatedString {           attribute DOMStringbaseVal;  readonly attribute DOMStringanimVal;};

ThebaseValandanimVal IDL attributesrepresent the current non-animated value of the reflected attribute.On gettingbaseValoranimVal,the following steps are run:

  1. If the reflected attribute is not present, then:
    1. If theSVGAnimatedString object is defined to additionally reflect a second, deprecated attribute, and that attribute is present, then return its value.
    2. Otherwise, if the reflected attribute has aninitial value, then return it.
    3. Otherwise, return the empty string.
  2. Otherwise, the reflected attribute is present. Return its value.

For thehrefmember on theSVGURIReference interface, this will result inthe deprecatedxlink:href attribute being returned if it ispresent and the‘href’ attribute is not,and in the‘href’ attribute beingreturned in all other cases.

On settingbaseVal,the following steps are run:

  1. If the reflected attribute is not present, theSVGAnimatedString object is defined to additionally reflect a second, deprecated attribute, and that deprecated attribute is present, then set that deprecated attribute to the specified value.
  2. Otherwise, set the reflected attribute to the specified value.

For thehrefmember on theSVGURIReference interface, this will result inthe deprecatedxlink:href attribute being set if it ispresent and the‘href’ attribute is not,and in the‘href’ attribute beingset in all other cases.

4.6.8. Interface SVGAnimatedRect

AnSVGAnimatedRect object is used toreflect ananimatable attribute that takes a rectangle value as specifiedby anx,y,width andheight.

In this specification the only attribute to bereflected as anSVGAnimatedRect isviewBox.

[Exposed=Window]interfaceSVGAnimatedRect {  [SameObject] readonly attributeDOMRectbaseVal;  [SameObject] readonly attributeDOMRectReadOnlyanimVal;};

ThebaseValandanimVal IDLattributes represent the current non-animated rectangle value ofthe reflected attribute. On gettingbaseValoranimVal,aDOMRect object is returned.

Upon creation of thebaseValoranimValDOMRect objects, and afterwards whenever the reflected content attributeis added, removed, or changed, the following steps are run:

  1. Letvalue be the value of the reflected attribute (using the attribute'sinitial value if it is not present or invalid).
  2. Letx,y,width andheight be those corresponding components ofvalue.
  3. Set theDOMRect object'sx coordinate,y coordinate,width andheight tox,y,width andheight, respectively.

Whenever thex coordinate,y coordinate,width orheight propertyof thebaseVal oranimValDOMRect object changes, except as part of the previous algorithm thatreflects the value of the content attribute into theDOMRect, the reflectedcontent attribute must bereserialized.

4.6.9. Interface SVGAnimatedNumberList

AnSVGAnimatedNumberList object is used toreflect an animatableattribute that takes a list of<number> values.

[Exposed=Window]interfaceSVGAnimatedNumberList {  [SameObject] readonly attributeSVGNumberListbaseVal;  [SameObject] readonly attributeSVGNumberListanimVal;};

ThebaseValandanimVal IDL attributesrepresent the current non-animated value of the reflected attribute.On gettingbaseVal oranimVal,anSVGNumberList object is returned that reflects the base valueof the reflected attribute.

4.6.10. Interface SVGAnimatedLengthList

AnSVGAnimatedLengthList object is used toreflect an animatableattribute that takes a list of<length>,<percentage>or<number> values.

[Exposed=Window]interfaceSVGAnimatedLengthList {  [SameObject] readonly attributeSVGLengthListbaseVal;  [SameObject] readonly attributeSVGLengthListanimVal;};

ThebaseValoranimVal IDL attributesrepresent the current non-animated value of the reflected attribute.On gettingbaseVal oranimVal,anSVGLengthList object is returned that reflects the base valueof the reflected attribute.

4.7. Other DOM interfaces

4.7.1. Interface SVGUnitTypes

TheSVGUnitTypes interface defines a commonly used set of constantsused for reflectinggradientUnits,patternContentUnits andother similar attributes.

[Exposed=Window]interfaceSVGUnitTypes {  // Unit Types  const unsigned shortSVG_UNIT_TYPE_UNKNOWN = 0;  const unsigned shortSVG_UNIT_TYPE_USERSPACEONUSE = 1;  const unsigned shortSVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 2;};

The unit type constants defined onSVGUnitTypes have the following meanings:

ConstantMeaning
SVG_UNIT_TYPE_USERSPACEONUSECorresponds to the'userSpaceOnUse' attribute value.
SVG_UNIT_TYPE_OBJECTBOUNDINGBOXCorresponds to the'objectBoundingBox' attribute value.
SVG_UNIT_TYPE_UNKNOWNSome other type of value.

4.7.2. Mixin SVGTests

TheSVGTests interface is used to reflectconditional processing attributes, and is mixed in to otherinterfaces for elements that support these attributes.

interface mixinSVGTests {  [SameObject] readonly attributeSVGStringListrequiredExtensions;  [SameObject] readonly attributeSVGStringListsystemLanguage;};

TherequiredExtensions IDL attributereflects therequiredExtensions content attribute.

ThesystemLanguage IDL attributereflects thesystemLanguage content attribute.

4.7.3. Mixin SVGFitToViewBox

TheSVGFitToViewBox interface is used to reflecttheviewBox andpreserveAspectRatio attributes,and is mixed in to other interfaces for elements that supportthese two attributes.

interface mixinSVGFitToViewBox {  [SameObject] readonly attributeSVGAnimatedRectviewBox;  [SameObject] readonly attributeSVGAnimatedPreserveAspectRatiopreserveAspectRatio;};

TheviewBox IDL attributereflects theviewBox content attribute.

ThepreserveAspectRatio IDL attributereflects thepreserveAspectRatio content attribute.

4.7.4. Mixin SVGZoomAndPan

TheSVGZoomAndPan interface is used to reflect thezoomAndPan attribute, and is mixed in to otherinterfaces for elements that support this attribute.

interface mixinSVGZoomAndPan {  // Zoom and Pan Types  const unsigned shortSVG_ZOOMANDPAN_UNKNOWN = 0;  const unsigned shortSVG_ZOOMANDPAN_DISABLE = 1;  const unsigned shortSVG_ZOOMANDPAN_MAGNIFY = 2;  attribute unsigned shortzoomAndPan;};

The zoom and pan type constants defined onSVGZoomAndPan have thefollowing meanings:

ConstantMeaning
SVG_ZOOMANDPAN_DISABLECorresponds to the'disable' attribute value.
SVG_ZOOMANDPAN_MAGNIFYCorresponds to the'magnify' attribute value.
SVG_ZOOMANDPAN_UNKNOWNSome other type of value.

ThezoomAndPanIDL attribute represents the value of thezoomAndPan attribute.On gettingzoomAndPan, thefollowing steps are run:

  1. Letvalue be the current value of thezoomAndPan attribute (using the attribute'sinitial value if it is not present or invalid).
  2. Return the corresponding constant in the zoom and pan type constant table above forvalue.

On settingzoomAndPan,the following steps are run:

  1. Letvalue be the value being assigned to azoomAndPan.
  2. Ifvalue isSVG_ZOOMANDPAN_UNKNOWN or does not correspond to an entry in the zoom and pan type constant table above, then return.
  3. Set thezoomAndPan attribute to the keyword value in the zoom and pan type constant table above that corresponds tovalue.

4.7.5. Mixin SVGURIReference

TheSVGURIReference interface is used to reflectthe‘href’ attribute and the deprecatedxlink:href attribute.

interface mixinSVGURIReference {  [SameObject] readonly attributeSVGAnimatedStringhref;};

Thehref IDL attributerepresents the value of the‘href’attribute, and, on elements that are defined to support it,the deprecatedxlink:href attribute. On gettinghref, anSVGAnimatedString object is returned that:

TheSVGAnimatedString interface is definedto reflect, through itsbaseValandanimVal members, the deprecatedxlink:href attribute, if that attribute ispresent and the‘href’ is not, and toreflect the‘href’ attribute in allother circumstances.Animation elementstreatattributeName='xlink:href'as being an alias for targetting the‘href’ attribute.


[8]ページ先頭

©2009-2025 Movatter.jp