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.MediaList;
  15. /**
  16. * The <code>CSSMediaRule</code> interface represents a @media rule in a CSS
  17. * style sheet. A <code>@media</code> rule can be used to delimit style
  18. * rules for specific media types.
  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 CSSMediaRule extends CSSRule {
  23. /**
  24. * A list of media types for this rule.
  25. */
  26. public MediaList getMedia();
  27. /**
  28. * A list of all CSS rules contained within the media block.
  29. */
  30. public CSSRuleList getCssRules();
  31. /**
  32. * Used to insert a new rule into the media block.
  33. * @param rule The parsable text representing the rule. For rule sets
  34. * this contains both the selector and the style declaration. For
  35. * at-rules, this specifies both the at-identifier and the rule
  36. * content.
  37. * @param index The index within the media block's rule collection of the
  38. * rule before which to insert the specified rule. If the specified
  39. * index is equal to the length of the media blocks's rule collection,
  40. * the rule will be added to the end of the media block.
  41. * @return The index within the media block's rule collection of the
  42. * newly inserted rule.
  43. * @exception DOMException
  44. * HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at the
  45. * specified index, e.g., if an <code>@import</code> rule is inserted
  46. * after a standard rule set or other at-rule.
  47. * <br>INDEX_SIZE_ERR: Raised if the specified index is not a valid
  48. * insertion point.
  49. * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is
  50. * readonly.
  51. * <br>SYNTAX_ERR: Raised if the specified rule has a syntax error and
  52. * is unparsable.
  53. */
  54. public int insertRule(String rule,
  55. int index)
  56. throws DOMException;
  57. /**
  58. * Used to delete a rule from the media block.
  59. * @param index The index within the media block's rule collection of the
  60. * rule to remove.
  61. * @exception DOMException
  62. * INDEX_SIZE_ERR: Raised if the specified index does not correspond to
  63. * a rule in the media rule list.
  64. * <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is
  65. * readonly.
  66. */
  67. public void deleteRule(int index)
  68. throws DOMException;
  69. }