/[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.19 - (hide annotations) (download)
Sun Dec 31 11:45:50 2006 UTC (17 years, 10 months ago) by wakaba
Branch: MAIN
Changes since 1.18: +7 -7 lines
++ manakai/lib/manakai/ChangeLog	31 Dec 2006 09:13:11 -0000
	* DISCore.dis (TFQNames): Removed.

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

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24