/[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.215 by wakaba, Thu Jul 2 22:11:51 2009 UTC revision 1.226 by wakaba, Sun Aug 16 06:26:14 2009 UTC
# Line 1419  sub _tree_construction_main ($) { Line 1419  sub _tree_construction_main ($) {
1419      ## Step 3      ## Step 3
1420      ## TODO: Mark as "already executed", if ...      ## TODO: Mark as "already executed", if ...
1421    
1422      ## Step 4      ## Step 4 (HTML5 revision 2702)
1423      $insert->($script_el);      $insert->($script_el);
   
     ## ISSUE: $script_el is not put into the stack  
1424      push @{$self->{open_elements}}, [$script_el, $el_category->{script}];      push @{$self->{open_elements}}, [$script_el, $el_category->{script}];
1425    
1426      ## Step 5      ## Step 5
# Line 1874  sub _tree_construction_main ($) { Line 1872  sub _tree_construction_main ($) {
1872          } elsif ({          } elsif ({
1873                    b => 1, big => 1, blockquote => 1, body => 1, br => 1,                    b => 1, big => 1, blockquote => 1, body => 1, br => 1,
1874                    center => 1, code => 1, dd => 1, div => 1, dl => 1, dt => 1,                    center => 1, code => 1, dd => 1, div => 1, dl => 1, dt => 1,
1875                    em => 1, embed => 1, font => 1, h1 => 1, h2 => 1, h3 => 1,                    em => 1, embed => 1, h1 => 1, h2 => 1, h3 => 1,
1876                    h4 => 1, h5 => 1, h6 => 1, head => 1, hr => 1, i => 1,                    h4 => 1, h5 => 1, h6 => 1, head => 1, hr => 1, i => 1,
1877                    img => 1, li => 1, listing => 1, menu => 1, meta => 1,                    img => 1, li => 1, listing => 1, menu => 1, meta => 1,
1878                    nobr => 1, ol => 1, p => 1, pre => 1, ruby => 1, s => 1,                    nobr => 1, ol => 1, p => 1, pre => 1, ruby => 1, s => 1,
1879                    small => 1, span => 1, strong => 1, strike => 1, sub => 1,                    small => 1, span => 1, strong => 1, strike => 1, sub => 1,
1880                    sup => 1, table => 1, tt => 1, u => 1, ul => 1, var => 1,                    sup => 1, table => 1, tt => 1, u => 1, ul => 1, var => 1,
1881                   }->{$token->{tag_name}}) {                   }->{$token->{tag_name}} or
1882                     ($token->{tag_name} eq 'font' and
1883                      ($token->{attributes}->{color} or
1884                       $token->{attributes}->{face} or
1885                       $token->{attributes}->{size}))) {
1886            !!!cp ('t87.2');            !!!cp ('t87.2');
1887            !!!parse-error (type => 'not closed',            !!!parse-error (type => 'not closed',
1888                            text => $self->{open_elements}->[-1]->[0]                            text => $self->{open_elements}->[-1]->[0]
# Line 1956  sub _tree_construction_main ($) { Line 1958  sub _tree_construction_main ($) {
1958          }          }
1959        } elsif ($token->{type} == END_TAG_TOKEN) {        } elsif ($token->{type} == END_TAG_TOKEN) {
1960          ## NOTE: "using the rules for secondary insertion mode" then "continue"          ## NOTE: "using the rules for secondary insertion mode" then "continue"
1961          !!!cp ('t87.5');          if ($token->{tag_name} eq 'script') {
1962          #            !!!cp ('t87.41');
1963              #
1964              ## XXXscript: Execute script here.
1965            } else {
1966              !!!cp ('t87.5');
1967              #
1968            }
1969        } elsif ($token->{type} == END_OF_FILE_TOKEN) {        } elsif ($token->{type} == END_OF_FILE_TOKEN) {
1970          !!!cp ('t87.6');          !!!cp ('t87.6');
1971          !!!parse-error (type => 'not closed',          !!!parse-error (type => 'not closed',
# Line 2257  sub _tree_construction_main ($) { Line 2265  sub _tree_construction_main ($) {
2265    
2266            ## NOTE: There is a "as if in head" code clone.            ## NOTE: There is a "as if in head" code clone.
2267            $parse_rcdata->(RCDATA_CONTENT_MODEL);            $parse_rcdata->(RCDATA_CONTENT_MODEL);
2268            ## ISSUE: A spec bug [Bug 6038]  
2269              ## NOTE: At this point the stack of open elements contain
2270              ## the |head| element (index == -2) and the |script| element
2271              ## (index == -1).  In the "after head" insertion mode the
2272              ## |head| element is inserted only for the purpose of
2273              ## providing the context for the |script| element, and
2274              ## therefore we can now and have to remove the element from
2275              ## the stack.
2276            splice @{$self->{open_elements}}, -2, 1, () # <head>            splice @{$self->{open_elements}}, -2, 1, () # <head>
2277                if ($self->{insertion_mode} & IM_MASK) == AFTER_HEAD_IM;                if ($self->{insertion_mode} & IM_MASK) == AFTER_HEAD_IM;
2278            next B;            next B;
# Line 2492  sub _tree_construction_main ($) { Line 2507  sub _tree_construction_main ($) {
2507                ## Ignore the token                ## Ignore the token
2508                !!!next-token;                !!!next-token;
2509                next B;                next B;
2510              } elsif ($token->{tag_name} eq 'br') {          } elsif ($token->{tag_name} eq 'br') {
2511                if ($self->{insertion_mode} == BEFORE_HEAD_IM) {            if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
2512                  !!!cp ('t142.2');              !!!cp ('t142.2');
2513                  ## (before head) as if <head>, (in head) as if </head>              ## (before head) as if <head>, (in head) as if </head>
2514                  !!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token);              !!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token);
2515                  $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});              $self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
2516                  $self->{insertion_mode} = AFTER_HEAD_IM;              $self->{insertion_mode} = AFTER_HEAD_IM;
2517        
2518                  ## Reprocess in the "after head" insertion mode...              ## Reprocess in the "after head" insertion mode...
2519                } elsif ($self->{insertion_mode} == IN_HEAD_IM) {            } elsif ($self->{insertion_mode} == IN_HEAD_IM) {
2520                  !!!cp ('t143.2');              !!!cp ('t143.2');
2521                  ## As if </head>              ## As if </head>
2522                  pop @{$self->{open_elements}};              pop @{$self->{open_elements}};
2523                  $self->{insertion_mode} = AFTER_HEAD_IM;              $self->{insertion_mode} = AFTER_HEAD_IM;
2524        
2525                  ## Reprocess in the "after head" insertion mode...              ## Reprocess in the "after head" insertion mode...
2526                } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {            } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
2527                  !!!cp ('t143.3');              !!!cp ('t143.3');
2528                  ## NOTE: Two parse errors for <head><noscript></br>              ## NOTE: Two parse errors for <head><noscript></br>
2529                  !!!parse-error (type => 'unmatched end tag',              !!!parse-error (type => 'unmatched end tag',
2530                                  text => 'br', token => $token);                              text => 'br', token => $token);
2531                  ## As if </noscript>              ## As if </noscript>
2532                  pop @{$self->{open_elements}};              pop @{$self->{open_elements}};
2533                  $self->{insertion_mode} = IN_HEAD_IM;              $self->{insertion_mode} = IN_HEAD_IM;
2534    
2535                  ## Reprocess in the "in head" insertion mode...              ## Reprocess in the "in head" insertion mode...
2536                  ## As if </head>              ## As if </head>
2537                  pop @{$self->{open_elements}};              pop @{$self->{open_elements}};
2538                  $self->{insertion_mode} = AFTER_HEAD_IM;              $self->{insertion_mode} = AFTER_HEAD_IM;
2539    
2540                  ## Reprocess in the "after head" insertion mode...              ## Reprocess in the "after head" insertion mode...
2541                } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {            } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
2542                  !!!cp ('t143.4');              !!!cp ('t143.4');
2543                  #              #
2544                } else {            } else {
2545                  die "$0: $self->{insertion_mode}: Unknown insertion mode";              die "$0: $self->{insertion_mode}: Unknown insertion mode";
2546                }            }
2547    
2548                ## ISSUE: does not agree with IE7 - it doesn't ignore </br>.            #
2549                !!!parse-error (type => 'unmatched end tag',          } else { ## Other end tags
                               text => 'br', token => $token);  
               ## Ignore the token  
               !!!next-token;  
               next B;  
             } else {  
2550                !!!cp ('t145');                !!!cp ('t145');
2551                !!!parse-error (type => 'unmatched end tag',                !!!parse-error (type => 'unmatched end tag',
2552                                text => $token->{tag_name}, token => $token);                                text => $token->{tag_name}, token => $token);
# Line 2580  sub _tree_construction_main ($) { Line 2590  sub _tree_construction_main ($) {
2590              !!!insert-element ('body',, $token);              !!!insert-element ('body',, $token);
2591              $self->{insertion_mode} = IN_BODY_IM;              $self->{insertion_mode} = IN_BODY_IM;
2592              ## reprocess              ## reprocess
2593              next B;          next B;
2594        } elsif ($token->{type} == END_OF_FILE_TOKEN) {        } elsif ($token->{type} == END_OF_FILE_TOKEN) {
2595          if ($self->{insertion_mode} == BEFORE_HEAD_IM) {          if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
2596            !!!cp ('t149.1');            !!!cp ('t149.1');
# Line 3837  sub _tree_construction_main ($) { Line 3847  sub _tree_construction_main ($) {
3847            !!!next-token;            !!!next-token;
3848            next B;            next B;
3849          } elsif ({          } elsif ({
3850                     select => 1, input => 1, textarea => 1,                     select => 1, input => 1, textarea => 1, keygen => 1,
3851                   }->{$token->{tag_name}} or                   }->{$token->{tag_name}} or
3852                   (($self->{insertion_mode} & IM_MASK)                   (($self->{insertion_mode} & IM_MASK)
3853                        == IN_SELECT_IN_TABLE_IM and                        == IN_SELECT_IN_TABLE_IM and
# Line 3846  sub _tree_construction_main ($) { Line 3856  sub _tree_construction_main ($) {
3856                     tbody => 1, tfoot => 1, thead => 1,                     tbody => 1, tfoot => 1, thead => 1,
3857                     tr => 1, td => 1, th => 1,                     tr => 1, td => 1, th => 1,
3858                    }->{$token->{tag_name}})) {                    }->{$token->{tag_name}})) {
3859            ## TODO: The type below is not good - <select> is replaced by </select>  
3860            !!!parse-error (type => 'not closed', text => 'select',            ## 1. Parse error.
3861                            token => $token);            if ($token->{tag_name} eq 'select') {
3862            ## NOTE: As if the token were </select> (<select> case) or                !!!parse-error (type => 'select in select', ## XXX: documentation
3863            ## as if there were </select> (otherwise).                                token => $token);
3864            ## have an element in table scope            } else {
3865                !!!parse-error (type => 'not closed', text => 'select',
3866                                token => $token);
3867              }
3868    
3869              ## 2./<select>-1. Unless "have an element in table scope" (select):
3870            my $i;            my $i;
3871            INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {            INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
3872              my $node = $self->{open_elements}->[$_];              my $node = $self->{open_elements}->[$_];
# Line 3866  sub _tree_construction_main ($) { Line 3881  sub _tree_construction_main ($) {
3881            } # INSCOPE            } # INSCOPE
3882            unless (defined $i) {            unless (defined $i) {
3883              !!!cp ('t280');              !!!cp ('t280');
3884              !!!parse-error (type => 'unmatched end tag',              if ($token->{tag_name} eq 'select') {
3885                              text => 'select', token => $token);                ## NOTE: This error would be raised when
3886              ## Ignore the token                ## |select.innerHTML = '<select>'| is executed; in this
3887                  ## case two errors, "select in select" and "unmatched
3888                  ## end tags" are reported to the user, the latter might
3889                  ## be confusing but this is what the spec requires.
3890                  !!!parse-error (type => 'unmatched end tag',
3891                                  text => 'select',
3892                                  token => $token);
3893                }
3894                ## Ignore the token.
3895              !!!nack ('t280.1');              !!!nack ('t280.1');
3896              !!!next-token;              !!!next-token;
3897              next B;              next B;
3898            }            }
3899    
3900              ## 3. Otherwise, as if there were <select>:
3901                                
3902            !!!cp ('t281');            !!!cp ('t281');
3903            splice @{$self->{open_elements}}, $i;            splice @{$self->{open_elements}}, $i;
# Line 3889  sub _tree_construction_main ($) { Line 3914  sub _tree_construction_main ($) {
3914              ## Reprocess the token.              ## Reprocess the token.
3915              next B;              next B;
3916            }            }
3917            } elsif ($token->{tag_name} eq 'script') {
3918              !!!cp ('t281.3');
3919              ## NOTE: This is an "as if in head" code clone
3920              $script_start_tag->();
3921              next B;
3922          } else {          } else {
3923            !!!cp ('t282');            !!!cp ('t282');
3924            !!!parse-error (type => 'in select',            !!!parse-error (type => 'in select',
# Line 4408  sub _tree_construction_main ($) { Line 4438  sub _tree_construction_main ($) {
4438                  table => 1,                  table => 1,
4439                  hr => 1,                  hr => 1,
4440                 }->{$token->{tag_name}}) {                 }->{$token->{tag_name}}) {
4441    
4442            ## 1. When there is an opening |form| element:
4443          if ($token->{tag_name} eq 'form' and defined $self->{form_element}) {          if ($token->{tag_name} eq 'form' and defined $self->{form_element}) {
4444            !!!cp ('t350');            !!!cp ('t350');
4445            !!!parse-error (type => 'in form:form', token => $token);            !!!parse-error (type => 'in form:form', token => $token);
# Line 4417  sub _tree_construction_main ($) { Line 4449  sub _tree_construction_main ($) {
4449            next B;            next B;
4450          }          }
4451    
4452          ## has a p element in scope          ## 2. Close the |p| element, if any.
4453          INSCOPE: for (reverse @{$self->{open_elements}}) {          if ($token->{tag_name} ne 'table' or # The Hixie Quirk
4454            if ($_->[1] == P_EL) {              $self->{document}->manakai_compat_mode ne 'quirks') {
4455              !!!cp ('t344');            ## has a p element in scope
4456              !!!back-token; # <form>            INSCOPE: for (reverse @{$self->{open_elements}}) {
4457              $token = {type => END_TAG_TOKEN, tag_name => 'p',              if ($_->[1] == P_EL) {
4458                        line => $token->{line}, column => $token->{column}};                !!!cp ('t344');
4459              next B;                !!!back-token; # <form>
4460            } elsif ($_->[1] & SCOPING_EL) {                $token = {type => END_TAG_TOKEN, tag_name => 'p',
4461              !!!cp ('t345');                          line => $token->{line}, column => $token->{column}};
4462              last INSCOPE;                next B;
4463                } elsif ($_->[1] & SCOPING_EL) {
4464                  !!!cp ('t345');
4465                  last INSCOPE;
4466                }
4467              } # INSCOPE
4468            }
4469    
4470            ## 3. Close the opening <hn> element, if any.
4471            if ({h1 => 1, h2 => 1, h3 => 1,
4472                 h4 => 1, h5 => 1, h6 => 1}->{$token->{tag_name}}) {
4473              if ($self->{open_elements}->[-1]->[1] == HEADING_EL) {
4474                !!!parse-error (type => 'not closed',
4475                                text => $self->{open_elements}->[-1]->[0]->manakai_local_name,
4476                                token => $token);
4477                pop @{$self->{open_elements}};
4478            }            }
4479          } # INSCOPE          }
4480              
4481            ## 4. Insertion.
4482          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
4483          if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') {          if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') {
4484            !!!nack ('t346.1');            !!!nack ('t346.1');
# Line 4474  sub _tree_construction_main ($) { Line 4522  sub _tree_construction_main ($) {
4522        } elsif ($token->{tag_name} eq 'li') {        } elsif ($token->{tag_name} eq 'li') {
4523          ## NOTE: As normal, but imply </li> when there's another <li> ...          ## NOTE: As normal, but imply </li> when there's another <li> ...
4524    
4525          ## NOTE: Special, Scope (<li><foo><li> == <li><foo><li/></foo></li>)          ## NOTE: Special, Scope (<li><foo><li> == <li><foo><li/></foo></li>)::
4526            ## Interpreted as <li><foo/></li><li/> (non-conforming)            ## Interpreted as <li><foo/></li><li/> (non-conforming):
4527            ## blockquote (O9.27), center (O), dd (Fx3, O, S3.1.2, IE7),            ## blockquote (O9.27), center (O), dd (Fx3, O, S3.1.2, IE7),
4528            ## 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),
4529            ## 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),
4530            ## object (Fx)            ## object (Fx)
4531            ## Generate non-tree (non-conforming)            ## Generate non-tree (non-conforming):
4532            ## basefont (IE7 (where basefont is non-void)), center (IE),            ## basefont (IE7 (where basefont is non-void)), center (IE),
4533            ## form (IE), hn (IE)            ## form (IE), hn (IE)
4534          ## address, div, p (<li><foo><li> == <li><foo/></li><li/>)          ## address, div, p (<li><foo><li> == <li><foo/></li><li/>)::
4535            ## Interpreted as <li><foo><li/></foo></li> (non-conforming)            ## Interpreted as <li><foo><li/></foo></li> (non-conforming):
4536            ## div (Fx, S)            ## div (Fx, S)
4537    
4538          my $non_optional;          my $non_optional;
# Line 4831  sub _tree_construction_main ($) { Line 4879  sub _tree_construction_main ($) {
4879            next B;            next B;
4880          }          }
4881        } elsif ($token->{tag_name} eq 'textarea') {        } elsif ($token->{tag_name} eq 'textarea') {
4882          ## Step 1          ## 1. Insert
4883          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);          !!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token);
4884                    
4885          ## Step 2          ## Step 2 # XXX
4886          ## TODO: $self->{form_element} if defined          ## TODO: $self->{form_element} if defined
4887    
4888          ## Step 3          ## 2. Drop U+000A LINE FEED
4889          $self->{ignore_newline} = 1;          $self->{ignore_newline} = 1;
4890    
4891          ## Step 4          ## 3. RCDATA
         ## ISSUE: This step is wrong. (r2302 enbugged)  
   
         ## Step 5  
4892          $self->{content_model} = RCDATA_CONTENT_MODEL;          $self->{content_model} = RCDATA_CONTENT_MODEL;
4893          delete $self->{escape}; # MUST          delete $self->{escape}; # MUST
4894    
4895          ## Step 6-7          ## 4., 6. Insertion mode
4896          $self->{insertion_mode} |= IN_CDATA_RCDATA_IM;          $self->{insertion_mode} |= IN_CDATA_RCDATA_IM;
4897    
4898            ## XXX: 5. frameset-ok flag
4899    
4900          !!!nack ('t392.1');          !!!nack ('t392.1');
4901          !!!next-token;          !!!next-token;
4902          next B;          next B;
# Line 5021  sub _tree_construction_main ($) { Line 5068  sub _tree_construction_main ($) {
5068        }        }
5069      } elsif ($token->{type} == END_TAG_TOKEN) {      } elsif ($token->{type} == END_TAG_TOKEN) {
5070        if ($token->{tag_name} eq 'body') {        if ($token->{tag_name} eq 'body') {
5071          ## has a |body| element in scope  
5072            ## 1. If not "have an element in scope":
5073            ## "has a |body| element in scope"
5074          my $i;          my $i;
5075          INSCOPE: {          INSCOPE: {
5076            for (reverse @{$self->{open_elements}}) {            for (reverse @{$self->{open_elements}}) {
# Line 5044  sub _tree_construction_main ($) { Line 5093  sub _tree_construction_main ($) {
5093            next B;            next B;
5094          } # INSCOPE          } # INSCOPE
5095    
5096            ## 2. If unclosed elements:
5097          for (@{$self->{open_elements}}) {          for (@{$self->{open_elements}}) {
5098            unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL) {            unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL ||
5099                      $_->[1] == OPTGROUP_EL ||
5100                      $_->[1] == OPTION_EL ||
5101                      $_->[1] == RUBY_COMPONENT_EL) {
5102              !!!cp ('t403');              !!!cp ('t403');
5103              !!!parse-error (type => 'not closed',              !!!parse-error (type => 'not closed',
5104                              text => $_->[0]->manakai_local_name,                              text => $_->[0]->manakai_local_name,
# Line 5056  sub _tree_construction_main ($) { Line 5109  sub _tree_construction_main ($) {
5109            }            }
5110          }          }
5111    
5112            ## 3. Switch the insertion mode.
5113          $self->{insertion_mode} = AFTER_BODY_IM;          $self->{insertion_mode} = AFTER_BODY_IM;
5114          !!!next-token;          !!!next-token;
5115          next B;          next B;
# Line 5442  sub _tree_construction_main ($) { Line 5496  sub _tree_construction_main ($) {
5496    ## TODO: script stuffs    ## TODO: script stuffs
5497  } # _tree_construct_main  } # _tree_construct_main
5498    
5499    ## XXX: How this method is organized is somewhat out of date, although
5500    ## it still does what the current spec documents.
5501  sub set_inner_html ($$$$;$) {  sub set_inner_html ($$$$;$) {
5502    my $class = shift;    my $class = shift;
5503    my $node = shift;    my $node = shift; # /context/
5504    #my $s = \$_[0];    #my $s = \$_[0];
5505    my $onerror = $_[1];    my $onerror = $_[1];
5506    my $get_wrapper = $_[2] || sub ($) { return $_[0] };    my $get_wrapper = $_[2] || sub ($) { return $_[0] };
# Line 5452  sub set_inner_html ($$$$;$) { Line 5508  sub set_inner_html ($$$$;$) {
5508    ## ISSUE: Should {confident} be true?    ## ISSUE: Should {confident} be true?
5509    
5510    my $nt = $node->node_type;    my $nt = $node->node_type;
5511    if ($nt == 9) {    if ($nt == 9) { # Document (invoke the algorithm with no /context/ element)
5512      # MUST      # MUST
5513            
5514      ## Step 1 # MUST      ## Step 1 # MUST
# Line 5467  sub set_inner_html ($$$$;$) { Line 5523  sub set_inner_html ($$$$;$) {
5523    
5524      ## Step 3, 4, 5 # MUST      ## Step 3, 4, 5 # MUST
5525      $class->parse_char_string ($_[0] => $node, $onerror, $get_wrapper);      $class->parse_char_string ($_[0] => $node, $onerror, $get_wrapper);
5526    } elsif ($nt == 1) {    } elsif ($nt == 1) { # Element (invoke the algorithm with /context/ element)
5527      ## TODO: If non-html element      ## TODO: If non-html element
5528    
5529      ## NOTE: Most of this code is copied from |parse_string|      ## NOTE: Most of this code is copied from |parse_string|
5530    
5531  ## TODO: Support for $get_wrapper  ## TODO: Support for $get_wrapper
5532    
5533      ## Step 1 # MUST      ## F1. Create an HTML document.
5534      my $this_doc = $node->owner_document;      my $this_doc = $node->owner_document;
5535      my $doc = $this_doc->implementation->create_document;      my $doc = $this_doc->implementation->create_document;
5536      $doc->manakai_is_html (1);      $doc->manakai_is_html (1);
5537    
5538        ## F2. Propagate quirkness flag
5539        my $node_doc = $node->owner_document;
5540        $doc->manakai_compat_mode ($node_doc->manakai_compat_mode);
5541    
5542        ## F3. Create an HTML parser
5543      my $p = $class->new;      my $p = $class->new;
5544      $p->{document} = $doc;      $p->{document} = $doc;
5545    
# Line 5605  sub set_inner_html ($$$$;$) { Line 5667  sub set_inner_html ($$$$;$) {
5667      $p->_initialize_tokenizer;      $p->_initialize_tokenizer;
5668      $p->_initialize_tree_constructor;      $p->_initialize_tree_constructor;
5669    
5670      ## Step 2      ## F4. If /context/ is not undef...
5671    
5672        ## F4.1. content model flag
5673      my $node_ln = $node->manakai_local_name;      my $node_ln = $node->manakai_local_name;
5674      $p->{content_model} = {      $p->{content_model} = {
5675        title => RCDATA_CONTENT_MODEL,        title => RCDATA_CONTENT_MODEL,
# Line 5625  sub set_inner_html ($$$$;$) { Line 5689  sub set_inner_html ($$$$;$) {
5689      $p->{inner_html_node} = [$node, $el_category->{$node_ln}];      $p->{inner_html_node} = [$node, $el_category->{$node_ln}];
5690        ## TODO: Foreign element OK?        ## TODO: Foreign element OK?
5691    
5692      ## Step 3      ## F4.2. Root |html| element
5693      my $root = $doc->create_element_ns      my $root = $doc->create_element_ns
5694        ('http://www.w3.org/1999/xhtml', [undef, 'html']);        ('http://www.w3.org/1999/xhtml', [undef, 'html']);
5695    
5696      ## Step 4 # MUST      ## F4.3.
5697      $doc->append_child ($root);      $doc->append_child ($root);
5698    
5699      ## Step 5 # MUST      ## F4.4.
5700      push @{$p->{open_elements}}, [$root, $el_category->{html}];      push @{$p->{open_elements}}, [$root, $el_category->{html}];
5701    
5702      undef $p->{head_element};      undef $p->{head_element};
5703      undef $p->{head_element_inserted};      undef $p->{head_element_inserted};
5704    
5705      ## Step 6 # MUST      ## F4.5.
5706      $p->_reset_insertion_mode;      $p->_reset_insertion_mode;
5707    
5708      ## Step 7 # MUST      ## F4.6.
5709      my $anode = $node;      my $anode = $node;
5710      AN: while (defined $anode) {      AN: while (defined $anode) {
5711        if ($anode->node_type == 1) {        if ($anode->node_type == 1) {
# Line 5656  sub set_inner_html ($$$$;$) { Line 5720  sub set_inner_html ($$$$;$) {
5720        }        }
5721        $anode = $anode->parent_node;        $anode = $anode->parent_node;
5722      } # AN      } # AN
5723        
5724      ## Step 9 # MUST      ## F.6. Start the parser.
5725      {      {
5726        my $self = $p;        my $self = $p;
5727        !!!next-token;        !!!next-token;
5728      }      }
5729      $p->_tree_construction_main;      $p->_tree_construction_main;
5730    
5731      ## Step 10 # MUST      ## F.7.
5732      my @cn = @{$node->child_nodes};      my @cn = @{$node->child_nodes};
5733      for (@cn) {      for (@cn) {
5734        $node->remove_child ($_);        $node->remove_child ($_);

Legend:
Removed from v.1.215  
changed lines
  Added in v.1.226

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24