/[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.96 by wakaba, Sat Mar 8 13:26:45 2008 UTC revision 1.106 by wakaba, Sun Mar 9 10:31:19 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 303  sub TABLE_IMS ()      { 0b1000000 } Line 303  sub TABLE_IMS ()      { 0b1000000 }
303  sub ROW_IMS ()        { 0b10000000 }  sub ROW_IMS ()        { 0b10000000 }
304  sub BODY_AFTER_IMS () { 0b100000000 }  sub BODY_AFTER_IMS () { 0b100000000 }
305  sub FRAME_IMS ()      { 0b1000000000 }  sub FRAME_IMS ()      { 0b1000000000 }
306    sub SELECT_IMS ()     { 0b10000000000 }
307    
308  ## NOTE: "initial" and "before html" insertion modes have no constants.  ## NOTE: "initial" and "before html" insertion modes have no constants.
309    
# Line 325  sub IN_TABLE_IM () { TABLE_IMS } Line 326  sub IN_TABLE_IM () { TABLE_IMS }
326  sub AFTER_BODY_IM () { BODY_AFTER_IMS }  sub AFTER_BODY_IM () { BODY_AFTER_IMS }
327  sub IN_FRAMESET_IM () { FRAME_IMS | 0b01 }  sub IN_FRAMESET_IM () { FRAME_IMS | 0b01 }
328  sub AFTER_FRAMESET_IM () { FRAME_IMS | 0b10 }  sub AFTER_FRAMESET_IM () { FRAME_IMS | 0b10 }
329  sub IN_SELECT_IM () { 0b01 }  sub IN_SELECT_IM () { SELECT_IMS | 0b01 }
330    sub IN_SELECT_IN_TABLE_IM () { SELECT_IMS | 0b10 }
331  sub IN_COLUMN_GROUP_IM () { 0b10 }  sub IN_COLUMN_GROUP_IM () { 0b10 }
332    
333  ## Implementations MUST act as if state machine in the spec  ## Implementations MUST act as if state machine in the spec
# Line 3010  sub _tree_construction_main ($) { Line 3012  sub _tree_construction_main ($) {
3012      !!!next-token;      !!!next-token;
3013    }; # $script_start_tag    }; # $script_start_tag
3014    
3015      ## NOTE: $open_tables->[-1]->[0] is the "current table" element node.
3016      ## NOTE: $open_tables->[-1]->[1] is the "tainted" flag.
3017      my $open_tables = [[$self->{open_elements}->[0]->[0]]];
3018    
3019    my $formatting_end_tag = sub {    my $formatting_end_tag = sub {
3020      my $tag_name = shift;      my $tag_name = shift;
3021    
3022        ## NOTE: The adoption agency algorithm (AAA).
3023    
3024      FET: {      FET: {
3025        ## Step 1        ## Step 1
3026        my $formatting_element;        my $formatting_element;
# Line 3053  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 3080  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 3166  sub _tree_construction_main ($) { Line 3174  sub _tree_construction_main ($) {
3174        } # S7          } # S7  
3175                
3176        ## Step 8        ## Step 8
3177        $common_ancestor_node->[0]->append_child ($last_node->[0]);        if ({
3178               table => 1, tbody => 1, tfoot => 1, thead => 1, tr => 1,
3179              }->{$common_ancestor_node->[1]}) {
3180            my $foster_parent_element;
3181            my $next_sibling;
3182                             OE: for (reverse 0..$#{$self->{open_elements}}) {
3183                               if ($self->{open_elements}->[$_]->[1] eq 'table') {
3184                                 my $parent = $self->{open_elements}->[$_]->[0]->parent_node;
3185                                 if (defined $parent and $parent->node_type == 1) {
3186                                   !!!cp ('t65.1');
3187                                   $foster_parent_element = $parent;
3188                                   $next_sibling = $self->{open_elements}->[$_]->[0];
3189                                 } else {
3190                                   !!!cp ('t65.2');
3191                                   $foster_parent_element
3192                                     = $self->{open_elements}->[$_ - 1]->[0];
3193                                 }
3194                                 last OE;
3195                               }
3196                             } # OE
3197                             $foster_parent_element = $self->{open_elements}->[0]->[0]
3198                               unless defined $foster_parent_element;
3199            $foster_parent_element->insert_before ($last_node->[0], $next_sibling);
3200            $open_tables->[-1]->[1] = 1; # tainted
3201          } else {
3202            !!!cp ('t65.3');
3203            $common_ancestor_node->[0]->append_child ($last_node->[0]);
3204          }
3205                
3206        ## Step 9        ## Step 9
3207        my $clone = [$formatting_element->[0]->clone_node (0),        my $clone = [$formatting_element->[0]->clone_node (0),
# Line 3212  sub _tree_construction_main ($) { Line 3247  sub _tree_construction_main ($) {
3247      } # FET      } # FET
3248    }; # $formatting_end_tag    }; # $formatting_end_tag
3249    
   ## NOTE: $open_tables->[-1]->[0] is the "current table".  
   ## NOTE: $open_tables->[-1]->[1] is the "tainted" flag.  
   my $open_tables = [[$self->{open_elements}->[0]->[0]]];  
   
3250    $insert = my $insert_to_current = sub {    $insert = my $insert_to_current = sub {
3251      $self->{open_elements}->[-1]->[0]->append_child ($_[0]);      $self->{open_elements}->[-1]->[0]->append_child ($_[0]);
3252    }; # $insert_to_current    }; # $insert_to_current
# Line 3262  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 3338  sub _tree_construction_main ($) { Line 3337  sub _tree_construction_main ($) {
3337      } elsif ($self->{insertion_mode} & HEAD_IMS) {      } elsif ($self->{insertion_mode} & HEAD_IMS) {
3338        if ($token->{type} == CHARACTER_TOKEN) {        if ($token->{type} == CHARACTER_TOKEN) {
3339          if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {          if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {
3340            $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);            unless ($self->{insertion_mode} == BEFORE_HEAD_IM) {
3341                !!!cp ('t88.2');
3342                $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);
3343              } else {
3344                !!!cp ('t88.1');
3345                ## Ignore the token.
3346                !!!next-token;
3347                redo B;
3348              }
3349            unless (length $token->{data}) {            unless (length $token->{data}) {
3350              !!!cp ('t88');              !!!cp ('t88');
3351              !!!next-token;              !!!next-token;
# Line 3439  sub _tree_construction_main ($) { Line 3446  sub _tree_construction_main ($) {
3446                }                }
3447                !!!insert-element ($token->{tag_name}, $token->{attributes});                !!!insert-element ($token->{tag_name}, $token->{attributes});
3448                pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.                pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
3449                pop @{$self->{open_elements}}                pop @{$self->{open_elements}} # <head>
3450                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
3451                !!!next-token;                !!!next-token;
3452                redo B;                redo B;
# Line 3454  sub _tree_construction_main ($) { Line 3461  sub _tree_construction_main ($) {
3461                }                }
3462                !!!insert-element ($token->{tag_name}, $token->{attributes});                !!!insert-element ($token->{tag_name}, $token->{attributes});
3463                pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.                pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
3464                pop @{$self->{open_elements}}                pop @{$self->{open_elements}} # <head>
3465                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
3466                !!!next-token;                !!!next-token;
3467                redo B;                redo B;
# Line 3515  sub _tree_construction_main ($) { Line 3522  sub _tree_construction_main ($) {
3522                  }                  }
3523                }                }
3524    
3525                pop @{$self->{open_elements}}                pop @{$self->{open_elements}} # <head>
3526                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
3527                !!!next-token;                !!!next-token;
3528                redo B;                redo B;
# Line 3540  sub _tree_construction_main ($) { Line 3547  sub _tree_construction_main ($) {
3547                my $parent = defined $self->{head_element} ? $self->{head_element}                my $parent = defined $self->{head_element} ? $self->{head_element}
3548                    : $self->{open_elements}->[-1]->[0];                    : $self->{open_elements}->[-1]->[0];
3549                $parse_rcdata->(RCDATA_CONTENT_MODEL);                $parse_rcdata->(RCDATA_CONTENT_MODEL);
3550                pop @{$self->{open_elements}}                pop @{$self->{open_elements}} # <head>
3551                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
3552                redo B;                redo B;
3553              } elsif ($token->{tag_name} eq 'style') {              } elsif ($token->{tag_name} eq 'style') {
# Line 3555  sub _tree_construction_main ($) { Line 3562  sub _tree_construction_main ($) {
3562                  !!!cp ('t115');                  !!!cp ('t115');
3563                }                }
3564                $parse_rcdata->(CDATA_CONTENT_MODEL);                $parse_rcdata->(CDATA_CONTENT_MODEL);
3565                pop @{$self->{open_elements}}                pop @{$self->{open_elements}} # <head>
3566                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
3567                redo B;                redo B;
3568              } elsif ($token->{tag_name} eq 'noscript') {              } elsif ($token->{tag_name} eq 'noscript') {
# Line 3594  sub _tree_construction_main ($) { Line 3601  sub _tree_construction_main ($) {
3601                }                }
3602    
3603                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
3604                $script_start_tag->($insert_to_current);                $script_start_tag->();
3605                pop @{$self->{open_elements}}                pop @{$self->{open_elements}} # <head>
3606                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
3607                redo B;                redo B;
3608              } elsif ($token->{tag_name} eq 'body' or              } elsif ($token->{tag_name} eq 'body' or
# Line 3804  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 4148  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 4461  sub _tree_construction_main ($) { Line 4535  sub _tree_construction_main ($) {
4535                  redo B;                  redo B;
4536                }                }
4537                                
4538    ## TODO: Followings are removed from the latest spec.
4539                ## generate implied end tags                ## generate implied end tags
4540                while ({                while ({
4541                        dd => 1, dt => 1, li => 1, p => 1,                        dd => 1, dt => 1, li => 1, p => 1,
# Line 4484  sub _tree_construction_main ($) { Line 4559  sub _tree_construction_main ($) {
4559    
4560                ## reprocess                ## reprocess
4561                redo B;                redo B;
4562            } elsif ($token->{tag_name} eq 'style') {
4563              if (not $open_tables->[-1]->[1]) { # tainted
4564                !!!cp ('t227.8');
4565                ## NOTE: This is a "as if in head" code clone.
4566                $parse_rcdata->(CDATA_CONTENT_MODEL);
4567                redo B;
4568              } else {
4569                !!!cp ('t227.7');
4570                #
4571              }
4572            } elsif ($token->{tag_name} eq 'script') {
4573              if (not $open_tables->[-1]->[1]) { # tainted
4574                !!!cp ('t227.6');
4575                ## NOTE: This is a "as if in head" code clone.
4576                $script_start_tag->();
4577                redo B;
4578              } else {
4579                !!!cp ('t227.5');
4580                #
4581              }
4582            } elsif ($token->{tag_name} eq 'input') {
4583              if (not $open_tables->[-1]->[1]) { # tainted
4584                if ($token->{attributes}->{type}) { ## TODO: case
4585                  my $type = lc $token->{attributes}->{type}->{value};
4586                  if ($type eq 'hidden') {
4587                    !!!cp ('t227.3');
4588                    !!!parse-error (type => 'in table:'.$token->{tag_name});
4589    
4590                    !!!insert-element ($token->{tag_name}, $token->{attributes});
4591    
4592                    ## TODO: form element pointer
4593    
4594                    pop @{$self->{open_elements}};
4595    
4596                    !!!next-token;
4597                    redo B;
4598                  } else {
4599                    !!!cp ('t227.2');
4600                    #
4601                  }
4602                } else {
4603                  !!!cp ('t227.1');
4604                  #
4605                }
4606              } else {
4607                !!!cp ('t227.4');
4608                #
4609              }
4610          } else {          } else {
4611            !!!cp ('t227');            !!!cp ('t227');
           !!!parse-error (type => 'in table:'.$token->{tag_name});  
   
           $insert = $insert_to_foster;  
4612            #            #
4613          }          }
4614    
4615            !!!parse-error (type => 'in table:'.$token->{tag_name});
4616    
4617            $insert = $insert_to_foster;
4618            #
4619        } elsif ($token->{type} == END_TAG_TOKEN) {        } elsif ($token->{type} == END_TAG_TOKEN) {
4620              if ($token->{tag_name} eq 'tr' and              if ($token->{tag_name} eq 'tr' and
4621                  $self->{insertion_mode} == IN_ROW_IM) {                  $self->{insertion_mode} == IN_ROW_IM) {
# Line 4774  sub _tree_construction_main ($) { Line 4899  sub _tree_construction_main ($) {
4899            $insert = $insert_to_foster;            $insert = $insert_to_foster;
4900            #            #
4901          }          }
4902          } elsif ($token->{type} == END_OF_FILE_TOKEN) {
4903            unless ($self->{open_elements}->[-1]->[1] eq 'html' and
4904                    @{$self->{open_elements}} == 1) { # redundant, maybe
4905              !!!parse-error (type => 'in body:#eof');
4906              !!!cp ('t259.1');
4907              #
4908            } else {
4909              !!!cp ('t259.2');
4910              #
4911            }
4912    
4913            ## Stop parsing
4914            last B;
4915        } else {        } else {
4916          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
4917        }        }
# Line 4826  sub _tree_construction_main ($) { Line 4964  sub _tree_construction_main ($) {
4964                !!!cp ('t267');                !!!cp ('t267');
4965                #                #
4966              }              }
4967            } else {        } elsif ($token->{type} == END_OF_FILE_TOKEN) {
4968              die "$0: $token->{type}: Unknown token type";          if ($self->{open_elements}->[-1]->[1] eq 'html' or
4969            }              @{$self->{open_elements}} == 1) { # redundant, maybe
4970              !!!cp ('t270.2');
4971              ## Stop parsing.
4972              last B;
4973            } else {
4974              ## NOTE: As if </colgroup>.
4975              !!!cp ('t270.1');
4976              pop @{$self->{open_elements}}; # colgroup
4977              $self->{insertion_mode} = IN_TABLE_IM;
4978              ## Reprocess.
4979              redo B;
4980            }
4981          } else {
4982            die "$0: $token->{type}: Unknown token type";
4983          }
4984    
4985            ## As if </colgroup>            ## As if </colgroup>
4986            if ($self->{open_elements}->[-1]->[1] eq 'html') {            if ($self->{open_elements}->[-1]->[1] eq 'html') {
4987              !!!cp ('t269');              !!!cp ('t269');
4988    ## TODO: Wrong error type?
4989              !!!parse-error (type => 'unmatched end tag:colgroup');              !!!parse-error (type => 'unmatched end tag:colgroup');
4990              ## Ignore the token              ## Ignore the token
4991              !!!next-token;              !!!next-token;
# Line 4844  sub _tree_construction_main ($) { Line 4997  sub _tree_construction_main ($) {
4997              ## reprocess              ## reprocess
4998              redo B;              redo B;
4999            }            }
5000      } elsif ($self->{insertion_mode} == IN_SELECT_IM) {      } elsif ($self->{insertion_mode} & SELECT_IMS) {
5001        if ($token->{type} == CHARACTER_TOKEN) {        if ($token->{type} == CHARACTER_TOKEN) {
5002          !!!cp ('t271');          !!!cp ('t271');
5003          $self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data});          $self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data});
# Line 4883  sub _tree_construction_main ($) { Line 5036  sub _tree_construction_main ($) {
5036                !!!insert-element ($token->{tag_name}, $token->{attributes});                !!!insert-element ($token->{tag_name}, $token->{attributes});
5037                !!!next-token;                !!!next-token;
5038                redo B;                redo B;
5039              } elsif ($token->{tag_name} eq 'select') {          } elsif ($token->{tag_name} eq 'select' or
5040  ## TODO: The type below is not good - <select> is replaced by </select>                   $token->{tag_name} eq 'input' or
5041                !!!parse-error (type => 'not closed:select');                   ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and
5042                ## As if </select> instead                    {
5043                       caption => 1, table => 1,
5044                       tbody => 1, tfoot => 1, thead => 1,
5045                       tr => 1, td => 1, th => 1,
5046                      }->{$token->{tag_name}})) {
5047              ## TODO: The type below is not good - <select> is replaced by </select>
5048              !!!parse-error (type => 'not closed:select');
5049              ## NOTE: As if the token were </select> (<select> case) or
5050              ## as if there were </select> (otherwise).
5051                ## have an element in table scope                ## have an element in table scope
5052                my $i;                my $i;
5053                INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {                INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
5054                  my $node = $self->{open_elements}->[$_];                  my $node = $self->{open_elements}->[$_];
5055                  if ($node->[1] eq $token->{tag_name}) {                  if ($node->[1] eq 'select') {
5056                    !!!cp ('t278');                    !!!cp ('t278');
5057                    $i = $_;                    $i = $_;
5058                    last INSCOPE;                    last INSCOPE;
# Line 4915  sub _tree_construction_main ($) { Line 5076  sub _tree_construction_main ($) {
5076    
5077                $self->_reset_insertion_mode;                $self->_reset_insertion_mode;
5078    
5079                !!!next-token;            if ($token->{tag_name} eq 'select') {
5080                redo B;              !!!cp ('t281.2');
5081                !!!next-token;
5082                redo B;
5083              } else {
5084                !!!cp ('t281.1');
5085                ## Reprocess the token.
5086                redo B;
5087              }
5088          } else {          } else {
5089            !!!cp ('t282');            !!!cp ('t282');
5090            !!!parse-error (type => 'in select:'.$token->{tag_name});            !!!parse-error (type => 'in select:'.$token->{tag_name});
# Line 4983  sub _tree_construction_main ($) { Line 5151  sub _tree_construction_main ($) {
5151    
5152                !!!next-token;                !!!next-token;
5153                redo B;                redo B;
5154              } elsif ({          } elsif ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and
5155                        caption => 1, table => 1, tbody => 1,                   {
5156                        tfoot => 1, thead => 1, tr => 1, td => 1, th => 1,                    caption => 1, table => 1, tbody => 1,
5157                       }->{$token->{tag_name}}) {                    tfoot => 1, thead => 1, tr => 1, td => 1, th => 1,
5158                     }->{$token->{tag_name}}) {
5159  ## TODO: The following is wrong?  ## TODO: The following is wrong?
5160                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
5161                                
# Line 5052  sub _tree_construction_main ($) { Line 5221  sub _tree_construction_main ($) {
5221            !!!next-token;            !!!next-token;
5222            redo B;            redo B;
5223          }          }
5224          } elsif ($token->{type} == END_OF_FILE_TOKEN) {
5225            unless ($self->{open_elements}->[-1]->[1] eq 'html' and
5226                    @{$self->{open_elements}} == 1) { # redundant, maybe
5227              !!!cp ('t299.1');
5228              !!!parse-error (type => 'in body:#eof');
5229            } else {
5230              !!!cp ('t299.2');
5231            }
5232    
5233            ## Stop parsing.
5234            last B;
5235        } else {        } else {
5236          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
5237        }        }
# Line 5135  sub _tree_construction_main ($) { Line 5315  sub _tree_construction_main ($) {
5315            ## reprocess            ## reprocess
5316            redo B;            redo B;
5317          }          }
5318          } elsif ($token->{type} == END_OF_FILE_TOKEN) {
5319            !!!cp ('t309.2');
5320            ## Stop parsing
5321            last B;
5322        } else {        } else {
5323          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
5324        }        }
# Line 5270  sub _tree_construction_main ($) { Line 5454  sub _tree_construction_main ($) {
5454            !!!next-token;            !!!next-token;
5455            redo B;            redo B;
5456          }          }
5457          } elsif ($token->{type} == END_OF_FILE_TOKEN) {
5458            unless ($self->{open_elements}->[-1]->[1] eq 'html' and
5459                    @{$self->{open_elements}} == 1) { # redundant, maybe
5460              !!!cp ('t331.1');
5461              !!!parse-error (type => 'in body:#eof');
5462            } else {
5463              !!!cp ('t331.2');
5464            }
5465            
5466            ## Stop parsing
5467            last B;
5468        } else {        } else {
5469          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
5470        }        }
# Line 5284  sub _tree_construction_main ($) { Line 5479  sub _tree_construction_main ($) {
5479        if ($token->{tag_name} eq 'script') {        if ($token->{tag_name} eq 'script') {
5480          !!!cp ('t332');          !!!cp ('t332');
5481          ## NOTE: This is an "as if in head" code clone          ## NOTE: This is an "as if in head" code clone
5482          $script_start_tag->($insert);          $script_start_tag->();
5483          redo B;          redo B;
5484        } elsif ($token->{tag_name} eq 'style') {        } elsif ($token->{tag_name} eq 'style') {
5485          !!!cp ('t333');          !!!cp ('t333');
# Line 5379  sub _tree_construction_main ($) { Line 5574  sub _tree_construction_main ($) {
5574                  address => 1, blockquote => 1, center => 1, dir => 1,                  address => 1, blockquote => 1, center => 1, dir => 1,
5575                  div => 1, dl => 1, fieldset => 1,                  div => 1, dl => 1, fieldset => 1,
5576                  h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,                  h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,
5577                  listing => 1, menu => 1, ol => 1, p => 1, ul => 1,                  menu => 1, ol => 1, p => 1, ul => 1,
5578                  pre => 1,                  pre => 1, listing => 1,
5579                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
5580          ## has a p element in scope          ## has a p element in scope
5581          INSCOPE: for (reverse @{$self->{open_elements}}) {          INSCOPE: for (reverse @{$self->{open_elements}}) {
# Line 5390  sub _tree_construction_main ($) { Line 5585  sub _tree_construction_main ($) {
5585              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5586              redo B;              redo B;
5587            } elsif ({            } elsif ({
5588                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5589                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5590                     }->{$_->[1]}) {                     }->{$_->[1]}) {
5591              !!!cp ('t345');              !!!cp ('t345');
# Line 5399  sub _tree_construction_main ($) { Line 5594  sub _tree_construction_main ($) {
5594          } # INSCOPE          } # INSCOPE
5595                        
5596          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes});
5597          if ($token->{tag_name} eq 'pre') {          if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') {
5598            !!!next-token;            !!!next-token;
5599            if ($token->{type} == CHARACTER_TOKEN) {            if ($token->{type} == CHARACTER_TOKEN) {
5600              $token->{data} =~ s/^\x0A//;              $token->{data} =~ s/^\x0A//;
# Line 5433  sub _tree_construction_main ($) { Line 5628  sub _tree_construction_main ($) {
5628                $token = {type => END_TAG_TOKEN, tag_name => 'p'};                $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5629                redo B;                redo B;
5630              } elsif ({              } elsif ({
5631                        table => 1, caption => 1, td => 1, th => 1,                        applet => 1, table => 1, caption => 1, td => 1, th => 1,
5632                        button => 1, marquee => 1, object => 1, html => 1,                        button => 1, marquee => 1, object => 1, html => 1,
5633                       }->{$_->[1]}) {                       }->{$_->[1]}) {
5634                !!!cp ('t352');                !!!cp ('t352');
# Line 5455  sub _tree_construction_main ($) { Line 5650  sub _tree_construction_main ($) {
5650              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5651              redo B;              redo B;
5652            } elsif ({            } elsif ({
5653                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5654                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5655                     }->{$_->[1]}) {                     }->{$_->[1]}) {
5656              !!!cp ('t354');              !!!cp ('t354');
# Line 5511  sub _tree_construction_main ($) { Line 5706  sub _tree_construction_main ($) {
5706              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5707              redo B;              redo B;
5708            } elsif ({            } elsif ({
5709                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5710                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5711                     }->{$_->[1]}) {                     }->{$_->[1]}) {
5712              !!!cp ('t361');              !!!cp ('t361');
# Line 5567  sub _tree_construction_main ($) { Line 5762  sub _tree_construction_main ($) {
5762              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5763              redo B;              redo B;
5764            } elsif ({            } elsif ({
5765                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5766                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5767                     }->{$_->[1]}) {                     }->{$_->[1]}) {
5768              !!!cp ('t368');              !!!cp ('t368');
# Line 5646  sub _tree_construction_main ($) { Line 5841  sub _tree_construction_main ($) {
5841              $token = {type => END_TAG_TOKEN, tag_name => 'nobr'};              $token = {type => END_TAG_TOKEN, tag_name => 'nobr'};
5842              redo B;              redo B;
5843            } elsif ({            } elsif ({
5844                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5845                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5846                     }->{$node->[1]}) {                     }->{$node->[1]}) {
5847              !!!cp ('t377');              !!!cp ('t377');
# Line 5670  sub _tree_construction_main ($) { Line 5865  sub _tree_construction_main ($) {
5865              $token = {type => END_TAG_TOKEN, tag_name => 'button'};              $token = {type => END_TAG_TOKEN, tag_name => 'button'};
5866              redo B;              redo B;
5867            } elsif ({            } elsif ({
5868                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5869                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5870                     }->{$node->[1]}) {                     }->{$node->[1]}) {
5871              !!!cp ('t379');              !!!cp ('t379');
# Line 5688  sub _tree_construction_main ($) { Line 5883  sub _tree_construction_main ($) {
5883    
5884          !!!next-token;          !!!next-token;
5885          redo B;          redo B;
5886        } elsif ($token->{tag_name} eq 'marquee' or        } elsif ({
5887                 $token->{tag_name} eq 'object') {                  applet => 1, marquee => 1, object => 1,
5888                   }->{$token->{tag_name}}) {
5889          !!!cp ('t380');          !!!cp ('t380');
5890          $reconstruct_active_formatting_elements->($insert_to_current);          $reconstruct_active_formatting_elements->($insert_to_current);
5891                    
# Line 5712  sub _tree_construction_main ($) { Line 5908  sub _tree_construction_main ($) {
5908              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5909              redo B;              redo B;
5910            } elsif ({            } elsif ({
5911                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5912                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5913                     }->{$_->[1]}) {                     }->{$_->[1]}) {
5914              !!!cp ('t383');              !!!cp ('t383');
# Line 5757  sub _tree_construction_main ($) { Line 5953  sub _tree_construction_main ($) {
5953              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5954              redo B;              redo B;
5955            } elsif ({            } elsif ({
5956                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5957                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5958                     }->{$_->[1]}) {                     }->{$_->[1]}) {
5959              !!!cp ('t387');              !!!cp ('t387');
# Line 5887  sub _tree_construction_main ($) { Line 6083  sub _tree_construction_main ($) {
6083    
6084          ## TODO: associate with $self->{form_element} if defined          ## TODO: associate with $self->{form_element} if defined
6085                    
6086          $self->{insertion_mode} = IN_SELECT_IM;          if ($self->{insertion_mode} & TABLE_IMS or
6087                $self->{insertion_mode} & BODY_TABLE_IMS or
6088                $self->{insertion_mode} == IN_COLUMN_GROUP_IM) {
6089              !!!cp ('t400.1');
6090              $self->{insertion_mode} = IN_SELECT_IN_TABLE_IM;
6091            } else {
6092              !!!cp ('t400.2');
6093              $self->{insertion_mode} = IN_SELECT_IM;
6094            }
6095          !!!next-token;          !!!next-token;
6096          redo B;          redo B;
6097        } elsif ({        } elsif ({
# Line 5963  sub _tree_construction_main ($) { Line 6167  sub _tree_construction_main ($) {
6167                  div => 1, dl => 1, fieldset => 1, listing => 1,                  div => 1, dl => 1, fieldset => 1, listing => 1,
6168                  menu => 1, ol => 1, pre => 1, ul => 1,                  menu => 1, ol => 1, pre => 1, ul => 1,
6169                  dd => 1, dt => 1, li => 1,                  dd => 1, dt => 1, li => 1,
6170                  button => 1, marquee => 1, object => 1,                  applet => 1, button => 1, marquee => 1, object => 1,
6171                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
6172          ## has an element in scope          ## has an element in scope
6173          my $i;          my $i;
# Line 5974  sub _tree_construction_main ($) { Line 6178  sub _tree_construction_main ($) {
6178              $i = $_;              $i = $_;
6179              last INSCOPE;              last INSCOPE;
6180            } elsif ({            } elsif ({
6181                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
6182                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
6183                     }->{$node->[1]}) {                     }->{$node->[1]}) {
6184              !!!cp ('t411');              !!!cp ('t411');
# Line 6011  sub _tree_construction_main ($) { Line 6215  sub _tree_construction_main ($) {
6215            ## Step 4.            ## Step 4.
6216            $clear_up_to_marker->()            $clear_up_to_marker->()
6217                if {                if {
6218                  button => 1, marquee => 1, object => 1,                  applet => 1, button => 1, marquee => 1, object => 1,
6219                }->{$token->{tag_name}};                }->{$token->{tag_name}};
6220          }          }
6221          !!!next-token;          !!!next-token;
# Line 6028  sub _tree_construction_main ($) { Line 6232  sub _tree_construction_main ($) {
6232              $i = $_;              $i = $_;
6233              last INSCOPE;              last INSCOPE;
6234            } elsif ({            } elsif ({
6235                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
6236                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
6237                     }->{$node->[1]}) {                     }->{$node->[1]}) {
6238              !!!cp ('t419');              !!!cp ('t419');
# Line 6076  sub _tree_construction_main ($) { Line 6280  sub _tree_construction_main ($) {
6280              $i = $_;              $i = $_;
6281              last INSCOPE;              last INSCOPE;
6282            } elsif ({            } elsif ({
6283                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
6284                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
6285                     }->{$node->[1]}) {                     }->{$node->[1]}) {
6286              !!!cp ('t424');              !!!cp ('t424');
# Line 6120  sub _tree_construction_main ($) { Line 6324  sub _tree_construction_main ($) {
6324              $i = $_;              $i = $_;
6325              last INSCOPE;              last INSCOPE;
6326            } elsif ({            } elsif ({
6327                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
6328                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
6329                     }->{$node->[1]}) {                     }->{$node->[1]}) {
6330              !!!cp ('t411.1');              !!!cp ('t411.1');

Legend:
Removed from v.1.96  
changed lines
  Added in v.1.106

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24