001/*
002 * Copyright (c) 2000 World Wide Web Consortium,
003 * (Massachusetts Institute of Technology, Institut National de
004 * Recherche en Informatique et en Automatique, Keio University). All
005 * Rights Reserved. This program is distributed under the W3C's Software
006 * Intellectual Property License. This program is distributed in the
007 * hope that it will be useful, but WITHOUT ANY WARRANTY; without even
008 * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
009 * PURPOSE.
010 * See W3C License http://www.w3.org/Consortium/Legal/ for more details.
011 */
012
013package org.w3c.dom.css;
014
015import org.w3c.dom.DOMException;
016import org.w3c.dom.stylesheets.MediaList;
017
018/**
019 *  The <code>CSSMediaRule</code> interface represents a @media rule in a CSS 
020 * style sheet. A <code>@media</code> rule can be used to delimit style 
021 * rules for specific media types. 
022 * <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>.
023 * @since DOM Level 2
024 */
025public interface CSSMediaRule extends CSSRule {
026    /**
027     *  A list of media types for this rule. 
028     */
029    public MediaList getMedia();
030
031    /**
032     *  A list of all CSS rules contained within the media block. 
033     */
034    public CSSRuleList getCssRules();
035
036    /**
037     *  Used to insert a new rule into the media block. 
038     * @param rule  The parsable text representing the rule. For rule sets 
039     *   this contains both the selector and the style declaration. For 
040     *   at-rules, this specifies both the at-identifier and the rule 
041     *   content. 
042     * @param index  The index within the media block's rule collection of 
043     *   the rule before which to insert the specified rule. If the 
044     *   specified index is equal to the length of the media blocks's rule 
045     *   collection, the rule will be added to the end of the media block. 
046     * @return  The index within the media block's rule collection of the 
047     *   newly inserted rule. 
048     * @exception DOMException
049     *   HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at the 
050     *   specified index, e.g., if an <code>@import</code> rule is inserted 
051     *   after a standard rule set or other at-rule.
052     *   <br>INDEX_SIZE_ERR: Raised if the specified index is not a valid 
053     *   insertion point.
054     *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is 
055     *   readonly.
056     *   <br>SYNTAX_ERR: Raised if the specified rule has a syntax error and 
057     *   is unparsable.
058     */
059    public int insertRule(String rule, 
060                          int index)
061                          throws DOMException;
062
063    /**
064     *  Used to delete a rule from the media block. 
065     * @param index  The index within the media block's rule collection of 
066     *   the rule to remove. 
067     * @exception DOMException
068     *   INDEX_SIZE_ERR: Raised if the specified index does not correspond to 
069     *   a rule in the media rule list.
070     *   <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is 
071     *   readonly.
072     */
073    public void deleteRule(int index)
074                           throws DOMException;
075
076}