1734 |
## document.write ("b")</script>| |
## document.write ("b")</script>| |
1735 |
|
|
1736 |
B: while (1) { |
B: while (1) { |
1737 |
|
|
1738 |
|
## The "in table text" insertion mode. |
1739 |
|
if ($self->{insertion_mode} & TABLE_IMS and |
1740 |
|
not $self->{insertion_mode} & IN_FOREIGN_CONTENT_IM and |
1741 |
|
not $self->{insertion_mode} & IN_CDATA_RCDATA_IM) { |
1742 |
|
C: { |
1743 |
|
my $s; |
1744 |
|
if ($token->{type} == CHARACTER_TOKEN) { |
1745 |
|
!!!cp ('t194'); |
1746 |
|
$self->{pending_chars} ||= []; |
1747 |
|
push @{$self->{pending_chars}}, $token; |
1748 |
|
!!!next-token; |
1749 |
|
next B; |
1750 |
|
} else { |
1751 |
|
if ($self->{pending_chars}) { |
1752 |
|
$s = join '', map { $_->{data} } @{$self->{pending_chars}}; |
1753 |
|
delete $self->{pending_chars}; |
1754 |
|
if ($s =~ /[^\x09\x0A\x0C\x0D\x20]/) { |
1755 |
|
!!!cp ('t195'); |
1756 |
|
# |
1757 |
|
} else { |
1758 |
|
!!!cp ('t195.1'); |
1759 |
|
#$self->{open_elements}->[-1]->[0]->manakai_append_text ($s); |
1760 |
|
$self->{open_elements}->[-1]->[0]->append_child |
1761 |
|
($self->{document}->create_text_node ($s)); |
1762 |
|
last C; |
1763 |
|
} |
1764 |
|
} else { |
1765 |
|
!!!cp ('t195.2'); |
1766 |
|
last C; |
1767 |
|
} |
1768 |
|
} |
1769 |
|
|
1770 |
|
## Foster parenting |
1771 |
|
!!!parse-error (type => 'in table:#text', token => $token); |
1772 |
|
|
1773 |
|
## NOTE: As if in body, but insert into the foster parent element. |
1774 |
|
$reconstruct_active_formatting_elements->($insert_to_foster); |
1775 |
|
|
1776 |
|
if ($self->{open_elements}->[-1]->[1] & TABLE_ROWS_EL) { |
1777 |
|
# MUST |
1778 |
|
my $foster_parent_element; |
1779 |
|
my $next_sibling; |
1780 |
|
#my $prev_sibling; |
1781 |
|
OE: for (reverse 0..$#{$self->{open_elements}}) { |
1782 |
|
if ($self->{open_elements}->[$_]->[1] == TABLE_EL) { |
1783 |
|
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
1784 |
|
if (defined $parent and $parent->node_type == 1) { |
1785 |
|
$foster_parent_element = $parent; |
1786 |
|
!!!cp ('t196'); |
1787 |
|
$next_sibling = $self->{open_elements}->[$_]->[0]; |
1788 |
|
# $prev_sibling = $next_sibling->previous_sibling; |
1789 |
|
# |
1790 |
|
} else { |
1791 |
|
!!!cp ('t197'); |
1792 |
|
$foster_parent_element = $self->{open_elements}->[$_ - 1]->[0]; |
1793 |
|
# $prev_sibling = $foster_parent_element->last_child; |
1794 |
|
# |
1795 |
|
} |
1796 |
|
last OE; |
1797 |
|
} |
1798 |
|
} # OE |
1799 |
|
$foster_parent_element = $self->{open_elements}->[0]->[0] #and |
1800 |
|
#$prev_sibling = $foster_parent_element->last_child |
1801 |
|
unless defined $foster_parent_element; |
1802 |
|
#undef $prev_sibling unless $open_tables->[-1]->[2]; # ~node inserted |
1803 |
|
#if (defined $prev_sibling and |
1804 |
|
# $prev_sibling->node_type == 3) { |
1805 |
|
# !!! cp ('t198'); |
1806 |
|
# $prev_sibling->manakai_append_text ($s); |
1807 |
|
#} else { |
1808 |
|
!!!cp ('t199'); |
1809 |
|
$foster_parent_element->insert_before |
1810 |
|
($self->{document}->create_text_node ($s), $next_sibling); |
1811 |
|
#} |
1812 |
|
$open_tables->[-1]->[1] = 1; # tainted |
1813 |
|
$open_tables->[-1]->[2] = 1; # ~node inserted |
1814 |
|
} else { |
1815 |
|
## NOTE: Fragment case or in a foster parent'ed element |
1816 |
|
## (e.g. |<table><span>a|). In fragment case, whether the |
1817 |
|
## character is appended to existing node or a new node is |
1818 |
|
## created is irrelevant, since the foster parent'ed nodes |
1819 |
|
## are discarded and fragment parsing does not invoke any |
1820 |
|
## script. |
1821 |
|
!!!cp ('t200'); |
1822 |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($s); |
1823 |
|
} |
1824 |
|
} # C |
1825 |
|
} # TABLE_IMS |
1826 |
|
|
1827 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
1828 |
!!!cp ('t73'); |
!!!cp ('t73'); |
1829 |
!!!parse-error (type => 'in html:#DOCTYPE', token => $token); |
!!!parse-error (type => 'in html:#DOCTYPE', token => $token); |
3111 |
$insert = $insert_to_current; |
$insert = $insert_to_current; |
3112 |
# |
# |
3113 |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
|
C: { |
|
|
my $s; |
|
|
if ($token->{type} == CHARACTER_TOKEN) { |
|
|
!!!cp ('t194'); |
|
|
$self->{pending_chars} ||= []; |
|
|
push @{$self->{pending_chars}}, $token; |
|
|
!!!next-token; |
|
|
next B; |
|
|
} else { |
|
|
if ($self->{pending_chars}) { |
|
|
$s = join '', map { $_->{data} } @{$self->{pending_chars}}; |
|
|
delete $self->{pending_chars}; |
|
|
if ($s =~ /[^\x09\x0A\x0C\x0D\x20]/) { |
|
|
!!!cp ('t195'); |
|
|
# |
|
|
} else { |
|
|
!!!cp ('t195.1'); |
|
|
#$self->{open_elements}->[-1]->[0]->manakai_append_text ($s); |
|
|
$self->{open_elements}->[-1]->[0]->append_child |
|
|
($self->{document}->create_text_node ($s)); |
|
|
last C; |
|
|
} |
|
|
} else { |
|
|
!!!cp ('t195.2'); |
|
|
last C; |
|
|
} |
|
|
} |
|
|
|
|
|
## Foster parenting |
|
|
!!!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 ($s); |
|
|
#} else { |
|
|
!!!cp ('t199'); |
|
|
$foster_parent_element->insert_before |
|
|
($self->{document}->create_text_node ($s), $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 ($s); |
|
|
} |
|
|
} # C |
|
|
|
|
3114 |
if ($token->{type} == START_TAG_TOKEN) { |
if ($token->{type} == START_TAG_TOKEN) { |
3115 |
if ({ |
if ({ |
3116 |
tr => (($self->{insertion_mode} & IM_MASK) != IN_ROW_IM), |
tr => (($self->{insertion_mode} & IM_MASK) != IN_ROW_IM), |