/[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.200 by wakaba, Sat Oct 4 11:32:15 2008 UTC revision 1.203 by wakaba, Sat Oct 4 17:16:02 2008 UTC
# Line 86  sub ALL_END_TAG_OPTIONAL_EL () { Line 86  sub ALL_END_TAG_OPTIONAL_EL () {
86    LI_EL |    LI_EL |
87    P_EL |    P_EL |
88    
89      ## ISSUE: option, optgroup, rt, rp?
90    
91    BODY_EL |    BODY_EL |
92    HTML_EL |    HTML_EL |
93    TABLE_CELL_EL |    TABLE_CELL_EL |
# Line 130  sub SPECIAL_EL () { Line 132  sub SPECIAL_EL () {
132    FORM_EL |    FORM_EL |
133    FRAMESET_EL |    FRAMESET_EL |
134    HEADING_EL |    HEADING_EL |
   OPTION_EL |  
   OPTGROUP_EL |  
135    SELECT_EL |    SELECT_EL |
136    TABLE_ROW_EL |    TABLE_ROW_EL |
137    TABLE_ROW_GROUP_EL |    TABLE_ROW_GROUP_EL |
# Line 2987  sub _get_next_token ($) { Line 2987  sub _get_next_token ($) {
2987          redo A;          redo A;
2988        } elsif ($self->{nc} == -1) {        } elsif ($self->{nc} == -1) {
2989          !!!cp (220);          !!!cp (220);
         !!!parse-error (type => 'unclosed DOCTYPE');  
2990          $self->{state} = DATA_STATE;          $self->{state} = DATA_STATE;
2991          ## reconsume          ## reconsume
2992    
# Line 3476  sub _construct_tree ($) { Line 3475  sub _construct_tree ($) {
3475    
3476    undef $self->{form_element};    undef $self->{form_element};
3477    undef $self->{head_element};    undef $self->{head_element};
3478      undef $self->{head_element_inserted};
3479    $self->{open_elements} = [];    $self->{open_elements} = [];
3480    undef $self->{inner_html_node};    undef $self->{inner_html_node};
3481    
# Line 4083  sub _tree_construction_main ($) { Line 4083  sub _tree_construction_main ($) {
4083    
4084    ## NOTE: $open_tables->[-1]->[0] is the "current table" element node.    ## NOTE: $open_tables->[-1]->[0] is the "current table" element node.
4085    ## NOTE: $open_tables->[-1]->[1] is the "tainted" flag.    ## NOTE: $open_tables->[-1]->[1] is the "tainted" flag.
4086      ## NOTE: $open_tables->[-1]->[2] is set false when non-Text node inserted.
4087    my $open_tables = [[$self->{open_elements}->[0]->[0]]];    my $open_tables = [[$self->{open_elements}->[0]->[0]]];
4088    
4089    my $formatting_end_tag = sub {    my $formatting_end_tag = sub {
# Line 4167  sub _tree_construction_main ($) { Line 4168  sub _tree_construction_main ($) {
4168            !!!cp ('t59');            !!!cp ('t59');
4169            $furthest_block = $node;            $furthest_block = $node;
4170            $furthest_block_i_in_open = $_;            $furthest_block_i_in_open = $_;
4171              ## NOTE: The topmost (eldest) node.
4172          } elsif ($node->[0] eq $formatting_element->[0]) {          } elsif ($node->[0] eq $formatting_element->[0]) {
4173            !!!cp ('t60');            !!!cp ('t60');
4174            last OE;            last OE;
# Line 4313  sub _tree_construction_main ($) { Line 4315  sub _tree_construction_main ($) {
4315            $i = $_;            $i = $_;
4316          }          }
4317        } # OE        } # OE
4318        splice @{$self->{open_elements}}, $i + 1, 1, $clone;        splice @{$self->{open_elements}}, $i + 1, 0, $clone;
4319                
4320        ## Step 14        ## Step 14
4321        redo FET;        redo FET;
# Line 4356  sub _tree_construction_main ($) { Line 4358  sub _tree_construction_main ($) {
4358      }      }
4359    }; # $insert_to_foster    }; # $insert_to_foster
4360    
4361      ## NOTE: When a character is inserted, if the last node that was
4362      ## inserted by the parser is a Text node and the character has to be
4363      ## inserted after that node, then the character is appended to the
4364      ## Text node.  However, if any other node is inserted by the parser,
4365      ## then a new Text node is created and the character is appended as
4366      ## that Text node.  If I'm not wrong, there are only two cases where
4367      ## this occurs.  One is the case where an element node is inserted
4368      ## to the |head| element.  This is covered by using the
4369      ## |$self->{head_element_inserted}| flag.  Another is the case where
4370      ## an element or comment is inserted into the |table| subtree while
4371      ## foster parenting happens.  This is covered by using the [2] flag
4372      ## of the |$open_tables| structure.  All other cases are handled
4373      ## simply by calling |manakai_append_text| method.
4374    
4375    B: while (1) {    B: while (1) {
4376      if ($token->{type} == DOCTYPE_TOKEN) {      if ($token->{type} == DOCTYPE_TOKEN) {
4377        !!!cp ('t73');        !!!cp ('t73');
# Line 4403  sub _tree_construction_main ($) { Line 4419  sub _tree_construction_main ($) {
4419        } else {        } else {
4420          !!!cp ('t87');          !!!cp ('t87');
4421          $self->{open_elements}->[-1]->[0]->append_child ($comment);          $self->{open_elements}->[-1]->[0]->append_child ($comment);
4422            $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
4423        }        }
4424        !!!next-token;        !!!next-token;
4425        next B;        next B;
# Line 4532  sub _tree_construction_main ($) { Line 4549  sub _tree_construction_main ($) {
4549        if ($token->{type} == CHARACTER_TOKEN) {        if ($token->{type} == CHARACTER_TOKEN) {
4550          if ($token->{data} =~ s/^([\x09\x0A\x0C\x20]+)//) {          if ($token->{data} =~ s/^([\x09\x0A\x0C\x20]+)//) {
4551            unless ($self->{insertion_mode} == BEFORE_HEAD_IM) {            unless ($self->{insertion_mode} == BEFORE_HEAD_IM) {
4552              !!!cp ('t88.2');              if ($self->{head_element_inserted}) {
4553              $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);                !!!cp ('t88.3');
4554              #                $self->{open_elements}->[-1]->[0]->append_child
4555                    ($self->{document}->create_text_node ($1));
4556                  delete $self->{head_element_inserted};
4557                  ## NOTE: |</head> <link> |
4558                  #
4559                } else {
4560                  !!!cp ('t88.2');
4561                  $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);
4562                  ## NOTE: |</head> &#x20;|
4563                  #
4564                }
4565            } else {            } else {
4566              !!!cp ('t88.1');              !!!cp ('t88.1');
4567              ## Ignore the token.              ## Ignore the token.
# Line 4630  sub _tree_construction_main ($) { Line 4657  sub _tree_construction_main ($) {
4657            !!!cp ('t97');            !!!cp ('t97');
4658          }          }
4659    
4660              if ($token->{tag_name} eq 'base') {          if ($token->{tag_name} eq 'base') {
4661                if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {            if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
4662                  !!!cp ('t98');              !!!cp ('t98');
4663                  ## As if </noscript>              ## As if </noscript>
4664                  pop @{$self->{open_elements}};              pop @{$self->{open_elements}};
4665                  !!!parse-error (type => 'in noscript', text => 'base',              !!!parse-error (type => 'in noscript', text => 'base',
4666                                  token => $token);                              token => $token);
4667                            
4668                  $self->{insertion_mode} = IN_HEAD_IM;              $self->{insertion_mode} = IN_HEAD_IM;
4669                  ## Reprocess in the "in head" insertion mode...              ## Reprocess in the "in head" insertion mode...
4670                } else {            } else {
4671                  !!!cp ('t99');              !!!cp ('t99');
4672                }            }
4673    
4674                ## NOTE: There is a "as if in head" code clone.            ## NOTE: There is a "as if in head" code clone.
4675                if ($self->{insertion_mode} == AFTER_HEAD_IM) {            if ($self->{insertion_mode} == AFTER_HEAD_IM) {
4676                  !!!cp ('t100');              !!!cp ('t100');
4677                  !!!parse-error (type => 'after head',              !!!parse-error (type => 'after head',
4678                                  text => $token->{tag_name}, token => $token);                              text => $token->{tag_name}, token => $token);
4679                  push @{$self->{open_elements}},              push @{$self->{open_elements}},
4680                      [$self->{head_element}, $el_category->{head}];                  [$self->{head_element}, $el_category->{head}];
4681                } else {              $self->{head_element_inserted} = 1;
4682                  !!!cp ('t101');            } else {
4683                }              !!!cp ('t101');
4684                !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);            }
4685                pop @{$self->{open_elements}};            !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
4686                pop @{$self->{open_elements}} # <head>            pop @{$self->{open_elements}};
4687                    if $self->{insertion_mode} == AFTER_HEAD_IM;            pop @{$self->{open_elements}} # <head>
4688                !!!nack ('t101.1');                if $self->{insertion_mode} == AFTER_HEAD_IM;
4689                !!!next-token;            !!!nack ('t101.1');
4690                next B;            !!!next-token;
4691              next B;
4692          } elsif ($token->{tag_name} eq 'link') {          } elsif ($token->{tag_name} eq 'link') {
4693            ## NOTE: There is a "as if in head" code clone.            ## NOTE: There is a "as if in head" code clone.
4694            if ($self->{insertion_mode} == AFTER_HEAD_IM) {            if ($self->{insertion_mode} == AFTER_HEAD_IM) {
# Line 4669  sub _tree_construction_main ($) { Line 4697  sub _tree_construction_main ($) {
4697                              text => $token->{tag_name}, token => $token);                              text => $token->{tag_name}, token => $token);
4698              push @{$self->{open_elements}},              push @{$self->{open_elements}},
4699                  [$self->{head_element}, $el_category->{head}];                  [$self->{head_element}, $el_category->{head}];
4700                $self->{head_element_inserted} = 1;
4701            } else {            } else {
4702              !!!cp ('t103');              !!!cp ('t103');
4703            }            }
# Line 4701  sub _tree_construction_main ($) { Line 4730  sub _tree_construction_main ($) {
4730              !!!cp ('t103.3');              !!!cp ('t103.3');
4731              #              #
4732            }            }
4733              } elsif ($token->{tag_name} eq 'meta') {          } elsif ($token->{tag_name} eq 'meta') {
4734                ## NOTE: There is a "as if in head" code clone.            ## NOTE: There is a "as if in head" code clone.
4735                if ($self->{insertion_mode} == AFTER_HEAD_IM) {            if ($self->{insertion_mode} == AFTER_HEAD_IM) {
4736                  !!!cp ('t104');              !!!cp ('t104');
4737                  !!!parse-error (type => 'after head',              !!!parse-error (type => 'after head',
4738                                  text => $token->{tag_name}, token => $token);                              text => $token->{tag_name}, token => $token);
4739                  push @{$self->{open_elements}},              push @{$self->{open_elements}},
4740                      [$self->{head_element}, $el_category->{head}];                  [$self->{head_element}, $el_category->{head}];
4741                } else {              $self->{head_element_inserted} = 1;
4742                  !!!cp ('t105');            } else {
4743                }              !!!cp ('t105');
4744                !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);            }
4745                my $meta_el = pop @{$self->{open_elements}};            !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
4746              my $meta_el = pop @{$self->{open_elements}};
4747    
4748                unless ($self->{confident}) {                unless ($self->{confident}) {
4749                  if ($token->{attributes}->{charset}) {                  if ($token->{attributes}->{charset}) {
# Line 4771  sub _tree_construction_main ($) { Line 4801  sub _tree_construction_main ($) {
4801                !!!ack ('t110.1');                !!!ack ('t110.1');
4802                !!!next-token;                !!!next-token;
4803                next B;                next B;
4804              } elsif ($token->{tag_name} eq 'title') {          } elsif ($token->{tag_name} eq 'title') {
4805                if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {            if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
4806                  !!!cp ('t111');              !!!cp ('t111');
4807                  ## As if </noscript>              ## As if </noscript>
4808                  pop @{$self->{open_elements}};              pop @{$self->{open_elements}};
4809                  !!!parse-error (type => 'in noscript', text => 'title',              !!!parse-error (type => 'in noscript', text => 'title',
4810                                  token => $token);                              token => $token);
4811                            
4812                  $self->{insertion_mode} = IN_HEAD_IM;              $self->{insertion_mode} = IN_HEAD_IM;
4813                  ## Reprocess in the "in head" insertion mode...              ## Reprocess in the "in head" insertion mode...
4814                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {            } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4815                  !!!cp ('t112');              !!!cp ('t112');
4816                  !!!parse-error (type => 'after head',              !!!parse-error (type => 'after head',
4817                                  text => $token->{tag_name}, token => $token);                              text => $token->{tag_name}, token => $token);
4818                  push @{$self->{open_elements}},              push @{$self->{open_elements}},
4819                      [$self->{head_element}, $el_category->{head}];                  [$self->{head_element}, $el_category->{head}];
4820                } else {              $self->{head_element_inserted} = 1;
4821                  !!!cp ('t113');            } else {
4822                }              !!!cp ('t113');
4823              }
4824    
4825                ## NOTE: There is a "as if in head" code clone.            ## NOTE: There is a "as if in head" code clone.
4826                my $parent = defined $self->{head_element} ? $self->{head_element}            $parse_rcdata->(RCDATA_CONTENT_MODEL);
4827                    : $self->{open_elements}->[-1]->[0];            pop @{$self->{open_elements}} # <head>
4828                $parse_rcdata->(RCDATA_CONTENT_MODEL);                if $self->{insertion_mode} == AFTER_HEAD_IM;
4829                pop @{$self->{open_elements}} # <head>            next B;
4830                    if $self->{insertion_mode} == AFTER_HEAD_IM;          } elsif ($token->{tag_name} eq 'style' or
4831                next B;                   $token->{tag_name} eq 'noframes') {
4832              } elsif ($token->{tag_name} eq 'style' or            ## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and
4833                       $token->{tag_name} eq 'noframes') {            ## insertion mode IN_HEAD_IM)
4834                ## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and            ## NOTE: There is a "as if in head" code clone.
4835                ## insertion mode IN_HEAD_IM)            if ($self->{insertion_mode} == AFTER_HEAD_IM) {
4836                ## NOTE: There is a "as if in head" code clone.              !!!cp ('t114');
4837                if ($self->{insertion_mode} == AFTER_HEAD_IM) {              !!!parse-error (type => 'after head',
4838                  !!!cp ('t114');                              text => $token->{tag_name}, token => $token);
4839                  !!!parse-error (type => 'after head',              push @{$self->{open_elements}},
4840                                  text => $token->{tag_name}, token => $token);                  [$self->{head_element}, $el_category->{head}];
4841                  push @{$self->{open_elements}},              $self->{head_element_inserted} = 1;
4842                      [$self->{head_element}, $el_category->{head}];            } else {
4843                } else {              !!!cp ('t115');
4844                  !!!cp ('t115');            }
4845                }            $parse_rcdata->(CDATA_CONTENT_MODEL);
4846                $parse_rcdata->(CDATA_CONTENT_MODEL);            pop @{$self->{open_elements}} # <head>
4847                pop @{$self->{open_elements}} # <head>                if $self->{insertion_mode} == AFTER_HEAD_IM;
4848                    if $self->{insertion_mode} == AFTER_HEAD_IM;            next B;
               next B;  
4849              } elsif ($token->{tag_name} eq 'noscript') {              } elsif ($token->{tag_name} eq 'noscript') {
4850                if ($self->{insertion_mode} == IN_HEAD_IM) {                if ($self->{insertion_mode} == IN_HEAD_IM) {
4851                  !!!cp ('t116');                  !!!cp ('t116');
# Line 4837  sub _tree_construction_main ($) { Line 4867  sub _tree_construction_main ($) {
4867                  !!!cp ('t118');                  !!!cp ('t118');
4868                  #                  #
4869                }                }
4870              } elsif ($token->{tag_name} eq 'script') {          } elsif ($token->{tag_name} eq 'script') {
4871                if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {            if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
4872                  !!!cp ('t119');              !!!cp ('t119');
4873                  ## As if </noscript>              ## As if </noscript>
4874                  pop @{$self->{open_elements}};              pop @{$self->{open_elements}};
4875                  !!!parse-error (type => 'in noscript', text => 'script',              !!!parse-error (type => 'in noscript', text => 'script',
4876                                  token => $token);                              token => $token);
4877                            
4878                  $self->{insertion_mode} = IN_HEAD_IM;              $self->{insertion_mode} = IN_HEAD_IM;
4879                  ## Reprocess in the "in head" insertion mode...              ## Reprocess in the "in head" insertion mode...
4880                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {            } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4881                  !!!cp ('t120');              !!!cp ('t120');
4882                  !!!parse-error (type => 'after head',              !!!parse-error (type => 'after head',
4883                                  text => $token->{tag_name}, token => $token);                              text => $token->{tag_name}, token => $token);
4884                  push @{$self->{open_elements}},              push @{$self->{open_elements}},
4885                      [$self->{head_element}, $el_category->{head}];                  [$self->{head_element}, $el_category->{head}];
4886                } else {              $self->{head_element_inserted} = 1;
4887                  !!!cp ('t121');            } else {
4888                }              !!!cp ('t121');
4889              }
4890    
4891                ## NOTE: There is a "as if in head" code clone.            ## NOTE: There is a "as if in head" code clone.
4892                $script_start_tag->();            $script_start_tag->();
4893                pop @{$self->{open_elements}} # <head>            pop @{$self->{open_elements}} # <head>
4894                    if $self->{insertion_mode} == AFTER_HEAD_IM;                if $self->{insertion_mode} == AFTER_HEAD_IM;
4895                next B;            next B;
4896              } elsif ($token->{tag_name} eq 'body' or          } elsif ($token->{tag_name} eq 'body' or
4897                       $token->{tag_name} eq 'frameset') {                   $token->{tag_name} eq 'frameset') {
4898                if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {                if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
4899                  !!!cp ('t122');                  !!!cp ('t122');
4900                  ## As if </noscript>                  ## As if </noscript>
# Line 4998  sub _tree_construction_main ($) { Line 5029  sub _tree_construction_main ($) {
5029              } elsif ({              } elsif ({
5030                        body => 1, html => 1,                        body => 1, html => 1,
5031                       }->{$token->{tag_name}}) {                       }->{$token->{tag_name}}) {
5032                if ($self->{insertion_mode} == BEFORE_HEAD_IM or                ## TODO: This branch is entirely redundant.
5033                  if ($self->{insertion_mode} == BEFORE_HEAD_IM or
5034                    $self->{insertion_mode} == IN_HEAD_IM or                    $self->{insertion_mode} == IN_HEAD_IM or
5035                    $self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {                    $self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
5036                  !!!cp ('t140');                  !!!cp ('t140');
# Line 5555  sub _tree_construction_main ($) { Line 5587  sub _tree_construction_main ($) {
5587    
5588          !!!parse-error (type => 'in table:#text', token => $token);          !!!parse-error (type => 'in table:#text', token => $token);
5589    
5590              ## As if in body, but insert into foster parent element          ## NOTE: As if in body, but insert into the foster parent element.
5591              ## ISSUE: Spec says that "whenever a node would be inserted          $reconstruct_active_formatting_elements->($insert_to_foster);
             ## into the current node" while characters might not be  
             ## result in a new Text node.  
             $reconstruct_active_formatting_elements->($insert_to_foster);  
5592                            
5593              if ($self->{open_elements}->[-1]->[1] & TABLE_ROWS_EL) {          if ($self->{open_elements}->[-1]->[1] & TABLE_ROWS_EL) {
5594                # MUST            # MUST
5595                my $foster_parent_element;            my $foster_parent_element;
5596                my $next_sibling;            my $next_sibling;
5597                my $prev_sibling;            my $prev_sibling;
5598                OE: for (reverse 0..$#{$self->{open_elements}}) {            OE: for (reverse 0..$#{$self->{open_elements}}) {
5599                  if ($self->{open_elements}->[$_]->[1] & TABLE_EL) {              if ($self->{open_elements}->[$_]->[1] & TABLE_EL) {
5600                    my $parent = $self->{open_elements}->[$_]->[0]->parent_node;                my $parent = $self->{open_elements}->[$_]->[0]->parent_node;
5601                    if (defined $parent and $parent->node_type == 1) {                if (defined $parent and $parent->node_type == 1) {
5602                      !!!cp ('t196');                  $foster_parent_element = $parent;
5603                      $foster_parent_element = $parent;                  !!!cp ('t196');
5604                      $next_sibling = $self->{open_elements}->[$_]->[0];                  $next_sibling = $self->{open_elements}->[$_]->[0];
5605                      $prev_sibling = $next_sibling->previous_sibling;                  $prev_sibling = $next_sibling->previous_sibling;
5606                    } else {                  #
                     !!!cp ('t197');  
                     $foster_parent_element = $self->{open_elements}->[$_ - 1]->[0];  
                     $prev_sibling = $foster_parent_element->last_child;  
                   }  
                   last OE;  
                 }  
               } # OE  
               $foster_parent_element = $self->{open_elements}->[0]->[0] and  
               $prev_sibling = $foster_parent_element->last_child  
                 unless defined $foster_parent_element;  
               if (defined $prev_sibling and  
                   $prev_sibling->node_type == 3) {  
                 !!!cp ('t198');  
                 $prev_sibling->manakai_append_text ($token->{data});  
5607                } else {                } else {
5608                  !!!cp ('t199');                  !!!cp ('t197');
5609                  $foster_parent_element->insert_before                  $foster_parent_element = $self->{open_elements}->[$_ - 1]->[0];
5610                    ($self->{document}->create_text_node ($token->{data}),                  $prev_sibling = $foster_parent_element->last_child;
5611                     $next_sibling);                  #
5612                }                }
5613                  last OE;
5614                }
5615              } # OE
5616              $foster_parent_element = $self->{open_elements}->[0]->[0] and
5617              $prev_sibling = $foster_parent_element->last_child
5618                  unless defined $foster_parent_element;
5619              undef $prev_sibling unless $open_tables->[-1]->[2]; # ~node inserted
5620              if (defined $prev_sibling and
5621                  $prev_sibling->node_type == 3) {
5622                !!!cp ('t198');
5623                $prev_sibling->manakai_append_text ($token->{data});
5624              } else {
5625                !!!cp ('t199');
5626                $foster_parent_element->insert_before
5627                    ($self->{document}->create_text_node ($token->{data}),
5628                     $next_sibling);
5629              }
5630            $open_tables->[-1]->[1] = 1; # tainted            $open_tables->[-1]->[1] = 1; # tainted
5631              $open_tables->[-1]->[2] = 1; # ~node inserted
5632          } else {          } else {
5633              ## NOTE: Fragment case or in a foster parent'ed element
5634              ## (e.g. |<table><span>a|).  In fragment case, whether the
5635              ## character is appended to existing node or a new node is
5636              ## created is irrelevant, since the foster parent'ed nodes
5637              ## are discarded and fragment parsing does not invoke any
5638              ## script.
5639            !!!cp ('t200');            !!!cp ('t200');
5640            $self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data});            $self->{open_elements}->[-1]->[0]->manakai_append_text
5641                  ($token->{data});
5642          }          }
5643                            
5644          !!!next-token;          !!!next-token;
# Line 5635  sub _tree_construction_main ($) { Line 5675  sub _tree_construction_main ($) {
5675                pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
5676              }              }
5677                                    
5678                  $self->{insertion_mode} = IN_ROW_IM;              $self->{insertion_mode} = IN_ROW_IM;
5679                  if ($token->{tag_name} eq 'tr') {              if ($token->{tag_name} eq 'tr') {
5680                    !!!cp ('t204');                !!!cp ('t204');
5681                    !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);                !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
5682                    !!!nack ('t204');                $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
5683                    !!!next-token;                !!!nack ('t204');
5684                    next B;                !!!next-token;
5685                  } else {                next B;
5686                    !!!cp ('t205');              } else {
5687                    !!!insert-element ('tr',, $token);                !!!cp ('t205');
5688                    ## reprocess in the "in row" insertion mode                !!!insert-element ('tr',, $token);
5689                  }                ## reprocess in the "in row" insertion mode
5690                } else {              }
5691                  !!!cp ('t206');            } else {
5692                }              !!!cp ('t206');
5693              }
5694    
5695                ## Clear back to table row context                ## Clear back to table row context
5696                while (not ($self->{open_elements}->[-1]->[1]                while (not ($self->{open_elements}->[-1]->[1]
# Line 5658  sub _tree_construction_main ($) { Line 5699  sub _tree_construction_main ($) {
5699                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
5700                }                }
5701                                
5702                !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);            !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
5703                $self->{insertion_mode} = IN_CELL_IM;            $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
5704              $self->{insertion_mode} = IN_CELL_IM;
5705    
5706                push @$active_formatting_elements, ['#marker', ''];            push @$active_formatting_elements, ['#marker', ''];
5707                                
5708                !!!nack ('t207.1');            !!!nack ('t207.1');
5709              !!!next-token;
5710              next B;
5711            } elsif ({
5712                      caption => 1, col => 1, colgroup => 1,
5713                      tbody => 1, tfoot => 1, thead => 1,
5714                      tr => 1, # $self->{insertion_mode} == IN_ROW_IM
5715                     }->{$token->{tag_name}}) {
5716              if ($self->{insertion_mode} == IN_ROW_IM) {
5717                ## As if </tr>
5718                ## have an element in table scope
5719                my $i;
5720                INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
5721                  my $node = $self->{open_elements}->[$_];
5722                  if ($node->[1] & TABLE_ROW_EL) {
5723                    !!!cp ('t208');
5724                    $i = $_;
5725                    last INSCOPE;
5726                  } elsif ($node->[1] & TABLE_SCOPING_EL) {
5727                    !!!cp ('t209');
5728                    last INSCOPE;
5729                  }
5730                } # INSCOPE
5731                unless (defined $i) {
5732                  !!!cp ('t210');
5733                  ## TODO: This type is wrong.
5734                  !!!parse-error (type => 'unmacthed end tag',
5735                                  text => $token->{tag_name}, token => $token);
5736                  ## Ignore the token
5737                  !!!nack ('t210.1');
5738                !!!next-token;                !!!next-token;
5739                next B;                next B;
5740              } elsif ({              }
                       caption => 1, col => 1, colgroup => 1,  
                       tbody => 1, tfoot => 1, thead => 1,  
                       tr => 1, # $self->{insertion_mode} == IN_ROW_IM  
                      }->{$token->{tag_name}}) {  
               if ($self->{insertion_mode} == IN_ROW_IM) {  
                 ## As if </tr>  
                 ## have an element in table scope  
                 my $i;  
                 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {  
                   my $node = $self->{open_elements}->[$_];  
                   if ($node->[1] & TABLE_ROW_EL) {  
                     !!!cp ('t208');  
                     $i = $_;  
                     last INSCOPE;  
                   } elsif ($node->[1] & TABLE_SCOPING_EL) {  
                     !!!cp ('t209');  
                     last INSCOPE;  
                   }  
                 } # INSCOPE  
                 unless (defined $i) {  
                   !!!cp ('t210');  
 ## TODO: This type is wrong.  
                   !!!parse-error (type => 'unmacthed end tag',  
                                   text => $token->{tag_name}, token => $token);  
                   ## Ignore the token  
                   !!!nack ('t210.1');  
                   !!!next-token;  
                   next B;  
                 }  
5741                                    
5742                  ## Clear back to table row context                  ## Clear back to table row context
5743                  while (not ($self->{open_elements}->[-1]->[1]                  while (not ($self->{open_elements}->[-1]->[1]
# Line 5765  sub _tree_construction_main ($) { Line 5807  sub _tree_construction_main ($) {
5807                  !!!cp ('t218');                  !!!cp ('t218');
5808                }                }
5809    
5810                if ($token->{tag_name} eq 'col') {            if ($token->{tag_name} eq 'col') {
5811                  ## Clear back to table context              ## Clear back to table context
5812                  while (not ($self->{open_elements}->[-1]->[1]              while (not ($self->{open_elements}->[-1]->[1]
5813                                  & TABLE_SCOPING_EL)) {                              & TABLE_SCOPING_EL)) {
5814                    !!!cp ('t219');                !!!cp ('t219');
5815                    ## ISSUE: Can this state be reached?                ## ISSUE: Can this state be reached?
5816                    pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
5817                  }              }
5818                                
5819                  !!!insert-element ('colgroup',, $token);              !!!insert-element ('colgroup',, $token);
5820                  $self->{insertion_mode} = IN_COLUMN_GROUP_IM;              $self->{insertion_mode} = IN_COLUMN_GROUP_IM;
5821                  ## reprocess              ## reprocess
5822                  !!!ack-later;              $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
5823                  next B;              !!!ack-later;
5824                } elsif ({              next B;
5825                          caption => 1,            } elsif ({
5826                          colgroup => 1,                      caption => 1,
5827                          tbody => 1, tfoot => 1, thead => 1,                      colgroup => 1,
5828                         }->{$token->{tag_name}}) {                      tbody => 1, tfoot => 1, thead => 1,
5829                  ## Clear back to table context                     }->{$token->{tag_name}}) {
5830                ## Clear back to table context
5831                  while (not ($self->{open_elements}->[-1]->[1]                  while (not ($self->{open_elements}->[-1]->[1]
5832                                  & TABLE_SCOPING_EL)) {                                  & TABLE_SCOPING_EL)) {
5833                    !!!cp ('t220');                    !!!cp ('t220');
# Line 5792  sub _tree_construction_main ($) { Line 5835  sub _tree_construction_main ($) {
5835                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
5836                  }                  }
5837                                    
5838                  push @$active_formatting_elements, ['#marker', '']              push @$active_formatting_elements, ['#marker', '']
5839                      if $token->{tag_name} eq 'caption';                  if $token->{tag_name} eq 'caption';
5840                                    
5841                  !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);              !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
5842                  $self->{insertion_mode} = {              $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
5843                                             caption => IN_CAPTION_IM,              $self->{insertion_mode} = {
5844                                             colgroup => IN_COLUMN_GROUP_IM,                                         caption => IN_CAPTION_IM,
5845                                             tbody => IN_TABLE_BODY_IM,                                         colgroup => IN_COLUMN_GROUP_IM,
5846                                             tfoot => IN_TABLE_BODY_IM,                                         tbody => IN_TABLE_BODY_IM,
5847                                             thead => IN_TABLE_BODY_IM,                                         tfoot => IN_TABLE_BODY_IM,
5848                                            }->{$token->{tag_name}};                                         thead => IN_TABLE_BODY_IM,
5849                  !!!next-token;                                        }->{$token->{tag_name}};
5850                  !!!nack ('t220.1');              !!!next-token;
5851                  next B;              !!!nack ('t220.1');
5852                } else {              next B;
5853                  die "$0: in table: <>: $token->{tag_name}";            } else {
5854                }              die "$0: in table: <>: $token->{tag_name}";
5855              }
5856              } elsif ($token->{tag_name} eq 'table') {              } elsif ($token->{tag_name} eq 'table') {
5857                !!!parse-error (type => 'not closed',                !!!parse-error (type => 'not closed',
5858                                text => $self->{open_elements}->[-1]->[0]                                text => $self->{open_elements}->[-1]->[0]
# Line 5871  sub _tree_construction_main ($) { Line 5915  sub _tree_construction_main ($) {
5915              !!!cp ('t227.8');              !!!cp ('t227.8');
5916              ## NOTE: This is a "as if in head" code clone.              ## NOTE: This is a "as if in head" code clone.
5917              $parse_rcdata->(CDATA_CONTENT_MODEL);              $parse_rcdata->(CDATA_CONTENT_MODEL);
5918                $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
5919              next B;              next B;
5920            } else {            } else {
5921              !!!cp ('t227.7');              !!!cp ('t227.7');
# Line 5881  sub _tree_construction_main ($) { Line 5926  sub _tree_construction_main ($) {
5926              !!!cp ('t227.6');              !!!cp ('t227.6');
5927              ## NOTE: This is a "as if in head" code clone.              ## NOTE: This is a "as if in head" code clone.
5928              $script_start_tag->();              $script_start_tag->();
5929                $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
5930              next B;              next B;
5931            } else {            } else {
5932              !!!cp ('t227.5');              !!!cp ('t227.5');
# Line 5896  sub _tree_construction_main ($) { Line 5942  sub _tree_construction_main ($) {
5942                                  text => $token->{tag_name}, token => $token);                                  text => $token->{tag_name}, token => $token);
5943    
5944                  !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);                  !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
5945                    $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
5946    
5947                  ## TODO: form element pointer                  ## TODO: form element pointer
5948    
# Line 7398  sub _tree_construction_main ($) { Line 7445  sub _tree_construction_main ($) {
7445          }          }
7446          !!!next-token;          !!!next-token;
7447          next B;          next B;
7448          } elsif ($token->{tag_name} eq 'optgroup' or
7449                   $token->{tag_name} eq 'option') {
7450            ## has an |option| element in scope
7451            INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
7452              my $node = $self->{open_elements}->[$_];
7453              if ($node->[1] & OPTION_EL) {
7454                !!!cp ('t397.1');
7455                ## NOTE: As if </option>
7456                !!!back-token; # <option> or <optgroup>
7457                $token = {type => END_TAG_TOKEN, tag_name => 'option',
7458                          line => $token->{line}, column => $token->{column}};
7459                next B;
7460              } elsif ($node->[1] & SCOPING_EL) {
7461                !!!cp ('t397.2');
7462                last INSCOPE;
7463              }
7464            } # INSCOPE
7465    
7466            $reconstruct_active_formatting_elements->($insert_to_current);
7467    
7468            !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
7469    
7470            !!!nack ('t397.3');
7471            !!!next-token;
7472            redo B;
7473        } elsif ($token->{tag_name} eq 'rt' or        } elsif ($token->{tag_name} eq 'rt' or
7474                 $token->{tag_name} eq 'rp') {                 $token->{tag_name} eq 'rp') {
7475          ## has a |ruby| element in scope          ## has a |ruby| element in scope
# Line 7445  sub _tree_construction_main ($) { Line 7517  sub _tree_construction_main ($) {
7517                    
7518          if ($self->{self_closing}) {          if ($self->{self_closing}) {
7519            pop @{$self->{open_elements}};            pop @{$self->{open_elements}};
7520            !!!ack ('t398.1');            !!!ack ('t398.6');
7521          } else {          } else {
7522            !!!cp ('t398.2');            !!!cp ('t398.7');
7523            $self->{insertion_mode} |= IN_FOREIGN_CONTENT_IM;            $self->{insertion_mode} |= IN_FOREIGN_CONTENT_IM;
7524            ## NOTE: |<body><math><mi><svg>| -> "in foreign content" insertion            ## NOTE: |<body><math><mi><svg>| -> "in foreign content" insertion
7525            ## mode, "in body" (not "in foreign content") secondary insertion            ## mode, "in body" (not "in foreign content") secondary insertion
# Line 7458  sub _tree_construction_main ($) { Line 7530  sub _tree_construction_main ($) {
7530          next B;          next B;
7531        } elsif ({        } elsif ({
7532                  caption => 1, col => 1, colgroup => 1, frame => 1,                  caption => 1, col => 1, colgroup => 1, frame => 1,
7533                  frameset => 1, head => 1, option => 1, optgroup => 1,                  frameset => 1, head => 1,
7534                  tbody => 1, td => 1, tfoot => 1, th => 1,                  tbody => 1, td => 1, tfoot => 1, th => 1,
7535                  thead => 1, tr => 1,                  thead => 1, tr => 1,
7536                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
# Line 8155  sub set_inner_html ($$$$;$) { Line 8227  sub set_inner_html ($$$$;$) {
8227      push @{$p->{open_elements}}, [$root, $el_category->{html}];      push @{$p->{open_elements}}, [$root, $el_category->{html}];
8228    
8229      undef $p->{head_element};      undef $p->{head_element};
8230        undef $p->{head_element_inserted};
8231    
8232      ## Step 6 # MUST      ## Step 6 # MUST
8233      $p->_reset_insertion_mode;      $p->_reset_insertion_mode;

Legend:
Removed from v.1.200  
changed lines
  Added in v.1.203

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24