/[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.48 by wakaba, Sat Jul 21 09:54:45 2007 UTC revision 1.50 by wakaba, Sat Jul 21 10:59:40 2007 UTC
# Line 3409  sub _tree_construction_main ($) { Line 3409  sub _tree_construction_main ($) {
3409        }        }
3410        !!!next-token;        !!!next-token;
3411        redo B;        redo B;
3412      } elsif ($self->{insertion_mode} eq 'before head') {      } elsif ($self->{insertion_mode} eq 'in head' or
3413            if ($token->{type} eq 'character') {               $self->{insertion_mode} eq 'in head noscript' or
3414              if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {               $self->{insertion_mode} eq 'after head' or
3415                $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);               $self->{insertion_mode} eq 'before head') {
3416                unless (length $token->{data}) {        if ($token->{type} eq 'character') {
3417                  !!!next-token;          if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {
3418                  redo B;            $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);
3419                }            unless (length $token->{data}) {
3420              }              !!!next-token;
3421              ## As if <head>              redo B;
3422              !!!create-element ($self->{head_element}, 'head');            }
3423              $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});          }
3424              push @{$self->{open_elements}}, [$self->{head_element}, 'head'];  
3425              $self->{insertion_mode} = 'in head';          if ($self->{insertion_mode} eq 'before head') {
3426              ## As if <head>
3427              !!!create-element ($self->{head_element}, 'head');
3428              $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
3429              push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3430    
3431              ## Reprocess in the "in head" insertion mode...
3432              pop @{$self->{open_elements}};
3433    
3434              ## Reprocess in the "after head" insertion mode...
3435            } elsif ($self->{insertion_mode} eq 'in head noscript') {
3436              ## As if </noscript>
3437              pop @{$self->{open_elements}};
3438              !!!parse-error (type => 'in noscript:#character');
3439              
3440              ## Reprocess in the "in head" insertion mode...
3441              ## As if </head>
3442              pop @{$self->{open_elements}};
3443    
3444              ## Reprocess in the "after head" insertion mode...
3445            } elsif ($self->{insertion_mode} eq 'in head') {
3446              pop @{$self->{open_elements}};
3447    
3448              ## Reprocess in the "after head" insertion mode...
3449            }
3450    
3451                ## "after head" insertion mode
3452                ## As if <body>
3453                !!!insert-element ('body');
3454                $self->{insertion_mode} = 'in body';
3455              ## reprocess              ## reprocess
3456              redo B;              redo B;
3457            } elsif ($token->{type} eq 'start tag') {            } elsif ($token->{type} eq 'start tag') {
             my $attr = $token->{tag_name} eq 'head' ? $token->{attributes} : {};  
             !!!create-element ($self->{head_element}, 'head', $attr);  
             $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});  
             push @{$self->{open_elements}}, [$self->{head_element}, 'head'];  
             $self->{insertion_mode} = 'in head';  
3458              if ($token->{tag_name} eq 'head') {              if ($token->{tag_name} eq 'head') {
3459                !!!next-token;                if ($self->{insertion_mode} eq 'before head') {
3460              #} elsif ({                  !!!create-element ($self->{head_element}, $token->{tag_name}, $token->{attributes});
3461              #          base => 1, link => 1, meta => 1,                  $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
3462              #          script => 1, style => 1, title => 1,                  push @{$self->{open_elements}}, [$self->{head_element}, $token->{tag_name}];
3463              #         }->{$token->{tag_name}}) {                  $self->{insertion_mode} = 'in head';
3464              #  ## reprocess                  !!!next-token;
3465              } else {                  redo B;
3466                ## reprocess                } elsif ($self->{insertion_mode} ne 'after head') {
3467              }                  !!!parse-error (type => 'in head:head'); # or in head noscript
3468              redo B;                  ## Ignore the token
3469            } elsif ($token->{type} eq 'end tag') {                  !!!next-token;
3470              if ({                  redo B;
3471                   head => 1, body => 1, html => 1,                } else {
3472                   p => 1, br => 1,                  #
3473                  }->{$token->{tag_name}}) {                }
3474                } elsif ($self->{insertion_mode} eq 'before head') {
3475                ## As if <head>                ## As if <head>
3476                !!!create-element ($self->{head_element}, 'head');                !!!create-element ($self->{head_element}, 'head');
3477                $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});                $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
3478                push @{$self->{open_elements}}, [$self->{head_element}, 'head'];                push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3479    
3480                $self->{insertion_mode} = 'in head';                $self->{insertion_mode} = 'in head';
3481                ## reprocess                ## Reprocess in the "in head" insertion mode...
               redo B;  
             } else {  
               !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});  
               ## Ignore the token ## ISSUE: An issue in the spec.  
               !!!next-token;  
               redo B;  
3482              }              }
3483            } else {  
3484              die "$0: $token->{type}: Unknown type";              if ($token->{tag_name} eq 'base') {
3485            }                if ($self->{insertion_mode} eq 'in head noscript') {
3486          } elsif ($self->{insertion_mode} eq 'in head' or                  ## As if </noscript>
3487                   $self->{insertion_mode} eq 'in head noscript' or                  pop @{$self->{open_elements}};
3488                   $self->{insertion_mode} eq 'after head') {                  !!!parse-error (type => 'in noscript:base');
3489            if ($token->{type} eq 'character') {                
3490              if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {                  $self->{insertion_mode} = 'in head';
3491                $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);                  ## Reprocess in the "in head" insertion mode...
               unless (length $token->{data}) {  
                 !!!next-token;  
                 redo B;  
3492                }                }
3493              }  
3494                              ## NOTE: There is a "as if in head" code clone.
3495              #                if ($self->{insertion_mode} eq 'after head') {
3496            } elsif ($token->{type} eq 'start tag') {                  !!!parse-error (type => 'after head:'.$token->{tag_name});
3497              if ({base => ($self->{insertion_mode} eq 'in head' or                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3498                            $self->{insertion_mode} eq 'after head'),                }
3499                   link => 1}->{$token->{tag_name}}) {                !!!insert-element ($token->{tag_name}, $token->{attributes});
3500                  pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
3501                  pop @{$self->{open_elements}}
3502                      if $self->{insertion_mode} eq 'after head';
3503                  !!!next-token;
3504                  redo B;
3505                } elsif ($token->{tag_name} eq 'link') {
3506                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
3507                if ($self->{insertion_mode} eq 'after head') {                if ($self->{insertion_mode} eq 'after head') {
3508                  !!!parse-error (type => 'after head:'.$token->{tag_name});                  !!!parse-error (type => 'after head:'.$token->{tag_name});
# Line 3522  sub _tree_construction_main ($) { Line 3545  sub _tree_construction_main ($) {
3545                    if $self->{insertion_mode} eq 'after head';                    if $self->{insertion_mode} eq 'after head';
3546                !!!next-token;                !!!next-token;
3547                redo B;                redo B;
3548              } elsif ($token->{tag_name} eq 'title' and              } elsif ($token->{tag_name} eq 'title') {
3549                       $self->{insertion_mode} eq 'in head') {                if ($self->{insertion_mode} eq 'in head noscript') {
3550                ## NOTE: There is a "as if in head" code clone.                  ## As if </noscript>
3551                if ($self->{insertion_mode} eq 'after head') {                  pop @{$self->{open_elements}};
3552                    !!!parse-error (type => 'in noscript:title');
3553                  
3554                    $self->{insertion_mode} = 'in head';
3555                    ## Reprocess in the "in head" insertion mode...
3556                  } elsif ($self->{insertion_mode} eq 'after head') {
3557                  !!!parse-error (type => 'after head:'.$token->{tag_name});                  !!!parse-error (type => 'after head:'.$token->{tag_name});
3558                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3559                }                }
3560    
3561                  ## NOTE: There is a "as if in head" code clone.
3562                my $parent = defined $self->{head_element} ? $self->{head_element}                my $parent = defined $self->{head_element} ? $self->{head_element}
3563                    : $self->{open_elements}->[-1]->[0];                    : $self->{open_elements}->[-1]->[0];
3564                $parse_rcdata->(RCDATA_CONTENT_MODEL,                $parse_rcdata->(RCDATA_CONTENT_MODEL,
# Line 3563  sub _tree_construction_main ($) { Line 3593  sub _tree_construction_main ($) {
3593                } else {                } else {
3594                  #                  #
3595                }                }
3596              } elsif ($token->{tag_name} eq 'head' and              } elsif ($token->{tag_name} eq 'script') {
3597                       $self->{insertion_mode} ne 'after head') {                if ($self->{insertion_mode} eq 'in head noscript') {
3598                !!!parse-error (type => 'in head:head'); # or in head noscript                  ## As if </noscript>
3599                ## Ignore the token                  pop @{$self->{open_elements}};
3600                !!!next-token;                  !!!parse-error (type => 'in noscript:script');
3601                redo B;                
3602              } elsif ($self->{insertion_mode} ne 'in head noscript' and                  $self->{insertion_mode} = 'in head';
3603                       $token->{tag_name} eq 'script') {                  ## Reprocess in the "in head" insertion mode...
3604                if ($self->{insertion_mode} eq 'after head') {                } elsif ($self->{insertion_mode} eq 'after head') {
3605                  !!!parse-error (type => 'after head:'.$token->{tag_name});                  !!!parse-error (type => 'after head:'.$token->{tag_name});
3606                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3607                }                }
3608    
3609                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
3610                $script_start_tag->($insert_to_current);                $script_start_tag->($insert_to_current);
3611                pop @{$self->{open_elements}}                pop @{$self->{open_elements}}
3612                    if $self->{insertion_mode} eq 'after head';                    if $self->{insertion_mode} eq 'after head';
3613                redo B;                redo B;
3614              } elsif ($self->{insertion_mode} eq 'after head' and              } elsif ($token->{tag_name} eq 'body' or
                      $token->{tag_name} eq 'body') {  
               !!!insert-element ('body', $token->{attributes});  
               $self->{insertion_mode} = 'in body';  
               !!!next-token;  
               redo B;  
             } elsif ($self->{insertion_mode} eq 'after head' and  
3615                       $token->{tag_name} eq 'frameset') {                       $token->{tag_name} eq 'frameset') {
3616                !!!insert-element ('frameset', $token->{attributes});                if ($self->{insertion_mode} eq 'in head noscript') {
3617                $self->{insertion_mode} = 'in frameset';                  ## As if </noscript>
3618                    pop @{$self->{open_elements}};
3619                    !!!parse-error (type => 'in noscript:'.$token->{tag_name});
3620                    
3621                    ## Reprocess in the "in head" insertion mode...
3622                    ## As if </head>
3623                    pop @{$self->{open_elements}};
3624                    
3625                    ## Reprocess in the "after head" insertion mode...
3626                  } elsif ($self->{insertion_mode} eq 'in head') {
3627                    pop @{$self->{open_elements}};
3628                    
3629                    ## Reprocess in the "after head" insertion mode...
3630                  }
3631    
3632                  ## "after head" insertion mode
3633                  !!!insert-element ($token->{tag_name}, $token->{attributes});
3634                  $self->{insertion_mode} = 'in '.$token->{tag_name};
3635                !!!next-token;                !!!next-token;
3636                redo B;                redo B;
3637              } else {              } else {
3638                #                #
3639              }              }
3640            } elsif ($token->{type} eq 'end tag') {  
3641              if ($self->{insertion_mode} eq 'in head' and              if ($self->{insertion_mode} eq 'in head noscript') {
3642                  $token->{tag_name} eq 'head') {                ## As if </noscript>
3643                pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
3644                $self->{insertion_mode} = 'after head';                !!!parse-error (type => 'in noscript:/'.$token->{tag_name});
3645                !!!next-token;                
3646                redo B;                ## Reprocess in the "in head" insertion mode...
3647              } elsif ($self->{insertion_mode} eq 'in head noscript' and                ## As if </head>
                 $token->{tag_name} eq 'noscript') {  
3648                pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
3649                $self->{insertion_mode} = 'in head';  
3650                !!!next-token;                ## Reprocess in the "after head" insertion mode...
3651                redo B;              } elsif ($self->{insertion_mode} eq 'in head') {
3652              } elsif ($self->{insertion_mode} eq 'in head' and                ## As if </head>
3653                       {                pop @{$self->{open_elements}};
3654    
3655                  ## Reprocess in the "after head" insertion mode...
3656                }
3657    
3658                ## "after head" insertion mode
3659                ## As if <body>
3660                !!!insert-element ('body');
3661                $self->{insertion_mode} = 'in body';
3662                ## reprocess
3663                redo B;
3664              } elsif ($token->{type} eq 'end tag') {
3665                if ($token->{tag_name} eq 'head') {
3666                  if ($self->{insertion_mode} eq 'before head') {
3667                    ## As if <head>
3668                    !!!create-element ($self->{head_element}, 'head');
3669                    $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
3670                    push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3671    
3672                    ## Reprocess in the "in head" insertion mode...
3673                    pop @{$self->{open_elements}};
3674                    $self->{insertion_mode} = 'after head';
3675                    !!!next-token;
3676                    redo B;
3677                  } elsif ($self->{insertion_mode} eq 'in head noscript') {
3678                    ## As if </noscript>
3679                    pop @{$self->{open_elements}};
3680                    !!!parse-error (type => 'in noscript:script');
3681                    
3682                    ## Reprocess in the "in head" insertion mode...
3683                    pop @{$self->{open_elements}};
3684                    $self->{insertion_mode} = 'after head';
3685                    !!!next-token;
3686                    redo B;
3687                  } elsif ($self->{insertion_mode} eq 'in head') {
3688                    pop @{$self->{open_elements}};
3689                    $self->{insertion_mode} = 'after head';
3690                    !!!next-token;
3691                    redo B;
3692                  } else {
3693                    #
3694                  }
3695                } elsif ($token->{tag_name} eq 'noscript') {
3696                  if ($self->{insertion_mode} eq 'in head noscript') {
3697                    pop @{$self->{open_elements}};
3698                    $self->{insertion_mode} = 'in head';
3699                    !!!next-token;
3700                    redo B;
3701                  } elsif ($self->{insertion_mode} eq 'before head') {
3702                    !!!parse-error (type => 'unmatched end tag:noscript');
3703                    ## Ignore the token ## ISSUE: An issue in the spec.
3704                    !!!next-token;
3705                    redo B;
3706                  } else {
3707                    #
3708                  }
3709                } elsif ({
3710                        body => 1, html => 1,                        body => 1, html => 1,
                       p => 1, br => 1,  
3711                       }->{$token->{tag_name}}) {                       }->{$token->{tag_name}}) {
3712                  if ($self->{insertion_mode} eq 'before head') {
3713                    ## As if <head>
3714                    !!!create-element ($self->{head_element}, 'head');
3715                    $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
3716                    push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3717    
3718                    $self->{insertion_mode} = 'in head';
3719                    ## Reprocess in the "in head" insertion mode...
3720                  } elsif ($self->{insertion_mode} eq 'in head noscript') {
3721                    !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
3722                    ## Ignore the token
3723                    !!!next-token;
3724                    redo B;
3725                  }
3726                  
3727                #                #
3728              } elsif ($self->{insertion_mode} eq 'in head noscript' and              } elsif ({
                      {  
3729                        p => 1, br => 1,                        p => 1, br => 1,
3730                       }->{$token->{tag_name}}) {                       }->{$token->{tag_name}}) {
3731                  if ($self->{insertion_mode} eq 'before head') {
3732                    ## As if <head>
3733                    !!!create-element ($self->{head_element}, 'head');
3734                    $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
3735                    push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3736    
3737                    $self->{insertion_mode} = 'in head';
3738                    ## Reprocess in the "in head" insertion mode...
3739                  }
3740    
3741                #                #
3742              } elsif ($self->{insertion_mode} ne 'after head') {              } else {
3743                  if ($self->{insertion_mode} ne 'after head') {
3744                    !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
3745                    ## Ignore the token
3746                    !!!next-token;
3747                    redo B;
3748                  } else {
3749                    #
3750                  }
3751                }
3752    
3753                if ($self->{insertion_mode} eq 'in head noscript') {
3754                  ## As if </noscript>
3755                  pop @{$self->{open_elements}};
3756                  !!!parse-error (type => 'in noscript:/'.$token->{tag_name});
3757                  
3758                  ## Reprocess in the "in head" insertion mode...
3759                  ## As if </head>
3760                  pop @{$self->{open_elements}};
3761    
3762                  ## Reprocess in the "after head" insertion mode...
3763                } elsif ($self->{insertion_mode} eq 'in head') {
3764                  ## As if </head>
3765                  pop @{$self->{open_elements}};
3766    
3767                  ## Reprocess in the "after head" insertion mode...
3768                } elsif ($self->{insertion_mode} eq 'before head') {
3769                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
3770                ## Ignore the token                ## Ignore the token ## ISSUE: An issue in the spec.
3771                !!!next-token;                !!!next-token;
3772                redo B;                redo B;
             } else {  
               #  
3773              }              }
           } else {  
             #  
           }  
3774    
3775            ## As if </head> or </noscript> or <body>              ## "after head" insertion mode
3776            if ($self->{insertion_mode} eq 'in head') {              ## As if <body>
             pop @{$self->{open_elements}};  
             $self->{insertion_mode} = 'after head';  
           } elsif ($self->{insertion_mode} eq 'in head noscript') {  
             pop @{$self->{open_elements}};  
             !!!parse-error (type => 'in noscript:'.(defined $token->{tag_name} ? ($token->{type} eq 'end tag' ? '/' : '') . $token->{tag_name} : '#' . $token->{type}));  
             $self->{insertion_mode} = 'in head';  
           } else { # 'after head'  
3777              !!!insert-element ('body');              !!!insert-element ('body');
3778              $self->{insertion_mode} = 'in body';              $self->{insertion_mode} = 'in body';
3779                ## reprocess
3780                redo B;
3781              } else {
3782                die "$0: $token->{type}: Unknown token type";
3783            }            }
           ## reprocess  
           redo B;  
3784    
3785            ## ISSUE: An issue in the spec.            ## ISSUE: An issue in the spec.
3786          } elsif ($self->{insertion_mode} eq 'in body' or      } elsif ($self->{insertion_mode} eq 'in body' or
3787                   $self->{insertion_mode} eq 'in cell' or               $self->{insertion_mode} eq 'in cell' or
3788                   $self->{insertion_mode} eq 'in caption') {               $self->{insertion_mode} eq 'in caption') {
3789            if ($token->{type} eq 'character') {            if ($token->{type} eq 'character') {
3790              ## NOTE: There is a code clone of "character in body".              ## NOTE: There is a code clone of "character in body".
3791              $reconstruct_active_formatting_elements->($insert_to_current);              $reconstruct_active_formatting_elements->($insert_to_current);

Legend:
Removed from v.1.48  
changed lines
  Added in v.1.50

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24