/[suikacvs]/messaging/manakai/lib/Message/DOM/CSSRule.pm
Suika

Contents of /messaging/manakai/lib/Message/DOM/CSSRule.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Sun Dec 23 08:18:59 2007 UTC (16 years, 11 months ago) by wakaba
Branch: MAIN
Changes since 1.2: +28 -9 lines
++ manakai/lib/Message/DOM/ChangeLog	23 Dec 2007 08:18:42 -0000
2007-12-23  Wakaba  <wakaba@suika.fam.cx>

	* CSSRule.pm (type, css_text): Typo fixed.
	(____new): s/_selector/_selectors/g;
	(CSSStyleRule.css_text, selectors_text): Ad hoc implementation.

	* CSSStyleDeclaration.pm (css_text): Ad hoc implementation.

	* CSSStyleSheet.pm (new): s/new/____new/.
	(css_text): New attribute.

1 package Message::DOM::CSSRule;
2 use strict;
3 our $VERSION=do{my @r=(q$Revision: 1.2 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
4 push our @ISA, 'Message::IF::CSSRule';
5 require Scalar::Util;
6
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 $_[0])."->css_text: Not implemented";
21 } # css_text
22
23 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
44 sub type ($) {
45 die "$0: ".(ref $_[0])."->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 \{_selectors => $_[1], style => $_[2]}, $_[0];
53 ${$_[2]}->{parent_rule} = $self;
54 Scalar::Util::weaken (${$_[2]}->{parent_rule});
55 return $self;
56 } # ____new
57
58 ## |CSSRule| attributes
59
60 sub css_text ($;$) {
61 ## TODO: setter
62
63 ## TODO: Browser compatibility
64 local $Error::Depth = $Error::Depth + 1;
65 return $_[0]->selector_text . " {\n" . $_[0]->style->css_text . "}\n";
66 } # css_text
67
68 sub type ($) { Message::DOM::CSSRule::STYLE_RULE }
69
70 ## |CSSStyleRule| attributes
71
72 sub selector_text ($;$) {
73 ## TODO: setter
74
75 ## TODO: Browser-compatible serializer
76 require Whatpm::CSS::SelectorsSerializer;
77 return Whatpm::CSS::SelectorsSerializer->serialize_test
78 (${$_[0]}->{_selectors});
79 } # selector_text
80
81 sub style ($) {
82 return ${$_[0]}->{style};
83 } # style
84
85 package Message::DOM::CSSCharsetRule;
86 push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSCharsetRule';
87
88 sub ____new ($$) {
89 return bless \{encoding => $_[1]}, $_[0];
90 } # ____new
91
92 ## |CSSRule| attributes
93
94 ## TODO: |css_text|
95
96 sub type ($) { Message::DOM::CSSRule::CHARSET_RULE }
97
98 ## |CSSCharsetRule| attribute
99
100 sub encoding ($) {
101 return ${$_[0]}->{encoding};
102 } # encoding
103
104 package Message::DOM::CSSImportRule;
105 push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSImportRule';
106
107 sub ____new ($$$$) {
108 my $self = bless \{href => $_[1], media => $_[2], style_sheet => $_[3]}, $_[0];
109 ${$_[3]}->{owner_rule} = $self;
110 Scalar::Util::weaken (${$_[3]}->{owner_rule});
111 return $self;
112 } # ____new
113
114 ## |CSSRule| attributes
115
116 ## TODO: |css_text|
117
118 sub type ($) { Message::DOM::CSSRule::IMPORT_RULE }
119
120 ## |CSSImportRule| attributes
121
122 sub href ($) {
123 return ${$_[0]}->{href};
124 } # href
125
126 sub media ($) {
127 return ${$_[0]}->{media};
128 } # media
129
130 sub style_sheet ($) {
131 return ${$_[0]}->{style_sheet};
132 } # style_sheet
133
134 package Message::DOM::CSSMediaRule;
135 push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSMediaRule';
136
137 sub ____new ($$$) {
138 my $self = bless \{media => $_[1], css_rules => $_[2]}, $_[0];
139 for (@{$_[2]}) {
140 ${$_}->{parent_rule} = $self;
141 Scalar::Util::weaken (${$_}->{parent_rule});
142 }
143 return $self;
144 } # ____new
145
146 ## |CSSRule| attributes
147
148 ## TODO: |css_text|
149
150 sub type ($) { Message::DOM::CSSRule::MEDIA_RULE }
151
152 ## |CSSMediaRule| attributes
153
154 sub css_rules ($) {
155 require Message::DOM::CSSRuleList;
156 return bless \\($_[0]), 'Message::DOM::CSSRuleList';
157 } # css_rules
158
159 sub media ($) {
160 return ${$_[0]}->{media};
161 } # media
162
163 package Message::DOM::CSSFontFaceRule;
164 push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSFontFaceRule';
165
166 sub ____new ($$) {
167 my $self = bless \{style => $_[1]}, $_[0];
168 ${$_[2]}->{parent_rule} = $self;
169 Scalar::Util::weaken (${$_[2]}->{parent_rule});
170 return $self;
171 } # ____new
172
173 ## |CSSRule| attributes
174
175 ## TODO: |css_text|
176
177 sub type ($) { Message::DOM::CSSRule::FONT_FACE_RULE }
178
179 ## |CSSFontFaceRule| attribute
180
181 sub style ($) {
182 return ${$_[0]}->{style};
183 } # style
184
185 package Message::DOM::CSSPageRule;
186 push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSPageRule';
187
188 sub ____new ($$$) {
189 my $self = bless \{_selectors => $_[1], style => $_[2]}, $_[0];
190 ${$_[2]}->{parent_rule} = $self;
191 Scalar::Util::weaken (${$_[2]}->{parent_rule});
192 return $self;
193 } # ____new
194
195 ## |CSSRule| attributes
196
197 ## TODO: |css_text|
198
199 sub type ($) { Message::DOM::CSSRule::PAGE_RULE }
200
201 ## |CSSPageRule| attributes
202
203 sub selector_text ($;$) {
204 ## TODO: setter
205
206 ## TODO: Browser-compatible serializer
207 require Whatpm::CSS::SelectorsSerializer;
208 return Whatpm::CSS::SelectorsSerializer->serialize_test (${$_[0]}->{_selectors});
209 } # selector_text
210
211 sub style ($) {
212 return ${$_[0]}->{style};
213 } # style
214
215 package Message::DOM::CSSNamespaceRule;
216 push our @ISA, 'Message::DOM::CSSRule', 'Message::IF::CSSNamespaceRule';
217
218 sub ____new ($$$) {
219 return bless \{namespace_uri => $_[2], prefix => $_[1]}, $_[0];
220 } # ___new
221
222 ## |CSSRule| attributes
223
224 ## TODO: |css_text|
225
226 sub type ($) { Message::DOM::CSSRule::NAMESPACE_RULE }
227
228 ## |CSSNamespaceRule| attributes
229
230 sub namespace_uri ($) {
231 return ${$_[0]}->{namespace_uri};
232 } # namespace_uri
233
234 sub prefix ($) {
235 return ${$_[0]}->{prefix};
236 } # prefix
237
238 package Message::IF::CSSRule;
239 package Message::IF::CSSStyleRule;
240 package Message::IF::CSSCharsetRule;
241 package Message::IF::CSSImportRule;
242 package Message::IF::CSSMediaRule;
243 package Message::IF::CSSFontFaceRule;
244 package Message::IF::CSSPageRule;
245
246 1;
247 ## $Date: 2007/12/22 06:57:46 $

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24