| 2903 |
!!!cp ('t39'); |
!!!cp ('t39'); |
| 2904 |
}; # $clear_up_to_marker |
}; # $clear_up_to_marker |
| 2905 |
|
|
| 2906 |
my $parse_rcdata = sub ($$) { |
my $insert; |
| 2907 |
my ($content_model_flag, $insert) = @_; |
|
| 2908 |
|
my $parse_rcdata = sub ($) { |
| 2909 |
|
my ($content_model_flag) = @_; |
| 2910 |
|
|
| 2911 |
## Step 1 |
## Step 1 |
| 2912 |
my $start_tag_name = $token->{tag_name}; |
my $start_tag_name = $token->{tag_name}; |
| 2914 |
!!!create-element ($el, $start_tag_name, $token->{attributes}); |
!!!create-element ($el, $start_tag_name, $token->{attributes}); |
| 2915 |
|
|
| 2916 |
## Step 2 |
## Step 2 |
| 2917 |
$insert->($el); # /context node/->append_child ($el) |
$insert->($el); |
| 2918 |
|
|
| 2919 |
## Step 3 |
## Step 3 |
| 2920 |
$self->{content_model} = $content_model_flag; # CDATA or RCDATA |
$self->{content_model} = $content_model_flag; # CDATA or RCDATA |
| 2944 |
$token->{tag_name} eq $start_tag_name) { |
$token->{tag_name} eq $start_tag_name) { |
| 2945 |
!!!cp ('t42'); |
!!!cp ('t42'); |
| 2946 |
## Ignore the token |
## Ignore the token |
|
} elsif ($content_model_flag == CDATA_CONTENT_MODEL) { |
|
|
!!!cp ('t43'); |
|
|
!!!parse-error (type => 'in CDATA:#'.$token->{type}); |
|
|
} elsif ($content_model_flag == RCDATA_CONTENT_MODEL) { |
|
|
!!!cp ('t44'); |
|
|
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
|
| 2947 |
} else { |
} else { |
| 2948 |
die "$0: $content_model_flag in parse_rcdata"; |
## NOTE: An end-of-file token. |
| 2949 |
|
if ($content_model_flag == CDATA_CONTENT_MODEL) { |
| 2950 |
|
!!!cp ('t43'); |
| 2951 |
|
!!!parse-error (type => 'in CDATA:#'.$token->{type}); |
| 2952 |
|
} elsif ($content_model_flag == RCDATA_CONTENT_MODEL) { |
| 2953 |
|
!!!cp ('t44'); |
| 2954 |
|
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
| 2955 |
|
} else { |
| 2956 |
|
die "$0: $content_model_flag in parse_rcdata"; |
| 2957 |
|
} |
| 2958 |
} |
} |
| 2959 |
!!!next-token; |
!!!next-token; |
| 2960 |
}; # $parse_rcdata |
}; # $parse_rcdata |
| 2961 |
|
|
| 2962 |
my $script_start_tag = sub ($) { |
my $script_start_tag = sub () { |
|
my $insert = $_[0]; |
|
| 2963 |
my $script_el; |
my $script_el; |
| 2964 |
!!!create-element ($script_el, 'script', $token->{attributes}); |
!!!create-element ($script_el, 'script', $token->{attributes}); |
| 2965 |
## TODO: mark as "parser-inserted" |
## TODO: mark as "parser-inserted" |
| 3216 |
## NOTE: $open_tables->[-1]->[1] is the "tainted" flag. |
## NOTE: $open_tables->[-1]->[1] is the "tainted" flag. |
| 3217 |
my $open_tables = [[$self->{open_elements}->[0]->[0]]]; |
my $open_tables = [[$self->{open_elements}->[0]->[0]]]; |
| 3218 |
|
|
| 3219 |
my $insert_to_current = sub { |
$insert = my $insert_to_current = sub { |
| 3220 |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
| 3221 |
}; # $insert_to_current |
}; # $insert_to_current |
| 3222 |
|
|
| 3254 |
} |
} |
| 3255 |
}; # $insert_to_foster |
}; # $insert_to_foster |
| 3256 |
|
|
|
my $insert; |
|
|
|
|
| 3257 |
B: { |
B: { |
| 3258 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
| 3259 |
!!!cp ('t73'); |
!!!cp ('t73'); |
| 3338 |
} elsif ($self->{insertion_mode} & HEAD_IMS) { |
} elsif ($self->{insertion_mode} & HEAD_IMS) { |
| 3339 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 3340 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 3341 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
unless ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3342 |
|
!!!cp ('t88.2'); |
| 3343 |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 3344 |
|
} else { |
| 3345 |
|
!!!cp ('t88.1'); |
| 3346 |
|
## Ignore the token. |
| 3347 |
|
!!!next-token; |
| 3348 |
|
redo B; |
| 3349 |
|
} |
| 3350 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 3351 |
!!!cp ('t88'); |
!!!cp ('t88'); |
| 3352 |
!!!next-token; |
!!!next-token; |
| 3447 |
} |
} |
| 3448 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 3449 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 3450 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3451 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3452 |
!!!next-token; |
!!!next-token; |
| 3453 |
redo B; |
redo B; |
| 3462 |
} |
} |
| 3463 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 3464 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 3465 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3466 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3467 |
!!!next-token; |
!!!next-token; |
| 3468 |
redo B; |
redo B; |
| 3523 |
} |
} |
| 3524 |
} |
} |
| 3525 |
|
|
| 3526 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3527 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3528 |
!!!next-token; |
!!!next-token; |
| 3529 |
redo B; |
redo B; |
| 3547 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3548 |
my $parent = defined $self->{head_element} ? $self->{head_element} |
my $parent = defined $self->{head_element} ? $self->{head_element} |
| 3549 |
: $self->{open_elements}->[-1]->[0]; |
: $self->{open_elements}->[-1]->[0]; |
| 3550 |
$parse_rcdata->(RCDATA_CONTENT_MODEL, |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
| 3551 |
sub { $parent->append_child ($_[0]) }); |
pop @{$self->{open_elements}} # <head> |
|
pop @{$self->{open_elements}} |
|
| 3552 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3553 |
redo B; |
redo B; |
| 3554 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 3562 |
} else { |
} else { |
| 3563 |
!!!cp ('t115'); |
!!!cp ('t115'); |
| 3564 |
} |
} |
| 3565 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 3566 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3567 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3568 |
redo B; |
redo B; |
| 3569 |
} elsif ($token->{tag_name} eq 'noscript') { |
} elsif ($token->{tag_name} eq 'noscript') { |
| 3602 |
} |
} |
| 3603 |
|
|
| 3604 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3605 |
$script_start_tag->($insert_to_current); |
$script_start_tag->(); |
| 3606 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3607 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3608 |
redo B; |
redo B; |
| 3609 |
} elsif ($token->{tag_name} eq 'body' or |
} elsif ($token->{tag_name} eq 'body' or |
| 4492 |
|
|
| 4493 |
## reprocess |
## reprocess |
| 4494 |
redo B; |
redo B; |
| 4495 |
|
} elsif ($token->{tag_name} eq 'style') { |
| 4496 |
|
if (not $open_tables->[-1]->[1]) { # tainted |
| 4497 |
|
!!!cp ('t227.8'); |
| 4498 |
|
## NOTE: This is a "as if in head" code clone. |
| 4499 |
|
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 4500 |
|
redo B; |
| 4501 |
|
} else { |
| 4502 |
|
!!!cp ('t227.7'); |
| 4503 |
|
# |
| 4504 |
|
} |
| 4505 |
|
} elsif ($token->{tag_name} eq 'script') { |
| 4506 |
|
if (not $open_tables->[-1]->[1]) { # tainted |
| 4507 |
|
!!!cp ('t227.6'); |
| 4508 |
|
## NOTE: This is a "as if in head" code clone. |
| 4509 |
|
$script_start_tag->(); |
| 4510 |
|
redo B; |
| 4511 |
|
} else { |
| 4512 |
|
!!!cp ('t227.5'); |
| 4513 |
|
# |
| 4514 |
|
} |
| 4515 |
|
} elsif ($token->{tag_name} eq 'input') { |
| 4516 |
|
if (not $open_tables->[-1]->[1]) { # tainted |
| 4517 |
|
if ($token->{attributes}->{type}) { ## TODO: case |
| 4518 |
|
my $type = lc $token->{attributes}->{type}->{value}; |
| 4519 |
|
if ($type eq 'hidden') { |
| 4520 |
|
!!!cp ('t227.3'); |
| 4521 |
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
| 4522 |
|
|
| 4523 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4524 |
|
|
| 4525 |
|
## TODO: form element pointer |
| 4526 |
|
|
| 4527 |
|
pop @{$self->{open_elements}}; |
| 4528 |
|
|
| 4529 |
|
!!!next-token; |
| 4530 |
|
redo B; |
| 4531 |
|
} else { |
| 4532 |
|
!!!cp ('t227.2'); |
| 4533 |
|
# |
| 4534 |
|
} |
| 4535 |
|
} else { |
| 4536 |
|
!!!cp ('t227.1'); |
| 4537 |
|
# |
| 4538 |
|
} |
| 4539 |
|
} else { |
| 4540 |
|
!!!cp ('t227.4'); |
| 4541 |
|
# |
| 4542 |
|
} |
| 4543 |
} else { |
} else { |
| 4544 |
!!!cp ('t227'); |
!!!cp ('t227'); |
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
|
|
|
|
|
$insert = $insert_to_foster; |
|
| 4545 |
# |
# |
| 4546 |
} |
} |
| 4547 |
|
|
| 4548 |
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
| 4549 |
|
|
| 4550 |
|
$insert = $insert_to_foster; |
| 4551 |
|
# |
| 4552 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 4553 |
if ($token->{tag_name} eq 'tr' and |
if ($token->{tag_name} eq 'tr' and |
| 4554 |
$self->{insertion_mode} == IN_ROW_IM) { |
$self->{insertion_mode} == IN_ROW_IM) { |
| 5263 |
} elsif ($token->{tag_name} eq 'noframes') { |
} elsif ($token->{tag_name} eq 'noframes') { |
| 5264 |
!!!cp ('t320'); |
!!!cp ('t320'); |
| 5265 |
## NOTE: As if in body. |
## NOTE: As if in body. |
| 5266 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5267 |
redo B; |
redo B; |
| 5268 |
} else { |
} else { |
| 5269 |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
| 5342 |
if ($token->{tag_name} eq 'script') { |
if ($token->{tag_name} eq 'script') { |
| 5343 |
!!!cp ('t332'); |
!!!cp ('t332'); |
| 5344 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 5345 |
$script_start_tag->($insert); |
$script_start_tag->(); |
| 5346 |
redo B; |
redo B; |
| 5347 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 5348 |
!!!cp ('t333'); |
!!!cp ('t333'); |
| 5349 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 5350 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5351 |
redo B; |
redo B; |
| 5352 |
} elsif ({ |
} elsif ({ |
| 5353 |
base => 1, link => 1, |
base => 1, link => 1, |
| 5410 |
redo B; |
redo B; |
| 5411 |
} elsif ($token->{tag_name} eq 'title') { |
} elsif ($token->{tag_name} eq 'title') { |
| 5412 |
!!!cp ('t341'); |
!!!cp ('t341'); |
|
!!!parse-error (type => 'in body:title'); |
|
| 5413 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 5414 |
$parse_rcdata->(RCDATA_CONTENT_MODEL, sub { |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
|
if (defined $self->{head_element}) { |
|
|
!!!cp ('t339'); |
|
|
$self->{head_element}->append_child ($_[0]); |
|
|
} else { |
|
|
!!!cp ('t340'); |
|
|
$insert->($_[0]); |
|
|
} |
|
|
}); |
|
| 5415 |
redo B; |
redo B; |
| 5416 |
} elsif ($token->{tag_name} eq 'body') { |
} elsif ($token->{tag_name} eq 'body') { |
| 5417 |
!!!parse-error (type => 'in body:body'); |
!!!parse-error (type => 'in body:body'); |
| 5437 |
address => 1, blockquote => 1, center => 1, dir => 1, |
address => 1, blockquote => 1, center => 1, dir => 1, |
| 5438 |
div => 1, dl => 1, fieldset => 1, |
div => 1, dl => 1, fieldset => 1, |
| 5439 |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
| 5440 |
listing => 1, menu => 1, ol => 1, p => 1, ul => 1, |
menu => 1, ol => 1, p => 1, ul => 1, |
| 5441 |
pre => 1, |
pre => 1, listing => 1, |
| 5442 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5443 |
## has a p element in scope |
## has a p element in scope |
| 5444 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 5457 |
} # INSCOPE |
} # INSCOPE |
| 5458 |
|
|
| 5459 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 5460 |
if ($token->{tag_name} eq 'pre') { |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
| 5461 |
!!!next-token; |
!!!next-token; |
| 5462 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 5463 |
$token->{data} =~ s/^\x0A//; |
$token->{data} =~ s/^\x0A//; |
| 5759 |
} elsif ($token->{tag_name} eq 'xmp') { |
} elsif ($token->{tag_name} eq 'xmp') { |
| 5760 |
!!!cp ('t381'); |
!!!cp ('t381'); |
| 5761 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 5762 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5763 |
redo B; |
redo B; |
| 5764 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 5765 |
## has a p element in scope |
## has a p element in scope |
| 5935 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5936 |
!!!cp ('t399'); |
!!!cp ('t399'); |
| 5937 |
## NOTE: There is an "as if in body" code clone. |
## NOTE: There is an "as if in body" code clone. |
| 5938 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5939 |
redo B; |
redo B; |
| 5940 |
} elsif ($token->{tag_name} eq 'select') { |
} elsif ($token->{tag_name} eq 'select') { |
| 5941 |
!!!cp ('t400'); |
!!!cp ('t400'); |