/[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.138 by wakaba, Sun May 18 04:15:48 2008 UTC revision 1.146 by wakaba, Sat May 24 14:19:55 2008 UTC
# Line 8  use Error qw(:try); Line 8  use Error qw(:try);
8  ## doc.write ('');  ## doc.write ('');
9  ## alert (doc.compatMode);  ## alert (doc.compatMode);
10    
11  ## TODO: 1252 parse error (revision 1264)  require IO::Handle;
 ## TODO: 8859-11 = 874 (revision 1271)  
12    
13  my $HTML_NS = q<http://www.w3.org/1999/xhtml>;  my $HTML_NS = q<http://www.w3.org/1999/xhtml>;
14  my $MML_NS = q<http://www.w3.org/1998/Math/MathML>;  my $MML_NS = q<http://www.w3.org/1998/Math/MathML>;
# Line 212  my $el_category_f = { Line 211  my $el_category_f = {
211  };  };
212    
213  my $svg_attr_name = {  my $svg_attr_name = {
214      attributename => 'attributeName',
215    attributetype => 'attributeType',    attributetype => 'attributeType',
216    basefrequency => 'baseFrequency',    basefrequency => 'baseFrequency',
217    baseprofile => 'baseProfile',    baseprofile => 'baseProfile',
# Line 222  my $svg_attr_name = { Line 222  my $svg_attr_name = {
222    diffuseconstant => 'diffuseConstant',    diffuseconstant => 'diffuseConstant',
223    edgemode => 'edgeMode',    edgemode => 'edgeMode',
224    externalresourcesrequired => 'externalResourcesRequired',    externalresourcesrequired => 'externalResourcesRequired',
   fecolormatrix => 'feColorMatrix',  
   fecomposite => 'feComposite',  
   fegaussianblur => 'feGaussianBlur',  
   femorphology => 'feMorphology',  
   fetile => 'feTile',  
225    filterres => 'filterRes',    filterres => 'filterRes',
226    filterunits => 'filterUnits',    filterunits => 'filterUnits',
227    glyphref => 'glyphRef',    glyphref => 'glyphRef',
# Line 260  my $svg_attr_name = { Line 255  my $svg_attr_name = {
255    repeatcount => 'repeatCount',    repeatcount => 'repeatCount',
256    repeatdur => 'repeatDur',    repeatdur => 'repeatDur',
257    requiredextensions => 'requiredExtensions',    requiredextensions => 'requiredExtensions',
258      requiredfeatures => 'requiredFeatures',
259    specularconstant => 'specularConstant',    specularconstant => 'specularConstant',
260    specularexponent => 'specularExponent',    specularexponent => 'specularExponent',
261    spreadmethod => 'spreadMethod',    spreadmethod => 'spreadMethod',
# Line 566  sub parse_byte_stream ($$$$;$) { Line 562  sub parse_byte_stream ($$$$;$) {
562    
563  sub parse_char_string ($$$;$) {  sub parse_char_string ($$$;$) {
564    my $self = shift;    my $self = shift;
565    open my $input, '<:utf8', ref $_[0] ? $_[0] : \($_[0]);    require utf8;
566      my $s = ref $_[0] ? $_[0] : \($_[0]);
567      open my $input, '<' . (utf8::is_utf8 ($$s) ? ':utf8' : ''), $s;
568    return $self->parse_char_stream ($input, @_[1..$#_]);    return $self->parse_char_stream ($input, @_[1..$#_]);
569  } # parse_char_string  } # parse_char_string
570  *parse_string = \&parse_char_string;  *parse_string = \&parse_char_string;
# Line 592  sub parse_char_stream ($$$;$) { Line 590  sub parse_char_stream ($$$;$) {
590      pop @{$self->{prev_char}};      pop @{$self->{prev_char}};
591      unshift @{$self->{prev_char}}, $self->{next_char};      unshift @{$self->{prev_char}}, $self->{next_char};
592    
593      my $char = $input->getc;      my $char;
594        if (defined $self->{next_next_char}) {
595          $char = $self->{next_next_char};
596          delete $self->{next_next_char};
597        } else {
598          $char = $input->getc;
599        }
600      $self->{next_char} = -1 and return unless defined $char;      $self->{next_char} = -1 and return unless defined $char;
601      $self->{next_char} = ord $char;      $self->{next_char} = ord $char;
602    
# Line 607  sub parse_char_stream ($$$;$) { Line 611  sub parse_char_stream ($$$;$) {
611      } elsif ($self->{next_char} == 0x000D) { # CR      } elsif ($self->{next_char} == 0x000D) { # CR
612        !!!cp ('j2');        !!!cp ('j2');
613        my $next = $input->getc;        my $next = $input->getc;
614        if ($next ne "\x0A") {        if (defined $next and $next ne "\x0A") {
615          $input->ungetc ($next);          $self->{next_next_char} = $next;
616        }        }
617        $self->{next_char} = 0x000A; # LF # MUST        $self->{next_char} = 0x000A; # LF # MUST
618        $self->{line}++;        $self->{line}++;
# Line 1817  sub _get_next_token ($) { Line 1821  sub _get_next_token ($) {
1821          $self->{state} = SELF_CLOSING_START_TAG_STATE;          $self->{state} = SELF_CLOSING_START_TAG_STATE;
1822          !!!next-input-character;          !!!next-input-character;
1823          redo A;          redo A;
1824          } elsif ($self->{next_char} == -1) {
1825            !!!parse-error (type => 'unclosed tag');
1826            if ($self->{current_token}->{type} == START_TAG_TOKEN) {
1827              !!!cp (122.3);
1828              $self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name};
1829            } elsif ($self->{current_token}->{type} == END_TAG_TOKEN) {
1830              if ($self->{current_token}->{attributes}) {
1831                !!!cp (122.1);
1832                !!!parse-error (type => 'end tag attribute');
1833              } else {
1834                ## NOTE: This state should never be reached.
1835                !!!cp (122.2);
1836              }
1837            } else {
1838              die "$0: $self->{current_token}->{type}: Unknown token type";
1839            }
1840            $self->{state} = DATA_STATE;
1841            ## Reconsume.
1842            !!!emit ($self->{current_token}); # start tag or end tag
1843            redo A;
1844        } else {        } else {
1845          !!!cp ('124.1');          !!!cp ('124.1');
1846          !!!parse-error (type => 'no space between attributes');          !!!parse-error (type => 'no space between attributes');
# Line 1849  sub _get_next_token ($) { Line 1873  sub _get_next_token ($) {
1873          !!!emit ($self->{current_token}); # start tag or end tag          !!!emit ($self->{current_token}); # start tag or end tag
1874    
1875          redo A;          redo A;
1876          } elsif ($self->{next_char} == -1) {
1877            !!!parse-error (type => 'unclosed tag');
1878            if ($self->{current_token}->{type} == START_TAG_TOKEN) {
1879              !!!cp (124.7);
1880              $self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name};
1881            } elsif ($self->{current_token}->{type} == END_TAG_TOKEN) {
1882              if ($self->{current_token}->{attributes}) {
1883                !!!cp (124.5);
1884                !!!parse-error (type => 'end tag attribute');
1885              } else {
1886                ## NOTE: This state should never be reached.
1887                !!!cp (124.6);
1888              }
1889            } else {
1890              die "$0: $self->{current_token}->{type}: Unknown token type";
1891            }
1892            $self->{state} = DATA_STATE;
1893            ## Reconsume.
1894            !!!emit ($self->{current_token}); # start tag or end tag
1895            redo A;
1896        } else {        } else {
1897          !!!cp ('124.4');          !!!cp ('124.4');
1898          !!!parse-error (type => 'nestc');          !!!parse-error (type => 'nestc');
# Line 2689  sub _get_next_token ($) { Line 2733  sub _get_next_token ($) {
2733          redo A;          redo A;
2734        } elsif ($self->{next_char} == -1) {        } elsif ($self->{next_char} == -1) {
2735          !!!cp (217);          !!!cp (217);
         !!!parse-error (type => 'unclosed DOCTYPE');  
2736    
2737          $self->{state} = DATA_STATE;          $self->{state} = DATA_STATE;
2738          ## reconsume          ## reconsume
# Line 3093  sub _tree_construction_initial ($) { Line 3136  sub _tree_construction_initial ($) {
3136        } elsif (defined $token->{public_identifier}) {        } elsif (defined $token->{public_identifier}) {
3137          my $pubid = $token->{public_identifier};          my $pubid = $token->{public_identifier};
3138          $pubid =~ tr/a-z/A-z/;          $pubid =~ tr/a-z/A-z/;
3139          if ({          my $prefix = [
3140            "+//SILMARIL//DTD HTML PRO V0R11 19970101//EN" => 1,            "+//SILMARIL//DTD HTML PRO V0R11 19970101//",
3141            "-//ADVASOFT LTD//DTD HTML 3.0 ASWEDIT + EXTENSIONS//EN" => 1,            "-//ADVASOFT LTD//DTD HTML 3.0 ASWEDIT + EXTENSIONS//",
3142            "-//AS//DTD HTML 3.0 ASWEDIT + EXTENSIONS//EN" => 1,            "-//AS//DTD HTML 3.0 ASWEDIT + EXTENSIONS//",
3143            "-//IETF//DTD HTML 2.0 LEVEL 1//EN" => 1,            "-//IETF//DTD HTML 2.0 LEVEL 1//",
3144            "-//IETF//DTD HTML 2.0 LEVEL 2//EN" => 1,            "-//IETF//DTD HTML 2.0 LEVEL 2//",
3145            "-//IETF//DTD HTML 2.0 STRICT LEVEL 1//EN" => 1,            "-//IETF//DTD HTML 2.0 STRICT LEVEL 1//",
3146            "-//IETF//DTD HTML 2.0 STRICT LEVEL 2//EN" => 1,            "-//IETF//DTD HTML 2.0 STRICT LEVEL 2//",
3147            "-//IETF//DTD HTML 2.0 STRICT//EN" => 1,            "-//IETF//DTD HTML 2.0 STRICT//",
3148            "-//IETF//DTD HTML 2.0//EN" => 1,            "-//IETF//DTD HTML 2.0//",
3149            "-//IETF//DTD HTML 2.1E//EN" => 1,            "-//IETF//DTD HTML 2.1E//",
3150            "-//IETF//DTD HTML 3.0//EN" => 1,            "-//IETF//DTD HTML 3.0//",
3151            "-//IETF//DTD HTML 3.0//EN//" => 1,            "-//IETF//DTD HTML 3.2 FINAL//",
3152            "-//IETF//DTD HTML 3.2 FINAL//EN" => 1,            "-//IETF//DTD HTML 3.2//",
3153            "-//IETF//DTD HTML 3.2//EN" => 1,            "-//IETF//DTD HTML 3//",
3154            "-//IETF//DTD HTML 3//EN" => 1,            "-//IETF//DTD HTML LEVEL 0//",
3155            "-//IETF//DTD HTML LEVEL 0//EN" => 1,            "-//IETF//DTD HTML LEVEL 1//",
3156            "-//IETF//DTD HTML LEVEL 0//EN//2.0" => 1,            "-//IETF//DTD HTML LEVEL 2//",
3157            "-//IETF//DTD HTML LEVEL 1//EN" => 1,            "-//IETF//DTD HTML LEVEL 3//",
3158            "-//IETF//DTD HTML LEVEL 1//EN//2.0" => 1,            "-//IETF//DTD HTML STRICT LEVEL 0//",
3159            "-//IETF//DTD HTML LEVEL 2//EN" => 1,            "-//IETF//DTD HTML STRICT LEVEL 1//",
3160            "-//IETF//DTD HTML LEVEL 2//EN//2.0" => 1,            "-//IETF//DTD HTML STRICT LEVEL 2//",
3161            "-//IETF//DTD HTML LEVEL 3//EN" => 1,            "-//IETF//DTD HTML STRICT LEVEL 3//",
3162            "-//IETF//DTD HTML LEVEL 3//EN//3.0" => 1,            "-//IETF//DTD HTML STRICT//",
3163            "-//IETF//DTD HTML STRICT LEVEL 0//EN" => 1,            "-//IETF//DTD HTML//",
3164            "-//IETF//DTD HTML STRICT LEVEL 0//EN//2.0" => 1,            "-//METRIUS//DTD METRIUS PRESENTATIONAL//",
3165            "-//IETF//DTD HTML STRICT LEVEL 1//EN" => 1,            "-//MICROSOFT//DTD INTERNET EXPLORER 2.0 HTML STRICT//",
3166            "-//IETF//DTD HTML STRICT LEVEL 1//EN//2.0" => 1,            "-//MICROSOFT//DTD INTERNET EXPLORER 2.0 HTML//",
3167            "-//IETF//DTD HTML STRICT LEVEL 2//EN" => 1,            "-//MICROSOFT//DTD INTERNET EXPLORER 2.0 TABLES//",
3168            "-//IETF//DTD HTML STRICT LEVEL 2//EN//2.0" => 1,            "-//MICROSOFT//DTD INTERNET EXPLORER 3.0 HTML STRICT//",
3169            "-//IETF//DTD HTML STRICT LEVEL 3//EN" => 1,            "-//MICROSOFT//DTD INTERNET EXPLORER 3.0 HTML//",
3170            "-//IETF//DTD HTML STRICT LEVEL 3//EN//3.0" => 1,            "-//MICROSOFT//DTD INTERNET EXPLORER 3.0 TABLES//",
3171            "-//IETF//DTD HTML STRICT//EN" => 1,            "-//NETSCAPE COMM. CORP.//DTD HTML//",
3172            "-//IETF//DTD HTML STRICT//EN//2.0" => 1,            "-//NETSCAPE COMM. CORP.//DTD STRICT HTML//",
3173            "-//IETF//DTD HTML STRICT//EN//3.0" => 1,            "-//O'REILLY AND ASSOCIATES//DTD HTML 2.0//",
3174            "-//IETF//DTD HTML//EN" => 1,            "-//O'REILLY AND ASSOCIATES//DTD HTML EXTENDED 1.0//",
3175            "-//IETF//DTD HTML//EN//2.0" => 1,            "-//O'REILLY AND ASSOCIATES//DTD HTML EXTENDED RELAXED 1.0//",
3176            "-//IETF//DTD HTML//EN//3.0" => 1,            "-//SOFTQUAD SOFTWARE//DTD HOTMETAL PRO 6.0::19990601::EXTENSIONS TO HTML 4.0//",
3177            "-//METRIUS//DTD METRIUS PRESENTATIONAL//EN" => 1,            "-//SOFTQUAD//DTD HOTMETAL PRO 4.0::19971010::EXTENSIONS TO HTML 4.0//",
3178            "-//MICROSOFT//DTD INTERNET EXPLORER 2.0 HTML STRICT//EN" => 1,            "-//SPYGLASS//DTD HTML 2.0 EXTENDED//",
3179            "-//MICROSOFT//DTD INTERNET EXPLORER 2.0 HTML//EN" => 1,            "-//SQ//DTD HTML 2.0 HOTMETAL + EXTENSIONS//",
3180            "-//MICROSOFT//DTD INTERNET EXPLORER 2.0 TABLES//EN" => 1,            "-//SUN MICROSYSTEMS CORP.//DTD HOTJAVA HTML//",
3181            "-//MICROSOFT//DTD INTERNET EXPLORER 3.0 HTML STRICT//EN" => 1,            "-//SUN MICROSYSTEMS CORP.//DTD HOTJAVA STRICT HTML//",
3182            "-//MICROSOFT//DTD INTERNET EXPLORER 3.0 HTML//EN" => 1,            "-//W3C//DTD HTML 3 1995-03-24//",
3183            "-//MICROSOFT//DTD INTERNET EXPLORER 3.0 TABLES//EN" => 1,            "-//W3C//DTD HTML 3.2 DRAFT//",
3184            "-//NETSCAPE COMM. CORP.//DTD HTML//EN" => 1,            "-//W3C//DTD HTML 3.2 FINAL//",
3185            "-//NETSCAPE COMM. CORP.//DTD STRICT HTML//EN" => 1,            "-//W3C//DTD HTML 3.2//",
3186            "-//O'REILLY AND ASSOCIATES//DTD HTML 2.0//EN" => 1,            "-//W3C//DTD HTML 3.2S DRAFT//",
3187            "-//O'REILLY AND ASSOCIATES//DTD HTML EXTENDED 1.0//EN" => 1,            "-//W3C//DTD HTML 4.0 FRAMESET//",
3188            "-//O'REILLY AND ASSOCIATES//DTD HTML EXTENDED RELAXED 1.0//EN" => 1,            "-//W3C//DTD HTML 4.0 TRANSITIONAL//",
3189            "-//SOFTQUAD SOFTWARE//DTD HOTMETAL PRO 6.0::19990601::EXTENSIONS TO HTML 4.0//EN" => 1,            "-//W3C//DTD HTML EXPERIMETNAL 19960712//",
3190            "-//SOFTQUAD//DTD HOTMETAL PRO 4.0::19971010::EXTENSIONS TO HTML 4.0//EN" => 1,            "-//W3C//DTD HTML EXPERIMENTAL 970421//",
3191            "-//SPYGLASS//DTD HTML 2.0 EXTENDED//EN" => 1,            "-//W3C//DTD W3 HTML//",
3192            "-//SQ//DTD HTML 2.0 HOTMETAL + EXTENSIONS//EN" => 1,            "-//W3O//DTD W3 HTML 3.0//",
3193            "-//SUN MICROSYSTEMS CORP.//DTD HOTJAVA HTML//EN" => 1,            "-//WEBTECHS//DTD MOZILLA HTML 2.0//",
3194            "-//SUN MICROSYSTEMS CORP.//DTD HOTJAVA STRICT HTML//EN" => 1,            "-//WEBTECHS//DTD MOZILLA HTML//",
3195            "-//W3C//DTD HTML 3 1995-03-24//EN" => 1,          ]; # $prefix
3196            "-//W3C//DTD HTML 3.2 DRAFT//EN" => 1,          my $match;
3197            "-//W3C//DTD HTML 3.2 FINAL//EN" => 1,          for (@$prefix) {
3198            "-//W3C//DTD HTML 3.2//EN" => 1,            if (substr ($prefix, 0, length $_) eq $_) {
3199            "-//W3C//DTD HTML 3.2S DRAFT//EN" => 1,              $match = 1;
3200            "-//W3C//DTD HTML 4.0 FRAMESET//EN" => 1,              last;
3201            "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN" => 1,            }
3202            "-//W3C//DTD HTML EXPERIMETNAL 19960712//EN" => 1,          }
3203            "-//W3C//DTD HTML EXPERIMENTAL 970421//EN" => 1,          if ($match or
3204            "-//W3C//DTD W3 HTML//EN" => 1,              $pubid eq "-//W3O//DTD W3 HTML STRICT 3.0//EN//" or
3205            "-//W3O//DTD W3 HTML 3.0//EN" => 1,              $pubid eq "-/W3C/DTD HTML 4.0 TRANSITIONAL/EN" or
3206            "-//W3O//DTD W3 HTML 3.0//EN//" => 1,              $pubid eq "HTML") {
           "-//W3O//DTD W3 HTML STRICT 3.0//EN//" => 1,  
           "-//WEBTECHS//DTD MOZILLA HTML 2.0//EN" => 1,  
           "-//WEBTECHS//DTD MOZILLA HTML//EN" => 1,  
           "-/W3C/DTD HTML 4.0 TRANSITIONAL/EN" => 1,  
           "HTML" => 1,  
         }->{$pubid}) {  
3207            !!!cp ('t5');            !!!cp ('t5');
3208            $self->{document}->manakai_compat_mode ('quirks');            $self->{document}->manakai_compat_mode ('quirks');
3209          } elsif ($pubid eq "-//W3C//DTD HTML 4.01 FRAMESET//EN" or          } elsif ($pubid =~ m[^-//W3C//DTD HTML 4.01 FRAMESET//] or
3210                   $pubid eq "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN") {                   $pubid =~ m[^-//W3C//DTD HTML 4.01 TRANSITIONAL//]) {
3211            if (defined $token->{system_identifier}) {            if (defined $token->{system_identifier}) {
3212              !!!cp ('t6');              !!!cp ('t6');
3213              $self->{document}->manakai_compat_mode ('quirks');              $self->{document}->manakai_compat_mode ('quirks');
# Line 3178  sub _tree_construction_initial ($) { Line 3215  sub _tree_construction_initial ($) {
3215              !!!cp ('t7');              !!!cp ('t7');
3216              $self->{document}->manakai_compat_mode ('limited quirks');              $self->{document}->manakai_compat_mode ('limited quirks');
3217            }            }
3218          } elsif ($pubid eq "-//W3C//DTD XHTML 1.0 FRAMESET//EN" or          } elsif ($pubid =~ m[^-//W3C//DTD XHTML 1.0 FRAMESET//] or
3219                   $pubid eq "-//W3C//DTD XHTML 1.0 TRANSITIONAL//EN") {                   $pubid =~ m[^-//W3C//DTD XHTML 1.0 TRANSITIONAL//]) {
3220            !!!cp ('t8');            !!!cp ('t8');
3221            $self->{document}->manakai_compat_mode ('limited quirks');            $self->{document}->manakai_compat_mode ('limited quirks');
3222          } else {          } else {
# Line 3192  sub _tree_construction_initial ($) { Line 3229  sub _tree_construction_initial ($) {
3229          my $sysid = $token->{system_identifier};          my $sysid = $token->{system_identifier};
3230          $sysid =~ tr/A-Z/a-z/;          $sysid =~ tr/A-Z/a-z/;
3231          if ($sysid eq "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd") {          if ($sysid eq "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd") {
3232            ## TODO: Check the spec: PUBLIC "(limited quirks)" "(quirks)"            ## NOTE: Ensure that |PUBLIC "(limited quirks)" "(quirks)"| is
3233              ## marked as quirks.
3234            $self->{document}->manakai_compat_mode ('quirks');            $self->{document}->manakai_compat_mode ('quirks');
3235            !!!cp ('t11');            !!!cp ('t11');
3236          } else {          } else {
# Line 3364  sub _reset_insertion_mode ($) { Line 3402  sub _reset_insertion_mode ($) {
3402        if ($self->{open_elements}->[0]->[0] eq $node->[0]) {        if ($self->{open_elements}->[0]->[0] eq $node->[0]) {
3403          $last = 1;          $last = 1;
3404          if (defined $self->{inner_html_node}) {          if (defined $self->{inner_html_node}) {
3405            if ($self->{inner_html_node}->[1] & TABLE_CELL_EL) {            !!!cp ('t28');
3406              !!!cp ('t27');            $node = $self->{inner_html_node};
3407              #          } else {
3408            } else {            die "_reset_insertion_mode: t27";
             !!!cp ('t28');  
             $node = $self->{inner_html_node};  
           }  
3409          }          }
3410        }        }
3411              
3412      ## Step 4..14        ## Step 4..14
3413      my $new_mode;        my $new_mode;
3414      if ($node->[1] & FOREIGN_EL) {        if ($node->[1] & FOREIGN_EL) {
3415        ## NOTE: Strictly spaking, the line below only applies to MathML and          !!!cp ('t28.1');
3416        ## SVG elements.  Currently the HTML syntax supports only MathML and          ## NOTE: Strictly spaking, the line below only applies to MathML and
3417        ## SVG elements as foreigners.          ## SVG elements.  Currently the HTML syntax supports only MathML and
3418        $new_mode = $self->{insertion_mode} | IN_FOREIGN_CONTENT_IM;          ## SVG elements as foreigners.
3419        ## ISSUE: What is set as the secondary insertion mode?          $new_mode = $self->{insertion_mode} | IN_FOREIGN_CONTENT_IM;
3420      } else {          ## ISSUE: What is set as the secondary insertion mode?
3421        $new_mode = {        } elsif ($node->[1] & TABLE_CELL_EL) {
3422            if ($last) {
3423              !!!cp ('t28.2');
3424              #
3425            } else {
3426              !!!cp ('t28.3');
3427              $new_mode = IN_CELL_IM;
3428            }
3429          } else {
3430            !!!cp ('t28.4');
3431            $new_mode = {
3432                        select => IN_SELECT_IM,                        select => IN_SELECT_IM,
3433                        ## NOTE: |option| and |optgroup| do not set                        ## NOTE: |option| and |optgroup| do not set
3434                        ## insertion mode to "in select" by themselves.                        ## insertion mode to "in select" by themselves.
                       td => IN_CELL_IM,  
                       th => IN_CELL_IM,  
3435                        tr => IN_ROW_IM,                        tr => IN_ROW_IM,
3436                        tbody => IN_TABLE_BODY_IM,                        tbody => IN_TABLE_BODY_IM,
3437                        thead => IN_TABLE_BODY_IM,                        thead => IN_TABLE_BODY_IM,
# Line 3400  sub _reset_insertion_mode ($) { Line 3443  sub _reset_insertion_mode ($) {
3443                        body => IN_BODY_IM,                        body => IN_BODY_IM,
3444                        frameset => IN_FRAMESET_IM,                        frameset => IN_FRAMESET_IM,
3445                       }->{$node->[0]->manakai_local_name};                       }->{$node->[0]->manakai_local_name};
3446      }        }
3447      $self->{insertion_mode} = $new_mode and return if defined $new_mode;        $self->{insertion_mode} = $new_mode and return if defined $new_mode;
3448                
3449        ## Step 15        ## Step 15
3450        if ($node->[1] & HTML_EL) {        if ($node->[1] & HTML_EL) {
# Line 3978  sub _tree_construction_main ($) { Line 4021  sub _tree_construction_main ($) {
4021            #            #
4022          } elsif ({          } elsif ({
4023                    b => 1, big => 1, blockquote => 1, body => 1, br => 1,                    b => 1, big => 1, blockquote => 1, body => 1, br => 1,
4024                    center => 1, code => 1, dd => 1, div => 1, dl => 1, em => 1,                    center => 1, code => 1, dd => 1, div => 1, dl => 1, dt => 1,
4025                    embed => 1, font => 1, h1 => 1, h2 => 1, h3 => 1, ## No h4!                    em => 1, embed => 1, font => 1, h1 => 1, h2 => 1, h3 => 1,
4026                    h5 => 1, h6 => 1, head => 1, hr => 1, i => 1, img => 1,                    h4 => 1, h5 => 1, h6 => 1, head => 1, hr => 1, i => 1,
4027                    li => 1, menu => 1, meta => 1, nobr => 1, p => 1, pre => 1,                    img => 1, li => 1, listing => 1, menu => 1, meta => 1,
4028                    ruby => 1, s => 1, small => 1, span => 1, strong => 1,                    nobr => 1, ol => 1, p => 1, pre => 1, ruby => 1, s => 1,
4029                    sub => 1, sup => 1, table => 1, tt => 1, u => 1, ul => 1,                    small => 1, span => 1, strong => 1, strike => 1, sub => 1,
4030                    var => 1,                    sup => 1, table => 1, tt => 1, u => 1, ul => 1, var => 1,
4031                   }->{$token->{tag_name}}) {                   }->{$token->{tag_name}}) {
4032            !!!cp ('t87.2');            !!!cp ('t87.2');
4033            !!!parse-error (type => 'not closed',            !!!parse-error (type => 'not closed',
# Line 4064  sub _tree_construction_main ($) { Line 4107  sub _tree_construction_main ($) {
4107          !!!cp ('t87.5');          !!!cp ('t87.5');
4108          #          #
4109        } elsif ($token->{type} == END_OF_FILE_TOKEN) {        } elsif ($token->{type} == END_OF_FILE_TOKEN) {
         ## NOTE: "using the rules for secondary insertion mode" then "continue"  
4110          !!!cp ('t87.6');          !!!cp ('t87.6');
4111          #          !!!parse-error (type => 'not closed',
4112          ## TODO: ...                          value => $self->{open_elements}->[-1]->[0]
4113                                ->manakai_local_name,
4114                            token => $token);
4115    
4116            pop @{$self->{open_elements}}
4117                while $self->{open_elements}->[-1]->[1] & FOREIGN_EL;
4118    
4119            $self->{insertion_mode} &= ~ IN_FOREIGN_CONTENT_IM;
4120            ## Reprocess.
4121            next B;
4122        } else {        } else {
4123          die "$0: $token->{type}: Unknown token type";                  die "$0: $token->{type}: Unknown token type";        
4124        }        }
# Line 4144  sub _tree_construction_main ($) { Line 4195  sub _tree_construction_main ($) {
4195              !!!next-token;              !!!next-token;
4196              next B;              next B;
4197            } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {            } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4198              !!!cp ('t94');              !!!cp ('t93.2');
4199              #              !!!parse-error (type => 'after head:head', token => $token); ## TODO: error type
4200                ## Ignore the token
4201                !!!nack ('t93.3');
4202                !!!next-token;
4203                next B;
4204            } else {            } else {
4205              !!!cp ('t95');              !!!cp ('t95');
4206              !!!parse-error (type => 'in head:head', token => $token); # or in head noscript              !!!parse-error (type => 'in head:head', token => $token); # or in head noscript
# Line 4242  sub _tree_construction_main ($) { Line 4297  sub _tree_construction_main ($) {
4297                                                 ->{has_reference});                                                 ->{has_reference});
4298                  } elsif ($token->{attributes}->{content}) {                  } elsif ($token->{attributes}->{content}) {
4299                    if ($token->{attributes}->{content}->{value}                    if ($token->{attributes}->{content}->{value}
4300                        =~ /\A[^;]*;[\x09-\x0D\x20]*[Cc][Hh][Aa][Rr][Ss][Ee][Tt]                        =~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt]
4301                            [\x09-\x0D\x20]*=                            [\x09-\x0D\x20]*=
4302                            [\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'|                            [\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'|
4303                            ([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) {                            ([^"'\x09-\x0D\x20][^\x09-\x0D\x20\x3B]*))/x) {
4304                      !!!cp ('t107');                      !!!cp ('t107');
4305                      ## NOTE: Whether the encoding is supported or not is handled                      ## NOTE: Whether the encoding is supported or not is handled
4306                      ## in the {change_encoding} callback.                      ## in the {change_encoding} callback.
# Line 4467  sub _tree_construction_main ($) { Line 4522  sub _tree_construction_main ($) {
4522                  $self->{insertion_mode} = AFTER_HEAD_IM;                  $self->{insertion_mode} = AFTER_HEAD_IM;
4523                  !!!next-token;                  !!!next-token;
4524                  next B;                  next B;
4525                  } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4526                    !!!cp ('t134.1');
4527                    !!!parse-error (type => 'unmatched end tag:head', token => $token);
4528                    ## Ignore the token
4529                    !!!next-token;
4530                    next B;
4531                } else {                } else {
4532                  !!!cp ('t135');                  die "$0: $self->{insertion_mode}: Unknown insertion mode";
                 #  
4533                }                }
4534              } elsif ($token->{tag_name} eq 'noscript') {              } elsif ($token->{tag_name} eq 'noscript') {
4535                if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {                if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
# Line 4478  sub _tree_construction_main ($) { Line 4538  sub _tree_construction_main ($) {
4538                  $self->{insertion_mode} = IN_HEAD_IM;                  $self->{insertion_mode} = IN_HEAD_IM;
4539                  !!!next-token;                  !!!next-token;
4540                  next B;                  next B;
4541                } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {                } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM or
4542                           $self->{insertion_mode} == AFTER_HEAD_IM) {
4543                  !!!cp ('t137');                  !!!cp ('t137');
4544                  !!!parse-error (type => 'unmatched end tag:noscript', token => $token);                  !!!parse-error (type => 'unmatched end tag:noscript', token => $token);
4545                  ## Ignore the token ## ISSUE: An issue in the spec.                  ## Ignore the token ## ISSUE: An issue in the spec.
# Line 4491  sub _tree_construction_main ($) { Line 4552  sub _tree_construction_main ($) {
4552              } elsif ({              } elsif ({
4553                        body => 1, html => 1,                        body => 1, html => 1,
4554                       }->{$token->{tag_name}}) {                       }->{$token->{tag_name}}) {
4555                if ($self->{insertion_mode} == BEFORE_HEAD_IM) {                if ($self->{insertion_mode} == BEFORE_HEAD_IM or
4556                  !!!cp ('t139');                    $self->{insertion_mode} == IN_HEAD_IM or
4557                  ## As if <head>                    $self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
                 !!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token);  
                 $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});  
                 push @{$self->{open_elements}},  
                     [$self->{head_element}, $el_category->{head}];  
   
                 $self->{insertion_mode} = IN_HEAD_IM;  
                 ## Reprocess in the "in head" insertion mode...  
               } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {  
4558                  !!!cp ('t140');                  !!!cp ('t140');
4559                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
4560                  ## Ignore the token                  ## Ignore the token
4561                  !!!next-token;                  !!!next-token;
4562                  next B;                  next B;
4563                  } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4564                    !!!cp ('t140.1');
4565                    !!!parse-error (type => 'unmatched end tag:' . $token->{tag_name}, token => $token);
4566                    ## Ignore the token
4567                    !!!next-token;
4568                    next B;
4569                } else {                } else {
4570                  !!!cp ('t141');                  die "$0: $self->{insertion_mode}: Unknown insertion mode";
4571                }                }
4572                              } elsif ($token->{tag_name} eq 'p') {
4573                #                !!!cp ('t142');
4574              } elsif ({                !!!parse-error (type => 'unmatched end tag:p', token => $token);
4575                        p => 1, br => 1,                ## Ignore the token
4576                       }->{$token->{tag_name}}) {                !!!next-token;
4577                  next B;
4578                } elsif ($token->{tag_name} eq 'br') {
4579                if ($self->{insertion_mode} == BEFORE_HEAD_IM) {                if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
4580                  !!!cp ('t142');                  !!!cp ('t142.2');
4581                  ## As if <head>                  ## (before head) as if <head>, (in head) as if </head>
4582                  !!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token);                  !!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token);
4583                  $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});                  $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
4584                  push @{$self->{open_elements}},                  $self->{insertion_mode} = AFTER_HEAD_IM;
4585                      [$self->{head_element}, $el_category->{head}];    
4586                    ## Reprocess in the "after head" insertion mode...
4587                  } elsif ($self->{insertion_mode} == IN_HEAD_IM) {
4588                    !!!cp ('t143.2');
4589                    ## As if </head>
4590                    pop @{$self->{open_elements}};
4591                    $self->{insertion_mode} = AFTER_HEAD_IM;
4592      
4593                    ## Reprocess in the "after head" insertion mode...
4594                  } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
4595                    !!!cp ('t143.3');
4596                    ## ISSUE: Two parse errors for <head><noscript></br>
4597                    !!!parse-error (type => 'unmatched end tag:br', token => $token);
4598                    ## As if </noscript>
4599                    pop @{$self->{open_elements}};
4600                  $self->{insertion_mode} = IN_HEAD_IM;                  $self->{insertion_mode} = IN_HEAD_IM;
4601    
4602                  ## Reprocess in the "in head" insertion mode...                  ## Reprocess in the "in head" insertion mode...
4603                } else {                  ## As if </head>
4604                  !!!cp ('t143');                  pop @{$self->{open_elements}};
4605                }                  $self->{insertion_mode} = AFTER_HEAD_IM;
4606    
4607                #                  ## Reprocess in the "after head" insertion mode...
4608              } else {                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
4609                if ($self->{insertion_mode} == AFTER_HEAD_IM) {                  !!!cp ('t143.4');
                 !!!cp ('t144');  
4610                  #                  #
4611                } else {                } else {
4612                  !!!cp ('t145');                  die "$0: $self->{insertion_mode}: Unknown insertion mode";
                 !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);  
                 ## Ignore the token  
                 !!!next-token;  
                 next B;  
4613                }                }
4614    
4615                  ## ISSUE: does not agree with IE7 - it doesn't ignore </br>.
4616                  !!!parse-error (type => 'unmatched end tag:br', token => $token);
4617                  ## Ignore the token
4618                  !!!next-token;
4619                  next B;
4620                } else {
4621                  !!!cp ('t145');
4622                  !!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token);
4623                  ## Ignore the token
4624                  !!!next-token;
4625                  next B;
4626              }              }
4627    
4628              if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {              if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
# Line 5792  sub _tree_construction_main ($) { Line 5874  sub _tree_construction_main ($) {
5874            !!!nack ('t277.1');            !!!nack ('t277.1');
5875            !!!next-token;            !!!next-token;
5876            next B;            next B;
5877          } elsif ($token->{tag_name} eq 'select' or          } elsif ({
5878                   $token->{tag_name} eq 'input' or                     select => 1, input => 1, textarea => 1,
5879                     }->{$token->{tag_name}} or
5880                   ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and                   ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and
5881                    {                    {
5882                     caption => 1, table => 1,                     caption => 1, table => 1,
# Line 6278  sub _tree_construction_main ($) { Line 6361  sub _tree_construction_main ($) {
6361                                           ->{has_reference});                                           ->{has_reference});
6362            } elsif ($token->{attributes}->{content}) {            } elsif ($token->{attributes}->{content}) {
6363              if ($token->{attributes}->{content}->{value}              if ($token->{attributes}->{content}->{value}
6364                  =~ /\A[^;]*;[\x09-\x0D\x20]*[Cc][Hh][Aa][Rr][Ss][Ee][Tt]                  =~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt]
6365                      [\x09-\x0D\x20]*=                      [\x09-\x0D\x20]*=
6366                      [\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'|                      [\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'|
6367                      ([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) {                      ([^"'\x09-\x0D\x20][^\x09-\x0D\x20\x3B]*))/x) {
6368                !!!cp ('t336');                !!!cp ('t336');
6369                ## NOTE: Whether the encoding is supported or not is handled                ## NOTE: Whether the encoding is supported or not is handled
6370                ## in the {change_encoding} callback.                ## in the {change_encoding} callback.

Legend:
Removed from v.1.138  
changed lines
  Added in v.1.146

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24