/[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.145 by wakaba, Sat May 24 11:57:47 2008 UTC revision 1.154 by wakaba, Sat Aug 16 07:35:23 2008 UTC
# Line 45  sub MISC_SPECIAL_EL () { 0b1000000000000 Line 45  sub MISC_SPECIAL_EL () { 0b1000000000000
45  sub FOREIGN_EL () { 0b10000000000000000000000000 }  sub FOREIGN_EL () { 0b10000000000000000000000000 }
46  sub FOREIGN_FLOW_CONTENT_EL () { 0b100000000000000000000000000 }  sub FOREIGN_FLOW_CONTENT_EL () { 0b100000000000000000000000000 }
47  sub MML_AXML_EL () { 0b1000000000000000000000000000 }  sub MML_AXML_EL () { 0b1000000000000000000000000000 }
48    sub RUBY_EL () { 0b10000000000000000000000000000 }
49    sub RUBY_COMPONENT_EL () { 0b100000000000000000000000000000 }
50    
51  sub TABLE_ROWS_EL () {  sub TABLE_ROWS_EL () {
52    TABLE_EL |    TABLE_EL |
# Line 52  sub TABLE_ROWS_EL () { Line 54  sub TABLE_ROWS_EL () {
54    TABLE_ROW_GROUP_EL    TABLE_ROW_GROUP_EL
55  }  }
56    
57    ## NOTE: Used in "generate implied end tags" algorithm.
58    ## NOTE: There is a code where a modified version of END_TAG_OPTIONAL_EL
59    ## is used in "generate implied end tags" implementation (search for the
60    ## function mae).
61  sub END_TAG_OPTIONAL_EL () {  sub END_TAG_OPTIONAL_EL () {
62    DD_EL |    DD_EL |
63    DT_EL |    DT_EL |
64    LI_EL |    LI_EL |
65    P_EL    P_EL |
66      RUBY_COMPONENT_EL
67  }  }
68    
69    ## NOTE: Used in </body> and EOF algorithms.
70  sub ALL_END_TAG_OPTIONAL_EL () {  sub ALL_END_TAG_OPTIONAL_EL () {
71    END_TAG_OPTIONAL_EL |    DD_EL |
72      DT_EL |
73      LI_EL |
74      P_EL |
75    
76    BODY_EL |    BODY_EL |
77    HTML_EL |    HTML_EL |
78    TABLE_CELL_EL |    TABLE_CELL_EL |
# Line 96  sub SPECIAL_EL () { Line 108  sub SPECIAL_EL () {
108    ADDRESS_EL |    ADDRESS_EL |
109    BODY_EL |    BODY_EL |
110    DIV_EL |    DIV_EL |
111    END_TAG_OPTIONAL_EL |  
112      DD_EL |
113      DT_EL |
114      LI_EL |
115      P_EL |
116    
117    FORM_EL |    FORM_EL |
118    FRAMESET_EL |    FRAMESET_EL |
119    HEADING_EL |    HEADING_EL |
# Line 170  my $el_category = { Line 187  my $el_category = {
187    param => MISC_SPECIAL_EL,    param => MISC_SPECIAL_EL,
188    plaintext => MISC_SPECIAL_EL,    plaintext => MISC_SPECIAL_EL,
189    pre => MISC_SPECIAL_EL,    pre => MISC_SPECIAL_EL,
190      rp => RUBY_COMPONENT_EL,
191      rt => RUBY_COMPONENT_EL,
192      ruby => RUBY_EL,
193    s => FORMATTING_EL,    s => FORMATTING_EL,
194    script => MISC_SPECIAL_EL,    script => MISC_SPECIAL_EL,
195    select => SELECT_EL,    select => SELECT_EL,
# Line 211  my $el_category_f = { Line 231  my $el_category_f = {
231  };  };
232    
233  my $svg_attr_name = {  my $svg_attr_name = {
234      attributename => 'attributeName',
235    attributetype => 'attributeType',    attributetype => 'attributeType',
236    basefrequency => 'baseFrequency',    basefrequency => 'baseFrequency',
237    baseprofile => 'baseProfile',    baseprofile => 'baseProfile',
# Line 221  my $svg_attr_name = { Line 242  my $svg_attr_name = {
242    diffuseconstant => 'diffuseConstant',    diffuseconstant => 'diffuseConstant',
243    edgemode => 'edgeMode',    edgemode => 'edgeMode',
244    externalresourcesrequired => 'externalResourcesRequired',    externalresourcesrequired => 'externalResourcesRequired',
   fecolormatrix => 'feColorMatrix',  
   fecomposite => 'feComposite',  
   fegaussianblur => 'feGaussianBlur',  
   femorphology => 'feMorphology',  
   fetile => 'feTile',  
245    filterres => 'filterRes',    filterres => 'filterRes',
246    filterunits => 'filterUnits',    filterunits => 'filterUnits',
247    glyphref => 'glyphRef',    glyphref => 'glyphRef',
# Line 259  my $svg_attr_name = { Line 275  my $svg_attr_name = {
275    repeatcount => 'repeatCount',    repeatcount => 'repeatCount',
276    repeatdur => 'repeatDur',    repeatdur => 'repeatDur',
277    requiredextensions => 'requiredExtensions',    requiredextensions => 'requiredExtensions',
278      requiredfeatures => 'requiredFeatures',
279    specularconstant => 'specularConstant',    specularconstant => 'specularConstant',
280    specularexponent => 'specularExponent',    specularexponent => 'specularExponent',
281    spreadmethod => 'spreadMethod',    spreadmethod => 'spreadMethod',
# Line 426  sub parse_byte_stream ($$$$;$) { Line 443  sub parse_byte_stream ($$$$;$) {
443             allow_fallback => 1, byte_buffer => \$byte_buffer);             allow_fallback => 1, byte_buffer => \$byte_buffer);
444        if ($char_stream) {        if ($char_stream) {
445          $buffer->{buffer} = $byte_buffer;          $buffer->{buffer} = $byte_buffer;
446          !!!parse-error (type => 'sniffing:chardet', ## TODO: type name          !!!parse-error (type => 'sniffing:chardet',
447                          value => $charset_name,                          text => $charset_name,
448                          level => $self->{info_level},                          level => $self->{level}->{info},
449                            layer => 'encode',
450                          line => 1, column => 1);                          line => 1, column => 1);
451          $self->{confident} = 0;          $self->{confident} = 0;
452          last SNIFFING;          last SNIFFING;
# Line 449  sub parse_byte_stream ($$$$;$) { Line 467  sub parse_byte_stream ($$$$;$) {
467                                         allow_fallback => 1,                                         allow_fallback => 1,
468                                         byte_buffer => \$byte_buffer);                                         byte_buffer => \$byte_buffer);
469      $buffer->{buffer} = $byte_buffer;      $buffer->{buffer} = $byte_buffer;
470      !!!parse-error (type => 'sniffing:default', ## TODO: type name      !!!parse-error (type => 'sniffing:default',
471                      value => 'windows-1252',                      text => 'windows-1252',
472                      level => $self->{info_level},                      level => $self->{level}->{info},
473                      line => 1, column => 1);                      line => 1, column => 1,
474                        layer => 'encode');
475      $self->{confident} = 0;      $self->{confident} = 0;
476    } # SNIFFING    } # SNIFFING
477    
478    $self->{input_encoding} = $charset->get_iana_name;    $self->{input_encoding} = $charset->get_iana_name;
479    if ($e_status & Message::Charset::Info::FALLBACK_ENCODING_IMPL ()) {    if ($e_status & Message::Charset::Info::FALLBACK_ENCODING_IMPL ()) {
480      !!!parse-error (type => 'chardecode:fallback', ## TODO: type name      !!!parse-error (type => 'chardecode:fallback',
481                      value => $self->{input_encoding},                      text => $self->{input_encoding},
482                      level => $self->{unsupported_level},                      level => $self->{level}->{uncertain},
483                      line => 1, column => 1);                      line => 1, column => 1,
484                        layer => 'encode');
485    } elsif (not ($e_status &    } elsif (not ($e_status &
486                  Message::Charset::Info::ERROR_REPORTING_ENCODING_IMPL())) {                  Message::Charset::Info::ERROR_REPORTING_ENCODING_IMPL())) {
487      !!!parse-error (type => 'chardecode:no error', ## TODO: type name      !!!parse-error (type => 'chardecode:no error',
488                      value => $self->{input_encoding},                      text => $self->{input_encoding},
489                      level => $self->{unsupported_level},                      level => $self->{level}->{uncertain},
490                      line => 1, column => 1);                      line => 1, column => 1,
491                        layer => 'encode');
492    }    }
493    
494    $self->{change_encoding} = sub {    $self->{change_encoding} = sub {
# Line 484  sub parse_byte_stream ($$$$;$) { Line 505  sub parse_byte_stream ($$$$;$) {
505        ## "Change the encoding" algorithm:        ## "Change the encoding" algorithm:
506    
507        ## Step 1            ## Step 1    
508        if ($charset->{iana_names}->{'utf-16'}) { ## ISSUE: UTF-16BE -> UTF-8? UTF-16LE -> UTF-8?        if ($charset->{category} &
509              Message::Charset::Info::CHARSET_CATEGORY_UTF16 ()) {
510          $charset = Message::Charset::Info->get_by_iana_name ('utf-8');          $charset = Message::Charset::Info->get_by_iana_name ('utf-8');
511          ($char_stream, $e_status) = $charset->get_decode_handle          ($char_stream, $e_status) = $charset->get_decode_handle
512              ($byte_stream,              ($byte_stream,
# Line 495  sub parse_byte_stream ($$$$;$) { Line 517  sub parse_byte_stream ($$$$;$) {
517        ## Step 2        ## Step 2
518        if (defined $self->{input_encoding} and        if (defined $self->{input_encoding} and
519            $self->{input_encoding} eq $charset_name) {            $self->{input_encoding} eq $charset_name) {
520          !!!parse-error (type => 'charset label:matching', ## TODO: type          !!!parse-error (type => 'charset label:matching',
521                          value => $charset_name,                          text => $charset_name,
522                          level => $self->{info_level});                          level => $self->{level}->{info});
523          $self->{confident} = 1;          $self->{confident} = 1;
524          return;          return;
525        }        }
526    
527        !!!parse-error (type => 'charset label detected:'.$self->{input_encoding}.        !!!parse-error (type => 'charset label detected',
528            ':'.$charset_name, level => 'w', token => $token);                        text => $self->{input_encoding},
529                          value => $charset_name,
530                          level => $self->{level}->{warn},
531                          token => $token);
532                
533        ## Step 3        ## Step 3
534        # if (can) {        # if (can) {
# Line 519  sub parse_byte_stream ($$$$;$) { Line 544  sub parse_byte_stream ($$$$;$) {
544    
545    my $char_onerror = sub {    my $char_onerror = sub {
546      my (undef, $type, %opt) = @_;      my (undef, $type, %opt) = @_;
547      !!!parse-error (%opt, type => $type,      !!!parse-error (layer => 'encode',
548                        %opt, type => $type,
549                      line => $self->{line}, column => $self->{column} + 1);                      line => $self->{line}, column => $self->{column} + 1);
550      if ($opt{octets}) {      if ($opt{octets}) {
551        ${$opt{octets}} = "\x{FFFD}"; # relacement character        ${$opt{octets}} = "\x{FFFD}"; # relacement character
# Line 536  sub parse_byte_stream ($$$$;$) { Line 562  sub parse_byte_stream ($$$$;$) {
562    
563      $self->{input_encoding} = $charset->get_iana_name;      $self->{input_encoding} = $charset->get_iana_name;
564      if ($e_status & Message::Charset::Info::FALLBACK_ENCODING_IMPL ()) {      if ($e_status & Message::Charset::Info::FALLBACK_ENCODING_IMPL ()) {
565        !!!parse-error (type => 'chardecode:fallback', ## TODO: type name        !!!parse-error (type => 'chardecode:fallback',
566                        value => $self->{input_encoding},                        text => $self->{input_encoding},
567                        level => $self->{unsupported_level},                        level => $self->{level}->{uncertain},
568                        line => 1, column => 1);                        line => 1, column => 1,
569                          layer => 'encode');
570      } elsif (not ($e_status &      } elsif (not ($e_status &
571                    Message::Charset::Info::ERROR_REPORTING_ENCODING_IMPL())) {                    Message::Charset::Info::ERROR_REPORTING_ENCODING_IMPL())) {
572        !!!parse-error (type => 'chardecode:no error', ## TODO: type name        !!!parse-error (type => 'chardecode:no error',
573                        value => $self->{input_encoding},                        text => $self->{input_encoding},
574                        level => $self->{unsupported_level},                        level => $self->{level}->{uncertain},
575                        line => 1, column => 1);                        line => 1, column => 1,
576                          layer => 'encode');
577      }      }
578      $self->{confident} = 1;      $self->{confident} = 1;
579      $char_stream->onerror ($char_onerror);      $char_stream->onerror ($char_onerror);
# Line 644  sub parse_char_stream ($$$;$) { Line 672  sub parse_char_stream ($$$;$) {
672                0x10FFFE => 1, 0x10FFFF => 1,                0x10FFFE => 1, 0x10FFFF => 1,
673               }->{$self->{next_char}}) {               }->{$self->{next_char}}) {
674        !!!cp ('j5');        !!!cp ('j5');
675        !!!parse-error (type => 'control char', level => $self->{must_level});        if ($self->{next_char} < 0x10000) {
676  ## TODO: error type documentation          !!!parse-error (type => 'control char',
677                            text => (sprintf 'U+%04X', $self->{next_char}));
678          } else {
679            !!!parse-error (type => 'control char',
680                            text => (sprintf 'U-%08X', $self->{next_char}));
681          }
682      }      }
683    };    };
684    $self->{prev_char} = [-1, -1, -1];    $self->{prev_char} = [-1, -1, -1];
# Line 674  sub parse_char_stream ($$$;$) { Line 707  sub parse_char_stream ($$$;$) {
707  sub new ($) {  sub new ($) {
708    my $class = shift;    my $class = shift;
709    my $self = bless {    my $self = bless {
710      must_level => 'm',      level => {must => 'm',
711      should_level => 's',                warn => 'w',
712      good_level => 'w',                info => 'i',
713      warn_level => 'w',                uncertain => 'u'},
     info_level => 'i',  
     unsupported_level => 'u',  
714    }, $class;    }, $class;
715    $self->{set_next_char} = sub {    $self->{set_next_char} = sub {
716      $self->{next_char} = -1;      $self->{next_char} = -1;
# Line 826  sub _initialize_tokenizer ($) { Line 857  sub _initialize_tokenizer ($) {
857  ##     |->{self_closing}| is used to save the value of |$self->{self_closing}|  ##     |->{self_closing}| is used to save the value of |$self->{self_closing}|
858  ##     while the token is pushed back to the stack.  ##     while the token is pushed back to the stack.
859    
 ## ISSUE: "When a DOCTYPE token is created, its  
 ## <i>self-closing flag</i> must be unset (its other state is that it  
 ## be set), and its attributes list must be empty.": Wrong subject?  
   
860  ## Emitted token MUST immediately be handled by the tree construction state.  ## Emitted token MUST immediately be handled by the tree construction state.
861    
862  ## Before each step, UA MAY check to see if either one of the scripts in  ## Before each step, UA MAY check to see if either one of the scripts in
# Line 1342  sub _get_next_token ($) { Line 1369  sub _get_next_token ($) {
1369          if (exists $self->{current_token}->{attributes} # start tag or end tag          if (exists $self->{current_token}->{attributes} # start tag or end tag
1370              ->{$self->{current_attribute}->{name}}) { # MUST              ->{$self->{current_attribute}->{name}}) { # MUST
1371            !!!cp (57);            !!!cp (57);
1372            !!!parse-error (type => 'duplicate attribute:'.$self->{current_attribute}->{name}, line => $self->{current_attribute}->{line}, column => $self->{current_attribute}->{column});            !!!parse-error (type => 'duplicate attribute', text => $self->{current_attribute}->{name}, line => $self->{current_attribute}->{line}, column => $self->{current_attribute}->{column});
1373            ## Discard $self->{current_attribute} # MUST            ## Discard $self->{current_attribute} # MUST
1374          } else {          } else {
1375            !!!cp (58);            !!!cp (58);
# Line 2653  sub _get_next_token ($) { Line 2680  sub _get_next_token ($) {
2680          redo A;          redo A;
2681        } elsif ($self->{next_char} == 0x003E) { # >        } elsif ($self->{next_char} == 0x003E) { # >
2682          !!!cp (208);          !!!cp (208);
2683          !!!parse-error (type => 'unclosed PUBLIC literal');          !!!parse-error (type => 'unclosed SYSTEM literal');
2684    
2685          $self->{state} = DATA_STATE;          $self->{state} = DATA_STATE;
2686          !!!next-input-character;          !!!next-input-character;
# Line 2689  sub _get_next_token ($) { Line 2716  sub _get_next_token ($) {
2716          redo A;          redo A;
2717        } elsif ($self->{next_char} == 0x003E) { # >        } elsif ($self->{next_char} == 0x003E) { # >
2718          !!!cp (212);          !!!cp (212);
2719          !!!parse-error (type => 'unclosed PUBLIC literal');          !!!parse-error (type => 'unclosed SYSTEM literal');
2720    
2721          $self->{state} = DATA_STATE;          $self->{state} = DATA_STATE;
2722          !!!next-input-character;          !!!next-input-character;
# Line 2736  sub _get_next_token ($) { Line 2763  sub _get_next_token ($) {
2763          redo A;          redo A;
2764        } elsif ($self->{next_char} == -1) {        } elsif ($self->{next_char} == -1) {
2765          !!!cp (217);          !!!cp (217);
2766            !!!parse-error (type => 'unclosed DOCTYPE');
2767          $self->{state} = DATA_STATE;          $self->{state} = DATA_STATE;
2768          ## reconsume          ## reconsume
2769    
# Line 2898  sub _tokenize_attempt_to_consume_an_enti Line 2925  sub _tokenize_attempt_to_consume_an_enti
2925    
2926          if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) {          if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) {
2927            !!!cp (1008);            !!!cp (1008);
2928            !!!parse-error (type => (sprintf 'invalid character reference:U+%04X', $code), line => $l, column => $c);            !!!parse-error (type => 'invalid character reference',
2929                              text => (sprintf 'U+%04X', $code),
2930                              line => $l, column => $c);
2931            $code = 0xFFFD;            $code = 0xFFFD;
2932          } elsif ($code > 0x10FFFF) {          } elsif ($code > 0x10FFFF) {
2933            !!!cp (1009);            !!!cp (1009);
2934            !!!parse-error (type => (sprintf 'invalid character reference:U-%08X', $code), line => $l, column => $c);            !!!parse-error (type => 'invalid character reference',
2935                              text => (sprintf 'U-%08X', $code),
2936                              line => $l, column => $c);
2937            $code = 0xFFFD;            $code = 0xFFFD;
2938          } elsif ($code == 0x000D) {          } elsif ($code == 0x000D) {
2939            !!!cp (1010);            !!!cp (1010);
# Line 2910  sub _tokenize_attempt_to_consume_an_enti Line 2941  sub _tokenize_attempt_to_consume_an_enti
2941            $code = 0x000A;            $code = 0x000A;
2942          } elsif (0x80 <= $code and $code <= 0x9F) {          } elsif (0x80 <= $code and $code <= 0x9F) {
2943            !!!cp (1011);            !!!cp (1011);
2944            !!!parse-error (type => (sprintf 'C1 character reference:U+%04X', $code), line => $l, column => $c);            !!!parse-error (type => 'C1 character reference', text => (sprintf 'U+%04X', $code), line => $l, column => $c);
2945            $code = $c1_entity_char->{$code};            $code = $c1_entity_char->{$code};
2946          }          }
2947    
# Line 2943  sub _tokenize_attempt_to_consume_an_enti Line 2974  sub _tokenize_attempt_to_consume_an_enti
2974    
2975        if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) {        if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) {
2976          !!!cp (1015);          !!!cp (1015);
2977          !!!parse-error (type => (sprintf 'invalid character reference:U+%04X', $code), line => $l, column => $c);          !!!parse-error (type => 'invalid character reference',
2978                            text => (sprintf 'U+%04X', $code),
2979                            line => $l, column => $c);
2980          $code = 0xFFFD;          $code = 0xFFFD;
2981        } elsif ($code > 0x10FFFF) {        } elsif ($code > 0x10FFFF) {
2982          !!!cp (1016);          !!!cp (1016);
2983          !!!parse-error (type => (sprintf 'invalid character reference:U-%08X', $code), line => $l, column => $c);          !!!parse-error (type => 'invalid character reference',
2984                            text => (sprintf 'U-%08X', $code),
2985                            line => $l, column => $c);
2986          $code = 0xFFFD;          $code = 0xFFFD;
2987        } elsif ($code == 0x000D) {        } elsif ($code == 0x000D) {
2988          !!!cp (1017);          !!!cp (1017);
2989          !!!parse-error (type => 'CR character reference', line => $l, column => $c);          !!!parse-error (type => 'CR character reference',
2990                            line => $l, column => $c);
2991          $code = 0x000A;          $code = 0x000A;
2992        } elsif (0x80 <= $code and $code <= 0x9F) {        } elsif (0x80 <= $code and $code <= 0x9F) {
2993          !!!cp (1018);          !!!cp (1018);
2994          !!!parse-error (type => (sprintf 'C1 character reference:U+%04X', $code), line => $l, column => $c);          !!!parse-error (type => 'C1 character reference',
2995                            text => (sprintf 'U+%04X', $code),
2996                            line => $l, column => $c);
2997          $code = $c1_entity_char->{$code};          $code = $c1_entity_char->{$code};
2998        }        }
2999                
# Line 3053  sub _initialize_tree_constructor ($) { Line 3091  sub _initialize_tree_constructor ($) {
3091    ## TODO: Turn mutation events off # MUST    ## TODO: Turn mutation events off # MUST
3092    ## TODO: Turn loose Document option (manakai extension) on    ## TODO: Turn loose Document option (manakai extension) on
3093    $self->{document}->manakai_is_html (1); # MUST    $self->{document}->manakai_is_html (1); # MUST
3094      $self->{document}->set_user_data (manakai_source_line => 1);
3095      $self->{document}->set_user_data (manakai_source_column => 1);
3096  } # _initialize_tree_constructor  } # _initialize_tree_constructor
3097    
3098  sub _terminate_tree_constructor ($) {  sub _terminate_tree_constructor ($) {
# Line 3419  sub _reset_insertion_mode ($) { Line 3459  sub _reset_insertion_mode ($) {
3459          ## NOTE: Strictly spaking, the line below only applies to MathML and          ## NOTE: Strictly spaking, the line below only applies to MathML and
3460          ## SVG elements.  Currently the HTML syntax supports only MathML and          ## SVG elements.  Currently the HTML syntax supports only MathML and
3461          ## SVG elements as foreigners.          ## SVG elements as foreigners.
3462          $new_mode = $self->{insertion_mode} | IN_FOREIGN_CONTENT_IM;          $new_mode = IN_BODY_IM | IN_FOREIGN_CONTENT_IM;
         ## ISSUE: What is set as the secondary insertion mode?  
3463        } elsif ($node->[1] & TABLE_CELL_EL) {        } elsif ($node->[1] & TABLE_CELL_EL) {
3464          if ($last) {          if ($last) {
3465            !!!cp ('t28.2');            !!!cp ('t28.2');
# Line 3621  sub _tree_construction_main ($) { Line 3660  sub _tree_construction_main ($) {
3660        ## NOTE: An end-of-file token.        ## NOTE: An end-of-file token.
3661        if ($content_model_flag == CDATA_CONTENT_MODEL) {        if ($content_model_flag == CDATA_CONTENT_MODEL) {
3662          !!!cp ('t43');          !!!cp ('t43');
3663          !!!parse-error (type => 'in CDATA:#'.$token->{type}, token => $token);          !!!parse-error (type => 'in CDATA:#eof', token => $token);
3664        } elsif ($content_model_flag == RCDATA_CONTENT_MODEL) {        } elsif ($content_model_flag == RCDATA_CONTENT_MODEL) {
3665          !!!cp ('t44');          !!!cp ('t44');
3666          !!!parse-error (type => 'in RCDATA:#'.$token->{type}, token => $token);          !!!parse-error (type => 'in RCDATA:#eof', token => $token);
3667        } else {        } else {
3668          die "$0: $content_model_flag in parse_rcdata";          die "$0: $content_model_flag in parse_rcdata";
3669        }        }
# Line 3661  sub _tree_construction_main ($) { Line 3700  sub _tree_construction_main ($) {
3700        ## Ignore the token        ## Ignore the token
3701      } else {      } else {
3702        !!!cp ('t48');        !!!cp ('t48');
3703        !!!parse-error (type => 'in CDATA:#'.$token->{type}, token => $token);        !!!parse-error (type => 'in CDATA:#eof', token => $token);
3704        ## ISSUE: And ignore?        ## ISSUE: And ignore?
3705        ## TODO: mark as "already executed"        ## TODO: mark as "already executed"
3706      }      }
# Line 3712  sub _tree_construction_main ($) { Line 3751  sub _tree_construction_main ($) {
3751        } # AFE        } # AFE
3752        unless (defined $formatting_element) {        unless (defined $formatting_element) {
3753          !!!cp ('t53');          !!!cp ('t53');
3754          !!!parse-error (type => 'unmatched end tag:'.$tag_name, token => $end_tag_token);          !!!parse-error (type => 'unmatched end tag', text => $tag_name, token => $end_tag_token);
3755          ## Ignore the token          ## Ignore the token
3756          !!!next-token;          !!!next-token;
3757          return;          return;
# Line 3729  sub _tree_construction_main ($) { Line 3768  sub _tree_construction_main ($) {
3768              last INSCOPE;              last INSCOPE;
3769            } else { # in open elements but not in scope            } else { # in open elements but not in scope
3770              !!!cp ('t55');              !!!cp ('t55');
3771              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name},              !!!parse-error (type => 'unmatched end tag',
3772                                text => $token->{tag_name},
3773                              token => $end_tag_token);                              token => $end_tag_token);
3774              ## Ignore the token              ## Ignore the token
3775              !!!next-token;              !!!next-token;
# Line 3742  sub _tree_construction_main ($) { Line 3782  sub _tree_construction_main ($) {
3782        } # INSCOPE        } # INSCOPE
3783        unless (defined $formatting_element_i_in_open) {        unless (defined $formatting_element_i_in_open) {
3784          !!!cp ('t57');          !!!cp ('t57');
3785          !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name},          !!!parse-error (type => 'unmatched end tag',
3786                            text => $token->{tag_name},
3787                          token => $end_tag_token);                          token => $end_tag_token);
3788          pop @$active_formatting_elements; # $formatting_element          pop @$active_formatting_elements; # $formatting_element
3789          !!!next-token; ## TODO: ok?          !!!next-token; ## TODO: ok?
# Line 3751  sub _tree_construction_main ($) { Line 3792  sub _tree_construction_main ($) {
3792        if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) {        if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) {
3793          !!!cp ('t58');          !!!cp ('t58');
3794          !!!parse-error (type => 'not closed',          !!!parse-error (type => 'not closed',
3795                          value => $self->{open_elements}->[-1]->[0]                          text => $self->{open_elements}->[-1]->[0]
3796                              ->manakai_local_name,                              ->manakai_local_name,
3797                          token => $end_tag_token);                          token => $end_tag_token);
3798        }        }
# Line 3960  sub _tree_construction_main ($) { Line 4001  sub _tree_construction_main ($) {
4001    B: while (1) {    B: while (1) {
4002      if ($token->{type} == DOCTYPE_TOKEN) {      if ($token->{type} == DOCTYPE_TOKEN) {
4003        !!!cp ('t73');        !!!cp ('t73');
4004        !!!parse-error (type => 'DOCTYPE in the middle', token => $token);        !!!parse-error (type => 'in html:#DOCTYPE', token => $token);
4005        ## Ignore the token        ## Ignore the token
4006        ## Stay in the phase        ## Stay in the phase
4007        !!!next-token;        !!!next-token;
# Line 3969  sub _tree_construction_main ($) { Line 4010  sub _tree_construction_main ($) {
4010               $token->{tag_name} eq 'html') {               $token->{tag_name} eq 'html') {
4011        if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {        if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
4012          !!!cp ('t79');          !!!cp ('t79');
4013          !!!parse-error (type => 'after html:html', token => $token);          !!!parse-error (type => 'after html', text => 'html', token => $token);
4014          $self->{insertion_mode} = AFTER_BODY_IM;          $self->{insertion_mode} = AFTER_BODY_IM;
4015        } elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {        } elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {
4016          !!!cp ('t80');          !!!cp ('t80');
4017          !!!parse-error (type => 'after html:html', token => $token);          !!!parse-error (type => 'after html', text => 'html', token => $token);
4018          $self->{insertion_mode} = AFTER_FRAMESET_IM;          $self->{insertion_mode} = AFTER_FRAMESET_IM;
4019        } else {        } else {
4020          !!!cp ('t81');          !!!cp ('t81');
# Line 4024  sub _tree_construction_main ($) { Line 4065  sub _tree_construction_main ($) {
4065            #            #
4066          } elsif ({          } elsif ({
4067                    b => 1, big => 1, blockquote => 1, body => 1, br => 1,                    b => 1, big => 1, blockquote => 1, body => 1, br => 1,
4068                    center => 1, code => 1, dd => 1, div => 1, dl => 1, em => 1,                    center => 1, code => 1, dd => 1, div => 1, dl => 1, dt => 1,
4069                    embed => 1, font => 1, h1 => 1, h2 => 1, h3 => 1, ## No h4!                    em => 1, embed => 1, font => 1, h1 => 1, h2 => 1, h3 => 1,
4070                    h5 => 1, h6 => 1, head => 1, hr => 1, i => 1, img => 1,                    h4 => 1, h5 => 1, h6 => 1, head => 1, hr => 1, i => 1,
4071                    li => 1, menu => 1, meta => 1, nobr => 1, p => 1, pre => 1,                    img => 1, li => 1, listing => 1, menu => 1, meta => 1,
4072                    ruby => 1, s => 1, small => 1, span => 1, strong => 1,                    nobr => 1, ol => 1, p => 1, pre => 1, ruby => 1, s => 1,
4073                    sub => 1, sup => 1, table => 1, tt => 1, u => 1, ul => 1,                    small => 1, span => 1, strong => 1, strike => 1, sub => 1,
4074                    var => 1,                    sup => 1, table => 1, tt => 1, u => 1, ul => 1, var => 1,
4075                   }->{$token->{tag_name}}) {                   }->{$token->{tag_name}}) {
4076            !!!cp ('t87.2');            !!!cp ('t87.2');
4077            !!!parse-error (type => 'not closed',            !!!parse-error (type => 'not closed',
4078                            value => $self->{open_elements}->[-1]->[0]                            text => $self->{open_elements}->[-1]->[0]
4079                                ->manakai_local_name,                                ->manakai_local_name,
4080                            token => $token);                            token => $token);
4081    
# Line 4110  sub _tree_construction_main ($) { Line 4151  sub _tree_construction_main ($) {
4151          !!!cp ('t87.5');          !!!cp ('t87.5');
4152          #          #
4153        } elsif ($token->{type} == END_OF_FILE_TOKEN) {        } elsif ($token->{type} == END_OF_FILE_TOKEN) {
         ## NOTE: "using the rules for secondary insertion mode" then "continue"  
4154          !!!cp ('t87.6');          !!!cp ('t87.6');
4155          #          !!!parse-error (type => 'not closed',
4156          ## TODO: ...                          text => $self->{open_elements}->[-1]->[0]
4157                                ->manakai_local_name,
4158                            token => $token);
4159    
4160            pop @{$self->{open_elements}}
4161                while $self->{open_elements}->[-1]->[1] & FOREIGN_EL;
4162    
4163            $self->{insertion_mode} &= ~ IN_FOREIGN_CONTENT_IM;
4164            ## Reprocess.
4165            next B;
4166        } else {        } else {
4167          die "$0: $token->{type}: Unknown token type";                  die "$0: $token->{type}: Unknown token type";        
4168        }        }
# Line 4154  sub _tree_construction_main ($) { Line 4203  sub _tree_construction_main ($) {
4203            !!!cp ('t90');            !!!cp ('t90');
4204            ## As if </noscript>            ## As if </noscript>
4205            pop @{$self->{open_elements}};            pop @{$self->{open_elements}};
4206            !!!parse-error (type => 'in noscript:#character', token => $token);            !!!parse-error (type => 'in noscript:#text', token => $token);
4207                        
4208            ## Reprocess in the "in head" insertion mode...            ## Reprocess in the "in head" insertion mode...
4209            ## As if </head>            ## As if </head>
# Line 4191  sub _tree_construction_main ($) { Line 4240  sub _tree_construction_main ($) {
4240              next B;              next B;
4241            } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {            } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4242              !!!cp ('t93.2');              !!!cp ('t93.2');
4243              !!!parse-error (type => 'after head:head', token => $token); ## TODO: error type              !!!parse-error (type => 'after head', text => 'head',
4244                                token => $token);
4245              ## Ignore the token              ## Ignore the token
4246              !!!nack ('t93.3');              !!!nack ('t93.3');
4247              !!!next-token;              !!!next-token;
4248              next B;              next B;
4249            } else {            } else {
4250              !!!cp ('t95');              !!!cp ('t95');
4251              !!!parse-error (type => 'in head:head', token => $token); # or in head noscript              !!!parse-error (type => 'in head:head',
4252                                token => $token); # or in head noscript
4253              ## Ignore the token              ## Ignore the token
4254              !!!nack ('t95.1');              !!!nack ('t95.1');
4255              !!!next-token;              !!!next-token;
# Line 4223  sub _tree_construction_main ($) { Line 4274  sub _tree_construction_main ($) {
4274                  !!!cp ('t98');                  !!!cp ('t98');
4275                  ## As if </noscript>                  ## As if </noscript>
4276                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4277                  !!!parse-error (type => 'in noscript:base', token => $token);                  !!!parse-error (type => 'in noscript', text => 'base',
4278                                    token => $token);
4279                                
4280                  $self->{insertion_mode} = IN_HEAD_IM;                  $self->{insertion_mode} = IN_HEAD_IM;
4281                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
# Line 4234  sub _tree_construction_main ($) { Line 4286  sub _tree_construction_main ($) {
4286                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
4287                if ($self->{insertion_mode} == AFTER_HEAD_IM) {                if ($self->{insertion_mode} == AFTER_HEAD_IM) {
4288                  !!!cp ('t100');                  !!!cp ('t100');
4289                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'after head',
4290                                    text => $token->{tag_name}, token => $token);
4291                  push @{$self->{open_elements}},                  push @{$self->{open_elements}},
4292                      [$self->{head_element}, $el_category->{head}];                      [$self->{head_element}, $el_category->{head}];
4293                } else {                } else {
# Line 4251  sub _tree_construction_main ($) { Line 4304  sub _tree_construction_main ($) {
4304                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
4305                if ($self->{insertion_mode} == AFTER_HEAD_IM) {                if ($self->{insertion_mode} == AFTER_HEAD_IM) {
4306                  !!!cp ('t102');                  !!!cp ('t102');
4307                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'after head',
4308                                    text => $token->{tag_name}, token => $token);
4309                  push @{$self->{open_elements}},                  push @{$self->{open_elements}},
4310                      [$self->{head_element}, $el_category->{head}];                      [$self->{head_element}, $el_category->{head}];
4311                } else {                } else {
# Line 4268  sub _tree_construction_main ($) { Line 4322  sub _tree_construction_main ($) {
4322                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
4323                if ($self->{insertion_mode} == AFTER_HEAD_IM) {                if ($self->{insertion_mode} == AFTER_HEAD_IM) {
4324                  !!!cp ('t104');                  !!!cp ('t104');
4325                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'after head',
4326                                    text => $token->{tag_name}, token => $token);
4327                  push @{$self->{open_elements}},                  push @{$self->{open_elements}},
4328                      [$self->{head_element}, $el_category->{head}];                      [$self->{head_element}, $el_category->{head}];
4329                } else {                } else {
# Line 4337  sub _tree_construction_main ($) { Line 4392  sub _tree_construction_main ($) {
4392                  !!!cp ('t111');                  !!!cp ('t111');
4393                  ## As if </noscript>                  ## As if </noscript>
4394                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4395                  !!!parse-error (type => 'in noscript:title', token => $token);                  !!!parse-error (type => 'in noscript', text => 'title',
4396                                    token => $token);
4397                                
4398                  $self->{insertion_mode} = IN_HEAD_IM;                  $self->{insertion_mode} = IN_HEAD_IM;
4399                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
4400                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4401                  !!!cp ('t112');                  !!!cp ('t112');
4402                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'after head',
4403                                    text => $token->{tag_name}, token => $token);
4404                  push @{$self->{open_elements}},                  push @{$self->{open_elements}},
4405                      [$self->{head_element}, $el_category->{head}];                      [$self->{head_element}, $el_category->{head}];
4406                } else {                } else {
# Line 4357  sub _tree_construction_main ($) { Line 4414  sub _tree_construction_main ($) {
4414                pop @{$self->{open_elements}} # <head>                pop @{$self->{open_elements}} # <head>
4415                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
4416                next B;                next B;
4417              } elsif ($token->{tag_name} eq 'style') {              } elsif ($token->{tag_name} eq 'style' or
4418                         $token->{tag_name} eq 'noframes') {
4419                ## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and                ## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and
4420                ## insertion mode IN_HEAD_IM)                ## insertion mode IN_HEAD_IM)
4421                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
4422                if ($self->{insertion_mode} == AFTER_HEAD_IM) {                if ($self->{insertion_mode} == AFTER_HEAD_IM) {
4423                  !!!cp ('t114');                  !!!cp ('t114');
4424                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'after head',
4425                                    text => $token->{tag_name}, token => $token);
4426                  push @{$self->{open_elements}},                  push @{$self->{open_elements}},
4427                      [$self->{head_element}, $el_category->{head}];                      [$self->{head_element}, $el_category->{head}];
4428                } else {                } else {
# Line 4384  sub _tree_construction_main ($) { Line 4443  sub _tree_construction_main ($) {
4443                  next B;                  next B;
4444                } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {                } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
4445                  !!!cp ('t117');                  !!!cp ('t117');
4446                  !!!parse-error (type => 'in noscript:noscript', token => $token);                  !!!parse-error (type => 'in noscript', text => 'noscript',
4447                                    token => $token);
4448                  ## Ignore the token                  ## Ignore the token
4449                  !!!nack ('t117.1');                  !!!nack ('t117.1');
4450                  !!!next-token;                  !!!next-token;
# Line 4398  sub _tree_construction_main ($) { Line 4458  sub _tree_construction_main ($) {
4458                  !!!cp ('t119');                  !!!cp ('t119');
4459                  ## As if </noscript>                  ## As if </noscript>
4460                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4461                  !!!parse-error (type => 'in noscript:script', token => $token);                  !!!parse-error (type => 'in noscript', text => 'script',
4462                                    token => $token);
4463                                
4464                  $self->{insertion_mode} = IN_HEAD_IM;                  $self->{insertion_mode} = IN_HEAD_IM;
4465                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
4466                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4467                  !!!cp ('t120');                  !!!cp ('t120');
4468                  !!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'after head',
4469                                    text => $token->{tag_name}, token => $token);
4470                  push @{$self->{open_elements}},                  push @{$self->{open_elements}},
4471                      [$self->{head_element}, $el_category->{head}];                      [$self->{head_element}, $el_category->{head}];
4472                } else {                } else {
# Line 4422  sub _tree_construction_main ($) { Line 4484  sub _tree_construction_main ($) {
4484                  !!!cp ('t122');                  !!!cp ('t122');
4485                  ## As if </noscript>                  ## As if </noscript>
4486                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4487                  !!!parse-error (type => 'in noscript:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'in noscript',
4488                                    text => $token->{tag_name}, token => $token);
4489                                    
4490                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
4491                  ## As if </head>                  ## As if </head>
# Line 4461  sub _tree_construction_main ($) { Line 4524  sub _tree_construction_main ($) {
4524                !!!cp ('t129');                !!!cp ('t129');
4525                ## As if </noscript>                ## As if </noscript>
4526                pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
4527                !!!parse-error (type => 'in noscript:/'.$token->{tag_name}, token => $token);                !!!parse-error (type => 'in noscript:/',
4528                                  text => $token->{tag_name}, token => $token);
4529                                
4530                ## Reprocess in the "in head" insertion mode...                ## Reprocess in the "in head" insertion mode...
4531                ## As if </head>                ## As if </head>
# Line 4504  sub _tree_construction_main ($) { Line 4568  sub _tree_construction_main ($) {
4568                  !!!cp ('t133');                  !!!cp ('t133');
4569                  ## As if </noscript>                  ## As if </noscript>
4570                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4571                  !!!parse-error (type => 'in noscript:/head', token => $token);                  !!!parse-error (type => 'in noscript:/',
4572                                    text => 'head', token => $token);
4573                                    
4574                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
4575                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
# Line 4519  sub _tree_construction_main ($) { Line 4584  sub _tree_construction_main ($) {
4584                  next B;                  next B;
4585                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4586                  !!!cp ('t134.1');                  !!!cp ('t134.1');
4587                  !!!parse-error (type => 'unmatched end tag:head', token => $token);                  !!!parse-error (type => 'unmatched end tag', text => 'head',
4588                                    token => $token);
4589                  ## Ignore the token                  ## Ignore the token
4590                  !!!next-token;                  !!!next-token;
4591                  next B;                  next B;
# Line 4536  sub _tree_construction_main ($) { Line 4602  sub _tree_construction_main ($) {
4602                } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM or                } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM or
4603                         $self->{insertion_mode} == AFTER_HEAD_IM) {                         $self->{insertion_mode} == AFTER_HEAD_IM) {
4604                  !!!cp ('t137');                  !!!cp ('t137');
4605                  !!!parse-error (type => 'unmatched end tag:noscript', token => $token);                  !!!parse-error (type => 'unmatched end tag',
4606                                    text => 'noscript', token => $token);
4607                  ## Ignore the token ## ISSUE: An issue in the spec.                  ## Ignore the token ## ISSUE: An issue in the spec.
4608                  !!!next-token;                  !!!next-token;
4609                  next B;                  next B;
# Line 4551  sub _tree_construction_main ($) { Line 4618  sub _tree_construction_main ($) {
4618                    $self->{insertion_mode} == IN_HEAD_IM or                    $self->{insertion_mode} == IN_HEAD_IM or
4619                    $self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {                    $self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
4620                  !!!cp ('t140');                  !!!cp ('t140');
4621                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
4622                                    text => $token->{tag_name}, token => $token);
4623                  ## Ignore the token                  ## Ignore the token
4624                  !!!next-token;                  !!!next-token;
4625                  next B;                  next B;
4626                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4627                  !!!cp ('t140.1');                  !!!cp ('t140.1');
4628                  !!!parse-error (type => 'unmatched end tag:' . $token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
4629                                    text => $token->{tag_name}, token => $token);
4630                  ## Ignore the token                  ## Ignore the token
4631                  !!!next-token;                  !!!next-token;
4632                  next B;                  next B;
# Line 4566  sub _tree_construction_main ($) { Line 4635  sub _tree_construction_main ($) {
4635                }                }
4636              } elsif ($token->{tag_name} eq 'p') {              } elsif ($token->{tag_name} eq 'p') {
4637                !!!cp ('t142');                !!!cp ('t142');
4638                !!!parse-error (type => 'unmatched end tag:p', token => $token);                !!!parse-error (type => 'unmatched end tag',
4639                                  text => $token->{tag_name}, token => $token);
4640                ## Ignore the token                ## Ignore the token
4641                !!!next-token;                !!!next-token;
4642                next B;                next B;
# Line 4589  sub _tree_construction_main ($) { Line 4659  sub _tree_construction_main ($) {
4659                } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {                } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
4660                  !!!cp ('t143.3');                  !!!cp ('t143.3');
4661                  ## ISSUE: Two parse errors for <head><noscript></br>                  ## ISSUE: Two parse errors for <head><noscript></br>
4662                  !!!parse-error (type => 'unmatched end tag:br', token => $token);                  !!!parse-error (type => 'unmatched end tag',
4663                                    text => 'br', token => $token);
4664                  ## As if </noscript>                  ## As if </noscript>
4665                  pop @{$self->{open_elements}};                  pop @{$self->{open_elements}};
4666                  $self->{insertion_mode} = IN_HEAD_IM;                  $self->{insertion_mode} = IN_HEAD_IM;
# Line 4608  sub _tree_construction_main ($) { Line 4679  sub _tree_construction_main ($) {
4679                }                }
4680    
4681                ## ISSUE: does not agree with IE7 - it doesn't ignore </br>.                ## ISSUE: does not agree with IE7 - it doesn't ignore </br>.
4682                !!!parse-error (type => 'unmatched end tag:br', token => $token);                !!!parse-error (type => 'unmatched end tag',
4683                                  text => 'br', token => $token);
4684                ## Ignore the token                ## Ignore the token
4685                !!!next-token;                !!!next-token;
4686                next B;                next B;
4687              } else {              } else {
4688                !!!cp ('t145');                !!!cp ('t145');
4689                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                !!!parse-error (type => 'unmatched end tag',
4690                                  text => $token->{tag_name}, token => $token);
4691                ## Ignore the token                ## Ignore the token
4692                !!!next-token;                !!!next-token;
4693                next B;                next B;
# Line 4624  sub _tree_construction_main ($) { Line 4697  sub _tree_construction_main ($) {
4697                !!!cp ('t146');                !!!cp ('t146');
4698                ## As if </noscript>                ## As if </noscript>
4699                pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
4700                !!!parse-error (type => 'in noscript:/'.$token->{tag_name}, token => $token);                !!!parse-error (type => 'in noscript:/',
4701                                  text => $token->{tag_name}, token => $token);
4702                                
4703                ## Reprocess in the "in head" insertion mode...                ## Reprocess in the "in head" insertion mode...
4704                ## As if </head>                ## As if </head>
# Line 4640  sub _tree_construction_main ($) { Line 4714  sub _tree_construction_main ($) {
4714              } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {              } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {
4715  ## ISSUE: This case cannot be reached?  ## ISSUE: This case cannot be reached?
4716                !!!cp ('t148');                !!!cp ('t148');
4717                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                !!!parse-error (type => 'unmatched end tag',
4718                                  text => $token->{tag_name}, token => $token);
4719                ## Ignore the token ## ISSUE: An issue in the spec.                ## Ignore the token ## ISSUE: An issue in the spec.
4720                !!!next-token;                !!!next-token;
4721                next B;                next B;
# Line 4751  sub _tree_construction_main ($) { Line 4826  sub _tree_construction_main ($) {
4826    
4827                  !!!cp ('t153');                  !!!cp ('t153');
4828                  !!!parse-error (type => 'start tag not allowed',                  !!!parse-error (type => 'start tag not allowed',
4829                      value => $token->{tag_name}, token => $token);                      text => $token->{tag_name}, token => $token);
4830                  ## Ignore the token                  ## Ignore the token
4831                  !!!nack ('t153.1');                  !!!nack ('t153.1');
4832                  !!!next-token;                  !!!next-token;
4833                  next B;                  next B;
4834                } elsif ($self->{insertion_mode} == IN_CAPTION_IM) {                } elsif ($self->{insertion_mode} == IN_CAPTION_IM) {
4835                  !!!parse-error (type => 'not closed:caption', token => $token);                  !!!parse-error (type => 'not closed', text => 'caption',
4836                                    token => $token);
4837                                    
4838                  ## NOTE: As if </caption>.                  ## NOTE: As if </caption>.
4839                  ## have a table element in table scope                  ## have a table element in table scope
# Line 4777  sub _tree_construction_main ($) { Line 4853  sub _tree_construction_main ($) {
4853    
4854                    !!!cp ('t157');                    !!!cp ('t157');
4855                    !!!parse-error (type => 'start tag not allowed',                    !!!parse-error (type => 'start tag not allowed',
4856                                    value => $token->{tag_name}, token => $token);                                    text => $token->{tag_name}, token => $token);
4857                    ## Ignore the token                    ## Ignore the token
4858                    !!!nack ('t157.1');                    !!!nack ('t157.1');
4859                    !!!next-token;                    !!!next-token;
# Line 4794  sub _tree_construction_main ($) { Line 4870  sub _tree_construction_main ($) {
4870                  unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) {                  unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) {
4871                    !!!cp ('t159');                    !!!cp ('t159');
4872                    !!!parse-error (type => 'not closed',                    !!!parse-error (type => 'not closed',
4873                                    value => $self->{open_elements}->[-1]->[0]                                    text => $self->{open_elements}->[-1]->[0]
4874                                        ->manakai_local_name,                                        ->manakai_local_name,
4875                                    token => $token);                                    token => $token);
4876                  } else {                  } else {
# Line 4836  sub _tree_construction_main ($) { Line 4912  sub _tree_construction_main ($) {
4912                  } # INSCOPE                  } # INSCOPE
4913                    unless (defined $i) {                    unless (defined $i) {
4914                      !!!cp ('t165');                      !!!cp ('t165');
4915                      !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                      !!!parse-error (type => 'unmatched end tag',
4916                                        text => $token->{tag_name},
4917                                        token => $token);
4918                      ## Ignore the token                      ## Ignore the token
4919                      !!!next-token;                      !!!next-token;
4920                      next B;                      next B;
# Line 4853  sub _tree_construction_main ($) { Line 4931  sub _tree_construction_main ($) {
4931                          ne $token->{tag_name}) {                          ne $token->{tag_name}) {
4932                    !!!cp ('t167');                    !!!cp ('t167');
4933                    !!!parse-error (type => 'not closed',                    !!!parse-error (type => 'not closed',
4934                                    value => $self->{open_elements}->[-1]->[0]                                    text => $self->{open_elements}->[-1]->[0]
4935                                        ->manakai_local_name,                                        ->manakai_local_name,
4936                                    token => $token);                                    token => $token);
4937                  } else {                  } else {
# Line 4870  sub _tree_construction_main ($) { Line 4948  sub _tree_construction_main ($) {
4948                  next B;                  next B;
4949                } elsif ($self->{insertion_mode} == IN_CAPTION_IM) {                } elsif ($self->{insertion_mode} == IN_CAPTION_IM) {
4950                  !!!cp ('t169');                  !!!cp ('t169');
4951                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
4952                                    text => $token->{tag_name}, token => $token);
4953                  ## Ignore the token                  ## Ignore the token
4954                  !!!next-token;                  !!!next-token;
4955                  next B;                  next B;
# Line 4897  sub _tree_construction_main ($) { Line 4976  sub _tree_construction_main ($) {
4976    
4977                    !!!cp ('t173');                    !!!cp ('t173');
4978                    !!!parse-error (type => 'unmatched end tag',                    !!!parse-error (type => 'unmatched end tag',
4979                                    value => $token->{tag_name}, token => $token);                                    text => $token->{tag_name}, token => $token);
4980                    ## Ignore the token                    ## Ignore the token
4981                    !!!next-token;                    !!!next-token;
4982                    next B;                    next B;
# Line 4913  sub _tree_construction_main ($) { Line 4992  sub _tree_construction_main ($) {
4992                  unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) {                  unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) {
4993                    !!!cp ('t175');                    !!!cp ('t175');
4994                    !!!parse-error (type => 'not closed',                    !!!parse-error (type => 'not closed',
4995                                    value => $self->{open_elements}->[-1]->[0]                                    text => $self->{open_elements}->[-1]->[0]
4996                                        ->manakai_local_name,                                        ->manakai_local_name,
4997                                    token => $token);                                    token => $token);
4998                  } else {                  } else {
# Line 4930  sub _tree_construction_main ($) { Line 5009  sub _tree_construction_main ($) {
5009                  next B;                  next B;
5010                } elsif ($self->{insertion_mode} == IN_CELL_IM) {                } elsif ($self->{insertion_mode} == IN_CELL_IM) {
5011                  !!!cp ('t177');                  !!!cp ('t177');
5012                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
5013                                    text => $token->{tag_name}, token => $token);
5014                  ## Ignore the token                  ## Ignore the token
5015                  !!!next-token;                  !!!next-token;
5016                  next B;                  next B;
# Line 4973  sub _tree_construction_main ($) { Line 5053  sub _tree_construction_main ($) {
5053    
5054                  !!!cp ('t182');                  !!!cp ('t182');
5055                  !!!parse-error (type => 'unmatched end tag',                  !!!parse-error (type => 'unmatched end tag',
5056                      value => $token->{tag_name}, token => $token);                      text => $token->{tag_name}, token => $token);
5057                  ## Ignore the token                  ## Ignore the token
5058                  !!!next-token;                  !!!next-token;
5059                  next B;                  next B;
5060                } # INSCOPE                } # INSCOPE
5061              } elsif ($token->{tag_name} eq 'table' and              } elsif ($token->{tag_name} eq 'table' and
5062                       $self->{insertion_mode} == IN_CAPTION_IM) {                       $self->{insertion_mode} == IN_CAPTION_IM) {
5063                !!!parse-error (type => 'not closed:caption', token => $token);                !!!parse-error (type => 'not closed', text => 'caption',
5064                                  token => $token);
5065    
5066                ## As if </caption>                ## As if </caption>
5067                ## have a table element in table scope                ## have a table element in table scope
# Line 4998  sub _tree_construction_main ($) { Line 5079  sub _tree_construction_main ($) {
5079                } # INSCOPE                } # INSCOPE
5080                unless (defined $i) {                unless (defined $i) {
5081                  !!!cp ('t186');                  !!!cp ('t186');
5082                  !!!parse-error (type => 'unmatched end tag:caption', token => $token);                  !!!parse-error (type => 'unmatched end tag',
5083                                    text => 'caption', token => $token);
5084                  ## Ignore the token                  ## Ignore the token
5085                  !!!next-token;                  !!!next-token;
5086                  next B;                  next B;
# Line 5013  sub _tree_construction_main ($) { Line 5095  sub _tree_construction_main ($) {
5095                unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) {                unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) {
5096                  !!!cp ('t188');                  !!!cp ('t188');
5097                  !!!parse-error (type => 'not closed',                  !!!parse-error (type => 'not closed',
5098                                  value => $self->{open_elements}->[-1]->[0]                                  text => $self->{open_elements}->[-1]->[0]
5099                                      ->manakai_local_name,                                      ->manakai_local_name,
5100                                  token => $token);                                  token => $token);
5101                } else {                } else {
# Line 5033  sub _tree_construction_main ($) { Line 5115  sub _tree_construction_main ($) {
5115                       }->{$token->{tag_name}}) {                       }->{$token->{tag_name}}) {
5116                if ($self->{insertion_mode} & BODY_TABLE_IMS) {                if ($self->{insertion_mode} & BODY_TABLE_IMS) {
5117                  !!!cp ('t190');                  !!!cp ('t190');
5118                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
5119                                    text => $token->{tag_name}, token => $token);
5120                  ## Ignore the token                  ## Ignore the token
5121                  !!!next-token;                  !!!next-token;
5122                  next B;                  next B;
# Line 5047  sub _tree_construction_main ($) { Line 5130  sub _tree_construction_main ($) {
5130                       }->{$token->{tag_name}} and                       }->{$token->{tag_name}} and
5131                       $self->{insertion_mode} == IN_CAPTION_IM) {                       $self->{insertion_mode} == IN_CAPTION_IM) {
5132                !!!cp ('t192');                !!!cp ('t192');
5133                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                !!!parse-error (type => 'unmatched end tag',
5134                                  text => $token->{tag_name}, token => $token);
5135                ## Ignore the token                ## Ignore the token
5136                !!!next-token;                !!!next-token;
5137                next B;                next B;
# Line 5087  sub _tree_construction_main ($) { Line 5171  sub _tree_construction_main ($) {
5171            }            }
5172          }          }
5173    
5174              !!!parse-error (type => 'in table:#character', token => $token);          !!!parse-error (type => 'in table:#text', token => $token);
5175    
5176              ## As if in body, but insert into foster parent element              ## As if in body, but insert into foster parent element
5177              ## ISSUE: Spec says that "whenever a node would be inserted              ## ISSUE: Spec says that "whenever a node would be inserted
# Line 5138  sub _tree_construction_main ($) { Line 5222  sub _tree_construction_main ($) {
5222          !!!next-token;          !!!next-token;
5223          next B;          next B;
5224        } elsif ($token->{type} == START_TAG_TOKEN) {        } elsif ($token->{type} == START_TAG_TOKEN) {
5225              if ({          if ({
5226                   tr => ($self->{insertion_mode} != IN_ROW_IM),               tr => ($self->{insertion_mode} != IN_ROW_IM),
5227                   th => 1, td => 1,               th => 1, td => 1,
5228                  }->{$token->{tag_name}}) {              }->{$token->{tag_name}}) {
5229                if ($self->{insertion_mode} == IN_TABLE_IM) {            if ($self->{insertion_mode} == IN_TABLE_IM) {
5230                  ## Clear back to table context              ## Clear back to table context
5231                  while (not ($self->{open_elements}->[-1]->[1]              while (not ($self->{open_elements}->[-1]->[1]
5232                                  & TABLE_SCOPING_EL)) {                              & TABLE_SCOPING_EL)) {
5233                    !!!cp ('t201');                !!!cp ('t201');
5234                    pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
5235                  }              }
5236                                
5237                  !!!insert-element ('tbody',, $token);              !!!insert-element ('tbody',, $token);
5238                  $self->{insertion_mode} = IN_TABLE_BODY_IM;              $self->{insertion_mode} = IN_TABLE_BODY_IM;
5239                  ## reprocess in the "in table body" insertion mode...              ## reprocess in the "in table body" insertion mode...
5240                }            }
5241              
5242                if ($self->{insertion_mode} == IN_TABLE_BODY_IM) {            if ($self->{insertion_mode} == IN_TABLE_BODY_IM) {
5243                  unless ($token->{tag_name} eq 'tr') {              unless ($token->{tag_name} eq 'tr') {
5244                    !!!cp ('t202');                !!!cp ('t202');
5245                    !!!parse-error (type => 'missing start tag:tr', token => $token);                !!!parse-error (type => 'missing start tag:tr', token => $token);
5246                  }              }
5247                                    
5248                  ## Clear back to table body context              ## Clear back to table body context
5249                  while (not ($self->{open_elements}->[-1]->[1]              while (not ($self->{open_elements}->[-1]->[1]
5250                                  & TABLE_ROWS_SCOPING_EL)) {                              & TABLE_ROWS_SCOPING_EL)) {
5251                    !!!cp ('t203');                !!!cp ('t203');
5252                    ## ISSUE: Can this case be reached?                ## ISSUE: Can this case be reached?
5253                    pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
5254                  }              }
5255                                    
5256                  $self->{insertion_mode} = IN_ROW_IM;                  $self->{insertion_mode} = IN_ROW_IM;
5257                  if ($token->{tag_name} eq 'tr') {                  if ($token->{tag_name} eq 'tr') {
# Line 5223  sub _tree_construction_main ($) { Line 5307  sub _tree_construction_main ($) {
5307                  unless (defined $i) {                  unless (defined $i) {
5308                    !!!cp ('t210');                    !!!cp ('t210');
5309  ## TODO: This type is wrong.  ## TODO: This type is wrong.
5310                    !!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}, token => $token);                    !!!parse-error (type => 'unmacthed end tag',
5311                                      text => $token->{tag_name}, token => $token);
5312                    ## Ignore the token                    ## Ignore the token
5313                    !!!nack ('t210.1');                    !!!nack ('t210.1');
5314                    !!!next-token;                    !!!next-token;
# Line 5267  sub _tree_construction_main ($) { Line 5352  sub _tree_construction_main ($) {
5352                  } # INSCOPE                  } # INSCOPE
5353                  unless (defined $i) {                  unless (defined $i) {
5354                    !!!cp ('t216');                    !!!cp ('t216');
5355  ## TODO: This erorr type ios wrong.  ## TODO: This erorr type is wrong.
5356                    !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                    !!!parse-error (type => 'unmatched end tag',
5357                                      text => $token->{tag_name}, token => $token);
5358                    ## Ignore the token                    ## Ignore the token
5359                    !!!nack ('t216.1');                    !!!nack ('t216.1');
5360                    !!!next-token;                    !!!next-token;
# Line 5343  sub _tree_construction_main ($) { Line 5429  sub _tree_construction_main ($) {
5429                }                }
5430              } elsif ($token->{tag_name} eq 'table') {              } elsif ($token->{tag_name} eq 'table') {
5431                !!!parse-error (type => 'not closed',                !!!parse-error (type => 'not closed',
5432                                value => $self->{open_elements}->[-1]->[0]                                text => $self->{open_elements}->[-1]->[0]
5433                                    ->manakai_local_name,                                    ->manakai_local_name,
5434                                token => $token);                                token => $token);
5435    
# Line 5364  sub _tree_construction_main ($) { Line 5450  sub _tree_construction_main ($) {
5450                unless (defined $i) {                unless (defined $i) {
5451                  !!!cp ('t223');                  !!!cp ('t223');
5452  ## TODO: The following is wrong, maybe.  ## TODO: The following is wrong, maybe.
5453                  !!!parse-error (type => 'unmatched end tag:table', token => $token);                  !!!parse-error (type => 'unmatched end tag', text => 'table',
5454                                    token => $token);
5455                  ## Ignore tokens </table><table>                  ## Ignore tokens </table><table>
5456                  !!!nack ('t223.1');                  !!!nack ('t223.1');
5457                  !!!next-token;                  !!!next-token;
5458                  next B;                  next B;
5459                }                }
5460                                
5461  ## TODO: Followings are removed from the latest spec.  ## TODO: Followings are removed from the latest spec.
5462                ## generate implied end tags                ## generate implied end tags
5463                while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {                while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {
5464                  !!!cp ('t224');                  !!!cp ('t224');
# Line 5382  sub _tree_construction_main ($) { Line 5469  sub _tree_construction_main ($) {
5469                  !!!cp ('t225');                  !!!cp ('t225');
5470                  ## NOTE: |<table><tr><table>|                  ## NOTE: |<table><tr><table>|
5471                  !!!parse-error (type => 'not closed',                  !!!parse-error (type => 'not closed',
5472                                  value => $self->{open_elements}->[-1]->[0]                                  text => $self->{open_elements}->[-1]->[0]
5473                                      ->manakai_local_name,                                      ->manakai_local_name,
5474                                  token => $token);                                  token => $token);
5475                } else {                } else {
# Line 5423  sub _tree_construction_main ($) { Line 5510  sub _tree_construction_main ($) {
5510                my $type = lc $token->{attributes}->{type}->{value};                my $type = lc $token->{attributes}->{type}->{value};
5511                if ($type eq 'hidden') {                if ($type eq 'hidden') {
5512                  !!!cp ('t227.3');                  !!!cp ('t227.3');
5513                  !!!parse-error (type => 'in table:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'in table',
5514                                    text => $token->{tag_name}, token => $token);
5515    
5516                  !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);                  !!!insert-element ($token->{tag_name}, $token->{attributes}, $token);
5517    
# Line 5451  sub _tree_construction_main ($) { Line 5539  sub _tree_construction_main ($) {
5539            #            #
5540          }          }
5541    
5542          !!!parse-error (type => 'in table:'.$token->{tag_name}, token => $token);          !!!parse-error (type => 'in table', text => $token->{tag_name},
5543                            token => $token);
5544    
5545          $insert = $insert_to_foster;          $insert = $insert_to_foster;
5546          #          #
# Line 5473  sub _tree_construction_main ($) { Line 5562  sub _tree_construction_main ($) {
5562                } # INSCOPE                } # INSCOPE
5563                unless (defined $i) {                unless (defined $i) {
5564                  !!!cp ('t230');                  !!!cp ('t230');
5565                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
5566                                    text => $token->{tag_name}, token => $token);
5567                  ## Ignore the token                  ## Ignore the token
5568                  !!!nack ('t230.1');                  !!!nack ('t230.1');
5569                  !!!next-token;                  !!!next-token;
# Line 5514  sub _tree_construction_main ($) { Line 5604  sub _tree_construction_main ($) {
5604                  unless (defined $i) {                  unless (defined $i) {
5605                    !!!cp ('t235');                    !!!cp ('t235');
5606  ## TODO: The following is wrong.  ## TODO: The following is wrong.
5607                    !!!parse-error (type => 'unmatched end tag:'.$token->{type}, token => $token);                    !!!parse-error (type => 'unmatched end tag',
5608                                      text => $token->{type}, token => $token);
5609                    ## Ignore the token                    ## Ignore the token
5610                    !!!nack ('t236.1');                    !!!nack ('t236.1');
5611                    !!!next-token;                    !!!next-token;
# Line 5550  sub _tree_construction_main ($) { Line 5641  sub _tree_construction_main ($) {
5641                  } # INSCOPE                  } # INSCOPE
5642                  unless (defined $i) {                  unless (defined $i) {
5643                    !!!cp ('t239');                    !!!cp ('t239');
5644                    !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                    !!!parse-error (type => 'unmatched end tag',
5645                                      text => $token->{tag_name}, token => $token);
5646                    ## Ignore the token                    ## Ignore the token
5647                    !!!nack ('t239.1');                    !!!nack ('t239.1');
5648                    !!!next-token;                    !!!next-token;
# Line 5596  sub _tree_construction_main ($) { Line 5688  sub _tree_construction_main ($) {
5688                } # INSCOPE                } # INSCOPE
5689                unless (defined $i) {                unless (defined $i) {
5690                  !!!cp ('t243');                  !!!cp ('t243');
5691                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
5692                                    text => $token->{tag_name}, token => $token);
5693                  ## Ignore the token                  ## Ignore the token
5694                  !!!nack ('t243.1');                  !!!nack ('t243.1');
5695                  !!!next-token;                  !!!next-token;
# Line 5630  sub _tree_construction_main ($) { Line 5723  sub _tree_construction_main ($) {
5723                  } # INSCOPE                  } # INSCOPE
5724                    unless (defined $i) {                    unless (defined $i) {
5725                      !!!cp ('t249');                      !!!cp ('t249');
5726                      !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                      !!!parse-error (type => 'unmatched end tag',
5727                                        text => $token->{tag_name}, token => $token);
5728                      ## Ignore the token                      ## Ignore the token
5729                      !!!nack ('t249.1');                      !!!nack ('t249.1');
5730                      !!!next-token;                      !!!next-token;
# Line 5653  sub _tree_construction_main ($) { Line 5747  sub _tree_construction_main ($) {
5747                  } # INSCOPE                  } # INSCOPE
5748                    unless (defined $i) {                    unless (defined $i) {
5749                      !!!cp ('t252');                      !!!cp ('t252');
5750                      !!!parse-error (type => 'unmatched end tag:tr', token => $token);                      !!!parse-error (type => 'unmatched end tag',
5751                                        text => 'tr', token => $token);
5752                      ## Ignore the token                      ## Ignore the token
5753                      !!!nack ('t252.1');                      !!!nack ('t252.1');
5754                      !!!next-token;                      !!!next-token;
# Line 5688  sub _tree_construction_main ($) { Line 5783  sub _tree_construction_main ($) {
5783                } # INSCOPE                } # INSCOPE
5784                unless (defined $i) {                unless (defined $i) {
5785                  !!!cp ('t256');                  !!!cp ('t256');
5786                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag',
5787                                    text => $token->{tag_name}, token => $token);
5788                  ## Ignore the token                  ## Ignore the token
5789                  !!!nack ('t256.1');                  !!!nack ('t256.1');
5790                  !!!next-token;                  !!!next-token;
# Line 5715  sub _tree_construction_main ($) { Line 5811  sub _tree_construction_main ($) {
5811                        tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM                        tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM
5812                       }->{$token->{tag_name}}) {                       }->{$token->{tag_name}}) {
5813            !!!cp ('t258');            !!!cp ('t258');
5814            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'unmatched end tag',
5815                              text => $token->{tag_name}, token => $token);
5816            ## Ignore the token            ## Ignore the token
5817            !!!nack ('t258.1');            !!!nack ('t258.1');
5818             !!!next-token;             !!!next-token;
5819            next B;            next B;
5820          } else {          } else {
5821            !!!cp ('t259');            !!!cp ('t259');
5822            !!!parse-error (type => 'in table:/'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'in table:/',
5823                              text => $token->{tag_name}, token => $token);
5824    
5825            $insert = $insert_to_foster;            $insert = $insert_to_foster;
5826            #            #
# Line 5772  sub _tree_construction_main ($) { Line 5870  sub _tree_construction_main ($) {
5870              if ($token->{tag_name} eq 'colgroup') {              if ($token->{tag_name} eq 'colgroup') {
5871                if ($self->{open_elements}->[-1]->[1] & HTML_EL) {                if ($self->{open_elements}->[-1]->[1] & HTML_EL) {
5872                  !!!cp ('t264');                  !!!cp ('t264');
5873                  !!!parse-error (type => 'unmatched end tag:colgroup', token => $token);                  !!!parse-error (type => 'unmatched end tag',
5874                                    text => 'colgroup', token => $token);
5875                  ## Ignore the token                  ## Ignore the token
5876                  !!!next-token;                  !!!next-token;
5877                  next B;                  next B;
# Line 5785  sub _tree_construction_main ($) { Line 5884  sub _tree_construction_main ($) {
5884                }                }
5885              } elsif ($token->{tag_name} eq 'col') {              } elsif ($token->{tag_name} eq 'col') {
5886                !!!cp ('t266');                !!!cp ('t266');
5887                !!!parse-error (type => 'unmatched end tag:col', token => $token);                !!!parse-error (type => 'unmatched end tag',
5888                                  text => 'col', token => $token);
5889                ## Ignore the token                ## Ignore the token
5890                !!!next-token;                !!!next-token;
5891                next B;                next B;
# Line 5815  sub _tree_construction_main ($) { Line 5915  sub _tree_construction_main ($) {
5915            if ($self->{open_elements}->[-1]->[1] & HTML_EL) {            if ($self->{open_elements}->[-1]->[1] & HTML_EL) {
5916              !!!cp ('t269');              !!!cp ('t269');
5917  ## TODO: Wrong error type?  ## TODO: Wrong error type?
5918              !!!parse-error (type => 'unmatched end tag:colgroup', token => $token);              !!!parse-error (type => 'unmatched end tag',
5919                                text => 'colgroup', token => $token);
5920              ## Ignore the token              ## Ignore the token
5921              !!!nack ('t269.1');              !!!nack ('t269.1');
5922              !!!next-token;              !!!next-token;
# Line 5869  sub _tree_construction_main ($) { Line 5970  sub _tree_construction_main ($) {
5970            !!!nack ('t277.1');            !!!nack ('t277.1');
5971            !!!next-token;            !!!next-token;
5972            next B;            next B;
5973          } elsif ($token->{tag_name} eq 'select' or          } elsif ({
5974                   $token->{tag_name} eq 'input' or                     select => 1, input => 1, textarea => 1,
5975                     }->{$token->{tag_name}} or
5976                   ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and                   ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and
5977                    {                    {
5978                     caption => 1, table => 1,                     caption => 1, table => 1,
# Line 5878  sub _tree_construction_main ($) { Line 5980  sub _tree_construction_main ($) {
5980                     tr => 1, td => 1, th => 1,                     tr => 1, td => 1, th => 1,
5981                    }->{$token->{tag_name}})) {                    }->{$token->{tag_name}})) {
5982            ## TODO: The type below is not good - <select> is replaced by </select>            ## TODO: The type below is not good - <select> is replaced by </select>
5983            !!!parse-error (type => 'not closed:select', token => $token);            !!!parse-error (type => 'not closed', text => 'select',
5984                              token => $token);
5985            ## NOTE: As if the token were </select> (<select> case) or            ## NOTE: As if the token were </select> (<select> case) or
5986            ## as if there were </select> (otherwise).            ## as if there were </select> (otherwise).
5987            ## have an element in table scope            ## have an element in table scope
# Line 5896  sub _tree_construction_main ($) { Line 5999  sub _tree_construction_main ($) {
5999            } # INSCOPE            } # INSCOPE
6000            unless (defined $i) {            unless (defined $i) {
6001              !!!cp ('t280');              !!!cp ('t280');
6002              !!!parse-error (type => 'unmatched end tag:select', token => $token);              !!!parse-error (type => 'unmatched end tag',
6003                                text => 'select', token => $token);
6004              ## Ignore the token              ## Ignore the token
6005              !!!nack ('t280.1');              !!!nack ('t280.1');
6006              !!!next-token;              !!!next-token;
# Line 5920  sub _tree_construction_main ($) { Line 6024  sub _tree_construction_main ($) {
6024            }            }
6025          } else {          } else {
6026            !!!cp ('t282');            !!!cp ('t282');
6027            !!!parse-error (type => 'in select:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'in select',
6028                              text => $token->{tag_name}, token => $token);
6029            ## Ignore the token            ## Ignore the token
6030            !!!nack ('t282.1');            !!!nack ('t282.1');
6031            !!!next-token;            !!!next-token;
# Line 5938  sub _tree_construction_main ($) { Line 6043  sub _tree_construction_main ($) {
6043              pop @{$self->{open_elements}};              pop @{$self->{open_elements}};
6044            } else {            } else {
6045              !!!cp ('t285');              !!!cp ('t285');
6046              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'unmatched end tag',
6047                                text => $token->{tag_name}, token => $token);
6048              ## Ignore the token              ## Ignore the token
6049            }            }
6050            !!!nack ('t285.1');            !!!nack ('t285.1');
# Line 5950  sub _tree_construction_main ($) { Line 6056  sub _tree_construction_main ($) {
6056              pop @{$self->{open_elements}};              pop @{$self->{open_elements}};
6057            } else {            } else {
6058              !!!cp ('t287');              !!!cp ('t287');
6059              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'unmatched end tag',
6060                                text => $token->{tag_name}, token => $token);
6061              ## Ignore the token              ## Ignore the token
6062            }            }
6063            !!!nack ('t287.1');            !!!nack ('t287.1');
# Line 5972  sub _tree_construction_main ($) { Line 6079  sub _tree_construction_main ($) {
6079            } # INSCOPE            } # INSCOPE
6080            unless (defined $i) {            unless (defined $i) {
6081              !!!cp ('t290');              !!!cp ('t290');
6082              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'unmatched end tag',
6083                                text => $token->{tag_name}, token => $token);
6084              ## Ignore the token              ## Ignore the token
6085              !!!nack ('t290.1');              !!!nack ('t290.1');
6086              !!!next-token;              !!!next-token;
# Line 5993  sub _tree_construction_main ($) { Line 6101  sub _tree_construction_main ($) {
6101                    tfoot => 1, thead => 1, tr => 1, td => 1, th => 1,                    tfoot => 1, thead => 1, tr => 1, td => 1, th => 1,
6102                   }->{$token->{tag_name}}) {                   }->{$token->{tag_name}}) {
6103  ## TODO: The following is wrong?  ## TODO: The following is wrong?
6104            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'unmatched end tag',
6105                              text => $token->{tag_name}, token => $token);
6106                                
6107            ## have an element in table scope            ## have an element in table scope
6108            my $i;            my $i;
# Line 6034  sub _tree_construction_main ($) { Line 6143  sub _tree_construction_main ($) {
6143            unless (defined $i) {            unless (defined $i) {
6144              !!!cp ('t297');              !!!cp ('t297');
6145  ## TODO: The following error type is correct?  ## TODO: The following error type is correct?
6146              !!!parse-error (type => 'unmatched end tag:select', token => $token);              !!!parse-error (type => 'unmatched end tag',
6147                                text => 'select', token => $token);
6148              ## Ignore the </select> token              ## Ignore the </select> token
6149              !!!nack ('t297.1');              !!!nack ('t297.1');
6150              !!!next-token; ## TODO: ok?              !!!next-token; ## TODO: ok?
# Line 6051  sub _tree_construction_main ($) { Line 6161  sub _tree_construction_main ($) {
6161            next B;            next B;
6162          } else {          } else {
6163            !!!cp ('t299');            !!!cp ('t299');
6164            !!!parse-error (type => 'in select:/'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'in select:/',
6165                              text => $token->{tag_name}, token => $token);
6166            ## Ignore the token            ## Ignore the token
6167            !!!nack ('t299.3');            !!!nack ('t299.3');
6168            !!!next-token;            !!!next-token;
# Line 6089  sub _tree_construction_main ($) { Line 6200  sub _tree_construction_main ($) {
6200                    
6201          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
6202            !!!cp ('t301');            !!!cp ('t301');
6203            !!!parse-error (type => 'after html:#character', token => $token);            !!!parse-error (type => 'after html:#text', token => $token);
6204    
6205            ## Reprocess in the "after body" insertion mode.            ## Reprocess in the "after body" insertion mode.
6206          } else {          } else {
# Line 6097  sub _tree_construction_main ($) { Line 6208  sub _tree_construction_main ($) {
6208          }          }
6209                    
6210          ## "after body" insertion mode          ## "after body" insertion mode
6211          !!!parse-error (type => 'after body:#character', token => $token);          !!!parse-error (type => 'after body:#text', token => $token);
6212    
6213          $self->{insertion_mode} = IN_BODY_IM;          $self->{insertion_mode} = IN_BODY_IM;
6214          ## reprocess          ## reprocess
# Line 6105  sub _tree_construction_main ($) { Line 6216  sub _tree_construction_main ($) {
6216        } elsif ($token->{type} == START_TAG_TOKEN) {        } elsif ($token->{type} == START_TAG_TOKEN) {
6217          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
6218            !!!cp ('t303');            !!!cp ('t303');
6219            !!!parse-error (type => 'after html:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'after html',
6220                              text => $token->{tag_name}, token => $token);
6221                        
6222            ## Reprocess in the "after body" insertion mode.            ## Reprocess in the "after body" insertion mode.
6223          } else {          } else {
# Line 6113  sub _tree_construction_main ($) { Line 6225  sub _tree_construction_main ($) {
6225          }          }
6226    
6227          ## "after body" insertion mode          ## "after body" insertion mode
6228          !!!parse-error (type => 'after body:'.$token->{tag_name}, token => $token);          !!!parse-error (type => 'after body',
6229                            text => $token->{tag_name}, token => $token);
6230    
6231          $self->{insertion_mode} = IN_BODY_IM;          $self->{insertion_mode} = IN_BODY_IM;
6232          !!!ack-later;          !!!ack-later;
# Line 6122  sub _tree_construction_main ($) { Line 6235  sub _tree_construction_main ($) {
6235        } elsif ($token->{type} == END_TAG_TOKEN) {        } elsif ($token->{type} == END_TAG_TOKEN) {
6236          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {          if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
6237            !!!cp ('t305');            !!!cp ('t305');
6238            !!!parse-error (type => 'after html:/'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'after html:/',
6239                              text => $token->{tag_name}, token => $token);
6240                        
6241            $self->{insertion_mode} = AFTER_BODY_IM;            $self->{insertion_mode} = AFTER_BODY_IM;
6242            ## Reprocess in the "after body" insertion mode.            ## Reprocess in the "after body" insertion mode.
# Line 6134  sub _tree_construction_main ($) { Line 6248  sub _tree_construction_main ($) {
6248          if ($token->{tag_name} eq 'html') {          if ($token->{tag_name} eq 'html') {
6249            if (defined $self->{inner_html_node}) {            if (defined $self->{inner_html_node}) {
6250              !!!cp ('t307');              !!!cp ('t307');
6251              !!!parse-error (type => 'unmatched end tag:html', token => $token);              !!!parse-error (type => 'unmatched end tag',
6252                                text => 'html', token => $token);
6253              ## Ignore the token              ## Ignore the token
6254              !!!next-token;              !!!next-token;
6255              next B;              next B;
# Line 6146  sub _tree_construction_main ($) { Line 6261  sub _tree_construction_main ($) {
6261            }            }
6262          } else {          } else {
6263            !!!cp ('t309');            !!!cp ('t309');
6264            !!!parse-error (type => 'after body:/'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'after body:/',
6265                              text => $token->{tag_name}, token => $token);
6266    
6267            $self->{insertion_mode} = IN_BODY_IM;            $self->{insertion_mode} = IN_BODY_IM;
6268            ## reprocess            ## reprocess
# Line 6174  sub _tree_construction_main ($) { Line 6290  sub _tree_construction_main ($) {
6290          if ($token->{data} =~ s/^[^\x09\x0A\x0B\x0C\x20]+//) {          if ($token->{data} =~ s/^[^\x09\x0A\x0B\x0C\x20]+//) {
6291            if ($self->{insertion_mode} == IN_FRAMESET_IM) {            if ($self->{insertion_mode} == IN_FRAMESET_IM) {
6292              !!!cp ('t311');              !!!cp ('t311');
6293              !!!parse-error (type => 'in frameset:#character', token => $token);              !!!parse-error (type => 'in frameset:#text', token => $token);
6294            } elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) {            } elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) {
6295              !!!cp ('t312');              !!!cp ('t312');
6296              !!!parse-error (type => 'after frameset:#character', token => $token);              !!!parse-error (type => 'after frameset:#text', token => $token);
6297            } else { # "after html frameset"            } else { # "after html frameset"
6298              !!!cp ('t313');              !!!cp ('t313');
6299              !!!parse-error (type => 'after html:#character', token => $token);              !!!parse-error (type => 'after html:#text', token => $token);
6300    
6301              $self->{insertion_mode} = AFTER_FRAMESET_IM;              $self->{insertion_mode} = AFTER_FRAMESET_IM;
6302              ## Reprocess in the "after frameset" insertion mode.              ## Reprocess in the "after frameset" insertion mode.
6303              !!!parse-error (type => 'after frameset:#character', token => $token);              !!!parse-error (type => 'after frameset:#text', token => $token);
6304            }            }
6305                        
6306            ## Ignore the token.            ## Ignore the token.
# Line 6202  sub _tree_construction_main ($) { Line 6318  sub _tree_construction_main ($) {
6318        } elsif ($token->{type} == START_TAG_TOKEN) {        } elsif ($token->{type} == START_TAG_TOKEN) {
6319          if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {          if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {
6320            !!!cp ('t316');            !!!cp ('t316');
6321            !!!parse-error (type => 'after html:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'after html',
6322                              text => $token->{tag_name}, token => $token);
6323    
6324            $self->{insertion_mode} = AFTER_FRAMESET_IM;            $self->{insertion_mode} = AFTER_FRAMESET_IM;
6325            ## Process in the "after frameset" insertion mode.            ## Process in the "after frameset" insertion mode.
# Line 6227  sub _tree_construction_main ($) { Line 6344  sub _tree_construction_main ($) {
6344            next B;            next B;
6345          } elsif ($token->{tag_name} eq 'noframes') {          } elsif ($token->{tag_name} eq 'noframes') {
6346            !!!cp ('t320');            !!!cp ('t320');
6347            ## NOTE: As if in body.            ## NOTE: As if in head.
6348            $parse_rcdata->(CDATA_CONTENT_MODEL);            $parse_rcdata->(CDATA_CONTENT_MODEL);
6349            next B;            next B;
6350          } else {          } else {
6351            if ($self->{insertion_mode} == IN_FRAMESET_IM) {            if ($self->{insertion_mode} == IN_FRAMESET_IM) {
6352              !!!cp ('t321');              !!!cp ('t321');
6353              !!!parse-error (type => 'in frameset:'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'in frameset',
6354                                text => $token->{tag_name}, token => $token);
6355            } else {            } else {
6356              !!!cp ('t322');              !!!cp ('t322');
6357              !!!parse-error (type => 'after frameset:'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'after frameset',
6358                                text => $token->{tag_name}, token => $token);
6359            }            }
6360            ## Ignore the token            ## Ignore the token
6361            !!!nack ('t322.1');            !!!nack ('t322.1');
# Line 6246  sub _tree_construction_main ($) { Line 6365  sub _tree_construction_main ($) {
6365        } elsif ($token->{type} == END_TAG_TOKEN) {        } elsif ($token->{type} == END_TAG_TOKEN) {
6366          if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {          if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {
6367            !!!cp ('t323');            !!!cp ('t323');
6368            !!!parse-error (type => 'after html:/'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'after html:/',
6369                              text => $token->{tag_name}, token => $token);
6370    
6371            $self->{insertion_mode} = AFTER_FRAMESET_IM;            $self->{insertion_mode} = AFTER_FRAMESET_IM;
6372            ## Process in the "after frameset" insertion mode.            ## Process in the "after frameset" insertion mode.
# Line 6259  sub _tree_construction_main ($) { Line 6379  sub _tree_construction_main ($) {
6379            if ($self->{open_elements}->[-1]->[1] & HTML_EL and            if ($self->{open_elements}->[-1]->[1] & HTML_EL and
6380                @{$self->{open_elements}} == 1) {                @{$self->{open_elements}} == 1) {
6381              !!!cp ('t325');              !!!cp ('t325');
6382              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'unmatched end tag',
6383                                text => $token->{tag_name}, token => $token);
6384              ## Ignore the token              ## Ignore the token
6385              !!!next-token;              !!!next-token;
6386            } else {            } else {
# Line 6285  sub _tree_construction_main ($) { Line 6406  sub _tree_construction_main ($) {
6406          } else {          } else {
6407            if ($self->{insertion_mode} == IN_FRAMESET_IM) {            if ($self->{insertion_mode} == IN_FRAMESET_IM) {
6408              !!!cp ('t330');              !!!cp ('t330');
6409              !!!parse-error (type => 'in frameset:/'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'in frameset:/',
6410                                text => $token->{tag_name}, token => $token);
6411            } else {            } else {
6412              !!!cp ('t331');              !!!cp ('t331');
6413              !!!parse-error (type => 'after frameset:/'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'after frameset:/',
6414                                text => $token->{tag_name}, token => $token);
6415            }            }
6416            ## Ignore the token            ## Ignore the token
6417            !!!next-token;            !!!next-token;
# Line 6396  sub _tree_construction_main ($) { Line 6519  sub _tree_construction_main ($) {
6519          $parse_rcdata->(RCDATA_CONTENT_MODEL);          $parse_rcdata->(RCDATA_CONTENT_MODEL);
6520          next B;          next B;
6521        } elsif ($token->{tag_name} eq 'body') {        } elsif ($token->{tag_name} eq 'body') {
6522          !!!parse-error (type => 'in body:body', token => $token);          !!!parse-error (type => 'in body', text => 'body', token => $token);
6523                                
6524          if (@{$self->{open_elements}} == 1 or          if (@{$self->{open_elements}} == 1 or
6525              not ($self->{open_elements}->[1]->[1] & BODY_EL)) {              not ($self->{open_elements}->[1]->[1] & BODY_EL)) {
# Line 6516  sub _tree_construction_main ($) { Line 6639  sub _tree_construction_main ($) {
6639              if ($i != -1) {              if ($i != -1) {
6640                !!!cp ('t355');                !!!cp ('t355');
6641                !!!parse-error (type => 'not closed',                !!!parse-error (type => 'not closed',
6642                                value => $self->{open_elements}->[-1]->[0]                                text => $self->{open_elements}->[-1]->[0]
6643                                    ->manakai_local_name,                                    ->manakai_local_name,
6644                                token => $token);                                token => $token);
6645              } else {              } else {
# Line 6670  sub _tree_construction_main ($) { Line 6793  sub _tree_construction_main ($) {
6793                  xmp => 1,                  xmp => 1,
6794                  iframe => 1,                  iframe => 1,
6795                  noembed => 1,                  noembed => 1,
6796                  noframes => 1,                  noframes => 1, ## NOTE: This is an "as if in head" code clone.
6797                  noscript => 0, ## TODO: 1 if scripting is enabled                  noscript => 0, ## TODO: 1 if scripting is enabled
6798                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
6799          if ($token->{tag_name} eq 'xmp') {          if ($token->{tag_name} eq 'xmp') {
# Line 6692  sub _tree_construction_main ($) { Line 6815  sub _tree_construction_main ($) {
6815            !!!next-token;            !!!next-token;
6816            next B;            next B;
6817          } else {          } else {
6818              !!!ack ('t391.1');
6819    
6820            my $at = $token->{attributes};            my $at = $token->{attributes};
6821            my $form_attrs;            my $form_attrs;
6822            $form_attrs->{action} = $at->{action} if $at->{action};            $form_attrs->{action} = $at->{action} if $at->{action};
# Line 6735  sub _tree_construction_main ($) { Line 6860  sub _tree_construction_main ($) {
6860                           line => $token->{line}, column => $token->{column}},                           line => $token->{line}, column => $token->{column}},
6861                          {type => END_TAG_TOKEN, tag_name => 'form',                          {type => END_TAG_TOKEN, tag_name => 'form',
6862                           line => $token->{line}, column => $token->{column}};                           line => $token->{line}, column => $token->{column}};
           !!!nack ('t391.1'); ## NOTE: Not acknowledged.  
6863            !!!back-token (@tokens);            !!!back-token (@tokens);
6864            !!!next-token;            !!!next-token;
6865            next B;            next B;
# Line 6783  sub _tree_construction_main ($) { Line 6907  sub _tree_construction_main ($) {
6907            ## Ignore the token            ## Ignore the token
6908          } else {          } else {
6909            !!!cp ('t398');            !!!cp ('t398');
6910            !!!parse-error (type => 'in RCDATA:#'.$token->{type}, token => $token);            !!!parse-error (type => 'in RCDATA:#eof', token => $token);
6911          }          }
6912          !!!next-token;          !!!next-token;
6913          next B;          next B;
6914          } elsif ($token->{tag_name} eq 'rt' or
6915                   $token->{tag_name} eq 'rp') {
6916            ## has a |ruby| element in scope
6917            INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
6918              my $node = $self->{open_elements}->[$_];
6919              if ($node->[1] & RUBY_EL) {
6920                !!!cp ('t398.1');
6921                ## generate implied end tags
6922                while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {
6923                  !!!cp ('t398.2');
6924                  pop @{$self->{open_elements}};
6925                }
6926                unless ($self->{open_elements}->[-1]->[1] & RUBY_EL) {
6927                  !!!cp ('t398.3');
6928                  !!!parse-error (type => 'not closed',
6929                                  text => $self->{open_elements}->[-1]->[0]
6930                                      ->manakai_local_name,
6931                                  token => $token);
6932                  pop @{$self->{open_elements}}
6933                      while not $self->{open_elements}->[-1]->[1] & RUBY_EL;
6934                }
6935                last INSCOPE;
6936              } elsif ($node->[1] & SCOPING_EL) {
6937                !!!cp ('t398.4');
6938                last INSCOPE;
6939              }
6940            } # INSCOPE
6941    
6942            !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
6943    
6944            !!!nack ('t398.5');
6945            !!!next-token;
6946            redo B;
6947        } elsif ($token->{tag_name} eq 'math' or        } elsif ($token->{tag_name} eq 'math' or
6948                 $token->{tag_name} eq 'svg') {                 $token->{tag_name} eq 'svg') {
6949          $reconstruct_active_formatting_elements->($insert_to_current);          $reconstruct_active_formatting_elements->($insert_to_current);
# Line 6817  sub _tree_construction_main ($) { Line 6974  sub _tree_construction_main ($) {
6974                  thead => 1, tr => 1,                  thead => 1, tr => 1,
6975                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
6976          !!!cp ('t401');          !!!cp ('t401');
6977          !!!parse-error (type => 'in body:'.$token->{tag_name}, token => $token);          !!!parse-error (type => 'in body',
6978                            text => $token->{tag_name}, token => $token);
6979          ## Ignore the token          ## Ignore the token
6980          !!!nack ('t401.1'); ## NOTE: |<col/>| or |<frame/>| here is an error.          !!!nack ('t401.1'); ## NOTE: |<col/>| or |<frame/>| here is an error.
6981          !!!next-token;          !!!next-token;
# Line 6902  sub _tree_construction_main ($) { Line 7060  sub _tree_construction_main ($) {
7060            }            }
7061    
7062            !!!parse-error (type => 'start tag not allowed',            !!!parse-error (type => 'start tag not allowed',
7063                            value => $token->{tag_name}, token => $token);                            text => $token->{tag_name}, token => $token);
7064            ## NOTE: Ignore the token.            ## NOTE: Ignore the token.
7065            !!!next-token;            !!!next-token;
7066            next B;            next B;
# Line 6912  sub _tree_construction_main ($) { Line 7070  sub _tree_construction_main ($) {
7070            unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL) {            unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL) {
7071              !!!cp ('t403');              !!!cp ('t403');
7072              !!!parse-error (type => 'not closed',              !!!parse-error (type => 'not closed',
7073                              value => $_->[0]->manakai_local_name,                              text => $_->[0]->manakai_local_name,
7074                              token => $token);                              token => $token);
7075              last;              last;
7076            } else {            } else {
# Line 6932  sub _tree_construction_main ($) { Line 7090  sub _tree_construction_main ($) {
7090            unless ($self->{open_elements}->[-1]->[1] & BODY_EL) {            unless ($self->{open_elements}->[-1]->[1] & BODY_EL) {
7091              !!!cp ('t406');              !!!cp ('t406');
7092              !!!parse-error (type => 'not closed',              !!!parse-error (type => 'not closed',
7093                              value => $self->{open_elements}->[1]->[0]                              text => $self->{open_elements}->[1]->[0]
7094                                  ->manakai_local_name,                                  ->manakai_local_name,
7095                              token => $token);                              token => $token);
7096            } else {            } else {
# Line 6943  sub _tree_construction_main ($) { Line 7101  sub _tree_construction_main ($) {
7101            next B;            next B;
7102          } else {          } else {
7103            !!!cp ('t408');            !!!cp ('t408');
7104            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'unmatched end tag',
7105                              text => $token->{tag_name}, token => $token);
7106            ## Ignore the token            ## Ignore the token
7107            !!!next-token;            !!!next-token;
7108            next B;            next B;
# Line 6971  sub _tree_construction_main ($) { Line 7130  sub _tree_construction_main ($) {
7130    
7131          unless (defined $i) { # has an element in scope          unless (defined $i) { # has an element in scope
7132            !!!cp ('t413');            !!!cp ('t413');
7133            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'unmatched end tag',
7134                              text => $token->{tag_name}, token => $token);
7135          } else {          } else {
7136            ## Step 1. generate implied end tags            ## Step 1. generate implied end tags
7137            while ({            while ({
7138                      ## END_TAG_OPTIONAL_EL
7139                    dd => ($token->{tag_name} ne 'dd'),                    dd => ($token->{tag_name} ne 'dd'),
7140                    dt => ($token->{tag_name} ne 'dt'),                    dt => ($token->{tag_name} ne 'dt'),
7141                    li => ($token->{tag_name} ne 'li'),                    li => ($token->{tag_name} ne 'li'),
7142                    p => 1,                    p => 1,
7143                      rt => 1,
7144                      rp => 1,
7145                   }->{$self->{open_elements}->[-1]->[0]->manakai_local_name}) {                   }->{$self->{open_elements}->[-1]->[0]->manakai_local_name}) {
7146              !!!cp ('t409');              !!!cp ('t409');
7147              pop @{$self->{open_elements}};              pop @{$self->{open_elements}};
# Line 6989  sub _tree_construction_main ($) { Line 7152  sub _tree_construction_main ($) {
7152                    ne $token->{tag_name}) {                    ne $token->{tag_name}) {
7153              !!!cp ('t412');              !!!cp ('t412');
7154              !!!parse-error (type => 'not closed',              !!!parse-error (type => 'not closed',
7155                              value => $self->{open_elements}->[-1]->[0]                              text => $self->{open_elements}->[-1]->[0]
7156                                  ->manakai_local_name,                                  ->manakai_local_name,
7157                              token => $token);                              token => $token);
7158            } else {            } else {
# Line 7026  sub _tree_construction_main ($) { Line 7189  sub _tree_construction_main ($) {
7189    
7190          unless (defined $i) { # has an element in scope          unless (defined $i) { # has an element in scope
7191            !!!cp ('t421');            !!!cp ('t421');
7192            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'unmatched end tag',
7193                              text => $token->{tag_name}, token => $token);
7194          } else {          } else {
7195            ## Step 1. generate implied end tags            ## Step 1. generate implied end tags
7196            while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {            while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {
# Line 7039  sub _tree_construction_main ($) { Line 7203  sub _tree_construction_main ($) {
7203                    ne $token->{tag_name}) {                    ne $token->{tag_name}) {
7204              !!!cp ('t417.1');              !!!cp ('t417.1');
7205              !!!parse-error (type => 'not closed',              !!!parse-error (type => 'not closed',
7206                              value => $self->{open_elements}->[-1]->[0]                              text => $self->{open_elements}->[-1]->[0]
7207                                  ->manakai_local_name,                                  ->manakai_local_name,
7208                              token => $token);                              token => $token);
7209            } else {            } else {
# Line 7071  sub _tree_construction_main ($) { Line 7235  sub _tree_construction_main ($) {
7235    
7236          unless (defined $i) { # has an element in scope          unless (defined $i) { # has an element in scope
7237            !!!cp ('t425.1');            !!!cp ('t425.1');
7238            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'unmatched end tag',
7239                              text => $token->{tag_name}, token => $token);
7240          } else {          } else {
7241            ## Step 1. generate implied end tags            ## Step 1. generate implied end tags
7242            while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {            while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {
# Line 7083  sub _tree_construction_main ($) { Line 7248  sub _tree_construction_main ($) {
7248            if ($self->{open_elements}->[-1]->[0]->manakai_local_name            if ($self->{open_elements}->[-1]->[0]->manakai_local_name
7249                    ne $token->{tag_name}) {                    ne $token->{tag_name}) {
7250              !!!cp ('t425');              !!!cp ('t425');
7251              !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);              !!!parse-error (type => 'unmatched end tag',
7252                                text => $token->{tag_name}, token => $token);
7253            } else {            } else {
7254              !!!cp ('t426');              !!!cp ('t426');
7255            }            }
# Line 7114  sub _tree_construction_main ($) { Line 7280  sub _tree_construction_main ($) {
7280                    ne $token->{tag_name}) {                    ne $token->{tag_name}) {
7281              !!!cp ('t412.1');              !!!cp ('t412.1');
7282              !!!parse-error (type => 'not closed',              !!!parse-error (type => 'not closed',
7283                              value => $self->{open_elements}->[-1]->[0]                              text => $self->{open_elements}->[-1]->[0]
7284                                  ->manakai_local_name,                                  ->manakai_local_name,
7285                              token => $token);                              token => $token);
7286            } else {            } else {
# Line 7124  sub _tree_construction_main ($) { Line 7290  sub _tree_construction_main ($) {
7290            splice @{$self->{open_elements}}, $i;            splice @{$self->{open_elements}}, $i;
7291          } else {          } else {
7292            !!!cp ('t413.1');            !!!cp ('t413.1');
7293            !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);            !!!parse-error (type => 'unmatched end tag',
7294                              text => $token->{tag_name}, token => $token);
7295    
7296            !!!cp ('t415.1');            !!!cp ('t415.1');
7297            ## As if <p>, then reprocess the current token            ## As if <p>, then reprocess the current token
# Line 7147  sub _tree_construction_main ($) { Line 7314  sub _tree_construction_main ($) {
7314          next B;          next B;
7315        } elsif ($token->{tag_name} eq 'br') {        } elsif ($token->{tag_name} eq 'br') {
7316          !!!cp ('t428');          !!!cp ('t428');
7317          !!!parse-error (type => 'unmatched end tag:br', token => $token);          !!!parse-error (type => 'unmatched end tag',
7318                            text => 'br', token => $token);
7319    
7320          ## As if <br>          ## As if <br>
7321          $reconstruct_active_formatting_elements->($insert_to_current);          $reconstruct_active_formatting_elements->($insert_to_current);
# Line 7172  sub _tree_construction_main ($) { Line 7340  sub _tree_construction_main ($) {
7340                  noscript => 0, ## TODO: if scripting is enabled                  noscript => 0, ## TODO: if scripting is enabled
7341                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
7342          !!!cp ('t429');          !!!cp ('t429');
7343          !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);          !!!parse-error (type => 'unmatched end tag',
7344                            text => $token->{tag_name}, token => $token);
7345          ## Ignore the token          ## Ignore the token
7346          !!!next-token;          !!!next-token;
7347          next B;          next B;
# Line 7191  sub _tree_construction_main ($) { Line 7360  sub _tree_construction_main ($) {
7360              ## generate implied end tags              ## generate implied end tags
7361              while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {              while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {
7362                !!!cp ('t430');                !!!cp ('t430');
7363                ## ISSUE: Can this case be reached?                ## NOTE: |<ruby><rt></ruby>|.
7364                  ## ISSUE: <ruby><rt></rt> will also take this code path,
7365                  ## which seems wrong.
7366                pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
7367                  $node_i++;
7368              }              }
7369                    
7370              ## Step 2              ## Step 2
# Line 7201  sub _tree_construction_main ($) { Line 7373  sub _tree_construction_main ($) {
7373                !!!cp ('t431');                !!!cp ('t431');
7374                ## NOTE: <x><y></x>                ## NOTE: <x><y></x>
7375                !!!parse-error (type => 'not closed',                !!!parse-error (type => 'not closed',
7376                                value => $self->{open_elements}->[-1]->[0]                                text => $self->{open_elements}->[-1]->[0]
7377                                    ->manakai_local_name,                                    ->manakai_local_name,
7378                                token => $token);                                token => $token);
7379              } else {              } else {
# Line 7209  sub _tree_construction_main ($) { Line 7381  sub _tree_construction_main ($) {
7381              }              }
7382                            
7383              ## Step 3              ## Step 3
7384              splice @{$self->{open_elements}}, $node_i;              splice @{$self->{open_elements}}, $node_i if $node_i < 0;
7385    
7386              !!!next-token;              !!!next-token;
7387              last S2;              last S2;
# Line 7220  sub _tree_construction_main ($) { Line 7392  sub _tree_construction_main ($) {
7392                  ($node->[1] & SPECIAL_EL or                  ($node->[1] & SPECIAL_EL or
7393                   $node->[1] & SCOPING_EL)) {                   $node->[1] & SCOPING_EL)) {
7394                !!!cp ('t433');                !!!cp ('t433');
7395                !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                !!!parse-error (type => 'unmatched end tag',
7396                                  text => $token->{tag_name}, token => $token);
7397                ## Ignore the token                ## Ignore the token
7398                !!!next-token;                !!!next-token;
7399                last S2;                last S2;
# Line 7356  sub set_inner_html ($$$) { Line 7529  sub set_inner_html ($$$) {
7529                  0x10FFFE => 1, 0x10FFFF => 1,                  0x10FFFE => 1, 0x10FFFF => 1,
7530                 }->{$self->{next_char}}) {                 }->{$self->{next_char}}) {
7531          !!!cp ('i4.1');          !!!cp ('i4.1');
7532          !!!parse-error (type => 'control char', level => $self->{must_level});          if ($self->{next_char} < 0x10000) {
7533  ## TODO: error type documentation            !!!parse-error (type => 'control char',
7534                              text => (sprintf 'U+%04X', $self->{next_char}));
7535            } else {
7536              !!!parse-error (type => 'control char',
7537                              text => (sprintf 'U-%08X', $self->{next_char}));
7538            }
7539        }        }
7540      };      };
7541      $p->{prev_char} = [-1, -1, -1];      $p->{prev_char} = [-1, -1, -1];

Legend:
Removed from v.1.145  
changed lines
  Added in v.1.154

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24