/[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.80 by wakaba, Tue Mar 4 00:03:13 2008 UTC revision 1.84 by wakaba, Thu Mar 6 15:23:17 2008 UTC
# Line 304  sub ROW_IMS ()        { 0b10000000 } Line 304  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    
307    ## NOTE: "initial" and "before html" insertion modes have no constants.
308    
309    ## NOTE: "after after body" insertion mode.
310  sub AFTER_HTML_BODY_IM () { AFTER_HTML_IMS | BODY_AFTER_IMS }  sub AFTER_HTML_BODY_IM () { AFTER_HTML_IMS | BODY_AFTER_IMS }
311    
312    ## NOTE: "after after frameset" insertion mode.
313  sub AFTER_HTML_FRAMESET_IM () { AFTER_HTML_IMS | FRAME_IMS }  sub AFTER_HTML_FRAMESET_IM () { AFTER_HTML_IMS | FRAME_IMS }
314    
315  sub IN_HEAD_IM () { HEAD_IMS | 0b00 }  sub IN_HEAD_IM () { HEAD_IMS | 0b00 }
316  sub IN_HEAD_NOSCRIPT_IM () { HEAD_IMS | 0b01 }  sub IN_HEAD_NOSCRIPT_IM () { HEAD_IMS | 0b01 }
317  sub AFTER_HEAD_IM () { HEAD_IMS | 0b10 }  sub AFTER_HEAD_IM () { HEAD_IMS | 0b10 }
# Line 2420  sub _construct_tree ($) { Line 2426  sub _construct_tree ($) {
2426        
2427    !!!next-token;    !!!next-token;
2428    
   $self->{insertion_mode} = BEFORE_HEAD_IM;  
2429    undef $self->{form_element};    undef $self->{form_element};
2430    undef $self->{head_element};    undef $self->{head_element};
2431    $self->{open_elements} = [];    $self->{open_elements} = [];
2432    undef $self->{inner_html_node};    undef $self->{inner_html_node};
2433    
2434      ## NOTE: The "initial" insertion mode.
2435    $self->_tree_construction_initial; # MUST    $self->_tree_construction_initial; # MUST
2436    
2437      ## NOTE: The "before html" insertion mode.
2438    $self->_tree_construction_root_element;    $self->_tree_construction_root_element;
2439      $self->{insertion_mode} = BEFORE_HEAD_IM;
2440    
2441      ## NOTE: The "before head" insertion mode and so on.
2442    $self->_tree_construction_main;    $self->_tree_construction_main;
2443  } # _construct_tree  } # _construct_tree
2444    
2445  sub _tree_construction_initial ($) {  sub _tree_construction_initial ($) {
2446    my $self = shift;    my $self = shift;
2447    
2448      ## NOTE: "initial" insertion mode
2449    
2450    INITIAL: {    INITIAL: {
2451      if ($token->{type} == DOCTYPE_TOKEN) {      if ($token->{type} == DOCTYPE_TOKEN) {
2452        ## NOTE: Conformance checkers MAY, instead of reporting "not HTML5"        ## NOTE: Conformance checkers MAY, instead of reporting "not HTML5"
# Line 2579  sub _tree_construction_initial ($) { Line 2593  sub _tree_construction_initial ($) {
2593          !!!cp ('t13');          !!!cp ('t13');
2594        }        }
2595                
2596        ## Go to the root element phase.        ## Go to the "before html" insertion mode.
2597        !!!next-token;        !!!next-token;
2598        return;        return;
2599      } elsif ({      } elsif ({
# Line 2590  sub _tree_construction_initial ($) { Line 2604  sub _tree_construction_initial ($) {
2604        !!!cp ('t14');        !!!cp ('t14');
2605        !!!parse-error (type => 'no DOCTYPE');        !!!parse-error (type => 'no DOCTYPE');
2606        $self->{document}->manakai_compat_mode ('quirks');        $self->{document}->manakai_compat_mode ('quirks');
2607        ## Go to the root element phase        ## Go to the "before html" insertion mode.
2608        ## reprocess        ## reprocess
2609        return;        return;
2610      } elsif ($token->{type} == CHARACTER_TOKEN) {      } elsif ($token->{type} == CHARACTER_TOKEN) {
# Line 2599  sub _tree_construction_initial ($) { Line 2613  sub _tree_construction_initial ($) {
2613    
2614          unless (length $token->{data}) {          unless (length $token->{data}) {
2615            !!!cp ('t15');            !!!cp ('t15');
2616            ## Stay in the phase            ## Stay in the insertion mode.
2617            !!!next-token;            !!!next-token;
2618            redo INITIAL;            redo INITIAL;
2619          } else {          } else {
# Line 2611  sub _tree_construction_initial ($) { Line 2625  sub _tree_construction_initial ($) {
2625    
2626        !!!parse-error (type => 'no DOCTYPE');        !!!parse-error (type => 'no DOCTYPE');
2627        $self->{document}->manakai_compat_mode ('quirks');        $self->{document}->manakai_compat_mode ('quirks');
2628        ## Go to the root element phase        ## Go to the "before html" insertion mode.
2629        ## reprocess        ## reprocess
2630        return;        return;
2631      } elsif ($token->{type} == COMMENT_TOKEN) {      } elsif ($token->{type} == COMMENT_TOKEN) {
# Line 2619  sub _tree_construction_initial ($) { Line 2633  sub _tree_construction_initial ($) {
2633        my $comment = $self->{document}->create_comment ($token->{data});        my $comment = $self->{document}->create_comment ($token->{data});
2634        $self->{document}->append_child ($comment);        $self->{document}->append_child ($comment);
2635                
2636        ## Stay in the phase.        ## Stay in the insertion mode.
2637        !!!next-token;        !!!next-token;
2638        redo INITIAL;        redo INITIAL;
2639      } else {      } else {
# Line 2632  sub _tree_construction_initial ($) { Line 2646  sub _tree_construction_initial ($) {
2646    
2647  sub _tree_construction_root_element ($) {  sub _tree_construction_root_element ($) {
2648    my $self = shift;    my $self = shift;
2649    
2650      ## NOTE: "before html" insertion mode.
2651        
2652    B: {    B: {
2653        if ($token->{type} == DOCTYPE_TOKEN) {        if ($token->{type} == DOCTYPE_TOKEN) {
2654          !!!cp ('t19');          !!!cp ('t19');
2655          !!!parse-error (type => 'in html:#DOCTYPE');          !!!parse-error (type => 'in html:#DOCTYPE');
2656          ## Ignore the token          ## Ignore the token
2657          ## Stay in the phase          ## Stay in the insertion mode.
2658          !!!next-token;          !!!next-token;
2659          redo B;          redo B;
2660        } elsif ($token->{type} == COMMENT_TOKEN) {        } elsif ($token->{type} == COMMENT_TOKEN) {
2661          !!!cp ('t20');          !!!cp ('t20');
2662          my $comment = $self->{document}->create_comment ($token->{data});          my $comment = $self->{document}->create_comment ($token->{data});
2663          $self->{document}->append_child ($comment);          $self->{document}->append_child ($comment);
2664          ## Stay in the phase          ## Stay in the insertion mode.
2665          !!!next-token;          !!!next-token;
2666          redo B;          redo B;
2667        } elsif ($token->{type} == CHARACTER_TOKEN) {        } elsif ($token->{type} == CHARACTER_TOKEN) {
# Line 2654  sub _tree_construction_root_element ($) Line 2670  sub _tree_construction_root_element ($)
2670    
2671            unless (length $token->{data}) {            unless (length $token->{data}) {
2672              !!!cp ('t21');              !!!cp ('t21');
2673              ## Stay in the phase              ## Stay in the insertion mode.
2674              !!!next-token;              !!!next-token;
2675              redo B;              redo B;
2676            } else {            } else {
# Line 2668  sub _tree_construction_root_element ($) Line 2684  sub _tree_construction_root_element ($)
2684    
2685          #          #
2686        } elsif ($token->{type} == START_TAG_TOKEN) {        } elsif ($token->{type} == START_TAG_TOKEN) {
2687          if ($token->{tag_name} eq 'html' and          if ($token->{tag_name} eq 'html') {
2688              $token->{attributes}->{manifest}) {            my $root_element;
2689            !!!cp ('t24');            !!!create-element ($root_element, $token->{tag_name}, $token->{attributes});
2690            $self->{application_cache_selection}            $self->{document}->append_child ($root_element);
2691                 ->($token->{attributes}->{manifest}->{value});            push @{$self->{open_elements}}, [$root_element, 'html'];
2692            ## ISSUE: No relative reference resolution?  
2693              if ($token->{attributes}->{manifest}) {
2694                !!!cp ('t24');
2695                $self->{application_cache_selection}
2696                    ->($token->{attributes}->{manifest}->{value});
2697                ## ISSUE: No relative reference resolution?
2698              } else {
2699                !!!cp ('t25');
2700                $self->{application_cache_selection}->(undef);
2701              }
2702    
2703              !!!next-token;
2704              return; ## Go to the "before head" insertion mode.
2705          } else {          } else {
2706            !!!cp ('t25');            !!!cp ('t25.1');
2707            $self->{application_cache_selection}->(undef);            #
2708          }          }
   
         ## ISSUE: There is an issue in the spec  
         #  
2709        } elsif ({        } elsif ({
2710                  END_TAG_TOKEN, 1,                  END_TAG_TOKEN, 1,
2711                  END_OF_FILE_TOKEN, 1,                  END_OF_FILE_TOKEN, 1,
2712                 }->{$token->{type}}) {                 }->{$token->{type}}) {
2713          !!!cp ('t26');          !!!cp ('t26');
         $self->{application_cache_selection}->(undef);  
   
         ## ISSUE: There is an issue in the spec  
2714          #          #
2715        } else {        } else {
2716          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
2717        }        }
2718    
2719        my $root_element; !!!create-element ($root_element, 'html');      my $root_element; !!!create-element ($root_element, 'html');
2720        $self->{document}->append_child ($root_element);      $self->{document}->append_child ($root_element);
2721        push @{$self->{open_elements}}, [$root_element, 'html'];      push @{$self->{open_elements}}, [$root_element, 'html'];
2722        ## reprocess  
2723        #redo B;      $self->{application_cache_selection}->(undef);
2724        return; ## Go to the main phase.  
2725        ## NOTE: Reprocess the token.
2726        return; ## Go to the "before head" insertion mode.
2727    
2728        ## ISSUE: There is an issue in the spec
2729    } # B    } # B
2730    
2731    die "$0: _tree_construction_root_element: This should never be reached";    die "$0: _tree_construction_root_element: This should never be reached";
# Line 2739  sub _reset_insertion_mode ($) { Line 2765  sub _reset_insertion_mode ($) {
2765        ## Step 4..13        ## Step 4..13
2766        my $new_mode = {        my $new_mode = {
2767                        select => IN_SELECT_IM,                        select => IN_SELECT_IM,
2768                          ## NOTE: |option| and |optgroup| do not set
2769                          ## insertion mode to "in select" by themselves.
2770                        td => IN_CELL_IM,                        td => IN_CELL_IM,
2771                        th => IN_CELL_IM,                        th => IN_CELL_IM,
2772                        tr => IN_ROW_IM,                        tr => IN_ROW_IM,
# Line 2760  sub _reset_insertion_mode ($) { Line 2788  sub _reset_insertion_mode ($) {
2788            !!!cp ('t29');            !!!cp ('t29');
2789            $self->{insertion_mode} = BEFORE_HEAD_IM;            $self->{insertion_mode} = BEFORE_HEAD_IM;
2790          } else {          } else {
2791              ## ISSUE: Can this state be reached?
2792            !!!cp ('t30');            !!!cp ('t30');
2793            $self->{insertion_mode} = AFTER_HEAD_IM;            $self->{insertion_mode} = AFTER_HEAD_IM;
2794          }          }
# Line 2816  sub _tree_construction_main ($) { Line 2845  sub _tree_construction_main ($) {
2845    
2846        ## Step 6        ## Step 6
2847        if ($entry->[0] eq '#marker') {        if ($entry->[0] eq '#marker') {
2848          !!!cp ('t33');          !!!cp ('t33_1');
2849          #          #
2850        } else {        } else {
2851          my $in_open_elements;          my $in_open_elements;
# Line 2831  sub _tree_construction_main ($) { Line 2860  sub _tree_construction_main ($) {
2860            !!!cp ('t34');            !!!cp ('t34');
2861            #            #
2862          } else {          } else {
2863              ## NOTE: <!DOCTYPE HTML><p><b><i><u></p> <p>X
2864            !!!cp ('t35');            !!!cp ('t35');
2865            redo S4;            redo S4;
2866          }          }
# Line 3254  sub _tree_construction_main ($) { Line 3284  sub _tree_construction_main ($) {
3284          } elsif (defined $self->{inner_html_node} and          } elsif (defined $self->{inner_html_node} and
3285                   @{$self->{open_elements}} > 1 and                   @{$self->{open_elements}} > 1 and
3286                   $self->{open_elements}->[1]->[1] ne 'body') {                   $self->{open_elements}->[1]->[1] ne 'body') {
3287    ## ISSUE: This case is never reached.
3288            !!!cp ('t77');            !!!cp ('t77');
3289            !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);            !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
3290          } else {          } else {
# Line 3269  sub _tree_construction_main ($) { Line 3300  sub _tree_construction_main ($) {
3300               $token->{tag_name} eq 'html') {               $token->{tag_name} eq 'html') {
3301        if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {        if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
3302          !!!cp ('t79');          !!!cp ('t79');
         ## Turn into the main phase  
3303          !!!parse-error (type => 'after html:html');          !!!parse-error (type => 'after html:html');
3304          $self->{insertion_mode} = AFTER_BODY_IM;          $self->{insertion_mode} = AFTER_BODY_IM;
3305        } elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {        } elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {
3306          !!!cp ('t80');          !!!cp ('t80');
         ## Turn into the main phase  
3307          !!!parse-error (type => 'after html:html');          !!!parse-error (type => 'after html:html');
3308          $self->{insertion_mode} = AFTER_FRAMESET_IM;          $self->{insertion_mode} = AFTER_FRAMESET_IM;
3309        } else {        } else {
3310          !!!cp ('t81');          !!!cp ('t81');
3311        }        }
3312    
3313  ## ISSUE: "aa<html>" is not a parse error.        !!!cp ('t82');
3314  ## ISSUE: "<html>" in fragment is not a parse error.        !!!parse-error (type => 'not first start tag');
       unless ($token->{first_start_tag}) {  
         !!!cp ('t82');  
         !!!parse-error (type => 'not first start tag');  
       } else {  
         !!!cp ('t83');  
       }  
3315        my $top_el = $self->{open_elements}->[0]->[0];        my $top_el = $self->{open_elements}->[0]->[0];
3316        for my $attr_name (keys %{$token->{attributes}}) {        for my $attr_name (keys %{$token->{attributes}}) {
3317          unless ($top_el->has_attribute_ns (undef, $attr_name)) {          unless ($top_el->has_attribute_ns (undef, $attr_name)) {
# Line 3663  sub _tree_construction_main ($) { Line 3686  sub _tree_construction_main ($) {
3686                  !!!cp ('t133');                  !!!cp ('t133');
3687                  ## As if </noscript>                  ## As if </noscript>
3688                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
3689                  !!!parse-error (type => 'in noscript:script');                  !!!parse-error (type => 'in noscript:/head');
3690                                    
3691                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
3692                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
# Line 3768  sub _tree_construction_main ($) { Line 3791  sub _tree_construction_main ($) {
3791    
3792                ## Reprocess in the "after head" insertion mode...                ## Reprocess in the "after head" insertion mode...
3793              } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {              } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {
3794    ## ISSUE: This case cannot be reached?
3795                !!!cp ('t148');                !!!cp ('t148');
3796                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
3797                ## Ignore the token ## ISSUE: An issue in the spec.                ## Ignore the token ## ISSUE: An issue in the spec.
# Line 3821  sub _tree_construction_main ($) { Line 3845  sub _tree_construction_main ($) {
3845                  } # INSCOPE                  } # INSCOPE
3846                    unless (defined $tn) {                    unless (defined $tn) {
3847                      !!!cp ('t153');                      !!!cp ('t153');
3848    ## TODO: This error type is wrong.
3849                      !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                      !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
3850                      ## Ignore the token                      ## Ignore the token
3851                      !!!next-token;                      !!!next-token;
# Line 3853  sub _tree_construction_main ($) { Line 3878  sub _tree_construction_main ($) {
3878                  } # INSCOPE                  } # INSCOPE
3879                    unless (defined $i) {                    unless (defined $i) {
3880                      !!!cp ('t157');                      !!!cp ('t157');
3881    ## TODO: this type is wrong.
3882                      !!!parse-error (type => 'unmatched end tag:caption');                      !!!parse-error (type => 'unmatched end tag:caption');
3883                      ## Ignore the token                      ## Ignore the token
3884                      !!!next-token;                      !!!next-token;
# Line 3862  sub _tree_construction_main ($) { Line 3888  sub _tree_construction_main ($) {
3888                  ## generate implied end tags                  ## generate implied end tags
3889                  if ({                  if ({
3890                       dd => 1, dt => 1, li => 1, p => 1,                       dd => 1, dt => 1, li => 1, p => 1,
3891    
3892                         ## NOTE: Maybe the following elements never appear here.
3893                       td => 1, th => 1, tr => 1,                       td => 1, th => 1, tr => 1,
3894                       tbody => 1, tfoot=> 1, thead => 1,                       tbody => 1, tfoot => 1, thead => 1,
3895                      }->{$self->{open_elements}->[-1]->[1]}) {                      }->{$self->{open_elements}->[-1]->[1]}) {
3896                    !!!cp ('t158');                    !!!cp ('t158');
3897                    !!!back-token; # <?>                    !!!back-token; # <?>
# Line 3928  sub _tree_construction_main ($) { Line 3956  sub _tree_construction_main ($) {
3956                       dd => 1, dt => 1, li => 1, p => 1,                       dd => 1, dt => 1, li => 1, p => 1,
3957                       td => ($token->{tag_name} eq 'th'),                       td => ($token->{tag_name} eq 'th'),
3958                       th => ($token->{tag_name} eq 'td'),                       th => ($token->{tag_name} eq 'td'),
3959    
3960                         ## NOTE: Maybe the following elements never appear here.
3961                       tr => 1,                       tr => 1,
3962                       tbody => 1, tfoot=> 1, thead => 1,                       tbody => 1, tfoot => 1, thead => 1,
3963                      }->{$self->{open_elements}->[-1]->[1]}) {                      }->{$self->{open_elements}->[-1]->[1]}) {
3964                    !!!cp ('t166');                    !!!cp ('t166');
3965                    !!!back-token;                    !!!back-token;
# Line 3991  sub _tree_construction_main ($) { Line 4021  sub _tree_construction_main ($) {
4021                  ## generate implied end tags                  ## generate implied end tags
4022                  if ({                  if ({
4023                       dd => 1, dt => 1, li => 1, p => 1,                       dd => 1, dt => 1, li => 1, p => 1,
4024    
4025                         ## NOTE: The following elements never appear here, maybe.
4026                       td => 1, th => 1, tr => 1,                       td => 1, th => 1, tr => 1,
4027                       tbody => 1, tfoot=> 1, thead => 1,                       tbody => 1, tfoot => 1, thead => 1,
4028                      }->{$self->{open_elements}->[-1]->[1]}) {                      }->{$self->{open_elements}->[-1]->[1]}) {
4029                    !!!cp ('t174');                    !!!cp ('t174');
4030                    !!!back-token;                    !!!back-token;
# Line 4097  sub _tree_construction_main ($) { Line 4129  sub _tree_construction_main ($) {
4129                ## generate implied end tags                ## generate implied end tags
4130                if ({                if ({
4131                     dd => 1, dt => 1, li => 1, p => 1,                     dd => 1, dt => 1, li => 1, p => 1,
4132    
4133                       ## NOTE: The following elements never appear, maybe.
4134                     td => 1, th => 1, tr => 1,                     td => 1, th => 1, tr => 1,
4135                     tbody => 1, tfoot=> 1, thead => 1,                     tbody => 1, tfoot => 1, thead => 1,
4136                    }->{$self->{open_elements}->[-1]->[1]}) {                    }->{$self->{open_elements}->[-1]->[1]}) {
4137                  !!!cp ('t187');                  !!!cp ('t187');
4138                  !!!back-token; # </table>                  !!!back-token; # </table>
# Line 4253  sub _tree_construction_main ($) { Line 4287  sub _tree_construction_main ($) {
4287                    tbody => 1, tfoot => 1, thead => 1, html => 1,                    tbody => 1, tfoot => 1, thead => 1, html => 1,
4288                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4289                    !!!cp ('t203');                    !!!cp ('t203');
4290                      ## ISSUE: Can this case be reached?
4291                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
4292                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4293                  }                  }
# Line 4304  sub _tree_construction_main ($) { Line 4339  sub _tree_construction_main ($) {
4339                      $i = $_;                      $i = $_;
4340                      last INSCOPE;                      last INSCOPE;
4341                    } elsif ({                    } elsif ({
4342                              table => 1, html => 1,                              html => 1,
4343    
4344                                ## NOTE: This element does not appear here, maybe.
4345                                table => 1,
4346                             }->{$node->[1]}) {                             }->{$node->[1]}) {
4347                      !!!cp ('t209');                      !!!cp ('t209');
4348                      last INSCOPE;                      last INSCOPE;
# Line 4312  sub _tree_construction_main ($) { Line 4350  sub _tree_construction_main ($) {
4350                  } # INSCOPE                  } # INSCOPE
4351                  unless (defined $i) {                  unless (defined $i) {
4352                   !!!cp ('t210');                   !!!cp ('t210');
4353    ## TODO: This type is wrong.
4354                   !!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name});                   !!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name});
4355                    ## Ignore the token                    ## Ignore the token
4356                    !!!next-token;                    !!!next-token;
# Line 4323  sub _tree_construction_main ($) { Line 4362  sub _tree_construction_main ($) {
4362                    tr => 1, html => 1,                    tr => 1, html => 1,
4363                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4364                    !!!cp ('t211');                    !!!cp ('t211');
4365                      ## ISSUE: Can this case be reached?
4366                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
4367                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4368                  }                  }
# Line 4359  sub _tree_construction_main ($) { Line 4399  sub _tree_construction_main ($) {
4399                  } # INSCOPE                  } # INSCOPE
4400                  unless (defined $i) {                  unless (defined $i) {
4401                    !!!cp ('t216');                    !!!cp ('t216');
4402    ## TODO: This erorr type ios wrong.
4403                    !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                    !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
4404                    ## Ignore the token                    ## Ignore the token
4405                    !!!next-token;                    !!!next-token;
# Line 4370  sub _tree_construction_main ($) { Line 4411  sub _tree_construction_main ($) {
4411                    tbody => 1, tfoot => 1, thead => 1, html => 1,                    tbody => 1, tfoot => 1, thead => 1, html => 1,
4412                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4413                    !!!cp ('t217');                    !!!cp ('t217');
4414                      ## ISSUE: Can this state be reached?
4415                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
4416                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4417                  }                  }
# Line 4393  sub _tree_construction_main ($) { Line 4435  sub _tree_construction_main ($) {
4435                  while ($self->{open_elements}->[-1]->[1] ne 'table' and                  while ($self->{open_elements}->[-1]->[1] ne 'table' and
4436                         $self->{open_elements}->[-1]->[1] ne 'html') {                         $self->{open_elements}->[-1]->[1] ne 'html') {
4437                    !!!cp ('t219');                    !!!cp ('t219');
4438                      ## ISSUE: Can this state be reached?
4439                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
4440                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4441                  }                  }
# Line 4410  sub _tree_construction_main ($) { Line 4453  sub _tree_construction_main ($) {
4453                  while ($self->{open_elements}->[-1]->[1] ne 'table' and                  while ($self->{open_elements}->[-1]->[1] ne 'table' and
4454                         $self->{open_elements}->[-1]->[1] ne 'html') {                         $self->{open_elements}->[-1]->[1] ne 'html') {
4455                    !!!cp ('t220');                    !!!cp ('t220');
4456                      ## ISSUE: Can this state be reached?
4457                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
4458                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4459                  }                  }
# Line 4443  sub _tree_construction_main ($) { Line 4487  sub _tree_construction_main ($) {
4487                    $i = $_;                    $i = $_;
4488                    last INSCOPE;                    last INSCOPE;
4489                  } elsif ({                  } elsif ({
4490                            table => 1, html => 1,                            #table => 1,
4491                              html => 1,
4492                           }->{$node->[1]}) {                           }->{$node->[1]}) {
4493                    !!!cp ('t222');                    !!!cp ('t222');
4494                    last INSCOPE;                    last INSCOPE;
# Line 4451  sub _tree_construction_main ($) { Line 4496  sub _tree_construction_main ($) {
4496                } # INSCOPE                } # INSCOPE
4497                unless (defined $i) {                unless (defined $i) {
4498                  !!!cp ('t223');                  !!!cp ('t223');
4499    ## TODO: The following is wrong, maybe.
4500                  !!!parse-error (type => 'unmatched end tag:table');                  !!!parse-error (type => 'unmatched end tag:table');
4501                  ## Ignore tokens </table><table>                  ## Ignore tokens </table><table>
4502                  !!!next-token;                  !!!next-token;
# Line 4474  sub _tree_construction_main ($) { Line 4520  sub _tree_construction_main ($) {
4520    
4521                if ($self->{open_elements}->[-1]->[1] ne 'table') {                if ($self->{open_elements}->[-1]->[1] ne 'table') {
4522                  !!!cp ('t225');                  !!!cp ('t225');
4523    ## ISSUE: Can this case be reached?
4524                  !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                  !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
4525                } else {                } else {
4526                  !!!cp ('t226');                  !!!cp ('t226');
# Line 4525  sub _tree_construction_main ($) { Line 4572  sub _tree_construction_main ($) {
4572                  tr => 1, html => 1,                  tr => 1, html => 1,
4573                }->{$self->{open_elements}->[-1]->[1]}) {                }->{$self->{open_elements}->[-1]->[1]}) {
4574                  !!!cp ('t231');                  !!!cp ('t231');
4575    ## ISSUE: Can this state be reached?
4576                  !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                  !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
4577                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4578                }                }
# Line 4553  sub _tree_construction_main ($) { Line 4601  sub _tree_construction_main ($) {
4601                  } # INSCOPE                  } # INSCOPE
4602                  unless (defined $i) {                  unless (defined $i) {
4603                    !!!cp ('t235');                    !!!cp ('t235');
4604    ## TODO: The following is wrong.
4605                    !!!parse-error (type => 'unmatched end tag:'.$token->{type});                    !!!parse-error (type => 'unmatched end tag:'.$token->{type});
4606                    ## Ignore the token                    ## Ignore the token
4607                    !!!next-token;                    !!!next-token;
# Line 4564  sub _tree_construction_main ($) { Line 4613  sub _tree_construction_main ($) {
4613                    tr => 1, html => 1,                    tr => 1, html => 1,
4614                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4615                    !!!cp ('t236');                    !!!cp ('t236');
4616    ## ISSUE: Can this state be reached?
4617                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
4618                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4619                  }                  }
# Line 4650  sub _tree_construction_main ($) { Line 4700  sub _tree_construction_main ($) {
4700                     tbody => 1, tfoot=> 1, thead => 1,                     tbody => 1, tfoot=> 1, thead => 1,
4701                    }->{$self->{open_elements}->[-1]->[1]}) {                    }->{$self->{open_elements}->[-1]->[1]}) {
4702                  !!!cp ('t244');                  !!!cp ('t244');
4703    ## ISSUE: Can this case be reached?
4704                  !!!back-token;                  !!!back-token;
4705                  $token = {type => END_TAG_TOKEN,                  $token = {type => END_TAG_TOKEN,
4706                            tag_name => $self->{open_elements}->[-1]->[1]}; # MUST                            tag_name => $self->{open_elements}->[-1]->[1]}; # MUST
# Line 4726  sub _tree_construction_main ($) { Line 4777  sub _tree_construction_main ($) {
4777                    tr => 1, html => 1,                    tr => 1, html => 1,
4778                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
4779                    !!!cp ('t253');                    !!!cp ('t253');
4780    ## ISSUE: Can this case be reached?
4781                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                    !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
4782                    pop @{$self->{open_elements}};                    pop @{$self->{open_elements}};
4783                  }                  }
# Line 4763  sub _tree_construction_main ($) { Line 4815  sub _tree_construction_main ($) {
4815                  tbody => 1, tfoot => 1, thead => 1, html => 1,                  tbody => 1, tfoot => 1, thead => 1, html => 1,
4816                }->{$self->{open_elements}->[-1]->[1]}) {                }->{$self->{open_elements}->[-1]->[1]}) {
4817                  !!!cp ('t257');                  !!!cp ('t257');
4818    ## ISSUE: Can this case be reached?
4819                  !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);                  !!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
4820                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4821                }                }
# Line 4842  sub _tree_construction_main ($) { Line 4895  sub _tree_construction_main ($) {
4895                #                #
4896              }              }
4897            } else {            } else {
4898              !!!cp ('t268');              die "$0: $token->{type}: Unknown token type";
             #  
4899            }            }
4900    
4901            ## As if </colgroup>            ## As if </colgroup>
# Line 4900  sub _tree_construction_main ($) { Line 4952  sub _tree_construction_main ($) {
4952                !!!next-token;                !!!next-token;
4953                redo B;                redo B;
4954              } elsif ($token->{tag_name} eq 'select') {              } elsif ($token->{tag_name} eq 'select') {
4955    ## TODO: The type below is not good - <select> is replaced by </select>
4956                !!!parse-error (type => 'not closed:select');                !!!parse-error (type => 'not closed:select');
4957                ## As if </select> instead                ## As if </select> instead
4958                ## have an element in table scope                ## have an element in table scope
# Line 5002  sub _tree_construction_main ($) { Line 5055  sub _tree_construction_main ($) {
5055                        caption => 1, table => 1, tbody => 1,                        caption => 1, table => 1, tbody => 1,
5056                        tfoot => 1, thead => 1, tr => 1, td => 1, th => 1,                        tfoot => 1, thead => 1, tr => 1, td => 1, th => 1,
5057                       }->{$token->{tag_name}}) {                       }->{$token->{tag_name}}) {
5058    ## TODO: The following is wrong?
5059                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
5060                                
5061                ## have an element in table scope                ## have an element in table scope
# Line 5038  sub _tree_construction_main ($) { Line 5092  sub _tree_construction_main ($) {
5092                  } elsif ({                  } elsif ({
5093                            table => 1, html => 1,                            table => 1, html => 1,
5094                           }->{$node->[1]}) {                           }->{$node->[1]}) {
5095    ## ISSUE: Can this state be reached?
5096                    !!!cp ('t296');                    !!!cp ('t296');
5097                    last INSCOPE;                    last INSCOPE;
5098                  }                  }
5099                } # INSCOPE                } # INSCOPE
5100                unless (defined $i) {                unless (defined $i) {
5101                  !!!cp ('t297');                  !!!cp ('t297');
5102    ## TODO: The following error type is correct?
5103                  !!!parse-error (type => 'unmatched end tag:select');                  !!!parse-error (type => 'unmatched end tag:select');
5104                  ## Ignore the </select> token                  ## Ignore the </select> token
5105                  !!!next-token; ## TODO: ok?                  !!!next-token; ## TODO: ok?
# Line 5087  sub _tree_construction_main ($) { Line 5143  sub _tree_construction_main ($) {
5143            !!!cp ('t301');            !!!cp ('t301');
5144            !!!parse-error (type => 'after html:#character');            !!!parse-error (type => 'after html:#character');
5145    
5146            ## Reprocess in the "main" phase, "after body" insertion mode...            ## Reprocess in the "after body" insertion mode.
5147          } else {          } else {
5148            !!!cp ('t302');            !!!cp ('t302');
5149          }          }
# Line 5103  sub _tree_construction_main ($) { Line 5159  sub _tree_construction_main ($) {
5159            !!!cp ('t303');            !!!cp ('t303');
5160            !!!parse-error (type => 'after html:'.$token->{tag_name});            !!!parse-error (type => 'after html:'.$token->{tag_name});
5161                        
5162            ## Reprocess in the "main" phase, "after body" insertion mode...            ## Reprocess in the "after body" insertion mode.
5163          } else {          } else {
5164            !!!cp ('t304');            !!!cp ('t304');
5165          }          }
# Line 5120  sub _tree_construction_main ($) { Line 5176  sub _tree_construction_main ($) {
5176            !!!parse-error (type => 'after html:/'.$token->{tag_name});            !!!parse-error (type => 'after html:/'.$token->{tag_name});
5177                        
5178            $self->{insertion_mode} = AFTER_BODY_IM;            $self->{insertion_mode} = AFTER_BODY_IM;
5179            ## Reprocess in the "main" phase, "after body" insertion mode...            ## Reprocess in the "after body" insertion mode.
5180          } else {          } else {
5181            !!!cp ('t306');            !!!cp ('t306');
5182          }          }
# Line 5174  sub _tree_construction_main ($) { Line 5230  sub _tree_construction_main ($) {
5230              !!!parse-error (type => 'after html:#character');              !!!parse-error (type => 'after html:#character');
5231    
5232              $self->{insertion_mode} = AFTER_FRAMESET_IM;              $self->{insertion_mode} = AFTER_FRAMESET_IM;
5233              ## Reprocess in the "main" phase, "after frameset"...              ## Reprocess in the "after frameset" insertion mode.
5234              !!!parse-error (type => 'after frameset:#character');              !!!parse-error (type => 'after frameset:#character');
5235            }            }
5236                        
# Line 5196  sub _tree_construction_main ($) { Line 5252  sub _tree_construction_main ($) {
5252            !!!parse-error (type => 'after html:'.$token->{tag_name});            !!!parse-error (type => 'after html:'.$token->{tag_name});
5253    
5254            $self->{insertion_mode} = AFTER_FRAMESET_IM;            $self->{insertion_mode} = AFTER_FRAMESET_IM;
5255            ## Process in the "main" phase, "after frameset" insertion mode...            ## Process in the "after frameset" insertion mode.
5256          } else {          } else {
5257            !!!cp ('t317');            !!!cp ('t317');
5258          }          }
# Line 5237  sub _tree_construction_main ($) { Line 5293  sub _tree_construction_main ($) {
5293            !!!parse-error (type => 'after html:/'.$token->{tag_name});            !!!parse-error (type => 'after html:/'.$token->{tag_name});
5294    
5295            $self->{insertion_mode} = AFTER_FRAMESET_IM;            $self->{insertion_mode} = AFTER_FRAMESET_IM;
5296            ## Process in the "main" phase, "after frameset" insertion mode...            ## Process in the "after frameset" insertion mode.
5297          } else {          } else {
5298            !!!cp ('t324');            !!!cp ('t324');
5299          }          }
# Line 6096  sub _tree_construction_main ($) { Line 6152  sub _tree_construction_main ($) {
6152              ## generate implied end tags              ## generate implied end tags
6153              if ({              if ({
6154                   dd => 1, dt => 1, li => 1, p => 1,                   dd => 1, dt => 1, li => 1, p => 1,
6155    
6156                     ## NOTE: The following elements never appear here, maybe.
6157                   td => 1, th => 1, tr => 1,                   td => 1, th => 1, tr => 1,
6158                   tbody => 1, tfoot=> 1, thead => 1,                   tbody => 1, tfoot => 1, thead => 1,
6159                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
6160                !!!cp ('t417');                !!!cp ('t417');
6161                !!!back-token;                !!!back-token;
# Line 6232  sub _tree_construction_main ($) { Line 6290  sub _tree_construction_main ($) {
6290                   tbody => 1, tfoot => 1, thead => 1,                   tbody => 1, tfoot => 1, thead => 1,
6291                  }->{$self->{open_elements}->[-1]->[1]}) {                  }->{$self->{open_elements}->[-1]->[1]}) {
6292                !!!cp ('t430');                !!!cp ('t430');
6293                  ## ISSUE: Can this case be reached?
6294                !!!back-token;                !!!back-token;
6295                $token = {type => END_TAG_TOKEN,                $token = {type => END_TAG_TOKEN,
6296                          tag_name => $self->{open_elements}->[-1]->[1]}; # MUST                          tag_name => $self->{open_elements}->[-1]->[1]}; # MUST
# Line 6281  sub _tree_construction_main ($) { Line 6340  sub _tree_construction_main ($) {
6340      redo B;      redo B;
6341    } # B    } # B
6342    
   ## NOTE: The "trailing end" phase in HTML5 is split into  
   ## two insertion modes: "after html body" and "after html frameset".  
   ## NOTE: States in the main stage is preserved while  
   ## the parser stays in the trailing end phase. # MUST  
   
6343    ## Stop parsing # MUST    ## Stop parsing # MUST
6344        
6345    ## TODO: script stuffs    ## TODO: script stuffs
# Line 6327  sub set_inner_html ($$$) { Line 6381  sub set_inner_html ($$$) {
6381      my $p = $class->new;      my $p = $class->new;
6382      $p->{document} = $doc;      $p->{document} = $doc;
6383    
6384      ## Step 9 # MUST      ## Step 8 # MUST
6385      my $i = 0;      my $i = 0;
6386      my $line = 1;      my $line = 1;
6387      my $column = 0;      my $column = 0;
# Line 6394  sub set_inner_html ($$$) { Line 6448  sub set_inner_html ($$$) {
6448    
6449      $p->{inner_html_node} = [$node, $node_ln];      $p->{inner_html_node} = [$node, $node_ln];
6450    
6451      ## Step 4      ## Step 3
6452      my $root = $doc->create_element_ns      my $root = $doc->create_element_ns
6453        ('http://www.w3.org/1999/xhtml', [undef, 'html']);        ('http://www.w3.org/1999/xhtml', [undef, 'html']);
6454    
6455      ## Step 5 # MUST      ## Step 4 # MUST
6456      $doc->append_child ($root);      $doc->append_child ($root);
6457    
6458      ## Step 6 # MUST      ## Step 5 # MUST
6459      push @{$p->{open_elements}}, [$root, 'html'];      push @{$p->{open_elements}}, [$root, 'html'];
6460    
6461      undef $p->{head_element};      undef $p->{head_element};
6462    
6463      ## Step 7 # MUST      ## Step 6 # MUST
6464      $p->_reset_insertion_mode;      $p->_reset_insertion_mode;
6465    
6466      ## Step 8 # MUST      ## Step 7 # MUST
6467      my $anode = $node;      my $anode = $node;
6468      AN: while (defined $anode) {      AN: while (defined $anode) {
6469        if ($anode->node_type == 1) {        if ($anode->node_type == 1) {
# Line 6425  sub set_inner_html ($$$) { Line 6479  sub set_inner_html ($$$) {
6479        $anode = $anode->parent_node;        $anode = $anode->parent_node;
6480      } # AN      } # AN
6481            
6482      ## Step 3 # MUST      ## Step 9 # MUST
     ## Step 10 # MUST  
6483      {      {
6484        my $self = $p;        my $self = $p;
6485        !!!next-token;        !!!next-token;
6486      }      }
6487      $p->_tree_construction_main;      $p->_tree_construction_main;
6488    
6489      ## Step 11 # MUST      ## Step 10 # MUST
6490      my @cn = @{$node->child_nodes};      my @cn = @{$node->child_nodes};
6491      for (@cn) {      for (@cn) {
6492        $node->remove_child ($_);        $node->remove_child ($_);
6493      }      }
6494      ## ISSUE: mutation events? read-only?      ## ISSUE: mutation events? read-only?
6495    
6496      ## Step 12 # MUST      ## Step 11 # MUST
6497      @cn = @{$root->child_nodes};      @cn = @{$root->child_nodes};
6498      for (@cn) {      for (@cn) {
6499        $this_doc->adopt_node ($_);        $this_doc->adopt_node ($_);

Legend:
Removed from v.1.80  
changed lines
  Added in v.1.84

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24