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