line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::DOM::Value::List; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '0.16'; |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
1946
|
use CSS'DOM'Constants ; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
387
|
|
6
|
4
|
|
|
4
|
|
26
|
use Scalar'Util 'weaken'; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
563
|
|
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
|
190
|
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
|
|
1603
|
'@{}' => sub { tie my @shext, __PACKAGE__, shift; \@shext }; |
|
4
|
|
|
9
|
|
1097
|
|
|
4
|
|
|
|
|
45
|
|
|
9
|
|
|
|
|
43
|
|
|
9
|
|
|
|
|
55
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
30
|
|
|
30
|
0
|
500
|
my $class = shift; |
26
|
30
|
|
|
|
|
140
|
my %args = @_; |
27
|
30
|
|
|
|
|
52
|
my %self; |
28
|
|
|
|
|
|
|
@self{< c v s o p >} |
29
|
30
|
|
|
|
|
1665
|
= @args{< css values separator owner property >}; |
30
|
30
|
|
|
|
|
199
|
weaken $self{o}; |
31
|
30
|
|
|
|
|
230
|
bless \%self, $class; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub cssText { |
35
|
25
|
|
|
25
|
1
|
2232
|
my $self = shift; |
36
|
25
|
|
|
|
|
38
|
my $old; |
37
|
25
|
100
|
|
|
|
72
|
if(defined wantarray) {{ |
38
|
21
|
100
|
100
|
|
|
34
|
if(!defined $$self{c} || grep ref ne 'ARRAY', @{$$self{v}}) { |
|
21
|
|
|
|
|
159
|
|
|
16
|
|
|
|
|
102
|
|
39
|
14
|
100
|
|
|
|
19
|
@{$$self{v}} or $old = 'none', last; |
|
14
|
|
|
|
|
52
|
|
40
|
13
|
|
|
|
|
72
|
require CSS'DOM'Value'Primitive; |
41
|
13
|
|
|
|
|
19
|
my @args; my $index = 0; |
|
13
|
|
|
|
|
20
|
|
42
|
13
|
|
|
|
|
20
|
for(@{$$self{v}}) { |
|
13
|
|
|
|
|
38
|
|
43
|
18
|
100
|
|
|
|
66
|
next unless ref eq 'ARRAY'; |
44
|
|
|
|
|
|
|
@args or @args = ( |
45
|
6
|
100
|
|
|
|
78
|
(owner => property => @$self{})[0,2,1,3], index => $index |
46
|
|
|
|
|
|
|
); |
47
|
6
|
|
|
|
|
34
|
$_ = new CSS'DOM'Value'Primitive @$_, @args; |
48
|
|
|
|
|
|
|
} |
49
|
4
|
|
|
4
|
|
1308
|
no warnings 'uninitialized'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
2128
|
|
50
|
|
|
|
|
|
|
$old = join length $$self{s} ? $$self{s} : ' ', |
51
|
13
|
100
|
|
|
|
54
|
map cssText $_, @{$$self{v}} |
|
13
|
|
|
|
|
62
|
|
52
|
|
|
|
|
|
|
} |
53
|
7
|
|
|
|
|
17
|
else { $old = $$self{c} } |
54
|
|
|
|
|
|
|
}} |
55
|
25
|
100
|
|
|
|
277
|
if(@_) { # assignment |
56
|
|
|
|
|
|
|
die new CSS'DOM'Exception |
57
|
|
|
|
|
|
|
NO_MODIFICATION_ALLOWED_ERR, |
58
|
|
|
|
|
|
|
"Unowned value objects cannot be modified" |
59
|
4
|
100
|
|
|
|
23
|
unless my $owner = $self->{o}; |
60
|
|
|
|
|
|
|
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
|
3
|
100
|
|
|
|
15
|
unless my $prop = $self->{p}; |
65
|
|
|
|
|
|
|
|
66
|
2
|
50
|
|
|
|
8
|
if( |
67
|
|
|
|
|
|
|
my @arsg |
68
|
|
|
|
|
|
|
= $owner->property_parser->match($prop, $_[0]) |
69
|
|
|
|
|
|
|
) { |
70
|
2
|
|
|
|
|
11
|
require CSS'DOM'Value; |
71
|
2
|
|
|
|
|
8
|
CSS'DOM'Value::_apply_args_to_self($self,$owner,$prop,@arsg); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
2
|
50
|
|
|
|
13
|
if(my $mh = $owner->modification_handler) { |
75
|
2
|
|
|
|
|
7
|
&$mh(); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
23
|
|
|
|
|
109
|
$old; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
10
|
|
|
10
|
1
|
47
|
sub cssValueType { CSS_VALUE_LIST } |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub item { |
84
|
24
|
|
|
24
|
1
|
51
|
my($self, $index) = @_; |
85
|
24
|
|
50
|
|
|
134
|
my $v = $self->{v} || return; |
86
|
24
|
50
|
|
|
|
76
|
exists $$v[$index] or return; |
87
|
|
|
|
|
|
|
|
88
|
24
|
|
|
|
|
66
|
for($$v[$index]) { |
89
|
24
|
50
|
|
|
|
103
|
defined or return; |
90
|
24
|
100
|
|
|
|
88
|
ref eq 'ARRAY' or return exit die return $_; |
91
|
|
|
|
|
|
|
|
92
|
21
|
|
|
|
|
805
|
require CSS'DOM'Value'Primitive; |
93
|
|
|
|
|
|
|
return $_ = new CSS'DOM'Value'Primitive |
94
|
|
|
|
|
|
|
@$_, |
95
|
21
|
|
|
|
|
362
|
(owner => property => @$self{})[0,2,1,3], |
96
|
|
|
|
|
|
|
index => $index; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
21
|
50
|
|
21
|
1
|
35
|
sub length { scalar @{ shift->{v} || return 0 } } |
|
21
|
|
|
|
|
126
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
*FETCH = *item; |
103
|
|
|
|
|
|
|
*FETCHSIZE = *length; |
104
|
9
|
|
|
9
|
|
26
|
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.16 |
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- and
|
129
|
|
|
|
|
|
|
C 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 |
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. |
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 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 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 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 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 |
210
|
|
|
|
|
|
|
apply to individual elements of a list value. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=back |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head1 SEE ALSO |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
L |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
L |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
L |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
L |