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