1 |
wakaba |
1.1 |
package Message::DOM::CSSRule; |
2 |
|
|
use strict; |
3 |
wakaba |
1.2 |
our $VERSION=do{my @r=(q$Revision: 1.1 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
4 |
wakaba |
1.1 |
push our @ISA, 'Message::IF::CSSRule'; |
5 |
wakaba |
1.2 |
require Scalar::Util; |
6 |
wakaba |
1.1 |
|
7 |
|
|
## |CSSRule| constants |
8 |
|
|
|
9 |
|
|
sub STYLE_RULE () { 1 } |
10 |
|
|
sub CHARSET_RULE () { 2 } |
11 |
|
|
sub IMPORT_RULE () { 3 } |
12 |
|
|
sub MEDIA_RULE () { 4 } |
13 |
|
|
sub FONT_FACE_RULE () { 5 } |
14 |
|
|
sub PAGE_RULE () { 6 } |
15 |
|
|
sub NAMESPACE_RULE () { 7 } |
16 |
|
|
|
17 |
|
|
## |CSSRule| attributes |
18 |
|
|
|
19 |
|
|
sub css_text ($) { |
20 |
|
|
die "$0: ".(ref $self)."->css_text: Not implemented"; |
21 |
|
|
} # css_text |
22 |
|
|
|
23 |
wakaba |
1.2 |
sub parent_rule ($) { |
24 |
|
|
return ${$_[0]}->{parent_rule}; |
25 |
|
|
} # parent_rule |
26 |
|
|
|
27 |
|
|
sub parent_style_sheet ($) { |
28 |
|
|
if (${$_[0]}->{parent_style_sheet}) { |
29 |
|
|
return ${$_[0]}->{parent_style_sheet}; |
30 |
|
|
} elsif (${$_[0]}->{parent_rule}) { |
31 |
|
|
local $Error::Depth = $Error::Depth + 1; |
32 |
|
|
return ${$_[0]}->{parent_rule}->parent_style_sheet; |
33 |
|
|
} else { |
34 |
|
|
## NOTE: Not in the CSSOM ED: If the |CSSRule| object is not |
35 |
|
|
## yet associated to any CSS style sheet. Such object should not be |
36 |
|
|
## returned to applications - that is, the intention is that only |
37 |
|
|
## modules belonging to manakai may get |undef| from the |
38 |
|
|
## |parent_style_sheet| attribute during the construction of CSSOM. |
39 |
|
|
## Therefore, this is not counted as a manakai extension to CSSOM spec. |
40 |
|
|
return undef; |
41 |
|
|
} |
42 |
|
|
} # parent_style_sheet |
43 |
wakaba |
1.1 |
|
44 |
|
|
sub type ($) { |
45 |
|
|
die "$0: ".(ref $self)."->type: Not implemented"; |
46 |
|
|
} # type |
47 |
|
|
|
48 |
|
|
package Message::DOM::CSSStyleRule; |
49 |
|
|
push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSStyleRule'; |
50 |
|
|
|
51 |
|
|
sub ____new ($$$) { |
52 |
|
|
my $self = bless \{_selector => $_[1], style => $_[2]}, $_[0]; |
53 |
wakaba |
1.2 |
${$_[2]}->{parent_rule} = $self; |
54 |
|
|
Scalar::Util::weaken (${$_[2]}->{parent_rule}); |
55 |
wakaba |
1.1 |
return $self; |
56 |
|
|
} # ____new |
57 |
|
|
|
58 |
|
|
## |CSSRule| attributes |
59 |
|
|
|
60 |
|
|
## TODO: |css_text| |
61 |
|
|
|
62 |
|
|
sub type ($) { Message::DOM::CSSRule::STYLE_RULE } |
63 |
|
|
|
64 |
|
|
## |CSSStyleRule| attributes |
65 |
|
|
|
66 |
|
|
## TODO: |selector_text| |
67 |
|
|
|
68 |
|
|
sub style ($) { |
69 |
|
|
return ${$_[0]}->{style}; |
70 |
|
|
} # style |
71 |
|
|
|
72 |
|
|
package Message::DOM::CSSCharsetRule; |
73 |
|
|
push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSCharsetRule'; |
74 |
|
|
|
75 |
|
|
sub ____new ($$) { |
76 |
|
|
return bless \{encoding => $_[1]}, $_[0]; |
77 |
|
|
} # ____new |
78 |
|
|
|
79 |
|
|
## |CSSRule| attributes |
80 |
|
|
|
81 |
|
|
## TODO: |css_text| |
82 |
|
|
|
83 |
|
|
sub type ($) { Message::DOM::CSSRule::CHARSET_RULE } |
84 |
|
|
|
85 |
|
|
## |CSSCharsetRule| attribute |
86 |
|
|
|
87 |
|
|
sub encoding ($) { |
88 |
|
|
return ${$_[0]}->{encoding}; |
89 |
|
|
} # encoding |
90 |
|
|
|
91 |
|
|
package Message::DOM::CSSImportRule; |
92 |
|
|
push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSImportRule'; |
93 |
|
|
|
94 |
|
|
sub ____new ($$$$) { |
95 |
|
|
my $self = bless \{href => $_[1], media => $_[2], style_sheet => $_[3]}, $_[0]; |
96 |
wakaba |
1.2 |
${$_[3]}->{owner_rule} = $self; |
97 |
|
|
Scalar::Util::weaken (${$_[3]}->{owner_rule}); |
98 |
wakaba |
1.1 |
return $self; |
99 |
|
|
} # ____new |
100 |
|
|
|
101 |
|
|
## |CSSRule| attributes |
102 |
|
|
|
103 |
|
|
## TODO: |css_text| |
104 |
|
|
|
105 |
|
|
sub type ($) { Message::DOM::CSSRule::IMPORT_RULE } |
106 |
|
|
|
107 |
|
|
## |CSSImportRule| attributes |
108 |
|
|
|
109 |
|
|
sub href ($) { |
110 |
|
|
return ${$_[0]}->{href}; |
111 |
|
|
} # href |
112 |
|
|
|
113 |
|
|
sub media ($) { |
114 |
|
|
return ${$_[0]}->{media}; |
115 |
|
|
} # media |
116 |
|
|
|
117 |
|
|
sub style_sheet ($) { |
118 |
|
|
return ${$_[0]}->{style_sheet}; |
119 |
|
|
} # style_sheet |
120 |
|
|
|
121 |
|
|
package Message::DOM::CSSMediaRule; |
122 |
|
|
push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSMediaRule'; |
123 |
|
|
|
124 |
|
|
sub ____new ($$$) { |
125 |
|
|
my $self = bless \{media => $_[1], css_rules => $_[2]}, $_[0]; |
126 |
|
|
for (@{$_[2]}) { |
127 |
wakaba |
1.2 |
${$_}->{parent_rule} = $self; |
128 |
|
|
Scalar::Util::weaken (${$_}->{parent_rule}); |
129 |
wakaba |
1.1 |
} |
130 |
|
|
return $self; |
131 |
|
|
} # ____new |
132 |
|
|
|
133 |
|
|
## |CSSRule| attributes |
134 |
|
|
|
135 |
|
|
## TODO: |css_text| |
136 |
|
|
|
137 |
|
|
sub type ($) { Message::DOM::CSSRule::MEDIA_RULE } |
138 |
|
|
|
139 |
|
|
## |CSSMediaRule| attributes |
140 |
|
|
|
141 |
|
|
sub css_rules ($) { |
142 |
|
|
require Message::DOM::CSSRuleList; |
143 |
|
|
return bless \\($_[0]), 'Message::DOM::CSSRuleList'; |
144 |
|
|
} # css_rules |
145 |
|
|
|
146 |
|
|
sub media ($) { |
147 |
|
|
return ${$_[0]}->{media}; |
148 |
|
|
} # media |
149 |
|
|
|
150 |
|
|
package Message::DOM::CSSFontFaceRule; |
151 |
|
|
push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSFontFaceRule'; |
152 |
|
|
|
153 |
|
|
sub ____new ($$) { |
154 |
|
|
my $self = bless \{style => $_[1]}, $_[0]; |
155 |
wakaba |
1.2 |
${$_[2]}->{parent_rule} = $self; |
156 |
|
|
Scalar::Util::weaken (${$_[2]}->{parent_rule}); |
157 |
|
|
return $self; |
158 |
wakaba |
1.1 |
} # ____new |
159 |
|
|
|
160 |
|
|
## |CSSRule| attributes |
161 |
|
|
|
162 |
|
|
## TODO: |css_text| |
163 |
|
|
|
164 |
|
|
sub type ($) { Message::DOM::CSSRule::FONT_FACE_RULE } |
165 |
|
|
|
166 |
|
|
## |CSSFontFaceRule| attribute |
167 |
|
|
|
168 |
|
|
sub style ($) { |
169 |
|
|
return ${$_[0]}->{style}; |
170 |
|
|
} # style |
171 |
|
|
|
172 |
|
|
package Message::DOM::CSSPageRule; |
173 |
|
|
push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSPageRule'; |
174 |
|
|
|
175 |
|
|
sub ____new ($$$) { |
176 |
|
|
my $self = bless \{_selector => $_[1], style => $_[2]}, $_[0]; |
177 |
wakaba |
1.2 |
${$_[2]}->{parent_rule} = $self; |
178 |
|
|
Scalar::Util::weaken (${$_[2]}->{parent_rule}); |
179 |
wakaba |
1.1 |
return $self; |
180 |
|
|
} # ____new |
181 |
|
|
|
182 |
|
|
## |CSSRule| attributes |
183 |
|
|
|
184 |
|
|
## TODO: |css_text| |
185 |
|
|
|
186 |
|
|
sub type ($) { Message::DOM::CSSRule::PAGE_RULE } |
187 |
|
|
|
188 |
|
|
## |CSSPageRule| attributes |
189 |
|
|
|
190 |
|
|
## TODO: |selector_text| |
191 |
|
|
|
192 |
|
|
sub style ($) { |
193 |
|
|
return ${$_[0]}->{style}; |
194 |
|
|
} # style |
195 |
|
|
|
196 |
|
|
package Message::DOM::CSSNamespaceRule; |
197 |
|
|
push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSNamespaceRule'; |
198 |
|
|
|
199 |
|
|
sub ____new ($$$) { |
200 |
|
|
return bless \{namespace_uri => $_[2], prefix => $_[1]}, $_[0]; |
201 |
|
|
} # ___new |
202 |
|
|
|
203 |
|
|
## |CSSRule| attributes |
204 |
|
|
|
205 |
|
|
## TODO: |css_text| |
206 |
|
|
|
207 |
|
|
sub type ($) { Message::DOM::CSSRule::NAMESPACE_RULE } |
208 |
|
|
|
209 |
|
|
## |CSSNamespaceRule| attributes |
210 |
|
|
|
211 |
|
|
sub namespace_uri ($) { |
212 |
|
|
return ${$_[0]}->{namespace_uri}; |
213 |
|
|
} # namespace_uri |
214 |
|
|
|
215 |
|
|
sub prefix ($) { |
216 |
|
|
return ${$_[0]}->{prefix}; |
217 |
|
|
} # prefix |
218 |
|
|
|
219 |
|
|
package Message::IF::CSSRule; |
220 |
|
|
package Message::IF::CSSStyleRule; |
221 |
|
|
package Message::IF::CSSCharsetRule; |
222 |
|
|
package Message::IF::CSSImportRule; |
223 |
|
|
package Message::IF::CSSMediaRule; |
224 |
|
|
package Message::IF::CSSFontFaceRule; |
225 |
|
|
package Message::IF::CSSPageRule; |
226 |
|
|
|
227 |
|
|
1; |
228 |
wakaba |
1.2 |
## $Date: 2007/12/22 06:29:32 $ |