| 1956 |
} |
} |
| 1957 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 1958 |
## NOTE: "using the rules for secondary insertion mode" then "continue" |
## NOTE: "using the rules for secondary insertion mode" then "continue" |
| 1959 |
!!!cp ('t87.5'); |
if ($token->{tag_name} eq 'script') { |
| 1960 |
# |
!!!cp ('t87.41'); |
| 1961 |
|
# |
| 1962 |
|
## XXXscript: Execute script here. |
| 1963 |
|
} else { |
| 1964 |
|
!!!cp ('t87.5'); |
| 1965 |
|
# |
| 1966 |
|
} |
| 1967 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 1968 |
!!!cp ('t87.6'); |
!!!cp ('t87.6'); |
| 1969 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 4423 |
next B; |
next B; |
| 4424 |
} |
} |
| 4425 |
|
|
| 4426 |
## has a p element in scope |
if ($token->{tag_name} ne 'table' or # The Hixie Quirk |
| 4427 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
$self->{document}->manakai_compat_mode ne 'quirks') { |
| 4428 |
if ($_->[1] == P_EL) { |
## has a p element in scope |
| 4429 |
!!!cp ('t344'); |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 4430 |
!!!back-token; # <form> |
if ($_->[1] == P_EL) { |
| 4431 |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
!!!cp ('t344'); |
| 4432 |
line => $token->{line}, column => $token->{column}}; |
!!!back-token; # <form> |
| 4433 |
next B; |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
| 4434 |
} elsif ($_->[1] & SCOPING_EL) { |
line => $token->{line}, column => $token->{column}}; |
| 4435 |
!!!cp ('t345'); |
next B; |
| 4436 |
last INSCOPE; |
} elsif ($_->[1] & SCOPING_EL) { |
| 4437 |
} |
!!!cp ('t345'); |
| 4438 |
} # INSCOPE |
last INSCOPE; |
| 4439 |
|
} |
| 4440 |
|
} # INSCOPE |
| 4441 |
|
} |
| 4442 |
|
|
| 4443 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 4444 |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
| 5054 |
} # INSCOPE |
} # INSCOPE |
| 5055 |
|
|
| 5056 |
for (@{$self->{open_elements}}) { |
for (@{$self->{open_elements}}) { |
| 5057 |
unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL) { |
unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL || |
| 5058 |
|
$_->[1] == OPTGROUP_EL || |
| 5059 |
|
$_->[1] == OPTION_EL || |
| 5060 |
|
$_->[1] == RUBY_COMPONENT_EL) { |
| 5061 |
!!!cp ('t403'); |
!!!cp ('t403'); |
| 5062 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
| 5063 |
text => $_->[0]->manakai_local_name, |
text => $_->[0]->manakai_local_name, |
| 5454 |
## TODO: script stuffs |
## TODO: script stuffs |
| 5455 |
} # _tree_construct_main |
} # _tree_construct_main |
| 5456 |
|
|
| 5457 |
|
## XXX: How this method is organized is somewhat out of date, although |
| 5458 |
|
## it still does what the current spec documents. |
| 5459 |
sub set_inner_html ($$$$;$) { |
sub set_inner_html ($$$$;$) { |
| 5460 |
my $class = shift; |
my $class = shift; |
| 5461 |
my $node = shift; |
my $node = shift; # /context/ |
| 5462 |
#my $s = \$_[0]; |
#my $s = \$_[0]; |
| 5463 |
my $onerror = $_[1]; |
my $onerror = $_[1]; |
| 5464 |
my $get_wrapper = $_[2] || sub ($) { return $_[0] }; |
my $get_wrapper = $_[2] || sub ($) { return $_[0] }; |
| 5466 |
## ISSUE: Should {confident} be true? |
## ISSUE: Should {confident} be true? |
| 5467 |
|
|
| 5468 |
my $nt = $node->node_type; |
my $nt = $node->node_type; |
| 5469 |
if ($nt == 9) { |
if ($nt == 9) { # Document (invoke the algorithm with no /context/ element) |
| 5470 |
# MUST |
# MUST |
| 5471 |
|
|
| 5472 |
## Step 1 # MUST |
## Step 1 # MUST |
| 5481 |
|
|
| 5482 |
## Step 3, 4, 5 # MUST |
## Step 3, 4, 5 # MUST |
| 5483 |
$class->parse_char_string ($_[0] => $node, $onerror, $get_wrapper); |
$class->parse_char_string ($_[0] => $node, $onerror, $get_wrapper); |
| 5484 |
} elsif ($nt == 1) { |
} elsif ($nt == 1) { # Element (invoke the algorithm with /context/ element) |
| 5485 |
## TODO: If non-html element |
## TODO: If non-html element |
| 5486 |
|
|
| 5487 |
## NOTE: Most of this code is copied from |parse_string| |
## NOTE: Most of this code is copied from |parse_string| |
| 5488 |
|
|
| 5489 |
## TODO: Support for $get_wrapper |
## TODO: Support for $get_wrapper |
| 5490 |
|
|
| 5491 |
## Step 1 # MUST |
## F1. Create an HTML document. |
| 5492 |
my $this_doc = $node->owner_document; |
my $this_doc = $node->owner_document; |
| 5493 |
my $doc = $this_doc->implementation->create_document; |
my $doc = $this_doc->implementation->create_document; |
| 5494 |
$doc->manakai_is_html (1); |
$doc->manakai_is_html (1); |
| 5495 |
|
|
| 5496 |
|
## F2. Propagate quirkness flag |
| 5497 |
|
my $node_doc = $node->owner_document; |
| 5498 |
|
$doc->manakai_compat_mode ($node_doc->manakai_compat_mode); |
| 5499 |
|
|
| 5500 |
|
## F3. Create an HTML parser |
| 5501 |
my $p = $class->new; |
my $p = $class->new; |
| 5502 |
$p->{document} = $doc; |
$p->{document} = $doc; |
| 5503 |
|
|
| 5625 |
$p->_initialize_tokenizer; |
$p->_initialize_tokenizer; |
| 5626 |
$p->_initialize_tree_constructor; |
$p->_initialize_tree_constructor; |
| 5627 |
|
|
| 5628 |
## Step 2 |
## F4. If /context/ is not undef... |
| 5629 |
|
|
| 5630 |
|
## F4.1. content model flag |
| 5631 |
my $node_ln = $node->manakai_local_name; |
my $node_ln = $node->manakai_local_name; |
| 5632 |
$p->{content_model} = { |
$p->{content_model} = { |
| 5633 |
title => RCDATA_CONTENT_MODEL, |
title => RCDATA_CONTENT_MODEL, |
| 5647 |
$p->{inner_html_node} = [$node, $el_category->{$node_ln}]; |
$p->{inner_html_node} = [$node, $el_category->{$node_ln}]; |
| 5648 |
## TODO: Foreign element OK? |
## TODO: Foreign element OK? |
| 5649 |
|
|
| 5650 |
## Step 3 |
## F4.2. Root |html| element |
| 5651 |
my $root = $doc->create_element_ns |
my $root = $doc->create_element_ns |
| 5652 |
('http://www.w3.org/1999/xhtml', [undef, 'html']); |
('http://www.w3.org/1999/xhtml', [undef, 'html']); |
| 5653 |
|
|
| 5654 |
## Step 4 # MUST |
## F4.3. |
| 5655 |
$doc->append_child ($root); |
$doc->append_child ($root); |
| 5656 |
|
|
| 5657 |
## Step 5 # MUST |
## F4.4. |
| 5658 |
push @{$p->{open_elements}}, [$root, $el_category->{html}]; |
push @{$p->{open_elements}}, [$root, $el_category->{html}]; |
| 5659 |
|
|
| 5660 |
undef $p->{head_element}; |
undef $p->{head_element}; |
| 5661 |
undef $p->{head_element_inserted}; |
undef $p->{head_element_inserted}; |
| 5662 |
|
|
| 5663 |
## Step 6 # MUST |
## F4.5. |
| 5664 |
$p->_reset_insertion_mode; |
$p->_reset_insertion_mode; |
| 5665 |
|
|
| 5666 |
## Step 7 # MUST |
## F4.6. |
| 5667 |
my $anode = $node; |
my $anode = $node; |
| 5668 |
AN: while (defined $anode) { |
AN: while (defined $anode) { |
| 5669 |
if ($anode->node_type == 1) { |
if ($anode->node_type == 1) { |
| 5678 |
} |
} |
| 5679 |
$anode = $anode->parent_node; |
$anode = $anode->parent_node; |
| 5680 |
} # AN |
} # AN |
| 5681 |
|
|
| 5682 |
## Step 9 # MUST |
## F.6. Start the parser. |
| 5683 |
{ |
{ |
| 5684 |
my $self = $p; |
my $self = $p; |
| 5685 |
!!!next-token; |
!!!next-token; |
| 5686 |
} |
} |
| 5687 |
$p->_tree_construction_main; |
$p->_tree_construction_main; |
| 5688 |
|
|
| 5689 |
## Step 10 # MUST |
## F.7. |
| 5690 |
my @cn = @{$node->child_nodes}; |
my @cn = @{$node->child_nodes}; |
| 5691 |
for (@cn) { |
for (@cn) { |
| 5692 |
$node->remove_child ($_); |
$node->remove_child ($_); |