Package cssutils :: Package css :: Module cssproperties |
[hide private]
[frames] | no frames]

# Module cssproperties

source code

CSS2Properties (partly!) implements DOM Level 2 CSS CSS2Properties used by CSSStyleDeclaration

TODO: CSS2Properties

  If an implementation does implement this interface, it is expected to understand the specific syntax of the shorthand properties, and apply their semantics; when the margin property is set, for example, the marginTop, marginRight, marginBottom and marginLeft properties are actually being set by the underlying implementation.

  When dealing with CSS "shorthand" properties, the shorthand properties should be decomposed into their component longhand properties as appropriate, and when querying for their value, the form returned should be the shortest form exactly equivalent to the declarations made in the ruleset. However, if there is no shorthand declaration that could be added to the ruleset without changing in any way the rules already declared in the ruleset (i.e., by adding longhand rules that were previously not declared in the ruleset), then the empty string should be returned for the shorthand property.

  For example, querying for the font property should not return "normal normal normal 14pt/normal Arial, sans-serif", when "14pt Arial, sans-serif" suffices. (The normals are initial values, and are implied by use of the longhand property.)

  If the values for all the longhand properties that compose a particular string are the initial values, then a string consisting of all the initial values should be returned (e.g. a border-width value of "medium" should be returned as such, not as "").

  For some shorthand properties that take missing values from other sides, such as the margin, padding, and border-[width|style|color] properties, the minimum number of sides possible should be used; i.e., "0px 10px" will be returned instead of "0px 10px 0px 10px".

  If the value of a shorthand property can not be decomposed into its component longhand properties, as is the case for the font property with a value of "menu", querying for the values of the component longhand properties should return the empty string.

TODO: CSS2Properties DOMImplementation
  The interface found within this section are not mandatory. A DOM application can use the hasFeature method of the DOMImplementation interface to determine whether it is supported or not. The feature string for this extended interface listed in this section is "CSS2" and the version is "2.0".

# cssvalues

contributed by Kevin D. Smith, thanks!

"cssvalues" is used as a property validator. it is an importable object that contains a dictionary of compiled regular expressions. The keys of this dictionary are all of the valid CSS property names. The values are compiled regular expressions that can be used to validate the values for that property. (Actually, the values are references to the 'match' method of a compiled regular expression, so that they are simply called like functions.)

Version: $LastChangedRevision: 241 $

Date: $LastChangedDate: 2007-08-19 16:17:06 +0200 (So, 19 Aug 2007) $

Author: $LastChangedBy: cthedot $

Classes | [hide private]
| CSS2Properties The CSS2Properties interface represents a convenience mechanism for retrieving and setting properties within a CSSStyleDeclaration.

Functions | [hide private]
_expand_macros(tokdict) Expand macros in token dictionary | source code
_compile_regexes(tokdict) Compile all regular expressions into callable objects | source code
_toDOMname(CSSname) returns DOMname for given CSSname e.g. | source code
_toCSSname(DOMname) returns CSSname for given DOMname e.g. | source code
__named_property_def(DOMname) closure to keep name known in each properties accessor function DOMname is converted to CSSname here, so actual calls use CSSname | source code

Variables | [hide private]
| MACROS = ``{``'``absolute-size``'``:` `'``(x?x-)?(small|large)|medium``'``,` `'``ang``...`` Define the regular expressions for validation all CSS values
| cssvalues = ``{``'``azimuth``'``:` <built-in method match of _sre.SRE_Pat`...``
| _reCSStoDOMname = `re.compile(r'`(?i)`-`[`a`-`z`]`')`
| _reDOMtoCSSname = `re.compile(r'`(``[`A`-`Z`]``)``[`a`-`z`]``+`')`
| DOMname = ``'``listStylePosition``'``
| p = ``'``list-style-position``'``

Imports: re

Function Details | [hide private]

### _toDOMname(CSSname) | source code
returns DOMname for given CSSname e.g. for CSSname 'font-style' returns 'fontStyle'

### _toCSSname(DOMname) | source code
returns CSSname for given DOMname e.g. for DOMname 'fontStyle' returns 'font-style'

Variables Details | [hide private]

  ### MACROS Define the regular expressions for validation all CSS values Value:
      {'absolute-size': '(x?x-)?(small|large)|medium',
       'angle': '0|{num}(deg|grad|rad)',
       'background-attachment': 'scroll|fixed|inherit',
       'background-attrs': '{background-color}|{background-image}|{backgroun
      d-repeat}|{background-attachment}|{background-position}',
       'background-color': '{color}|transparent|inherit',
       'background-image': '{uri}|none|inherit',
       'background-position': '(({percentage}|{length}|left|center|right)(\\
      ...

  ### cssvalues Value:
      {'azimuth': r'{angle}|(behind\s+)?(left-side|far-left|left|center-left
      |center|center-right|right|far-right|right-side)(\s+behind)?|behind|le
      ftwards|rightwards|inherit', 'background-attachment': r'{background-at
      tachment}', 'background-color': r'{background-color}', 'background-ima
      ge': r'{background-image}', 'background-position': r'{background-posit
      ion}', 'background-repeat': r'{background-repeat}', 'background': r'{b
      ackground-attrs}(\s+{background-attrs})*|inherit', 'border-collapse':
      r'collapse|separate|inherit', 'border-color': r'({border-color}|transp
      ...