| 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 |
|
my $doctype = $self->{document}->create_document_type_definition |
| 921 |
|
($doctype_name); |
| 922 |
|
|
| 923 |
$doctype_name =~ tr/a-z/A-Z/; # ASCII case-insensitive |
$doctype_name =~ tr/a-z/A-Z/; # ASCII case-insensitive |
| 924 |
if (not defined $token->{name} or # <!DOCTYPE> |
if (not defined $token->{name} or # <!DOCTYPE> |
| 925 |
defined $token->{sysid}) { |
defined $token->{sysid}) { |
| 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 |
| 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 |
| 1875 |
} elsif ({ |
} elsif ({ |
| 1876 |
b => 1, big => 1, blockquote => 1, body => 1, br => 1, |
b => 1, big => 1, blockquote => 1, body => 1, br => 1, |
| 1877 |
center => 1, code => 1, dd => 1, div => 1, dl => 1, dt => 1, |
center => 1, code => 1, dd => 1, div => 1, dl => 1, dt => 1, |
| 1878 |
em => 1, embed => 1, font => 1, h1 => 1, h2 => 1, h3 => 1, |
em => 1, embed => 1, h1 => 1, h2 => 1, h3 => 1, |
| 1879 |
h4 => 1, h5 => 1, h6 => 1, head => 1, hr => 1, i => 1, |
h4 => 1, h5 => 1, h6 => 1, head => 1, hr => 1, i => 1, |
| 1880 |
img => 1, li => 1, listing => 1, menu => 1, meta => 1, |
img => 1, li => 1, listing => 1, menu => 1, meta => 1, |
| 1881 |
nobr => 1, ol => 1, p => 1, pre => 1, ruby => 1, s => 1, |
nobr => 1, ol => 1, p => 1, pre => 1, ruby => 1, s => 1, |
| 1882 |
small => 1, span => 1, strong => 1, strike => 1, sub => 1, |
small => 1, span => 1, strong => 1, strike => 1, sub => 1, |
| 1883 |
sup => 1, table => 1, tt => 1, u => 1, ul => 1, var => 1, |
sup => 1, table => 1, tt => 1, u => 1, ul => 1, var => 1, |
| 1884 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}} or |
| 1885 |
|
($token->{tag_name} eq 'font' and |
| 1886 |
|
($token->{attributes}->{color} or |
| 1887 |
|
$token->{attributes}->{face} or |
| 1888 |
|
$token->{attributes}->{size}))) { |
| 1889 |
!!!cp ('t87.2'); |
!!!cp ('t87.2'); |
| 1890 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 1891 |
text => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
| 1961 |
} |
} |
| 1962 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 1963 |
## NOTE: "using the rules for secondary insertion mode" then "continue" |
## NOTE: "using the rules for secondary insertion mode" then "continue" |
| 1964 |
!!!cp ('t87.5'); |
if ($token->{tag_name} eq 'script') { |
| 1965 |
# |
!!!cp ('t87.41'); |
| 1966 |
|
# |
| 1967 |
|
## XXXscript: Execute script here. |
| 1968 |
|
} else { |
| 1969 |
|
!!!cp ('t87.5'); |
| 1970 |
|
# |
| 1971 |
|
} |
| 1972 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 1973 |
!!!cp ('t87.6'); |
!!!cp ('t87.6'); |
| 1974 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 2268 |
|
|
| 2269 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 2270 |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
| 2271 |
## ISSUE: A spec bug [Bug 6038] |
|
| 2272 |
|
## NOTE: At this point the stack of open elements contain |
| 2273 |
|
## the |head| element (index == -2) and the |script| element |
| 2274 |
|
## (index == -1). In the "after head" insertion mode the |
| 2275 |
|
## |head| element is inserted only for the purpose of |
| 2276 |
|
## providing the context for the |script| element, and |
| 2277 |
|
## therefore we can now and have to remove the element from |
| 2278 |
|
## the stack. |
| 2279 |
splice @{$self->{open_elements}}, -2, 1, () # <head> |
splice @{$self->{open_elements}}, -2, 1, () # <head> |
| 2280 |
if ($self->{insertion_mode} & IM_MASK) == AFTER_HEAD_IM; |
if ($self->{insertion_mode} & IM_MASK) == AFTER_HEAD_IM; |
| 2281 |
next B; |
next B; |
| 2510 |
## Ignore the token |
## Ignore the token |
| 2511 |
!!!next-token; |
!!!next-token; |
| 2512 |
next B; |
next B; |
| 2513 |
} elsif ($token->{tag_name} eq 'br') { |
} elsif ($token->{tag_name} eq 'br') { |
| 2514 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 2515 |
!!!cp ('t142.2'); |
!!!cp ('t142.2'); |
| 2516 |
## (before head) as if <head>, (in head) as if </head> |
## (before head) as if <head>, (in head) as if </head> |
| 2517 |
!!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token); |
!!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token); |
| 2518 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 2519 |
$self->{insertion_mode} = AFTER_HEAD_IM; |
$self->{insertion_mode} = AFTER_HEAD_IM; |
| 2520 |
|
|
| 2521 |
## Reprocess in the "after head" insertion mode... |
## Reprocess in the "after head" insertion mode... |
| 2522 |
} elsif ($self->{insertion_mode} == IN_HEAD_IM) { |
} elsif ($self->{insertion_mode} == IN_HEAD_IM) { |
| 2523 |
!!!cp ('t143.2'); |
!!!cp ('t143.2'); |
| 2524 |
## As if </head> |
## As if </head> |
| 2525 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 2526 |
$self->{insertion_mode} = AFTER_HEAD_IM; |
$self->{insertion_mode} = AFTER_HEAD_IM; |
| 2527 |
|
|
| 2528 |
## Reprocess in the "after head" insertion mode... |
## Reprocess in the "after head" insertion mode... |
| 2529 |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 2530 |
!!!cp ('t143.3'); |
!!!cp ('t143.3'); |
| 2531 |
## NOTE: Two parse errors for <head><noscript></br> |
## NOTE: Two parse errors for <head><noscript></br> |
| 2532 |
!!!parse-error (type => 'unmatched end tag', |
!!!parse-error (type => 'unmatched end tag', |
| 2533 |
text => 'br', token => $token); |
text => 'br', token => $token); |
| 2534 |
## As if </noscript> |
## As if </noscript> |
| 2535 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 2536 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 2537 |
|
|
| 2538 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 2539 |
## As if </head> |
## As if </head> |
| 2540 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 2541 |
$self->{insertion_mode} = AFTER_HEAD_IM; |
$self->{insertion_mode} = AFTER_HEAD_IM; |
| 2542 |
|
|
| 2543 |
## Reprocess in the "after head" insertion mode... |
## Reprocess in the "after head" insertion mode... |
| 2544 |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 2545 |
!!!cp ('t143.4'); |
!!!cp ('t143.4'); |
| 2546 |
# |
# |
| 2547 |
} else { |
} else { |
| 2548 |
die "$0: $self->{insertion_mode}: Unknown insertion mode"; |
die "$0: $self->{insertion_mode}: Unknown insertion mode"; |
| 2549 |
} |
} |
| 2550 |
|
|
| 2551 |
## ISSUE: does not agree with IE7 - it doesn't ignore </br>. |
# |
| 2552 |
!!!parse-error (type => 'unmatched end tag', |
} else { ## Other end tags |
|
text => 'br', token => $token); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
next B; |
|
|
} else { |
|
| 2553 |
!!!cp ('t145'); |
!!!cp ('t145'); |
| 2554 |
!!!parse-error (type => 'unmatched end tag', |
!!!parse-error (type => 'unmatched end tag', |
| 2555 |
text => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
| 2593 |
!!!insert-element ('body',, $token); |
!!!insert-element ('body',, $token); |
| 2594 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 2595 |
## reprocess |
## reprocess |
| 2596 |
next B; |
next B; |
| 2597 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 2598 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 2599 |
!!!cp ('t149.1'); |
!!!cp ('t149.1'); |
| 3859 |
tbody => 1, tfoot => 1, thead => 1, |
tbody => 1, tfoot => 1, thead => 1, |
| 3860 |
tr => 1, td => 1, th => 1, |
tr => 1, td => 1, th => 1, |
| 3861 |
}->{$token->{tag_name}})) { |
}->{$token->{tag_name}})) { |
| 3862 |
## TODO: The type below is not good - <select> is replaced by </select> |
|
| 3863 |
!!!parse-error (type => 'not closed', text => 'select', |
## 1. Parse error. |
| 3864 |
token => $token); |
if ($token->{tag_name} eq 'select') { |
| 3865 |
## NOTE: As if the token were </select> (<select> case) or |
!!!parse-error (type => 'select in select', ## XXX: documentation |
| 3866 |
## as if there were </select> (otherwise). |
token => $token); |
| 3867 |
## have an element in table scope |
} else { |
| 3868 |
|
!!!parse-error (type => 'not closed', text => 'select', |
| 3869 |
|
token => $token); |
| 3870 |
|
} |
| 3871 |
|
|
| 3872 |
|
## 2./<select>-1. Unless "have an element in table scope" (select): |
| 3873 |
my $i; |
my $i; |
| 3874 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3875 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 3884 |
} # INSCOPE |
} # INSCOPE |
| 3885 |
unless (defined $i) { |
unless (defined $i) { |
| 3886 |
!!!cp ('t280'); |
!!!cp ('t280'); |
| 3887 |
!!!parse-error (type => 'unmatched end tag', |
if ($token->{tag_name} eq 'select') { |
| 3888 |
text => 'select', token => $token); |
## NOTE: This error would be raised when |
| 3889 |
## Ignore the token |
## |select.innerHTML = '<select>'| is executed; in this |
| 3890 |
|
## case two errors, "select in select" and "unmatched |
| 3891 |
|
## end tags" are reported to the user, the latter might |
| 3892 |
|
## be confusing but this is what the spec requires. |
| 3893 |
|
!!!parse-error (type => 'unmatched end tag', |
| 3894 |
|
text => 'select', |
| 3895 |
|
token => $token); |
| 3896 |
|
} |
| 3897 |
|
## Ignore the token. |
| 3898 |
!!!nack ('t280.1'); |
!!!nack ('t280.1'); |
| 3899 |
!!!next-token; |
!!!next-token; |
| 3900 |
next B; |
next B; |
| 3901 |
} |
} |
| 3902 |
|
|
| 3903 |
|
## 3. Otherwise, as if there were <select>: |
| 3904 |
|
|
| 3905 |
!!!cp ('t281'); |
!!!cp ('t281'); |
| 3906 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 3917 |
## Reprocess the token. |
## Reprocess the token. |
| 3918 |
next B; |
next B; |
| 3919 |
} |
} |
| 3920 |
|
} elsif ($token->{tag_name} eq 'script') { |
| 3921 |
|
!!!cp ('t281.3'); |
| 3922 |
|
## NOTE: This is an "as if in head" code clone |
| 3923 |
|
$script_start_tag->(); |
| 3924 |
|
next B; |
| 3925 |
} else { |
} else { |
| 3926 |
!!!cp ('t282'); |
!!!cp ('t282'); |
| 3927 |
!!!parse-error (type => 'in select', |
!!!parse-error (type => 'in select', |
| 4441 |
table => 1, |
table => 1, |
| 4442 |
hr => 1, |
hr => 1, |
| 4443 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4444 |
|
|
| 4445 |
|
## 1. When there is an opening |form| element: |
| 4446 |
if ($token->{tag_name} eq 'form' and defined $self->{form_element}) { |
if ($token->{tag_name} eq 'form' and defined $self->{form_element}) { |
| 4447 |
!!!cp ('t350'); |
!!!cp ('t350'); |
| 4448 |
!!!parse-error (type => 'in form:form', token => $token); |
!!!parse-error (type => 'in form:form', token => $token); |
| 4452 |
next B; |
next B; |
| 4453 |
} |
} |
| 4454 |
|
|
| 4455 |
|
## 2. Close the |p| element, if any. |
| 4456 |
if ($token->{tag_name} ne 'table' or # The Hixie Quirk |
if ($token->{tag_name} ne 'table' or # The Hixie Quirk |
| 4457 |
$self->{document}->manakai_compat_mode ne 'quirks') { |
$self->{document}->manakai_compat_mode ne 'quirks') { |
| 4458 |
## has a p element in scope |
## has a p element in scope |
| 4469 |
} |
} |
| 4470 |
} # INSCOPE |
} # INSCOPE |
| 4471 |
} |
} |
| 4472 |
|
|
| 4473 |
|
## 3. Close the opening <hn> element, if any. |
| 4474 |
|
if ({h1 => 1, h2 => 1, h3 => 1, |
| 4475 |
|
h4 => 1, h5 => 1, h6 => 1}->{$token->{tag_name}}) { |
| 4476 |
|
if ($self->{open_elements}->[-1]->[1] == HEADING_EL) { |
| 4477 |
|
!!!parse-error (type => 'not closed', |
| 4478 |
|
text => $self->{open_elements}->[-1]->[0]->manakai_local_name, |
| 4479 |
|
token => $token); |
| 4480 |
|
pop @{$self->{open_elements}}; |
| 4481 |
|
} |
| 4482 |
|
} |
| 4483 |
|
|
| 4484 |
|
## 4. Insertion. |
| 4485 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 4486 |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
| 4487 |
!!!nack ('t346.1'); |
!!!nack ('t346.1'); |
| 4525 |
} elsif ($token->{tag_name} eq 'li') { |
} elsif ($token->{tag_name} eq 'li') { |
| 4526 |
## NOTE: As normal, but imply </li> when there's another <li> ... |
## NOTE: As normal, but imply </li> when there's another <li> ... |
| 4527 |
|
|
| 4528 |
## NOTE: Special, Scope (<li><foo><li> == <li><foo><li/></foo></li>) |
## NOTE: Special, Scope (<li><foo><li> == <li><foo><li/></foo></li>):: |
| 4529 |
## Interpreted as <li><foo/></li><li/> (non-conforming) |
## Interpreted as <li><foo/></li><li/> (non-conforming): |
| 4530 |
## blockquote (O9.27), center (O), dd (Fx3, O, S3.1.2, IE7), |
## blockquote (O9.27), center (O), dd (Fx3, O, S3.1.2, IE7), |
| 4531 |
## 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), |
| 4532 |
## 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), |
| 4533 |
## object (Fx) |
## object (Fx) |
| 4534 |
## Generate non-tree (non-conforming) |
## Generate non-tree (non-conforming): |
| 4535 |
## basefont (IE7 (where basefont is non-void)), center (IE), |
## basefont (IE7 (where basefont is non-void)), center (IE), |
| 4536 |
## form (IE), hn (IE) |
## form (IE), hn (IE) |
| 4537 |
## address, div, p (<li><foo><li> == <li><foo/></li><li/>) |
## address, div, p (<li><foo><li> == <li><foo/></li><li/>):: |
| 4538 |
## Interpreted as <li><foo><li/></foo></li> (non-conforming) |
## Interpreted as <li><foo><li/></foo></li> (non-conforming): |
| 4539 |
## div (Fx, S) |
## div (Fx, S) |
| 4540 |
|
|
| 4541 |
my $non_optional; |
my $non_optional; |
| 4882 |
next B; |
next B; |
| 4883 |
} |
} |
| 4884 |
} elsif ($token->{tag_name} eq 'textarea') { |
} elsif ($token->{tag_name} eq 'textarea') { |
| 4885 |
## Step 1 |
## 1. Insert |
| 4886 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 4887 |
|
|
| 4888 |
## Step 2 |
## Step 2 # XXX |
| 4889 |
## TODO: $self->{form_element} if defined |
## TODO: $self->{form_element} if defined |
| 4890 |
|
|
| 4891 |
## Step 3 |
## 2. Drop U+000A LINE FEED |
| 4892 |
$self->{ignore_newline} = 1; |
$self->{ignore_newline} = 1; |
| 4893 |
|
|
| 4894 |
## Step 4 |
## 3. RCDATA |
|
## ISSUE: This step is wrong. (r2302 enbugged) |
|
|
|
|
|
## Step 5 |
|
| 4895 |
$self->{content_model} = RCDATA_CONTENT_MODEL; |
$self->{content_model} = RCDATA_CONTENT_MODEL; |
| 4896 |
delete $self->{escape}; # MUST |
delete $self->{escape}; # MUST |
| 4897 |
|
|
| 4898 |
## Step 6-7 |
## 4., 6. Insertion mode |
| 4899 |
$self->{insertion_mode} |= IN_CDATA_RCDATA_IM; |
$self->{insertion_mode} |= IN_CDATA_RCDATA_IM; |
| 4900 |
|
|
| 4901 |
|
## XXX: 5. frameset-ok flag |
| 4902 |
|
|
| 4903 |
!!!nack ('t392.1'); |
!!!nack ('t392.1'); |
| 4904 |
!!!next-token; |
!!!next-token; |
| 4905 |
next B; |
next B; |
| 5071 |
} |
} |
| 5072 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 5073 |
if ($token->{tag_name} eq 'body') { |
if ($token->{tag_name} eq 'body') { |
| 5074 |
## has a |body| element in scope |
|
| 5075 |
|
## 1. If not "have an element in scope": |
| 5076 |
|
## "has a |body| element in scope" |
| 5077 |
my $i; |
my $i; |
| 5078 |
INSCOPE: { |
INSCOPE: { |
| 5079 |
for (reverse @{$self->{open_elements}}) { |
for (reverse @{$self->{open_elements}}) { |
| 5096 |
next B; |
next B; |
| 5097 |
} # INSCOPE |
} # INSCOPE |
| 5098 |
|
|
| 5099 |
|
## 2. If unclosed elements: |
| 5100 |
for (@{$self->{open_elements}}) { |
for (@{$self->{open_elements}}) { |
| 5101 |
unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL) { |
unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL || |
| 5102 |
|
$_->[1] == OPTGROUP_EL || |
| 5103 |
|
$_->[1] == OPTION_EL || |
| 5104 |
|
$_->[1] == RUBY_COMPONENT_EL) { |
| 5105 |
!!!cp ('t403'); |
!!!cp ('t403'); |
| 5106 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 5107 |
text => $_->[0]->manakai_local_name, |
text => $_->[0]->manakai_local_name, |
| 5112 |
} |
} |
| 5113 |
} |
} |
| 5114 |
|
|
| 5115 |
|
## 3. Switch the insertion mode. |
| 5116 |
$self->{insertion_mode} = AFTER_BODY_IM; |
$self->{insertion_mode} = AFTER_BODY_IM; |
| 5117 |
!!!next-token; |
!!!next-token; |
| 5118 |
next B; |
next B; |
| 5499 |
## TODO: script stuffs |
## TODO: script stuffs |
| 5500 |
} # _tree_construct_main |
} # _tree_construct_main |
| 5501 |
|
|
| 5502 |
|
## XXX: How this method is organized is somewhat out of date, although |
| 5503 |
|
## it still does what the current spec documents. |
| 5504 |
sub set_inner_html ($$$$;$) { |
sub set_inner_html ($$$$;$) { |
| 5505 |
my $class = shift; |
my $class = shift; |
| 5506 |
my $node = shift; |
my $node = shift; # /context/ |
| 5507 |
#my $s = \$_[0]; |
#my $s = \$_[0]; |
| 5508 |
my $onerror = $_[1]; |
my $onerror = $_[1]; |
| 5509 |
my $get_wrapper = $_[2] || sub ($) { return $_[0] }; |
my $get_wrapper = $_[2] || sub ($) { return $_[0] }; |
| 5511 |
## ISSUE: Should {confident} be true? |
## ISSUE: Should {confident} be true? |
| 5512 |
|
|
| 5513 |
my $nt = $node->node_type; |
my $nt = $node->node_type; |
| 5514 |
if ($nt == 9) { |
if ($nt == 9) { # Document (invoke the algorithm with no /context/ element) |
| 5515 |
# MUST |
# MUST |
| 5516 |
|
|
| 5517 |
## Step 1 # MUST |
## Step 1 # MUST |
| 5526 |
|
|
| 5527 |
## Step 3, 4, 5 # MUST |
## Step 3, 4, 5 # MUST |
| 5528 |
$class->parse_char_string ($_[0] => $node, $onerror, $get_wrapper); |
$class->parse_char_string ($_[0] => $node, $onerror, $get_wrapper); |
| 5529 |
} elsif ($nt == 1) { |
} elsif ($nt == 1) { # Element (invoke the algorithm with /context/ element) |
| 5530 |
## TODO: If non-html element |
## TODO: If non-html element |
| 5531 |
|
|
| 5532 |
## NOTE: Most of this code is copied from |parse_string| |
## NOTE: Most of this code is copied from |parse_string| |
| 5533 |
|
|
| 5534 |
## TODO: Support for $get_wrapper |
## TODO: Support for $get_wrapper |
| 5535 |
|
|
| 5536 |
## Step 1 # MUST |
## F1. Create an HTML document. |
| 5537 |
my $this_doc = $node->owner_document; |
my $this_doc = $node->owner_document; |
| 5538 |
my $doc = $this_doc->implementation->create_document; |
my $doc = $this_doc->implementation->create_document; |
| 5539 |
$doc->manakai_is_html (1); |
$doc->manakai_is_html (1); |
| 5540 |
|
|
| 5541 |
|
## F2. Propagate quirkness flag |
| 5542 |
|
my $node_doc = $node->owner_document; |
| 5543 |
|
$doc->manakai_compat_mode ($node_doc->manakai_compat_mode); |
| 5544 |
|
|
| 5545 |
|
## F3. Create an HTML parser |
| 5546 |
my $p = $class->new; |
my $p = $class->new; |
| 5547 |
$p->{document} = $doc; |
$p->{document} = $doc; |
| 5548 |
|
|
| 5670 |
$p->_initialize_tokenizer; |
$p->_initialize_tokenizer; |
| 5671 |
$p->_initialize_tree_constructor; |
$p->_initialize_tree_constructor; |
| 5672 |
|
|
| 5673 |
## Step 2 |
## F4. If /context/ is not undef... |
| 5674 |
|
|
| 5675 |
|
## F4.1. content model flag |
| 5676 |
my $node_ln = $node->manakai_local_name; |
my $node_ln = $node->manakai_local_name; |
| 5677 |
$p->{content_model} = { |
$p->{content_model} = { |
| 5678 |
title => RCDATA_CONTENT_MODEL, |
title => RCDATA_CONTENT_MODEL, |
| 5692 |
$p->{inner_html_node} = [$node, $el_category->{$node_ln}]; |
$p->{inner_html_node} = [$node, $el_category->{$node_ln}]; |
| 5693 |
## TODO: Foreign element OK? |
## TODO: Foreign element OK? |
| 5694 |
|
|
| 5695 |
## Step 3 |
## F4.2. Root |html| element |
| 5696 |
my $root = $doc->create_element_ns |
my $root = $doc->create_element_ns |
| 5697 |
('http://www.w3.org/1999/xhtml', [undef, 'html']); |
('http://www.w3.org/1999/xhtml', [undef, 'html']); |
| 5698 |
|
|
| 5699 |
## Step 4 # MUST |
## F4.3. |
| 5700 |
$doc->append_child ($root); |
$doc->append_child ($root); |
| 5701 |
|
|
| 5702 |
## Step 5 # MUST |
## F4.4. |
| 5703 |
push @{$p->{open_elements}}, [$root, $el_category->{html}]; |
push @{$p->{open_elements}}, [$root, $el_category->{html}]; |
| 5704 |
|
|
| 5705 |
undef $p->{head_element}; |
undef $p->{head_element}; |
| 5706 |
undef $p->{head_element_inserted}; |
undef $p->{head_element_inserted}; |
| 5707 |
|
|
| 5708 |
## Step 6 # MUST |
## F4.5. |
| 5709 |
$p->_reset_insertion_mode; |
$p->_reset_insertion_mode; |
| 5710 |
|
|
| 5711 |
## Step 7 # MUST |
## F4.6. |
| 5712 |
my $anode = $node; |
my $anode = $node; |
| 5713 |
AN: while (defined $anode) { |
AN: while (defined $anode) { |
| 5714 |
if ($anode->node_type == 1) { |
if ($anode->node_type == 1) { |
| 5723 |
} |
} |
| 5724 |
$anode = $anode->parent_node; |
$anode = $anode->parent_node; |
| 5725 |
} # AN |
} # AN |
| 5726 |
|
|
| 5727 |
## Step 9 # MUST |
## F.6. Start the parser. |
| 5728 |
{ |
{ |
| 5729 |
my $self = $p; |
my $self = $p; |
| 5730 |
!!!next-token; |
!!!next-token; |
| 5731 |
} |
} |
| 5732 |
$p->_tree_construction_main; |
$p->_tree_construction_main; |
| 5733 |
|
|
| 5734 |
## Step 10 # MUST |
## F.7. |
| 5735 |
my @cn = @{$node->child_nodes}; |
my @cn = @{$node->child_nodes}; |
| 5736 |
for (@cn) { |
for (@cn) { |
| 5737 |
$node->remove_child ($_); |
$node->remove_child ($_); |