1 |
#!/usr/bin/perl |
## NOTE: This module will be renamed as Document.pm. |
|
## This file is automatically generated |
|
|
## at 2006-12-30T04:24:35+00:00, |
|
|
## from file "Document.dis", |
|
|
## module <http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#ManakaiDOM.Document>, |
|
|
## for <http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#ManakaiDOMLatest>. |
|
|
## Don't edit by hand! |
|
|
use strict; |
|
|
require Message::DOM::DOMCore; |
|
|
require Message::DOM::TreeCore; |
|
|
require Message::Util::Error::DOMException; |
|
|
package Message::DOM::Document; |
|
|
our $VERSION = 20061230.0424; |
|
|
package Message::DOM::Document::ManakaiDOMImplementationDocument; |
|
|
our $VERSION = 20061230.0424; |
|
|
push @Message::DOM::DOMCore::ManakaiDOMImplementation::ISA, q<Message::DOM::Document::ManakaiDOMImplementationDocument> unless Message::DOM::DOMCore::ManakaiDOMImplementation->isa (q<Message::DOM::Document::ManakaiDOMImplementationDocument>); |
|
|
sub create_document ($;$$$) { |
|
|
my ($self, $namespaceURI, $qualifiedName, $doctype) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) { |
|
|
require Message::DOM::DOMMain; |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:tag:suika.fam.cx,2005-09:1167450139:7187:cCkYT15288+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$namespaceURI = undef; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
require |
|
|
Scalar::Util; |
|
|
$r = bless \{ |
|
|
|
|
|
'child' |
|
|
=> [], |
|
|
|
|
|
'impl' |
|
|
=> $self, |
|
|
|
|
|
'http://www.w3.org/2001/04/infoset#version' |
|
|
=> '1.0', |
|
|
|
|
|
'chk' |
|
|
=> 1, |
|
|
}, |
|
|
'Message::DOM::Document::ManakaiDOMDocument' |
|
|
; |
|
|
|
|
|
if (defined $doctype) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$r-> |
|
|
append_child |
|
|
($doctype); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
if (defined $qualifiedName) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
$el = $r-> |
|
|
create_element_ns |
|
|
|
|
|
($namespaceURI, $qualifiedName); |
|
|
$r-> |
|
|
append_child |
|
|
($el); |
|
|
$r = $el-> |
|
|
owner_document |
|
|
; |
|
|
## Choose the class based on document element type |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
2 |
|
|
3 |
; |
package Message::DOM::Document; |
4 |
} elsif (defined $namespaceURI) { |
use strict; |
5 |
|
our $VERSION=do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
6 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NAMESPACE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'create_document', 'http://www.w3.org/2001/04/infoset#namespaceURI' => $namespaceURI, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_NS_NULL_QNAME_WITH_NON_NULL_URI', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMImplementationDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'namespaceURI'; |
push our @ISA, 'Message::DOM::Node', 'Message::IF::Document', |
7 |
|
'Message::IF::DocumentTraversal', 'Message::IF::DocumentXDoctype', |
8 |
; |
'Message::IF::DocumentSelector', # MUST in Selectors API spec |
9 |
} |
'Message::IF::HTMLDocument'; |
10 |
|
require Message::DOM::Node; |
11 |
|
use Char::Class::XML |
12 |
} |
qw/ |
13 |
$r} |
InXML_NameStartChar10 InXMLNameStartChar11 |
14 |
$Message::DOM::DOMFeature::ClassInfo->{q<Message::DOM::Document::ManakaiDOMImplementationDocument>}->{has_feature} = {}; |
InXMLNameChar10 InXMLNameChar11 |
15 |
$Message::DOM::ClassPoint{q<Message::DOM::Document::ManakaiDOMImplementationDocument>} = 0; |
InXML_NCNameStartChar10 InXMLNCNameStartChar11 |
16 |
package Message::DOM::IFLatest::Document; |
InXMLNCNameChar10 InXMLNCNameChar11 |
17 |
our $VERSION = 20061230.0424; |
/; |
18 |
package Message::DOM::Document::ManakaiDOMDocument; |
|
19 |
our $VERSION = 20061230.0424; |
sub ____new ($$) { |
20 |
push our @ISA, 'Message::DOM::TreeCore::ManakaiDOMNode', |
my $self = shift->SUPER::____new (undef); |
21 |
'Message::DOM::IFLatest::Document', |
$$self->{implementation} = $_[0]; |
22 |
'Message::DOM::IFLatest::Node'; |
$$self->{strict_error_checking} = 1; |
23 |
sub node_type ($;$) { |
$$self->{child_nodes} = []; |
24 |
if (@_ == 1) {my ($self) = @_; |
$$self->{'http://suika.fam.cx/www/2006/dom-config/strict-document-children'} = 1; |
25 |
my $r; |
$$self->{'http://suika.fam.cx/www/2006/dom-config/dtd-default-attribute'} = 1; |
26 |
$r = 9; |
$$self->{'http://suika.fam.cx/www/2006/dom-config/clone-entity-reference-subtree'} = 1; |
27 |
$r; |
$$self->{'error-handler'} = sub ($) { |
28 |
} else {my ($self) = @_; |
## NOTE: Same as one set by |setParameter| with |undef| value. |
29 |
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'node_type'; |
warn $_[0]; |
30 |
} |
return $_[0]->severity != 3; # SEVERITY_FATAL_ERROR |
31 |
} |
}; |
32 |
sub append_child ($$) { |
return $self; |
33 |
my ($self, $newChild) = @_; |
} # ____new |
34 |
my $r; |
|
35 |
|
sub AUTOLOAD { |
36 |
{ |
my $method_name = our $AUTOLOAD; |
37 |
|
$method_name =~ s/.*:://; |
38 |
my |
return if $method_name eq 'DESTROY'; |
|
$strictc = $self-> |
|
|
dom_config |
|
|
|
|
|
-> |
|
|
get_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/strict-document-children' |
|
|
); |
|
|
my $child_od = $newChild-> |
|
|
owner_document |
|
|
|| $self; |
|
|
my $child_nt = $newChild-> |
|
|
node_type |
|
|
; |
|
|
if ($strictc and $self-> |
|
|
strict_error_checking |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
$has_el; |
|
|
my $has_dt; |
|
|
if ($child_nt == |
|
|
1 |
|
|
) { |
|
|
$has_el = |
|
|
1 |
|
|
; |
|
|
} elsif ($child_nt == |
|
|
10 |
|
|
) { |
|
|
$has_dt = |
|
|
1 |
|
|
; |
|
|
} elsif ($child_nt == |
|
|
11 |
|
|
) { |
|
|
for my $cn (@{$newChild-> |
|
|
child_nodes |
|
|
}) { |
|
|
my $cnt = $cn-> |
|
|
node_type |
|
|
; |
|
|
if ($cnt == |
|
|
1 |
|
|
) { |
|
|
if ($has_el) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'append_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
39 |
|
|
40 |
; |
if ({ |
41 |
|
## Read-only attributes (trivial accessors) |
42 |
|
implementation => 1, |
43 |
|
}->{$method_name}) { |
44 |
|
no strict 'refs'; |
45 |
|
eval qq{ |
46 |
|
sub $method_name (\$) { |
47 |
|
return \${\$_[0]}->{$method_name}; |
48 |
|
} |
49 |
|
}; |
50 |
|
goto &{ $AUTOLOAD }; |
51 |
|
} elsif ({ |
52 |
|
## Read-write attributes (DOMString, trivial accessors) |
53 |
|
document_uri => 1, |
54 |
|
input_encoding => 1, |
55 |
|
}->{$method_name}) { |
56 |
|
no strict 'refs'; |
57 |
|
eval qq{ |
58 |
|
sub $method_name (\$;\$) { |
59 |
|
if (\@_ > 1) { |
60 |
|
if (\${\$_[0]}->{strict_error_checking} and |
61 |
|
\${\$_[0]}->{manakai_read_only}) { |
62 |
|
report Message::DOM::DOMException |
63 |
|
-object => \$_[0], |
64 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
65 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
66 |
|
} |
67 |
|
if (defined \$_[1]) { |
68 |
|
\${\$_[0]}->{$method_name} = ''.\$_[1]; |
69 |
|
} else { |
70 |
|
delete \${\$_[0]}->{$method_name}; |
71 |
} |
} |
|
$has_el = |
|
|
1 |
|
|
; |
|
72 |
} |
} |
73 |
# DocumentType node cannot be contained in DocumentFragments |
return \${\$_[0]}->{$method_name}; |
74 |
} |
} |
75 |
} |
}; |
76 |
|
goto &{ $AUTOLOAD }; |
77 |
if ($has_el) { |
} elsif ({ |
78 |
my $anode = $self-> |
## Read-write attributes (boolean, trivial accessors) |
79 |
last_child |
all_declarations_processed => 1, |
80 |
; |
}->{$method_name}) { |
81 |
while (defined $anode) { |
no strict 'refs'; |
82 |
if ($anode-> |
eval qq{ |
83 |
node_type |
sub $method_name (\$;\$) { |
84 |
== |
if (\@_ > 1) { |
85 |
1 |
if (\${\$_[0]}->{manakai_strict_error_checking} and |
86 |
) { |
\${\$_[0]}->{manakai_read_only}) { |
87 |
|
report Message::DOM::DOMException |
88 |
|
-object => \$_[0], |
89 |
{ |
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
90 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
91 |
local $Error::Depth = $Error::Depth - 1; |
} |
92 |
|
if (\$_[1]) { |
93 |
{ |
\${\$_[0]}->{$method_name} = 1; |
94 |
|
} else { |
95 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'append_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
delete \${\$_[0]}->{$method_name}; |
96 |
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
97 |
} |
} |
98 |
$anode = $anode-> |
return \${\$_[0]}->{$method_name}; |
|
previous_sibling |
|
|
; |
|
99 |
} |
} |
100 |
} # has_el |
}; |
101 |
if ($has_dt) { |
goto &{ $AUTOLOAD }; |
102 |
my $anode = $self-> |
} elsif (my $module_name = { |
103 |
last_child |
can_dispatch => 'Message::DOM::EventTargetNode', |
104 |
; |
create_attribute => 'Message::DOM::Attr', |
105 |
while (defined $anode) { |
create_attribute_ns => 'Message::DOM::Attr', |
106 |
my $ant = $anode-> |
create_attribute_definition => 'Message::DOM::AttributeDefinition', |
107 |
node_type |
create_cdata_section => 'Message::DOM::Text', |
108 |
; |
create_comment => 'Message::DOM::CharacterData', |
109 |
if ($ant == |
create_document_fragment => 'Message::DOM::DocumentFragment', |
110 |
1 |
create_document_type_definition => 'Message::DOM::DocumentType', |
111 |
) { |
create_element => 'Message::DOM::Element', |
112 |
|
create_element_ns => 'Message::DOM::Element', |
113 |
|
create_element_type_definition => 'Message::DOM::ElementTypeDefinition', |
114 |
{ |
create_entity_reference => 'Message::DOM::EntityReference', |
115 |
|
create_event => 'Message::DOM::EventTargetNode', |
116 |
local $Error::Depth = $Error::Depth - 1; |
create_general_entity => 'Message::DOM::Entity', |
117 |
|
create_notation => 'Message::DOM::Notation', |
118 |
|
create_processing_instruction => 'Message::DOM::ProcessingInstruction', |
119 |
|
manakai_create_serial_walker => 'Message::DOM::SerialWalker', |
120 |
|
create_text_node => 'Message::DOM::Text', |
121 |
|
create_tree_walker => 'Message::DOM::TreeWalker', |
122 |
|
query_selector => 'Message::DOM::SelectorsAPI', |
123 |
|
query_selector_all => 'Message::DOM::SelectorsAPI', |
124 |
|
}->{$method_name}) { |
125 |
|
eval qq{ require $module_name } or die $@; |
126 |
|
goto &{ $AUTOLOAD }; |
127 |
|
} else { |
128 |
|
require Carp; |
129 |
|
Carp::croak (qq<Can't locate method "$AUTOLOAD">); |
130 |
|
} |
131 |
|
} # AUTOLOAD |
132 |
|
sub implementation ($); |
133 |
|
sub create_attribute ($$); |
134 |
|
sub create_attribute_ns ($$$); |
135 |
|
sub create_attribute_definition ($$); |
136 |
|
sub create_cdata_section ($$); |
137 |
|
sub create_comment ($$); |
138 |
|
sub create_document_fragment ($); |
139 |
|
sub create_document_type_definition ($$); |
140 |
|
sub create_element ($$); |
141 |
|
sub create_element_ns ($$$); |
142 |
|
sub create_element_type_definition ($$); |
143 |
|
sub create_entity_reference ($$); |
144 |
|
sub create_general_entity ($$); |
145 |
|
sub create_notation ($$); |
146 |
|
sub create_processing_instruction ($$$); |
147 |
|
sub create_text_node ($$); |
148 |
|
|
149 |
|
## |Node| attributes |
150 |
|
|
151 |
|
sub base_uri ($) { |
152 |
|
my $v = ${$_[0]}->{manakai_entity_base_uri}; |
153 |
|
if (defined $v) { |
154 |
|
return $v; |
155 |
|
} else { |
156 |
|
return ${$_[0]}->{document_uri}; |
157 |
|
} |
158 |
|
## TODO: HTML5 <base> |
159 |
|
} # base_uri |
160 |
|
|
161 |
{ |
sub node_name () { '#document' } |
162 |
|
|
163 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'append_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#HIERARCHY_WRONG_DOCTYPE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
sub node_type () { 9 } # DOCUMENT_NODE |
164 |
|
|
165 |
|
sub text_content ($;$) { |
166 |
|
my $self = shift; |
167 |
|
if ($$self->{'http://suika.fam.cx/www/2006/dom-config/strict-document-children'}) { |
168 |
|
return undef; |
169 |
|
} else { |
170 |
|
local $Error::Depth = $Error::Depth + 1; |
171 |
|
return $self->SUPER::text_content (@_); |
172 |
|
} |
173 |
|
} # text_content |
174 |
|
|
175 |
} |
## |Node| methods |
176 |
|
|
177 |
|
sub adopt_node ($$) { |
178 |
|
my ($self, $source) = @_; |
179 |
|
## TODO: Should we apply |copy-asis| configuration parameter to this method? |
180 |
|
|
181 |
;} |
return undef unless UNIVERSAL::isa ($source, 'Message::DOM::Node'); |
182 |
|
|
183 |
; |
my $strict = $self->strict_error_checking; |
184 |
} elsif ($ant == |
if ($strict and $$self->{manakai_read_only}) { |
185 |
10 |
report Message::DOM::DOMException |
186 |
) { |
-object => $self, |
187 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
188 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
189 |
|
} |
190 |
|
|
191 |
{ |
my $parent = $source->parent_node; |
192 |
|
if ($strict and defined $parent and $$parent->{manakai_read_only}) { |
193 |
|
report Message::DOM::DOMException |
194 |
|
-object => $self, |
195 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
196 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
197 |
|
} |
198 |
|
|
199 |
local $Error::Depth = $Error::Depth - 1; |
my $nt = $source->node_type; |
200 |
|
my $oe; |
201 |
|
if ($nt == 2) { # ATTRIBUTE_NODE |
202 |
|
$oe = $source->owner_element; |
203 |
|
if ($strict and defined $oe and $$oe->{manakai_read_only}) { |
204 |
|
report Message::DOM::DOMException |
205 |
|
-object => $self, |
206 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
207 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
208 |
|
} |
209 |
|
} elsif ($nt == 9 or $nt == 10 or $nt == 6 or $nt == 12 or |
210 |
|
$nt == 81001 or $nt == 81002) { |
211 |
|
# DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ENTITY_NODE, NOTATION_NODE, |
212 |
|
# ELEMENT_TYPE_DEFINITION_NODE, ATTRIBUTE_DEFINITION_NODE |
213 |
|
report Message::DOM::DOMException |
214 |
|
-object => $self, |
215 |
|
-type => 'NOT_SUPPORTED_ERR', |
216 |
|
-subtype => 'ADOPT_NODE_TYPE_NOT_SUPPORTED_ERR'; |
217 |
|
## ISSUE: Define ELEMENT_TYPE_DEFINITION_NODE and ATTRIBUTE_DEFINITION_NODE |
218 |
|
} |
219 |
|
|
220 |
{ |
my @change_od; |
221 |
|
my @nodes = ($source); |
222 |
|
while (@nodes) { |
223 |
|
my $node = shift @nodes; |
224 |
|
my $nt = $node->node_type; |
225 |
|
if ($strict and $$node->{manakai_read_only}) { |
226 |
|
report Message::DOM::DOMException |
227 |
|
-object => $self, |
228 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
229 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
230 |
|
} |
231 |
|
|
232 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'append_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOCTYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
push @change_od, $node; |
233 |
|
push @nodes, @{$node->child_nodes}, @{$node->attributes or []}; |
234 |
|
} # @nodes |
235 |
|
|
236 |
|
local $Error::Depth = $Error::Depth + 1; |
237 |
|
|
238 |
} |
if (defined $parent) { |
239 |
|
$parent->remove_child ($source); |
240 |
|
} elsif (defined $oe) { |
241 |
|
$oe->remove_attribute_node ($source); |
242 |
|
} |
243 |
|
|
244 |
|
return $source if $self eq $change_od[0]->owner_document; |
245 |
|
## NOTE: The array must have more than zero |
246 |
|
## nodes by definition. In addition, |
247 |
|
## it cannot contain document or document |
248 |
|
## type nodes in current implementation. |
249 |
|
|
250 |
;} |
my @ud_node; |
251 |
|
for my $n (@change_od) { |
252 |
|
$$n->{owner_document} = $self; |
253 |
|
Scalar::Util::weaken ($$n->{owner_document}); |
254 |
|
if ($$n->{user_data}) { |
255 |
|
push @ud_node, $n; |
256 |
|
} |
257 |
|
} |
258 |
|
|
259 |
; |
for my $src (@ud_node) { |
260 |
} |
my $src_ud = $$src->{user_data}; |
261 |
$anode = $anode-> |
for my $key (keys %{$src_ud}) { |
262 |
previous_sibling |
my $dh = $src_ud->{$key}->[1]; |
263 |
; |
if ($dh) { |
264 |
|
$dh->(5, $key, $src_ud->{$key}->[0], $src, undef); # NODE_ADOPTED |
265 |
} |
} |
266 |
} # has_dt |
} |
267 |
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
268 |
|
|
269 |
|
return $source; |
270 |
|
} # adopt_node |
271 |
|
|
272 |
my |
sub append_child ($$) { |
273 |
$strict = $self-> |
## NOTE: Overrides |Node|'s implementation. |
274 |
strict_error_checking |
my $self = $_[0]; |
275 |
; |
|
276 |
|
## NOTE: |$self_od| code here in some $self->node_type. |
277 |
|
|
278 |
## -- Node Type check |
## -- Node Type check |
279 |
my @new_child; |
my @new_child; |
280 |
if ({ |
my $new_child_parent; |
281 |
3 => (not $strictc), |
if ($_[1]->node_type == 11) { # DOCUMENT_FRAGMENT_NODE |
282 |
5 => (not $strictc), |
push @new_child, @{$_[1]->child_nodes}; |
283 |
1 => 1, |
$new_child_parent = $_[1]; |
|
4 => (not $strictc), |
|
|
7 => 1, |
|
|
8 => 1, |
|
|
10 => 1, |
|
|
}->{$child_nt}) { |
|
|
push @new_child, $newChild; |
|
|
} elsif ($child_nt == |
|
|
11 |
|
|
) { |
|
|
for my $cn (@{$newChild-> |
|
|
child_nodes |
|
|
}) { |
|
|
unless ({ |
|
|
3 => (not $strictc), |
|
|
5 => (not $strictc), |
|
|
1 => 1, |
|
|
4 => (not $strictc), |
|
|
7 => 1, |
|
|
8 => 1, |
|
|
10 => 1, |
|
|
}->{$cn-> |
|
|
node_type |
|
|
}) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
push @new_child, $cn; |
|
|
} |
|
284 |
} else { |
} else { |
285 |
|
@new_child = ($_[1]); |
286 |
|
$new_child_parent = $_[1]->parent_node; |
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
287 |
} |
} |
288 |
|
|
289 |
my $nc_parent = @new_child ? $new_child[0]-> |
## NOTE: Depends on $self->node_type: |
290 |
parent_node |
if ($$self->{strict_error_checking}) { |
291 |
: |
my $child_od = $_[1]->owner_document || $_[1]; # might be DocumentType |
292 |
|
if ($self ne $child_od and $child_od->node_type != 10) { |
293 |
undef |
report Message::DOM::DOMException # DOCUMENT_TYPE_NODE |
294 |
; |
-object => $self, |
295 |
if ($strict) { |
-type => 'WRONG_DOCUMENT_ERR', |
296 |
## -- Wrong-document check |
-subtype => 'EXTERNAL_OBJECT_ERR'; |
297 |
unless ($self eq $child_od) { |
} |
298 |
|
|
299 |
|
if ($$self->{manakai_read_only} or |
300 |
{ |
(@new_child and defined $new_child_parent and |
301 |
|
$$new_child_parent->{manakai_read_only})) { |
302 |
local $Error::Depth = $Error::Depth - 1; |
report Message::DOM::DOMException |
303 |
|
-object => $self, |
304 |
{ |
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
305 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
306 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
} |
307 |
|
|
308 |
|
## NOTE: Only in |Document|: |
309 |
} |
my $strict_children = $self->dom_config->get_parameter |
310 |
|
(q<http://suika.fam.cx/www/2006/dom-config/strict-document-children>); |
311 |
|
if ($strict_children) { |
312 |
;} |
my $has_el; |
313 |
|
my $has_dt; |
314 |
; |
my $child_nt = $_[1]->node_type; |
315 |
} |
if ($child_nt == 1) { # ELEMENT_NODE |
316 |
|
$has_el = 1; |
317 |
## -- Read-onlyness check |
} elsif ($child_nt == 10) { # DOCUMENT_TYPE_NODE |
318 |
if ($self-> |
$has_dt = 1; |
319 |
manakai_read_only |
} elsif ($child_nt == 11) { # DOCUMENT_FRAGMENT_NODE |
320 |
) { |
for my $cn (@{$_[1]->child_nodes}) { |
321 |
|
my $cnt = $cn->node_type; |
322 |
|
if ($cnt == 1) { # ELEMENT_NODE |
323 |
{ |
if ($has_el) { |
324 |
|
report Message::DOM::DOMException |
325 |
local $Error::Depth = $Error::Depth - 1; |
-object => $self, |
326 |
|
-type => 'HIERARCHY_REQUEST_ERR', |
327 |
{ |
-subtype => 'CHILD_NODE_TYPE_ERR'; |
328 |
|
} |
329 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
$has_el = 1; |
330 |
|
} elsif ($cnt == 10) { # DOCUMENT_TYPE_NODE |
331 |
|
## NOTE: |DocumentType| node cannot be contained in |
332 |
} |
## |DocumentFragment| in strict mode. |
333 |
|
if ($has_dt) { |
334 |
|
report Message::DOM::DOMException |
335 |
;} |
-object => $self, |
336 |
|
-type => 'HIERARCHY_REQUEST_ERR', |
337 |
; |
-subtype => 'CHILD_NODE_TYPE_ERR'; |
338 |
|
} |
339 |
|
$has_dt = 1; |
340 |
|
} |
341 |
|
} |
342 |
|
} |
343 |
|
|
344 |
|
if ($has_el) { |
345 |
|
my $anode = $self->last_child; |
346 |
|
while (defined $anode) { |
347 |
|
if ($anode->node_type == 1) { # ELEMENT_NODE |
348 |
|
report Message::DOM::DOMException |
349 |
|
-object => $self, |
350 |
|
-type => 'HIERARCHY_REQUEST_ERR', |
351 |
|
-subtype => 'CHILD_NODE_TYPE_ERR'; |
352 |
|
} |
353 |
|
$anode = $anode->previous_sibling; |
354 |
|
} |
355 |
|
} # has_el |
356 |
|
if ($has_dt) { |
357 |
|
my $anode = $self->last_child; |
358 |
|
while (defined $anode) { |
359 |
|
my $ant = $anode->node_type; |
360 |
|
if ($ant == 1 or $ant == 10) { # ELEMENT_NODE or DOCUMENT_TYPE_NODE |
361 |
|
report Message::DOM::DOMException |
362 |
|
-object => $self, |
363 |
|
-type => 'HIERARCHY_REQUEST_ERR', |
364 |
|
-subtype => 'CHILD_NODE_TYPE_ERR'; |
365 |
|
} |
366 |
|
$anode = $anode->previous_sibling; |
367 |
|
} |
368 |
|
} # has_dt |
369 |
} |
} |
|
if (@new_child) { |
|
|
if ($nc_parent and |
|
|
$nc_parent-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
370 |
|
|
371 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
for my $cn (@new_child) { |
372 |
|
unless ({ |
373 |
|
3, (not $strict_children), # TEXT_NODE |
374 |
} |
5, (not $strict_children), # ENTITY_REFERENCE_NODE |
375 |
|
1, 1, # ELEMENT_NODE |
376 |
|
4, (not $strict_children), # CDATA_SECTION_NODE |
377 |
;} |
7, 1, # PROCESSING_INSTRUCTION_NODE |
378 |
|
8, 1, # COMMENT_NODE |
379 |
; |
10, 1, # DOCUMENT_TYPE_NODE |
380 |
|
}->{$cn->node_type}) { |
381 |
|
report Message::DOM::DOMException |
382 |
|
-object => $self, |
383 |
|
-type => 'HIERARCHY_REQUEST_ERR', |
384 |
|
-subtype => 'CHILD_NODE_TYPE_ERR'; |
385 |
} |
} |
386 |
} |
} |
|
} |
|
387 |
|
|
388 |
## -- Insert at... |
## NOTE: Ancestor check here in |Node|. |
389 |
my $index = -1; # last |
} |
|
|
|
390 |
|
|
391 |
; # FOR !tc:ForAppendChild |
## NOTE: "Insert at" code only in insert_before and replace_child |
392 |
|
|
393 |
## -- Removes from parent |
## -- Removes from parent |
394 |
if ($nc_parent) { |
if ($new_child_parent) { |
395 |
if ($child_nt == |
if (@new_child == 1) { |
396 |
11 |
my $v = $$new_child_parent->{child_nodes}; |
|
) { |
|
|
$$newChild->{ |
|
|
'child' |
|
|
} = []; |
|
|
} else { |
|
|
my $v = $$nc_parent->{ |
|
|
'child' |
|
|
}; |
|
397 |
RP: for my $i (0..$#$v) { |
RP: for my $i (0..$#$v) { |
398 |
if ($v->[$i] eq $new_child[0]) { |
if ($v->[$i] eq $new_child[0]) { |
399 |
splice @$v, $i, 1, (); |
splice @$v, $i, 1, (); |
400 |
last RP; |
last RP; |
401 |
} |
} |
402 |
} # RP |
} # RP |
403 |
|
} else { |
404 |
|
@{$$new_child_parent->{child_nodes}} = (); |
405 |
} |
} |
406 |
} |
} |
407 |
|
|
408 |
## -- Rewrite the |parentNode| properties |
## -- Rewrite the |parentNode| properties |
409 |
for my $nc (@new_child) { |
for my $nc (@new_child) { |
410 |
$$nc->{ |
$$nc->{parent_node} = $self; |
411 |
'parent' |
Scalar::Util::weaken ($$nc->{parent_node}); |
|
} = $self; |
|
|
Scalar::Util::weaken ($$nc->{ |
|
|
'parent' |
|
|
}); |
|
412 |
} |
} |
413 |
|
|
414 |
my $children = $$self->{ |
## NOTE: Depends on method: |
415 |
'child' |
push @{$$self->{child_nodes}}, @new_child; |
|
}; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
## -- Adds to children list |
|
|
push @$children, @new_child; |
|
|
$r = $newChild; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
if ($child_nt == |
|
|
10 and |
|
|
|
|
|
not defined $newChild-> |
|
|
owner_document |
|
|
) { |
|
|
CORE::delete $$newChild->{ |
|
|
'impl' |
|
|
}; |
|
|
$$newChild->{ |
|
|
'od' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$newChild->{ |
|
|
'od' |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub insert_before ($$;$) { |
|
|
my ($self, $newChild, $refChild) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$strictc = $self-> |
|
|
dom_config |
|
|
|
|
|
-> |
|
|
get_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/strict-document-children' |
|
|
); |
|
|
my $child_od = $newChild-> |
|
|
owner_document |
|
|
|| $self; |
|
|
my $child_nt = $newChild-> |
|
|
node_type |
|
|
; |
|
|
if ($strictc and $self-> |
|
|
strict_error_checking |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
416 |
|
|
417 |
|
## NOTE: Only in |Document|. |
418 |
|
for (@new_child) { |
419 |
|
delete $$_->{implementation}; |
420 |
|
$$_->{owner_document} = $self; |
421 |
|
Scalar::Util::weaken ($$_->{owner_document}); |
422 |
|
} |
423 |
|
|
424 |
my |
return $_[1]; |
425 |
$has_el; |
} # apepnd_child |
|
my $has_dt; |
|
|
if ($child_nt == |
|
|
1 |
|
|
) { |
|
|
$has_el = |
|
|
1 |
|
|
; |
|
|
} elsif ($child_nt == |
|
|
10 |
|
|
) { |
|
|
$has_dt = |
|
|
1 |
|
|
; |
|
|
} elsif ($child_nt == |
|
|
11 |
|
|
) { |
|
|
for my $cn (@{$newChild-> |
|
|
child_nodes |
|
|
}) { |
|
|
my $cnt = $cn-> |
|
|
node_type |
|
|
; |
|
|
if ($cnt == |
|
|
1 |
|
|
) { |
|
|
if ($has_el) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
426 |
|
|
427 |
|
sub manakai_append_text ($$) { |
428 |
|
my $self = shift; |
429 |
|
if ($$self->{'http://suika.fam.cx/www/2006/dom-config/strict-document-children'}) { |
430 |
|
# |
431 |
|
} else { |
432 |
|
local $Error::Depth = $Error::Depth + 1; |
433 |
|
return $self->SUPER::manakai_append_text (@_); |
434 |
|
} |
435 |
|
} # manakai_append_text |
436 |
|
|
437 |
} |
sub insert_before ($$) { |
438 |
|
## NOTE: Overrides |Node|'s implementation. |
439 |
|
my $self = $_[0]; |
440 |
|
|
441 |
|
## NOTE: |$self_od| code here depending on $self->node_type. |
442 |
|
|
443 |
;} |
## -- Node Type check |
444 |
|
my @new_child; |
445 |
|
my $new_child_parent; |
446 |
|
if ($_[1]->node_type == 11) { # DOCUMENT_FRAGMENT_NODE |
447 |
|
push @new_child, @{$_[1]->child_nodes}; |
448 |
|
$new_child_parent = $_[1]; |
449 |
|
} else { |
450 |
|
@new_child = ($_[1]); |
451 |
|
$new_child_parent = $_[1]->parent_node; |
452 |
|
} |
453 |
|
|
454 |
; |
## NOTE: Depends on $self->node_type: |
455 |
|
if ($$self->{strict_error_checking}) { |
456 |
|
my $child_od = $_[1]->owner_document || $_[1]; # might be DocumentType |
457 |
|
if ($self ne $child_od and $child_od->node_type != 10) { |
458 |
|
report Message::DOM::DOMException # DOCUMENT_TYPE_NODE |
459 |
|
-object => $self, |
460 |
|
-type => 'WRONG_DOCUMENT_ERR', |
461 |
|
-subtype => 'EXTERNAL_OBJECT_ERR'; |
462 |
|
} |
463 |
|
|
464 |
|
if ($$self->{manakai_read_only} or |
465 |
|
(@new_child and defined $new_child_parent and |
466 |
|
$$new_child_parent->{manakai_read_only})) { |
467 |
|
report Message::DOM::DOMException |
468 |
|
-object => $self, |
469 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
470 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
471 |
|
} |
472 |
|
|
473 |
|
## NOTE: Only in |Document|: |
474 |
|
my $strict_children = $self->dom_config->get_parameter |
475 |
|
(q<http://suika.fam.cx/www/2006/dom-config/strict-document-children>); |
476 |
|
if ($strict_children) { |
477 |
|
my $has_el; |
478 |
|
my $has_dt; |
479 |
|
my $child_nt = $_[1]->node_type; |
480 |
|
if ($child_nt == 1) { # ELEMENT_NODE |
481 |
|
$has_el = 1; |
482 |
|
} elsif ($child_nt == 10) { # DOCUMENT_TYPE_NODE |
483 |
|
$has_dt = 1; |
484 |
|
} elsif ($child_nt == 11) { # DOCUMENT_FRAGMENT_NODE |
485 |
|
for my $cn (@{$_[1]->child_nodes}) { |
486 |
|
my $cnt = $cn->node_type; |
487 |
|
if ($cnt == 1) { # ELEMENT_NODE |
488 |
|
if ($has_el) { |
489 |
|
report Message::DOM::DOMException |
490 |
|
-object => $self, |
491 |
|
-type => 'HIERARCHY_REQUEST_ERR', |
492 |
|
-subtype => 'CHILD_NODE_TYPE_ERR'; |
493 |
|
} |
494 |
|
$has_el = 1; |
495 |
|
} elsif ($cnt == 10) { # DOCUMENT_TYPE_NODE |
496 |
|
## NOTE: |DocumentType| node cannot be contained in |
497 |
|
## |DocumentFragment| in strict mode. |
498 |
|
if ($has_dt) { |
499 |
|
report Message::DOM::DOMException |
500 |
|
-object => $self, |
501 |
|
-type => 'HIERARCHY_REQUEST_ERR', |
502 |
|
-subtype => 'CHILD_NODE_TYPE_ERR'; |
503 |
|
} |
504 |
|
$has_dt = 1; |
505 |
} |
} |
|
$has_el = |
|
|
1 |
|
|
; |
|
506 |
} |
} |
|
# DocumentType node cannot be contained in DocumentFragments |
|
507 |
} |
} |
|
} |
|
|
|
|
|
if ($has_el) { |
|
|
my $anode = $refChild ? $refChild-> |
|
|
previous_sibling |
|
|
: |
|
|
$self-> |
|
|
last_child |
|
|
; |
|
|
while (defined $anode) { |
|
|
if ($anode-> |
|
|
node_type |
|
|
== |
|
|
1 |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
$anode = $anode-> |
|
|
previous_sibling |
|
|
; |
|
|
} |
|
|
$anode = $refChild; |
|
|
while (defined $anode) { |
|
|
my $ant = $anode-> |
|
|
node_type |
|
|
; |
|
|
if ($ant == |
|
|
1 |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
508 |
|
|
509 |
local $Error::Depth = $Error::Depth - 1; |
## ISSUE: This code is wrong. Old manakai's implementation |
510 |
|
## is better, but it is also wrong in some edge cases. |
511 |
{ |
## Maybe we should remove these code entirely. DOM3Core |
512 |
|
## conformance is not important for this bit. It only makes |
513 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
## things too complex. Same for replace_child's code. |
514 |
|
if ($has_el) { |
515 |
|
my $anode = $self->last_child; |
516 |
} |
while (defined $anode) { |
517 |
|
if ($anode->node_type == 1) { # ELEMENT_NODE |
518 |
|
report Message::DOM::DOMException |
519 |
;} |
-object => $self, |
520 |
|
-type => 'HIERARCHY_REQUEST_ERR', |
521 |
; |
-subtype => 'CHILD_NODE_TYPE_ERR'; |
522 |
} elsif ($ant == |
} |
523 |
10 |
$anode = $anode->previous_sibling; |
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#HIERARCHY_WRONG_DOCTYPE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
$anode = $anode-> |
|
|
next_sibling |
|
|
; |
|
|
} |
|
|
} # has_el |
|
|
if ($has_dt) { |
|
|
my $anode = $refChild ? $refChild-> |
|
|
previous_sibling |
|
|
: |
|
|
$self-> |
|
|
last_child |
|
|
; |
|
|
while (defined $anode) { |
|
|
my $ant = $anode-> |
|
|
node_type |
|
|
; |
|
|
if ($ant == |
|
|
1 |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#HIERARCHY_WRONG_DOCTYPE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} elsif ($ant == |
|
|
10 |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOCTYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
524 |
} |
} |
525 |
$anode = $anode-> |
} # has_el |
526 |
previous_sibling |
if ($has_dt) { |
527 |
; |
my $anode = $self->last_child; |
528 |
} |
while (defined $anode) { |
529 |
$anode = $refChild; |
my $ant = $anode->node_type; |
530 |
while (defined $anode) { |
if ($ant == 1 or $ant == 10) { # ELEMENT_NODE or DOCUMENT_TYPE_NODE |
531 |
if ($anode-> |
report Message::DOM::DOMException |
532 |
node_type |
-object => $self, |
533 |
|
-type => 'HIERARCHY_REQUEST_ERR', |
534 |
== |
-subtype => 'CHILD_NODE_TYPE_ERR'; |
535 |
10 |
} |
536 |
) { |
$anode = $anode->previous_sibling; |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOCTYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
537 |
} |
} |
538 |
$anode = $anode-> |
} # has_dt |
539 |
next_sibling |
} |
|
; |
|
|
} |
|
|
} # has_dt |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
$strict = $self-> |
|
|
strict_error_checking |
|
|
; |
|
540 |
|
|
541 |
## -- Node Type check |
for my $cn (@new_child) { |
|
my @new_child; |
|
|
if ({ |
|
|
3 => (not $strictc), |
|
|
5 => (not $strictc), |
|
|
1 => 1, |
|
|
4 => (not $strictc), |
|
|
7 => 1, |
|
|
8 => 1, |
|
|
10 => 1, |
|
|
}->{$child_nt}) { |
|
|
push @new_child, $newChild; |
|
|
} elsif ($child_nt == |
|
|
11 |
|
|
) { |
|
|
for my $cn (@{$newChild-> |
|
|
child_nodes |
|
|
}) { |
|
542 |
unless ({ |
unless ({ |
543 |
3 => (not $strictc), |
3, (not $strict_children), # TEXT_NODE |
544 |
5 => (not $strictc), |
5, (not $strict_children), # ENTITY_REFERENCE_NODE |
545 |
1 => 1, |
1, 1, # ELEMENT_NODE |
546 |
4 => (not $strictc), |
4, (not $strict_children), # CDATA_SECTION_NODE |
547 |
7 => 1, |
7, 1, # PROCESSING_INSTRUCTION_NODE |
548 |
8 => 1, |
8, 1, # COMMENT_NODE |
549 |
10 => 1, |
10, 1, # DOCUMENT_TYPE_NODE |
550 |
}->{$cn-> |
}->{$cn->node_type}) { |
551 |
node_type |
report Message::DOM::DOMException |
552 |
}) { |
-object => $self, |
553 |
|
-type => 'HIERARCHY_REQUEST_ERR', |
554 |
|
-subtype => 'CHILD_NODE_TYPE_ERR'; |
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
555 |
} |
} |
|
push @new_child, $cn; |
|
556 |
} |
} |
|
} else { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
557 |
|
|
558 |
|
## NOTE: Ancestor check here in |Node|. |
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
559 |
} |
} |
|
|
|
|
my $nc_parent = @new_child ? $new_child[0]-> |
|
|
parent_node |
|
|
: |
|
|
|
|
|
undef |
|
|
; |
|
|
if ($strict) { |
|
|
## -- Wrong-document check |
|
|
unless ($self eq $child_od) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
## -- Read-onlyness check |
|
|
if ($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
if (@new_child) { |
|
|
if ($nc_parent and |
|
|
$nc_parent-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
## -- Insert at... |
|
|
my $index = -1; # last |
|
560 |
|
|
561 |
|
## -- Insert at... ## NOTE: Only in insert_before and replace_child |
562 |
{ |
my $index = -1; # last |
563 |
|
if (defined $_[2]) { |
564 |
|
## error if $_[1] eq $_[2]; |
565 |
# tc:ForAppendChild & tc:ForReplaceChild |
|
566 |
if (defined $refChild) { |
my $cns = $self->child_nodes; |
567 |
if ($refChild eq $newChild) { |
my $cnsl = @$cns; |
568 |
|
C: { |
569 |
|
$index = 0; |
570 |
{ |
for my $i (0..($cnsl-1)) { |
571 |
|
my $cn = $cns->[$i]; |
572 |
|
if ($cn eq $_[2]) { |
573 |
{ |
$index += $i; |
574 |
|
last C; |
575 |
local $Error::Depth = $Error::Depth - 1; |
} elsif ($cn eq $_[1]) { |
576 |
|
$index = -1; # offset |
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#insert-before-itself', 'rdata' => $refChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
my $cns = $self-> |
|
|
child_nodes |
|
|
; |
|
|
my $cnsl = @$cns; |
|
|
C: { |
|
|
$index = 0; |
|
|
for my $i (0..($cnsl-1)) { |
|
|
my $cn = $cns->[$i]; |
|
|
if ($cn eq $refChild) { |
|
|
$index += $i; |
|
|
last C; |
|
|
} elsif ($cn eq $newChild) { |
|
|
$index = -1; # offset |
|
|
} |
|
577 |
} |
} |
578 |
|
} |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'refChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $refChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
; |
|
|
} # C |
|
|
} else { # |oldChild| is not defined |
|
579 |
|
|
580 |
|
report Message::DOM::DOMException |
581 |
; |
-object => $self, |
582 |
} |
-type => 'NOT_FOUND_ERR', |
583 |
|
-subtype => 'NOT_CHILD_ERR'; |
584 |
|
} # C |
585 |
|
} |
586 |
} |
## NOTE: "else" only in replace_child |
|
|
|
|
; # FOR !tc:ForAppendChild |
|
587 |
|
|
588 |
## -- Removes from parent |
## -- Removes from parent |
589 |
if ($nc_parent) { |
if ($new_child_parent) { |
590 |
if ($child_nt == |
if (@new_child == 1) { |
591 |
11 |
my $v = $$new_child_parent->{child_nodes}; |
|
) { |
|
|
$$newChild->{ |
|
|
'child' |
|
|
} = []; |
|
|
} else { |
|
|
my $v = $$nc_parent->{ |
|
|
'child' |
|
|
}; |
|
592 |
RP: for my $i (0..$#$v) { |
RP: for my $i (0..$#$v) { |
593 |
if ($v->[$i] eq $new_child[0]) { |
if ($v->[$i] eq $new_child[0]) { |
594 |
splice @$v, $i, 1, (); |
splice @$v, $i, 1, (); |
595 |
last RP; |
last RP; |
596 |
} |
} |
597 |
} # RP |
} # RP |
598 |
|
} else { |
599 |
|
@{$$new_child_parent->{child_nodes}} = (); |
600 |
} |
} |
601 |
} |
} |
602 |
|
|
603 |
## -- Rewrite the |parentNode| properties |
## -- Rewrite the |parentNode| properties |
604 |
for my $nc (@new_child) { |
for my $nc (@new_child) { |
605 |
$$nc->{ |
$$nc->{parent_node} = $self; |
606 |
'parent' |
Scalar::Util::weaken ($$nc->{parent_node}); |
|
} = $self; |
|
|
Scalar::Util::weaken ($$nc->{ |
|
|
'parent' |
|
|
}); |
|
607 |
} |
} |
608 |
|
|
609 |
my $children = $$self->{ |
## NOTE: Depends on method: |
610 |
'child' |
if ($index == -1) { |
611 |
}; |
push @{$$self->{child_nodes}}, @new_child; |
612 |
|
} else { |
613 |
|
splice @{$$self->{child_nodes}}, $index, 0, @new_child; |
614 |
|
} |
|
; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
## -- Adds to children list |
|
|
if ($index == -1) { |
|
|
push @$children, @new_child; |
|
|
} else { |
|
|
splice @$children, $index, 0, @new_child; |
|
|
} |
|
|
$r = $newChild; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
if ($child_nt == |
|
|
10 and |
|
|
|
|
|
not defined $newChild-> |
|
|
owner_document |
|
|
) { |
|
|
CORE::delete $$newChild->{ |
|
|
'impl' |
|
|
}; |
|
|
$$newChild->{ |
|
|
'od' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$newChild->{ |
|
|
'od' |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub replace_child ($$$) { |
|
|
my ($self, $newChild, $oldChild) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
my |
|
|
$strictc = $self-> |
|
|
dom_config |
|
|
|
|
|
-> |
|
|
get_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/strict-document-children' |
|
|
); |
|
|
my $child_od = $newChild-> |
|
|
owner_document |
|
|
|| $self; |
|
|
my $child_nt = $newChild-> |
|
|
node_type |
|
|
; |
|
|
if ($strictc and $self-> |
|
|
strict_error_checking |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
615 |
|
|
616 |
my |
## NOTE: Only in |Document|. |
617 |
$has_el; |
for (@new_child) { |
618 |
my $has_dt; |
delete $$_->{implementation}; |
619 |
if ($child_nt == |
$$_->{owner_document} = $self; |
620 |
1 |
Scalar::Util::weaken ($$_->{owner_document}); |
621 |
) { |
} |
|
$has_el = |
|
|
1 |
|
|
; |
|
|
} elsif ($child_nt == |
|
|
10 |
|
|
) { |
|
|
$has_dt = |
|
|
1 |
|
|
; |
|
|
} elsif ($child_nt == |
|
|
11 |
|
|
) { |
|
|
for my $cn (@{$newChild-> |
|
|
child_nodes |
|
|
}) { |
|
|
my $cnt = $cn-> |
|
|
node_type |
|
|
; |
|
|
if ($cnt == |
|
|
1 |
|
|
) { |
|
|
if ($has_el) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
622 |
|
|
623 |
|
return $_[1]; |
624 |
|
} # insert_before |
625 |
|
|
626 |
} |
sub replace_child ($$) { |
627 |
|
## NOTE: Overrides |Node|'s implementation. |
628 |
|
my $self = $_[0]; |
629 |
|
|
630 |
|
## NOTE: |$self_od| code here depending on $self->node_type. |
631 |
|
|
632 |
;} |
## -- Node Type check |
633 |
|
my @new_child; |
634 |
|
my $new_child_parent; |
635 |
|
if ($_[1]->node_type == 11) { # DOCUMENT_FRAGMENT_NODE |
636 |
|
push @new_child, @{$_[1]->child_nodes}; |
637 |
|
$new_child_parent = $_[1]; |
638 |
|
} else { |
639 |
|
@new_child = ($_[1]); |
640 |
|
$new_child_parent = $_[1]->parent_node; |
641 |
|
} |
642 |
|
|
643 |
; |
## NOTE: Depends on $self->node_type: |
644 |
|
if ($$self->{strict_error_checking}) { |
645 |
|
my $child_od = $_[1]->owner_document || $_[1]; # might be DocumentType |
646 |
|
if ($self ne $child_od and $child_od->node_type != 10) { |
647 |
|
report Message::DOM::DOMException # DOCUMENT_TYPE_NODE |
648 |
|
-object => $self, |
649 |
|
-type => 'WRONG_DOCUMENT_ERR', |
650 |
|
-subtype => 'EXTERNAL_OBJECT_ERR'; |
651 |
|
} |
652 |
|
|
653 |
|
if ($$self->{manakai_read_only} or |
654 |
|
(@new_child and defined $new_child_parent and |
655 |
|
$$new_child_parent->{manakai_read_only})) { |
656 |
|
report Message::DOM::DOMException |
657 |
|
-object => $self, |
658 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
659 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
660 |
|
} |
661 |
|
|
662 |
|
## NOTE: Only in |Document|: |
663 |
|
my $strict_children = $self->dom_config->get_parameter |
664 |
|
(q<http://suika.fam.cx/www/2006/dom-config/strict-document-children>); |
665 |
|
if ($strict_children) { |
666 |
|
my $has_el; |
667 |
|
my $has_dt; |
668 |
|
my $child_nt = $_[1]->node_type; |
669 |
|
if ($child_nt == 1) { # ELEMENT_NODE |
670 |
|
$has_el = 1; |
671 |
|
} elsif ($child_nt == 10) { # DOCUMENT_TYPE_NODE |
672 |
|
$has_dt = 1; |
673 |
|
} elsif ($child_nt == 11) { # DOCUMENT_FRAGMENT_NODE |
674 |
|
for my $cn (@{$_[1]->child_nodes}) { |
675 |
|
my $cnt = $cn->node_type; |
676 |
|
if ($cnt == 1) { # ELEMENT_NODE |
677 |
|
if ($has_el) { |
678 |
|
report Message::DOM::DOMException |
679 |
|
-object => $self, |
680 |
|
-type => 'HIERARCHY_REQUEST_ERR', |
681 |
|
-subtype => 'CHILD_NODE_TYPE_ERR'; |
682 |
|
} |
683 |
|
$has_el = 1; |
684 |
|
} elsif ($cnt == 10) { # DOCUMENT_TYPE_NODE |
685 |
|
## NOTE: |DocumentType| node cannot be contained in |
686 |
|
## |DocumentFragment| in strict mode. |
687 |
|
if ($has_dt) { |
688 |
|
report Message::DOM::DOMException |
689 |
|
-object => $self, |
690 |
|
-type => 'HIERARCHY_REQUEST_ERR', |
691 |
|
-subtype => 'CHILD_NODE_TYPE_ERR'; |
692 |
|
} |
693 |
|
$has_dt = 1; |
694 |
} |
} |
|
$has_el = |
|
|
1 |
|
|
; |
|
|
} |
|
|
# DocumentType node cannot be contained in DocumentFragments |
|
|
} |
|
|
} |
|
|
|
|
|
if ($has_el) { |
|
|
my $anode = $oldChild-> |
|
|
previous_sibling |
|
|
; |
|
|
while (defined $anode) { |
|
|
if ($anode-> |
|
|
node_type |
|
|
== |
|
|
1 |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
$anode = $anode-> |
|
|
previous_sibling |
|
|
; |
|
|
} |
|
|
$anode = $oldChild-> |
|
|
next_sibling |
|
|
; |
|
|
while (defined $anode) { |
|
|
my $ant = $anode-> |
|
|
node_type |
|
|
; |
|
|
if ($ant == |
|
|
1 |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOC_ELEMENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} elsif ($ant == |
|
|
10 |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#HIERARCHY_WRONG_DOCTYPE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
695 |
} |
} |
|
$anode = $anode-> |
|
|
next_sibling |
|
|
; |
|
696 |
} |
} |
697 |
} # has_el |
|
698 |
if ($has_dt) { |
if ($has_el) { |
699 |
my $anode = $oldChild-> |
my $anode = $self->last_child; |
700 |
previous_sibling |
while (defined $anode) { |
701 |
; |
if ($anode->node_type == 1) { # ELEMENT_NODE |
702 |
while (defined $anode) { |
report Message::DOM::DOMException |
703 |
my $ant = $anode-> |
-object => $self, |
704 |
node_type |
-type => 'HIERARCHY_REQUEST_ERR', |
705 |
; |
-subtype => 'CHILD_NODE_TYPE_ERR'; |
706 |
if ($ant == |
} |
707 |
1 |
$anode = $anode->previous_sibling; |
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#HIERARCHY_WRONG_DOCTYPE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} elsif ($ant == |
|
|
10 |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOCTYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
708 |
} |
} |
709 |
$anode = $anode-> |
} # has_el |
710 |
previous_sibling |
if ($has_dt) { |
711 |
; |
my $anode = $self->last_child; |
712 |
} |
while (defined $anode) { |
713 |
$anode = $oldChild-> |
my $ant = $anode->node_type; |
714 |
next_sibling |
if ($ant == 1 or $ant == 10) { # ELEMENT_NODE or DOCUMENT_TYPE_NODE |
715 |
; |
report Message::DOM::DOMException |
716 |
while (defined $anode) { |
-object => $self, |
717 |
if ($anode-> |
-type => 'HIERARCHY_REQUEST_ERR', |
718 |
node_type |
-subtype => 'CHILD_NODE_TYPE_ERR'; |
719 |
|
} |
720 |
== |
$anode = $anode->previous_sibling; |
|
10 |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_SECOND_DOCTYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
721 |
} |
} |
722 |
$anode = $anode-> |
} # has_dt |
723 |
next_sibling |
} |
|
; |
|
|
} |
|
|
} # has_dt |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
$strict = $self-> |
|
|
strict_error_checking |
|
|
; |
|
724 |
|
|
725 |
## -- Node Type check |
for my $cn (@new_child) { |
|
my @new_child; |
|
|
if ({ |
|
|
3 => (not $strictc), |
|
|
5 => (not $strictc), |
|
|
1 => 1, |
|
|
4 => (not $strictc), |
|
|
7 => 1, |
|
|
8 => 1, |
|
|
10 => 1, |
|
|
}->{$child_nt}) { |
|
|
push @new_child, $newChild; |
|
|
} elsif ($child_nt == |
|
|
11 |
|
|
) { |
|
|
for my $cn (@{$newChild-> |
|
|
child_nodes |
|
|
}) { |
|
726 |
unless ({ |
unless ({ |
727 |
3 => (not $strictc), |
3, (not $strict_children), # TEXT_NODE |
728 |
5 => (not $strictc), |
5, (not $strict_children), # ENTITY_REFERENCE_NODE |
729 |
1 => 1, |
1, 1, # ELEMENT_NODE |
730 |
4 => (not $strictc), |
4, (not $strict_children), # CDATA_SECTION_NODE |
731 |
7 => 1, |
7, 1, # PROCESSING_INSTRUCTION_NODE |
732 |
8 => 1, |
8, 1, # COMMENT_NODE |
733 |
10 => 1, |
10, 1, # DOCUMENT_TYPE_NODE |
734 |
}->{$cn-> |
}->{$cn->node_type}) { |
735 |
node_type |
report Message::DOM::DOMException |
736 |
}) { |
-object => $self, |
737 |
|
-type => 'HIERARCHY_REQUEST_ERR', |
738 |
|
-subtype => 'CHILD_NODE_TYPE_ERR'; |
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
739 |
} |
} |
|
push @new_child, $cn; |
|
|
} |
|
|
} else { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
my $nc_parent = @new_child ? $new_child[0]-> |
|
|
parent_node |
|
|
: |
|
|
|
|
|
undef |
|
|
; |
|
|
if ($strict) { |
|
|
## -- Wrong-document check |
|
|
unless ($self eq $child_od) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
740 |
} |
} |
741 |
|
|
742 |
## -- Read-onlyness check |
## NOTE: Ancestor check here in |Node|. |
|
if ($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
if (@new_child) { |
|
|
if ($nc_parent and |
|
|
$nc_parent-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
} |
|
743 |
} |
} |
|
|
|
|
## -- Insert at... |
|
|
my $index = -1; # last |
|
744 |
|
|
745 |
|
## -- Insert at... ## NOTE: Only in insertBefore and replaceChild |
746 |
{ |
my $index = -1; # last |
747 |
|
if (defined $_[2]) { |
748 |
|
## error if $_[1] eq $_[2]; |
749 |
# tc:ForAppendChild & tc:ForReplaceChild |
|
750 |
if (defined $oldChild) { |
my $cns = $self->child_nodes; |
751 |
if ($oldChild eq $newChild) { |
my $cnsl = @$cns; |
752 |
|
C: { |
753 |
|
$index = 0; |
754 |
; |
for my $i (0..($cnsl-1)) { |
755 |
|
my $cn = $cns->[$i]; |
756 |
|
if ($cn eq $_[2]) { |
757 |
{ |
$index += $i; |
758 |
|
last C; |
759 |
|
} elsif ($cn eq $_[1]) { |
760 |
{ |
$index = -1; # offset |
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#replace-by-itself', 'rdata' => $oldChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
my $cns = $self-> |
|
|
child_nodes |
|
|
; |
|
|
my $cnsl = @$cns; |
|
|
C: { |
|
|
$index = 0; |
|
|
for my $i (0..($cnsl-1)) { |
|
|
my $cn = $cns->[$i]; |
|
|
if ($cn eq $oldChild) { |
|
|
$index += $i; |
|
|
last C; |
|
|
} elsif ($cn eq $newChild) { |
|
|
$index = -1; # offset |
|
|
} |
|
761 |
} |
} |
762 |
|
} |
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} # C |
|
|
} else { # |oldChild| is not defined |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
763 |
|
|
764 |
|
report Message::DOM::DOMException |
765 |
|
-object => $self, |
766 |
} |
-type => 'NOT_FOUND_ERR', |
767 |
|
-subtype => 'NOT_CHILD_ERR'; |
768 |
; |
} # C |
769 |
} |
} else { |
770 |
|
## NOTE: Only in replaceChild |
771 |
|
report Message::DOM::DOMException |
772 |
|
-object => $self, |
773 |
} |
-type => 'NOT_FOUND_ERR', |
774 |
|
-subtype => 'NOT_CHILD_ERR'; |
775 |
; # FOR !tc:ForAppendChild |
} |
776 |
|
|
777 |
## -- Removes from parent |
## -- Removes from parent |
778 |
if ($nc_parent) { |
if ($new_child_parent) { |
779 |
if ($child_nt == |
if (@new_child == 1) { |
780 |
11 |
my $v = $$new_child_parent->{child_nodes}; |
|
) { |
|
|
$$newChild->{ |
|
|
'child' |
|
|
} = []; |
|
|
} else { |
|
|
my $v = $$nc_parent->{ |
|
|
'child' |
|
|
}; |
|
781 |
RP: for my $i (0..$#$v) { |
RP: for my $i (0..$#$v) { |
782 |
if ($v->[$i] eq $new_child[0]) { |
if ($v->[$i] eq $new_child[0]) { |
783 |
splice @$v, $i, 1, (); |
splice @$v, $i, 1, (); |
784 |
last RP; |
last RP; |
785 |
} |
} |
786 |
} # RP |
} # RP |
787 |
|
} else { |
788 |
|
@{$$new_child_parent->{child_nodes}} = (); |
789 |
} |
} |
790 |
} |
} |
791 |
|
|
792 |
## -- Rewrite the |parentNode| properties |
## -- Rewrite the |parentNode| properties |
793 |
for my $nc (@new_child) { |
for my $nc (@new_child) { |
794 |
$$nc->{ |
$$nc->{parent_node} = $self; |
795 |
'parent' |
Scalar::Util::weaken ($$nc->{parent_node}); |
|
} = $self; |
|
|
Scalar::Util::weaken ($$nc->{ |
|
|
'parent' |
|
|
}); |
|
796 |
} |
} |
797 |
|
|
798 |
my $children = $$self->{ |
## NOTE: Depends on method: |
799 |
'child' |
splice @{$$self->{child_nodes}}, $index, 1, @new_child; |
800 |
}; |
delete ${$_[2]}->{parent_node}; |
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
## -- Replaces the node |
|
|
splice @$children, $index, 1, @new_child; |
|
|
CORE::delete $$oldChild->{ |
|
|
'parent' |
|
|
}; |
|
|
$r = $oldChild; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
if ($child_nt == |
|
|
10 and |
|
|
|
|
|
not defined $newChild-> |
|
|
owner_document |
|
|
) { |
|
|
CORE::delete $$newChild->{ |
|
|
'impl' |
|
|
}; |
|
|
$$newChild->{ |
|
|
'od' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$newChild->{ |
|
|
'od' |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub manakai_append_text ($$) { |
|
|
my ($self, $string) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
801 |
|
|
802 |
|
## NOTE: Only in |Document|. |
803 |
|
for (@new_child) { |
804 |
|
delete $$_->{implementation}; |
805 |
|
$$_->{owner_document} = $self; |
806 |
|
Scalar::Util::weaken ($$_->{owner_document}); |
807 |
|
} |
808 |
|
|
809 |
unless |
return $_[2]; |
810 |
($self-> |
} # replace_child |
|
dom_config |
|
811 |
|
|
812 |
-> |
## |Document| attributes |
|
get_parameter |
|
813 |
|
|
814 |
( |
## NOTE: A manakai extension. |
815 |
'http://suika.fam.cx/www/2006/dom-config/strict-document-children' |
sub all_declarations_processed ($;$); |
|
)) { |
|
|
my $lc = $self-> |
|
|
last_child |
|
|
; |
|
|
if (defined $lc and |
|
|
$lc-> |
|
|
node_type |
|
|
== |
|
|
3 |
|
|
) { |
|
|
$lc-> |
|
|
manakai_append_text |
|
816 |
|
|
817 |
(ref $string eq 'SCALAR' ? $string : \$string); |
sub doctype ($) { |
818 |
} else { |
my $self = $_[0]; |
819 |
my $text = $self-> |
for (@{$self->child_nodes}) { |
820 |
create_text_node |
if ($_->node_type == 10) { # DOCUMENT_TYPE_NODE |
821 |
|
return $_; |
|
(ref $string eq 'SCALAR' ? $$string : $string); |
|
|
$self-> |
|
|
append_child |
|
|
($text); |
|
822 |
} |
} |
823 |
} |
} |
824 |
$r = $self; |
return undef; |
825 |
|
} # doctype |
826 |
|
|
827 |
|
sub document_element ($) { |
828 |
} |
my $self = shift; |
829 |
|
for (@{$self->child_nodes}) { |
830 |
|
if ($_->node_type == 1) { # ELEMENT_NODE |
831 |
;} |
return $_; |
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub remove_child ($$) { |
|
|
my ($self, $oldChild) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
strict_error_checking and |
|
|
|
|
|
$self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'remove_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
F: |
|
|
{ |
|
|
my $i = -1; |
|
|
my $v = $$self->{ |
|
|
'child' |
|
|
}; |
|
|
for my $cld (@$v) { |
|
|
$i++; |
|
|
if ($cld eq $oldChild) { |
|
|
splice @$v, $i, 1, (); |
|
|
CORE::delete $$oldChild->{ |
|
|
'parent' |
|
|
}; |
|
|
$r = $oldChild; |
|
|
last F; |
|
832 |
} |
} |
833 |
} |
} |
834 |
|
return undef; |
835 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/removeChildImpl+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild; |
} # document_element |
|
|
|
|
; |
|
|
} # F |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub node_name ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
$r = '#document'; |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'node_name'; |
|
|
} |
|
|
} |
|
|
sub text_content ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
836 |
|
|
837 |
{ |
sub document_uri ($;$); |
838 |
|
|
839 |
|
sub dom_config ($) { |
840 |
|
require Message::DOM::DOMConfiguration; |
841 |
|
return bless \\($_[0]), 'Message::DOM::DOMConfiguration'; |
842 |
|
} # dom_config |
843 |
|
|
844 |
if |
sub manakai_entity_base_uri ($;$) { |
845 |
($self-> |
my $self = $_[0]; |
846 |
dom_config |
if (@_ > 1) { |
847 |
|
if ($$self->{strict_error_checking}) { |
848 |
-> |
if ($$self->{manakai_read_only}) { |
849 |
get_parameter |
report Message::DOM::DOMException |
850 |
|
-object => $self, |
851 |
( |
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
852 |
'http://suika.fam.cx/www/2006/dom-config/strict-document-children' |
-subtype => 'READ_ONLY_NODE_ERR'; |
|
)) { |
|
|
$r = |
|
|
undef |
|
|
; |
|
|
} else { |
|
|
$r = ''; |
|
|
my @target = @{$self-> |
|
|
child_nodes |
|
|
}; |
|
|
C: for my $node (@target) { |
|
|
my $nt = $node-> |
|
|
node_type |
|
|
; |
|
|
if ($nt == |
|
|
3 or |
|
|
|
|
|
$nt == |
|
|
4 |
|
|
) { |
|
|
$r .= $node-> |
|
|
data |
|
|
unless |
|
|
$node-> |
|
|
is_element_content_whitespace |
|
|
; |
|
|
} elsif ($nt == |
|
|
1 or |
|
|
|
|
|
$nt == |
|
|
5 |
|
|
) { |
|
|
unshift @target, @{$node-> |
|
|
child_nodes |
|
|
}; |
|
853 |
} |
} |
854 |
} |
} |
855 |
|
if (defined $_[1]) { |
856 |
|
$$self->{manakai_entity_base_uri} = ''.$_[1]; |
857 |
|
} else { |
858 |
|
delete $$self->{manakai_entity_base_uri}; |
859 |
|
} |
860 |
} |
} |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self, $given) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
dom_config |
|
|
|
|
|
-> |
|
|
get_parameter |
|
|
|
|
|
( |
|
|
'http://suika.fam.cx/www/2006/dom-config/strict-document-children' |
|
|
)) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#setting-node-value-no-effect', 'rdata' => $self, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'set', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'text_content'; |
|
|
|
|
|
; |
|
|
} else { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
861 |
|
|
862 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
if (defined $$self->{manakai_entity_base_uri}) { |
863 |
|
return $$self->{manakai_entity_base_uri}; |
864 |
; |
} else { |
865 |
} |
return $$self->{document_uri}; |
866 |
|
} |
867 |
|
} # manakai_entity_base_uri |
|
} |
|
|
|
|
|
; |
|
|
|
|
|
for my $__old_child (@{${$self}->{ |
|
|
'child' |
|
|
}}) { |
|
|
CORE::delete $$__old_child->{ |
|
|
'parent' |
|
|
}; |
|
|
} |
|
|
|
|
|
my @__new_children; |
|
|
if (defined $given and length $given) { |
|
|
my $__text = $self-> |
|
|
create_text_node |
|
|
($given); |
|
|
push @__new_children, $__text; |
|
|
$$__text->{ |
|
|
'parent' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$__text->{ |
|
|
'parent' |
|
|
}); |
|
|
} |
|
|
|
|
|
${$self}->{ |
|
|
'child' |
|
|
} = \@__new_children; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
sub get_feature ($$$) { |
|
|
my ($self, $feature, $version) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$feature = lc $feature; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$version = '' unless defined $version; |
|
|
|
|
|
|
|
|
} |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$feature =~ s/^\+//; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($Message::Util::AutoLoad::Registry::Feature->{$feature}->{$version}) { |
|
|
$r = $self; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
unless (defined $r) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$r = $self->SUPER::get_feature ($feature, $version); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub base_uri ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = $$self->{ |
|
|
'buri' |
|
|
}; |
|
|
unless (defined $r) { |
|
|
$r = $$self->{ |
|
|
'duri' |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'base_uri'; |
|
|
} |
|
|
} |
|
|
sub create_document_fragment ($) { |
|
|
my ($self) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = bless \{ |
|
|
|
|
|
'od' |
|
|
=> $self, |
|
|
|
|
|
'child' |
|
|
=> [], |
|
|
}, |
|
|
'Message::DOM::Document::ManakaiDOMDocumentFragment' |
|
|
; |
|
|
Scalar::Util::weaken ($$r->{ |
|
|
'od' |
|
|
}); |
|
868 |
|
|
869 |
|
sub input_encoding ($;$); |
870 |
|
|
|
} |
|
|
$r} |
|
871 |
sub strict_error_checking ($;$) { |
sub strict_error_checking ($;$) { |
872 |
if (@_ == 1) {my ($self) = @_; |
## NOTE: Same as trivial boolean accessor, except no read-only checking. |
873 |
my $r = 0; |
if (@_ > 1) { |
874 |
|
if ($_[1]) { |
875 |
{ |
${$_[0]}->{strict_error_checking} = 1; |
876 |
|
} else { |
877 |
|
delete ${$_[0]}->{strict_error_checking}; |
|
$r = $$self->{ |
|
|
'chk' |
|
|
}; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self, $given) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$$self->{ |
|
|
'chk' |
|
|
} = $given; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
sub dom_config ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = bless [$self, $$self, 'Message::DOM::IFLatest::Document'], |
|
|
|
|
|
'Message::DOM::DOMCore::ManakaiDOMConfiguration' |
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'dom_config'; |
|
|
} |
|
|
} |
|
|
sub document_element ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
F: |
|
|
for my $child (@{$self-> |
|
|
child_nodes |
|
|
}) { |
|
|
if ($child-> |
|
|
node_type |
|
|
== |
|
|
1 |
|
|
) { |
|
|
$r = $child; |
|
|
last F; |
|
|
} |
|
|
} # F |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'document_element'; |
|
|
} |
|
|
} |
|
|
sub implementation ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = $$self->{ |
|
|
'impl' |
|
|
}; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'implementation'; |
|
|
} |
|
|
} |
|
|
sub xml_version ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = $$self->{ |
|
|
'http://www.w3.org/2001/04/infoset#version' |
|
|
}; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self, $given) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
if (defined $given and |
|
|
($given eq '1.0' or $given eq '1.1' or |
|
|
not $self-> |
|
|
strict_error_checking |
|
|
)) { |
|
|
$$self->{ |
|
|
'http://www.w3.org/2001/04/infoset#version' |
|
|
} = $given; |
|
|
} else { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_SUPPORTED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'set', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_IMPL_NOSUPPORT_XMLVER', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'xml_version', 'http://www.w3.org/2001/04/infoset#version' => $given; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
sub doctype ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
F: |
|
|
for my $child (@{$self-> |
|
|
child_nodes |
|
|
}) { |
|
|
my $nt = $child-> |
|
|
node_type |
|
|
; |
|
|
if ($nt == |
|
|
10 |
|
|
) { |
|
|
$r = $child; |
|
|
last F; |
|
|
} elsif ($nt == |
|
|
1 |
|
|
) { # document element |
|
|
last F; |
|
878 |
} |
} |
879 |
} # F |
} |
880 |
|
return ${$_[0]}->{strict_error_checking}; |
881 |
|
} # strict_error_checking |
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'doctype'; |
|
|
} |
|
|
} |
|
|
sub document_uri ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = $$self->{ |
|
|
'duri' |
|
|
}; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self, $given) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
$$self->{ |
|
|
'duri' |
|
|
} = $given; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
sub input_encoding ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
882 |
|
|
883 |
|
## ISSUE: Setting manakai_is_html true shadows |
884 |
|
## xml_* properties. Is this desired? |
885 |
|
|
|
$r = $$self->{ |
|
|
'ces' |
|
|
}; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self, $given) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
$$self->{ |
|
|
'ces' |
|
|
} = $given; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
886 |
sub xml_encoding ($;$) { |
sub xml_encoding ($;$) { |
887 |
if (@_ == 1) {my ($self) = @_; |
my $self = $_[0]; |
888 |
my $r = ''; |
if (@_ > 1) { |
889 |
|
## NOTE: A manakai extension. |
890 |
{ |
if ($$self->{strict_error_checking}) { |
891 |
|
if ($$self->{manakai_is_html}) { |
892 |
|
report Message::DOM::DOMException |
893 |
$r = $$self->{ |
-object => $self, |
894 |
'xcs' |
-type => 'NOT_SUPPORTED_ERR', |
895 |
}; |
-subtype => 'NON_HTML_OPERATION_ERR'; |
896 |
|
} |
897 |
|
if ($$self->{manakai_read_only}) { |
898 |
} |
report Message::DOM::DOMException |
899 |
$r; |
-object => $self, |
900 |
} else {my ($self, $given) = @_; |
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
901 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
$$self->{ |
|
|
'xcs' |
|
|
} = $given; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
sub xml_standalone ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = 0; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = $$self->{ |
|
|
'http://www.w3.org/2001/04/infoset#standalone' |
|
|
}; |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self, $given) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
$$self->{ |
|
|
'http://www.w3.org/2001/04/infoset#standalone' |
|
|
} = $given; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
sub adopt_node ($$) { |
|
|
my ($self, $source) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
ADOPT: |
|
|
{ |
|
|
last ADOPT |
|
|
unless $source->isa ( |
|
|
'Message::DOM::TreeCore::ManakaiDOMNode' |
|
|
); |
|
|
|
|
|
my $strict = $self-> |
|
|
strict_error_checking |
|
|
; |
|
|
if ($strict and $self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'adopt_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'source', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => 'source'; |
|
|
|
|
|
; |
|
|
} |
|
|
my $parent = $source-> |
|
|
parent_node |
|
|
; |
|
|
if ($strict and defined $parent and |
|
|
$parent-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'adopt_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'source', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => 'parent'; |
|
|
|
|
|
; |
|
|
} |
|
|
my $nt = $source-> |
|
|
node_type |
|
|
; |
|
|
my $oe; |
|
|
if ($nt == |
|
|
2 |
|
|
) { |
|
|
$oe = $source-> |
|
|
owner_element |
|
|
; |
|
|
if ($strict and defined $oe and $oe-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'adopt_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'source', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => 'oe'; |
|
|
|
|
|
; |
|
|
} |
|
|
} elsif ($nt == |
|
|
9 or |
|
|
|
|
|
$nt == |
|
|
10 or |
|
|
|
|
|
$nt == |
|
|
6 or |
|
|
|
|
|
$nt == |
|
|
12 |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_SUPPORTED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'adopt_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#ADOPT_NODE_TYPE_NOT_SUPPORTED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'source', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => 'source'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
my @change_od; |
|
|
my @nodes = ($source); |
|
|
while (@nodes) { |
|
|
my $node = shift @nodes; |
|
|
my $nt = $node-> |
|
|
node_type |
|
|
; |
|
|
if ($strict and $node-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'adopt_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOMOD_DESCENDANT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'source', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $node; |
|
|
|
|
|
; |
|
|
} |
|
|
if ($nt == |
|
|
1 |
|
|
) { |
|
|
push @change_od, $node; |
|
|
push @nodes, @{$node-> |
|
|
child_nodes |
|
|
}; |
|
|
my $attrs = $node-> |
|
|
attributes |
|
|
; |
|
|
my $attrsLength = $attrs-> |
|
|
length |
|
|
; |
|
|
for my $i (0..($attrsLength - 1)) { |
|
|
push @nodes, $attrs-> |
|
|
item |
|
|
($i); |
|
902 |
} |
} |
903 |
} elsif ($nt == |
} |
904 |
2 or |
if (defined $_[1]) { |
905 |
|
$$self->{xml_encoding} = ''.$_[1]; |
|
$nt == |
|
|
5 or |
|
|
|
|
|
$nt == |
|
|
11 |
|
|
) { |
|
|
push @change_od, $node; |
|
|
push @nodes, @{$node-> |
|
|
child_nodes |
|
|
}; |
|
|
} elsif ($nt == |
|
|
3 or |
|
|
|
|
|
$nt == |
|
|
8 or |
|
|
|
|
|
$nt == |
|
|
7 or |
|
|
|
|
|
$nt == |
|
|
4 |
|
|
) { |
|
|
push @change_od, $node; |
|
906 |
} else { |
} else { |
907 |
## TODO: assertion |
delete $$self->{xml_encoding}; |
908 |
} |
} |
909 |
} # nodes |
} |
|
|
|
910 |
|
|
911 |
|
if ($$self->{manakai_is_html}) { |
912 |
|
return undef; |
913 |
|
} else { |
914 |
|
return $$self->{xml_encoding}; |
915 |
|
} |
916 |
|
} # xml_encoding |
917 |
|
|
918 |
{ |
sub xml_standalone ($;$) { |
919 |
|
my $self = $_[0]; |
920 |
local $Error::Depth = $Error::Depth + 1; |
if (@_ > 1) { |
921 |
|
if ($$self->{strict_error_checking}) { |
922 |
{ |
if ($$self->{manakai_is_html}) { |
923 |
|
report Message::DOM::DOMException |
924 |
|
-object => $self, |
925 |
if |
-type => 'NOT_SUPPORTED_ERR', |
926 |
(defined $parent) { |
-subtype => 'NON_HTML_OPERATION_ERR'; |
927 |
$parent-> |
} |
928 |
remove_child |
## NOTE: Not in DOM3. |
929 |
($source); |
if ($$self->{manakai_read_only}) { |
930 |
} elsif (defined $oe) { |
report Message::DOM::DOMException |
931 |
$oe-> |
-object => $self, |
932 |
remove_attribute_node |
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
933 |
($source); |
-subtype => 'READ_ONLY_NODE_ERR'; |
934 |
|
} |
935 |
|
} |
936 |
|
if ($_[1]) { |
937 |
|
$$self->{xml_standalone} = 1; |
938 |
|
} else { |
939 |
|
delete $$self->{xml_standalone}; |
940 |
} |
} |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
$r = $source; |
|
|
my $old_od = $change_od[0]-> |
|
|
owner_document |
|
|
; |
|
|
## NOTE: The array must have more than zero |
|
|
## nodes by definition. In addition, |
|
|
## it cannot contain document or document |
|
|
## type nodes in current implementation. |
|
|
|
|
|
if ($old_od eq $self) { |
|
|
last ADOPT; |
|
941 |
} |
} |
942 |
|
|
943 |
for my $n (@change_od) { |
if ($$self->{manakai_is_html}) { |
944 |
$$n->{ |
return 0; |
945 |
'od' |
} else { |
946 |
} = $self; |
return $$self->{xml_standalone}; |
|
Scalar::Util::weaken ($$n->{ |
|
|
'od' |
|
|
}); |
|
947 |
} |
} |
948 |
|
} # xml_standalone |
949 |
|
|
950 |
for my $src (@change_od) { |
sub xml_version ($;$) { |
951 |
my $src_ud = $$src->{ |
my $self = $_[0]; |
952 |
'ud' |
if (@_ > 1) { |
953 |
}; |
my $v = ''.$_[1]; |
954 |
for my $key (keys %{$src_ud or {}}) { |
if ($$self->{strict_error_checking}) { |
955 |
my $dh = $src_ud->{$key}->[1]; |
if ($$self->{manakai_is_html}) { |
956 |
if ($dh) { |
report Message::DOM::DOMException |
957 |
$dh-> |
-object => $self, |
958 |
handle |
-type => 'NOT_SUPPORTED_ERR', |
959 |
|
-subtype => 'NON_HTML_OPERATION_ERR'; |
960 |
( |
} |
961 |
5 |
if ($v ne '1.0' and $v ne '1.1') { |
962 |
, |
report Message::DOM::DOMException |
963 |
$key, $src_ud->{$key}->[0], $src, |
-object => $self, |
964 |
undef |
-type => 'NOT_SUPPORTED_ERR', |
965 |
); |
-subtype => 'UNKNOWN_XML_VERSION_ERR'; |
966 |
} |
} |
967 |
|
if ($$self->{manakai_read_only}) { |
968 |
|
## ISSUE: Not in DOM3. |
969 |
|
report Message::DOM::DOMException |
970 |
|
-object => $self, |
971 |
|
-type => 'NO_MODIFICATION_ALLOWED_ERR', |
972 |
|
-subtype => 'READ_ONLY_NODE_ERR'; |
973 |
|
} |
974 |
|
} |
975 |
|
$$self->{xml_version} = $v; |
976 |
|
} |
977 |
|
|
978 |
|
if (defined wantarray) { |
979 |
|
if ($$self->{manakai_is_html}) { |
980 |
|
return undef; |
981 |
|
} elsif (defined $$self->{xml_version}) { |
982 |
|
return $$self->{xml_version}; |
983 |
|
} else { |
984 |
|
return '1.0'; |
985 |
} |
} |
986 |
} |
} |
987 |
} # ADOPT |
} # xml_version |
988 |
|
|
989 |
|
## |Document| methods |
990 |
|
|
|
} |
|
|
$r} |
|
991 |
sub get_element_by_id ($$) { |
sub get_element_by_id ($$) { |
992 |
my ($self, $elementId) = @_; |
local $Error::Depth = $Error::Depth + 1; |
993 |
my $r; |
my @nodes = @{$_[0]->child_nodes}; |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
@nodes = @{$self-> |
|
|
child_nodes |
|
|
}; |
|
994 |
N: while (@nodes) { |
N: while (@nodes) { |
995 |
my $node = shift @nodes; |
my $node = shift @nodes; |
996 |
next N unless $node-> |
next N unless $node->node_type == 1; # ELEMENT_NODE |
997 |
node_type |
for my $attr (@{$node->attributes}) { |
998 |
== |
if ($attr->is_id and $attr->value eq $_[1]) { |
999 |
1 |
return $node; |
|
; |
|
|
for my $attr (@{$node-> |
|
|
attributes |
|
|
}) { |
|
|
if ($attr-> |
|
|
is_id and |
|
|
|
|
|
$attr-> |
|
|
value eq |
|
|
$elementId) { |
|
|
$r = $attr; |
|
|
last N; |
|
1000 |
} |
} |
1001 |
} |
} |
1002 |
unshift @nodes, @{$node-> |
unshift @nodes, @{$node->child_nodes}; |
|
child_nodes |
|
|
}; |
|
1003 |
} # N |
} # N |
1004 |
|
return undef; |
1005 |
|
} # get_element_by_id |
1006 |
|
|
1007 |
|
## TODO: HTML5 case normalization |
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
1008 |
sub get_elements_by_tag_name ($$) { |
sub get_elements_by_tag_name ($$) { |
1009 |
my ($self, $name) = @_; |
my $name = ''.$_[1]; |
1010 |
my $r; |
my $chk; |
1011 |
|
if ($name eq '*') { |
1012 |
{ |
$chk = sub () { 1 }; |
|
|
|
|
|
|
|
$name = "$name"; |
|
|
my $chk; |
|
|
if ($name eq '*') { |
|
|
$chk = sub { |
|
|
1 |
|
|
}; |
|
|
} else { |
|
|
$chk = sub { |
|
|
my $node = shift; |
|
|
my $nodeName = $node-> |
|
|
node_name |
|
|
; |
|
|
($nodeName eq $name); |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = bless \[$self, $chk], |
|
|
'Message::DOM::TreeCore::ManakaiDOMGetElementsNodeList' |
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub get_elements_by_tag_name_ns ($$$) { |
|
|
my ($self, $namespaceURI, $localName) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) { |
|
|
require Message::DOM::DOMMain; |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:tag:suika.fam.cx,2005-09:1167450139:7187:cCkYT15288+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$namespaceURI = undef; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$namespaceURI = "$namespaceURI" if defined $namespaceURI; |
|
|
$localName = "$localName"; |
|
|
my $chk; |
|
|
if (not defined $namespaceURI) { |
|
|
if ($localName eq '*') { |
|
|
$chk = sub { |
|
|
my $node = shift; |
|
|
(not defined $node-> |
|
|
namespace_uri |
|
|
); |
|
|
}; |
|
|
} else { |
|
|
$chk = sub { |
|
|
my $node = shift; |
|
|
(not defined $node-> |
|
|
namespace_uri and |
|
|
|
|
|
$node-> |
|
|
local_name eq |
|
|
$localName); |
|
|
}; |
|
|
} |
|
|
} elsif ($namespaceURI eq '*') { |
|
|
if ($localName eq '*') { |
|
|
$chk = sub { |
|
|
1 |
|
|
}; |
|
1013 |
} else { |
} else { |
1014 |
$chk = sub { |
$chk = sub ($) { |
1015 |
my $node = shift; |
return $_[0]->manakai_tag_name eq $name; |
|
($node-> |
|
|
local_name eq |
|
|
$localName); |
|
1016 |
}; |
}; |
1017 |
} |
} |
|
} else { |
|
|
if ($localName eq '*') { |
|
|
$chk = sub { |
|
|
my $node = shift; |
|
|
my $nsuri = $node-> |
|
|
namespace_uri |
|
|
; |
|
|
(defined $nsuri and $nsuri eq $namespaceURI); |
|
|
}; |
|
|
} else { |
|
|
$chk = sub { |
|
|
my $node = shift; |
|
|
my $nsuri = $node-> |
|
|
namespace_uri |
|
|
; |
|
|
(defined $nsuri and $nsuri eq $namespaceURI and |
|
|
$node-> |
|
|
local_name eq |
|
|
$localName); |
|
|
}; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = bless \[$self, $chk], |
|
|
'Message::DOM::TreeCore::ManakaiDOMGetElementsNodeList' |
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub import_node ($$;$) { |
|
|
my ($self, $importedNode, $deep) = @_; |
|
|
my $r; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NOT_SUPPORTED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'import_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_IMPL_METHOD_NOT_IMPLEMENTED', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument'; |
|
|
$r} |
|
|
sub normalize_document ($) { |
|
|
my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NOT_SUPPORTED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'normalize_document', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_IMPL_METHOD_NOT_IMPLEMENTED', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument'; |
|
|
} |
|
|
sub rename_node ($$$$) { |
|
|
my ($self, $n, $namespaceURI, $qualifiedName) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
(CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) { |
|
|
require Message::DOM::DOMMain; |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:tag:suika.fam.cx,2005-09:1167450139:7187:cCkYT15288+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$namespaceURI = undef; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
my $r; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NOT_SUPPORTED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'rename_node', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#MDOM_IMPL_METHOD_NOT_IMPLEMENTED', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocument'; |
|
|
$r} |
|
|
sub manakai_entity_base_uri ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$r = $$self->{ |
|
|
'buri' |
|
|
}; |
|
|
unless (defined $r) { |
|
|
$r = $$self->{ |
|
|
'duri' |
|
|
}; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self, $given) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
$$self->{ |
|
|
'buri' |
|
|
} = $given; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
sub all_declarations_processed ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = 0; |
|
|
|
|
|
{ |
|
1018 |
|
|
1019 |
|
require Message::DOM::NodeList; |
1020 |
|
return bless \[$_[0], $chk], 'Message::DOM::NodeList::GetElementsList'; |
1021 |
|
} # get_elements_by_tag_name |
1022 |
|
|
1023 |
$r = $$self->{ |
sub get_elements_by_tag_name_ns ($$$) { |
1024 |
'http://www.w3.org/2001/04/infoset#allDeclarationsProcessed' |
my $nsuri = defined $_[1] ? ''.$_[1] : ''; |
1025 |
}; |
my $lname = ''.$_[2]; |
1026 |
|
my $chk; |
1027 |
|
if ($nsuri eq '*') { |
1028 |
} |
if ($lname eq '*') { |
1029 |
$r; |
$chk = sub () { 1 }; |
1030 |
} else {my ($self, $given) = @_; |
} else { |
1031 |
|
$chk = sub ($) { |
1032 |
{ |
return $_[0]->manakai_local_name eq $lname; |
1033 |
|
}; |
1034 |
|
} |
1035 |
{ |
} elsif ($nsuri eq '') { |
1036 |
|
if ($lname eq '*') { |
1037 |
if |
$chk = sub ($) { |
1038 |
($self-> |
return not defined $_[0]->namespace_uri; |
1039 |
manakai_read_only |
}; |
1040 |
) { |
} else { |
1041 |
|
$chk = sub ($) { |
1042 |
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
return (not defined $_[0]->namespace_uri and |
1043 |
|
$_[0]->manakai_local_name eq $lname); |
1044 |
; |
}; |
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
$$self->{ |
|
|
'http://www.w3.org/2001/04/infoset#allDeclarationsProcessed' |
|
|
} = $given; |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
$Message::DOM::DOMFeature::ClassInfo->{q<Message::DOM::Document::ManakaiDOMDocument>}->{has_feature} = {'core', |
|
|
{'', |
|
|
'1', |
|
|
'1.0', |
|
|
'1', |
|
|
'2.0', |
|
|
'1', |
|
|
'3.0', |
|
|
'1'}, |
|
|
'xml', |
|
|
{'', |
|
|
'1', |
|
|
'1.0', |
|
|
'1', |
|
|
'2.0', |
|
|
'1', |
|
|
'3.0', |
|
|
'1'}, |
|
|
'xmlversion', |
|
|
{'', |
|
|
'1', |
|
|
'1.0', |
|
|
'1', |
|
|
'1.1', |
|
|
'1'}}; |
|
|
$Message::DOM::ClassPoint{q<Message::DOM::Document::ManakaiDOMDocument>} = 14.1; |
|
|
package Message::DOM::IFLatest::DocumentFragment; |
|
|
our $VERSION = 20061230.0424; |
|
|
package Message::DOM::Document::ManakaiDOMDocumentFragment; |
|
|
our $VERSION = 20061230.0424; |
|
|
push our @ISA, 'Message::DOM::TreeCore::ManakaiDOMNode', |
|
|
'Message::DOM::IFLatest::DocumentFragment', |
|
|
'Message::DOM::IFLatest::Node'; |
|
|
sub node_type ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r; |
|
|
$r = 11; |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocumentFragment', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'node_type'; |
|
|
} |
|
|
} |
|
|
sub append_child ($$) { |
|
|
my ($self, $newChild) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self eq $newChild) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'append_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#HIERARCHY_DOCUMENT_FRAGMENT_ITSELF_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocumentFragment', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild'; |
|
|
|
|
|
; |
|
|
} |
|
|
my $self_od = $self-> |
|
|
owner_document |
|
|
; |
|
|
my $child_od = $newChild-> |
|
|
owner_document |
|
|
; |
|
|
my $child_nt = $newChild-> |
|
|
node_type |
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
$strict = $self_od-> |
|
|
strict_error_checking |
|
|
; |
|
|
|
|
|
## -- Node Type check |
|
|
my @new_child; |
|
|
if ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
1 => 1, |
|
|
7 => 1, |
|
|
4 => 1, |
|
|
8 => 1, |
|
|
}->{$child_nt}) { |
|
|
push @new_child, $newChild; |
|
|
} elsif ($child_nt == |
|
|
11 |
|
|
) { |
|
|
for my $cn (@{$newChild-> |
|
|
child_nodes |
|
|
}) { |
|
|
unless ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
1 => 1, |
|
|
7 => 1, |
|
|
4 => 1, |
|
|
8 => 1, |
|
|
}->{$cn-> |
|
|
node_type |
|
|
}) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
push @new_child, $cn; |
|
1045 |
} |
} |
1046 |
} else { |
} else { |
1047 |
|
if ($lname eq '*') { |
1048 |
|
$chk = sub ($) { |
1049 |
{ |
my $ns = $_[0]->namespace_uri; |
1050 |
|
return (defined $ns and $ns eq $nsuri); |
1051 |
local $Error::Depth = $Error::Depth - 1; |
}; |
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
my $nc_parent = @new_child ? $new_child[0]-> |
|
|
parent_node |
|
|
: |
|
|
|
|
|
undef |
|
|
; |
|
|
if ($strict) { |
|
|
## -- Wrong-document check |
|
|
unless ($self_od eq $child_od) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
## -- Read-onlyness check |
|
|
if ($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
if (@new_child) { |
|
|
if ($nc_parent and |
|
|
$nc_parent-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
## -- Insert at... |
|
|
my $index = -1; # last |
|
|
|
|
|
|
|
|
; # FOR !tc:ForAppendChild |
|
|
|
|
|
## -- Removes from parent |
|
|
if ($nc_parent) { |
|
|
if ($child_nt == |
|
|
11 |
|
|
) { |
|
|
$$newChild->{ |
|
|
'child' |
|
|
} = []; |
|
1052 |
} else { |
} else { |
1053 |
my $v = $$nc_parent->{ |
$chk = sub ($) { |
1054 |
'child' |
my $ns = $_[0]->namespace_uri; |
1055 |
}; |
return (defined $ns and $ns eq $nsuri and |
1056 |
RP: for my $i (0..$#$v) { |
$_[0]->manakai_local_name eq $lname); |
1057 |
if ($v->[$i] eq $new_child[0]) { |
}; |
|
splice @$v, $i, 1, (); |
|
|
last RP; |
|
|
} |
|
|
} # RP |
|
1058 |
} |
} |
1059 |
} |
} |
1060 |
|
|
1061 |
## -- Rewrite the |parentNode| properties |
require Message::DOM::NodeList; |
1062 |
for my $nc (@new_child) { |
return bless \[$_[0], $chk], 'Message::DOM::NodeList::GetElementsList'; |
1063 |
$$nc->{ |
} # get_elements_by_tag_name |
|
'parent' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$nc->{ |
|
|
'parent' |
|
|
}); |
|
|
} |
|
|
|
|
|
my $children = $$self->{ |
|
|
'child' |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
## -- Adds to children list |
|
|
push @$children, @new_child; |
|
|
$r = $newChild; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
1064 |
|
|
1065 |
|
## TODO: import_node |
1066 |
|
|
1067 |
|
## TODO: normalize_document |
1068 |
|
|
1069 |
} |
## TODO: rename_node |
1070 |
|
|
1071 |
|
## |DocumentTraversal| methods |
1072 |
|
|
1073 |
;} |
## TODO: create_node_iterator |
1074 |
|
|
1075 |
; |
sub manakai_create_serial_walker ($$;$$$); |
1076 |
|
|
1077 |
|
sub create_tree_walker ($$;$$$); |
1078 |
|
|
1079 |
} |
## |HTMLDocument| attributes |
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub insert_before ($$;$) { |
|
|
my ($self, $newChild, $refChild) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self eq $newChild) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'insert_before', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#HIERARCHY_DOCUMENT_FRAGMENT_ITSELF_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocumentFragment', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild'; |
|
1080 |
|
|
1081 |
; |
sub compat_mode ($) { |
1082 |
} |
if (${$_[0]}->{manakai_is_html}) { |
1083 |
my $self_od = $self-> |
if (defined ${$_[0]}->{manakai_compat_mode} and |
1084 |
owner_document |
${$_[0]}->{manakai_compat_mode} eq 'quirks') { |
1085 |
; |
return 'BackCompat'; |
1086 |
my $child_od = $newChild-> |
} |
1087 |
owner_document |
} |
1088 |
; |
return 'CSS1Compat'; |
1089 |
my $child_nt = $newChild-> |
} # compat_mode |
|
node_type |
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
$strict = $self_od-> |
|
|
strict_error_checking |
|
|
; |
|
|
|
|
|
## -- Node Type check |
|
|
my @new_child; |
|
|
if ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
1 => 1, |
|
|
7 => 1, |
|
|
4 => 1, |
|
|
8 => 1, |
|
|
}->{$child_nt}) { |
|
|
push @new_child, $newChild; |
|
|
} elsif ($child_nt == |
|
|
11 |
|
|
) { |
|
|
for my $cn (@{$newChild-> |
|
|
child_nodes |
|
|
}) { |
|
|
unless ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
1 => 1, |
|
|
7 => 1, |
|
|
4 => 1, |
|
|
8 => 1, |
|
|
}->{$cn-> |
|
|
node_type |
|
|
}) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
1090 |
|
|
1091 |
; |
sub manakai_compat_mode ($;$) { |
1092 |
} |
if (${$_[0]}->{manakai_is_html}) { |
1093 |
push @new_child, $cn; |
if (@_ > 1 and defined $_[1] and |
1094 |
|
{'no quirks' => 1, 'limited quirks' => 1, 'quirks' => 1}->{$_[1]}) { |
1095 |
|
${$_[0]}->{manakai_compat_mode} = $_[1]; |
1096 |
} |
} |
1097 |
|
return ${$_[0]}->{manakai_compat_mode} || 'no quirks'; |
1098 |
} else { |
} else { |
1099 |
|
return 'no quirks'; |
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
1100 |
} |
} |
1101 |
|
} # manakai_compat_mode |
1102 |
|
|
1103 |
my $nc_parent = @new_child ? $new_child[0]-> |
sub inner_html ($;$) { |
1104 |
parent_node |
my $self = $_[0]; |
1105 |
: |
local $Error::Depth = $Error::Depth + 1; |
1106 |
|
|
1107 |
undef |
if ($$self->{manakai_is_html}) { |
1108 |
; |
require Whatpm::HTML; |
1109 |
if ($strict) { |
if (@_ > 1) { |
1110 |
## -- Wrong-document check |
## Step 1 |
1111 |
unless ($self_od eq $child_od) { |
## TODO: Stop parsing and ... |
1112 |
|
|
1113 |
|
## Step 2 |
1114 |
|
my @cn = @{$self->child_nodes}; |
1115 |
|
for (@cn) { ## NOTE: Might throw a |NO_MODIFICATION_ALLOWED_ERR|. |
1116 |
|
$self->remove_child ($_); # |
1117 |
|
} |
1118 |
|
|
1119 |
{ |
## Step 3, 4, 5 |
1120 |
|
Whatpm::HTML->parse_string ($_[1] => $self); |
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
1121 |
|
|
1122 |
;} |
## TODO: |
1123 |
|
## <script>var input = function_to_do_xmlhttprequest (location.href); |
1124 |
|
## document.innerHTML = input</script> |
1125 |
|
|
1126 |
; |
return unless defined wantarray; |
1127 |
} |
} |
1128 |
|
|
1129 |
## -- Read-onlyness check |
require Whatpm::HTML::Serializer; |
1130 |
if ($self-> |
return ${ Whatpm::HTML::Serializer->get_inner_html ($self) }; |
1131 |
manakai_read_only |
} else { |
1132 |
) { |
if (@_ > 1) { |
1133 |
|
## Step 1 |
1134 |
|
require Whatpm::XMLParser; # MUST |
1135 |
|
my $doc = $self->implementation->create_document; |
1136 |
|
|
1137 |
|
## Step 2 |
1138 |
|
# |
1139 |
|
|
1140 |
{ |
## Step 3 |
1141 |
|
$doc = Whatpm::XMLParser->parse_string ($_[1] => $doc); # MUST |
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
1142 |
|
|
1143 |
; |
## Step 4 |
1144 |
} |
# |
|
if (@new_child) { |
|
|
if ($nc_parent and |
|
|
$nc_parent-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
|
|
|
} |
|
1145 |
|
|
1146 |
|
## Step 5 |
1147 |
|
## TODO: ill-formed -> SYNTAX_ERR # MUST |
1148 |
|
|
1149 |
;} |
## Step 6 # MUST |
1150 |
|
my @cn = @{$self->child_nodes}; ## TODO: If read-only |
1151 |
; |
for (@cn) { |
1152 |
|
$self->remove_child ($_); |
1153 |
} |
} |
|
} |
|
|
} |
|
|
|
|
|
## -- Insert at... |
|
|
my $index = -1; # last |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
# tc:ForAppendChild & tc:ForReplaceChild |
|
|
if (defined $refChild) { |
|
|
if ($refChild eq $newChild) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#insert-before-itself', 'rdata' => $refChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
1154 |
|
|
1155 |
;} |
## Step 7, 8, 9, 10 |
1156 |
|
for my $node (@{$doc->child_nodes}) { |
1157 |
; |
$self->append_child ($self->adopt_node ($node)); |
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
; |
|
1158 |
} |
} |
1159 |
|
|
1160 |
my $cns = $self-> |
return unless defined wantarray; |
|
child_nodes |
|
|
; |
|
|
my $cnsl = @$cns; |
|
|
C: { |
|
|
$index = 0; |
|
|
for my $i (0..($cnsl-1)) { |
|
|
my $cn = $cns->[$i]; |
|
|
if ($cn eq $refChild) { |
|
|
$index += $i; |
|
|
last C; |
|
|
} elsif ($cn eq $newChild) { |
|
|
$index = -1; # offset |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'refChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $refChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
; |
|
|
} # C |
|
|
} else { # |oldChild| is not defined |
|
|
|
|
|
|
|
|
; |
|
1161 |
} |
} |
|
|
|
|
|
|
1162 |
|
|
1163 |
} |
## TODO: This serializer is currently not conformant to HTML5 spec. |
1164 |
|
require Whatpm::XMLSerializer; |
1165 |
; # FOR !tc:ForAppendChild |
my $r = ''; |
1166 |
|
for (@{$self->child_nodes}) { |
1167 |
## -- Removes from parent |
$r .= ${ Whatpm::XMLSerializer->get_outer_xml ($_, sub { |
1168 |
if ($nc_parent) { |
## TODO: INVALID_STATE_ERR |
1169 |
if ($child_nt == |
}) }; |
|
11 |
|
|
) { |
|
|
$$newChild->{ |
|
|
'child' |
|
|
} = []; |
|
|
} else { |
|
|
my $v = $$nc_parent->{ |
|
|
'child' |
|
|
}; |
|
|
RP: for my $i (0..$#$v) { |
|
|
if ($v->[$i] eq $new_child[0]) { |
|
|
splice @$v, $i, 1, (); |
|
|
last RP; |
|
|
} |
|
|
} # RP |
|
1170 |
} |
} |
1171 |
|
return $r; |
1172 |
} |
} |
1173 |
|
} # inner_html |
1174 |
|
|
1175 |
## -- Rewrite the |parentNode| properties |
sub manakai_is_html ($;$) { |
1176 |
for my $nc (@new_child) { |
if (@_ > 1) { |
1177 |
$$nc->{ |
if ($_[1]) { |
1178 |
'parent' |
${$_[0]}->{manakai_is_html} = 1; |
|
} = $self; |
|
|
Scalar::Util::weaken ($$nc->{ |
|
|
'parent' |
|
|
}); |
|
|
} |
|
|
|
|
|
my $children = $$self->{ |
|
|
'child' |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
## -- Adds to children list |
|
|
if ($index == -1) { |
|
|
push @$children, @new_child; |
|
1179 |
} else { |
} else { |
1180 |
splice @$children, $index, 0, @new_child; |
delete ${$_[0]}->{manakai_is_html}; |
1181 |
|
delete ${$_[0]}->{manakai_compat_mode}; |
1182 |
} |
} |
|
$r = $newChild; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub replace_child ($$$) { |
|
|
my ($self, $newChild, $oldChild) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($self eq $newChild) { |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#method' => 'replace_child', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#HIERARCHY_DOCUMENT_FRAGMENT_ITSELF_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocumentFragment', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild'; |
|
|
|
|
|
; |
|
|
} |
|
|
my $self_od = $self-> |
|
|
owner_document |
|
|
; |
|
|
my $child_od = $newChild-> |
|
|
owner_document |
|
|
; |
|
|
my $child_nt = $newChild-> |
|
|
node_type |
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
$strict = $self_od-> |
|
|
strict_error_checking |
|
|
; |
|
|
|
|
|
## -- Node Type check |
|
|
my @new_child; |
|
|
if ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
1 => 1, |
|
|
7 => 1, |
|
|
4 => 1, |
|
|
8 => 1, |
|
|
}->{$child_nt}) { |
|
|
push @new_child, $newChild; |
|
|
} elsif ($child_nt == |
|
|
11 |
|
|
) { |
|
|
for my $cn (@{$newChild-> |
|
|
child_nodes |
|
|
}) { |
|
|
unless ({ |
|
|
3 => 1, |
|
|
5 => 1, |
|
|
1 => 1, |
|
|
7 => 1, |
|
|
4 => 1, |
|
|
8 => 1, |
|
|
}->{$cn-> |
|
|
node_type |
|
|
}) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
push @new_child, $cn; |
|
|
} |
|
|
} else { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
1183 |
} |
} |
1184 |
|
return ${$_[0]}->{manakai_is_html}; |
1185 |
|
} # manakai_is_html |
1186 |
|
|
1187 |
my $nc_parent = @new_child ? $new_child[0]-> |
package Message::IF::Document; |
1188 |
parent_node |
package Message::IF::DocumentTraversal; |
1189 |
: |
package Message::IF::DocumentXDoctype; |
1190 |
|
package Message::IF::DocumentSelector; |
1191 |
undef |
package Message::IF::HTMLDocument; |
|
; |
|
|
if ($strict) { |
|
|
## -- Wrong-document check |
|
|
unless ($self_od eq $child_od) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
1192 |
|
|
1193 |
;} |
package Message::DOM::DOMImplementation; |
1194 |
|
|
1195 |
; |
sub create_document ($;$$$) { |
1196 |
} |
my $r = Message::DOM::Document->____new ($_[0]); |
|
|
|
|
## -- Read-onlyness check |
|
|
if ($self-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
if (@new_child) { |
|
|
if ($nc_parent and |
|
|
$nc_parent-> |
|
|
manakai_read_only |
|
|
) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
1197 |
|
|
1198 |
; |
if (defined $_[2]) { |
1199 |
} |
local $Error::Depth = $Error::Depth + 1; |
1200 |
} |
$r->append_child ($r->create_element_ns ($_[1], $_[2])); # NAMESPACE_ERR |
1201 |
|
## NOTE: manakai might raise DOMExceptions in cases not defined |
1202 |
|
## in DOM3Core spec: XMLNSPREFIX_NONXMLNSNS_ERR, |
1203 |
|
## XMLNS_NONXMLNSNS_ERR, and NONXMLNSPREFIX_XMLNSNS_ERR. |
1204 |
|
} elsif (defined $_[1]) { |
1205 |
|
report Message::DOM::DOMException |
1206 |
|
-object => $_[0], |
1207 |
|
-type => 'NAMESPACE_ERR', |
1208 |
|
-subtype => 'QNAME_NULLNS_ERR'; |
1209 |
} |
} |
1210 |
|
|
1211 |
## -- Insert at... |
if (defined $_[3]) { |
1212 |
my $index = -1; # last |
if ($_[3]->parent_node) { |
1213 |
|
report Message::DOM::DOMException |
1214 |
|
-object => $_[0], |
1215 |
{ |
-type => 'WRONG_DOCUMENT_ERR', |
1216 |
|
-subtype => 'INUSE_DOCTYPE_ERR'; |
|
|
|
|
# tc:ForAppendChild & tc:ForReplaceChild |
|
|
if (defined $oldChild) { |
|
|
if ($oldChild eq $newChild) { |
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#replace-by-itself', 'rdata' => $oldChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest'; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
my $cns = $self-> |
|
|
child_nodes |
|
|
; |
|
|
my $cnsl = @$cns; |
|
|
C: { |
|
|
$index = 0; |
|
|
for my $i (0..($cnsl-1)) { |
|
|
my $cn = $cns->[$i]; |
|
|
if ($cn eq $oldChild) { |
|
|
$index += $i; |
|
|
last C; |
|
|
} elsif ($cn eq $newChild) { |
|
|
$index = -1; # offset |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
} # C |
|
|
} else { # |oldChild| is not defined |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth - 1; |
|
|
|
|
|
{ |
|
|
|
|
|
report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
1217 |
} |
} |
1218 |
|
local $Error::Depth = $Error::Depth + 1; |
1219 |
|
$r->insert_before ($_[3], $r->first_child); # EXTERNAL_OBJECT_ERR |
|
|
|
|
} |
|
|
|
|
|
; # FOR !tc:ForAppendChild |
|
|
|
|
|
## -- Removes from parent |
|
|
if ($nc_parent) { |
|
|
if ($child_nt == |
|
|
11 |
|
|
) { |
|
|
$$newChild->{ |
|
|
'child' |
|
|
} = []; |
|
|
} else { |
|
|
my $v = $$nc_parent->{ |
|
|
'child' |
|
|
}; |
|
|
RP: for my $i (0..$#$v) { |
|
|
if ($v->[$i] eq $new_child[0]) { |
|
|
splice @$v, $i, 1, (); |
|
|
last RP; |
|
|
} |
|
|
} # RP |
|
|
} |
|
|
} |
|
|
|
|
|
## -- Rewrite the |parentNode| properties |
|
|
for my $nc (@new_child) { |
|
|
$$nc->{ |
|
|
'parent' |
|
|
} = $self; |
|
|
Scalar::Util::weaken ($$nc->{ |
|
|
'parent' |
|
|
}); |
|
|
} |
|
|
|
|
|
my $children = $$self->{ |
|
|
'child' |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
## -- Replaces the node |
|
|
splice @$children, $index, 1, @new_child; |
|
|
CORE::delete $$oldChild->{ |
|
|
'parent' |
|
|
}; |
|
|
$r = $oldChild; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub node_name ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
$r = '#document-fragment'; |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocumentFragment', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'node_name'; |
|
|
} |
|
|
} |
|
|
sub manakai_append_text ($$) { |
|
|
my ($self, $string) = @_; |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
my |
|
|
$lc = $self-> |
|
|
last_child |
|
|
; |
|
|
if (defined $lc and |
|
|
$lc-> |
|
|
node_type |
|
|
== |
|
|
3 |
|
|
) { |
|
|
$lc-> |
|
|
manakai_append_text |
|
|
|
|
|
(ref $string eq 'SCALAR' ? $string : \$string); |
|
|
} else { |
|
|
my $text = $self-> |
|
|
owner_document |
|
|
|
|
|
-> |
|
|
create_text_node |
|
|
|
|
|
(ref $string eq 'SCALAR' ? $$string : $string); |
|
|
$self-> |
|
|
append_child |
|
|
($text); |
|
1220 |
} |
} |
|
$r = $self; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub get_feature ($$$) { |
|
|
my ($self, $feature, $version) = @_; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$feature = lc $feature; |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$version = '' unless defined $version; |
|
|
|
|
|
|
|
|
} |
|
|
my $r; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
$feature =~ s/^\+//; |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if |
|
|
($Message::Util::AutoLoad::Registry::Feature->{$feature}->{$version}) { |
|
|
$r = $self; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
; |
|
|
unless (defined $r) { |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$r = $self->SUPER::get_feature ($feature, $version); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
;} |
|
|
|
|
|
; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
$r} |
|
|
sub base_uri ($;$) { |
|
|
if (@_ == 1) {my ($self) = @_; |
|
|
my $r = ''; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
local $Error::Depth = $Error::Depth + 1; |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
$r = $self-> |
|
|
owner_document |
|
|
-> |
|
|
base_uri |
|
|
; |
|
|
|
|
|
|
|
1221 |
|
|
1222 |
} |
return $r; |
1223 |
|
} # create_document |
1224 |
|
|
1225 |
|
=head1 LICENSE |
1226 |
|
|
1227 |
;} |
Copyright 2007 Wakaba <w@suika.fam.cx> |
1228 |
|
|
1229 |
; |
This program is free software; you can redistribute it and/or |
1230 |
|
modify it under the same terms as Perl itself. |
1231 |
|
|
1232 |
|
=cut |
1233 |
|
|
|
} |
|
|
$r; |
|
|
} else {my ($self) = @_; |
|
|
report Message::Util::Error::DOMException::CoreException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#on' => 'get', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2005/manakai/Util/Error/DOMException#READ_ONLY_ATTRIBUTE_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#class' => 'Message::DOM::Document::ManakaiDOMDocumentFragment', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#attr' => 'base_uri'; |
|
|
} |
|
|
} |
|
|
$Message::DOM::DOMFeature::ClassInfo->{q<Message::DOM::Document::ManakaiDOMDocumentFragment>}->{has_feature} = {'core', |
|
|
{'', |
|
|
'1', |
|
|
'1.0', |
|
|
'1', |
|
|
'2.0', |
|
|
'1', |
|
|
'3.0', |
|
|
'1'}, |
|
|
'xml', |
|
|
{'', |
|
|
'1', |
|
|
'1.0', |
|
|
'1', |
|
|
'2.0', |
|
|
'1', |
|
|
'3.0', |
|
|
'1'}, |
|
|
'xmlversion', |
|
|
{'', |
|
|
'1', |
|
|
'1.0', |
|
|
'1', |
|
|
'1.1', |
|
|
'1'}}; |
|
|
$Message::DOM::ClassPoint{q<Message::DOM::Document::ManakaiDOMDocumentFragment>} = 14.1; |
|
|
for ($Message::DOM::IFLatest::Node::){} |
|
|
## License: <http://suika.fam.cx/~wakaba/archive/2004/8/18/license#Perl+MPL> |
|
1234 |
1; |
1; |
1235 |
|
## $Date$ |