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. import org.w3c.dom.stylesheets.StyleSheet;
  15. /**
  16. * The <code>CSSStyleSheet</code> interface is a concrete interface used to
  17. * represent a CSS style sheet i.e., a style sheet whose content type is
  18. * "text/css".
  19. * <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>.
  20. * @since DOM Level 2
  21. */
  22. public interface CSSStyleSheet extends StyleSheet {
  23. /**
  24. * If this style sheet comes from an <code>@import</code> rule, the
  25. * <code>ownerRule</code> attribute will contain the
  26. * <code>CSSImportRule</code>. In that case, the <code>ownerNode</code>
  27. * attribute in the <code>StyleSheet</code> interface will be
  28. * <code>null</code>. If the style sheet comes from an element or a
  29. * processing instruction, the <code>ownerRule</code> attribute will be
  30. * <code>null</code> and the <code>ownerNode</code> attribute will
  31. * contain the <code>Node</code>.
  32. */
  33. public CSSRule getOwnerRule();
  34. /**
  35. * The list of all CSS rules contained within the style sheet. This
  36. * includes both rule sets and at-rules.
  37. */
  38. public CSSRuleList getCssRules();
  39. /**
  40. * Used to insert a new rule into the style sheet. The new rule now
  41. * becomes part of the cascade.
  42. * @param rule The parsable text representing the rule. For rule sets
  43. * this contains both the selector and the style declaration. For
  44. * at-rules, this specifies both the at-identifier and the rule
  45. * content.
  46. * @param index The index within the style sheet's rule list of the rule
  47. * before which to insert the specified rule. If the specified index
  48. * is equal to the length of the style sheet's rule collection, the
  49. * rule will be added to the end of the style sheet.
  50. * @return The index within the style sheet's rule collection of the
  51. * newly inserted rule.
  52. * @exception DOMException
  53. * HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at the
  54. * specified index e.g. if an <code>@import</code> rule is inserted
  55. * after a standard rule set or other at-rule.
  56. * <br>INDEX_SIZE_ERR: Raised if the specified index is not a valid
  57. * insertion point.
  58. * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is
  59. * readonly.
  60. * <br>SYNTAX_ERR: Raised if the specified rule has a syntax error and
  61. * is unparsable.
  62. */
  63. public int insertRule(String rule,
  64. int index)
  65. throws DOMException;
  66. /**
  67. * Used to delete a rule from the style sheet.
  68. * @param index The index within the style sheet's rule list of the rule
  69. * to remove.
  70. * @exception DOMException
  71. * INDEX_SIZE_ERR: Raised if the specified index does not correspond to
  72. * a rule in the style sheet's rule list.
  73. * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this style sheet is
  74. * readonly.
  75. */
  76. public void deleteRule(int index)
  77. throws DOMException;
  78. }