1 |
wakaba |
1.1 |
package Message::DOM::Event; |
2 |
|
|
use strict; |
3 |
|
|
our $VERSION=do{my @r=(q$Revision: 1.16 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
4 |
|
|
push our @ISA, 'Message::IF::Event'; |
5 |
|
|
|
6 |
|
|
## The |Event| interface - constants |
7 |
|
|
|
8 |
|
|
## |PhaseType| |
9 |
|
|
|
10 |
|
|
sub CAPTURING_PHASE () { 1 } |
11 |
|
|
sub AT_TARGET () { 2 } |
12 |
|
|
sub BUBBLING_PHASE () { 3 } |
13 |
|
|
|
14 |
|
|
sub AUTOLOAD { |
15 |
|
|
my $method_name = our $AUTOLOAD; |
16 |
|
|
$method_name =~ s/.*:://; |
17 |
|
|
return if $method_name eq 'DESTROY'; |
18 |
|
|
|
19 |
|
|
if ({ |
20 |
|
|
## Read-only attributes (trivial accessors) |
21 |
|
|
'Message::DOM::Event::bubbles' => 1, |
22 |
|
|
'Message::DOM::Event::cancelable' => 1, |
23 |
|
|
'Message::DOM::Event::current_target' => 1, |
24 |
|
|
'Message::DOM::Event::default_prevented' => 1, |
25 |
|
|
'Message::DOM::Event::manakai_dispatched' => 1, |
26 |
|
|
'Message::DOM::Event::event_phase' => 1, |
27 |
|
|
'Message::DOM::Event::manakai_immediate_propagation_stopped' => 1, |
28 |
|
|
'Message::DOM::Event::namespace_uri' => 1, |
29 |
|
|
'Message::DOM::Event::manakai_propagation_stopped' => 1, |
30 |
|
|
'Message::DOM::Event::target' => 1, |
31 |
|
|
'Message::DOM::Event::time_stamp' => 1, |
32 |
|
|
'Message::DOM::Event::type' => 1, |
33 |
|
|
|
34 |
|
|
'Message::DOM::Event::CustomEvent::detail' => 1, |
35 |
|
|
}->{$AUTOLOAD}) { |
36 |
|
|
no strict 'refs'; |
37 |
|
|
eval qq{ |
38 |
|
|
sub $method_name (\$) { |
39 |
|
|
return \${\$_[0]}->{$method_name}; |
40 |
|
|
} |
41 |
|
|
}; |
42 |
|
|
goto &{ $AUTOLOAD }; |
43 |
|
|
} else { |
44 |
|
|
require Carp; |
45 |
|
|
Carp::croak (qq<Can't locate method "$AUTOLOAD">); |
46 |
|
|
} |
47 |
|
|
} # AUTOLOAD |
48 |
|
|
|
49 |
|
|
## The |Event| interface - attributes |
50 |
|
|
|
51 |
|
|
sub bubbles ($); |
52 |
|
|
|
53 |
|
|
sub cancelable ($); |
54 |
|
|
|
55 |
|
|
sub current_target ($); |
56 |
|
|
|
57 |
|
|
sub default_prevented ($); |
58 |
|
|
|
59 |
|
|
## TODO: documentation |
60 |
|
|
sub manakai_dispatched ($); |
61 |
|
|
|
62 |
|
|
sub event_phase ($); |
63 |
|
|
|
64 |
|
|
## TODO: documentation |
65 |
|
|
sub manakai_immediate_propagation_stopped ($); |
66 |
|
|
|
67 |
|
|
sub namespace_uri ($); |
68 |
|
|
|
69 |
|
|
## TODO: documentation |
70 |
|
|
sub manakai_propagation_stopped ($); |
71 |
|
|
|
72 |
|
|
sub target ($); |
73 |
|
|
|
74 |
|
|
sub time_stamp ($); |
75 |
|
|
|
76 |
|
|
sub type ($); |
77 |
|
|
|
78 |
|
|
## The |Event| interface - methods |
79 |
|
|
|
80 |
|
|
sub init_event ($$;$$) { |
81 |
|
|
my $self = $_[0]; |
82 |
|
|
unless ($self->{manakai_dispatched}) { |
83 |
|
|
$self->{type} = ''.$_[1]; |
84 |
|
|
$self->{bubbles} = $_[2]; |
85 |
|
|
$self->{cancelable} = $_[3]; |
86 |
|
|
} |
87 |
|
|
} # init_event |
88 |
|
|
|
89 |
|
|
sub init_event_ns ($$;$$) { |
90 |
|
|
my $self = $_[0]; |
91 |
|
|
unless ($self->{manakai_dispatched}) { |
92 |
|
|
if (not defined $_[1] or $_[1] eq '') { |
93 |
|
|
$self->{namespace_uri} = $_[1]; |
94 |
|
|
} |
95 |
|
|
$self->{type} = ''.$_[2]; |
96 |
|
|
$self->{bubbles} = $_[3]; |
97 |
|
|
$self->{cancelable} = $_[4]; |
98 |
|
|
} |
99 |
|
|
} # init_event_ns |
100 |
|
|
|
101 |
|
|
sub prevent_default ($) { |
102 |
|
|
if ($_[0]->{cancelable}) { |
103 |
|
|
$_[0]->{default_prevented} = 1; |
104 |
|
|
} |
105 |
|
|
} # prevent_default |
106 |
|
|
|
107 |
|
|
sub stop_immediate_propagation ($) { |
108 |
|
|
$_[0]->{manakai_immediate_propagation_stopped} = 1; |
109 |
|
|
$_[0]->{manakai_propagation_stopped} = 1; |
110 |
|
|
} # stop_immediate_propagation |
111 |
|
|
|
112 |
|
|
sub stop_propagation ($) { |
113 |
|
|
$_[0]->{manakai_propagation_stopped} = 1; |
114 |
|
|
} # stop_propagation |
115 |
|
|
|
116 |
|
|
package Message::DOM::Event::CustomEvent; |
117 |
|
|
push our @ISA, 'Message::DOM::Event', 'Message::IF::CustomEvent'; |
118 |
|
|
|
119 |
|
|
## The |CustomEvent| interface - attribute |
120 |
|
|
|
121 |
|
|
sub detail ($); |
122 |
|
|
|
123 |
|
|
## The |CustomEvent| interface - method |
124 |
|
|
|
125 |
|
|
sub init_custom_event_ns ($$$;$$$) { |
126 |
|
|
my $self = $_[0]; |
127 |
|
|
unless ($self->{manakai_dispatched}) { |
128 |
|
|
if (not defined $_[1] or $_[1] eq '') { |
129 |
|
|
$self->{namespace_uri} = $_[1]; |
130 |
|
|
} |
131 |
|
|
$self->{type} = ''.$_[2]; |
132 |
|
|
$self->{bubbles} = $_[3]; |
133 |
|
|
$self->{cancelable} = $_[4]; |
134 |
|
|
$self->{detail} = $_[5]; |
135 |
|
|
} |
136 |
|
|
} # init_custom_event_ns |
137 |
|
|
|
138 |
|
|
package Message::IF::Event; |
139 |
|
|
package Message::IF::CustomEvent; |
140 |
|
|
|
141 |
|
|
1; |