| 2067 |
th => 'in cell', |
th => 'in cell', |
| 2068 |
tr => 'in row', |
tr => 'in row', |
| 2069 |
tbody => 'in table body', |
tbody => 'in table body', |
| 2070 |
thead => 'in table head', |
thead => 'in table body', |
| 2071 |
tfoot => 'in table foot', |
tfoot => 'in table body', |
| 2072 |
caption => 'in caption', |
caption => 'in caption', |
| 2073 |
colgroup => 'in column group', |
colgroup => 'in column group', |
| 2074 |
table => 'in table', |
table => 'in table', |
| 3046 |
noframes => 1, |
noframes => 1, |
| 3047 |
noscript => 0, ## TODO: 1 if scripting is enabled |
noscript => 0, ## TODO: 1 if scripting is enabled |
| 3048 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 3049 |
|
## NOTE: There are two "as if in body" code clones. |
| 3050 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
| 3051 |
return; |
return; |
| 3052 |
} elsif ($token->{tag_name} eq 'select') { |
} elsif ($token->{tag_name} eq 'select') { |
| 3648 |
|
|
| 3649 |
## ISSUE: An issue in the spec. |
## ISSUE: An issue in the spec. |
| 3650 |
} elsif ($self->{insertion_mode} eq 'in body' or |
} elsif ($self->{insertion_mode} eq 'in body' or |
| 3651 |
|
$self->{insertion_mode} eq 'in cell' or |
| 3652 |
$self->{insertion_mode} eq 'in caption') { |
$self->{insertion_mode} eq 'in caption') { |
| 3653 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 3654 |
## NOTE: There is a code clone of "character in body". |
## NOTE: There is a code clone of "character in body". |
| 3662 |
if ({ |
if ({ |
| 3663 |
caption => 1, col => 1, colgroup => 1, tbody => 1, |
caption => 1, col => 1, colgroup => 1, tbody => 1, |
| 3664 |
td => 1, tfoot => 1, th => 1, thead => 1, tr => 1, |
td => 1, tfoot => 1, th => 1, thead => 1, tr => 1, |
| 3665 |
}->{$token->{tag_name}} and |
}->{$token->{tag_name}}) { |
| 3666 |
$self->{insertion_mode} eq 'in caption') { |
if ($self->{insertion_mode} eq 'in cell') { |
| 3667 |
!!!parse-error (type => 'not closed:caption'); |
## have an element in table scope |
| 3668 |
|
my $tn; |
| 3669 |
## As if </caption> |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3670 |
## have a table element in table scope |
my $node = $self->{open_elements}->[$_]; |
| 3671 |
my $i; |
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
| 3672 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
$tn = $node->[1]; |
| 3673 |
my $node = $self->{open_elements}->[$_]; |
last INSCOPE; |
| 3674 |
if ($node->[1] eq 'caption') { |
} elsif ({ |
| 3675 |
$i = $_; |
table => 1, html => 1, |
| 3676 |
last INSCOPE; |
}->{$node->[1]}) { |
| 3677 |
} elsif ({ |
last INSCOPE; |
| 3678 |
table => 1, html => 1, |
} |
| 3679 |
}->{$node->[1]}) { |
} # INSCOPE |
| 3680 |
last INSCOPE; |
unless (defined $tn) { |
| 3681 |
} |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3682 |
} # INSCOPE |
## Ignore the token |
| 3683 |
unless (defined $i) { |
!!!next-token; |
| 3684 |
!!!parse-error (type => 'unmatched end tag:caption'); |
redo B; |
| 3685 |
## Ignore the token |
} |
| 3686 |
!!!next-token; |
|
| 3687 |
redo B; |
## Close the cell |
|
} |
|
|
|
|
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 3688 |
!!!back-token; # <?> |
!!!back-token; # <?> |
| 3689 |
$token = {type => 'end tag', tag_name => 'caption'}; |
$token = {type => 'end tag', tag_name => $tn}; |
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
| 3690 |
redo B; |
redo B; |
| 3691 |
|
} elsif ($self->{insertion_mode} eq 'in caption') { |
| 3692 |
|
!!!parse-error (type => 'not closed:caption'); |
| 3693 |
|
|
| 3694 |
|
## As if </caption> |
| 3695 |
|
## have a table element in table scope |
| 3696 |
|
my $i; |
| 3697 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3698 |
|
my $node = $self->{open_elements}->[$_]; |
| 3699 |
|
if ($node->[1] eq 'caption') { |
| 3700 |
|
$i = $_; |
| 3701 |
|
last INSCOPE; |
| 3702 |
|
} elsif ({ |
| 3703 |
|
table => 1, html => 1, |
| 3704 |
|
}->{$node->[1]}) { |
| 3705 |
|
last INSCOPE; |
| 3706 |
|
} |
| 3707 |
|
} # INSCOPE |
| 3708 |
|
unless (defined $i) { |
| 3709 |
|
!!!parse-error (type => 'unmatched end tag:caption'); |
| 3710 |
|
## Ignore the token |
| 3711 |
|
!!!next-token; |
| 3712 |
|
redo B; |
| 3713 |
|
} |
| 3714 |
|
|
| 3715 |
|
## generate implied end tags |
| 3716 |
|
if ({ |
| 3717 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 3718 |
|
td => 1, th => 1, tr => 1, |
| 3719 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3720 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3721 |
|
!!!back-token; # <?> |
| 3722 |
|
$token = {type => 'end tag', tag_name => 'caption'}; |
| 3723 |
|
!!!back-token; |
| 3724 |
|
$token = {type => 'end tag', |
| 3725 |
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
| 3726 |
|
redo B; |
| 3727 |
|
} |
| 3728 |
|
|
| 3729 |
|
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 3730 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 3731 |
|
} |
| 3732 |
|
|
| 3733 |
|
splice @{$self->{open_elements}}, $i; |
| 3734 |
|
|
| 3735 |
|
$clear_up_to_marker->(); |
| 3736 |
|
|
| 3737 |
|
$self->{insertion_mode} = 'in table'; |
| 3738 |
|
|
| 3739 |
|
## reprocess |
| 3740 |
|
redo B; |
| 3741 |
|
} else { |
| 3742 |
|
# |
| 3743 |
} |
} |
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} |
|
|
|
|
|
splice @{$self->{open_elements}}, $i; |
|
|
|
|
|
$clear_up_to_marker->(); |
|
|
|
|
|
$self->{insertion_mode} = 'in table'; |
|
|
|
|
|
## reprocess |
|
|
redo B; |
|
| 3744 |
} else { |
} else { |
| 3745 |
# |
# |
| 3746 |
} |
} |
| 3747 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 3748 |
if ($token->{tag_name} eq 'caption' and |
if ($token->{tag_name} eq 'td' or $token->{tag_name} eq 'th') { |
| 3749 |
$self->{insertion_mode} eq 'in caption') { |
if ($self->{insertion_mode} eq 'in cell') { |
| 3750 |
## have a table element in table scope |
## have an element in table scope |
| 3751 |
|
my $i; |
| 3752 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3753 |
|
my $node = $self->{open_elements}->[$_]; |
| 3754 |
|
if ($node->[1] eq $token->{tag_name}) { |
| 3755 |
|
$i = $_; |
| 3756 |
|
last INSCOPE; |
| 3757 |
|
} elsif ({ |
| 3758 |
|
table => 1, html => 1, |
| 3759 |
|
}->{$node->[1]}) { |
| 3760 |
|
last INSCOPE; |
| 3761 |
|
} |
| 3762 |
|
} # INSCOPE |
| 3763 |
|
unless (defined $i) { |
| 3764 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3765 |
|
## Ignore the token |
| 3766 |
|
!!!next-token; |
| 3767 |
|
redo B; |
| 3768 |
|
} |
| 3769 |
|
|
| 3770 |
|
## generate implied end tags |
| 3771 |
|
if ({ |
| 3772 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 3773 |
|
td => ($token->{tag_name} eq 'th'), |
| 3774 |
|
th => ($token->{tag_name} eq 'td'), |
| 3775 |
|
tr => 1, |
| 3776 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3777 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3778 |
|
!!!back-token; |
| 3779 |
|
$token = {type => 'end tag', |
| 3780 |
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
| 3781 |
|
redo B; |
| 3782 |
|
} |
| 3783 |
|
|
| 3784 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 3785 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 3786 |
|
} |
| 3787 |
|
|
| 3788 |
|
splice @{$self->{open_elements}}, $i; |
| 3789 |
|
|
| 3790 |
|
$clear_up_to_marker->(); |
| 3791 |
|
|
| 3792 |
|
$self->{insertion_mode} = 'in row'; |
| 3793 |
|
|
| 3794 |
|
!!!next-token; |
| 3795 |
|
redo B; |
| 3796 |
|
} elsif ($self->{insertion_mode} eq 'in caption') { |
| 3797 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3798 |
|
## Ignore the token |
| 3799 |
|
!!!next-token; |
| 3800 |
|
redo B; |
| 3801 |
|
} else { |
| 3802 |
|
# |
| 3803 |
|
} |
| 3804 |
|
} elsif ($token->{tag_name} eq 'caption') { |
| 3805 |
|
if ($self->{insertion_mode} eq 'in caption') { |
| 3806 |
|
## have a table element in table scope |
| 3807 |
|
my $i; |
| 3808 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3809 |
|
my $node = $self->{open_elements}->[$_]; |
| 3810 |
|
if ($node->[1] eq $token->{tag_name}) { |
| 3811 |
|
$i = $_; |
| 3812 |
|
last INSCOPE; |
| 3813 |
|
} elsif ({ |
| 3814 |
|
table => 1, html => 1, |
| 3815 |
|
}->{$node->[1]}) { |
| 3816 |
|
last INSCOPE; |
| 3817 |
|
} |
| 3818 |
|
} # INSCOPE |
| 3819 |
|
unless (defined $i) { |
| 3820 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3821 |
|
## Ignore the token |
| 3822 |
|
!!!next-token; |
| 3823 |
|
redo B; |
| 3824 |
|
} |
| 3825 |
|
|
| 3826 |
|
## generate implied end tags |
| 3827 |
|
if ({ |
| 3828 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 3829 |
|
td => 1, th => 1, tr => 1, |
| 3830 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3831 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3832 |
|
!!!back-token; |
| 3833 |
|
$token = {type => 'end tag', |
| 3834 |
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
| 3835 |
|
redo B; |
| 3836 |
|
} |
| 3837 |
|
|
| 3838 |
|
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 3839 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 3840 |
|
} |
| 3841 |
|
|
| 3842 |
|
splice @{$self->{open_elements}}, $i; |
| 3843 |
|
|
| 3844 |
|
$clear_up_to_marker->(); |
| 3845 |
|
|
| 3846 |
|
$self->{insertion_mode} = 'in table'; |
| 3847 |
|
|
| 3848 |
|
!!!next-token; |
| 3849 |
|
redo B; |
| 3850 |
|
} elsif ($self->{insertion_mode} eq 'in cell') { |
| 3851 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3852 |
|
## Ignore the token |
| 3853 |
|
!!!next-token; |
| 3854 |
|
redo B; |
| 3855 |
|
} else { |
| 3856 |
|
# |
| 3857 |
|
} |
| 3858 |
|
} elsif ({ |
| 3859 |
|
table => 1, tbody => 1, tfoot => 1, |
| 3860 |
|
thead => 1, tr => 1, |
| 3861 |
|
}->{$token->{tag_name}} and |
| 3862 |
|
$self->{insertion_mode} eq 'in cell') { |
| 3863 |
|
## have an element in table scope |
| 3864 |
my $i; |
my $i; |
| 3865 |
|
my $tn; |
| 3866 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3867 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 3868 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq $token->{tag_name}) { |
| 3869 |
$i = $_; |
$i = $_; |
| 3870 |
last INSCOPE; |
last INSCOPE; |
| 3871 |
|
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
| 3872 |
|
$tn = $node->[1]; |
| 3873 |
|
## NOTE: There is exactly one |td| or |th| element |
| 3874 |
|
## in scope in the stack of open elements by definition. |
| 3875 |
} elsif ({ |
} elsif ({ |
| 3876 |
table => 1, html => 1, |
table => 1, html => 1, |
| 3877 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 3884 |
!!!next-token; |
!!!next-token; |
| 3885 |
redo B; |
redo B; |
| 3886 |
} |
} |
|
|
|
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} |
|
|
|
|
|
splice @{$self->{open_elements}}, $i; |
|
|
|
|
|
$clear_up_to_marker->(); |
|
|
|
|
|
$self->{insertion_mode} = 'in table'; |
|
| 3887 |
|
|
| 3888 |
!!!next-token; |
## Close the cell |
| 3889 |
|
!!!back-token; # </?> |
| 3890 |
|
$token = {type => 'end tag', tag_name => $tn}; |
| 3891 |
redo B; |
redo B; |
| 3892 |
} elsif ($token->{tag_name} eq 'table' and |
} elsif ($token->{tag_name} eq 'table' and |
| 3893 |
$self->{insertion_mode} eq 'in caption') { |
$self->{insertion_mode} eq 'in caption') { |
| 3941 |
## reprocess |
## reprocess |
| 3942 |
redo B; |
redo B; |
| 3943 |
} elsif ({ |
} elsif ({ |
| 3944 |
body => 1, col => 1, colgroup => 1, |
body => 1, col => 1, colgroup => 1, html => 1, |
| 3945 |
html => 1, tbody => 1, td => 1, tfoot => 1, |
}->{$token->{tag_name}}) { |
| 3946 |
th => 1, thead => 1, tr => 1, |
if ($self->{insertion_mode} eq 'in cell' or |
| 3947 |
|
$self->{insertion_mode} eq 'in caption') { |
| 3948 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3949 |
|
## Ignore the token |
| 3950 |
|
!!!next-token; |
| 3951 |
|
redo B; |
| 3952 |
|
} else { |
| 3953 |
|
# |
| 3954 |
|
} |
| 3955 |
|
} elsif ({ |
| 3956 |
|
tbody => 1, tfoot => 1, |
| 3957 |
|
thead => 1, tr => 1, |
| 3958 |
}->{$token->{tag_name}} and |
}->{$token->{tag_name}} and |
| 3959 |
$self->{insertion_mode} eq 'in caption') { |
$self->{insertion_mode} eq 'in caption') { |
| 3960 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3967 |
} else { |
} else { |
| 3968 |
# |
# |
| 3969 |
} |
} |
| 3970 |
|
|
| 3971 |
$in_body->($insert_to_current); |
$in_body->($insert_to_current); |
| 3972 |
redo B; |
redo B; |
| 3973 |
} elsif ($self->{insertion_mode} eq 'in table') { |
} elsif ($self->{insertion_mode} eq 'in row' or |
| 3974 |
|
$self->{insertion_mode} eq 'in table body' or |
| 3975 |
|
$self->{insertion_mode} eq 'in table') { |
| 3976 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 3977 |
## NOTE: There are "character in table" code clones. |
## NOTE: There are "character in table" code clones. |
| 3978 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4033 |
redo B; |
redo B; |
| 4034 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 4035 |
if ({ |
if ({ |
| 4036 |
caption => 1, |
tr => ($self->{insertion_mode} ne 'in row'), |
| 4037 |
colgroup => 1, |
th => 1, td => 1, |
|
tbody => 1, tfoot => 1, thead => 1, |
|
| 4038 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4039 |
## Clear back to table context |
if ($self->{insertion_mode} eq 'in table') { |
| 4040 |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
## Clear back to table context |
| 4041 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
| 4042 |
|
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4043 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4044 |
|
pop @{$self->{open_elements}}; |
| 4045 |
|
} |
| 4046 |
|
|
| 4047 |
|
!!!insert-element ('tbody'); |
| 4048 |
|
$self->{insertion_mode} = 'in table body'; |
| 4049 |
|
## reprocess in the "in table body" insertion mode... |
| 4050 |
|
} |
| 4051 |
|
|
| 4052 |
|
if ($self->{insertion_mode} eq 'in table body') { |
| 4053 |
|
unless ($token->{tag_name} eq 'tr') { |
| 4054 |
|
!!!parse-error (type => 'missing start tag:tr'); |
| 4055 |
|
} |
| 4056 |
|
|
| 4057 |
|
## Clear back to table body context |
| 4058 |
|
while (not { |
| 4059 |
|
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4060 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4061 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4062 |
|
pop @{$self->{open_elements}}; |
| 4063 |
|
} |
| 4064 |
|
|
| 4065 |
|
$self->{insertion_mode} = 'in row'; |
| 4066 |
|
if ($token->{tag_name} eq 'tr') { |
| 4067 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4068 |
|
!!!next-token; |
| 4069 |
|
redo B; |
| 4070 |
|
} else { |
| 4071 |
|
!!!insert-element ('tr'); |
| 4072 |
|
## reprocess in the "in row" insertion mode |
| 4073 |
|
} |
| 4074 |
|
} |
| 4075 |
|
|
| 4076 |
|
## Clear back to table row context |
| 4077 |
|
while (not { |
| 4078 |
|
tr => 1, html => 1, |
| 4079 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4080 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4081 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4082 |
} |
} |
| 4083 |
|
|
|
push @$active_formatting_elements, ['#marker', ''] |
|
|
if $token->{tag_name} eq 'caption'; |
|
|
|
|
| 4084 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4085 |
$self->{insertion_mode} = { |
$self->{insertion_mode} = 'in cell'; |
| 4086 |
caption => 'in caption', |
|
| 4087 |
colgroup => 'in column group', |
push @$active_formatting_elements, ['#marker', '']; |
| 4088 |
tbody => 'in table body', |
|
|
tfoot => 'in table body', |
|
|
thead => 'in table body', |
|
|
}->{$token->{tag_name}}; |
|
| 4089 |
!!!next-token; |
!!!next-token; |
| 4090 |
redo B; |
redo B; |
| 4091 |
} elsif ({ |
} elsif ({ |
| 4092 |
col => 1, |
caption => 1, col => 1, colgroup => 1, |
| 4093 |
td => 1, th => 1, tr => 1, |
tbody => 1, tfoot => 1, thead => 1, |
| 4094 |
|
tr => 1, # $self->{insertion_mode} eq 'in row' |
| 4095 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4096 |
## Clear back to table context |
if ($self->{insertion_mode} eq 'in row') { |
| 4097 |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
## As if </tr> |
| 4098 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
## have an element in table scope |
| 4099 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
my $i; |
| 4100 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4101 |
|
my $node = $self->{open_elements}->[$_]; |
| 4102 |
|
if ($node->[1] eq 'tr') { |
| 4103 |
|
$i = $_; |
| 4104 |
|
last INSCOPE; |
| 4105 |
|
} elsif ({ |
| 4106 |
|
table => 1, html => 1, |
| 4107 |
|
}->{$node->[1]}) { |
| 4108 |
|
last INSCOPE; |
| 4109 |
|
} |
| 4110 |
|
} # INSCOPE |
| 4111 |
|
unless (defined $i) { |
| 4112 |
|
!!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}); |
| 4113 |
|
## Ignore the token |
| 4114 |
|
!!!next-token; |
| 4115 |
|
redo B; |
| 4116 |
|
} |
| 4117 |
|
|
| 4118 |
|
## Clear back to table row context |
| 4119 |
|
while (not { |
| 4120 |
|
tr => 1, html => 1, |
| 4121 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4122 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4123 |
|
pop @{$self->{open_elements}}; |
| 4124 |
|
} |
| 4125 |
|
|
| 4126 |
|
pop @{$self->{open_elements}}; # tr |
| 4127 |
|
$self->{insertion_mode} = 'in table body'; |
| 4128 |
|
if ($token->{tag_name} eq 'tr') { |
| 4129 |
|
## reprocess |
| 4130 |
|
redo B; |
| 4131 |
|
} else { |
| 4132 |
|
## reprocess in the "in table body" insertion mode... |
| 4133 |
|
} |
| 4134 |
|
} |
| 4135 |
|
|
| 4136 |
|
if ($self->{insertion_mode} eq 'in table body') { |
| 4137 |
|
## have an element in table scope |
| 4138 |
|
my $i; |
| 4139 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4140 |
|
my $node = $self->{open_elements}->[$_]; |
| 4141 |
|
if ({ |
| 4142 |
|
tbody => 1, thead => 1, tfoot => 1, |
| 4143 |
|
}->{$node->[1]}) { |
| 4144 |
|
$i = $_; |
| 4145 |
|
last INSCOPE; |
| 4146 |
|
} elsif ({ |
| 4147 |
|
table => 1, html => 1, |
| 4148 |
|
}->{$node->[1]}) { |
| 4149 |
|
last INSCOPE; |
| 4150 |
|
} |
| 4151 |
|
} # INSCOPE |
| 4152 |
|
unless (defined $i) { |
| 4153 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4154 |
|
## Ignore the token |
| 4155 |
|
!!!next-token; |
| 4156 |
|
redo B; |
| 4157 |
|
} |
| 4158 |
|
|
| 4159 |
|
## Clear back to table body context |
| 4160 |
|
while (not { |
| 4161 |
|
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4162 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4163 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4164 |
|
pop @{$self->{open_elements}}; |
| 4165 |
|
} |
| 4166 |
|
|
| 4167 |
|
## As if <{current node}> |
| 4168 |
|
## have an element in table scope |
| 4169 |
|
## true by definition |
| 4170 |
|
|
| 4171 |
|
## Clear back to table body context |
| 4172 |
|
## nop by definition |
| 4173 |
|
|
| 4174 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4175 |
|
$self->{insertion_mode} = 'in table'; |
| 4176 |
|
## reprocess in "in table" insertion mode... |
| 4177 |
} |
} |
| 4178 |
|
|
| 4179 |
!!!insert-element ($token->{tag_name} eq 'col' ? 'colgroup' : 'tbody'); |
if ($token->{tag_name} eq 'col') { |
| 4180 |
$self->{insertion_mode} = $token->{tag_name} eq 'col' |
## Clear back to table context |
| 4181 |
? 'in column group' : 'in table body'; |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
| 4182 |
## reprocess |
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4183 |
redo B; |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4184 |
|
pop @{$self->{open_elements}}; |
| 4185 |
|
} |
| 4186 |
|
|
| 4187 |
|
!!!insert-element ('colgroup'); |
| 4188 |
|
$self->{insertion_mode} = 'in column group'; |
| 4189 |
|
## reprocess |
| 4190 |
|
redo B; |
| 4191 |
|
} elsif ({ |
| 4192 |
|
caption => 1, |
| 4193 |
|
colgroup => 1, |
| 4194 |
|
tbody => 1, tfoot => 1, thead => 1, |
| 4195 |
|
}->{$token->{tag_name}}) { |
| 4196 |
|
## Clear back to table context |
| 4197 |
|
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
| 4198 |
|
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4199 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4200 |
|
pop @{$self->{open_elements}}; |
| 4201 |
|
} |
| 4202 |
|
|
| 4203 |
|
push @$active_formatting_elements, ['#marker', ''] |
| 4204 |
|
if $token->{tag_name} eq 'caption'; |
| 4205 |
|
|
| 4206 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4207 |
|
$self->{insertion_mode} = { |
| 4208 |
|
caption => 'in caption', |
| 4209 |
|
colgroup => 'in column group', |
| 4210 |
|
tbody => 'in table body', |
| 4211 |
|
tfoot => 'in table body', |
| 4212 |
|
thead => 'in table body', |
| 4213 |
|
}->{$token->{tag_name}}; |
| 4214 |
|
!!!next-token; |
| 4215 |
|
redo B; |
| 4216 |
|
} else { |
| 4217 |
|
die "$0: in table: <>: $token->{tag_name}"; |
| 4218 |
|
} |
| 4219 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 4220 |
## NOTE: There are code clones for this "table in table" |
## NOTE: There are code clones for this "table in table" |
| 4221 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4269 |
# |
# |
| 4270 |
} |
} |
| 4271 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 4272 |
if ($token->{tag_name} eq 'table') { |
if ($token->{tag_name} eq 'tr' and |
| 4273 |
## have a table element in table scope |
$self->{insertion_mode} eq 'in row') { |
| 4274 |
|
## have an element in table scope |
| 4275 |
my $i; |
my $i; |
| 4276 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4277 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4290 |
!!!next-token; |
!!!next-token; |
| 4291 |
redo B; |
redo B; |
| 4292 |
} |
} |
|
|
|
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
| 4293 |
|
|
| 4294 |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
## Clear back to table row context |
| 4295 |
|
while (not { |
| 4296 |
|
tr => 1, html => 1, |
| 4297 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4298 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4299 |
|
pop @{$self->{open_elements}}; |
| 4300 |
} |
} |
| 4301 |
|
|
| 4302 |
splice @{$self->{open_elements}}, $i; |
pop @{$self->{open_elements}}; # tr |
| 4303 |
|
$self->{insertion_mode} = 'in table body'; |
|
$self->_reset_insertion_mode; |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
body => 1, caption => 1, col => 1, colgroup => 1, |
|
|
html => 1, tbody => 1, td => 1, tfoot => 1, th => 1, |
|
|
thead => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} else { |
|
|
# |
|
|
} |
|
|
|
|
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
|
|
$in_body->($insert_to_foster); |
|
|
redo B; |
|
|
} elsif ($self->{insertion_mode} eq 'in column group') { |
|
|
if ($token->{type} eq 'character') { |
|
|
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
|
|
unless (length $token->{data}) { |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
} |
|
|
|
|
|
# |
|
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ($token->{tag_name} eq 'col') { |
|
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
|
|
pop @{$self->{open_elements}}; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} elsif ($token->{type} eq 'end tag') { |
|
|
if ($token->{tag_name} eq 'colgroup') { |
|
|
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
|
|
!!!parse-error (type => 'unmatched end tag:colgroup'); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} else { |
|
|
pop @{$self->{open_elements}}; # colgroup |
|
|
$self->{insertion_mode} = 'in table'; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
} elsif ($token->{tag_name} eq 'col') { |
|
|
!!!parse-error (type => 'unmatched end tag:col'); |
|
|
## Ignore the token |
|
| 4304 |
!!!next-token; |
!!!next-token; |
| 4305 |
redo B; |
redo B; |
| 4306 |
} else { |
} elsif ($token->{tag_name} eq 'table') { |
| 4307 |
# |
if ($self->{insertion_mode} eq 'in row') { |
| 4308 |
} |
## As if </tr> |
| 4309 |
} else { |
## have an element in table scope |
| 4310 |
# |
my $i; |
| 4311 |
} |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4312 |
|
my $node = $self->{open_elements}->[$_]; |
| 4313 |
## As if </colgroup> |
if ($node->[1] eq 'tr') { |
| 4314 |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
$i = $_; |
| 4315 |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
last INSCOPE; |
| 4316 |
## Ignore the token |
} elsif ({ |
| 4317 |
!!!next-token; |
table => 1, html => 1, |
| 4318 |
redo B; |
}->{$node->[1]}) { |
| 4319 |
} else { |
last INSCOPE; |
| 4320 |
pop @{$self->{open_elements}}; # colgroup |
} |
| 4321 |
$self->{insertion_mode} = 'in table'; |
} # INSCOPE |
| 4322 |
## reprocess |
unless (defined $i) { |
| 4323 |
redo B; |
!!!parse-error (type => 'unmatched end tag:'.$token->{type}); |
| 4324 |
} |
## Ignore the token |
| 4325 |
} elsif ($self->{insertion_mode} eq 'in table body') { |
!!!next-token; |
| 4326 |
if ($token->{type} eq 'character') { |
redo B; |
| 4327 |
## NOTE: This is a "character in table" code clone. |
} |
| 4328 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
|
| 4329 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
## Clear back to table row context |
| 4330 |
|
while (not { |
| 4331 |
unless (length $token->{data}) { |
tr => 1, html => 1, |
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
} |
|
|
|
|
|
!!!parse-error (type => 'in table:#character'); |
|
|
|
|
|
## As if in body, but insert into foster parent element |
|
|
## ISSUE: Spec says that "whenever a node would be inserted |
|
|
## into the current node" while characters might not be |
|
|
## result in a new Text node. |
|
|
$reconstruct_active_formatting_elements->($insert_to_foster); |
|
|
|
|
|
if ({ |
|
|
table => 1, tbody => 1, tfoot => 1, |
|
|
thead => 1, tr => 1, |
|
| 4332 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4333 |
# MUST |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4334 |
my $foster_parent_element; |
pop @{$self->{open_elements}}; |
| 4335 |
my $next_sibling; |
} |
| 4336 |
my $prev_sibling; |
|
| 4337 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
pop @{$self->{open_elements}}; # tr |
| 4338 |
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
$self->{insertion_mode} = 'in table body'; |
| 4339 |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
## reprocess in the "in table body" insertion mode... |
| 4340 |
if (defined $parent and $parent->node_type == 1) { |
} |
| 4341 |
$foster_parent_element = $parent; |
|
| 4342 |
$next_sibling = $self->{open_elements}->[$_]->[0]; |
if ($self->{insertion_mode} eq 'in table body') { |
| 4343 |
$prev_sibling = $next_sibling->previous_sibling; |
## have an element in table scope |
| 4344 |
} else { |
my $i; |
| 4345 |
$foster_parent_element = $self->{open_elements}->[$_ - 1]->[0]; |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4346 |
$prev_sibling = $foster_parent_element->last_child; |
my $node = $self->{open_elements}->[$_]; |
| 4347 |
|
if ({ |
| 4348 |
|
tbody => 1, thead => 1, tfoot => 1, |
| 4349 |
|
}->{$node->[1]}) { |
| 4350 |
|
$i = $_; |
| 4351 |
|
last INSCOPE; |
| 4352 |
|
} elsif ({ |
| 4353 |
|
table => 1, html => 1, |
| 4354 |
|
}->{$node->[1]}) { |
| 4355 |
|
last INSCOPE; |
| 4356 |
} |
} |
| 4357 |
last OE; |
} # INSCOPE |
| 4358 |
|
unless (defined $i) { |
| 4359 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4360 |
|
## Ignore the token |
| 4361 |
|
!!!next-token; |
| 4362 |
|
redo B; |
| 4363 |
|
} |
| 4364 |
|
|
| 4365 |
|
## Clear back to table body context |
| 4366 |
|
while (not { |
| 4367 |
|
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4368 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4369 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4370 |
|
pop @{$self->{open_elements}}; |
| 4371 |
} |
} |
| 4372 |
} # OE |
|
| 4373 |
$foster_parent_element = $self->{open_elements}->[0]->[0] and |
## As if <{current node}> |
| 4374 |
$prev_sibling = $foster_parent_element->last_child |
## have an element in table scope |
| 4375 |
unless defined $foster_parent_element; |
## true by definition |
| 4376 |
if (defined $prev_sibling and |
|
| 4377 |
$prev_sibling->node_type == 3) { |
## Clear back to table body context |
| 4378 |
$prev_sibling->manakai_append_text ($token->{data}); |
## nop by definition |
| 4379 |
} else { |
|
|
$foster_parent_element->insert_before |
|
|
($self->{document}->create_text_node ($token->{data}), |
|
|
$next_sibling); |
|
|
} |
|
|
} else { |
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
|
|
} |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ({ |
|
|
tr => 1, |
|
|
th => 1, td => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
unless ($token->{tag_name} eq 'tr') { |
|
|
!!!parse-error (type => 'missing start tag:tr'); |
|
|
} |
|
|
|
|
|
## Clear back to table body context |
|
|
while (not { |
|
|
tbody => 1, tfoot => 1, thead => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4380 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4381 |
|
$self->{insertion_mode} = 'in table'; |
| 4382 |
|
## reprocess in the "in table" insertion mode... |
| 4383 |
} |
} |
| 4384 |
|
|
| 4385 |
$self->{insertion_mode} = 'in row'; |
## have a table element in table scope |
|
if ($token->{tag_name} eq 'tr') { |
|
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
|
|
!!!next-token; |
|
|
} else { |
|
|
!!!insert-element ('tr'); |
|
|
## reprocess |
|
|
} |
|
|
redo B; |
|
|
} elsif ({ |
|
|
caption => 1, col => 1, colgroup => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## have an element in table scope |
|
| 4386 |
my $i; |
my $i; |
| 4387 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4388 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4389 |
if ({ |
if ($node->[1] eq $token->{tag_name}) { |
|
tbody => 1, thead => 1, tfoot => 1, |
|
|
}->{$node->[1]}) { |
|
| 4390 |
$i = $_; |
$i = $_; |
| 4391 |
last INSCOPE; |
last INSCOPE; |
| 4392 |
} elsif ({ |
} elsif ({ |
| 4402 |
redo B; |
redo B; |
| 4403 |
} |
} |
| 4404 |
|
|
|
## Clear back to table body context |
|
|
while (not { |
|
|
tbody => 1, tfoot => 1, thead => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
|
## As if <{current node}> |
|
|
## have an element in table scope |
|
|
## true by definition |
|
|
|
|
|
## Clear back to table body context |
|
|
## nop by definition |
|
|
|
|
|
pop @{$self->{open_elements}}; |
|
|
$self->{insertion_mode} = 'in table'; |
|
|
## reprocess |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'table') { |
|
|
## NOTE: This is a code clone of "table in table" |
|
|
!!!parse-error (type => 'not closed:table'); |
|
|
|
|
|
## As if </table> |
|
|
## have a table element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq 'table') { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:table'); |
|
|
## Ignore tokens </table><table> |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
| 4405 |
## generate implied end tags |
## generate implied end tags |
| 4406 |
if ({ |
if ({ |
| 4407 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4408 |
td => 1, th => 1, tr => 1, |
td => 1, th => 1, tr => 1, |
| 4409 |
tbody => 1, tfoot=> 1, thead => 1, |
tbody => 1, tfoot=> 1, thead => 1, |
| 4410 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
!!!back-token; # <table> |
|
|
$token = {type => 'end tag', tag_name => 'table'}; |
|
| 4411 |
!!!back-token; |
!!!back-token; |
| 4412 |
$token = {type => 'end tag', |
$token = {type => 'end tag', |
| 4413 |
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
| 4414 |
redo B; |
redo B; |
| 4415 |
} |
} |
| 4416 |
|
|
| 4417 |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
| 4418 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4419 |
} |
} |
| 4420 |
|
|
| 4421 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 4422 |
|
|
| 4423 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 4424 |
|
|
| 4425 |
## reprocess |
!!!next-token; |
| 4426 |
redo B; |
redo B; |
| 4427 |
} else { |
} elsif ({ |
| 4428 |
# |
tbody => 1, tfoot => 1, thead => 1, |
| 4429 |
} |
}->{$token->{tag_name}} and |
| 4430 |
} elsif ($token->{type} eq 'end tag') { |
($self->{insertion_mode} eq 'in row' or |
| 4431 |
if ({ |
$self->{insertion_mode} eq 'in table body')) { |
| 4432 |
tbody => 1, tfoot => 1, thead => 1, |
if ($self->{insertion_mode} eq 'in row') { |
| 4433 |
}->{$token->{tag_name}}) { |
## have an element in table scope |
| 4434 |
## have an element in table scope |
my $i; |
| 4435 |
my $i; |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4436 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
my $node = $self->{open_elements}->[$_]; |
| 4437 |
my $node = $self->{open_elements}->[$_]; |
if ($node->[1] eq $token->{tag_name}) { |
| 4438 |
if ($node->[1] eq $token->{tag_name}) { |
$i = $_; |
| 4439 |
$i = $_; |
last INSCOPE; |
| 4440 |
last INSCOPE; |
} elsif ({ |
| 4441 |
} elsif ({ |
table => 1, html => 1, |
| 4442 |
table => 1, html => 1, |
}->{$node->[1]}) { |
| 4443 |
}->{$node->[1]}) { |
last INSCOPE; |
| 4444 |
last INSCOPE; |
} |
| 4445 |
|
} # INSCOPE |
| 4446 |
|
unless (defined $i) { |
| 4447 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4448 |
|
## Ignore the token |
| 4449 |
|
!!!next-token; |
| 4450 |
|
redo B; |
| 4451 |
|
} |
| 4452 |
|
|
| 4453 |
|
## As if </tr> |
| 4454 |
|
## have an element in table scope |
| 4455 |
|
my $i; |
| 4456 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4457 |
|
my $node = $self->{open_elements}->[$_]; |
| 4458 |
|
if ($node->[1] eq 'tr') { |
| 4459 |
|
$i = $_; |
| 4460 |
|
last INSCOPE; |
| 4461 |
|
} elsif ({ |
| 4462 |
|
table => 1, html => 1, |
| 4463 |
|
}->{$node->[1]}) { |
| 4464 |
|
last INSCOPE; |
| 4465 |
|
} |
| 4466 |
|
} # INSCOPE |
| 4467 |
|
unless (defined $i) { |
| 4468 |
|
!!!parse-error (type => 'unmatched end tag:tr'); |
| 4469 |
|
## Ignore the token |
| 4470 |
|
!!!next-token; |
| 4471 |
|
redo B; |
| 4472 |
|
} |
| 4473 |
|
|
| 4474 |
|
## Clear back to table row context |
| 4475 |
|
while (not { |
| 4476 |
|
tr => 1, html => 1, |
| 4477 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4478 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4479 |
|
pop @{$self->{open_elements}}; |
| 4480 |
} |
} |
| 4481 |
} # INSCOPE |
|
| 4482 |
unless (defined $i) { |
pop @{$self->{open_elements}}; # tr |
| 4483 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
$self->{insertion_mode} = 'in table body'; |
| 4484 |
## Ignore the token |
## reprocess in the "in table body" insertion mode... |
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## Clear back to table body context |
|
|
while (not { |
|
|
tbody => 1, tfoot => 1, thead => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
pop @{$self->{open_elements}}; |
|
| 4485 |
} |
} |
| 4486 |
|
|
|
pop @{$self->{open_elements}}; |
|
|
$self->{insertion_mode} = 'in table'; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'table') { |
|
| 4487 |
## have an element in table scope |
## have an element in table scope |
| 4488 |
my $i; |
my $i; |
| 4489 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4490 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4491 |
if ({ |
if ($node->[1] eq $token->{tag_name}) { |
|
tbody => 1, thead => 1, tfoot => 1, |
|
|
}->{$node->[1]}) { |
|
| 4492 |
$i = $_; |
$i = $_; |
| 4493 |
last INSCOPE; |
last INSCOPE; |
| 4494 |
} elsif ({ |
} elsif ({ |
| 4512 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4513 |
} |
} |
| 4514 |
|
|
|
## As if <{current node}> |
|
|
## have an element in table scope |
|
|
## true by definition |
|
|
|
|
|
## Clear back to table body context |
|
|
## nop by definition |
|
|
|
|
| 4515 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4516 |
$self->{insertion_mode} = 'in table'; |
$self->{insertion_mode} = 'in table'; |
| 4517 |
## reprocess |
!!!next-token; |
| 4518 |
redo B; |
redo B; |
| 4519 |
} elsif ({ |
} elsif ({ |
| 4520 |
body => 1, caption => 1, col => 1, colgroup => 1, |
body => 1, caption => 1, col => 1, colgroup => 1, |
| 4521 |
html => 1, td => 1, th => 1, tr => 1, |
html => 1, td => 1, th => 1, |
| 4522 |
|
tr => 1, # $self->{insertion_mode} eq 'in row' |
| 4523 |
|
tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} eq 'in table' |
| 4524 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4525 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4526 |
## Ignore the token |
## Ignore the token |
| 4530 |
# |
# |
| 4531 |
} |
} |
| 4532 |
} else { |
} else { |
| 4533 |
# |
die "$0: $token->{type}: Unknown token type"; |
| 4534 |
} |
} |
| 4535 |
|
|
|
## As if in table |
|
| 4536 |
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
| 4537 |
$in_body->($insert_to_foster); |
$in_body->($insert_to_foster); |
| 4538 |
redo B; |
redo B; |
| 4539 |
} elsif ($self->{insertion_mode} eq 'in row') { |
} elsif ($self->{insertion_mode} eq 'in column group') { |
| 4540 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
|
## NOTE: This is a "character in table" code clone. |
|
| 4541 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4542 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
|
|
|
| 4543 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 4544 |
!!!next-token; |
!!!next-token; |
| 4545 |
redo B; |
redo B; |
| 4546 |
} |
} |
| 4547 |
} |
} |
|
|
|
|
!!!parse-error (type => 'in table:#character'); |
|
|
|
|
|
## As if in body, but insert into foster parent element |
|
|
## ISSUE: Spec says that "whenever a node would be inserted |
|
|
## into the current node" while characters might not be |
|
|
## result in a new Text node. |
|
|
$reconstruct_active_formatting_elements->($insert_to_foster); |
|
| 4548 |
|
|
| 4549 |
if ({ |
# |
|
table => 1, tbody => 1, tfoot => 1, |
|
|
thead => 1, tr => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
# MUST |
|
|
my $foster_parent_element; |
|
|
my $next_sibling; |
|
|
my $prev_sibling; |
|
|
OE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
|
|
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
|
|
if (defined $parent and $parent->node_type == 1) { |
|
|
$foster_parent_element = $parent; |
|
|
$next_sibling = $self->{open_elements}->[$_]->[0]; |
|
|
$prev_sibling = $next_sibling->previous_sibling; |
|
|
} else { |
|
|
$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; |
|
|
if (defined $prev_sibling and |
|
|
$prev_sibling->node_type == 3) { |
|
|
$prev_sibling->manakai_append_text ($token->{data}); |
|
|
} else { |
|
|
$foster_parent_element->insert_before |
|
|
($self->{document}->create_text_node ($token->{data}), |
|
|
$next_sibling); |
|
|
} |
|
|
} else { |
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
|
|
} |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
| 4550 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 4551 |
if ($token->{tag_name} eq 'th' or |
if ($token->{tag_name} eq 'col') { |
|
$token->{tag_name} eq 'td') { |
|
|
## Clear back to table row context |
|
|
while (not { |
|
|
tr => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
| 4552 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4553 |
$self->{insertion_mode} = 'in cell'; |
pop @{$self->{open_elements}}; |
|
|
|
|
push @$active_formatting_elements, ['#marker', '']; |
|
|
|
|
| 4554 |
!!!next-token; |
!!!next-token; |
| 4555 |
redo B; |
redo B; |
| 4556 |
} elsif ({ |
} else { |
|
caption => 1, col => 1, colgroup => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## As if </tr> |
|
|
## have an element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq 'tr') { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## Clear back to table row context |
|
|
while (not { |
|
|
tr => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
|
pop @{$self->{open_elements}}; # tr |
|
|
$self->{insertion_mode} = 'in table body'; |
|
|
## reprocess |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'table') { |
|
|
## NOTE: This is a code clone of "table in table" |
|
|
!!!parse-error (type => 'not closed:table'); |
|
|
|
|
|
## As if </table> |
|
|
## have a table element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq 'table') { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:table'); |
|
|
## Ignore tokens </table><table> |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!back-token; # <table> |
|
|
$token = {type => 'end tag', tag_name => 'table'}; |
|
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} |
|
|
|
|
|
splice @{$self->{open_elements}}, $i; |
|
|
|
|
|
$self->_reset_insertion_mode; |
|
|
|
|
|
## reprocess |
|
|
redo B; |
|
|
} else { |
|
| 4557 |
# |
# |
| 4558 |
} |
} |
| 4559 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 4560 |
if ($token->{tag_name} eq 'tr') { |
if ($token->{tag_name} eq 'colgroup') { |
| 4561 |
## have an element in table scope |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
| 4562 |
my $i; |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq $token->{tag_name}) { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## Clear back to table row context |
|
|
while (not { |
|
|
tr => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
|
pop @{$self->{open_elements}}; # tr |
|
|
$self->{insertion_mode} = 'in table body'; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'table') { |
|
|
## As if </tr> |
|
|
## have an element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq 'tr') { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{type}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## Clear back to table row context |
|
|
while (not { |
|
|
tr => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
|
pop @{$self->{open_elements}}; # tr |
|
|
$self->{insertion_mode} = 'in table body'; |
|
|
## reprocess |
|
|
redo B; |
|
|
} elsif ({ |
|
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## have an element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq $token->{tag_name}) { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
| 4563 |
## Ignore the token |
## Ignore the token |
| 4564 |
!!!next-token; |
!!!next-token; |
| 4565 |
redo B; |
redo B; |
| 4566 |
} |
} else { |
| 4567 |
|
pop @{$self->{open_elements}}; # colgroup |
| 4568 |
## As if </tr> |
$self->{insertion_mode} = 'in table'; |
|
## have an element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq 'tr') { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:tr'); |
|
|
## Ignore the token |
|
| 4569 |
!!!next-token; |
!!!next-token; |
| 4570 |
redo B; |
redo B; |
|
} |
|
|
|
|
|
## Clear back to table row context |
|
|
while (not { |
|
|
tr => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
pop @{$self->{open_elements}}; |
|
| 4571 |
} |
} |
| 4572 |
|
} elsif ($token->{tag_name} eq 'col') { |
| 4573 |
pop @{$self->{open_elements}}; # tr |
!!!parse-error (type => 'unmatched end tag:col'); |
|
$self->{insertion_mode} = 'in table body'; |
|
|
## reprocess |
|
|
redo B; |
|
|
} elsif ({ |
|
|
body => 1, caption => 1, col => 1, |
|
|
colgroup => 1, html => 1, td => 1, th => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
| 4574 |
## Ignore the token |
## Ignore the token |
| 4575 |
!!!next-token; |
!!!next-token; |
| 4576 |
redo B; |
redo B; |
| 4577 |
} else { |
} else { |
| 4578 |
# |
# |
| 4579 |
} |
} |
| 4580 |
} else { |
} else { |
| 4581 |
# |
# |
| 4582 |
} |
} |
| 4583 |
|
|
| 4584 |
## As if in table |
## As if </colgroup> |
| 4585 |
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
| 4586 |
$in_body->($insert_to_foster); |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
| 4587 |
redo B; |
## Ignore the token |
|
} elsif ($self->{insertion_mode} eq 'in cell') { |
|
|
if ($token->{type} eq 'character') { |
|
|
## NOTE: This is a code clone of "character in body". |
|
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
|
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
|
|
|
|
| 4588 |
!!!next-token; |
!!!next-token; |
| 4589 |
redo B; |
redo B; |
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ({ |
|
|
caption => 1, col => 1, colgroup => 1, |
|
|
tbody => 1, td => 1, tfoot => 1, th => 1, |
|
|
thead => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## have an element in table scope |
|
|
my $tn; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
|
|
$tn = $node->[1]; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $tn) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## Close the cell |
|
|
!!!back-token; # <?> |
|
|
$token = {type => 'end tag', tag_name => $tn}; |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} elsif ($token->{type} eq 'end tag') { |
|
|
if ($token->{tag_name} eq 'td' or $token->{tag_name} eq 'th') { |
|
|
## have an element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq $token->{tag_name}) { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => ($token->{tag_name} eq 'th'), |
|
|
th => ($token->{tag_name} eq 'td'), |
|
|
tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} |
|
|
|
|
|
splice @{$self->{open_elements}}, $i; |
|
|
|
|
|
$clear_up_to_marker->(); |
|
|
|
|
|
$self->{insertion_mode} = 'in row'; |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
body => 1, caption => 1, col => 1, |
|
|
colgroup => 1, html => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
table => 1, tbody => 1, tfoot => 1, |
|
|
thead => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## have an element in table scope |
|
|
my $i; |
|
|
my $tn; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq $token->{tag_name}) { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
|
|
$tn = $node->[1]; |
|
|
## NOTE: There is exactly one |td| or |th| element |
|
|
## in scope in the stack of open elements by definition. |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## Close the cell |
|
|
!!!back-token; # </?> |
|
|
$token = {type => 'end tag', tag_name => $tn}; |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
| 4590 |
} else { |
} else { |
| 4591 |
# |
pop @{$self->{open_elements}}; # colgroup |
| 4592 |
|
$self->{insertion_mode} = 'in table'; |
| 4593 |
|
## reprocess |
| 4594 |
|
redo B; |
| 4595 |
} |
} |
|
|
|
|
$in_body->($insert_to_current); |
|
|
redo B; |
|
| 4596 |
} elsif ($self->{insertion_mode} eq 'in select') { |
} elsif ($self->{insertion_mode} eq 'in select') { |
| 4597 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 4598 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 4836 |
!!!next-token; |
!!!next-token; |
| 4837 |
redo B; |
redo B; |
| 4838 |
} elsif ($token->{tag_name} eq 'noframes') { |
} elsif ($token->{tag_name} eq 'noframes') { |
| 4839 |
$in_body->($insert_to_current); |
## NOTE: As if in body. |
| 4840 |
|
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current); |
| 4841 |
redo B; |
redo B; |
| 4842 |
} else { |
} else { |
| 4843 |
!!!parse-error (type => 'in frameset:'.$token->{tag_name}); |
!!!parse-error (type => 'in frameset:'.$token->{tag_name}); |
| 4897 |
die qq[$0: Character "$token->{data}"]; |
die qq[$0: Character "$token->{data}"]; |
| 4898 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 4899 |
if ($token->{tag_name} eq 'noframes') { |
if ($token->{tag_name} eq 'noframes') { |
| 4900 |
$in_body->($insert_to_current); |
## NOTE: As if in body. |
| 4901 |
|
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current); |
| 4902 |
redo B; |
redo B; |
| 4903 |
} else { |
} else { |
| 4904 |
!!!parse-error (type => 'after frameset:'.$token->{tag_name}); |
!!!parse-error (type => 'after frameset:'.$token->{tag_name}); |