Package cssutils :: Package css :: Module cssmediarule :: Class CSSMediaRule
[hide private]
[frames] | no frames]

Class CSSMediaRule

source code

object --+            
         |            
 util.Base --+        
             |        
    util.Base2 --+    
                 |    
   cssrule.CSSRule --+
                     |
                    CSSMediaRule

Objects implementing the CSSMediaRule interface can be identified by the MEDIA_RULE constant. On these objects the type attribute must return the value of that constant.

Properties

atkeyword: (cssutils only)
the literal keyword used
cssRules: A css::CSSRuleList of all CSS rules contained within the
media block.
cssText: of type DOMString
The parsable textual representation of this rule
media: of type stylesheets::MediaList, (DOM readonly)
A list of media types for this rule of type MediaList.
name:
An optional name used for cascading

Format

media

: MEDIA_SYM S* medium [ COMMA S* medium ]*

STRING? # the name

LBRACE S* ruleset* '}' S*;

Nested Classes [hide private]

Inherited from util.Base (private): _prods

Instance Methods [hide private]
 
__init__(self, mediaText='all', name=None, parentRule=None, parentStyleSheet=None, readonly=False)
constructor
source code
 
__iter__(self)
generator which iterates over cssRules.
source code
 
_getCssText(self)
return serialized property cssText
source code
 
_setCssText(self, cssText)
DOMException on setting
source code
 
_setName(self, name) source code
 
deleteRule(self, index)
within the media block's rule collection of the rule to remove.
source code
 
add(self, rule)
Add rule to end of this mediarule.
source code
 
insertRule(self, rule, index=None)
The parsable text representing the rule.
source code
 
__repr__(self)
repr(x)
source code
 
__str__(self)
str(x)
source code

Inherited from cssrule.CSSRule (private): _setAtkeyword

Inherited from util.Base2 (private): _adddefaultproductions, _setSeq, _tempSeq

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__

Static Methods [hide private]

Inherited from util.Base (private): _normalize

Class Variables [hide private]

Inherited from cssrule.CSSRule: CHARSET_RULE, COMMENT, FONT_FACE_RULE, IMPORT_RULE, MEDIA_RULE, NAMESPACE_RULE, PAGE_RULE, STYLE_RULE, UNKNOWN_RULE

Inherited from cssrule.CSSRule (private): _typestrings

Inherited from util.Base (private): _SHORTHANDPROPERTIES, _log

Properties [hide private]
  type
The type of this rule, as defined by a CSSRule type constant.
  cssText
(DOM attribute) The parsable textual representation.
  name
An optional name for the media rules
  media
(DOM readonly) A list of media types for this rule of type MediaList
  wellformed
READONLY

Inherited from cssrule.CSSRule: atkeyword, parentRule, parentStyleSheet, typeString

Inherited from util.Base2: seq

Inherited from object: __class__

Method Details [hide private]

__init__(self, mediaText='all', name=None, parentRule=None, parentStyleSheet=None, readonly=False)
(Constructor)

source code 
constructor
Overrides: object.__init__

_setCssText(self, cssText)

source code 

DOMException on setting

  • SYNTAX_ERR: Raised if the specified CSS string value has a syntax error and is unparsable.
  • INVALID_MODIFICATION_ERR: Raised if the specified CSS string value represents a different type of rule than the current one.
  • HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at this point in the style sheet.
  • NO_MODIFICATION_ALLOWED_ERR: (self) Raised if the rule is readonly.
Parameters:
  • cssText - a parseable string or a tuple of (cssText, dict-of-namespaces)
Raises:
  • NAMESPACE_ERR - (Selector) Raised if a specified selector uses an unknown namespace prefix.
  • SYNTAX_ERR - (self, StyleDeclaration, etc) Raised if the specified CSS string value has a syntax error and is unparsable.
  • INVALID_MODIFICATION_ERR - (self) Raised if the specified CSS string value represents a different type of rule than the current one.
  • HIERARCHY_REQUEST_ERR - (CSSStylesheet) Raised if the rule cannot be inserted at this point in the style sheet.
  • NO_MODIFICATION_ALLOWED_ERR - (CSSRule) Raised if the rule is readonly.
Overrides: cssrule.CSSRule._setCssText

deleteRule(self, index)

source code 
index
within the media block's rule collection of the rule to remove.

Used to delete a rule from the media block.

DOMExceptions

  • INDEX_SIZE_ERR: (self) Raised if the specified index does not correspond to a rule in the media rule list.
  • NO_MODIFICATION_ALLOWED_ERR: (self) Raised if this media rule is readonly.

add(self, rule)

source code 
Add rule to end of this mediarule. Same as .insertRule(rule).

insertRule(self, rule, index=None)

source code 
rule

The parsable text representing the rule. For rule sets this contains both the selector and the style declaration. For at-rules, this specifies both the at-identifier and the rule content.

cssutils also allows rule to be a valid CSSRule object

index
within the media block's rule collection of the rule before which to insert the specified rule. If the specified index is equal to the length of the media blocks's rule collection, the rule will be added to the end of the media block. If index is not given or None rule will be appended to rule list.

Used to insert a new rule into the media block.

DOMException on setting

  • HIERARCHY_REQUEST_ERR: (no use case yet as no @charset or @import allowed)) Raised if the rule cannot be inserted at the specified index, e.g., if an @import rule is inserted after a standard rule set or other at-rule.
  • INDEX_SIZE_ERR: (self) Raised if the specified index is not a valid insertion point.
  • NO_MODIFICATION_ALLOWED_ERR: (self) Raised if this media rule is readonly.
  • SYNTAX_ERR: (CSSStyleRule) Raised if the specified rule has a syntax error and is unparsable.

returns the index within the media block's rule collection of the newly inserted rule.

__repr__(self)
(Representation operator)

source code 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)

Property Details [hide private]

type

The type of this rule, as defined by a CSSRule type constant. Overwritten in derived classes.

The expectation is that binding-specific casting methods can be used to cast down from an instance of the CSSRule interface to the specific derived interface implied by the type. (Casting not for this Python implementation I guess...)

Get Method:
unreachable(self)

cssText

(DOM attribute) The parsable textual representation.
Get Method:
_getCssText(self) - return serialized property cssText
Set Method:
_setCssText(self, cssText) - DOMException on setting

name

An optional name for the media rules
Get Method:
unreachable(self)
Set Method:
_setName(self, name)

media

(DOM readonly) A list of media types for this rule of type MediaList
Get Method:
unreachable(self)

wellformed

READONLY
Get Method:
unreachable(self)