/[suikacvs]/markup/html/whatpm/Whatpm/HTML.pm.src
Suika

Diff of /markup/html/whatpm/Whatpm/HTML.pm.src

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.217 by wakaba, Sun Jul 5 05:13:13 2009 UTC revision 1.218 by wakaba, Sat Jul 25 03:38:42 2009 UTC
# Line 5445  sub _tree_construction_main ($) { Line 5445  sub _tree_construction_main ($) {
5445    ## TODO: script stuffs    ## TODO: script stuffs
5446  } # _tree_construct_main  } # _tree_construct_main
5447    
5448    ## XXX: How this method is organized is somewhat out of date, although
5449    ## it still does what the current spec documents.
5450  sub set_inner_html ($$$$;$) {  sub set_inner_html ($$$$;$) {
5451    my $class = shift;    my $class = shift;
5452    my $node = shift;    my $node = shift; # /context/
5453    #my $s = \$_[0];    #my $s = \$_[0];
5454    my $onerror = $_[1];    my $onerror = $_[1];
5455    my $get_wrapper = $_[2] || sub ($) { return $_[0] };    my $get_wrapper = $_[2] || sub ($) { return $_[0] };
# Line 5455  sub set_inner_html ($$$$;$) { Line 5457  sub set_inner_html ($$$$;$) {
5457    ## ISSUE: Should {confident} be true?    ## ISSUE: Should {confident} be true?
5458    
5459    my $nt = $node->node_type;    my $nt = $node->node_type;
5460    if ($nt == 9) {    if ($nt == 9) { # Document (invoke the algorithm with no /context/ element)
5461      # MUST      # MUST
5462            
5463      ## Step 1 # MUST      ## Step 1 # MUST
# Line 5470  sub set_inner_html ($$$$;$) { Line 5472  sub set_inner_html ($$$$;$) {
5472    
5473      ## Step 3, 4, 5 # MUST      ## Step 3, 4, 5 # MUST
5474      $class->parse_char_string ($_[0] => $node, $onerror, $get_wrapper);      $class->parse_char_string ($_[0] => $node, $onerror, $get_wrapper);
5475    } elsif ($nt == 1) {    } elsif ($nt == 1) { # Element (invoke the algorithm with /context/ element)
5476      ## TODO: If non-html element      ## TODO: If non-html element
5477    
5478      ## NOTE: Most of this code is copied from |parse_string|      ## NOTE: Most of this code is copied from |parse_string|
5479    
5480  ## TODO: Support for $get_wrapper  ## TODO: Support for $get_wrapper
5481    
5482      ## Step 1 # MUST      ## F1. Create an HTML document.
5483      my $this_doc = $node->owner_document;      my $this_doc = $node->owner_document;
5484      my $doc = $this_doc->implementation->create_document;      my $doc = $this_doc->implementation->create_document;
5485      $doc->manakai_is_html (1);      $doc->manakai_is_html (1);
5486    
5487        ## F2. Propagate quirkness flag
5488        my $node_doc = $node->owner_document;
5489        $doc->manakai_compat_mode ($node_doc->manakai_compat_mode);
5490    
5491        ## F3. Create an HTML parser
5492      my $p = $class->new;      my $p = $class->new;
5493      $p->{document} = $doc;      $p->{document} = $doc;
5494    
# Line 5608  sub set_inner_html ($$$$;$) { Line 5616  sub set_inner_html ($$$$;$) {
5616      $p->_initialize_tokenizer;      $p->_initialize_tokenizer;
5617      $p->_initialize_tree_constructor;      $p->_initialize_tree_constructor;
5618    
5619      ## Step 2      ## F4. If /context/ is not undef...
5620    
5621        ## F4.1. content model flag
5622      my $node_ln = $node->manakai_local_name;      my $node_ln = $node->manakai_local_name;
5623      $p->{content_model} = {      $p->{content_model} = {
5624        title => RCDATA_CONTENT_MODEL,        title => RCDATA_CONTENT_MODEL,
# Line 5628  sub set_inner_html ($$$$;$) { Line 5638  sub set_inner_html ($$$$;$) {
5638      $p->{inner_html_node} = [$node, $el_category->{$node_ln}];      $p->{inner_html_node} = [$node, $el_category->{$node_ln}];
5639        ## TODO: Foreign element OK?        ## TODO: Foreign element OK?
5640    
5641      ## Step 3      ## F4.2. Root |html| element
5642      my $root = $doc->create_element_ns      my $root = $doc->create_element_ns
5643        ('http://www.w3.org/1999/xhtml', [undef, 'html']);        ('http://www.w3.org/1999/xhtml', [undef, 'html']);
5644    
5645      ## Step 4 # MUST      ## F4.3.
5646      $doc->append_child ($root);      $doc->append_child ($root);
5647    
5648      ## Step 5 # MUST      ## F4.4.
5649      push @{$p->{open_elements}}, [$root, $el_category->{html}];      push @{$p->{open_elements}}, [$root, $el_category->{html}];
5650    
5651      undef $p->{head_element};      undef $p->{head_element};
5652      undef $p->{head_element_inserted};      undef $p->{head_element_inserted};
5653    
5654      ## Step 6 # MUST      ## F4.5.
5655      $p->_reset_insertion_mode;      $p->_reset_insertion_mode;
5656    
5657      ## Step 7 # MUST      ## F4.6.
5658      my $anode = $node;      my $anode = $node;
5659      AN: while (defined $anode) {      AN: while (defined $anode) {
5660        if ($anode->node_type == 1) {        if ($anode->node_type == 1) {
# Line 5659  sub set_inner_html ($$$$;$) { Line 5669  sub set_inner_html ($$$$;$) {
5669        }        }
5670        $anode = $anode->parent_node;        $anode = $anode->parent_node;
5671      } # AN      } # AN
5672        
5673      ## Step 9 # MUST      ## F.6. Start the parser.
5674      {      {
5675        my $self = $p;        my $self = $p;
5676        !!!next-token;        !!!next-token;
5677      }      }
5678      $p->_tree_construction_main;      $p->_tree_construction_main;
5679    
5680      ## Step 10 # MUST      ## F.7.
5681      my @cn = @{$node->child_nodes};      my @cn = @{$node->child_nodes};
5682      for (@cn) {      for (@cn) {
5683        $node->remove_child ($_);        $node->remove_child ($_);

Legend:
Removed from v.1.217  
changed lines
  Added in v.1.218

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24