/[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.42 by wakaba, Sat Jul 21 06:59:16 2007 UTC revision 1.44 by wakaba, Sat Jul 21 07:34:32 2007 UTC
# Line 3046  sub _tree_construction_main ($) { Line 3046  sub _tree_construction_main ($) {
3046                  noframes => 1,                  noframes => 1,
3047                  noscript => 0, ## TODO: 1 if scripting is enabled                  noscript => 0, ## TODO: 1 if scripting is enabled
3048                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
3049            ## NOTE: There are two "as if in body" code clones.
3050          $parse_rcdata->(CDATA_CONTENT_MODEL, $insert);          $parse_rcdata->(CDATA_CONTENT_MODEL, $insert);
3051          return;          return;
3052        } elsif ($token->{tag_name} eq 'select') {        } elsif ($token->{tag_name} eq 'select') {
# Line 3647  sub _tree_construction_main ($) { Line 3648  sub _tree_construction_main ($) {
3648    
3649            ## ISSUE: An issue in the spec.            ## ISSUE: An issue in the spec.
3650          } elsif ($self->{insertion_mode} eq 'in body' or          } elsif ($self->{insertion_mode} eq 'in body' or
3651                     $self->{insertion_mode} eq 'in cell' or
3652                   $self->{insertion_mode} eq 'in caption') {                   $self->{insertion_mode} eq 'in caption') {
3653            if ($token->{type} eq 'character') {            if ($token->{type} eq 'character') {
3654              ## NOTE: There is a code clone of "character in body".              ## NOTE: There is a code clone of "character in body".
# Line 3660  sub _tree_construction_main ($) { Line 3662  sub _tree_construction_main ($) {
3662              if ({              if ({
3663                   caption => 1, col => 1, colgroup => 1, tbody => 1,                   caption => 1, col => 1, colgroup => 1, tbody => 1,
3664                   td => 1, tfoot => 1, th => 1, thead => 1, tr => 1,                   td => 1, tfoot => 1, th => 1, thead => 1, tr => 1,
3665                  }->{$token->{tag_name}} and                  }->{$token->{tag_name}}) {
3666                  $self->{insertion_mode} eq 'in caption') {                if ($self->{insertion_mode} eq 'in cell') {
3667                !!!parse-error (type => 'not closed:caption');                  ## have an element in table scope
3668                    my $tn;
3669                ## As if </caption>                  INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
3670                ## have a table element in table scope                    my $node = $self->{open_elements}->[$_];
3671                my $i;                    if ($node->[1] eq 'td' or $node->[1] eq 'th') {
3672                INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {                      $tn = $node->[1];
3673                  my $node = $self->{open_elements}->[$_];                      last INSCOPE;
3674                  if ($node->[1] eq 'caption') {                    } elsif ({
3675                    $i = $_;                              table => 1, html => 1,
3676                    last INSCOPE;                             }->{$node->[1]}) {
3677                  } elsif ({                      last INSCOPE;
3678                            table => 1, html => 1,                    }
3679                           }->{$node->[1]}) {                  } # INSCOPE
3680                    last INSCOPE;                    unless (defined $tn) {
3681                  }                      !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
3682                } # INSCOPE                      ## Ignore the token
3683                unless (defined $i) {                      !!!next-token;
3684                  !!!parse-error (type => 'unmatched end tag:caption');                      redo B;
3685                  ## Ignore the token                    }
3686                  !!!next-token;                  
3687                  redo B;                  ## Close the cell
               }  
                 
               ## generate implied end tags  
               if ({  
                    dd => 1, dt => 1, li => 1, p => 1,  
                    td => 1, th => 1, tr => 1,  
                    tbody => 1, tfoot=> 1, thead => 1,  
                   }->{$self->{open_elements}->[-1]->[1]}) {  
3688                  !!!back-token; # <?>                  !!!back-token; # <?>
3689                  $token = {type => 'end tag', tag_name => 'caption'};                  $token = {type => 'end tag', tag_name => $tn};
                 !!!back-token;  
                 $token = {type => 'end tag',  
                           tag_name => $self->{open_elements}->[-1]->[1]}; # MUST  
3690                  redo B;                  redo B;
3691                  } elsif ($self->{insertion_mode} eq 'in caption') {
3692                    !!!parse-error (type => 'not closed:caption');
3693                    
3694                    ## As if </caption>
3695                    ## have a table element in table scope
3696                    my $i;
3697                    INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
3698                      my $node = $self->{open_elements}->[$_];
3699                      if ($node->[1] eq 'caption') {
3700                        $i = $_;
3701                        last INSCOPE;
3702                      } elsif ({
3703                                table => 1, html => 1,
3704                               }->{$node->[1]}) {
3705                        last INSCOPE;
3706                      }
3707                    } # INSCOPE
3708                      unless (defined $i) {
3709                        !!!parse-error (type => 'unmatched end tag:caption');
3710                        ## Ignore the token
3711                        !!!next-token;
3712                        redo B;
3713                      }
3714                    
3715                    ## generate implied end tags
3716                    if ({
3717                         dd => 1, dt => 1, li => 1, p => 1,
3718                         td => 1, th => 1, tr => 1,
3719                         tbody => 1, tfoot=> 1, thead => 1,
3720                        }->{$self->{open_elements}->[-1]->[1]}) {
3721                      !!!back-token; # <?>
3722                      $token = {type => 'end tag', tag_name => 'caption'};
3723                      !!!back-token;
3724                      $token = {type => 'end tag',
3725                                tag_name => $self->{open_elements}->[-1]->[1]}; # MUST
3726                      redo B;
3727                    }
3728    
3729                    if ($self->{open_elements}->[-1]->[1] ne 'caption') {
3730                      !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
3731                    }
3732                    
3733                    splice @{$self->{open_elements}}, $i;
3734                    
3735                    $clear_up_to_marker->();
3736                    
3737                    $self->{insertion_mode} = 'in table';
3738                    
3739                    ## reprocess
3740                    redo B;
3741                  } else {
3742                    #
3743                }                }
   
               if ($self->{open_elements}->[-1]->[1] ne 'caption') {  
                 !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
               }  
   
               splice @{$self->{open_elements}}, $i;  
   
               $clear_up_to_marker->();  
   
               $self->{insertion_mode} = 'in table';  
   
               ## reprocess  
               redo B;  
3744              } else {              } else {
3745                #                #
3746              }              }
3747            } elsif ($token->{type} eq 'end tag') {            } elsif ($token->{type} eq 'end tag') {
3748              if ($token->{tag_name} eq 'caption' and              if ($token->{tag_name} eq 'td' or $token->{tag_name} eq 'th') {
3749                  $self->{insertion_mode} eq 'in caption') {                if ($self->{insertion_mode} eq 'in cell') {
3750                ## have a table element in table scope                  ## have an element in table scope
3751                    my $i;
3752                    INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
3753                      my $node = $self->{open_elements}->[$_];
3754                      if ($node->[1] eq $token->{tag_name}) {
3755                        $i = $_;
3756                        last INSCOPE;
3757                      } elsif ({
3758                                table => 1, html => 1,
3759                               }->{$node->[1]}) {
3760                        last INSCOPE;
3761                      }
3762                    } # INSCOPE
3763                      unless (defined $i) {
3764                        !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
3765                        ## Ignore the token
3766                        !!!next-token;
3767                        redo B;
3768                      }
3769                    
3770                    ## generate implied end tags
3771                    if ({
3772                         dd => 1, dt => 1, li => 1, p => 1,
3773                         td => ($token->{tag_name} eq 'th'),
3774                         th => ($token->{tag_name} eq 'td'),
3775                         tr => 1,
3776                         tbody => 1, tfoot=> 1, thead => 1,
3777                        }->{$self->{open_elements}->[-1]->[1]}) {
3778                      !!!back-token;
3779                      $token = {type => 'end tag',
3780                                tag_name => $self->{open_elements}->[-1]->[1]}; # MUST
3781                      redo B;
3782                    }
3783                    
3784                    if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
3785                      !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
3786                    }
3787                    
3788                    splice @{$self->{open_elements}}, $i;
3789                    
3790                    $clear_up_to_marker->();
3791                    
3792                    $self->{insertion_mode} = 'in row';
3793                    
3794                    !!!next-token;
3795                    redo B;
3796                  } elsif ($self->{insertion_mode} eq 'in caption') {
3797                    !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
3798                    ## Ignore the token
3799                    !!!next-token;
3800                    redo B;
3801                  } else {
3802                    #
3803                  }
3804                } elsif ($token->{tag_name} eq 'caption') {
3805                  if ($self->{insertion_mode} eq 'in caption') {
3806                    ## have a table element in table scope
3807                    my $i;
3808                    INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
3809                      my $node = $self->{open_elements}->[$_];
3810                      if ($node->[1] eq $token->{tag_name}) {
3811                        $i = $_;
3812                        last INSCOPE;
3813                      } elsif ({
3814                                table => 1, html => 1,
3815                               }->{$node->[1]}) {
3816                        last INSCOPE;
3817                      }
3818                    } # INSCOPE
3819                      unless (defined $i) {
3820                        !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
3821                        ## Ignore the token
3822                        !!!next-token;
3823                        redo B;
3824                      }
3825                    
3826                    ## generate implied end tags
3827                    if ({
3828                         dd => 1, dt => 1, li => 1, p => 1,
3829                         td => 1, th => 1, tr => 1,
3830                         tbody => 1, tfoot=> 1, thead => 1,
3831                        }->{$self->{open_elements}->[-1]->[1]}) {
3832                      !!!back-token;
3833                      $token = {type => 'end tag',
3834                                tag_name => $self->{open_elements}->[-1]->[1]}; # MUST
3835                      redo B;
3836                    }
3837                    
3838                    if ($self->{open_elements}->[-1]->[1] ne 'caption') {
3839                      !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
3840                    }
3841                    
3842                    splice @{$self->{open_elements}}, $i;
3843                    
3844                    $clear_up_to_marker->();
3845                    
3846                    $self->{insertion_mode} = 'in table';
3847                    
3848                    !!!next-token;
3849                    redo B;
3850                  } elsif ($self->{insertion_mode} eq 'in cell') {
3851                    !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
3852                    ## Ignore the token
3853                    !!!next-token;
3854                    redo B;
3855                  } else {
3856                    #
3857                  }
3858                } elsif ({
3859                          table => 1, tbody => 1, tfoot => 1,
3860                          thead => 1, tr => 1,
3861                         }->{$token->{tag_name}} and
3862                         $self->{insertion_mode} eq 'in cell') {
3863                  ## have an element in table scope
3864                my $i;                my $i;
3865                  my $tn;
3866                INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {                INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
3867                  my $node = $self->{open_elements}->[$_];                  my $node = $self->{open_elements}->[$_];
3868                  if ($node->[1] eq $token->{tag_name}) {                  if ($node->[1] eq $token->{tag_name}) {
3869                    $i = $_;                    $i = $_;
3870                    last INSCOPE;                    last INSCOPE;
3871                    } elsif ($node->[1] eq 'td' or $node->[1] eq 'th') {
3872                      $tn = $node->[1];
3873                      ## NOTE: There is exactly one |td| or |th| element
3874                      ## in scope in the stack of open elements by definition.
3875                  } elsif ({                  } elsif ({
3876                            table => 1, html => 1,                            table => 1, html => 1,
3877                           }->{$node->[1]}) {                           }->{$node->[1]}) {
# Line 3736  sub _tree_construction_main ($) { Line 3884  sub _tree_construction_main ($) {
3884                  !!!next-token;                  !!!next-token;
3885                  redo B;                  redo B;
3886                }                }
                 
               ## generate implied end tags  
               if ({  
                    dd => 1, dt => 1, li => 1, p => 1,  
                    td => 1, th => 1, tr => 1,  
                    tbody => 1, tfoot=> 1, thead => 1,  
                   }->{$self->{open_elements}->[-1]->[1]}) {  
                 !!!back-token;  
                 $token = {type => 'end tag',  
                           tag_name => $self->{open_elements}->[-1]->[1]}; # MUST  
                 redo B;  
               }  
   
               if ($self->{open_elements}->[-1]->[1] ne 'caption') {  
                 !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
               }  
   
               splice @{$self->{open_elements}}, $i;  
   
               $clear_up_to_marker->();  
   
               $self->{insertion_mode} = 'in table';  
3887    
3888                !!!next-token;                ## Close the cell
3889                  !!!back-token; # </?>
3890                  $token = {type => 'end tag', tag_name => $tn};
3891                redo B;                redo B;
3892              } elsif ($token->{tag_name} eq 'table' and              } elsif ($token->{tag_name} eq 'table' and
3893                       $self->{insertion_mode} eq 'in caption') {                       $self->{insertion_mode} eq 'in caption') {
# Line 3813  sub _tree_construction_main ($) { Line 3941  sub _tree_construction_main ($) {
3941                ## reprocess                ## reprocess
3942                redo B;                redo B;
3943              } elsif ({              } elsif ({
3944                        body => 1, col => 1, colgroup => 1,                        body => 1, col => 1, colgroup => 1, html => 1,
3945                        html => 1, tbody => 1, td => 1, tfoot => 1,                       }->{$token->{tag_name}}) {
3946                        th => 1, thead => 1, tr => 1,                if ($self->{insertion_mode} eq 'in cell' or
3947                      $self->{insertion_mode} eq 'in caption') {
3948                    !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
3949                    ## Ignore the token
3950                    !!!next-token;
3951                    redo B;
3952                  } else {
3953                    #
3954                  }
3955                } elsif ({
3956                          tbody => 1, tfoot => 1,
3957                          thead => 1, tr => 1,
3958                       }->{$token->{tag_name}} and                       }->{$token->{tag_name}} and
3959                       $self->{insertion_mode} eq 'in caption') {                       $self->{insertion_mode} eq 'in caption') {
3960                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
# Line 3828  sub _tree_construction_main ($) { Line 3967  sub _tree_construction_main ($) {
3967            } else {            } else {
3968              #              #
3969            }            }
3970              
3971            $in_body->($insert_to_current);            $in_body->($insert_to_current);
3972            redo B;            redo B;
3973          } elsif ($self->{insertion_mode} eq 'in table') {          } elsif ($self->{insertion_mode} eq 'in table') {
# Line 4692  sub _tree_construction_main ($) { Line 4831  sub _tree_construction_main ($) {
4831            !!!parse-error (type => 'in table:'.$token->{tag_name});            !!!parse-error (type => 'in table:'.$token->{tag_name});
4832            $in_body->($insert_to_foster);            $in_body->($insert_to_foster);
4833            redo B;            redo B;
         } elsif ($self->{insertion_mode} eq 'in cell') {  
           if ($token->{type} eq 'character') {  
             ## NOTE: This is a code clone of "character in body".  
             $reconstruct_active_formatting_elements->($insert_to_current);  
               
             $self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data});  
   
             !!!next-token;  
             redo B;  
           } elsif ($token->{type} eq 'start tag') {  
             if ({  
                  caption => 1, col => 1, colgroup => 1,  
                  tbody => 1, td => 1, tfoot => 1, th => 1,  
                  thead => 1, tr => 1,  
                 }->{$token->{tag_name}}) {  
               ## have an element in table scope  
               my $tn;  
               INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {  
                 my $node = $self->{open_elements}->[$_];  
                 if ($node->[1] eq 'td' or $node->[1] eq 'th') {  
                   $tn = $node->[1];  
                   last INSCOPE;  
                 } elsif ({  
                           table => 1, html => 1,  
                          }->{$node->[1]}) {  
                   last INSCOPE;  
                 }  
               } # INSCOPE  
               unless (defined $tn) {  
                 !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});  
                 ## Ignore the token  
                 !!!next-token;  
                 redo B;  
               }  
   
               ## Close the cell  
               !!!back-token; # <?>  
               $token = {type => 'end tag', tag_name => $tn};  
               redo B;  
             } else {  
               #  
             }  
           } elsif ($token->{type} eq 'end tag') {  
             if ($token->{tag_name} eq 'td' or $token->{tag_name} eq 'th') {  
               ## have an element in table scope  
               my $i;  
               INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {  
                 my $node = $self->{open_elements}->[$_];  
                 if ($node->[1] eq $token->{tag_name}) {  
                   $i = $_;  
                   last INSCOPE;  
                 } elsif ({  
                           table => 1, html => 1,  
                          }->{$node->[1]}) {  
                   last INSCOPE;  
                 }  
               } # INSCOPE  
               unless (defined $i) {  
                 !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});  
                 ## Ignore the token  
                 !!!next-token;  
                 redo B;  
               }  
                 
               ## generate implied end tags  
               if ({  
                    dd => 1, dt => 1, li => 1, p => 1,  
                    td => ($token->{tag_name} eq 'th'),  
                    th => ($token->{tag_name} eq 'td'),  
                    tr => 1,  
                    tbody => 1, tfoot=> 1, thead => 1,  
                   }->{$self->{open_elements}->[-1]->[1]}) {  
                 !!!back-token;  
                 $token = {type => 'end tag',  
                           tag_name => $self->{open_elements}->[-1]->[1]}; # MUST  
                 redo B;  
               }  
   
               if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {  
                 !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
               }  
   
               splice @{$self->{open_elements}}, $i;  
   
               $clear_up_to_marker->();  
   
               $self->{insertion_mode} = 'in row';  
   
               !!!next-token;  
               redo B;  
             } elsif ({  
                       body => 1, caption => 1, col => 1,  
                       colgroup => 1, html => 1,  
                      }->{$token->{tag_name}}) {  
               !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});  
               ## Ignore the token  
               !!!next-token;  
               redo B;  
             } elsif ({  
                       table => 1, tbody => 1, tfoot => 1,  
                       thead => 1, tr => 1,  
                      }->{$token->{tag_name}}) {  
               ## have an element in table scope  
               my $i;  
               my $tn;  
               INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {  
                 my $node = $self->{open_elements}->[$_];  
                 if ($node->[1] eq $token->{tag_name}) {  
                   $i = $_;  
                   last INSCOPE;  
                 } elsif ($node->[1] eq 'td' or $node->[1] eq 'th') {  
                   $tn = $node->[1];  
                   ## NOTE: There is exactly one |td| or |th| element  
                   ## in scope in the stack of open elements by definition.  
                 } elsif ({  
                           table => 1, html => 1,  
                          }->{$node->[1]}) {  
                   last INSCOPE;  
                 }  
               } # INSCOPE  
               unless (defined $i) {  
                 !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});  
                 ## Ignore the token  
                 !!!next-token;  
                 redo B;  
               }  
   
               ## Close the cell  
               !!!back-token; # </?>  
               $token = {type => 'end tag', tag_name => $tn};  
               redo B;  
             } else {  
               #  
             }  
           } else {  
             #  
           }  
             
           $in_body->($insert_to_current);  
           redo B;  
4834          } elsif ($self->{insertion_mode} eq 'in select') {          } elsif ($self->{insertion_mode} eq 'in select') {
4835            if ($token->{type} eq 'character') {            if ($token->{type} eq 'character') {
4836              $self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data});              $self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data});
# Line 5075  sub _tree_construction_main ($) { Line 5074  sub _tree_construction_main ($) {
5074            !!!next-token;            !!!next-token;
5075            redo B;            redo B;
5076          } elsif ($token->{tag_name} eq 'noframes') {          } elsif ($token->{tag_name} eq 'noframes') {
5077            $in_body->($insert_to_current);            ## NOTE: As if in body.
5078              $parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current);
5079            redo B;            redo B;
5080          } else {          } else {
5081            !!!parse-error (type => 'in frameset:'.$token->{tag_name});            !!!parse-error (type => 'in frameset:'.$token->{tag_name});
# Line 5135  sub _tree_construction_main ($) { Line 5135  sub _tree_construction_main ($) {
5135          die qq[$0: Character "$token->{data}"];          die qq[$0: Character "$token->{data}"];
5136        } elsif ($token->{type} eq 'start tag') {        } elsif ($token->{type} eq 'start tag') {
5137          if ($token->{tag_name} eq 'noframes') {          if ($token->{tag_name} eq 'noframes') {
5138            $in_body->($insert_to_current);            ## NOTE: As if in body.
5139              $parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current);
5140            redo B;            redo B;
5141          } else {          } else {
5142            !!!parse-error (type => 'after frameset:'.$token->{tag_name});            !!!parse-error (type => 'after frameset:'.$token->{tag_name});

Legend:
Removed from v.1.42  
changed lines
  Added in v.1.44

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24