line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::Struct::Output::Indent; |
2
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
81301
|
use base qw(CSS::Struct::Output); |
|
14
|
|
|
|
|
104
|
|
|
14
|
|
|
|
|
8411
|
|
4
|
14
|
|
|
14
|
|
476789
|
use strict; |
|
14
|
|
|
|
|
34
|
|
|
14
|
|
|
|
|
287
|
|
5
|
14
|
|
|
14
|
|
72
|
use warnings; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
338
|
|
6
|
|
|
|
|
|
|
|
7
|
14
|
|
|
14
|
|
6869
|
use Indent; |
|
14
|
|
|
|
|
9368
|
|
|
14
|
|
|
|
|
414
|
|
8
|
14
|
|
|
14
|
|
95
|
use Readonly; |
|
14
|
|
|
|
|
28
|
|
|
14
|
|
|
|
|
14054
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Constants. |
11
|
|
|
|
|
|
|
Readonly::Scalar my $EMPTY_STR => q{}; |
12
|
|
|
|
|
|
|
Readonly::Scalar my $SPACE => q{ }; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = 0.04; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Resets internal variables. |
17
|
|
|
|
|
|
|
sub reset { |
18
|
38
|
|
|
38
|
1
|
20955
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Reset internal variables from *::Output. |
21
|
38
|
|
|
|
|
175
|
$self->SUPER::reset; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Comment after selector. |
24
|
38
|
|
|
|
|
179
|
$self->{'comment_after_selector'} = 0; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Indent object. |
27
|
|
|
|
|
|
|
$self->{'indent'} = Indent->new( |
28
|
38
|
|
|
|
|
182
|
'next_indent' => $self->{'next_indent'}, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Any processed selector. |
32
|
38
|
|
|
|
|
1268
|
$self->{'processed'} = 0; |
33
|
|
|
|
|
|
|
|
34
|
38
|
|
|
|
|
80
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Default parameters. |
38
|
|
|
|
|
|
|
sub _default_parameters { |
39
|
23
|
|
|
23
|
|
35211
|
my $self = shift; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Default parameters from SUPER. |
42
|
23
|
|
|
|
|
172
|
$self->SUPER::_default_parameters; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Indent string. |
45
|
23
|
|
|
|
|
433
|
$self->{'next_indent'} = "\t"; |
46
|
|
|
|
|
|
|
|
47
|
23
|
|
|
|
|
53
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Flush $self->{'tmp_code'}. |
51
|
|
|
|
|
|
|
sub _flush_tmp { |
52
|
49
|
|
|
49
|
|
84
|
my $self = shift; |
53
|
49
|
100
|
|
|
|
72
|
if (@{$self->{'tmp_code'}}) { |
|
49
|
|
|
|
|
126
|
|
54
|
29
|
|
|
|
|
99
|
$self->{'indent'}->add; |
55
|
29
|
|
|
|
|
246
|
my @comment; |
56
|
29
|
100
|
|
|
|
74
|
if ($self->{'comment_after_selector'}) { |
57
|
2
|
|
|
|
|
7
|
@comment = splice @{$self->{'tmp_code'}}, |
58
|
2
|
|
|
|
|
3
|
-$self->{'comment_after_selector'}; |
59
|
2
|
|
|
|
|
5
|
pop @comment; |
60
|
2
|
|
|
|
|
5
|
foreach my $com (@comment) { |
61
|
10
|
100
|
100
|
|
|
37
|
if ($com ne $EMPTY_STR && $com ne "\n") { |
62
|
3
|
|
|
|
|
7
|
$com = $self->{'indent'}->get.$com; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} else { |
66
|
27
|
|
|
|
|
36
|
pop @{$self->{'tmp_code'}}; |
|
27
|
|
|
|
|
53
|
|
67
|
|
|
|
|
|
|
} |
68
|
29
|
|
|
|
|
56
|
pop @{$self->{'tmp_code'}}; |
|
29
|
|
|
|
|
50
|
|
69
|
29
|
|
|
|
|
50
|
push @{$self->{'flush_code'}}, |
70
|
29
|
|
|
|
|
47
|
(join $EMPTY_STR, @{$self->{'tmp_code'}}).' {'. |
|
29
|
|
|
|
|
101
|
|
71
|
|
|
|
|
|
|
(join $EMPTY_STR, @comment); |
72
|
29
|
|
|
|
|
57
|
$self->{'tmp_code'} = []; |
73
|
29
|
|
|
|
|
55
|
$self->{'processed'} = 1; |
74
|
|
|
|
|
|
|
} |
75
|
49
|
|
|
|
|
84
|
return; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# At-rules. |
79
|
|
|
|
|
|
|
sub _put_at_rules { |
80
|
1
|
|
|
1
|
|
53
|
my ($self, $at_rule, $file) = @_; |
81
|
1
|
|
|
|
|
2
|
push @{$self->{'flush_code'}}, $at_rule.' "'.$file.'";'; |
|
1
|
|
|
|
|
6
|
|
82
|
1
|
|
|
|
|
3
|
$self->{'processed'} = 1; |
83
|
1
|
|
|
|
|
3
|
return; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# Comment. |
87
|
|
|
|
|
|
|
sub _put_comment { |
88
|
26
|
|
|
26
|
|
320
|
my ($self, @comments) = @_; |
89
|
26
|
100
|
|
|
|
67
|
if (! $self->{'skip_comments'}) { |
90
|
13
|
|
|
|
|
31
|
push @comments, $SPACE.$self->{'comment_delimeters'}->[1]; |
91
|
13
|
|
|
|
|
35
|
unshift @comments, $self->{'comment_delimeters'}->[0].$SPACE; |
92
|
13
|
100
|
|
|
|
34
|
if ($self->{'processed'}) { |
93
|
3
|
|
|
|
|
6
|
push @{$self->{'flush_code'}}, $EMPTY_STR; |
|
3
|
|
|
|
|
6
|
|
94
|
|
|
|
|
|
|
} |
95
|
13
|
|
|
|
|
30
|
my $comment = (join $EMPTY_STR, @comments); |
96
|
13
|
100
|
|
|
|
20
|
if (@{$self->{'tmp_code'}}) { |
|
13
|
|
|
|
|
32
|
|
97
|
4
|
|
|
|
|
7
|
my $sep = $EMPTY_STR; |
98
|
4
|
100
|
|
|
|
12
|
if ($self->{'comment_after_selector'} == 0) { |
99
|
3
|
|
|
|
|
6
|
$sep = $self->{'output_sep'}; |
100
|
3
|
|
|
|
|
4
|
pop @{$self->{'tmp_code'}}; |
|
3
|
|
|
|
|
6
|
|
101
|
|
|
|
|
|
|
} |
102
|
4
|
|
|
|
|
16
|
push @{$self->{'tmp_code'}}, ($sep) x 2, $comment, |
103
|
4
|
|
|
|
|
5
|
$self->{'output_sep'}; |
104
|
4
|
|
|
|
|
6
|
$self->{'comment_after_selector'} += 4; |
105
|
|
|
|
|
|
|
} else { |
106
|
9
|
|
|
|
|
26
|
push @{$self->{'flush_code'}}, |
107
|
9
|
|
|
|
|
13
|
$self->{'indent'}->get.$comment; |
108
|
|
|
|
|
|
|
} |
109
|
13
|
|
|
|
|
60
|
$self->{'processed'} = 0; |
110
|
|
|
|
|
|
|
} |
111
|
26
|
|
|
|
|
55
|
return; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Definition. |
115
|
|
|
|
|
|
|
sub _put_definition { |
116
|
20
|
|
|
20
|
|
381
|
my ($self, $key, $value) = @_; |
117
|
20
|
|
|
|
|
64
|
$self->_check_opened_selector; |
118
|
20
|
|
|
|
|
130
|
$self->_flush_tmp; |
119
|
20
|
|
|
|
|
31
|
push @{$self->{'flush_code'}}, $self->{'indent'}->get.$key.':'. |
|
20
|
|
|
|
|
60
|
|
120
|
|
|
|
|
|
|
$SPACE.$value.';'; |
121
|
20
|
|
|
|
|
119
|
$self->{'processed'} = 1; |
122
|
20
|
|
|
|
|
48
|
return; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# End of selector. |
126
|
|
|
|
|
|
|
sub _put_end_of_selector { |
127
|
30
|
|
|
30
|
|
543
|
my $self = shift; |
128
|
30
|
|
|
|
|
91
|
$self->_check_opened_selector; |
129
|
29
|
|
|
|
|
189
|
$self->_flush_tmp; |
130
|
29
|
|
|
|
|
87
|
$self->{'indent'}->remove; |
131
|
29
|
|
|
|
|
349
|
push @{$self->{'flush_code'}}, '}'; |
|
29
|
|
|
|
|
61
|
|
132
|
29
|
|
|
|
|
53
|
$self->{'open_selector'} = 0; |
133
|
29
|
|
|
|
|
47
|
$self->{'processed'} = 1; |
134
|
29
|
|
|
|
|
75
|
return; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# Instruction. |
138
|
|
|
|
|
|
|
sub _put_instruction { |
139
|
2
|
|
|
2
|
|
88
|
my ($self, $target, $code) = @_; |
140
|
2
|
|
|
|
|
8
|
$self->_put_comment($target, $code); |
141
|
2
|
|
|
|
|
17
|
return; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# Raw data. |
145
|
|
|
|
|
|
|
sub _put_raw { |
146
|
1
|
|
|
1
|
|
33
|
my ($self, @raw_data) = @_; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# To flush code. |
149
|
1
|
|
|
|
|
2
|
push @{$self->{'flush_code'}}, (join $EMPTY_STR, @raw_data); |
|
1
|
|
|
|
|
4
|
|
150
|
|
|
|
|
|
|
|
151
|
1
|
|
|
|
|
3
|
return; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# Selectors. |
155
|
|
|
|
|
|
|
sub _put_selector { |
156
|
34
|
|
|
34
|
|
4941
|
my ($self, $selector) = @_; |
157
|
34
|
|
|
|
|
66
|
push @{$self->{'tmp_code'}}, $selector, ',', ' '; |
|
34
|
|
|
|
|
130
|
|
158
|
34
|
|
|
|
|
73
|
$self->{'comment_after_selector'} = 0; |
159
|
34
|
|
|
|
|
55
|
$self->{'open_selector'} = 1; |
160
|
34
|
|
|
|
|
128
|
return; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
# Reset flush code. |
164
|
|
|
|
|
|
|
sub _reset_flush_code { |
165
|
39
|
|
|
39
|
|
358
|
my $self = shift; |
166
|
39
|
|
|
|
|
85
|
$self->{'flush_code'} = []; |
167
|
39
|
|
|
|
|
108
|
return; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
1; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
__END__ |