| 179 |
dt => DTDD_EL, |
dt => DTDD_EL, |
| 180 |
em => FORMATTING_EL, |
em => FORMATTING_EL, |
| 181 |
embed => MISC_SPECIAL_EL, |
embed => MISC_SPECIAL_EL, |
|
eventsource => MISC_SPECIAL_EL, |
|
| 182 |
fieldset => MISC_SPECIAL_EL, |
fieldset => MISC_SPECIAL_EL, |
| 183 |
figure => MISC_SPECIAL_EL, |
figure => MISC_SPECIAL_EL, |
| 184 |
font => FORMATTING_EL, |
font => FORMATTING_EL, |
| 202 |
#image => MISC_SPECIAL_EL, ## NOTE: Commented out in the spec. |
#image => MISC_SPECIAL_EL, ## NOTE: Commented out in the spec. |
| 203 |
input => MISC_SPECIAL_EL, |
input => MISC_SPECIAL_EL, |
| 204 |
isindex => MISC_SPECIAL_EL, |
isindex => MISC_SPECIAL_EL, |
| 205 |
|
## XXX keygen? (Whether a void element is in Special or not does not |
| 206 |
|
## affect to the processing, however.) |
| 207 |
li => LI_EL, |
li => LI_EL, |
| 208 |
link => MISC_SPECIAL_EL, |
link => MISC_SPECIAL_EL, |
| 209 |
listing => MISC_SPECIAL_EL, |
listing => MISC_SPECIAL_EL, |
| 1439 |
}; # $script_start_tag |
}; # $script_start_tag |
| 1440 |
|
|
| 1441 |
## NOTE: $open_tables->[-1]->[0] is the "current table" element node. |
## NOTE: $open_tables->[-1]->[0] is the "current table" element node. |
| 1442 |
## NOTE: $open_tables->[-1]->[1] is the "tainted" flag. |
## NOTE: $open_tables->[-1]->[1] is the "tainted" flag (OBSOLETE; unused). |
| 1443 |
## NOTE: $open_tables->[-1]->[2] is set false when non-Text node inserted. |
## NOTE: $open_tables->[-1]->[2] is set false when non-Text node inserted. |
| 1444 |
my $open_tables = [[$self->{open_elements}->[0]->[0]]]; |
my $open_tables = [[$self->{open_elements}->[0]->[0]]]; |
| 1445 |
|
|
| 1609 |
|
|
| 1610 |
## Step 8 |
## Step 8 |
| 1611 |
if ($common_ancestor_node->[1] & TABLE_ROWS_EL) { |
if ($common_ancestor_node->[1] & TABLE_ROWS_EL) { |
| 1612 |
|
## Foster parenting. |
| 1613 |
my $foster_parent_element; |
my $foster_parent_element; |
| 1614 |
my $next_sibling; |
my $next_sibling; |
| 1615 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
| 1616 |
if ($self->{open_elements}->[$_]->[1] == TABLE_EL) { |
if ($self->{open_elements}->[$_]->[1] == TABLE_EL) { |
| 1617 |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
!!!cp ('t65.2'); |
| 1618 |
if (defined $parent and $parent->node_type == 1) { |
$foster_parent_element = $self->{open_elements}->[$_ - 1]->[0]; |
| 1619 |
!!!cp ('t65.1'); |
$next_sibling = $self->{open_elements}->[$_]->[0]; |
| 1620 |
$foster_parent_element = $parent; |
undef $next_sibling |
| 1621 |
$next_sibling = $self->{open_elements}->[$_]->[0]; |
unless $next_sibling->parent_node eq $foster_parent_element; |
| 1622 |
} else { |
last OE; |
| 1623 |
!!!cp ('t65.2'); |
} |
| 1624 |
$foster_parent_element |
} # OE |
| 1625 |
= $self->{open_elements}->[$_ - 1]->[0]; |
$foster_parent_element ||= $self->{open_elements}->[0]->[0]; |
| 1626 |
} |
|
|
last OE; |
|
|
} |
|
|
} # OE |
|
|
$foster_parent_element = $self->{open_elements}->[0]->[0] |
|
|
unless defined $foster_parent_element; |
|
| 1627 |
$foster_parent_element->insert_before ($last_node->[0], $next_sibling); |
$foster_parent_element->insert_before ($last_node->[0], $next_sibling); |
| 1628 |
$open_tables->[-1]->[1] = 1; # tainted |
$open_tables->[-1]->[1] = 1; # tainted |
| 1629 |
} else { |
} else { |
| 1679 |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
| 1680 |
}; # $insert_to_current |
}; # $insert_to_current |
| 1681 |
|
|
| 1682 |
|
## Foster parenting. Note that there are three "foster parenting" |
| 1683 |
|
## code in the parser: for elements (this one), for texts, and for |
| 1684 |
|
## elements in the AAA code. |
| 1685 |
my $insert_to_foster = sub { |
my $insert_to_foster = sub { |
| 1686 |
my $child = shift; |
my $child = shift; |
| 1687 |
if ($self->{open_elements}->[-1]->[1] & TABLE_ROWS_EL) { |
if ($self->{open_elements}->[-1]->[1] & TABLE_ROWS_EL) { |
| 1690 |
my $next_sibling; |
my $next_sibling; |
| 1691 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
| 1692 |
if ($self->{open_elements}->[$_]->[1] == TABLE_EL) { |
if ($self->{open_elements}->[$_]->[1] == TABLE_EL) { |
| 1693 |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
!!!cp ('t71'); |
| 1694 |
if (defined $parent and $parent->node_type == 1) { |
$foster_parent_element = $self->{open_elements}->[$_ - 1]->[0]; |
| 1695 |
!!!cp ('t70'); |
$next_sibling = $self->{open_elements}->[$_]->[0]; |
| 1696 |
$foster_parent_element = $parent; |
undef $next_sibling |
| 1697 |
$next_sibling = $self->{open_elements}->[$_]->[0]; |
unless $next_sibling->parent_node eq $foster_parent_element; |
| 1698 |
} else { |
last OE; |
| 1699 |
!!!cp ('t71'); |
} |
| 1700 |
$foster_parent_element |
} # OE |
| 1701 |
= $self->{open_elements}->[$_ - 1]->[0]; |
$foster_parent_element ||= $self->{open_elements}->[0]->[0]; |
| 1702 |
} |
|
| 1703 |
last OE; |
$foster_parent_element->insert_before ($child, $next_sibling); |
|
} |
|
|
} # OE |
|
|
$foster_parent_element = $self->{open_elements}->[0]->[0] |
|
|
unless defined $foster_parent_element; |
|
|
$foster_parent_element->insert_before |
|
|
($child, $next_sibling); |
|
| 1704 |
$open_tables->[-1]->[1] = 1; # tainted |
$open_tables->[-1]->[1] = 1; # tainted |
| 1705 |
} else { |
} else { |
| 1706 |
!!!cp ('t72'); |
!!!cp ('t72'); |
| 1728 |
## document.write ("b")</script>| |
## document.write ("b")</script>| |
| 1729 |
|
|
| 1730 |
B: while (1) { |
B: while (1) { |
| 1731 |
|
|
| 1732 |
|
## The "in table text" insertion mode. |
| 1733 |
|
if ($self->{insertion_mode} & TABLE_IMS and |
| 1734 |
|
not $self->{insertion_mode} & IN_FOREIGN_CONTENT_IM and |
| 1735 |
|
not $self->{insertion_mode} & IN_CDATA_RCDATA_IM) { |
| 1736 |
|
C: { |
| 1737 |
|
my $s; |
| 1738 |
|
if ($token->{type} == CHARACTER_TOKEN) { |
| 1739 |
|
!!!cp ('t194'); |
| 1740 |
|
$self->{pending_chars} ||= []; |
| 1741 |
|
push @{$self->{pending_chars}}, $token; |
| 1742 |
|
!!!next-token; |
| 1743 |
|
next B; |
| 1744 |
|
} else { |
| 1745 |
|
if ($self->{pending_chars}) { |
| 1746 |
|
$s = join '', map { $_->{data} } @{$self->{pending_chars}}; |
| 1747 |
|
delete $self->{pending_chars}; |
| 1748 |
|
if ($s =~ /[^\x09\x0A\x0C\x0D\x20]/) { |
| 1749 |
|
!!!cp ('t195'); |
| 1750 |
|
# |
| 1751 |
|
} else { |
| 1752 |
|
!!!cp ('t195.1'); |
| 1753 |
|
#$self->{open_elements}->[-1]->[0]->manakai_append_text ($s); |
| 1754 |
|
$self->{open_elements}->[-1]->[0]->append_child |
| 1755 |
|
($self->{document}->create_text_node ($s)); |
| 1756 |
|
last C; |
| 1757 |
|
} |
| 1758 |
|
} else { |
| 1759 |
|
!!!cp ('t195.2'); |
| 1760 |
|
last C; |
| 1761 |
|
} |
| 1762 |
|
} |
| 1763 |
|
|
| 1764 |
|
## Foster parenting. |
| 1765 |
|
!!!parse-error (type => 'in table:#text', token => $token); |
| 1766 |
|
|
| 1767 |
|
## NOTE: As if in body, but insert into the foster parent element. |
| 1768 |
|
$reconstruct_active_formatting_elements->($insert_to_foster); |
| 1769 |
|
|
| 1770 |
|
if ($self->{open_elements}->[-1]->[1] & TABLE_ROWS_EL) { |
| 1771 |
|
# MUST |
| 1772 |
|
my $foster_parent_element; |
| 1773 |
|
my $next_sibling; |
| 1774 |
|
OE: for (reverse 0..$#{$self->{open_elements}}) { |
| 1775 |
|
if ($self->{open_elements}->[$_]->[1] == TABLE_EL) { |
| 1776 |
|
!!!cp ('t197'); |
| 1777 |
|
$foster_parent_element = $self->{open_elements}->[$_ - 1]->[0]; |
| 1778 |
|
$next_sibling = $self->{open_elements}->[$_]->[0]; |
| 1779 |
|
undef $next_sibling |
| 1780 |
|
unless $next_sibling->parent_node eq $foster_parent_element; |
| 1781 |
|
last OE; |
| 1782 |
|
} |
| 1783 |
|
} # OE |
| 1784 |
|
$foster_parent_element ||= $self->{open_elements}->[0]->[0]; |
| 1785 |
|
|
| 1786 |
|
!!!cp ('t199'); |
| 1787 |
|
$foster_parent_element->insert_before |
| 1788 |
|
($self->{document}->create_text_node ($s), $next_sibling); |
| 1789 |
|
|
| 1790 |
|
$open_tables->[-1]->[1] = 1; # tainted |
| 1791 |
|
$open_tables->[-1]->[2] = 1; # ~node inserted |
| 1792 |
|
} else { |
| 1793 |
|
## NOTE: Fragment case or in a foster parent'ed element |
| 1794 |
|
## (e.g. |<table><span>a|). In fragment case, whether the |
| 1795 |
|
## character is appended to existing node or a new node is |
| 1796 |
|
## created is irrelevant, since the foster parent'ed nodes |
| 1797 |
|
## are discarded and fragment parsing does not invoke any |
| 1798 |
|
## script. |
| 1799 |
|
!!!cp ('t200'); |
| 1800 |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($s); |
| 1801 |
|
} |
| 1802 |
|
} # C |
| 1803 |
|
} # TABLE_IMS |
| 1804 |
|
|
| 1805 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
| 1806 |
!!!cp ('t73'); |
!!!cp ('t73'); |
| 1807 |
!!!parse-error (type => 'in html:#DOCTYPE', token => $token); |
!!!parse-error (type => 'in html:#DOCTYPE', token => $token); |
| 2220 |
!!!ack ('t103.1'); |
!!!ack ('t103.1'); |
| 2221 |
!!!next-token; |
!!!next-token; |
| 2222 |
next B; |
next B; |
| 2223 |
} elsif ($token->{tag_name} eq 'command' or |
} elsif ($token->{tag_name} eq 'command') { |
|
$token->{tag_name} eq 'eventsource') { |
|
| 2224 |
if ($self->{insertion_mode} == IN_HEAD_IM) { |
if ($self->{insertion_mode} == IN_HEAD_IM) { |
| 2225 |
## NOTE: If the insertion mode at the time of the emission |
## NOTE: If the insertion mode at the time of the emission |
| 2226 |
## of the token was "before head", $self->{insertion_mode} |
## of the token was "before head", $self->{insertion_mode} |
| 3088 |
$insert = $insert_to_current; |
$insert = $insert_to_current; |
| 3089 |
# |
# |
| 3090 |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
| 3091 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == START_TAG_TOKEN) { |
|
if (not $open_tables->[-1]->[1] and # tainted |
|
|
$token->{data} =~ s/^([\x09\x0A\x0C\x20]+)//) { |
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
|
|
|
|
|
unless (length $token->{data}) { |
|
|
!!!cp ('t194'); |
|
|
!!!next-token; |
|
|
next B; |
|
|
} else { |
|
|
!!!cp ('t195'); |
|
|
} |
|
|
} |
|
|
|
|
|
!!!parse-error (type => 'in table:#text', token => $token); |
|
|
|
|
|
## NOTE: As if in body, but insert into the foster parent element. |
|
|
$reconstruct_active_formatting_elements->($insert_to_foster); |
|
|
|
|
|
if ($self->{open_elements}->[-1]->[1] & TABLE_ROWS_EL) { |
|
|
# MUST |
|
|
my $foster_parent_element; |
|
|
my $next_sibling; |
|
|
my $prev_sibling; |
|
|
OE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
if ($self->{open_elements}->[$_]->[1] == TABLE_EL) { |
|
|
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
|
|
if (defined $parent and $parent->node_type == 1) { |
|
|
$foster_parent_element = $parent; |
|
|
!!!cp ('t196'); |
|
|
$next_sibling = $self->{open_elements}->[$_]->[0]; |
|
|
$prev_sibling = $next_sibling->previous_sibling; |
|
|
# |
|
|
} else { |
|
|
!!!cp ('t197'); |
|
|
$foster_parent_element = $self->{open_elements}->[$_ - 1]->[0]; |
|
|
$prev_sibling = $foster_parent_element->last_child; |
|
|
# |
|
|
} |
|
|
last OE; |
|
|
} |
|
|
} # OE |
|
|
$foster_parent_element = $self->{open_elements}->[0]->[0] and |
|
|
$prev_sibling = $foster_parent_element->last_child |
|
|
unless defined $foster_parent_element; |
|
|
undef $prev_sibling unless $open_tables->[-1]->[2]; # ~node inserted |
|
|
if (defined $prev_sibling and |
|
|
$prev_sibling->node_type == 3) { |
|
|
!!!cp ('t198'); |
|
|
$prev_sibling->manakai_append_text ($token->{data}); |
|
|
} else { |
|
|
!!!cp ('t199'); |
|
|
$foster_parent_element->insert_before |
|
|
($self->{document}->create_text_node ($token->{data}), |
|
|
$next_sibling); |
|
|
} |
|
|
$open_tables->[-1]->[1] = 1; # tainted |
|
|
$open_tables->[-1]->[2] = 1; # ~node inserted |
|
|
} else { |
|
|
## NOTE: Fragment case or in a foster parent'ed element |
|
|
## (e.g. |<table><span>a|). In fragment case, whether the |
|
|
## character is appended to existing node or a new node is |
|
|
## created is irrelevant, since the foster parent'ed nodes |
|
|
## are discarded and fragment parsing does not invoke any |
|
|
## script. |
|
|
!!!cp ('t200'); |
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text |
|
|
($token->{data}); |
|
|
} |
|
|
|
|
|
!!!next-token; |
|
|
next B; |
|
|
} elsif ($token->{type} == START_TAG_TOKEN) { |
|
| 3092 |
if ({ |
if ({ |
| 3093 |
tr => (($self->{insertion_mode} & IM_MASK) != IN_ROW_IM), |
tr => (($self->{insertion_mode} & IM_MASK) != IN_ROW_IM), |
| 3094 |
th => 1, td => 1, |
th => 1, td => 1, |
| 3356 |
!!!ack-later; |
!!!ack-later; |
| 3357 |
next B; |
next B; |
| 3358 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 3359 |
if (not $open_tables->[-1]->[1]) { # tainted |
!!!cp ('t227.8'); |
| 3360 |
!!!cp ('t227.8'); |
## NOTE: This is a "as if in head" code clone. |
| 3361 |
## NOTE: This is a "as if in head" code clone. |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 3362 |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
$open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted |
| 3363 |
$open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted |
next B; |
|
next B; |
|
|
} else { |
|
|
!!!cp ('t227.7'); |
|
|
# |
|
|
} |
|
| 3364 |
} elsif ($token->{tag_name} eq 'script') { |
} elsif ($token->{tag_name} eq 'script') { |
| 3365 |
if (not $open_tables->[-1]->[1]) { # tainted |
!!!cp ('t227.6'); |
| 3366 |
!!!cp ('t227.6'); |
## NOTE: This is a "as if in head" code clone. |
| 3367 |
## NOTE: This is a "as if in head" code clone. |
$script_start_tag->(); |
| 3368 |
$script_start_tag->(); |
$open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted |
| 3369 |
$open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted |
next B; |
|
next B; |
|
|
} else { |
|
|
!!!cp ('t227.5'); |
|
|
# |
|
|
} |
|
| 3370 |
} elsif ($token->{tag_name} eq 'input') { |
} elsif ($token->{tag_name} eq 'input') { |
| 3371 |
if (not $open_tables->[-1]->[1]) { # tainted |
if ($token->{attributes}->{type}) { |
| 3372 |
if ($token->{attributes}->{type}) { ## TODO: case |
my $type = $token->{attributes}->{type}->{value}; |
| 3373 |
my $type = lc $token->{attributes}->{type}->{value}; |
$type =~ tr/A-Z/a-z/; ## ASCII case-insensitive. |
| 3374 |
if ($type eq 'hidden') { |
if ($type eq 'hidden') { |
| 3375 |
!!!cp ('t227.3'); |
!!!cp ('t227.3'); |
| 3376 |
!!!parse-error (type => 'in table', |
!!!parse-error (type => 'in table', |
| 3377 |
text => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
| 3378 |
|
|
| 3379 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 3380 |
$open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted |
$open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted |
| 3381 |
|
|
| 3382 |
## TODO: form element pointer |
## TODO: form element pointer |
| 3383 |
|
|
| 3384 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3385 |
|
|
| 3386 |
!!!next-token; |
!!!next-token; |
| 3387 |
!!!ack ('t227.2.1'); |
!!!ack ('t227.2.1'); |
| 3388 |
next B; |
next B; |
|
} else { |
|
|
!!!cp ('t227.2'); |
|
|
# |
|
|
} |
|
| 3389 |
} else { |
} else { |
| 3390 |
!!!cp ('t227.1'); |
!!!cp ('t227.1'); |
| 3391 |
# |
# |
| 4314 |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 4315 |
next B; |
next B; |
| 4316 |
} elsif ({ |
} elsif ({ |
| 4317 |
base => 1, command => 1, eventsource => 1, link => 1, |
base => 1, command => 1, link => 1, |
| 4318 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4319 |
!!!cp ('t334'); |
!!!cp ('t334'); |
| 4320 |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
| 5026 |
} elsif ({ |
} elsif ({ |
| 5027 |
area => 1, basefont => 1, bgsound => 1, br => 1, |
area => 1, basefont => 1, bgsound => 1, br => 1, |
| 5028 |
embed => 1, img => 1, spacer => 1, wbr => 1, |
embed => 1, img => 1, spacer => 1, wbr => 1, |
| 5029 |
|
keygen => 1, |
| 5030 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5031 |
!!!cp ('t388.1'); |
!!!cp ('t388.1'); |
| 5032 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |