line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::DOM::Event; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.057'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
28
|
|
|
28
|
|
89
|
use strict; |
|
28
|
|
|
|
|
26
|
|
|
28
|
|
|
|
|
876
|
|
7
|
28
|
|
|
28
|
|
82
|
use warnings; |
|
28
|
|
|
|
|
25
|
|
|
28
|
|
|
|
|
1812
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Look, TMTOWTDI: |
10
|
|
|
|
|
|
|
sub CAPTURING_PHASE (){ 1,} |
11
|
|
|
|
|
|
|
sub AT_TARGET (){ 2,} |
12
|
|
|
|
|
|
|
sub BUBBLING_PHASE (){ 3,} |
13
|
|
|
|
|
|
|
|
14
|
28
|
|
|
28
|
|
1109
|
use HTML::DOM::Exception 'NOT_SUPPORTED_ERR'; |
|
28
|
|
|
|
|
72
|
|
|
28
|
|
|
|
|
1091
|
|
15
|
28
|
|
|
28
|
|
95
|
use Exporter 5.57 'import'; |
|
28
|
|
|
|
|
359
|
|
|
28
|
|
|
|
|
17646
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our @EXPORT_OK = qw' |
18
|
|
|
|
|
|
|
CAPTURING_PHASE |
19
|
|
|
|
|
|
|
AT_TARGET |
20
|
|
|
|
|
|
|
BUBBLING_PHASE |
21
|
|
|
|
|
|
|
'; |
22
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => \@EXPORT_OK); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
25
|
1574
|
|
|
1574
|
0
|
5325
|
bless {time => time}, $_[0]; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub create_event { |
29
|
1575
|
|
|
1575
|
0
|
2281
|
my $class = class_for($_[0]); |
30
|
1575
|
100
|
|
|
|
2724
|
defined $class or die new HTML::DOM::Exception NOT_SUPPORTED_ERR, |
31
|
|
|
|
|
|
|
"The event category '$_[0]' is not supported"; |
32
|
1574
|
|
|
|
|
5140
|
(my $path =$class) =~ s/::/\//g; |
33
|
1574
|
|
|
|
|
22794
|
require "$path.pm"; |
34
|
1574
|
|
|
|
|
3408
|
$class->new |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# ----------- ATTRIBUTE METHODS ------------- # |
38
|
|
|
|
|
|
|
# (all read-only) |
39
|
|
|
|
|
|
|
|
40
|
1770
|
|
|
1770
|
1
|
3561
|
sub type { $_[0]{name } } |
41
|
2834
|
100
|
|
2834
|
1
|
14109
|
sub target { $_[0]{target }||() } |
42
|
24
|
100
|
|
24
|
1
|
121
|
sub currentTarget { $_[0]{cur_target}||() } |
43
|
1591
|
|
|
1591
|
1
|
3211
|
sub eventPhase { $_[0]{phase } } |
44
|
1578
|
|
|
1578
|
1
|
5003
|
sub bubbles { $_[0]{froth } } |
45
|
39
|
|
|
39
|
1
|
148
|
sub cancelable { $_[0]{cancelable} } |
46
|
1
|
|
|
1
|
1
|
5
|
sub timeStamp { $_[0]{time } } |
47
|
1555
|
|
|
1555
|
1
|
9203
|
sub cancelled { $_[0]{cancelled } } # non-DOM |
48
|
5324
|
|
|
5324
|
1
|
14254
|
sub propagation_stopped { $_[0]{stopped} } # same hear |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# ----------- METHOD METHODS ------------- # |
52
|
|
|
|
|
|
|
|
53
|
12
|
|
|
12
|
1
|
38
|
sub stopPropagation { $_[0]{stopped } = !0; return } |
|
12
|
|
|
|
|
18
|
|
54
|
12
|
100
|
|
12
|
1
|
36
|
sub preventDefault { $_[0]{cancelled} = !0 if $_[0]->cancelable; return } |
|
12
|
|
|
|
|
23
|
|
55
|
|
|
|
|
|
|
# similar: |
56
|
899
|
|
|
899
|
|
1490
|
sub _set_eventPhase { $_[0]{phase } = $_[1] } |
57
|
1560
|
|
|
1560
|
|
2397
|
sub _set_target { $_[0]{target } = $_[1] } |
58
|
995
|
|
|
995
|
|
1636
|
sub _set_currentTarget { $_[0]{cur_target} = $_[1] } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub initEvent { |
61
|
|
|
|
|
|
|
shift->init( |
62
|
27
|
|
|
27
|
1
|
1320
|
type => shift, |
63
|
|
|
|
|
|
|
propagates_up => shift, |
64
|
|
|
|
|
|
|
cancellable => shift, |
65
|
|
|
|
|
|
|
); |
66
|
27
|
|
|
|
|
34
|
return; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub init { |
70
|
1576
|
|
|
1576
|
1
|
2937
|
my($event, %args) = @_; |
71
|
1576
|
50
|
|
|
|
2203
|
return if defined $event->eventPhase; |
72
|
|
|
|
|
|
|
@$event{qw/name froth cancelable target/} |
73
|
1576
|
|
|
|
|
4232
|
= @args{qw/ type propagates_up cancellable target /}; |
74
|
1576
|
|
|
|
|
3241
|
$event; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# ----------- OTHER STUFF ------------- # |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# ~~~ Should I document these? |
80
|
|
|
|
|
|
|
# ~~~ If I do make these public, I probably ought to rename them to make |
81
|
|
|
|
|
|
|
# some distinction between the arg types; the arg to class_for is a DOM |
82
|
|
|
|
|
|
|
# event module name, and the arg to defaults is an event type. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my %class_for = ( |
85
|
|
|
|
|
|
|
'' => __PACKAGE__, |
86
|
|
|
|
|
|
|
UIEvents => 'HTML::DOM::Event::UI', |
87
|
|
|
|
|
|
|
HTMLEvents => __PACKAGE__, |
88
|
|
|
|
|
|
|
MouseEvents => 'HTML::DOM::Event::Mouse', |
89
|
|
|
|
|
|
|
MutationEvents => "HTML::DOM::Event::Mutation", |
90
|
|
|
|
|
|
|
); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub class_for { |
93
|
1575
|
|
|
1575
|
0
|
2233
|
$class_for{$_[0]}; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# ~~~ The DOM 2 spec lists mouseover and -out as cancellable. Firefox has |
97
|
|
|
|
|
|
|
# the cancelable property set to true, but preventDefault does nothing. |
98
|
|
|
|
|
|
|
# The DOM 3 spec also lists mousemove as cancellable. None of this |
99
|
|
|
|
|
|
|
# makes any sense. |
100
|
|
|
|
|
|
|
my %defaults = ( |
101
|
|
|
|
|
|
|
domfocusin => [ UIEvents => |
102
|
|
|
|
|
|
|
propagates_up => 1, |
103
|
|
|
|
|
|
|
cancellable => 0, |
104
|
|
|
|
|
|
|
], |
105
|
|
|
|
|
|
|
domfocusout => [ UIEvents => |
106
|
|
|
|
|
|
|
propagates_up => 1, |
107
|
|
|
|
|
|
|
cancellable => 0, |
108
|
|
|
|
|
|
|
], |
109
|
|
|
|
|
|
|
domactivate => [ UIEvents => |
110
|
|
|
|
|
|
|
propagates_up => 1, |
111
|
|
|
|
|
|
|
cancellable => 1, |
112
|
|
|
|
|
|
|
detail => 1, |
113
|
|
|
|
|
|
|
], |
114
|
|
|
|
|
|
|
click => [ MouseEvents => |
115
|
|
|
|
|
|
|
propagates_up => 1, |
116
|
|
|
|
|
|
|
cancellable => 1, |
117
|
|
|
|
|
|
|
detail => 1, |
118
|
|
|
|
|
|
|
screen_x => 0, |
119
|
|
|
|
|
|
|
screen_y => 0, |
120
|
|
|
|
|
|
|
client_x => 0, |
121
|
|
|
|
|
|
|
client_y => 0, |
122
|
|
|
|
|
|
|
ctrl => 0, |
123
|
|
|
|
|
|
|
alt => 0, |
124
|
|
|
|
|
|
|
shift => 0, |
125
|
|
|
|
|
|
|
meta => 0, |
126
|
|
|
|
|
|
|
button => 1, |
127
|
|
|
|
|
|
|
], |
128
|
|
|
|
|
|
|
mousedown => [ MouseEvents => |
129
|
|
|
|
|
|
|
propagates_up => 1, |
130
|
|
|
|
|
|
|
cancellable => 1, |
131
|
|
|
|
|
|
|
detail => 1, |
132
|
|
|
|
|
|
|
screen_x => 0, |
133
|
|
|
|
|
|
|
screen_y => 0, |
134
|
|
|
|
|
|
|
client_x => 0, |
135
|
|
|
|
|
|
|
client_y => 0, |
136
|
|
|
|
|
|
|
ctrl => 0, |
137
|
|
|
|
|
|
|
alt => 0, |
138
|
|
|
|
|
|
|
shift => 0, |
139
|
|
|
|
|
|
|
meta => 0, |
140
|
|
|
|
|
|
|
button => 1, |
141
|
|
|
|
|
|
|
], |
142
|
|
|
|
|
|
|
mouseup => [ MouseEvents => |
143
|
|
|
|
|
|
|
propagates_up => 1, |
144
|
|
|
|
|
|
|
cancellable => 1, |
145
|
|
|
|
|
|
|
detail => 1, |
146
|
|
|
|
|
|
|
screen_x => 0, |
147
|
|
|
|
|
|
|
screen_y => 0, |
148
|
|
|
|
|
|
|
client_x => 0, |
149
|
|
|
|
|
|
|
client_y => 0, |
150
|
|
|
|
|
|
|
ctrl => 0, |
151
|
|
|
|
|
|
|
alt => 0, |
152
|
|
|
|
|
|
|
shift => 0, |
153
|
|
|
|
|
|
|
meta => 0, |
154
|
|
|
|
|
|
|
button => 1, |
155
|
|
|
|
|
|
|
], |
156
|
|
|
|
|
|
|
mouseover => [ MouseEvents => |
157
|
|
|
|
|
|
|
propagates_up => 1, |
158
|
|
|
|
|
|
|
cancellable => 1, |
159
|
|
|
|
|
|
|
screen_x => 0, |
160
|
|
|
|
|
|
|
screen_y => 0, |
161
|
|
|
|
|
|
|
client_x => 0, |
162
|
|
|
|
|
|
|
client_y => 0, |
163
|
|
|
|
|
|
|
ctrl => 0, |
164
|
|
|
|
|
|
|
alt => 0, |
165
|
|
|
|
|
|
|
shift => 0, |
166
|
|
|
|
|
|
|
meta => 0, |
167
|
|
|
|
|
|
|
], |
168
|
|
|
|
|
|
|
mousemove => [ MouseEvents => |
169
|
|
|
|
|
|
|
propagates_up => 1, |
170
|
|
|
|
|
|
|
cancellable => 0, |
171
|
|
|
|
|
|
|
screen_x => 0, |
172
|
|
|
|
|
|
|
screen_y => 0, |
173
|
|
|
|
|
|
|
client_x => 0, |
174
|
|
|
|
|
|
|
client_y => 0, |
175
|
|
|
|
|
|
|
ctrl => 0, |
176
|
|
|
|
|
|
|
alt => 0, |
177
|
|
|
|
|
|
|
shift => 0, |
178
|
|
|
|
|
|
|
meta => 0, |
179
|
|
|
|
|
|
|
], |
180
|
|
|
|
|
|
|
mouseout => [ MouseEvents => |
181
|
|
|
|
|
|
|
propagates_up => 1, |
182
|
|
|
|
|
|
|
cancellable => 1, |
183
|
|
|
|
|
|
|
screen_x => 0, |
184
|
|
|
|
|
|
|
screen_y => 0, |
185
|
|
|
|
|
|
|
client_x => 0, |
186
|
|
|
|
|
|
|
client_y => 0, |
187
|
|
|
|
|
|
|
ctrl => 0, |
188
|
|
|
|
|
|
|
alt => 0, |
189
|
|
|
|
|
|
|
shift => 0, |
190
|
|
|
|
|
|
|
meta => 0, |
191
|
|
|
|
|
|
|
], |
192
|
|
|
|
|
|
|
domsubtreemodified => [ MutationEvents => |
193
|
|
|
|
|
|
|
propagates_up => 1, |
194
|
|
|
|
|
|
|
cancellable => 0, |
195
|
|
|
|
|
|
|
], |
196
|
|
|
|
|
|
|
domnodeinserted => [ MutationEvents => |
197
|
|
|
|
|
|
|
propagates_up => 1, |
198
|
|
|
|
|
|
|
cancellable => 0, |
199
|
|
|
|
|
|
|
], |
200
|
|
|
|
|
|
|
domnoderemoved => [ MutationEvents => |
201
|
|
|
|
|
|
|
propagates_up => 1, |
202
|
|
|
|
|
|
|
cancellable => 0, |
203
|
|
|
|
|
|
|
], |
204
|
|
|
|
|
|
|
domnoderemovedfromdocument => [ MutationEvents => |
205
|
|
|
|
|
|
|
propagates_up => 0, |
206
|
|
|
|
|
|
|
cancellable => 0, |
207
|
|
|
|
|
|
|
], |
208
|
|
|
|
|
|
|
domnodeinsertedintodocument => [ MutationEvents => |
209
|
|
|
|
|
|
|
propagates_up => 0, |
210
|
|
|
|
|
|
|
cancellable => 0, |
211
|
|
|
|
|
|
|
], |
212
|
|
|
|
|
|
|
domattrmodified => [ MutationEvents => |
213
|
|
|
|
|
|
|
propagates_up => 1, |
214
|
|
|
|
|
|
|
cancellable => 0, |
215
|
|
|
|
|
|
|
], |
216
|
|
|
|
|
|
|
domcharacterdatamodified => [ MutationEvents => |
217
|
|
|
|
|
|
|
propagates_up => 1, |
218
|
|
|
|
|
|
|
cancellable => 0, |
219
|
|
|
|
|
|
|
], |
220
|
|
|
|
|
|
|
load => [ HTMLEvents => |
221
|
|
|
|
|
|
|
propagates_up => 0, |
222
|
|
|
|
|
|
|
cancellable => 0, |
223
|
|
|
|
|
|
|
], |
224
|
|
|
|
|
|
|
unload => [ HTMLEvents => |
225
|
|
|
|
|
|
|
propagates_up => 0, |
226
|
|
|
|
|
|
|
cancellable => 0, |
227
|
|
|
|
|
|
|
], |
228
|
|
|
|
|
|
|
focus => [ HTMLEvents => |
229
|
|
|
|
|
|
|
propagates_up => 0, |
230
|
|
|
|
|
|
|
cancellable => 0, |
231
|
|
|
|
|
|
|
], |
232
|
|
|
|
|
|
|
blur => [ HTMLEvents => |
233
|
|
|
|
|
|
|
propagates_up => 0, |
234
|
|
|
|
|
|
|
cancellable => 0, |
235
|
|
|
|
|
|
|
], |
236
|
|
|
|
|
|
|
abort => [ HTMLEvents => |
237
|
|
|
|
|
|
|
propagates_up => 1, |
238
|
|
|
|
|
|
|
cancellable => 0, |
239
|
|
|
|
|
|
|
], |
240
|
|
|
|
|
|
|
error => [ HTMLEvents => |
241
|
|
|
|
|
|
|
propagates_up => 1, |
242
|
|
|
|
|
|
|
cancellable => 0, |
243
|
|
|
|
|
|
|
], |
244
|
|
|
|
|
|
|
select => [ HTMLEvents => |
245
|
|
|
|
|
|
|
propagates_up => 1, |
246
|
|
|
|
|
|
|
cancellable => 0, |
247
|
|
|
|
|
|
|
], |
248
|
|
|
|
|
|
|
change => [ HTMLEvents => |
249
|
|
|
|
|
|
|
propagates_up => 1, |
250
|
|
|
|
|
|
|
cancellable => 0, |
251
|
|
|
|
|
|
|
], |
252
|
|
|
|
|
|
|
# submit uses the defaults |
253
|
|
|
|
|
|
|
reset => [ HTMLEvents => |
254
|
|
|
|
|
|
|
propagates_up => 1, |
255
|
|
|
|
|
|
|
cancellable => 0, |
256
|
|
|
|
|
|
|
], |
257
|
|
|
|
|
|
|
resize => [ HTMLEvents => |
258
|
|
|
|
|
|
|
propagates_up => 1, |
259
|
|
|
|
|
|
|
cancellable => 0, |
260
|
|
|
|
|
|
|
], |
261
|
|
|
|
|
|
|
scroll => [ HTMLEvents => |
262
|
|
|
|
|
|
|
propagates_up => 1, |
263
|
|
|
|
|
|
|
cancellable => 0, |
264
|
|
|
|
|
|
|
], |
265
|
|
|
|
|
|
|
); |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
sub defaults { |
268
|
1890
|
|
|
1890
|
0
|
2294
|
my $evnt_name = lc $_[0]; |
269
|
|
|
|
|
|
|
return exists $defaults{$evnt_name} |
270
|
1890
|
100
|
|
|
|
2987
|
? @{$defaults{$evnt_name}} |
|
1858
|
|
|
|
|
5926
|
|
271
|
|
|
|
|
|
|
: (''=>propagates_up=>1,cancellable=>1); |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
# ($event_category, @args) = HTML'DOM'Event'defaults foo; |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
1; |
277
|
|
|
|
|
|
|
__END__ |