/[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.86 by wakaba, Thu Mar 6 15:56:52 2008 UTC revision 1.98 by wakaba, Sun Mar 9 03:23:43 2008 UTC
# Line 2743  sub _reset_insertion_mode ($) { Line 2743  sub _reset_insertion_mode ($) {
2743            
2744      ## Step 3      ## Step 3
2745      S3: {      S3: {
       ## ISSUE: Oops! "If node is the first node in the stack of open  
       ## elements, then set last to true. If the context element of the  
       ## HTML fragment parsing algorithm is neither a td element nor a  
       ## th element, then set node to the context element. (fragment case)":  
       ## The second "if" is in the scope of the first "if"!?  
2746        if ($self->{open_elements}->[0]->[0] eq $node->[0]) {        if ($self->{open_elements}->[0]->[0] eq $node->[0]) {
2747          $last = 1;          $last = 1;
2748          if (defined $self->{inner_html_node}) {          if (defined $self->{inner_html_node}) {
# Line 2908  sub _tree_construction_main ($) { Line 2903  sub _tree_construction_main ($) {
2903      !!!cp ('t39');      !!!cp ('t39');
2904    }; # $clear_up_to_marker    }; # $clear_up_to_marker
2905    
2906    my $parse_rcdata = sub ($$) {    my $insert;
2907      my ($content_model_flag, $insert) = @_;  
2908      my $parse_rcdata = sub ($) {
2909        my ($content_model_flag) = @_;
2910    
2911      ## Step 1      ## Step 1
2912      my $start_tag_name = $token->{tag_name};      my $start_tag_name = $token->{tag_name};
# Line 2917  sub _tree_construction_main ($) { Line 2914  sub _tree_construction_main ($) {
2914      !!!create-element ($el, $start_tag_name, $token->{attributes});      !!!create-element ($el, $start_tag_name, $token->{attributes});
2915    
2916      ## Step 2      ## Step 2
2917      $insert->($el); # /context node/->append_child ($el)      $insert->($el);
2918    
2919      ## Step 3      ## Step 3
2920      $self->{content_model} = $content_model_flag; # CDATA or RCDATA      $self->{content_model} = $content_model_flag; # CDATA or RCDATA
# Line 2947  sub _tree_construction_main ($) { Line 2944  sub _tree_construction_main ($) {
2944          $token->{tag_name} eq $start_tag_name) {          $token->{tag_name} eq $start_tag_name) {
2945        !!!cp ('t42');        !!!cp ('t42');
2946        ## Ignore the token        ## Ignore the token
     } elsif ($content_model_flag == CDATA_CONTENT_MODEL) {  
       !!!cp ('t43');  
       !!!parse-error (type => 'in CDATA:#'.$token->{type});  
     } elsif ($content_model_flag == RCDATA_CONTENT_MODEL) {  
       !!!cp ('t44');  
       !!!parse-error (type => 'in RCDATA:#'.$token->{type});  
2947      } else {      } else {
2948        die "$0: $content_model_flag in parse_rcdata";        ## NOTE: An end-of-file token.
2949          if ($content_model_flag == CDATA_CONTENT_MODEL) {
2950            !!!cp ('t43');
2951            !!!parse-error (type => 'in CDATA:#'.$token->{type});
2952          } elsif ($content_model_flag == RCDATA_CONTENT_MODEL) {
2953            !!!cp ('t44');
2954            !!!parse-error (type => 'in RCDATA:#'.$token->{type});
2955          } else {
2956            die "$0: $content_model_flag in parse_rcdata";
2957          }
2958      }      }
2959      !!!next-token;      !!!next-token;
2960    }; # $parse_rcdata    }; # $parse_rcdata
2961    
2962    my $script_start_tag = sub ($) {    my $script_start_tag = sub () {
     my $insert = $_[0];  
2963      my $script_el;      my $script_el;
2964      !!!create-element ($script_el, 'script', $token->{attributes});      !!!create-element ($script_el, 'script', $token->{attributes});
2965      ## TODO: mark as "parser-inserted"      ## TODO: mark as "parser-inserted"
# Line 3213  sub _tree_construction_main ($) { Line 3212  sub _tree_construction_main ($) {
3212      } # FET      } # FET
3213    }; # $formatting_end_tag    }; # $formatting_end_tag
3214    
3215    my $insert_to_current = sub {    ## NOTE: $open_tables->[-1]->[0] is the "current table".
3216      ## NOTE: $open_tables->[-1]->[1] is the "tainted" flag.
3217      my $open_tables = [[$self->{open_elements}->[0]->[0]]];
3218    
3219      $insert = my $insert_to_current = sub {
3220      $self->{open_elements}->[-1]->[0]->append_child ($_[0]);      $self->{open_elements}->[-1]->[0]->append_child ($_[0]);
3221    }; # $insert_to_current    }; # $insert_to_current
3222    
3223    my $insert_to_foster = sub {    my $insert_to_foster = sub {
3224                         my $child = shift;      my $child = shift;
3225                         if ({      if ({
3226                              table => 1, tbody => 1, tfoot => 1,           table => 1, tbody => 1, tfoot => 1, thead => 1, tr => 1,
3227                              thead => 1, tr => 1,          }->{$self->{open_elements}->[-1]->[1]}) {
3228                             }->{$self->{open_elements}->[-1]->[1]}) {        # MUST
3229                           # MUST        my $foster_parent_element;
3230                           my $foster_parent_element;        my $next_sibling;
                          my $next_sibling;  
3231                           OE: for (reverse 0..$#{$self->{open_elements}}) {                           OE: for (reverse 0..$#{$self->{open_elements}}) {
3232                             if ($self->{open_elements}->[$_]->[1] eq 'table') {                             if ($self->{open_elements}->[$_]->[1] eq 'table') {
3233                               my $parent = $self->{open_elements}->[$_]->[0]->parent_node;                               my $parent = $self->{open_elements}->[$_]->[0]->parent_node;
# Line 3245  sub _tree_construction_main ($) { Line 3247  sub _tree_construction_main ($) {
3247                             unless defined $foster_parent_element;                             unless defined $foster_parent_element;
3248                           $foster_parent_element->insert_before                           $foster_parent_element->insert_before
3249                             ($child, $next_sibling);                             ($child, $next_sibling);
3250                         } else {        $open_tables->[-1]->[1] = 1; # tainted
3251                           !!!cp ('t72');      } else {
3252                           $self->{open_elements}->[-1]->[0]->append_child ($child);        !!!cp ('t72');
3253                         }        $self->{open_elements}->[-1]->[0]->append_child ($child);
3254        }
3255    }; # $insert_to_foster    }; # $insert_to_foster
3256    
   my $insert;  
   
3257    B: {    B: {
3258      if ($token->{type} == DOCTYPE_TOKEN) {      if ($token->{type} == DOCTYPE_TOKEN) {
3259        !!!cp ('t73');        !!!cp ('t73');
# Line 3538  sub _tree_construction_main ($) { Line 3539  sub _tree_construction_main ($) {
3539                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
3540                my $parent = defined $self->{head_element} ? $self->{head_element}                my $parent = defined $self->{head_element} ? $self->{head_element}
3541                    : $self->{open_elements}->[-1]->[0];                    : $self->{open_elements}->[-1]->[0];
3542                $parse_rcdata->(RCDATA_CONTENT_MODEL,                $parse_rcdata->(RCDATA_CONTENT_MODEL);
                               sub { $parent->append_child ($_[0]) });  
3543                pop @{$self->{open_elements}}                pop @{$self->{open_elements}}
3544                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
3545                redo B;                redo B;
# Line 3554  sub _tree_construction_main ($) { Line 3554  sub _tree_construction_main ($) {
3554                } else {                } else {
3555                  !!!cp ('t115');                  !!!cp ('t115');
3556                }                }
3557                $parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current);                $parse_rcdata->(CDATA_CONTENT_MODEL);
3558                pop @{$self->{open_elements}}                pop @{$self->{open_elements}}
3559                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
3560                redo B;                redo B;
# Line 4156  sub _tree_construction_main ($) { Line 4156  sub _tree_construction_main ($) {
4156        #        #
4157      } elsif ($self->{insertion_mode} & TABLE_IMS) {      } elsif ($self->{insertion_mode} & TABLE_IMS) {
4158        if ($token->{type} == CHARACTER_TOKEN) {        if ($token->{type} == CHARACTER_TOKEN) {
4159              if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {          if (not $open_tables->[-1]->[1] and # tainted
4160                $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);              $token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {
4161              $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);
4162                                
4163                unless (length $token->{data}) {            unless (length $token->{data}) {
4164                  !!!cp ('t194');              !!!cp ('t194');
4165                  !!!next-token;              !!!next-token;
4166                  redo B;              redo B;
4167                } else {            } else {
4168                  !!!cp ('t195');              !!!cp ('t195');
4169                }            }
4170              }          }
4171    
4172              !!!parse-error (type => 'in table:#character');              !!!parse-error (type => 'in table:#character');
4173    
# Line 4213  sub _tree_construction_main ($) { Line 4214  sub _tree_construction_main ($) {
4214                    ($self->{document}->create_text_node ($token->{data}),                    ($self->{document}->create_text_node ($token->{data}),
4215                     $next_sibling);                     $next_sibling);
4216                }                }
4217              } else {            $open_tables->[-1]->[1] = 1; # tainted
4218                !!!cp ('t200');          } else {
4219                $self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data});            !!!cp ('t200');
4220              }            $self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data});
4221            }
4222                            
4223              !!!next-token;          !!!next-token;
4224              redo B;          redo B;
4225        } elsif ($token->{type} == START_TAG_TOKEN) {        } elsif ($token->{type} == START_TAG_TOKEN) {
4226              if ({              if ({
4227                   tr => ($self->{insertion_mode} != IN_ROW_IM),                   tr => ($self->{insertion_mode} != IN_ROW_IM),
# Line 4230  sub _tree_construction_main ($) { Line 4232  sub _tree_construction_main ($) {
4232                  while ($self->{open_elements}->[-1]->[1] ne 'table' and                  while ($self->{open_elements}->[-1]->[1] ne 'table' and
4233                         $self->{open_elements}->[-1]->[1] ne 'html') {                         $self->{open_elements}->[-1]->[1] ne 'html') {
4234                    !!!cp ('t201');                    !!!cp ('t201');
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4235                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4236                  }                  }
4237                                    
# Line 4251  sub _tree_construction_main ($) { Line 4252  sub _tree_construction_main ($) {
4252                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4253                    !!!cp ('t203');                    !!!cp ('t203');
4254                    ## ISSUE: Can this case be reached?                    ## ISSUE: Can this case be reached?
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4255                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4256                  }                  }
4257                                    
# Line 4275  sub _tree_construction_main ($) { Line 4275  sub _tree_construction_main ($) {
4275                  tr => 1, html => 1,                  tr => 1, html => 1,
4276                }->{$self->{open_elements}->[-1]->[1]}) {                }->{$self->{open_elements}->[-1]->[1]}) {
4277                  !!!cp ('t207');                  !!!cp ('t207');
                 !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4278                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4279                }                }
4280                                
# Line 4326  sub _tree_construction_main ($) { Line 4325  sub _tree_construction_main ($) {
4325                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4326                    !!!cp ('t211');                    !!!cp ('t211');
4327                    ## ISSUE: Can this case be reached?                    ## ISSUE: Can this case be reached?
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4328                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4329                  }                  }
4330                                    
# Line 4375  sub _tree_construction_main ($) { Line 4373  sub _tree_construction_main ($) {
4373                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4374                    !!!cp ('t217');                    !!!cp ('t217');
4375                    ## ISSUE: Can this state be reached?                    ## ISSUE: Can this state be reached?
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4376                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4377                  }                  }
4378                                    
# Line 4399  sub _tree_construction_main ($) { Line 4396  sub _tree_construction_main ($) {
4396                         $self->{open_elements}->[-1]->[1] ne 'html') {                         $self->{open_elements}->[-1]->[1] ne 'html') {
4397                    !!!cp ('t219');                    !!!cp ('t219');
4398                    ## ISSUE: Can this state be reached?                    ## ISSUE: Can this state be reached?
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4399                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4400                  }                  }
4401                                    
# Line 4417  sub _tree_construction_main ($) { Line 4413  sub _tree_construction_main ($) {
4413                         $self->{open_elements}->[-1]->[1] ne 'html') {                         $self->{open_elements}->[-1]->[1] ne 'html') {
4414                    !!!cp ('t220');                    !!!cp ('t220');
4415                    ## ISSUE: Can this state be reached?                    ## ISSUE: Can this state be reached?
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4416                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4417                  }                  }
4418                                    
# Line 4483  sub _tree_construction_main ($) { Line 4478  sub _tree_construction_main ($) {
4478                }                }
4479    
4480                splice @{$self->{open_elements}}, $i;                splice @{$self->{open_elements}}, $i;
4481                  pop @{$open_tables};
4482    
4483                $self->_reset_insertion_mode;                $self->_reset_insertion_mode;
4484    
4485                ## reprocess                ## reprocess
4486                redo B;                redo B;
4487            } elsif ($token->{tag_name} eq 'input') {
4488              if (not $open_tables->[-1]->[1]) { # tainted
4489                if ($token->{attributes}->{type}) { ## TODO: case
4490                  my $type = lc $token->{attributes}->{type}->{value};
4491                  if ($type eq 'hidden') {
4492                    !!!cp ('t227.3');
4493                    !!!parse-error (type => 'in table:'.$token->{tag_name});
4494    
4495                    !!!insert-element ($token->{tag_name}, $token->{attributes});
4496    
4497                    ## TODO: form element pointer
4498    
4499                    pop @{$self->{open_elements}};
4500    
4501                    !!!next-token;
4502                    redo B;
4503                  } else {
4504                    !!!cp ('t227.2');
4505                    #
4506                  }
4507                } else {
4508                  !!!cp ('t227.1');
4509                  #
4510                }
4511              } else {
4512                !!!cp ('t227.4');
4513                #
4514              }
4515          } else {          } else {
4516            !!!cp ('t227');            !!!cp ('t227');
           !!!parse-error (type => 'in table:'.$token->{tag_name});  
   
           $insert = $insert_to_foster;  
4517            #            #
4518          }          }
4519    
4520            !!!parse-error (type => 'in table:'.$token->{tag_name});
4521    
4522            $insert = $insert_to_foster;
4523            #
4524        } elsif ($token->{type} == END_TAG_TOKEN) {        } elsif ($token->{type} == END_TAG_TOKEN) {
4525              if ($token->{tag_name} eq 'tr' and              if ($token->{tag_name} eq 'tr' and
4526                  $self->{insertion_mode} == IN_ROW_IM) {                  $self->{insertion_mode} == IN_ROW_IM) {
# Line 4529  sub _tree_construction_main ($) { Line 4555  sub _tree_construction_main ($) {
4555                }->{$self->{open_elements}->[-1]->[1]}) {                }->{$self->{open_elements}->[-1]->[1]}) {
4556                  !!!cp ('t231');                  !!!cp ('t231');
4557  ## ISSUE: Can this state be reached?  ## ISSUE: Can this state be reached?
                 !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4558                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4559                }                }
4560    
# Line 4570  sub _tree_construction_main ($) { Line 4595  sub _tree_construction_main ($) {
4595                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4596                    !!!cp ('t236');                    !!!cp ('t236');
4597  ## ISSUE: Can this state be reached?  ## ISSUE: Can this state be reached?
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4598                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4599                  }                  }
4600                                    
# Line 4610  sub _tree_construction_main ($) { Line 4634  sub _tree_construction_main ($) {
4634                    tbody => 1, tfoot => 1, thead => 1, html => 1,                    tbody => 1, tfoot => 1, thead => 1, html => 1,
4635                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4636                    !!!cp ('t240');                    !!!cp ('t240');
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4637                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4638                  }                  }
4639                                    
# Line 4626  sub _tree_construction_main ($) { Line 4649  sub _tree_construction_main ($) {
4649                  ## reprocess in the "in table" insertion mode...                  ## reprocess in the "in table" insertion mode...
4650                }                }
4651    
4652                  ## NOTE: </table> in the "in table" insertion mode.
4653                  ## When you edit the code fragment below, please ensure that
4654                  ## the code for <table> in the "in table" insertion mode
4655                  ## is synced with it.
4656    
4657                ## have a table element in table scope                ## have a table element in table scope
4658                my $i;                my $i;
4659                INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {                INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
# Line 4648  sub _tree_construction_main ($) { Line 4676  sub _tree_construction_main ($) {
4676                  !!!next-token;                  !!!next-token;
4677                  redo B;                  redo B;
4678                }                }
   
               ## generate implied end tags  
               while ({  
                       dd => 1, dt => 1, li => 1, p => 1,  
                      }->{$self->{open_elements}->[-1]->[1]}) {  
                 !!!cp ('t244');  
 ## ISSUE: Can this case be reached?  
                 pop @{$self->{open_elements}};  
               }  
                 
               if ($self->{open_elements}->[-1]->[1] ne 'table') {  
                 !!!cp ('t245');  
                 !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
               } else {  
                 !!!cp ('t246');  
               }  
4679                                    
4680                splice @{$self->{open_elements}}, $i;                splice @{$self->{open_elements}}, $i;
4681                  pop @{$open_tables};
4682                                
4683                $self->_reset_insertion_mode;                $self->_reset_insertion_mode;
4684                                
# Line 4729  sub _tree_construction_main ($) { Line 4742  sub _tree_construction_main ($) {
4742                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4743                    !!!cp ('t253');                    !!!cp ('t253');
4744  ## ISSUE: Can this case be reached?  ## ISSUE: Can this case be reached?
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4745                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4746                  }                  }
4747                                    
# Line 4767  sub _tree_construction_main ($) { Line 4779  sub _tree_construction_main ($) {
4779                }->{$self->{open_elements}->[-1]->[1]}) {                }->{$self->{open_elements}->[-1]->[1]}) {
4780                  !!!cp ('t257');                  !!!cp ('t257');
4781  ## ISSUE: Can this case be reached?  ## ISSUE: Can this case be reached?
                 !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4782                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4783                }                }
4784    
# Line 5224  sub _tree_construction_main ($) { Line 5235  sub _tree_construction_main ($) {
5235          } elsif ($token->{tag_name} eq 'noframes') {          } elsif ($token->{tag_name} eq 'noframes') {
5236            !!!cp ('t320');            !!!cp ('t320');
5237            ## NOTE: As if in body.            ## NOTE: As if in body.
5238            $parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current);            $parse_rcdata->(CDATA_CONTENT_MODEL);
5239            redo B;            redo B;
5240          } else {          } else {
5241            if ($self->{insertion_mode} == IN_FRAMESET_IM) {            if ($self->{insertion_mode} == IN_FRAMESET_IM) {
# Line 5308  sub _tree_construction_main ($) { Line 5319  sub _tree_construction_main ($) {
5319        } elsif ($token->{tag_name} eq 'style') {        } elsif ($token->{tag_name} eq 'style') {
5320          !!!cp ('t333');          !!!cp ('t333');
5321          ## NOTE: This is an "as if in head" code clone          ## NOTE: This is an "as if in head" code clone
5322          $parse_rcdata->(CDATA_CONTENT_MODEL, $insert);          $parse_rcdata->(CDATA_CONTENT_MODEL);
5323          redo B;          redo B;
5324        } elsif ({        } elsif ({
5325                  base => 1, link => 1,                  base => 1, link => 1,
# Line 5371  sub _tree_construction_main ($) { Line 5382  sub _tree_construction_main ($) {
5382          redo B;          redo B;
5383        } elsif ($token->{tag_name} eq 'title') {        } elsif ($token->{tag_name} eq 'title') {
5384          !!!cp ('t341');          !!!cp ('t341');
         !!!parse-error (type => 'in body:title');  
5385          ## NOTE: This is an "as if in head" code clone          ## NOTE: This is an "as if in head" code clone
5386          $parse_rcdata->(RCDATA_CONTENT_MODEL, sub {          $parse_rcdata->(RCDATA_CONTENT_MODEL);
           if (defined $self->{head_element}) {  
             !!!cp ('t339');  
             $self->{head_element}->append_child ($_[0]);  
           } else {  
             !!!cp ('t340');  
             $insert->($_[0]);  
           }  
         });  
5387          redo B;          redo B;
5388        } elsif ($token->{tag_name} eq 'body') {        } elsif ($token->{tag_name} eq 'body') {
5389          !!!parse-error (type => 'in body:body');          !!!parse-error (type => 'in body:body');
# Line 5407  sub _tree_construction_main ($) { Line 5409  sub _tree_construction_main ($) {
5409                  address => 1, blockquote => 1, center => 1, dir => 1,                  address => 1, blockquote => 1, center => 1, dir => 1,
5410                  div => 1, dl => 1, fieldset => 1,                  div => 1, dl => 1, fieldset => 1,
5411                  h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,                  h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,
5412                  listing => 1, menu => 1, ol => 1, p => 1, ul => 1,                  menu => 1, ol => 1, p => 1, ul => 1,
5413                  pre => 1,                  pre => 1, listing => 1,
5414                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
5415          ## has a p element in scope          ## has a p element in scope
5416          INSCOPE: for (reverse @{$self->{open_elements}}) {          INSCOPE: for (reverse @{$self->{open_elements}}) {
# Line 5427  sub _tree_construction_main ($) { Line 5429  sub _tree_construction_main ($) {
5429          } # INSCOPE          } # INSCOPE
5430                        
5431          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes});
5432          if ($token->{tag_name} eq 'pre') {          if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') {
5433            !!!next-token;            !!!next-token;
5434            if ($token->{type} == CHARACTER_TOKEN) {            if ($token->{type} == CHARACTER_TOKEN) {
5435              $token->{data} =~ s/^\x0A//;              $token->{data} =~ s/^\x0A//;
# Line 5729  sub _tree_construction_main ($) { Line 5731  sub _tree_construction_main ($) {
5731        } elsif ($token->{tag_name} eq 'xmp') {        } elsif ($token->{tag_name} eq 'xmp') {
5732          !!!cp ('t381');          !!!cp ('t381');
5733          $reconstruct_active_formatting_elements->($insert_to_current);          $reconstruct_active_formatting_elements->($insert_to_current);
5734          $parse_rcdata->(CDATA_CONTENT_MODEL, $insert);          $parse_rcdata->(CDATA_CONTENT_MODEL);
5735          redo B;          redo B;
5736        } elsif ($token->{tag_name} eq 'table') {        } elsif ($token->{tag_name} eq 'table') {
5737          ## has a p element in scope          ## has a p element in scope
# Line 5749  sub _tree_construction_main ($) { Line 5751  sub _tree_construction_main ($) {
5751          } # INSCOPE          } # INSCOPE
5752                        
5753          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes});
5754                      push @{$open_tables}, [$self->{open_elements}->[-1]->[0]];
5755    
5756          $self->{insertion_mode} = IN_TABLE_IM;          $self->{insertion_mode} = IN_TABLE_IM;
5757                        
5758          !!!next-token;          !!!next-token;
# Line 5904  sub _tree_construction_main ($) { Line 5907  sub _tree_construction_main ($) {
5907                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
5908          !!!cp ('t399');          !!!cp ('t399');
5909          ## NOTE: There is an "as if in body" code clone.          ## NOTE: There is an "as if in body" code clone.
5910          $parse_rcdata->(CDATA_CONTENT_MODEL, $insert);          $parse_rcdata->(CDATA_CONTENT_MODEL);
5911          redo B;          redo B;
5912        } elsif ($token->{tag_name} eq 'select') {        } elsif ($token->{tag_name} eq 'select') {
5913          !!!cp ('t400');          !!!cp ('t400');
# Line 5989  sub _tree_construction_main ($) { Line 5992  sub _tree_construction_main ($) {
5992                  address => 1, blockquote => 1, center => 1, dir => 1,                  address => 1, blockquote => 1, center => 1, dir => 1,
5993                  div => 1, dl => 1, fieldset => 1, listing => 1,                  div => 1, dl => 1, fieldset => 1, listing => 1,
5994                  menu => 1, ol => 1, pre => 1, ul => 1,                  menu => 1, ol => 1, pre => 1, ul => 1,
                 p => 1,  
5995                  dd => 1, dt => 1, li => 1,                  dd => 1, dt => 1, li => 1,
5996                  button => 1, marquee => 1, object => 1,                  button => 1, marquee => 1, object => 1,
5997                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
# Line 5998  sub _tree_construction_main ($) { Line 6000  sub _tree_construction_main ($) {
6000          INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {          INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
6001            my $node = $self->{open_elements}->[$_];            my $node = $self->{open_elements}->[$_];
6002            if ($node->[1] eq $token->{tag_name}) {            if ($node->[1] eq $token->{tag_name}) {
             ## generate implied end tags  
             while ({  
                     dd => ($token->{tag_name} ne 'dd'),  
                     dt => ($token->{tag_name} ne 'dt'),  
                     li => ($token->{tag_name} ne 'li'),  
                     p => ($token->{tag_name} ne 'p'),  
                    }->{$self->{open_elements}->[-1]->[1]}) {  
               !!!cp ('t409');  
               pop @{$self->{open_elements}};  
             }  
               
6003              !!!cp ('t410');              !!!cp ('t410');
6004              $i = $_;              $i = $_;
6005              last INSCOPE unless $token->{tag_name} eq 'p';              last INSCOPE;
6006            } elsif ({            } elsif ({
6007                      table => 1, caption => 1, td => 1, th => 1,                      table => 1, caption => 1, td => 1, th => 1,
6008                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
# Line 6020  sub _tree_construction_main ($) { Line 6011  sub _tree_construction_main ($) {
6011              last INSCOPE;              last INSCOPE;
6012            }            }
6013          } # INSCOPE          } # INSCOPE
6014            
6015          if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {          unless (defined $i) { # has an element in scope
6016            if (defined $i) {            !!!cp ('t413');
6017              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
6018            } else {
6019              ## Step 1. generate implied end tags
6020              while ({
6021                      dd => ($token->{tag_name} ne 'dd'),
6022                      dt => ($token->{tag_name} ne 'dt'),
6023                      li => ($token->{tag_name} ne 'li'),
6024                      p => 1,
6025                     }->{$self->{open_elements}->[-1]->[1]}) {
6026                !!!cp ('t409');
6027                pop @{$self->{open_elements}};
6028              }
6029    
6030              ## Step 2.
6031              if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
6032              !!!cp ('t412');              !!!cp ('t412');
6033              !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);              !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
6034            } else {            } else {
6035              !!!cp ('t413');              !!!cp ('t414');
             !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});  
6036            }            }
6037          }  
6038                      ## Step 3.
         if (defined $i) {  
           !!!cp ('t414');  
6039            splice @{$self->{open_elements}}, $i;            splice @{$self->{open_elements}}, $i;
6040          } elsif ($token->{tag_name} eq 'p') {  
6041            !!!cp ('t415');            ## Step 4.
6042            ## As if <p>, then reprocess the current token            $clear_up_to_marker->()
6043            my $el;                if {
6044            !!!create-element ($el, 'p');                  button => 1, marquee => 1, object => 1,
6045            $insert->($el);                }->{$token->{tag_name}};
         } else {  
           !!!cp ('t416');  
6046          }          }
         $clear_up_to_marker->()  
           if {  
             button => 1, marquee => 1, object => 1,  
           }->{$token->{tag_name}};  
6047          !!!next-token;          !!!next-token;
6048          redo B;          redo B;
6049        } elsif ($token->{tag_name} eq 'form') {        } elsif ($token->{tag_name} eq 'form') {
6050            undef $self->{form_element};
6051    
6052          ## has an element in scope          ## has an element in scope
6053            my $i;
6054          INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {          INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
6055            my $node = $self->{open_elements}->[$_];            my $node = $self->{open_elements}->[$_];
6056            if ($node->[1] eq $token->{tag_name}) {            if ($node->[1] eq $token->{tag_name}) {
             ## generate implied end tags  
             while ({  
                     dd => 1, dt => 1, li => 1, p => 1,  
                    }->{$self->{open_elements}->[-1]->[1]}) {  
               !!!cp ('t417');  
               pop @{$self->{open_elements}};  
             }  
   
6057              !!!cp ('t418');              !!!cp ('t418');
6058                $i = $_;
6059              last INSCOPE;              last INSCOPE;
6060            } elsif ({            } elsif ({
6061                      table => 1, caption => 1, td => 1, th => 1,                      table => 1, caption => 1, td => 1, th => 1,
# Line 6072  sub _tree_construction_main ($) { Line 6065  sub _tree_construction_main ($) {
6065              last INSCOPE;              last INSCOPE;
6066            }            }
6067          } # INSCOPE          } # INSCOPE
6068            
6069          if ($self->{open_elements}->[-1]->[1] eq $token->{tag_name}) {          unless (defined $i) { # has an element in scope
           !!!cp ('t420');  
           pop @{$self->{open_elements}};  
         } else {  
6070            !!!cp ('t421');            !!!cp ('t421');
6071            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
6072            } else {
6073              ## Step 1. generate implied end tags
6074              while ({
6075                      dd => 1, dt => 1, li => 1, p => 1,
6076                     }->{$self->{open_elements}->[-1]->[1]}) {
6077                !!!cp ('t417');
6078                pop @{$self->{open_elements}};
6079              }
6080              
6081              ## Step 2.
6082              if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
6083                !!!cp ('t417.1');
6084                !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
6085              } else {
6086                !!!cp ('t420');
6087              }  
6088              
6089              ## Step 3.
6090              splice @{$self->{open_elements}}, $i;
6091          }          }
6092    
         undef $self->{form_element};  
6093          !!!next-token;          !!!next-token;
6094          redo B;          redo B;
6095        } elsif ({        } elsif ({
# Line 6094  sub _tree_construction_main ($) { Line 6102  sub _tree_construction_main ($) {
6102            if ({            if ({
6103                 h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,                 h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,
6104                }->{$node->[1]}) {                }->{$node->[1]}) {
             ## generate implied end tags  
             while ({  
                     dd => 1, dt => 1, li => 1, p => 1,  
                    }->{$self->{open_elements}->[-1]->[1]}) {  
               !!!cp ('t422');  
               pop @{$self->{open_elements}};  
             }  
   
6105              !!!cp ('t423');              !!!cp ('t423');
6106              $i = $_;              $i = $_;
6107              last INSCOPE;              last INSCOPE;
# Line 6113  sub _tree_construction_main ($) { Line 6113  sub _tree_construction_main ($) {
6113              last INSCOPE;              last INSCOPE;
6114            }            }
6115          } # INSCOPE          } # INSCOPE
6116            
6117          if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {          unless (defined $i) { # has an element in scope
6118            !!!cp ('t425');            !!!cp ('t425.1');
6119            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
6120          } else {          } else {
6121            !!!cp ('t426');            ## Step 1. generate implied end tags
6122              while ({
6123                      dd => 1, dt => 1, li => 1, p => 1,
6124                     }->{$self->{open_elements}->[-1]->[1]}) {
6125                !!!cp ('t422');
6126                pop @{$self->{open_elements}};
6127              }
6128              
6129              ## Step 2.
6130              if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
6131                !!!cp ('t425');
6132                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
6133              } else {
6134                !!!cp ('t426');
6135              }
6136    
6137              ## Step 3.
6138              splice @{$self->{open_elements}}, $i;
6139          }          }
6140                    
6141          splice @{$self->{open_elements}}, $i if defined $i;          !!!next-token;
6142            redo B;
6143          } elsif ($token->{tag_name} eq 'p') {
6144            ## has an element in scope
6145            my $i;
6146            INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
6147              my $node = $self->{open_elements}->[$_];
6148              if ($node->[1] eq $token->{tag_name}) {
6149                !!!cp ('t410.1');
6150                $i = $_;
6151                last INSCOPE;
6152              } elsif ({
6153                        table => 1, caption => 1, td => 1, th => 1,
6154                        button => 1, marquee => 1, object => 1, html => 1,
6155                       }->{$node->[1]}) {
6156                !!!cp ('t411.1');
6157                last INSCOPE;
6158              }
6159            } # INSCOPE
6160    
6161            if (defined $i) {
6162              if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
6163                !!!cp ('t412.1');
6164                !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
6165              } else {
6166                !!!cp ('t414.1');
6167              }
6168    
6169              splice @{$self->{open_elements}}, $i;
6170            } else {
6171              !!!cp ('t413.1');
6172              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
6173    
6174              !!!cp ('t415.1');
6175              ## As if <p>, then reprocess the current token
6176              my $el;
6177              !!!create-element ($el, 'p');
6178              $insert->($el);
6179              ## NOTE: Not inserted into |$self->{open_elements}|.
6180            }
6181    
6182          !!!next-token;          !!!next-token;
6183          redo B;          redo B;
6184        } elsif ({        } elsif ({

Legend:
Removed from v.1.86  
changed lines
  Added in v.1.98

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24