/[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.215 by wakaba, Thu Jul 2 22:11:51 2009 UTC revision 1.222 by wakaba, Sun Aug 16 03:41:52 2009 UTC
# Line 1419  sub _tree_construction_main ($) { Line 1419  sub _tree_construction_main ($) {
1419      ## Step 3      ## Step 3
1420      ## TODO: Mark as "already executed", if ...      ## TODO: Mark as "already executed", if ...
1421    
1422      ## Step 4      ## Step 4 (HTML5 revision 2702)
1423      $insert->($script_el);      $insert->($script_el);
   
     ## ISSUE: $script_el is not put into the stack  
1424      push @{$self->{open_elements}}, [$script_el, $el_category->{script}];      push @{$self->{open_elements}}, [$script_el, $el_category->{script}];
1425    
1426      ## Step 5      ## Step 5
# Line 1956  sub _tree_construction_main ($) { Line 1954  sub _tree_construction_main ($) {
1954          }          }
1955        } elsif ($token->{type} == END_TAG_TOKEN) {        } elsif ($token->{type} == END_TAG_TOKEN) {
1956          ## NOTE: "using the rules for secondary insertion mode" then "continue"          ## NOTE: "using the rules for secondary insertion mode" then "continue"
1957          !!!cp ('t87.5');          if ($token->{tag_name} eq 'script') {
1958          #            !!!cp ('t87.41');
1959              #
1960              ## XXXscript: Execute script here.
1961            } else {
1962              !!!cp ('t87.5');
1963              #
1964            }
1965        } elsif ($token->{type} == END_OF_FILE_TOKEN) {        } elsif ($token->{type} == END_OF_FILE_TOKEN) {
1966          !!!cp ('t87.6');          !!!cp ('t87.6');
1967          !!!parse-error (type => 'not closed',          !!!parse-error (type => 'not closed',
# Line 3837  sub _tree_construction_main ($) { Line 3841  sub _tree_construction_main ($) {
3841            !!!next-token;            !!!next-token;
3842            next B;            next B;
3843          } elsif ({          } elsif ({
3844                     select => 1, input => 1, textarea => 1,                     select => 1, input => 1, textarea => 1, keygen => 1,
3845                   }->{$token->{tag_name}} or                   }->{$token->{tag_name}} or
3846                   (($self->{insertion_mode} & IM_MASK)                   (($self->{insertion_mode} & IM_MASK)
3847                        == IN_SELECT_IN_TABLE_IM and                        == IN_SELECT_IN_TABLE_IM and
# Line 3846  sub _tree_construction_main ($) { Line 3850  sub _tree_construction_main ($) {
3850                     tbody => 1, tfoot => 1, thead => 1,                     tbody => 1, tfoot => 1, thead => 1,
3851                     tr => 1, td => 1, th => 1,                     tr => 1, td => 1, th => 1,
3852                    }->{$token->{tag_name}})) {                    }->{$token->{tag_name}})) {
3853            ## TODO: The type below is not good - <select> is replaced by </select>  
3854            !!!parse-error (type => 'not closed', text => 'select',            ## 1. Parse error.
3855                            token => $token);            if ($token->{tag_name} eq 'select') {
3856            ## NOTE: As if the token were </select> (<select> case) or                !!!parse-error (type => 'select in select', ## XXX: documentation
3857            ## as if there were </select> (otherwise).                                token => $token);
3858            ## have an element in table scope            } else {
3859                !!!parse-error (type => 'not closed', text => 'select',
3860                                token => $token);
3861              }
3862    
3863              ## 2./<select>-1. Unless "have an element in table scope" (select):
3864            my $i;            my $i;
3865            INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {            INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
3866              my $node = $self->{open_elements}->[$_];              my $node = $self->{open_elements}->[$_];
# Line 3866  sub _tree_construction_main ($) { Line 3875  sub _tree_construction_main ($) {
3875            } # INSCOPE            } # INSCOPE
3876            unless (defined $i) {            unless (defined $i) {
3877              !!!cp ('t280');              !!!cp ('t280');
3878              !!!parse-error (type => 'unmatched end tag',              if ($token->{tag_name} eq 'select') {
3879                              text => 'select', token => $token);                ## NOTE: This error would be raised when
3880              ## Ignore the token                ## |select.innerHTML = '<select>'| is executed; in this
3881                  ## case two errors, "select in select" and "unmatched
3882                  ## end tags" are reported to the user, the latter might
3883                  ## be confusing but this is what the spec requires.
3884                  !!!parse-error (type => 'unmatched end tag',
3885                                  text => 'select',
3886                                  token => $token);
3887                }
3888                ## Ignore the token.
3889              !!!nack ('t280.1');              !!!nack ('t280.1');
3890              !!!next-token;              !!!next-token;
3891              next B;              next B;
3892            }            }
3893    
3894              ## 3. Otherwise, as if there were <select>:
3895                                
3896            !!!cp ('t281');            !!!cp ('t281');
3897            splice @{$self->{open_elements}}, $i;            splice @{$self->{open_elements}}, $i;
# Line 4417  sub _tree_construction_main ($) { Line 4436  sub _tree_construction_main ($) {
4436            next B;            next B;
4437          }          }
4438    
4439          ## has a p element in scope          if ($token->{tag_name} ne 'table' or # The Hixie Quirk
4440          INSCOPE: for (reverse @{$self->{open_elements}}) {              $self->{document}->manakai_compat_mode ne 'quirks') {
4441            if ($_->[1] == P_EL) {            ## has a p element in scope
4442              !!!cp ('t344');            INSCOPE: for (reverse @{$self->{open_elements}}) {
4443              !!!back-token; # <form>              if ($_->[1] == P_EL) {
4444              $token = {type => END_TAG_TOKEN, tag_name => 'p',                !!!cp ('t344');
4445                        line => $token->{line}, column => $token->{column}};                !!!back-token; # <form>
4446              next B;                $token = {type => END_TAG_TOKEN, tag_name => 'p',
4447            } elsif ($_->[1] & SCOPING_EL) {                          line => $token->{line}, column => $token->{column}};
4448              !!!cp ('t345');                next B;
4449              last INSCOPE;              } elsif ($_->[1] & SCOPING_EL) {
4450            }                !!!cp ('t345');
4451          } # INSCOPE                last INSCOPE;
4452                }
4453              } # INSCOPE
4454            }
4455                        
4456          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
4457          if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') {          if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') {
# Line 5045  sub _tree_construction_main ($) { Line 5067  sub _tree_construction_main ($) {
5067          } # INSCOPE          } # INSCOPE
5068    
5069          for (@{$self->{open_elements}}) {          for (@{$self->{open_elements}}) {
5070            unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL) {            unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL ||
5071                      $_->[1] == OPTGROUP_EL ||
5072                      $_->[1] == OPTION_EL ||
5073                      $_->[1] == RUBY_COMPONENT_EL) {
5074              !!!cp ('t403');              !!!cp ('t403');
5075              !!!parse-error (type => 'not closed',              !!!parse-error (type => 'not closed',
5076                              text => $_->[0]->manakai_local_name,                              text => $_->[0]->manakai_local_name,
# Line 5442  sub _tree_construction_main ($) { Line 5467  sub _tree_construction_main ($) {
5467    ## TODO: script stuffs    ## TODO: script stuffs
5468  } # _tree_construct_main  } # _tree_construct_main
5469    
5470    ## XXX: How this method is organized is somewhat out of date, although
5471    ## it still does what the current spec documents.
5472  sub set_inner_html ($$$$;$) {  sub set_inner_html ($$$$;$) {
5473    my $class = shift;    my $class = shift;
5474    my $node = shift;    my $node = shift; # /context/
5475    #my $s = \$_[0];    #my $s = \$_[0];
5476    my $onerror = $_[1];    my $onerror = $_[1];
5477    my $get_wrapper = $_[2] || sub ($) { return $_[0] };    my $get_wrapper = $_[2] || sub ($) { return $_[0] };
# Line 5452  sub set_inner_html ($$$$;$) { Line 5479  sub set_inner_html ($$$$;$) {
5479    ## ISSUE: Should {confident} be true?    ## ISSUE: Should {confident} be true?
5480    
5481    my $nt = $node->node_type;    my $nt = $node->node_type;
5482    if ($nt == 9) {    if ($nt == 9) { # Document (invoke the algorithm with no /context/ element)
5483      # MUST      # MUST
5484            
5485      ## Step 1 # MUST      ## Step 1 # MUST
# Line 5467  sub set_inner_html ($$$$;$) { Line 5494  sub set_inner_html ($$$$;$) {
5494    
5495      ## Step 3, 4, 5 # MUST      ## Step 3, 4, 5 # MUST
5496      $class->parse_char_string ($_[0] => $node, $onerror, $get_wrapper);      $class->parse_char_string ($_[0] => $node, $onerror, $get_wrapper);
5497    } elsif ($nt == 1) {    } elsif ($nt == 1) { # Element (invoke the algorithm with /context/ element)
5498      ## TODO: If non-html element      ## TODO: If non-html element
5499    
5500      ## NOTE: Most of this code is copied from |parse_string|      ## NOTE: Most of this code is copied from |parse_string|
5501    
5502  ## TODO: Support for $get_wrapper  ## TODO: Support for $get_wrapper
5503    
5504      ## Step 1 # MUST      ## F1. Create an HTML document.
5505      my $this_doc = $node->owner_document;      my $this_doc = $node->owner_document;
5506      my $doc = $this_doc->implementation->create_document;      my $doc = $this_doc->implementation->create_document;
5507      $doc->manakai_is_html (1);      $doc->manakai_is_html (1);
5508    
5509        ## F2. Propagate quirkness flag
5510        my $node_doc = $node->owner_document;
5511        $doc->manakai_compat_mode ($node_doc->manakai_compat_mode);
5512    
5513        ## F3. Create an HTML parser
5514      my $p = $class->new;      my $p = $class->new;
5515      $p->{document} = $doc;      $p->{document} = $doc;
5516    
# Line 5605  sub set_inner_html ($$$$;$) { Line 5638  sub set_inner_html ($$$$;$) {
5638      $p->_initialize_tokenizer;      $p->_initialize_tokenizer;
5639      $p->_initialize_tree_constructor;      $p->_initialize_tree_constructor;
5640    
5641      ## Step 2      ## F4. If /context/ is not undef...
5642    
5643        ## F4.1. content model flag
5644      my $node_ln = $node->manakai_local_name;      my $node_ln = $node->manakai_local_name;
5645      $p->{content_model} = {      $p->{content_model} = {
5646        title => RCDATA_CONTENT_MODEL,        title => RCDATA_CONTENT_MODEL,
# Line 5625  sub set_inner_html ($$$$;$) { Line 5660  sub set_inner_html ($$$$;$) {
5660      $p->{inner_html_node} = [$node, $el_category->{$node_ln}];      $p->{inner_html_node} = [$node, $el_category->{$node_ln}];
5661        ## TODO: Foreign element OK?        ## TODO: Foreign element OK?
5662    
5663      ## Step 3      ## F4.2. Root |html| element
5664      my $root = $doc->create_element_ns      my $root = $doc->create_element_ns
5665        ('http://www.w3.org/1999/xhtml', [undef, 'html']);        ('http://www.w3.org/1999/xhtml', [undef, 'html']);
5666    
5667      ## Step 4 # MUST      ## F4.3.
5668      $doc->append_child ($root);      $doc->append_child ($root);
5669    
5670      ## Step 5 # MUST      ## F4.4.
5671      push @{$p->{open_elements}}, [$root, $el_category->{html}];      push @{$p->{open_elements}}, [$root, $el_category->{html}];
5672    
5673      undef $p->{head_element};      undef $p->{head_element};
5674      undef $p->{head_element_inserted};      undef $p->{head_element_inserted};
5675    
5676      ## Step 6 # MUST      ## F4.5.
5677      $p->_reset_insertion_mode;      $p->_reset_insertion_mode;
5678    
5679      ## Step 7 # MUST      ## F4.6.
5680      my $anode = $node;      my $anode = $node;
5681      AN: while (defined $anode) {      AN: while (defined $anode) {
5682        if ($anode->node_type == 1) {        if ($anode->node_type == 1) {
# Line 5656  sub set_inner_html ($$$$;$) { Line 5691  sub set_inner_html ($$$$;$) {
5691        }        }
5692        $anode = $anode->parent_node;        $anode = $anode->parent_node;
5693      } # AN      } # AN
5694        
5695      ## Step 9 # MUST      ## F.6. Start the parser.
5696      {      {
5697        my $self = $p;        my $self = $p;
5698        !!!next-token;        !!!next-token;
5699      }      }
5700      $p->_tree_construction_main;      $p->_tree_construction_main;
5701    
5702      ## Step 10 # MUST      ## F.7.
5703      my @cn = @{$node->child_nodes};      my @cn = @{$node->child_nodes};
5704      for (@cn) {      for (@cn) {
5705        $node->remove_child ($_);        $node->remove_child ($_);

Legend:
Removed from v.1.215  
changed lines
  Added in v.1.222

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24