/[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.30 by wakaba, Sat Jun 30 13:12:32 2007 UTC revision 1.31 by wakaba, Sat Jun 30 14:13:19 2007 UTC
# Line 7  our $VERSION=do{my @r=(q$Revision$=~/\d+ Line 7  our $VERSION=do{my @r=(q$Revision$=~/\d+
7  ## doc.write ('');  ## doc.write ('');
8  ## alert (doc.compatMode);  ## alert (doc.compatMode);
9    
10    ## ISSUE: HTML5 revision 967 says that the encoding layer MUST NOT
11    ## strip BOM and the HTML layer MUST ignore it.  Whether we can do it
12    ## is not yet clear.
13    ## "{U+FEFF}..." in UTF-16BE/UTF-16LE is three or four characters?
14    ## "{U+FEFF}..." in GB18030?
15    
16  my $permitted_slash_tag_name = {  my $permitted_slash_tag_name = {
17    base => 1,    base => 1,
18    link => 1,    link => 1,
# Line 2502  sub _tree_construction_main ($) { Line 2508  sub _tree_construction_main ($) {
2508        } elsif ($token->{tag_name} eq 'title') {        } elsif ($token->{tag_name} eq 'title') {
2509          !!!parse-error (type => 'in body:title');          !!!parse-error (type => 'in body:title');
2510          ## NOTE: This is an "as if in head" code clone          ## NOTE: This is an "as if in head" code clone
2511          $parse_rcdata->('RCDATA', $insert);          $parse_rcdata->('RCDATA', sub {
2512              if (defined $self->{head_element}) {
2513                $self->{head_element}->append_child ($_[0]);
2514              } else {
2515                $insert->($_[0]);
2516              }
2517            });
2518          return;          return;
2519        } elsif ($token->{tag_name} eq 'body') {        } elsif ($token->{tag_name} eq 'body') {
2520          !!!parse-error (type => 'in body:body');          !!!parse-error (type => 'in body:body');
# Line 2795  sub _tree_construction_main ($) { Line 2807  sub _tree_construction_main ($) {
2807          INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {          INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
2808            my $node = $self->{open_elements}->[$_];            my $node = $self->{open_elements}->[$_];
2809            if ($node->[1] eq 'nobr') {            if ($node->[1] eq 'nobr') {
2810                !!!parse-error (type => 'not closed:nobr');
2811              !!!back-token;              !!!back-token;
2812              $token = {type => 'end tag', tag_name => 'nobr'};              $token = {type => 'end tag', tag_name => 'nobr'};
2813              return;              return;
# Line 2878  sub _tree_construction_main ($) { Line 2891  sub _tree_construction_main ($) {
2891            !!!parse-error (type => 'image');            !!!parse-error (type => 'image');
2892            $token->{tag_name} = 'img';            $token->{tag_name} = 'img';
2893          }          }
2894            
2895            ## NOTE: There is an "as if <br>" code clone.
2896          $reconstruct_active_formatting_elements->($insert_to_current);          $reconstruct_active_formatting_elements->($insert_to_current);
2897                    
2898          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes});
# Line 3036  sub _tree_construction_main ($) { Line 3050  sub _tree_construction_main ($) {
3050              unless ({              unless ({
3051                         dd => 1, dt => 1, li => 1, p => 1, td => 1,                         dd => 1, dt => 1, li => 1, p => 1, td => 1,
3052                         th => 1, tr => 1, body => 1, html => 1,                         th => 1, tr => 1, body => 1, html => 1,
3053                         tbody => 1, tfoot => 1, thead => 1,
3054                      }->{$_->[1]}) {                      }->{$_->[1]}) {
3055                !!!parse-error (type => 'not closed:'.$_->[1]);                !!!parse-error (type => 'not closed:'.$_->[1]);
3056              }              }
# Line 3085  sub _tree_construction_main ($) { Line 3100  sub _tree_construction_main ($) {
3100                   li => ($token->{tag_name} ne 'li'),                   li => ($token->{tag_name} ne 'li'),
3101                   p => ($token->{tag_name} ne 'p'),                   p => ($token->{tag_name} ne 'p'),
3102                   td => 1, th => 1, tr => 1,                   td => 1, th => 1, tr => 1,
3103                     tbody => 1, tfoot=> 1, thead => 1,
3104                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
3105                !!!back-token;                !!!back-token;
3106                $token = {type => 'end tag',                $token = {type => 'end tag',
# Line 3105  sub _tree_construction_main ($) { Line 3121  sub _tree_construction_main ($) {
3121            !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);            !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
3122          }          }
3123                    
3124          splice @{$self->{open_elements}}, $i if defined $i;          if (defined $i) {
3125              splice @{$self->{open_elements}}, $i;
3126            } elsif ($token->{tag_name} eq 'p') {
3127              ## As if <p>, then reprocess the current token
3128              my $el;
3129              !!!create-element ($el, 'p');
3130              $insert->($el);
3131            }
3132          $clear_up_to_marker->()          $clear_up_to_marker->()
3133            if {            if {
3134              button => 1, marquee => 1, object => 1,              button => 1, marquee => 1, object => 1,
# Line 3121  sub _tree_construction_main ($) { Line 3144  sub _tree_construction_main ($) {
3144              if ({              if ({
3145                   dd => 1, dt => 1, li => 1, p => 1,                   dd => 1, dt => 1, li => 1, p => 1,
3146                   td => 1, th => 1, tr => 1,                   td => 1, th => 1, tr => 1,
3147                     tbody => 1, tfoot=> 1, thead => 1,
3148                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
3149                !!!back-token;                !!!back-token;
3150                $token = {type => 'end tag',                $token = {type => 'end tag',
# Line 3159  sub _tree_construction_main ($) { Line 3183  sub _tree_construction_main ($) {
3183              if ({              if ({
3184                   dd => 1, dt => 1, li => 1, p => 1,                   dd => 1, dt => 1, li => 1, p => 1,
3185                   td => 1, th => 1, tr => 1,                   td => 1, th => 1, tr => 1,
3186                     tbody => 1, tfoot=> 1, thead => 1,
3187                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
3188                !!!back-token;                !!!back-token;
3189                $token = {type => 'end tag',                $token = {type => 'end tag',
# Line 3189  sub _tree_construction_main ($) { Line 3214  sub _tree_construction_main ($) {
3214                  strong => 1, tt => 1, u => 1,                  strong => 1, tt => 1, u => 1,
3215                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
3216          $formatting_end_tag->($token->{tag_name});          $formatting_end_tag->($token->{tag_name});
3217  ## TODO: <http://html5.org/tools/web-apps-tracker?from=883&to=884>          return;
3218          } elsif ($token->{tag_name} eq 'br') {
3219            !!!parse-error (type => 'unmatched end tag:br');
3220    
3221            ## As if <br>
3222            $reconstruct_active_formatting_elements->($insert_to_current);
3223            
3224            my $el;
3225            !!!create-element ($el, 'br');
3226            $insert->($el);
3227            
3228            ## Ignore the token.
3229            !!!next-token;
3230          return;          return;
3231        } elsif ({        } elsif ({
3232                  caption => 1, col => 1, colgroup => 1, frame => 1,                  caption => 1, col => 1, colgroup => 1, frame => 1,
3233                  frameset => 1, head => 1, option => 1, optgroup => 1,                  frameset => 1, head => 1, option => 1, optgroup => 1,
3234                  tbody => 1, td => 1, tfoot => 1, th => 1,                  tbody => 1, td => 1, tfoot => 1, th => 1,
3235                  thead => 1, tr => 1,                  thead => 1, tr => 1,
3236                  area => 1, basefont => 1, bgsound => 1, br => 1,                  area => 1, basefont => 1, bgsound => 1,
3237                  embed => 1, hr => 1, iframe => 1, image => 1,                  embed => 1, hr => 1, iframe => 1, image => 1,
3238                  img => 1, input => 1, isindex => 1, noembed => 1,                  img => 1, input => 1, isindex => 1, noembed => 1,
3239                  noframes => 1, param => 1, select => 1, spacer => 1,                  noframes => 1, param => 1, select => 1, spacer => 1,
# Line 3223  sub _tree_construction_main ($) { Line 3260  sub _tree_construction_main ($) {
3260              if ({              if ({
3261                   dd => 1, dt => 1, li => 1, p => 1,                   dd => 1, dt => 1, li => 1, p => 1,
3262                   td => 1, th => 1, tr => 1,                   td => 1, th => 1, tr => 1,
3263                     tbody => 1, tfoot=> 1, thead => 1,
3264                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
3265                !!!back-token;                !!!back-token;
3266                $token = {type => 'end tag',                $token = {type => 'end tag',
# Line 3294  sub _tree_construction_main ($) { Line 3332  sub _tree_construction_main ($) {
3332          ## Generate implied end tags          ## Generate implied end tags
3333          if ({          if ({
3334               dd => 1, dt => 1, li => 1, p => 1, td => 1, th => 1, tr => 1,               dd => 1, dt => 1, li => 1, p => 1, td => 1, th => 1, tr => 1,
3335                 tbody => 1, tfoot=> 1, thead => 1,
3336              }->{$self->{open_elements}->[-1]->[1]}) {              }->{$self->{open_elements}->[-1]->[1]}) {
3337            !!!back-token;            !!!back-token;
3338            $token = {type => 'end tag', tag_name => $self->{open_elements}->[-1]->[1]};            $token = {type => 'end tag', tag_name => $self->{open_elements}->[-1]->[1]};
# Line 3353  sub _tree_construction_main ($) { Line 3392  sub _tree_construction_main ($) {
3392              }              }
3393              redo B;              redo B;
3394            } elsif ($token->{type} eq 'end tag') {            } elsif ($token->{type} eq 'end tag') {
3395              if ({head => 1, body => 1, html => 1}->{$token->{tag_name}}) {              if ({
3396                     head => 1, body => 1, html => 1,
3397                     p => 1, br => 1,
3398                    }->{$token->{tag_name}}) {
3399                ## As if <head>                ## As if <head>
3400                !!!create-element ($self->{head_element}, 'head');                !!!create-element ($self->{head_element}, 'head');
3401                $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});                $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
# Line 3411  sub _tree_construction_main ($) { Line 3453  sub _tree_construction_main ($) {
3453                  !!!parse-error (type => 'after head:'.$token->{tag_name});                  !!!parse-error (type => 'after head:'.$token->{tag_name});
3454                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];                  push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3455                }                }
3456                $parse_rcdata->('RCDATA', $insert_to_current);                my $parent = defined $self->{head_element} ? $self->{head_element}
3457                      : $self->{open_elements}->[-1]->[0];
3458                  $parse_rcdata->('RCDATA', sub { $parent->append_child ($_[0]) });
3459                pop @{$self->{open_elements}}                pop @{$self->{open_elements}}
3460                    if $self->{insertion_mode} eq 'after head';                    if $self->{insertion_mode} eq 'after head';
3461                redo B;                redo B;
# Line 3487  sub _tree_construction_main ($) { Line 3531  sub _tree_construction_main ($) {
3531                !!!next-token;                !!!next-token;
3532                redo B;                redo B;
3533              } elsif ($self->{insertion_mode} eq 'in head' and              } elsif ($self->{insertion_mode} eq 'in head' and
3534                       ($token->{tag_name} eq 'body' or                       {
3535                        $token->{tag_name} eq 'html')) {                        body => 1, html => 1,
3536                          p => 1, br => 1,
3537                         }->{$token->{tag_name}}) {
3538                  #
3539                } elsif ($self->{insertion_mode} eq 'in head noscript' and
3540                         {
3541                          p => 1, br => 1,
3542                         }->{$token->{tag_name}}) {
3543                #                #
3544              } elsif ($self->{insertion_mode} ne 'after head') {              } elsif ($self->{insertion_mode} ne 'after head') {
3545                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
# Line 3672  sub _tree_construction_main ($) { Line 3723  sub _tree_construction_main ($) {
3723                if ({                if ({
3724                     dd => 1, dt => 1, li => 1, p => 1,                     dd => 1, dt => 1, li => 1, p => 1,
3725                     td => 1, th => 1, tr => 1,                     td => 1, th => 1, tr => 1,
3726                       tbody => 1, tfoot=> 1, thead => 1,
3727                    }->{$self->{open_elements}->[-1]->[1]}) {                    }->{$self->{open_elements}->[-1]->[1]}) {
3728                  !!!back-token; # <table>                  !!!back-token; # <table>
3729                  $token = {type => 'end tag', tag_name => 'table'};                  $token = {type => 'end tag', tag_name => 'table'};
# Line 3720  sub _tree_construction_main ($) { Line 3772  sub _tree_construction_main ($) {
3772                if ({                if ({
3773                     dd => 1, dt => 1, li => 1, p => 1,                     dd => 1, dt => 1, li => 1, p => 1,
3774                     td => 1, th => 1, tr => 1,                     td => 1, th => 1, tr => 1,
3775                       tbody => 1, tfoot=> 1, thead => 1,
3776                    }->{$self->{open_elements}->[-1]->[1]}) {                    }->{$self->{open_elements}->[-1]->[1]}) {
3777                  !!!back-token;                  !!!back-token;
3778                  $token = {type => 'end tag',                  $token = {type => 'end tag',
# Line 3803  sub _tree_construction_main ($) { Line 3856  sub _tree_construction_main ($) {
3856                if ({                if ({
3857                     dd => 1, dt => 1, li => 1, p => 1,                     dd => 1, dt => 1, li => 1, p => 1,
3858                     td => 1, th => 1, tr => 1,                     td => 1, th => 1, tr => 1,
3859                       tbody => 1, tfoot=> 1, thead => 1,
3860                    }->{$self->{open_elements}->[-1]->[1]}) {                    }->{$self->{open_elements}->[-1]->[1]}) {
3861                  !!!back-token; # <?>                  !!!back-token; # <?>
3862                  $token = {type => 'end tag', tag_name => 'caption'};                  $token = {type => 'end tag', tag_name => 'caption'};
# Line 3853  sub _tree_construction_main ($) { Line 3907  sub _tree_construction_main ($) {
3907                if ({                if ({
3908                     dd => 1, dt => 1, li => 1, p => 1,                     dd => 1, dt => 1, li => 1, p => 1,
3909                     td => 1, th => 1, tr => 1,                     td => 1, th => 1, tr => 1,
3910                       tbody => 1, tfoot=> 1, thead => 1,
3911                    }->{$self->{open_elements}->[-1]->[1]}) {                    }->{$self->{open_elements}->[-1]->[1]}) {
3912                  !!!back-token;                  !!!back-token;
3913                  $token = {type => 'end tag',                  $token = {type => 'end tag',
# Line 3900  sub _tree_construction_main ($) { Line 3955  sub _tree_construction_main ($) {
3955                if ({                if ({
3956                     dd => 1, dt => 1, li => 1, p => 1,                     dd => 1, dt => 1, li => 1, p => 1,
3957                     td => 1, th => 1, tr => 1,                     td => 1, th => 1, tr => 1,
3958                       tbody => 1, tfoot=> 1, thead => 1,
3959                    }->{$self->{open_elements}->[-1]->[1]}) {                    }->{$self->{open_elements}->[-1]->[1]}) {
3960                  !!!back-token; # </table>                  !!!back-token; # </table>
3961                  $token = {type => 'end tag', tag_name => 'caption'};                  $token = {type => 'end tag', tag_name => 'caption'};
# Line 4165  sub _tree_construction_main ($) { Line 4221  sub _tree_construction_main ($) {
4221                if ({                if ({
4222                     dd => 1, dt => 1, li => 1, p => 1,                     dd => 1, dt => 1, li => 1, p => 1,
4223                     td => 1, th => 1, tr => 1,                     td => 1, th => 1, tr => 1,
4224                       tbody => 1, tfoot=> 1, thead => 1,
4225                    }->{$self->{open_elements}->[-1]->[1]}) {                    }->{$self->{open_elements}->[-1]->[1]}) {
4226                  !!!back-token; # <table>                  !!!back-token; # <table>
4227                  $token = {type => 'end tag', tag_name => 'table'};                  $token = {type => 'end tag', tag_name => 'table'};
# Line 4433  sub _tree_construction_main ($) { Line 4490  sub _tree_construction_main ($) {
4490                if ({                if ({
4491                     dd => 1, dt => 1, li => 1, p => 1,                     dd => 1, dt => 1, li => 1, p => 1,
4492                     td => 1, th => 1, tr => 1,                     td => 1, th => 1, tr => 1,
4493                       tbody => 1, tfoot=> 1, thead => 1,
4494                    }->{$self->{open_elements}->[-1]->[1]}) {                    }->{$self->{open_elements}->[-1]->[1]}) {
4495                  !!!back-token; # <table>                  !!!back-token; # <table>
4496                  $token = {type => 'end tag', tag_name => 'table'};                  $token = {type => 'end tag', tag_name => 'table'};
# Line 4674  sub _tree_construction_main ($) { Line 4732  sub _tree_construction_main ($) {
4732                     td => ($token->{tag_name} eq 'th'),                     td => ($token->{tag_name} eq 'th'),
4733                     th => ($token->{tag_name} eq 'td'),                     th => ($token->{tag_name} eq 'td'),
4734                     tr => 1,                     tr => 1,
4735                       tbody => 1, tfoot=> 1, thead => 1,
4736                    }->{$self->{open_elements}->[-1]->[1]}) {                    }->{$self->{open_elements}->[-1]->[1]}) {
4737                  !!!back-token;                  !!!back-token;
4738                  $token = {type => 'end tag',                  $token = {type => 'end tag',

Legend:
Removed from v.1.30  
changed lines
  Added in v.1.31

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24