line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
19
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
144
|
|
2
|
3
|
|
|
3
|
|
26
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
136
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package |
5
|
|
|
|
|
|
|
XHTML::Instrumented::Context; |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
16
|
use Params::Validate; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
386
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new |
10
|
|
|
|
|
|
|
{ |
11
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
my %p = Params::Validate::validate( @_, { |
14
|
|
|
|
|
|
|
args => 0, |
15
|
|
|
|
|
|
|
data => 0, |
16
|
|
|
|
|
|
|
flags => 0, |
17
|
|
|
|
|
|
|
special => 0, |
18
|
|
|
|
|
|
|
loop => 0, |
19
|
|
|
|
|
|
|
start => 0, |
20
|
|
|
|
|
|
|
hash => 1, |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
); |
23
|
0
|
|
|
|
|
|
bless({ %p }, $class); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
3
|
|
|
3
|
|
17
|
use Data::Dumper; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
2827
|
|
27
|
|
|
|
|
|
|
sub copy |
28
|
|
|
|
|
|
|
{ |
29
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my %p = Params::Validate::validate( @_, { |
32
|
|
|
|
|
|
|
merge => 0, |
33
|
|
|
|
|
|
|
form => 0, |
34
|
|
|
|
|
|
|
loop => 0, |
35
|
|
|
|
|
|
|
count => 0, |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
); |
38
|
0
|
0
|
|
|
|
|
if ($p{form}) { |
39
|
|
|
|
|
|
|
#die 'form ', Dumper $p{form}; |
40
|
|
|
|
|
|
|
} |
41
|
0
|
0
|
|
|
|
|
if ($p{merge}) { |
42
|
0
|
|
|
|
|
|
my $merge = $p{merge}; |
43
|
0
|
|
|
|
|
|
die 'merge'; |
44
|
0
|
|
|
|
|
|
delete $p{merge}; |
45
|
0
|
|
|
|
|
|
$p{hash} = { %{$self->{hash}}, %$merge }; |
|
0
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
|
my $loop = $self->{loop}; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $copy = bless({ %$self, %p }, ref($self)); |
50
|
|
|
|
|
|
|
|
51
|
0
|
0
|
0
|
|
|
|
if ($loop && ($loop ne $copy->{loop})) { |
52
|
0
|
|
|
|
|
|
push(@{$copy->{loops}}, $loop); |
|
0
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$copy->{_xcount} = $loop->count + 1; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
$copy; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub get_form |
60
|
|
|
|
|
|
|
{ |
61
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
62
|
0
|
|
|
|
|
|
my $id = shift; |
63
|
0
|
|
|
|
|
|
my $ret; |
64
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
if (my $loop = $self->{loop}) { |
66
|
0
|
0
|
|
|
|
|
if ($loop->get_id($id)) { |
67
|
0
|
|
|
|
|
|
$ret = $loop->get_id($id)->_control; |
68
|
0
|
0
|
0
|
|
|
|
if (my $count = $self->{count} && $ret) { |
69
|
0
|
|
|
|
|
|
$ret->set_id_count($count); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
0
|
0
|
|
|
|
|
if (!$ret) { |
74
|
0
|
0
|
|
|
|
|
if (UNIVERSAL::isa($self->{hash}{$id}, 'XHTML::Instrumented::Form')) { |
75
|
0
|
|
|
|
|
|
$ret = $self->{hash}{$id}->_control; |
76
|
0
|
0
|
0
|
|
|
|
if (my $count = $self->{count} && $ret) { |
77
|
0
|
|
|
|
|
|
$ret->set_id_count($count); |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
} else { |
80
|
0
|
|
|
|
|
|
warn $id, ' is not a form'; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
0
|
0
|
0
|
|
|
|
if ($ret && !$ret->is_form) { |
84
|
0
|
|
|
|
|
|
warn $id, ' is not a form'; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
return $ret; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub get_name |
91
|
|
|
|
|
|
|
{ |
92
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
93
|
0
|
|
|
|
|
|
my $name = shift; |
94
|
0
|
|
|
|
|
|
my $control = shift; |
95
|
0
|
|
|
|
|
|
my $ret; |
96
|
|
|
|
|
|
|
|
97
|
0
|
0
|
|
|
|
|
if (my $form = $self->{form}) { |
98
|
0
|
|
|
|
|
|
$ret = $form->get_element($name); |
99
|
|
|
|
|
|
|
} else { |
100
|
|
|
|
|
|
|
# this in normal |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
|
if ($ret) { |
104
|
0
|
|
|
|
|
|
$ret->{control} = $control; |
105
|
0
|
0
|
|
|
|
|
if ($self->{loop}) { |
106
|
0
|
|
|
|
|
|
$self->set_count($ret); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
|
$ret || $control; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub set_count |
114
|
|
|
|
|
|
|
{ |
115
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
116
|
0
|
|
|
|
|
|
my $ret = shift; |
117
|
|
|
|
|
|
|
|
118
|
0
|
0
|
|
|
|
|
die caller unless $self->{loop}; |
119
|
0
|
0
|
|
|
|
|
die caller unless $ret->isa('XHTML::Instrumented::Control'); |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
my $cnt = $self->{loop}->count + 1; |
122
|
|
|
|
|
|
|
|
123
|
0
|
0
|
|
|
|
|
if (my $x = $self->{_xcount}) { |
124
|
0
|
|
|
|
|
|
$cnt = $x . '.' . $cnt; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
0
|
|
|
|
|
|
$ret->set_id_count( $cnt ); |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub get_id |
131
|
|
|
|
|
|
|
{ |
132
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
133
|
0
|
|
|
|
|
|
my $id = shift; |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
my $ret; |
136
|
|
|
|
|
|
|
|
137
|
0
|
0
|
|
|
|
|
if (my $loop = $self->{loop}) { |
|
|
0
|
|
|
|
|
|
138
|
0
|
|
|
|
|
|
$ret = $loop->get_id($id); |
139
|
|
|
|
|
|
|
|
140
|
0
|
0
|
|
|
|
|
if (ref($ret)) { |
141
|
0
|
0
|
|
|
|
|
if (my $name = $ret->{args}{name}) { |
142
|
0
|
|
|
|
|
|
$self->{name} = $name; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
} elsif (my $form = $self->{form}) { |
146
|
0
|
|
|
|
|
|
my $name = $form->{_ids_}{$id}; |
147
|
0
|
|
|
|
|
|
my $tmp = $self->{hash}{$id}; |
148
|
0
|
0
|
|
|
|
|
$ret = $form->get_element($name) if $name; |
149
|
0
|
0
|
|
|
|
|
if ($ret) { |
150
|
0
|
0
|
0
|
|
|
|
if ($tmp && $tmp != $ret) { |
151
|
0
|
|
|
|
|
|
die "$tmp $ret"; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
} else { |
154
|
0
|
|
|
|
|
|
$ret = $tmp; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
} else { |
157
|
0
|
|
|
|
|
|
$ret = $self->{hash}{$id}; |
158
|
|
|
|
|
|
|
} |
159
|
0
|
0
|
|
|
|
|
if (defined($ret)) { |
160
|
0
|
0
|
|
|
|
|
if (!ref($ret)) { |
161
|
0
|
|
|
|
|
|
$ret = XHTML::Instrumented::Control->new(text => $ret); |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
} |
164
|
0
|
|
0
|
|
|
|
$ret ||= XHTML::Instrumented::Control::Dummy->new(); |
165
|
|
|
|
|
|
|
|
166
|
0
|
0
|
0
|
|
|
|
if ($self->{loop} && $ret) { |
167
|
0
|
|
|
|
|
|
$self->set_count($ret); |
168
|
|
|
|
|
|
|
} |
169
|
3
|
|
|
3
|
|
21
|
use Data::Dumper; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
878
|
|
170
|
0
|
0
|
|
|
|
|
die "bad control ($id)" . Dumper $self unless UNIVERSAL::isa($ret, 'XHTML::Instrumented::Control'); |
171
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
return $ret; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub inc_loop |
176
|
|
|
|
|
|
|
{ |
177
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
178
|
|
|
|
|
|
|
|
179
|
0
|
0
|
|
|
|
|
if (my $loop = $self->{loop}) { |
180
|
0
|
|
|
|
|
|
$loop->inc; |
181
|
|
|
|
|
|
|
} else { |
182
|
0
|
|
|
|
|
|
warn 'Not in loop'; |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
1; |
187
|
|
|
|
|
|
|
__END__ |