/[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.91 by wakaba, Sat Mar 8 03:04:09 2008 UTC revision 1.95 by wakaba, Sat Mar 8 05:09:25 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 3213  sub _tree_construction_main ($) { Line 3208  sub _tree_construction_main ($) {
3208      } # FET      } # FET
3209    }; # $formatting_end_tag    }; # $formatting_end_tag
3210    
3211      ## NOTE: $open_tables->[-1]->[0] is the "current table".
3212      ## NOTE: $open_tables->[-1]->[1] is the "tainted" flag.
3213      my $open_tables = [[$self->{open_elements}->[0]->[0]]];
3214    
3215    my $insert_to_current = sub {    my $insert_to_current = sub {
3216      $self->{open_elements}->[-1]->[0]->append_child ($_[0]);      $self->{open_elements}->[-1]->[0]->append_child ($_[0]);
3217    }; # $insert_to_current    }; # $insert_to_current
3218    
3219    my $insert_to_foster = sub {    my $insert_to_foster = sub {
3220                         my $child = shift;      my $child = shift;
3221                         if ({      if ({
3222                              table => 1, tbody => 1, tfoot => 1,           table => 1, tbody => 1, tfoot => 1, thead => 1, tr => 1,
3223                              thead => 1, tr => 1,          }->{$self->{open_elements}->[-1]->[1]}) {
3224                             }->{$self->{open_elements}->[-1]->[1]}) {        # MUST
3225                           # MUST        my $foster_parent_element;
3226                           my $foster_parent_element;        my $next_sibling;
                          my $next_sibling;  
3227                           OE: for (reverse 0..$#{$self->{open_elements}}) {                           OE: for (reverse 0..$#{$self->{open_elements}}) {
3228                             if ($self->{open_elements}->[$_]->[1] eq 'table') {                             if ($self->{open_elements}->[$_]->[1] eq 'table') {
3229                               my $parent = $self->{open_elements}->[$_]->[0]->parent_node;                               my $parent = $self->{open_elements}->[$_]->[0]->parent_node;
# Line 3245  sub _tree_construction_main ($) { Line 3243  sub _tree_construction_main ($) {
3243                             unless defined $foster_parent_element;                             unless defined $foster_parent_element;
3244                           $foster_parent_element->insert_before                           $foster_parent_element->insert_before
3245                             ($child, $next_sibling);                             ($child, $next_sibling);
3246                         } else {        $open_tables->[-1]->[1] = 1; # tainted
3247                           !!!cp ('t72');      } else {
3248                           $self->{open_elements}->[-1]->[0]->append_child ($child);        !!!cp ('t72');
3249                         }        $self->{open_elements}->[-1]->[0]->append_child ($child);
3250        }
3251    }; # $insert_to_foster    }; # $insert_to_foster
3252    
3253    my $insert;    my $insert;
# Line 4156  sub _tree_construction_main ($) { Line 4155  sub _tree_construction_main ($) {
4155        #        #
4156      } elsif ($self->{insertion_mode} & TABLE_IMS) {      } elsif ($self->{insertion_mode} & TABLE_IMS) {
4157        if ($token->{type} == CHARACTER_TOKEN) {        if ($token->{type} == CHARACTER_TOKEN) {
4158              if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {          if (not $open_tables->[-1]->[1] and # tainted
4159                $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);              $token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {
4160              $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);
4161                                
4162                unless (length $token->{data}) {            unless (length $token->{data}) {
4163                  !!!cp ('t194');              !!!cp ('t194');
4164                  !!!next-token;              !!!next-token;
4165                  redo B;              redo B;
4166                } else {            } else {
4167                  !!!cp ('t195');              !!!cp ('t195');
4168                }            }
4169              }          }
4170    
4171              !!!parse-error (type => 'in table:#character');              !!!parse-error (type => 'in table:#character');
4172    
# Line 4213  sub _tree_construction_main ($) { Line 4213  sub _tree_construction_main ($) {
4213                    ($self->{document}->create_text_node ($token->{data}),                    ($self->{document}->create_text_node ($token->{data}),
4214                     $next_sibling);                     $next_sibling);
4215                }                }
4216              } else {            $open_tables->[-1]->[1] = 1; # tainted
4217                !!!cp ('t200');          } else {
4218                $self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data});            !!!cp ('t200');
4219              }            $self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data});
4220            }
4221                            
4222              !!!next-token;          !!!next-token;
4223              redo B;          redo B;
4224        } elsif ($token->{type} == START_TAG_TOKEN) {        } elsif ($token->{type} == START_TAG_TOKEN) {
4225              if ({              if ({
4226                   tr => ($self->{insertion_mode} != IN_ROW_IM),                   tr => ($self->{insertion_mode} != IN_ROW_IM),
# Line 4230  sub _tree_construction_main ($) { Line 4231  sub _tree_construction_main ($) {
4231                  while ($self->{open_elements}->[-1]->[1] ne 'table' and                  while ($self->{open_elements}->[-1]->[1] ne 'table' and
4232                         $self->{open_elements}->[-1]->[1] ne 'html') {                         $self->{open_elements}->[-1]->[1] ne 'html') {
4233                    !!!cp ('t201');                    !!!cp ('t201');
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4234                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4235                  }                  }
4236                                    
# Line 4251  sub _tree_construction_main ($) { Line 4251  sub _tree_construction_main ($) {
4251                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4252                    !!!cp ('t203');                    !!!cp ('t203');
4253                    ## ISSUE: Can this case be reached?                    ## ISSUE: Can this case be reached?
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4254                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4255                  }                  }
4256                                    
# Line 4275  sub _tree_construction_main ($) { Line 4274  sub _tree_construction_main ($) {
4274                  tr => 1, html => 1,                  tr => 1, html => 1,
4275                }->{$self->{open_elements}->[-1]->[1]}) {                }->{$self->{open_elements}->[-1]->[1]}) {
4276                  !!!cp ('t207');                  !!!cp ('t207');
                 !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4277                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4278                }                }
4279                                
# Line 4326  sub _tree_construction_main ($) { Line 4324  sub _tree_construction_main ($) {
4324                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4325                    !!!cp ('t211');                    !!!cp ('t211');
4326                    ## ISSUE: Can this case be reached?                    ## ISSUE: Can this case be reached?
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4327                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4328                  }                  }
4329                                    
# Line 4375  sub _tree_construction_main ($) { Line 4372  sub _tree_construction_main ($) {
4372                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4373                    !!!cp ('t217');                    !!!cp ('t217');
4374                    ## ISSUE: Can this state be reached?                    ## ISSUE: Can this state be reached?
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4375                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4376                  }                  }
4377                                    
# Line 4399  sub _tree_construction_main ($) { Line 4395  sub _tree_construction_main ($) {
4395                         $self->{open_elements}->[-1]->[1] ne 'html') {                         $self->{open_elements}->[-1]->[1] ne 'html') {
4396                    !!!cp ('t219');                    !!!cp ('t219');
4397                    ## ISSUE: Can this state be reached?                    ## ISSUE: Can this state be reached?
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4398                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4399                  }                  }
4400                                    
# Line 4417  sub _tree_construction_main ($) { Line 4412  sub _tree_construction_main ($) {
4412                         $self->{open_elements}->[-1]->[1] ne 'html') {                         $self->{open_elements}->[-1]->[1] ne 'html') {
4413                    !!!cp ('t220');                    !!!cp ('t220');
4414                    ## ISSUE: Can this state be reached?                    ## ISSUE: Can this state be reached?
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4415                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4416                  }                  }
4417                                    
# Line 4483  sub _tree_construction_main ($) { Line 4477  sub _tree_construction_main ($) {
4477                }                }
4478    
4479                splice @{$self->{open_elements}}, $i;                splice @{$self->{open_elements}}, $i;
4480                  pop @{$open_tables};
4481    
4482                $self->_reset_insertion_mode;                $self->_reset_insertion_mode;
4483    
# Line 4529  sub _tree_construction_main ($) { Line 4524  sub _tree_construction_main ($) {
4524                }->{$self->{open_elements}->[-1]->[1]}) {                }->{$self->{open_elements}->[-1]->[1]}) {
4525                  !!!cp ('t231');                  !!!cp ('t231');
4526  ## ISSUE: Can this state be reached?  ## ISSUE: Can this state be reached?
                 !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4527                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4528                }                }
4529    
# Line 4570  sub _tree_construction_main ($) { Line 4564  sub _tree_construction_main ($) {
4564                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4565                    !!!cp ('t236');                    !!!cp ('t236');
4566  ## ISSUE: Can this state be reached?  ## ISSUE: Can this state be reached?
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4567                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4568                  }                  }
4569                                    
# Line 4610  sub _tree_construction_main ($) { Line 4603  sub _tree_construction_main ($) {
4603                    tbody => 1, tfoot => 1, thead => 1, html => 1,                    tbody => 1, tfoot => 1, thead => 1, html => 1,
4604                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4605                    !!!cp ('t240');                    !!!cp ('t240');
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4606                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4607                  }                  }
4608                                    
# Line 4626  sub _tree_construction_main ($) { Line 4618  sub _tree_construction_main ($) {
4618                  ## reprocess in the "in table" insertion mode...                  ## reprocess in the "in table" insertion mode...
4619                }                }
4620    
4621                  ## NOTE: </table> in the "in table" insertion mode.
4622                  ## When you edit the code fragment below, please ensure that
4623                  ## the code for <table> in the "in table" insertion mode
4624                  ## is synced with it.
4625    
4626                ## have a table element in table scope                ## have a table element in table scope
4627                my $i;                my $i;
4628                INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {                INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
# Line 4648  sub _tree_construction_main ($) { Line 4645  sub _tree_construction_main ($) {
4645                  !!!next-token;                  !!!next-token;
4646                  redo B;                  redo B;
4647                }                }
   
               ## 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');  
               }  
4648                                    
4649                splice @{$self->{open_elements}}, $i;                splice @{$self->{open_elements}}, $i;
4650                  pop @{$open_tables};
4651                                
4652                $self->_reset_insertion_mode;                $self->_reset_insertion_mode;
4653                                
# Line 4729  sub _tree_construction_main ($) { Line 4711  sub _tree_construction_main ($) {
4711                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4712                    !!!cp ('t253');                    !!!cp ('t253');
4713  ## ISSUE: Can this case be reached?  ## ISSUE: Can this case be reached?
                   !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4714                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4715                  }                  }
4716                                    
# Line 4767  sub _tree_construction_main ($) { Line 4748  sub _tree_construction_main ($) {
4748                }->{$self->{open_elements}->[-1]->[1]}) {                }->{$self->{open_elements}->[-1]->[1]}) {
4749                  !!!cp ('t257');                  !!!cp ('t257');
4750  ## ISSUE: Can this case be reached?  ## ISSUE: Can this case be reached?
                 !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
4751                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4752                }                }
4753    
# Line 5749  sub _tree_construction_main ($) { Line 5729  sub _tree_construction_main ($) {
5729          } # INSCOPE          } # INSCOPE
5730                        
5731          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes});
5732                      push @{$open_tables}, [$self->{open_elements}->[-1]->[0]];
5733    
5734          $self->{insertion_mode} = IN_TABLE_IM;          $self->{insertion_mode} = IN_TABLE_IM;
5735                        
5736          !!!next-token;          !!!next-token;
# Line 6044  sub _tree_construction_main ($) { Line 6025  sub _tree_construction_main ($) {
6025          !!!next-token;          !!!next-token;
6026          redo B;          redo B;
6027        } elsif ($token->{tag_name} eq 'form') {        } elsif ($token->{tag_name} eq 'form') {
6028            undef $self->{form_element};
6029    
6030          ## has an element in scope          ## has an element in scope
6031            my $i;
6032          INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {          INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
6033            my $node = $self->{open_elements}->[$_];            my $node = $self->{open_elements}->[$_];
6034            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}};  
             }  
   
6035              !!!cp ('t418');              !!!cp ('t418');
6036                $i = $_;
6037              last INSCOPE;              last INSCOPE;
6038            } elsif ({            } elsif ({
6039                      table => 1, caption => 1, td => 1, th => 1,                      table => 1, caption => 1, td => 1, th => 1,
# Line 6066  sub _tree_construction_main ($) { Line 6043  sub _tree_construction_main ($) {
6043              last INSCOPE;              last INSCOPE;
6044            }            }
6045          } # INSCOPE          } # INSCOPE
6046            
6047          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 {  
6048            !!!cp ('t421');            !!!cp ('t421');
6049            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
6050            } else {
6051              ## Step 1. generate implied end tags
6052              while ({
6053                      dd => 1, dt => 1, li => 1, p => 1,
6054                     }->{$self->{open_elements}->[-1]->[1]}) {
6055                !!!cp ('t417');
6056                pop @{$self->{open_elements}};
6057              }
6058              
6059              ## Step 2.
6060              if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
6061                !!!cp ('t417.1');
6062                !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
6063              } else {
6064                !!!cp ('t420');
6065              }  
6066              
6067              ## Step 3.
6068              splice @{$self->{open_elements}}, $i;
6069          }          }
6070    
         undef $self->{form_element};  
6071          !!!next-token;          !!!next-token;
6072          redo B;          redo B;
6073        } elsif ({        } elsif ({
# Line 6088  sub _tree_construction_main ($) { Line 6080  sub _tree_construction_main ($) {
6080            if ({            if ({
6081                 h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,                 h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,
6082                }->{$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}};  
             }  
   
6083              !!!cp ('t423');              !!!cp ('t423');
6084              $i = $_;              $i = $_;
6085              last INSCOPE;              last INSCOPE;
# Line 6107  sub _tree_construction_main ($) { Line 6091  sub _tree_construction_main ($) {
6091              last INSCOPE;              last INSCOPE;
6092            }            }
6093          } # INSCOPE          } # INSCOPE
6094            
6095          if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {          unless (defined $i) { # has an element in scope
6096            !!!cp ('t425');            !!!cp ('t425.1');
6097            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
6098          } else {          } else {
6099            !!!cp ('t426');            ## Step 1. generate implied end tags
6100              while ({
6101                      dd => 1, dt => 1, li => 1, p => 1,
6102                     }->{$self->{open_elements}->[-1]->[1]}) {
6103                !!!cp ('t422');
6104                pop @{$self->{open_elements}};
6105              }
6106              
6107              ## Step 2.
6108              if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
6109                !!!cp ('t425');
6110                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
6111              } else {
6112                !!!cp ('t426');
6113              }
6114    
6115              ## Step 3.
6116              splice @{$self->{open_elements}}, $i;
6117          }          }
6118                    
         splice @{$self->{open_elements}}, $i if defined $i;  
6119          !!!next-token;          !!!next-token;
6120          redo B;          redo B;
6121        } elsif ($token->{tag_name} eq 'p') {        } elsif ($token->{tag_name} eq 'p') {

Legend:
Removed from v.1.91  
changed lines
  Added in v.1.95

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24