| 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 |
| 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] |
| 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', |
| 2500 |
## Ignore the token |
## Ignore the token |
| 2501 |
!!!next-token; |
!!!next-token; |
| 2502 |
next B; |
next B; |
| 2503 |
} elsif ($token->{tag_name} eq 'br') { |
} elsif ($token->{tag_name} eq 'br') { |
| 2504 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 2505 |
!!!cp ('t142.2'); |
!!!cp ('t142.2'); |
| 2506 |
## (before head) as if <head>, (in head) as if </head> |
## (before head) as if <head>, (in head) as if </head> |
| 2507 |
!!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token); |
!!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token); |
| 2508 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 2509 |
$self->{insertion_mode} = AFTER_HEAD_IM; |
$self->{insertion_mode} = AFTER_HEAD_IM; |
| 2510 |
|
|
| 2511 |
## Reprocess in the "after head" insertion mode... |
## Reprocess in the "after head" insertion mode... |
| 2512 |
} elsif ($self->{insertion_mode} == IN_HEAD_IM) { |
} elsif ($self->{insertion_mode} == IN_HEAD_IM) { |
| 2513 |
!!!cp ('t143.2'); |
!!!cp ('t143.2'); |
| 2514 |
## As if </head> |
## As if </head> |
| 2515 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 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_NOSCRIPT_IM) { |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 2520 |
!!!cp ('t143.3'); |
!!!cp ('t143.3'); |
| 2521 |
## NOTE: Two parse errors for <head><noscript></br> |
## NOTE: Two parse errors for <head><noscript></br> |
| 2522 |
!!!parse-error (type => 'unmatched end tag', |
!!!parse-error (type => 'unmatched end tag', |
| 2523 |
text => 'br', token => $token); |
text => 'br', token => $token); |
| 2524 |
## As if </noscript> |
## As if </noscript> |
| 2525 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 2526 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 2527 |
|
|
| 2528 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 2529 |
## As if </head> |
## As if </head> |
| 2530 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 2531 |
$self->{insertion_mode} = AFTER_HEAD_IM; |
$self->{insertion_mode} = AFTER_HEAD_IM; |
| 2532 |
|
|
| 2533 |
## Reprocess in the "after head" insertion mode... |
## Reprocess in the "after head" insertion mode... |
| 2534 |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 2535 |
!!!cp ('t143.4'); |
!!!cp ('t143.4'); |
| 2536 |
# |
# |
| 2537 |
} else { |
} else { |
| 2538 |
die "$0: $self->{insertion_mode}: Unknown insertion mode"; |
die "$0: $self->{insertion_mode}: Unknown insertion mode"; |
| 2539 |
} |
} |
| 2540 |
|
|
| 2541 |
## ISSUE: does not agree with IE7 - it doesn't ignore </br>. |
# |
| 2542 |
!!!parse-error (type => 'unmatched end tag', |
} else { ## Other end tags |
|
text => 'br', token => $token); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
next B; |
|
|
} else { |
|
| 2543 |
!!!cp ('t145'); |
!!!cp ('t145'); |
| 2544 |
!!!parse-error (type => 'unmatched end tag', |
!!!parse-error (type => 'unmatched end tag', |
| 2545 |
text => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
| 2583 |
!!!insert-element ('body',, $token); |
!!!insert-element ('body',, $token); |
| 2584 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 2585 |
## reprocess |
## reprocess |
| 2586 |
next B; |
next B; |
| 2587 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 2588 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 2589 |
!!!cp ('t149.1'); |
!!!cp ('t149.1'); |
| 3840 |
!!!next-token; |
!!!next-token; |
| 3841 |
next B; |
next B; |
| 3842 |
} elsif ({ |
} elsif ({ |
| 3843 |
select => 1, input => 1, textarea => 1, |
select => 1, input => 1, textarea => 1, keygen => 1, |
| 3844 |
}->{$token->{tag_name}} or |
}->{$token->{tag_name}} or |
| 3845 |
(($self->{insertion_mode} & IM_MASK) |
(($self->{insertion_mode} & IM_MASK) |
| 3846 |
== IN_SELECT_IN_TABLE_IM and |
== IN_SELECT_IN_TABLE_IM and |
| 3849 |
tbody => 1, tfoot => 1, thead => 1, |
tbody => 1, tfoot => 1, thead => 1, |
| 3850 |
tr => 1, td => 1, th => 1, |
tr => 1, td => 1, th => 1, |
| 3851 |
}->{$token->{tag_name}})) { |
}->{$token->{tag_name}})) { |
| 3852 |
## TODO: The type below is not good - <select> is replaced by </select> |
|
| 3853 |
!!!parse-error (type => 'not closed', text => 'select', |
## 1. Parse error. |
| 3854 |
token => $token); |
if ($token->{tag_name} eq 'select') { |
| 3855 |
## NOTE: As if the token were </select> (<select> case) or |
!!!parse-error (type => 'select in select', ## XXX: documentation |
| 3856 |
## as if there were </select> (otherwise). |
token => $token); |
| 3857 |
## have an element in table scope |
} else { |
| 3858 |
|
!!!parse-error (type => 'not closed', text => 'select', |
| 3859 |
|
token => $token); |
| 3860 |
|
} |
| 3861 |
|
|
| 3862 |
|
## 2./<select>-1. Unless "have an element in table scope" (select): |
| 3863 |
my $i; |
my $i; |
| 3864 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3865 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 3874 |
} # INSCOPE |
} # INSCOPE |
| 3875 |
unless (defined $i) { |
unless (defined $i) { |
| 3876 |
!!!cp ('t280'); |
!!!cp ('t280'); |
| 3877 |
!!!parse-error (type => 'unmatched end tag', |
if ($token->{tag_name} eq 'select') { |
| 3878 |
text => 'select', token => $token); |
## NOTE: This error would be raised when |
| 3879 |
## Ignore the token |
## |select.innerHTML = '<select>'| is executed; in this |
| 3880 |
|
## case two errors, "select in select" and "unmatched |
| 3881 |
|
## end tags" are reported to the user, the latter might |
| 3882 |
|
## be confusing but this is what the spec requires. |
| 3883 |
|
!!!parse-error (type => 'unmatched end tag', |
| 3884 |
|
text => 'select', |
| 3885 |
|
token => $token); |
| 3886 |
|
} |
| 3887 |
|
## Ignore the token. |
| 3888 |
!!!nack ('t280.1'); |
!!!nack ('t280.1'); |
| 3889 |
!!!next-token; |
!!!next-token; |
| 3890 |
next B; |
next B; |
| 3891 |
} |
} |
| 3892 |
|
|
| 3893 |
|
## 3. Otherwise, as if there were <select>: |
| 3894 |
|
|
| 3895 |
!!!cp ('t281'); |
!!!cp ('t281'); |
| 3896 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 4435 |
next B; |
next B; |
| 4436 |
} |
} |
| 4437 |
|
|
| 4438 |
## has a p element in scope |
if ($token->{tag_name} ne 'table' or # The Hixie Quirk |
| 4439 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
$self->{document}->manakai_compat_mode ne 'quirks') { |
| 4440 |
if ($_->[1] == P_EL) { |
## has a p element in scope |
| 4441 |
!!!cp ('t344'); |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 4442 |
!!!back-token; # <form> |
if ($_->[1] == P_EL) { |
| 4443 |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
!!!cp ('t344'); |
| 4444 |
line => $token->{line}, column => $token->{column}}; |
!!!back-token; # <form> |
| 4445 |
next B; |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
| 4446 |
} elsif ($_->[1] & SCOPING_EL) { |
line => $token->{line}, column => $token->{column}}; |
| 4447 |
!!!cp ('t345'); |
next B; |
| 4448 |
last INSCOPE; |
} elsif ($_->[1] & SCOPING_EL) { |
| 4449 |
} |
!!!cp ('t345'); |
| 4450 |
} # INSCOPE |
last INSCOPE; |
| 4451 |
|
} |
| 4452 |
|
} # INSCOPE |
| 4453 |
|
} |
| 4454 |
|
|
| 4455 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 4456 |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
| 4852 |
next B; |
next B; |
| 4853 |
} |
} |
| 4854 |
} elsif ($token->{tag_name} eq 'textarea') { |
} elsif ($token->{tag_name} eq 'textarea') { |
| 4855 |
## Step 1 |
## 1. Insert |
| 4856 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 4857 |
|
|
| 4858 |
## Step 2 |
## Step 2 # XXX |
| 4859 |
## TODO: $self->{form_element} if defined |
## TODO: $self->{form_element} if defined |
| 4860 |
|
|
| 4861 |
## Step 3 |
## 2. Drop U+000A LINE FEED |
| 4862 |
$self->{ignore_newline} = 1; |
$self->{ignore_newline} = 1; |
| 4863 |
|
|
| 4864 |
## Step 4 |
## 3. RCDATA |
|
## ISSUE: This step is wrong. (r2302 enbugged) |
|
|
|
|
|
## Step 5 |
|
| 4865 |
$self->{content_model} = RCDATA_CONTENT_MODEL; |
$self->{content_model} = RCDATA_CONTENT_MODEL; |
| 4866 |
delete $self->{escape}; # MUST |
delete $self->{escape}; # MUST |
| 4867 |
|
|
| 4868 |
## Step 6-7 |
## 4., 6. Insertion mode |
| 4869 |
$self->{insertion_mode} |= IN_CDATA_RCDATA_IM; |
$self->{insertion_mode} |= IN_CDATA_RCDATA_IM; |
| 4870 |
|
|
| 4871 |
|
## XXX: 5. frameset-ok flag |
| 4872 |
|
|
| 4873 |
!!!nack ('t392.1'); |
!!!nack ('t392.1'); |
| 4874 |
!!!next-token; |
!!!next-token; |
| 4875 |
next B; |
next B; |
| 5065 |
} # INSCOPE |
} # INSCOPE |
| 5066 |
|
|
| 5067 |
for (@{$self->{open_elements}}) { |
for (@{$self->{open_elements}}) { |
| 5068 |
unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL) { |
unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL || |
| 5069 |
|
$_->[1] == OPTGROUP_EL || |
| 5070 |
|
$_->[1] == OPTION_EL || |
| 5071 |
|
$_->[1] == RUBY_COMPONENT_EL) { |
| 5072 |
!!!cp ('t403'); |
!!!cp ('t403'); |
| 5073 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 5074 |
text => $_->[0]->manakai_local_name, |
text => $_->[0]->manakai_local_name, |
| 5465 |
## TODO: script stuffs |
## TODO: script stuffs |
| 5466 |
} # _tree_construct_main |
} # _tree_construct_main |
| 5467 |
|
|
| 5468 |
|
## XXX: How this method is organized is somewhat out of date, although |
| 5469 |
|
## it still does what the current spec documents. |
| 5470 |
sub set_inner_html ($$$$;$) { |
sub set_inner_html ($$$$;$) { |
| 5471 |
my $class = shift; |
my $class = shift; |
| 5472 |
my $node = shift; |
my $node = shift; # /context/ |
| 5473 |
#my $s = \$_[0]; |
#my $s = \$_[0]; |
| 5474 |
my $onerror = $_[1]; |
my $onerror = $_[1]; |
| 5475 |
my $get_wrapper = $_[2] || sub ($) { return $_[0] }; |
my $get_wrapper = $_[2] || sub ($) { return $_[0] }; |
| 5477 |
## ISSUE: Should {confident} be true? |
## ISSUE: Should {confident} be true? |
| 5478 |
|
|
| 5479 |
my $nt = $node->node_type; |
my $nt = $node->node_type; |
| 5480 |
if ($nt == 9) { |
if ($nt == 9) { # Document (invoke the algorithm with no /context/ element) |
| 5481 |
# MUST |
# MUST |
| 5482 |
|
|
| 5483 |
## Step 1 # MUST |
## Step 1 # MUST |
| 5492 |
|
|
| 5493 |
## Step 3, 4, 5 # MUST |
## Step 3, 4, 5 # MUST |
| 5494 |
$class->parse_char_string ($_[0] => $node, $onerror, $get_wrapper); |
$class->parse_char_string ($_[0] => $node, $onerror, $get_wrapper); |
| 5495 |
} elsif ($nt == 1) { |
} elsif ($nt == 1) { # Element (invoke the algorithm with /context/ element) |
| 5496 |
## TODO: If non-html element |
## TODO: If non-html element |
| 5497 |
|
|
| 5498 |
## NOTE: Most of this code is copied from |parse_string| |
## NOTE: Most of this code is copied from |parse_string| |
| 5499 |
|
|
| 5500 |
## TODO: Support for $get_wrapper |
## TODO: Support for $get_wrapper |
| 5501 |
|
|
| 5502 |
## Step 1 # MUST |
## F1. Create an HTML document. |
| 5503 |
my $this_doc = $node->owner_document; |
my $this_doc = $node->owner_document; |
| 5504 |
my $doc = $this_doc->implementation->create_document; |
my $doc = $this_doc->implementation->create_document; |
| 5505 |
$doc->manakai_is_html (1); |
$doc->manakai_is_html (1); |
| 5506 |
|
|
| 5507 |
|
## F2. Propagate quirkness flag |
| 5508 |
|
my $node_doc = $node->owner_document; |
| 5509 |
|
$doc->manakai_compat_mode ($node_doc->manakai_compat_mode); |
| 5510 |
|
|
| 5511 |
|
## F3. Create an HTML parser |
| 5512 |
my $p = $class->new; |
my $p = $class->new; |
| 5513 |
$p->{document} = $doc; |
$p->{document} = $doc; |
| 5514 |
|
|
| 5636 |
$p->_initialize_tokenizer; |
$p->_initialize_tokenizer; |
| 5637 |
$p->_initialize_tree_constructor; |
$p->_initialize_tree_constructor; |
| 5638 |
|
|
| 5639 |
## Step 2 |
## F4. If /context/ is not undef... |
| 5640 |
|
|
| 5641 |
|
## F4.1. content model flag |
| 5642 |
my $node_ln = $node->manakai_local_name; |
my $node_ln = $node->manakai_local_name; |
| 5643 |
$p->{content_model} = { |
$p->{content_model} = { |
| 5644 |
title => RCDATA_CONTENT_MODEL, |
title => RCDATA_CONTENT_MODEL, |
| 5658 |
$p->{inner_html_node} = [$node, $el_category->{$node_ln}]; |
$p->{inner_html_node} = [$node, $el_category->{$node_ln}]; |
| 5659 |
## TODO: Foreign element OK? |
## TODO: Foreign element OK? |
| 5660 |
|
|
| 5661 |
## Step 3 |
## F4.2. Root |html| element |
| 5662 |
my $root = $doc->create_element_ns |
my $root = $doc->create_element_ns |
| 5663 |
('http://www.w3.org/1999/xhtml', [undef, 'html']); |
('http://www.w3.org/1999/xhtml', [undef, 'html']); |
| 5664 |
|
|
| 5665 |
## Step 4 # MUST |
## F4.3. |
| 5666 |
$doc->append_child ($root); |
$doc->append_child ($root); |
| 5667 |
|
|
| 5668 |
## Step 5 # MUST |
## F4.4. |
| 5669 |
push @{$p->{open_elements}}, [$root, $el_category->{html}]; |
push @{$p->{open_elements}}, [$root, $el_category->{html}]; |
| 5670 |
|
|
| 5671 |
undef $p->{head_element}; |
undef $p->{head_element}; |
| 5672 |
undef $p->{head_element_inserted}; |
undef $p->{head_element_inserted}; |
| 5673 |
|
|
| 5674 |
## Step 6 # MUST |
## F4.5. |
| 5675 |
$p->_reset_insertion_mode; |
$p->_reset_insertion_mode; |
| 5676 |
|
|
| 5677 |
## Step 7 # MUST |
## F4.6. |
| 5678 |
my $anode = $node; |
my $anode = $node; |
| 5679 |
AN: while (defined $anode) { |
AN: while (defined $anode) { |
| 5680 |
if ($anode->node_type == 1) { |
if ($anode->node_type == 1) { |
| 5689 |
} |
} |
| 5690 |
$anode = $anode->parent_node; |
$anode = $anode->parent_node; |
| 5691 |
} # AN |
} # AN |
| 5692 |
|
|
| 5693 |
## Step 9 # MUST |
## F.6. Start the parser. |
| 5694 |
{ |
{ |
| 5695 |
my $self = $p; |
my $self = $p; |
| 5696 |
!!!next-token; |
!!!next-token; |
| 5697 |
} |
} |
| 5698 |
$p->_tree_construction_main; |
$p->_tree_construction_main; |
| 5699 |
|
|
| 5700 |
## Step 10 # MUST |
## F.7. |
| 5701 |
my @cn = @{$node->child_nodes}; |
my @cn = @{$node->child_nodes}; |
| 5702 |
for (@cn) { |
for (@cn) { |
| 5703 |
$node->remove_child ($_); |
$node->remove_child ($_); |