820 |
## combined with the original insertion mode. In thie parser, |
## combined with the original insertion mode. In thie parser, |
821 |
## they are stored together in the bit-or'ed form. |
## they are stored together in the bit-or'ed form. |
822 |
|
|
823 |
|
sub IM_MASK () { 0b11111111111 } |
824 |
|
|
825 |
## NOTE: "initial" and "before html" insertion modes have no constants. |
## NOTE: "initial" and "before html" insertion modes have no constants. |
826 |
|
|
827 |
## NOTE: "after after body" insertion mode. |
## NOTE: "after after body" insertion mode. |
2249 |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
2250 |
## ISSUE: A spec bug [Bug 6038] |
## ISSUE: A spec bug [Bug 6038] |
2251 |
splice @{$self->{open_elements}}, -2, 1, () # <head> |
splice @{$self->{open_elements}}, -2, 1, () # <head> |
2252 |
if ($self->{insertion_mode} & AFTER_HEAD_IM) == AFTER_HEAD_IM; |
if ($self->{insertion_mode} & IM_MASK) == AFTER_HEAD_IM; |
2253 |
next B; |
next B; |
2254 |
} elsif ($token->{tag_name} eq 'style' or |
} elsif ($token->{tag_name} eq 'style' or |
2255 |
$token->{tag_name} eq 'noframes') { |
$token->{tag_name} eq 'noframes') { |
2269 |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
2270 |
## ISSUE: A spec bug [Bug 6038] |
## ISSUE: A spec bug [Bug 6038] |
2271 |
splice @{$self->{open_elements}}, -2, 1, () # <head> |
splice @{$self->{open_elements}}, -2, 1, () # <head> |
2272 |
if ($self->{insertion_mode} & AFTER_HEAD_IM) == AFTER_HEAD_IM; |
if ($self->{insertion_mode} & IM_MASK) == AFTER_HEAD_IM; |
2273 |
next B; |
next B; |
2274 |
} elsif ($token->{tag_name} eq 'noscript') { |
} elsif ($token->{tag_name} eq 'noscript') { |
2275 |
if ($self->{insertion_mode} == IN_HEAD_IM) { |
if ($self->{insertion_mode} == IN_HEAD_IM) { |
2317 |
$script_start_tag->(); |
$script_start_tag->(); |
2318 |
## ISSUE: A spec bug [Bug 6038] |
## ISSUE: A spec bug [Bug 6038] |
2319 |
splice @{$self->{open_elements}}, -2, 1 # <head> |
splice @{$self->{open_elements}}, -2, 1 # <head> |
2320 |
if ($self->{insertion_mode} & AFTER_HEAD_IM) == AFTER_HEAD_IM; |
if ($self->{insertion_mode} & IM_MASK) == AFTER_HEAD_IM; |
2321 |
next B; |
next B; |
2322 |
} elsif ($token->{tag_name} eq 'body' or |
} elsif ($token->{tag_name} eq 'body' or |
2323 |
$token->{tag_name} eq 'frameset') { |
$token->{tag_name} eq 'frameset') { |
2643 |
caption => 1, col => 1, colgroup => 1, tbody => 1, |
caption => 1, col => 1, colgroup => 1, tbody => 1, |
2644 |
td => 1, tfoot => 1, th => 1, thead => 1, tr => 1, |
td => 1, tfoot => 1, th => 1, thead => 1, tr => 1, |
2645 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
2646 |
if ($self->{insertion_mode} == IN_CELL_IM) { |
if (($self->{insertion_mode} & IM_MASK) == IN_CELL_IM) { |
2647 |
## have an element in table scope |
## have an element in table scope |
2648 |
for (reverse 0..$#{$self->{open_elements}}) { |
for (reverse 0..$#{$self->{open_elements}}) { |
2649 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
2671 |
!!!nack ('t153.1'); |
!!!nack ('t153.1'); |
2672 |
!!!next-token; |
!!!next-token; |
2673 |
next B; |
next B; |
2674 |
} elsif ($self->{insertion_mode} & IN_CAPTION_IM) { |
} elsif (($self->{insertion_mode} & IM_MASK) == IN_CAPTION_IM) { |
2675 |
!!!parse-error (type => 'not closed', text => 'caption', |
!!!parse-error (type => 'not closed', text => 'caption', |
2676 |
token => $token); |
token => $token); |
2677 |
|
|
2736 |
} |
} |
2737 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
2738 |
if ($token->{tag_name} eq 'td' or $token->{tag_name} eq 'th') { |
if ($token->{tag_name} eq 'td' or $token->{tag_name} eq 'th') { |
2739 |
if ($self->{insertion_mode} == IN_CELL_IM) { |
if (($self->{insertion_mode} & IM_MASK) == IN_CELL_IM) { |
2740 |
## have an element in table scope |
## have an element in table scope |
2741 |
my $i; |
my $i; |
2742 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
2786 |
|
|
2787 |
!!!next-token; |
!!!next-token; |
2788 |
next B; |
next B; |
2789 |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
} elsif (($self->{insertion_mode} & IM_MASK) == IN_CAPTION_IM) { |
2790 |
!!!cp ('t169'); |
!!!cp ('t169'); |
2791 |
!!!parse-error (type => 'unmatched end tag', |
!!!parse-error (type => 'unmatched end tag', |
2792 |
text => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
2798 |
# |
# |
2799 |
} |
} |
2800 |
} elsif ($token->{tag_name} eq 'caption') { |
} elsif ($token->{tag_name} eq 'caption') { |
2801 |
if ($self->{insertion_mode} == IN_CAPTION_IM) { |
if (($self->{insertion_mode} & IM_MASK) == IN_CAPTION_IM) { |
2802 |
## have a table element in table scope |
## have a table element in table scope |
2803 |
my $i; |
my $i; |
2804 |
INSCOPE: { |
INSCOPE: { |
2847 |
|
|
2848 |
!!!next-token; |
!!!next-token; |
2849 |
next B; |
next B; |
2850 |
} elsif ($self->{insertion_mode} == IN_CELL_IM) { |
} elsif (($self->{insertion_mode} & IM_MASK) == IN_CELL_IM) { |
2851 |
!!!cp ('t177'); |
!!!cp ('t177'); |
2852 |
!!!parse-error (type => 'unmatched end tag', |
!!!parse-error (type => 'unmatched end tag', |
2853 |
text => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
2862 |
table => 1, tbody => 1, tfoot => 1, |
table => 1, tbody => 1, tfoot => 1, |
2863 |
thead => 1, tr => 1, |
thead => 1, tr => 1, |
2864 |
}->{$token->{tag_name}} and |
}->{$token->{tag_name}} and |
2865 |
$self->{insertion_mode} == IN_CELL_IM) { |
($self->{insertion_mode} & IM_MASK) == IN_CELL_IM) { |
2866 |
## have an element in table scope |
## have an element in table scope |
2867 |
my $i; |
my $i; |
2868 |
my $tn; |
my $tn; |
2899 |
next B; |
next B; |
2900 |
} # INSCOPE |
} # INSCOPE |
2901 |
} elsif ($token->{tag_name} eq 'table' and |
} elsif ($token->{tag_name} eq 'table' and |
2902 |
$self->{insertion_mode} == IN_CAPTION_IM) { |
($self->{insertion_mode} & IM_MASK) == IN_CAPTION_IM) { |
2903 |
!!!parse-error (type => 'not closed', text => 'caption', |
!!!parse-error (type => 'not closed', text => 'caption', |
2904 |
token => $token); |
token => $token); |
2905 |
|
|
2965 |
!!!cp ('t191'); |
!!!cp ('t191'); |
2966 |
# |
# |
2967 |
} |
} |
2968 |
} elsif ({ |
} elsif ({ |
2969 |
tbody => 1, tfoot => 1, |
tbody => 1, tfoot => 1, |
2970 |
thead => 1, tr => 1, |
thead => 1, tr => 1, |
2971 |
}->{$token->{tag_name}} and |
}->{$token->{tag_name}} and |
2972 |
$self->{insertion_mode} == IN_CAPTION_IM) { |
($self->{insertion_mode} & IM_MASK) == IN_CAPTION_IM) { |
2973 |
!!!cp ('t192'); |
!!!cp ('t192'); |
2974 |
!!!parse-error (type => 'unmatched end tag', |
!!!parse-error (type => 'unmatched end tag', |
2975 |
text => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
2976 |
## Ignore the token |
## Ignore the token |
2977 |
!!!next-token; |
!!!next-token; |
2978 |
next B; |
next B; |
2979 |
} else { |
} else { |
2980 |
!!!cp ('t193'); |
!!!cp ('t193'); |
2981 |
# |
# |
2982 |
} |
} |
2983 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
2984 |
for my $entry (@{$self->{open_elements}}) { |
for my $entry (@{$self->{open_elements}}) { |
2985 |
unless ($entry->[1] & ALL_END_TAG_OPTIONAL_EL) { |
unless ($entry->[1] & ALL_END_TAG_OPTIONAL_EL) { |
3072 |
next B; |
next B; |
3073 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
3074 |
if ({ |
if ({ |
3075 |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
tr => (($self->{insertion_mode} & IM_MASK) != IN_ROW_IM), |
3076 |
th => 1, td => 1, |
th => 1, td => 1, |
3077 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
3078 |
if ($self->{insertion_mode} == IN_TABLE_IM) { |
if (($self->{insertion_mode} & IM_MASK) == IN_TABLE_IM) { |
3079 |
## Clear back to table context |
## Clear back to table context |
3080 |
while (not ($self->{open_elements}->[-1]->[1] |
while (not ($self->{open_elements}->[-1]->[1] |
3081 |
& TABLE_SCOPING_EL)) { |
& TABLE_SCOPING_EL)) { |
3088 |
## reprocess in the "in table body" insertion mode... |
## reprocess in the "in table body" insertion mode... |
3089 |
} |
} |
3090 |
|
|
3091 |
if ($self->{insertion_mode} == IN_TABLE_BODY_IM) { |
if (($self->{insertion_mode} & IM_MASK) == IN_TABLE_BODY_IM) { |
3092 |
unless ($token->{tag_name} eq 'tr') { |
unless ($token->{tag_name} eq 'tr') { |
3093 |
!!!cp ('t202'); |
!!!cp ('t202'); |
3094 |
!!!parse-error (type => 'missing start tag:tr', token => $token); |
!!!parse-error (type => 'missing start tag:tr', token => $token); |
3140 |
tbody => 1, tfoot => 1, thead => 1, |
tbody => 1, tfoot => 1, thead => 1, |
3141 |
tr => 1, # $self->{insertion_mode} == IN_ROW_IM |
tr => 1, # $self->{insertion_mode} == IN_ROW_IM |
3142 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
3143 |
if ($self->{insertion_mode} == IN_ROW_IM) { |
if (($self->{insertion_mode} & IM_MASK) == IN_ROW_IM) { |
3144 |
## As if </tr> |
## As if </tr> |
3145 |
## have an element in table scope |
## have an element in table scope |
3146 |
my $i; |
my $i; |
3187 |
} |
} |
3188 |
} |
} |
3189 |
|
|
3190 |
if ($self->{insertion_mode} == IN_TABLE_BODY_IM) { |
if (($self->{insertion_mode} & IM_MASK) == IN_TABLE_BODY_IM) { |
3191 |
## have an element in table scope |
## have an element in table scope |
3192 |
my $i; |
my $i; |
3193 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
3401 |
$insert = $insert_to_foster; |
$insert = $insert_to_foster; |
3402 |
# |
# |
3403 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
3404 |
if ($token->{tag_name} eq 'tr' and |
if ($token->{tag_name} eq 'tr' and |
3405 |
$self->{insertion_mode} == IN_ROW_IM) { |
($self->{insertion_mode} & IM_MASK) == IN_ROW_IM) { |
3406 |
## have an element in table scope |
## have an element in table scope |
3407 |
my $i; |
my $i; |
3408 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
3409 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
3442 |
!!!nack ('t231.1'); |
!!!nack ('t231.1'); |
3443 |
next B; |
next B; |
3444 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
3445 |
if ($self->{insertion_mode} == IN_ROW_IM) { |
if (($self->{insertion_mode} & IM_MASK) == IN_ROW_IM) { |
3446 |
## As if </tr> |
## As if </tr> |
3447 |
## have an element in table scope |
## have an element in table scope |
3448 |
my $i; |
my $i; |
3481 |
## reprocess in the "in table body" insertion mode... |
## reprocess in the "in table body" insertion mode... |
3482 |
} |
} |
3483 |
|
|
3484 |
if ($self->{insertion_mode} == IN_TABLE_BODY_IM) { |
if (($self->{insertion_mode} & IM_MASK) == IN_TABLE_BODY_IM) { |
3485 |
## have an element in table scope |
## have an element in table scope |
3486 |
my $i; |
my $i; |
3487 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
3563 |
tbody => 1, tfoot => 1, thead => 1, |
tbody => 1, tfoot => 1, thead => 1, |
3564 |
}->{$token->{tag_name}} and |
}->{$token->{tag_name}} and |
3565 |
$self->{insertion_mode} & ROW_IMS) { |
$self->{insertion_mode} & ROW_IMS) { |
3566 |
if ($self->{insertion_mode} == IN_ROW_IM) { |
if (($self->{insertion_mode} & IM_MASK) == IN_ROW_IM) { |
3567 |
## have an element in table scope |
## have an element in table scope |
3568 |
my $i; |
my $i; |
3569 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
3697 |
} else { |
} else { |
3698 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
3699 |
} |
} |
3700 |
} elsif ($self->{insertion_mode} == IN_COLUMN_GROUP_IM) { |
} elsif (($self->{insertion_mode} & IM_MASK) == IN_COLUMN_GROUP_IM) { |
3701 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
3702 |
if ($token->{data} =~ s/^([\x09\x0A\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0C\x20]+)//) { |
3703 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
3829 |
} elsif ({ |
} elsif ({ |
3830 |
select => 1, input => 1, textarea => 1, |
select => 1, input => 1, textarea => 1, |
3831 |
}->{$token->{tag_name}} or |
}->{$token->{tag_name}} or |
3832 |
($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
(($self->{insertion_mode} & IM_MASK) |
3833 |
|
== IN_SELECT_IN_TABLE_IM and |
3834 |
{ |
{ |
3835 |
caption => 1, table => 1, |
caption => 1, table => 1, |
3836 |
tbody => 1, tfoot => 1, thead => 1, |
tbody => 1, tfoot => 1, thead => 1, |
3952 |
!!!nack ('t291.1'); |
!!!nack ('t291.1'); |
3953 |
!!!next-token; |
!!!next-token; |
3954 |
next B; |
next B; |
3955 |
} elsif ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
} elsif (($self->{insertion_mode} & IM_MASK) |
3956 |
|
== IN_SELECT_IN_TABLE_IM and |
3957 |
{ |
{ |
3958 |
caption => 1, table => 1, tbody => 1, |
caption => 1, table => 1, tbody => 1, |
3959 |
tfoot => 1, thead => 1, tr => 1, td => 1, th => 1, |
tfoot => 1, thead => 1, tr => 1, td => 1, th => 1, |
4996 |
|
|
4997 |
if ($self->{insertion_mode} & TABLE_IMS or |
if ($self->{insertion_mode} & TABLE_IMS or |
4998 |
$self->{insertion_mode} & BODY_TABLE_IMS or |
$self->{insertion_mode} & BODY_TABLE_IMS or |
4999 |
$self->{insertion_mode} == IN_COLUMN_GROUP_IM) { |
($self->{insertion_mode} & IM_MASK) == IN_COLUMN_GROUP_IM) { |
5000 |
!!!cp ('t400.1'); |
!!!cp ('t400.1'); |
5001 |
$self->{insertion_mode} = IN_SELECT_IN_TABLE_IM; |
$self->{insertion_mode} = IN_SELECT_IN_TABLE_IM; |
5002 |
} else { |
} else { |