/[suikacvs]/messaging/manakai/lib/Message/DOM/EventTargetNode.pm
Suika

Contents of /messaging/manakai/lib/Message/DOM/EventTargetNode.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Sat Oct 27 13:07:27 2007 UTC (17 years, 1 month ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +2 -0 lines
++ manakai/lib/Message/DOM/ChangeLog	27 Oct 2007 13:06:39 -0000
2007-10-27  Wakaba  <wakaba@suika.fam.cx>

	* Event.pm (init_event, init_event_ns, init_custom_event_ns):
	The |namespaceURI| attribute was not set correctly.

	* DOMEvents.dis: Removed.

1 package Message::DOM::Node;
2 use strict;
3 require Message::DOM::Node;
4 require Message::DOM::EventTarget;
5 push our @ISA, 'Message::DOM::EventTarget';
6
7 sub __dispatch_event ($$) {
8 my $ev = $_[1];
9
10 $ev->{target} = $_[0];
11 $ev->{manakai_dispatched} = 1;
12
13 my @target = ($_[0]);
14 while (defined (my $p = $target[0]->parent_node)) {
15 unshift @target, $p;
16 }
17
18 my $evns = $ev->{namespace_uri};
19 $evns = '' unless defined $evns;
20 my $evln = $ev->{local_name};
21 local $Error::Depth = $Error::Depth + 1;
22
23 {
24 $ev->{event_phase} = 1; # CAPTURE_PHASE
25 for my $ct (@target[0..$#target-1]) {
26 $ev->{current_target} = $ct;
27 ## ISSUE: {event_handler} mutation
28 for (@{$ct->{event_handler}->{$evns}->{$evln}->[1] or []}) {
29 $_->($ev);
30 }
31 }
32 }
33
34 {
35 $ev->{event_phase} = 2; # AT_TARGET
36 {
37 my $ct = $target[-1];
38 $ev->{current_target} = $ct;
39 ## ISSUE: {event_handler} mutation
40 for (@{$ct->{event_handler}->{$evns}->{$evln}->[0] or []}) {
41 $_->($ev);
42 }
43 }
44 }
45
46 if ($ev->{bubbles}) {
47 $ev->{event_phase} = 3; # BUBBLE_PHASE
48 for my $ct (reverse @target[0..$#target-1]) {
49 $ev->{current_phase} = $ct;
50 ## ISSUE: {event_handler} mutation
51 for (@{$ct->{event_handler}->{$evns}->{$evln}->[0] or []}) {
52 $_->($ev);
53 }
54 }
55 }
56
57 ## TODO: stop_propagation
58
59 ## ISSUE: Should we remove {current_target}?
60
61 return not $ev->{default_prevented};
62 } # __dispatch_event
63
64 package Message::DOM::Document;
65 push our @ISA, 'Message::IF::DocumentEvent';
66
67 sub can_dispatch ($$$) {
68 ## ISSUE: What should we do??
69 return 1;
70 } # can_dispatch
71
72 sub create_event ($$) {
73 ## ISSUE: Case-sensitivity in implementations?
74 my $mc = {
75 Event => ['Message::DOM::Event', 'Message::DOM::Event'],
76 ## ISSUE: Events?
77 CustomEvents => ['Message::DOM::Event',
78 'Message::DOM::Event::CustomEvent'],
79 HTMLEvents => ['Message::DOM::Event', 'Message::DOM::Event'],
80 ## TODO: MouseEvents
81 ## TODO: MutationEvents
82 ## TODO: UIEvents
83 }->{$_[1]};
84
85 unless (defined $mc) {
86 report Message::DOM::DOMException
87 -object => $_[0],
88 -type => 'NOT_SUPPORTED_ERR',
89 -subtype => 'EVENT_INTERFACE_NOT_SUPPORTED_ERR';
90 }
91
92 eval qq{ require $mc->[0]; 1 } or die $@;
93 ## TODO: Should we provide an option to use Time::HiRes?
94 return bless {time_stamp => time}, $mc->[1];
95
96 ## ISSUE: What value should be set to attributes?
97 } # create_event
98
99 package Message::IF::DocumentEvent;
100
101 1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24