/[suikacvs]/markup/html/whatpm/Whatpm/HTML.pm.src
Suika

Diff of /markup/html/whatpm/Whatpm/HTML.pm.src

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.145 by wakaba, Sat May 24 11:57:47 2008 UTC revision 1.151 by wakaba, Sun Jun 8 05:08:42 2008 UTC
# Line 45  sub MISC_SPECIAL_EL () { 0b1000000000000 Line 45  sub MISC_SPECIAL_EL () { 0b1000000000000
45  sub FOREIGN_EL () { 0b10000000000000000000000000 }  sub FOREIGN_EL () { 0b10000000000000000000000000 }
46  sub FOREIGN_FLOW_CONTENT_EL () { 0b100000000000000000000000000 }  sub FOREIGN_FLOW_CONTENT_EL () { 0b100000000000000000000000000 }
47  sub MML_AXML_EL () { 0b1000000000000000000000000000 }  sub MML_AXML_EL () { 0b1000000000000000000000000000 }
48    sub RUBY_EL () { 0b10000000000000000000000000000 }
49    sub RUBY_COMPONENT_EL () { 0b100000000000000000000000000000 }
50    
51  sub TABLE_ROWS_EL () {  sub TABLE_ROWS_EL () {
52    TABLE_EL |    TABLE_EL |
# Line 52  sub TABLE_ROWS_EL () { Line 54  sub TABLE_ROWS_EL () {
54    TABLE_ROW_GROUP_EL    TABLE_ROW_GROUP_EL
55  }  }
56    
57    ## NOTE: Used in "generate implied end tags" algorithm.
58    ## NOTE: There is a code where a modified version of END_TAG_OPTIONAL_EL
59    ## is used in "generate implied end tags" implementation (search for the
60    ## function mae).
61  sub END_TAG_OPTIONAL_EL () {  sub END_TAG_OPTIONAL_EL () {
62    DD_EL |    DD_EL |
63    DT_EL |    DT_EL |
64    LI_EL |    LI_EL |
65    P_EL    P_EL |
66      RUBY_COMPONENT_EL
67  }  }
68    
69    ## NOTE: Used in </body> and EOF algorithms.
70  sub ALL_END_TAG_OPTIONAL_EL () {  sub ALL_END_TAG_OPTIONAL_EL () {
71    END_TAG_OPTIONAL_EL |    DD_EL |
72      DT_EL |
73      LI_EL |
74      P_EL |
75    
76    BODY_EL |    BODY_EL |
77    HTML_EL |    HTML_EL |
78    TABLE_CELL_EL |    TABLE_CELL_EL |
# Line 96  sub SPECIAL_EL () { Line 108  sub SPECIAL_EL () {
108    ADDRESS_EL |    ADDRESS_EL |
109    BODY_EL |    BODY_EL |
110    DIV_EL |    DIV_EL |
111    END_TAG_OPTIONAL_EL |  
112      DD_EL |
113      DT_EL |
114      LI_EL |
115      P_EL |
116    
117    FORM_EL |    FORM_EL |
118    FRAMESET_EL |    FRAMESET_EL |
119    HEADING_EL |    HEADING_EL |
# Line 170  my $el_category = { Line 187  my $el_category = {
187    param => MISC_SPECIAL_EL,    param => MISC_SPECIAL_EL,
188    plaintext => MISC_SPECIAL_EL,    plaintext => MISC_SPECIAL_EL,
189    pre => MISC_SPECIAL_EL,    pre => MISC_SPECIAL_EL,
190      rp => RUBY_COMPONENT_EL,
191      rt => RUBY_COMPONENT_EL,
192      ruby => RUBY_EL,
193    s => FORMATTING_EL,    s => FORMATTING_EL,
194    script => MISC_SPECIAL_EL,    script => MISC_SPECIAL_EL,
195    select => SELECT_EL,    select => SELECT_EL,
# Line 211  my $el_category_f = { Line 231  my $el_category_f = {
231  };  };
232    
233  my $svg_attr_name = {  my $svg_attr_name = {
234      attributename => 'attributeName',
235    attributetype => 'attributeType',    attributetype => 'attributeType',
236    basefrequency => 'baseFrequency',    basefrequency => 'baseFrequency',
237    baseprofile => 'baseProfile',    baseprofile => 'baseProfile',
# Line 221  my $svg_attr_name = { Line 242  my $svg_attr_name = {
242    diffuseconstant => 'diffuseConstant',    diffuseconstant => 'diffuseConstant',
243    edgemode => 'edgeMode',    edgemode => 'edgeMode',
244    externalresourcesrequired => 'externalResourcesRequired',    externalresourcesrequired => 'externalResourcesRequired',
   fecolormatrix => 'feColorMatrix',  
   fecomposite => 'feComposite',  
   fegaussianblur => 'feGaussianBlur',  
   femorphology => 'feMorphology',  
   fetile => 'feTile',  
245    filterres => 'filterRes',    filterres => 'filterRes',
246    filterunits => 'filterUnits',    filterunits => 'filterUnits',
247    glyphref => 'glyphRef',    glyphref => 'glyphRef',
# Line 259  my $svg_attr_name = { Line 275  my $svg_attr_name = {
275    repeatcount => 'repeatCount',    repeatcount => 'repeatCount',
276    repeatdur => 'repeatDur',    repeatdur => 'repeatDur',
277    requiredextensions => 'requiredExtensions',    requiredextensions => 'requiredExtensions',
278      requiredfeatures => 'requiredFeatures',
279    specularconstant => 'specularConstant',    specularconstant => 'specularConstant',
280    specularexponent => 'specularExponent',    specularexponent => 'specularExponent',
281    spreadmethod => 'spreadMethod',    spreadmethod => 'spreadMethod',
# Line 484  sub parse_byte_stream ($$$$;$) { Line 501  sub parse_byte_stream ($$$$;$) {
501        ## "Change the encoding" algorithm:        ## "Change the encoding" algorithm:
502    
503        ## Step 1            ## Step 1    
504        if ($charset->{iana_names}->{'utf-16'}) { ## ISSUE: UTF-16BE -> UTF-8? UTF-16LE -> UTF-8?        if ($charset->{category} &
505              Message::Charset::Info::CHARSET_CATEGORY_UTF16 ()) {
506          $charset = Message::Charset::Info->get_by_iana_name ('utf-8');          $charset = Message::Charset::Info->get_by_iana_name ('utf-8');
507          ($char_stream, $e_status) = $charset->get_decode_handle          ($char_stream, $e_status) = $charset->get_decode_handle
508              ($byte_stream,              ($byte_stream,
# Line 826  sub _initialize_tokenizer ($) { Line 844  sub _initialize_tokenizer ($) {
844  ##     |->{self_closing}| is used to save the value of |$self->{self_closing}|  ##     |->{self_closing}| is used to save the value of |$self->{self_closing}|
845  ##     while the token is pushed back to the stack.  ##     while the token is pushed back to the stack.
846    
 ## ISSUE: "When a DOCTYPE token is created, its  
 ## <i>self-closing flag</i> must be unset (its other state is that it  
 ## be set), and its attributes list must be empty.": Wrong subject?  
   
847  ## Emitted token MUST immediately be handled by the tree construction state.  ## Emitted token MUST immediately be handled by the tree construction state.
848    
849  ## Before each step, UA MAY check to see if either one of the scripts in  ## Before each step, UA MAY check to see if either one of the scripts in
# Line 2736  sub _get_next_token ($) { Line 2750  sub _get_next_token ($) {
2750          redo A;          redo A;
2751        } elsif ($self->{next_char} == -1) {        } elsif ($self->{next_char} == -1) {
2752          !!!cp (217);          !!!cp (217);
2753            !!!parse-error (type => 'unclosed DOCTYPE');
2754          $self->{state} = DATA_STATE;          $self->{state} = DATA_STATE;
2755          ## reconsume          ## reconsume
2756    
# Line 3419  sub _reset_insertion_mode ($) { Line 3433  sub _reset_insertion_mode ($) {
3433          ## NOTE: Strictly spaking, the line below only applies to MathML and          ## NOTE: Strictly spaking, the line below only applies to MathML and
3434          ## SVG elements.  Currently the HTML syntax supports only MathML and          ## SVG elements.  Currently the HTML syntax supports only MathML and
3435          ## SVG elements as foreigners.          ## SVG elements as foreigners.
3436          $new_mode = $self->{insertion_mode} | IN_FOREIGN_CONTENT_IM;          $new_mode = IN_BODY_IM | IN_FOREIGN_CONTENT_IM;
         ## ISSUE: What is set as the secondary insertion mode?  
3437        } elsif ($node->[1] & TABLE_CELL_EL) {        } elsif ($node->[1] & TABLE_CELL_EL) {
3438          if ($last) {          if ($last) {
3439            !!!cp ('t28.2');            !!!cp ('t28.2');
# Line 4024  sub _tree_construction_main ($) { Line 4037  sub _tree_construction_main ($) {
4037            #            #
4038          } elsif ({          } elsif ({
4039                    b => 1, big => 1, blockquote => 1, body => 1, br => 1,                    b => 1, big => 1, blockquote => 1, body => 1, br => 1,
4040                    center => 1, code => 1, dd => 1, div => 1, dl => 1, em => 1,                    center => 1, code => 1, dd => 1, div => 1, dl => 1, dt => 1,
4041                    embed => 1, font => 1, h1 => 1, h2 => 1, h3 => 1, ## No h4!                    em => 1, embed => 1, font => 1, h1 => 1, h2 => 1, h3 => 1,
4042                    h5 => 1, h6 => 1, head => 1, hr => 1, i => 1, img => 1,                    h4 => 1, h5 => 1, h6 => 1, head => 1, hr => 1, i => 1,
4043                    li => 1, menu => 1, meta => 1, nobr => 1, p => 1, pre => 1,                    img => 1, li => 1, listing => 1, menu => 1, meta => 1,
4044                    ruby => 1, s => 1, small => 1, span => 1, strong => 1,                    nobr => 1, ol => 1, p => 1, pre => 1, ruby => 1, s => 1,
4045                    sub => 1, sup => 1, table => 1, tt => 1, u => 1, ul => 1,                    small => 1, span => 1, strong => 1, strike => 1, sub => 1,
4046                    var => 1,                    sup => 1, table => 1, tt => 1, u => 1, ul => 1, var => 1,
4047                   }->{$token->{tag_name}}) {                   }->{$token->{tag_name}}) {
4048            !!!cp ('t87.2');            !!!cp ('t87.2');
4049            !!!parse-error (type => 'not closed',            !!!parse-error (type => 'not closed',
# Line 4110  sub _tree_construction_main ($) { Line 4123  sub _tree_construction_main ($) {
4123          !!!cp ('t87.5');          !!!cp ('t87.5');
4124          #          #
4125        } elsif ($token->{type} == END_OF_FILE_TOKEN) {        } elsif ($token->{type} == END_OF_FILE_TOKEN) {
         ## NOTE: "using the rules for secondary insertion mode" then "continue"  
4126          !!!cp ('t87.6');          !!!cp ('t87.6');
4127          #          !!!parse-error (type => 'not closed',
4128          ## TODO: ...                          value => $self->{open_elements}->[-1]->[0]
4129                                ->manakai_local_name,
4130                            token => $token);
4131    
4132            pop @{$self->{open_elements}}
4133                while $self->{open_elements}->[-1]->[1] & FOREIGN_EL;
4134    
4135            $self->{insertion_mode} &= ~ IN_FOREIGN_CONTENT_IM;
4136            ## Reprocess.
4137            next B;
4138        } else {        } else {
4139          die "$0: $token->{type}: Unknown token type";                  die "$0: $token->{type}: Unknown token type";        
4140        }        }
# Line 4357  sub _tree_construction_main ($) { Line 4378  sub _tree_construction_main ($) {
4378                pop @{$self->{open_elements}} # <head>                pop @{$self->{open_elements}} # <head>
4379                    if $self->{insertion_mode} == AFTER_HEAD_IM;                    if $self->{insertion_mode} == AFTER_HEAD_IM;
4380                next B;                next B;
4381              } elsif ($token->{tag_name} eq 'style') {              } elsif ($token->{tag_name} eq 'style' or
4382                         $token->{tag_name} eq 'noframes') {
4383                ## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and                ## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and
4384                ## insertion mode IN_HEAD_IM)                ## insertion mode IN_HEAD_IM)
4385                ## NOTE: There is a "as if in head" code clone.                ## NOTE: There is a "as if in head" code clone.
# Line 5371  sub _tree_construction_main ($) { Line 5393  sub _tree_construction_main ($) {
5393                  next B;                  next B;
5394                }                }
5395                                
5396  ## TODO: Followings are removed from the latest spec.  ## TODO: Followings are removed from the latest spec.
5397                ## generate implied end tags                ## generate implied end tags
5398                while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {                while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {
5399                  !!!cp ('t224');                  !!!cp ('t224');
# Line 5869  sub _tree_construction_main ($) { Line 5891  sub _tree_construction_main ($) {
5891            !!!nack ('t277.1');            !!!nack ('t277.1');
5892            !!!next-token;            !!!next-token;
5893            next B;            next B;
5894          } elsif ($token->{tag_name} eq 'select' or          } elsif ({
5895                   $token->{tag_name} eq 'input' or                     select => 1, input => 1, textarea => 1,
5896                     }->{$token->{tag_name}} or
5897                   ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and                   ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and
5898                    {                    {
5899                     caption => 1, table => 1,                     caption => 1, table => 1,
# Line 6227  sub _tree_construction_main ($) { Line 6250  sub _tree_construction_main ($) {
6250            next B;            next B;
6251          } elsif ($token->{tag_name} eq 'noframes') {          } elsif ($token->{tag_name} eq 'noframes') {
6252            !!!cp ('t320');            !!!cp ('t320');
6253            ## NOTE: As if in body.            ## NOTE: As if in head.
6254            $parse_rcdata->(CDATA_CONTENT_MODEL);            $parse_rcdata->(CDATA_CONTENT_MODEL);
6255            next B;            next B;
6256          } else {          } else {
# Line 6670  sub _tree_construction_main ($) { Line 6693  sub _tree_construction_main ($) {
6693                  xmp => 1,                  xmp => 1,
6694                  iframe => 1,                  iframe => 1,
6695                  noembed => 1,                  noembed => 1,
6696                  noframes => 1,                  noframes => 1, ## NOTE: This is an "as if in head" code clone.
6697                  noscript => 0, ## TODO: 1 if scripting is enabled                  noscript => 0, ## TODO: 1 if scripting is enabled
6698                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
6699          if ($token->{tag_name} eq 'xmp') {          if ($token->{tag_name} eq 'xmp') {
# Line 6692  sub _tree_construction_main ($) { Line 6715  sub _tree_construction_main ($) {
6715            !!!next-token;            !!!next-token;
6716            next B;            next B;
6717          } else {          } else {
6718              !!!ack ('t391.1');
6719    
6720            my $at = $token->{attributes};            my $at = $token->{attributes};
6721            my $form_attrs;            my $form_attrs;
6722            $form_attrs->{action} = $at->{action} if $at->{action};            $form_attrs->{action} = $at->{action} if $at->{action};
# Line 6735  sub _tree_construction_main ($) { Line 6760  sub _tree_construction_main ($) {
6760                           line => $token->{line}, column => $token->{column}},                           line => $token->{line}, column => $token->{column}},
6761                          {type => END_TAG_TOKEN, tag_name => 'form',                          {type => END_TAG_TOKEN, tag_name => 'form',
6762                           line => $token->{line}, column => $token->{column}};                           line => $token->{line}, column => $token->{column}};
           !!!nack ('t391.1'); ## NOTE: Not acknowledged.  
6763            !!!back-token (@tokens);            !!!back-token (@tokens);
6764            !!!next-token;            !!!next-token;
6765            next B;            next B;
# Line 6787  sub _tree_construction_main ($) { Line 6811  sub _tree_construction_main ($) {
6811          }          }
6812          !!!next-token;          !!!next-token;
6813          next B;          next B;
6814          } elsif ($token->{tag_name} eq 'rt' or
6815                   $token->{tag_name} eq 'rp') {
6816            ## has a |ruby| element in scope
6817            INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
6818              my $node = $self->{open_elements}->[$_];
6819              if ($node->[1] & RUBY_EL) {
6820                !!!cp ('t398.1');
6821                ## generate implied end tags
6822                while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {
6823                  !!!cp ('t398.2');
6824                  pop @{$self->{open_elements}};
6825                }
6826                unless ($self->{open_elements}->[-1]->[1] & RUBY_EL) {
6827                  !!!cp ('t398.3');
6828                  !!!parse-error (type => 'not closed',
6829                                  value => $self->{open_elements}->[-1]->[0]
6830                                      ->manakai_local_name,
6831                                  token => $token);
6832                  pop @{$self->{open_elements}}
6833                      while not $self->{open_elements}->[-1]->[1] & RUBY_EL;
6834                }
6835                last INSCOPE;
6836              } elsif ($node->[1] & SCOPING_EL) {
6837                !!!cp ('t398.4');
6838                last INSCOPE;
6839              }
6840            } # INSCOPE
6841    
6842            !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
6843    
6844            !!!nack ('t398.5');
6845            !!!next-token;
6846            redo B;
6847        } elsif ($token->{tag_name} eq 'math' or        } elsif ($token->{tag_name} eq 'math' or
6848                 $token->{tag_name} eq 'svg') {                 $token->{tag_name} eq 'svg') {
6849          $reconstruct_active_formatting_elements->($insert_to_current);          $reconstruct_active_formatting_elements->($insert_to_current);
# Line 6975  sub _tree_construction_main ($) { Line 7032  sub _tree_construction_main ($) {
7032          } else {          } else {
7033            ## Step 1. generate implied end tags            ## Step 1. generate implied end tags
7034            while ({            while ({
7035                      ## END_TAG_OPTIONAL_EL
7036                    dd => ($token->{tag_name} ne 'dd'),                    dd => ($token->{tag_name} ne 'dd'),
7037                    dt => ($token->{tag_name} ne 'dt'),                    dt => ($token->{tag_name} ne 'dt'),
7038                    li => ($token->{tag_name} ne 'li'),                    li => ($token->{tag_name} ne 'li'),
7039                    p => 1,                    p => 1,
7040                      rt => 1,
7041                      rp => 1,
7042                   }->{$self->{open_elements}->[-1]->[0]->manakai_local_name}) {                   }->{$self->{open_elements}->[-1]->[0]->manakai_local_name}) {
7043              !!!cp ('t409');              !!!cp ('t409');
7044              pop @{$self->{open_elements}};              pop @{$self->{open_elements}};
# Line 7191  sub _tree_construction_main ($) { Line 7251  sub _tree_construction_main ($) {
7251              ## generate implied end tags              ## generate implied end tags
7252              while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {              while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {
7253                !!!cp ('t430');                !!!cp ('t430');
7254                ## ISSUE: Can this case be reached?                ## NOTE: |<ruby><rt></ruby>|.
7255                  ## ISSUE: <ruby><rt></rt> will also take this code path,
7256                  ## which seems wrong.
7257                pop @{$self->{open_elements}};                pop @{$self->{open_elements}};
7258                  $node_i++;
7259              }              }
7260                    
7261              ## Step 2              ## Step 2
# Line 7209  sub _tree_construction_main ($) { Line 7272  sub _tree_construction_main ($) {
7272              }              }
7273                            
7274              ## Step 3              ## Step 3
7275              splice @{$self->{open_elements}}, $node_i;              splice @{$self->{open_elements}}, $node_i if $node_i < 0;
7276    
7277              !!!next-token;              !!!next-token;
7278              last S2;              last S2;

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24