| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
3
|
|
|
3
|
|
18
|
use strict; |
|
|
3
|
|
|
|
|
4
|
|
|
|
3
|
|
|
|
|
94
|
|
|
2
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
95
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package |
|
5
|
|
|
|
|
|
|
XHTML::Instrumented::Entry; |
|
6
|
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1953
|
use XHTML::Instrumented::Control; |
|
|
3
|
|
|
|
|
9
|
|
|
|
3
|
|
|
|
|
94
|
|
|
8
|
3
|
|
|
3
|
|
18
|
use Params::Validate qw(validate HASHREF); |
|
|
3
|
|
|
|
|
6
|
|
|
|
3
|
|
|
|
|
4985
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our @unused; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new |
|
13
|
|
|
|
|
|
|
{ |
|
14
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
15
|
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my %p = Params::Validate::validate( @_, { |
|
17
|
|
|
|
|
|
|
args => HASHREF, |
|
18
|
|
|
|
|
|
|
flags => HASHREF, |
|
19
|
|
|
|
|
|
|
tag => 1, |
|
20
|
|
|
|
|
|
|
id => 0, |
|
21
|
|
|
|
|
|
|
name => 0, |
|
22
|
|
|
|
|
|
|
data => 0, |
|
23
|
|
|
|
|
|
|
for => 0, |
|
24
|
|
|
|
|
|
|
# ids => HASHREF, |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
); |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
bless({ data => [], %p }, $class); |
|
29
|
|
|
|
|
|
|
} |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub copy() |
|
32
|
|
|
|
|
|
|
{ |
|
33
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
34
|
0
|
|
|
|
|
|
my %p = Params::Validate::validate( @_, { |
|
35
|
|
|
|
|
|
|
args => 0, |
|
36
|
|
|
|
|
|
|
control => { optional => 1, isa => 'XHTML::Instrumented::Control' }, |
|
37
|
|
|
|
|
|
|
data => 0, |
|
38
|
|
|
|
|
|
|
extra => 0, |
|
39
|
|
|
|
|
|
|
flags => 0, |
|
40
|
|
|
|
|
|
|
form => 0, |
|
41
|
|
|
|
|
|
|
id => 0, |
|
42
|
|
|
|
|
|
|
special => 0, |
|
43
|
|
|
|
|
|
|
tag => 0, |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
); |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
bless({ |
|
48
|
|
|
|
|
|
|
date => [], |
|
49
|
0
|
|
|
|
|
|
%{$self}, |
|
50
|
0
|
|
|
|
|
|
args => {%{$self->{args}}}, |
|
51
|
|
|
|
|
|
|
%p |
|
52
|
|
|
|
|
|
|
}, ref($self)); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub split_char |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
0
|
|
|
0
|
1
|
|
'\.'; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub child |
|
61
|
|
|
|
|
|
|
{ |
|
62
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
63
|
0
|
|
|
|
|
|
my %p = Params::Validate::validate(@_, |
|
64
|
|
|
|
|
|
|
{ |
|
65
|
|
|
|
|
|
|
args => 1, |
|
66
|
|
|
|
|
|
|
tag => 1, |
|
67
|
|
|
|
|
|
|
form => 0, |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
); |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
my $args = $p{args}; |
|
72
|
0
|
|
|
|
|
|
my $id; |
|
73
|
|
|
|
|
|
|
my $for; |
|
74
|
0
|
|
|
|
|
|
my @flags; |
|
75
|
0
|
0
|
|
|
|
|
if (my $id_full = $args->{id}) { |
|
76
|
0
|
|
|
|
|
|
($id, @flags) = split($self->split_char, $id_full); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
0
|
0
|
|
|
|
|
if (my $id_full = $args->{for}) { |
|
79
|
0
|
|
|
|
|
|
my @fflags; |
|
80
|
0
|
|
|
|
|
|
($for, @fflags) = split($self->split_char, $id_full); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my $ret = ref($self)->new( |
|
84
|
|
|
|
|
|
|
%p, |
|
85
|
0
|
|
|
|
|
|
flags => { map({ my ($x, @x) = split(':', $_); $x => [@x]} @flags) }, |
|
|
0
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
id => $id, |
|
87
|
|
|
|
|
|
|
name => $args->{name}, |
|
88
|
|
|
|
|
|
|
('for' => $for) x!! $for, |
|
89
|
|
|
|
|
|
|
); |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
return $ret; |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub prepend |
|
95
|
|
|
|
|
|
|
{ |
|
96
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
for my $child (@_) { |
|
99
|
0
|
|
|
|
|
|
unshift(@{$self->{data}}, $child); |
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub id |
|
104
|
|
|
|
|
|
|
{ |
|
105
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
106
|
0
|
|
|
|
|
|
$self->{id}; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub name |
|
110
|
|
|
|
|
|
|
{ |
|
111
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
112
|
0
|
|
|
|
|
|
$self->{name}; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# elements that have no id or name can be converted to text here |
|
116
|
|
|
|
|
|
|
# or that can happen latter. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub append |
|
119
|
|
|
|
|
|
|
{ |
|
120
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
for my $child (@_) { |
|
123
|
0
|
|
|
|
|
|
push(@{$self->{data}}, $child); |
|
|
0
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
return; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# accesor methods |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub context |
|
132
|
|
|
|
|
|
|
{ |
|
133
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
134
|
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
die caller; |
|
136
|
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
$self->{contextu}; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub tag |
|
141
|
|
|
|
|
|
|
{ |
|
142
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
143
|
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
$self->{tag}; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub args |
|
148
|
|
|
|
|
|
|
{ |
|
149
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
150
|
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
%{$self->{args}}; |
|
|
0
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
} |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub flags |
|
155
|
|
|
|
|
|
|
{ |
|
156
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
157
|
|
|
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
$self->{flags}; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# methods |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub are_if |
|
164
|
|
|
|
|
|
|
{ |
|
165
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
0
|
|
|
|
|
exists $self->{flags}{eq} || exists $self->{flags}{if}; |
|
168
|
|
|
|
|
|
|
} |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub if |
|
171
|
|
|
|
|
|
|
{ |
|
172
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
173
|
0
|
|
|
|
|
|
my $ret = 1; |
|
174
|
|
|
|
|
|
|
|
|
175
|
0
|
0
|
|
|
|
|
if (exists $self->{flags}{eq}) { |
|
176
|
0
|
|
|
|
|
|
$ret = $self->control->eq(@{$self->{flags}{eq}}); |
|
|
0
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
} |
|
178
|
0
|
0
|
|
|
|
|
if (exists $self->{flags}{if}) { |
|
179
|
0
|
|
|
|
|
|
$ret = $self->control->if; |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
return $ret; |
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub control |
|
186
|
|
|
|
|
|
|
{ |
|
187
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
188
|
|
|
|
|
|
|
|
|
189
|
0
|
0
|
|
|
|
|
$self->{control} or die; |
|
190
|
|
|
|
|
|
|
} |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub children |
|
193
|
|
|
|
|
|
|
{ |
|
194
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
195
|
0
|
|
|
|
|
|
my @ret; |
|
196
|
0
|
|
|
|
|
|
my %p = Params::Validate::validate( @_, { |
|
197
|
|
|
|
|
|
|
context => { isa => 'XHTML::Instrumented::Context' }, |
|
198
|
|
|
|
|
|
|
} |
|
199
|
|
|
|
|
|
|
); |
|
200
|
|
|
|
|
|
|
|
|
201
|
0
|
|
|
|
|
|
return @{$self->{data}}; |
|
|
0
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
} |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# we enter here with the complete parsed datastructure. |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
sub is_form |
|
207
|
|
|
|
|
|
|
{ |
|
208
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
209
|
|
|
|
|
|
|
|
|
210
|
0
|
|
|
|
|
|
$self->{tag} eq 'form'; |
|
211
|
|
|
|
|
|
|
} |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub is_label |
|
214
|
|
|
|
|
|
|
{ |
|
215
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
216
|
0
|
|
|
|
|
|
$self->{tag} eq 'label'; |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub expand |
|
220
|
|
|
|
|
|
|
{ |
|
221
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
222
|
|
|
|
|
|
|
|
|
223
|
0
|
|
|
|
|
|
my %p = Params::Validate::validate( @_, { |
|
224
|
|
|
|
|
|
|
context => { isa => 'XHTML::Instrumented::Context' }, |
|
225
|
|
|
|
|
|
|
} |
|
226
|
|
|
|
|
|
|
); |
|
227
|
0
|
|
|
|
|
|
my $context = $p{context}; |
|
228
|
|
|
|
|
|
|
|
|
229
|
0
|
|
|
|
|
|
my @ret; |
|
230
|
|
|
|
|
|
|
my $control; |
|
231
|
|
|
|
|
|
|
|
|
232
|
0
|
0
|
|
|
|
|
if ($self->{args}{class}) { |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
} |
|
235
|
|
|
|
|
|
|
|
|
236
|
0
|
|
|
|
|
|
my $id; |
|
237
|
|
|
|
|
|
|
|
|
238
|
0
|
0
|
0
|
|
|
|
if ($self->name || $self->id) { |
|
239
|
0
|
0
|
|
|
|
|
if ($self->is_form) { |
|
240
|
0
|
0
|
|
|
|
|
if (my $name = $self->name) { |
|
241
|
0
|
|
|
|
|
|
$control = $context->get_form($name); |
|
242
|
0
|
|
|
|
|
|
$id = $name; |
|
243
|
0
|
0
|
|
|
|
|
if ($control) { |
|
244
|
0
|
|
|
|
|
|
$control->{id} = $id; |
|
245
|
0
|
|
|
|
|
|
$control->{_ids_} = $self->{_ids_}; |
|
246
|
0
|
|
|
|
|
|
$control->{_names_} = $self->{_names_}; |
|
247
|
|
|
|
|
|
|
} |
|
248
|
|
|
|
|
|
|
} |
|
249
|
0
|
|
|
|
|
|
$context = $context->copy(form => $control); |
|
250
|
0
|
0
|
|
|
|
|
if ($control) { |
|
251
|
0
|
0
|
|
|
|
|
die unless $control->is_form; |
|
252
|
|
|
|
|
|
|
} |
|
253
|
|
|
|
|
|
|
} else { |
|
254
|
0
|
0
|
|
|
|
|
if (my $id = $self->id) { |
|
255
|
0
|
|
|
|
|
|
$control = $context->get_id($id); |
|
256
|
0
|
0
|
|
|
|
|
if ($control->has_name) { |
|
257
|
0
|
|
|
|
|
|
$self->{name} = $control->name; |
|
258
|
|
|
|
|
|
|
} |
|
259
|
0
|
0
|
|
|
|
|
if (ref $control eq 'XHTML::Instrumented::Control::Dummy') { |
|
260
|
0
|
|
|
|
|
|
$control = $context->get_name($id, $control); |
|
261
|
|
|
|
|
|
|
} |
|
262
|
|
|
|
|
|
|
} |
|
263
|
0
|
0
|
|
|
|
|
if (my $name = $self->name) { |
|
264
|
0
|
|
|
|
|
|
$control = $context->get_name($name, $control); |
|
265
|
|
|
|
|
|
|
} |
|
266
|
|
|
|
|
|
|
} |
|
267
|
0
|
|
0
|
|
|
|
$control ||= $context->get_id('__dummy__'); |
|
268
|
|
|
|
|
|
|
} else { |
|
269
|
0
|
|
|
|
|
|
$control = $context->get_id('__dummy__'); |
|
270
|
|
|
|
|
|
|
} |
|
271
|
|
|
|
|
|
|
|
|
272
|
0
|
|
|
|
|
|
$control->set_tag( |
|
273
|
|
|
|
|
|
|
tag => $self->{tag}, |
|
274
|
|
|
|
|
|
|
args => $self->{args}, |
|
275
|
|
|
|
|
|
|
); |
|
276
|
0
|
0
|
|
|
|
|
die unless $control; |
|
277
|
|
|
|
|
|
|
|
|
278
|
0
|
0
|
|
|
|
|
die "no control ($id)" . $control unless UNIVERSAL::isa($control, 'XHTML::Instrumented::Control'); |
|
279
|
|
|
|
|
|
|
|
|
280
|
0
|
|
|
|
|
|
$self->{control} = $control; |
|
281
|
|
|
|
|
|
|
|
|
282
|
0
|
|
|
|
|
|
my $if = $self->if; |
|
283
|
0
|
0
|
|
|
|
|
if ($self->{args}{class}) { |
|
284
|
0
|
0
|
|
|
|
|
if (grep({ $_ eq ':even'} split('\s', $self->{args}{class}))) { |
|
|
0
|
|
|
|
|
|
|
|
285
|
0
|
0
|
|
|
|
|
if ($context->{loop}->count % 2 == 0) { |
|
286
|
0
|
|
|
|
|
|
$if = 0; |
|
287
|
|
|
|
|
|
|
} |
|
288
|
|
|
|
|
|
|
} |
|
289
|
0
|
0
|
|
|
|
|
if (grep({ $_ eq ':odd'} split('\s', $self->{args}{class}))) { |
|
|
0
|
|
|
|
|
|
|
|
290
|
0
|
0
|
|
|
|
|
if ($context->{loop}->count % 2 == 1) { |
|
291
|
0
|
|
|
|
|
|
$if = 0; |
|
292
|
|
|
|
|
|
|
} |
|
293
|
|
|
|
|
|
|
} |
|
294
|
|
|
|
|
|
|
} |
|
295
|
|
|
|
|
|
|
|
|
296
|
0
|
0
|
|
|
|
|
if ($self->are_if) { |
|
297
|
0
|
|
|
|
|
|
$self->{control} = $control = XHTML::Instrumented::Control::Dummy->new(id_count => $control->{id_count}); |
|
298
|
|
|
|
|
|
|
} |
|
299
|
|
|
|
|
|
|
|
|
300
|
0
|
0
|
|
|
|
|
if ($if) { |
|
301
|
0
|
0
|
|
|
|
|
if ($self->is_label) { |
|
302
|
0
|
0
|
|
|
|
|
if (my $for = $self->{for}) { |
|
303
|
0
|
|
|
|
|
|
my $control = $context->get_id($for); |
|
304
|
0
|
0
|
|
|
|
|
if ($control->required) { |
|
305
|
0
|
|
|
|
|
|
$self->{args}{style} .= "color: red;"; |
|
306
|
|
|
|
|
|
|
} |
|
307
|
|
|
|
|
|
|
} |
|
308
|
|
|
|
|
|
|
} |
|
309
|
|
|
|
|
|
|
|
|
310
|
0
|
|
|
|
|
|
my @asdf = $control->to_text( |
|
311
|
|
|
|
|
|
|
tag => $self->{tag}, |
|
312
|
|
|
|
|
|
|
children => [ $self->children(context => $context->copy(form => $control->form)) ], |
|
313
|
|
|
|
|
|
|
args => { $self->args }, |
|
314
|
|
|
|
|
|
|
flags => $self->flags, |
|
315
|
|
|
|
|
|
|
context => $context, |
|
316
|
|
|
|
|
|
|
(special => $self->{flags}{sp}) x!! defined $self->{flags}{sp}, |
|
317
|
|
|
|
|
|
|
); |
|
318
|
|
|
|
|
|
|
|
|
319
|
0
|
|
|
|
|
|
for (@asdf) { |
|
320
|
3
|
|
|
3
|
|
23
|
use Data::Dumper; |
|
|
3
|
|
|
|
|
5
|
|
|
|
3
|
|
|
|
|
779
|
|
|
321
|
0
|
0
|
|
|
|
|
warn Dumper $control, \@asdf unless defined $_; |
|
322
|
|
|
|
|
|
|
} |
|
323
|
|
|
|
|
|
|
|
|
324
|
0
|
|
|
|
|
|
push(@ret, @asdf); |
|
325
|
|
|
|
|
|
|
} else { |
|
326
|
0
|
|
|
|
|
|
my $tag = $self->{tag}; |
|
327
|
0
|
|
|
|
|
|
push(@ret, ""); # Fixme need verbose flag |
|
328
|
|
|
|
|
|
|
} |
|
329
|
|
|
|
|
|
|
|
|
330
|
0
|
0
|
|
|
|
|
if ($self->{args}{class}) { |
|
331
|
0
|
0
|
|
|
|
|
if (grep({ $_ eq ':data'} split('\s', $self->{args}{class}))) { |
|
|
0
|
|
|
|
|
|
|
|
332
|
0
|
|
|
|
|
|
$context->inc_loop; |
|
333
|
|
|
|
|
|
|
} |
|
334
|
|
|
|
|
|
|
} |
|
335
|
|
|
|
|
|
|
|
|
336
|
0
|
|
|
|
|
|
join('', @ret); |
|
337
|
|
|
|
|
|
|
} |
|
338
|
|
|
|
|
|
|
|
|
339
|
|
|
|
|
|
|
1; |
|
340
|
|
|
|
|
|
|
__END__ |