/[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.102 by wakaba, Sun Mar 9 06:29:25 2008 UTC revision 1.104 by wakaba, Sun Mar 9 08:47:33 2008 UTC
# Line 74  my $special_category = { Line 74  my $special_category = {
74    textarea => 1, tfoot => 1, thead => 1, title => 1, tr => 1, ul => 1, wbr => 1,    textarea => 1, tfoot => 1, thead => 1, title => 1, tr => 1, ul => 1, wbr => 1,
75  };  };
76  my $scoping_category = {  my $scoping_category = {
77    button => 1, caption => 1, html => 1, marquee => 1, object => 1,    applet => 1, button => 1, caption => 1, html => 1, marquee => 1, object => 1,
78    table => 1, td => 1, th => 1,    table => 1, td => 1, th => 1,
79  };  };
80  my $formatting_category = {  my $formatting_category = {
# Line 3019  sub _tree_construction_main ($) { Line 3019  sub _tree_construction_main ($) {
3019    my $formatting_end_tag = sub {    my $formatting_end_tag = sub {
3020      my $tag_name = shift;      my $tag_name = shift;
3021    
3022      ## NOTE: The adoptioon agency algorithm (AAA).      ## NOTE: The adoption agency algorithm (AAA).
3023    
3024      FET: {      FET: {
3025        ## Step 1        ## Step 1
# Line 3061  sub _tree_construction_main ($) { Line 3061  sub _tree_construction_main ($) {
3061              return;              return;
3062            }            }
3063          } elsif ({          } elsif ({
3064                    table => 1, caption => 1, td => 1, th => 1,                    applet => 1, table => 1, caption => 1, td => 1, th => 1,
3065                    button => 1, marquee => 1, object => 1, html => 1,                    button => 1, marquee => 1, object => 1, html => 1,
3066                   }->{$node->[1]}) {                   }->{$node->[1]}) {
3067            !!!cp ('t56');            !!!cp ('t56');
# Line 3088  sub _tree_construction_main ($) { Line 3088  sub _tree_construction_main ($) {
3088          if (not $formatting_category->{$node->[1]} and          if (not $formatting_category->{$node->[1]} and
3089              #not $phrasing_category->{$node->[1]} and              #not $phrasing_category->{$node->[1]} and
3090              ($special_category->{$node->[1]} or              ($special_category->{$node->[1]} or
3091               $scoping_category->{$node->[1]})) {               $scoping_category->{$node->[1]})) { ## Scoping is redundant, maybe
3092            !!!cp ('t59');            !!!cp ('t59');
3093            $furthest_block = $node;            $furthest_block = $node;
3094            $furthest_block_i_in_open = $_;            $furthest_block_i_in_open = $_;
# Line 3293  sub _tree_construction_main ($) { Line 3293  sub _tree_construction_main ($) {
3293        ## Stay in the phase        ## Stay in the phase
3294        !!!next-token;        !!!next-token;
3295        redo B;        redo B;
     } elsif ($token->{type} == END_OF_FILE_TOKEN) {  
       if ($self->{insertion_mode} & AFTER_HTML_IMS) {  
         !!!cp ('t74');  
         #  
       } else {  
         ## Generate implied end tags  
         while ({  
                 dd => 1, dt => 1, li => 1, p => 1,  
                }->{$self->{open_elements}->[-1]->[1]}) {  
           !!!cp ('t75');  
           pop @{$self->{open_elements}};  
         }  
           
         if (@{$self->{open_elements}} > 2 or  
             (@{$self->{open_elements}} == 2 and $self->{open_elements}->[1]->[1] ne 'body')) {  
           !!!cp ('t76');  
           !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
         } elsif (defined $self->{inner_html_node} and  
                  @{$self->{open_elements}} > 1 and  
                  $self->{open_elements}->[1]->[1] ne 'body') {  
 ## ISSUE: This case is never reached.  
           !!!cp ('t77');  
           !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);  
         } else {  
           !!!cp ('t78');  
         }  
   
         ## ISSUE: There is an issue in the spec.  
       }  
   
       ## Stop parsing  
       last B;  
3296      } elsif ($token->{type} == START_TAG_TOKEN and      } elsif ($token->{type} == START_TAG_TOKEN and
3297               $token->{tag_name} eq 'html') {               $token->{tag_name} eq 'html') {
3298        if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {        if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
# Line 3843  sub _tree_construction_main ($) { Line 3811  sub _tree_construction_main ($) {
3811              $self->{insertion_mode} = IN_BODY_IM;              $self->{insertion_mode} = IN_BODY_IM;
3812              ## reprocess              ## reprocess
3813              redo B;              redo B;
3814            } else {        } elsif ($token->{type} == END_OF_FILE_TOKEN) {
3815              die "$0: $token->{type}: Unknown token type";          if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
3816            }            !!!cp ('t149.1');
3817    
3818              ## NOTE: As if <head>
3819              !!!create-element ($self->{head_element}, 'head');
3820              $self->{open_elements}->[-1]->[0]->append_child
3821                  ($self->{head_element});
3822              #push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3823              #$self->{insertion_mode} = IN_HEAD_IM;
3824              ## NOTE: Reprocess.
3825    
3826              ## NOTE: As if </head>
3827              #pop @{$self->{open_elements}};
3828              #$self->{insertion_mode} = IN_AFTER_HEAD_IM;
3829              ## NOTE: Reprocess.
3830              
3831              #
3832            } elsif ($self->{insertion_mode} == IN_HEAD_IM) {
3833              !!!cp ('t149.2');
3834    
3835              ## NOTE: As if </head>
3836              pop @{$self->{open_elements}};
3837              #$self->{insertion_mode} = IN_AFTER_HEAD_IM;
3838              ## NOTE: Reprocess.
3839    
3840              #
3841            } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
3842              !!!cp ('t149.3');
3843    
3844              !!!parse-error (type => 'in noscript:#eof');
3845    
3846              ## As if </noscript>
3847              pop @{$self->{open_elements}};
3848              #$self->{insertion_mode} = IN_HEAD_IM;
3849              ## NOTE: Reprocess.
3850    
3851              ## NOTE: As if </head>
3852              pop @{$self->{open_elements}};
3853              #$self->{insertion_mode} = IN_AFTER_HEAD_IM;
3854              ## NOTE: Reprocess.
3855    
3856              #
3857            } else {
3858              !!!cp ('t149.4');
3859              #
3860            }
3861    
3862            ## NOTE: As if <body>
3863            !!!insert-element ('body');
3864            $self->{insertion_mode} = IN_BODY_IM;
3865            ## NOTE: Reprocess.
3866            redo B;
3867          } else {
3868            die "$0: $token->{type}: Unknown token type";
3869          }
3870    
3871            ## ISSUE: An issue in the spec.            ## ISSUE: An issue in the spec.
3872      } elsif ($self->{insertion_mode} & BODY_IMS) {      } elsif ($self->{insertion_mode} & BODY_IMS) {
# Line 4187  sub _tree_construction_main ($) { Line 4208  sub _tree_construction_main ($) {
4208                !!!cp ('t193');                !!!cp ('t193');
4209                #                #
4210              }              }
4211          } elsif ($token->{type} == END_OF_FILE_TOKEN) {
4212            for my $entry (@{$self->{open_elements}}) {
4213              if (not {
4214                dd => 1, dt => 1, li => 1, p => 1, tbody => 1, td => 1, tfoot => 1,
4215                th => 1, thead => 1, tr => 1, body => 1, html => 1,
4216              }->{$entry->[1]}) {
4217                !!!cp ('t75');
4218                !!!parse-error (type => 'in body:#eof');
4219                last;
4220              }
4221            }
4222    
4223            ## Stop parsing.
4224            last B;
4225        } else {        } else {
4226          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
4227        }        }
# Line 4863  sub _tree_construction_main ($) { Line 4898  sub _tree_construction_main ($) {
4898            $insert = $insert_to_foster;            $insert = $insert_to_foster;
4899            #            #
4900          }          }
4901          } elsif ($token->{type} == END_OF_FILE_TOKEN) {
4902            unless ($self->{open_elements}->[-1]->[1] eq 'html' and
4903                    @{$self->{open_elements}} == 1) { # redundant, maybe
4904              !!!cp ('t259.1');
4905              !!!parse-error (type => 'in body:#eof');
4906            } else {
4907              !!!cp ('t259.2');
4908            }
4909    
4910            ## Stop parsing
4911            last B;
4912        } else {        } else {
4913          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
4914        }        }
# Line 4915  sub _tree_construction_main ($) { Line 4961  sub _tree_construction_main ($) {
4961                !!!cp ('t267');                !!!cp ('t267');
4962                #                #
4963              }              }
4964            } else {        } elsif ($token->{type} == END_OF_FILE_TOKEN) {
4965              die "$0: $token->{type}: Unknown token type";          if ($self->{open_elements}->[-1]->[1] eq 'html' or
4966            }              @{$self->{open_elements}} == 1) { # redundant, maybe
4967              !!!cp ('t270.2');
4968              ## Stop parsing.
4969              last B;
4970            } else {
4971              ## NOTE: As if </colgroup>.
4972              !!!cp ('t270.1');
4973              pop @{$self->{open_elements}}; # colgroup
4974              $self->{insertion_mode} = IN_TABLE_IM;
4975              ## Reprocess.
4976              redo B;
4977            }
4978          } else {
4979            die "$0: $token->{type}: Unknown token type";
4980          }
4981    
4982            ## As if </colgroup>            ## As if </colgroup>
4983            if ($self->{open_elements}->[-1]->[1] eq 'html') {            if ($self->{open_elements}->[-1]->[1] eq 'html') {
4984              !!!cp ('t269');              !!!cp ('t269');
4985    ## TODO: Wrong error type?
4986              !!!parse-error (type => 'unmatched end tag:colgroup');              !!!parse-error (type => 'unmatched end tag:colgroup');
4987              ## Ignore the token              ## Ignore the token
4988              !!!next-token;              !!!next-token;
# Line 5157  sub _tree_construction_main ($) { Line 5218  sub _tree_construction_main ($) {
5218            !!!next-token;            !!!next-token;
5219            redo B;            redo B;
5220          }          }
5221          } elsif ($token->{type} == END_OF_FILE_TOKEN) {
5222            unless ($self->{open_elements}->[-1]->[1] eq 'html' and
5223                    @{$self->{open_elements}} == 1) { # redundant, maybe
5224              !!!cp ('t299.1');
5225              !!!parse-error (type => 'in body:#eof');
5226            } else {
5227              !!!cp ('t299.2');
5228            }
5229    
5230            ## Stop parsing.
5231            last B;
5232        } else {        } else {
5233          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
5234        }        }
# Line 5240  sub _tree_construction_main ($) { Line 5312  sub _tree_construction_main ($) {
5312            ## reprocess            ## reprocess
5313            redo B;            redo B;
5314          }          }
5315          } elsif ($token->{type} == END_OF_FILE_TOKEN) {
5316            !!!cp ('t309.2');
5317            ## Stop parsing
5318            last B;
5319        } else {        } else {
5320          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
5321        }        }
# Line 5375  sub _tree_construction_main ($) { Line 5451  sub _tree_construction_main ($) {
5451            !!!next-token;            !!!next-token;
5452            redo B;            redo B;
5453          }          }
5454          } elsif ($token->{type} == END_OF_FILE_TOKEN) {
5455            unless ($self->{open_elements}->[-1]->[1] eq 'html' and
5456                    @{$self->{open_elements}} == 1) { # redundant, maybe
5457              !!!cp ('t331.1');
5458              !!!parse-error (type => 'in body:#eof');
5459            } else {
5460              !!!cp ('t331.2');
5461            }
5462            
5463            ## Stop parsing
5464            last B;
5465        } else {        } else {
5466          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
5467        }        }
# Line 5495  sub _tree_construction_main ($) { Line 5582  sub _tree_construction_main ($) {
5582              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5583              redo B;              redo B;
5584            } elsif ({            } elsif ({
5585                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5586                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5587                     }->{$_->[1]}) {                     }->{$_->[1]}) {
5588              !!!cp ('t345');              !!!cp ('t345');
# Line 5538  sub _tree_construction_main ($) { Line 5625  sub _tree_construction_main ($) {
5625                $token = {type => END_TAG_TOKEN, tag_name => 'p'};                $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5626                redo B;                redo B;
5627              } elsif ({              } elsif ({
5628                        table => 1, caption => 1, td => 1, th => 1,                        applet => 1, table => 1, caption => 1, td => 1, th => 1,
5629                        button => 1, marquee => 1, object => 1, html => 1,                        button => 1, marquee => 1, object => 1, html => 1,
5630                       }->{$_->[1]}) {                       }->{$_->[1]}) {
5631                !!!cp ('t352');                !!!cp ('t352');
# Line 5560  sub _tree_construction_main ($) { Line 5647  sub _tree_construction_main ($) {
5647              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5648              redo B;              redo B;
5649            } elsif ({            } elsif ({
5650                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5651                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5652                     }->{$_->[1]}) {                     }->{$_->[1]}) {
5653              !!!cp ('t354');              !!!cp ('t354');
# Line 5616  sub _tree_construction_main ($) { Line 5703  sub _tree_construction_main ($) {
5703              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5704              redo B;              redo B;
5705            } elsif ({            } elsif ({
5706                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5707                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5708                     }->{$_->[1]}) {                     }->{$_->[1]}) {
5709              !!!cp ('t361');              !!!cp ('t361');
# Line 5672  sub _tree_construction_main ($) { Line 5759  sub _tree_construction_main ($) {
5759              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5760              redo B;              redo B;
5761            } elsif ({            } elsif ({
5762                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5763                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5764                     }->{$_->[1]}) {                     }->{$_->[1]}) {
5765              !!!cp ('t368');              !!!cp ('t368');
# Line 5751  sub _tree_construction_main ($) { Line 5838  sub _tree_construction_main ($) {
5838              $token = {type => END_TAG_TOKEN, tag_name => 'nobr'};              $token = {type => END_TAG_TOKEN, tag_name => 'nobr'};
5839              redo B;              redo B;
5840            } elsif ({            } elsif ({
5841                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5842                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5843                     }->{$node->[1]}) {                     }->{$node->[1]}) {
5844              !!!cp ('t377');              !!!cp ('t377');
# Line 5775  sub _tree_construction_main ($) { Line 5862  sub _tree_construction_main ($) {
5862              $token = {type => END_TAG_TOKEN, tag_name => 'button'};              $token = {type => END_TAG_TOKEN, tag_name => 'button'};
5863              redo B;              redo B;
5864            } elsif ({            } elsif ({
5865                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5866                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5867                     }->{$node->[1]}) {                     }->{$node->[1]}) {
5868              !!!cp ('t379');              !!!cp ('t379');
# Line 5793  sub _tree_construction_main ($) { Line 5880  sub _tree_construction_main ($) {
5880    
5881          !!!next-token;          !!!next-token;
5882          redo B;          redo B;
5883        } elsif ($token->{tag_name} eq 'marquee' or        } elsif ({
5884                 $token->{tag_name} eq 'object') {                  applet => 1, marquee => 1, object => 1,
5885                   }->{$token->{tag_name}}) {
5886          !!!cp ('t380');          !!!cp ('t380');
5887          $reconstruct_active_formatting_elements->($insert_to_current);          $reconstruct_active_formatting_elements->($insert_to_current);
5888                    
# Line 5817  sub _tree_construction_main ($) { Line 5905  sub _tree_construction_main ($) {
5905              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5906              redo B;              redo B;
5907            } elsif ({            } elsif ({
5908                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5909                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5910                     }->{$_->[1]}) {                     }->{$_->[1]}) {
5911              !!!cp ('t383');              !!!cp ('t383');
# Line 5862  sub _tree_construction_main ($) { Line 5950  sub _tree_construction_main ($) {
5950              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5951              redo B;              redo B;
5952            } elsif ({            } elsif ({
5953                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5954                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5955                     }->{$_->[1]}) {                     }->{$_->[1]}) {
5956              !!!cp ('t387');              !!!cp ('t387');
# Line 6076  sub _tree_construction_main ($) { Line 6164  sub _tree_construction_main ($) {
6164                  div => 1, dl => 1, fieldset => 1, listing => 1,                  div => 1, dl => 1, fieldset => 1, listing => 1,
6165                  menu => 1, ol => 1, pre => 1, ul => 1,                  menu => 1, ol => 1, pre => 1, ul => 1,
6166                  dd => 1, dt => 1, li => 1,                  dd => 1, dt => 1, li => 1,
6167                  button => 1, marquee => 1, object => 1,                  applet => 1, button => 1, marquee => 1, object => 1,
6168                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
6169          ## has an element in scope          ## has an element in scope
6170          my $i;          my $i;
# Line 6087  sub _tree_construction_main ($) { Line 6175  sub _tree_construction_main ($) {
6175              $i = $_;              $i = $_;
6176              last INSCOPE;              last INSCOPE;
6177            } elsif ({            } elsif ({
6178                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
6179                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
6180                     }->{$node->[1]}) {                     }->{$node->[1]}) {
6181              !!!cp ('t411');              !!!cp ('t411');
# Line 6124  sub _tree_construction_main ($) { Line 6212  sub _tree_construction_main ($) {
6212            ## Step 4.            ## Step 4.
6213            $clear_up_to_marker->()            $clear_up_to_marker->()
6214                if {                if {
6215                  button => 1, marquee => 1, object => 1,                  applet => 1, button => 1, marquee => 1, object => 1,
6216                }->{$token->{tag_name}};                }->{$token->{tag_name}};
6217          }          }
6218          !!!next-token;          !!!next-token;
# Line 6141  sub _tree_construction_main ($) { Line 6229  sub _tree_construction_main ($) {
6229              $i = $_;              $i = $_;
6230              last INSCOPE;              last INSCOPE;
6231            } elsif ({            } elsif ({
6232                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
6233                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
6234                     }->{$node->[1]}) {                     }->{$node->[1]}) {
6235              !!!cp ('t419');              !!!cp ('t419');
# Line 6189  sub _tree_construction_main ($) { Line 6277  sub _tree_construction_main ($) {
6277              $i = $_;              $i = $_;
6278              last INSCOPE;              last INSCOPE;
6279            } elsif ({            } elsif ({
6280                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
6281                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
6282                     }->{$node->[1]}) {                     }->{$node->[1]}) {
6283              !!!cp ('t424');              !!!cp ('t424');
# Line 6233  sub _tree_construction_main ($) { Line 6321  sub _tree_construction_main ($) {
6321              $i = $_;              $i = $_;
6322              last INSCOPE;              last INSCOPE;
6323            } elsif ({            } elsif ({
6324                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
6325                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
6326                     }->{$node->[1]}) {                     }->{$node->[1]}) {
6327              !!!cp ('t411.1');              !!!cp ('t411.1');

Legend:
Removed from v.1.102  
changed lines
  Added in v.1.104

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24