1 |
package Message::DOM::CSSStyleDeclaration; |
package Message::DOM::CSSStyleDeclaration; |
2 |
use strict; |
use strict; |
3 |
our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
4 |
push our @ISA, 'Message::IF::CSSStyleDeclaration'; |
push our @ISA, 'Message::IF::CSSStyleDeclaration', |
5 |
|
'Message::IF::CSS2Properties'; |
6 |
|
|
7 |
sub ____new ($) { |
sub ____new ($) { |
8 |
return bless \{}, $_[0]; |
return bless \{}, $_[0]; |
37 |
} |
} |
38 |
} # AUTOLOAD |
} # AUTOLOAD |
39 |
|
|
40 |
|
use overload |
41 |
|
'@{}' => sub { |
42 |
|
tie my @list, ref $_[0], $_[0]; |
43 |
|
return \@list; |
44 |
|
}, |
45 |
|
fallback => 1; |
46 |
|
|
47 |
|
sub TIEARRAY ($$) { $_[1] } |
48 |
|
|
49 |
## |CSSStyleDeclaration| attributes |
## |CSSStyleDeclaration| attributes |
50 |
|
|
51 |
sub css_text ($;$) { |
sub css_text ($;$) { |
85 |
return $r; |
return $r; |
86 |
} # css_text |
} # css_text |
87 |
|
|
88 |
|
sub length ($) { |
89 |
|
require Whatpm::CSS::Parser; |
90 |
|
return scalar @{[grep {$_} |
91 |
|
map { $Whatpm::CSS::Parser::Key->{$_} } |
92 |
|
keys %${$_[0]}]->[$_[1]]}; |
93 |
|
} # length |
94 |
|
*FETCHSIZE = \&length; |
95 |
|
|
96 |
|
## TODO: STORESIZE |
97 |
|
|
98 |
sub parent_rule ($) { |
sub parent_rule ($) { |
99 |
return ${$_[0]}->{parent_rule}; |
return ${$_[0]}->{parent_rule}; |
100 |
} # parent_rule |
} # parent_rule |
112 |
return $v ? $v->[1] : ''; |
return $v ? $v->[1] : ''; |
113 |
} # get_property_priority |
} # get_property_priority |
114 |
|
|
115 |
|
sub item ($$) { |
116 |
|
require Whatpm::CSS::Parser; |
117 |
|
return '' if $_[1] < 0; |
118 |
|
## TODO: ordering (should be same as that in |css_text|. |
119 |
|
my $v = [map {$_->{key}} |
120 |
|
grep {$_} |
121 |
|
map { $Whatpm::CSS::Parser::Key->{$_} } |
122 |
|
keys %${$_[0]}]->[$_[1]]; |
123 |
|
return defined $v ? $v : ''; |
124 |
|
} # item |
125 |
|
*FETCH = \&item; |
126 |
|
|
127 |
|
## TODO: STORE, DELETE |
128 |
|
|
129 |
|
sub EXISTS ($$) { |
130 |
|
return length $_[0]->item; |
131 |
|
} # EXISTS |
132 |
|
|
133 |
## TODO: Implement other methods and attributes |
## TODO: Implement other methods and attributes |
134 |
|
|
135 |
package Message::DOM::CSSComputedStyleDeclaration; |
package Message::DOM::CSSComputedStyleDeclaration; |
136 |
push our @ISA, 'Message::IF::CSSStyleDeclaration'; |
push our @ISA, 'Message::IF::CSSStyleDeclaration', |
137 |
|
'Message::IF::CSS2Properties'; |
138 |
|
|
139 |
sub ____new ($$$) { |
sub ____new ($$$) { |
140 |
my $self = bless \{}, shift; |
my $self = bless \{}, shift; |
172 |
} |
} |
173 |
} # AUTOLOAD |
} # AUTOLOAD |
174 |
|
|
175 |
|
use overload |
176 |
|
'@{}' => sub { |
177 |
|
tie my @list, ref $_[0], $_[0]; |
178 |
|
return \@list; |
179 |
|
}, |
180 |
|
fallback => 1; |
181 |
|
|
182 |
|
sub TIEARRAY ($$) { $_[1] } |
183 |
|
|
184 |
|
## |CSSStyleDeclaration| attributes |
185 |
|
|
186 |
sub css_text ($;$) { |
sub css_text ($;$) { |
187 |
## TODO: error if modified |
## TODO: error if modified |
188 |
|
|
229 |
return $r; |
return $r; |
230 |
} # css_text |
} # css_text |
231 |
|
|
232 |
|
## TODO: What should we enumerate is unclear. |
233 |
|
sub length ($) { |
234 |
|
require Whatpm::CSS::Parser; |
235 |
|
return scalar @{[grep {$_} |
236 |
|
values %$Whatpm::CSS::Parser::Key]}; |
237 |
|
} # length |
238 |
|
*FETCHSIZE = \&length; |
239 |
|
|
240 |
|
## TODO: STORESIZE |
241 |
|
|
242 |
## |CSSStyleDeclaration| methods |
## |CSSStyleDeclaration| methods |
243 |
|
|
244 |
sub get_property_priority ($$) { '' } |
sub get_property_priority ($$) { '' } |
245 |
|
|
246 |
|
sub item ($$) { |
247 |
|
require Whatpm::CSS::Parser; |
248 |
|
return '' if $_[1] < 0; |
249 |
|
## TODO: ordering (should be same as that in |css_text|. |
250 |
|
my $v = [sort {$a cmp $b} |
251 |
|
map {$_->{css}} |
252 |
|
grep {$_} |
253 |
|
values %$Whatpm::CSS::Parser::Key]->[$_[1]]; |
254 |
|
return defined $v ? $v : ''; |
255 |
|
} # item |
256 |
|
*FETCH = \&item; |
257 |
|
|
258 |
|
## TODO: STORE, DELETE |
259 |
|
|
260 |
|
sub EXISTS ($$) { |
261 |
|
return length $_[0]->item; |
262 |
|
} # EXISTS |
263 |
|
|
264 |
## TODO: members |
## TODO: members |
265 |
|
|
266 |
package Message::IF::CSSStyleDeclaration; |
package Message::IF::CSSStyleDeclaration; |
267 |
|
package Message::IF::CSS2Properties; |
268 |
|
|
269 |
1; |
1; |
270 |
## $Date$ |
## $Date$ |