/[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.194 by wakaba, Sat Oct 4 05:53:45 2008 UTC revision 1.197 by wakaba, Sat Oct 4 08:29:19 2008 UTC
# Line 6911  sub _tree_construction_main ($) { Line 6911  sub _tree_construction_main ($) {
6911          !!!next-token;          !!!next-token;
6912          next B;          next B;
6913        } elsif ({        } elsif ({
6914                  address => 1, blockquote => 1, center => 1, dir => 1,                  ## NOTE: Start tags for non-phrasing flow content elements
6915                  div => 1, dl => 1, fieldset => 1,  
6916                  h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,                  ## NOTE: The normal one
6917                  menu => 1, ol => 1, p => 1, ul => 1,                  address => 1, article => 1, aside => 1, blockquote => 1,
6918                    center => 1, datagrid => 1, details => 1, dialog => 1,
6919                    dir => 1, div => 1, dl => 1, fieldset => 1, figure => 1,
6920                    footer => 1, h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1,
6921                    h6 => 1, header => 1, menu => 1, nav => 1, ol => 1, p => 1,
6922                    section => 1, ul => 1,
6923                    ## NOTE: As normal, but drops leading newline
6924                  pre => 1, listing => 1,                  pre => 1, listing => 1,
6925                    ## NOTE: As normal, but interacts with the form element pointer
6926                  form => 1,                  form => 1,
6927                    
6928                  table => 1,                  table => 1,
6929                  hr => 1,                  hr => 1,
6930                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
# Line 6983  sub _tree_construction_main ($) { Line 6991  sub _tree_construction_main ($) {
6991            !!!next-token;            !!!next-token;
6992          }          }
6993          next B;          next B;
6994        } elsif ({li => 1, dt => 1, dd => 1}->{$token->{tag_name}}) {        } elsif ($token->{tag_name} eq 'li') {
6995          ## has a p element in scope          ## NOTE: As normal, but imply </li> when there's another <li> ...
         INSCOPE: for (reverse @{$self->{open_elements}}) {  
           if ($_->[1] & P_EL) {  
             !!!cp ('t353');  
             !!!back-token; # <x>  
             $token = {type => END_TAG_TOKEN, tag_name => 'p',  
                       line => $token->{line}, column => $token->{column}};  
             next B;  
           } elsif ($_->[1] & SCOPING_EL) {  
             !!!cp ('t354');  
             last INSCOPE;  
           }  
         } # INSCOPE  
6996    
6997          ## NOTE: Special, Scope (<li><foo><li> == <li><foo><li/></foo></li>)          ## NOTE: Special, Scope (<li><foo><li> == <li><foo><li/></foo></li>)
6998            ## Interpreted as <li><foo/></li><li/> (non-conforming)            ## Interpreted as <li><foo/></li><li/> (non-conforming)
# Line 7010  sub _tree_construction_main ($) { Line 7006  sub _tree_construction_main ($) {
7006          ## address, div, p (<li><foo><li> == <li><foo/></li><li/>)          ## address, div, p (<li><foo><li> == <li><foo/></li><li/>)
7007            ## Interpreted as <li><foo><li/></foo></li> (non-conforming)            ## Interpreted as <li><foo><li/></foo></li> (non-conforming)
7008            ## div (Fx, S)            ## div (Fx, S)
7009              
7010          ## Step 1          my $non_optional;
7011          my $i = -1;          my $i = -1;
7012          my $node = $self->{open_elements}->[$i];  
7013          my $li_or_dtdd = {li => {li => 1},          ## 1.
7014                            dt => {dt => 1, dd => 1},          for my $node (reverse @{$self->{open_elements}}) {
7015                            dd => {dt => 1, dd => 1}}->{$token->{tag_name}};            if ($node->[1] & LI_EL) {
7016          LI: {              ## 2. (a) As if </li>
7017            ## Step 2              {
7018            if ($li_or_dtdd->{$node->[0]->manakai_local_name}) {                ## If no </li> - not applied
7019              if ($i != -1) {                #
7020                !!!cp ('t355');  
7021                !!!parse-error (type => 'not closed',                ## Otherwise
7022                                text => $self->{open_elements}->[-1]->[0]  
7023                                    ->manakai_local_name,                ## 1. generate implied end tags, except for </li>
7024                                token => $token);                #
7025              } else {  
7026                !!!cp ('t356');                ## 2. If current node != "li", parse error
7027                  if ($non_optional) {
7028                    !!!parse-error (type => 'not closed',
7029                                    text => $non_optional->[0]->manakai_local_name,
7030                                    token => $token);
7031                    !!!cp ('t355');
7032                  } else {
7033                    !!!cp ('t356');
7034                  }
7035    
7036                  ## 3. Pop
7037                  splice @{$self->{open_elements}}, $i;
7038              }              }
7039              splice @{$self->{open_elements}}, $i;  
7040              last LI;              last; ## 2. (b) goto 5.
7041            } else {            } elsif (
7042                       ## NOTE: not "formatting" and not "phrasing"
7043                       ($node->[1] & SPECIAL_EL or
7044                        $node->[1] & SCOPING_EL) and
7045                       ## NOTE: "li", "dt", and "dd" are in |SPECIAL_EL|.
7046    
7047                       (not $node->[1] & ADDRESS_EL) &
7048                       (not $node->[1] & DIV_EL) &
7049                       (not $node->[1] & P_EL)) {
7050                ## 3.
7051              !!!cp ('t357');              !!!cp ('t357');
7052            }              last; ## goto 5.
7053                        } elsif ($node->[1] & END_TAG_OPTIONAL_EL) {
           ## Step 3  
           if (not ($node->[1] & FORMATTING_EL) and  
               #not $phrasing_category->{$node->[1]} and  
               ($node->[1] & SPECIAL_EL or  
                $node->[1] & SCOPING_EL) and  
               not ($node->[1] & ADDRESS_EL) and  
               not ($node->[1] & DIV_EL)) {  
7054              !!!cp ('t358');              !!!cp ('t358');
7055              last LI;              #
7056              } else {
7057                !!!cp ('t359');
7058                $non_optional ||= $node;
7059                #
7060            }            }
7061                        ## 4.
7062            !!!cp ('t359');            ## goto 2.
           ## Step 4  
7063            $i--;            $i--;
7064            $node = $self->{open_elements}->[$i];          }
7065            redo LI;  
7066          } # LI          ## 5. (a) has a |p| element in scope
7067                      INSCOPE: for (reverse @{$self->{open_elements}}) {
7068              if ($_->[1] & P_EL) {
7069                !!!cp ('t353');
7070                !!!back-token; # <x>
7071                $token = {type => END_TAG_TOKEN, tag_name => 'p',
7072                          line => $token->{line}, column => $token->{column}};
7073                next B;
7074              } elsif ($_->[1] & SCOPING_EL) {
7075                !!!cp ('t354');
7076                last INSCOPE;
7077              }
7078            } # INSCOPE
7079    
7080            ## 5. (b) insert
7081          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
7082          !!!nack ('t359.1');          !!!nack ('t359.1');
7083          !!!next-token;          !!!next-token;
7084          next B;          next B;
7085          } elsif ($token->{tag_name} eq 'dt' or
7086                   $token->{tag_name} eq 'dd') {
7087            ## NOTE: As normal, but imply </dt> or </dd> when ...
7088    
7089            my $non_optional;
7090            my $i = -1;
7091    
7092            ## 1.
7093            for my $node (reverse @{$self->{open_elements}}) {
7094              if ($node->[1] & DT_EL or $node->[1] & DD_EL) {
7095                ## 2. (a) As if </li>
7096                {
7097                  ## If no </li> - not applied
7098                  #
7099    
7100                  ## Otherwise
7101    
7102                  ## 1. generate implied end tags, except for </dt> or </dd>
7103                  #
7104    
7105                  ## 2. If current node != "dt"|"dd", parse error
7106                  if ($non_optional) {
7107                    !!!parse-error (type => 'not closed',
7108                                    text => $non_optional->[0]->manakai_local_name,
7109                                    token => $token);
7110                    !!!cp ('t355.1');
7111                  } else {
7112                    !!!cp ('t356.1');
7113                  }
7114    
7115                  ## 3. Pop
7116                  splice @{$self->{open_elements}}, $i;
7117                }
7118    
7119                last; ## 2. (b) goto 5.
7120              } elsif (
7121                       ## NOTE: not "formatting" and not "phrasing"
7122                       ($node->[1] & SPECIAL_EL or
7123                        $node->[1] & SCOPING_EL) and
7124                       ## NOTE: "li", "dt", and "dd" are in |SPECIAL_EL|.
7125    
7126                       (not $node->[1] & ADDRESS_EL) &
7127                       (not $node->[1] & DIV_EL) &
7128                       (not $node->[1] & P_EL)) {
7129                ## 3.
7130                !!!cp ('t357.1');
7131                last; ## goto 5.
7132              } elsif ($node->[1] & END_TAG_OPTIONAL_EL) {
7133                !!!cp ('t358.1');
7134                #
7135              } else {
7136                !!!cp ('t359.1');
7137                $non_optional ||= $node;
7138                #
7139              }
7140              ## 4.
7141              ## goto 2.
7142              $i--;
7143            }
7144    
7145            ## 5. (a) has a |p| element in scope
7146            INSCOPE: for (reverse @{$self->{open_elements}}) {
7147              if ($_->[1] & P_EL) {
7148                !!!cp ('t353.1');
7149                !!!back-token; # <x>
7150                $token = {type => END_TAG_TOKEN, tag_name => 'p',
7151                          line => $token->{line}, column => $token->{column}};
7152                next B;
7153              } elsif ($_->[1] & SCOPING_EL) {
7154                !!!cp ('t354.1');
7155                last INSCOPE;
7156              }
7157            } # INSCOPE
7158    
7159            ## 5. (b) insert
7160            !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
7161            !!!nack ('t359.2');
7162            !!!next-token;
7163            next B;
7164        } elsif ($token->{tag_name} eq 'plaintext') {        } elsif ($token->{tag_name} eq 'plaintext') {
7165            ## NOTE: As normal, but effectively ends parsing
7166    
7167          ## has a p element in scope          ## has a p element in scope
7168          INSCOPE: for (reverse @{$self->{open_elements}}) {          INSCOPE: for (reverse @{$self->{open_elements}}) {
7169            if ($_->[1] & P_EL) {            if ($_->[1] & P_EL) {
# Line 7494  sub _tree_construction_main ($) { Line 7600  sub _tree_construction_main ($) {
7600            next B;            next B;
7601          }          }
7602        } elsif ({        } elsif ({
7603                  address => 1, blockquote => 1, center => 1, dir => 1,                  ## NOTE: End tags for non-phrasing flow content elements
7604                  div => 1, dl => 1, fieldset => 1, listing => 1,  
7605                  menu => 1, ol => 1, pre => 1, ul => 1,                  ## NOTE: The normal ones
7606                    address => 1, article => 1, aside => 1, blockquote => 1,
7607                    center => 1, datagrid => 1, details => 1, dialog => 1,
7608                    dir => 1, div => 1, dl => 1, fieldset => 1, figure => 1,
7609                    footer => 1, header => 1, listing => 1, menu => 1, nav => 1,
7610                    ol => 1, pre => 1, section => 1, ul => 1,
7611    
7612                    ## NOTE: As normal, but ... optional tags
7613                  dd => 1, dt => 1, li => 1,                  dd => 1, dt => 1, li => 1,
7614    
7615                  applet => 1, button => 1, marquee => 1, object => 1,                  applet => 1, button => 1, marquee => 1, object => 1,
7616                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
7617            ## NOTE: Code for <li> start tags includes "as if </li>" code.
7618            ## Code for <dt> or <dd> start tags includes "as if </dt> or
7619            ## </dd>" code.
7620    
7621          ## has an element in scope          ## has an element in scope
7622          my $i;          my $i;
7623          INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {          INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
# Line 7560  sub _tree_construction_main ($) { Line 7678  sub _tree_construction_main ($) {
7678          !!!next-token;          !!!next-token;
7679          next B;          next B;
7680        } elsif ($token->{tag_name} eq 'form') {        } elsif ($token->{tag_name} eq 'form') {
7681            ## NOTE: As normal, but interacts with the form element pointer
7682    
7683          undef $self->{form_element};          undef $self->{form_element};
7684    
7685          ## has an element in scope          ## has an element in scope
# Line 7607  sub _tree_construction_main ($) { Line 7727  sub _tree_construction_main ($) {
7727          !!!next-token;          !!!next-token;
7728          next B;          next B;
7729        } elsif ({        } elsif ({
7730                    ## NOTE: As normal, except acts as a closer for any ...
7731                  h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,                  h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,
7732                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
7733          ## has an element in scope          ## has an element in scope
# Line 7652  sub _tree_construction_main ($) { Line 7773  sub _tree_construction_main ($) {
7773          !!!next-token;          !!!next-token;
7774          next B;          next B;
7775        } elsif ($token->{tag_name} eq 'p') {        } elsif ($token->{tag_name} eq 'p') {
7776            ## NOTE: As normal, except </p> implies <p> and ...
7777    
7778          ## has an element in scope          ## has an element in scope
7779            my $non_optional;
7780          my $i;          my $i;
7781          INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {          INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
7782            my $node = $self->{open_elements}->[$_];            my $node = $self->{open_elements}->[$_];
# Line 7663  sub _tree_construction_main ($) { Line 7787  sub _tree_construction_main ($) {
7787            } elsif ($node->[1] & SCOPING_EL) {            } elsif ($node->[1] & SCOPING_EL) {
7788              !!!cp ('t411.1');              !!!cp ('t411.1');
7789              last INSCOPE;              last INSCOPE;
7790              } elsif ($node->[1] & END_TAG_OPTIONAL_EL) {
7791                ## NOTE: |END_TAG_OPTIONAL_EL| includes "p"
7792                !!!cp ('t411.2');
7793                #
7794              } else {
7795                !!!cp ('t411.3');
7796                $non_optional ||= $node;
7797                #
7798            }            }
7799          } # INSCOPE          } # INSCOPE
7800    
7801          if (defined $i) {          if (defined $i) {
7802            if ($self->{open_elements}->[-1]->[0]->manakai_local_name            ## 1. Generate implied end tags
7803                    ne $token->{tag_name}) {            #
7804    
7805              ## 2. If current node != "p", parse error
7806              if ($non_optional) {
7807              !!!cp ('t412.1');              !!!cp ('t412.1');
7808              !!!parse-error (type => 'not closed',              !!!parse-error (type => 'not closed',
7809                              text => $self->{open_elements}->[-1]->[0]                              text => $non_optional->[0]->manakai_local_name,
                                 ->manakai_local_name,  
7810                              token => $token);                              token => $token);
7811            } else {            } else {
7812              !!!cp ('t414.1');              !!!cp ('t414.1');
7813            }            }
7814    
7815              ## 3. Pop
7816            splice @{$self->{open_elements}}, $i;            splice @{$self->{open_elements}}, $i;
7817          } else {          } else {
7818            !!!cp ('t413.1');            !!!cp ('t413.1');
# Line 7736  sub _tree_construction_main ($) { Line 7871  sub _tree_construction_main ($) {
7871          ## Ignore the token          ## Ignore the token
7872          !!!next-token;          !!!next-token;
7873          next B;          next B;
           
         ## ISSUE: Issue on HTML5 new elements in spec  
           
7874        } else {        } else {
7875            if ($token->{tag_name} eq 'sarcasm') {
7876              sleep 0.001; # take a deep breath
7877            }
7878    
7879          ## Step 1          ## Step 1
7880          my $node_i = -1;          my $node_i = -1;
7881          my $node = $self->{open_elements}->[$node_i];          my $node = $self->{open_elements}->[$node_i];

Legend:
Removed from v.1.194  
changed lines
  Added in v.1.197

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24