line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CSS::Struct::Output::Indent; |
2
|
|
|
|
|
|
|
|
3
|
14
|
|
|
14
|
|
82028
|
use base qw(CSS::Struct::Output); |
|
14
|
|
|
|
|
101
|
|
|
14
|
|
|
|
|
7945
|
|
4
|
14
|
|
|
14
|
|
456610
|
use strict; |
|
14
|
|
|
|
|
35
|
|
|
14
|
|
|
|
|
307
|
|
5
|
14
|
|
|
14
|
|
72
|
use warnings; |
|
14
|
|
|
|
|
31
|
|
|
14
|
|
|
|
|
345
|
|
6
|
|
|
|
|
|
|
|
7
|
14
|
|
|
14
|
|
7262
|
use Indent; |
|
14
|
|
|
|
|
9535
|
|
|
14
|
|
|
|
|
421
|
|
8
|
14
|
|
|
14
|
|
96
|
use Readonly; |
|
14
|
|
|
|
|
29
|
|
|
14
|
|
|
|
|
13660
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# Constants. |
11
|
|
|
|
|
|
|
Readonly::Scalar my $EMPTY_STR => q{}; |
12
|
|
|
|
|
|
|
Readonly::Scalar my $SPACE => q{ }; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = 0.02; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Resets internal variables. |
17
|
|
|
|
|
|
|
sub reset { |
18
|
38
|
|
|
38
|
1
|
20769
|
my $self = shift; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Reset internal variables from *::Core. |
21
|
38
|
|
|
|
|
170
|
$self->SUPER::reset; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# Comment after selector. |
24
|
38
|
|
|
|
|
178
|
$self->{'comment_after_selector'} = 0; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# Indent object. |
27
|
|
|
|
|
|
|
$self->{'indent'} = Indent->new( |
28
|
38
|
|
|
|
|
188
|
'next_indent' => $self->{'next_indent'}, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Any processed selector. |
32
|
38
|
|
|
|
|
1229
|
$self->{'processed'} = 0; |
33
|
|
|
|
|
|
|
|
34
|
38
|
|
|
|
|
87
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Default parameters. |
38
|
|
|
|
|
|
|
sub _default_parameters { |
39
|
23
|
|
|
23
|
|
34613
|
my $self = shift; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# Default parameters from SUPER. |
42
|
23
|
|
|
|
|
185
|
$self->SUPER::_default_parameters; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Indent string. |
45
|
23
|
|
|
|
|
432
|
$self->{'next_indent'} = "\t"; |
46
|
|
|
|
|
|
|
|
47
|
23
|
|
|
|
|
52
|
return; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Flush $self->{'tmp_code'}. |
51
|
|
|
|
|
|
|
sub _flush_tmp { |
52
|
49
|
|
|
49
|
|
75
|
my $self = shift; |
53
|
49
|
100
|
|
|
|
71
|
if (@{$self->{'tmp_code'}}) { |
|
49
|
|
|
|
|
141
|
|
54
|
29
|
|
|
|
|
103
|
$self->{'indent'}->add; |
55
|
29
|
|
|
|
|
251
|
my @comment; |
56
|
29
|
100
|
|
|
|
71
|
if ($self->{'comment_after_selector'}) { |
57
|
2
|
|
|
|
|
8
|
@comment = splice @{$self->{'tmp_code'}}, |
58
|
2
|
|
|
|
|
3
|
-$self->{'comment_after_selector'}; |
59
|
2
|
|
|
|
|
4
|
pop @comment; |
60
|
2
|
|
|
|
|
5
|
foreach my $com (@comment) { |
61
|
10
|
100
|
100
|
|
|
38
|
if ($com ne $EMPTY_STR && $com ne "\n") { |
62
|
3
|
|
|
|
|
7
|
$com = $self->{'indent'}->get.$com; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} else { |
66
|
27
|
|
|
|
|
43
|
pop @{$self->{'tmp_code'}}; |
|
27
|
|
|
|
|
52
|
|
67
|
|
|
|
|
|
|
} |
68
|
29
|
|
|
|
|
58
|
pop @{$self->{'tmp_code'}}; |
|
29
|
|
|
|
|
56
|
|
69
|
29
|
|
|
|
|
49
|
push @{$self->{'flush_code'}}, |
70
|
29
|
|
|
|
|
47
|
(join $EMPTY_STR, @{$self->{'tmp_code'}}).' {'. |
|
29
|
|
|
|
|
109
|
|
71
|
|
|
|
|
|
|
(join $EMPTY_STR, @comment); |
72
|
29
|
|
|
|
|
62
|
$self->{'tmp_code'} = []; |
73
|
29
|
|
|
|
|
57
|
$self->{'processed'} = 1; |
74
|
|
|
|
|
|
|
} |
75
|
49
|
|
|
|
|
107
|
return; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# At-rules. |
79
|
|
|
|
|
|
|
sub _put_at_rules { |
80
|
1
|
|
|
1
|
|
43
|
my ($self, $at_rule, $file) = @_; |
81
|
1
|
|
|
|
|
3
|
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
|
|
306
|
my ($self, @comments) = @_; |
89
|
26
|
100
|
|
|
|
69
|
if (! $self->{'skip_comments'}) { |
90
|
13
|
|
|
|
|
32
|
push @comments, $SPACE.$self->{'comment_delimeters'}->[1]; |
91
|
13
|
|
|
|
|
33
|
unshift @comments, $self->{'comment_delimeters'}->[0].$SPACE; |
92
|
13
|
100
|
|
|
|
33
|
if ($self->{'processed'}) { |
93
|
3
|
|
|
|
|
6
|
push @{$self->{'flush_code'}}, $EMPTY_STR; |
|
3
|
|
|
|
|
7
|
|
94
|
|
|
|
|
|
|
} |
95
|
13
|
|
|
|
|
31
|
my $comment = (join $EMPTY_STR, @comments); |
96
|
13
|
100
|
|
|
|
20
|
if (@{$self->{'tmp_code'}}) { |
|
13
|
|
|
|
|
30
|
|
97
|
4
|
|
|
|
|
5
|
my $sep = $EMPTY_STR; |
98
|
4
|
100
|
|
|
|
13
|
if ($self->{'comment_after_selector'} == 0) { |
99
|
3
|
|
|
|
|
4
|
$sep = $self->{'output_sep'}; |
100
|
3
|
|
|
|
|
6
|
pop @{$self->{'tmp_code'}}; |
|
3
|
|
|
|
|
5
|
|
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
|
|
|
|
|
28
|
push @{$self->{'flush_code'}}, |
107
|
9
|
|
|
|
|
17
|
$self->{'indent'}->get.$comment; |
108
|
|
|
|
|
|
|
} |
109
|
13
|
|
|
|
|
56
|
$self->{'processed'} = 0; |
110
|
|
|
|
|
|
|
} |
111
|
26
|
|
|
|
|
56
|
return; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Definition. |
115
|
|
|
|
|
|
|
sub _put_definition { |
116
|
20
|
|
|
20
|
|
368
|
my ($self, $key, $value) = @_; |
117
|
20
|
|
|
|
|
67
|
$self->_check_opened_selector; |
118
|
20
|
|
|
|
|
137
|
$self->_flush_tmp; |
119
|
20
|
|
|
|
|
31
|
push @{$self->{'flush_code'}}, $self->{'indent'}->get.$key.':'. |
|
20
|
|
|
|
|
65
|
|
120
|
|
|
|
|
|
|
$SPACE.$value.';'; |
121
|
20
|
|
|
|
|
131
|
$self->{'processed'} = 1; |
122
|
20
|
|
|
|
|
50
|
return; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
# End of selector. |
126
|
|
|
|
|
|
|
sub _put_end_of_selector { |
127
|
30
|
|
|
30
|
|
564
|
my $self = shift; |
128
|
30
|
|
|
|
|
91
|
$self->_check_opened_selector; |
129
|
29
|
|
|
|
|
181
|
$self->_flush_tmp; |
130
|
29
|
|
|
|
|
89
|
$self->{'indent'}->remove; |
131
|
29
|
|
|
|
|
351
|
push @{$self->{'flush_code'}}, '}'; |
|
29
|
|
|
|
|
63
|
|
132
|
29
|
|
|
|
|
64
|
$self->{'open_selector'} = 0; |
133
|
29
|
|
|
|
|
51
|
$self->{'processed'} = 1; |
134
|
29
|
|
|
|
|
64
|
return; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# Instruction. |
138
|
|
|
|
|
|
|
sub _put_instruction { |
139
|
2
|
|
|
2
|
|
92
|
my ($self, $target, $code) = @_; |
140
|
2
|
|
|
|
|
9
|
$self->_put_comment($target, $code); |
141
|
2
|
|
|
|
|
16
|
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
|
|
|
|
|
3
|
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
|
|
5050
|
my ($self, $selector) = @_; |
157
|
34
|
|
|
|
|
69
|
push @{$self->{'tmp_code'}}, $selector, ',', ' '; |
|
34
|
|
|
|
|
116
|
|
158
|
34
|
|
|
|
|
68
|
$self->{'comment_after_selector'} = 0; |
159
|
34
|
|
|
|
|
78
|
$self->{'open_selector'} = 1; |
160
|
34
|
|
|
|
|
116
|
return; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
# Reset flush code. |
164
|
|
|
|
|
|
|
sub _reset_flush_code { |
165
|
39
|
|
|
39
|
|
352
|
my $self = shift; |
166
|
39
|
|
|
|
|
93
|
$self->{'flush_code'} = []; |
167
|
39
|
|
|
|
|
85
|
return; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
1; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
__END__ |