line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::DOM::Event; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.058'; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
28
|
|
|
28
|
|
146
|
use strict; |
|
28
|
|
|
|
|
42
|
|
|
28
|
|
|
|
|
597
|
|
7
|
28
|
|
|
28
|
|
105
|
use warnings; |
|
28
|
|
|
|
|
43
|
|
|
28
|
|
|
|
|
1600
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Look, TMTOWTDI: |
10
|
|
|
|
|
|
|
sub CAPTURING_PHASE (){ 1,} |
11
|
|
|
|
|
|
|
sub AT_TARGET (){ 2,} |
12
|
|
|
|
|
|
|
sub BUBBLING_PHASE (){ 3,} |
13
|
|
|
|
|
|
|
|
14
|
28
|
|
|
28
|
|
1175
|
use HTML::DOM::Exception 'NOT_SUPPORTED_ERR'; |
|
28
|
|
|
|
|
39
|
|
|
28
|
|
|
|
|
1494
|
|
15
|
28
|
|
|
28
|
|
155
|
use Exporter 5.57 'import'; |
|
28
|
|
|
|
|
374
|
|
|
28
|
|
|
|
|
21713
|
|
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
|
1577
|
|
|
1577
|
0
|
5047
|
bless {time => time}, $_[0]; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub create_event { |
29
|
1578
|
|
|
1578
|
0
|
2952
|
my $class = class_for($_[0]); |
30
|
1578
|
100
|
|
|
|
2701
|
defined $class or die new HTML::DOM::Exception NOT_SUPPORTED_ERR, |
31
|
|
|
|
|
|
|
"The event category '$_[0]' is not supported"; |
32
|
1577
|
|
|
|
|
6267
|
(my $path =$class) =~ s/::/\//g; |
33
|
1577
|
|
|
|
|
21377
|
require "$path.pm"; |
34
|
1577
|
|
|
|
|
3564
|
$class->new |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# ----------- ATTRIBUTE METHODS ------------- # |
38
|
|
|
|
|
|
|
# (all read-only) |
39
|
|
|
|
|
|
|
|
40
|
1773
|
|
|
1773
|
1
|
3439
|
sub type { $_[0]{name } } |
41
|
2840
|
100
|
|
2840
|
1
|
12417
|
sub target { $_[0]{target }||() } |
42
|
24
|
100
|
|
24
|
1
|
123
|
sub currentTarget { $_[0]{cur_target}||() } |
43
|
1594
|
|
|
1594
|
1
|
3442
|
sub eventPhase { $_[0]{phase } } |
44
|
1581
|
|
|
1581
|
1
|
4316
|
sub bubbles { $_[0]{froth } } |
45
|
39
|
|
|
39
|
1
|
143
|
sub cancelable { $_[0]{cancelable} } |
46
|
1
|
|
|
1
|
1
|
6
|
sub timeStamp { $_[0]{time } } |
47
|
1558
|
|
|
1558
|
1
|
7896
|
sub cancelled { $_[0]{cancelled } } # non-DOM |
48
|
5357
|
|
|
5357
|
1
|
11615
|
sub propagation_stopped { $_[0]{stopped} } # same hear |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# ----------- METHOD METHODS ------------- # |
52
|
|
|
|
|
|
|
|
53
|
12
|
|
|
12
|
1
|
40
|
sub stopPropagation { $_[0]{stopped } = !0; return } |
|
12
|
|
|
|
|
20
|
|
54
|
12
|
100
|
|
12
|
1
|
37
|
sub preventDefault { $_[0]{cancelled} = !0 if $_[0]->cancelable; return } |
|
12
|
|
|
|
|
22
|
|
55
|
|
|
|
|
|
|
# similar: |
56
|
899
|
|
|
899
|
|
1916
|
sub _set_eventPhase { $_[0]{phase } = $_[1] } |
57
|
1563
|
|
|
1563
|
|
2486
|
sub _set_target { $_[0]{target } = $_[1] } |
58
|
995
|
|
|
995
|
|
1568
|
sub _set_currentTarget { $_[0]{cur_target} = $_[1] } |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub initEvent { |
61
|
|
|
|
|
|
|
shift->init( |
62
|
27
|
|
|
27
|
1
|
1621
|
type => shift, |
63
|
|
|
|
|
|
|
propagates_up => shift, |
64
|
|
|
|
|
|
|
cancellable => shift, |
65
|
|
|
|
|
|
|
); |
66
|
27
|
|
|
|
|
40
|
return; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub init { |
70
|
1579
|
|
|
1579
|
1
|
3976
|
my($event, %args) = @_; |
71
|
1579
|
50
|
|
|
|
2886
|
return if defined $event->eventPhase; |
72
|
|
|
|
|
|
|
@$event{qw/name froth cancelable target/} |
73
|
1579
|
|
|
|
|
4581
|
= @args{qw/ type propagates_up cancellable target /}; |
74
|
1579
|
|
|
|
|
3415
|
$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
|
1578
|
|
|
1578
|
0
|
2582
|
$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
|
1893
|
|
|
1893
|
0
|
2973
|
my $evnt_name = lc $_[0]; |
269
|
|
|
|
|
|
|
return exists $defaults{$evnt_name} |
270
|
1893
|
100
|
|
|
|
3635
|
? @{$defaults{$evnt_name}} |
|
1860
|
|
|
|
|
5662
|
|
271
|
|
|
|
|
|
|
: (''=>propagates_up=>1,cancellable=>1); |
272
|
|
|
|
|
|
|
} |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
# ($event_category, @args) = HTML'DOM'Event'defaults foo; |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
1; |
277
|
|
|
|
|
|
|
__END__ |