| 55 |
|
|
| 56 |
if ({ |
if ({ |
| 57 |
## Read-only attributes (trivial accessors) |
## Read-only attributes (trivial accessors) |
|
local_name => 1, |
|
|
namespace_uri => 1, |
|
| 58 |
owner_document => 1, |
owner_document => 1, |
| 59 |
parent_node => 1, |
parent_node => 1, |
| 60 |
}->{$method_name}) { |
}->{$method_name}) { |
| 61 |
no strict 'refs'; |
no strict 'refs'; |
| 62 |
eval qq{ |
eval qq{ |
| 63 |
sub $method_name (\$) { |
sub $method_name (\$) { |
|
if (\@_ > 1) { |
|
|
require Carp; |
|
|
Carp::croak (qq<Can't modify read-only attribute>); |
|
|
} |
|
| 64 |
return \${\$_[0]}->{$method_name}; |
return \${\$_[0]}->{$method_name}; |
| 65 |
} |
} |
| 66 |
}; |
}; |
| 67 |
goto &{ $AUTOLOAD }; |
goto &{ $AUTOLOAD }; |
| 68 |
} elsif ({ |
} elsif ({ |
| 69 |
## Read-write attributes (DOMString, trivial accessors) |
## Read-write attributes (DOMString, trivial accessors) |
|
prefix => 1, |
|
| 70 |
}->{$method_name}) { |
}->{$method_name}) { |
| 71 |
no strict 'refs'; |
no strict 'refs'; |
| 72 |
eval qq{ |
eval qq{ |
| 83 |
Carp::croak (qq<Can't locate method "$AUTOLOAD">); |
Carp::croak (qq<Can't locate method "$AUTOLOAD">); |
| 84 |
} |
} |
| 85 |
} # AUTOLOAD |
} # AUTOLOAD |
|
sub local_name ($); |
|
|
sub namespace_uri ($); |
|
|
sub owner_document ($); |
|
|
sub parent_node ($); |
|
|
sub prefix ($;$); |
|
| 86 |
|
|
| 87 |
## The |Node| interface - attribute |
## The |Node| interface - attribute |
| 88 |
|
|
|
## Spec: |
|
|
## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-84CF096> |
|
|
## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-1950641247> |
|
|
|
|
| 89 |
sub attributes ($) { |
sub attributes ($) { |
| 90 |
## NOTE: Overloaded by |Message::DOM::Element|. |
## NOTE: Overloaded by |Message::DOM::Element|. |
| 91 |
return undef; |
return undef; |
| 92 |
} # attributes |
} # attributes |
| 93 |
|
|
| 94 |
## Spec: |
## TODO: baseURI |
| 95 |
## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-F68D095> |
|
| 96 |
## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-1950641247> |
## TODO: childNodes |
| 97 |
|
sub child_nodes ($) { |
| 98 |
|
my $self = shift; |
| 99 |
|
return $$self->{child_nodes} || []; |
| 100 |
|
} # child_nodes |
| 101 |
|
|
| 102 |
|
sub first_child ($) { |
| 103 |
|
my $self = shift; |
| 104 |
|
return $$self->{child_nodes} ? $$self->{child_nodes}->[0] : undef; |
| 105 |
|
} # first_child |
| 106 |
|
|
| 107 |
|
sub last_child ($) { |
| 108 |
|
my $self = shift; |
| 109 |
|
return $$self->{child_nodes} && $$self->{child_nodes}->[0] |
| 110 |
|
? $$self->{child_nodes}->[-1] : undef; |
| 111 |
|
} # last_child |
| 112 |
|
|
| 113 |
|
sub local_name ($) { undef } |
| 114 |
|
sub manakai_local_name ($) { undef } |
| 115 |
|
|
| 116 |
|
sub namespace_uri ($) { undef } |
| 117 |
|
|
| 118 |
|
sub next_sibling ($) { |
| 119 |
|
my $self = shift; |
| 120 |
|
my $parent = $$self->{parent_node}; |
| 121 |
|
return undef unless defined $parent; |
| 122 |
|
my $has_self; |
| 123 |
|
for (@{$parent->child_nodes}) { |
| 124 |
|
if ($_ eq $self) { |
| 125 |
|
$has_self = 1; |
| 126 |
|
} elsif ($has_self) { |
| 127 |
|
return $_; |
| 128 |
|
} |
| 129 |
|
} |
| 130 |
|
return undef; |
| 131 |
|
} # next_sibling |
| 132 |
|
|
| 133 |
sub node_name ($) { |
sub node_name ($) { |
| 134 |
## NOTE: Overloaded by subclasses. |
## NOTE: Overloaded by subclasses. |
| 135 |
return undef; |
return undef; |
| 136 |
} # node_name |
} # node_name |
| 137 |
|
|
|
## Spec: |
|
|
## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-111237558> |
|
|
|
|
| 138 |
sub node_type ($) { |
sub node_type ($) { |
| 139 |
## NOTE: Overloaded by subclasses. |
## NOTE: Overloaded by subclasses. |
| 140 |
die "Node->node_type is not defined"; |
die "Node->node_type is not defined"; |
| 141 |
} # node_type |
} # node_type |
| 142 |
|
|
|
## Spec: |
|
|
## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-F68D080> |
|
|
## <http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-1950641247> |
|
|
|
|
| 143 |
sub node_value ($;$) { |
sub node_value ($;$) { |
| 144 |
## NOTE: Overloaded by subclasses. |
## NOTE: Overloaded by subclasses. |
| 145 |
return undef; |
return undef; |
| 146 |
} # node_value |
} # node_value |
| 147 |
|
|
| 148 |
|
## TODO: node_value setter |
| 149 |
|
|
| 150 |
|
sub owner_document ($); |
| 151 |
|
|
| 152 |
|
sub parent_node ($); |
| 153 |
|
|
| 154 |
|
sub prefix ($;$) { undef } |
| 155 |
|
|
| 156 |
|
sub previous_sibling ($) { |
| 157 |
|
my $self = shift; |
| 158 |
|
my $parent = $$self->{parent_node}; |
| 159 |
|
return undef unless defined $parent; |
| 160 |
|
my $prev; |
| 161 |
|
for (@{$parent->child_nodes}) { |
| 162 |
|
if ($_ eq $self) { |
| 163 |
|
return $prev; |
| 164 |
|
} else { |
| 165 |
|
$prev = $_; |
| 166 |
|
} |
| 167 |
|
} |
| 168 |
|
return undef; |
| 169 |
|
} # previous_sibling |
| 170 |
|
|
| 171 |
|
sub text_content ($;$) { |
| 172 |
|
## TODO: |
| 173 |
|
} # text_content |
| 174 |
|
|
| 175 |
sub is_equal_node ($$) { |
sub is_equal_node ($$) { |
| 176 |
return shift eq shift; |
return shift eq shift; |
| 177 |
} # is_equal_node |
} # is_equal_node |
| 178 |
|
|
|
sub manakai_local_name ($) { |
|
|
if (@_ > 1) { |
|
|
require Carp; |
|
|
Carp::croak (qq<Can't modify read-only attribute>); |
|
|
} |
|
|
return ${$_[0]}->{local_name}; |
|
|
} # manakai_local_name |
|
| 179 |
|
|
| 180 |
sub manakai_parent_element ($) { |
sub manakai_parent_element ($) { |
| 181 |
my $self = shift; |
my $self = shift; |