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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.14 - (hide annotations) (download)
Sat Dec 30 04:42:51 2006 UTC (17 years, 10 months ago) by wakaba
Branch: MAIN
Changes since 1.13: +19 -36 lines
++ manakai/lib/Message/Markup/ChangeLog	30 Dec 2006 04:39:04 -0000
2006-12-30  Wakaba  <wakaba@suika.fam.cx>

	* Atom.dis, SuikaWiki.dis: References
	to the |ManakaiDOM:ManakaiDOM| mode are removed.

++ manakai/lib/Message/Util/ChangeLog	30 Dec 2006 04:39:32 -0000
	* DIS.dis, PerlCode.dis: References to the |ManakaiDOM:ManakaiDOM|
	mode are removed.

2006-12-30  Wakaba  <wakaba@suika.fam.cx>

++ manakai/lib/Message/Util/DIS/ChangeLog	30 Dec 2006 04:42:43 -0000
	* DPG.dis, Perl.dis, Value.dis, Test.dis: References
	to |ManakaiDOM:ManakaiDOM| modes are removed.

	* Perl.dis (plCodeFragment): |local|ize
	the |DIS:plCodeFragment| cache to avoid
	ancestor nodes of the cached fragment
	are destroyed so that the cached nodes
	become invalid.

2006-12-30  Wakaba  <wakaba@suika.fam.cx>

++ manakai/lib/Message/DOM/ChangeLog	30 Dec 2006 04:37:29 -0000
	* CharacterData.dis, DOMCore.dis, DOMFeature.dis,
	GenericLS.dis, TreeCore.dis, DOMString.dis,
	XML.dis, Element.dis, Document.dis, TreeStore,dis,
	Traversal.dis, XDoctype.dis, XMLParser.dis, DOMLS.dis,
	SimpleLS.dis, DOMMain.dis: References
	to the |ManakaiDOM:ManakaiDOM|, |ManakaiDOM:ManakaiDOM1|,
	|ManakaiDOM:ManakaiDOM2|, and |ManakaiDOM:ManakaiDOM3|
	modes are removed.

2006-12-30  Wakaba  <wakaba@suika.fam.cx>

++ manakai/lib/Message/URI/ChangeLog	30 Dec 2006 04:35:39 -0000
2006-12-30  Wakaba  <wakaba@suika.fam.cx>

	* Generic.dis (Require): Reference to the |ManakaiDOM:ManakaiDOM|
	mode is removed.

++ manakai/lib/Message/Charset/ChangeLog	30 Dec 2006 04:35:23 -0000
2006-12-30  Wakaba  <wakaba@suika.fam.cx>

	* Encode.dis (Require): Reference to the |ManakaiDOM:ManakaiDOM|
	mode is removed.

1 wakaba 1.1 #!/usr/bin/perl
2     ## This file is automatically generated
3 wakaba 1.14 ## at 2006-12-30T04:24:35+00:00,
4 wakaba 1.12 ## from file "Document.dis",
5 wakaba 1.1 ## module <http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#ManakaiDOM.Document>,
6     ## for <http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom#ManakaiDOMLatest>.
7     ## Don't edit by hand!
8     use strict;
9     require Message::DOM::DOMCore;
10     require Message::DOM::TreeCore;
11     require Message::Util::Error::DOMException;
12     package Message::DOM::Document;
13 wakaba 1.14 our $VERSION = 20061230.0424;
14 wakaba 1.10 package Message::DOM::Document::ManakaiDOMImplementationDocument;
15 wakaba 1.14 our $VERSION = 20061230.0424;
16 wakaba 1.10 push @Message::DOM::DOMCore::ManakaiDOMImplementation::ISA, q<Message::DOM::Document::ManakaiDOMImplementationDocument> unless Message::DOM::DOMCore::ManakaiDOMImplementation->isa (q<Message::DOM::Document::ManakaiDOMImplementationDocument>);
17     sub create_document ($;$$$) {
18     my ($self, $namespaceURI, $qualifiedName, $doctype) = @_;
19    
20     {
21    
22     if
23     (CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) {
24     require Message::DOM::DOMMain;
25    
26 wakaba 1.14 report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:tag:suika.fam.cx,2005-09:1167450139:7187:cCkYT15288+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
27 wakaba 1.10
28     ;
29    
30    
31    
32     {
33    
34    
35     $namespaceURI = undef;
36    
37    
38    
39     }
40    
41     ;
42     }
43    
44    
45     }
46     my $r;
47    
48     {
49    
50 wakaba 1.14 require
51     Scalar::Util;
52     $r = bless \{
53 wakaba 1.10
54 wakaba 1.13 'child'
55     => [],
56 wakaba 1.10
57 wakaba 1.13 'impl'
58     => $self,
59 wakaba 1.10
60 wakaba 1.13 'http://www.w3.org/2001/04/infoset#version'
61     => '1.0',
62 wakaba 1.10
63 wakaba 1.13 'chk'
64     => 1,
65 wakaba 1.14 },
66 wakaba 1.13 'Message::DOM::Document::ManakaiDOMDocument'
67 wakaba 1.10 ;
68    
69     if (defined $doctype) {
70    
71    
72     {
73    
74     local $Error::Depth = $Error::Depth + 1;
75    
76     {
77    
78    
79    
80     $r->
81     append_child
82     ($doctype);
83    
84    
85    
86     }
87    
88    
89     ;}
90    
91     ;
92     }
93    
94     if (defined $qualifiedName) {
95    
96    
97     {
98    
99     local $Error::Depth = $Error::Depth + 1;
100    
101     {
102    
103    
104     my
105     $el = $r->
106     create_element_ns
107    
108     ($namespaceURI, $qualifiedName);
109     $r->
110     append_child
111     ($el);
112     $r = $el->
113     owner_document
114     ;
115     ## Choose the class based on document element type
116    
117    
118    
119     }
120    
121    
122     ;}
123    
124     ;
125     } elsif (defined $namespaceURI) {
126    
127     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';
128    
129     ;
130     }
131    
132    
133     }
134     $r}
135     $Message::DOM::DOMFeature::ClassInfo->{q<Message::DOM::Document::ManakaiDOMImplementationDocument>}->{has_feature} = {};
136     $Message::DOM::ClassPoint{q<Message::DOM::Document::ManakaiDOMImplementationDocument>} = 0;
137 wakaba 1.1 package Message::DOM::IFLatest::Document;
138 wakaba 1.14 our $VERSION = 20061230.0424;
139 wakaba 1.1 package Message::DOM::Document::ManakaiDOMDocument;
140 wakaba 1.14 our $VERSION = 20061230.0424;
141 wakaba 1.1 push our @ISA, 'Message::DOM::TreeCore::ManakaiDOMNode',
142     'Message::DOM::IFLatest::Document',
143 wakaba 1.14 'Message::DOM::IFLatest::Node';
144 wakaba 1.1 sub node_type ($;$) {
145     if (@_ == 1) {my ($self) = @_;
146     my $r;
147 wakaba 1.7 $r = 9;
148 wakaba 1.1 $r;
149     } else {my ($self) = @_;
150     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';
151     }
152     }
153     sub append_child ($$) {
154     my ($self, $newChild) = @_;
155     my $r;
156    
157     {
158    
159     my
160     $strictc = $self->
161     dom_config
162    
163     ->
164     get_parameter
165    
166     (
167     'http://suika.fam.cx/www/2006/dom-config/strict-document-children'
168     );
169     my $child_od = $newChild->
170     owner_document
171     || $self;
172     my $child_nt = $newChild->
173     node_type
174     ;
175     if ($strictc and $self->
176     strict_error_checking
177     ) {
178    
179    
180     {
181    
182     local $Error::Depth = $Error::Depth + 1;
183    
184     {
185    
186    
187     my
188     $has_el;
189     my $has_dt;
190     if ($child_nt ==
191 wakaba 1.7 1
192 wakaba 1.1 ) {
193     $has_el =
194     1
195     ;
196     } elsif ($child_nt ==
197 wakaba 1.7 10
198 wakaba 1.1 ) {
199     $has_dt =
200     1
201     ;
202     } elsif ($child_nt ==
203 wakaba 1.7 11
204 wakaba 1.1 ) {
205     for my $cn (@{$newChild->
206     child_nodes
207     }) {
208     my $cnt = $cn->
209     node_type
210     ;
211     if ($cnt ==
212 wakaba 1.7 1
213 wakaba 1.1 ) {
214     if ($has_el) {
215    
216    
217     {
218    
219     local $Error::Depth = $Error::Depth - 1;
220    
221     {
222    
223     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;
224    
225    
226 wakaba 1.3 }
227 wakaba 1.1
228    
229     ;}
230    
231     ;
232     }
233     $has_el =
234     1
235     ;
236     }
237     # DocumentType node cannot be contained in DocumentFragments
238     }
239     }
240    
241     if ($has_el) {
242     my $anode = $self->
243     last_child
244     ;
245     while (defined $anode) {
246     if ($anode->
247     node_type
248     ==
249 wakaba 1.7 1
250 wakaba 1.1 ) {
251    
252    
253     {
254    
255     local $Error::Depth = $Error::Depth - 1;
256    
257     {
258    
259     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;
260    
261    
262 wakaba 1.3 }
263 wakaba 1.1
264    
265     ;}
266    
267     ;
268     }
269     $anode = $anode->
270     previous_sibling
271     ;
272     }
273     } # has_el
274     if ($has_dt) {
275     my $anode = $self->
276     last_child
277     ;
278     while (defined $anode) {
279     my $ant = $anode->
280     node_type
281     ;
282     if ($ant ==
283 wakaba 1.7 1
284 wakaba 1.1 ) {
285    
286    
287     {
288    
289     local $Error::Depth = $Error::Depth - 1;
290    
291     {
292    
293     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;
294    
295    
296 wakaba 1.3 }
297 wakaba 1.1
298    
299     ;}
300    
301     ;
302     } elsif ($ant ==
303 wakaba 1.7 10
304 wakaba 1.1 ) {
305    
306    
307     {
308    
309     local $Error::Depth = $Error::Depth - 1;
310    
311     {
312    
313     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;
314    
315    
316 wakaba 1.3 }
317 wakaba 1.1
318    
319     ;}
320    
321     ;
322     }
323     $anode = $anode->
324     previous_sibling
325     ;
326     }
327     } # has_dt
328    
329    
330    
331 wakaba 1.3 }
332 wakaba 1.1
333    
334     ;}
335    
336     ;
337     }
338    
339    
340     {
341    
342    
343     {
344    
345     local $Error::Depth = $Error::Depth + 1;
346    
347     {
348    
349    
350     my
351     $strict = $self->
352     strict_error_checking
353     ;
354    
355     ## -- Node Type check
356     my @new_child;
357     if ({
358 wakaba 1.7 3 => (not $strictc),
359     5 => (not $strictc),
360     1 => 1,
361     4 => (not $strictc),
362     7 => 1,
363     8 => 1,
364     10 => 1,
365 wakaba 1.1 }->{$child_nt}) {
366     push @new_child, $newChild;
367     } elsif ($child_nt ==
368 wakaba 1.7 11
369 wakaba 1.1 ) {
370     for my $cn (@{$newChild->
371     child_nodes
372     }) {
373     unless ({
374 wakaba 1.7 3 => (not $strictc),
375     5 => (not $strictc),
376     1 => 1,
377     4 => (not $strictc),
378     7 => 1,
379     8 => 1,
380     10 => 1,
381 wakaba 1.1 }->{$cn->
382     node_type
383     }) {
384    
385    
386     {
387    
388     local $Error::Depth = $Error::Depth - 1;
389    
390     {
391    
392     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
393    
394    
395 wakaba 1.3 }
396 wakaba 1.1
397    
398     ;}
399    
400     ;
401     }
402     push @new_child, $cn;
403     }
404     } else {
405    
406    
407     {
408    
409     local $Error::Depth = $Error::Depth - 1;
410    
411     {
412    
413     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
414    
415    
416 wakaba 1.3 }
417 wakaba 1.1
418    
419     ;}
420    
421     ;
422     }
423    
424     my $nc_parent = @new_child ? $new_child[0]->
425     parent_node
426     :
427    
428     undef
429     ;
430     if ($strict) {
431     ## -- Wrong-document check
432     unless ($self eq $child_od) {
433    
434    
435     {
436    
437     local $Error::Depth = $Error::Depth - 1;
438    
439     {
440    
441     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
442    
443    
444 wakaba 1.3 }
445 wakaba 1.1
446    
447     ;}
448    
449     ;
450     }
451    
452     ## -- Read-onlyness check
453     if ($self->
454     manakai_read_only
455     ) {
456    
457    
458     {
459    
460     local $Error::Depth = $Error::Depth - 1;
461    
462     {
463    
464     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
465    
466    
467 wakaba 1.3 }
468 wakaba 1.1
469    
470     ;}
471    
472     ;
473     }
474     if (@new_child) {
475     if ($nc_parent and
476     $nc_parent->
477     manakai_read_only
478     ) {
479    
480    
481     {
482    
483     local $Error::Depth = $Error::Depth - 1;
484    
485     {
486    
487     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
488    
489    
490 wakaba 1.3 }
491 wakaba 1.1
492    
493     ;}
494    
495     ;
496     }
497     }
498     }
499    
500     ## -- Insert at...
501     my $index = -1; # last
502    
503    
504     ; # FOR !tc:ForAppendChild
505    
506     ## -- Removes from parent
507     if ($nc_parent) {
508     if ($child_nt ==
509 wakaba 1.7 11
510 wakaba 1.1 ) {
511 wakaba 1.13 $$newChild->{
512     'child'
513     } = [];
514 wakaba 1.1 } else {
515 wakaba 1.13 my $v = $$nc_parent->{
516     'child'
517     };
518 wakaba 1.1 RP: for my $i (0..$#$v) {
519 wakaba 1.13 if ($v->[$i] eq $new_child[0]) {
520 wakaba 1.1 splice @$v, $i, 1, ();
521     last RP;
522     }
523     } # RP
524     }
525     }
526    
527     ## -- Rewrite the |parentNode| properties
528     for my $nc (@new_child) {
529 wakaba 1.13 $$nc->{
530     'parent'
531     } = $self;
532     Scalar::Util::weaken ($$nc->{
533     'parent'
534     });
535     }
536 wakaba 1.1
537 wakaba 1.13 my $children = $$self->{
538     'child'
539 wakaba 1.1 };
540    
541    
542    
543     {
544    
545    
546     ## -- Adds to children list
547 wakaba 1.13 push @$children, @new_child;
548 wakaba 1.1 $r = $newChild;
549    
550    
551    
552 wakaba 1.3 }
553 wakaba 1.1
554     ;
555    
556    
557    
558     ;
559    
560    
561    
562     ;
563    
564    
565    
566 wakaba 1.3 }
567 wakaba 1.1
568    
569     ;}
570    
571     ;
572    
573    
574 wakaba 1.3 }
575 wakaba 1.1
576     ;
577     if ($child_nt ==
578 wakaba 1.7 10 and
579 wakaba 1.1
580     not defined $newChild->
581     owner_document
582     ) {
583 wakaba 1.13 CORE::delete $$newChild->{
584     'impl'
585 wakaba 1.1 };
586 wakaba 1.13 $$newChild->{
587     'od'
588     } = $self;
589     Scalar::Util::weaken ($$newChild->{
590     'od'
591     });
592 wakaba 1.1 }
593    
594    
595 wakaba 1.3 }
596 wakaba 1.1 $r}
597     sub insert_before ($$;$) {
598     my ($self, $newChild, $refChild) = @_;
599     my $r;
600    
601     {
602    
603     my
604     $strictc = $self->
605     dom_config
606    
607     ->
608     get_parameter
609    
610     (
611     'http://suika.fam.cx/www/2006/dom-config/strict-document-children'
612     );
613     my $child_od = $newChild->
614     owner_document
615     || $self;
616     my $child_nt = $newChild->
617     node_type
618     ;
619     if ($strictc and $self->
620     strict_error_checking
621     ) {
622    
623    
624     {
625    
626     local $Error::Depth = $Error::Depth + 1;
627    
628     {
629    
630    
631     my
632     $has_el;
633     my $has_dt;
634     if ($child_nt ==
635 wakaba 1.7 1
636 wakaba 1.1 ) {
637     $has_el =
638     1
639     ;
640     } elsif ($child_nt ==
641 wakaba 1.7 10
642 wakaba 1.1 ) {
643     $has_dt =
644     1
645     ;
646     } elsif ($child_nt ==
647 wakaba 1.7 11
648 wakaba 1.1 ) {
649     for my $cn (@{$newChild->
650     child_nodes
651     }) {
652     my $cnt = $cn->
653     node_type
654     ;
655     if ($cnt ==
656 wakaba 1.7 1
657 wakaba 1.1 ) {
658     if ($has_el) {
659    
660    
661     {
662    
663     local $Error::Depth = $Error::Depth - 1;
664    
665     {
666    
667     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;
668    
669    
670 wakaba 1.3 }
671 wakaba 1.1
672    
673     ;}
674    
675     ;
676     }
677     $has_el =
678     1
679     ;
680     }
681     # DocumentType node cannot be contained in DocumentFragments
682     }
683     }
684    
685     if ($has_el) {
686     my $anode = $refChild ? $refChild->
687     previous_sibling
688     :
689     $self->
690     last_child
691     ;
692     while (defined $anode) {
693     if ($anode->
694     node_type
695     ==
696 wakaba 1.7 1
697 wakaba 1.1 ) {
698    
699    
700     {
701    
702     local $Error::Depth = $Error::Depth - 1;
703    
704     {
705    
706     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;
707    
708    
709 wakaba 1.3 }
710 wakaba 1.1
711    
712     ;}
713    
714     ;
715     }
716     $anode = $anode->
717     previous_sibling
718     ;
719     }
720     $anode = $refChild;
721     while (defined $anode) {
722     my $ant = $anode->
723     node_type
724     ;
725     if ($ant ==
726 wakaba 1.7 1
727 wakaba 1.1 ) {
728    
729    
730     {
731    
732     local $Error::Depth = $Error::Depth - 1;
733    
734     {
735    
736     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;
737    
738    
739 wakaba 1.3 }
740 wakaba 1.1
741    
742     ;}
743    
744     ;
745     } elsif ($ant ==
746 wakaba 1.7 10
747 wakaba 1.1 ) {
748    
749    
750     {
751    
752     local $Error::Depth = $Error::Depth - 1;
753    
754     {
755    
756     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;
757    
758    
759 wakaba 1.3 }
760 wakaba 1.1
761    
762     ;}
763    
764     ;
765     }
766     $anode = $anode->
767     next_sibling
768     ;
769     }
770     } # has_el
771     if ($has_dt) {
772     my $anode = $refChild ? $refChild->
773     previous_sibling
774     :
775     $self->
776     last_child
777     ;
778     while (defined $anode) {
779     my $ant = $anode->
780     node_type
781     ;
782     if ($ant ==
783 wakaba 1.7 1
784 wakaba 1.1 ) {
785    
786    
787     {
788    
789     local $Error::Depth = $Error::Depth - 1;
790    
791     {
792    
793     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;
794    
795    
796 wakaba 1.3 }
797 wakaba 1.1
798    
799     ;}
800    
801     ;
802     } elsif ($ant ==
803 wakaba 1.7 10
804 wakaba 1.1 ) {
805    
806    
807     {
808    
809     local $Error::Depth = $Error::Depth - 1;
810    
811     {
812    
813     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;
814    
815    
816 wakaba 1.3 }
817 wakaba 1.1
818    
819     ;}
820    
821     ;
822     }
823     $anode = $anode->
824     previous_sibling
825     ;
826     }
827     $anode = $refChild;
828     while (defined $anode) {
829     if ($anode->
830     node_type
831    
832     ==
833 wakaba 1.7 10
834 wakaba 1.1 ) {
835    
836    
837     {
838    
839     local $Error::Depth = $Error::Depth - 1;
840    
841     {
842    
843     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;
844    
845    
846 wakaba 1.3 }
847 wakaba 1.1
848    
849     ;}
850    
851     ;
852     }
853     $anode = $anode->
854     next_sibling
855     ;
856     }
857     } # has_dt
858    
859    
860    
861 wakaba 1.3 }
862 wakaba 1.1
863    
864     ;}
865    
866     ;
867     }
868    
869    
870     {
871    
872    
873     {
874    
875     local $Error::Depth = $Error::Depth + 1;
876    
877     {
878    
879    
880     my
881     $strict = $self->
882     strict_error_checking
883     ;
884    
885     ## -- Node Type check
886     my @new_child;
887     if ({
888 wakaba 1.7 3 => (not $strictc),
889     5 => (not $strictc),
890     1 => 1,
891     4 => (not $strictc),
892     7 => 1,
893     8 => 1,
894     10 => 1,
895 wakaba 1.1 }->{$child_nt}) {
896     push @new_child, $newChild;
897     } elsif ($child_nt ==
898 wakaba 1.7 11
899 wakaba 1.1 ) {
900     for my $cn (@{$newChild->
901     child_nodes
902     }) {
903     unless ({
904 wakaba 1.7 3 => (not $strictc),
905     5 => (not $strictc),
906     1 => 1,
907     4 => (not $strictc),
908     7 => 1,
909     8 => 1,
910     10 => 1,
911 wakaba 1.1 }->{$cn->
912     node_type
913     }) {
914    
915    
916     {
917    
918     local $Error::Depth = $Error::Depth - 1;
919    
920     {
921    
922     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
923    
924    
925 wakaba 1.3 }
926 wakaba 1.1
927    
928     ;}
929    
930     ;
931     }
932     push @new_child, $cn;
933     }
934     } else {
935    
936    
937     {
938    
939     local $Error::Depth = $Error::Depth - 1;
940    
941     {
942    
943     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
944    
945    
946 wakaba 1.3 }
947 wakaba 1.1
948    
949     ;}
950    
951     ;
952     }
953    
954     my $nc_parent = @new_child ? $new_child[0]->
955     parent_node
956     :
957    
958     undef
959     ;
960     if ($strict) {
961     ## -- Wrong-document check
962     unless ($self eq $child_od) {
963    
964    
965     {
966    
967     local $Error::Depth = $Error::Depth - 1;
968    
969     {
970    
971     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
972    
973    
974 wakaba 1.3 }
975 wakaba 1.1
976    
977     ;}
978    
979     ;
980     }
981    
982     ## -- Read-onlyness check
983     if ($self->
984     manakai_read_only
985     ) {
986    
987    
988     {
989    
990     local $Error::Depth = $Error::Depth - 1;
991    
992     {
993    
994     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
995    
996    
997 wakaba 1.3 }
998 wakaba 1.1
999    
1000     ;}
1001    
1002     ;
1003     }
1004     if (@new_child) {
1005     if ($nc_parent and
1006     $nc_parent->
1007     manakai_read_only
1008     ) {
1009    
1010    
1011     {
1012    
1013     local $Error::Depth = $Error::Depth - 1;
1014    
1015     {
1016    
1017     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
1018    
1019    
1020 wakaba 1.3 }
1021 wakaba 1.1
1022    
1023     ;}
1024    
1025     ;
1026     }
1027     }
1028     }
1029    
1030     ## -- Insert at...
1031     my $index = -1; # last
1032    
1033    
1034     {
1035    
1036    
1037     # tc:ForAppendChild & tc:ForReplaceChild
1038     if (defined $refChild) {
1039     if ($refChild eq $newChild) {
1040    
1041    
1042     {
1043    
1044    
1045     {
1046    
1047     local $Error::Depth = $Error::Depth - 1;
1048    
1049     {
1050    
1051     report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#insert-before-itself', 'rdata' => $refChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
1052    
1053    
1054 wakaba 1.3 }
1055 wakaba 1.1
1056    
1057     ;}
1058    
1059     ;
1060    
1061    
1062    
1063 wakaba 1.3 }
1064 wakaba 1.1
1065     ;
1066    
1067    
1068     ;
1069     }
1070    
1071     my $cns = $self->
1072     child_nodes
1073     ;
1074     my $cnsl = @$cns;
1075     C: {
1076     $index = 0;
1077     for my $i (0..($cnsl-1)) {
1078     my $cn = $cns->[$i];
1079     if ($cn eq $refChild) {
1080     $index += $i;
1081     last C;
1082     } elsif ($cn eq $newChild) {
1083     $index = -1; # offset
1084     }
1085     }
1086    
1087    
1088     {
1089    
1090    
1091     {
1092    
1093     local $Error::Depth = $Error::Depth - 1;
1094    
1095     {
1096    
1097     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'refChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $refChild;
1098    
1099    
1100 wakaba 1.3 }
1101 wakaba 1.1
1102    
1103     ;}
1104    
1105     ;
1106    
1107    
1108    
1109 wakaba 1.3 }
1110 wakaba 1.1
1111     ;
1112    
1113    
1114     ;
1115     } # C
1116     } else { # |oldChild| is not defined
1117    
1118    
1119     ;
1120     }
1121    
1122    
1123    
1124 wakaba 1.3 }
1125 wakaba 1.1
1126     ; # FOR !tc:ForAppendChild
1127    
1128     ## -- Removes from parent
1129     if ($nc_parent) {
1130     if ($child_nt ==
1131 wakaba 1.7 11
1132 wakaba 1.1 ) {
1133 wakaba 1.13 $$newChild->{
1134     'child'
1135     } = [];
1136 wakaba 1.1 } else {
1137 wakaba 1.13 my $v = $$nc_parent->{
1138     'child'
1139     };
1140 wakaba 1.1 RP: for my $i (0..$#$v) {
1141 wakaba 1.13 if ($v->[$i] eq $new_child[0]) {
1142 wakaba 1.1 splice @$v, $i, 1, ();
1143     last RP;
1144     }
1145     } # RP
1146     }
1147     }
1148    
1149     ## -- Rewrite the |parentNode| properties
1150     for my $nc (@new_child) {
1151 wakaba 1.13 $$nc->{
1152     'parent'
1153     } = $self;
1154     Scalar::Util::weaken ($$nc->{
1155     'parent'
1156     });
1157     }
1158 wakaba 1.1
1159 wakaba 1.13 my $children = $$self->{
1160     'child'
1161 wakaba 1.1 };
1162    
1163    
1164    
1165     ;
1166    
1167    
1168    
1169     {
1170    
1171    
1172     ## -- Adds to children list
1173     if ($index == -1) {
1174 wakaba 1.13 push @$children, @new_child;
1175 wakaba 1.1 } else {
1176 wakaba 1.13 splice @$children, $index, 0, @new_child;
1177 wakaba 1.1 }
1178     $r = $newChild;
1179    
1180    
1181    
1182 wakaba 1.3 }
1183 wakaba 1.1
1184     ;
1185    
1186    
1187    
1188     ;
1189    
1190    
1191    
1192 wakaba 1.3 }
1193 wakaba 1.1
1194    
1195     ;}
1196    
1197     ;
1198    
1199    
1200 wakaba 1.3 }
1201 wakaba 1.1
1202     ;
1203     if ($child_nt ==
1204 wakaba 1.7 10 and
1205 wakaba 1.1
1206     not defined $newChild->
1207     owner_document
1208     ) {
1209 wakaba 1.13 CORE::delete $$newChild->{
1210     'impl'
1211 wakaba 1.1 };
1212 wakaba 1.13 $$newChild->{
1213     'od'
1214     } = $self;
1215     Scalar::Util::weaken ($$newChild->{
1216     'od'
1217     });
1218 wakaba 1.1 }
1219    
1220    
1221 wakaba 1.3 }
1222 wakaba 1.1 $r}
1223     sub replace_child ($$$) {
1224     my ($self, $newChild, $oldChild) = @_;
1225     my $r;
1226    
1227     {
1228    
1229     my
1230     $strictc = $self->
1231     dom_config
1232    
1233     ->
1234     get_parameter
1235    
1236     (
1237     'http://suika.fam.cx/www/2006/dom-config/strict-document-children'
1238     );
1239     my $child_od = $newChild->
1240     owner_document
1241     || $self;
1242     my $child_nt = $newChild->
1243     node_type
1244     ;
1245     if ($strictc and $self->
1246     strict_error_checking
1247     ) {
1248    
1249    
1250     {
1251    
1252     local $Error::Depth = $Error::Depth + 1;
1253    
1254     {
1255    
1256    
1257     my
1258     $has_el;
1259     my $has_dt;
1260     if ($child_nt ==
1261 wakaba 1.7 1
1262 wakaba 1.1 ) {
1263     $has_el =
1264     1
1265     ;
1266     } elsif ($child_nt ==
1267 wakaba 1.7 10
1268 wakaba 1.1 ) {
1269     $has_dt =
1270     1
1271     ;
1272     } elsif ($child_nt ==
1273 wakaba 1.7 11
1274 wakaba 1.1 ) {
1275     for my $cn (@{$newChild->
1276     child_nodes
1277     }) {
1278     my $cnt = $cn->
1279     node_type
1280     ;
1281     if ($cnt ==
1282 wakaba 1.7 1
1283 wakaba 1.1 ) {
1284     if ($has_el) {
1285    
1286    
1287     {
1288    
1289     local $Error::Depth = $Error::Depth - 1;
1290    
1291     {
1292    
1293     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;
1294    
1295    
1296 wakaba 1.3 }
1297 wakaba 1.1
1298    
1299     ;}
1300    
1301     ;
1302     }
1303     $has_el =
1304     1
1305     ;
1306     }
1307     # DocumentType node cannot be contained in DocumentFragments
1308     }
1309     }
1310    
1311     if ($has_el) {
1312     my $anode = $oldChild->
1313     previous_sibling
1314     ;
1315     while (defined $anode) {
1316     if ($anode->
1317     node_type
1318     ==
1319 wakaba 1.7 1
1320 wakaba 1.1 ) {
1321    
1322    
1323     {
1324    
1325     local $Error::Depth = $Error::Depth - 1;
1326    
1327     {
1328    
1329     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;
1330    
1331    
1332 wakaba 1.3 }
1333 wakaba 1.1
1334    
1335     ;}
1336    
1337     ;
1338     }
1339     $anode = $anode->
1340     previous_sibling
1341     ;
1342     }
1343     $anode = $oldChild->
1344     next_sibling
1345     ;
1346     while (defined $anode) {
1347     my $ant = $anode->
1348     node_type
1349     ;
1350     if ($ant ==
1351 wakaba 1.7 1
1352 wakaba 1.1 ) {
1353    
1354    
1355     {
1356    
1357     local $Error::Depth = $Error::Depth - 1;
1358    
1359     {
1360    
1361     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;
1362    
1363    
1364 wakaba 1.3 }
1365 wakaba 1.1
1366    
1367     ;}
1368    
1369     ;
1370     } elsif ($ant ==
1371 wakaba 1.7 10
1372 wakaba 1.1 ) {
1373    
1374    
1375     {
1376    
1377     local $Error::Depth = $Error::Depth - 1;
1378    
1379     {
1380    
1381     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;
1382    
1383    
1384 wakaba 1.3 }
1385 wakaba 1.1
1386    
1387     ;}
1388    
1389     ;
1390     }
1391     $anode = $anode->
1392     next_sibling
1393     ;
1394     }
1395     } # has_el
1396     if ($has_dt) {
1397     my $anode = $oldChild->
1398     previous_sibling
1399     ;
1400     while (defined $anode) {
1401     my $ant = $anode->
1402     node_type
1403     ;
1404     if ($ant ==
1405 wakaba 1.7 1
1406 wakaba 1.1 ) {
1407    
1408    
1409     {
1410    
1411     local $Error::Depth = $Error::Depth - 1;
1412    
1413     {
1414    
1415     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;
1416    
1417    
1418 wakaba 1.3 }
1419 wakaba 1.1
1420    
1421     ;}
1422    
1423     ;
1424     } elsif ($ant ==
1425 wakaba 1.7 10
1426 wakaba 1.1 ) {
1427    
1428    
1429     {
1430    
1431     local $Error::Depth = $Error::Depth - 1;
1432    
1433     {
1434    
1435     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;
1436    
1437    
1438 wakaba 1.3 }
1439 wakaba 1.1
1440    
1441     ;}
1442    
1443     ;
1444     }
1445     $anode = $anode->
1446     previous_sibling
1447     ;
1448     }
1449     $anode = $oldChild->
1450     next_sibling
1451     ;
1452     while (defined $anode) {
1453     if ($anode->
1454     node_type
1455    
1456     ==
1457 wakaba 1.7 10
1458 wakaba 1.1 ) {
1459    
1460    
1461     {
1462    
1463     local $Error::Depth = $Error::Depth - 1;
1464    
1465     {
1466    
1467     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;
1468    
1469    
1470 wakaba 1.3 }
1471 wakaba 1.1
1472    
1473     ;}
1474    
1475     ;
1476     }
1477     $anode = $anode->
1478     next_sibling
1479     ;
1480     }
1481     } # has_dt
1482    
1483    
1484    
1485 wakaba 1.3 }
1486 wakaba 1.1
1487    
1488     ;}
1489    
1490     ;
1491     }
1492    
1493    
1494     {
1495    
1496    
1497     {
1498    
1499     local $Error::Depth = $Error::Depth + 1;
1500    
1501     {
1502    
1503    
1504     my
1505     $strict = $self->
1506     strict_error_checking
1507     ;
1508    
1509     ## -- Node Type check
1510     my @new_child;
1511     if ({
1512 wakaba 1.7 3 => (not $strictc),
1513     5 => (not $strictc),
1514     1 => 1,
1515     4 => (not $strictc),
1516     7 => 1,
1517     8 => 1,
1518     10 => 1,
1519 wakaba 1.1 }->{$child_nt}) {
1520     push @new_child, $newChild;
1521     } elsif ($child_nt ==
1522 wakaba 1.7 11
1523 wakaba 1.1 ) {
1524     for my $cn (@{$newChild->
1525     child_nodes
1526     }) {
1527     unless ({
1528 wakaba 1.7 3 => (not $strictc),
1529     5 => (not $strictc),
1530     1 => 1,
1531     4 => (not $strictc),
1532     7 => 1,
1533     8 => 1,
1534     10 => 1,
1535 wakaba 1.1 }->{$cn->
1536     node_type
1537     }) {
1538    
1539    
1540     {
1541    
1542     local $Error::Depth = $Error::Depth - 1;
1543    
1544     {
1545    
1546     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
1547    
1548    
1549 wakaba 1.3 }
1550 wakaba 1.1
1551    
1552     ;}
1553    
1554     ;
1555     }
1556     push @new_child, $cn;
1557     }
1558     } else {
1559    
1560    
1561     {
1562    
1563     local $Error::Depth = $Error::Depth - 1;
1564    
1565     {
1566    
1567     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
1568    
1569    
1570 wakaba 1.3 }
1571 wakaba 1.1
1572    
1573     ;}
1574    
1575     ;
1576     }
1577    
1578     my $nc_parent = @new_child ? $new_child[0]->
1579     parent_node
1580     :
1581    
1582     undef
1583     ;
1584     if ($strict) {
1585     ## -- Wrong-document check
1586     unless ($self eq $child_od) {
1587    
1588    
1589     {
1590    
1591     local $Error::Depth = $Error::Depth - 1;
1592    
1593     {
1594    
1595     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
1596    
1597    
1598 wakaba 1.3 }
1599 wakaba 1.1
1600    
1601     ;}
1602    
1603     ;
1604     }
1605    
1606     ## -- Read-onlyness check
1607     if ($self->
1608     manakai_read_only
1609     ) {
1610    
1611    
1612     {
1613    
1614     local $Error::Depth = $Error::Depth - 1;
1615    
1616     {
1617    
1618     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
1619    
1620    
1621 wakaba 1.3 }
1622 wakaba 1.1
1623    
1624     ;}
1625    
1626     ;
1627     }
1628     if (@new_child) {
1629     if ($nc_parent and
1630     $nc_parent->
1631     manakai_read_only
1632     ) {
1633    
1634    
1635     {
1636    
1637     local $Error::Depth = $Error::Depth - 1;
1638    
1639     {
1640    
1641     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
1642    
1643    
1644 wakaba 1.3 }
1645 wakaba 1.1
1646    
1647     ;}
1648    
1649     ;
1650     }
1651     }
1652     }
1653    
1654     ## -- Insert at...
1655     my $index = -1; # last
1656    
1657    
1658     {
1659    
1660    
1661     # tc:ForAppendChild & tc:ForReplaceChild
1662     if (defined $oldChild) {
1663     if ($oldChild eq $newChild) {
1664    
1665    
1666     ;
1667    
1668    
1669     {
1670    
1671    
1672     {
1673    
1674     local $Error::Depth = $Error::Depth - 1;
1675    
1676     {
1677    
1678     report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#replace-by-itself', 'rdata' => $oldChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
1679    
1680    
1681 wakaba 1.3 }
1682 wakaba 1.1
1683    
1684     ;}
1685    
1686     ;
1687    
1688    
1689    
1690 wakaba 1.3 }
1691 wakaba 1.1
1692     ;
1693     }
1694    
1695     my $cns = $self->
1696     child_nodes
1697     ;
1698     my $cnsl = @$cns;
1699     C: {
1700     $index = 0;
1701     for my $i (0..($cnsl-1)) {
1702     my $cn = $cns->[$i];
1703     if ($cn eq $oldChild) {
1704     $index += $i;
1705     last C;
1706     } elsif ($cn eq $newChild) {
1707     $index = -1; # offset
1708     }
1709     }
1710    
1711    
1712     ;
1713    
1714    
1715     {
1716    
1717    
1718     {
1719    
1720     local $Error::Depth = $Error::Depth - 1;
1721    
1722     {
1723    
1724     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild;
1725    
1726    
1727 wakaba 1.3 }
1728 wakaba 1.1
1729    
1730     ;}
1731    
1732     ;
1733    
1734    
1735    
1736 wakaba 1.3 }
1737 wakaba 1.1
1738     ;
1739     } # C
1740     } else { # |oldChild| is not defined
1741    
1742    
1743     {
1744    
1745    
1746     {
1747    
1748     local $Error::Depth = $Error::Depth - 1;
1749    
1750     {
1751    
1752     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild;
1753    
1754    
1755 wakaba 1.3 }
1756 wakaba 1.1
1757    
1758     ;}
1759    
1760     ;
1761    
1762    
1763    
1764 wakaba 1.3 }
1765 wakaba 1.1
1766     ;
1767     }
1768    
1769    
1770    
1771 wakaba 1.3 }
1772 wakaba 1.1
1773     ; # FOR !tc:ForAppendChild
1774    
1775     ## -- Removes from parent
1776     if ($nc_parent) {
1777     if ($child_nt ==
1778 wakaba 1.7 11
1779 wakaba 1.1 ) {
1780 wakaba 1.13 $$newChild->{
1781     'child'
1782     } = [];
1783 wakaba 1.1 } else {
1784 wakaba 1.13 my $v = $$nc_parent->{
1785     'child'
1786     };
1787 wakaba 1.1 RP: for my $i (0..$#$v) {
1788 wakaba 1.13 if ($v->[$i] eq $new_child[0]) {
1789 wakaba 1.1 splice @$v, $i, 1, ();
1790     last RP;
1791     }
1792     } # RP
1793     }
1794     }
1795    
1796     ## -- Rewrite the |parentNode| properties
1797     for my $nc (@new_child) {
1798 wakaba 1.13 $$nc->{
1799     'parent'
1800     } = $self;
1801     Scalar::Util::weaken ($$nc->{
1802     'parent'
1803     });
1804     }
1805 wakaba 1.1
1806 wakaba 1.13 my $children = $$self->{
1807     'child'
1808     };
1809 wakaba 1.1
1810 wakaba 1.13
1811 wakaba 1.1
1812 wakaba 1.13 ;
1813 wakaba 1.1
1814 wakaba 1.13
1815 wakaba 1.1
1816     ;
1817    
1818    
1819    
1820     {
1821    
1822    
1823 wakaba 1.13 ## -- Replaces the node
1824     splice @$children, $index, 1, @new_child;
1825     CORE::delete $$oldChild->{
1826     'parent'
1827     };
1828     $r = $oldChild;
1829    
1830 wakaba 1.1
1831    
1832 wakaba 1.3 }
1833 wakaba 1.1
1834     ;
1835    
1836    
1837    
1838 wakaba 1.13 }
1839    
1840    
1841     ;}
1842 wakaba 1.1
1843     ;
1844    
1845    
1846 wakaba 1.13 }
1847 wakaba 1.1
1848 wakaba 1.13 ;
1849 wakaba 1.1 if ($child_nt ==
1850 wakaba 1.7 10 and
1851 wakaba 1.1
1852     not defined $newChild->
1853     owner_document
1854     ) {
1855 wakaba 1.13 CORE::delete $$newChild->{
1856     'impl'
1857 wakaba 1.1 };
1858 wakaba 1.13 $$newChild->{
1859     'od'
1860     } = $self;
1861     Scalar::Util::weaken ($$newChild->{
1862     'od'
1863     });
1864 wakaba 1.1 }
1865    
1866    
1867 wakaba 1.3 }
1868 wakaba 1.1 $r}
1869     sub manakai_append_text ($$) {
1870     my ($self, $string) = @_;
1871     my $r;
1872    
1873     {
1874    
1875    
1876     {
1877    
1878     local $Error::Depth = $Error::Depth + 1;
1879    
1880     {
1881    
1882    
1883     unless
1884     ($self->
1885     dom_config
1886    
1887     ->
1888     get_parameter
1889    
1890     (
1891     'http://suika.fam.cx/www/2006/dom-config/strict-document-children'
1892     )) {
1893     my $lc = $self->
1894     last_child
1895     ;
1896     if (defined $lc and
1897     $lc->
1898     node_type
1899     ==
1900 wakaba 1.7 3
1901 wakaba 1.1 ) {
1902     $lc->
1903     manakai_append_text
1904    
1905     (ref $string eq 'SCALAR' ? $string : \$string);
1906     } else {
1907     my $text = $self->
1908     create_text_node
1909    
1910     (ref $string eq 'SCALAR' ? $$string : $string);
1911     $self->
1912     append_child
1913     ($text);
1914     }
1915     }
1916     $r = $self;
1917    
1918    
1919    
1920 wakaba 1.3 }
1921 wakaba 1.1
1922    
1923     ;}
1924    
1925     ;
1926    
1927    
1928 wakaba 1.3 }
1929 wakaba 1.1 $r}
1930     sub remove_child ($$) {
1931     my ($self, $oldChild) = @_;
1932     my $r;
1933    
1934     {
1935    
1936     if
1937     ($self->
1938     strict_error_checking and
1939    
1940     $self->
1941     manakai_read_only
1942     ) {
1943    
1944     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';
1945    
1946     ;
1947     }
1948    
1949    
1950     {
1951    
1952     F:
1953     {
1954     my $i = -1;
1955 wakaba 1.13 my $v = $$self->{
1956     'child'
1957     };
1958     for my $cld (@$v) {
1959 wakaba 1.1 $i++;
1960     if ($cld eq $oldChild) {
1961     splice @$v, $i, 1, ();
1962 wakaba 1.13 CORE::delete $$oldChild->{
1963     'parent'
1964     };
1965 wakaba 1.1 $r = $oldChild;
1966     last F;
1967     }
1968     }
1969    
1970     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/removeChildImpl+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild;
1971    
1972     ;
1973     } # F
1974    
1975    
1976 wakaba 1.3 }
1977 wakaba 1.1
1978     ;
1979    
1980    
1981 wakaba 1.3 }
1982 wakaba 1.1 $r}
1983     sub node_name ($;$) {
1984     if (@_ == 1) {my ($self) = @_;
1985 wakaba 1.12 my $r = '';
1986 wakaba 1.1 $r = '#document';
1987     $r;
1988     } else {my ($self) = @_;
1989     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';
1990     }
1991     }
1992     sub text_content ($;$) {
1993     if (@_ == 1) {my ($self) = @_;
1994 wakaba 1.12 my $r = '';
1995 wakaba 1.1
1996     {
1997    
1998    
1999     {
2000    
2001     local $Error::Depth = $Error::Depth + 1;
2002    
2003     {
2004    
2005    
2006     if
2007     ($self->
2008     dom_config
2009    
2010     ->
2011     get_parameter
2012    
2013     (
2014     'http://suika.fam.cx/www/2006/dom-config/strict-document-children'
2015     )) {
2016     $r =
2017     undef
2018     ;
2019     } else {
2020     $r = '';
2021     my @target = @{$self->
2022     child_nodes
2023     };
2024     C: for my $node (@target) {
2025     my $nt = $node->
2026     node_type
2027     ;
2028     if ($nt ==
2029 wakaba 1.7 3 or
2030 wakaba 1.1
2031     $nt ==
2032 wakaba 1.7 4
2033 wakaba 1.1 ) {
2034     $r .= $node->
2035     data
2036     unless
2037     $node->
2038     is_element_content_whitespace
2039     ;
2040     } elsif ($nt ==
2041 wakaba 1.7 1 or
2042 wakaba 1.1
2043     $nt ==
2044 wakaba 1.7 5
2045 wakaba 1.1 ) {
2046     unshift @target, @{$node->
2047     child_nodes
2048     };
2049     }
2050     }
2051     }
2052    
2053    
2054    
2055 wakaba 1.3 }
2056 wakaba 1.1
2057    
2058     ;}
2059    
2060     ;
2061    
2062    
2063 wakaba 1.3 }
2064 wakaba 1.1 $r;
2065     } else {my ($self, $given) = @_;
2066    
2067     {
2068    
2069     if
2070     ($self->
2071     dom_config
2072    
2073     ->
2074     get_parameter
2075    
2076     (
2077     'http://suika.fam.cx/www/2006/dom-config/strict-document-children'
2078     )) {
2079    
2080     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';
2081    
2082     ;
2083     } else {
2084    
2085    
2086     {
2087    
2088    
2089     {
2090    
2091     if
2092     ($self->
2093     manakai_read_only
2094     ) {
2095    
2096     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
2097    
2098     ;
2099     }
2100    
2101    
2102 wakaba 1.3 }
2103 wakaba 1.1
2104     ;
2105 wakaba 1.10
2106 wakaba 1.13 for my $__old_child (@{${$self}->{
2107     'child'
2108     }}) {
2109     CORE::delete $$__old_child->{
2110     'parent'
2111 wakaba 1.10 };
2112     }
2113 wakaba 1.1
2114 wakaba 1.10 my @__new_children;
2115     if (defined $given and length $given) {
2116     my $__text = $self->
2117     create_text_node
2118     ($given);
2119 wakaba 1.13 push @__new_children, $__text;
2120     $$__text->{
2121     'parent'
2122     } = $self;
2123     Scalar::Util::weaken ($$__text->{
2124     'parent'
2125     });
2126 wakaba 1.10 }
2127 wakaba 1.1
2128 wakaba 1.13 ${$self}->{
2129     'child'
2130     } = \@__new_children;
2131 wakaba 1.1
2132    
2133 wakaba 1.3 }
2134 wakaba 1.1
2135     ;
2136     }
2137    
2138    
2139 wakaba 1.3 }
2140 wakaba 1.1 }
2141 wakaba 1.10 }
2142     sub get_feature ($$$) {
2143     my ($self, $feature, $version) = @_;
2144 wakaba 1.1
2145 wakaba 1.10 {
2146 wakaba 1.1
2147    
2148 wakaba 1.10 $feature = lc $feature;
2149 wakaba 1.1
2150    
2151 wakaba 1.10 }
2152 wakaba 1.1
2153 wakaba 1.10 {
2154 wakaba 1.1
2155    
2156 wakaba 1.10 $version = '' unless defined $version;
2157 wakaba 1.1
2158    
2159 wakaba 1.3 }
2160 wakaba 1.10 my $r;
2161    
2162     {
2163 wakaba 1.1
2164    
2165 wakaba 1.10 $feature =~ s/^\+//;
2166 wakaba 1.1
2167    
2168     {
2169    
2170 wakaba 1.10 if
2171     ($Message::Util::AutoLoad::Registry::Feature->{$feature}->{$version}) {
2172     $r = $self;
2173     }
2174 wakaba 1.1
2175    
2176 wakaba 1.3 }
2177 wakaba 1.1
2178     ;
2179 wakaba 1.10 unless (defined $r) {
2180    
2181 wakaba 1.1
2182     {
2183    
2184     local $Error::Depth = $Error::Depth + 1;
2185    
2186     {
2187    
2188    
2189    
2190 wakaba 1.10 $r = $self->SUPER::get_feature ($feature, $version);
2191    
2192 wakaba 1.1
2193    
2194 wakaba 1.3 }
2195 wakaba 1.1
2196    
2197     ;}
2198    
2199     ;
2200 wakaba 1.10 }
2201 wakaba 1.1
2202    
2203 wakaba 1.3 }
2204 wakaba 1.1 $r}
2205 wakaba 1.10 sub base_uri ($;$) {
2206     if (@_ == 1) {my ($self) = @_;
2207 wakaba 1.12 my $r = '';
2208 wakaba 1.10
2209     {
2210    
2211 wakaba 1.1
2212 wakaba 1.13 $r = $$self->{
2213     'buri'
2214     };
2215 wakaba 1.10 unless (defined $r) {
2216 wakaba 1.13 $r = $$self->{
2217     'duri'
2218     };
2219 wakaba 1.1 }
2220    
2221    
2222 wakaba 1.3 }
2223 wakaba 1.10 $r;
2224     } else {my ($self) = @_;
2225     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';
2226     }
2227     }
2228     sub create_document_fragment ($) {
2229     my ($self) = @_;
2230     my $r;
2231 wakaba 1.1
2232 wakaba 1.10 {
2233 wakaba 1.1
2234    
2235 wakaba 1.14 $r = bless \{
2236 wakaba 1.1
2237 wakaba 1.13 'od'
2238     => $self,
2239 wakaba 1.1
2240 wakaba 1.13 'child'
2241     => [],
2242 wakaba 1.14 },
2243 wakaba 1.13 'Message::DOM::Document::ManakaiDOMDocumentFragment'
2244     ;
2245     Scalar::Util::weaken ($$r->{
2246     'od'
2247     });
2248 wakaba 1.1
2249    
2250 wakaba 1.3 }
2251 wakaba 1.1 $r}
2252     sub strict_error_checking ($;$) {
2253     if (@_ == 1) {my ($self) = @_;
2254     my $r = 0;
2255    
2256     {
2257    
2258    
2259 wakaba 1.13 $r = $$self->{
2260     'chk'
2261     };
2262 wakaba 1.1
2263    
2264 wakaba 1.3 }
2265 wakaba 1.1 $r;
2266     } else {my ($self, $given) = @_;
2267    
2268     {
2269    
2270    
2271 wakaba 1.13 $$self->{
2272     'chk'
2273     } = $given;
2274 wakaba 1.1
2275    
2276 wakaba 1.3 }
2277 wakaba 1.1 }
2278     }
2279     sub dom_config ($;$) {
2280     if (@_ == 1) {my ($self) = @_;
2281     my $r;
2282    
2283     {
2284    
2285    
2286     {
2287    
2288    
2289 wakaba 1.13 $r = bless [$self, $$self, 'Message::DOM::IFLatest::Document'],
2290 wakaba 1.1
2291     'Message::DOM::DOMCore::ManakaiDOMConfiguration'
2292     ;
2293    
2294    
2295 wakaba 1.3 }
2296 wakaba 1.1
2297     ;
2298    
2299    
2300 wakaba 1.3 }
2301 wakaba 1.1 $r;
2302     } else {my ($self) = @_;
2303     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';
2304     }
2305     }
2306     sub document_element ($;$) {
2307     if (@_ == 1) {my ($self) = @_;
2308     my $r;
2309    
2310     {
2311    
2312    
2313     {
2314    
2315     local $Error::Depth = $Error::Depth + 1;
2316    
2317     {
2318    
2319    
2320     F:
2321     for my $child (@{$self->
2322     child_nodes
2323     }) {
2324     if ($child->
2325     node_type
2326     ==
2327 wakaba 1.7 1
2328 wakaba 1.1 ) {
2329     $r = $child;
2330     last F;
2331     }
2332     } # F
2333    
2334    
2335    
2336 wakaba 1.3 }
2337 wakaba 1.1
2338    
2339     ;}
2340    
2341     ;
2342    
2343    
2344 wakaba 1.3 }
2345 wakaba 1.1 $r;
2346     } else {my ($self) = @_;
2347     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';
2348     }
2349     }
2350     sub implementation ($;$) {
2351     if (@_ == 1) {my ($self) = @_;
2352     my $r;
2353    
2354     {
2355    
2356    
2357 wakaba 1.13 $r = $$self->{
2358     'impl'
2359     };
2360 wakaba 1.1
2361    
2362 wakaba 1.3 }
2363 wakaba 1.1 $r;
2364     } else {my ($self) = @_;
2365     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';
2366     }
2367     }
2368     sub xml_version ($;$) {
2369     if (@_ == 1) {my ($self) = @_;
2370 wakaba 1.12 my $r = '';
2371 wakaba 1.1
2372     {
2373    
2374    
2375 wakaba 1.13 $r = $$self->{
2376     'http://www.w3.org/2001/04/infoset#version'
2377     };
2378 wakaba 1.1
2379    
2380 wakaba 1.3 }
2381 wakaba 1.1 $r;
2382     } else {my ($self, $given) = @_;
2383    
2384     {
2385    
2386    
2387     {
2388    
2389     if
2390     ($self->
2391     manakai_read_only
2392     ) {
2393    
2394     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
2395    
2396     ;
2397     }
2398    
2399    
2400 wakaba 1.3 }
2401 wakaba 1.1
2402     ;
2403     if (defined $given and
2404     ($given eq '1.0' or $given eq '1.1' or
2405     not $self->
2406     strict_error_checking
2407     )) {
2408 wakaba 1.13 $$self->{
2409     'http://www.w3.org/2001/04/infoset#version'
2410     } = $given;
2411 wakaba 1.1 } else {
2412    
2413     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;
2414    
2415     ;
2416     }
2417    
2418    
2419 wakaba 1.3 }
2420 wakaba 1.1 }
2421     }
2422     sub doctype ($;$) {
2423     if (@_ == 1) {my ($self) = @_;
2424     my $r;
2425    
2426     {
2427    
2428    
2429     {
2430    
2431     local $Error::Depth = $Error::Depth + 1;
2432    
2433     {
2434    
2435    
2436     F:
2437     for my $child (@{$self->
2438     child_nodes
2439     }) {
2440     my $nt = $child->
2441     node_type
2442     ;
2443     if ($nt ==
2444 wakaba 1.7 10
2445 wakaba 1.1 ) {
2446     $r = $child;
2447     last F;
2448     } elsif ($nt ==
2449 wakaba 1.7 1
2450 wakaba 1.1 ) { # document element
2451     last F;
2452     }
2453     } # F
2454    
2455    
2456    
2457 wakaba 1.3 }
2458 wakaba 1.1
2459    
2460     ;}
2461    
2462     ;
2463    
2464    
2465 wakaba 1.3 }
2466 wakaba 1.1 $r;
2467     } else {my ($self) = @_;
2468     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';
2469     }
2470     }
2471     sub document_uri ($;$) {
2472     if (@_ == 1) {my ($self) = @_;
2473     my $r = '';
2474    
2475     {
2476    
2477    
2478 wakaba 1.13 $r = $$self->{
2479     'duri'
2480     };
2481 wakaba 1.1
2482    
2483 wakaba 1.3 }
2484 wakaba 1.1 $r;
2485     } else {my ($self, $given) = @_;
2486    
2487     {
2488    
2489    
2490     {
2491    
2492     if
2493     ($self->
2494     manakai_read_only
2495     ) {
2496    
2497     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
2498    
2499     ;
2500     }
2501    
2502    
2503 wakaba 1.3 }
2504 wakaba 1.1
2505     ;
2506 wakaba 1.13 $$self->{
2507     'duri'
2508     } = $given;
2509 wakaba 1.1
2510    
2511 wakaba 1.3 }
2512 wakaba 1.1 }
2513     }
2514     sub input_encoding ($;$) {
2515     if (@_ == 1) {my ($self) = @_;
2516 wakaba 1.12 my $r = '';
2517 wakaba 1.1
2518     {
2519    
2520    
2521 wakaba 1.13 $r = $$self->{
2522     'ces'
2523     };
2524 wakaba 1.1
2525    
2526 wakaba 1.3 }
2527 wakaba 1.1 $r;
2528     } else {my ($self, $given) = @_;
2529    
2530     {
2531    
2532    
2533     {
2534    
2535     if
2536     ($self->
2537     manakai_read_only
2538     ) {
2539    
2540     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
2541    
2542     ;
2543     }
2544    
2545    
2546 wakaba 1.3 }
2547 wakaba 1.1
2548     ;
2549 wakaba 1.13 $$self->{
2550     'ces'
2551     } = $given;
2552 wakaba 1.1
2553    
2554 wakaba 1.3 }
2555 wakaba 1.1 }
2556     }
2557     sub xml_encoding ($;$) {
2558     if (@_ == 1) {my ($self) = @_;
2559 wakaba 1.12 my $r = '';
2560 wakaba 1.1
2561     {
2562    
2563    
2564 wakaba 1.13 $r = $$self->{
2565     'xcs'
2566     };
2567 wakaba 1.1
2568    
2569 wakaba 1.3 }
2570 wakaba 1.1 $r;
2571     } else {my ($self, $given) = @_;
2572    
2573     {
2574    
2575    
2576     {
2577    
2578     if
2579     ($self->
2580     manakai_read_only
2581     ) {
2582    
2583     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
2584    
2585     ;
2586     }
2587    
2588    
2589 wakaba 1.3 }
2590 wakaba 1.1
2591     ;
2592 wakaba 1.13 $$self->{
2593     'xcs'
2594     } = $given;
2595 wakaba 1.1
2596    
2597 wakaba 1.3 }
2598 wakaba 1.1 }
2599     }
2600     sub xml_standalone ($;$) {
2601     if (@_ == 1) {my ($self) = @_;
2602     my $r = 0;
2603    
2604     {
2605    
2606    
2607 wakaba 1.13 $r = $$self->{
2608     'http://www.w3.org/2001/04/infoset#standalone'
2609     };
2610 wakaba 1.1
2611    
2612 wakaba 1.3 }
2613 wakaba 1.1 $r;
2614     } else {my ($self, $given) = @_;
2615    
2616     {
2617    
2618    
2619     {
2620    
2621     if
2622     ($self->
2623     manakai_read_only
2624     ) {
2625    
2626     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
2627    
2628     ;
2629     }
2630    
2631    
2632 wakaba 1.3 }
2633 wakaba 1.1
2634     ;
2635 wakaba 1.13 $$self->{
2636     'http://www.w3.org/2001/04/infoset#standalone'
2637     } = $given;
2638 wakaba 1.1
2639    
2640 wakaba 1.3 }
2641 wakaba 1.1 }
2642     }
2643     sub adopt_node ($$) {
2644     my ($self, $source) = @_;
2645     my $r;
2646    
2647     {
2648    
2649 wakaba 1.3 ADOPT:
2650     {
2651     last ADOPT
2652     unless $source->isa (
2653 wakaba 1.1 'Message::DOM::TreeCore::ManakaiDOMNode'
2654 wakaba 1.13 );
2655 wakaba 1.3
2656 wakaba 1.2 my $strict = $self->
2657     strict_error_checking
2658     ;
2659     if ($strict and $self->
2660 wakaba 1.1 manakai_read_only
2661     ) {
2662    
2663     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';
2664    
2665     ;
2666     }
2667     my $parent = $source->
2668     parent_node
2669     ;
2670 wakaba 1.2 if ($strict and defined $parent and
2671     $parent->
2672 wakaba 1.1 manakai_read_only
2673     ) {
2674    
2675     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';
2676    
2677     ;
2678     }
2679     my $nt = $source->
2680     node_type
2681     ;
2682     my $oe;
2683     if ($nt ==
2684 wakaba 1.7 2
2685 wakaba 1.1 ) {
2686     $oe = $source->
2687     owner_element
2688     ;
2689 wakaba 1.2 if ($strict and defined $oe and $oe->
2690 wakaba 1.1 manakai_read_only
2691     ) {
2692    
2693     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';
2694    
2695     ;
2696     }
2697     } elsif ($nt ==
2698 wakaba 1.7 9 or
2699 wakaba 1.1
2700     $nt ==
2701 wakaba 1.7 10 or
2702 wakaba 1.1
2703     $nt ==
2704 wakaba 1.7 6 or
2705 wakaba 1.1
2706     $nt ==
2707 wakaba 1.7 12
2708 wakaba 1.1 ) {
2709    
2710     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';
2711    
2712     ;
2713     }
2714    
2715     my @change_od;
2716     my @nodes = ($source);
2717     while (@nodes) {
2718     my $node = shift @nodes;
2719     my $nt = $node->
2720     node_type
2721     ;
2722 wakaba 1.2 if ($strict and $node->
2723 wakaba 1.1 manakai_read_only
2724     ) {
2725    
2726     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;
2727    
2728     ;
2729     }
2730     if ($nt ==
2731 wakaba 1.7 1
2732 wakaba 1.1 ) {
2733     push @change_od, $node;
2734     push @nodes, @{$node->
2735     child_nodes
2736     };
2737     my $attrs = $node->
2738     attributes
2739     ;
2740     my $attrsLength = $attrs->
2741     length
2742     ;
2743     for my $i (0..($attrsLength - 1)) {
2744     push @nodes, $attrs->
2745     item
2746     ($i);
2747     }
2748     } elsif ($nt ==
2749 wakaba 1.7 2 or
2750 wakaba 1.1
2751     $nt ==
2752 wakaba 1.7 5 or
2753 wakaba 1.1
2754     $nt ==
2755 wakaba 1.7 11
2756 wakaba 1.1 ) {
2757     push @change_od, $node;
2758     push @nodes, @{$node->
2759     child_nodes
2760     };
2761     } elsif ($nt ==
2762 wakaba 1.7 3 or
2763 wakaba 1.1
2764     $nt ==
2765 wakaba 1.7 8 or
2766 wakaba 1.1
2767     $nt ==
2768 wakaba 1.7 7 or
2769 wakaba 1.1
2770     $nt ==
2771 wakaba 1.7 4
2772 wakaba 1.1 ) {
2773     push @change_od, $node;
2774     } else {
2775     ## TODO: assertion
2776     }
2777     } # nodes
2778    
2779 wakaba 1.2
2780 wakaba 1.1
2781     {
2782    
2783     local $Error::Depth = $Error::Depth + 1;
2784    
2785     {
2786    
2787    
2788 wakaba 1.2 if
2789     (defined $parent) {
2790 wakaba 1.1 $parent->
2791     remove_child
2792     ($source);
2793 wakaba 1.2 } elsif (defined $oe) {
2794 wakaba 1.1 $oe->
2795     remove_attribute_node
2796     ($source);
2797 wakaba 1.2 }
2798    
2799 wakaba 1.1
2800    
2801 wakaba 1.3 }
2802 wakaba 1.1
2803    
2804 wakaba 1.13 ;}
2805 wakaba 1.1
2806 wakaba 1.13 ;
2807 wakaba 1.1
2808 wakaba 1.13 $r = $source;
2809     my $old_od = $change_od[0]->
2810     owner_document
2811     ;
2812     ## NOTE: The array must have more than zero
2813     ## nodes by definition. In addition,
2814     ## it cannot contain document or document
2815     ## type nodes in current implementation.
2816 wakaba 1.1
2817 wakaba 1.13 if ($old_od eq $self) {
2818     last ADOPT;
2819     }
2820 wakaba 1.1
2821 wakaba 1.13 for my $n (@change_od) {
2822     $$n->{
2823     'od'
2824     } = $self;
2825     Scalar::Util::weaken ($$n->{
2826     'od'
2827     });
2828     }
2829 wakaba 1.1
2830 wakaba 1.13 for my $src (@change_od) {
2831     my $src_ud = $$src->{
2832     'ud'
2833     };
2834 wakaba 1.1 for my $key (keys %{$src_ud or {}}) {
2835     my $dh = $src_ud->{$key}->[1];
2836     if ($dh) {
2837     $dh->
2838     handle
2839    
2840     (
2841 wakaba 1.7 5
2842 wakaba 1.1 ,
2843     $key, $src_ud->{$key}->[0], $src,
2844     undef
2845     );
2846     }
2847     }
2848     }
2849 wakaba 1.3 } # ADOPT
2850 wakaba 1.1
2851    
2852 wakaba 1.3 }
2853 wakaba 1.1 $r}
2854     sub get_element_by_id ($$) {
2855     my ($self, $elementId) = @_;
2856     my $r;
2857    
2858     {
2859    
2860    
2861     {
2862    
2863     local $Error::Depth = $Error::Depth + 1;
2864    
2865     {
2866    
2867    
2868     my
2869     @nodes = @{$self->
2870     child_nodes
2871     };
2872     N: while (@nodes) {
2873     my $node = shift @nodes;
2874     next N unless $node->
2875     node_type
2876     ==
2877 wakaba 1.7 1
2878 wakaba 1.1 ;
2879     for my $attr (@{$node->
2880     attributes
2881     }) {
2882     if ($attr->
2883     is_id and
2884    
2885     $attr->
2886     value eq
2887     $elementId) {
2888     $r = $attr;
2889     last N;
2890     }
2891     }
2892     unshift @nodes, @{$node->
2893     child_nodes
2894     };
2895     } # N
2896    
2897    
2898    
2899 wakaba 1.3 }
2900 wakaba 1.1
2901    
2902     ;}
2903    
2904     ;
2905    
2906    
2907 wakaba 1.3 }
2908 wakaba 1.1 $r}
2909     sub get_elements_by_tag_name ($$) {
2910     my ($self, $name) = @_;
2911     my $r;
2912    
2913     {
2914    
2915    
2916     $name = "$name";
2917     my $chk;
2918     if ($name eq '*') {
2919     $chk = sub {
2920     1
2921     };
2922     } else {
2923     $chk = sub {
2924     my $node = shift;
2925     my $nodeName = $node->
2926     node_name
2927     ;
2928     ($nodeName eq $name);
2929     };
2930     }
2931    
2932    
2933     {
2934    
2935    
2936     $r = bless \[$self, $chk],
2937     'Message::DOM::TreeCore::ManakaiDOMGetElementsNodeList'
2938     ;
2939    
2940    
2941 wakaba 1.3 }
2942 wakaba 1.1
2943     ;
2944    
2945    
2946 wakaba 1.3 }
2947 wakaba 1.1 $r}
2948     sub get_elements_by_tag_name_ns ($$$) {
2949     my ($self, $namespaceURI, $localName) = @_;
2950    
2951     {
2952    
2953     if
2954     (CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) {
2955 wakaba 1.10 require Message::DOM::DOMMain;
2956 wakaba 1.1
2957 wakaba 1.14 report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:tag:suika.fam.cx,2005-09:1167450139:7187:cCkYT15288+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
2958 wakaba 1.1
2959     ;
2960    
2961    
2962    
2963     {
2964    
2965    
2966     $namespaceURI = undef;
2967    
2968    
2969    
2970 wakaba 1.3 }
2971 wakaba 1.1
2972     ;
2973     }
2974    
2975    
2976 wakaba 1.3 }
2977 wakaba 1.1 my $r;
2978    
2979     {
2980    
2981    
2982     $namespaceURI = "$namespaceURI" if defined $namespaceURI;
2983     $localName = "$localName";
2984     my $chk;
2985     if (not defined $namespaceURI) {
2986     if ($localName eq '*') {
2987     $chk = sub {
2988     my $node = shift;
2989     (not defined $node->
2990     namespace_uri
2991     );
2992     };
2993     } else {
2994     $chk = sub {
2995     my $node = shift;
2996     (not defined $node->
2997     namespace_uri and
2998    
2999     $node->
3000     local_name eq
3001     $localName);
3002     };
3003     }
3004     } elsif ($namespaceURI eq '*') {
3005     if ($localName eq '*') {
3006     $chk = sub {
3007     1
3008     };
3009     } else {
3010     $chk = sub {
3011     my $node = shift;
3012     ($node->
3013     local_name eq
3014     $localName);
3015     };
3016     }
3017     } else {
3018     if ($localName eq '*') {
3019     $chk = sub {
3020     my $node = shift;
3021     my $nsuri = $node->
3022     namespace_uri
3023     ;
3024     (defined $nsuri and $nsuri eq $namespaceURI);
3025     };
3026     } else {
3027     $chk = sub {
3028     my $node = shift;
3029     my $nsuri = $node->
3030     namespace_uri
3031     ;
3032     (defined $nsuri and $nsuri eq $namespaceURI and
3033     $node->
3034     local_name eq
3035     $localName);
3036     };
3037     }
3038     }
3039    
3040    
3041     {
3042    
3043    
3044     $r = bless \[$self, $chk],
3045     'Message::DOM::TreeCore::ManakaiDOMGetElementsNodeList'
3046     ;
3047    
3048    
3049 wakaba 1.3 }
3050 wakaba 1.1
3051     ;
3052    
3053    
3054 wakaba 1.3 }
3055 wakaba 1.1 $r}
3056     sub import_node ($$;$) {
3057     my ($self, $importedNode, $deep) = @_;
3058     my $r;
3059     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';
3060     $r}
3061     sub normalize_document ($) {
3062     my ($self) = @_;
3063     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';
3064     }
3065     sub rename_node ($$$$) {
3066     my ($self, $n, $namespaceURI, $qualifiedName) = @_;
3067    
3068     {
3069    
3070     if
3071     (CORE::defined $namespaceURI and CORE::length $namespaceURI == 0) {
3072 wakaba 1.10 require Message::DOM::DOMMain;
3073 wakaba 1.1
3074 wakaba 1.14 report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/main#empty-namespace-uri', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:tag:suika.fam.cx,2005-09:1167450139:7187:cCkYT15288+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
3075 wakaba 1.1
3076     ;
3077    
3078    
3079    
3080     {
3081    
3082    
3083     $namespaceURI = undef;
3084    
3085    
3086    
3087 wakaba 1.3 }
3088 wakaba 1.1
3089     ;
3090     }
3091    
3092    
3093 wakaba 1.3 }
3094 wakaba 1.1 my $r;
3095     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';
3096     $r}
3097     sub manakai_entity_base_uri ($;$) {
3098     if (@_ == 1) {my ($self) = @_;
3099 wakaba 1.12 my $r = '';
3100 wakaba 1.1
3101     {
3102    
3103    
3104 wakaba 1.13 $r = $$self->{
3105     'buri'
3106     };
3107 wakaba 1.1 unless (defined $r) {
3108 wakaba 1.13 $r = $$self->{
3109     'duri'
3110     };
3111 wakaba 1.1 }
3112    
3113    
3114 wakaba 1.3 }
3115 wakaba 1.1 $r;
3116     } else {my ($self, $given) = @_;
3117    
3118     {
3119    
3120    
3121     {
3122    
3123     if
3124     ($self->
3125     manakai_read_only
3126     ) {
3127    
3128     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
3129    
3130     ;
3131     }
3132    
3133    
3134 wakaba 1.3 }
3135 wakaba 1.1
3136     ;
3137 wakaba 1.13 $$self->{
3138     'buri'
3139     } = $given;
3140 wakaba 1.1
3141    
3142 wakaba 1.3 }
3143 wakaba 1.1 }
3144     }
3145     sub all_declarations_processed ($;$) {
3146     if (@_ == 1) {my ($self) = @_;
3147     my $r = 0;
3148    
3149     {
3150    
3151    
3152 wakaba 1.13 $r = $$self->{
3153     'http://www.w3.org/2001/04/infoset#allDeclarationsProcessed'
3154     };
3155 wakaba 1.1
3156    
3157 wakaba 1.3 }
3158 wakaba 1.1 $r;
3159     } else {my ($self, $given) = @_;
3160    
3161     {
3162    
3163    
3164     {
3165    
3166     if
3167     ($self->
3168     manakai_read_only
3169     ) {
3170    
3171     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/NodeReadOnlyError+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
3172    
3173     ;
3174     }
3175    
3176    
3177 wakaba 1.3 }
3178 wakaba 1.1
3179     ;
3180 wakaba 1.13 $$self->{
3181     'http://www.w3.org/2001/04/infoset#allDeclarationsProcessed'
3182     } = $given;
3183 wakaba 1.1
3184    
3185 wakaba 1.3 }
3186 wakaba 1.1 }
3187     }
3188     $Message::DOM::DOMFeature::ClassInfo->{q<Message::DOM::Document::ManakaiDOMDocument>}->{has_feature} = {'core',
3189     {'',
3190     '1',
3191     '1.0',
3192     '1',
3193     '2.0',
3194     '1',
3195     '3.0',
3196     '1'},
3197     'xml',
3198     {'',
3199     '1',
3200     '1.0',
3201     '1',
3202     '2.0',
3203     '1',
3204     '3.0',
3205     '1'},
3206     'xmlversion',
3207     {'',
3208     '1',
3209     '1.0',
3210     '1',
3211     '1.1',
3212     '1'}};
3213     $Message::DOM::ClassPoint{q<Message::DOM::Document::ManakaiDOMDocument>} = 14.1;
3214     package Message::DOM::IFLatest::DocumentFragment;
3215 wakaba 1.14 our $VERSION = 20061230.0424;
3216 wakaba 1.1 package Message::DOM::Document::ManakaiDOMDocumentFragment;
3217 wakaba 1.14 our $VERSION = 20061230.0424;
3218 wakaba 1.1 push our @ISA, 'Message::DOM::TreeCore::ManakaiDOMNode',
3219     'Message::DOM::IFLatest::DocumentFragment',
3220 wakaba 1.14 'Message::DOM::IFLatest::Node';
3221 wakaba 1.1 sub node_type ($;$) {
3222     if (@_ == 1) {my ($self) = @_;
3223     my $r;
3224 wakaba 1.7 $r = 11;
3225 wakaba 1.1 $r;
3226     } else {my ($self) = @_;
3227     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';
3228     }
3229     }
3230     sub append_child ($$) {
3231     my ($self, $newChild) = @_;
3232     my $r;
3233    
3234     {
3235    
3236     if
3237     ($self eq $newChild) {
3238    
3239     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';
3240    
3241     ;
3242     }
3243     my $self_od = $self->
3244     owner_document
3245     ;
3246     my $child_od = $newChild->
3247     owner_document
3248     ;
3249     my $child_nt = $newChild->
3250     node_type
3251     ;
3252    
3253    
3254     {
3255    
3256    
3257     {
3258    
3259     local $Error::Depth = $Error::Depth + 1;
3260    
3261     {
3262    
3263    
3264     my
3265     $strict = $self_od->
3266     strict_error_checking
3267     ;
3268    
3269     ## -- Node Type check
3270     my @new_child;
3271     if ({
3272 wakaba 1.7 3 => 1,
3273     5 => 1,
3274     1 => 1,
3275     7 => 1,
3276     4 => 1,
3277     8 => 1,
3278 wakaba 1.1 }->{$child_nt}) {
3279     push @new_child, $newChild;
3280     } elsif ($child_nt ==
3281 wakaba 1.7 11
3282 wakaba 1.1 ) {
3283     for my $cn (@{$newChild->
3284     child_nodes
3285     }) {
3286     unless ({
3287 wakaba 1.7 3 => 1,
3288     5 => 1,
3289     1 => 1,
3290     7 => 1,
3291     4 => 1,
3292     8 => 1,
3293 wakaba 1.1 }->{$cn->
3294     node_type
3295     }) {
3296    
3297    
3298     {
3299    
3300     local $Error::Depth = $Error::Depth - 1;
3301    
3302     {
3303    
3304     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3305    
3306    
3307 wakaba 1.3 }
3308 wakaba 1.1
3309    
3310     ;}
3311    
3312     ;
3313     }
3314     push @new_child, $cn;
3315     }
3316     } else {
3317    
3318    
3319     {
3320    
3321     local $Error::Depth = $Error::Depth - 1;
3322    
3323     {
3324    
3325     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3326    
3327    
3328 wakaba 1.3 }
3329 wakaba 1.1
3330    
3331     ;}
3332    
3333     ;
3334     }
3335    
3336     my $nc_parent = @new_child ? $new_child[0]->
3337     parent_node
3338     :
3339    
3340     undef
3341     ;
3342     if ($strict) {
3343     ## -- Wrong-document check
3344     unless ($self_od eq $child_od) {
3345    
3346    
3347     {
3348    
3349     local $Error::Depth = $Error::Depth - 1;
3350    
3351     {
3352    
3353     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3354    
3355    
3356 wakaba 1.3 }
3357 wakaba 1.1
3358    
3359     ;}
3360    
3361     ;
3362     }
3363    
3364     ## -- Read-onlyness check
3365     if ($self->
3366     manakai_read_only
3367     ) {
3368    
3369    
3370     {
3371    
3372     local $Error::Depth = $Error::Depth - 1;
3373    
3374     {
3375    
3376     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
3377    
3378    
3379 wakaba 1.3 }
3380 wakaba 1.1
3381    
3382     ;}
3383    
3384     ;
3385     }
3386     if (@new_child) {
3387     if ($nc_parent and
3388     $nc_parent->
3389     manakai_read_only
3390     ) {
3391    
3392    
3393     {
3394    
3395     local $Error::Depth = $Error::Depth - 1;
3396    
3397     {
3398    
3399     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/appendChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
3400    
3401    
3402 wakaba 1.3 }
3403 wakaba 1.1
3404    
3405     ;}
3406    
3407     ;
3408     }
3409     }
3410     }
3411    
3412     ## -- Insert at...
3413     my $index = -1; # last
3414    
3415    
3416     ; # FOR !tc:ForAppendChild
3417    
3418     ## -- Removes from parent
3419     if ($nc_parent) {
3420     if ($child_nt ==
3421 wakaba 1.7 11
3422 wakaba 1.1 ) {
3423 wakaba 1.13 $$newChild->{
3424     'child'
3425     } = [];
3426 wakaba 1.1 } else {
3427 wakaba 1.13 my $v = $$nc_parent->{
3428     'child'
3429     };
3430 wakaba 1.1 RP: for my $i (0..$#$v) {
3431 wakaba 1.13 if ($v->[$i] eq $new_child[0]) {
3432 wakaba 1.1 splice @$v, $i, 1, ();
3433     last RP;
3434     }
3435     } # RP
3436     }
3437     }
3438    
3439     ## -- Rewrite the |parentNode| properties
3440     for my $nc (@new_child) {
3441 wakaba 1.13 $$nc->{
3442     'parent'
3443     } = $self;
3444     Scalar::Util::weaken ($$nc->{
3445     'parent'
3446     });
3447     }
3448 wakaba 1.1
3449 wakaba 1.13 my $children = $$self->{
3450     'child'
3451 wakaba 1.1 };
3452    
3453    
3454    
3455     {
3456    
3457    
3458     ## -- Adds to children list
3459 wakaba 1.13 push @$children, @new_child;
3460 wakaba 1.1 $r = $newChild;
3461    
3462    
3463    
3464 wakaba 1.3 }
3465 wakaba 1.1
3466     ;
3467    
3468    
3469    
3470     ;
3471    
3472    
3473    
3474     ;
3475    
3476    
3477    
3478 wakaba 1.3 }
3479 wakaba 1.1
3480    
3481     ;}
3482    
3483     ;
3484    
3485    
3486 wakaba 1.3 }
3487 wakaba 1.1
3488     ;
3489    
3490    
3491 wakaba 1.3 }
3492 wakaba 1.1 $r}
3493     sub insert_before ($$;$) {
3494     my ($self, $newChild, $refChild) = @_;
3495     my $r;
3496    
3497     {
3498    
3499     if
3500     ($self eq $newChild) {
3501    
3502     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';
3503    
3504     ;
3505     }
3506     my $self_od = $self->
3507     owner_document
3508     ;
3509     my $child_od = $newChild->
3510     owner_document
3511     ;
3512     my $child_nt = $newChild->
3513     node_type
3514     ;
3515    
3516    
3517     {
3518    
3519    
3520     {
3521    
3522     local $Error::Depth = $Error::Depth + 1;
3523    
3524     {
3525    
3526    
3527     my
3528     $strict = $self_od->
3529     strict_error_checking
3530     ;
3531    
3532     ## -- Node Type check
3533     my @new_child;
3534     if ({
3535 wakaba 1.7 3 => 1,
3536     5 => 1,
3537     1 => 1,
3538     7 => 1,
3539     4 => 1,
3540     8 => 1,
3541 wakaba 1.1 }->{$child_nt}) {
3542     push @new_child, $newChild;
3543     } elsif ($child_nt ==
3544 wakaba 1.7 11
3545 wakaba 1.1 ) {
3546     for my $cn (@{$newChild->
3547     child_nodes
3548     }) {
3549     unless ({
3550 wakaba 1.7 3 => 1,
3551     5 => 1,
3552     1 => 1,
3553     7 => 1,
3554     4 => 1,
3555     8 => 1,
3556 wakaba 1.1 }->{$cn->
3557     node_type
3558     }) {
3559    
3560    
3561     {
3562    
3563     local $Error::Depth = $Error::Depth - 1;
3564    
3565     {
3566    
3567     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3568    
3569    
3570 wakaba 1.3 }
3571 wakaba 1.1
3572    
3573     ;}
3574    
3575     ;
3576     }
3577     push @new_child, $cn;
3578     }
3579     } else {
3580    
3581    
3582     {
3583    
3584     local $Error::Depth = $Error::Depth - 1;
3585    
3586     {
3587    
3588     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3589    
3590    
3591 wakaba 1.3 }
3592 wakaba 1.1
3593    
3594     ;}
3595    
3596     ;
3597     }
3598    
3599     my $nc_parent = @new_child ? $new_child[0]->
3600     parent_node
3601     :
3602    
3603     undef
3604     ;
3605     if ($strict) {
3606     ## -- Wrong-document check
3607     unless ($self_od eq $child_od) {
3608    
3609    
3610     {
3611    
3612     local $Error::Depth = $Error::Depth - 1;
3613    
3614     {
3615    
3616     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3617    
3618    
3619 wakaba 1.3 }
3620 wakaba 1.1
3621    
3622     ;}
3623    
3624     ;
3625     }
3626    
3627     ## -- Read-onlyness check
3628     if ($self->
3629     manakai_read_only
3630     ) {
3631    
3632    
3633     {
3634    
3635     local $Error::Depth = $Error::Depth - 1;
3636    
3637     {
3638    
3639     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
3640    
3641    
3642 wakaba 1.3 }
3643 wakaba 1.1
3644    
3645     ;}
3646    
3647     ;
3648     }
3649     if (@new_child) {
3650     if ($nc_parent and
3651     $nc_parent->
3652     manakai_read_only
3653     ) {
3654    
3655    
3656     {
3657    
3658     local $Error::Depth = $Error::Depth - 1;
3659    
3660     {
3661    
3662     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
3663    
3664    
3665 wakaba 1.3 }
3666 wakaba 1.1
3667    
3668     ;}
3669    
3670     ;
3671     }
3672     }
3673     }
3674    
3675     ## -- Insert at...
3676     my $index = -1; # last
3677    
3678    
3679     {
3680    
3681    
3682     # tc:ForAppendChild & tc:ForReplaceChild
3683     if (defined $refChild) {
3684     if ($refChild eq $newChild) {
3685    
3686    
3687     {
3688    
3689    
3690     {
3691    
3692     local $Error::Depth = $Error::Depth - 1;
3693    
3694     {
3695    
3696     report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#insert-before-itself', 'rdata' => $refChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
3697    
3698    
3699 wakaba 1.3 }
3700 wakaba 1.1
3701    
3702     ;}
3703    
3704     ;
3705    
3706    
3707    
3708 wakaba 1.3 }
3709 wakaba 1.1
3710     ;
3711    
3712    
3713     ;
3714     }
3715    
3716     my $cns = $self->
3717     child_nodes
3718     ;
3719     my $cnsl = @$cns;
3720     C: {
3721     $index = 0;
3722     for my $i (0..($cnsl-1)) {
3723     my $cn = $cns->[$i];
3724     if ($cn eq $refChild) {
3725     $index += $i;
3726     last C;
3727     } elsif ($cn eq $newChild) {
3728     $index = -1; # offset
3729     }
3730     }
3731    
3732    
3733     {
3734    
3735    
3736     {
3737    
3738     local $Error::Depth = $Error::Depth - 1;
3739    
3740     {
3741    
3742     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/insertBeforeImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'refChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $refChild;
3743    
3744    
3745 wakaba 1.3 }
3746 wakaba 1.1
3747    
3748     ;}
3749    
3750     ;
3751    
3752    
3753    
3754 wakaba 1.3 }
3755 wakaba 1.1
3756     ;
3757    
3758    
3759     ;
3760     } # C
3761     } else { # |oldChild| is not defined
3762    
3763    
3764     ;
3765     }
3766    
3767    
3768    
3769 wakaba 1.3 }
3770 wakaba 1.1
3771     ; # FOR !tc:ForAppendChild
3772    
3773     ## -- Removes from parent
3774     if ($nc_parent) {
3775     if ($child_nt ==
3776 wakaba 1.7 11
3777 wakaba 1.1 ) {
3778 wakaba 1.13 $$newChild->{
3779     'child'
3780     } = [];
3781 wakaba 1.1 } else {
3782 wakaba 1.13 my $v = $$nc_parent->{
3783     'child'
3784     };
3785 wakaba 1.1 RP: for my $i (0..$#$v) {
3786 wakaba 1.13 if ($v->[$i] eq $new_child[0]) {
3787 wakaba 1.1 splice @$v, $i, 1, ();
3788     last RP;
3789     }
3790     } # RP
3791     }
3792     }
3793    
3794     ## -- Rewrite the |parentNode| properties
3795     for my $nc (@new_child) {
3796 wakaba 1.13 $$nc->{
3797     'parent'
3798     } = $self;
3799     Scalar::Util::weaken ($$nc->{
3800     'parent'
3801     });
3802     }
3803 wakaba 1.1
3804 wakaba 1.13 my $children = $$self->{
3805     'child'
3806 wakaba 1.1 };
3807    
3808    
3809    
3810     ;
3811    
3812    
3813    
3814     {
3815    
3816    
3817     ## -- Adds to children list
3818     if ($index == -1) {
3819 wakaba 1.13 push @$children, @new_child;
3820 wakaba 1.1 } else {
3821 wakaba 1.13 splice @$children, $index, 0, @new_child;
3822 wakaba 1.1 }
3823     $r = $newChild;
3824    
3825    
3826    
3827 wakaba 1.3 }
3828 wakaba 1.1
3829     ;
3830    
3831    
3832    
3833     ;
3834    
3835    
3836    
3837 wakaba 1.3 }
3838 wakaba 1.1
3839    
3840     ;}
3841    
3842     ;
3843    
3844    
3845 wakaba 1.3 }
3846 wakaba 1.1
3847     ;
3848    
3849    
3850 wakaba 1.3 }
3851 wakaba 1.1 $r}
3852     sub replace_child ($$$) {
3853     my ($self, $newChild, $oldChild) = @_;
3854     my $r;
3855    
3856     {
3857    
3858     if
3859     ($self eq $newChild) {
3860    
3861     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';
3862    
3863     ;
3864     }
3865     my $self_od = $self->
3866     owner_document
3867     ;
3868     my $child_od = $newChild->
3869     owner_document
3870     ;
3871     my $child_nt = $newChild->
3872     node_type
3873     ;
3874    
3875    
3876     {
3877    
3878    
3879     {
3880    
3881     local $Error::Depth = $Error::Depth + 1;
3882    
3883     {
3884    
3885    
3886     my
3887     $strict = $self_od->
3888     strict_error_checking
3889     ;
3890    
3891     ## -- Node Type check
3892     my @new_child;
3893     if ({
3894 wakaba 1.7 3 => 1,
3895     5 => 1,
3896     1 => 1,
3897     7 => 1,
3898     4 => 1,
3899     8 => 1,
3900 wakaba 1.1 }->{$child_nt}) {
3901     push @new_child, $newChild;
3902     } elsif ($child_nt ==
3903 wakaba 1.7 11
3904 wakaba 1.1 ) {
3905     for my $cn (@{$newChild->
3906     child_nodes
3907     }) {
3908     unless ({
3909 wakaba 1.7 3 => 1,
3910     5 => 1,
3911     1 => 1,
3912     7 => 1,
3913     4 => 1,
3914     8 => 1,
3915 wakaba 1.1 }->{$cn->
3916     node_type
3917     }) {
3918    
3919    
3920     {
3921    
3922     local $Error::Depth = $Error::Depth - 1;
3923    
3924     {
3925    
3926     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3927    
3928    
3929 wakaba 1.3 }
3930 wakaba 1.1
3931    
3932     ;}
3933    
3934     ;
3935     }
3936     push @new_child, $cn;
3937     }
3938     } else {
3939    
3940    
3941     {
3942    
3943     local $Error::Depth = $Error::Depth - 1;
3944    
3945     {
3946    
3947     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'HIERARCHY_REQUEST_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#HIERARCHY_BAD_TYPE', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3948    
3949    
3950 wakaba 1.3 }
3951 wakaba 1.1
3952    
3953     ;}
3954    
3955     ;
3956     }
3957    
3958     my $nc_parent = @new_child ? $new_child[0]->
3959     parent_node
3960     :
3961    
3962     undef
3963     ;
3964     if ($strict) {
3965     ## -- Wrong-document check
3966     unless ($self_od eq $child_od) {
3967    
3968    
3969     {
3970    
3971     local $Error::Depth = $Error::Depth - 1;
3972    
3973     {
3974    
3975     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'WRONG_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#DIFFERENT_DOCUMENT_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'newChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $newChild;
3976    
3977    
3978 wakaba 1.3 }
3979 wakaba 1.1
3980    
3981     ;}
3982    
3983     ;
3984     }
3985    
3986     ## -- Read-onlyness check
3987     if ($self->
3988     manakai_read_only
3989     ) {
3990    
3991    
3992     {
3993    
3994     local $Error::Depth = $Error::Depth - 1;
3995    
3996     {
3997    
3998     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_THIS', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
3999    
4000    
4001 wakaba 1.3 }
4002 wakaba 1.1
4003    
4004     ;}
4005    
4006     ;
4007     }
4008     if (@new_child) {
4009     if ($nc_parent and
4010     $nc_parent->
4011     manakai_read_only
4012     ) {
4013    
4014    
4015     {
4016    
4017     local $Error::Depth = $Error::Depth - 1;
4018    
4019     {
4020    
4021     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NO_MODIFICATION_ALLOWED_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#NOMOD_SRC_PARENT', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
4022    
4023    
4024 wakaba 1.3 }
4025 wakaba 1.1
4026    
4027     ;}
4028    
4029     ;
4030     }
4031     }
4032     }
4033    
4034     ## -- Insert at...
4035     my $index = -1; # last
4036    
4037    
4038     {
4039    
4040    
4041     # tc:ForAppendChild & tc:ForReplaceChild
4042     if (defined $oldChild) {
4043     if ($oldChild eq $newChild) {
4044    
4045    
4046     ;
4047    
4048    
4049     {
4050    
4051    
4052     {
4053    
4054     local $Error::Depth = $Error::Depth - 1;
4055    
4056     {
4057    
4058     report Message::DOM::DOMCore::ManakaiDOMError -object => $self, '-type' => 'http://suika.fam.cx/~wakaba/archive/2004/dom/tree#replace-by-itself', 'rdata' => $oldChild, 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest';
4059    
4060    
4061 wakaba 1.3 }
4062 wakaba 1.1
4063    
4064     ;}
4065    
4066     ;
4067    
4068    
4069    
4070 wakaba 1.3 }
4071 wakaba 1.1
4072     ;
4073     }
4074    
4075     my $cns = $self->
4076     child_nodes
4077     ;
4078     my $cnsl = @$cns;
4079     C: {
4080     $index = 0;
4081     for my $i (0..($cnsl-1)) {
4082     my $cn = $cns->[$i];
4083     if ($cn eq $oldChild) {
4084     $index += $i;
4085     last C;
4086     } elsif ($cn eq $newChild) {
4087     $index = -1; # offset
4088     }
4089     }
4090    
4091    
4092     ;
4093    
4094    
4095     {
4096    
4097    
4098     {
4099    
4100     local $Error::Depth = $Error::Depth - 1;
4101    
4102     {
4103    
4104     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild;
4105    
4106    
4107 wakaba 1.3 }
4108 wakaba 1.1
4109    
4110     ;}
4111    
4112     ;
4113    
4114    
4115    
4116 wakaba 1.3 }
4117 wakaba 1.1
4118     ;
4119     } # C
4120     } else { # |oldChild| is not defined
4121    
4122    
4123     {
4124    
4125    
4126     {
4127    
4128     local $Error::Depth = $Error::Depth - 1;
4129    
4130     {
4131    
4132     report Message::DOM::DOMCore::ManakaiDOMException -object => $self, '-type' => 'NOT_FOUND_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#subtype' => 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#NOT_CHILD_ERR', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#resourceURI' => 'tag:suika.fam.cx,2005-09:http://suika.fam.cx/~wakaba/archive/2005/manakai/DOM/TreeCore/replaceChildImpl1+http://suika.fam.cx/~wakaba/archive/2004/8/18/manakai-dom%23ManakaiDOMLatest', 'http://suika.fam.cx/~wakaba/archive/2004/8/4/manakai-dom-exception#param-name' => 'oldChild', 'http://suika.fam.cx/~wakaba/archive/2004/8/18/dom-core#node' => $oldChild;
4133    
4134    
4135 wakaba 1.3 }
4136 wakaba 1.1
4137    
4138     ;}
4139    
4140     ;
4141    
4142    
4143    
4144 wakaba 1.3 }
4145 wakaba 1.1
4146     ;
4147     }
4148    
4149    
4150    
4151 wakaba 1.3 }
4152 wakaba 1.1
4153     ; # FOR !tc:ForAppendChild
4154    
4155     ## -- Removes from parent
4156     if ($nc_parent) {
4157     if ($child_nt ==
4158 wakaba 1.7 11
4159 wakaba 1.1 ) {
4160 wakaba 1.13 $$newChild->{
4161     'child'
4162     } = [];
4163 wakaba 1.1 } else {
4164 wakaba 1.13 my $v = $$nc_parent->{
4165     'child'
4166     };
4167 wakaba 1.1 RP: for my $i (0..$#$v) {
4168 wakaba 1.13 if ($v->[$i] eq $new_child[0]) {
4169 wakaba 1.1 splice @$v, $i, 1, ();
4170     last RP;
4171     }
4172     } # RP
4173     }
4174     }
4175    
4176     ## -- Rewrite the |parentNode| properties
4177     for my $nc (@new_child) {
4178 wakaba 1.13 $$nc->{
4179     'parent'
4180     } = $self;
4181     Scalar::Util::weaken ($$nc->{
4182     'parent'
4183     });
4184     }
4185 wakaba 1.1
4186 wakaba 1.13 my $children = $$self->{
4187     'child'
4188 wakaba 1.1 };
4189    
4190    
4191    
4192     ;
4193    
4194    
4195    
4196     ;
4197    
4198    
4199    
4200     {
4201    
4202    
4203     ## -- Replaces the node
4204 wakaba 1.13 splice @$children, $index, 1, @new_child;
4205     CORE::delete $$oldChild->{
4206     'parent'
4207     };
4208 wakaba 1.1 $r = $oldChild;
4209    
4210    
4211    
4212 wakaba 1.3 }
4213 wakaba 1.1
4214     ;
4215    
4216    
4217    
4218 wakaba 1.3 }
4219 wakaba 1.1
4220    
4221     ;}
4222    
4223     ;
4224    
4225    
4226 wakaba 1.3 }
4227 wakaba 1.1
4228     ;
4229    
4230    
4231 wakaba 1.3 }
4232 wakaba 1.1 $r}
4233     sub node_name ($;$) {
4234     if (@_ == 1) {my ($self) = @_;
4235 wakaba 1.12 my $r = '';
4236 wakaba 1.1 $r = '#document-fragment';
4237     $r;
4238     } else {my ($self) = @_;
4239     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';
4240     }
4241     }
4242     sub manakai_append_text ($$) {
4243     my ($self, $string) = @_;
4244     my $r;
4245    
4246     {
4247    
4248    
4249     {
4250    
4251     local $Error::Depth = $Error::Depth + 1;
4252    
4253     {
4254    
4255    
4256     my
4257     $lc = $self->
4258     last_child
4259     ;
4260     if (defined $lc and
4261     $lc->
4262     node_type
4263     ==
4264 wakaba 1.7 3
4265 wakaba 1.1 ) {
4266     $lc->
4267     manakai_append_text
4268    
4269     (ref $string eq 'SCALAR' ? $string : \$string);
4270     } else {
4271     my $text = $self->
4272     owner_document
4273    
4274     ->
4275     create_text_node
4276    
4277     (ref $string eq 'SCALAR' ? $$string : $string);
4278     $self->
4279     append_child
4280     ($text);
4281     }
4282     $r = $self;
4283    
4284    
4285    
4286 wakaba 1.3 }
4287 wakaba 1.1
4288    
4289     ;}
4290    
4291     ;
4292    
4293    
4294 wakaba 1.3 }
4295 wakaba 1.1 $r}
4296     sub get_feature ($$$) {
4297     my ($self, $feature, $version) = @_;
4298    
4299     {
4300    
4301    
4302     $feature = lc $feature;
4303    
4304    
4305 wakaba 1.3 }
4306 wakaba 1.1
4307     {
4308    
4309    
4310     $version = '' unless defined $version;
4311    
4312    
4313 wakaba 1.3 }
4314 wakaba 1.1 my $r;
4315    
4316     {
4317    
4318    
4319     $feature =~ s/^\+//;
4320    
4321    
4322     {
4323    
4324     if
4325 wakaba 1.10 ($Message::Util::AutoLoad::Registry::Feature->{$feature}->{$version}) {
4326 wakaba 1.1 $r = $self;
4327     }
4328    
4329    
4330 wakaba 1.3 }
4331 wakaba 1.1
4332     ;
4333     unless (defined $r) {
4334    
4335    
4336     {
4337    
4338     local $Error::Depth = $Error::Depth + 1;
4339    
4340     {
4341    
4342    
4343    
4344     $r = $self->SUPER::get_feature ($feature, $version);
4345    
4346    
4347    
4348 wakaba 1.3 }
4349 wakaba 1.1
4350    
4351     ;}
4352    
4353     ;
4354     }
4355    
4356    
4357 wakaba 1.3 }
4358 wakaba 1.1 $r}
4359     sub base_uri ($;$) {
4360     if (@_ == 1) {my ($self) = @_;
4361 wakaba 1.12 my $r = '';
4362 wakaba 1.1
4363     {
4364    
4365    
4366     {
4367    
4368     local $Error::Depth = $Error::Depth + 1;
4369    
4370     {
4371    
4372    
4373    
4374     $r = $self->
4375     owner_document
4376     ->
4377     base_uri
4378     ;
4379    
4380    
4381    
4382 wakaba 1.3 }
4383 wakaba 1.1
4384    
4385     ;}
4386    
4387     ;
4388    
4389    
4390 wakaba 1.3 }
4391 wakaba 1.1 $r;
4392     } else {my ($self) = @_;
4393     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';
4394     }
4395     }
4396     $Message::DOM::DOMFeature::ClassInfo->{q<Message::DOM::Document::ManakaiDOMDocumentFragment>}->{has_feature} = {'core',
4397     {'',
4398     '1',
4399     '1.0',
4400     '1',
4401     '2.0',
4402     '1',
4403     '3.0',
4404     '1'},
4405     'xml',
4406     {'',
4407     '1',
4408     '1.0',
4409     '1',
4410     '2.0',
4411     '1',
4412     '3.0',
4413     '1'},
4414     'xmlversion',
4415     {'',
4416     '1',
4417     '1.0',
4418     '1',
4419     '1.1',
4420     '1'}};
4421     $Message::DOM::ClassPoint{q<Message::DOM::Document::ManakaiDOMDocumentFragment>} = 14.1;
4422 wakaba 1.14 for ($Message::DOM::IFLatest::Node::){}
4423 wakaba 1.1 ## License: <http://suika.fam.cx/~wakaba/archive/2004/8/18/license#Perl+MPL>
4424     1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24