line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::DOM::Value::List; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '0.15'; |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
2737
|
use CSS'DOM'Constants <CSS_VALUE_LIST NO_MODIFICATION_ALLOWED_ERR>; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
464
|
|
6
|
4
|
|
|
4
|
|
38
|
use Scalar'Util 'weaken'; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
600
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Object of this class are hashes, with the following keys: |
9
|
|
|
|
|
|
|
# c: CSS code |
10
|
|
|
|
|
|
|
# v: values |
11
|
|
|
|
|
|
|
# s: separator |
12
|
|
|
|
|
|
|
# o: owner |
13
|
|
|
|
|
|
|
# p: property |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub DOES { |
16
|
1
|
50
|
|
1
|
0
|
247
|
return 1 if $_[1] eq 'CSS::DOM::Value'; |
17
|
0
|
0
|
|
|
|
0
|
goto &UNIVERSAL'DOES if defined &UNIVERSAL'DOES; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use overload |
21
|
|
|
|
|
|
|
fallback => 1, |
22
|
4
|
|
|
4
|
|
1772
|
'@{}' => sub { tie my @shext, __PACKAGE__, shift; \@shext }; |
|
4
|
|
|
9
|
|
1322
|
|
|
4
|
|
|
|
|
49
|
|
|
9
|
|
|
|
|
58
|
|
|
9
|
|
|
|
|
69
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
30
|
|
|
30
|
0
|
874
|
my $class = shift; |
26
|
30
|
|
|
|
|
178
|
my %args = @_; |
27
|
30
|
|
|
|
|
57
|
my %self; |
28
|
30
|
|
|
|
|
2606
|
@self{< c v s o p >} |
29
|
|
|
|
|
|
|
= @args{< css values separator owner property >}; |
30
|
30
|
|
|
|
|
946
|
weaken $self{o}; |
31
|
30
|
|
|
|
|
321
|
bless \%self, $class; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub cssText { |
35
|
25
|
|
|
25
|
1
|
3079
|
my $self = shift; |
36
|
25
|
|
|
|
|
44
|
my $old; |
37
|
25
|
100
|
|
|
|
73
|
if(defined wantarray) {{ |
38
|
21
|
100
|
100
|
|
|
34
|
if(!defined $$self{c} || grep ref ne 'ARRAY', @{$$self{v}}) { |
|
21
|
|
|
|
|
149
|
|
|
16
|
|
|
|
|
235
|
|
39
|
14
|
100
|
|
|
|
22
|
@{$$self{v}} or $old = 'none', last; |
|
14
|
|
|
|
|
72
|
|
40
|
13
|
|
|
|
|
90
|
require CSS'DOM'Value'Primitive; |
41
|
13
|
|
|
|
|
25
|
my @args; my $index = 0; |
|
13
|
|
|
|
|
27
|
|
42
|
13
|
|
|
|
|
28
|
for(@{$$self{v}}) { |
|
13
|
|
|
|
|
54
|
|
43
|
18
|
100
|
|
|
|
91
|
next unless ref eq 'ARRAY'; |
44
|
6
|
100
|
|
|
|
138
|
@args or @args = ( |
45
|
|
|
|
|
|
|
(owner => property => @$self{<o p>})[0,2,1,3], index => $index |
46
|
|
|
|
|
|
|
); |
47
|
6
|
|
|
|
|
49
|
$_ = new CSS'DOM'Value'Primitive @$_, @args; |
48
|
|
|
|
|
|
|
} |
49
|
4
|
|
|
4
|
|
1508
|
no warnings 'uninitialized'; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
2544
|
|
50
|
13
|
|
|
|
|
72
|
$old = join length $$self{s} ? $$self{s} : ' ', |
51
|
13
|
100
|
|
|
|
66
|
map cssText $_, @{$$self{v}} |
52
|
|
|
|
|
|
|
} |
53
|
7
|
|
|
|
|
23
|
else { $old = $$self{c} } |
54
|
|
|
|
|
|
|
}} |
55
|
25
|
100
|
|
|
|
606
|
if(@_) { # assignment |
56
|
4
|
100
|
|
|
|
27
|
die new CSS'DOM'Exception |
57
|
|
|
|
|
|
|
NO_MODIFICATION_ALLOWED_ERR, |
58
|
|
|
|
|
|
|
"Unowned value objects cannot be modified" |
59
|
|
|
|
|
|
|
unless my $owner = $self->{o}; |
60
|
3
|
100
|
|
|
|
19
|
die new CSS'DOM'Exception |
61
|
|
|
|
|
|
|
NO_MODIFICATION_ALLOWED_ERR, |
62
|
|
|
|
|
|
|
"CSS::DOM::Value objects that do not know to which " |
63
|
|
|
|
|
|
|
."property they belong cannot be modified" |
64
|
|
|
|
|
|
|
unless my $prop = $self->{p}; |
65
|
|
|
|
|
|
|
|
66
|
2
|
50
|
|
|
|
9
|
if( |
67
|
|
|
|
|
|
|
my @arsg |
68
|
|
|
|
|
|
|
= $owner->property_parser->match($prop, $_[0]) |
69
|
|
|
|
|
|
|
) { |
70
|
2
|
|
|
|
|
18
|
require CSS'DOM'Value; |
71
|
2
|
|
|
|
|
13
|
CSS'DOM'Value::_apply_args_to_self($self,$owner,$prop,@arsg); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
2
|
50
|
|
|
|
20
|
if(my $mh = $owner->modification_handler) { |
75
|
2
|
|
|
|
|
8
|
&$mh(); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
23
|
|
|
|
|
127
|
$old; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
10
|
|
|
10
|
1
|
57
|
sub cssValueType { CSS_VALUE_LIST } |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub item { |
84
|
24
|
|
|
24
|
1
|
54
|
my($self, $index) = @_; |
85
|
24
|
|
50
|
|
|
241
|
my $v = $self->{v} || return; |
86
|
24
|
50
|
|
|
|
76
|
exists $$v[$index] or return; |
87
|
|
|
|
|
|
|
|
88
|
24
|
|
|
|
|
66
|
for($$v[$index]) { |
89
|
24
|
50
|
|
|
|
68
|
defined or return; |
90
|
24
|
100
|
|
|
|
96
|
ref eq 'ARRAY' or return exit die return $_; |
91
|
|
|
|
|
|
|
|
92
|
21
|
|
|
|
|
1029
|
require CSS'DOM'Value'Primitive; |
93
|
21
|
|
|
|
|
539
|
return $_ = new CSS'DOM'Value'Primitive |
94
|
|
|
|
|
|
|
@$_, |
95
|
|
|
|
|
|
|
(owner => property => @$self{<o p>})[0,2,1,3], |
96
|
|
|
|
|
|
|
index => $index; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
21
|
50
|
|
21
|
1
|
33
|
sub length { scalar @{ shift->{v} || return 0 } } |
|
21
|
|
|
|
|
156
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
*FETCH = *item; |
103
|
|
|
|
|
|
|
*FETCHSIZE = *length; |
104
|
9
|
|
|
9
|
|
28
|
sub TIEARRAY { $_[1] } |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
(undef) = (undef) __END__ |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 NAME |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
CSS::DOM::Value::List - CSSValueList class for CSS::DOM |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 VERSION |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Version 0.15 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 SYNOPSIS |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# ... |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 DESCRIPTION |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This module implements objects that represent CSS list property |
125
|
|
|
|
|
|
|
values. It |
126
|
|
|
|
|
|
|
implements the DOM CSSValueList interface. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
You can access the individual elements of the list using the C<item> and |
129
|
|
|
|
|
|
|
C<length> methods, or by using it as an array ref. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 METHODS |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
If you need the constructor, it's below the object methods. Normally you |
134
|
|
|
|
|
|
|
would get an object via L<CSS::DOM::Style's C<getPropertyCSSValue> |
135
|
|
|
|
|
|
|
method|CSS::DOM::Style/getPropertyCSSValue>. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head2 CSSValue Interface |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=over 4 |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item cssText |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Returns a string representation of the attribute. Pass an argument to set |
144
|
|
|
|
|
|
|
it. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item cssValueType |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Returns C<CSS::DOM::Value::CSS_PRIMITIVE_VALUE>. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=back |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 CSSValueList Interface |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=over |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item item |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Returns the 'primitive' value at the given index. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item length |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Returns the number of values in the list. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=back |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head2 Constructor |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
You probably don't need to call this, but here it is anyway: |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
$val = new CSS::DOM::Value::List:: %args; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
The hash-style arguments are as follows. Only C<values> is |
173
|
|
|
|
|
|
|
required. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=over |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item values |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
This must be an array ref containing the individual values to be stored in |
180
|
|
|
|
|
|
|
the list. The individual elements can be value objects or array refs of |
181
|
|
|
|
|
|
|
arguments to pass to C<< new CSS::DOM::Value::Primitive >>. E.g., |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
[ |
184
|
|
|
|
|
|
|
[type => CSS_PX, value => 20], |
185
|
|
|
|
|
|
|
[type => CSS_PERCENTAGE, value => 50], |
186
|
|
|
|
|
|
|
[type => CSS_PERCENTAGE, value => 50], |
187
|
|
|
|
|
|
|
[type => CSS_PX, value => 50], |
188
|
|
|
|
|
|
|
] |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item css |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
CSS code used for serialisation. This will make reading C<cssText> faster |
193
|
|
|
|
|
|
|
at least until the value is modified. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item separator |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
The value separator used in serialisation. This is usually S<' '> or |
198
|
|
|
|
|
|
|
S<', '>. An empty string or C<undef> is treated as a space. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=item owner |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
The style object that owns this value; if this is omitted, then the value |
203
|
|
|
|
|
|
|
is read-only. The value object holds a weak reference to the owner. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=item property |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
The name of the CSS property to which this value belongs. C<cssText> uses |
208
|
|
|
|
|
|
|
this to determine how to parse text passed to it. This does not |
209
|
|
|
|
|
|
|
apply to the sub-values of colours, counters and rects, but it I<does> |
210
|
|
|
|
|
|
|
apply to individual elements of a list value. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=back |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head1 SEE ALSO |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
L<CSS::DOM> |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
L<CSS::DOM::Value> |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
L<CSS::DOM::Value::Primitive> |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
L<CSS::DOM::Style> |