line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::Parse::Packed; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
26477
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
105
|
|
4
|
3
|
|
|
3
|
|
16
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
169
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
7
|
|
|
|
|
|
|
|
8
|
3
|
|
|
3
|
|
15
|
use base qw/CSS::Parse/; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
2821
|
|
9
|
3
|
|
|
3
|
|
638
|
use Carp; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
236
|
|
10
|
3
|
|
|
3
|
|
812
|
use CSS::Style; |
|
3
|
|
|
|
|
3634
|
|
|
3
|
|
|
|
|
70
|
|
11
|
3
|
|
|
3
|
|
1161
|
use CSS::Selector; |
|
3
|
|
|
|
|
353
|
|
|
3
|
|
|
|
|
66
|
|
12
|
3
|
|
|
3
|
|
835
|
use CSS::Property; |
|
3
|
|
|
|
|
1290
|
|
|
3
|
|
|
|
|
5652
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub parse_string { |
15
|
6
|
|
|
6
|
0
|
8668
|
my $self = shift; |
16
|
6
|
|
|
|
|
8
|
my $string = shift; |
17
|
|
|
|
|
|
|
|
18
|
6
|
|
|
|
|
46
|
$string =~ s{\r\n|\r|\n}{ }g; |
19
|
6
|
|
|
|
|
18
|
$string =~ s{(?:\@[\S\s]*?;)}{}g; |
20
|
6
|
|
|
|
|
14
|
$self->_parse_string($string); |
21
|
6
|
|
|
|
|
13
|
$self->_create_styles; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _parse_string { |
25
|
6
|
|
|
6
|
|
6
|
my $self = shift; |
26
|
6
|
|
|
|
|
7
|
my $string = shift; |
27
|
|
|
|
|
|
|
|
28
|
6
|
|
|
|
|
60
|
for my $str (grep { /\S/ } split /(?<=\})/, $string) { |
|
17
|
|
|
|
|
44
|
|
29
|
11
|
50
|
|
|
|
70
|
my ($selectors, $properties) = $str =~ m/^\s*([^{]+?)\s*\{(.*)\}\s*$/ |
30
|
|
|
|
|
|
|
or carp "Invalid style data '$str'", next; |
31
|
|
|
|
|
|
|
|
32
|
11
|
|
|
|
|
24
|
my @selectors = split /\s*,\s*/, $selectors; |
33
|
11
|
|
|
|
|
23
|
for my $property (grep { /\S/ } split /\;/, $properties) { |
|
23
|
|
|
|
|
52
|
|
34
|
13
|
100
|
|
|
|
69
|
my ($name, $val) = $property =~ m/^\s*([\w._-]+)\s*:\s*(.*?)\s*$/ |
35
|
|
|
|
|
|
|
or carp "Invalid property '$property'", next; |
36
|
12
|
|
|
|
|
15
|
for my $selector (@selectors) { |
37
|
12
|
|
|
|
|
27
|
$self->stash->{$selector}->{$name} = $val; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _create_styles { |
44
|
6
|
|
|
6
|
|
7
|
my $self = shift; |
45
|
|
|
|
|
|
|
|
46
|
6
|
|
|
|
|
6
|
my @styles; |
47
|
6
|
|
|
|
|
7
|
for my $selector (keys %{$self->stash}) { |
|
6
|
|
|
|
|
10
|
|
48
|
6
|
|
|
|
|
33
|
my $s = CSS::Style->new({ adaptor => $self->{parent}->{adaptor} }); |
49
|
6
|
|
|
|
|
148
|
$s->add_selector(CSS::Selector->new({ name => $selector })); |
50
|
6
|
|
|
|
|
116
|
while (my ($name, $val) = each %{ $self->stash->{$selector} }) { |
|
17
|
|
|
|
|
114
|
|
51
|
11
|
|
|
|
|
53
|
my $property = CSS::Property->new({ |
52
|
|
|
|
|
|
|
property => $name, |
53
|
|
|
|
|
|
|
value => $val, |
54
|
|
|
|
|
|
|
adaptor => $s->{adaptor}, |
55
|
|
|
|
|
|
|
}); |
56
|
11
|
|
|
|
|
402
|
$s->add_property($property); |
57
|
|
|
|
|
|
|
} |
58
|
6
|
|
|
|
|
13
|
push @styles, $s; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
6
|
|
|
|
|
41
|
$self->{parent}->{styles} = \@styles; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub stash { |
65
|
35
|
|
100
|
35
|
0
|
212
|
$_[0]->{parent}->{__PACKAGE__."::stash"} ||= {}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
__END__ |