line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Apache2::ASP::ASPDOM::Node; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
607
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings 'all'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
41
|
|
6
|
1
|
|
|
1
|
|
4
|
use Carp 'confess'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
7
|
1
|
|
|
1
|
|
4
|
use Scalar::Util 'weaken'; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
581
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#============================================================================== |
11
|
|
|
|
|
|
|
sub new |
12
|
|
|
|
|
|
|
{ |
13
|
113
|
|
|
113
|
0
|
798
|
my ($class, %args) = @_; |
14
|
|
|
|
|
|
|
|
15
|
113
|
|
|
|
|
362
|
my $s = bless { |
16
|
|
|
|
|
|
|
%args, |
17
|
|
|
|
|
|
|
childNodes => [ ], |
18
|
|
|
|
|
|
|
events => { |
19
|
|
|
|
|
|
|
before_appendChild => [ ], |
20
|
|
|
|
|
|
|
after_appendChild => [ ], |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
}, $class; |
23
|
113
|
50
|
|
|
|
173
|
weaken($s->{parentNode}) if $s->{parentNode}; |
24
|
113
|
|
|
|
|
170
|
return $s; |
25
|
|
|
|
|
|
|
}# end new() |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#============================================================================== |
29
|
6800
|
|
|
6800
|
0
|
7933
|
sub id { $_[0]->{id} } |
30
|
0
|
|
|
0
|
0
|
0
|
sub tagName { $_[0]->{tagName} } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
#============================================================================== |
34
|
|
|
|
|
|
|
sub addHandler |
35
|
|
|
|
|
|
|
{ |
36
|
6
|
|
|
6
|
0
|
643
|
my ($s, $event, $code) = @_; |
37
|
|
|
|
|
|
|
|
38
|
6
|
50
|
|
|
|
11
|
confess "Unknown event '$event'" unless exists($s->{events}->{$event}); |
39
|
|
|
|
|
|
|
|
40
|
6
|
100
|
|
|
|
5
|
return if grep { "$_" eq "$code" } @{$s->{events}->{$event}}; |
|
4
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
12
|
|
41
|
2
|
|
|
|
|
3
|
push @{$s->{events}->{$event}}, $code; |
|
2
|
|
|
|
|
3
|
|
42
|
|
|
|
|
|
|
}# end addHandler() |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
#============================================================================== |
46
|
|
|
|
|
|
|
sub removeHandler |
47
|
|
|
|
|
|
|
{ |
48
|
2
|
|
|
2
|
0
|
358
|
my ($s, $event, $code) = @_; |
49
|
|
|
|
|
|
|
|
50
|
2
|
50
|
|
|
|
5
|
confess "Unknown event '$event'" unless exists($s->{events}->{$event}); |
51
|
|
|
|
|
|
|
|
52
|
2
|
|
|
|
|
2
|
for( 0...@{$s->{events}->{$event}} - 1 ) |
|
2
|
|
|
|
|
5
|
|
53
|
|
|
|
|
|
|
{ |
54
|
2
|
50
|
|
|
|
6
|
splice( @{$s->{events}->{$event}}, $_, 1 ) |
|
2
|
|
|
|
|
6
|
|
55
|
|
|
|
|
|
|
if "$s->{events}->{$event}->[$_]" eq "$code"; |
56
|
|
|
|
|
|
|
}# end for() |
57
|
|
|
|
|
|
|
}# end addHandler() |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
#============================================================================== |
61
|
|
|
|
|
|
|
sub childNodes |
62
|
|
|
|
|
|
|
{ |
63
|
10428
|
100
|
|
10428
|
0
|
8128
|
@{$_[0]->{childNodes}} or return; |
|
10428
|
|
|
|
|
17620
|
|
64
|
1428
|
|
|
|
|
887
|
@{$_[0]->{childNodes}} |
|
1428
|
|
|
|
|
1688
|
|
65
|
|
|
|
|
|
|
}# end childNodes() |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
#============================================================================== |
69
|
|
|
|
|
|
|
sub parentNode |
70
|
|
|
|
|
|
|
{ |
71
|
112
|
|
|
112
|
0
|
71
|
my $s = shift; |
72
|
|
|
|
|
|
|
|
73
|
112
|
50
|
|
|
|
223
|
@_ ? weaken($s->{parentNode} = shift) : $s->{parentNode}; |
74
|
|
|
|
|
|
|
}# end parentNode() |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
#============================================================================== |
78
|
|
|
|
|
|
|
sub appendChild |
79
|
|
|
|
|
|
|
{ |
80
|
112
|
|
|
112
|
0
|
82
|
my ($s, $child) = @_; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# Call "before" handlers? |
83
|
112
|
|
|
|
|
70
|
foreach( @{$s->{events}->{before_appendChild}} ) |
|
112
|
|
|
|
|
128
|
|
84
|
|
|
|
|
|
|
{ |
85
|
2
|
|
|
|
|
7
|
local $SIG{__DIE__} = \&confess; |
86
|
2
|
|
|
|
|
4
|
$_->( $s, $child ); |
87
|
|
|
|
|
|
|
}# end foreach() |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# Add the child: |
90
|
112
|
|
|
|
|
673
|
$child->parentNode( $s ); |
91
|
112
|
|
|
|
|
63
|
push @{$s->{childNodes}}, $child; |
|
112
|
|
|
|
|
107
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
# Call "after" handlers?: |
94
|
112
|
|
|
|
|
73
|
foreach( @{$s->{events}->{after_appendChild}} ) |
|
112
|
|
|
|
|
116
|
|
95
|
|
|
|
|
|
|
{ |
96
|
0
|
|
|
|
|
0
|
local $SIG{__DIE__} = \&confess; |
97
|
0
|
|
|
|
|
0
|
$_->( $s, $child ); |
98
|
|
|
|
|
|
|
}# end foreach() |
99
|
|
|
|
|
|
|
|
100
|
112
|
|
|
|
|
107
|
$child; |
101
|
|
|
|
|
|
|
}# end appendChild() |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
#============================================================================== |
105
|
|
|
|
|
|
|
sub removeChild |
106
|
|
|
|
|
|
|
{ |
107
|
1
|
|
|
1
|
0
|
2
|
my ($s, $child) = @_; |
108
|
|
|
|
|
|
|
|
109
|
1
|
|
|
|
|
2
|
for( 0...@{$s->{childNodes}} - 1 ) |
|
1
|
|
|
|
|
5
|
|
110
|
|
|
|
|
|
|
{ |
111
|
1
|
50
|
|
|
|
6
|
if( "$s->{childNodes}->[$_]" eq "$child" ) |
112
|
|
|
|
|
|
|
{ |
113
|
1
|
|
|
|
|
2
|
splice( @{$s->{childNodes}}, $_, 1 ); |
|
1
|
|
|
|
|
3
|
|
114
|
1
|
|
|
|
|
4
|
last; |
115
|
|
|
|
|
|
|
}# end if() |
116
|
|
|
|
|
|
|
}# end for() |
117
|
|
|
|
|
|
|
}# end removeChild() |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
#============================================================================== |
121
|
|
|
|
|
|
|
sub getElementById |
122
|
|
|
|
|
|
|
{ |
123
|
5268
|
|
|
5268
|
0
|
36301
|
my ($s, $id) = @_; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my ($match) = grep { |
126
|
5268
|
|
|
|
|
4720
|
$_->id eq $id |
|
6800
|
|
|
|
|
6017
|
|
127
|
|
|
|
|
|
|
} $s->childNodes; |
128
|
|
|
|
|
|
|
|
129
|
5268
|
100
|
|
|
|
5813
|
return $match if $match; |
130
|
|
|
|
|
|
|
|
131
|
5158
|
|
|
|
|
4697
|
foreach my $child ( $s->childNodes ) |
132
|
|
|
|
|
|
|
{ |
133
|
5158
|
|
|
|
|
4881
|
$match = $child->getElementById( $id ); |
134
|
5158
|
100
|
|
|
|
7089
|
return $match if $match; |
135
|
|
|
|
|
|
|
}# end foreach() |
136
|
|
|
|
|
|
|
}# end getElementById() |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1;# return true: |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
__END__ |