, [undef, 'html']);
$self->{document}->append_child ($root_element);
push @{$self->{open_elements}}, [$root_element, 'html'];
$self->{application_cache_selection}->(undef);
## NOTE: Reprocess the token.
return; ## Go to the "before head" insertion mode.
## ISSUE: There is an issue in the spec
} # B
die "$0: _tree_construction_root_element: This should never be reached";
} # _tree_construction_root_element
sub _reset_insertion_mode ($) {
my $self = shift;
## Step 1
my $last;
## Step 2
my $i = -1;
my $node = $self->{open_elements}->[$i];
## Step 3
S3: {
## ISSUE: Oops! "If node is the first node in the stack of open
## elements, then set last to true. If the context element of the
## HTML fragment parsing algorithm is neither a td element nor a
## th element, then set node to the context element. (fragment case)":
## The second "if" is in the scope of the first "if"!?
if ($self->{open_elements}->[0]->[0] eq $node->[0]) {
$last = 1;
if (defined $self->{inner_html_node}) {
if ($self->{inner_html_node}->[1] eq 'td' or
$self->{inner_html_node}->[1] eq 'th') {
$Whatpm::HTML::Debug::cp_pass->('t27') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t27'} = 1;
}
#
} else {
$Whatpm::HTML::Debug::cp_pass->('t28') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t28'} = 1;
}
$node = $self->{inner_html_node};
}
}
}
## Step 4..13
my $new_mode = {
select => IN_SELECT_IM,
## NOTE: |option| and |optgroup| do not set
## insertion mode to "in select" by themselves.
td => IN_CELL_IM,
th => IN_CELL_IM,
tr => IN_ROW_IM,
tbody => IN_TABLE_BODY_IM,
thead => IN_TABLE_BODY_IM,
tfoot => IN_TABLE_BODY_IM,
caption => IN_CAPTION_IM,
colgroup => IN_COLUMN_GROUP_IM,
table => IN_TABLE_IM,
head => IN_BODY_IM, # not in head!
body => IN_BODY_IM,
frameset => IN_FRAMESET_IM,
}->{$node->[1]};
$self->{insertion_mode} = $new_mode and return if defined $new_mode;
## Step 14
if ($node->[1] eq 'html') {
unless (defined $self->{head_element}) {
$Whatpm::HTML::Debug::cp_pass->('t29') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t29'} = 1;
}
$self->{insertion_mode} = BEFORE_HEAD_IM;
} else {
## ISSUE: Can this state be reached?
$Whatpm::HTML::Debug::cp_pass->('t30') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t30'} = 1;
}
$self->{insertion_mode} = AFTER_HEAD_IM;
}
return;
} else {
$Whatpm::HTML::Debug::cp_pass->('t31') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t31'} = 1;
}
}
## Step 15
$self->{insertion_mode} = IN_BODY_IM and return if $last;
## Step 16
$i--;
$node = $self->{open_elements}->[$i];
## Step 17
redo S3;
} # S3
die "$0: _reset_insertion_mode: This line should never be reached";
} # _reset_insertion_mode
sub _tree_construction_main ($) {
my $self = shift;
my $active_formatting_elements = [];
my $reconstruct_active_formatting_elements = sub { # MUST
my $insert = shift;
## Step 1
return unless @$active_formatting_elements;
## Step 3
my $i = -1;
my $entry = $active_formatting_elements->[$i];
## Step 2
return if $entry->[0] eq '#marker';
for (@{$self->{open_elements}}) {
if ($entry->[0] eq $_->[0]) {
$Whatpm::HTML::Debug::cp_pass->('t32') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t32'} = 1;
}
return;
}
}
S4: {
## Step 4
last S4 if $active_formatting_elements->[0]->[0] eq $entry->[0];
## Step 5
$i--;
$entry = $active_formatting_elements->[$i];
## Step 6
if ($entry->[0] eq '#marker') {
$Whatpm::HTML::Debug::cp_pass->('t33_1') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t33_1'} = 1;
}
#
} else {
my $in_open_elements;
OE: for (@{$self->{open_elements}}) {
if ($entry->[0] eq $_->[0]) {
$Whatpm::HTML::Debug::cp_pass->('t33') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t33'} = 1;
}
$in_open_elements = 1;
last OE;
}
}
if ($in_open_elements) {
$Whatpm::HTML::Debug::cp_pass->('t34') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t34'} = 1;
}
#
} else {
## NOTE:
X
$Whatpm::HTML::Debug::cp_pass->('t35') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t35'} = 1;
}
redo S4;
}
}
## Step 7
$i++;
$entry = $active_formatting_elements->[$i];
} # S4
S7: {
## Step 8
my $clone = [$entry->[0]->clone_node (0), $entry->[1]];
## Step 9
$insert->($clone->[0]);
push @{$self->{open_elements}}, $clone;
## Step 10
$active_formatting_elements->[$i] = $self->{open_elements}->[-1];
## Step 11
unless ($clone->[0] eq $active_formatting_elements->[-1]->[0]) {
$Whatpm::HTML::Debug::cp_pass->('t36') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t36'} = 1;
}
## Step 7'
$i++;
$entry = $active_formatting_elements->[$i];
redo S7;
}
$Whatpm::HTML::Debug::cp_pass->('t37') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t37'} = 1;
}
} # S7
}; # $reconstruct_active_formatting_elements
my $clear_up_to_marker = sub {
for (reverse 0..$#$active_formatting_elements) {
if ($active_formatting_elements->[$_]->[0] eq '#marker') {
$Whatpm::HTML::Debug::cp_pass->('t38') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t38'} = 1;
}
splice @$active_formatting_elements, $_;
return;
}
}
$Whatpm::HTML::Debug::cp_pass->('t39') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t39'} = 1;
}
}; # $clear_up_to_marker
my $parse_rcdata = sub ($$) {
my ($content_model_flag, $insert) = @_;
## Step 1
my $start_tag_name = $token->{tag_name};
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $start_tag_name]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
## Step 2
$insert->($el); # /context node/->append_child ($el)
## Step 3
$self->{content_model} = $content_model_flag; # CDATA or RCDATA
delete $self->{escape}; # MUST
## Step 4
my $text = '';
$token = $self->_get_next_token;
while ($token->{type} == CHARACTER_TOKEN) { # or until stop tokenizing
$Whatpm::HTML::Debug::cp_pass->('t40') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t40'} = 1;
}
$text .= $token->{data};
$token = $self->_get_next_token;
}
## Step 5
if (length $text) {
$Whatpm::HTML::Debug::cp_pass->('t41') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t41'} = 1;
}
my $text = $self->{document}->create_text_node ($text);
$el->append_child ($text);
}
## Step 6
$self->{content_model} = PCDATA_CONTENT_MODEL;
## Step 7
if ($token->{type} == END_TAG_TOKEN and
$token->{tag_name} eq $start_tag_name) {
$Whatpm::HTML::Debug::cp_pass->('t42') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t42'} = 1;
}
## Ignore the token
} elsif ($content_model_flag == CDATA_CONTENT_MODEL) {
$Whatpm::HTML::Debug::cp_pass->('t43') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t43'} = 1;
}
$self->{parse_error}-> (type => 'in CDATA:#'.$token->{type});
} elsif ($content_model_flag == RCDATA_CONTENT_MODEL) {
$Whatpm::HTML::Debug::cp_pass->('t44') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t44'} = 1;
}
$self->{parse_error}-> (type => 'in RCDATA:#'.$token->{type});
} else {
die "$0: $content_model_flag in parse_rcdata";
}
$token = $self->_get_next_token;
}; # $parse_rcdata
my $script_start_tag = sub ($) {
my $insert = $_[0];
my $script_el;
$script_el = $self->{document}->create_element_ns
(q, [undef, 'script']);
for my $attr_name (keys %{ $token->{attributes}}) {
$script_el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
## TODO: mark as "parser-inserted"
$self->{content_model} = CDATA_CONTENT_MODEL;
delete $self->{escape}; # MUST
my $text = '';
$token = $self->_get_next_token;
while ($token->{type} == CHARACTER_TOKEN) {
$Whatpm::HTML::Debug::cp_pass->('t45') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t45'} = 1;
}
$text .= $token->{data};
$token = $self->_get_next_token;
} # stop if non-character token or tokenizer stops tokenising
if (length $text) {
$Whatpm::HTML::Debug::cp_pass->('t46') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t46'} = 1;
}
$script_el->manakai_append_text ($text);
}
$self->{content_model} = PCDATA_CONTENT_MODEL;
if ($token->{type} == END_TAG_TOKEN and
$token->{tag_name} eq 'script') {
$Whatpm::HTML::Debug::cp_pass->('t47') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t47'} = 1;
}
## Ignore the token
} else {
$Whatpm::HTML::Debug::cp_pass->('t48') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t48'} = 1;
}
$self->{parse_error}-> (type => 'in CDATA:#'.$token->{type});
## ISSUE: And ignore?
## TODO: mark as "already executed"
}
if (defined $self->{inner_html_node}) {
$Whatpm::HTML::Debug::cp_pass->('t49') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t49'} = 1;
}
## TODO: mark as "already executed"
} else {
$Whatpm::HTML::Debug::cp_pass->('t50') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t50'} = 1;
}
## TODO: $old_insertion_point = current insertion point
## TODO: insertion point = just before the next input character
$insert->($script_el);
## TODO: insertion point = $old_insertion_point (might be "undefined")
## TODO: if there is a script that will execute as soon as the parser resume, then...
}
$token = $self->_get_next_token;
}; # $script_start_tag
my $formatting_end_tag = sub {
my $tag_name = shift;
FET: {
## Step 1
my $formatting_element;
my $formatting_element_i_in_active;
AFE: for (reverse 0..$#$active_formatting_elements) {
if ($active_formatting_elements->[$_]->[1] eq $tag_name) {
$Whatpm::HTML::Debug::cp_pass->('t51') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t51'} = 1;
}
$formatting_element = $active_formatting_elements->[$_];
$formatting_element_i_in_active = $_;
last AFE;
} elsif ($active_formatting_elements->[$_]->[0] eq '#marker') {
$Whatpm::HTML::Debug::cp_pass->('t52') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t52'} = 1;
}
last AFE;
}
} # AFE
unless (defined $formatting_element) {
$Whatpm::HTML::Debug::cp_pass->('t53') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t53'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$tag_name);
## Ignore the token
$token = $self->_get_next_token;
return;
}
## has an element in scope
my $in_scope = 1;
my $formatting_element_i_in_open;
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
my $node = $self->{open_elements}->[$_];
if ($node->[0] eq $formatting_element->[0]) {
if ($in_scope) {
$Whatpm::HTML::Debug::cp_pass->('t54') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t54'} = 1;
}
$formatting_element_i_in_open = $_;
last INSCOPE;
} else { # in open elements but not in scope
$Whatpm::HTML::Debug::cp_pass->('t55') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t55'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
return;
}
} elsif ({
table => 1, caption => 1, td => 1, th => 1,
button => 1, marquee => 1, object => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t56') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t56'} = 1;
}
$in_scope = 0;
}
} # INSCOPE
unless (defined $formatting_element_i_in_open) {
$Whatpm::HTML::Debug::cp_pass->('t57') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t57'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
pop @$active_formatting_elements; # $formatting_element
$token = $self->_get_next_token; ## TODO: ok?
return;
}
if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) {
$Whatpm::HTML::Debug::cp_pass->('t58') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t58'} = 1;
}
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
}
## Step 2
my $furthest_block;
my $furthest_block_i_in_open;
OE: for (reverse 0..$#{$self->{open_elements}}) {
my $node = $self->{open_elements}->[$_];
if (not $formatting_category->{$node->[1]} and
#not $phrasing_category->{$node->[1]} and
($special_category->{$node->[1]} or
$scoping_category->{$node->[1]})) {
$Whatpm::HTML::Debug::cp_pass->('t59') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t59'} = 1;
}
$furthest_block = $node;
$furthest_block_i_in_open = $_;
} elsif ($node->[0] eq $formatting_element->[0]) {
$Whatpm::HTML::Debug::cp_pass->('t60') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t60'} = 1;
}
last OE;
}
} # OE
## Step 3
unless (defined $furthest_block) { # MUST
$Whatpm::HTML::Debug::cp_pass->('t61') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t61'} = 1;
}
splice @{$self->{open_elements}}, $formatting_element_i_in_open;
splice @$active_formatting_elements, $formatting_element_i_in_active, 1;
$token = $self->_get_next_token;
return;
}
## Step 4
my $common_ancestor_node = $self->{open_elements}->[$formatting_element_i_in_open - 1];
## Step 5
my $furthest_block_parent = $furthest_block->[0]->parent_node;
if (defined $furthest_block_parent) {
$Whatpm::HTML::Debug::cp_pass->('t62') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t62'} = 1;
}
$furthest_block_parent->remove_child ($furthest_block->[0]);
}
## Step 6
my $bookmark_prev_el
= $active_formatting_elements->[$formatting_element_i_in_active - 1]
->[0];
## Step 7
my $node = $furthest_block;
my $node_i_in_open = $furthest_block_i_in_open;
my $last_node = $furthest_block;
S7: {
## Step 1
$node_i_in_open--;
$node = $self->{open_elements}->[$node_i_in_open];
## Step 2
my $node_i_in_active;
S7S2: {
for (reverse 0..$#$active_formatting_elements) {
if ($active_formatting_elements->[$_]->[0] eq $node->[0]) {
$Whatpm::HTML::Debug::cp_pass->('t63') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t63'} = 1;
}
$node_i_in_active = $_;
last S7S2;
}
}
splice @{$self->{open_elements}}, $node_i_in_open, 1;
redo S7;
} # S7S2
## Step 3
last S7 if $node->[0] eq $formatting_element->[0];
## Step 4
if ($last_node->[0] eq $furthest_block->[0]) {
$Whatpm::HTML::Debug::cp_pass->('t64') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t64'} = 1;
}
$bookmark_prev_el = $node->[0];
}
## Step 5
if ($node->[0]->has_child_nodes ()) {
$Whatpm::HTML::Debug::cp_pass->('t65') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t65'} = 1;
}
my $clone = [$node->[0]->clone_node (0), $node->[1]];
$active_formatting_elements->[$node_i_in_active] = $clone;
$self->{open_elements}->[$node_i_in_open] = $clone;
$node = $clone;
}
## Step 6
$node->[0]->append_child ($last_node->[0]);
## Step 7
$last_node = $node;
## Step 8
redo S7;
} # S7
## Step 8
$common_ancestor_node->[0]->append_child ($last_node->[0]);
## Step 9
my $clone = [$formatting_element->[0]->clone_node (0),
$formatting_element->[1]];
## Step 10
my @cn = @{$furthest_block->[0]->child_nodes};
$clone->[0]->append_child ($_) for @cn;
## Step 11
$furthest_block->[0]->append_child ($clone->[0]);
## Step 12
my $i;
AFE: for (reverse 0..$#$active_formatting_elements) {
if ($active_formatting_elements->[$_]->[0] eq $formatting_element->[0]) {
$Whatpm::HTML::Debug::cp_pass->('t66') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t66'} = 1;
}
splice @$active_formatting_elements, $_, 1;
$i-- and last AFE if defined $i;
} elsif ($active_formatting_elements->[$_]->[0] eq $bookmark_prev_el) {
$Whatpm::HTML::Debug::cp_pass->('t67') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t67'} = 1;
}
$i = $_;
}
} # AFE
splice @$active_formatting_elements, $i + 1, 0, $clone;
## Step 13
undef $i;
OE: for (reverse 0..$#{$self->{open_elements}}) {
if ($self->{open_elements}->[$_]->[0] eq $formatting_element->[0]) {
$Whatpm::HTML::Debug::cp_pass->('t68') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t68'} = 1;
}
splice @{$self->{open_elements}}, $_, 1;
$i-- and last OE if defined $i;
} elsif ($self->{open_elements}->[$_]->[0] eq $furthest_block->[0]) {
$Whatpm::HTML::Debug::cp_pass->('t69') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t69'} = 1;
}
$i = $_;
}
} # OE
splice @{$self->{open_elements}}, $i + 1, 1, $clone;
## Step 14
redo FET;
} # FET
}; # $formatting_end_tag
my $insert_to_current = sub {
$self->{open_elements}->[-1]->[0]->append_child ($_[0]);
}; # $insert_to_current
my $insert_to_foster = sub {
my $child = shift;
if ({
table => 1, tbody => 1, tfoot => 1,
thead => 1, tr => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
# MUST
my $foster_parent_element;
my $next_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) {
$Whatpm::HTML::Debug::cp_pass->('t70') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t70'} = 1;
}
$foster_parent_element = $parent;
$next_sibling = $self->{open_elements}->[$_]->[0];
} else {
$Whatpm::HTML::Debug::cp_pass->('t71') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t71'} = 1;
}
$foster_parent_element
= $self->{open_elements}->[$_ - 1]->[0];
}
last OE;
}
} # OE
$foster_parent_element = $self->{open_elements}->[0]->[0]
unless defined $foster_parent_element;
$foster_parent_element->insert_before
($child, $next_sibling);
} else {
$Whatpm::HTML::Debug::cp_pass->('t72') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t72'} = 1;
}
$self->{open_elements}->[-1]->[0]->append_child ($child);
}
}; # $insert_to_foster
my $insert;
B: {
if ($token->{type} == DOCTYPE_TOKEN) {
$Whatpm::HTML::Debug::cp_pass->('t73') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t73'} = 1;
}
$self->{parse_error}-> (type => 'DOCTYPE in the middle');
## Ignore the token
## Stay in the phase
$token = $self->_get_next_token;
redo B;
} elsif ($token->{type} == END_OF_FILE_TOKEN) {
if ($self->{insertion_mode} & AFTER_HTML_IMS) {
$Whatpm::HTML::Debug::cp_pass->('t74') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t74'} = 1;
}
#
} else {
## Generate implied end tags
while ({
dd => 1, dt => 1, li => 1, p => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t75') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t75'} = 1;
}
pop @{$self->{open_elements}};
}
if (@{$self->{open_elements}} > 2 or
(@{$self->{open_elements}} == 2 and $self->{open_elements}->[1]->[1] ne 'body')) {
$Whatpm::HTML::Debug::cp_pass->('t76') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t76'} = 1;
}
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
} elsif (defined $self->{inner_html_node} and
@{$self->{open_elements}} > 1 and
$self->{open_elements}->[1]->[1] ne 'body') {
## ISSUE: This case is never reached.
$Whatpm::HTML::Debug::cp_pass->('t77') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t77'} = 1;
}
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
} else {
$Whatpm::HTML::Debug::cp_pass->('t78') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t78'} = 1;
}
}
## ISSUE: There is an issue in the spec.
}
## Stop parsing
last B;
} elsif ($token->{type} == START_TAG_TOKEN and
$token->{tag_name} eq 'html') {
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
$Whatpm::HTML::Debug::cp_pass->('t79') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t79'} = 1;
}
$self->{parse_error}-> (type => 'after html:html');
$self->{insertion_mode} = AFTER_BODY_IM;
} elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {
$Whatpm::HTML::Debug::cp_pass->('t80') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t80'} = 1;
}
$self->{parse_error}-> (type => 'after html:html');
$self->{insertion_mode} = AFTER_FRAMESET_IM;
} else {
$Whatpm::HTML::Debug::cp_pass->('t81') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t81'} = 1;
}
}
$Whatpm::HTML::Debug::cp_pass->('t82') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t82'} = 1;
}
$self->{parse_error}-> (type => 'not first start tag');
my $top_el = $self->{open_elements}->[0]->[0];
for my $attr_name (keys %{$token->{attributes}}) {
unless ($top_el->has_attribute_ns (undef, $attr_name)) {
$Whatpm::HTML::Debug::cp_pass->('t84') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t84'} = 1;
}
$top_el->set_attribute_ns
(undef, [undef, $attr_name],
$token->{attributes}->{$attr_name}->{value});
}
}
$token = $self->_get_next_token;
redo B;
} elsif ($token->{type} == COMMENT_TOKEN) {
my $comment = $self->{document}->create_comment ($token->{data});
if ($self->{insertion_mode} & AFTER_HTML_IMS) {
$Whatpm::HTML::Debug::cp_pass->('t85') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t85'} = 1;
}
$self->{document}->append_child ($comment);
} elsif ($self->{insertion_mode} == AFTER_BODY_IM) {
$Whatpm::HTML::Debug::cp_pass->('t86') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t86'} = 1;
}
$self->{open_elements}->[0]->[0]->append_child ($comment);
} else {
$Whatpm::HTML::Debug::cp_pass->('t87') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t87'} = 1;
}
$self->{open_elements}->[-1]->[0]->append_child ($comment);
}
$token = $self->_get_next_token;
redo B;
} elsif ($self->{insertion_mode} & HEAD_IMS) {
if ($token->{type} == CHARACTER_TOKEN) {
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1);
unless (length $token->{data}) {
$Whatpm::HTML::Debug::cp_pass->('t88') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t88'} = 1;
}
$token = $self->_get_next_token;
redo B;
}
}
if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t89') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t89'} = 1;
}
## As if
$self->{head_element} = $self->{document}->create_element_ns
(q, [undef, 'head']);
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
## Reprocess in the "in head" insertion mode...
pop @{$self->{open_elements}};
## Reprocess in the "after head" insertion mode...
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
$Whatpm::HTML::Debug::cp_pass->('t90') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t90'} = 1;
}
## As if
pop @{$self->{open_elements}};
$self->{parse_error}-> (type => 'in noscript:#character');
## Reprocess in the "in head" insertion mode...
## As if
pop @{$self->{open_elements}};
## Reprocess in the "after head" insertion mode...
} elsif ($self->{insertion_mode} == IN_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t91') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t91'} = 1;
}
pop @{$self->{open_elements}};
## Reprocess in the "after head" insertion mode...
} else {
$Whatpm::HTML::Debug::cp_pass->('t92') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t92'} = 1;
}
}
## "after head" insertion mode
## As if
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, 'body']);
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, 'body'];
}
$self->{insertion_mode} = IN_BODY_IM;
## reprocess
redo B;
} elsif ($token->{type} == START_TAG_TOKEN) {
if ($token->{tag_name} eq 'head') {
if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t93') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t93'} = 1;
}
$self->{head_element} = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$self->{head_element}->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
push @{$self->{open_elements}}, [$self->{head_element}, $token->{tag_name}];
$self->{insertion_mode} = IN_HEAD_IM;
$token = $self->_get_next_token;
redo B;
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t94') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t94'} = 1;
}
#
} else {
$Whatpm::HTML::Debug::cp_pass->('t95') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t95'} = 1;
}
$self->{parse_error}-> (type => 'in head:head'); # or in head noscript
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t96') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t96'} = 1;
}
## As if
$self->{head_element} = $self->{document}->create_element_ns
(q, [undef, 'head']);
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
$self->{insertion_mode} = IN_HEAD_IM;
## Reprocess in the "in head" insertion mode...
} else {
$Whatpm::HTML::Debug::cp_pass->('t97') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t97'} = 1;
}
}
if ($token->{tag_name} eq 'base') {
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
$Whatpm::HTML::Debug::cp_pass->('t98') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t98'} = 1;
}
## As if
pop @{$self->{open_elements}};
$self->{parse_error}-> (type => 'in noscript:base');
$self->{insertion_mode} = IN_HEAD_IM;
## Reprocess in the "in head" insertion mode...
} else {
$Whatpm::HTML::Debug::cp_pass->('t99') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t99'} = 1;
}
}
## NOTE: There is a "as if in head" code clone.
if ($self->{insertion_mode} == AFTER_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t100') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t100'} = 1;
}
$self->{parse_error}-> (type => 'after head:'.$token->{tag_name});
push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
} else {
$Whatpm::HTML::Debug::cp_pass->('t101') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t101'} = 1;
}
}
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
pop @{$self->{open_elements}}
if $self->{insertion_mode} == AFTER_HEAD_IM;
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'link') {
## NOTE: There is a "as if in head" code clone.
if ($self->{insertion_mode} == AFTER_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t102') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t102'} = 1;
}
$self->{parse_error}-> (type => 'after head:'.$token->{tag_name});
push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
} else {
$Whatpm::HTML::Debug::cp_pass->('t103') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t103'} = 1;
}
}
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
pop @{$self->{open_elements}}
if $self->{insertion_mode} == AFTER_HEAD_IM;
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'meta') {
## NOTE: There is a "as if in head" code clone.
if ($self->{insertion_mode} == AFTER_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t104') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t104'} = 1;
}
$self->{parse_error}-> (type => 'after head:'.$token->{tag_name});
push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
} else {
$Whatpm::HTML::Debug::cp_pass->('t105') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t105'} = 1;
}
}
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
unless ($self->{confident}) {
if ($token->{attributes}->{charset}) { ## TODO: And if supported
$Whatpm::HTML::Debug::cp_pass->('t106') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t106'} = 1;
}
$self->{change_encoding}
->($self, $token->{attributes}->{charset}->{value});
$meta_el->[0]->get_attribute_node_ns (undef, 'charset')
->set_user_data (manakai_has_reference =>
$token->{attributes}->{charset}
->{has_reference});
} elsif ($token->{attributes}->{content}) {
## ISSUE: Algorithm name in the spec was incorrect so that not linked to the definition.
if ($token->{attributes}->{content}->{value}
=~ /\A[^;]*;[\x09-\x0D\x20]*[Cc][Hh][Aa][Rr][Ss][Ee][Tt]
[\x09-\x0D\x20]*=
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'|
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) {
$Whatpm::HTML::Debug::cp_pass->('t107') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t107'} = 1;
}
$self->{change_encoding}
->($self, defined $1 ? $1 : defined $2 ? $2 : $3);
$meta_el->[0]->get_attribute_node_ns (undef, 'content')
->set_user_data (manakai_has_reference =>
$token->{attributes}->{content}
->{has_reference});
} else {
$Whatpm::HTML::Debug::cp_pass->('t108') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t108'} = 1;
}
}
}
} else {
if ($token->{attributes}->{charset}) {
$Whatpm::HTML::Debug::cp_pass->('t109') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t109'} = 1;
}
$meta_el->[0]->get_attribute_node_ns (undef, 'charset')
->set_user_data (manakai_has_reference =>
$token->{attributes}->{charset}
->{has_reference});
}
if ($token->{attributes}->{content}) {
$Whatpm::HTML::Debug::cp_pass->('t110') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t110'} = 1;
}
$meta_el->[0]->get_attribute_node_ns (undef, 'content')
->set_user_data (manakai_has_reference =>
$token->{attributes}->{content}
->{has_reference});
}
}
pop @{$self->{open_elements}}
if $self->{insertion_mode} == AFTER_HEAD_IM;
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'title') {
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
$Whatpm::HTML::Debug::cp_pass->('t111') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t111'} = 1;
}
## As if
pop @{$self->{open_elements}};
$self->{parse_error}-> (type => 'in noscript:title');
$self->{insertion_mode} = IN_HEAD_IM;
## Reprocess in the "in head" insertion mode...
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t112') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t112'} = 1;
}
$self->{parse_error}-> (type => 'after head:'.$token->{tag_name});
push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
} else {
$Whatpm::HTML::Debug::cp_pass->('t113') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t113'} = 1;
}
}
## NOTE: There is a "as if in head" code clone.
my $parent = defined $self->{head_element} ? $self->{head_element}
: $self->{open_elements}->[-1]->[0];
$parse_rcdata->(RCDATA_CONTENT_MODEL,
sub { $parent->append_child ($_[0]) });
pop @{$self->{open_elements}}
if $self->{insertion_mode} == AFTER_HEAD_IM;
redo B;
} elsif ($token->{tag_name} eq 'style') {
## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and
## insertion mode IN_HEAD_IM)
## NOTE: There is a "as if in head" code clone.
if ($self->{insertion_mode} == AFTER_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t114') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t114'} = 1;
}
$self->{parse_error}-> (type => 'after head:'.$token->{tag_name});
push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
} else {
$Whatpm::HTML::Debug::cp_pass->('t115') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t115'} = 1;
}
}
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current);
pop @{$self->{open_elements}}
if $self->{insertion_mode} == AFTER_HEAD_IM;
redo B;
} elsif ($token->{tag_name} eq 'noscript') {
if ($self->{insertion_mode} == IN_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t116') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t116'} = 1;
}
## NOTE: and scripting is disalbed
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
$self->{insertion_mode} = IN_HEAD_NOSCRIPT_IM;
$token = $self->_get_next_token;
redo B;
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
$Whatpm::HTML::Debug::cp_pass->('t117') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t117'} = 1;
}
$self->{parse_error}-> (type => 'in noscript:noscript');
## Ignore the token
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t118') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t118'} = 1;
}
#
}
} elsif ($token->{tag_name} eq 'script') {
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
$Whatpm::HTML::Debug::cp_pass->('t119') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t119'} = 1;
}
## As if
pop @{$self->{open_elements}};
$self->{parse_error}-> (type => 'in noscript:script');
$self->{insertion_mode} = IN_HEAD_IM;
## Reprocess in the "in head" insertion mode...
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t120') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t120'} = 1;
}
$self->{parse_error}-> (type => 'after head:'.$token->{tag_name});
push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
} else {
$Whatpm::HTML::Debug::cp_pass->('t121') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t121'} = 1;
}
}
## NOTE: There is a "as if in head" code clone.
$script_start_tag->($insert_to_current);
pop @{$self->{open_elements}}
if $self->{insertion_mode} == AFTER_HEAD_IM;
redo B;
} elsif ($token->{tag_name} eq 'body' or
$token->{tag_name} eq 'frameset') {
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
$Whatpm::HTML::Debug::cp_pass->('t122') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t122'} = 1;
}
## As if
pop @{$self->{open_elements}};
$self->{parse_error}-> (type => 'in noscript:'.$token->{tag_name});
## Reprocess in the "in head" insertion mode...
## As if
pop @{$self->{open_elements}};
## Reprocess in the "after head" insertion mode...
} elsif ($self->{insertion_mode} == IN_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t124') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t124'} = 1;
}
pop @{$self->{open_elements}};
## Reprocess in the "after head" insertion mode...
} else {
$Whatpm::HTML::Debug::cp_pass->('t125') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t125'} = 1;
}
}
## "after head" insertion mode
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
if ($token->{tag_name} eq 'body') {
$Whatpm::HTML::Debug::cp_pass->('t126') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t126'} = 1;
}
$self->{insertion_mode} = IN_BODY_IM;
} elsif ($token->{tag_name} eq 'frameset') {
$Whatpm::HTML::Debug::cp_pass->('t127') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t127'} = 1;
}
$self->{insertion_mode} = IN_FRAMESET_IM;
} else {
die "$0: tag name: $self->{tag_name}";
}
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t128') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t128'} = 1;
}
#
}
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
$Whatpm::HTML::Debug::cp_pass->('t129') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t129'} = 1;
}
## As if
pop @{$self->{open_elements}};
$self->{parse_error}-> (type => 'in noscript:/'.$token->{tag_name});
## Reprocess in the "in head" insertion mode...
## As if
pop @{$self->{open_elements}};
## Reprocess in the "after head" insertion mode...
} elsif ($self->{insertion_mode} == IN_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t130') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t130'} = 1;
}
## As if
pop @{$self->{open_elements}};
## Reprocess in the "after head" insertion mode...
} else {
$Whatpm::HTML::Debug::cp_pass->('t131') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t131'} = 1;
}
}
## "after head" insertion mode
## As if
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, 'body']);
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, 'body'];
}
$self->{insertion_mode} = IN_BODY_IM;
## reprocess
redo B;
} elsif ($token->{type} == END_TAG_TOKEN) {
if ($token->{tag_name} eq 'head') {
if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t132') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t132'} = 1;
}
## As if
$self->{head_element} = $self->{document}->create_element_ns
(q, [undef, 'head']);
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
## Reprocess in the "in head" insertion mode...
pop @{$self->{open_elements}};
$self->{insertion_mode} = AFTER_HEAD_IM;
$token = $self->_get_next_token;
redo B;
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
$Whatpm::HTML::Debug::cp_pass->('t133') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t133'} = 1;
}
## As if
pop @{$self->{open_elements}};
$self->{parse_error}-> (type => 'in noscript:/head');
## Reprocess in the "in head" insertion mode...
pop @{$self->{open_elements}};
$self->{insertion_mode} = AFTER_HEAD_IM;
$token = $self->_get_next_token;
redo B;
} elsif ($self->{insertion_mode} == IN_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t134') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t134'} = 1;
}
pop @{$self->{open_elements}};
$self->{insertion_mode} = AFTER_HEAD_IM;
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t135') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t135'} = 1;
}
#
}
} elsif ($token->{tag_name} eq 'noscript') {
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
$Whatpm::HTML::Debug::cp_pass->('t136') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t136'} = 1;
}
pop @{$self->{open_elements}};
$self->{insertion_mode} = IN_HEAD_IM;
$token = $self->_get_next_token;
redo B;
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t137') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t137'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:noscript');
## Ignore the token ## ISSUE: An issue in the spec.
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t138') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t138'} = 1;
}
#
}
} elsif ({
body => 1, html => 1,
}->{$token->{tag_name}}) {
if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t139') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t139'} = 1;
}
## As if
$self->{head_element} = $self->{document}->create_element_ns
(q, [undef, 'head']);
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
$self->{insertion_mode} = IN_HEAD_IM;
## Reprocess in the "in head" insertion mode...
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
$Whatpm::HTML::Debug::cp_pass->('t140') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t140'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t141') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t141'} = 1;
}
}
#
} elsif ({
p => 1, br => 1,
}->{$token->{tag_name}}) {
if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t142') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t142'} = 1;
}
## As if
$self->{head_element} = $self->{document}->create_element_ns
(q, [undef, 'head']);
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element});
push @{$self->{open_elements}}, [$self->{head_element}, 'head'];
$self->{insertion_mode} = IN_HEAD_IM;
## Reprocess in the "in head" insertion mode...
} else {
$Whatpm::HTML::Debug::cp_pass->('t143') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t143'} = 1;
}
}
#
} else {
if ($self->{insertion_mode} == AFTER_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t144') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t144'} = 1;
}
#
} else {
$Whatpm::HTML::Debug::cp_pass->('t145') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t145'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
}
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
$Whatpm::HTML::Debug::cp_pass->('t146') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t146'} = 1;
}
## As if
pop @{$self->{open_elements}};
$self->{parse_error}-> (type => 'in noscript:/'.$token->{tag_name});
## Reprocess in the "in head" insertion mode...
## As if
pop @{$self->{open_elements}};
## Reprocess in the "after head" insertion mode...
} elsif ($self->{insertion_mode} == IN_HEAD_IM) {
$Whatpm::HTML::Debug::cp_pass->('t147') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t147'} = 1;
}
## As if
pop @{$self->{open_elements}};
## Reprocess in the "after head" insertion mode...
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {
## ISSUE: This case cannot be reached?
$Whatpm::HTML::Debug::cp_pass->('t148') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t148'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token ## ISSUE: An issue in the spec.
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t149') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t149'} = 1;
}
}
## "after head" insertion mode
## As if
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, 'body']);
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, 'body'];
}
$self->{insertion_mode} = IN_BODY_IM;
## reprocess
redo B;
} else {
die "$0: $token->{type}: Unknown token type";
}
## ISSUE: An issue in the spec.
} elsif ($self->{insertion_mode} & BODY_IMS) {
if ($token->{type} == CHARACTER_TOKEN) {
$Whatpm::HTML::Debug::cp_pass->('t150') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t150'} = 1;
}
## NOTE: There 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});
$token = $self->_get_next_token;
redo B;
} elsif ($token->{type} == START_TAG_TOKEN) {
if ({
caption => 1, col => 1, colgroup => 1, tbody => 1,
td => 1, tfoot => 1, th => 1, thead => 1, tr => 1,
}->{$token->{tag_name}}) {
if ($self->{insertion_mode} == IN_CELL_IM) {
## 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') {
$Whatpm::HTML::Debug::cp_pass->('t151') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t151'} = 1;
}
$tn = $node->[1];
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t152') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t152'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $tn) {
$Whatpm::HTML::Debug::cp_pass->('t153') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t153'} = 1;
}
## TODO: This error type is wrong.
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
$Whatpm::HTML::Debug::cp_pass->('t154') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t154'} = 1;
}
## Close the cell
unshift @{$self->{token}}, $token; # >
$token = {type => END_TAG_TOKEN, tag_name => $tn};
redo B;
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) {
$self->{parse_error}-> (type => 'not closed:caption');
## As if
## 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 'caption') {
$Whatpm::HTML::Debug::cp_pass->('t155') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t155'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t156') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t156'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t157') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t157'} = 1;
}
## TODO: this type is wrong.
$self->{parse_error}-> (type => 'unmatched end tag:caption');
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
## generate implied end tags
while ({
dd => 1, dt => 1, li => 1, p => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t158') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t158'} = 1;
}
pop @{$self->{open_elements}};
}
if ($self->{open_elements}->[-1]->[1] ne 'caption') {
$Whatpm::HTML::Debug::cp_pass->('t159') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t159'} = 1;
}
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
} else {
$Whatpm::HTML::Debug::cp_pass->('t160') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t160'} = 1;
}
}
splice @{$self->{open_elements}}, $i;
$clear_up_to_marker->();
$self->{insertion_mode} = IN_TABLE_IM;
## reprocess
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t161') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t161'} = 1;
}
#
}
} else {
$Whatpm::HTML::Debug::cp_pass->('t162') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t162'} = 1;
}
#
}
} elsif ($token->{type} == END_TAG_TOKEN) {
if ($token->{tag_name} eq 'td' or $token->{tag_name} eq 'th') {
if ($self->{insertion_mode} == IN_CELL_IM) {
## 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}) {
$Whatpm::HTML::Debug::cp_pass->('t163') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t163'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t164') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t164'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t165') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t165'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
## generate implied end tags
while ({
dd => 1, dt => 1, li => 1, p => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t166') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t166'} = 1;
}
pop @{$self->{open_elements}};
}
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
$Whatpm::HTML::Debug::cp_pass->('t167') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t167'} = 1;
}
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
} else {
$Whatpm::HTML::Debug::cp_pass->('t168') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t168'} = 1;
}
}
splice @{$self->{open_elements}}, $i;
$clear_up_to_marker->();
$self->{insertion_mode} = IN_ROW_IM;
$token = $self->_get_next_token;
redo B;
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) {
$Whatpm::HTML::Debug::cp_pass->('t169') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t169'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t170') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t170'} = 1;
}
#
}
} elsif ($token->{tag_name} eq 'caption') {
if ($self->{insertion_mode} == IN_CAPTION_IM) {
## 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 $token->{tag_name}) {
$Whatpm::HTML::Debug::cp_pass->('t171') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t171'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t172') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t172'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t173') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t173'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
## generate implied end tags
while ({
dd => 1, dt => 1, li => 1, p => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t174') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t174'} = 1;
}
pop @{$self->{open_elements}};
}
if ($self->{open_elements}->[-1]->[1] ne 'caption') {
$Whatpm::HTML::Debug::cp_pass->('t175') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t175'} = 1;
}
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
} else {
$Whatpm::HTML::Debug::cp_pass->('t176') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t176'} = 1;
}
}
splice @{$self->{open_elements}}, $i;
$clear_up_to_marker->();
$self->{insertion_mode} = IN_TABLE_IM;
$token = $self->_get_next_token;
redo B;
} elsif ($self->{insertion_mode} == IN_CELL_IM) {
$Whatpm::HTML::Debug::cp_pass->('t177') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t177'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t178') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t178'} = 1;
}
#
}
} elsif ({
table => 1, tbody => 1, tfoot => 1,
thead => 1, tr => 1,
}->{$token->{tag_name}} and
$self->{insertion_mode} == IN_CELL_IM) {
## 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}) {
$Whatpm::HTML::Debug::cp_pass->('t179') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t179'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') {
$Whatpm::HTML::Debug::cp_pass->('t180') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t180'} = 1;
}
$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]}) {
$Whatpm::HTML::Debug::cp_pass->('t181') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t181'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t182') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t182'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t183') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t183'} = 1;
}
}
## Close the cell
unshift @{$self->{token}}, $token; # ?>
$token = {type => END_TAG_TOKEN, tag_name => $tn};
redo B;
} elsif ($token->{tag_name} eq 'table' and
$self->{insertion_mode} == IN_CAPTION_IM) {
$self->{parse_error}-> (type => 'not closed:caption');
## As if
## 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 'caption') {
$Whatpm::HTML::Debug::cp_pass->('t184') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t184'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t185') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t185'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t186') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t186'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:caption');
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
## generate implied end tags
while ({
dd => 1, dt => 1, li => 1, p => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t187') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t187'} = 1;
}
pop @{$self->{open_elements}};
}
if ($self->{open_elements}->[-1]->[1] ne 'caption') {
$Whatpm::HTML::Debug::cp_pass->('t188') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t188'} = 1;
}
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
} else {
$Whatpm::HTML::Debug::cp_pass->('t189') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t189'} = 1;
}
}
splice @{$self->{open_elements}}, $i;
$clear_up_to_marker->();
$self->{insertion_mode} = IN_TABLE_IM;
## reprocess
redo B;
} elsif ({
body => 1, col => 1, colgroup => 1, html => 1,
}->{$token->{tag_name}}) {
if ($self->{insertion_mode} & BODY_TABLE_IMS) {
$Whatpm::HTML::Debug::cp_pass->('t190') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t190'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t191') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t191'} = 1;
}
#
}
} elsif ({
tbody => 1, tfoot => 1,
thead => 1, tr => 1,
}->{$token->{tag_name}} and
$self->{insertion_mode} == IN_CAPTION_IM) {
$Whatpm::HTML::Debug::cp_pass->('t192') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t192'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t193') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t193'} = 1;
}
#
}
} else {
die "$0: $token->{type}: Unknown token type";
}
$insert = $insert_to_current;
#
} elsif ($self->{insertion_mode} & TABLE_IMS) {
if ($token->{type} == CHARACTER_TOKEN) {
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1);
unless (length $token->{data}) {
$Whatpm::HTML::Debug::cp_pass->('t194') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t194'} = 1;
}
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t195') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t195'} = 1;
}
}
}
$self->{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,
}->{$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) {
$Whatpm::HTML::Debug::cp_pass->('t196') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t196'} = 1;
}
$foster_parent_element = $parent;
$next_sibling = $self->{open_elements}->[$_]->[0];
$prev_sibling = $next_sibling->previous_sibling;
} else {
$Whatpm::HTML::Debug::cp_pass->('t197') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t197'} = 1;
}
$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) {
$Whatpm::HTML::Debug::cp_pass->('t198') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t198'} = 1;
}
$prev_sibling->manakai_append_text ($token->{data});
} else {
$Whatpm::HTML::Debug::cp_pass->('t199') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t199'} = 1;
}
$foster_parent_element->insert_before
($self->{document}->create_text_node ($token->{data}),
$next_sibling);
}
} else {
$Whatpm::HTML::Debug::cp_pass->('t200') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t200'} = 1;
}
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data});
}
$token = $self->_get_next_token;
redo B;
} elsif ($token->{type} == START_TAG_TOKEN) {
if ({
tr => ($self->{insertion_mode} != IN_ROW_IM),
th => 1, td => 1,
}->{$token->{tag_name}}) {
if ($self->{insertion_mode} == IN_TABLE_IM) {
## Clear back to table context
while ($self->{open_elements}->[-1]->[1] ne 'table' and
$self->{open_elements}->[-1]->[1] ne 'html') {
$Whatpm::HTML::Debug::cp_pass->('t201') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t201'} = 1;
}
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
pop @{$self->{open_elements}};
}
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, 'tbody']);
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, 'tbody'];
}
$self->{insertion_mode} = IN_TABLE_BODY_IM;
## reprocess in the "in table body" insertion mode...
}
if ($self->{insertion_mode} == IN_TABLE_BODY_IM) {
unless ($token->{tag_name} eq 'tr') {
$Whatpm::HTML::Debug::cp_pass->('t202') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t202'} = 1;
}
$self->{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]}) {
$Whatpm::HTML::Debug::cp_pass->('t203') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t203'} = 1;
}
## ISSUE: Can this case be reached?
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
pop @{$self->{open_elements}};
}
$self->{insertion_mode} = IN_ROW_IM;
if ($token->{tag_name} eq 'tr') {
$Whatpm::HTML::Debug::cp_pass->('t204') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t204'} = 1;
}
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t205') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t205'} = 1;
}
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, 'tr']);
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, 'tr'];
}
## reprocess in the "in row" insertion mode
}
} else {
$Whatpm::HTML::Debug::cp_pass->('t206') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t206'} = 1;
}
}
## Clear back to table row context
while (not {
tr => 1, html => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t207') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t207'} = 1;
}
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
pop @{$self->{open_elements}};
}
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
$self->{insertion_mode} = IN_CELL_IM;
push @$active_formatting_elements, ['#marker', ''];
$token = $self->_get_next_token;
redo B;
} 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
## 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') {
$Whatpm::HTML::Debug::cp_pass->('t208') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t208'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
html => 1,
## NOTE: This element does not appear here, maybe.
table => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t209') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t209'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t210') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t210'} = 1;
}
## TODO: This type is wrong.
$self->{parse_error}-> (type => 'unmacthed end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
## Clear back to table row context
while (not {
tr => 1, html => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t211') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t211'} = 1;
}
## ISSUE: Can this case be reached?
$self->{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_IM;
if ($token->{tag_name} eq 'tr') {
$Whatpm::HTML::Debug::cp_pass->('t212') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t212'} = 1;
}
## reprocess
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t213') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t213'} = 1;
}
## reprocess in the "in table body" insertion mode...
}
}
if ($self->{insertion_mode} == IN_TABLE_BODY_IM) {
## have an element in table scope
my $i;
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
my $node = $self->{open_elements}->[$_];
if ({
tbody => 1, thead => 1, tfoot => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t214') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t214'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t215') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t215'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t216') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t216'} = 1;
}
## TODO: This erorr type ios wrong.
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_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]}) {
$Whatpm::HTML::Debug::cp_pass->('t217') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t217'} = 1;
}
## ISSUE: Can this state be reached?
$self->{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_IM;
## reprocess in "in table" insertion mode...
} else {
$Whatpm::HTML::Debug::cp_pass->('t218') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t218'} = 1;
}
}
if ($token->{tag_name} eq 'col') {
## Clear back to table context
while ($self->{open_elements}->[-1]->[1] ne 'table' and
$self->{open_elements}->[-1]->[1] ne 'html') {
$Whatpm::HTML::Debug::cp_pass->('t219') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t219'} = 1;
}
## ISSUE: Can this state be reached?
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
pop @{$self->{open_elements}};
}
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, 'colgroup']);
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, 'colgroup'];
}
$self->{insertion_mode} = IN_COLUMN_GROUP_IM;
## reprocess
redo B;
} elsif ({
caption => 1,
colgroup => 1,
tbody => 1, tfoot => 1, thead => 1,
}->{$token->{tag_name}}) {
## Clear back to table context
while ($self->{open_elements}->[-1]->[1] ne 'table' and
$self->{open_elements}->[-1]->[1] ne 'html') {
$Whatpm::HTML::Debug::cp_pass->('t220') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t220'} = 1;
}
## ISSUE: Can this state be reached?
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
pop @{$self->{open_elements}};
}
push @$active_formatting_elements, ['#marker', '']
if $token->{tag_name} eq 'caption';
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
$self->{insertion_mode} = {
caption => IN_CAPTION_IM,
colgroup => IN_COLUMN_GROUP_IM,
tbody => IN_TABLE_BODY_IM,
tfoot => IN_TABLE_BODY_IM,
thead => IN_TABLE_BODY_IM,
}->{$token->{tag_name}};
$token = $self->_get_next_token;
redo B;
} else {
die "$0: in table: <>: $token->{tag_name}";
}
} elsif ($token->{tag_name} eq 'table') {
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
## As if
## 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') {
$Whatpm::HTML::Debug::cp_pass->('t221') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t221'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
#table => 1,
html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t222') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t222'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t223') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t223'} = 1;
}
## TODO: The following is wrong, maybe.
$self->{parse_error}-> (type => 'unmatched end tag:table');
## Ignore tokens
$token = $self->_get_next_token;
redo B;
}
## generate implied end tags
while ({
dd => 1, dt => 1, li => 1, p => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t224') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t224'} = 1;
}
pop @{$self->{open_elements}};
}
if ($self->{open_elements}->[-1]->[1] ne 'table') {
$Whatpm::HTML::Debug::cp_pass->('t225') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t225'} = 1;
}
## ISSUE: Can this case be reached?
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
} else {
$Whatpm::HTML::Debug::cp_pass->('t226') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t226'} = 1;
}
}
splice @{$self->{open_elements}}, $i;
$self->_reset_insertion_mode;
## reprocess
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t227') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t227'} = 1;
}
$self->{parse_error}-> (type => 'in table:'.$token->{tag_name});
$insert = $insert_to_foster;
#
}
} elsif ($token->{type} == END_TAG_TOKEN) {
if ($token->{tag_name} eq 'tr' and
$self->{insertion_mode} == IN_ROW_IM) {
## 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}) {
$Whatpm::HTML::Debug::cp_pass->('t228') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t228'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t229') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t229'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t230') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t230'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t232') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t232'} = 1;
}
}
## Clear back to table row context
while (not {
tr => 1, html => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t231') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t231'} = 1;
}
## ISSUE: Can this state be reached?
$self->{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_IM;
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'table') {
if ($self->{insertion_mode} == IN_ROW_IM) {
## As if
## 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') {
$Whatpm::HTML::Debug::cp_pass->('t233') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t233'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t234') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t234'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t235') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t235'} = 1;
}
## TODO: The following is wrong.
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{type});
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
## Clear back to table row context
while (not {
tr => 1, html => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t236') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t236'} = 1;
}
## ISSUE: Can this state be reached?
$self->{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_IM;
## reprocess in the "in table body" insertion mode...
}
if ($self->{insertion_mode} == IN_TABLE_BODY_IM) {
## have an element in table scope
my $i;
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
my $node = $self->{open_elements}->[$_];
if ({
tbody => 1, thead => 1, tfoot => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t237') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t237'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t238') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t238'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t239') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t239'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_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]}) {
$Whatpm::HTML::Debug::cp_pass->('t240') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t240'} = 1;
}
$self->{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_IM;
## reprocess in the "in table" insertion mode...
}
## 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 $token->{tag_name}) {
$Whatpm::HTML::Debug::cp_pass->('t241') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t241'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t242') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t242'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t243') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t243'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
## generate implied end tags
while ({
dd => 1, dt => 1, li => 1, p => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t244') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t244'} = 1;
}
## ISSUE: Can this case be reached?
pop @{$self->{open_elements}};
}
if ($self->{open_elements}->[-1]->[1] ne 'table') {
$Whatpm::HTML::Debug::cp_pass->('t245') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t245'} = 1;
}
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
} else {
$Whatpm::HTML::Debug::cp_pass->('t246') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t246'} = 1;
}
}
splice @{$self->{open_elements}}, $i;
$self->_reset_insertion_mode;
$token = $self->_get_next_token;
redo B;
} elsif ({
tbody => 1, tfoot => 1, thead => 1,
}->{$token->{tag_name}} and
$self->{insertion_mode} & ROW_IMS) {
if ($self->{insertion_mode} == IN_ROW_IM) {
## 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}) {
$Whatpm::HTML::Debug::cp_pass->('t247') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t247'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t248') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t248'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t249') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t249'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
## As if
## 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') {
$Whatpm::HTML::Debug::cp_pass->('t250') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t250'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t251') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t251'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t252') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t252'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:tr');
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
## Clear back to table row context
while (not {
tr => 1, html => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t253') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t253'} = 1;
}
## ISSUE: Can this case be reached?
$self->{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_IM;
## reprocess in the "in table body" insertion mode...
}
## 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}) {
$Whatpm::HTML::Debug::cp_pass->('t254') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t254'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t255') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t255'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t256') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t256'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_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]}) {
$Whatpm::HTML::Debug::cp_pass->('t257') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t257'} = 1;
}
## ISSUE: Can this case be reached?
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
pop @{$self->{open_elements}};
}
pop @{$self->{open_elements}};
$self->{insertion_mode} = IN_TABLE_IM;
$token = $self->_get_next_token;
redo B;
} elsif ({
body => 1, caption => 1, col => 1, colgroup => 1,
html => 1, td => 1, th => 1,
tr => 1, # $self->{insertion_mode} == IN_ROW_IM
tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM
}->{$token->{tag_name}}) {
$Whatpm::HTML::Debug::cp_pass->('t258') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t258'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t259') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t259'} = 1;
}
$self->{parse_error}-> (type => 'in table:/'.$token->{tag_name});
$insert = $insert_to_foster;
#
}
} else {
die "$0: $token->{type}: Unknown token type";
}
} elsif ($self->{insertion_mode} == IN_COLUMN_GROUP_IM) {
if ($token->{type} == CHARACTER_TOKEN) {
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1);
unless (length $token->{data}) {
$Whatpm::HTML::Debug::cp_pass->('t260') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t260'} = 1;
}
$token = $self->_get_next_token;
redo B;
}
}
$Whatpm::HTML::Debug::cp_pass->('t261') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t261'} = 1;
}
#
} elsif ($token->{type} == START_TAG_TOKEN) {
if ($token->{tag_name} eq 'col') {
$Whatpm::HTML::Debug::cp_pass->('t262') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t262'} = 1;
}
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
pop @{$self->{open_elements}};
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t263') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t263'} = 1;
}
#
}
} elsif ($token->{type} == END_TAG_TOKEN) {
if ($token->{tag_name} eq 'colgroup') {
if ($self->{open_elements}->[-1]->[1] eq 'html') {
$Whatpm::HTML::Debug::cp_pass->('t264') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t264'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:colgroup');
## Ignore the token
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t265') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t265'} = 1;
}
pop @{$self->{open_elements}}; # colgroup
$self->{insertion_mode} = IN_TABLE_IM;
$token = $self->_get_next_token;
redo B;
}
} elsif ($token->{tag_name} eq 'col') {
$Whatpm::HTML::Debug::cp_pass->('t266') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t266'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:col');
## Ignore the token
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t267') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t267'} = 1;
}
#
}
} else {
die "$0: $token->{type}: Unknown token type";
}
## As if
if ($self->{open_elements}->[-1]->[1] eq 'html') {
$Whatpm::HTML::Debug::cp_pass->('t269') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t269'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:colgroup');
## Ignore the token
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t270') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t270'} = 1;
}
pop @{$self->{open_elements}}; # colgroup
$self->{insertion_mode} = IN_TABLE_IM;
## reprocess
redo B;
}
} elsif ($self->{insertion_mode} == IN_SELECT_IM) {
if ($token->{type} == CHARACTER_TOKEN) {
$Whatpm::HTML::Debug::cp_pass->('t271') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t271'} = 1;
}
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data});
$token = $self->_get_next_token;
redo B;
} elsif ($token->{type} == START_TAG_TOKEN) {
if ($token->{tag_name} eq 'option') {
if ($self->{open_elements}->[-1]->[1] eq 'option') {
$Whatpm::HTML::Debug::cp_pass->('t272') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t272'} = 1;
}
## As if
pop @{$self->{open_elements}};
} else {
$Whatpm::HTML::Debug::cp_pass->('t273') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t273'} = 1;
}
}
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'optgroup') {
if ($self->{open_elements}->[-1]->[1] eq 'option') {
$Whatpm::HTML::Debug::cp_pass->('t274') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t274'} = 1;
}
## As if
pop @{$self->{open_elements}};
} else {
$Whatpm::HTML::Debug::cp_pass->('t275') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t275'} = 1;
}
}
if ($self->{open_elements}->[-1]->[1] eq 'optgroup') {
$Whatpm::HTML::Debug::cp_pass->('t276') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t276'} = 1;
}
## As if
pop @{$self->{open_elements}};
} else {
$Whatpm::HTML::Debug::cp_pass->('t277') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t277'} = 1;
}
}
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'select') {
## TODO: The type below is not good -
$self->{parse_error}-> (type => 'not closed:select');
## As if instead
## 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}) {
$Whatpm::HTML::Debug::cp_pass->('t278') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t278'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t279') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t279'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t280') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t280'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:select');
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
$Whatpm::HTML::Debug::cp_pass->('t281') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t281'} = 1;
}
splice @{$self->{open_elements}}, $i;
$self->_reset_insertion_mode;
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t282') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t282'} = 1;
}
$self->{parse_error}-> (type => 'in select:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
} elsif ($token->{type} == END_TAG_TOKEN) {
if ($token->{tag_name} eq 'optgroup') {
if ($self->{open_elements}->[-1]->[1] eq 'option' and
$self->{open_elements}->[-2]->[1] eq 'optgroup') {
$Whatpm::HTML::Debug::cp_pass->('t283') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t283'} = 1;
}
## As if
splice @{$self->{open_elements}}, -2;
} elsif ($self->{open_elements}->[-1]->[1] eq 'optgroup') {
$Whatpm::HTML::Debug::cp_pass->('t284') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t284'} = 1;
}
pop @{$self->{open_elements}};
} else {
$Whatpm::HTML::Debug::cp_pass->('t285') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t285'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
}
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'option') {
if ($self->{open_elements}->[-1]->[1] eq 'option') {
$Whatpm::HTML::Debug::cp_pass->('t286') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t286'} = 1;
}
pop @{$self->{open_elements}};
} else {
$Whatpm::HTML::Debug::cp_pass->('t287') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t287'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
}
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'select') {
## 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}) {
$Whatpm::HTML::Debug::cp_pass->('t288') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t288'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t289') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t289'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t290') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t290'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
$Whatpm::HTML::Debug::cp_pass->('t291') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t291'} = 1;
}
splice @{$self->{open_elements}}, $i;
$self->_reset_insertion_mode;
$token = $self->_get_next_token;
redo B;
} elsif ({
caption => 1, table => 1, tbody => 1,
tfoot => 1, thead => 1, tr => 1, td => 1, th => 1,
}->{$token->{tag_name}}) {
## TODO: The following is wrong?
$self->{parse_error}-> (type => 'unmatched end tag:'.$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}) {
$Whatpm::HTML::Debug::cp_pass->('t292') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t292'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t293') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t293'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t294') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t294'} = 1;
}
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
## As if
## have an element in table scope
undef $i;
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
my $node = $self->{open_elements}->[$_];
if ($node->[1] eq 'select') {
$Whatpm::HTML::Debug::cp_pass->('t295') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t295'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, html => 1,
}->{$node->[1]}) {
## ISSUE: Can this state be reached?
$Whatpm::HTML::Debug::cp_pass->('t296') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t296'} = 1;
}
last INSCOPE;
}
} # INSCOPE
unless (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t297') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t297'} = 1;
}
## TODO: The following error type is correct?
$self->{parse_error}-> (type => 'unmatched end tag:select');
## Ignore the token
$token = $self->_get_next_token; ## TODO: ok?
redo B;
}
$Whatpm::HTML::Debug::cp_pass->('t298') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t298'} = 1;
}
splice @{$self->{open_elements}}, $i;
$self->_reset_insertion_mode;
## reprocess
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t299') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t299'} = 1;
}
$self->{parse_error}-> (type => 'in select:/'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
} else {
die "$0: $token->{type}: Unknown token type";
}
} elsif ($self->{insertion_mode} & BODY_AFTER_IMS) {
if ($token->{type} == CHARACTER_TOKEN) {
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {
my $data = $1;
## As if in body
$reconstruct_active_formatting_elements->($insert_to_current);
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1);
unless (length $token->{data}) {
$Whatpm::HTML::Debug::cp_pass->('t300') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t300'} = 1;
}
$token = $self->_get_next_token;
redo B;
}
}
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
$Whatpm::HTML::Debug::cp_pass->('t301') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t301'} = 1;
}
$self->{parse_error}-> (type => 'after html:#character');
## Reprocess in the "after body" insertion mode.
} else {
$Whatpm::HTML::Debug::cp_pass->('t302') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t302'} = 1;
}
}
## "after body" insertion mode
$self->{parse_error}-> (type => 'after body:#character');
$self->{insertion_mode} = IN_BODY_IM;
## reprocess
redo B;
} elsif ($token->{type} == START_TAG_TOKEN) {
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
$Whatpm::HTML::Debug::cp_pass->('t303') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t303'} = 1;
}
$self->{parse_error}-> (type => 'after html:'.$token->{tag_name});
## Reprocess in the "after body" insertion mode.
} else {
$Whatpm::HTML::Debug::cp_pass->('t304') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t304'} = 1;
}
}
## "after body" insertion mode
$self->{parse_error}-> (type => 'after body:'.$token->{tag_name});
$self->{insertion_mode} = IN_BODY_IM;
## reprocess
redo B;
} elsif ($token->{type} == END_TAG_TOKEN) {
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
$Whatpm::HTML::Debug::cp_pass->('t305') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t305'} = 1;
}
$self->{parse_error}-> (type => 'after html:/'.$token->{tag_name});
$self->{insertion_mode} = AFTER_BODY_IM;
## Reprocess in the "after body" insertion mode.
} else {
$Whatpm::HTML::Debug::cp_pass->('t306') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t306'} = 1;
}
}
## "after body" insertion mode
if ($token->{tag_name} eq 'html') {
if (defined $self->{inner_html_node}) {
$Whatpm::HTML::Debug::cp_pass->('t307') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t307'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:html');
## Ignore the token
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t308') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t308'} = 1;
}
$self->{insertion_mode} = AFTER_HTML_BODY_IM;
$token = $self->_get_next_token;
redo B;
}
} else {
$Whatpm::HTML::Debug::cp_pass->('t309') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t309'} = 1;
}
$self->{parse_error}-> (type => 'after body:/'.$token->{tag_name});
$self->{insertion_mode} = IN_BODY_IM;
## reprocess
redo B;
}
} else {
die "$0: $token->{type}: Unknown token type";
}
} elsif ($self->{insertion_mode} & FRAME_IMS) {
if ($token->{type} == CHARACTER_TOKEN) {
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) {
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1);
unless (length $token->{data}) {
$Whatpm::HTML::Debug::cp_pass->('t310') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t310'} = 1;
}
$token = $self->_get_next_token;
redo B;
}
}
if ($token->{data} =~ s/^[^\x09\x0A\x0B\x0C\x20]+//) {
if ($self->{insertion_mode} == IN_FRAMESET_IM) {
$Whatpm::HTML::Debug::cp_pass->('t311') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t311'} = 1;
}
$self->{parse_error}-> (type => 'in frameset:#character');
} elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) {
$Whatpm::HTML::Debug::cp_pass->('t312') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t312'} = 1;
}
$self->{parse_error}-> (type => 'after frameset:#character');
} else { # "after html frameset"
$Whatpm::HTML::Debug::cp_pass->('t313') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t313'} = 1;
}
$self->{parse_error}-> (type => 'after html:#character');
$self->{insertion_mode} = AFTER_FRAMESET_IM;
## Reprocess in the "after frameset" insertion mode.
$self->{parse_error}-> (type => 'after frameset:#character');
}
## Ignore the token.
if (length $token->{data}) {
$Whatpm::HTML::Debug::cp_pass->('t314') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t314'} = 1;
}
## reprocess the rest of characters
} else {
$Whatpm::HTML::Debug::cp_pass->('t315') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t315'} = 1;
}
$token = $self->_get_next_token;
}
redo B;
}
die qq[$0: Character "$token->{data}"];
} elsif ($token->{type} == START_TAG_TOKEN) {
if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {
$Whatpm::HTML::Debug::cp_pass->('t316') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t316'} = 1;
}
$self->{parse_error}-> (type => 'after html:'.$token->{tag_name});
$self->{insertion_mode} = AFTER_FRAMESET_IM;
## Process in the "after frameset" insertion mode.
} else {
$Whatpm::HTML::Debug::cp_pass->('t317') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t317'} = 1;
}
}
if ($token->{tag_name} eq 'frameset' and
$self->{insertion_mode} == IN_FRAMESET_IM) {
$Whatpm::HTML::Debug::cp_pass->('t318') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t318'} = 1;
}
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'frame' and
$self->{insertion_mode} == IN_FRAMESET_IM) {
$Whatpm::HTML::Debug::cp_pass->('t319') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t319'} = 1;
}
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$self->{open_elements}->[-1]->[0]->append_child ($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
pop @{$self->{open_elements}};
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'noframes') {
$Whatpm::HTML::Debug::cp_pass->('t320') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t320'} = 1;
}
## NOTE: As if in body.
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current);
redo B;
} else {
if ($self->{insertion_mode} == IN_FRAMESET_IM) {
$Whatpm::HTML::Debug::cp_pass->('t321') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t321'} = 1;
}
$self->{parse_error}-> (type => 'in frameset:'.$token->{tag_name});
} else {
$Whatpm::HTML::Debug::cp_pass->('t322') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t322'} = 1;
}
$self->{parse_error}-> (type => 'after frameset:'.$token->{tag_name});
}
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
} elsif ($token->{type} == END_TAG_TOKEN) {
if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {
$Whatpm::HTML::Debug::cp_pass->('t323') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t323'} = 1;
}
$self->{parse_error}-> (type => 'after html:/'.$token->{tag_name});
$self->{insertion_mode} = AFTER_FRAMESET_IM;
## Process in the "after frameset" insertion mode.
} else {
$Whatpm::HTML::Debug::cp_pass->('t324') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t324'} = 1;
}
}
if ($token->{tag_name} eq 'frameset' and
$self->{insertion_mode} == IN_FRAMESET_IM) {
if ($self->{open_elements}->[-1]->[1] eq 'html' and
@{$self->{open_elements}} == 1) {
$Whatpm::HTML::Debug::cp_pass->('t325') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t325'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
} else {
$Whatpm::HTML::Debug::cp_pass->('t326') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t326'} = 1;
}
pop @{$self->{open_elements}};
$token = $self->_get_next_token;
}
if (not defined $self->{inner_html_node} and
$self->{open_elements}->[-1]->[1] ne 'frameset') {
$Whatpm::HTML::Debug::cp_pass->('t327') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t327'} = 1;
}
$self->{insertion_mode} = AFTER_FRAMESET_IM;
} else {
$Whatpm::HTML::Debug::cp_pass->('t328') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t328'} = 1;
}
}
redo B;
} elsif ($token->{tag_name} eq 'html' and
$self->{insertion_mode} == AFTER_FRAMESET_IM) {
$Whatpm::HTML::Debug::cp_pass->('t329') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t329'} = 1;
}
$self->{insertion_mode} = AFTER_HTML_FRAMESET_IM;
$token = $self->_get_next_token;
redo B;
} else {
if ($self->{insertion_mode} == IN_FRAMESET_IM) {
$Whatpm::HTML::Debug::cp_pass->('t330') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t330'} = 1;
}
$self->{parse_error}-> (type => 'in frameset:/'.$token->{tag_name});
} else {
$Whatpm::HTML::Debug::cp_pass->('t331') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t331'} = 1;
}
$self->{parse_error}-> (type => 'after frameset:/'.$token->{tag_name});
}
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
} else {
die "$0: $token->{type}: Unknown token type";
}
## ISSUE: An issue in spec here
} else {
die "$0: $self->{insertion_mode}: Unknown insertion mode";
}
## "in body" insertion mode
if ($token->{type} == START_TAG_TOKEN) {
if ($token->{tag_name} eq 'script') {
$Whatpm::HTML::Debug::cp_pass->('t332') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t332'} = 1;
}
## NOTE: This is an "as if in head" code clone
$script_start_tag->($insert);
redo B;
} elsif ($token->{tag_name} eq 'style') {
$Whatpm::HTML::Debug::cp_pass->('t333') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t333'} = 1;
}
## NOTE: This is an "as if in head" code clone
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert);
redo B;
} elsif ({
base => 1, link => 1,
}->{$token->{tag_name}}) {
$Whatpm::HTML::Debug::cp_pass->('t334') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t334'} = 1;
}
## NOTE: This is an "as if in head" code clone, only "-t" differs
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'meta') {
## NOTE: This is an "as if in head" code clone, only "-t" differs
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec.
unless ($self->{confident}) {
if ($token->{attributes}->{charset}) { ## TODO: And if supported
$Whatpm::HTML::Debug::cp_pass->('t335') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t335'} = 1;
}
$self->{change_encoding}
->($self, $token->{attributes}->{charset}->{value});
$meta_el->[0]->get_attribute_node_ns (undef, 'charset')
->set_user_data (manakai_has_reference =>
$token->{attributes}->{charset}
->{has_reference});
} elsif ($token->{attributes}->{content}) {
## ISSUE: Algorithm name in the spec was incorrect so that not linked to the definition.
if ($token->{attributes}->{content}->{value}
=~ /\A[^;]*;[\x09-\x0D\x20]*[Cc][Hh][Aa][Rr][Ss][Ee][Tt]
[\x09-\x0D\x20]*=
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'|
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) {
$Whatpm::HTML::Debug::cp_pass->('t336') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t336'} = 1;
}
$self->{change_encoding}
->($self, defined $1 ? $1 : defined $2 ? $2 : $3);
$meta_el->[0]->get_attribute_node_ns (undef, 'content')
->set_user_data (manakai_has_reference =>
$token->{attributes}->{content}
->{has_reference});
}
}
} else {
if ($token->{attributes}->{charset}) {
$Whatpm::HTML::Debug::cp_pass->('t337') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t337'} = 1;
}
$meta_el->[0]->get_attribute_node_ns (undef, 'charset')
->set_user_data (manakai_has_reference =>
$token->{attributes}->{charset}
->{has_reference});
}
if ($token->{attributes}->{content}) {
$Whatpm::HTML::Debug::cp_pass->('t338') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t338'} = 1;
}
$meta_el->[0]->get_attribute_node_ns (undef, 'content')
->set_user_data (manakai_has_reference =>
$token->{attributes}->{content}
->{has_reference});
}
}
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'title') {
$Whatpm::HTML::Debug::cp_pass->('t341') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t341'} = 1;
}
$self->{parse_error}-> (type => 'in body:title');
## NOTE: This is an "as if in head" code clone
$parse_rcdata->(RCDATA_CONTENT_MODEL, sub {
if (defined $self->{head_element}) {
$Whatpm::HTML::Debug::cp_pass->('t339') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t339'} = 1;
}
$self->{head_element}->append_child ($_[0]);
} else {
$Whatpm::HTML::Debug::cp_pass->('t340') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t340'} = 1;
}
$insert->($_[0]);
}
});
redo B;
} elsif ($token->{tag_name} eq 'body') {
$self->{parse_error}-> (type => 'in body:body');
if (@{$self->{open_elements}} == 1 or
$self->{open_elements}->[1]->[1] ne 'body') {
$Whatpm::HTML::Debug::cp_pass->('t342') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t342'} = 1;
}
## Ignore the token
} else {
my $body_el = $self->{open_elements}->[1]->[0];
for my $attr_name (keys %{$token->{attributes}}) {
unless ($body_el->has_attribute_ns (undef, $attr_name)) {
$Whatpm::HTML::Debug::cp_pass->('t343') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t343'} = 1;
}
$body_el->set_attribute_ns
(undef, [undef, $attr_name],
$token->{attributes}->{$attr_name}->{value});
}
}
}
$token = $self->_get_next_token;
redo B;
} elsif ({
address => 1, blockquote => 1, center => 1, dir => 1,
div => 1, dl => 1, fieldset => 1,
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,
listing => 1, menu => 1, ol => 1, p => 1, ul => 1,
pre => 1,
}->{$token->{tag_name}}) {
## has a p element in scope
INSCOPE: for (reverse @{$self->{open_elements}}) {
if ($_->[1] eq 'p') {
$Whatpm::HTML::Debug::cp_pass->('t344') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t344'} = 1;
}
unshift @{$self->{token}}, $token;
$token = {type => END_TAG_TOKEN, tag_name => 'p'};
redo B;
} elsif ({
table => 1, caption => 1, td => 1, th => 1,
button => 1, marquee => 1, object => 1, html => 1,
}->{$_->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t345') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t345'} = 1;
}
last INSCOPE;
}
} # INSCOPE
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
if ($token->{tag_name} eq 'pre') {
$token = $self->_get_next_token;
if ($token->{type} == CHARACTER_TOKEN) {
$token->{data} =~ s/^\x0A//;
unless (length $token->{data}) {
$Whatpm::HTML::Debug::cp_pass->('t346') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t346'} = 1;
}
$token = $self->_get_next_token;
} else {
$Whatpm::HTML::Debug::cp_pass->('t349') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t349'} = 1;
}
}
} else {
$Whatpm::HTML::Debug::cp_pass->('t348') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t348'} = 1;
}
}
} else {
$Whatpm::HTML::Debug::cp_pass->('t347') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t347'} = 1;
}
$token = $self->_get_next_token;
}
redo B;
} elsif ($token->{tag_name} eq 'form') {
if (defined $self->{form_element}) {
$Whatpm::HTML::Debug::cp_pass->('t350') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t350'} = 1;
}
$self->{parse_error}-> (type => 'in form:form');
## Ignore the token
$token = $self->_get_next_token;
redo B;
} else {
## has a p element in scope
INSCOPE: for (reverse @{$self->{open_elements}}) {
if ($_->[1] eq 'p') {
$Whatpm::HTML::Debug::cp_pass->('t351') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t351'} = 1;
}
unshift @{$self->{token}}, $token;
$token = {type => END_TAG_TOKEN, tag_name => 'p'};
redo B;
} elsif ({
table => 1, caption => 1, td => 1, th => 1,
button => 1, marquee => 1, object => 1, html => 1,
}->{$_->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t352') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t352'} = 1;
}
last INSCOPE;
}
} # INSCOPE
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
$self->{form_element} = $self->{open_elements}->[-1]->[0];
$token = $self->_get_next_token;
redo B;
}
} elsif ($token->{tag_name} eq 'li') {
## has a p element in scope
INSCOPE: for (reverse @{$self->{open_elements}}) {
if ($_->[1] eq 'p') {
$Whatpm::HTML::Debug::cp_pass->('t353') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t353'} = 1;
}
unshift @{$self->{token}}, $token;
$token = {type => END_TAG_TOKEN, tag_name => 'p'};
redo B;
} elsif ({
table => 1, caption => 1, td => 1, th => 1,
button => 1, marquee => 1, object => 1, html => 1,
}->{$_->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t354') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t354'} = 1;
}
last INSCOPE;
}
} # INSCOPE
## Step 1
my $i = -1;
my $node = $self->{open_elements}->[$i];
LI: {
## Step 2
if ($node->[1] eq 'li') {
if ($i != -1) {
$Whatpm::HTML::Debug::cp_pass->('t355') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t355'} = 1;
}
$self->{parse_error}-> (type => 'end tag missing:'.
$self->{open_elements}->[-1]->[1]);
} else {
$Whatpm::HTML::Debug::cp_pass->('t356') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t356'} = 1;
}
}
splice @{$self->{open_elements}}, $i;
last LI;
} else {
$Whatpm::HTML::Debug::cp_pass->('t357') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t357'} = 1;
}
}
## Step 3
if (not $formatting_category->{$node->[1]} and
#not $phrasing_category->{$node->[1]} and
($special_category->{$node->[1]} or
$scoping_category->{$node->[1]}) and
$node->[1] ne 'address' and $node->[1] ne 'div') {
$Whatpm::HTML::Debug::cp_pass->('t358') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t358'} = 1;
}
last LI;
}
$Whatpm::HTML::Debug::cp_pass->('t359') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t359'} = 1;
}
## Step 4
$i--;
$node = $self->{open_elements}->[$i];
redo LI;
} # LI
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'dd' or $token->{tag_name} eq 'dt') {
## has a p element in scope
INSCOPE: for (reverse @{$self->{open_elements}}) {
if ($_->[1] eq 'p') {
$Whatpm::HTML::Debug::cp_pass->('t360') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t360'} = 1;
}
unshift @{$self->{token}}, $token;
$token = {type => END_TAG_TOKEN, tag_name => 'p'};
redo B;
} elsif ({
table => 1, caption => 1, td => 1, th => 1,
button => 1, marquee => 1, object => 1, html => 1,
}->{$_->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t361') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t361'} = 1;
}
last INSCOPE;
}
} # INSCOPE
## Step 1
my $i = -1;
my $node = $self->{open_elements}->[$i];
LI: {
## Step 2
if ($node->[1] eq 'dt' or $node->[1] eq 'dd') {
if ($i != -1) {
$Whatpm::HTML::Debug::cp_pass->('t362') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t362'} = 1;
}
$self->{parse_error}-> (type => 'end tag missing:'.
$self->{open_elements}->[-1]->[1]);
} else {
$Whatpm::HTML::Debug::cp_pass->('t363') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t363'} = 1;
}
}
splice @{$self->{open_elements}}, $i;
last LI;
} else {
$Whatpm::HTML::Debug::cp_pass->('t364') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t364'} = 1;
}
}
## Step 3
if (not $formatting_category->{$node->[1]} and
#not $phrasing_category->{$node->[1]} and
($special_category->{$node->[1]} or
$scoping_category->{$node->[1]}) and
$node->[1] ne 'address' and $node->[1] ne 'div') {
$Whatpm::HTML::Debug::cp_pass->('t365') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t365'} = 1;
}
last LI;
}
$Whatpm::HTML::Debug::cp_pass->('t366') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t366'} = 1;
}
## Step 4
$i--;
$node = $self->{open_elements}->[$i];
redo LI;
} # LI
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'plaintext') {
## has a p element in scope
INSCOPE: for (reverse @{$self->{open_elements}}) {
if ($_->[1] eq 'p') {
$Whatpm::HTML::Debug::cp_pass->('t367') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t367'} = 1;
}
unshift @{$self->{token}}, $token;
$token = {type => END_TAG_TOKEN, tag_name => 'p'};
redo B;
} elsif ({
table => 1, caption => 1, td => 1, th => 1,
button => 1, marquee => 1, object => 1, html => 1,
}->{$_->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t368') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t368'} = 1;
}
last INSCOPE;
}
} # INSCOPE
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
$self->{content_model} = PLAINTEXT_CONTENT_MODEL;
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'a') {
AFE: for my $i (reverse 0..$#$active_formatting_elements) {
my $node = $active_formatting_elements->[$i];
if ($node->[1] eq 'a') {
$Whatpm::HTML::Debug::cp_pass->('t371') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t371'} = 1;
}
$self->{parse_error}-> (type => 'in a:a');
unshift @{$self->{token}}, $token;
$token = {type => END_TAG_TOKEN, tag_name => 'a'};
$formatting_end_tag->($token->{tag_name});
AFE2: for (reverse 0..$#$active_formatting_elements) {
if ($active_formatting_elements->[$_]->[0] eq $node->[0]) {
$Whatpm::HTML::Debug::cp_pass->('t372') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t372'} = 1;
}
splice @$active_formatting_elements, $_, 1;
last AFE2;
}
} # AFE2
OE: for (reverse 0..$#{$self->{open_elements}}) {
if ($self->{open_elements}->[$_]->[0] eq $node->[0]) {
$Whatpm::HTML::Debug::cp_pass->('t373') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t373'} = 1;
}
splice @{$self->{open_elements}}, $_, 1;
last OE;
}
} # OE
last AFE;
} elsif ($node->[0] eq '#marker') {
$Whatpm::HTML::Debug::cp_pass->('t374') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t374'} = 1;
}
last AFE;
}
} # AFE
$reconstruct_active_formatting_elements->($insert_to_current);
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
push @$active_formatting_elements, $self->{open_elements}->[-1];
$token = $self->_get_next_token;
redo B;
} elsif ({
b => 1, big => 1, em => 1, font => 1, i => 1,
s => 1, small => 1, strile => 1,
strong => 1, tt => 1, u => 1,
}->{$token->{tag_name}}) {
$Whatpm::HTML::Debug::cp_pass->('t375') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t375'} = 1;
}
$reconstruct_active_formatting_elements->($insert_to_current);
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
push @$active_formatting_elements, $self->{open_elements}->[-1];
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'nobr') {
$reconstruct_active_formatting_elements->($insert_to_current);
## has a |nobr| element in scope
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
my $node = $self->{open_elements}->[$_];
if ($node->[1] eq 'nobr') {
$Whatpm::HTML::Debug::cp_pass->('t376') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t376'} = 1;
}
$self->{parse_error}-> (type => 'in nobr:nobr');
unshift @{$self->{token}}, $token;
$token = {type => END_TAG_TOKEN, tag_name => 'nobr'};
redo B;
} elsif ({
table => 1, caption => 1, td => 1, th => 1,
button => 1, marquee => 1, object => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t377') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t377'} = 1;
}
last INSCOPE;
}
} # INSCOPE
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
push @$active_formatting_elements, $self->{open_elements}->[-1];
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'button') {
## has a button element in scope
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
my $node = $self->{open_elements}->[$_];
if ($node->[1] eq 'button') {
$Whatpm::HTML::Debug::cp_pass->('t378') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t378'} = 1;
}
$self->{parse_error}-> (type => 'in button:button');
unshift @{$self->{token}}, $token;
$token = {type => END_TAG_TOKEN, tag_name => 'button'};
redo B;
} elsif ({
table => 1, caption => 1, td => 1, th => 1,
button => 1, marquee => 1, object => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t379') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t379'} = 1;
}
last INSCOPE;
}
} # INSCOPE
$reconstruct_active_formatting_elements->($insert_to_current);
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
## TODO: associate with $self->{form_element} if defined
push @$active_formatting_elements, ['#marker', ''];
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'marquee' or
$token->{tag_name} eq 'object') {
$Whatpm::HTML::Debug::cp_pass->('t380') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t380'} = 1;
}
$reconstruct_active_formatting_elements->($insert_to_current);
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
push @$active_formatting_elements, ['#marker', ''];
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'xmp') {
$Whatpm::HTML::Debug::cp_pass->('t381') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t381'} = 1;
}
$reconstruct_active_formatting_elements->($insert_to_current);
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert);
redo B;
} elsif ($token->{tag_name} eq 'table') {
## has a p element in scope
INSCOPE: for (reverse @{$self->{open_elements}}) {
if ($_->[1] eq 'p') {
$Whatpm::HTML::Debug::cp_pass->('t382') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t382'} = 1;
}
unshift @{$self->{token}}, $token;
$token = {type => END_TAG_TOKEN, tag_name => 'p'};
redo B;
} elsif ({
table => 1, caption => 1, td => 1, th => 1,
button => 1, marquee => 1, object => 1, html => 1,
}->{$_->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t383') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t383'} = 1;
}
last INSCOPE;
}
} # INSCOPE
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
$self->{insertion_mode} = IN_TABLE_IM;
$token = $self->_get_next_token;
redo B;
} elsif ({
area => 1, basefont => 1, bgsound => 1, br => 1,
embed => 1, img => 1, param => 1, spacer => 1, wbr => 1,
image => 1,
}->{$token->{tag_name}}) {
if ($token->{tag_name} eq 'image') {
$Whatpm::HTML::Debug::cp_pass->('t384') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t384'} = 1;
}
$self->{parse_error}-> (type => 'image');
$token->{tag_name} = 'img';
} else {
$Whatpm::HTML::Debug::cp_pass->('t385') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t385'} = 1;
}
}
## NOTE: There is an "as if
" code clone.
$reconstruct_active_formatting_elements->($insert_to_current);
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
pop @{$self->{open_elements}};
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'hr') {
## has a p element in scope
INSCOPE: for (reverse @{$self->{open_elements}}) {
if ($_->[1] eq 'p') {
$Whatpm::HTML::Debug::cp_pass->('t386') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t386'} = 1;
}
unshift @{$self->{token}}, $token;
$token = {type => END_TAG_TOKEN, tag_name => 'p'};
redo B;
} elsif ({
table => 1, caption => 1, td => 1, th => 1,
button => 1, marquee => 1, object => 1, html => 1,
}->{$_->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t387') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t387'} = 1;
}
last INSCOPE;
}
} # INSCOPE
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
pop @{$self->{open_elements}};
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'input') {
$Whatpm::HTML::Debug::cp_pass->('t388') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t388'} = 1;
}
$reconstruct_active_formatting_elements->($insert_to_current);
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
## TODO: associate with $self->{form_element} if defined
pop @{$self->{open_elements}};
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'isindex') {
$self->{parse_error}-> (type => 'isindex');
if (defined $self->{form_element}) {
$Whatpm::HTML::Debug::cp_pass->('t389') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t389'} = 1;
}
## Ignore the token
$token = $self->_get_next_token;
redo B;
} else {
my $at = $token->{attributes};
my $form_attrs;
$form_attrs->{action} = $at->{action} if $at->{action};
my $prompt_attr = $at->{prompt};
$at->{name} = {name => 'name', value => 'isindex'};
delete $at->{action};
delete $at->{prompt};
my @tokens = (
{type => START_TAG_TOKEN, tag_name => 'form',
attributes => $form_attrs},
{type => START_TAG_TOKEN, tag_name => 'hr'},
{type => START_TAG_TOKEN, tag_name => 'p'},
{type => START_TAG_TOKEN, tag_name => 'label'},
);
if ($prompt_attr) {
$Whatpm::HTML::Debug::cp_pass->('t390') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t390'} = 1;
}
push @tokens, {type => CHARACTER_TOKEN, data => $prompt_attr->{value}};
} else {
$Whatpm::HTML::Debug::cp_pass->('t391') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t391'} = 1;
}
push @tokens, {type => CHARACTER_TOKEN,
data => 'This is a searchable index. Insert your search keywords here: '}; # SHOULD
## TODO: make this configurable
}
push @tokens,
{type => START_TAG_TOKEN, tag_name => 'input', attributes => $at},
#{type => CHARACTER_TOKEN, data => ''}, # SHOULD
{type => END_TAG_TOKEN, tag_name => 'label'},
{type => END_TAG_TOKEN, tag_name => 'p'},
{type => START_TAG_TOKEN, tag_name => 'hr'},
{type => END_TAG_TOKEN, tag_name => 'form'};
$token = shift @tokens;
unshift @{$self->{token}}, (@tokens);
redo B;
}
} elsif ($token->{tag_name} eq 'textarea') {
my $tag_name = $token->{tag_name};
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
## TODO: $self->{form_element} if defined
$self->{content_model} = RCDATA_CONTENT_MODEL;
delete $self->{escape}; # MUST
$insert->($el);
my $text = '';
$token = $self->_get_next_token;
if ($token->{type} == CHARACTER_TOKEN) {
$token->{data} =~ s/^\x0A//;
unless (length $token->{data}) {
$Whatpm::HTML::Debug::cp_pass->('t392') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t392'} = 1;
}
$token = $self->_get_next_token;
} else {
$Whatpm::HTML::Debug::cp_pass->('t393') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t393'} = 1;
}
}
} else {
$Whatpm::HTML::Debug::cp_pass->('t394') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t394'} = 1;
}
}
while ($token->{type} == CHARACTER_TOKEN) {
$Whatpm::HTML::Debug::cp_pass->('t395') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t395'} = 1;
}
$text .= $token->{data};
$token = $self->_get_next_token;
}
if (length $text) {
$Whatpm::HTML::Debug::cp_pass->('t396') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t396'} = 1;
}
$el->manakai_append_text ($text);
}
$self->{content_model} = PCDATA_CONTENT_MODEL;
if ($token->{type} == END_TAG_TOKEN and
$token->{tag_name} eq $tag_name) {
$Whatpm::HTML::Debug::cp_pass->('t397') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t397'} = 1;
}
## Ignore the token
} else {
$Whatpm::HTML::Debug::cp_pass->('t398') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t398'} = 1;
}
$self->{parse_error}-> (type => 'in RCDATA:#'.$token->{type});
}
$token = $self->_get_next_token;
redo B;
} elsif ({
iframe => 1,
noembed => 1,
noframes => 1,
noscript => 0, ## TODO: 1 if scripting is enabled
}->{$token->{tag_name}}) {
$Whatpm::HTML::Debug::cp_pass->('t399') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t399'} = 1;
}
## NOTE: There is an "as if in body" code clone.
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert);
redo B;
} elsif ($token->{tag_name} eq 'select') {
$Whatpm::HTML::Debug::cp_pass->('t400') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t400'} = 1;
}
$reconstruct_active_formatting_elements->($insert_to_current);
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
## TODO: associate with $self->{form_element} if defined
$self->{insertion_mode} = IN_SELECT_IM;
$token = $self->_get_next_token;
redo B;
} elsif ({
caption => 1, col => 1, colgroup => 1, frame => 1,
frameset => 1, head => 1, option => 1, optgroup => 1,
tbody => 1, td => 1, tfoot => 1, th => 1,
thead => 1, tr => 1,
}->{$token->{tag_name}}) {
$Whatpm::HTML::Debug::cp_pass->('t401') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t401'} = 1;
}
$self->{parse_error}-> (type => 'in body:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
## ISSUE: An issue on HTML5 new elements in the spec.
} else {
$Whatpm::HTML::Debug::cp_pass->('t402') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t402'} = 1;
}
$reconstruct_active_formatting_elements->($insert_to_current);
{
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, $token->{tag_name}]);
for my $attr_name (keys %{ $token->{attributes}}) {
$el->set_attribute_ns (undef, [undef, $attr_name],
$token->{attributes} ->{$attr_name}->{value});
}
$insert->($el);
push @{$self->{open_elements}}, [$el, $token->{tag_name}];
}
$token = $self->_get_next_token;
redo B;
}
} elsif ($token->{type} == END_TAG_TOKEN) {
if ($token->{tag_name} eq 'body') {
if (@{$self->{open_elements}} > 1 and
$self->{open_elements}->[1]->[1] eq 'body') {
for (@{$self->{open_elements}}) {
unless ({
dd => 1, dt => 1, li => 1, p => 1, td => 1,
th => 1, tr => 1, body => 1, html => 1,
tbody => 1, tfoot => 1, thead => 1,
}->{$_->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t403') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t403'} = 1;
}
$self->{parse_error}-> (type => 'not closed:'.$_->[1]);
} else {
$Whatpm::HTML::Debug::cp_pass->('t404') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t404'} = 1;
}
}
}
$self->{insertion_mode} = AFTER_BODY_IM;
$token = $self->_get_next_token;
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t405') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t405'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
} elsif ($token->{tag_name} eq 'html') {
if (@{$self->{open_elements}} > 1 and $self->{open_elements}->[1]->[1] eq 'body') {
## ISSUE: There is an issue in the spec.
if ($self->{open_elements}->[-1]->[1] ne 'body') {
$Whatpm::HTML::Debug::cp_pass->('t406') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t406'} = 1;
}
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[1]->[1]);
} else {
$Whatpm::HTML::Debug::cp_pass->('t407') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t407'} = 1;
}
}
$self->{insertion_mode} = AFTER_BODY_IM;
## reprocess
redo B;
} else {
$Whatpm::HTML::Debug::cp_pass->('t408') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t408'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
}
} elsif ({
address => 1, blockquote => 1, center => 1, dir => 1,
div => 1, dl => 1, fieldset => 1, listing => 1,
menu => 1, ol => 1, pre => 1, ul => 1,
dd => 1, dt => 1, li => 1,
button => 1, marquee => 1, object => 1,
}->{$token->{tag_name}}) {
## has an element in scope
my $i;
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
my $node = $self->{open_elements}->[$_];
if ($node->[1] eq $token->{tag_name}) {
## generate implied end tags
while ({
dd => ($token->{tag_name} ne 'dd'),
dt => ($token->{tag_name} ne 'dt'),
li => ($token->{tag_name} ne 'li'),
p => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t409') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t409'} = 1;
}
pop @{$self->{open_elements}};
}
$Whatpm::HTML::Debug::cp_pass->('t410') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t410'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, caption => 1, td => 1, th => 1,
button => 1, marquee => 1, object => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t411') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t411'} = 1;
}
last INSCOPE;
}
} # INSCOPE
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
if (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t412') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t412'} = 1;
}
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
} else {
$Whatpm::HTML::Debug::cp_pass->('t413') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t413'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
}
}
if (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t414') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t414'} = 1;
}
splice @{$self->{open_elements}}, $i;
} else {
$Whatpm::HTML::Debug::cp_pass->('t416') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t416'} = 1;
}
}
$clear_up_to_marker->()
if {
button => 1, marquee => 1, object => 1,
}->{$token->{tag_name}};
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'form') {
## has an element in scope
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
my $node = $self->{open_elements}->[$_];
if ($node->[1] eq $token->{tag_name}) {
## generate implied end tags
while ({
dd => 1, dt => 1, li => 1, p => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t417') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t417'} = 1;
}
pop @{$self->{open_elements}};
}
$Whatpm::HTML::Debug::cp_pass->('t418') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t418'} = 1;
}
last INSCOPE;
} elsif ({
table => 1, caption => 1, td => 1, th => 1,
button => 1, marquee => 1, object => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t419') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t419'} = 1;
}
last INSCOPE;
}
} # INSCOPE
if ($self->{open_elements}->[-1]->[1] eq $token->{tag_name}) {
$Whatpm::HTML::Debug::cp_pass->('t420') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t420'} = 1;
}
pop @{$self->{open_elements}};
} else {
$Whatpm::HTML::Debug::cp_pass->('t421') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t421'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
}
undef $self->{form_element};
$token = $self->_get_next_token;
redo B;
} elsif ({
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,
}->{$token->{tag_name}}) {
## has an element in scope
my $i;
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
my $node = $self->{open_elements}->[$_];
if ({
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,
}->{$node->[1]}) {
## generate implied end tags
while ({
dd => 1, dt => 1, li => 1, p => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t422') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t422'} = 1;
}
pop @{$self->{open_elements}};
}
$Whatpm::HTML::Debug::cp_pass->('t423') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t423'} = 1;
}
$i = $_;
last INSCOPE;
} elsif ({
table => 1, caption => 1, td => 1, th => 1,
button => 1, marquee => 1, object => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t424') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t424'} = 1;
}
last INSCOPE;
}
} # INSCOPE
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
$Whatpm::HTML::Debug::cp_pass->('t425') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t425'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
} else {
$Whatpm::HTML::Debug::cp_pass->('t426') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t426'} = 1;
}
}
splice @{$self->{open_elements}}, $i if defined $i;
$token = $self->_get_next_token;
redo B;
} elsif ($token->{tag_name} eq 'p') {
## has an element in scope
my $i;
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
my $node = $self->{open_elements}->[$_];
if ($node->[1] eq $token->{tag_name}) {
## generate implied end tags
while ({
dd => 1, dt => 1, li => 1, p => 0,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t409.1') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t409.1'} = 1;
}
pop @{$self->{open_elements}};
}
$Whatpm::HTML::Debug::cp_pass->('t410.1') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t410.1'} = 1;
}
$i = $_;
last INSCOPE unless $token->{tag_name} eq 'p';
} elsif ({
table => 1, caption => 1, td => 1, th => 1,
button => 1, marquee => 1, object => 1, html => 1,
}->{$node->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t411.1') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t411.1'} = 1;
}
last INSCOPE;
}
} # INSCOPE
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) {
if (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t412.1') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t412.1'} = 1;
}
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
} else {
$Whatpm::HTML::Debug::cp_pass->('t413.1') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t413.1'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
}
}
if (defined $i) {
$Whatpm::HTML::Debug::cp_pass->('t414.1') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t414.1'} = 1;
}
splice @{$self->{open_elements}}, $i;
} else {
$Whatpm::HTML::Debug::cp_pass->('t415.1') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t415.1'} = 1;
}
## As if , then reprocess the current token
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, 'p']);
$insert->($el);
}
$token = $self->_get_next_token;
redo B;
} elsif ({
a => 1,
b => 1, big => 1, em => 1, font => 1, i => 1,
nobr => 1, s => 1, small => 1, strile => 1,
strong => 1, tt => 1, u => 1,
}->{$token->{tag_name}}) {
$Whatpm::HTML::Debug::cp_pass->('t427') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t427'} = 1;
}
$formatting_end_tag->($token->{tag_name});
redo B;
} elsif ($token->{tag_name} eq 'br') {
$Whatpm::HTML::Debug::cp_pass->('t428') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t428'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:br');
## As if
$reconstruct_active_formatting_elements->($insert_to_current);
my $el;
$el = $self->{document}->create_element_ns
(q, [undef, 'br']);
$insert->($el);
## Ignore the token.
$token = $self->_get_next_token;
redo B;
} elsif ({
caption => 1, col => 1, colgroup => 1, frame => 1,
frameset => 1, head => 1, option => 1, optgroup => 1,
tbody => 1, td => 1, tfoot => 1, th => 1,
thead => 1, tr => 1,
area => 1, basefont => 1, bgsound => 1,
embed => 1, hr => 1, iframe => 1, image => 1,
img => 1, input => 1, isindex => 1, noembed => 1,
noframes => 1, param => 1, select => 1, spacer => 1,
table => 1, textarea => 1, wbr => 1,
noscript => 0, ## TODO: if scripting is enabled
}->{$token->{tag_name}}) {
$Whatpm::HTML::Debug::cp_pass->('t429') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t429'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
redo B;
## ISSUE: Issue on HTML5 new elements in spec
} else {
## Step 1
my $node_i = -1;
my $node = $self->{open_elements}->[$node_i];
## Step 2
S2: {
if ($node->[1] eq $token->{tag_name}) {
## Step 1
## generate implied end tags
while ({
dd => 1, dt => 1, li => 1, p => 1,
}->{$self->{open_elements}->[-1]->[1]}) {
$Whatpm::HTML::Debug::cp_pass->('t430') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t430'} = 1;
}
## ISSUE: Can this case be reached?
pop @{$self->{open_elements}};
}
## Step 2
if ($token->{tag_name} ne $self->{open_elements}->[-1]->[1]) {
$Whatpm::HTML::Debug::cp_pass->('t431') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t431'} = 1;
}
## NOTE:
$self->{parse_error}-> (type => 'not closed:'.$self->{open_elements}->[-1]->[1]);
} else {
$Whatpm::HTML::Debug::cp_pass->('t432') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t432'} = 1;
}
}
## Step 3
splice @{$self->{open_elements}}, $node_i;
$token = $self->_get_next_token;
last S2;
} else {
## Step 3
if (not $formatting_category->{$node->[1]} and
#not $phrasing_category->{$node->[1]} and
($special_category->{$node->[1]} or
$scoping_category->{$node->[1]})) {
$Whatpm::HTML::Debug::cp_pass->('t433') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t433'} = 1;
}
$self->{parse_error}-> (type => 'unmatched end tag:'.$token->{tag_name});
## Ignore the token
$token = $self->_get_next_token;
last S2;
}
$Whatpm::HTML::Debug::cp_pass->('t434') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'t434'} = 1;
}
}
## Step 4
$node_i--;
$node = $self->{open_elements}->[$node_i];
## Step 5;
redo S2;
} # S2
redo B;
}
}
redo B;
} # B
## Stop parsing # MUST
## TODO: script stuffs
} # _tree_construct_main
sub set_inner_html ($$$) {
my $class = shift;
my $node = shift;
my $s = \$_[0];
my $onerror = $_[1];
## ISSUE: Should {confident} be true?
my $nt = $node->node_type;
if ($nt == 9) {
# MUST
## Step 1 # MUST
## TODO: If the document has an active parser, ...
## ISSUE: There is an issue in the spec.
## Step 2 # MUST
my @cn = @{$node->child_nodes};
for (@cn) {
$node->remove_child ($_);
}
## Step 3, 4, 5 # MUST
$class->parse_string ($$s => $node, $onerror);
} elsif ($nt == 1) {
## TODO: If non-html element
## NOTE: Most of this code is copied from |parse_string|
## Step 1 # MUST
my $this_doc = $node->owner_document;
my $doc = $this_doc->implementation->create_document;
$doc->manakai_is_html (1);
my $p = $class->new;
$p->{document} = $doc;
## Step 8 # MUST
my $i = 0;
my $line = 1;
my $column = 0;
$p->{set_next_char} = sub {
my $self = shift;
pop @{$self->{prev_char}};
unshift @{$self->{prev_char}}, $self->{next_char};
$self->{next_char} = -1 and return if $i >= length $$s;
$self->{next_char} = ord substr $$s, $i++, 1;
$column++;
if ($self->{next_char} == 0x000A) { # LF
$line++;
$column = 0;
$Whatpm::HTML::Debug::cp_pass->('i1') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'i1'} = 1;
}
} elsif ($self->{next_char} == 0x000D) { # CR
$i++ if substr ($$s, $i, 1) eq "\x0A";
$self->{next_char} = 0x000A; # LF # MUST
$line++;
$column = 0;
$Whatpm::HTML::Debug::cp_pass->('i2') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'i2'} = 1;
}
} elsif ($self->{next_char} > 0x10FFFF) {
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST
$Whatpm::HTML::Debug::cp_pass->('i3') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'i3'} = 1;
}
} elsif ($self->{next_char} == 0x0000) { # NULL
$Whatpm::HTML::Debug::cp_pass->('i4') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'i4'} = 1;
}
$self->{parse_error}-> (type => 'NULL');
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST
}
};
$p->{prev_char} = [-1, -1, -1];
$p->{next_char} = -1;
my $ponerror = $onerror || sub {
my (%opt) = @_;
warn "Parse error ($opt{type}) at line $opt{line} column $opt{column}\n";
};
$p->{parse_error} = sub {
$ponerror->(@_, line => $line, column => $column);
};
$p->_initialize_tokenizer;
$p->_initialize_tree_constructor;
## Step 2
my $node_ln = $node->manakai_local_name;
$p->{content_model} = {
title => RCDATA_CONTENT_MODEL,
textarea => RCDATA_CONTENT_MODEL,
style => CDATA_CONTENT_MODEL,
script => CDATA_CONTENT_MODEL,
xmp => CDATA_CONTENT_MODEL,
iframe => CDATA_CONTENT_MODEL,
noembed => CDATA_CONTENT_MODEL,
noframes => CDATA_CONTENT_MODEL,
noscript => CDATA_CONTENT_MODEL,
plaintext => PLAINTEXT_CONTENT_MODEL,
}->{$node_ln};
$p->{content_model} = PCDATA_CONTENT_MODEL
unless defined $p->{content_model};
## ISSUE: What is "the name of the element"? local name?
$p->{inner_html_node} = [$node, $node_ln];
## Step 3
my $root = $doc->create_element_ns
('http://www.w3.org/1999/xhtml', [undef, 'html']);
## Step 4 # MUST
$doc->append_child ($root);
## Step 5 # MUST
push @{$p->{open_elements}}, [$root, 'html'];
undef $p->{head_element};
## Step 6 # MUST
$p->_reset_insertion_mode;
## Step 7 # MUST
my $anode = $node;
AN: while (defined $anode) {
if ($anode->node_type == 1) {
my $nsuri = $anode->namespace_uri;
if (defined $nsuri and $nsuri eq 'http://www.w3.org/1999/xhtml') {
if ($anode->manakai_local_name eq 'form') {
$Whatpm::HTML::Debug::cp_pass->('i5') if $Whatpm::HTML::Debug::cp_pass;
BEGIN {
$Whatpm::HTML::Debug::cp->{'i5'} = 1;
}
$p->{form_element} = $anode;
last AN;
}
}
}
$anode = $anode->parent_node;
} # AN
## Step 9 # MUST
{
my $self = $p;
$token = $self->_get_next_token;
}
$p->_tree_construction_main;
## Step 10 # MUST
my @cn = @{$node->child_nodes};
for (@cn) {
$node->remove_child ($_);
}
## ISSUE: mutation events? read-only?
## Step 11 # MUST
@cn = @{$root->child_nodes};
for (@cn) {
$this_doc->adopt_node ($_);
$node->append_child ($_);
}
## ISSUE: mutation events?
$p->_terminate_tree_constructor;
} else {
die "$0: |set_inner_html| is not defined for node of type $nt";
}
} # set_inner_html
} # tree construction stage
package Whatpm::HTML::RestartParser;
push our @ISA, 'Error';
1;
# $Date: 2008/03/08 02:29:22 $