line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::DOM::Value::List; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '0.17'; |
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
1410
|
use CSS'DOM'Constants ; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
301
|
|
6
|
4
|
|
|
4
|
|
24
|
use Scalar'Util 'weaken'; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
422
|
|
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
|
645
|
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
|
|
908
|
'@{}' => sub { tie my @shext, __PACKAGE__, shift; \@shext }; |
|
4
|
|
|
9
|
|
707
|
|
|
4
|
|
|
|
|
38
|
|
|
9
|
|
|
|
|
33
|
|
|
9
|
|
|
|
|
39
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
30
|
|
|
30
|
0
|
569
|
my $class = shift; |
26
|
30
|
|
|
|
|
103
|
my %args = @_; |
27
|
30
|
|
|
|
|
92
|
my %self; |
28
|
|
|
|
|
|
|
@self{< c v s o p >} |
29
|
30
|
|
|
|
|
1749
|
= @args{< css values separator owner property >}; |
30
|
30
|
|
|
|
|
185
|
weaken $self{o}; |
31
|
30
|
|
|
|
|
183
|
bless \%self, $class; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub cssText { |
35
|
25
|
|
|
25
|
1
|
2553
|
my $self = shift; |
36
|
25
|
|
|
|
|
32
|
my $old; |
37
|
25
|
100
|
|
|
|
44
|
if(defined wantarray) {{ |
38
|
21
|
100
|
100
|
|
|
24
|
if(!defined $$self{c} || grep ref ne 'ARRAY', @{$$self{v}}) { |
|
21
|
|
|
|
|
80
|
|
|
16
|
|
|
|
|
72
|
|
39
|
14
|
100
|
|
|
|
16
|
@{$$self{v}} or $old = 'none', last; |
|
14
|
|
|
|
|
31
|
|
40
|
13
|
|
|
|
|
54
|
require CSS'DOM'Value'Primitive; |
41
|
13
|
|
|
|
|
19
|
my @args; my $index = 0; |
|
13
|
|
|
|
|
15
|
|
42
|
13
|
|
|
|
|
15
|
for(@{$$self{v}}) { |
|
13
|
|
|
|
|
28
|
|
43
|
18
|
100
|
|
|
|
41
|
next unless ref eq 'ARRAY'; |
44
|
|
|
|
|
|
|
@args or @args = ( |
45
|
6
|
100
|
|
|
|
72
|
(owner => property => @$self{})[0,2,1,3], index => $index |
46
|
|
|
|
|
|
|
); |
47
|
6
|
|
|
|
|
24
|
$_ = new CSS'DOM'Value'Primitive @$_, @args; |
48
|
|
|
|
|
|
|
} |
49
|
4
|
|
|
4
|
|
1037
|
no warnings 'uninitialized'; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1609
|
|
50
|
|
|
|
|
|
|
$old = join length $$self{s} ? $$self{s} : ' ', |
51
|
13
|
100
|
|
|
|
32
|
map cssText $_, @{$$self{v}} |
|
13
|
|
|
|
|
37
|
|
52
|
|
|
|
|
|
|
} |
53
|
7
|
|
|
|
|
12
|
else { $old = $$self{c} } |
54
|
|
|
|
|
|
|
}} |
55
|
25
|
100
|
|
|
|
67
|
if(@_) { # assignment |
56
|
|
|
|
|
|
|
die new CSS'DOM'Exception |
57
|
|
|
|
|
|
|
NO_MODIFICATION_ALLOWED_ERR, |
58
|
|
|
|
|
|
|
"Unowned value objects cannot be modified" |
59
|
4
|
100
|
|
|
|
12
|
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
|
|
|
|
9
|
unless my $prop = $self->{p}; |
65
|
|
|
|
|
|
|
|
66
|
2
|
50
|
|
|
|
5
|
if( |
67
|
|
|
|
|
|
|
my @arsg |
68
|
|
|
|
|
|
|
= $owner->property_parser->match($prop, $_[0]) |
69
|
|
|
|
|
|
|
) { |
70
|
2
|
|
|
|
|
10
|
require CSS'DOM'Value; |
71
|
2
|
|
|
|
|
6
|
CSS'DOM'Value::_apply_args_to_self($self,$owner,$prop,@arsg); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
2
|
50
|
|
|
|
7
|
if(my $mh = $owner->modification_handler) { |
75
|
2
|
|
|
|
|
5
|
&$mh(); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
23
|
|
|
|
|
67
|
$old; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
10
|
|
|
10
|
1
|
33
|
sub cssValueType { CSS_VALUE_LIST } |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub item { |
84
|
24
|
|
|
24
|
1
|
45
|
my($self, $index) = @_; |
85
|
24
|
|
50
|
|
|
87
|
my $v = $self->{v} || return; |
86
|
24
|
50
|
|
|
|
50
|
exists $$v[$index] or return; |
87
|
|
|
|
|
|
|
|
88
|
24
|
|
|
|
|
57
|
for($$v[$index]) { |
89
|
24
|
50
|
|
|
|
45
|
defined or return; |
90
|
24
|
100
|
|
|
|
59
|
ref eq 'ARRAY' or return exit die return $_; |
91
|
|
|
|
|
|
|
|
92
|
21
|
|
|
|
|
506
|
require CSS'DOM'Value'Primitive; |
93
|
|
|
|
|
|
|
return $_ = new CSS'DOM'Value'Primitive |
94
|
|
|
|
|
|
|
@$_, |
95
|
21
|
|
|
|
|
419
|
(owner => property => @$self{})[0,2,1,3], |
96
|
|
|
|
|
|
|
index => $index; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
21
|
50
|
|
21
|
1
|
26
|
sub length { scalar @{ shift->{v} || return 0 } } |
|
21
|
|
|
|
|
101
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
*FETCH = *item; |
103
|
|
|
|
|
|
|
*FETCHSIZE = *length; |
104
|
9
|
|
|
9
|
|
20
|
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.17 |
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 |