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'); |
1761 |
} |
} |
1762 |
} |
} |
1763 |
|
|
1764 |
## Foster parenting |
## Foster parenting. |
1765 |
!!!parse-error (type => 'in table:#text', token => $token); |
!!!parse-error (type => 'in table:#text', token => $token); |
1766 |
|
|
1767 |
## NOTE: As if in body, but insert into the foster parent element. |
## NOTE: As if in body, but insert into the foster parent element. |
1771 |
# MUST |
# MUST |
1772 |
my $foster_parent_element; |
my $foster_parent_element; |
1773 |
my $next_sibling; |
my $next_sibling; |
|
#my $prev_sibling; |
|
1774 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
1775 |
if ($self->{open_elements}->[$_]->[1] == TABLE_EL) { |
if ($self->{open_elements}->[$_]->[1] == TABLE_EL) { |
1776 |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
!!!cp ('t197'); |
1777 |
if (defined $parent and $parent->node_type == 1) { |
$foster_parent_element = $self->{open_elements}->[$_ - 1]->[0]; |
1778 |
$foster_parent_element = $parent; |
$next_sibling = $self->{open_elements}->[$_]->[0]; |
1779 |
!!!cp ('t196'); |
undef $next_sibling |
1780 |
$next_sibling = $self->{open_elements}->[$_]->[0]; |
unless $next_sibling->parent_node eq $foster_parent_element; |
|
# $prev_sibling = $next_sibling->previous_sibling; |
|
|
# |
|
|
} else { |
|
|
!!!cp ('t197'); |
|
|
$foster_parent_element = $self->{open_elements}->[$_ - 1]->[0]; |
|
|
# $prev_sibling = $foster_parent_element->last_child; |
|
|
# |
|
|
} |
|
1781 |
last OE; |
last OE; |
1782 |
} |
} |
1783 |
} # OE |
} # OE |
1784 |
$foster_parent_element = $self->{open_elements}->[0]->[0] #and |
$foster_parent_element ||= $self->{open_elements}->[0]->[0]; |
1785 |
#$prev_sibling = $foster_parent_element->last_child |
|
1786 |
unless defined $foster_parent_element; |
!!!cp ('t199'); |
1787 |
#undef $prev_sibling unless $open_tables->[-1]->[2]; # ~node inserted |
$foster_parent_element->insert_before |
1788 |
#if (defined $prev_sibling and |
($self->{document}->create_text_node ($s), $next_sibling); |
1789 |
# $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); |
|
|
#} |
|
1790 |
$open_tables->[-1]->[1] = 1; # tainted |
$open_tables->[-1]->[1] = 1; # tainted |
1791 |
$open_tables->[-1]->[2] = 1; # ~node inserted |
$open_tables->[-1]->[2] = 1; # ~node inserted |
1792 |
} else { |
} else { |