3476 |
|
|
3477 |
undef $self->{form_element}; |
undef $self->{form_element}; |
3478 |
undef $self->{head_element}; |
undef $self->{head_element}; |
3479 |
|
undef $self->{head_element_inserted}; |
3480 |
$self->{open_elements} = []; |
$self->{open_elements} = []; |
3481 |
undef $self->{inner_html_node}; |
undef $self->{inner_html_node}; |
3482 |
|
|
4084 |
|
|
4085 |
## NOTE: $open_tables->[-1]->[0] is the "current table" element node. |
## NOTE: $open_tables->[-1]->[0] is the "current table" element node. |
4086 |
## NOTE: $open_tables->[-1]->[1] is the "tainted" flag. |
## NOTE: $open_tables->[-1]->[1] is the "tainted" flag. |
4087 |
|
## NOTE: $open_tables->[-1]->[2] is set false when non-Text node inserted. |
4088 |
my $open_tables = [[$self->{open_elements}->[0]->[0]]]; |
my $open_tables = [[$self->{open_elements}->[0]->[0]]]; |
4089 |
|
|
4090 |
my $formatting_end_tag = sub { |
my $formatting_end_tag = sub { |
4358 |
} |
} |
4359 |
}; # $insert_to_foster |
}; # $insert_to_foster |
4360 |
|
|
4361 |
|
## NOTE: When a character is inserted, if the last node that was |
4362 |
|
## inserted by the parser is a Text node and the character has to be |
4363 |
|
## inserted after that node, then the character is appended to the |
4364 |
|
## Text node. However, if any other node is inserted by the parser, |
4365 |
|
## then a new Text node is created and the character is appended as |
4366 |
|
## that Text node. If I'm not wrong, there are only two cases where |
4367 |
|
## this occurs. One is the case where an element node is inserted |
4368 |
|
## to the |head| element. This is covered by using the |
4369 |
|
## |$self->{head_element_inserted}| flag. Another is the case where |
4370 |
|
## an element or comment is inserted into the |table| subtree while |
4371 |
|
## foster parenting happens. This is covered by using the [2] flag |
4372 |
|
## of the |$open_tables| structure. All other cases are handled |
4373 |
|
## simply by calling |manakai_append_text| method. |
4374 |
|
|
4375 |
B: while (1) { |
B: while (1) { |
4376 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
4377 |
!!!cp ('t73'); |
!!!cp ('t73'); |
4419 |
} else { |
} else { |
4420 |
!!!cp ('t87'); |
!!!cp ('t87'); |
4421 |
$self->{open_elements}->[-1]->[0]->append_child ($comment); |
$self->{open_elements}->[-1]->[0]->append_child ($comment); |
4422 |
|
$open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted |
4423 |
} |
} |
4424 |
!!!next-token; |
!!!next-token; |
4425 |
next B; |
next B; |
4549 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
4550 |
if ($token->{data} =~ s/^([\x09\x0A\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0C\x20]+)//) { |
4551 |
unless ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
unless ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
4552 |
!!!cp ('t88.2'); |
if ($self->{head_element_inserted}) { |
4553 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
!!!cp ('t88.3'); |
4554 |
# |
$self->{open_elements}->[-1]->[0]->append_child |
4555 |
|
($self->{document}->create_text_node ($1)); |
4556 |
|
delete $self->{head_element_inserted}; |
4557 |
|
## NOTE: |</head> <link> | |
4558 |
|
# |
4559 |
|
} else { |
4560 |
|
!!!cp ('t88.2'); |
4561 |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
4562 |
|
## NOTE: |</head>  | |
4563 |
|
# |
4564 |
|
} |
4565 |
} else { |
} else { |
4566 |
!!!cp ('t88.1'); |
!!!cp ('t88.1'); |
4567 |
## Ignore the token. |
## Ignore the token. |
4657 |
!!!cp ('t97'); |
!!!cp ('t97'); |
4658 |
} |
} |
4659 |
|
|
4660 |
if ($token->{tag_name} eq 'base') { |
if ($token->{tag_name} eq 'base') { |
4661 |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
4662 |
!!!cp ('t98'); |
!!!cp ('t98'); |
4663 |
## As if </noscript> |
## As if </noscript> |
4664 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
4665 |
!!!parse-error (type => 'in noscript', text => 'base', |
!!!parse-error (type => 'in noscript', text => 'base', |
4666 |
token => $token); |
token => $token); |
4667 |
|
|
4668 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
4669 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
4670 |
} else { |
} else { |
4671 |
!!!cp ('t99'); |
!!!cp ('t99'); |
4672 |
} |
} |
4673 |
|
|
4674 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
4675 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
4676 |
!!!cp ('t100'); |
!!!cp ('t100'); |
4677 |
!!!parse-error (type => 'after head', |
!!!parse-error (type => 'after head', |
4678 |
text => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
4679 |
push @{$self->{open_elements}}, |
push @{$self->{open_elements}}, |
4680 |
[$self->{head_element}, $el_category->{head}]; |
[$self->{head_element}, $el_category->{head}]; |
4681 |
} else { |
$self->{head_element_inserted} = 1; |
4682 |
!!!cp ('t101'); |
} else { |
4683 |
} |
!!!cp ('t101'); |
4684 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
} |
4685 |
pop @{$self->{open_elements}}; |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
4686 |
pop @{$self->{open_elements}} # <head> |
pop @{$self->{open_elements}}; |
4687 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
pop @{$self->{open_elements}} # <head> |
4688 |
!!!nack ('t101.1'); |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
4689 |
!!!next-token; |
!!!nack ('t101.1'); |
4690 |
next B; |
!!!next-token; |
4691 |
|
next B; |
4692 |
} elsif ($token->{tag_name} eq 'link') { |
} elsif ($token->{tag_name} eq 'link') { |
4693 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
4694 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
4697 |
text => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
4698 |
push @{$self->{open_elements}}, |
push @{$self->{open_elements}}, |
4699 |
[$self->{head_element}, $el_category->{head}]; |
[$self->{head_element}, $el_category->{head}]; |
4700 |
|
$self->{head_element_inserted} = 1; |
4701 |
} else { |
} else { |
4702 |
!!!cp ('t103'); |
!!!cp ('t103'); |
4703 |
} |
} |
4730 |
!!!cp ('t103.3'); |
!!!cp ('t103.3'); |
4731 |
# |
# |
4732 |
} |
} |
4733 |
} elsif ($token->{tag_name} eq 'meta') { |
} elsif ($token->{tag_name} eq 'meta') { |
4734 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
4735 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
4736 |
!!!cp ('t104'); |
!!!cp ('t104'); |
4737 |
!!!parse-error (type => 'after head', |
!!!parse-error (type => 'after head', |
4738 |
text => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
4739 |
push @{$self->{open_elements}}, |
push @{$self->{open_elements}}, |
4740 |
[$self->{head_element}, $el_category->{head}]; |
[$self->{head_element}, $el_category->{head}]; |
4741 |
} else { |
$self->{head_element_inserted} = 1; |
4742 |
!!!cp ('t105'); |
} else { |
4743 |
} |
!!!cp ('t105'); |
4744 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
} |
4745 |
my $meta_el = pop @{$self->{open_elements}}; |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
4746 |
|
my $meta_el = pop @{$self->{open_elements}}; |
4747 |
|
|
4748 |
unless ($self->{confident}) { |
unless ($self->{confident}) { |
4749 |
if ($token->{attributes}->{charset}) { |
if ($token->{attributes}->{charset}) { |
4801 |
!!!ack ('t110.1'); |
!!!ack ('t110.1'); |
4802 |
!!!next-token; |
!!!next-token; |
4803 |
next B; |
next B; |
4804 |
} elsif ($token->{tag_name} eq 'title') { |
} elsif ($token->{tag_name} eq 'title') { |
4805 |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
4806 |
!!!cp ('t111'); |
!!!cp ('t111'); |
4807 |
## As if </noscript> |
## As if </noscript> |
4808 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
4809 |
!!!parse-error (type => 'in noscript', text => 'title', |
!!!parse-error (type => 'in noscript', text => 'title', |
4810 |
token => $token); |
token => $token); |
4811 |
|
|
4812 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
4813 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
4814 |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
4815 |
!!!cp ('t112'); |
!!!cp ('t112'); |
4816 |
!!!parse-error (type => 'after head', |
!!!parse-error (type => 'after head', |
4817 |
text => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
4818 |
push @{$self->{open_elements}}, |
push @{$self->{open_elements}}, |
4819 |
[$self->{head_element}, $el_category->{head}]; |
[$self->{head_element}, $el_category->{head}]; |
4820 |
} else { |
$self->{head_element_inserted} = 1; |
4821 |
!!!cp ('t113'); |
} else { |
4822 |
} |
!!!cp ('t113'); |
4823 |
|
} |
4824 |
|
|
4825 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
4826 |
my $parent = defined $self->{head_element} ? $self->{head_element} |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
4827 |
: $self->{open_elements}->[-1]->[0]; |
pop @{$self->{open_elements}} # <head> |
4828 |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
4829 |
pop @{$self->{open_elements}} # <head> |
next B; |
4830 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
} elsif ($token->{tag_name} eq 'style' or |
4831 |
next B; |
$token->{tag_name} eq 'noframes') { |
4832 |
} elsif ($token->{tag_name} eq 'style' or |
## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and |
4833 |
$token->{tag_name} eq 'noframes') { |
## insertion mode IN_HEAD_IM) |
4834 |
## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and |
## NOTE: There is a "as if in head" code clone. |
4835 |
## insertion mode IN_HEAD_IM) |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
4836 |
## NOTE: There is a "as if in head" code clone. |
!!!cp ('t114'); |
4837 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
!!!parse-error (type => 'after head', |
4838 |
!!!cp ('t114'); |
text => $token->{tag_name}, token => $token); |
4839 |
!!!parse-error (type => 'after head', |
push @{$self->{open_elements}}, |
4840 |
text => $token->{tag_name}, token => $token); |
[$self->{head_element}, $el_category->{head}]; |
4841 |
push @{$self->{open_elements}}, |
$self->{head_element_inserted} = 1; |
4842 |
[$self->{head_element}, $el_category->{head}]; |
} else { |
4843 |
} else { |
!!!cp ('t115'); |
4844 |
!!!cp ('t115'); |
} |
4845 |
} |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
4846 |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
pop @{$self->{open_elements}} # <head> |
4847 |
pop @{$self->{open_elements}} # <head> |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
4848 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
next B; |
|
next B; |
|
4849 |
} elsif ($token->{tag_name} eq 'noscript') { |
} elsif ($token->{tag_name} eq 'noscript') { |
4850 |
if ($self->{insertion_mode} == IN_HEAD_IM) { |
if ($self->{insertion_mode} == IN_HEAD_IM) { |
4851 |
!!!cp ('t116'); |
!!!cp ('t116'); |
4867 |
!!!cp ('t118'); |
!!!cp ('t118'); |
4868 |
# |
# |
4869 |
} |
} |
4870 |
} elsif ($token->{tag_name} eq 'script') { |
} elsif ($token->{tag_name} eq 'script') { |
4871 |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
4872 |
!!!cp ('t119'); |
!!!cp ('t119'); |
4873 |
## As if </noscript> |
## As if </noscript> |
4874 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
4875 |
!!!parse-error (type => 'in noscript', text => 'script', |
!!!parse-error (type => 'in noscript', text => 'script', |
4876 |
token => $token); |
token => $token); |
4877 |
|
|
4878 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
4879 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
4880 |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
4881 |
!!!cp ('t120'); |
!!!cp ('t120'); |
4882 |
!!!parse-error (type => 'after head', |
!!!parse-error (type => 'after head', |
4883 |
text => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
4884 |
push @{$self->{open_elements}}, |
push @{$self->{open_elements}}, |
4885 |
[$self->{head_element}, $el_category->{head}]; |
[$self->{head_element}, $el_category->{head}]; |
4886 |
} else { |
$self->{head_element_inserted} = 1; |
4887 |
!!!cp ('t121'); |
} else { |
4888 |
} |
!!!cp ('t121'); |
4889 |
|
} |
4890 |
|
|
4891 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
4892 |
$script_start_tag->(); |
$script_start_tag->(); |
4893 |
pop @{$self->{open_elements}} # <head> |
pop @{$self->{open_elements}} # <head> |
4894 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
4895 |
next B; |
next B; |
4896 |
} elsif ($token->{tag_name} eq 'body' or |
} elsif ($token->{tag_name} eq 'body' or |
4897 |
$token->{tag_name} eq 'frameset') { |
$token->{tag_name} eq 'frameset') { |
4898 |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
4899 |
!!!cp ('t122'); |
!!!cp ('t122'); |
4900 |
## As if </noscript> |
## As if </noscript> |
5586 |
|
|
5587 |
!!!parse-error (type => 'in table:#text', token => $token); |
!!!parse-error (type => 'in table:#text', token => $token); |
5588 |
|
|
5589 |
## As if in body, but insert into foster parent element |
## NOTE: As if in body, but insert into the foster parent element. |
5590 |
## ISSUE: Spec says that "whenever a node would be inserted |
$reconstruct_active_formatting_elements->($insert_to_foster); |
|
## into the current node" while characters might not be |
|
|
## result in a new Text node. |
|
|
$reconstruct_active_formatting_elements->($insert_to_foster); |
|
5591 |
|
|
5592 |
if ($self->{open_elements}->[-1]->[1] & TABLE_ROWS_EL) { |
if ($self->{open_elements}->[-1]->[1] & TABLE_ROWS_EL) { |
5593 |
# MUST |
# MUST |
5594 |
my $foster_parent_element; |
my $foster_parent_element; |
5595 |
my $next_sibling; |
my $next_sibling; |
5596 |
my $prev_sibling; |
my $prev_sibling; |
5597 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
5598 |
if ($self->{open_elements}->[$_]->[1] & TABLE_EL) { |
if ($self->{open_elements}->[$_]->[1] & TABLE_EL) { |
5599 |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
5600 |
if (defined $parent and $parent->node_type == 1) { |
if (defined $parent and $parent->node_type == 1) { |
5601 |
!!!cp ('t196'); |
$foster_parent_element = $parent; |
5602 |
$foster_parent_element = $parent; |
!!!cp ('t196'); |
5603 |
$next_sibling = $self->{open_elements}->[$_]->[0]; |
$next_sibling = $self->{open_elements}->[$_]->[0]; |
5604 |
$prev_sibling = $next_sibling->previous_sibling; |
$prev_sibling = $next_sibling->previous_sibling; |
5605 |
} 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; |
|
|
if (defined $prev_sibling and |
|
|
$prev_sibling->node_type == 3) { |
|
|
!!!cp ('t198'); |
|
|
$prev_sibling->manakai_append_text ($token->{data}); |
|
5606 |
} else { |
} else { |
5607 |
!!!cp ('t199'); |
!!!cp ('t197'); |
5608 |
$foster_parent_element->insert_before |
$foster_parent_element = $self->{open_elements}->[$_ - 1]->[0]; |
5609 |
($self->{document}->create_text_node ($token->{data}), |
$prev_sibling = $foster_parent_element->last_child; |
5610 |
$next_sibling); |
# |
5611 |
} |
} |
5612 |
|
last OE; |
5613 |
|
} |
5614 |
|
} # OE |
5615 |
|
$foster_parent_element = $self->{open_elements}->[0]->[0] and |
5616 |
|
$prev_sibling = $foster_parent_element->last_child |
5617 |
|
unless defined $foster_parent_element; |
5618 |
|
undef $prev_sibling unless $open_tables->[-1]->[2]; # ~node inserted |
5619 |
|
if (defined $prev_sibling and |
5620 |
|
$prev_sibling->node_type == 3) { |
5621 |
|
!!!cp ('t198'); |
5622 |
|
$prev_sibling->manakai_append_text ($token->{data}); |
5623 |
|
} else { |
5624 |
|
!!!cp ('t199'); |
5625 |
|
$foster_parent_element->insert_before |
5626 |
|
($self->{document}->create_text_node ($token->{data}), |
5627 |
|
$next_sibling); |
5628 |
|
} |
5629 |
$open_tables->[-1]->[1] = 1; # tainted |
$open_tables->[-1]->[1] = 1; # tainted |
5630 |
|
$open_tables->[-1]->[2] = 1; # ~node inserted |
5631 |
} else { |
} else { |
5632 |
|
## NOTE: Fragment case or in a foster parent'ed element |
5633 |
|
## (e.g. |<table><span>a|). In fragment case, whether the |
5634 |
|
## character is appended to existing node or a new node is |
5635 |
|
## created is irrelevant, since the foster parent'ed nodes |
5636 |
|
## are discarded and fragment parsing does not invoke any |
5637 |
|
## script. |
5638 |
!!!cp ('t200'); |
!!!cp ('t200'); |
5639 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text |
5640 |
|
($token->{data}); |
5641 |
} |
} |
5642 |
|
|
5643 |
!!!next-token; |
!!!next-token; |
5674 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
5675 |
} |
} |
5676 |
|
|
5677 |
$self->{insertion_mode} = IN_ROW_IM; |
$self->{insertion_mode} = IN_ROW_IM; |
5678 |
if ($token->{tag_name} eq 'tr') { |
if ($token->{tag_name} eq 'tr') { |
5679 |
!!!cp ('t204'); |
!!!cp ('t204'); |
5680 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
5681 |
!!!nack ('t204'); |
$open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted |
5682 |
!!!next-token; |
!!!nack ('t204'); |
5683 |
next B; |
!!!next-token; |
5684 |
} else { |
next B; |
5685 |
!!!cp ('t205'); |
} else { |
5686 |
!!!insert-element ('tr',, $token); |
!!!cp ('t205'); |
5687 |
## reprocess in the "in row" insertion mode |
!!!insert-element ('tr',, $token); |
5688 |
} |
## reprocess in the "in row" insertion mode |
5689 |
} else { |
} |
5690 |
!!!cp ('t206'); |
} else { |
5691 |
} |
!!!cp ('t206'); |
5692 |
|
} |
5693 |
|
|
5694 |
## Clear back to table row context |
## Clear back to table row context |
5695 |
while (not ($self->{open_elements}->[-1]->[1] |
while (not ($self->{open_elements}->[-1]->[1] |
5698 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
5699 |
} |
} |
5700 |
|
|
5701 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
5702 |
$self->{insertion_mode} = IN_CELL_IM; |
$open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted |
5703 |
|
$self->{insertion_mode} = IN_CELL_IM; |
5704 |
|
|
5705 |
push @$active_formatting_elements, ['#marker', '']; |
push @$active_formatting_elements, ['#marker', '']; |
5706 |
|
|
5707 |
!!!nack ('t207.1'); |
!!!nack ('t207.1'); |
5708 |
|
!!!next-token; |
5709 |
|
next B; |
5710 |
|
} elsif ({ |
5711 |
|
caption => 1, col => 1, colgroup => 1, |
5712 |
|
tbody => 1, tfoot => 1, thead => 1, |
5713 |
|
tr => 1, # $self->{insertion_mode} == IN_ROW_IM |
5714 |
|
}->{$token->{tag_name}}) { |
5715 |
|
if ($self->{insertion_mode} == IN_ROW_IM) { |
5716 |
|
## As if </tr> |
5717 |
|
## have an element in table scope |
5718 |
|
my $i; |
5719 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
5720 |
|
my $node = $self->{open_elements}->[$_]; |
5721 |
|
if ($node->[1] & TABLE_ROW_EL) { |
5722 |
|
!!!cp ('t208'); |
5723 |
|
$i = $_; |
5724 |
|
last INSCOPE; |
5725 |
|
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
5726 |
|
!!!cp ('t209'); |
5727 |
|
last INSCOPE; |
5728 |
|
} |
5729 |
|
} # INSCOPE |
5730 |
|
unless (defined $i) { |
5731 |
|
!!!cp ('t210'); |
5732 |
|
## TODO: This type is wrong. |
5733 |
|
!!!parse-error (type => 'unmacthed end tag', |
5734 |
|
text => $token->{tag_name}, token => $token); |
5735 |
|
## Ignore the token |
5736 |
|
!!!nack ('t210.1'); |
5737 |
!!!next-token; |
!!!next-token; |
5738 |
next B; |
next B; |
5739 |
} elsif ({ |
} |
|
caption => 1, col => 1, colgroup => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
tr => 1, # $self->{insertion_mode} == IN_ROW_IM |
|
|
}->{$token->{tag_name}}) { |
|
|
if ($self->{insertion_mode} == IN_ROW_IM) { |
|
|
## 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] & TABLE_ROW_EL) { |
|
|
!!!cp ('t208'); |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
|
!!!cp ('t209'); |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!cp ('t210'); |
|
|
## TODO: This type is wrong. |
|
|
!!!parse-error (type => 'unmacthed end tag', |
|
|
text => $token->{tag_name}, token => $token); |
|
|
## Ignore the token |
|
|
!!!nack ('t210.1'); |
|
|
!!!next-token; |
|
|
next B; |
|
|
} |
|
5740 |
|
|
5741 |
## Clear back to table row context |
## Clear back to table row context |
5742 |
while (not ($self->{open_elements}->[-1]->[1] |
while (not ($self->{open_elements}->[-1]->[1] |
5806 |
!!!cp ('t218'); |
!!!cp ('t218'); |
5807 |
} |
} |
5808 |
|
|
5809 |
if ($token->{tag_name} eq 'col') { |
if ($token->{tag_name} eq 'col') { |
5810 |
## Clear back to table context |
## Clear back to table context |
5811 |
while (not ($self->{open_elements}->[-1]->[1] |
while (not ($self->{open_elements}->[-1]->[1] |
5812 |
& TABLE_SCOPING_EL)) { |
& TABLE_SCOPING_EL)) { |
5813 |
!!!cp ('t219'); |
!!!cp ('t219'); |
5814 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
5815 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
5816 |
} |
} |
5817 |
|
|
5818 |
!!!insert-element ('colgroup',, $token); |
!!!insert-element ('colgroup',, $token); |
5819 |
$self->{insertion_mode} = IN_COLUMN_GROUP_IM; |
$self->{insertion_mode} = IN_COLUMN_GROUP_IM; |
5820 |
## reprocess |
## reprocess |
5821 |
!!!ack-later; |
$open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted |
5822 |
next B; |
!!!ack-later; |
5823 |
} elsif ({ |
next B; |
5824 |
caption => 1, |
} elsif ({ |
5825 |
colgroup => 1, |
caption => 1, |
5826 |
tbody => 1, tfoot => 1, thead => 1, |
colgroup => 1, |
5827 |
}->{$token->{tag_name}}) { |
tbody => 1, tfoot => 1, thead => 1, |
5828 |
## Clear back to table context |
}->{$token->{tag_name}}) { |
5829 |
|
## Clear back to table context |
5830 |
while (not ($self->{open_elements}->[-1]->[1] |
while (not ($self->{open_elements}->[-1]->[1] |
5831 |
& TABLE_SCOPING_EL)) { |
& TABLE_SCOPING_EL)) { |
5832 |
!!!cp ('t220'); |
!!!cp ('t220'); |
5834 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
5835 |
} |
} |
5836 |
|
|
5837 |
push @$active_formatting_elements, ['#marker', ''] |
push @$active_formatting_elements, ['#marker', ''] |
5838 |
if $token->{tag_name} eq 'caption'; |
if $token->{tag_name} eq 'caption'; |
5839 |
|
|
5840 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
5841 |
$self->{insertion_mode} = { |
$open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted |
5842 |
caption => IN_CAPTION_IM, |
$self->{insertion_mode} = { |
5843 |
colgroup => IN_COLUMN_GROUP_IM, |
caption => IN_CAPTION_IM, |
5844 |
tbody => IN_TABLE_BODY_IM, |
colgroup => IN_COLUMN_GROUP_IM, |
5845 |
tfoot => IN_TABLE_BODY_IM, |
tbody => IN_TABLE_BODY_IM, |
5846 |
thead => IN_TABLE_BODY_IM, |
tfoot => IN_TABLE_BODY_IM, |
5847 |
}->{$token->{tag_name}}; |
thead => IN_TABLE_BODY_IM, |
5848 |
!!!next-token; |
}->{$token->{tag_name}}; |
5849 |
!!!nack ('t220.1'); |
!!!next-token; |
5850 |
next B; |
!!!nack ('t220.1'); |
5851 |
} else { |
next B; |
5852 |
die "$0: in table: <>: $token->{tag_name}"; |
} else { |
5853 |
} |
die "$0: in table: <>: $token->{tag_name}"; |
5854 |
|
} |
5855 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
5856 |
!!!parse-error (type => 'not closed', |
!!!parse-error (type => 'not closed', |
5857 |
text => $self->{open_elements}->[-1]->[0] |
text => $self->{open_elements}->[-1]->[0] |
5914 |
!!!cp ('t227.8'); |
!!!cp ('t227.8'); |
5915 |
## NOTE: This is a "as if in head" code clone. |
## NOTE: This is a "as if in head" code clone. |
5916 |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
5917 |
|
$open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted |
5918 |
next B; |
next B; |
5919 |
} else { |
} else { |
5920 |
!!!cp ('t227.7'); |
!!!cp ('t227.7'); |
5925 |
!!!cp ('t227.6'); |
!!!cp ('t227.6'); |
5926 |
## NOTE: This is a "as if in head" code clone. |
## NOTE: This is a "as if in head" code clone. |
5927 |
$script_start_tag->(); |
$script_start_tag->(); |
5928 |
|
$open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted |
5929 |
next B; |
next B; |
5930 |
} else { |
} else { |
5931 |
!!!cp ('t227.5'); |
!!!cp ('t227.5'); |
5941 |
text => $token->{tag_name}, token => $token); |
text => $token->{tag_name}, token => $token); |
5942 |
|
|
5943 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
5944 |
|
$open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted |
5945 |
|
|
5946 |
## TODO: form element pointer |
## TODO: form element pointer |
5947 |
|
|
8226 |
push @{$p->{open_elements}}, [$root, $el_category->{html}]; |
push @{$p->{open_elements}}, [$root, $el_category->{html}]; |
8227 |
|
|
8228 |
undef $p->{head_element}; |
undef $p->{head_element}; |
8229 |
|
undef $p->{head_element_inserted}; |
8230 |
|
|
8231 |
## Step 6 # MUST |
## Step 6 # MUST |
8232 |
$p->_reset_insertion_mode; |
$p->_reset_insertion_mode; |