| 1 | #! perl | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 12 | ▶ | use v5.26; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 12 | ▶ | use Object::Pad; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 12 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 12 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | class SVGPDF::CSS; | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | ▶ | field $css :accessor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
css: not called CC=2 SCAR=11.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 0 | ▶ | field $errstr :accessor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
errstr: not called CC=2 SCAR=14.0
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | ▶ | field $base :mutator; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
base: not called CC=1 SCAR=2.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | field $ctx :accessor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ctx: not called CC=2 SCAR=14.0
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 12 | field @stack; | |||||||||||||||||||||||||||||||||||||||||
| 15 | 0 | ▶ | field $ffam :accessor; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ffam: not called CC=2 SCAR=14.0
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | BUILD { | ||||||||||||||||||||||||||||||||||||||||||
| 18 | $css = {}; | ||||||||||||||||||||||||||||||||||||||||||
| 19 | $base = | ||||||||||||||||||||||||||||||||||||||||||
| 20 | { 'font-family' => 'serif', | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 'font-size' => '10', | ||||||||||||||||||||||||||||||||||||||||||
| 22 | 'color' => 'black', | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 'background-color' => 'none', | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 'fill' => 'currentColor', | ||||||||||||||||||||||||||||||||||||||||||
| 25 | 'stroke' => 'none', | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 'line-width' => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 27 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 28 | $ctx = {}; | ||||||||||||||||||||||||||||||||||||||||||
| 29 | $ffam = []; | ||||||||||||||||||||||||||||||||||||||||||
| 30 | $self->push( @_ ) if @_; | ||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | # Parse a string with one or more styles. Augments. | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | method read_string ( $string ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_string: not called CC=33 SCAR=68.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | state $ffi = "face000"; # for unique font-face ids | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | $css->{'*'} //= $base; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$css->{"*"} //= $base
MC/DC0%0/2
$css->{"*"} //= $base
$css->{"*"}
$base
Truth table0%0/3
A //= B
A= $css->{"*"}B= $base
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | # Flatten whitespace and remove /* comment */ style comments. | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $string =~ s/\s+/ /g; | |||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $string =~ s!/\*.*?\*\/!!g; | |||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | # Hide semicolon in url(data:application/octet-stream;base64,...) | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | $string =~ s/(url\(['"]data:.*?\/.*?);(.*?),/$1\x{ff1b}$2,/g; | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | # Split into styles. | ||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | foreach ( grep { /\S/ } split /(?<=\})/, $string ) { | |||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | unless ( /^\s*([^{]+?)\s*\{(.*)\}\s*$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | $errstr = "Invalid or unexpected style data '$_'"; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | # Split in such a way as to support grouped styles. | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $style = $1; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $properties = $2; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $style =~ s/\s{2,}/ /g; | |||||||||||||||||||||||||||||||||||||||||
| 58 | my @styles = | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | grep { s/\s+/ /g; 1; } | |||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | grep { /\S/ } | |||||||||||||||||||||||||||||||||||||||||
| 61 | split( /\s*,\s*/, $style ); | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | foreach ( @styles ) { | |||||||||||||||||||||||||||||||||||||||||
| 63 | # Give @font-face rules an unique id. | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | if ( $_ eq '@font-face' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $_ = '@font-'.$ffi; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $ffi++; | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | ▶ | $css->{$_} //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$css->{$_} //= {}
MC/DC0%0/1
$css->{$_} //= {}
$css->{$_}
Truth table0%0/2
A
A= $css->{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | # Split into properties. | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | foreach ( grep { /\S/ } split /\;/, $properties ) { | |||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | unless ( /^\s*(\*?[\w._-]+)\s*:\s*(.*?)\s*$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $errstr = "Invalid or unexpected property '$_' in style '$style'"; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $s = lc($1); | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my %s = ( $s => $2 ); | |||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | # Split font shorthand. | ||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ( $s eq "font" ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 12 | ▶ | use Text::ParseWords qw(shellwords); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my @spec = shellwords($s{$s}); | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | foreach my $spec ( @spec ) { | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $spec =~ s/;$//; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ( $spec =~ /^([.\d]+)px/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $s{'font-size'} = $1; | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | elsif ( $spec eq "bold" ) { | ||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $s{'font-weight'} = "bold"; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | elsif ( $spec eq "italic" ) { | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $s{'font-style'} = "italic"; | |||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||
| 97 | elsif ( $spec eq "bolditalic" ) { | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $s{'font-weight'} = "bold"; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | $s{'font-style'} = "italic"; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | elsif ( $spec =~ /^(?:text,)?serif$/i ) { | ||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $s{'font-family'} = "serif"; | |||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||
| 104 | elsif ( $spec =~ /^(?:text,)?sans(?:-serif)?$/i ) { | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | $s{'font-family'} = "sans"; | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | # These are for ABC SVG processing. | ||||||||||||||||||||||||||||||||||||||||||
| 109 | elsif ( $spec =~ /^abc2svg(?:\.ttf)?$/i ) { | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | $s{'font-family'} = "abc2svg"; | |||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||
| 112 | elsif ( lc($spec) =~ /^musejazz\s*text$/i ) { | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $s{'font-family'} = "musejazztext"; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $s{'font-family'} = $spec; | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | # Remove the shorthand if we found something. | ||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | delete($s{$s}) if keys(%s) > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | # Split outline shorthand. | ||||||||||||||||||||||||||||||||||||||||||
| 125 | elsif ( $s eq "outline" ) { | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 12 | ▶ | use Text::ParseWords qw(shellwords); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my @spec = shellwords($s{$s}); | |||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | foreach my $spec ( @spec ) { | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $spec =~ s/;$//; | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if ( $spec =~ /^([.\d]+)px/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $s{'outline-width'} = $1; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | elsif ( $spec =~ /^(dotted|dashed|solid|double|groove|ridge|inset|outset)$/i ) { | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $s{'outline-style'} = $1; | |||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | $s{'outline-color'} = $spec; | |||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | # Remove the shorthand if we found something. | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | delete($s{$s}) if keys(%s) > 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | foreach my $k ( keys %s ) { | |||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | foreach ( @styles ) { | |||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $css->{$_}->{$k} = $s{$k}; | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my @keys = keys( %$css ); | |||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | for my $k ( @keys ) { | |||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if ( $k =~ /^\@font-face/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | # Unhide semicolons. | ||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | s/\x{ff1b}/;/g for values( %{$css->{$k}} ); | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | push( @$ffam, $css->{$k} ); | |||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | delete $css->{$k}; | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | for my $k ( @keys ) { | |||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | next unless $k =~ /^(\S+)\s+(\S+)$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | $css->{$1}->{" $2"} //= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$css->{$1}{" $2"} //= {}
MC/DC0%0/1
$css->{$1}{" $2"} //= {}
$css->{$1}{" $2"}
Truth table0%0/2
A
A= $css->{$1}{" $2"}
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $self->merge( $css->{$1}->{" $2"}, $css->{$k} ); | |||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | delete ( $css->{$k} ); | |||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 12 | } | |||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | # Merge hashes (and only hashes), recursive. | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | method merge ( $left, $right ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
merge: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | return unless defined $right; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | if ( ref($left) eq 'HASH' && ref($right) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $left eq "HASH" and ref $right eq "HASH"
MC/DC0%0/2
ref $left eq "HASH" and ref $right eq "HASH"
ref $left eq "HASH"
ref $right eq "HASH"
Truth table0%0/3
A and B
A= ref $left eq "HASH"B= ref $right eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | for ( keys %$right ) { | |||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ( exists $left->{$_} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists $left->{$_} and ref $left->{$_} eq "HASH" and ref $right->{$_} eq "HASH"
exists $left->{$_} and ref $left->{$_} eq "HASH"
MC/DC0%0/3
exists $left->{$_} and ref $left->{$_} eq "HASH" and ref $right->{$_} eq "HASH"
exists $left->{$_}
ref $left->{$_} eq "HASH"
ref $right->{$_} eq "HASH"
Truth table0%0/4
A and B and C
A= exists $left->{$_}B= ref $left->{$_} eq "HASH"C= ref $right->{$_} eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | && ref($left->{$_}) eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||
| 180 | && ref($right->{$_}) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $self->merge( $left->{$_}, $right->{$_} ); | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $left->{$_} = $right->{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | croak("Cannot merge " . ref($left) . " and " . ref($right)); | |||||||||||||||||||||||||||||||||||||||||
| 190 | 12 | } | |||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | method find ( $arg ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | $css->{'*'} //= $base; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$css->{"*"} //= $base
MC/DC0%0/2
$css->{"*"} //= $base
$css->{"*"}
$base
Truth table0%0/3
A //= B
A= $css->{"*"}B= $base
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my $ret = { %{$css->{'*'}} }; | |||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | if ( exists( $css->{_} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | $self->merge( $ret, $css->{_} ); | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | $ctx = $ret; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $ret->{$arg}; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 12 | } | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | method push ( @args ) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
push: not called CC=25 SCAR=64.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | my $args = ref($args[0]) eq 'HASH' ? $args[0] : { @args }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | $css->{'*'} //= $base; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$css->{"*"} //= $base
MC/DC0%0/2
$css->{"*"} //= $base
$css->{"*"}
$base
Truth table0%0/3
A //= B
A= $css->{"*"}B= $base
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my $ret; | |||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||
| 207 | # CSS defaults. | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | while ( my($k,$v) = each %{$css->{'*'}} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | $ret->{$k} //= $v; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ret->{$k} //= $v
MC/DC0%0/2
$ret->{$k} //= $v
$ret->{$k}
$v
Truth table0%0/3
A //= B
A= $ret->{$k}B= $v
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | ## Parent. | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if ( exists( $css->{_} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $self->merge( $ret, $css->{_} ); | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | ## Presentation attributes. | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | for ( keys %$args ) { | |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | next if /^(element|class|style|id)$/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $ret->{$_} = $args->{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | ## Tag style. | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if ( $args->{element} && exists( $css->{$args->{element}} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{"element"} and exists $$css{$args->{"element"}}
MC/DC0%0/2
$args->{"element"} and exists $$css{$args->{"element"}}
$args->{"element"}
exists $$css{$args->{"element"}}
Truth table0%0/3
A and B
A= $args->{"element"}B= exists $$css{$args->{"element"}}
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $self->merge( $ret, $css->{$args->{element}} ); | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | if ( $args->{element} && exists( $css->{_}->{" ".$args->{element}} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{"element"} and exists $css->{"_"}{' ' . $args->{"element"}}
MC/DC0%0/2
$args->{"element"} and exists $css->{"_"}{' ' . $args->{"element"}}
$args->{"element"}
exists $css->{"_"}{' ' . $args->{"element"}}
Truth table0%0/3
A and B
A= $args->{"element"}B= exists $css->{"_"}{' ' . $args->{"element"}}
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $self->merge( $ret, $css->{_}->{" ".$args->{element}} ); | |||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | ## Class style. | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if ( $args->{class} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | for ( split( ' ', $args->{class} ), "svg" ) { | |||||||||||||||||||||||||||||||||||||||||
| 234 | $self->merge( $ret, $css->{".$_"} ) | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | if exists( $css->{".$_"} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | $self->merge( $ret, $css->{$args->{element}.".$_"} ) | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | if $args->{element} && exists( $css->{$args->{element}.".$_"} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{"element"} and exists $$css{$args->{"element"} . ".$_"}
MC/DC0%0/2
$args->{"element"} and exists $$css{$args->{"element"} . ".$_"}
$args->{"element"}
exists $$css{$args->{"element"} . ".$_"}
Truth table0%0/3
A and B
A= $args->{"element"}B= exists $$css{$args->{"element"} . ".$_"}
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | ## ID (generic). | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if ( $args->{id} && exists( $css->{ "#" . $args->{id} } ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{"id"} and exists $$css{'#' . $args->{"id"}}
MC/DC0%0/2
$args->{"id"} and exists $$css{'#' . $args->{"id"}}
$args->{"id"}
exists $$css{'#' . $args->{"id"}}
Truth table0%0/3
A and B
A= $args->{"id"}B= exists $$css{'#' . $args->{"id"}}
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $self->merge( $ret, $css->{ "#" . $args->{id} } ); | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | ## ID (specific). | ||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | if ( $args->{id} && exists( $css->{ $args->{element} . "#" . $args->{id} } ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{"id"} and exists $$css{$args->{"element"} . '#' . $args->{"id"}}
MC/DC0%0/2
$args->{"id"} and exists $$css{$args->{"element"} . '#' . $args->{"id"}}
$args->{"id"}
exists $$css{$args->{"element"} . '#' . $args->{"id"}}
Truth table0%0/3
A and B
A= $args->{"id"}B= exists $$css{$args->{"element"} . '#' . $args->{"id"}}
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | $self->merge( $ret, $css->{ $args->{element} . "#" . $args->{id} } ); | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | ## Style attribute. | ||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if ( $args->{style} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | $self->read_string( "__ {" . $args->{style} . "}" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | or croak($errstr); | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $self->merge( $ret, delete $css->{__} ); | |||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | $ret->{'@font-face'} = $ffam if $ffam; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | push( @stack, { %{$css->{_}//{}} } ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$css->{"_"} // {}
MC/DC0%0/1
$css->{"_"} // {}
$css->{"_"}
Truth table0%0/2
A
A= $css->{"_"}
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $self->merge( $css, { _ => $ret } ); | |||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $ctx = $ret; | |||||||||||||||||||||||||||||||||||||||||
| 262 | 12 | } | |||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | method pop () { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pop: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | Carp::croak("CSS stack underflow") unless @stack; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $ctx = $css->{_} = pop(@stack); | |||||||||||||||||||||||||||||||||||||||||
| 267 | 12 | } | |||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | method level () { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
level: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | 0+@stack; | |||||||||||||||||||||||||||||||||||||||||
| 271 | 12 | } | |||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||
| 273 | 12 | 1; | |||||||||||||||||||||||||||||||||||||||||