/[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.52 by wakaba, Sat Jul 21 12:27:22 2007 UTC revision 1.53 by wakaba, Sat Jul 21 12:37:57 2007 UTC
# Line 4256  sub _tree_construction_main ($) { Line 4256  sub _tree_construction_main ($) {
4256      }      }
4257    
4258      ## "in body" insertion mode      ## "in body" insertion mode
   my $in_body = sub {  
4259      if ($token->{type} eq 'start tag') {      if ($token->{type} eq 'start tag') {
4260        if ($token->{tag_name} eq 'script') {        if ($token->{tag_name} eq 'script') {
4261          ## NOTE: This is an "as if in head" code clone          ## NOTE: This is an "as if in head" code clone
4262          $script_start_tag->($insert);          $script_start_tag->($insert);
4263          return;          redo B;
4264        } elsif ($token->{tag_name} eq 'style') {        } elsif ($token->{tag_name} eq 'style') {
4265          ## NOTE: This is an "as if in head" code clone          ## NOTE: This is an "as if in head" code clone
4266          $parse_rcdata->(CDATA_CONTENT_MODEL, $insert);          $parse_rcdata->(CDATA_CONTENT_MODEL, $insert);
4267          return;          redo B;
4268        } elsif ({        } elsif ({
4269                  base => 1, link => 1,                  base => 1, link => 1,
4270                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
# Line 4273  sub _tree_construction_main ($) { Line 4272  sub _tree_construction_main ($) {
4272          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes});
4273          pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.          pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
4274          !!!next-token;          !!!next-token;
4275          return;          redo B;
4276        } elsif ($token->{tag_name} eq 'meta') {        } elsif ($token->{tag_name} eq 'meta') {
4277          ## NOTE: This is an "as if in head" code clone, only "-t" differs          ## NOTE: This is an "as if in head" code clone, only "-t" differs
4278          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes});
# Line 4297  sub _tree_construction_main ($) { Line 4296  sub _tree_construction_main ($) {
4296          }          }
4297    
4298          !!!next-token;          !!!next-token;
4299          return;          redo B;
4300        } elsif ($token->{tag_name} eq 'title') {        } elsif ($token->{tag_name} eq 'title') {
4301          !!!parse-error (type => 'in body:title');          !!!parse-error (type => 'in body:title');
4302          ## NOTE: This is an "as if in head" code clone          ## NOTE: This is an "as if in head" code clone
# Line 4308  sub _tree_construction_main ($) { Line 4307  sub _tree_construction_main ($) {
4307              $insert->($_[0]);              $insert->($_[0]);
4308            }            }
4309          });          });
4310          return;          redo B;
4311        } elsif ($token->{tag_name} eq 'body') {        } elsif ($token->{tag_name} eq 'body') {
4312          !!!parse-error (type => 'in body:body');          !!!parse-error (type => 'in body:body');
4313                                
# Line 4326  sub _tree_construction_main ($) { Line 4325  sub _tree_construction_main ($) {
4325            }            }
4326          }          }
4327          !!!next-token;          !!!next-token;
4328          return;          redo B;
4329        } elsif ({        } elsif ({
4330                  address => 1, blockquote => 1, center => 1, dir => 1,                  address => 1, blockquote => 1, center => 1, dir => 1,
4331                  div => 1, dl => 1, fieldset => 1, listing => 1,                  div => 1, dl => 1, fieldset => 1, listing => 1,
# Line 4338  sub _tree_construction_main ($) { Line 4337  sub _tree_construction_main ($) {
4337            if ($_->[1] eq 'p') {            if ($_->[1] eq 'p') {
4338              !!!back-token;              !!!back-token;
4339              $token = {type => 'end tag', tag_name => 'p'};              $token = {type => 'end tag', tag_name => 'p'};
4340              return;              redo B;
4341            } elsif ({            } elsif ({
4342                      table => 1, caption => 1, td => 1, th => 1,                      table => 1, caption => 1, td => 1, th => 1,
4343                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
# Line 4359  sub _tree_construction_main ($) { Line 4358  sub _tree_construction_main ($) {
4358          } else {          } else {
4359            !!!next-token;            !!!next-token;
4360          }          }
4361          return;          redo B;
4362        } elsif ($token->{tag_name} eq 'form') {        } elsif ($token->{tag_name} eq 'form') {
4363          if (defined $self->{form_element}) {          if (defined $self->{form_element}) {
4364            !!!parse-error (type => 'in form:form');            !!!parse-error (type => 'in form:form');
4365            ## Ignore the token            ## Ignore the token
4366            !!!next-token;            !!!next-token;
4367            return;            redo B;
4368          } else {          } else {
4369            ## has a p element in scope            ## has a p element in scope
4370            INSCOPE: for (reverse @{$self->{open_elements}}) {            INSCOPE: for (reverse @{$self->{open_elements}}) {
4371              if ($_->[1] eq 'p') {              if ($_->[1] eq 'p') {
4372                !!!back-token;                !!!back-token;
4373                $token = {type => 'end tag', tag_name => 'p'};                $token = {type => 'end tag', tag_name => 'p'};
4374                return;                redo B;
4375              } elsif ({              } elsif ({
4376                        table => 1, caption => 1, td => 1, th => 1,                        table => 1, caption => 1, td => 1, th => 1,
4377                        button => 1, marquee => 1, object => 1, html => 1,                        button => 1, marquee => 1, object => 1, html => 1,
# Line 4384  sub _tree_construction_main ($) { Line 4383  sub _tree_construction_main ($) {
4383            !!!insert-element-t ($token->{tag_name}, $token->{attributes});            !!!insert-element-t ($token->{tag_name}, $token->{attributes});
4384            $self->{form_element} = $self->{open_elements}->[-1]->[0];            $self->{form_element} = $self->{open_elements}->[-1]->[0];
4385            !!!next-token;            !!!next-token;
4386            return;            redo B;
4387          }          }
4388        } elsif ($token->{tag_name} eq 'li') {        } elsif ($token->{tag_name} eq 'li') {
4389          ## has a p element in scope          ## has a p element in scope
# Line 4392  sub _tree_construction_main ($) { Line 4391  sub _tree_construction_main ($) {
4391            if ($_->[1] eq 'p') {            if ($_->[1] eq 'p') {
4392              !!!back-token;              !!!back-token;
4393              $token = {type => 'end tag', tag_name => 'p'};              $token = {type => 'end tag', tag_name => 'p'};
4394              return;              redo B;
4395            } elsif ({            } elsif ({
4396                      table => 1, caption => 1, td => 1, th => 1,                      table => 1, caption => 1, td => 1, th => 1,
4397                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
# Line 4432  sub _tree_construction_main ($) { Line 4431  sub _tree_construction_main ($) {
4431                        
4432          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes});
4433          !!!next-token;          !!!next-token;
4434          return;          redo B;
4435        } elsif ($token->{tag_name} eq 'dd' or $token->{tag_name} eq 'dt') {        } elsif ($token->{tag_name} eq 'dd' or $token->{tag_name} eq 'dt') {
4436          ## has a p element in scope          ## has a p element in scope
4437          INSCOPE: for (reverse @{$self->{open_elements}}) {          INSCOPE: for (reverse @{$self->{open_elements}}) {
4438            if ($_->[1] eq 'p') {            if ($_->[1] eq 'p') {
4439              !!!back-token;              !!!back-token;
4440              $token = {type => 'end tag', tag_name => 'p'};              $token = {type => 'end tag', tag_name => 'p'};
4441              return;              redo B;
4442            } elsif ({            } elsif ({
4443                      table => 1, caption => 1, td => 1, th => 1,                      table => 1, caption => 1, td => 1, th => 1,
4444                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
# Line 4479  sub _tree_construction_main ($) { Line 4478  sub _tree_construction_main ($) {
4478                        
4479          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes});
4480          !!!next-token;          !!!next-token;
4481          return;          redo B;
4482        } elsif ($token->{tag_name} eq 'plaintext') {        } elsif ($token->{tag_name} eq 'plaintext') {
4483          ## has a p element in scope          ## has a p element in scope
4484          INSCOPE: for (reverse @{$self->{open_elements}}) {          INSCOPE: for (reverse @{$self->{open_elements}}) {
4485            if ($_->[1] eq 'p') {            if ($_->[1] eq 'p') {
4486              !!!back-token;              !!!back-token;
4487              $token = {type => 'end tag', tag_name => 'p'};              $token = {type => 'end tag', tag_name => 'p'};
4488              return;              redo B;
4489   &nb