/[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.218 by wakaba, Sat Jul 25 03:38:42 2009 UTC revision 1.230 by wakaba, Sat Sep 5 13:42:53 2009 UTC
# Line 911  sub _tree_construction_initial ($) { Line 911  sub _tree_construction_initial ($) {
911    
912    INITIAL: {    INITIAL: {
913      if ($token->{type} == DOCTYPE_TOKEN) {      if ($token->{type} == DOCTYPE_TOKEN) {
914        ## NOTE: Conformance checkers MAY, instead of reporting "not HTML5"        ## NOTE: Conformance checkers MAY, instead of reporting "not
915        ## error, switch to a conformance checking mode for another        ## HTML5" error, switch to a conformance checking mode for
916        ## language.        ## another language.  (We don't support such mode switchings; it
917          ## is nonsense to do anything different from what browsers do.)
918        my $doctype_name = $token->{name};        my $doctype_name = $token->{name};
919        $doctype_name = '' unless defined $doctype_name;        $doctype_name = '' unless defined $doctype_name;
920        $doctype_name =~ tr/a-z/A-Z/; # ASCII case-insensitive        my $doctype = $self->{document}->create_document_type_definition
921        if (not defined $token->{name} or # <!DOCTYPE>            ($doctype_name);
922            defined $token->{sysid}) {  
923          $doctype_name =~ tr/A-Z/a-z/; # ASCII case-insensitive
924          if ($doctype_name ne 'html') {
925          !!!cp ('t1');          !!!cp ('t1');
926          !!!parse-error (type => 'not HTML5', token => $token);          !!!parse-error (type => 'not HTML5', token => $token);
927        } elsif ($doctype_name ne 'HTML') {        } elsif (defined $token->{pubid}) {
928          !!!cp ('t2');          !!!cp ('t2');
929            ## XXX Obsolete permitted DOCTYPEs
930          !!!parse-error (type => 'not HTML5', token => $token);          !!!parse-error (type => 'not HTML5', token => $token);
931        } elsif (defined $token->{pubid}) {        } elsif (defined $token->{sysid}) {
932          if ($token->{pubid} eq 'XSLT-compat') {          if ($token->{sysid} eq 'about:legacy-compat') {
933            !!!cp ('t1.2');            !!!cp ('t1.2'); ## <!DOCTYPE HTML SYSTEM "about:legacy-compat">
934            !!!parse-error (type => 'XSLT-compat', token => $token,            !!!parse-error (type => 'XSLT-compat', token => $token,
935                            level => $self->{level}->{should});                            level => $self->{level}->{should});
936          } else {          } else {
937            !!!parse-error (type => 'not HTML5', token => $token);            !!!parse-error (type => 'not HTML5', token => $token);
938          }          }
939        } else {        } else { ## <!DOCTYPE HTML>
940          !!!cp ('t3');          !!!cp ('t3');
941          #          #
942        }        }
943                
       my $doctype = $self->{document}->create_document_type_definition  
         ($token->{name}); ## ISSUE: If name is missing (e.g. <!DOCTYPE>)?  
944        ## NOTE: Default value for both |public_id| and |system_id| attributes        ## NOTE: Default value for both |public_id| and |system_id| attributes
945        ## are empty strings, so that we don't set any value in missing cases.        ## are empty strings, so that we don't set any value in missing cases.
946        $doctype->public_id ($token->{pubid}) if defined $token->{pubid};        $doctype->public_id ($token->{pubid}) if defined $token->{pubid};
947        $doctype->system_id ($token->{sysid}) if defined $token->{sysid};        $doctype->system_id ($token->{sysid}) if defined $token->{sysid};
948    
949        ## NOTE: Other DocumentType attributes are null or empty lists.        ## NOTE: Other DocumentType attributes are null or empty lists.
950        ## In Firefox3, |internalSubset| attribute is set to the empty        ## In Firefox3, |internalSubset| attribute is set to the empty
951        ## string, while |null| is an allowed value for the attribute        ## string, while |null| is an allowed value for the attribute
952        ## according to DOM3 Core.        ## according to DOM3 Core.
953        $self->{document}->append_child ($doctype);        $self->{document}->append_child ($doctype);
954                
955        if ($token->{quirks} or $doctype_name ne 'HTML') {        if ($token->{quirks} or $doctype_name ne 'html') {
956          !!!cp ('t4');          !!!cp ('t4');
957          $self->{document}->manakai_compat_mode ('quirks');          $self->{document}->manakai_compat_mode ('quirks');
958        } elsif (defined $token->{pubid}) {        } elsif (defined $token->{pubid}) {
# Line 1419  sub _tree_construction_main ($) { Line 1422  sub _tree_construction_main ($) {
1422      ## Step 3      ## Step 3
1423      ## TODO: Mark as "already executed", if ...      ## TODO: Mark as "already executed", if ...
1424    
1425      ## Step 4      ## Step 4 (HTML5 revision 2702)
1426      $insert->($script_el);      $insert->($script_el);
   
     ## ISSUE: $script_el is not put into the stack  
1427      push @{$self->{open_elements}}, [$script_el, $el_category->{script}];      push @{$self->{open_elements}}, [$script_el, $el_category->{script}];
1428    
1429      ## Step 5      ## Step 5
# Line 1437  sub _tree_construction_main ($) { Line 1438  sub _tree_construction_main ($) {
1438    }; # $script_start_tag    }; # $script_start_tag
1439    
1440    ## NOTE: $open_tables->[-1]->[0] is the "current table" element node.    ## NOTE: $open_tables->[-1]->[0] is the "current table" element node.
1441    ## NOTE: $open_tables->[-1]->[1] is the "tainted" flag.    ## NOTE: $open_tables->[-1]->[1] is the "tainted" flag (OBSOLETE; unused).
1442    ## NOTE: $open_tables->[-1]->[2] is set false when non-Text node inserted.    ## NOTE: $open_tables->[-1]->[2] is set false when non-Text node inserted.
1443    my $open_tables = [[$self->{open_elements}->[0]->[0]]];    my $open_tables = [[$self->{open_elements}->[0]->[0]]];
1444    
# Line 1733  sub _tree_construction_main ($) { Line 1734  sub _tree_construction_main ($) {
1734    ## document.write ("b")</script>|    ## document.write ("b")</script>|
1735    
1736    B: while (1) {    B: while (1) {
1737    
1738        ## The "in table text" insertion mode.
1739        if ($self->{insertion_mode} & TABLE_IMS and
1740            not $self->{insertion_mode} & IN_FOREIGN_CONTENT_IM and
1741            not $self->{insertion_mode} & IN_CDATA_RCDATA_IM) {
1742          C: {
1743            my $s;
1744            if ($token->{type} == CHARACTER_TOKEN) {
1745              !!!cp ('t194');
1746              $self->{pending_chars} ||= [];
1747              push @{$self->{pending_chars}}, $token;
1748              !!!next-token;
1749              next B;
1750            } else {
1751              if ($self->{pending_chars}) {
1752                $s = join '', map { $_->{data} } @{$self->{pending_chars}};
1753                delete $self->{pending_chars};
1754                if ($s =~ /[^\x09\x0A\x0C\x0D\x20]/) {
1755                  !!!cp ('t195');
1756                  #
1757                } else {
1758                  !!!cp ('t195.1');
1759                  #$self->{open_elements}->[-1]->[0]->manakai_append_text ($s);
1760                  $self->{open_elements}->[-1]->[0]->append_child
1761                      ($self->{document}->create_text_node ($s));
1762                  last C;
1763                }
1764              } else {
1765                !!!cp ('t195.2');
1766                last C;
1767              }
1768            }
1769    
1770            ## Foster parenting
1771            !!!parse-error (type => 'in table:#text', token => $token);
1772    
1773            ## NOTE: As if in body, but insert into the foster parent element.
1774            $reconstruct_active_formatting_elements->($insert_to_foster);
1775                
1776            if ($self->{open_elements}->[-1]->[1] & TABLE_ROWS_EL) {
1777              # MUST
1778              my $foster_parent_element;
1779              my $next_sibling;
1780              #my $prev_sibling;
1781              OE: for (reverse 0..$#{$self->{open_elements}}) {
1782                if ($self->{open_elements}->[$_]->[1] == TABLE_EL) {
1783                  my $parent = $self->{open_elements}->[$_]->[0]->parent_node;
1784                  if (defined $parent and $parent->node_type == 1) {
1785                    $foster_parent_element = $parent;
1786                    !!!cp ('t196');
1787                    $next_sibling = $self->{open_elements}->[$_]->[0];
1788              #      $prev_sibling = $next_sibling->previous_sibling;
1789                    #
1790                  } else {
1791                    !!!cp ('t197');
1792                    $foster_parent_element = $self->{open_elements}->[$_ - 1]->[0];
1793              #      $prev_sibling = $foster_parent_element->last_child;
1794                    #
1795                  }
1796                  last OE;
1797                }
1798              } # OE
1799              $foster_parent_element = $self->{open_elements}->[0]->[0] #and
1800              #$prev_sibling = $foster_parent_element->last_child
1801                  unless defined $foster_parent_element;
1802              #undef $prev_sibling unless $open_tables->[-1]->[2]; # ~node inserted
1803              #if (defined $prev_sibling and
1804              #    $prev_sibling->node_type == 3) {
1805              #  !!! cp ('t198');
1806              #  $prev_sibling->manakai_append_text ($s);
1807              #} else {
1808                !!!cp ('t199');
1809                $foster_parent_element->insert_before
1810                    ($self->{document}->create_text_node ($s), $next_sibling);
1811              #}
1812              $open_tables->[-1]->[1] = 1; # tainted
1813              $open_tables->[-1]->[2] = 1; # ~node inserted
1814            } else {
1815              ## NOTE: Fragment case or in a foster parent'ed element
1816              ## (e.g. |<table><span>a|).  In fragment case, whether the
1817              ## character is appended to existing node or a new node is
1818              ## created is irrelevant, since the foster parent'ed nodes
1819              ## are discarded and fragment parsing does not invoke any
1820              ## script.
1821              !!!cp ('t200');
1822              $self->{open_elements}->[-1]->[0]->manakai_append_text ($s);
1823            }
1824          } # C
1825        } # TABLE_IMS
1826    
1827      if ($token->{type} == DOCTYPE_TOKEN) {      if ($token->{type} == DOCTYPE_TOKEN) {
1828        !!!cp ('t73');        !!!cp ('t73');
1829        !!!parse-error (type => 'in html:#DOCTYPE', token => $token);        !!!parse-error (type => 'in html:#DOCTYPE', token => $token);
# Line 1874  sub _tree_construction_main ($) { Line 1965  sub _tree_construction_main ($) {
1965          } elsif ({          } elsif ({
1966                    b => 1, big => 1, blockquote => 1, body => 1, br => 1,                    b => 1, big => 1, blockquote => 1, body => 1, br => 1,
1967                    center => 1, code => 1, dd => 1, div => 1, dl => 1, dt => 1,                    center => 1, code => 1, dd => 1, div => 1, dl => 1, dt => 1,
1968                    em => 1, embed => 1, font => 1, h1 => 1, h2 => 1, h3 => 1,                    em => 1, embed => 1, h1 => 1, h2 => 1, h3 => 1,
1969                    h4 => 1, h5 => 1, h6 => 1, head => 1, hr => 1, i => 1,                    h4 => 1, h5 => 1, h6 => 1, head => 1, hr => 1, i => 1,
1970                    img => 1, li => 1, listing => 1, menu => 1, meta => 1,                    img => 1, li => 1, listing => 1, menu => 1, meta => 1,
1971                    nobr => 1, ol => 1, p => 1, pre => 1, ruby => 1, s => 1,                    nobr => 1, ol => 1, p => 1, pre => 1, ruby => 1, s => 1,
1972                    small => 1, span => 1, strong => 1, strike => 1, sub => 1,                    small => 1, span => 1, strong => 1, strike => 1, sub => 1,
1973                    sup => 1, table => 1, tt => 1, u => 1, ul => 1, var => 1,                    sup => 1, table => 1, tt => 1, u => 1, ul => 1, var => 1,
1974                   }->{$token->{tag_name}}) {                   }->{$token->{tag_name}} or
1975                     ($token->{tag_name} eq 'font' and
1976                      ($token->{attributes}->{color} or
1977                       $token->{attributes}->{face} or
1978                       $token->{attributes}->{size}))) {
1979            !!!cp ('t87.2');            !!!cp ('t87.2');
1980            !!!parse-error (type => 'not closed',            !!!parse-error (type => 'not closed',
1981                            text => $self->{open_elements}->[-1]->[0]                            text => $self->{open_elements}->[-1]->[0]
# Line 1956  sub _tree_construction_main ($) { Line 2051  sub _tree_construction_main ($) {
2051          }          }
2052        } elsif ($token->{type} == END_TAG_TOKEN) {        } elsif ($token->{type} == END_TAG_TOKEN) {
2053          ## NOTE: "using the rules for secondary insertion mode" then "continue"          ## NOTE: "using the rules for secondary insertion mode" then "continue"
2054          !!!cp ('t87.5');          if ($token->{tag_name} eq 'script') {
2055          #            !!!cp ('t87.41');
2056              #
2057              ## XXXscript: Execute script here.
2058            } else {
2059              !!!cp ('t87.5');
2060              #
2061            }
2062        } elsif ($token->{type} == END_OF_FILE_TOKEN) {        } elsif ($token->{type} == END_OF_FILE_TOKEN) {
2063          !!!cp ('t87.6');          !!!cp ('t87.6');
2064          !!!parse-error (type => 'not closed',          !!!parse-error (type => 'not closed',
# Line 2257  sub _tree_construction_main ($) { Line 2358  sub _tree_construction_main ($) {
2358    
2359            ## NOTE: There is a "as if in head" code clone.            ## NOTE: There is a "as if in head" code clone.
2360            $parse_rcdata->(RCDATA_CONTENT_MODEL);            $parse_rcdata->(RCDATA_CONTENT_MODEL);
2361            ## ISSUE: A spec bug [Bug 6038]  
2362              ## NOTE: At this point the stack of open elements contain
2363              ## the |head| element (index == -2) and the |script| element
2364              ## (index == -1).  In the "after head" insertion mode the
2365              ## |head| element is inserted only for the purpose of
2366              ## providing the context for the |script| element, and
2367              ## therefore we can now and have to remove the element from
2368              ## the stack.
2369            splice @{$self->{open_elements}}, -2, 1, () # <head>            splice @{$self->{open_elements}}, -2, 1, () # <head>
2370                if ($self->{insertion_mode} & IM_MASK) == AFTER_HEAD_IM;                if ($self->{insertion_mode} & IM_MASK) == AFTER_HEAD_IM;
2371            next B;            next B;
# Line 2492  sub _tree_construction_main ($) { Line 2600  sub _tree_construction_main ($) {
2600                ## Ignore the token                ## Ignore the token
2601                !!!next-token;                !!!next-token;
2602                next B;                next B;
2603              } elsif ($token->{tag_name} eq 'br') {          } elsif ($token->{tag_name} eq 'br') {
2604                if ($self->{insertion_mode} == BEFORE_HEAD_IM) {            if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
2605                  !!!cp ('t142.2');              !!!cp ('t142.2');
2606                  ## (before head) as if <head>, (in head) as if </head>              ## (before head) as if <head>, (in head) as if </head>
2607                  !!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token);              !!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token);
2608                  $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});              $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
2609                  $self->{insertion_mode} = AFTER_HEAD_IM;              $self->{insertion_mode} = AFTER_HEAD_IM;
2610        
2611                  ## Reprocess in the "after head" insertion mode...              ## Reprocess in the "after head" insertion mode...
2612                } elsif ($self->{insertion_mode} == IN_HEAD_IM) {            } elsif ($self->{insertion_mode} == IN_HEAD_IM) {
2613                  !!!cp ('t143.2');              !!!cp ('t143.2');
2614                  ## As if </head>              ## As if </head>
2615                  pop @{$self->{open_elements}};              pop @{$self->{open_elements}};
2616                  $self->{insertion_mode} = AFTER_HEAD_IM;              $self->{insertion_mode} = AFTER_HEAD_IM;
2617        
2618                  ## Reprocess in the "after head" insertion mode...              ## Reprocess in the "after head" insertion mode...
2619                } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {            } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
2620                  !!!cp ('t143.3');              !!!cp ('t143.3');
2621                  ## NOTE: Two parse errors for <head><noscript></br>              ## NOTE: Two parse errors for <head><noscript></br>
2622                  !!!parse-error (type => 'unmatched end tag',              !!!parse-error (type => 'unmatched end tag',
2623                                  text => 'br', token => $token);                              text => 'br', token => $token);
2624                  ## As if </noscript>              ## As if </noscript>
2625                  pop @{$self->{open_elements}};              pop @{$self->{open_elements}};
2626                  $self->{insertion_mode} = IN_HEAD_IM;              $self->{insertion_mode} = IN_HEAD_IM;
2627    
2628                  ## Reprocess in the "in head" insertion mode...              ## Reprocess in the "in head" insertion mode...
2629                  ## As if </head>              ## As if </head>
2630                  pop @{$self->{open_elements}};              pop @{$self->{open_elements}};
2631                  $self->{insertion_mode} = AFTER_HEAD_IM;              $self->{insertion_mode} = AFTER_HEAD_IM;
2632    
2633                  ## Reprocess in the "after head" insertion mode...              ## Reprocess in the "after head" insertion mode...
2634                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {            } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
2635                  !!!cp ('t143.4');              !!!cp ('t143.4');
2636                  #              #
2637                } else {            } else {
2638                  die "$0: $self->{insertion_mode}: Unknown insertion mode";              die "$0: $self->{insertion_mode}: Unknown insertion mode";
2639                }            }
2640    
2641                ## ISSUE: does not agree with IE7 - it doesn't ignore </br>.            #
2642                !!!parse-error (type => 'unmatched end tag',          } else { ## Other end tags
                               text => 'br', token => $token);  
               ## Ignore the token  
               !!!next-token;  
               next B;  
             } else {  
2643                !!!cp ('t145');                !!!cp ('t145');
2644                !!!parse-error (type => 'unmatched end tag',                !!!parse-error (type => 'unmatched end tag',
2645                                text => $token->{tag_name}, token => $token);                                text => $token->{tag_name}, token => $token);
# Line 2580  sub _tree_construction_main ($) { Line 2683  sub _tree_construction_main ($) {
2683              !!!insert-element ('body',, $token);              !!!insert-element ('body',, $token);
2684              $self->{insertion_mode} = IN_BODY_IM;              $self->{insertion_mode} = IN_BODY_IM;
2685              ## reprocess              ## reprocess
2686              next B;          next B;
2687        } elsif ($token->{type} == END_OF_FILE_TOKEN) {        } elsif ($token->{type} == END_OF_FILE_TOKEN) {
2688          if ($self->{insertion_mode} == BEFORE_HEAD_IM) {          if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
2689            !!!cp ('t149.1');            !!!cp ('t149.1');
# Line 3008  sub _tree_construction_main ($) { Line 3111  sub _tree_construction_main ($) {
3111        $insert = $insert_to_current;        $insert = $insert_to_current;
3112        #        #
3113      } elsif ($self->{insertion_mode} & TABLE_IMS) {      } elsif ($self->{insertion_mode} & TABLE_IMS) {
3114        if ($token->{type} == CHARACTER_TOKEN) {        if ($token->{type} == START_TAG_TOKEN) {
         if (not $open_tables->[-1]->[1] and # tainted  
             $token->{data} =~ s/^([\x09\x0A\x0C\x20]+)//) {  
           $self->{open_elements}->[-1]->[0]->manakai_append_text ($1);  
                 
           unless (length $token->{data}) {  
             !!!cp ('t194');  
             !!!next-token;  
             next B;  
           } else {  
             !!!cp ('t195');  
           }  
         }  
   
         !!!parse-error (type => 'in table:#text', token => $token);  
   
         ## NOTE: As if in body, but insert into the foster parent element.  
         $reconstruct_active_formatting_elements->($insert_to_foster);  
               
         if ($self->{open_elements}->[-1]->[1] & TABLE_ROWS_EL) {  
           # MUST  
           my $foster_parent_element;  
           my $next_sibling;  
           my $prev_sibling;  
           OE: for (reverse 0..$#{$self->{open_elements}}) {  
             if ($self->{open_elements}->[$_]->[1] == TABLE_EL) {  
               my $parent = $self->{open_elements}->[$_]->[0]->parent_node;  
               if (defined $parent and $parent->node_type == 1) {  
                 $foster_parent_element = $parent;  
                 !!!cp ('t196');  
                 $next_sibling = $self->{open_elements}->[$_]->[0];  
                 $prev_sibling = $next_sibling->previous_sibling;  
                 #  
               } else {  
                 !!!cp ('t197');  
                 $foster_parent_element = $self->{open_elements}->[$_ - 1]->[0];  
                 $prev_sibling = $foster_parent_element->last_child;  
                 #  
               }  
               last OE;  
             }  
           } # OE  
           $foster_parent_element = $self->{open_elements}->[0]->[0] and  
           $prev_sibling = $foster_parent_element->last_child  
               unless defined $foster_parent_element;  
           undef $prev_sibling unless $open_tables->[-1]->[2]; # ~node inserted  
           if (defined $prev_sibling and  
               $prev_sibling->node_type == 3) {  
             !!!cp ('t198');  
             $prev_sibling->manakai_append_text ($token->{data});  
           } else {  
             !!!cp ('t199');  
             $foster_parent_element->insert_before  
                 ($self->{document}->create_text_node ($token->{data}),  
                  $next_sibling);  
           }  
           $open_tables->[-1]->[1] = 1; # tainted  
           $open_tables->[-1]->[2] = 1; # ~node inserted  
         } else {  
           ## NOTE: Fragment case or in a foster parent'ed element  
           ## (e.g. |<table><span>a|).  In fragment case, whether the  
           ## character is appended to existing node or a new node is  
           ## created is irrelevant, since the foster parent'ed nodes  
           ## are discarded and fragment parsing does not invoke any  
           ## script.  
           !!!cp ('t200');  
           $self->{open_elements}->[-1]->[0]->manakai_append_text  
               ($token->{data});  
         }  
               
         !!!next-token;  
         next B;  
       } elsif ($token->{type} == START_TAG_TOKEN) {  
3115          if ({          if ({
3116               tr => (($self->{insertion_mode} & IM_MASK) != IN_ROW_IM),               tr => (($self->{insertion_mode} & IM_MASK) != IN_ROW_IM),
3117               th => 1, td => 1,               th => 1, td => 1,
# Line 3846  sub _tree_construction_main ($) { Line 3877  sub _tree_construction_main ($) {
3877                     tbody => 1, tfoot => 1, thead => 1,                     tbody => 1, tfoot => 1, thead => 1,
3878                     tr => 1, td => 1, th => 1,                     tr => 1, td => 1, th => 1,
3879                    }->{$token->{tag_name}})) {                    }->{$token->{tag_name}})) {
3880            ## TODO: The type below is not good - <select> is replaced by </select>  
3881            !!!parse-error (type => 'not closed', text => 'select',            ## 1. Parse error.
3882                            token => $token);            if ($token->{tag_name} eq 'select') {
3883            ## NOTE: As if the token were </select> (<select> case) or                !!!parse-error (type => 'select in select', ## XXX: documentation
3884            ## as if there were </select> (otherwise).                                token => $token);
3885            ## have an element in table scope            } else {
3886                !!!parse-error (type => 'not closed', text => 'select',
3887                                token => $token);
3888              }
3889    
3890              ## 2./<select>-1. Unless "have an element in table scope" (select):
3891            my $i;            my $i;
3892            INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {            INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
3893              my $node = $self->{open_elements}->[$_];              my $node = $self->{open_elements}->[$_];
# Line 3866  sub _tree_construction_main ($) { Line 3902  sub _tree_construction_main ($) {
3902            } # INSCOPE            } # INSCOPE
3903            unless (defined $i) {            unless (defined $i) {
3904              !!!cp ('t280');              !!!cp ('t280');
3905              !!!parse-error (type => 'unmatched end tag',              if ($token->{tag_name} eq 'select') {
3906                              text => 'select', token => $token);                ## NOTE: This error would be raised when
3907              ## Ignore the token                ## |select.innerHTML = '<select>'| is executed; in this
3908                  ## case two errors, "select in select" and "unmatched
3909                  ## end tags" are reported to the user, the latter might
3910                  ## be confusing but this is what the spec requires.
3911                  !!!parse-error (type => 'unmatched end tag',
3912                                  text => 'select',
3913                                  token => $token);
3914                }
3915                ## Ignore the token.
3916              !!!nack ('t280.1');              !!!nack ('t280.1');
3917              !!!next-token;              !!!next-token;
3918              next B;              next B;
3919            }            }
3920    
3921              ## 3. Otherwise, as if there were <select>:
3922                                
3923            !!!cp ('t281');            !!!cp ('t281');
3924            splice @{$self->{open_elements}}, $i;            splice @{$self->{open_elements}}, $i;
# Line 3889  sub _tree_construction_main ($) { Line 3935  sub _tree_construction_main ($) {
3935              ## Reprocess the token.              ## Reprocess the token.
3936              next B;              next B;
3937            }            }
3938            } elsif ($token->{tag_name} eq 'script') {
3939              !!!cp ('t281.3');
3940              ## NOTE: This is an "as if in head" code clone
3941              $script_start_tag->();
3942              next B;
3943          } else {          } else {
3944            !!!cp ('t282');            !!!cp ('t282');
3945            !!!parse-error (type => 'in select',            !!!parse-error (type => 'in select',
# Line 4408  sub _tree_construction_main ($) { Line 4459  sub _tree_construction_main ($) {
4459                  table => 1,                  table => 1,
4460                  hr => 1,                  hr => 1,
4461                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
4462    
4463            ## 1. When there is an opening |form| element:
4464          if ($token->{tag_name} eq 'form' and defined $self->{form_element}) {          if ($token->{tag_name} eq 'form' and defined $self->{form_element}) {
4465            !!!cp ('t350');            !!!cp ('t350');
4466            !!!parse-error (type => 'in form:form', token => $token);            !!!parse-error (type => 'in form:form', token => $token);
# Line 4417  sub _tree_construction_main ($) { Line 4470  sub _tree_construction_main ($) {
4470            next B;            next B;
4471          }          }
4472    
4473            ## 2. Close the |p| element, if any.
4474          if ($token->{tag_name} ne 'table' or # The Hixie Quirk          if ($token->{tag_name} ne 'table' or # The Hixie Quirk
4475              $self->{document}->manakai_compat_mode ne 'quirks') {              $self->{document}->manakai_compat_mode ne 'quirks') {
4476            ## has a p element in scope            ## has a p element in scope
# Line 4433  sub _tree_construction_main ($) { Line 4487  sub _tree_construction_main ($) {
4487              }              }
4488            } # INSCOPE            } # INSCOPE
4489          }          }
4490              
4491            ## 3. Close the opening <hn> element, if any.
4492            if ({h1 => 1, h2 => 1, h3 => 1,
4493                 h4 => 1, h5 => 1, h6 => 1}->{$token->{tag_name}}) {
4494              if ($self->{open_elements}->[-1]->[1] == HEADING_EL) {
4495                !!!parse-error (type => 'not closed',
4496                                text => $self->{open_elements}->[-1]->[0]->manakai_local_name,
4497                                token => $token);
4498                pop @{$self->{open_elements}};
4499              }
4500            }
4501    
4502            ## 4. Insertion.
4503          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
4504          if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') {          if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') {
4505            !!!nack ('t346.1');            !!!nack ('t346.1');
# Line 4477  sub _tree_construction_main ($) { Line 4543  sub _tree_construction_main ($) {
4543        } elsif ($token->{tag_name} eq 'li') {        } elsif ($token->{tag_name} eq 'li') {
4544          ## NOTE: As normal, but imply </li> when there's another <li> ...          ## NOTE: As normal, but imply </li> when there's another <li> ...
4545    
4546          ## NOTE: Special, Scope (<li><foo><li> == <li><foo><li/></foo></li>)          ## NOTE: Special, Scope (<li><foo><li> == <li><foo><li/></foo></li>)::
4547            ## Interpreted as <li><foo/></li><li/> (non-conforming)            ## Interpreted as <li><foo/></li><li/> (non-conforming):
4548            ## blockquote (O9.27), center (O), dd (Fx3, O, S3.1.2, IE7),            ## blockquote (O9.27), center (O), dd (Fx3, O, S3.1.2, IE7),
4549            ## dt (Fx, O, S, IE), dl (O), fieldset (O, S, IE), form (Fx, O, S),            ## dt (Fx, O, S, IE), dl (O), fieldset (O, S, IE), form (Fx, O, S),
4550            ## hn (O), pre (O), applet (O, S), button (O, S), marquee (Fx, O, S),            ## hn (O), pre (O), applet (O, S), button (O, S), marquee (Fx, O, S),
4551            ## object (Fx)            ## object (Fx)
4552            ## Generate non-tree (non-conforming)            ## Generate non-tree (non-conforming):
4553            ## basefont (IE7 (where basefont is non-void)), center (IE),            ## basefont (IE7 (where basefont is non-void)), center (IE),
4554            ## form (IE), hn (IE)            ## form (IE), hn (IE)
4555          ## address, div, p (<li><foo><li> == <li><foo/></li><li/>)          ## address, div, p (<li><foo><li> == <li><foo/></li><li/>)::
4556            ## Interpreted as <li><foo><li/></foo></li> (non-conforming)            ## Interpreted as <li><foo><li/></foo></li> (non-conforming):
4557            ## div (Fx, S)            ## div (Fx, S)
4558    
4559          my $non_optional;          my $non_optional;
# Line 4834  sub _tree_construction_main ($) { Line 4900  sub _tree_construction_main ($) {
4900            next B;            next B;
4901          }          }
4902        } elsif ($token->{tag_name} eq 'textarea') {        } elsif ($token->{tag_name} eq 'textarea') {
4903          ## Step 1          ## 1. Insert
4904          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
4905                    
4906          ## Step 2          ## Step 2 # XXX
4907          ## TODO: $self->{form_element} if defined          ## TODO: $self->{form_element} if defined
4908    
4909          ## Step 3          ## 2. Drop U+000A LINE FEED
4910          $self->{ignore_newline} = 1;          $self->{ignore_newline} = 1;
4911    
4912          ## Step 4          ## 3. RCDATA
         ## ISSUE: This step is wrong. (r2302 enbugged)  
   
         ## Step 5  
4913          $self->{content_model} = RCDATA_CONTENT_MODEL;          $self->{content_model} = RCDATA_CONTENT_MODEL;
4914          delete $self->{escape}; # MUST          delete $self->{escape}; # MUST
4915    
4916          ## Step 6-7          ## 4., 6. Insertion mode
4917          $self->{insertion_mode} |= IN_CDATA_RCDATA_IM;          $self->{insertion_mode} |= IN_CDATA_RCDATA_IM;
4918    
4919            ## XXX: 5. frameset-ok flag
4920    
4921          !!!nack ('t392.1');          !!!nack ('t392.1');
4922          !!!next-token;          !!!next-token;
4923          next B;          next B;
# Line 5024  sub _tree_construction_main ($) { Line 5089  sub _tree_construction_main ($) {
5089        }        }
5090      } elsif ($token->{type} == END_TAG_TOKEN) {      } elsif ($token->{type} == END_TAG_TOKEN) {
5091        if ($token->{tag_name} eq 'body') {        if ($token->{tag_name} eq 'body') {
5092          ## has a |body| element in scope  
5093            ## 1. If not "have an element in scope":
5094            ## "has a |body| element in scope"
5095          my $i;          my $i;
5096          INSCOPE: {          INSCOPE: {
5097            for (reverse @{$self->{open_elements}}) {            for (reverse @{$self->{open_elements}}) {
# Line 5047  sub _tree_construction_main ($) { Line 5114  sub _tree_construction_main ($) {
5114            next B;            next B;
5115          } # INSCOPE          } # INSCOPE
5116    
5117            ## 2. If unclosed elements:
5118          for (@{$self->{open_elements}}) {          for (@{$self->{open_elements}}) {
5119            unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL) {            unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL ||
5120                      $_->[1] == OPTGROUP_EL ||
5121                      $_->[1] == OPTION_EL ||
5122                      $_->[1] == RUBY_COMPONENT_EL) {
5123              !!!cp ('t403');              !!!cp ('t403');
5124              !!!parse-error (type => 'not closed',              !!!parse-error (type => 'not closed',
5125                              text => $_->[0]->manakai_local_name,                              text => $_->[0]->manakai_local_name,
# Line 5059  sub _tree_construction_main ($) { Line 5130  sub _tree_construction_main ($) {
5130            }            }
5131          }          }
5132    
5133            ## 3. Switch the insertion mode.
5134          $self->{insertion_mode} = AFTER_BODY_IM;          $self->{insertion_mode} = AFTER_BODY_IM;
5135          !!!next-token;          !!!next-token;
5136          next B;          next B;

Legend:
Removed from v.1.218  
changed lines
  Added in v.1.230

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24