/[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.95 by wakaba, Sat Mar 8 05:09:25 2008 UTC revision 1.112 by wakaba, Sun Mar 16 06:39:57 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 177  sub parse_string ($$$;$) { Line 177  sub parse_string ($$$;$) {
177        if defined $self->{input_encoding};        if defined $self->{input_encoding};
178    
179    my $i = 0;    my $i = 0;
180    my $line = 1;    $self->{line_prev} = $self->{line} = 1;
181    my $column = 0;    $self->{column_prev} = $self->{column} = 0;
182    $self->{set_next_char} = sub {    $self->{set_next_char} = sub {
183      my $self = shift;      my $self = shift;
184    
# Line 187  sub parse_string ($$$;$) { Line 187  sub parse_string ($$$;$) {
187    
188      $self->{next_char} = -1 and return if $i >= length $$s;      $self->{next_char} = -1 and return if $i >= length $$s;
189      $self->{next_char} = ord substr $$s, $i++, 1;      $self->{next_char} = ord substr $$s, $i++, 1;
190      $column++;  
191        ($self->{line_prev}, $self->{column_prev})
192            = ($self->{line}, $self->{column});
193        $self->{column}++;
194            
195      if ($self->{next_char} == 0x000A) { # LF      if ($self->{next_char} == 0x000A) { # LF
196        $line++;        $self->{line}++;
197        $column = 0;        $self->{column} = 0;
198      } elsif ($self->{next_char} == 0x000D) { # CR      } elsif ($self->{next_char} == 0x000D) { # CR
199        $i++ if substr ($$s, $i, 1) eq "\x0A";        $i++ if substr ($$s, $i, 1) eq "\x0A";
200        $self->{next_char} = 0x000A; # LF # MUST        $self->{next_char} = 0x000A; # LF # MUST
201        $line++;        $self->{line}++;
202        $column = 0;        $self->{column} = 0;
203      } elsif ($self->{next_char} > 0x10FFFF) {      } elsif ($self->{next_char} > 0x10FFFF) {
204        $self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST        $self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST
205      } elsif ($self->{next_char} == 0x0000) { # NULL      } elsif ($self->{next_char} == 0x0000) { # NULL
# Line 209  sub parse_string ($$$;$) { Line 212  sub parse_string ($$$;$) {
212    
213    my $onerror = $_[2] || sub {    my $onerror = $_[2] || sub {
214      my (%opt) = @_;      my (%opt) = @_;
215      warn "Parse error ($opt{type}) at line $opt{line} column $opt{column}\n";      my $line = $opt{token} ? $opt{token}->{line} : $opt{line};
216        my $column = $opt{token} ? $opt{token}->{column} : $opt{column};
217        warn "Parse error ($opt{type}) at line $line column $column\n";
218    };    };
219    $self->{parse_error} = sub {    $self->{parse_error} = sub {
220      $onerror->(@_, line => $line, column => $column);      $onerror->(line => $self->{line}, column => $self->{column}, @_);
221    };    };
222    
223    $self->_initialize_tokenizer;    $self->_initialize_tokenizer;
# Line 220  sub parse_string ($$$;$) { Line 225  sub parse_string ($$$;$) {
225    $self->_construct_tree;    $self->_construct_tree;
226    $self->_terminate_tree_constructor;    $self->_terminate_tree_constructor;
227    
228      delete $self->{parse_error}; # remove loop
229    
230    return $self->{document};    return $self->{document};
231  } # parse_string  } # parse_string
232    
# Line 303  sub TABLE_IMS ()      { 0b1000000 } Line 310  sub TABLE_IMS ()      { 0b1000000 }
310  sub ROW_IMS ()        { 0b10000000 }  sub ROW_IMS ()        { 0b10000000 }
311  sub BODY_AFTER_IMS () { 0b100000000 }  sub BODY_AFTER_IMS () { 0b100000000 }
312  sub FRAME_IMS ()      { 0b1000000000 }  sub FRAME_IMS ()      { 0b1000000000 }
313    sub SELECT_IMS ()     { 0b10000000000 }
314    
315  ## NOTE: "initial" and "before html" insertion modes have no constants.  ## NOTE: "initial" and "before html" insertion modes have no constants.
316    
# Line 325  sub IN_TABLE_IM () { TABLE_IMS } Line 333  sub IN_TABLE_IM () { TABLE_IMS }
333  sub AFTER_BODY_IM () { BODY_AFTER_IMS }  sub AFTER_BODY_IM () { BODY_AFTER_IMS }
334  sub IN_FRAMESET_IM () { FRAME_IMS | 0b01 }  sub IN_FRAMESET_IM () { FRAME_IMS | 0b01 }
335  sub AFTER_FRAMESET_IM () { FRAME_IMS | 0b10 }  sub AFTER_FRAMESET_IM () { FRAME_IMS | 0b10 }
336  sub IN_SELECT_IM () { 0b01 }  sub IN_SELECT_IM () { SELECT_IMS | 0b01 }
337    sub IN_SELECT_IN_TABLE_IM () { SELECT_IMS | 0b10 }
338  sub IN_COLUMN_GROUP_IM () { 0b10 }  sub IN_COLUMN_GROUP_IM () { 0b10 }
339    
340  ## Implementations MUST act as if state machine in the spec  ## Implementations MUST act as if state machine in the spec
# Line 447  sub _get_next_token ($) { Line 456  sub _get_next_token ($) {
456          #          #
457        } elsif ($self->{next_char} == -1) {        } elsif ($self->{next_char} == -1) {
458          !!!cp (11);          !!!cp (11);
459          !!!emit ({type => END_OF_FILE_TOKEN});          !!!emit ({type => END_OF_FILE_TOKEN,
460                      line => $self->{line}, column => $self->{column}});
461          last A; ## TODO: ok?          last A; ## TODO: ok?
462        } else {        } else {
463          !!!cp (12);          !!!cp (12);
464        }        }
465        # Anything else        # Anything else
466        my $token = {type => CHARACTER_TOKEN,        my $token = {type => CHARACTER_TOKEN,
467                     data => chr $self->{next_char}};                     data => chr $self->{next_char},
468                       line => $self->{line}, column => $self->{column}};
469        ## Stay in the data state        ## Stay in the data state
470        !!!next-input-character;        !!!next-input-character;
471    
# Line 463  sub _get_next_token ($) { Line 474  sub _get_next_token ($) {
474        redo A;        redo A;
475      } elsif ($self->{state} == ENTITY_DATA_STATE) {      } elsif ($self->{state} == ENTITY_DATA_STATE) {
476        ## (cannot happen in CDATA state)        ## (cannot happen in CDATA state)
477    
478          my ($l, $c) = ($self->{line_prev}, $self->{column_prev});
479                
480        my $token = $self->_tokenize_attempt_to_consume_an_entity (0, -1);        my $token = $self->_tokenize_attempt_to_consume_an_entity (0, -1);
481    
# Line 471  sub _get_next_token ($) { Line 484  sub _get_next_token ($) {
484    
485        unless (defined $token) {        unless (defined $token) {
486          !!!cp (13);          !!!cp (13);
487          !!!emit ({type => CHARACTER_TOKEN, data => '&'});          !!!emit ({type => CHARACTER_TOKEN, data => '&',
488                      line => $l, column => $c});
489        } else {        } else {
490          !!!cp (14);          !!!cp (14);
491          !!!emit ($token);          !!!emit ($token);
# Line 490  sub _get_next_token ($) { Line 504  sub _get_next_token ($) {
504            ## reconsume            ## reconsume
505            $self->{state} = DATA_STATE;            $self->{state} = DATA_STATE;
506    
507            !!!emit ({type => CHARACTER_TOKEN, data => '<'});            !!!emit ({type => CHARACTER_TOKEN, data => '<',
508                        line => $self->{line_prev},
509                        column => $self->{column_prev}});
510    
511            redo A;            redo A;
512          }          }
# Line 510  sub _get_next_token ($) { Line 526  sub _get_next_token ($) {
526            !!!cp (19);            !!!cp (19);
527            $self->{current_token}            $self->{current_token}
528              = {type => START_TAG_TOKEN,              = {type => START_TAG_TOKEN,
529                 tag_name => chr ($self->{next_char} + 0x0020)};                 tag_name => chr ($self->{next_char} + 0x0020),
530                   line => $self->{line_prev},
531                   column => $self->{column_prev}};
532            $self->{state} = TAG_NAME_STATE;            $self->{state} = TAG_NAME_STATE;
533            !!!next-input-character;            !!!next-input-character;
534            redo A;            redo A;
# Line 518  sub _get_next_token ($) { Line 536  sub _get_next_token ($) {
536                   $self->{next_char} <= 0x007A) { # a..z                   $self->{next_char} <= 0x007A) { # a..z
537            !!!cp (20);            !!!cp (20);
538            $self->{current_token} = {type => START_TAG_TOKEN,            $self->{current_token} = {type => START_TAG_TOKEN,
539                              tag_name => chr ($self->{next_char})};                                      tag_name => chr ($self->{next_char}),
540                                        line => $self->{line_prev},
541                                        column => $self->{column_prev}};
542            $self->{state} = TAG_NAME_STATE;            $self->{state} = TAG_NAME_STATE;
543            !!!next-input-character;            !!!next-input-character;
544            redo A;            redo A;
# Line 528  sub _get_next_token ($) { Line 548  sub _get_next_token ($) {
548            $self->{state} = DATA_STATE;            $self->{state} = DATA_STATE;
549            !!!next-input-character;            !!!next-input-character;
550    
551            !!!emit ({type => CHARACTER_TOKEN, data => '<>'});            !!!emit ({type => CHARACTER_TOKEN, data => '<>',
552                        line => $self->{line_prev},
553                        column => $self->{column_prev}});
554    
555            redo A;            redo A;
556          } elsif ($self->{next_char} == 0x003F) { # ?          } elsif ($self->{next_char} == 0x003F) { # ?
557            !!!cp (22);            !!!cp (22);
558            !!!parse-error (type => 'pio');            !!!parse-error (type => 'pio');
559            $self->{state} = BOGUS_COMMENT_STATE;            $self->{state} = BOGUS_COMMENT_STATE;
560              $self->{current_token} = {type => COMMENT_TOKEN, data => '',
561                                        line => $self->{line_prev},
562                                        column => $self->{column_prev}};
563            ## $self->{next_char} is intentionally left as is            ## $self->{next_char} is intentionally left as is
564            redo A;            redo A;
565          } else {          } else {
# Line 543  sub _get_next_token ($) { Line 568  sub _get_next_token ($) {
568            $self->{state} = DATA_STATE;            $self->{state} = DATA_STATE;
569            ## reconsume            ## reconsume
570    
571            !!!emit ({type => CHARACTER_TOKEN, data => '<'});            !!!emit ({type => CHARACTER_TOKEN, data => '<',
572                        line => $self->{line_prev},
573                        column => $self->{column_prev}});
574    
575            redo A;            redo A;
576          }          }
# Line 551  sub _get_next_token ($) { Line 578  sub _get_next_token ($) {
578          die "$0: $self->{content_model} in tag open";          die "$0: $self->{content_model} in tag open";
579        }        }
580      } elsif ($self->{state} == CLOSE_TAG_OPEN_STATE) {      } elsif ($self->{state} == CLOSE_TAG_OPEN_STATE) {
581          my ($l, $c) = ($self->{line_prev}, $self->{column_prev});
582        if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA        if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA
583          if (defined $self->{last_emitted_start_tag_name}) {          if (defined $self->{last_emitted_start_tag_name}) {
584    
585            ## NOTE: <http://krijnhoetmer.nl/irc-logs/whatwg/20070626#l-564>            ## NOTE: <http://krijnhoetmer.nl/irc-logs/whatwg/20070626#l-564>
586            my @next_char;            my @next_char;
587            TAGNAME: for (my $i = 0; $i < length $self->{last_emitted_start_tag_name}; $i++) {            TAGNAME: for (my $i = 0; $i < length $self->{last_emitted_start_tag_name}; $i++) {
# Line 569  sub _get_next_token ($) { Line 598  sub _get_next_token ($) {
598                !!!back-next-input-character (@next_char);                !!!back-next-input-character (@next_char);
599                $self->{state} = DATA_STATE;                $self->{state} = DATA_STATE;
600    
601                !!!emit ({type => CHARACTER_TOKEN, data => '</'});                !!!emit ({type => CHARACTER_TOKEN, data => '</',
602                            line => $l, column => $c});
603        
604                redo A;                redo A;
605              }              }
# Line 588  sub _get_next_token ($) { Line 618  sub _get_next_token ($) {
618              $self->{next_char} = shift @next_char; # reconsume              $self->{next_char} = shift @next_char; # reconsume
619              !!!back-next-input-character (@next_char);              !!!back-next-input-character (@next_char);
620              $self->{state} = DATA_STATE;              $self->{state} = DATA_STATE;
621              !!!emit ({type => CHARACTER_TOKEN, data => '</'});              !!!emit ({type => CHARACTER_TOKEN, data => '</',
622                          line => $l, column => $c});
623              redo A;              redo A;
624            } else {            } else {
625              !!!cp (27);              !!!cp (27);
# Line 601  sub _get_next_token ($) { Line 632  sub _get_next_token ($) {
632            !!!cp (28);            !!!cp (28);
633            # next-input-character is already done            # next-input-character is already done
634            $self->{state} = DATA_STATE;            $self->{state} = DATA_STATE;
635            !!!emit ({type => CHARACTER_TOKEN, data => '</'});            !!!emit ({type => CHARACTER_TOKEN, data => '</',
636                        line => $l, column => $c});
637            redo A;            redo A;
638          }          }
639        }        }
# Line 609  sub _get_next_token ($) { Line 641  sub _get_next_token ($) {
641        if (0x0041 <= $self->{next_char} and        if (0x0041 <= $self->{next_char} and
642            $self->{next_char} <= 0x005A) { # A..Z            $self->{next_char} <= 0x005A) { # A..Z
643          !!!cp (29);          !!!cp (29);
644          $self->{current_token} = {type => END_TAG_TOKEN,          $self->{current_token}
645                            tag_name => chr ($self->{next_char} + 0x0020)};              = {type => END_TAG_TOKEN,
646                   tag_name => chr ($self->{next_char} + 0x0020),
647                   line => $l, column => $c};
648          $self->{state} = TAG_NAME_STATE;          $self->{state} = TAG_NAME_STATE;
649          !!!next-input-character;          !!!next-input-character;
650          redo A;          redo A;
# Line 618  sub _get_next_token ($) { Line 652  sub _get_next_token ($) {
652                 $self->{next_char} <= 0x007A) { # a..z                 $self->{next_char} <= 0x007A) { # a..z
653          !!!cp (30);          !!!cp (30);
654          $self->{current_token} = {type => END_TAG_TOKEN,          $self->{current_token} = {type => END_TAG_TOKEN,
655                            tag_name => chr ($self->{next_char})};                                    tag_name => chr ($self->{next_char}),
656                                      line => $l, column => $c};
657          $self->{state} = TAG_NAME_STATE;          $self->{state} = TAG_NAME_STATE;
658          !!!next-input-character;          !!!next-input-character;
659          redo A;          redo A;
# Line 634  sub _get_next_token ($) { Line 669  sub _get_next_token ($) {
669          $self->{state} = DATA_STATE;          $self->{state} = DATA_STATE;
670          # reconsume          # reconsume
671    
672          !!!emit ({type => CHARACTER_TOKEN, data => '</'});          !!!emit ({type => CHARACTER_TOKEN, data => '</',
673                      line => $l, column => $c});
674    
675          redo A;          redo A;
676        } else {        } else {
677          !!!cp (33);          !!!cp (33);
678          !!!parse-error (type => 'bogus end tag');          !!!parse-error (type => 'bogus end tag');
679          $self->{state} = BOGUS_COMMENT_STATE;          $self->{state} = BOGUS_COMMENT_STATE;
680            $self->{current_token} = {type => COMMENT_TOKEN, data => '',
681                                      line => $self->{line_prev}, # "<" of "</"
682                                      column => $self->{column_prev} - 1};
683          ## $self->{next_char} is intentionally left as is          ## $self->{next_char} is intentionally left as is
684          redo A;          redo A;
685        }        }
# Line 1377  sub _get_next_token ($) { Line 1416  sub _get_next_token ($) {
1416      } elsif ($self->{state} == BOGUS_COMMENT_STATE) {      } elsif ($self->{state} == BOGUS_COMMENT_STATE) {
1417        ## (only happen if PCDATA state)        ## (only happen if PCDATA state)
1418                
1419        my $token = {type => COMMENT_TOKEN, data => ''};        ## NOTE: Set by the previous state
1420          #my $token = {type => COMMENT_TOKEN, data => ''};
1421    
1422        BC: {        BC: {
1423          if ($self->{next_char} == 0x003E) { # >          if ($self->{next_char} == 0x003E) { # >
# Line 1385  sub _get_next_token ($) { Line 1425  sub _get_next_token ($) {
1425            $self->{state} = DATA_STATE;            $self->{state} = DATA_STATE;
1426            !!!next-input-character;            !!!next-input-character;
1427    
1428            !!!emit ($token);            !!!emit ($self->{current_token}); # comment
1429    
1430            redo A;            redo A;
1431          } elsif ($self->{next_char} == -1) {          } elsif ($self->{next_char} == -1) {
# Line 1393  sub _get_next_token ($) { Line 1433  sub _get_next_token ($) {
1433            $self->{state} = DATA_STATE;            $self->{state} = DATA_STATE;
1434            ## reconsume            ## reconsume
1435    
1436            !!!emit ($token);            !!!emit ($self->{current_token}); # comment
1437    
1438            redo A;            redo A;
1439          } else {          } else {
1440            !!!cp (126);            !!!cp (126);
1441            $token->{data} .= chr ($self->{next_char});            $self->{current_token}->{data} .= chr ($self->{next_char}); # comment
1442            !!!next-input-character;            !!!next-input-character;
1443            redo BC;            redo BC;
1444          }          }
# Line 1408  sub _get_next_token ($) { Line 1448  sub _get_next_token ($) {
1448      } elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) {      } elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) {
1449        ## (only happen if PCDATA state)        ## (only happen if PCDATA state)
1450    
1451          my ($l, $c) = ($self->{line_prev}, $self->{column_prev} - 1);
1452    
1453        my @next_char;        my @next_char;
1454        push @next_char, $self->{next_char};        push @next_char, $self->{next_char};
1455                
# Line 1416  sub _get_next_token ($) { Line 1458  sub _get_next_token ($) {
1458          push @next_char, $self->{next_char};          push @next_char, $self->{next_char};
1459          if ($self->{next_char} == 0x002D) { # -          if ($self->{next_char} == 0x002D) { # -
1460            !!!cp (127);            !!!cp (127);
1461            $self->{current_token} = {type => COMMENT_TOKEN, data => ''};            $self->{current_token} = {type => COMMENT_TOKEN, data => '',
1462                                        line => $l, column => $c};
1463            $self->{state} = COMMENT_START_STATE;            $self->{state} = COMMENT_START_STATE;
1464            !!!next-input-character;            !!!next-input-character;
1465            redo A;            redo A;
# Line 1452  sub _get_next_token ($) { Line 1495  sub _get_next_token ($) {
1495                      !!!cp (129);                      !!!cp (129);
1496                      ## TODO: What a stupid code this is!                      ## TODO: What a stupid code this is!
1497                      $self->{state} = DOCTYPE_STATE;                      $self->{state} = DOCTYPE_STATE;
1498                        $self->{current_token} = {type => DOCTYPE_TOKEN,
1499                                                  quirks => 1,
1500                                                  line => $l, column => $c};
1501                      !!!next-input-character;                      !!!next-input-character;
1502                      redo A;                      redo A;
1503                    } else {                    } else {
# Line 1480  sub _get_next_token ($) { Line 1526  sub _get_next_token ($) {
1526        $self->{next_char} = shift @next_char;        $self->{next_char} = shift @next_char;
1527        !!!back-next-input-character (@next_char);        !!!back-next-input-character (@next_char);
1528        $self->{state} = BOGUS_COMMENT_STATE;        $self->{state} = BOGUS_COMMENT_STATE;
1529          $self->{current_token} = {type => COMMENT_TOKEN, data => '',
1530                                    line => $l, column => $c};
1531        redo A;        redo A;
1532                
1533        ## ISSUE: typos in spec: chacacters, is is a parse error        ## ISSUE: typos in spec: chacacters, is is a parse error
# Line 1658  sub _get_next_token ($) { Line 1706  sub _get_next_token ($) {
1706          $self->{state} = DATA_STATE;          $self->{state} = DATA_STATE;
1707          !!!next-input-character;          !!!next-input-character;
1708    
1709          !!!emit ({type => DOCTYPE_TOKEN, quirks => 1});          !!!emit ($self->{current_token}); # DOCTYPE (quirks)
1710    
1711          redo A;          redo A;
1712        } elsif ($self->{next_char} == -1) {        } elsif ($self->{next_char} == -1) {
# Line 1667  sub _get_next_token ($) { Line 1715  sub _get_next_token ($) {
1715          $self->{state} = DATA_STATE;          $self->{state} = DATA_STATE;
1716          ## reconsume          ## reconsume
1717    
1718          !!!emit ({type => DOCTYPE_TOKEN, quirks => 1});          !!!emit ($self->{current_token}); # DOCTYPE (quirks)
1719    
1720          redo A;          redo A;
1721        } else {        } else {
1722          !!!cp (160);          !!!cp (160);
1723          $self->{current_token}          $self->{current_token}->{name} = chr $self->{next_char};
1724              = {type => DOCTYPE_TOKEN,          delete $self->{current_token}->{quirks};
                name => chr ($self->{next_char}),  
                #quirks => 0,  
               };  
1725  ## ISSUE: "Set the token's name name to the" in the spec  ## ISSUE: "Set the token's name name to the" in the spec
1726          $self->{state} = DOCTYPE_NAME_STATE;          $self->{state} = DOCTYPE_NAME_STATE;
1727          !!!next-input-character;          !!!next-input-character;
# Line 2203  sub _get_next_token ($) { Line 2248  sub _get_next_token ($) {
2248  sub _tokenize_attempt_to_consume_an_entity ($$$) {  sub _tokenize_attempt_to_consume_an_entity ($$$) {
2249    my ($self, $in_attr, $additional) = @_;    my ($self, $in_attr, $additional) = @_;
2250    
2251      my ($l, $c) = ($self->{line_prev}, $self->{column_prev});
2252    
2253    if ({    if ({
2254         0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, # HT, LF, VT, FF,         0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, # HT, LF, VT, FF,
2255         0x0020 => 1, 0x003C => 1, 0x0026 => 1, -1 => 1, # SP, <, & # 0x000D # CR         0x0020 => 1, 0x003C => 1, 0x0026 => 1, -1 => 1, # SP, <, & # 0x000D # CR
# Line 2243  sub _tokenize_attempt_to_consume_an_enti Line 2290  sub _tokenize_attempt_to_consume_an_enti
2290            redo X;            redo X;
2291          } elsif (not defined $code) { # no hexadecimal digit          } elsif (not defined $code) { # no hexadecimal digit
2292            !!!cp (1005);            !!!cp (1005);
2293            !!!parse-error (type => 'bare hcro');            !!!parse-error (type => 'bare hcro', line => $l, column => $c);
2294            !!!back-next-input-character ($x_char, $self->{next_char});            !!!back-next-input-character ($x_char, $self->{next_char});
2295            $self->{next_char} = 0x0023; # #            $self->{next_char} = 0x0023; # #
2296            return undef;            return undef;
# Line 2252  sub _tokenize_attempt_to_consume_an_enti Line 2299  sub _tokenize_attempt_to_consume_an_enti
2299            !!!next-input-character;            !!!next-input-character;
2300          } else {          } else {
2301            !!!cp (1007);            !!!cp (1007);
2302            !!!parse-error (type => 'no refc');            !!!parse-error (type => 'no refc', line => $l, column => $c);
2303          }          }
2304    
2305          if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) {          if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) {
2306            !!!cp (1008);            !!!cp (1008);
2307            !!!parse-error (type => sprintf 'invalid character reference:U+%04X', $code);            !!!parse-error (type => (sprintf 'invalid character reference:U+%04X', $code), line => $l, column => $c);
2308            $code = 0xFFFD;            $code = 0xFFFD;
2309          } elsif ($code > 0x10FFFF) {          } elsif ($code > 0x10FFFF) {
2310            !!!cp (1009);            !!!cp (1009);
2311            !!!parse-error (type => sprintf 'invalid character reference:U-%08X', $code);            !!!parse-error (type => (sprintf 'invalid character reference:U-%08X', $code), line => $l, column => $c);
2312            $code = 0xFFFD;            $code = 0xFFFD;
2313          } elsif ($code == 0x000D) {          } elsif ($code == 0x000D) {
2314            !!!cp (1010);            !!!cp (1010);
2315            !!!parse-error (type => 'CR character reference');            !!!parse-error (type => 'CR character reference', line => $l, column => $c);
2316            $code = 0x000A;            $code = 0x000A;
2317          } elsif (0x80 <= $code and $code <= 0x9F) {          } elsif (0x80 <= $code and $code <= 0x9F) {
2318            !!!cp (1011);            !!!cp (1011);
2319            !!!parse-error (type => sprintf 'C1 character reference:U+%04X', $code);            !!!parse-error (type => (sprintf 'C1 character reference:U+%04X', $code), line => $l, column => $c);
2320            $code = $c1_entity_char->{$code};            $code = $c1_entity_char->{$code};
2321          }          }
2322    
2323          return {type => CHARACTER_TOKEN, data => chr $code,          return {type => CHARACTER_TOKEN, data => chr $code,
2324                  has_reference => 1};                  has_reference => 1, line => $l, column => $c};
2325        } # X        } # X
2326      } elsif (0x0030 <= $self->{next_char} and      } elsif (0x0030 <= $self->{next_char} and
2327               $self->{next_char} <= 0x0039) { # 0..9               $self->{next_char} <= 0x0039) { # 0..9
# Line 2295  sub _tokenize_attempt_to_consume_an_enti Line 2342  sub _tokenize_attempt_to_consume_an_enti
2342          !!!next-input-character;          !!!next-input-character;
2343        } else {        } else {
2344          !!!cp (1014);          !!!cp (1014);
2345          !!!parse-error (type => 'no refc');          !!!parse-error (type => 'no refc', line => $l, column => $c);
2346        }        }
2347    
2348        if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) {        if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) {
2349          !!!cp (1015);          !!!cp (1015);
2350          !!!parse-error (type => sprintf 'invalid character reference:U+%04X', $code);          !!!parse-error (type => (sprintf 'invalid character reference:U+%04X', $code), line => $l, column => $c);
2351          $code = 0xFFFD;          $code = 0xFFFD;
2352        } elsif ($code > 0x10FFFF) {        } elsif ($code > 0x10FFFF) {
2353          !!!cp (1016);          !!!cp (1016);
2354          !!!parse-error (type => sprintf 'invalid character reference:U-%08X', $code);          !!!parse-error (type => (sprintf 'invalid character reference:U-%08X', $code), line => $l, column => $c);
2355          $code = 0xFFFD;          $code = 0xFFFD;
2356        } elsif ($code == 0x000D) {        } elsif ($code == 0x000D) {
2357          !!!cp (1017);          !!!cp (1017);
2358          !!!parse-error (type => 'CR character reference');          !!!parse-error (type => 'CR character reference', line => $l, column => $c);
2359          $code = 0x000A;          $code = 0x000A;
2360        } elsif (0x80 <= $code and $code <= 0x9F) {        } elsif (0x80 <= $code and $code <= 0x9F) {
2361          !!!cp (1018);          !!!cp (1018);
2362          !!!parse-error (type => sprintf 'C1 character reference:U+%04X', $code);          !!!parse-error (type => (sprintf 'C1 character reference:U+%04X', $code), line => $l, column => $c);
2363          $code = $c1_entity_char->{$code};          $code = $c1_entity_char->{$code};
2364        }        }
2365                
2366        return {type => CHARACTER_TOKEN, data => chr $code, has_reference => 1};        return {type => CHARACTER_TOKEN, data => chr $code, has_reference => 1,
2367                  line => $l, column => $c};
2368      } else {      } else {
2369        !!!cp (1019);        !!!cp (1019);
2370        !!!parse-error (type => 'bare nero');        !!!parse-error (type => 'bare nero', line => $l, column => $c);
2371        !!!back-next-input-character ($self->{next_char});        !!!back-next-input-character ($self->{next_char});
2372        $self->{next_char} = 0x0023; # #        $self->{next_char} = 0x0023; # #
2373        return undef;        return undef;
# Line 2369  sub _tokenize_attempt_to_consume_an_enti Line 2417  sub _tokenize_attempt_to_consume_an_enti
2417            
2418      if ($match > 0) {      if ($match > 0) {
2419        !!!cp (1023);        !!!cp (1023);
2420        return {type => CHARACTER_TOKEN, data => $value, has_reference => 1};        return {type => CHARACTER_TOKEN, data => $value, has_reference => 1,
2421                  line => $l, column => $c};
2422      } elsif ($match < 0) {      } elsif ($match < 0) {
2423        !!!parse-error (type => 'no refc');        !!!parse-error (type => 'no refc', line => $l, column => $c);
2424        if ($in_attr and $match < -1) {        if ($in_attr and $match < -1) {
2425          !!!cp (1024);          !!!cp (1024);
2426          return {type => CHARACTER_TOKEN, data => '&'.$entity_name};          return {type => CHARACTER_TOKEN, data => '&'.$entity_name,
2427                    line => $l, column => $c};
2428        } else {        } else {
2429          !!!cp (1025);          !!!cp (1025);
2430          return {type => CHARACTER_TOKEN, data => $value, has_reference => 1};          return {type => CHARACTER_TOKEN, data => $value, has_reference => 1,
2431                    line => $l, column => $c};
2432        }        }
2433      } else {      } else {
2434        !!!cp (1026);        !!!cp (1026);
2435        !!!parse-error (type => 'bare ero');        !!!parse-error (type => 'bare ero', line => $l, column => $c);
2436        ## NOTE: "No characters are consumed" in the spec.        ## NOTE: "No characters are consumed" in the spec.
2437        return {type => CHARACTER_TOKEN, data => '&'.$value};        return {type => CHARACTER_TOKEN, data => '&'.$value,
2438                  line => $l, column => $c};
2439      }      }
2440    } else {    } else {
2441      !!!cp (1027);      !!!cp (1027);
2442      ## no characters are consumed      ## no characters are consumed
2443      !!!parse-error (type => 'bare ero');      !!!parse-error (type => 'bare ero', line => $l, column => $c);
2444      return undef;      return undef;
2445    }    }
2446  } # _tokenize_attempt_to_consume_an_entity  } # _tokenize_attempt_to_consume_an_entity
# Line 2903  sub _tree_construction_main ($) { Line 2955  sub _tree_construction_main ($) {
2955      !!!cp ('t39');      !!!cp ('t39');
2956    }; # $clear_up_to_marker    }; # $clear_up_to_marker
2957    
2958    my $parse_rcdata = sub ($$) {    my $insert;
2959      my ($content_model_flag, $insert) = @_;  
2960      my $parse_rcdata = sub ($) {
2961        my ($content_model_flag) = @_;
2962    
2963      ## Step 1      ## Step 1
2964      my $start_tag_name = $token->{tag_name};      my $start_tag_name = $token->{tag_name};
# Line 2912  sub _tree_construction_main ($) { Line 2966  sub _tree_construction_main ($) {
2966      !!!create-element ($el, $start_tag_name, $token->{attributes});      !!!create-element ($el, $start_tag_name, $token->{attributes});
2967    
2968      ## Step 2      ## Step 2
2969      $insert->($el); # /context node/->append_child ($el)      $insert->($el);
2970    
2971      ## Step 3      ## Step 3
2972      $self->{content_model} = $content_model_flag; # CDATA or RCDATA      $self->{content_model} = $content_model_flag; # CDATA or RCDATA
# Line 2942  sub _tree_construction_main ($) { Line 2996  sub _tree_construction_main ($) {
2996          $token->{tag_name} eq $start_tag_name) {          $token->{tag_name} eq $start_tag_name) {
2997        !!!cp ('t42');        !!!cp ('t42');
2998        ## Ignore the token        ## Ignore the token
     } elsif ($content_model_flag == CDATA_CONTENT_MODEL) {  
       !!!cp ('t43');  
       !!!parse-error (type => 'in CDATA:#'.$token->{type});  
     } elsif ($content_model_flag == RCDATA_CONTENT_MODEL) {  
       !!!cp ('t44');  
       !!!parse-error (type => 'in RCDATA:#'.$token->{type});  
2999      } else {      } else {
3000        die "$0: $content_model_flag in parse_rcdata";        ## NOTE: An end-of-file token.
3001          if ($content_model_flag == CDATA_CONTENT_MODEL) {
3002            !!!cp ('t43');
3003            !!!parse-error (type => 'in CDATA:#'.$token->{type});
3004          } elsif ($content_model_flag == RCDATA_CONTENT_MODEL) {
3005            !!!cp ('t44');
3006            !!!parse-error (type => 'in RCDATA:#'.$token->{type});
3007          } else {
3008            die "$0: $content_model_flag in parse_rcdata";
3009          }
3010      }      }
3011      !!!next-token;      !!!next-token;
3012    }; # $parse_rcdata    }; # $parse_rcdata
3013    
3014    my $script_start_tag = sub ($) {    my $script_start_tag = sub () {
     my $insert = $_[0];  
3015      my $script_el;      my $script_el;
3016      !!!create-element ($script_el, 'script', $token->{attributes});      !!!create-element ($script_el, 'script', $token->{attributes});
3017      ## TODO: mark as "parser-inserted"      ## TODO: mark as "parser-inserted"
# Line 3006  sub _tree_construction_main ($) { Line 3062  sub _tree_construction_main ($) {
3062      !!!next-token;      !!!next-token;
3063    }; # $script_start_tag    }; # $script_start_tag
3064    
3065      ## NOTE: $open_tables->[-1]->[0] is the "current table" element node.
3066      ## NOTE: $open_tables->[-1]->[1] is the "tainted" flag.
3067      my $open_tables = [[$self->{open_elements}->[0]->[0]]];
3068    
3069    my $formatting_end_tag = sub {    my $formatting_end_tag = sub {
3070      my $tag_name = shift;      my $tag_name = shift;
3071    
3072        ## NOTE: The adoption agency algorithm (AAA).
3073    
3074      FET: {      FET: {
3075        ## Step 1        ## Step 1
3076        my $formatting_element;        my $formatting_element;
# Line 3049  sub _tree_construction_main ($) { Line 3111  sub _tree_construction_main ($) {
3111              return;              return;
3112            }            }
3113          } elsif ({          } elsif ({
3114                    table => 1, caption => 1, td => 1, th => 1,                    applet => 1, table => 1, caption => 1, td => 1, th => 1,
3115                    button => 1, marquee => 1, object => 1, html => 1,                    button => 1, marquee => 1, object => 1, html => 1,
3116                   }->{$node->[1]}) {                   }->{$node->[1]}) {
3117            !!!cp ('t56');            !!!cp ('t56');
# Line 3076  sub _tree_construction_main ($) { Line 3138  sub _tree_construction_main ($) {
3138          if (not $formatting_category->{$node->[1]} and          if (not $formatting_category->{$node->[1]} and
3139              #not $phrasing_category->{$node->[1]} and              #not $phrasing_category->{$node->[1]} and
3140              ($special_category->{$node->[1]} or              ($special_category->{$node->[1]} or
3141               $scoping_category->{$node->[1]})) {               $scoping_category->{$node->[1]})) { ## Scoping is redundant, maybe
3142            !!!cp ('t59');            !!!cp ('t59');
3143            $furthest_block = $node;            $furthest_block = $node;
3144            $furthest_block_i_in_open = $_;            $furthest_block_i_in_open = $_;
# Line 3162  sub _tree_construction_main ($) { Line 3224  sub _tree_construction_main ($) {
3224        } # S7          } # S7  
3225                
3226        ## Step 8        ## Step 8
3227        $common_ancestor_node->[0]->append_child ($last_node->[0]);        if ({
3228               table => 1, tbody => 1, tfoot => 1, thead => 1, tr => 1,
3229              }->{$common_ancestor_node->[1]}) {
3230            my $foster_parent_element;
3231            my $next_sibling;
3232                             OE: for (reverse 0..$#{$self->{open_elements}}) {
3233                               if ($self->{open_elements}->[$_]->[1] eq 'table') {
3234                                 my $parent = $self->{open_elements}->[$_]->[0]->parent_node;
3235                                 if (defined $parent and $parent->node_type == 1) {
3236                                   !!!cp ('t65.1');
3237                                   $foster_parent_element = $parent;
3238                                   $next_sibling = $self->{open_elements}->[$_]->[0];
3239                                 } else {
3240                                   !!!cp ('t65.2');
3241                                   $foster_parent_element
3242                                     = $self->{open_elements}->[$_ - 1]->[0];
3243                                 }
3244                                 last OE;
3245                               }
3246                             } # OE
3247                             $foster_parent_element = $self->{open_elements}->[0]->[0]
3248                               unless defined $foster_parent_element;
3249            $foster_parent_element->insert_before ($last_node->[0], $next_sibling);
3250            $open_tables->[-1]->[1] = 1; # tainted
3251          } else {
3252            !!!cp ('t65.3');
3253            $common_ancestor_node->[0]->append_child ($last_node->[0]);
3254          }
3255                
3256        ## Step 9        ## Step 9
3257        my $clone = [$formatting_element->[0]->clone_node (0),        my $clone = [$formatting_element->[0]->clone_node (0),
# Line 3208  sub _tree_construction_main ($) { Line 3297  sub _tree_construction_main ($) {
3297      } # FET      } # FET
3298    }; # $formatting_end_tag    }; # $formatting_end_tag
3299    
3300    ## NOTE: $open_tables->[-1]->[0] is the "current table".    $insert = my $insert_to_current = sub {
   ## NOTE: $open_tables->[-1]->[1] is the "tainted" flag.  
   my $open_tables = [[$self->{open_elements}->[0]->[0]]];  
   
   my $insert_to_current = sub {  
3301      $self->{open_elements}->[-1]->[0]->append_child ($_[0]);      $self->{open_elements}->[-1]->[0]->append_child ($_[0]);
3302    }; # $insert_to_current    }; # $insert_to_current
3303    
# Line 3250  sub _tree_construction_main ($) { Line 3335  sub _tree_construction_main ($) {
3335      }      }
3336    }; # $insert_to_foster    }; # $insert_to_foster
3337    
   my $insert;  
   
3338    B: {    B: {
3339      if ($token->{type} == DOCTYPE_TOKEN) {      if ($token->{type} == DOCTYPE_TOKEN) {
3340        !!!cp ('t73');        !!!cp ('t73');
# Line 3260  sub _tree_construction_main ($) { Line 3343  sub _tree_construction_main ($) {
3343        ## Stay in the phase        ## Stay in the phase
3344        !!!next-token;        !!!next-token;
3345        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;  
3346      } elsif ($token->{type} == START_TAG_TOKEN and      } elsif ($token->{type} == START_TAG_TOKEN and
3347               $token->{tag_name} eq 'html') {               $token->{tag_name} eq 'html') {
3348        if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {        if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
# Line 3336  sub _tree_construction_main ($) { Line 3387  sub _tree_construction_main ($) {
3387      } elsif ($self->{insertion_mode} & HEAD_IMS) {      } elsif ($self->{insertion_mode} & HEAD_IMS) {
3388        if ($token->{type} == CHARACTER_TOKEN) {        if ($token->{type} == CHARACTER_TOKEN) {
3389          if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {          if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {
3390            $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);            unless ($self->{insertion_mode} == BEFORE_HEAD_IM) {
3391                !!!cp ('t88.2');
3392                $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);
3393              } else {
3394                !!!cp ('t88.1');
3395                ## Ignore the token.
3396                !!!next-token;
3397                redo B;
3398              }
3399            unless (length $token->{data}) {            unless (length $token->{data}) {
3400              !!!cp ('t88');              !!!cp ('t88');
3401              !!!next-token;              !!!next-token;
# Line 3437  sub _tree_construction_main ($) { Line 3496  sub _tree_construction_main ($) {
3496                }                }
3497                !!!insert-element ($token->{tag_name}, $token->{attributes});                !!!insert-element ($token->{tag_name}, $token->{attributes});
3498                pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.                pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
3499                pop @{$self->{open_elements}}                pop @{$self->{open_elements}} # <head>
3500                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
3501                !!!next-token;                !!!next-token;
3502                redo B;                redo B;
# Line 3452  sub _tree_construction_main ($) { Line 3511  sub _tree_construction_main ($) {
3511                }                }
3512                !!!insert-element ($token->{tag_name}, $token->{attributes});                !!!insert-element ($token->{tag_name}, $token->{attributes});
3513                pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.                pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
3514                pop @{$self->{open_elements}}                pop @{$self->{open_elements}} # <head>
3515                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
3516                !!!next-token;                !!!next-token;
3517                redo B;                redo B;
# Line 3513  sub _tree_construction_main ($) { Line 3572  sub _tree_construction_main ($) {
3572                  }                  }
3573                }                }
3574    
3575                pop @{$self->{open_elements}}                pop @{$self->{open_elements}} # <head>
3576                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
3577                !!!next-token;                !!!next-token;
3578                redo B;                redo B;
# Line 3537  sub _tree_construction_main ($) { Line 3596  sub _tree_construction_main ($) {
3596                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
3597                my $parent = defined $self->{head_element} ? $self->{head_element}                my $parent = defined $self->{head_element} ? $self->{head_element}
3598                    : $self->{open_elements}->[-1]->[0];                    : $self->{open_elements}->[-1]->[0];
3599                $parse_rcdata->(RCDATA_CONTENT_MODEL,                $parse_rcdata->(RCDATA_CONTENT_MODEL);
3600                                sub { $parent->append_child ($_[0]) });                pop @{$self->{open_elements}} # <head>
               pop @{$self->{open_elements}}  
3601                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
3602                redo B;                redo B;
3603              } elsif ($token->{tag_name} eq 'style') {              } elsif ($token->{tag_name} eq 'style') {
# Line 3553  sub _tree_construction_main ($) { Line 3611  sub _tree_construction_main ($) {
3611                } else {                } else {
3612                  !!!cp ('t115');                  !!!cp ('t115');
3613                }                }
3614                $parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current);                $parse_rcdata->(CDATA_CONTENT_MODEL);
3615                pop @{$self->{open_elements}}                pop @{$self->{open_elements}} # <head>
3616                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
3617                redo B;                redo B;
3618              } elsif ($token->{tag_name} eq 'noscript') {              } elsif ($token->{tag_name} eq 'noscript') {
# Line 3593  sub _tree_construction_main ($) { Line 3651  sub _tree_construction_main ($) {
3651                }                }
3652    
3653                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
3654                $script_start_tag->($insert_to_current);                $script_start_tag->();
3655                pop @{$self->{open_elements}}                pop @{$self->{open_elements}} # <head>
3656                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
3657                redo B;                redo B;
3658              } elsif ($token->{tag_name} eq 'body' or              } elsif ($token->{tag_name} eq 'body' or
# Line 3803  sub _tree_construction_main ($) { Line 3861  sub _tree_construction_main ($) {
3861              $self->{insertion_mode} = IN_BODY_IM;              $self->{insertion_mode} = IN_BODY_IM;
3862              ## reprocess              ## reprocess
3863              redo B;              redo B;
3864            } else {        } elsif ($token->{type} == END_OF_FILE_TOKEN) {
3865              die "$0: $token->{type}: Unknown token type";          if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
3866            }            !!!cp ('t149.1');
3867    
3868              ## NOTE: As if <head>
3869              !!!create-element ($self->{head_element}, 'head');
3870              $self->{open_elements}->[-1]->[0]->append_child
3871                  ($self->{head_element});
3872              #push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
3873              #$self->{insertion_mode} = IN_HEAD_IM;
3874              ## NOTE: Reprocess.
3875    
3876              ## NOTE: As if </head>
3877              #pop @{$self->{open_elements}};
3878              #$self->{insertion_mode} = IN_AFTER_HEAD_IM;
3879              ## NOTE: Reprocess.
3880              
3881              #
3882            } elsif ($self->{insertion_mode} == IN_HEAD_IM) {
3883              !!!cp ('t149.2');
3884    
3885              ## NOTE: As if </head>
3886              pop @{$self->{open_elements}};
3887              #$self->{insertion_mode} = IN_AFTER_HEAD_IM;
3888              ## NOTE: Reprocess.
3889    
3890              #
3891            } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
3892              !!!cp ('t149.3');
3893    
3894              !!!parse-error (type => 'in noscript:#eof');
3895    
3896              ## As if </noscript>
3897              pop @{$self->{open_elements}};
3898              #$self->{insertion_mode} = IN_HEAD_IM;
3899              ## NOTE: Reprocess.
3900    
3901              ## NOTE: As if </head>
3902              pop @{$self->{open_elements}};
3903              #$self->{insertion_mode} = IN_AFTER_HEAD_IM;
3904              ## NOTE: Reprocess.
3905    
3906              #
3907            } else {
3908              !!!cp ('t149.4');
3909              #
3910            }
3911    
3912            ## NOTE: As if <body>
3913            !!!insert-element ('body');
3914            $self->{insertion_mode} = IN_BODY_IM;
3915            ## NOTE: Reprocess.
3916            redo B;
3917          } else {
3918            die "$0: $token->{type}: Unknown token type";
3919          }
3920    
3921            ## ISSUE: An issue in the spec.            ## ISSUE: An issue in the spec.
3922      } elsif ($self->{insertion_mode} & BODY_IMS) {      } elsif ($self->{insertion_mode} & BODY_IMS) {
# Line 3825  sub _tree_construction_main ($) { Line 3936  sub _tree_construction_main ($) {
3936                  }->{$token->{tag_name}}) {                  }->{$token->{tag_name}}) {
3937                if ($self->{insertion_mode} == IN_CELL_IM) {                if ($self->{insertion_mode} == IN_CELL_IM) {
3938                  ## have an element in table scope                  ## have an element in table scope
3939                  my $tn;                  for (reverse 0..$#{$self->{open_elements}}) {
                 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {  
3940                    my $node = $self->{open_elements}->[$_];                    my $node = $self->{open_elements}->[$_];
3941                    if ($node->[1] eq 'td' or $node->[1] eq 'th') {                    if ($node->[1] eq 'td' or $node->[1] eq 'th') {
3942                      !!!cp ('t151');                      !!!cp ('t151');
3943                      $tn = $node->[1];  
3944                      last INSCOPE;                      ## Close the cell
3945                        !!!back-token; # <?>
3946                        $token = {type => END_TAG_TOKEN, tag_name => $node->[1]};
3947                        redo B;
3948                    } elsif ({                    } elsif ({
3949                              table => 1, html => 1,                              table => 1, html => 1,
3950                             }->{$node->[1]}) {                             }->{$node->[1]}) {
3951                      !!!cp ('t152');                      !!!cp ('t152');
3952                      last INSCOPE;                      ## ISSUE: This case can never be reached, maybe.
3953                    }                      last;
                 } # INSCOPE  
                   unless (defined $tn) {  
                     !!!cp ('t153');  
 ## TODO: This error type is wrong.  
                     !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});  
                     ## Ignore the token  
                     !!!next-token;  
                     redo B;  
3954                    }                    }
3955                                    }
3956                  !!!cp ('t154');  
3957                  ## Close the cell                  !!!cp ('t153');
3958                  !!!back-token; # <?>                  !!!parse-error (type => 'start tag not allowed',
3959                  $token = {type => END_TAG_TOKEN, tag_name => $tn};                      value => $token->{tag_name});
3960                    ## Ignore the token
3961                    !!!next-token;
3962                  redo B;                  redo B;
3963                } elsif ($self->{insertion_mode} == IN_CAPTION_IM) {                } elsif ($self->{insertion_mode} == IN_CAPTION_IM) {
3964                  !!!parse-error (type => 'not closed:caption');                  !!!parse-error (type => 'not closed:caption');
3965                                    
3966                  ## As if </caption>                  ## NOTE: As if </caption>.
3967                  ## have a table element in table scope                  ## have a table element in table scope
3968                  my $i;                  my $i;
3969                  INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {                  INSCOPE: {
3970                    my $node = $self->{open_elements}->[$_];                    for (reverse 0..$#{$self->{open_elements}}) {
3971                    if ($node->[1] eq 'caption') {                      my $node = $self->{open_elements}->[$_];
3972                      !!!cp ('t155');                      if ($node->[1] eq 'caption') {
3973                      $i = $_;                        !!!cp ('t155');
3974                      last INSCOPE;                        $i = $_;
3975                    } elsif ({                        last INSCOPE;
3976                              table => 1, html => 1,                      } elsif ({
3977                             }->{$node->[1]}) {                                table => 1, html => 1,
3978                      !!!cp ('t156');                               }->{$node->[1]}) {
3979                      last INSCOPE;                        !!!cp ('t156');
3980                          last;
3981                        }
3982                    }                    }
3983    
3984                      !!!cp ('t157');
3985                      !!!parse-error (type => 'start tag not allowed',
3986                                      value => $token->{tag_name});
3987                      ## Ignore the token
3988                      !!!next-token;
3989                      redo B;
3990                  } # INSCOPE                  } # INSCOPE
                   unless (defined $i) {  
                     !!!cp ('t157');  
 ## TODO: this type is wrong.  
                     !!!parse-error (type => 'unmatched end tag:caption');  
                     ## Ignore the token  
                     !!!next-token;  
                     redo B;  
                   }  
3991                                    
3992                  ## generate implied end tags                  ## generate implied end tags
3993                  while ({                  while ({
# Line 3975  sub _tree_construction_main ($) { Line 4083  sub _tree_construction_main ($) {
4083                if ($self->{insertion_mode} == IN_CAPTION_IM) {                if ($self->{insertion_mode} == IN_CAPTION_IM) {
4084                  ## have a table element in table scope                  ## have a table element in table scope
4085                  my $i;                  my $i;
4086                  INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {                  INSCOPE: {
4087                    my $node = $self->{open_elements}->[$_];                    for (reverse 0..$#{$self->{open_elements}}) {
4088                    if ($node->[1] eq $token->{tag_name}) {                      my $node = $self->{open_elements}->[$_];
4089                      !!!cp ('t171');                      if ($node->[1] eq $token->{tag_name}) {
4090                      $i = $_;                        !!!cp ('t171');
4091                      last INSCOPE;                        $i = $_;
4092                    } elsif ({                        last INSCOPE;
4093                              table => 1, html => 1,                      } elsif ({
4094                             }->{$node->[1]}) {                                table => 1, html => 1,
4095                      !!!cp ('t172');                               }->{$node->[1]}) {
4096                      last INSCOPE;                        !!!cp ('t172');
4097                          last;
4098                        }
4099                    }                    }
4100    
4101                      !!!cp ('t173');
4102                      !!!parse-error (type => 'unmatched end tag',
4103                                      value => $token->{tag_name});
4104                      ## Ignore the token
4105                      !!!next-token;
4106                      redo B;
4107                  } # INSCOPE                  } # INSCOPE
                   unless (defined $i) {  
                     !!!cp ('t173');  
                     !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});  
                     ## Ignore the token  
                     !!!next-token;  
                     redo B;  
                   }  
4108                                    
4109                  ## generate implied end tags                  ## generate implied end tags
4110                  while ({                  while ({
# Line 4037  sub _tree_construction_main ($) { Line 4147  sub _tree_construction_main ($) {
4147                ## have an element in table scope                ## have an element in table scope
4148                my $i;                my $i;
4149                my $tn;                my $tn;
4150                INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {                INSCOPE: {
4151                  my $node = $self->{open_elements}->[$_];                  for (reverse 0..$#{$self->{open_elements}}) {
4152                  if ($node->[1] eq $token->{tag_name}) {                    my $node = $self->{open_elements}->[$_];
4153                    !!!cp ('t179');                    if ($node->[1] eq $token->{tag_name}) {
4154                    $i = $_;                      !!!cp ('t179');
4155                    last INSCOPE;                      $i = $_;
4156                  } elsif ($node->[1] eq 'td' or $node->[1] eq 'th') {  
4157                    !!!cp ('t180');                      ## Close the cell
4158                    $tn = $node->[1];                      !!!back-token; # </?>
4159                    ## NOTE: There is exactly one |td| or |th| element                      $token = {type => END_TAG_TOKEN, tag_name => $tn};
4160                    ## in scope in the stack of open elements by definition.                      redo B;
4161                  } elsif ({                    } elsif ($node->[1] eq 'td' or $node->[1] eq 'th') {
4162                            table => 1, html => 1,                      !!!cp ('t180');
4163                           }->{$node->[1]}) {                      $tn = $node->[1];
4164                    !!!cp ('t181');                      ## NOTE: There is exactly one |td| or |th| element
4165                    last INSCOPE;                      ## in scope in the stack of open elements by definition.
4166                      } elsif ({
4167                                table => 1, html => 1,
4168                               }->{$node->[1]}) {
4169                        ## ISSUE: Can this be reached?
4170                        !!!cp ('t181');
4171                        last;
4172                      }
4173                  }                  }
4174                } # INSCOPE  
               unless (defined $i) {  
4175                  !!!cp ('t182');                  !!!cp ('t182');
4176                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                  !!!parse-error (type => 'unmatched end tag',
4177                        value => $token->{tag_name});
4178                  ## Ignore the token                  ## Ignore the token
4179                  !!!next-token;                  !!!next-token;
4180                  redo B;                  redo B;
4181                } else {                } # INSCOPE
                 !!!cp ('t183');  
               }  
   
               ## Close the cell  
               !!!back-token; # </?>  
               $token = {type => END_TAG_TOKEN, tag_name => $tn};  
               redo B;  
4182              } elsif ($token->{tag_name} eq 'table' and              } elsif ($token->{tag_name} eq 'table' and
4183                       $self->{insertion_mode} == IN_CAPTION_IM) {                       $self->{insertion_mode} == IN_CAPTION_IM) {
4184                !!!parse-error (type => 'not closed:caption');                !!!parse-error (type => 'not closed:caption');
# Line 4147  sub _tree_construction_main ($) { Line 4257  sub _tree_construction_main ($) {
4257                !!!cp ('t193');                !!!cp ('t193');
4258                #                #
4259              }              }
4260          } elsif ($token->{type} == END_OF_FILE_TOKEN) {
4261            for my $entry (@{$self->{open_elements}}) {
4262              if (not {
4263                dd => 1, dt => 1, li => 1, p => 1, tbody => 1, td => 1, tfoot => 1,
4264                th => 1, thead => 1, tr => 1, body => 1, html => 1,
4265              }->{$entry->[1]}) {
4266                !!!cp ('t75');
4267                !!!parse-error (type => 'in body:#eof');
4268                last;
4269              }
4270            }
4271    
4272            ## Stop parsing.
4273            last B;
4274        } else {        } else {
4275          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
4276        }        }
# Line 4460  sub _tree_construction_main ($) { Line 4584  sub _tree_construction_main ($) {
4584                  redo B;                  redo B;
4585                }                }
4586                                
4587    ## TODO: Followings are removed from the latest spec.
4588                ## generate implied end tags                ## generate implied end tags
4589                while ({                while ({
4590                        dd => 1, dt => 1, li => 1, p => 1,                        dd => 1, dt => 1, li => 1, p => 1,
# Line 4483  sub _tree_construction_main ($) { Line 4608  sub _tree_construction_main ($) {
4608    
4609                ## reprocess                ## reprocess
4610                redo B;                redo B;
4611            } elsif ($token->{tag_name} eq 'style') {
4612              if (not $open_tables->[-1]->[1]) { # tainted
4613                !!!cp ('t227.8');
4614                ## NOTE: This is a "as if in head" code clone.
4615                $parse_rcdata->(CDATA_CONTENT_MODEL);
4616                redo B;
4617              } else {
4618                !!!cp ('t227.7');
4619                #
4620              }
4621            } elsif ($token->{tag_name} eq 'script') {
4622              if (not $open_tables->[-1]->[1]) { # tainted
4623                !!!cp ('t227.6');
4624                ## NOTE: This is a "as if in head" code clone.
4625                $script_start_tag->();
4626                redo B;
4627              } else {
4628                !!!cp ('t227.5');
4629                #
4630              }
4631            } elsif ($token->{tag_name} eq 'input') {
4632              if (not $open_tables->[-1]->[1]) { # tainted
4633                if ($token->{attributes}->{type}) { ## TODO: case
4634                  my $type = lc $token->{attributes}->{type}->{value};
4635                  if ($type eq 'hidden') {
4636                    !!!cp ('t227.3');
4637                    !!!parse-error (type => 'in table:'.$token->{tag_name});
4638    
4639                    !!!insert-element ($token->{tag_name}, $token->{attributes});
4640    
4641                    ## TODO: form element pointer
4642    
4643                    pop @{$self->{open_elements}};
4644    
4645                    !!!next-token;
4646                    redo B;
4647                  } else {
4648                    !!!cp ('t227.2');
4649                    #
4650                  }
4651                } else {
4652                  !!!cp ('t227.1');
4653                  #
4654                }
4655              } else {
4656                !!!cp ('t227.4');
4657                #
4658              }
4659          } else {          } else {
4660            !!!cp ('t227');            !!!cp ('t227');
           !!!parse-error (type => 'in table:'.$token->{tag_name});  
   
           $insert = $insert_to_foster;  
4661            #            #
4662          }          }
4663    
4664            !!!parse-error (type => 'in table:'.$token->{tag_name});
4665    
4666            $insert = $insert_to_foster;
4667            #
4668        } elsif ($token->{type} == END_TAG_TOKEN) {        } elsif ($token->{type} == END_TAG_TOKEN) {
4669              if ($token->{tag_name} eq 'tr' and              if ($token->{tag_name} eq 'tr' and
4670                  $self->{insertion_mode} == IN_ROW_IM) {                  $self->{insertion_mode} == IN_ROW_IM) {
# Line 4773  sub _tree_construction_main ($) { Line 4948  sub _tree_construction_main ($) {
4948            $insert = $insert_to_foster;            $insert = $insert_to_foster;
4949            #            #
4950          }          }
4951          } elsif ($token->{type} == END_OF_FILE_TOKEN) {
4952            unless ($self->{open_elements}->[-1]->[1] eq 'html' and
4953                    @{$self->{open_elements}} == 1) { # redundant, maybe
4954              !!!parse-error (type => 'in body:#eof');
4955              !!!cp ('t259.1');
4956              #
4957            } else {
4958              !!!cp ('t259.2');
4959              #
4960            }
4961    
4962            ## Stop parsing
4963            last B;
4964        } else {        } else {
4965          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
4966        }        }
# Line 4825  sub _tree_construction_main ($) { Line 5013  sub _tree_construction_main ($) {
5013                !!!cp ('t267');                !!!cp ('t267');
5014                #                #
5015              }              }
5016            } else {        } elsif ($token->{type} == END_OF_FILE_TOKEN) {
5017              die "$0: $token->{type}: Unknown token type";          if ($self->{open_elements}->[-1]->[1] eq 'html' or
5018            }              @{$self->{open_elements}} == 1) { # redundant, maybe
5019              !!!cp ('t270.2');
5020              ## Stop parsing.
5021              last B;
5022            } else {
5023              ## NOTE: As if </colgroup>.
5024              !!!cp ('t270.1');
5025              pop @{$self->{open_elements}}; # colgroup
5026              $self->{insertion_mode} = IN_TABLE_IM;
5027              ## Reprocess.
5028              redo B;
5029            }
5030          } else {
5031            die "$0: $token->{type}: Unknown token type";
5032          }
5033    
5034            ## As if </colgroup>            ## As if </colgroup>
5035            if ($self->{open_elements}->[-1]->[1] eq 'html') {            if ($self->{open_elements}->[-1]->[1] eq 'html') {
5036              !!!cp ('t269');              !!!cp ('t269');
5037    ## TODO: Wrong error type?
5038              !!!parse-error (type => 'unmatched end tag:colgroup');              !!!parse-error (type => 'unmatched end tag:colgroup');
5039              ## Ignore the token              ## Ignore the token
5040              !!!next-token;              !!!next-token;
# Line 4843  sub _tree_construction_main ($) { Line 5046  sub _tree_construction_main ($) {
5046              ## reprocess              ## reprocess
5047              redo B;              redo B;
5048            }            }
5049      } elsif ($self->{insertion_mode} == IN_SELECT_IM) {      } elsif ($self->{insertion_mode} & SELECT_IMS) {
5050        if ($token->{type} == CHARACTER_TOKEN) {        if ($token->{type} == CHARACTER_TOKEN) {
5051          !!!cp ('t271');          !!!cp ('t271');
5052          $self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data});          $self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data});
# Line 4882  sub _tree_construction_main ($) { Line 5085  sub _tree_construction_main ($) {
5085                !!!insert-element ($token->{tag_name}, $token->{attributes});                !!!insert-element ($token->{tag_name}, $token->{attributes});
5086                !!!next-token;                !!!next-token;
5087                redo B;                redo B;
5088              } elsif ($token->{tag_name} eq 'select') {          } elsif ($token->{tag_name} eq 'select' or
5089  ## TODO: The type below is not good - <select> is replaced by </select>                   $token->{tag_name} eq 'input' or
5090                !!!parse-error (type => 'not closed:select');                   ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and
5091                ## As if </select> instead                    {
5092                       caption => 1, table => 1,
5093                       tbody => 1, tfoot => 1, thead => 1,
5094                       tr => 1, td => 1, th => 1,
5095                      }->{$token->{tag_name}})) {
5096              ## TODO: The type below is not good - <select> is replaced by </select>
5097              !!!parse-error (type => 'not closed:select');
5098              ## NOTE: As if the token were </select> (<select> case) or
5099              ## as if there were </select> (otherwise).
5100                ## have an element in table scope                ## have an element in table scope
5101                my $i;                my $i;
5102                INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {                INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
5103                  my $node = $self->{open_elements}->[$_];                  my $node = $self->{open_elements}->[$_];
5104                  if ($node->[1] eq $token->{tag_name}) {                  if ($node->[1] eq 'select') {
5105                    !!!cp ('t278');                    !!!cp ('t278');
5106                    $i = $_;                    $i = $_;
5107                    last INSCOPE;                    last INSCOPE;
# Line 4914  sub _tree_construction_main ($) { Line 5125  sub _tree_construction_main ($) {
5125    
5126                $self->_reset_insertion_mode;                $self->_reset_insertion_mode;
5127    
5128                !!!next-token;            if ($token->{tag_name} eq 'select') {
5129                redo B;              !!!cp ('t281.2');
5130                !!!next-token;
5131                redo B;
5132              } else {
5133                !!!cp ('t281.1');
5134                ## Reprocess the token.
5135                redo B;
5136              }
5137          } else {          } else {
5138            !!!cp ('t282');            !!!cp ('t282');
5139            !!!parse-error (type => 'in select:'.$token->{tag_name});            !!!parse-error (type => 'in select:'.$token->{tag_name});
# Line 4982  sub _tree_construction_main ($) { Line 5200  sub _tree_construction_main ($) {
5200    
5201                !!!next-token;                !!!next-token;
5202                redo B;                redo B;
5203              } elsif ({          } elsif ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and
5204                        caption => 1, table => 1, tbody => 1,                   {
5205                        tfoot => 1, thead => 1, tr => 1, td => 1, th => 1,                    caption => 1, table => 1, tbody => 1,
5206                       }->{$token->{tag_name}}) {                    tfoot => 1, thead => 1, tr => 1, td => 1, th => 1,
5207                     }->{$token->{tag_name}}) {
5208  ## TODO: The following is wrong?  ## TODO: The following is wrong?
5209                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});
5210                                
# Line 5051  sub _tree_construction_main ($) { Line 5270  sub _tree_construction_main ($) {
5270            !!!next-token;            !!!next-token;
5271            redo B;            redo B;
5272          }          }
5273          } elsif ($token->{type} == END_OF_FILE_TOKEN) {
5274            unless ($self->{open_elements}->[-1]->[1] eq 'html' and
5275                    @{$self->{open_elements}} == 1) { # redundant, maybe
5276              !!!cp ('t299.1');
5277              !!!parse-error (type => 'in body:#eof');
5278            } else {
5279              !!!cp ('t299.2');
5280            }
5281    
5282            ## Stop parsing.
5283            last B;
5284        } else {        } else {
5285          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
5286        }        }
# Line 5134  sub _tree_construction_main ($) { Line 5364  sub _tree_construction_main ($) {
5364            ## reprocess            ## reprocess
5365            redo B;            redo B;
5366          }          }
5367          } elsif ($token->{type} == END_OF_FILE_TOKEN) {
5368            !!!cp ('t309.2');
5369            ## Stop parsing
5370            last B;
5371        } else {        } else {
5372          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
5373        }        }
# Line 5204  sub _tree_construction_main ($) { Line 5438  sub _tree_construction_main ($) {
5438          } elsif ($token->{tag_name} eq 'noframes') {          } elsif ($token->{tag_name} eq 'noframes') {
5439            !!!cp ('t320');            !!!cp ('t320');
5440            ## NOTE: As if in body.            ## NOTE: As if in body.
5441            $parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current);            $parse_rcdata->(CDATA_CONTENT_MODEL);
5442            redo B;            redo B;
5443          } else {          } else {
5444            if ($self->{insertion_mode} == IN_FRAMESET_IM) {            if ($self->{insertion_mode} == IN_FRAMESET_IM) {
# Line 5269  sub _tree_construction_main ($) { Line 5503  sub _tree_construction_main ($) {
5503            !!!next-token;            !!!next-token;
5504            redo B;            redo B;
5505          }          }
5506          } elsif ($token->{type} == END_OF_FILE_TOKEN) {
5507            unless ($self->{open_elements}->[-1]->[1] eq 'html' and
5508                    @{$self->{open_elements}} == 1) { # redundant, maybe
5509              !!!cp ('t331.1');
5510              !!!parse-error (type => 'in body:#eof');
5511            } else {
5512              !!!cp ('t331.2');
5513            }
5514            
5515            ## Stop parsing
5516            last B;
5517        } else {        } else {
5518          die "$0: $token->{type}: Unknown token type";          die "$0: $token->{type}: Unknown token type";
5519        }        }
# Line 5283  sub _tree_construction_main ($) { Line 5528  sub _tree_construction_main ($) {
5528        if ($token->{tag_name} eq 'script') {        if ($token->{tag_name} eq 'script') {
5529          !!!cp ('t332');          !!!cp ('t332');
5530          ## NOTE: This is an "as if in head" code clone          ## NOTE: This is an "as if in head" code clone
5531          $script_start_tag->($insert);          $script_start_tag->();
5532          redo B;          redo B;
5533        } elsif ($token->{tag_name} eq 'style') {        } elsif ($token->{tag_name} eq 'style') {
5534          !!!cp ('t333');          !!!cp ('t333');
5535          ## NOTE: This is an "as if in head" code clone          ## NOTE: This is an "as if in head" code clone
5536          $parse_rcdata->(CDATA_CONTENT_MODEL, $insert);          $parse_rcdata->(CDATA_CONTENT_MODEL);
5537          redo B;          redo B;
5538        } elsif ({        } elsif ({
5539                  base => 1, link => 1,                  base => 1, link => 1,
# Line 5351  sub _tree_construction_main ($) { Line 5596  sub _tree_construction_main ($) {
5596          redo B;          redo B;
5597        } elsif ($token->{tag_name} eq 'title') {        } elsif ($token->{tag_name} eq 'title') {
5598          !!!cp ('t341');          !!!cp ('t341');
         !!!parse-error (type => 'in body:title');  
5599          ## NOTE: This is an "as if in head" code clone          ## NOTE: This is an "as if in head" code clone
5600          $parse_rcdata->(RCDATA_CONTENT_MODEL, sub {          $parse_rcdata->(RCDATA_CONTENT_MODEL);
           if (defined $self->{head_element}) {  
             !!!cp ('t339');  
             $self->{head_element}->append_child ($_[0]);  
           } else {  
             !!!cp ('t340');  
             $insert->($_[0]);  
           }  
         });  
5601          redo B;          redo B;
5602        } elsif ($token->{tag_name} eq 'body') {        } elsif ($token->{tag_name} eq 'body') {
5603          !!!parse-error (type => 'in body:body');          !!!parse-error (type => 'in body:body');
# Line 5387  sub _tree_construction_main ($) { Line 5623  sub _tree_construction_main ($) {
5623                  address => 1, blockquote => 1, center => 1, dir => 1,                  address => 1, blockquote => 1, center => 1, dir => 1,
5624                  div => 1, dl => 1, fieldset => 1,                  div => 1, dl => 1, fieldset => 1,
5625                  h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,                  h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,
5626                  listing => 1, menu => 1, ol => 1, p => 1, ul => 1,                  menu => 1, ol => 1, p => 1, ul => 1,
5627                  pre => 1,                  pre => 1, listing => 1,
5628                    form => 1,
5629                    table => 1,
5630                    hr => 1,
5631                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
5632            if ($token->{tag_name} eq 'form' and defined $self->{form_element}) {
5633              !!!cp ('t350');
5634              !!!parse-error (type => 'in form:form');
5635              ## Ignore the token
5636              !!!next-token;
5637              redo B;
5638            }
5639    
5640          ## has a p element in scope          ## has a p element in scope
5641          INSCOPE: for (reverse @{$self->{open_elements}}) {          INSCOPE: for (reverse @{$self->{open_elements}}) {
5642            if ($_->[1] eq 'p') {            if ($_->[1] eq 'p') {
# Line 5398  sub _tree_construction_main ($) { Line 5645  sub _tree_construction_main ($) {
5645              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5646              redo B;              redo B;
5647            } elsif ({            } elsif ({
5648                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5649                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5650                     }->{$_->[1]}) {                     }->{$_->[1]}) {
5651              !!!cp ('t345');              !!!cp ('t345');
# Line 5407  sub _tree_construction_main ($) { Line 5654  sub _tree_construction_main ($) {
5654          } # INSCOPE          } # INSCOPE
5655                        
5656          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes});
5657          if ($token->{tag_name} eq 'pre') {          if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') {
5658            !!!next-token;            !!!next-token;
5659            if ($token->{type} == CHARACTER_TOKEN) {            if ($token->{type} == CHARACTER_TOKEN) {
5660              $token->{data} =~ s/^\x0A//;              $token->{data} =~ s/^\x0A//;
# Line 5420  sub _tree_construction_main ($) { Line 5667  sub _tree_construction_main ($) {
5667            } else {            } else {
5668              !!!cp ('t348');              !!!cp ('t348');
5669            }            }
5670          } else {          } elsif ($token->{tag_name} eq 'form') {
5671            !!!cp ('t347');            !!!cp ('t347.1');
5672              $self->{form_element} = $self->{open_elements}->[-1]->[0];
5673    
5674            !!!next-token;            !!!next-token;
5675          }          } elsif ($token->{tag_name} eq 'table') {
5676          redo B;            !!!cp ('t382');
5677        } elsif ($token->{tag_name} eq 'form') {            push @{$open_tables}, [$self->{open_elements}->[-1]->[0]];
5678          if (defined $self->{form_element}) {            
5679            !!!cp ('t350');            $self->{insertion_mode} = IN_TABLE_IM;
5680            !!!parse-error (type => 'in form:form');  
5681            ## Ignore the token            !!!next-token;
5682            } elsif ($token->{tag_name} eq 'hr') {
5683              !!!cp ('t386');
5684              pop @{$self->{open_elements}};
5685            
5686            !!!next-token;            !!!next-token;
           redo B;  
5687          } else {          } else {
5688            ## has a p element in scope            !!!cp ('t347');
           INSCOPE: for (reverse @{$self->{open_elements}}) {  
             if ($_->[1] eq 'p') {  
               !!!cp ('t351');  
               !!!back-token;  
               $token = {type => END_TAG_TOKEN, tag_name => 'p'};  
               redo B;  
             } elsif ({  
                       table => 1, caption => 1, td => 1, th => 1,  
                       button => 1, marquee => 1, object => 1, html => 1,  
                      }->{$_->[1]}) {  
               !!!cp ('t352');  
               last INSCOPE;  
             }  
           } # INSCOPE  
               
           !!!insert-element-t ($token->{tag_name}, $token->{attributes});  
           $self->{form_element} = $self->{open_elements}->[-1]->[0];  
5689            !!!next-token;            !!!next-token;
           redo B;  
5690          }          }
5691        } elsif ($token->{tag_name} eq 'li') {          redo B;
5692          } elsif ({li => 1, dt => 1, dd => 1}->{$token->{tag_name}}) {
5693          ## has a p element in scope          ## has a p element in scope
5694          INSCOPE: for (reverse @{$self->{open_elements}}) {          INSCOPE: for (reverse @{$self->{open_elements}}) {
5695            if ($_->[1] eq 'p') {            if ($_->[1] eq 'p') {
# Line 5463  sub _tree_construction_main ($) { Line 5698  sub _tree_construction_main ($) {
5698              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5699              redo B;              redo B;
5700            } elsif ({            } elsif ({
5701                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5702                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5703                     }->{$_->[1]}) {                     }->{$_->[1]}) {
5704              !!!cp ('t354');              !!!cp ('t354');
# Line 5474  sub _tree_construction_main ($) { Line 5709  sub _tree_construction_main ($) {
5709          ## Step 1          ## Step 1
5710          my $i = -1;          my $i = -1;
5711          my $node = $self->{open_elements}->[$i];          my $node = $self->{open_elements}->[$i];
5712            my $li_or_dtdd = {li => {li => 1},
5713                              dt => {dt => 1, dd => 1},
5714                              dd => {dt => 1, dd => 1}}->{$token->{tag_name}};
5715          LI: {          LI: {
5716            ## Step 2            ## Step 2
5717            if ($node->[1] eq 'li') {            if ($li_or_dtdd->{$node->[1]}) {
5718              if ($i != -1) {              if ($i != -1) {
5719                !!!cp ('t355');                !!!cp ('t355');
5720                !!!parse-error (type => 'end tag missing:'.                !!!parse-error (type => 'end tag missing:'.
# Line 5510  sub _tree_construction_main ($) { Line 5748  sub _tree_construction_main ($) {
5748          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes});
5749          !!!next-token;          !!!next-token;
5750          redo B;          redo B;
       } elsif ($token->{tag_name} eq 'dd' or $token->{tag_name} eq 'dt') {  
         ## has a p element in scope  
         INSCOPE: for (reverse @{$self->{open_elements}}) {  
           if ($_->[1] eq 'p') {  
             !!!cp ('t360');  
             !!!back-token;  
             $token = {type => END_TAG_TOKEN, tag_name => 'p'};  
             redo B;  
           } elsif ({  
                     table => 1, caption => 1, td => 1, th => 1,  
                     button => 1, marquee => 1, object => 1, html => 1,  
                    }->{$_->[1]}) {  
             !!!cp ('t361');  
             last INSCOPE;  
           }  
         } # INSCOPE  
             
         ## Step 1  
         my $i = -1;  
         my $node = $self->{open_elements}->[$i];  
         LI: {  
           ## Step 2  
           if ($node->[1] eq 'dt' or $node->[1] eq 'dd') {  
             if ($i != -1) {  
               !!!cp ('t362');  
               !!!parse-error (type => 'end tag missing:'.  
                               $self->{open_elements}->[-1]->[1]);  
             } else {  
               !!!cp ('t363');  
             }  
             splice @{$self->{open_elements}}, $i;  
             last LI;  
           } else {  
             !!!cp ('t364');  
           }  
             
           ## Step 3  
           if (not $formatting_category->{$node->[1]} and  
               #not $phrasing_category->{$node->[1]} and  
               ($special_category->{$node->[1]} or  
                $scoping_category->{$node->[1]}) and  
               $node->[1] ne 'address' and $node->[1] ne 'div') {  
             !!!cp ('t365');  
             last LI;  
           }  
             
           !!!cp ('t366');  
           ## Step 4  
           $i--;  
           $node = $self->{open_elements}->[$i];  
           redo LI;  
         } # LI  
             
         !!!insert-element-t ($token->{tag_name}, $token->{attributes});  
         !!!next-token;  
         redo B;  
5751        } elsif ($token->{tag_name} eq 'plaintext') {        } elsif ($token->{tag_name} eq 'plaintext') {
5752          ## has a p element in scope          ## has a p element in scope
5753          INSCOPE: for (reverse @{$self->{open_elements}}) {          INSCOPE: for (reverse @{$self->{open_elements}}) {
# Line 5575  sub _tree_construction_main ($) { Line 5757  sub _tree_construction_main ($) {
5757              $token = {type => END_TAG_TOKEN, tag_name => 'p'};              $token = {type => END_TAG_TOKEN, tag_name => 'p'};
5758              redo B;              redo B;
5759            } elsif ({            } elsif ({
5760                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5761                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5762                     }->{$_->[1]}) {                     }->{$_->[1]}) {
5763              !!!cp ('t368');              !!!cp ('t368');
# Line 5628  sub _tree_construction_main ($) { Line 5810  sub _tree_construction_main ($) {
5810    
5811          !!!next-token;          !!!next-token;
5812          redo B;          redo B;
       } elsif ({  
                 b => 1, big => 1, em => 1, font => 1, i => 1,  
                 s => 1, small => 1, strile => 1,  
                 strong => 1, tt => 1, u => 1,  
                }->{$token->{tag_name}}) {  
         !!!cp ('t375');  
         $reconstruct_active_formatting_elements->($insert_to_current);  
           
         !!!insert-element-t ($token->{tag_name}, $token->{attributes});  
         push @$active_formatting_elements, $self->{open_elements}->[-1];  
           
         !!!next-token;  
         redo B;  
5813        } elsif ($token->{tag_name} eq 'nobr') {        } elsif ($token->{tag_name} eq 'nobr') {
5814          $reconstruct_active_formatting_elements->($insert_to_current);          $reconstruct_active_formatting_elements->($insert_to_current);
5815    
# Line 5654  sub _tree_construction_main ($) { Line 5823  sub _tree_construction_main ($) {
5823              $token = {type => END_TAG_TOKEN, tag_name => 'nobr'};              $token = {type => END_TAG_TOKEN, tag_name => 'nobr'};
5824              redo B;              redo B;
5825            } elsif ({            } elsif ({
5826                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5827                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5828                     }->{$node->[1]}) {                     }->{$node->[1]}) {
5829              !!!cp ('t377');              !!!cp ('t377');
# Line 5678  sub _tree_construction_main ($) { Line 5847  sub _tree_construction_main ($) {
5847              $token = {type => END_TAG_TOKEN, tag_name => 'button'};              $token = {type => END_TAG_TOKEN, tag_name => 'button'};
5848              redo B;              redo B;
5849            } elsif ({            } elsif ({
5850                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
5851                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
5852                     }->{$node->[1]}) {                     }->{$node->[1]}) {
5853              !!!cp ('t379');              !!!cp ('t379');
# Line 5696  sub _tree_construction_main ($) { Line 5865  sub _tree_construction_main ($) {
5865    
5866          !!!next-token;          !!!next-token;
5867          redo B;          redo B;
       } elsif ($token->{tag_name} eq 'marquee' or  
                $token->{tag_name} eq 'object') {  
         !!!cp ('t380');  
         $reconstruct_active_formatting_elements->($insert_to_current);  
           
         !!!insert-element-t ($token->{tag_name}, $token->{attributes});  
         push @$active_formatting_elements, ['#marker', ''];  
           
         !!!next-token;  
         redo B;  
       } elsif ($token->{tag_name} eq 'xmp') {  
         !!!cp ('t381');  
         $reconstruct_active_formatting_elements->($insert_to_current);  
         $parse_rcdata->(CDATA_CONTENT_MODEL, $insert);  
         redo B;  
       } elsif ($token->{tag_name} eq 'table') {  
         ## has a p element in scope  
         INSCOPE: for (reverse @{$self->{open_elements}}) {  
           if ($_->[1] eq 'p') {  
             !!!cp ('t382');  
             !!!back-token;  
             $token = {type => END_TAG_TOKEN, tag_name => 'p'};  
             redo B;  
           } elsif ({  
                     table => 1, caption => 1, td => 1, th => 1,  
                     button => 1, marquee => 1, object => 1, html => 1,  
                    }->{$_->[1]}) {  
             !!!cp ('t383');  
             last INSCOPE;  
           }  
         } # INSCOPE  
             
         !!!insert-element-t ($token->{tag_name}, $token->{attributes});  
         push @{$open_tables}, [$self->{open_elements}->[-1]->[0]];  
   
         $self->{insertion_mode} = IN_TABLE_IM;  
             
         !!!next-token;  
         redo B;  
5868        } elsif ({        } elsif ({
5869                  area => 1, basefont => 1, bgsound => 1, br => 1,                  xmp => 1,
5870                  embed => 1, img => 1, param => 1, spacer => 1, wbr => 1,                  iframe => 1,
5871                  image => 1,                  noembed => 1,
5872                    noframes => 1,
5873                    noscript => 0, ## TODO: 1 if scripting is enabled
5874                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
5875          if ($token->{tag_name} eq 'image') {          if ($token->{tag_name} eq 'xmp') {
5876            !!!cp ('t384');            !!!cp ('t381');
5877            !!!parse-error (type => 'image');            $reconstruct_active_formatting_elements->($insert_to_current);
           $token->{tag_name} = 'img';  
5878          } else {          } else {
5879            !!!cp ('t385');            !!!cp ('t399');
5880          }          }
5881            ## NOTE: There is an "as if in body" code clone.
5882          ## NOTE: There is an "as if <br>" code clone.          $parse_rcdata->(CDATA_CONTENT_MODEL);
         $reconstruct_active_formatting_elements->($insert_to_current);  
           
         !!!insert-element-t ($token->{tag_name}, $token->{attributes});  
         pop @{$self->{open_elements}};  
           
         !!!next-token;  
         redo B;  
       } elsif ($token->{tag_name} eq 'hr') {  
         ## has a p element in scope  
         INSCOPE: for (reverse @{$self->{open_elements}}) {  
           if ($_->[1] eq 'p') {  
             !!!cp ('t386');  
             !!!back-token;  
             $token = {type => END_TAG_TOKEN, tag_name => 'p'};  
             redo B;  
           } elsif ({  
                     table => 1, caption => 1, td => 1, th => 1,  
                     button => 1, marquee => 1, object => 1, html => 1,  
                    }->{$_->[1]}) {  
             !!!cp ('t387');  
             last INSCOPE;  
           }  
         } # INSCOPE  
             
         !!!insert-element-t ($token->{tag_name}, $token->{attributes});  
         pop @{$self->{open_elements}};  
             
         !!!next-token;  
         redo B;  
       } elsif ($token->{tag_name} eq 'input') {  
         !!!cp ('t388');  
         $reconstruct_active_formatting_elements->($insert_to_current);  
           
         !!!insert-element-t ($token->{tag_name}, $token->{attributes});  
         ## TODO: associate with $self->{form_element} if defined  
         pop @{$self->{open_elements}};  
           
         !!!next-token;  
5883          redo B;          redo B;
5884        } elsif ($token->{tag_name} eq 'isindex') {        } elsif ($token->{tag_name} eq 'isindex') {
5885          !!!parse-error (type => 'isindex');          !!!parse-error (type => 'isindex');
# Line 5878  sub _tree_construction_main ($) { Line 5971  sub _tree_construction_main ($) {
5971          !!!next-token;          !!!next-token;
5972          redo B;          redo B;
5973        } elsif ({        } elsif ({
                 iframe => 1,  
                 noembed => 1,  
                 noframes => 1,  
                 noscript => 0, ## TODO: 1 if scripting is enabled  
                }->{$token->{tag_name}}) {  
         !!!cp ('t399');  
         ## NOTE: There is an "as if in body" code clone.  
         $parse_rcdata->(CDATA_CONTENT_MODEL, $insert);  
         redo B;  
       } elsif ($token->{tag_name} eq 'select') {  
         !!!cp ('t400');  
         $reconstruct_active_formatting_elements->($insert_to_current);  
           
         !!!insert-element-t ($token->{tag_name}, $token->{attributes});  
   
         ## TODO: associate with $self->{form_element} if defined  
           
         $self->{insertion_mode} = IN_SELECT_IM;  
         !!!next-token;  
         redo B;  
       } elsif ({  
5974                  caption => 1, col => 1, colgroup => 1, frame => 1,                  caption => 1, col => 1, colgroup => 1, frame => 1,
5975                  frameset => 1, head => 1, option => 1, optgroup => 1,                  frameset => 1, head => 1, option => 1, optgroup => 1,
5976                  tbody => 1, td => 1, tfoot => 1, th => 1,                  tbody => 1, td => 1, tfoot => 1, th => 1,
# Line 5912  sub _tree_construction_main ($) { Line 5984  sub _tree_construction_main ($) {
5984                    
5985          ## ISSUE: An issue on HTML5 new elements in the spec.          ## ISSUE: An issue on HTML5 new elements in the spec.
5986        } else {        } else {
5987          !!!cp ('t402');          if ($token->{tag_name} eq 'image') {
5988              !!!cp ('t384');
5989              !!!parse-error (type => 'image');
5990              $token->{tag_name} = 'img';
5991            } else {
5992              !!!cp ('t385');
5993            }
5994    
5995            ## NOTE: There is an "as if <br>" code clone.
5996          $reconstruct_active_formatting_elements->($insert_to_current);          $reconstruct_active_formatting_elements->($insert_to_current);
5997                    
5998          !!!insert-element-t ($token->{tag_name}, $token->{attributes});          !!!insert-element-t ($token->{tag_name}, $token->{attributes});
5999    
6000            if ({
6001                 applet => 1, marquee => 1, object => 1,
6002                }->{$token->{tag_name}}) {
6003              !!!cp ('t380');
6004              push @$active_formatting_elements, ['#marker', ''];
6005            } elsif ({
6006                      b => 1, big => 1, em => 1, font => 1, i => 1,
6007                      s => 1, small => 1, strile => 1,
6008                      strong => 1, tt => 1, u => 1,
6009                     }->{$token->{tag_name}}) {
6010              !!!cp ('t375');
6011              push @$active_formatting_elements, $self->{open_elements}->[-1];
6012            } elsif ($token->{tag_name} eq 'input') {
6013              !!!cp ('t388');
6014              ## TODO: associate with $self->{form_element} if defined
6015              pop @{$self->{open_elements}};
6016            } elsif ({
6017                      area => 1, basefont => 1, bgsound => 1, br => 1,
6018                      embed => 1, img => 1, param => 1, spacer => 1, wbr => 1,
6019                      #image => 1,
6020                     }->{$token->{tag_name}}) {
6021              !!!cp ('t388.1');
6022              pop @{$self->{open_elements}};
6023            } elsif ($token->{tag_name} eq 'select') {
6024              ## TODO: associate with $self->{form_element} if defined
6025            
6026              if ($self->{insertion_mode} & TABLE_IMS or
6027                  $self->{insertion_mode} & BODY_TABLE_IMS or
6028                  $self->{insertion_mode} == IN_COLUMN_GROUP_IM) {
6029                !!!cp ('t400.1');
6030                $self->{insertion_mode} = IN_SELECT_IN_TABLE_IM;
6031              } else {
6032                !!!cp ('t400.2');
6033                $self->{insertion_mode} = IN_SELECT_IM;
6034              }
6035            } else {
6036              !!!cp ('t402');
6037            }
6038                    
6039          !!!next-token;          !!!next-token;
6040          redo B;          redo B;
6041        }        }
6042      } elsif ($token->{type} == END_TAG_TOKEN) {      } elsif ($token->{type} == END_TAG_TOKEN) {
6043        if ($token->{tag_name} eq 'body') {        if ($token->{tag_name} eq 'body') {
6044          if (@{$self->{open_elements}} > 1 and          ## has a |body| element in scope
6045              $self->{open_elements}->[1]->[1] eq 'body') {          my $i;
6046            for (@{$self->{open_elements}}) {          INSCOPE: {
6047              unless ({            for (reverse @{$self->{open_elements}}) {
6048                         dd => 1, dt => 1, li => 1, p => 1, td => 1,              if ($_->[1] eq 'body') {
6049                         th => 1, tr => 1, body => 1, html => 1,                !!!cp ('t405');
6050                       tbody => 1, tfoot => 1, thead => 1,                $i = $_;
6051                      }->{$_->[1]}) {                last INSCOPE;
6052                !!!cp ('t403');              } elsif ({
6053                !!!parse-error (type => 'not closed:'.$_->[1]);                        applet => 1, table => 1, caption => 1, td => 1, th => 1,
6054              } else {                        button => 1, marquee => 1, object => 1, html => 1,
6055                !!!cp ('t404');                       }->{$_->[1]}) {
6056                  !!!cp ('t405.1');
6057                  last;
6058              }              }
6059            }            }
6060    
6061            $self->{insertion_mode} = AFTER_BODY_IM;            !!!parse-error (type => 'start tag not allowed',
6062            !!!next-token;                            value => $token->{tag_name});
6063            redo B;            ## NOTE: Ignore the token.
         } else {  
           !!!cp ('t405');  
           !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name});  
           ## Ignore the token  
6064            !!!next-token;            !!!next-token;
6065            redo B;            redo B;
6066            } # INSCOPE
6067    
6068            for (@{$self->{open_elements}}) {
6069              unless ({
6070                       dd => 1, dt => 1, li => 1, p => 1, td => 1,
6071                       th => 1, tr => 1, body => 1, html => 1,
6072                       tbody => 1, tfoot => 1, thead => 1,
6073                      }->{$_->[1]}) {
6074                !!!cp ('t403');
6075                !!!parse-error (type => 'not closed:'.$_->[1]);
6076                last;
6077              } else {
6078                !!!cp ('t404');
6079              }
6080          }          }
6081    
6082            $self->{insertion_mode} = AFTER_BODY_IM;
6083            !!!next-token;
6084            redo B;
6085        } elsif ($token->{tag_name} eq 'html') {        } elsif ($token->{tag_name} eq 'html') {
6086          if (@{$self->{open_elements}} > 1 and $self->{open_elements}->[1]->[1] eq 'body') {          if (@{$self->{open_elements}} > 1 and $self->{open_elements}->[1]->[1] eq 'body') {
6087            ## ISSUE: There is an issue in the spec.            ## ISSUE: There is an issue in the spec.
# Line 5971  sub _tree_construction_main ($) { Line 6106  sub _tree_construction_main ($) {
6106                  div => 1, dl => 1, fieldset => 1, listing => 1,                  div => 1, dl => 1, fieldset => 1, listing => 1,
6107                  menu => 1, ol => 1, pre => 1, ul => 1,                  menu => 1, ol => 1, pre => 1, ul => 1,
6108                  dd => 1, dt => 1, li => 1,                  dd => 1, dt => 1, li => 1,
6109                  button => 1, marquee => 1, object => 1,                  applet => 1, button => 1, marquee => 1, object => 1,
6110                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
6111          ## has an element in scope          ## has an element in scope
6112          my $i;          my $i;
# Line 5982  sub _tree_construction_main ($) { Line 6117  sub _tree_construction_main ($) {
6117              $i = $_;              $i = $_;
6118              last INSCOPE;              last INSCOPE;
6119            } elsif ({            } elsif ({
6120                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
6121                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
6122                     }->{$node->[1]}) {                     }->{$node->[1]}) {
6123              !!!cp ('t411');              !!!cp ('t411');
# Line 6019  sub _tree_construction_main ($) { Line 6154  sub _tree_construction_main ($) {
6154            ## Step 4.            ## Step 4.
6155            $clear_up_to_marker->()            $clear_up_to_marker->()
6156                if {                if {
6157                  button => 1, marquee => 1, object => 1,                  applet => 1, button => 1, marquee => 1, object => 1,
6158                }->{$token->{tag_name}};                }->{$token->{tag_name}};
6159          }          }
6160          !!!next-token;          !!!next-token;
# Line 6036  sub _tree_construction_main ($) { Line 6171  sub _tree_construction_main ($) {
6171              $i = $_;              $i = $_;
6172              last INSCOPE;              last INSCOPE;
6173            } elsif ({            } elsif ({
6174                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
6175                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
6176                     }->{$node->[1]}) {                     }->{$node->[1]}) {
6177              !!!cp ('t419');              !!!cp ('t419');
# Line 6084  sub _tree_construction_main ($) { Line 6219  sub _tree_construction_main ($) {
6219              $i = $_;              $i = $_;
6220              last INSCOPE;              last INSCOPE;
6221            } elsif ({            } elsif ({
6222                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
6223                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
6224                     }->{$node->[1]}) {                     }->{$node->[1]}) {
6225              !!!cp ('t424');              !!!cp ('t424');
# Line 6128  sub _tree_construction_main ($) { Line 6263  sub _tree_construction_main ($) {
6263              $i = $_;              $i = $_;
6264              last INSCOPE;              last INSCOPE;
6265            } elsif ({            } elsif ({
6266                      table => 1, caption => 1, td => 1, th => 1,                      applet => 1, table => 1, caption => 1, td => 1, th => 1,
6267                      button => 1, marquee => 1, object => 1, html => 1,                      button => 1, marquee => 1, object => 1, html => 1,
6268                     }->{$node->[1]}) {                     }->{$node->[1]}) {
6269              !!!cp ('t411.1');              !!!cp ('t411.1');

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24