<?xml version="1.0" encoding="utf-8"?> <!-- CSSPrimitiveValue interface --> <interface id="CSS-CSSPrimitiveValue" name="CSSPrimitiveValue" inherits="CSSValue" since="DOM Level 2"> <descr> <p> The <code>CSSPrimitiveValue</code> interface represents a single <xspecref href="&css2;/syndata.html#values">CSS value</xspecref>. This interface may be used to determine the value of a specific style property currently set in a block or to set a specific style property explicitly within the block. An instance of this interface might be obtained from the <code>getPropertyCSSValue</code> method of the <code>CSSStyleDeclaration</code> interface. A <code>CSSPrimitiveValue</code> object only occurs in a context of a CSS property. </p> <p> Conversions are allowed between absolute values (from millimeters to centimeters, from degrees to radians, and so on) but not between relative values. (For example, a pixel value cannot be converted to a centimeter value.) Percentage values can't be converted since they are relative to the parent value (or another property value). There is one exception for color percentage values: since a color percentage value is relative to the range 0-255, a color percentage value can be converted to a number; (see also the <code>RGBColor</code> interface). </p> </descr> <group id="CSS-CSSPrimitiveValue-types" name="UnitTypes"> <descr> <p>An integer indicating which type of unit applies to the value.</p> </descr> <constant name="CSS_UNKNOWN" type="unsigned short" value="0"> <descr><p>The value is not a recognized CSS2 value. The value can only be obtained by using the <code>cssText</code> attribute.</p></descr> </constant> <constant name="CSS_NUMBER" type="unsigned short" value="1"> <descr><p>The value is a simple <xspecref href="&css2;/syndata.html#q13">number</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_PERCENTAGE" type="unsigned short" value="2"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#percentage-units">percentage</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_EMS" type="unsigned short" value="3"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#length-units">length (ems)</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_EXS" type="unsigned short" value="4"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#length-units">length (exs)</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_PX" type="unsigned short" value="5"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#length-units">length (px)</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_CM" type="unsigned short" value="6"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#length-units">length (cm)</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_MM" type="unsigned short" value="7"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#length-units">length (mm)</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_IN" type="unsigned short" value="8"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#length-units">length (in)</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_PT" type="unsigned short" value="9"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#length-units">length (pt)</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_PC" type="unsigned short" value="10"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#length-units">length (pc)</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_DEG" type="unsigned short" value="11"> <descr><p>The value is an <xspecref href="&css2;/syndata.html#q19">angle (deg)</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_RAD" type="unsigned short" value="12"> <descr><p>The value is an <xspecref href="&css2;/syndata.html#q19">angle (rad)</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_GRAD" type="unsigned short" value="13"> <descr><p>The value is an <xspecref href="&css2;/syndata.html#q19">angle (grad)</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_MS" type="unsigned short" value="14"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#q20">time (ms)</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_S" type="unsigned short" value="15"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#q20">time (s)</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_HZ" type="unsigned short" value="16"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#q21">frequency (Hz)</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_KHZ" type="unsigned short" value="17"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#q21">frequency (kHz)</xspecref>. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_DIMENSION" type="unsigned short" value="18"> <descr><p>The value is a number with an unknown dimension. The value can be obtained by using the <code>getFloatValue</code> method.</p></descr> </constant> <constant name="CSS_STRING" type="unsigned short" value="19"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#strings">STRING</xspecref>. The value can be obtained by using the <code>getStringValue</code> method.</p></descr> </constant> <constant name="CSS_URI" type="unsigned short" value="20"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#uri">URI</xspecref>. The value can be obtained by using the <code>getStringValue</code> method.</p></descr> </constant> <constant name="CSS_IDENT" type="unsigned short" value="21"> <descr><p>The value is an <xspecref href="&css2;/syndata.html#value-def-identifier">identifier</xspecref>. The value can be obtained by using the <code>getStringValue</code> method.</p></descr> </constant> <constant name="CSS_ATTR" type="unsigned short" value="22"> <descr><p>The value is a <xspecref href="&css2;/generate.html#x16">attribute function</xspecref>. The value can be obtained by using the <code>getStringValue</code> method.</p></descr> </constant> <constant name="CSS_COUNTER" type="unsigned short" value="23"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#counter">counter or counters function</xspecref>. The value can be obtained by using the <code>getCounterValue</code> method.</p></descr> </constant> <constant name="CSS_RECT" type="unsigned short" value="24"> <descr><p>The value is a <xspecref href="&css2;/visufx.html#value-def-shape">rect function</xspecref>. The value can be obtained by using the <code>getRectValue</code> method.</p></descr> </constant> <constant name="CSS_RGBCOLOR" type="unsigned short" value="25"> <descr><p>The value is a <xspecref href="&css2;/syndata.html#color-units">RGB color</xspecref>. The value can be obtained by using the <code>getRGBColorValue</code> method.</p></descr> </constant> </group> <attribute id="CSS-CSSPrimitiveValue-primitiveType" name="primitiveType" type="unsigned short" readonly="yes"> <descr> <p>The type of the value as defined by the constants specified above.</p> </descr> </attribute> <method id="CSS-CSSPrimitiveValue-setFloatValue" name="setFloatValue"> <descr> <p> A method to set the float value with a specified unit. If the property attached with this value can not accept the specified unit or the float value, the value will be unchanged and a <code>DOMException</code> will be raised. </p> </descr> <parameters> <param name="unitType" type="unsigned short" attr="in"> <descr> <p> A unit code as defined above. The unit code can only be a float unit type (i.e. <code>CSS_NUMBER</code>, <code>CSS_PERCENTAGE</code>, <code>CSS_EMS</code>, <code>CSS_EXS</code>, <code>CSS_PX</code>, <code>CSS_CM</code>, <code>CSS_MM</code>, <code>CSS_IN</code>, <code>CSS_PT</code>, <code>CSS_PC</code>, <code>CSS_DEG</code>, <code>CSS_RAD</code>, <code>CSS_GRAD</code>, <code>CSS_MS</code>, <code>CSS_S</code>, <code>CSS_HZ</code>, <code>CSS_KHZ</code>, <code>CSS_DIMENSION</code>). </p> </descr> </param> <param name="floatValue" type="float" attr="in"> <descr> <p> The new float value. </p> </descr> </param> </parameters> <returns type="void"> <descr> </descr> </returns> <raises> <exception name="DOMException"> <descr> <p> INVALID_ACCESS_ERR: Raised if the attached property doesn't support the float value or the unit type.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.</p> </descr> </exception> </raises> </method> <method id="CSS-CSSPrimitiveValue-getFloatValue" name="getFloatValue"> <descr> <p> This method is used to get a float value in a specified unit. If this CSS value doesn't contain a float value or can't be converted into the specified unit, a <code>DOMException</code> is raised. </p> </descr> <parameters> <param name="unitType" type="unsigned short" attr="in"> <descr> <p> A unit code to get the float value. The unit code can only be a float unit type (i.e. <code>CSS_NUMBER</code>, <code>CSS_PERCENTAGE</code>, <code>CSS_EMS</code>, <code>CSS_EXS</code>, <code>CSS_PX</code>, <code>CSS_CM</code>, <code>CSS_MM</code>, <code>CSS_IN</code>, <code>CSS_PT</code>, <code>CSS_PC</code>, <code>CSS_DEG</code>, <code>CSS_RAD</code>, <code>CSS_GRAD</code>, <code>CSS_MS</code>, <code>CSS_S</code>, <code>CSS_HZ</code>, <code>CSS_KHZ</code>, <code>CSS_DIMENSION</code>). </p> </descr> </param> </parameters> <returns type="float"> <descr> <p> The float value in the specified unit. </p> </descr> </returns> <raises> <exception name="DOMException"> <descr> <p> INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a float value or if the float value can't be converted into the specified unit. </p> </descr> </exception> </raises> </method> <method id="CSS-CSSPrimitiveValue-setStringValue" name="setStringValue"> <descr> <p> A method to set the string value with the specified unit. If the property attached to this value can't accept the specified unit or the string value, the value will be unchanged and a <code>DOMException</code> will be raised. </p> </descr> <parameters> <param name="stringType" type="unsigned short" attr="in"> <descr> <p> A string code as defined above. The string code can only be a string unit type (i.e. <code>CSS_STRING</code>, <code>CSS_URI</code>, <code>CSS_IDENT</code>, and <code>CSS_ATTR</code>). </p> </descr> </param> <param name="stringValue" type="DOMString" attr="in"> <descr> <p> The new string value. </p> </descr> </param> </parameters> <returns type="void"> <descr> </descr> </returns> <raises> <exception name="DOMException"> <descr> <p> INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string value or if the string value can't be converted into the specified unit.</p> <p>NO_MODIFICATION_ALLOWED_ERR: Raised if this property is readonly.</p> </descr> </exception> </raises> </method> <method id="CSS-CSSPrimitiveValue-getStringValue" name="getStringValue"> <descr> <p> This method is used to get the string value. If the CSS value doesn't contain a string value, a <code>DOMException</code> is raised. </p> <note> <p> Some properties (like <loc href="&css2;/fonts.html#propdef-font-family">'font-family'</loc> or <loc href="&css2;/aural.html#propdef-voice-family">'voice-family'</loc>) convert a whitespace separated list of idents to a string. </p> </note> </descr> <parameters> </parameters> <returns type="DOMString"> <descr> <p> The string value in the current unit. The current <code>primitiveType</code> can only be a string unit type (i.e. <code>CSS_STRING</code>, <code>CSS_URI</code>, <code>CSS_IDENT</code> and <code>CSS_ATTR</code>). </p> </descr> </returns> <raises> <exception name="DOMException"> <descr> <p> INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a string value. </p> </descr> </exception> </raises> </method> <method id="CSS-CSSPrimitiveValue-getCounterValue" name="getCounterValue"> <descr> <p> This method is used to get the Counter value. If this CSS value doesn't contain a counter value, a <code>DOMException</code> is raised. Modification to the corresponding style property can be achieved using the <code>Counter</code> interface. </p> </descr> <parameters> </parameters> <returns type="Counter"> <descr> <p>The Counter value.</p> </descr> </returns> <raises> <exception name="DOMException"> <descr> <p> INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a Counter value (e.g. this is not <code>CSS_COUNTER</code>). </p> </descr> </exception> </raises> </method> <method id="CSS-CSSPrimitiveValue-getRectValue" name="getRectValue"> <descr> <p> This method is used to get the Rect value. If this CSS value doesn't contain a rect value, a <code>DOMException</code> is raised. Modification to the corresponding style property can be achieved using the <code>Rect</code> interface. </p> </descr> <parameters> </parameters> <returns type="Rect"> <descr> <p>The Rect value.</p> </descr> </returns> <raises> <exception name="DOMException"> <descr> <p> INVALID_ACCESS_ERR: Raised if the CSS value doesn't contain a Rect value. (e.g. this is not <code>CSS_RECT</code>). </p> </descr> </exception> </raises> </method> <method id="CSS-CSSPrimitiveValue-getRGBColorValue" name="getRGBColorValue"> <descr> <p> This method is used to get the RGB color. If this CSS value doesn't contain a RGB color value, a <code>DOMException</code> is raised. Modification to the corresponding style property can be achieved using the <code>RGBColor</code> interface. </p> </descr> <parameters> </parameters> <returns type="RGBColor"> <descr> <p>the RGB color value.</p> </descr> </returns> <raises> <exception name="DOMException"> <descr> <p> INVALID_ACCESS_ERR: Raised if the attached property can't return a RGB color value (e.g. this is not <code>CSS_RGBCOLOR</code>). </p> </descr> </exception> </raises> </method> </interface>