1 """
2 StyleSheet implements DOM Level 2 Style Sheets StyleSheet.
3 """
4 __all__ = ['StyleSheet']
5 __docformat__ = 'restructuredtext'
6 __author__ = '$LastChangedBy: cthedot $'
7 __date__ = '$LastChangedDate: 2008-01-27 17:28:41 +0100 (So, 27 Jan 2008) $'
8 __version__ = '$LastChangedRevision: 950 $'
9
10 import cssutils
11
13 """
14 The StyleSheet interface is the abstract base interface
15 for any type of style sheet. It represents a single style
16 sheet associated with a structured document.
17
18 In HTML, the StyleSheet interface represents either an
19 external style sheet, included via the HTML LINK element,
20 or an inline STYLE element (-ch: also an @import stylesheet?).
21
22 In XML, this interface represents
23 an external style sheet, included via a style sheet
24 processing instruction.
25 """
26 - def __init__(self, type='text/css',
27 href=None,
28 media=None,
29 title=u'',
30 disabled=None,
31 ownerNode=None,
32 parentStyleSheet=None):
33 """
34 type: readonly
35 This specifies the style sheet language for this
36 style sheet. The style sheet language is specified
37 as a content type (e.g. "text/css"). The content
38 type is often specified in the ownerNode. Also see
39 the type attribute definition for the LINK element
40 in HTML 4.0, and the type pseudo-attribute for the
41 XML style sheet processing instruction.
42 href: readonly
43 If the style sheet is a linked style sheet, the value
44 of this attribute is its location. For inline style
45 sheets, the value of this attribute is None. See the
46 href attribute definition for the LINK element in HTML
47 4.0, and the href pseudo-attribute for the XML style
48 sheet processing instruction.
49 media: of type MediaList, readonly
50 The intended destination media for style information.
51 The media is often specified in the ownerNode. If no
52 media has been specified, the MediaList will be empty.
53 See the media attribute definition for the LINK element
54 in HTML 4.0, and the media pseudo-attribute for the XML
55 style sheet processing instruction. Modifying the media
56 list may cause a change to the attribute disabled.
57 title: readonly
58 The advisory title. The title is often specified in
59 the ownerNode. See the title attribute definition for
60 the LINK element in HTML 4.0, and the title
61 pseudo-attribute for the XML style sheet processing
62 instruction.
63 disabled: False if the style sheet is applied to the
64 document. True if it is not. Modifying this attribute
65 may cause a new resolution of style for the document.
66 A stylesheet only applies if both an appropriate medium
67 definition is present and the disabled attribute is False.
68 So, if the media doesn't apply to the current user agent,
69 the disabled attribute is ignored.
70 ownerNode: of type Node, readonly
71 The node that associates this style sheet with the
72 document. For HTML, this may be the corresponding LINK
73 or STYLE element. For XML, it may be the linking
74 processing instruction. For style sheets that are
75 included by other style sheets, the value of this
76 attribute is None.
77 parentStyleSheet: of type StyleSheet, readonly
78 For style sheet languages that support the concept
79 of style sheet inclusion, this attribute represents
80 the including style sheet, if one exists. If the style
81 sheet is a top-level style sheet, or the style sheet
82 language does not support inclusion, the value of this
83 attribute is None.
84 """
85 super(StyleSheet, self).__init__()
86
87 self.type = type
88 self.href = href
89 self.media = media
90 self.title = title
91 if disabled:
92 self.disabled = True
93 else:
94 self.disabled = False
95 self.ownerNode = ownerNode
96 self._parentStyleSheet = parentStyleSheet
97
98 parentStyleSheet = property(lambda self: self._parentStyleSheet)
99