1. /*
  2. * Copyright (c) 2000 World Wide Web Consortium,
  3. * (Massachusetts Institute of Technology, Institut National de
  4. * Recherche en Informatique et en Automatique, Keio University). All
  5. * Rights Reserved. This program is distributed under the W3C's Software
  6. * Intellectual Property License. This program is distributed in the
  7. * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
  8. * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  9. * PURPOSE.
  10. * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
  11. */
  12. package org.w3c.dom.css;
  13. import org.w3c.dom.DOMException;
  14. /**
  15. * The <code>CSSStyleDeclaration</code> interface represents a single CSS
  16. * declaration block. This interface may be used to determine the style
  17. * properties currently set in a block or to set style properties explicitly
  18. * within the block.
  19. * <p> While an implementation may not recognize all CSS properties within a
  20. * CSS declaration block, it is expected to provide access to all specified
  21. * properties in the style sheet through the <code>CSSStyleDeclaration</code>
  22. * interface. Furthermore, implementations that support a specific level of
  23. * CSS should correctly handle CSS shorthand properties for that level. For
  24. * a further discussion of shorthand properties, see the
  25. * <code>CSS2Properties</code> interface.
  26. * <p> This interface is also used to provide a read-only access to the
  27. * computed values of an element. See also the <code>ViewCSS</code>
  28. * interface. The CSS Object Model doesn't provide an access to the
  29. * specified or actual values of the CSS cascade.
  30. * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113'>Document Object Model (DOM) Level 2 Style Specification</a>.
  31. * @since DOM Level 2
  32. */
  33. public interface CSSStyleDeclaration {
  34. /**
  35. * The parsable textual representation of the declaration block
  36. * (excluding the surrounding curly braces). Setting this attribute will
  37. * result in the parsing of the new value and resetting of all the
  38. * properties in the declaration block including the removal or addition
  39. * of properties.
  40. * @exception DOMException
  41. * SYNTAX_ERR: Raised if the specified CSS string value has a syntax
  42. * error and is unparsable.
  43. * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is
  44. * readonly or a property is readonly.
  45. */
  46. public String getCssText();
  47. public void setCssText(String cssText)
  48. throws DOMException;
  49. /**
  50. * Used to retrieve the value of a CSS property if it has been explicitly
  51. * set within this declaration block.
  52. * @param propertyName The name of the CSS property. See the CSS property
  53. * index.
  54. * @return Returns the value of the property if it has been explicitly
  55. * set for this declaration block. Returns the empty string if the
  56. * property has not been set.
  57. */
  58. public String getPropertyValue(String propertyName);
  59. /**
  60. * Used to retrieve the object representation of the value of a CSS
  61. * property if it has been explicitly set within this declaration block.
  62. * This method returns <code>null</code> if the property is a shorthand
  63. * property. Shorthand property values can only be accessed and modified
  64. * as strings, using the <code>getPropertyValue</code> and
  65. * <code>setProperty</code> methods.
  66. * @param propertyName The name of the CSS property. See the CSS property
  67. * index.
  68. * @return Returns the value of the property if it has been explicitly
  69. * set for this declaration block. Returns <code>null</code> if the
  70. * property has not been set.
  71. */
  72. public CSSValue getPropertyCSSValue(String propertyName);
  73. /**
  74. * Used to remove a CSS property if it has been explicitly set within
  75. * this declaration block.
  76. * @param propertyName The name of the CSS property. See the CSS property
  77. * index.
  78. * @return Returns the value of the property if it has been explicitly
  79. * set for this declaration block. Returns the empty string if the
  80. * property has not been set or the property name does not correspond
  81. * to a known CSS property.
  82. * @exception DOMException
  83. * NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is readonly
  84. * or the property is readonly.
  85. */
  86. public String removeProperty(String propertyName)
  87. throws DOMException;
  88. /**
  89. * Used to retrieve the priority of a CSS property (e.g. the
  90. * <code>"important"</code> qualifier) if the property has been
  91. * explicitly set in this declaration block.
  92. * @param propertyName The name of the CSS property. See the CSS property
  93. * index.
  94. * @return A string representing the priority (e.g.
  95. * <code>"important"</code>) if one exists. The empty string if none
  96. * exists.
  97. */
  98. public String getPropertyPriority(String propertyName);
  99. /**
  100. * Used to set a property value and priority within this declaration
  101. * block.
  102. * @param propertyName The name of the CSS property. See the CSS property
  103. * index.
  104. * @param value The new value of the property.
  105. * @param priority The new priority of the property (e.g.
  106. * <code>"important"</code>).
  107. * @exception DOMException
  108. * SYNTAX_ERR: Raised if the specified value has a syntax error and is
  109. * unparsable.
  110. * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this declaration is
  111. * readonly or the property is readonly.
  112. */
  113. public void setProperty(String propertyName,
  114. String value,
  115. String priority)
  116. throws DOMException;
  117. /**
  118. * The number of properties that have been explicitly set in this
  119. * declaration block. The range of valid indices is 0 to length-1
  120. * inclusive.
  121. */
  122. public int getLength();
  123. /**
  124. * Used to retrieve the properties that have been explicitly set in this
  125. * declaration block. The order of the properties retrieved using this
  126. * method does not have to be the order in which they were set. This
  127. * method can be used to iterate over all properties in this declaration
  128. * block.
  129. * @param index Index of the property name to retrieve.
  130. * @return The name of the property at this ordinal position. The empty
  131. * string if no property exists at this position.
  132. */
  133. public String item(int index);
  134. /**
  135. * The CSS rule that contains this declaration block or <code>null</code>
  136. * if this <code>CSSStyleDeclaration</code> is not attached to a
  137. * <code>CSSRule</code>.
  138. */
  139. public CSSRule getParentRule();
  140. }