DOM/PropertyParser.pm

filter: Statementstmt 99.1% 346 / 349 Branchbran 93.5% 217 / 232 Conditioncond 90.7% 108 / 119 MC/DCmcdc 44.6% 25 / 56 Subroutinesub 100% 44 / 44 Podpod 87.5% 7 / 8 totaltotal 92.4% 747 / 808 CC 177 SCAR 29.9
CC
177
Cov
96%
_make_arg_list
40.4
_compile_format
36.0
match
28.4
CRAP 19.9
« DOM/Value/Primitive.pm ↑ Summary DOM.pm »
1 package CSS::DOM::PropertyParser;
2  
3 4 $VERSION = '0.16';
4  
5 4 ▶use warnings; no warnings qw 'utf8 parenthesis';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 4 ▶use constant 1.03 (); # multiple
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use CSS::DOM'Constants ':primitive', ':value';
Subroutine BEGIN: called CC=1 SCAR=0.0
10 4 ▶use CSS'DOM'Util<unescape unescape_str unescape_url>;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 ▶use constant old_perl => $] < 5.01;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 4 ▶{ no strict 'refs'; delete ${__PACKAGE__.'::'}{old_perl} }
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 # perl 5.10.0 has a bug affecting $^N (perl bug #56194; not the initial
16 # report, but regressions in 5.10; read the whole ticket for details). We
17 # have a workaround, but it requires more CPU, so we only enable it for
18 # this perl version.
19 4 ▶use constant naughty_perl => 0+$] eq 5.01;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 4 ▶{ no strict 'refs'; delete ${__PACKAGE__.'::'}{naughty_perl} }
Subroutine BEGIN: called CC=1 SCAR=0.0
21  
22 4 *s2c = *CSS'DOM'Constants'SuffixToConst;
23 4 our %s2c;
24  
25 4 our %compiled; # compiled formats
26 4 our %subcompiled; # compiled sub-formats
27 # We use ‘our’ instead of ‘my’, because re-evals that are compiled at run
28 # time can be a bit buggy when they refer to ‘my’ variables.
29  
30 sub new {
31 8 ▶ bless{}, shift
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
32 }
33  
34 sub add_property {
35 474 ▶ $_[0]{$_[1]}=$_[2]
Subroutine add_property: called CC=1 SCAR=0.0
Pod documented
36 }
37  
38 sub get_property {
39 2328 ▶ exists $_[0]{$_[1]} ? $_[0]{$_[1]} : ()
Subroutine get_property: called CC=2 SCAR=6.9
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
exists $_[0]{$_[1]} ? : 2326 2 2328
40 }
41  
42 sub delete_property {
43 1 ▶ delete $_[0]{$_[1]} or ()
Subroutine delete_property: called CC=2 SCAR=7.6
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
delete $_[0]{$_[1]} or () 0 1 1
44 }
45  
46 sub property_names {
47 1 ▶ sort keys %{$_[0]};
Subroutine property_names: called CC=1 SCAR=0.0
Pod documented
48 }
49  
50 sub subproperty_names {
51 1414 ▶ exists $_[0]{$_[1]} or return;
Subroutine subproperty_names: called CC=4 SCAR=14.0
Pod documented
Branch: 1 branch
BranchTrueFalseTotal
exists $_[0]{$_[1]} or return 0 1414 1414
52 1414 my $p = $_[0]{$_[1]};
53 1414 my @p = $p->{format} =~ /'([^']+)'/g;
54 exists $p->{properties} && $p->{properties} and
55 1414 ▶ push @p, keys %{$p->{properties}};
Branch: 1 branch
BranchTrueFalseTotal
exists $p->{"properties"} and $p->{"properties"} and push @p, keys %{$$p{"properties"};} 135 1279 1414
Condition66%2/3
exists $p->{"properties"} and $p->{"properties"}
!ll&&!rl&&r
12790135
MC/DC50%1/2
exists $p->{"properties"} and $p->{"properties"}
exists $p->{"properties"} $p->{"properties"}
Truth table66%2/3
A and B
A= exists $p->{"properties"}B= $p->{"properties"}
ABresult
0X0
100
111
56 1414 @p;
57 }
58  
59 sub clone {
60 # exists &dclone or require Storable, "Storable"->import('dclone');
61 # return dclone($_[0]);
62 1 ▶ require Clone;
Subroutine clone: called CC=1 SCAR=0.0
Pod documented
63 1 return Clone'clone($_[0]);
64 }
65  
66 # Declare the variables that the re-evals use. Some nasty hacker went and
67 # ‘fixed’ run-time re-evals to propagate hints, so now we have to do this
68 # as of perl 5.13.8.
69 our(
70 4 @match,@list,@valtypes,$prepped,$alt_types,@List,%Match,%match,@Match,
71 $tokens,$Self,$Fail
72 );
73  
74 # The interface for match is documented in a POD comment further down
75 # (search for the second occurrence of ‘=item match’).
76 sub match { SUB: {
77 1197 ▶ my ($self,$property) = (shift,shift);
Subroutine match: called CC=28 SCAR=33.5
Pod documented
78 1203 ▶ return unless exists $self->{$property};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{$property} 0 1203 1203
79  
80 # Prepare the value
81 1203 (my $types, local our ($tokens,$prepped,$alt_types)) = _prep_val(@_);
82 # tokens is the actual tokens; $prepped is the tokens unescaped and lc'd
83 # if they are ids; $alt_types contains single-char strings indicating pos-
84 # sible datum types.
85 #use DDS; Dump $types if $property =~ /clip/;
86  
87  
88 1203 my @subproperties = $self->subproperty_names($property);
89 1203 my $shorthand = @subproperties;
90 1203 my $spec = $self->{$property};
91  
92 # Check for special values
93 1203 ▶ if(exists $spec->{special_values}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $spec->{"special_values"} and $types eq "i" and exists $spec->{"special_values"}{$CSS::DOM::PropertyParser::prepped->[0]}) 6 1197 1203
Condition83%5/6
exists $spec->{"special_values"} and $types eq "i" and exists $spec->{"special_values"}{$CSS::DOM::PropertyParser::prepped->[0]}
!ll&&!rl&&r
119706
exists $spec->{"special_values"} and $types eq "i"
!ll&&!rl&&r
1182156
MC/DC66%2/3
exists $spec->{"special_values"} and $types eq "i" and exists $spec->{"special_values"}{$CSS::DOM::PropertyParser::prepped->[0]}
exists $spec->{"special_values"} $types eq "i" exists $spec->{"special_values"}{$CSS::DOM::PropertyParser::prepped->[0]}
Truth table75%3/4
A and B and C
A= exists $spec->{"special_values"}B= $types eq "i"C= exists $spec->{"special_values"}{$CSS::DOM::PropertyParser::prepped->[0]}
ABCresult
0XX0
10X0
1100
1111
94 && $types eq 'i'
95 && exists $spec->{special_values}{$prepped->[0]}) {
96 6 @_ = ($self,$property,$spec->{special_values}{$prepped->[0]});
97 6 redo SUB;
98 }
99  
100 # Check for inherit
101 1197 ▶ if($types eq 'i' and $prepped->[0] eq 'inherit') {
Branch: 1 branch
BranchTrueFalseTotal
if ($types eq "i" and $CSS::DOM::PropertyParser::prepped->[0] eq "inherit") 6 1191 1197
Condition100%3/3
$types eq "i" and $CSS::DOM::PropertyParser::prepped->[0] eq "inherit"
!ll&&!rl&&r
4717206
MC/DC100%2/2
$types eq "i" and $CSS::DOM::PropertyParser::prepped->[0] eq "inherit"
$types eq "i" $CSS::DOM::PropertyParser::prepped->[0] eq "inherit"
Truth table100%3/3
A and B
A= $types eq "i"B= $CSS::DOM::PropertyParser::prepped->[0] eq "inherit"
ABresult
0X0
100
111
102 6 my @arg_array = (
103 $$tokens[0],'CSS::DOM::Value', type => CSS_INHERIT, css => $$tokens[0]
104 );
105 6 ▶ if($shorthand) {
Branch: 1 branch
BranchTrueFalseTotal
if ($shorthand) { } 0 6 6
106 0 return { map +($_ => \@arg_array), @subproperties };
107 }
108 6 else { return @arg_array }
109 }
110  
111 # Localise other vars used by the hairy regexps
112 1191 local our (@Match,%Match,@valtypes,@List);
113 1191 local our $Self = $self;
114  
115 # Compile the formats of the sub-properties, something we can’t do
116 # during the pattern match, as compilation requires regular expressions
117 # and perl’s re engine is not reëntrant. This has to come before the for-
118 # mat for this property, in case it relies on list-style-type. We use
119 # (??{...}) to pick it up, but that is too buggy in perl 5.8.x, so, for
120 # old perls, we compile it straight in. Consequently we also have to
121 # ‘un-cache’ any compiled format containing <counter>, in case it is
122 # shared with another parser object with another definition for
123 # list-style-type.
124 1191 my $format = $$spec{format};
125 1191 ▶ for(
Branch: 1 branch
BranchTrueFalseTotal
$format =~ /<counter>/ ? : 32 1159 1191
126 @subproperties,
127 $format =~ '<counter>'
128 ? scalar(old_perl && delete $compiled{$format}, 'list-style-type')
129 : ()
130 ) {
131 670 ▶ next unless exists $self->{$_};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{$_} 1 669 670
132 669 my $format = $self->{$_}{format};
133 669 old_perl and $compiled{$format} and delete $compiled{$format};
134 669 ▶ $compiled{$format} ||= _compile_format($format)
Condition66%2/3
$CSS::DOM::PropertyParser::compiled{$format} ||= _compile_format($format)
l!l&&r!l&&!r
656130
MC/DC0%0/2
$CSS::DOM::PropertyParser::compiled{$format} ||= _compile_format($format)
$CSS::DOM::PropertyParser::compiled{$format} _compile_format($format)
Truth table66%2/3
A ||= B
A= $CSS::DOM::PropertyParser::compiled{$format}B= _compile_format($format)
ABresult
1X1
011
000
135 }
136  
137 # Prepare this property’s format pattern
138 1191 ▶ my $pattern = $compiled{$format} ||= _compile_format($format);
Condition66%2/3
$CSS::DOM::PropertyParser::compiled{$format} ||= _compile_format($format)
l!l&&r!l&&!r
10881030
MC/DC0%0/2
$CSS::DOM::PropertyParser::compiled{$format} ||= _compile_format($format)
$CSS::DOM::PropertyParser::compiled{$format} _compile_format($format)
Truth table66%2/3
A ||= B
A= $CSS::DOM::PropertyParser::compiled{$format}B= _compile_format($format)
ABresult
1X1
011
000
139  
140 # Do the actual pattern matching
141 1191 ▶ $types =~ /^$pattern\z/ or return;
Branch: 1 branch
BranchTrueFalseTotal
$types =~ /^$pattern\z/ or return 78 1113 1191
142  
143 #use DDS; Dump $types,$tokens,\@valtypes;
144 #use DDS; Dump \%Match if $property =~ /clip/;
145 # Get the values, convert them into CSSValue arg lists and return them
146 1113 ▶ if($shorthand) {
Branch: 1 branch
BranchTrueFalseTotal
if ($shorthand) { } 118 995 1113
147 118 my $retval = {%Match};
148 118 ▶ my $subprops = exists $spec->{properties} ? $spec->{properties} : undef;
Branch: 1 branch
BranchTrueFalseTotal
exists $spec->{'properties'} ? : 65 53 118
149  
150 # We record which captures have been turned into arg lists already,
151 # since these are sometimes shared between properties.
152 118 my @arglistified;
153  
154 118 for(@subproperties) {
155 621 ▶ if(exists $retval->{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $retval->{$_}) { } 106 515 621
156 106 @{ $retval->{$_} } = _make_arg_list( @{ $retval->{$_} } );
157 }
158 else {
159 515 my $set;
160 515 ▶ if($subprops and exists $subprops->{$_}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($subprops and exists $subprops->{$_}) 393 122 515
Condition66%2/3
$subprops and exists $subprops->{$_}
!ll&&!rl&&r
1220393
MC/DC50%1/2
$subprops and exists $subprops->{$_}
$subprops exists $subprops->{$_}
Truth table66%2/3
A and B
A= $subpropsB= exists $subprops->{$_}
ABresult
0X0
100
111
161 393 for my $c( @{ $subprops->{$_} } ) { # capture nums
162 # find the first one that matched something
163 446 ▶ if( $Match[$c] and length $Match[$c][0] ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($CSS::DOM::PropertyParser::Match[$c] and length $CSS::DOM::PropertyParser::Match[$c][0]) 273 173 446
Condition66%2/3
$CSS::DOM::PropertyParser::Match[$c] and length $CSS::DOM::PropertyParser::Match[$c][0]
!ll&&!rl&&r
1730273
MC/DC50%1/2
$CSS::DOM::PropertyParser::Match[$c] and length $CSS::DOM::PropertyParser::Match[$c][0]
$CSS::DOM::PropertyParser::Match[$c] length $CSS::DOM::PropertyParser::Match[$c][0]
Truth table66%2/3
A and B
A= $CSS::DOM::PropertyParser::Match[$c]B= length $CSS::DOM::PropertyParser::Match[$c][0]
ABresult
0X0
100
111
164 273 ▶ @{ $Match[$c] } = _make_arg_list( @{ $Match[$c] } )
Branch: 1 branch
BranchTrueFalseTotal
unless $arglistified[$c]++ 157 116 273
165 unless $arglistified[$c]++;
166 273 ++$set;
167 273 $retval->{$_} = $Match[$c];
168 273 last;
169 }
170 }
171 }
172 515 ▶ if(!$set) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($set) 242 273 515
173 # use default value
174 # ~~~ Should we cache this? (If we do, we need to distinguish between
175 # ‘content: Times New Roman’ and ‘font-family: Times New Roman’.)
176 242 my $default = $self->{$_}{default};
177 4 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
178 242 ▶ $retval->{$_} = length $default
Branch: 1 branch
BranchTrueFalseTotal
length $default ? : 176 66 242
179 ? [
180 $self->match($_, $default)
181 ]
182 : ""
183 }
184 }
185 }
186 118 $retval;
187 }
188 else { # simple
189 995 my $css = join "", @{ (_space_out($types,$tokens))[1] };
190 #use DDS; Dump \@List if exists $$spec{list} && $$spec{list};
191 return _make_arg_list(
192 $types, $tokens,
193 exists $$spec{list} && $$spec{list}
194 ? \@List
195 995 ▶ : (\@valtypes, $prepped)
Branch: 1 branch
BranchTrueFalseTotal
exists $spec->{'list'} && $spec->{'list'} ? : 90 905 995
Condition66%2/3
exists $spec->{"list"} and $spec->{"list"}
!ll&&!rl&&r
905090
MC/DC50%1/2
exists $spec->{"list"} and $spec->{"list"}
exists $spec->{"list"} $spec->{"list"}
Truth table66%2/3
A and B
A= exists $spec->{"list"}B= $spec->{"list"}
ABresult
0X0
100
111
196 );
197 }
198 }}
199  
200 sub _make_arg_list {
201 1424 ▶ my($types, $tokens) = (shift,shift);
Subroutine _make_arg_list: called CC=40 SCAR=37.0
202 1424 my($stypes,$stokens) = _space_out($types, $tokens);
203 1424 my $css = join "", @$stokens;
204 1424 ▶ if(@_ == 1) { # list property
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 90 1334 1424
205 90 my $list = shift @'_;
206 90 ▶ my $sep = @$list <= 1 ? '' : do {
Branch: 1 branch
BranchTrueFalseTotal
@$list <= 1 ? : 44 46 90
207 46 my $range_start = $$list[0][4];
208 46 my $range_end = $$list[1][4] - length($$list[1][4]) - 1;
209 46 my(undef,$stokens) = _space_out(
210 substr($types, $range_start-1, $range_end-$range_start+3),
211 [@$tokens[$range_start-1...$range_end+1]]
212 );
213 46 join "", @$stokens[1...$#$stokens-1];
214 };
215 return $css, "CSS::DOM::Value::List",
216 separator => $sep, css => $css,
217 values => [ map {
218 90 my @args = _make_arg_list(
219 @$_[0...3]
220 );
221 166 shift @args, shift @args;
222 \@args
223 166 } @$list ];
224 }
225 else{
226 1334 my($valtypes, $prepped) = @_;
227 1334 my @valtypes = grep defined, @$valtypes;
228 1334 ▶ if(@valtypes != 1 and
Branch: 1 branch
BranchTrueFalseTotal
if (@valtypes != 1 and $valtypes[0] != 23 || do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x51\x54\x01\x55\x55\x55\x55\x55\x55\x55\x55\x55"} my $found; foreach $_ (@valtypes[1 ... $#valtypes - 1]) { $_ == -1 and ++$found, last; } ; $found }) 64 1270 1334
Condition66%4/6
@valtypes != 1 and $valtypes[0] != 23 || do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x51\x54\x01\x55\x55\x55\x55\x55\x55\x55\x55\x55"} my $found; foreach $_ (@valtypes[1 ... $#valtypes - 1]) { $_ == -1 and ++$found, last; } ; $found }
!ll&&!rl&&r
1261730
$valtypes[0] != 23 or do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x51\x54\x01\x55\x55\x55\x55\x55\x55\x55\x55\x55"} my $found; foreach $_ (@valtypes[1 ... $#valtypes - 1]) { $_ == -1 and ++$found, last; } ; $found }
l!l&&r!l&&!r
6409
MC/DC0%0/3
@valtypes != 1 and $valtypes[0] != 23 || do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x51\x54\x01\x55\x55\x55\x55\x55\x55\x55\x55\x55"} my $found; foreach $_ (@valtypes[1 ... $#valtypes - 1]) { $_ == -1 and ++$found, last; } ; $found }
@valtypes != 1 $valtypes[0] != 23 do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x51\x54\x01\x55\x55\x55\x55\x55\x55\x55\x55\x55"} my $found; foreach $_ (@valtypes[1 ... $#valtypes - 1]) { $_ == -1 and ++$found, last; } ; $found }
Truth table50%2/4
A and B or C
A= @valtypes != 1B= $valtypes[0] != 23C= do { BEGIN {${^WARNING_BITS} = "\x55\x55\x55\x55\x55\x55\x55\x55\x54\x55\x51\x54\x01\x55\x55\x55\x55\x55\x55\x55\x55\x55"} my $found; foreach $_ (@valtypes[1 ... $#valtypes - 1]) { $_ == -1 and ++$found, last; } ; $found }
ABCresult
0XX0
1000
11X1
1011
229 $valtypes[0] != CSS_COUNTER || do { # The code in this block is to
230 4 ▶ no warnings 'uninitialized'; # distinguish between counter(id,
Subroutine BEGIN: called CC=1 SCAR=0.0
231 9 my $found; # id) (which is a CSS_COUNTER) and
232 9 for(@valtypes[1...$#valtypes-1]) { # counter(id) id (CSS_CUSTOM).
233 0 ▶ $_ == -1 and ++$found, last; # -1 is a special marker for the end of
Branch: 1 branch
BranchTrueFalseTotal
$_ == -1 and ++$found, last 0 0 0
234 } # a counter
235 $found
236 9 }) {
237 64 return $css => "CSS::DOM::Value", type => CSS_CUSTOM, value => $css;
238 }
239 1270 my $type = shift @valtypes;
240 return $css, "CSS::DOM::Value::Primitive",
241 type => $type, css => $css,
242 value =>
243 $type == CSS_NUMBER || $type == CSS_PERCENTAGE || $type == CSS_EMS ||
244 $type == CSS_EXS || $type == CSS_PX || $type == CSS_CM ||
245 $type == CSS_MM || $type == CSS_IN || $type == CSS_PT ||
246 $type == CSS_PC || $type == CSS_DEG || $type == CSS_RAD ||
247 $type == CSS_GRAD || $type == CSS_MS || $type == CSS_S ||
248 $type == CSS_HZ || $type == CSS_KHZ
249 ? $css
250 : $type == CSS_STRING
251 ? unescape_str $css
252 : $type == CSS_IDENT
253 ? unescape $css
254 : $type == CSS_URI
255 ? unescape_url $css
256 : $type == CSS_COUNTER
257 ? [
258 $$prepped[$types =~ /i/, $-[0]],
259 $types =~ /'/ ? $$prepped[$-[0]] : undef,
260 $types =~ /i.*?i/ ? $$prepped[$+[0]-1] : undef,
261 ]
262 : $type == CSS_RGBCOLOR
263 ? substr $types, 0, 1, eq '#'
264 ? $$prepped[0]
265 : do{
266 222 my @vals;
267 222 ▶ while($types =~ /([%D1])/g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($types =~ /([%D1])/g) 64 222 286
268 push @vals, [
269 type =>
270 $1 eq '%' ? CSS_PERCENTAGE
271 64 ▶ : $1 eq 'D' ? $s2c{unescape do{
Branch: 2 branches
BranchTrueFalseTotal
$1 eq '%' ? : 18 46 64
$1 eq 'D' ? : 0 46 46
272 0 ($$tokens[$-[1]] =~ '(\D+)')[0]
273 }}
274 : CSS_NUMBER,
275 value => $1,
276 css => $1,
277 ]
278 }
279 \@vals
280 222 ▶ }
Branch: 4 branches
BranchTrueFalseTotal
$type == 22 ? : 5 4 9
$type == 24 ? : 4 0 4
$1 eq 'i' ? : 3 13 16
$2 eq 'D' ? : 7 6 13
281 : $type == CSS_ATTR
282 ? $$prepped[$types =~ /i/, $-[0]]
283 : $type == CSS_RECT
284 ? [
285 map scalar(
286 $types =~ /\G.*?(d?([D1])|i)/g,
287 $1 eq 'i'
288 ? [type => CSS_IDENT, value => 'auto'] #$$prepped[$-[1]]]
289 : [
290 type =>
291 $2 eq 'D'
292 1270 ▶ ? $s2c{unescape do{($$tokens[$-[2]] =~ '(\D+)')[0]}}
Branch: 9 branches
BranchTrueFalseTotal
$type == 1 || $type == 2 || $type == 3 || $type == 4 || $type == 5 || $type == 6 || $type == 7 || $type == 8 || $type == 9 || $type == 10 || $type == 11 || $type == 12 || $type == 13 || $type == 14 || $type == 15 || $type == 16 || $type == 17 ? : 254 1016 1270
$type == 19 ? : 55 961 1016
$type == 21 ? : 671 290 961
$type == 20 ? : 40 250 290
$type == 23 ? : 9 241 250
$types =~ /'/ ? : 4 5 9
$types =~ /i.*?i/ ? : 4 5 9
$type == 25 ? : 232 9 241
substr($types, 0, 1) eq '#' ? : 10 222 232
Condition100%48/48
$type == 1 or $type == 2 or $type == 3 or $type == 4 or $type == 5 or $type == 6 or $type == 7 or $type == 8 or $type == 9 or $type == 10 or $type == 11 or $type == 12 or $type == 13 or $type == 14 or $type == 15 or $type == 16 or $type == 17
l!l&&r!l&&!r
24861016
$type == 1 or $type == 2 or $type == 3 or $type == 4 or $type == 5 or $type == 6 or $type == 7 or $type == 8 or $type == 9 or $type == 10 or $type == 11 or $type == 12 or $type == 13 or $type == 14 or $type == 15 or $type == 16
l!l&&r!l&&!r
24351022
$type == 1 or $type == 2 or $type == 3 or $type == 4 or $type == 5 or $type == 6 or $type == 7 or $type == 8 or $type == 9 or $type == 10 or $type == 11 or $type == 12 or $type == 13 or $type == 14 or $type == 15
l!l&&r!l&&!r
23671027
$type == 1 or $type == 2 or $type == 3 or $type == 4 or $type == 5 or $type == 6 or $type == 7 or $type == 8 or $type == 9 or $type == 10 or $type == 11 or $type == 12 or $type == 13 or $type == 14
l!l&&r!l&&!r
23331034
$type == 1 or $type == 2 or $type == 3 or $type == 4 or $type == 5 or $type == 6 or $type == 7 or $type == 8 or $type == 9 or $type == 10 or $type == 11 or $type == 12 or $type == 13
l!l&&r!l&&!r
22941037
$type == 1 or $type == 2 or $type == 3 or $type == 4 or $type == 5 or $type == 6 or $type == 7 or $type == 8 or $type == 9 or $type == 10 or $type == 11 or $type == 12
l!l&&r!l&&!r
22361041
$type == 1 or $type == 2 or $type == 3 or $type == 4 or $type == 5 or $type == 6 or $type == 7 or $type == 8 or $type == 9 or $type == 10 or $type == 11
l!l&&r!l&&!r
21581047
$type == 1 or $type == 2 or $type == 3 or $type == 4 or $type == 5 or $type == 6 or $type == 7 or $type == 8 or $type == 9 or $type == 10
l!l&&r!l&&!r
21141055
$type == 1 or $type == 2 or $type == 3 or $type == 4 or $type == 5 or $type == 6 or $type == 7 or $type == 8 or $type == 9
l!l&&r!l&&!r
20741059
$type == 1 or $type == 2 or $type == 3 or $type == 4 or $type == 5 or $type == 6 or $type == 7 or $type == 8
l!l&&r!l&&!r
20251063
$type == 1 or $type == 2 or $type == 3 or $type == 4 or $type == 5 or $type == 6 or $type == 7
l!l&&r!l&&!r
19841068
$type == 1 or $type == 2 or $type == 3 or $type == 4 or $type == 5 or $type == 6
l!l&&r!l&&!r
19351072
$type == 1 or $type == 2 or $type == 3 or $type == 4 or $type == 5
l!l&&r!l&&!r
154391077
$type == 1 or $type == 2 or $type == 3 or $type == 4
l!l&&r!l&&!r
15041116
$type == 1 or $type == 2 or $type == 3
l!l&&r!l&&!r
104461120
$type == 1 or $type == 2
l!l&&r!l&&!r
59451166
MC/DC0%0/17
$type == 1 or $type == 2 or $type == 3 or $type == 4 or $type == 5 or $type == 6 or $type == 7 or $type == 8 or $type == 9 or $type == 10 or $type == 11 or $type == 12 or $type == 13 or $type == 14 or $type == 15 or $type == 16 or $type == 17
too many conditions
293 : CSS_NUMBER,
294 value => join "", @$tokens[$-[1]...$+[1]-1]
295 ]
296 ), 1...4
297 ]
298 : die __PACKAGE__ . " internal error: unknown type: $type"
299 }
300 }
301  
302 sub _space_out {
303 2465 ▶ my($types,$tokens) = @_;
Subroutine _space_out: called CC=4 SCAR=13.9
304 2465 ▶Carp'cluck() if ref $tokens ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $tokens ne "ARRAY" 0 2465 2465
305 2465 $tokens = [@$tokens];
306 2465 my @posses;
307 2465 $types =~ s/(?<=[^(f])(?![),]|\z)/
308 577 ▶ if($tokens->[-1+pos $types] =~ m=^[+-]\z=) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$tokens[-1 + pos($types)] =~ /^[+-]\z/) { } 86 491 577
309 86 ''
310 }
311 else {
312 491 push @posses, pos $types; 's'
313 }
314 /ge;
315 2465 splice @$tokens, $_, 0, ' ' for reverse @posses;
316 2465 return $types, $tokens;
317 }
318  
319 # Defined further down, to keep the hairiness out of the way.
320 4 my($colour_names_re, $system_colour_names_re);
321  
322 sub _prep_val {
323 1203 ▶ defined &unescape or
Subroutine _prep_val: called CC=18 SCAR=28.9
Branch: 1 branch
BranchTrueFalseTotal
defined &CSS::DOM::PropertyParser::unescape or require CSS::DOM::Util, "CSS::DOM::Util"->import("unescape") 0 1203 1203
324 require CSS::DOM::Util, 'CSS::DOM::Util'->import('unescape');
325 1203 my($types,$tokens);
326 1203 ▶ if(@_ > 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ > 1) { } 915 288 1203
327 915 ($types,$tokens)= @_;
328 }
329 else {
330 288 require CSS::DOM::Parser;
331 288 ($types, $tokens) = CSS::DOM::Parser'tokenise($_[0]);
332 }
333  
334 # strip out all whitespace tokens
335 {
336 1203 my @posses;
337 1203 $tokens = [@$tokens]; # We have to copy it as it may be referenced
338 1203 $types =~ s/s/push @posses,pos$types;''/gem; # elsewhere.
339 1203 splice@$tokens,$_,1 for reverse @posses;
340 }
341
342 1203 my @prepped;
343 my @alt_type;
344 1203 for(0..$#$tokens) {
345 1843 my $type = substr $types, $_, 1;
346 1843 my $thing;
347 1843 ▶ if($type =~ /[if#]/) {
Branch: 4 branches
BranchTrueFalseTotal
if ($type =~ /[if#]/) { } 1119 724 1843
elsif ($type eq 'D') { } 200 524 724
elsif ($type eq '1') { } 141 383 524
elsif ($type eq 'd') { } 45 338 383
348 1119 $thing = lc unescape($$tokens[$_]);
349 1119 ▶ if($type eq 'i') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'i') { } 1061 58 1119
elsif ($type eq '#') { } 13 45 58
350 1061 ▶ if($thing =~ /^$colour_names_re\z/o) { $alt_type[$_] = 'c' }
Branch: 2 branches
BranchTrueFalseTotal
if ($thing =~ /^$colour_names_re\z/o) { } 216 845 1061
elsif ($thing =~ /^$system_colour_names_re\z/o) { } 31 814 845
351 31 elsif($thing =~ /^$system_colour_names_re\z/o) { $alt_type[$_] = 's' }
352 }
353 elsif($type eq '#') {
354 13 ▶ $thing =~ /^#(?:[0-9a-f]{3}){1,2}\z/ and $alt_type[$_] = 'c';#olour
Branch: 1 branch
BranchTrueFalseTotal
$thing =~ /^#(?:[0-9a-f]{3}){1,2}\z/ and $alt_type[$_] = "c" 11 2 13
355 # ~~~ What about escapes?
356 }
357 }
358 elsif($type eq 'D') { # dimension
359 200 ($thing = $$tokens[$_]) =~ s/^[.0-9]+//;
360 200 $thing = lc unescape($thing);
361 200 ▶ if($thing =~ /^(?:deg|g?rad)\z/) { $alt_type[$_] = 'a'}#ngle
Branch: 2 branches
BranchTrueFalseTotal
if ($thing =~ /^(?:deg|g?rad)\z/) { } 24 176 200
elsif ($thing =~ /^(?:e[mx]|p[xtc]|in|[cm]m)\z/) { } 147 29 176
362 elsif($thing =~ /^(?:e[mx]|p[xtc]|in|[cm]m)\z/) {
363 147 $alt_type[$_] = 'l'#ength
364 }
365 }
366 elsif($type eq '1') { # number
367 141 $thing = 0+$$tokens[$_]; # change 0.000 to 0, etc.
368 }
369 elsif($type eq 'd') { # delimiter
370 45 ▶ $alt_type[$_] = '+' if $$tokens[$_] =~ /^[+-]\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $tokens->[$_] =~ /^[+-]\z/ 43 2 45
371 }
372 1843 ▶ defined $alt_type[$_] or $alt_type[$_] = '';
Branch: 1 branch
BranchTrueFalseTotal
defined $alt_type[$_] or $alt_type[$_] = "" 1371 472 1843
373 1843 push @prepped, $thing;
374 }
375  
376 1203 return ($types,$tokens,\@prepped,\@alt_type);
377 }
378  
379  
380 # Various bits and pieces for _compile_format’s use
381  
382 4 $Fail = qr/(?!)/; # avoid recompiling the same sub-regexp doz-
383 # ens of times
384  
385 # This optionally matches a sign
386 4 my $sign = '(?:d(?(?{$$alt_types[pos()-1]eq"+"})|(?!)))?';
387  
388 # These $type_ expressions save the current value type in @valtypes.
389 4 my $type_is_ # generic one to stick inside (?{...})
390 = '$valtypes[$#valtypes='
391 . (naughty_perl ? '$pos[-1]' : 'pos()-length$^N')
392 . ']=';
393 4 my $type_is_dim_or_number
394 = '(?{
395 $valtypes[
396 $#valtypes=' . (naughty_perl ? '$pos[-1]' : 'pos()-length$^N') . '
397 ]
398 = $$prepped[pos()-1] ? $s2c{ $$prepped[pos()-1] } : CSS_NUMBER
399 })';
400  
401 # Constants defined in _compile_format and only used there get deleted at
402 # run time.
403 4 ▶{ no strict 'refs'; delete @{__PACKAGE__.'::'}{cap_start=>cap_end=>} }
Subroutine BEGIN: called CC=1 SCAR=0.0
404  
405 sub _compile_format {
406 116 ▶ my $format = shift;
Subroutine _compile_format: called CC=36 SCAR=35.8
407 116 my $no_match_stuff = shift; # Leave out the @%match localisation stuff
408  
409 # The types of transmogrifications we need to make:
410  
411 # Whitespace is ignored.
412 #
413 # [] is simply (?:).
414 #
415 # () is itself, except we record the captures manually with (?{}).
416 #
417 # The chars ? * + | are left as is (except when | is doubled).
418 #
419 # <...> thingies are replaced with simple regexps that match the type
420 # and then check with a re-eval to see whether the token matches. Then we
421 # have another re-eval that records the type of match in @valtypes, so we
422 # can distinguish between ‘red’ matched by <ident> (counter-reset: red),
423 # ‘red’ matched by <colour> (color: red) and ‘red’ matched by <str/words>
424 # (font-family: red).
425 #
426 # Identifiers are treated similarly.
427 #
428 # '...' references are turned into complicated re-evals that look up the
429 # format for the other property and add it to the %match hash if
430 # it matches.
431 #
432 # || causes the innermost enclosing group to be transformed into a per-
433 # mutation-matching pattern. Since at least one is required, we
434 # put question marks after all sub-patterns except the first in
435 # each alternate. For example, a||b||c (where the letters rep-
436 # resent sub-patterns, not actual chars in the format)
437 # becomes a(?:bc?|cb?)?|b(?:ac?|ca?)?|c(?:ab?|ba?)?.
438  
439 # Concerning the [@%][Mm]atch variables:
440 #
441 # All captures are saved separately in an array during matching. To
442 # account for backtracking, we have to localise every assignment. Since
443 # the localisations will be undone when the re exits, we have to save them
444 # in separate variables. The lc vars are used during matching; the capita-
445 # lised variables afterwards. Since we may be parsing sub-properties
446 # (with their own sets of captures), we need a second localisation mechan-
447 # ism that restores the previous set of captured values when a sub-proper-
448 # ty’s re exits. (We can’t use Perl’s, because the rest of the outer pat-
449 # tern is called recursively from within the inner pattern.) So:
450 #
451 # @match holds arrays of captures, $match[-1] being the current array.
452 # When the re exits, @{ $match[-1] } is copied into @Match. Subpatterns
453 # push onto @match upon entry and pop it on exit.
454 # ~~~ Actually, it seems we don’t currently pop it, but all tests pass. Why
455 # is this?
456 #
457 # @list is similar to @match, but it holds all captured matches in the
458 # order they matched, skipping those that did not match. It includes mul-
459 # tiple elements for quantified captures (that is, if they matched multi-
460 # ple times). @match, on the other hand, is indexed by capture number,
461 # like @-, et al. In other words, if we match ‘'rhext' 'scled'’ against
462 # ‘(<ident>)? (<string>)+’, we have:
463 # @match: undef (elem 0 is always undef), undef, 'scled'
464 # @list: 'rhext', 'scled'
465 #
466 # %match holds named captures (sub-properties) directly (no extra locali-
467 # sation necessary), which are then copied to %Match afterwards.
468 #
469 # In perl 5.10.0 (see the definition of naughty_perl, above). We work
470 # around the unreliability of $^N by pushing the current pos onto @pos
471 # before a sub-pattern or capture, and popping it afterwards. We use
472 # $pos[-1] instead of pos()-length$^N (for the beginning of the capture).
473  
474 116 ▶ my $pattern = $no_match_stuff
Branch: 1 branch
BranchTrueFalseTotal
$no_match_stuff ? : 0 116 116
475 ? '' : '(?{local @match=(@match,[]); local @list=(@list,[])})(?:';
476 # We add (?: to account for top-level alternations.
477  
478 116 my @group_start = length $pattern; # holds the position within $pattern of
479 # the last group start
480 116 my @permut_marker = []; # where a || occurs (array of arrays; each group
481 # has its own array on this stack)
482 116 my @capture_nums;
483 116 my $last_capture = 0;
484  
485 # For each piece of the format, add to the pattern.
486 116 ▶ while(
Branch: 1 branch
BranchTrueFalseTotal
if ($format =~ /(\s+)|(\|\|)|<([^>]+)>|([a-z-]+)|([0-9]+)|'([^']+)'|(.)/g) 1687 116 1803
487 $format =~ /(\s+)|(\|\|)|<([^>]+)>|([a-z-]+)|([0-9]+)|'([^']+)'|(.)/g
488 ) {
489 1687 ▶ next if $1; # ignore whitespace
Branch: 1 branch
BranchTrueFalseTotal
if $1 274 1413 1687
490  
491 # cygwin hack:
492 use constant { # re-evals for before and after captures
493 4 cap_start => naughty_perl ? '(?{local @pos=(@pos,pos)})' : '',
494 cap_end => naughty_perl ? '(?{local @pos=@pos; --$#pos})' : '',
495 4 ▶ };
Subroutine BEGIN: called CC=1 SCAR=0.0
496  
497 1413 ▶ if($2) { # ||
Branch: 6 branches
BranchTrueFalseTotal
if ($2) { } 32 1381 1413
elsif ($3) { } 138 1243 1381
elsif ($4) { } 477 766 1243
elsif ($5) { } 18 748 766
elsif ($6) { } 35 713 748
elsif (do { $7 =~ /^[]|[()]\z/ }) { } 659 54 713
498 32 push @{ $permut_marker[-1] }, length $pattern;
499 }
500 elsif($3) { # <...>
501 # We have to wrap most of these in (?:...) in case they get quantified.
502 # (‘ab’ has to become ‘(?:ab)’ so that ‘ab?’ becomes ‘(?:ab)?’.)
503 $pattern .=
504 $3 eq 'angle' ?
505 "(?:($sign\[D1])" . cap_start . '(?(?{
506 $$alt_types[pos()-1]eq"a"||$$prepped[pos()-1]eq 0
507 })|(?!))' . $type_is_dim_or_number . cap_end .")"
508 : $3 eq 'attr' ?
509 '(?x:' . cap_start . '(
510 f(?(?{$$prepped[pos()-1]eq"attr("})|(?!))i\)
511 )' . "(?{ $type_is_ CSS_ATTR })" . cap_end . ")"
512 : $3 =~ /^colou?r\z/ ?
513 "(?x:" . cap_start . "(?:
514 ([i#](?(?{
515 \$\$alt_types[pos()-1]eq 'c'||\$\$alt_types[pos()-1]eq 's'
516 })|(?!))) (?{ $type_is_ (
517 \$\$alt_types[pos()-1]eq 'c' ? CSS_RGBCOLOR : CSS_IDENT
518 ) })
519 |
520 (f
521 (?:
522 (?(?{\$\$prepped[pos()-1]eq 'rgb('})|(?!))
523 (?: $sign 1(?:,$sign 1){2} | $sign%(?:,$sign%){2} )
524 |
525 (?(?{\$\$prepped[pos()-1]eq 'rgba('})|(?!))
526 (?: $sign 1(?:,$sign 1){2} | $sign%(?:,$sign%){2} ),$sign 1
527 )
528 \\)) (?{ $type_is_ CSS_RGBCOLOR })
529 )" . cap_end . ")"
530  
531 # <counter> represents the following four:
532 # counter(<identifier>)
533 # counter(<identifier>,'list-style-type')
534 # counters(<identifier>,<string>)
535 # counters(<identifier>,<string>,'list-style-type')
536 138 ▶ : $3 eq 'counter' ? do {
Branch: 4 branches
BranchTrueFalseTotal
$3 eq 'angle' ? : 4 134 138
$3 eq 'attr' ? : 4 130 134
$3 =~ /^colou?r\z/ ? : 11 119 130
$3 eq 'counter' ? : 4 115 119
537 4 our $Self;
538 my $list_style_type = old_perl
539 ? exists $$Self{"list-style-type"}
540 ? $compiled{$$Self{"list-style-type"}{format}}
541 ||= _compile_format($$Self{"list-style-type"}{format})
542 4 : '(?!)'
543 : '(??{
544 exists $$Self{"list-style-type"}
545 ? $compiled{$$Self{"list-style-type"}{format}}
546 : $Fail
547 })'
548 ;
549 4 ▶ q*(?x:* . cap_start . q*(f(?{$$prepped[pos()-1]})
Branch: 11 branches
BranchTrueFalseTotal
$3 eq 'frequency' ? : 3 112 115
$3 eq 'identifier' ? : 3 109 112
$3 eq 'integer' ? : 5 104 109
$3 eq 'length' ? : 34 70 104
$3 eq 'number' ? : 7 63 70
$3 eq 'percentage' ? : 29 34 63
$3 eq 'shape' ? : 2 32 34
$3 eq 'string' ? : 8 24 32
$3 eq 'str/words' ? : 8 16 24
$3 eq 'time' ? : 3 13 16
$3 eq 'url' ? : 13 0 13
550 (?(?{$^R eq "counter("})
551 i(?:,* . $list_style_type . q*)?
552 |
553 (?(?{$^R eq "counters("})
554 i,'(?:,* . $list_style_type . q*)?
555 |
556 (?!)
557 )
558 )
559 \))*
560 . "(?{ $type_is_ CSS_COUNTER;"
561 . ' $valtypes[$#valtypes=pos()-1] = -1})' # -1 is a special
562 . cap_end . ')' # marker for the end
563 } # of a counter
564 : $3 eq 'frequency' ?
565 '(?:' . cap_start . '((?:d(?(?{
566 $$tokens[pos()-1]eq"+"||$$tokens[-1+pos]eq"-"&&$$tokens[pos]eq 0
567 })|(?!)))?[D1](?(?{
568 my$p=$$prepped[pos()-1];$p eq"hz"||$p eq"khz"||$p eq 0
569 })|(?!)))' . $type_is_dim_or_number . cap_end . ")"
570 : $3 eq 'identifier' ?
571 "(?:" . cap_start . "(i)(?{ $type_is_ CSS_IDENT })" . cap_end . ")"
572 : $3 eq 'integer' ?
573 '(?:' . cap_start . '(1(?(?{index$$tokens[pos()-1],".",==-1})|(?!)))'
574 . "(?{ $type_is_ CSS_NUMBER })" . cap_end . ")"
575 : $3 eq 'length' ?
576 "(?:" . cap_start . "($sign\[D1])" . '(?(?{
577 $$alt_types[pos()-1]eq"l"||$$prepped[pos()-1]eq 0
578 })|(?!))' . $type_is_dim_or_number . cap_end . ")"
579 : $3 eq 'number' ?
580 "(?:" . cap_start . "(1)(?{ $type_is_ CSS_NUMBER })" . cap_end . ")"
581 : $3 eq 'percentage' ?
582 "(?:" . cap_start
583 . "($sign%)(?{ $type_is_ CSS_PERCENTAGE })"
584 . cap_end . ")"
585 : $3 eq 'shape' ?
586 q*(?x:* . cap_start . q*(f
587 (?(?{$$prepped[pos()-1] eq "rect("})
588 (?:
589 (?:
590 (?:d(?(?{$$alt_types[pos()-1]eq"+"})|(?!)))?[D1](?(?{
591 $$alt_types[pos()-1]eq"l"||$$prepped[pos()-1] eq 0
592 })|(?!))
593 |
594 i(?(?{$$prepped[pos()-1]eq"auto"})|(?!))
595 ),?
596 ){4}
597 |
598 (?!)
599 )
600 \))* . "(?{ $type_is_ CSS_RECT })" . cap_end . ")"
601 : $3 eq 'string' ?
602 "(?:" . cap_start . "(')(?{ $type_is_ CSS_STRING })" . cap_end . ")"
603 : $3 eq 'str/words' ?
604 "(?:" . cap_start
605 . "('|i+)(?{ $type_is_ CSS_STRING })"
606 . cap_end . ")"
607 : $3 eq 'time' ?
608 "(?:" . cap_start . "($sign\[D1])" . '(?(?{
609 my$p=$$prepped[pos()-1];$p eq"ms"||$p eq"s"||$p eq 0
610 })|(?!))' . $type_is_dim_or_number . cap_end . ")"
611 : $3 eq 'url' ?
612 "(?:" . cap_start . "(u)(?{ $type_is_ CSS_URI })" . cap_end . ")"
613 : die "Unrecognised data type in property format: <$3>";
614 }
615 elsif($4) { # identifier
616 477 $pattern .=
617 '(?:' . cap_start
618 . '(i)(?(?{$$prepped[-1+pos]eq"' . $4 . '"})|(?!))'
619 . "(?{ $type_is_ CSS_IDENT })"
620 . cap_end . ")";
621 }
622 elsif($5) { # number
623 18 $pattern .=
624 '(?:' . cap_start
625 . '(1)(?(?{$$tokens[-1+pos]eq"' . $5 . '"})|(?!))'
626 . "(?{ $type_is_ CSS_NUMBER })"
627 . cap_end . ")";
628 }
629 elsif($6) { # '...' reference
630 35 $pattern .=
631 '(?:' # again, we use (?: ... ) in case a question mark is added
632 . cap_start
633 . '((??{
634 exists $$Self{"' . $6 . '"}
635 ? $compiled{$$Self{"' . $6 . '"}{format}}
636 : $Fail;
637 }))'
638 . '(?{
639 # We have a do-block here because a re-eval’s lexical pad is very
640 # buggy and must not be used. (See perl bug #65150.)
641 local$match{"'.$6.'"}=do{
642 my @range
643 = ' . (naughty_perl ? '$pos[-1]' : 'pos()-length$^N') . '
644 ...-1+pos;
645 [
646 '.(
647 naughty_perl ? 'substr($_,$pos[-1],pos()-$pos[-1])' : '$^N'
648 ).',
649 [@$tokens[@range]],[@valtypes[@range]],[@$prepped[@range]]
650 ];
651 }
652 })'
653 . cap_end
654 .')'
655
656 }
657 713 elsif(do{$7 =~ /^[]|[()]\z/}) { # group or alternation
658 # For non-capturing groups, we use (?: ... ).
659 # For capturing groups, since they may be quantified, and since we have
660 # to put a re-eval after them to capture the value, we use an extra non-
661 # capturing group: (?:( ... )(?{...}))
662 # Since || is stronger than |, we have to treat | a bit like ][
663  
664 659 ▶ if(do{$7 =~ /^[])|]\z/}) { # end of a group
Branch: 1 branch
BranchTrueFalseTotal
if (do { $7 =~ /^[])|]\z/ }) 569 90 659
665 569 my $markers = pop @permut_marker;
666 569 ▶ if(@$markers) { # Oh no!
Branch: 1 branch
BranchTrueFalseTotal
if (@$markers) 6 563 569
667 6 unshift @$markers, $group_start[-1];
668 6 _make_permutations($pattern, $markers);
669 }
670 569 pop @group_start;
671 569 ▶ $pattern .=
Branch: 2 branches
BranchTrueFalseTotal
$7 eq '|' ? : 479 90 569
$7 eq ']' ? : 39 51 90
672 $7 eq '|' ? '|'
673 : $7 eq ']' ? ')'
674 : ')(?{
675 (
676 local $match[-1][' . pop(@capture_nums) . '],
677 local $list[-1]
678 ) = do {
679 my @range
680 = '.(naughty_perl ? '$pos[-1]' : 'pos()-length$^N').'...-1+pos;
681 my @a = (
682 '.(
683 naughty_perl
684 ? 'substr($_,$pos[-1],pos()-$pos[-1])'
685 : '$^N'
686 ).',
687 [@$tokens[@range]],[@valtypes[@range]],[@$prepped[@range]],
688 pos
689 );
690 \@a, [@{$list[-1]}, \@a]
691 }
692 })' . cap_end . ')';
693 # We have to intertwine these assignments in this convoluted way
694 # because of the lexical-in-re-eval bug [perl #65150].
695 }
696 659 ▶ if(do{$7 =~ /^[[(|]\z/}) { # start of a group
Branch: 1 branch
BranchTrueFalseTotal
if (do { $7 =~ /^[[(|]\z/ }) 569 90 659
697 569 ▶ $pattern
Branch: 1 branch
BranchTrueFalseTotal
unless $7 eq "|" 90 479 569
698 .= '(?:'
699 . (cap_start.'(')
700 x ($7 eq '(')
701 unless $7 eq '|';
702 569 push @group_start, length $pattern;
703 569 push @permut_marker, [];
704 569 ▶ $7 eq '(' and push @capture_nums, ++$last_capture;
Branch: 1 branch
BranchTrueFalseTotal
$7 eq "(" and push @capture_nums, ++$last_capture 51 518 569
705 }
706 }
707 else {
708 54 ▶ $pattern .= do{$7 =~ /^[?*+]\z/} ? $7
Branch: 1 branch
BranchTrueFalseTotal
do { $7 =~ /^[;{},:]\z/ } ? : 7 2 9
709 54 ▶ : do{$7 =~ /^[;{},:]\z/} ? quotemeta $7
Branch: 1 branch
BranchTrueFalseTotal
do { $7 =~ /^[?*+]\z/ } ? : 45 9 54
710 : '(?:d(?(?{$$tokens[-1+pos]eq"' .quotemeta($7) .'"})|(?!)))'
711 ;
712 }
713 }
714  
715 # There may be top-level ‘||’ things, so we check for those.
716 116 ▶ if(@{$permut_marker[0]}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$permut_marker[0];}) 10 106 116
717 10 unshift @{ $permut_marker[0] }, $group_start[0];
718 10 _make_permutations($pattern, $permut_marker[0]);
719 }
720  
721 # Deal with the match vars
722 116 ▶ $pattern .= ')(?{@Match=@{$match[-1]};@List=@{$list[-1]};%Match=%match})'
Branch: 1 branch
BranchTrueFalseTotal
unless $no_match_stuff 116 0 116
723 unless $no_match_stuff;
724  
725 4 ▶ use re 'eval';
Subroutine BEGIN: called CC=1 SCAR=0.0
726 116 return qr/$pattern/;
727 }
728  
729 sub _make_permutations { # args: pattern, \@markers
730 # pattern is modified in-place
731 16 ▶ my $markers = pop;
Subroutine _make_permutations: called CC=3 SCAR=11.0
732 16 for my $pattern($_[0]) {
733 # Split up the end of the pattern back to the beginning of the inner-
734 # most enclosing group, as specified by the markers. Put the separate
735 # pieces into @alts.
736 16 my @alts;
737 16 for(reverse @$markers) {
738 48 unshift @alts, substr $pattern, $_, length $pattern, '';
739 }
740
741 # Do the permutations
742 16 $pattern .= _permute(@alts);
743 }
744 }
745  
746 sub _permute {
747 160 ▶ if(@_ == 2) { return "(?:$_[0]$_[1]?|$_[1]$_[0]?)" }
Subroutine _permute: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 2) { } 115 45 160
748 else {
749 return
750 45 "(?:"
751 . join("|", map $_[$_] . _permute(@_[0..$_-1,$_+1...$#_]) . '?', 0..$#_)
752 . ")"
753 }
754 }
755  
756  
757 =begin comment
758  
759 Colour names:
760  
761 perl -MRegexp::Assemble -le 'my $ra = new Regexp::Assemble; $ra->add($_) for qw " transparent aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen"; print $ra->re '
762  
763 perl -MRegexp::Assemble -le 'my $ra = new Regexp::Assemble; $ra->add($_) for qw " activeborder activecaption appworkspace background buttonface buttonhighlight buttonshadow buttontext captiontext graytext highlight highlighttext inactiveborder inactivecaption incativecaptiontext infobackground infotext menu menutext scrollbar threeddarkshadow threedface threedhighlight threedlightshadow threedshadow window windowframe windowtext "; print $ra->re '
764  
765 =end comment
766  
767 =cut
768  
769 4 $colour_names_re = '(?:d(?:ark(?:s(?:late(?:gr[ae]y|blue)|(?:eagree|almo)n)|g(?:r(?:e(?:en|y)|ay)|oldenrod)|o(?:r(?:ange|chid)|livegreen)|(?:turquois|blu)e|magenta|violet|khaki|cyan|red)|eep(?:skyblue|pink)|imgr[ae]y|odgerblue)|l(?:i(?:ght(?:s(?:(?:eagree|almo)n|(?:teel|ky)blue|lategr[ae]y)|g(?:r(?:e(?:en|y)|ay)|oldenrodyellow)|c(?:oral|yan)|yellow|blue|pink)|me(?:green)?|nen)|a(?:vender(?:blush)?|wngreen)|emonchiffon)|m(?:edium(?:(?:aquamarin|turquois|purpl|blu)e|s(?:(?:pring|ea)green|lateblue)|(?:violetre|orchi)d)|i(?:(?:dnightblu|styros)e|ntcream)|a(?:genta|roon)|occasin)|s(?:(?:a(?:(?:ddle|ndy)brow|lmo)|pringgree)n|late(?:gr[ae]y|blue)|ea(?:green|shell)|(?:teel|ky)blue|i(?:enna|lver)|now)|p(?:a(?:le(?:g(?:oldenrod|reen)|turquoise|violetred)|payawhip)|(?:owderblu|urpl)e|e(?:achpuff|ru)|ink|lum)|c(?:(?:h(?:artreus|ocolat)|adetblu)e|or(?:n(?:flowerblue|silk)|al)|(?:rimso|ya)n)|b(?:l(?:a(?:nchedalmond|ck)|ue(?:violet)?)|(?:isqu|eig)e|urlywood|rown)|g(?:r(?:e(?:en(?:yellow)?|y)|ay)|ol(?:denro)?d|hostwhite|ainsboro)|o(?:l(?:ive(?:drab)?|dlace)|r(?:ange(?:red)?|chid))|a(?:(?:ntiquewhit|liceblu|zur)e|qua(?:marine)?)|t(?:(?:urquois|histl)e|ransparent|omato|eal|an)|f(?:loralwhite|orestgreen|irebrick|uchsia)|r(?:o(?:sybrown|yalblue)|ed)|i(?:ndi(?:anred|go)|vory)|wh(?:it(?:esmok)?e|eat)|ho(?:neydew|tpink)|nav(?:ajowhite|y)|yellow(?:green)?|violet|khaki)';
770  
771 4 $system_colour_names_re = '(?:in(?:active(?:caption|border)|fo(?:background|text)|cativecaptiontext)|b(?:utton(?:(?:highligh|tex)t|shadow|face)|ackground)|threed(?:(?:light|dark)?shadow|highlight|face)|(?:(?:caption|gray)tex|highligh(?:ttex)?)t|a(?:ctive(?:caption|border)|ppworkspace)|window(?:frame|text)?|menu(?:text)?|scrollbar)';
772  
773 =encoding utf8
774  
775 =head1 NAME
776  
777 CSS::DOM::PropertyParser - Parser for CSS property values
778  
779 =head1 VERSION
780  
781 Version 0.16
782  
783 =head1 SYNOPSIS
784  
785 use CSS::DOM::PropertyParser;
786
787 $spec = new CSS::DOM::PropertyParser; # empty
788 # OR
789 $spec = $CSS::DOM::PropertyParser::Default->clone;
790
791 $spec->add_property(
792 overflow => {
793 format => 'visible|hidden|scroll|auto',
794 default => 'visible',
795 inherit => 0,
796 }
797 );
798
799 $hashref = $spec->get_property('overflow');
800
801 $hashref = $spec->delete_property('overflow');
802
803 @names = $spec->property_names;
804  
805 =head1 DESCRIPTION
806  
807 Objects of this class provide lists of supported properties for L<CSS::DOM>
808 style sheets. They also describe the syntax and parsing of those
809 properties' values.
810  
811 Some CSS properties simply have their own values (e.g., overflow); some
812 are abbreviated forms of several other properties (e.g., font). These are
813 referred to in this documentation as 'simple' and 'shorthand' properties.
814  
815 =head1 CONSTRUCTOR
816  
817 C<$spec = new CSS::DOM::PropertyParser> returns an object that does not
818 recognise any properties, to which you
819 can add your own properties.
820  
821 There are two parser objects that come with this module. These are
822 C<$CSS::DOM::PropertyParser::CSS21>, which contains all of CSS 2.1, and
823 C<$CSS::DOM::PropertyParser::Default>, which is currently identical to the
824 former, but to which parts of CSS 3 which eventually be added.
825  
826 If one of the default specs will do, you don't need a constructor. Simply
827 pass it to the L<CSS::DOM> constructor. If you want to modify it, clone it
828 first, using the C<clone> method (as shown in the L</SYNOPSIS>). It is
829 often convenient to clone the C<$Default> spec and delete those properties
830 that are not supported.
831  
832 =head1 METHODS
833  
834 =for comment
835 =head2 Methods for Controlling Property Specifications
836  
837 =over 4
838  
839 =item clone
840  
841 Returns a deep clone of the object. (It's deep so that you can modify the
842 hashes/arrays inside it without modifying the original.)
843  
844 =item add_property ( $name, \%spec )
845  
846 Adds the specification for the named property. See
847 L</HOW INDIVIDUAL PROPERTIES ARE SPECIFIED>, below.
848  
849 =item get_property ( $name )
850  
851 Returns the hashref passed to the previous method.
852  
853 =item delete_property ( $name )
854  
855 Deletes the property and returns the hash ref.
856  
857 =item property_names
858  
859 Returns a list of the names of supported properties.
860  
861 =item subproperty_names ( $name )
862  
863 Returns a list of the names of C<$name>'s sub-properties if it is a
864 shorthand property.
865  
866 =item match
867  
868 Currently for internal use only. See the source code for documentation.
869 Use at your own risk.
870  
871 =back
872  
873 =begin comment
874  
875 Once I’ve made CSS::DOM::Parser’s tokenise routine public (after a bit of
876 polishing) (or broken it out into a separate module, CSS::Tokeniser), I’ll
877 add this to the docs. I also actually have to modify ‘match’ to use this
878 interface, of course.
879  
880 =head2 Methods Used by L<CSS::DOM::Style>
881  
882 If you are thinking of writing a subclass of PropertyParser, you need to be
883 aware of these methods.
884  
885 Instead of writing a subclass, you can create your
886 own class that does not inherit from PropertyParser use that. It will need
887 to
888 implement these methods here. The methods listed above can be omitted.
889  
890 =over
891  
892 =item match ( $property, $value )
893  
894 =item match ( $property, $token_types, \@tokens )
895  
896 This checks to see whether C<$value> is a valid value for the C<$property>,
897 parsing it if it is. C<$token_types> and C<@tokens> are the values returned
898 by C<CSS::DOM::Parser::tokenise>.
899  
900 Return values are as follows:
901  
902 If the value doesn't match: empty list.
903  
904 If the property is a simple one: (0) the CSS
905 code for the value (possibly normalised), (1) the class to which a value
906 object belongs, (2..) arguments to be passed to the constructor.
907  
908 For a shorthand property, the return value is a single hash ref, the keys
909 being sub-property names and the values array refs containing what would be
910 returned for a simple property.
911  
912 A custom class or subclass can return a L<CSS::DOM::Value> instead of the
913 class and constructor args, in which case the first return value can
914 simply be C<undef> (it should return C<(undef, $object)>).
915  
916 Examples (return value starts on the line following each method call):
917  
918 # $prim stands for "CSS::DOM::Value::Primitive"
919 # $list stands for "CSS::DOM::Value::List"
920
921 $prop_parser->match('background-position','top left');
922 'top left', 'CSS::DOM::Value', CSS_CUSTOM, 'top left'
923
924 $prop_parser->match('background-position','inherit');
925 'inherit', 'CSS::DOM::Value', CSS_INHERIT
926
927 $prop_parser->match('top','1em');
928 '1em', $prim, type => CSS_EMS, value => 1
929  
930 $prop_parser->match('content','"\66oo"');
931 '"\66oo"', $prim, type => CSS_STRING, value => foo
932
933 $prop_parser->match('clip','rect( 5px, 6px, 7px, 8px )');
934 'rect(5px, 6px, 7px, 8px)', $prim,
935 type => CSS_RECT,
936 value => [ [ type => CSS_PX, value => 5 ],
937 [ type => CSS_PX, value => 6 ],
938 [ type => CSS_PX, value => 7 ],
939 [ type => CSS_PX, value => 8 ] ]
940
941 $prop_parser->match('color','#fff');
942 '#fff', $prim, type => CSS_RGBCOLOR, value => '#fff'
943
944 $prop_parser->match('color','rgba(255,0,0,.5)');
945 'rgba(255, 0, 0, .5)', $prim, type => CSS_RGBCOLOR,
946 value => [ [ type => CSS_NUMBER, value => 255 ],
947 [ type => CSS_NUMBER, value => 0 ],
948 [ type => CSS_NUMBER, value => 0 ],
949 [ type => CSS_NUMBER, value => .5 ] ]
950
951 $prop_parser->match('content','counter(foo,disc)');
952 'counter(foo, disc)', $list,
953 separator => ' ',
954 values => [
955 [
956 type => CSS_COUNTER,
957 value => [
958 [ type => CSS_IDENT, value => 'foo' ],
959 undef,
960 [ type => CSS_IDENT, value => 'disc' ],
961 ]
962 ],
963 ]
964
965 $prop_parser->match('font-family','Lucida Grande');
966 'Lucida Grande', $list,
967 separator => ', ',
968 values => [
969 [ type => CSS_STRING, value => 'Lucida Grande' ],
970 ]
971  
972 $prop_parser->match('counter-reset','Lucida Grande');
973 'Lucida Grande', $list,
974 separator => ' ',
975 values => [
976 [ type => CSS_IDENT, value => 'Lucida' ],
977 [ type => CSS_IDENT, value => 'Grande' ],
978 ]
979
980 $prop_parser->match('font','bold 13px Lucida Grande');
981 {
982 'font-style' => [
983 'normal', $prim, type => CSS_IDENT, value => 'normal'
984 ],
985 'font-variant' => [
986 'normal', $prim, type => CSS_IDENT, value => 'normal'
987 ],
988 'font-weight' => [
989 'bold', $prim, type => CSS_IDENT, value => 'bold'
990 ],
991 'font-size' => [ '13px', $prim, type => CSS_PX, value => 13 ],
992 'line-height' => [
993 'normal', $prim, type => CSS_IDENT, value => 'normal'
994 ],
995 'font-family' => [ 'Lucida Grande', $list,
996 separator => ', ',
997 values => [
998 [ type => CSS_STRING, value => 'Lucida Grande' ],
999 ]
1000 ]
1001 }
1002  
1003 =item whatever
1004  
1005 ~~~
1006 CSS::DOM::Style currently relies on the internal formatting of the hash
1007 refs. I want to allow custom property parser classes to do away with hash
1008 refs
1009 altogether, so I will need extra methods here that Style will use instead.
1010  
1011 =back
1012  
1013 =end comment
1014  
1015 =head1 HOW INDIVIDUAL PROPERTIES ARE SPECIFIED
1016  
1017 Before you read this the first time, look at the L</Example> below, and
1018 then come back and use this for reference.
1019  
1020 The specification for an individual property is a hash ref. There are
1021 several keys that each hash ref can have:
1022  
1023 =over
1024  
1025 =item format
1026  
1027 This is set to a string that describes the format of the property. The
1028 syntax used is based on the CSS 2.1 spec, but is not exactly the same.
1029 Unlike regular expressions, these formats are applied to properties on a
1030 token-by-token basis, not one character at a time. (This means that
1031 C<100|200> cannot be written as C<[1|2]00>, as that would mean
1032 S<C<1 00 | 2 00>>.)
1033  
1034 Whitespace is ignored in the format and in the CSS property except as a
1035 token separator.
1036  
1037 There are several metachars (in order of precedence):
1038  
1039 [...] grouping (like (?:...) )
1040 (...) capturing group (just like a regexp)
1041 ? optional
1042 * zero or more
1043 + one or more
1044 || alternates that can come in any order and are optional,
1045 but at least one must be specified (the order will be
1046 retained if possible)
1047 | alternates, exactly one of which is required
1048  
1049 In addition, the following datatypes can be specified in angle brackets:
1050  
1051 <angle> A number with a 'deg', 'rad' or 'grad' suffix
1052 <attr> attr(...)
1053 <colour> (You can omit the 'u' if you want to.) One of CSS's
1054 predefined colour or system colour names, or a #
1055 followed by 3 or 6 hex digits, or the 'rgb(...)'
1056 format (rgba is supported, too)
1057 <counter> counter(...)
1058 <frequency> A unit of Hz or kHz
1059 <identifier> An identifier token
1060 <integer> An integer (really?!)
1061 <length> Number followed by a length unit (em, ex, px, in, cm,
1062 mm, pt, pc)
1063 <number> A number token
1064 <percentage> Number followed by %
1065 <shape> rect(...)
1066 <string> A string token
1067 <str/words> A sequence of identifiers or a single string (e.g., a
1068 font name)
1069 <time> A unit of seconds or milliseconds
1070 <url> A URL token
1071  
1072 The format for a shorthand property can contain the name of a sub-property
1073 in single ASCII quotes.
1074  
1075 All other characters are understood verbatim.
1076  
1077 It is not necessary to include the word 'inherit' in the format, since
1078 every property supports that.
1079  
1080 C<< <counter> >> makes use of the specification for the list-style-type
1081 property. So if you modify the latter, it will affect C<< <counter> >> as
1082 well.
1083  
1084 =item default
1085  
1086 The default value. This only applies to simple properties.
1087  
1088 =item inherit
1089  
1090 Whether the property is inherited.
1091  
1092 =item special_values
1093  
1094 A hash ref of values that are replaced with other values (e.g.,
1095 S<C<< caption => '13px sans-serif' >>>.) The keys
1096 are lowercase identifier names.
1097  
1098 This feature only applies to single identifiers. In fact, it exists solely
1099 for the font property's use.
1100  
1101 =item list
1102  
1103 Set to true if the property is a list of values. The capturing parentheses
1104 in the format determine the individual values of the list.
1105  
1106 This applies to simple properties only.
1107  
1108 =item properties
1109  
1110 For a shorthand property, list the sub-properties here. The keys are the
1111 property names. The values are array refs. The elements within the arrays
1112 are numbers indicating which captures in the format are to be used for the
1113 sub-property's value. They are tried one after the other. Whichever is the
1114 first that matches (null matches not counting) is used.
1115  
1116 Sub-properties that are referenced in the C<format> need not be listed
1117 here.
1118  
1119 =item serialise
1120  
1121 For shorthand properties only. Set this to a subroutine that serialises the
1122 property. It is called with a hashref of sub-properties as its sole
1123 argument. The values of the hash are blank for properties that are set to
1124 their initial values. This sub is only called when all sub-properties are
1125 set.
1126  
1127 =back
1128  
1129 =head2 Example
1130  
1131 =cut
1132  
1133 4 0&&q r
1134  
1135 =for ;
1136  
1137 4 our $CSS21 = new CSS::DOM::PropertyParser;
1138 my %properties = (
1139 azimuth => {
1140 format => '<angle> |
1141 [ left-side | far-left | left | center-left |
1142 center | center-right | right | far-right |
1143 right-inside ] || behind
1144 | leftwards | rightwards',
1145 default => '0',
1146 inherit => 1,
1147 },
1148  
1149 'background-attachment' => {
1150 format => 'scroll | fixed',
1151 default => 'scroll',
1152 inherit => 0,
1153 },
1154  
1155 'background-color' => {
1156 format => '<colour>',
1157 default => 'transparent',
1158 inherit => 0,
1159 },
1160  
1161 'background-image' => {
1162 format => '<url> | none',
1163 default => 'none',
1164 inherit => 0,
1165 },
1166
1167 'background-position' => {
1168 format => '[<percentage>|<length>|left|right]
1169 [<percentage>|<length>|top|center|bottom]? |
1170 [top|bottom] [left|center|right]? |
1171 center [<percentage>|<length>|left|right|top|bottom|
1172 center]?',
1173 default => '0% 0%',
1174 inherit => 0,
1175 },
1176
1177 'background-repeat' => {
1178 format => 'repeat | repeat-x | repeat-y | no-repeat',
1179 default => 'repeat',
1180 inherit => 0,
1181 },
1182
1183 background => {
1184 format => "'background-color' || 'background-image' ||
1185 'background-repeat' || 'background-attachment' ||
1186 'background-position'",
1187 serialise => sub {
1188 11 ▶ my $p = shift;
Subroutine __ANON__: called CC=4 SCAR=13.9
1189 11 my $ret = '';
1190 11 for(qw/ background-color background-image background-repeat
1191 background-attachment background-position /) {
1192 55 ▶ length $p->{$_} and $ret .= "$p->{$_} ";
Branch: 1 branch
BranchTrueFalseTotal
length $p->{$_} and $ret .= "$p->{$_} " 16 39 55
1193 }
1194 11 chop $ret;
1195 11 ▶ length $ret ? $ret : 'none'
Branch: 1 branch
BranchTrueFalseTotal
length $ret ? : 10 1 11
1196 },
1197 },
1198
1199 'border-collapse' => {
1200 format => 'collapse | separate',
1201 inherit => 1,
1202 default => 'separate',
1203 },
1204
1205 'border-color' => {
1206 format => '(<colour>)[(<colour>)[(<colour>)(<colour>)?]?]?',
1207 properties => {
1208 'border-top-color' => [1],
1209 'border-right-color' => [2,1],
1210 'border-bottom-color' => [3,1],
1211 'border-left-color' => [4,2,1],
1212 },
1213 serialise => sub {
1214 7 ▶ my $p = shift;
Subroutine __ANON__: called CC=4 SCAR=13.9
1215 7 my @vals = map $p->{"border-$_-color"},
1216 qw/top right bottom left/;
1217 7 ▶ $vals[3] eq $vals[1] and pop @vals,
Branch: 1 branch
BranchTrueFalseTotal
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0] and pop @vals, $vals[1] eq $vals[0] and pop @vals 2 5 7
Condition100%6/6
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0] and pop @vals, $vals[1] eq $vals[0]
!ll&&!rl&&r
412
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0]
!ll&&!rl&&r
313
MC/DC100%3/3
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0] and pop @vals, $vals[1] eq $vals[0]
$vals[3] eq $vals[1] pop @vals, $vals[2] eq $vals[0] pop @vals, $vals[1] eq $vals[0]
Truth table100%4/4
A and B and C
A= $vals[3] eq $vals[1]B= pop @vals, $vals[2] eq $vals[0]C= pop @vals, $vals[1] eq $vals[0]
ABCresult
0XX0
10X0
1100
1111
1218 $vals[2] eq $vals[0] and pop @vals,
1219 $vals[1] eq $vals[0] and pop @vals;
1220 7 return join " ", @vals;
1221 },
1222 },
1223
1224 'border-spacing' => {
1225 format => '<length> <length>?',
1226 default => '0',
1227 inherit => 1,
1228 },
1229
1230 'border-style' => {
1231 format => "(none|hidden|dotted|dashed|solid|double|groove|ridge|
1232 inset|outset)
1233 [ (none|hidden|dotted|dashed|solid|double|groove|
1234 ridge|inset|outset)
1235 [ (none|hidden|dotted|dashed|solid|double|groove|
1236 ridge|inset|outset)
1237 (none|hidden|dotted|dashed|solid|double|groove|
1238 ridge|inset|outset)?
1239 ]?
1240 ]?",
1241 properties => {
1242 'border-top-style' => [1],
1243 'border-right-style' => [2,1],
1244 'border-bottom-style' => [3,1],
1245 'border-left-style' => [4,2,1],
1246 },
1247 serialise => sub {
1248 13 ▶ my $p = shift;
Subroutine __ANON__: called CC=5 SCAR=16.1
1249 13 my @vals = map $p->{"border-$_-style"},
1250 qw/top right bottom left/;
1251 13 ▶ $vals[3] eq $vals[1] and pop @vals,
Branch: 1 branch
BranchTrueFalseTotal
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0] and pop @vals, $vals[1] eq $vals[0] and pop @vals 1 12 13
Condition100%6/6
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0] and pop @vals, $vals[1] eq $vals[0]
!ll&&!rl&&r
1111
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0]
!ll&&!rl&&r
1012
MC/DC100%3/3
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0] and pop @vals, $vals[1] eq $vals[0]
$vals[3] eq $vals[1] pop @vals, $vals[2] eq $vals[0] pop @vals, $vals[1] eq $vals[0]
Truth table100%4/4
A and B and C
A= $vals[3] eq $vals[1]B= pop @vals, $vals[2] eq $vals[0]C= pop @vals, $vals[1] eq $vals[0]
ABCresult
0XX0
10X0
1100
1111
1252 $vals[2] eq $vals[0] and pop @vals,
1253 $vals[1] eq $vals[0] and pop @vals;
1254 13 ▶ return join " ", map $_||'none', @vals;
Condition100%2/2
$_ || 'none'
l!l
3610
MC/DC100%1/1
$_ || 'none'
$_
Truth table100%2/2
A
A= $_
Aresult
11
00
1255 },
1256 },
1257
1258 'border-top' => {
1259 format => "'border-top-width' || 'border-top-style' ||
1260 'border-top-color'",
1261 serialise => sub {
1262 2 ▶ my $p = shift;
Subroutine __ANON__: called CC=3 SCAR=11.0
1263 2 my $ret = '';
1264 2 for(qw/ width style color /) {
1265 length $p->{"border-top-$_"}
1266 6 ▶ and $ret .= $p->{"border-top-$_"}." ";
Branch: 1 branch
BranchTrueFalseTotal
length $$p{"border-top-$_"} and $ret .= $$p{"border-top-$_"} . ' ' 4 2 6
1267 }
1268 2 chop $ret;
1269 2 $ret
1270 },
1271 },
1272 'border-right' => {
1273 format => "'border-right-width' || 'border-right-style' ||
1274 'border-right-color'",
1275 serialise => sub {
1276 2 ▶ my $p = shift;
Subroutine __ANON__: called CC=3 SCAR=11.0
1277 2 my $ret = '';
1278 2 for(qw/ width style color /) {
1279 length $p->{"border-right-$_"}
1280 6 ▶ and $ret .= $p->{"border-right-$_"}." ";
Branch: 1 branch
BranchTrueFalseTotal
length $$p{"border-right-$_"} and $ret .= $$p{"border-right-$_"} . ' ' 4 2 6
1281 }
1282 2 chop $ret;
1283 2 $ret
1284 },
1285 },
1286 'border-bottom' => {
1287 format => "'border-bottom-width' || 'border-bottom-style' ||
1288 'border-bottom-color'",
1289 serialise => sub {
1290 2 ▶ my $p = shift;
Subroutine __ANON__: called CC=3 SCAR=11.0
1291 2 my $ret = '';
1292 2 for(qw/ width style color /) {
1293 length $p->{"border-bottom-$_"}
1294 6 ▶ and $ret .= $p->{"border-bottom-$_"}." ";
Branch: 1 branch
BranchTrueFalseTotal
length $$p{"border-bottom-$_"} and $ret .= $$p{"border-bottom-$_"} . ' ' 4 2 6
1295 }
1296 2 chop $ret;
1297 2 $ret
1298 },
1299 },
1300 'border-left' => {
1301 format => "'border-left-width' || 'border-left-style' ||
1302 'border-left-color'",
1303 serialise => sub {
1304 2 ▶ my $p = shift;
Subroutine __ANON__: called CC=3 SCAR=11.0
1305 2 my $ret = '';
1306 2 for(qw/ width style color /) {
1307 length $p->{"border-left-$_"}
1308 6 ▶ and $ret .= $p->{"border-left-$_"}." ";
Branch: 1 branch
BranchTrueFalseTotal
length $$p{"border-left-$_"} and $ret .= $$p{"border-left-$_"} . ' ' 4 2 6
1309 }
1310 2 chop $ret;
1311 2 $ret
1312 },
1313 },
1314
1315 'border-top-color' => {
1316 format => '<colour>',
1317 default => "",
1318 inherit => 0,
1319 },
1320 'border-right-color' => {
1321 format => '<colour>',
1322 default => "",
1323 inherit => 0,
1324 },
1325 'border-bottom-color' => {
1326 format => '<colour>',
1327 default => "",
1328 inherit => 0,
1329 },
1330 'border-left-color' => {
1331 format => '<colour>',
1332 default => "",
1333 inherit => 0,
1334 },
1335
1336 'border-top-style' => {
1337 format => 'none|hidden|dotted|dashed|solid|double|groove|ridge|
1338 inset|outset',
1339 default => 'none',
1340 inherit => 0,
1341 },
1342 'border-right-style' => {
1343 format => 'none|hidden|dotted|dashed|solid|double|groove|ridge|
1344 inset|outset',
1345 default => 'none',
1346 inherit => 0,
1347 },
1348 'border-bottom-style' => {
1349 format => 'none|hidden|dotted|dashed|solid|double|groove|ridge|
1350 inset|outset',
1351 default => 'none',
1352 inherit => 0,
1353 },
1354 'border-left-style' => {
1355 format => 'none|hidden|dotted|dashed|solid|double|groove|ridge|
1356 inset|outset',
1357 default => 'none',
1358 inherit => 0,
1359 },
1360
1361 'border-top-width' => {
1362 format => '<length>|thin|thick|medium',
1363 default => 'medium',
1364 inherit => 0,
1365 },
1366 'border-right-width' => {
1367 format => '<length>|thin|thick|medium',
1368 default => 'medium',
1369 inherit => 0,
1370 },
1371 'border-bottom-width' => {
1372 format => '<length>|thin|thick|medium',
1373 default => 'medium',
1374 inherit => 0,
1375 },
1376 'border-left-width' => {
1377 format => '<length>|thin|thick|medium',
1378 default => 'medium',
1379 inherit => 0,
1380 },
1381
1382 'border-width' => {
1383 format => "(<length>|thin|thick|medium)
1384 [ (<length>|thin|thick|medium)
1385 [ (<length>|thin|thick|medium)
1386 (<length>|thin|thick|medium)?
1387 ]?
1388 ]?",
1389 properties => {
1390 'border-top-width' => [1],
1391 'border-right-width' => [2,1],
1392 'border-bottom-width' => [3,1],
1393 'border-left-width' => [4,2,1],
1394 },
1395 serialise => sub {
1396 8 ▶ my $p = shift;
Subroutine __ANON__: called CC=5 SCAR=16.1
1397 8 my @vals = map $p->{"border-$_-width"},
1398 qw/top right bottom left/;
1399 8 ▶ $vals[3] eq $vals[1] and pop @vals,
Branch: 1 branch
BranchTrueFalseTotal
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0] and pop @vals, $vals[1] eq $vals[0] and pop @vals 1 7 8
Condition100%6/6
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0] and pop @vals, $vals[1] eq $vals[0]
!ll&&!rl&&r
611
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0]
!ll&&!rl&&r
512
MC/DC100%3/3
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0] and pop @vals, $vals[1] eq $vals[0]
$vals[3] eq $vals[1] pop @vals, $vals[2] eq $vals[0] pop @vals, $vals[1] eq $vals[0]
Truth table100%4/4
A and B and C
A= $vals[3] eq $vals[1]B= pop @vals, $vals[2] eq $vals[0]C= pop @vals, $vals[1] eq $vals[0]
ABCresult
0XX0
10X0
1100
1111
1400 $vals[2] eq $vals[0] and pop @vals,
1401 $vals[1] eq $vals[0] and pop @vals;
1402 8 ▶ return join " ", map length $_ ? $_ : 'medium', @vals;
Branch: 1 branch
BranchTrueFalseTotal
length $_ ? : 22 4 26
1403 },
1404 },
1405
1406 border => {
1407 format => "(<length>|thin|thick|medium) ||
1408 (none|hidden|dotted|dashed|solid|double|groove|ridge|
1409 inset|outset) || (<colour>)",
1410 properties => {
1411 'border-top-width' => [1],
1412 'border-right-width' => [1],
1413 'border-bottom-width' => [1],
1414 'border-left-width' => [1],
1415 'border-top-style' => [2],
1416 'border-right-style' => [2],
1417 'border-bottom-style' => [2],
1418 'border-left-style' => [2],
1419 'border-top-color' => [3],
1420 'border-right-color' => [3],
1421 'border-bottom-color' => [3],
1422 'border-left-color' => [3],
1423 },
1424 serialise => sub {
1425 5 ▶ my $p = shift;
Subroutine __ANON__: called CC=5 SCAR=16.1
1426 5 my $ret = '';
1427 5 for(qw/ width style color /) {
1428 12 my $temp = $p->{"border-top-$_"};
1429 12 for my $side(qw/ right bottom left /) {
1430 31 ▶ $temp eq $p->{"border-$side-$_"} or return "";
Branch: 1 branch
BranchTrueFalseTotal
$temp eq $$p{"border-$side-$_"} or return "" 3 28 31
1431 }
1432 9 ▶ length $temp and $ret .= "$temp ";
Branch: 1 branch
BranchTrueFalseTotal
length $temp and $ret .= "$temp " 7 2 9
1433 }
1434 2 chop $ret;
1435 2 $ret
1436 },
1437 },
1438
1439 bottom => {
1440 format => '<length>|<percentage>|auto',
1441 default => 'auto',
1442 inherit => 0,
1443 },
1444
1445 'caption-side' => {
1446 format => 'top|bottom',
1447 default => 'top',
1448 inherit => 1,
1449 },
1450
1451 clear => {
1452 format => 'none|left|right|both',
1453 default => 'none',
1454 inherit => 0,
1455 },
1456
1457 clip => {
1458 format => '<shape>|auto',
1459 default => 'auto',
1460 inherit => 0,
1461 },
1462
1463 color => {
1464 format => '<colour>',
1465 default => 'rgba(0,0,0,1)',
1466 inherit => 1,
1467 },
1468
1469 content => {
1470 format => '( normal|none|open-quote|close-quote|no-open-quote|
1471 no-close-quote|<string>|<url>|<counter>|<attr> )+',
1472 default => 'normal',
1473 inherit => 0,
1474 list => 1,
1475 },
1476
1477 'counter-increment' => {
1478 format => '[(<identifier>) (<integer>)? ]+ | none',
1479 default => 'none',
1480 inherit => 0,
1481 list => 1,
1482 },
1483 'counter-reset' => {
1484 format => '[(<identifier>) (<integer>)? ]+ | none',
1485 default => 'none',
1486 inherit => 0,
1487 list => 1,
1488 },
1489
1490 'cue-after' => {
1491 format => '<url>|none',
1492 default => 'none',
1493 inherit => 0,
1494 },
1495 'cue-before' => {
1496 format => '<url>|none',
1497 default => 'none',
1498 inherit => 0,
1499 },
1500
1501 cue =>{
1502 format => '(<url>|none) (<url>|none)?',
1503 properties => {
1504 'cue-before' => [1],
1505 'cue-after' => [2,1],
1506 },
1507 serialise => sub {
1508 3 ▶ my $p = shift;
Subroutine __ANON__: called CC=3 SCAR=11.0
1509 3 my @vals = @$p{"cue-before", "cue-after"};
1510 3 ▶ $vals[1] eq $vals[0] and pop @vals;
Branch: 1 branch
BranchTrueFalseTotal
$vals[1] eq $vals[0] and pop @vals 2 1 3
1511 3 ▶ return join " ", map length $_ ? $_ : 'none', @vals;
Branch: 1 branch
BranchTrueFalseTotal
length $_ ? : 2 2 4
1512 },
1513 },
1514
1515 cursor => {
1516 format => '[(<url>) ,]*
1517 (auto|crosshair|default|pointer|move|e-resize|
1518 ne-resize|nw-resize|n-resize|se-resize|sw-resize|
1519 s-resize|w-resize|text|wait|help|progress)',
1520 default => 'auto',
1521 inherit => 1,
1522 list => 1,
1523 },
1524
1525 direction => {
1526 format => 'ltr|rtl',
1527 default => 'ltr',
1528 inherit => 1,
1529 },
1530
1531 display => {
1532 format => 'inline|block|list-item|run-in|inline-block|table|
1533 inline-table|table-row-group|table-header-group|
1534 table-footer-group|table-row|table-column-group|
1535 table-column|table-cell|table-caption|none',
1536 default => 'inline',
1537 inherit => 0,
1538 },
1539
1540 elevation => {
1541 format => '<angle>|below|level|above|higher|lower',
1542 default => '0',
1543 inherit => 1,
1544 },
1545
1546 'empty-cells' => {
1547 format => 'show|hide',
1548 default => 'show',
1549 inherit => 1,
1550 },
1551
1552 float => {
1553 format => 'left|right|none',
1554 default => 'none',
1555 inherit => 0,
1556 },
1557
1558 'font-family' => { # aka typeface
1559 format => '(serif|sans-serif|cursive|fantasy|monospace|
1560 <str/words>)
1561 [,(serif|sans-serif|cursive|fantasy|monospace|
1562 <str/words>)]*',
1563 default => 'Times, serif',
1564 inherit => 1,
1565 list => 1,
1566 },
1567
1568 'font-size' => {
1569 format => 'xx-small|x-small|small|medium|large|x-large|xx-large|
1570 larger|smaller|<length>|<percentage>',
1571 default => 'medium',
1572 inherit => 1,
1573 },
1574
1575 'font-style' => {
1576 format => 'normal|italic|oblique',
1577 default => 'normal',
1578 inherit => 1,
1579 },
1580
1581 'font-variant' => {
1582 format => 'normal | small-caps',
1583 default => 'normal',
1584 inherit => 1,
1585 },
1586
1587 'font-weight' => {
1588 format => 'normal|bold|bolder|lighter|
1589 100|200|300|400|500|600|700|800|900',
1590 default => 'normal',
1591 inherit => 1,
1592 },
1593
1594 font => {
1595 format => "[ 'font-style' || 'font-variant' || 'font-weight' ]?
1596 'font-size' [ / 'line-height' ]? 'font-family'",
1597 special_values => {
1598 caption => '13px Lucida Grande, sans-serif',
1599 icon => '13px Lucida Grande, sans-serif',
1600 menu => '13px Lucida Grande, sans-serif',
1601 'message-box' => '13px Lucida Grande, sans-serif',
1602 'small-caption' => '11px Lucida Grande, sans-serif',
1603 'status-bar' => '10px Lucida Grande, sans-serif',
1604 },
1605 serialise => sub {
1606 8 ▶ my $p = shift;
Subroutine __ANON__: called CC=6 SCAR=17.9
1607 8 my $ret = '';
1608 8 for(qw/ style variant weight /) {
1609 length $p->{"font-$_"}
1610 24 ▶ and $ret .= $p->{"font-$_"}." ";
Branch: 1 branch
BranchTrueFalseTotal
length $$p{"font-$_"} and $ret .= $$p{"font-$_"} . ' ' 9 15 24
1611 }
1612 $ret .= length $p->{'font-size'}
1613 8 ▶ ? $p->{'font-size'}
Branch: 1 branch
BranchTrueFalseTotal
length $p->{'font-size'} ? : 4 4 8
1614 : 'medium';
1615 8 ▶ $ret .= "/$p->{'line-height'}" if length $p->{'line-height'};
Branch: 1 branch
BranchTrueFalseTotal
if length $p->{"line-height"} 2 6 8
1616 8 ▶ $ret .= " " . ($p->{'font-family'} || "Times, serif");
Condition100%2/2
$p->{'font-family'} || 'Times, serif'
l!l
71
MC/DC100%1/1
$p->{'font-family'} || 'Times, serif'
$p->{'font-family'}
Truth table100%2/2
A
A= $p->{'font-family'}
Aresult
11
00
1617 8 $ret
1618 },
1619 },
1620
1621 height => {
1622 format => '<length>|<percentage>|auto',
1623 default => 'auto',
1624 inherit => 0,
1625 },
1626
1627 left => {
1628 format => '<length>|<percentage>|auto',
1629 default => 'auto',
1630 inherit => 0,
1631 },
1632
1633 'letter-spacing' => { # aka tracking
1634 format => 'normal|<length>',
1635 default => 'normal',
1636 inherit => 1,
1637 },
1638
1639 'line-height' => { # aka leading
1640 format => 'normal|<number>|<length>|<percentage>',
1641 default => "normal",
1642 inherit => 1,
1643 },
1644
1645 'list-style-image' => {
1646 format => '<url>|none',
1647 default => 'none',
1648 inherit => 1,
1649 },
1650
1651 'list-style-position' => {
1652 format => 'inside|outside',
1653 default => 'outside',
1654 inherit => 1,
1655 },
1656
1657 'list-style-type' => {
1658 format => 'disc|circle|square|decimal|decimal-leading-zero|
1659 lower-roman|upper-roman|lower-greek|lower-latin|
1660 upper-latin|armenian|georgian|lower-alpha|
1661 upper-alpha',
1662 default => 'disc',
1663 inherit => 1,
1664 },
1665
1666 'list-style' => {
1667 format => "'list-style-type'||'list-style-position'||
1668 'list-style-image'",
1669 serialise => sub {
1670 4 ▶ my $p = shift;
Subroutine __ANON__: called CC=4 SCAR=13.9
1671 4 my $ret = '';
1672 4 for(qw/ type position image /) {
1673 $p->{"list-style-$_"}
1674 12 ▶ and $ret .= $p->{"list-style-$_"}." ";
Branch: 1 branch
BranchTrueFalseTotal
$$p{"list-style-$_"} and $ret .= $$p{"list-style-$_"} . ' ' 6 6 12
1675 }
1676 4 chop $ret;
1677 4 ▶ $ret || 'disc'
Branch: 1 branch
BranchTrueFalseTotal
$ret or "disc" 0 4 4
1678 },
1679 },
1680
1681 'margin-right' => {
1682 format => '<length>|<percentage>|auto',
1683 default => '0',
1684 inherit => 0,
1685 },
1686 'margin-left' => {
1687 format => '<length>|<percentage>|auto',
1688 default => '0',
1689 inherit => 0,
1690 },
1691 'margin-top' => {
1692 format => '<length>|<percentage>|auto',
1693 default => '0',
1694 inherit => 0,
1695 },
1696 'margin-bottom' => {
1697 format => '<length>|<percentage>|auto',
1698 default => '0',
1699 inherit => 0,
1700 },
1701
1702 margin => {
1703 format => "(<length>|<percentage>|auto)
1704 [ (<length>|<percentage>|auto)
1705 [ (<length>|<percentage>|auto)
1706 (<length>|<percentage>|auto)?
1707 ]?
1708 ]?",
1709 properties => {
1710 'margin-top' => [1],
1711 'margin-right' => [2,1],
1712 'margin-bottom' => [3,1],
1713 'margin-left' => [4,2,1],
1714 },
1715 serialise => sub {
1716 6 ▶ my $p = shift;
Subroutine __ANON__: called CC=5 SCAR=16.1
1717 6 my @vals = map $p->{"margin-$_"},
1718 qw/top right bottom left/;
1719 6 ▶ $vals[3] eq $vals[1] and pop @vals,
Branch: 1 branch
BranchTrueFalseTotal
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0] and pop @vals, $vals[1] eq $vals[0] and pop @vals 1 5 6
Condition100%6/6
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0] and pop @vals, $vals[1] eq $vals[0]
!ll&&!rl&&r
411
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0]
!ll&&!rl&&r
312
MC/DC100%3/3
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0] and pop @vals, $vals[1] eq $vals[0]
$vals[3] eq $vals[1] pop @vals, $vals[2] eq $vals[0] pop @vals, $vals[1] eq $vals[0]
Truth table100%4/4
A and B and C
A= $vals[3] eq $vals[1]B= pop @vals, $vals[2] eq $vals[0]C= pop @vals, $vals[1] eq $vals[0]
ABCresult
0XX0
10X0
1100
1111
1720 $vals[2] eq $vals[0] and pop @vals,
1721 $vals[1] eq $vals[0] and pop @vals;
1722 6 ▶ return join " ", map $_ || 0, @vals;
Condition50%1/2
$_ || 0
l!l
180
MC/DC0%0/1
$_ || 0
$_
Truth table50%1/2
A
A= $_
Aresult
11
00
1723 },
1724 },
1725
1726 'max-height' => {
1727 format => '<length>|<percentage>|none',
1728 default => 'none',
1729 inherit => 0,
1730 },
1731 'max-width' => {
1732 format => '<length>|<percentage>|none',
1733 default => 'none',
1734 inherit => 0,
1735 },
1736 'min-height' => {
1737 format => '<length>|<percentage>|none',
1738 default => 'none',
1739 inherit => 0,
1740 },
1741 'min-width' => {
1742 format => '<length>|<percentage>|none',
1743 default => 'none',
1744 inherit => 0,
1745 },
1746
1747 orphans => {
1748 format => '<integer>',
1749 default => 2,
1750 inherit => 1,
1751 },
1752
1753 'outline-color' => {
1754 format => '<colour>|invert',
1755 default => 'invert',
1756 inherit => 0,
1757 },
1758
1759 'outline-style' => {
1760 format => 'none|hidden|dotted|dashed|solid|double|groove|ridge|
1761 inset|outset',
1762 default => 'none',
1763 inherit => 0,
1764 },
1765
1766 'outline-width' => {
1767 format => '<length>|thin|thick|medium',
1768 default => 'medium',
1769 inherit => 0,
1770 },
1771
1772 outline => {
1773 format => "'outline-color'||'outline-style'||'outline-width'",
1774 serialise => sub {
1775 4 ▶ my $p = shift;
Subroutine __ANON__: called CC=4 SCAR=13.9
1776 4 my $ret = '';
1777 4 for(qw/ color style width /) {
1778 length $p->{"outline-$_"}
1779 12 ▶ and $ret .= $p->{"outline-$_"}." ";
Branch: 1 branch
BranchTrueFalseTotal
length $$p{"outline-$_"} and $ret .= $$p{"outline-$_"} . ' ' 6 6 12
1780 }
1781 4 chop $ret;
1782 4 ▶ length $ret ? $ret : 'invert';
Branch: 1 branch
BranchTrueFalseTotal
length $ret ? : 4 0 4
1783 },
1784 },
1785
1786 overflow => {
1787 format => 'visible|hidden|scroll|auto',
1788 default => 'visible',
1789 inherit => 0,
1790 },
1791
1792 'padding-top' => {
1793 format => '<length>|<percentage>',
1794 default => 0,
1795 inherit => 0,
1796 },
1797 'padding-right' => {
1798 format => '<length>|<percentage>',
1799 default => 0,
1800 inherit => 0,
1801 },
1802 'padding-bottom' => {
1803 format => '<length>|<percentage>',
1804 default => 0,
1805 inherit => 0,
1806 },
1807 'padding-left' => {
1808 format => '<length>|<percentage>',
1809 default => 0,
1810 inherit => 0,
1811 },
1812
1813 padding => {
1814 format => "(<length>|<percentage>)
1815 [ (<length>|<percentage>)
1816 [ (<length>|<percentage>)
1817 (<length>|<percentage>)?
1818 ]?
1819 ]?",
1820 properties => {
1821 'padding-top' => [1],
1822 'padding-right' => [2,1],
1823 'padding-bottom' => [3,1],
1824 'padding-left' => [4,2,1],
1825 },
1826 serialise => sub {
1827 5 ▶ my $p = shift;
Subroutine __ANON__: called CC=5 SCAR=16.1
1828 5 my @vals = map $p->{"padding-$_"},
1829 qw/top right bottom left/;
1830 5 ▶ $vals[3] eq $vals[1] and pop @vals,
Branch: 1 branch
BranchTrueFalseTotal
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0] and pop @vals, $vals[1] eq $vals[0] and pop @vals 1 4 5
Condition100%6/6
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0] and pop @vals, $vals[1] eq $vals[0]
!ll&&!rl&&r
311
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0]
!ll&&!rl&&r
212
MC/DC100%3/3
$vals[3] eq $vals[1] and pop @vals, $vals[2] eq $vals[0] and pop @vals, $vals[1] eq $vals[0]
$vals[3] eq $vals[1] pop @vals, $vals[2] eq $vals[0] pop @vals, $vals[1] eq $vals[0]
Truth table100%4/4
A and B and C
A= $vals[3] eq $vals[1]B= pop @vals, $vals[2] eq $vals[0]C= pop @vals, $vals[1] eq $vals[0]
ABCresult
0XX0
10X0
1100
1111
1831 $vals[2] eq $vals[0] and pop @vals,
1832 $vals[1] eq $vals[0] and pop @vals;
1833 5 ▶ return join " ", map $_ || 0, @vals;
Condition50%1/2
$_ || 0
l!l
140
MC/DC0%0/1
$_ || 0
$_
Truth table50%1/2
A
A= $_
Aresult
11
00
1834 },
1835 },
1836
1837 4 'page-break-after' => {
1838 format => 'auto|always|avoid|left|right',
1839 default => 'auto',
1840 inherit => 0,
1841 },
1842 'page-break-before' => {
1843 format => 'auto|always|avoid|left|right',
1844 default => 'auto',
1845 inherit => 0,
1846 },
1847
1848 'page-break-inside' => {
1849 format => 'avoid|auto',
1850 default => 'auto',
1851 inherit => 1,
1852 },
1853
1854 'pause-after' => {
1855 format => '<time>|<percentage>',
1856 default => 0,
1857 inherit => 0,
1858 },
1859 'pause-before' => {
1860 format => '<time>|<percentage>',
1861 default => 0,
1862 inherit => 0,
1863 },
1864
1865 pause => {
1866 format => '(<time>|<percentage>)(<time>|<percentage>)?',
1867 properties => {
1868 'pause-before' => [1],
1869 'pause-after' => [2,1],
1870 }
1871 },
1872
1873 'pitch-range' => {
1874 format => '<number>',
1875 default => 50,
1876 inherit => 1,
1877 },
1878
1879 pitch => {
1880 format => '<frequency>|x-low|low|medium|high|x-high',
1881 default => 'medium',
1882 inherit => 1,
1883 },
1884
1885 'play-during' => {
1886 format => '<url> [ mix || repeat ]? | auto | none',
1887 default => 'auto',
1888 inherit => 0,
1889 },
1890
1891 position => {
1892 format => 'static|relative|absolute|fixed',
1893 default => 'relative',
1894 inherit => 0,
1895 },
1896
1897 quotes => {
1898 format => '[(<string>)(<string>)]+|none',
1899 default => 'none',
1900 inherit => 1,
1901 list => 1,
1902 },
1903
1904 richness => {
1905 format => '<number>',
1906 default => 50,
1907 inherit => 1,
1908 },
1909
1910 right => {
1911 format => '<length>|<percentage>|auto',
1912 default => 'auto',
1913 inherit => 0,
1914 },
1915
1916 'speak-header' => {
1917 format => 'once|always',
1918 default => 'once',
1919 inherit => 1,
1920 },
1921
1922 'speak-numeral' => {
1923 format => 'digits|continuous',
1924 default => 'continuous',
1925 inherit => 1,
1926 },
1927
1928 'speak-punctuation' => {
1929 format => 'code|none',
1930 default => 'none',
1931 inherit => 1,
1932 },
1933
1934 speak => {
1935 format => 'normal|none|spell-out',
1936 default => 'normal',
1937 inherit => 1,
1938 },
1939
1940 'speech-rate' => {
1941 format => '<number>|x-slow|slow|medium|fast|x-fast|faster|slower',
1942 default => 'medium',
1943 inherit => 1,
1944 },
1945
1946 stress => {
1947 format => '<number>',
1948 default => 50,
1949 inherit => 1,
1950 },
1951
1952 'table-layout' => {
1953 format => 'auto|fixed',
1954 default => 'auto',
1955 inherit => 0,
1956 },
1957
1958 'text-align' => {
1959 format => 'left|right|center|justify|auto',
1960 default => 'auto',
1961 inherit => 1,
1962 },
1963
1964 'text-decoration' => {
1965 format => 'none | underline||overline||line-through||blink ',
1966 default => 'none',
1967 inherit => 0,
1968 },
1969
1970 'text-indent' => {
1971 format => '<length>|<percentage>',
1972 default => 0,
1973 inherit => 1,
1974 },
1975
1976 'text-transform' => {
1977 format => 'capitalize|uppercase|lowercase|none',
1978 default => 'none',
1979 inherit => 1,
1980 },
1981
1982 top => {
1983 format => '<length>|<percentage>|auto',
1984 default => 'auto',
1985 inherit => 0,
1986 },
1987
1988 'unicode-bidi' => {
1989 format => 'normal|embed|bidi-override',
1990 default => 'normal',
1991 inherit => 0,
1992 },
1993
1994 'vertical-align' => {
1995 format => 'baseline|sub|super|top|text-top|middle|bottom|
1996 text-bottom|<percentage>|<length>',
1997 default => 'baseline',
1998 inherit => 0,
1999 },
2000
2001 visibility => {
2002 format => 'visible|hidden|collapse',
2003 default => 'visible',
2004 inherit => 1,
2005 },
2006
2007 'voice-family' => {
2008 format => '(male|female|child|<str/words>)
2009 [, (male|female|child|<str/words>) ]*',
2010 default => '',
2011 inherit => 1,
2012 list => 1,
2013 },
2014
2015 volume => {
2016 format => '<number>|<percentage>|silent|x-soft|soft|medium|loud|
2017 x-loud',
2018 default => 'medium',
2019 inherit => 1,
2020 },
2021
2022 'white-space' => {
2023 format => 'normal|pre|nowrap|pre-wrap|pre-line',
2024 default => 'normal',
2025 inherit => 1,
2026 },
2027
2028 widows => {
2029 format => '<integer>',
2030 default => 2,
2031 inherit => 1,
2032 },
2033
2034 width => {
2035 format => '<length>|<percentage>|auto',
2036 default => 'auto',
2037 inherit => 0,
2038 },
2039
2040 'word-spacing' => {
2041 format => 'normal|<length>',
2042 default => 'normal',
2043 inherit => 1,
2044 },
2045
2046 'z-index' => {
2047 format => 'auto|<integer>',
2048 default => 'auto',
2049 inherit => 0,
2050 },
2051 );
2052 4 $CSS21->add_property( $_ => $properties{$_} ) for keys %properties;
2053  
2054 =pod
2055  
2056 =cut
2057  
2058 4 our $Default = $CSS21;
2059  
2060 =head1 SEE ALSO
2061  
2062 L<CSS::DOM>
« DOM/Value/Primitive.pm ↑ Summary DOM.pm »