| 2067 |
th => 'in cell', |
th => 'in cell', |
| 2068 |
tr => 'in row', |
tr => 'in row', |
| 2069 |
tbody => 'in table body', |
tbody => 'in table body', |
| 2070 |
thead => 'in table head', |
thead => 'in table body', |
| 2071 |
tfoot => 'in table foot', |
tfoot => 'in table body', |
| 2072 |
caption => 'in caption', |
caption => 'in caption', |
| 2073 |
colgroup => 'in column group', |
colgroup => 'in column group', |
| 2074 |
table => 'in table', |
table => 'in table', |
| 2103 |
sub _tree_construction_main ($) { |
sub _tree_construction_main ($) { |
| 2104 |
my $self = shift; |
my $self = shift; |
| 2105 |
|
|
|
my $previous_insertion_mode; |
|
|
|
|
| 2106 |
my $active_formatting_elements = []; |
my $active_formatting_elements = []; |
| 2107 |
|
|
| 2108 |
my $reconstruct_active_formatting_elements = sub { # MUST |
my $reconstruct_active_formatting_elements = sub { # MUST |
| 3044 |
noframes => 1, |
noframes => 1, |
| 3045 |
noscript => 0, ## TODO: 1 if scripting is enabled |
noscript => 0, ## TODO: 1 if scripting is enabled |
| 3046 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 3047 |
|
## NOTE: There are two "as if in body" code clones. |
| 3048 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
| 3049 |
return; |
return; |
| 3050 |
} elsif ($token->{tag_name} eq 'select') { |
} elsif ($token->{tag_name} eq 'select') { |
| 3348 |
!!!next-token; |
!!!next-token; |
| 3349 |
redo B; |
redo B; |
| 3350 |
} elsif ($token->{type} eq 'end-of-file') { |
} elsif ($token->{type} eq 'end-of-file') { |
| 3351 |
if ($token->{insertion_mode} ne 'trailing end') { |
if ($self->{insertion_mode} eq 'after html body' or |
| 3352 |
|
$self->{insertion_mode} eq 'after html frameset') { |
| 3353 |
|
# |
| 3354 |
|
} else { |
| 3355 |
## Generate implied end tags |
## Generate implied end tags |
| 3356 |
if ({ |
if ({ |
| 3357 |
dd => 1, dt => 1, li => 1, p => 1, td => 1, th => 1, tr => 1, |
dd => 1, dt => 1, li => 1, p => 1, td => 1, th => 1, tr => 1, |
| 3378 |
last B; |
last B; |
| 3379 |
} elsif ($token->{type} eq 'start tag' and |
} elsif ($token->{type} eq 'start tag' and |
| 3380 |
$token->{tag_name} eq 'html') { |
$token->{tag_name} eq 'html') { |
| 3381 |
if ($self->{insertion_mode} eq 'trailing end') { |
if ($self->{insertion_mode} eq 'after html body') { |
| 3382 |
|
## Turn into the main phase |
| 3383 |
|
!!!parse-error (type => 'after html:html'); |
| 3384 |
|
$self->{insertion_mode} = 'after body'; |
| 3385 |
|
} elsif ($self->{insertion_mode} eq 'after html frameset') { |
| 3386 |
## Turn into the main phase |
## Turn into the main phase |
| 3387 |
!!!parse-error (type => 'after html:html'); |
!!!parse-error (type => 'after html:html'); |
| 3388 |
$self->{insertion_mode} = $previous_insertion_mode; |
$self->{insertion_mode} = 'after frameset'; |
| 3389 |
} |
} |
| 3390 |
|
|
| 3391 |
## ISSUE: "aa<html>" is not a parse error. |
## ISSUE: "aa<html>" is not a parse error. |
| 3405 |
redo B; |
redo B; |
| 3406 |
} elsif ($token->{type} eq 'comment') { |
} elsif ($token->{type} eq 'comment') { |
| 3407 |
my $comment = $self->{document}->create_comment ($token->{data}); |
my $comment = $self->{document}->create_comment ($token->{data}); |
| 3408 |
if ($self->{insertion_mode} eq 'trailing end') { |
if ($self->{insertion_mode} eq 'after html body' or |
| 3409 |
|
$self->{insertion_mode} eq 'after html frameset') { |
| 3410 |
$self->{document}->append_child ($comment); |
$self->{document}->append_child ($comment); |
| 3411 |
} elsif ($self->{insertion_mode} eq 'after body') { |
} elsif ($self->{insertion_mode} eq 'after body') { |
| 3412 |
$self->{open_elements}->[0]->[0]->append_child ($comment); |
$self->{open_elements}->[0]->[0]->append_child ($comment); |
| 3415 |
} |
} |
| 3416 |
!!!next-token; |
!!!next-token; |
| 3417 |
redo B; |
redo B; |
| 3418 |
} elsif ($self->{insertion_mode} eq 'before head') { |
} elsif ($self->{insertion_mode} eq 'in head' or |
| 3419 |
if ($token->{type} eq 'character') { |
$self->{insertion_mode} eq 'in head noscript' or |
| 3420 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
$self->{insertion_mode} eq 'after head' or |
| 3421 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{insertion_mode} eq 'before head') { |
| 3422 |
unless (length $token->{data}) { |
if ($token->{type} eq 'character') { |
| 3423 |
!!!next-token; |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 3424 |
redo B; |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 3425 |
} |
unless (length $token->{data}) { |
| 3426 |
} |
!!!next-token; |
| 3427 |
## As if <head> |
redo B; |
| 3428 |
!!!create-element ($self->{head_element}, 'head'); |
} |
| 3429 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
} |
| 3430 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
|
| 3431 |
$self->{insertion_mode} = 'in head'; |
if ($self->{insertion_mode} eq 'before head') { |
| 3432 |
|
## As if <head> |
| 3433 |
|
!!!create-element ($self->{head_element}, 'head'); |
| 3434 |
|
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3435 |
|
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3436 |
|
|
| 3437 |
|
## Reprocess in the "in head" insertion mode... |
| 3438 |
|
pop @{$self->{open_elements}}; |
| 3439 |
|
|
| 3440 |
|
## Reprocess in the "after head" insertion mode... |
| 3441 |
|
} elsif ($self->{insertion_mode} eq 'in head noscript') { |
| 3442 |
|
## As if </noscript> |
| 3443 |
|
pop @{$self->{open_elements}}; |
| 3444 |
|
!!!parse-error (type => 'in noscript:#character'); |
| 3445 |
|
|
| 3446 |
|
## Reprocess in the "in head" insertion mode... |
| 3447 |
|
## As if </head> |
| 3448 |
|
pop @{$self->{open_elements}}; |
| 3449 |
|
|
| 3450 |
|
## Reprocess in the "after head" insertion mode... |
| 3451 |
|
} elsif ($self->{insertion_mode} eq 'in head') { |
| 3452 |
|
pop @{$self->{open_elements}}; |
| 3453 |
|
|
| 3454 |
|
## Reprocess in the "after head" insertion mode... |
| 3455 |
|
} |
| 3456 |
|
|
| 3457 |
|
## "after head" insertion mode |
| 3458 |
|
## As if <body> |
| 3459 |
|
!!!insert-element ('body'); |
| 3460 |
|
$self->{insertion_mode} = 'in body'; |
| 3461 |
## reprocess |
## reprocess |
| 3462 |
redo B; |
redo B; |
| 3463 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
|
my $attr = $token->{tag_name} eq 'head' ? $token->{attributes} : {}; |
|
|
!!!create-element ($self->{head_element}, 'head', $attr); |
|
|
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
|
|
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
|
|
$self->{insertion_mode} = 'in head'; |
|
| 3464 |
if ($token->{tag_name} eq 'head') { |
if ($token->{tag_name} eq 'head') { |
| 3465 |
!!!next-token; |
if ($self->{insertion_mode} eq 'before head') { |
| 3466 |
#} elsif ({ |
!!!create-element ($self->{head_element}, $token->{tag_name}, $token->{attributes}); |
| 3467 |
# base => 1, link => 1, meta => 1, |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3468 |
# script => 1, style => 1, title => 1, |
push @{$self->{open_elements}}, [$self->{head_element}, $token->{tag_name}]; |
| 3469 |
# }->{$token->{tag_name}}) { |
$self->{insertion_mode} = 'in head'; |
| 3470 |
# ## reprocess |
!!!next-token; |
| 3471 |
} else { |
redo B; |
| 3472 |
## reprocess |
} elsif ($self->{insertion_mode} ne 'after head') { |
| 3473 |
} |
!!!parse-error (type => 'in head:head'); # or in head noscript |
| 3474 |
redo B; |
## Ignore the token |
| 3475 |
} elsif ($token->{type} eq 'end tag') { |
!!!next-token; |
| 3476 |
if ({ |
redo B; |
| 3477 |
head => 1, body => 1, html => 1, |
} else { |
| 3478 |
p => 1, br => 1, |
# |
| 3479 |
}->{$token->{tag_name}}) { |
} |
| 3480 |
|
} elsif ($self->{insertion_mode} eq 'before head') { |
| 3481 |
## As if <head> |
## As if <head> |
| 3482 |
!!!create-element ($self->{head_element}, 'head'); |
!!!create-element ($self->{head_element}, 'head'); |
| 3483 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3484 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3485 |
|
|
| 3486 |
$self->{insertion_mode} = 'in head'; |
$self->{insertion_mode} = 'in head'; |
| 3487 |
## reprocess |
## Reprocess in the "in head" insertion mode... |
|
redo B; |
|
|
} else { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token ## ISSUE: An issue in the spec. |
|
|
!!!next-token; |
|
|
redo B; |
|
| 3488 |
} |
} |
| 3489 |
} else { |
|
| 3490 |
die "$0: $token->{type}: Unknown type"; |
if ($token->{tag_name} eq 'base') { |
| 3491 |
} |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3492 |
} elsif ($self->{insertion_mode} eq 'in head' or |
## As if </noscript> |
| 3493 |
$self->{insertion_mode} eq 'in head noscript' or |
pop @{$self->{open_elements}}; |
| 3494 |
$self->{insertion_mode} eq 'after head') { |
!!!parse-error (type => 'in noscript:base'); |
| 3495 |
if ($token->{type} eq 'character') { |
|
| 3496 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
$self->{insertion_mode} = 'in head'; |
| 3497 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
## Reprocess in the "in head" insertion mode... |
|
unless (length $token->{data}) { |
|
|
!!!next-token; |
|
|
redo B; |
|
| 3498 |
} |
} |
| 3499 |
} |
|
| 3500 |
|
## NOTE: There is a "as if in head" code clone. |
| 3501 |
# |
if ($self->{insertion_mode} eq 'after head') { |
| 3502 |
} elsif ($token->{type} eq 'start tag') { |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3503 |
if ({base => ($self->{insertion_mode} eq 'in head' or |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3504 |
$self->{insertion_mode} eq 'after head'), |
} |
| 3505 |
link => 1}->{$token->{tag_name}}) { |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 3506 |
|
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 3507 |
|
pop @{$self->{open_elements}} |
| 3508 |
|
if $self->{insertion_mode} eq 'after head'; |
| 3509 |
|
!!!next-token; |
| 3510 |
|
redo B; |
| 3511 |
|
} elsif ($token->{tag_name} eq 'link') { |
| 3512 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3513 |
if ($self->{insertion_mode} eq 'after head') { |
if ($self->{insertion_mode} eq 'after head') { |
| 3514 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3551 |
if $self->{insertion_mode} eq 'after head'; |
if $self->{insertion_mode} eq 'after head'; |
| 3552 |
!!!next-token; |
!!!next-token; |
| 3553 |
redo B; |
redo B; |
| 3554 |
} elsif ($token->{tag_name} eq 'title' and |
} elsif ($token->{tag_name} eq 'title') { |
| 3555 |
$self->{insertion_mode} eq 'in head') { |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3556 |
## NOTE: There is a "as if in head" code clone. |
## As if </noscript> |
| 3557 |
if ($self->{insertion_mode} eq 'after head') { |
pop @{$self->{open_elements}}; |
| 3558 |
|
!!!parse-error (type => 'in noscript:title'); |
| 3559 |
|
|
| 3560 |
|
$self->{insertion_mode} = 'in head'; |
| 3561 |
|
## Reprocess in the "in head" insertion mode... |
| 3562 |
|
} elsif ($self->{insertion_mode} eq 'after head') { |
| 3563 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3564 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3565 |
} |
} |
| 3566 |
|
|
| 3567 |
|
## NOTE: There is a "as if in head" code clone. |
| 3568 |
my $parent = defined $self->{head_element} ? $self->{head_element} |
my $parent = defined $self->{head_element} ? $self->{head_element} |
| 3569 |
: $self->{open_elements}->[-1]->[0]; |
: $self->{open_elements}->[-1]->[0]; |
| 3570 |
$parse_rcdata->(RCDATA_CONTENT_MODEL, |
$parse_rcdata->(RCDATA_CONTENT_MODEL, |
| 3599 |
} else { |
} else { |
| 3600 |
# |
# |
| 3601 |
} |
} |
| 3602 |
} elsif ($token->{tag_name} eq 'head' and |
} elsif ($token->{tag_name} eq 'script') { |
| 3603 |
$self->{insertion_mode} ne 'after head') { |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3604 |
!!!parse-error (type => 'in head:head'); # or in head noscript |
## As if </noscript> |
| 3605 |
## Ignore the token |
pop @{$self->{open_elements}}; |
| 3606 |
!!!next-token; |
!!!parse-error (type => 'in noscript:script'); |
| 3607 |
redo B; |
|
| 3608 |
} elsif ($self->{insertion_mode} ne 'in head noscript' and |
$self->{insertion_mode} = 'in head'; |
| 3609 |
$token->{tag_name} eq 'script') { |
## Reprocess in the "in head" insertion mode... |
| 3610 |
if ($self->{insertion_mode} eq 'after head') { |
} elsif ($self->{insertion_mode} eq 'after head') { |
| 3611 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3612 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3613 |
} |
} |
| 3614 |
|
|
| 3615 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3616 |
$script_start_tag->($insert_to_current); |
$script_start_tag->($insert_to_current); |
| 3617 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} |
| 3618 |
if $self->{insertion_mode} eq 'after head'; |
if $self->{insertion_mode} eq 'after head'; |
| 3619 |
redo B; |
redo B; |
| 3620 |
} elsif ($self->{insertion_mode} eq 'after head' and |
} elsif ($token->{tag_name} eq 'body' or |
|
$token->{tag_name} eq 'body') { |
|
|
!!!insert-element ('body', $token->{attributes}); |
|
|
$self->{insertion_mode} = 'in body'; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($self->{insertion_mode} eq 'after head' and |
|
| 3621 |
$token->{tag_name} eq 'frameset') { |
$token->{tag_name} eq 'frameset') { |
| 3622 |
!!!insert-element ('frameset', $token->{attributes}); |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3623 |
$self->{insertion_mode} = 'in frameset'; |
## As if </noscript> |
| 3624 |
|
pop @{$self->{open_elements}}; |
| 3625 |
|
!!!parse-error (type => 'in noscript:'.$token->{tag_name}); |
| 3626 |
|
|
| 3627 |
|
## Reprocess in the "in head" insertion mode... |
| 3628 |
|
## As if </head> |
| 3629 |
|
pop @{$self->{open_elements}}; |
| 3630 |
|
|
| 3631 |
|
## Reprocess in the "after head" insertion mode... |
| 3632 |
|
} elsif ($self->{insertion_mode} eq 'in head') { |
| 3633 |
|
pop @{$self->{open_elements}}; |
| 3634 |
|
|
| 3635 |
|
## Reprocess in the "after head" insertion mode... |
| 3636 |
|
} |
| 3637 |
|
|
| 3638 |
|
## "after head" insertion mode |
| 3639 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 3640 |
|
$self->{insertion_mode} = 'in '.$token->{tag_name}; |
| 3641 |
!!!next-token; |
!!!next-token; |
| 3642 |
redo B; |
redo B; |
| 3643 |
} else { |
} else { |
| 3644 |
# |
# |
| 3645 |
} |
} |
| 3646 |
} elsif ($token->{type} eq 'end tag') { |
|
| 3647 |
if ($self->{insertion_mode} eq 'in head' and |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3648 |
$token->{tag_name} eq 'head') { |
## As if </noscript> |
| 3649 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3650 |
$self->{insertion_mode} = 'after head'; |
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}); |
| 3651 |
!!!next-token; |
|
| 3652 |
redo B; |
## Reprocess in the "in head" insertion mode... |
| 3653 |
} elsif ($self->{insertion_mode} eq 'in head noscript' and |
## As if </head> |
|
$token->{tag_name} eq 'noscript') { |
|
| 3654 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3655 |
$self->{insertion_mode} = 'in head'; |
|
| 3656 |
!!!next-token; |
## Reprocess in the "after head" insertion mode... |
| 3657 |
redo B; |
} elsif ($self->{insertion_mode} eq 'in head') { |
| 3658 |
} elsif ($self->{insertion_mode} eq 'in head' and |
## As if </head> |
| 3659 |
{ |
pop @{$self->{open_elements}}; |
| 3660 |
body => 1, html => 1, |
|
| 3661 |
p => 1, br => 1, |
## Reprocess in the "after head" insertion mode... |
|
}->{$token->{tag_name}}) { |
|
|
# |
|
|
} elsif ($self->{insertion_mode} eq 'in head noscript' and |
|
|
{ |
|
|
p => 1, br => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
# |
|
|
} elsif ($self->{insertion_mode} ne 'after head') { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
| 3662 |
} |
} |
|
} else { |
|
|
# |
|
|
} |
|
| 3663 |
|
|
| 3664 |
## As if </head> or </noscript> or <body> |
## "after head" insertion mode |
| 3665 |
if ($self->{insertion_mode} eq 'in head') { |
## As if <body> |
|
pop @{$self->{open_elements}}; |
|
|
$self->{insertion_mode} = 'after head'; |
|
|
} elsif ($self->{insertion_mode} eq 'in head noscript') { |
|
|
pop @{$self->{open_elements}}; |
|
|
!!!parse-error (type => 'in noscript:'.(defined $token->{tag_name} ? ($token->{type} eq 'end tag' ? '/' : '') . $token->{tag_name} : '#' . $token->{type})); |
|
|
$self->{insertion_mode} = 'in head'; |
|
|
} else { # 'after head' |
|
| 3666 |
!!!insert-element ('body'); |
!!!insert-element ('body'); |
| 3667 |
$self->{insertion_mode} = 'in body'; |
$self->{insertion_mode} = 'in body'; |
| 3668 |
} |
## reprocess |
|
## reprocess |
|
|
redo B; |
|
|
|
|
|
## ISSUE: An issue in the spec. |
|
|
} elsif ($self->{insertion_mode} eq 'in body') { |
|
|
if ($token->{type} eq 'character') { |
|
|
## 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}); |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} else { |
|
|
$in_body->($insert_to_current); |
|
| 3669 |
redo B; |
redo B; |
| 3670 |
} |
} elsif ($token->{type} eq 'end tag') { |
| 3671 |
} elsif ($self->{insertion_mode} eq 'in table') { |
if ($token->{tag_name} eq 'head') { |
| 3672 |
if ($token->{type} eq 'character') { |
if ($self->{insertion_mode} eq 'before head') { |
| 3673 |
## NOTE: There are "character in table" code clones. |
## As if <head> |
| 3674 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
!!!create-element ($self->{head_element}, 'head'); |
| 3675 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3676 |
|
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3677 |
unless (length $token->{data}) { |
|
| 3678 |
|
## Reprocess in the "in head" insertion mode... |
| 3679 |
|
pop @{$self->{open_elements}}; |
| 3680 |
|
$self->{insertion_mode} = 'after head'; |
| 3681 |
|
!!!next-token; |
| 3682 |
|
redo B; |
| 3683 |
|
} elsif ($self->{insertion_mode} eq 'in head noscript') { |
| 3684 |
|
## As if </noscript> |
| 3685 |
|
pop @{$self->{open_elements}}; |
| 3686 |
|
!!!parse-error (type => 'in noscript:script'); |
| 3687 |
|
|
| 3688 |
|
## Reprocess in the "in head" insertion mode... |
| 3689 |
|
pop @{$self->{open_elements}}; |
| 3690 |
|
$self->{insertion_mode} = 'after head'; |
| 3691 |
|
!!!next-token; |
| 3692 |
|
redo B; |
| 3693 |
|
} elsif ($self->{insertion_mode} eq 'in head') { |
| 3694 |
|
pop @{$self->{open_elements}}; |
| 3695 |
|
$self->{insertion_mode} = 'after head'; |
| 3696 |
!!!next-token; |
!!!next-token; |
| 3697 |
redo B; |
redo B; |
|
} |
|
|
} |
|
|
|
|
|
!!!parse-error (type => 'in table:#character'); |
|
|
|
|
|
## As if in body, but insert into foster parent element |
|
|
## ISSUE: Spec says that "whenever a node would be inserted |
|
|
## into the current node" while characters might not be |
|
|
## result in a new Text node. |
|
|
$reconstruct_active_formatting_elements->($insert_to_foster); |
|
|
|
|
|
if ({ |
|
|
table => 1, tbody => 1, tfoot => 1, |
|
|
thead => 1, tr => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
# MUST |
|
|
my $foster_parent_element; |
|
|
my $next_sibling; |
|
|
my $prev_sibling; |
|
|
OE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
|
|
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
|
|
if (defined $parent and $parent->node_type == 1) { |
|
|
$foster_parent_element = $parent; |
|
|
$next_sibling = $self->{open_elements}->[$_]->[0]; |
|
|
$prev_sibling = $next_sibling->previous_sibling; |
|
|
} else { |
|
|
$foster_parent_element = $self->{open_elements}->[$_ - 1]->[0]; |
|
|
$prev_sibling = $foster_parent_element->last_child; |
|
|
} |
|
|
last OE; |
|
|
} |
|
|
} # OE |
|
|
$foster_parent_element = $self->{open_elements}->[0]->[0] and |
|
|
$prev_sibling = $foster_parent_element->last_child |
|
|
unless defined $foster_parent_element; |
|
|
if (defined $prev_sibling and |
|
|
$prev_sibling->node_type == 3) { |
|
|
$prev_sibling->manakai_append_text ($token->{data}); |
|
| 3698 |
} else { |
} else { |
| 3699 |
$foster_parent_element->insert_before |
# |
|
($self->{document}->create_text_node ($token->{data}), |
|
|
$next_sibling); |
|
| 3700 |
} |
} |
| 3701 |
} else { |
} elsif ($token->{tag_name} eq 'noscript') { |
| 3702 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
if ($self->{insertion_mode} eq 'in head noscript') { |
|
} |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ({ |
|
|
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') { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 3703 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3704 |
|
$self->{insertion_mode} = 'in head'; |
| 3705 |
|
!!!next-token; |
| 3706 |
|
redo B; |
| 3707 |
|
} elsif ($self->{insertion_mode} eq 'before head') { |
| 3708 |
|
!!!parse-error (type => 'unmatched end tag:noscript'); |
| 3709 |
|
## Ignore the token ## ISSUE: An issue in the spec. |
| 3710 |
|
!!!next-token; |
| 3711 |
|
redo B; |
| 3712 |
|
} else { |
| 3713 |
|
# |
| 3714 |
} |
} |
|
|
|
|
push @$active_formatting_elements, ['#marker', ''] |
|
|
if $token->{tag_name} eq 'caption'; |
|
|
|
|
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
|
|
$self->{insertion_mode} = { |
|
|
caption => 'in caption', |
|
|
colgroup => 'in column group', |
|
|
tbody => 'in table body', |
|
|
tfoot => 'in table body', |
|
|
thead => 'in table body', |
|
|
}->{$token->{tag_name}}; |
|
|
!!!next-token; |
|
|
redo B; |
|
| 3715 |
} elsif ({ |
} elsif ({ |
| 3716 |
col => 1, |
body => 1, html => 1, |
|
td => 1, th => 1, tr => 1, |
|
| 3717 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 3718 |
## Clear back to table context |
if ($self->{insertion_mode} eq 'before head') { |
| 3719 |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
## As if <head> |
| 3720 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
!!!create-element ($self->{head_element}, 'head'); |
| 3721 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3722 |
pop @{$self->{open_elements}}; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
|
} |
|
|
|
|
|
!!!insert-element ($token->{tag_name} eq 'col' ? 'colgroup' : 'tbody'); |
|
|
$self->{insertion_mode} = $token->{tag_name} eq 'col' |
|
|
? 'in column group' : 'in table body'; |
|
|
## reprocess |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'table') { |
|
|
## NOTE: There are code clones for this "table in table" |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 3723 |
|
|
| 3724 |
## As if </table> |
$self->{insertion_mode} = 'in head'; |
| 3725 |
## have a table element in table scope |
## Reprocess in the "in head" insertion mode... |
| 3726 |
my $i; |
} elsif ($self->{insertion_mode} eq 'in head noscript') { |
| 3727 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3728 |
my $node = $self->{open_elements}->[$_]; |
## Ignore the token |
|
if ($node->[1] eq 'table') { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:table'); |
|
|
## Ignore tokens </table><table> |
|
| 3729 |
!!!next-token; |
!!!next-token; |
| 3730 |
redo B; |
redo B; |
| 3731 |
} |
} |
| 3732 |
|
|
| 3733 |
## generate implied end tags |
# |
| 3734 |
if ({ |
} elsif ({ |
| 3735 |
dd => 1, dt => 1, li => 1, p => 1, |
p => 1, br => 1, |
| 3736 |
td => 1, th => 1, tr => 1, |
}->{$token->{tag_name}}) { |
| 3737 |
tbody => 1, tfoot=> 1, thead => 1, |
if ($self->{insertion_mode} eq 'before head') { |
| 3738 |
}->{$self->{open_elements}->[-1]->[1]}) { |
## As if <head> |
| 3739 |
!!!back-token; # <table> |
!!!create-element ($self->{head_element}, 'head'); |
| 3740 |
$token = {type => 'end tag', tag_name => 'table'}; |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3741 |
!!!back-token; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
| 3742 |
|
|
| 3743 |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
$self->{insertion_mode} = 'in head'; |
| 3744 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
## Reprocess in the "in head" insertion mode... |
| 3745 |
} |
} |
| 3746 |
|
|
|
splice @{$self->{open_elements}}, $i; |
|
|
|
|
|
$self->_reset_insertion_mode; |
|
|
|
|
|
## reprocess |
|
|
redo B; |
|
|
} else { |
|
| 3747 |
# |
# |
| 3748 |
} |
} else { |
| 3749 |
} elsif ($token->{type} eq 'end tag') { |
if ($self->{insertion_mode} ne 'after head') { |
|
if ($token->{tag_name} eq 'table') { |
|
|
## have a table element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq $token->{tag_name}) { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
| 3750 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3751 |
## Ignore the token |
## Ignore the token |
| 3752 |
!!!next-token; |
!!!next-token; |
| 3753 |
redo B; |
redo B; |
| 3754 |
|
} else { |
| 3755 |
|
# |
| 3756 |
} |
} |
| 3757 |
|
} |
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} |
|
| 3758 |
|
|
| 3759 |
splice @{$self->{open_elements}}, $i; |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3760 |
|
## As if </noscript> |
| 3761 |
|
pop @{$self->{open_elements}}; |
| 3762 |
|
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}); |
| 3763 |
|
|
| 3764 |
|
## Reprocess in the "in head" insertion mode... |
| 3765 |
|
## As if </head> |
| 3766 |
|
pop @{$self->{open_elements}}; |
| 3767 |
|
|
| 3768 |
$self->_reset_insertion_mode; |
## Reprocess in the "after head" insertion mode... |
| 3769 |
|
} elsif ($self->{insertion_mode} eq 'in head') { |
| 3770 |
|
## As if </head> |
| 3771 |
|
pop @{$self->{open_elements}}; |
| 3772 |
|
|
| 3773 |
!!!next-token; |
## Reprocess in the "after head" insertion mode... |
| 3774 |
redo B; |
} elsif ($self->{insertion_mode} eq 'before head') { |
|
} elsif ({ |
|
|
body => 1, caption => 1, col => 1, colgroup => 1, |
|
|
html => 1, tbody => 1, td => 1, tfoot => 1, th => 1, |
|
|
thead => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
| 3775 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3776 |
## Ignore the token |
## Ignore the token ## ISSUE: An issue in the spec. |
| 3777 |
!!!next-token; |
!!!next-token; |
| 3778 |
redo B; |
redo B; |
|
} else { |
|
|
# |
|
| 3779 |
} |
} |
| 3780 |
|
|
| 3781 |
|
## "after head" insertion mode |
| 3782 |
|
## As if <body> |
| 3783 |
|
!!!insert-element ('body'); |
| 3784 |
|
$self->{insertion_mode} = 'in body'; |
| 3785 |
|
## reprocess |
| 3786 |
|
redo B; |
| 3787 |
} else { |
} else { |
| 3788 |
# |
die "$0: $token->{type}: Unknown token type"; |
| 3789 |
} |
} |
| 3790 |
|
|
| 3791 |
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
## ISSUE: An issue in the spec. |
| 3792 |
$in_body->($insert_to_foster); |
} elsif ($self->{insertion_mode} eq 'in body' or |
| 3793 |
redo B; |
$self->{insertion_mode} eq 'in cell' or |
| 3794 |
} elsif ($self->{insertion_mode} eq 'in caption') { |
$self->{insertion_mode} eq 'in caption') { |
| 3795 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 3796 |
## NOTE: This is a code clone of "character in body". |
## NOTE: There is a code clone of "character in body". |
| 3797 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 3798 |
|
|
| 3799 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 3805 |
caption => 1, col => 1, colgroup => 1, tbody => 1, |
caption => 1, col => 1, colgroup => 1, tbody => 1, |
| 3806 |
td => 1, tfoot => 1, th => 1, thead => 1, tr => 1, |
td => 1, tfoot => 1, th => 1, thead => 1, tr => 1, |
| 3807 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 3808 |
!!!parse-error (type => 'not closed:caption'); |
if ($self->{insertion_mode} eq 'in cell') { |
| 3809 |
|
## have an element in table scope |
| 3810 |
## As if </caption> |
my $tn; |
| 3811 |
## have a table element in table scope |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3812 |
my $i; |
my $node = $self->{open_elements}->[$_]; |
| 3813 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
| 3814 |
my $node = $self->{open_elements}->[$_]; |
$tn = $node->[1]; |
| 3815 |
if ($node->[1] eq 'caption') { |
last INSCOPE; |
| 3816 |
$i = $_; |
} elsif ({ |
| 3817 |
last INSCOPE; |
table => 1, html => 1, |
| 3818 |
} elsif ({ |
}->{$node->[1]}) { |
| 3819 |
table => 1, html => 1, |
last INSCOPE; |
| 3820 |
}->{$node->[1]}) { |
} |
| 3821 |
last INSCOPE; |
} # INSCOPE |
| 3822 |
} |
unless (defined $tn) { |
| 3823 |
} # INSCOPE |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3824 |
unless (defined $i) { |
## Ignore the token |
| 3825 |
!!!parse-error (type => 'unmatched end tag:caption'); |
!!!next-token; |
| 3826 |
## Ignore the token |
redo B; |
| 3827 |
!!!next-token; |
} |
| 3828 |
redo B; |
|
| 3829 |
} |
## Close the cell |
|
|
|
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 3830 |
!!!back-token; # <?> |
!!!back-token; # <?> |
| 3831 |
$token = {type => 'end tag', tag_name => 'caption'}; |
$token = {type => 'end tag', tag_name => $tn}; |
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
| 3832 |
redo B; |
redo B; |
| 3833 |
|
} elsif ($self->{insertion_mode} eq 'in caption') { |
| 3834 |
|
!!!parse-error (type => 'not closed:caption'); |
| 3835 |
|
|
| 3836 |
|
## As if </caption> |
| 3837 |
|
## have a table element in table scope |
| 3838 |
|
my $i; |
| 3839 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3840 |
|
my $node = $self->{open_elements}->[$_]; |
| 3841 |
|
if ($node->[1] eq 'caption') { |
| 3842 |
|
$i = $_; |
| 3843 |
|
last INSCOPE; |
| 3844 |
|
} elsif ({ |
| 3845 |
|
table => 1, html => 1, |
| 3846 |
|
}->{$node->[1]}) { |
| 3847 |
|
last INSCOPE; |
| 3848 |
|
} |
| 3849 |
|
} # INSCOPE |
| 3850 |
|
unless (defined $i) { |
| 3851 |
|
!!!parse-error (type => 'unmatched end tag:caption'); |
| 3852 |
|
## Ignore the token |
| 3853 |
|
!!!next-token; |
| 3854 |
|
redo B; |
| 3855 |
|
} |
| 3856 |
|
|
| 3857 |
|
## generate implied end tags |
| 3858 |
|
if ({ |
| 3859 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 3860 |
|
td => 1, th => 1, tr => 1, |
| 3861 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3862 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3863 |
|
!!!back-token; # <?> |
| 3864 |
|
$token = {type => 'end tag', tag_name => 'caption'}; |
| 3865 |
|
!!!back-token; |
| 3866 |
|
$token = {type => 'end tag', |
| 3867 |
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
| 3868 |
|
redo B; |
| 3869 |
|
} |
| 3870 |
|
|
| 3871 |
|
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 3872 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 3873 |
|
} |
| 3874 |
|
|
| 3875 |
|
splice @{$self->{open_elements}}, $i; |
| 3876 |
|
|
| 3877 |
|
$clear_up_to_marker->(); |
| 3878 |
|
|
| 3879 |
|
$self->{insertion_mode} = 'in table'; |
| 3880 |
|
|
| 3881 |
|
## reprocess |
| 3882 |
|
redo B; |
| 3883 |
|
} else { |
| 3884 |
|
# |
| 3885 |
} |
} |
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} |
|
|
|
|
|
splice @{$self->{open_elements}}, $i; |
|
|
|
|
|
$clear_up_to_marker->(); |
|
|
|
|
|
$self->{insertion_mode} = 'in table'; |
|
|
|
|
|
## reprocess |
|
|
redo B; |
|
| 3886 |
} else { |
} else { |
| 3887 |
# |
# |
| 3888 |
} |
} |
| 3889 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 3890 |
if ($token->{tag_name} eq 'caption') { |
if ($token->{tag_name} eq 'td' or $token->{tag_name} eq 'th') { |
| 3891 |
## have a table element in table scope |
if ($self->{insertion_mode} eq 'in cell') { |
| 3892 |
|
## have an element in table scope |
| 3893 |
|
my $i; |
| 3894 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3895 |
|
my $node = $self->{open_elements}->[$_]; |
| 3896 |
|
if ($node->[1] eq $token->{tag_name}) { |
| 3897 |
|
$i = $_; |
| 3898 |
|
last INSCOPE; |
| 3899 |
|
} elsif ({ |
| 3900 |
|
table => 1, html => 1, |
| 3901 |
|
}->{$node->[1]}) { |
| 3902 |
|
last INSCOPE; |
| 3903 |
|
} |
| 3904 |
|
} # INSCOPE |
| 3905 |
|
unless (defined $i) { |
| 3906 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3907 |
|
## Ignore the token |
| 3908 |
|
!!!next-token; |
| 3909 |
|
redo B; |
| 3910 |
|
} |
| 3911 |
|
|
| 3912 |
|
## generate implied end tags |
| 3913 |
|
if ({ |
| 3914 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 3915 |
|
td => ($token->{tag_name} eq 'th'), |
| 3916 |
|
th => ($token->{tag_name} eq 'td'), |
| 3917 |
|
tr => 1, |
| 3918 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3919 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3920 |
|
!!!back-token; |
| 3921 |
|
$token = {type => 'end tag', |
| 3922 |
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
| 3923 |
|
redo B; |
| 3924 |
|
} |
| 3925 |
|
|
| 3926 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 3927 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 3928 |
|
} |
| 3929 |
|
|
| 3930 |
|
splice @{$self->{open_elements}}, $i; |
| 3931 |
|
|
| 3932 |
|
$clear_up_to_marker->(); |
| 3933 |
|
|
| 3934 |
|
$self->{insertion_mode} = 'in row'; |
| 3935 |
|
|
| 3936 |
|
!!!next-token; |
| 3937 |
|
redo B; |
| 3938 |
|
} elsif ($self->{insertion_mode} eq 'in caption') { |
| 3939 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3940 |
|
## Ignore the token |
| 3941 |
|
!!!next-token; |
| 3942 |
|
redo B; |
| 3943 |
|
} else { |
| 3944 |
|
# |
| 3945 |
|
} |
| 3946 |
|
} elsif ($token->{tag_name} eq 'caption') { |
| 3947 |
|
if ($self->{insertion_mode} eq 'in caption') { |
| 3948 |
|
## have a table element in table scope |
| 3949 |
|
my $i; |
| 3950 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3951 |
|
my $node = $self->{open_elements}->[$_]; |
| 3952 |
|
if ($node->[1] eq $token->{tag_name}) { |
| 3953 |
|
$i = $_; |
| 3954 |
|
last INSCOPE; |
| 3955 |
|
} elsif ({ |
| 3956 |
|
table => 1, html => 1, |
| 3957 |
|
}->{$node->[1]}) { |
| 3958 |
|
last INSCOPE; |
| 3959 |
|
} |
| 3960 |
|
} # INSCOPE |
| 3961 |
|
unless (defined $i) { |
| 3962 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3963 |
|
## Ignore the token |
| 3964 |
|
!!!next-token; |
| 3965 |
|
redo B; |
| 3966 |
|
} |
| 3967 |
|
|
| 3968 |
|
## generate implied end tags |
| 3969 |
|
if ({ |
| 3970 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 3971 |
|
td => 1, th => 1, tr => 1, |
| 3972 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3973 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3974 |
|
!!!back-token; |
| 3975 |
|
$token = {type => 'end tag', |
| 3976 |
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
| 3977 |
|
redo B; |
| 3978 |
|
} |
| 3979 |
|
|
| 3980 |
|
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 3981 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 3982 |
|
} |
| 3983 |
|
|
| 3984 |
|
splice @{$self->{open_elements}}, $i; |
| 3985 |
|
|
| 3986 |
|
$clear_up_to_marker->(); |
| 3987 |
|
|
| 3988 |
|
$self->{insertion_mode} = 'in table'; |
| 3989 |
|
|
| 3990 |
|
!!!next-token; |
| 3991 |
|
redo B; |
| 3992 |
|
} elsif ($self->{insertion_mode} eq 'in cell') { |
| 3993 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3994 |
|
## Ignore the token |
| 3995 |
|
!!!next-token; |
| 3996 |
|
redo B; |
| 3997 |
|
} else { |
| 3998 |
|
# |
| 3999 |
|
} |
| 4000 |
|
} elsif ({ |
| 4001 |
|
table => 1, tbody => 1, tfoot => 1, |
| 4002 |
|
thead => 1, tr => 1, |
| 4003 |
|
}->{$token->{tag_name}} and |
| 4004 |
|
$self->{insertion_mode} eq 'in cell') { |
| 4005 |
|
## have an element in table scope |
| 4006 |
my $i; |
my $i; |
| 4007 |
|
my $tn; |
| 4008 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4009 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4010 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq $token->{tag_name}) { |
| 4011 |
$i = $_; |
$i = $_; |
| 4012 |
last INSCOPE; |
last INSCOPE; |
| 4013 |
|
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
| 4014 |
|
$tn = $node->[1]; |
| 4015 |
|
## NOTE: There is exactly one |td| or |th| element |
| 4016 |
|
## in scope in the stack of open elements by definition. |
| 4017 |
} elsif ({ |
} elsif ({ |
| 4018 |
table => 1, html => 1, |
table => 1, html => 1, |
| 4019 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 4026 |
!!!next-token; |
!!!next-token; |
| 4027 |
redo B; |
redo B; |
| 4028 |
} |
} |
|
|
|
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} |
|
|
|
|
|
splice @{$self->{open_elements}}, $i; |
|
|
|
|
|
$clear_up_to_marker->(); |
|
|
|
|
|
$self->{insertion_mode} = 'in table'; |
|
| 4029 |
|
|
| 4030 |
!!!next-token; |
## Close the cell |
| 4031 |
|
!!!back-token; # </?> |
| 4032 |
|
$token = {type => 'end tag', tag_name => $tn}; |
| 4033 |
redo B; |
redo B; |
| 4034 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table' and |
| 4035 |
|
$self->{insertion_mode} eq 'in caption') { |
| 4036 |
!!!parse-error (type => 'not closed:caption'); |
!!!parse-error (type => 'not closed:caption'); |
| 4037 |
|
|
| 4038 |
## As if </caption> |
## As if </caption> |
| 4083 |
## reprocess |
## reprocess |
| 4084 |
redo B; |
redo B; |
| 4085 |
} elsif ({ |
} elsif ({ |
| 4086 |
body => 1, col => 1, colgroup => 1, |
body => 1, col => 1, colgroup => 1, html => 1, |
|
html => 1, tbody => 1, td => 1, tfoot => 1, |
|
|
th => 1, thead => 1, tr => 1, |
|
| 4087 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4088 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
if ($self->{insertion_mode} eq 'in cell' or |
| 4089 |
## Ignore the token |
$self->{insertion_mode} eq 'in caption') { |
| 4090 |
!!!next-token; |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} else { |
|
|
# |
|
|
} |
|
|
|
|
|
$in_body->($insert_to_current); |
|
|
redo B; |
|
|
} elsif ($self->{insertion_mode} eq 'in column group') { |
|
|
if ($token->{type} eq 'character') { |
|
|
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
|
|
unless (length $token->{data}) { |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
} |
|
|
|
|
|
# |
|
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ($token->{tag_name} eq 'col') { |
|
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
|
|
pop @{$self->{open_elements}}; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} elsif ($token->{type} eq 'end tag') { |
|
|
if ($token->{tag_name} eq 'colgroup') { |
|
|
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
|
|
!!!parse-error (type => 'unmatched end tag:colgroup'); |
|
| 4091 |
## Ignore the token |
## Ignore the token |
| 4092 |
!!!next-token; |
!!!next-token; |
| 4093 |
redo B; |
redo B; |
| 4094 |
} else { |
} else { |
| 4095 |
pop @{$self->{open_elements}}; # colgroup |
# |
|
$self->{insertion_mode} = 'in table'; |
|
|
!!!next-token; |
|
|
redo B; |
|
| 4096 |
} |
} |
| 4097 |
} elsif ($token->{tag_name} eq 'col') { |
} elsif ({ |
| 4098 |
!!!parse-error (type => 'unmatched end tag:col'); |
tbody => 1, tfoot => 1, |
| 4099 |
|
thead => 1, tr => 1, |
| 4100 |
|
}->{$token->{tag_name}} and |
| 4101 |
|
$self->{insertion_mode} eq 'in caption') { |
| 4102 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4103 |
## Ignore the token |
## Ignore the token |
| 4104 |
!!!next-token; |
!!!next-token; |
| 4105 |
redo B; |
redo B; |
| 4106 |
} else { |
} else { |
| 4107 |
# |
# |
| 4108 |
} |
} |
| 4109 |
} else { |
} else { |
| 4110 |
# |
# |
| 4111 |
} |
} |
| 4112 |
|
|
| 4113 |
## As if </colgroup> |
$in_body->($insert_to_current); |
| 4114 |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
redo B; |
| 4115 |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
} elsif ($self->{insertion_mode} eq 'in row' or |
| 4116 |
## Ignore the token |
$self->{insertion_mode} eq 'in table body' or |
| 4117 |
!!!next-token; |
$self->{insertion_mode} eq 'in table') { |
|
redo B; |
|
|
} else { |
|
|
pop @{$self->{open_elements}}; # colgroup |
|
|
$self->{insertion_mode} = 'in table'; |
|
|
## reprocess |
|
|
redo B; |
|
|
} |
|
|
} elsif ($self->{insertion_mode} eq 'in table body') { |
|
| 4118 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 4119 |
## NOTE: This is a "character in table" code clone. |
## NOTE: There are "character in table" code clones. |
| 4120 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4121 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 4122 |
|
|
| 4133 |
## into the current node" while characters might not be |
## into the current node" while characters might not be |
| 4134 |
## result in a new Text node. |
## result in a new Text node. |
| 4135 |
$reconstruct_active_formatting_elements->($insert_to_foster); |
$reconstruct_active_formatting_elements->($insert_to_foster); |
| 4136 |
|
|
| 4137 |
if ({ |
if ({ |
| 4138 |
table => 1, tbody => 1, tfoot => 1, |
table => 1, tbody => 1, tfoot => 1, |
| 4139 |
thead => 1, tr => 1, |
thead => 1, tr => 1, |
| 4175 |
redo B; |
redo B; |
| 4176 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 4177 |
if ({ |
if ({ |
| 4178 |
tr => 1, |
tr => ($self->{insertion_mode} ne 'in row'), |
| 4179 |
th => 1, td => 1, |
th => 1, td => 1, |
| 4180 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4181 |
unless ($token->{tag_name} eq 'tr') { |
if ($self->{insertion_mode} eq 'in table') { |
| 4182 |
!!!parse-error (type => 'missing start tag:tr'); |
## Clear back to table context |
| 4183 |
|
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
| 4184 |
|
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4185 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4186 |
|
pop @{$self->{open_elements}}; |
| 4187 |
|
} |
| 4188 |
|
|
| 4189 |
|
!!!insert-element ('tbody'); |
| 4190 |
|
$self->{insertion_mode} = 'in table body'; |
| 4191 |
|
## reprocess in the "in table body" insertion mode... |
| 4192 |
|
} |
| 4193 |
|
|
| 4194 |
|
if ($self->{insertion_mode} eq 'in table body') { |
| 4195 |
|
unless ($token->{tag_name} eq 'tr') { |
| 4196 |
|
!!!parse-error (type => 'missing start tag:tr'); |
| 4197 |
|
} |
| 4198 |
|
|
| 4199 |
|
## Clear back to table body context |
| 4200 |
|
while (not { |
| 4201 |
|
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4202 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4203 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4204 |
|
pop @{$self->{open_elements}}; |
| 4205 |
|
} |
| 4206 |
|
|
| 4207 |
|
$self->{insertion_mode} = 'in row'; |
| 4208 |
|
if ($token->{tag_name} eq 'tr') { |
| 4209 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4210 |
|
!!!next-token; |
| 4211 |
|
redo B; |
| 4212 |
|
} else { |
| 4213 |
|
!!!insert-element ('tr'); |
| 4214 |
|
## reprocess in the "in row" insertion mode |
| 4215 |
|
} |
| 4216 |
} |
} |
| 4217 |
|
|
| 4218 |
## Clear back to table body context |
## Clear back to table row context |
| 4219 |
while (not { |
while (not { |
| 4220 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
tr => 1, html => 1, |
| 4221 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4222 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4223 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4224 |
} |
} |
| 4225 |
|
|
| 4226 |
$self->{insertion_mode} = 'in row'; |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4227 |
if ($token->{tag_name} eq 'tr') { |
$self->{insertion_mode} = 'in cell'; |
| 4228 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
|
| 4229 |
!!!next-token; |
push @$active_formatting_elements, ['#marker', '']; |
| 4230 |
} else { |
|
| 4231 |
!!!insert-element ('tr'); |
!!!next-token; |
|
## reprocess |
|
|
} |
|
| 4232 |
redo B; |
redo B; |
| 4233 |
} elsif ({ |
} elsif ({ |
| 4234 |
caption => 1, col => 1, colgroup => 1, |
caption => 1, col => 1, colgroup => 1, |
| 4235 |
tbody => 1, tfoot => 1, thead => 1, |
tbody => 1, tfoot => 1, thead => 1, |
| 4236 |
|
tr => 1, # $self->{insertion_mode} eq 'in row' |
| 4237 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4238 |
## have an element in table scope |
if ($self->{insertion_mode} eq 'in row') { |
| 4239 |
my $i; |
## As if </tr> |
| 4240 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
## have an element in table scope |
| 4241 |
my $node = $self->{open_elements}->[$_]; |
my $i; |
| 4242 |
if ({ |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4243 |
tbody => 1, thead => 1, tfoot => 1, |
my $node = $self->{open_elements}->[$_]; |
| 4244 |
}->{$node->[1]}) { |
if ($node->[1] eq 'tr') { |
| 4245 |
$i = $_; |
$i = $_; |
| 4246 |
last INSCOPE; |
last INSCOPE; |
| 4247 |
} elsif ({ |
} elsif ({ |
| 4248 |
table => 1, html => 1, |
table => 1, html => 1, |
| 4249 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 4250 |
last INSCOPE; |
last INSCOPE; |
| 4251 |
|
} |
| 4252 |
|
} # INSCOPE |
| 4253 |
|
unless (defined $i) { |
| 4254 |
|
!!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}); |
| 4255 |
|
## Ignore the token |
| 4256 |
|
!!!next-token; |
| 4257 |
|
redo B; |
| 4258 |
|
} |
| 4259 |
|
|
| 4260 |
|
## Clear back to table row context |
| 4261 |
|
while (not { |
| 4262 |
|
tr => 1, html => 1, |
| 4263 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4264 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4265 |
|
pop @{$self->{open_elements}}; |
| 4266 |
|
} |
| 4267 |
|
|
| 4268 |
|
pop @{$self->{open_elements}}; # tr |
| 4269 |
|
$self->{insertion_mode} = 'in table body'; |
| 4270 |
|
if ($token->{tag_name} eq 'tr') { |
| 4271 |
|
## reprocess |
| 4272 |
|
redo B; |
| 4273 |
|
} else { |
| 4274 |
|
## reprocess in the "in table body" insertion mode... |
| 4275 |
} |
} |
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
| 4276 |
} |
} |
| 4277 |
|
|
| 4278 |
## Clear back to table body context |
if ($self->{insertion_mode} eq 'in table body') { |
| 4279 |
while (not { |
## have an element in table scope |
| 4280 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
my $i; |
| 4281 |
}->{$self->{open_elements}->[-1]->[1]}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4282 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
my $node = $self->{open_elements}->[$_]; |
| 4283 |
|
if ({ |
| 4284 |
|
tbody => 1, thead => 1, tfoot => 1, |
| 4285 |
|
}->{$node->[1]}) { |
| 4286 |
|
$i = $_; |
| 4287 |
|
last INSCOPE; |
| 4288 |
|
} elsif ({ |
| 4289 |
|
table => 1, html => 1, |
| 4290 |
|
}->{$node->[1]}) { |
| 4291 |
|
last INSCOPE; |
| 4292 |
|
} |
| 4293 |
|
} # INSCOPE |
| 4294 |
|
unless (defined $i) { |
| 4295 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4296 |
|
## Ignore the token |
| 4297 |
|
!!!next-token; |
| 4298 |
|
redo B; |
| 4299 |
|
} |
| 4300 |
|
|
| 4301 |
|
## Clear back to table body context |
| 4302 |
|
while (not { |
| 4303 |
|
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4304 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4305 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4306 |
|
pop @{$self->{open_elements}}; |
| 4307 |
|
} |
| 4308 |
|
|
| 4309 |
|
## As if <{current node}> |
| 4310 |
|
## have an element in table scope |
| 4311 |
|
## true by definition |
| 4312 |
|
|
| 4313 |
|
## Clear back to table body context |
| 4314 |
|
## nop by definition |
| 4315 |
|
|
| 4316 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4317 |
|
$self->{insertion_mode} = 'in table'; |
| 4318 |
|
## reprocess in "in table" insertion mode... |
| 4319 |
} |
} |
| 4320 |
|
|
| 4321 |
## As if <{current node}> |
if ($token->{tag_name} eq 'col') { |
| 4322 |
## have an element in table scope |
## Clear back to table context |
| 4323 |
## true by definition |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
| 4324 |
|
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4325 |
## Clear back to table body context |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4326 |
## nop by definition |
pop @{$self->{open_elements}}; |
| 4327 |
|
} |
| 4328 |
pop @{$self->{open_elements}}; |
|
| 4329 |
$self->{insertion_mode} = 'in table'; |
!!!insert-element ('colgroup'); |
| 4330 |
## reprocess |
$self->{insertion_mode} = 'in column group'; |
| 4331 |
redo B; |
## reprocess |
| 4332 |
|
redo B; |
| 4333 |
|
} elsif ({ |
| 4334 |
|
caption => 1, |
| 4335 |
|
colgroup => 1, |
| 4336 |
|
tbody => 1, tfoot => 1, thead => 1, |
| 4337 |
|
}->{$token->{tag_name}}) { |
| 4338 |
|
## Clear back to table context |
| 4339 |
|
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
| 4340 |
|
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4341 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4342 |
|
pop @{$self->{open_elements}}; |
| 4343 |
|
} |
| 4344 |
|
|
| 4345 |
|
push @$active_formatting_elements, ['#marker', ''] |
| 4346 |
|
if $token->{tag_name} eq 'caption'; |
| 4347 |
|
|
| 4348 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4349 |
|
$self->{insertion_mode} = { |
| 4350 |
|
caption => 'in caption', |
| 4351 |
|
colgroup => 'in column group', |
| 4352 |
|
tbody => 'in table body', |
| 4353 |
|
tfoot => 'in table body', |
| 4354 |
|
thead => 'in table body', |
| 4355 |
|
}->{$token->{tag_name}}; |
| 4356 |
|
!!!next-token; |
| 4357 |
|
redo B; |
| 4358 |
|
} else { |
| 4359 |
|
die "$0: in table: <>: $token->{tag_name}"; |
| 4360 |
|
} |
| 4361 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 4362 |
## NOTE: This is a code clone of "table in table" |
## NOTE: There are code clones for this "table in table" |
| 4363 |
!!!parse-error (type => 'not closed:table'); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4364 |
|
|
| 4365 |
## As if </table> |
## As if </table> |
| 4366 |
## have a table element in table scope |
## have a table element in table scope |
| 4403 |
|
|
| 4404 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 4405 |
|
|
| 4406 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 4407 |
|
|
| 4408 |
## reprocess |
## reprocess |
| 4409 |
redo B; |
redo B; |
| 4411 |
# |
# |
| 4412 |
} |
} |
| 4413 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 4414 |
if ({ |
if ($token->{tag_name} eq 'tr' and |
| 4415 |
tbody => 1, tfoot => 1, thead => 1, |
$self->{insertion_mode} eq 'in row') { |
|
}->{$token->{tag_name}}) { |
|
| 4416 |
## have an element in table scope |
## have an element in table scope |
| 4417 |
my $i; |
my $i; |
| 4418 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4433 |
redo B; |
redo B; |
| 4434 |
} |
} |
| 4435 |
|
|
| 4436 |
## Clear back to table body context |
## Clear back to table row context |
| 4437 |
while (not { |
while (not { |
| 4438 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
tr => 1, html => 1, |
| 4439 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4440 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4441 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4442 |
} |
} |
| 4443 |
|
|
| 4444 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; # tr |
| 4445 |
$self->{insertion_mode} = 'in table'; |
$self->{insertion_mode} = 'in table body'; |
| 4446 |
!!!next-token; |
!!!next-token; |
| 4447 |
redo B; |
redo B; |
| 4448 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 4449 |
## have an element in table scope |
if ($self->{insertion_mode} eq 'in row') { |
| 4450 |
my $i; |
## As if </tr> |
| 4451 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
## have an element in table scope |
| 4452 |
my $node = $self->{open_elements}->[$_]; |
my $i; |
| 4453 |
if ({ |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4454 |
tbody => 1, thead => 1, tfoot => 1, |
my $node = $self->{open_elements}->[$_]; |
| 4455 |
}->{$node->[1]}) { |
if ($node->[1] eq 'tr') { |
| 4456 |
$i = $_; |
$i = $_; |
| 4457 |
last INSCOPE; |
last INSCOPE; |
| 4458 |
} elsif ({ |
} elsif ({ |
| 4459 |
table => 1, html => 1, |
table => 1, html => 1, |
| 4460 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 4461 |
last INSCOPE; |
last INSCOPE; |
| 4462 |
} |
} |
| 4463 |
} # INSCOPE |
} # INSCOPE |
| 4464 |
unless (defined $i) { |
unless (defined $i) { |
| 4465 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{type}); |
| 4466 |
## Ignore the token |
## Ignore the token |
| 4467 |
!!!next-token; |
!!!next-token; |
| 4468 |
redo B; |
redo B; |
| 4469 |
} |
} |
| 4470 |
|
|
| 4471 |
## Clear back to table body context |
## Clear back to table row context |
| 4472 |
while (not { |
while (not { |
| 4473 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
tr => 1, html => 1, |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
|
## As if <{current node}> |
|
|
## have an element in table scope |
|
|
## true by definition |
|
|
|
|
|
## Clear back to table body context |
|
|
## nop by definition |
|
|
|
|
|
pop @{$self->{open_elements}}; |
|
|
$self->{insertion_mode} = 'in table'; |
|
|
## reprocess |
|
|
redo B; |
|
|
} elsif ({ |
|
|
body => 1, caption => 1, col => 1, colgroup => 1, |
|
|
html => 1, td => 1, th => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} else { |
|
|
# |
|
|
} |
|
|
|
|
|
## As if in table |
|
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
|
|
$in_body->($insert_to_foster); |
|
|
redo B; |
|
|
} elsif ($self->{insertion_mode} eq 'in row') { |
|
|
if ($token->{type} eq 'character') { |
|
|
## NOTE: This is a "character in table" code clone. |
|
|
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
|
|
|
|
|
unless (length $token->{data}) { |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
} |
|
|
|
|
|
!!!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, |
|
| 4474 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4475 |
# MUST |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4476 |
my $foster_parent_element; |
pop @{$self->{open_elements}}; |
| 4477 |
my $next_sibling; |
} |
| 4478 |
my $prev_sibling; |
|
| 4479 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
pop @{$self->{open_elements}}; # tr |
| 4480 |
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
$self->{insertion_mode} = 'in table body'; |
| 4481 |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
## reprocess in the "in table body" insertion mode... |
| 4482 |
if (defined $parent and $parent->node_type == 1) { |
} |
| 4483 |
$foster_parent_element = $parent; |
|
| 4484 |
$next_sibling = $self->{open_elements}->[$_]->[0]; |
if ($self->{insertion_mode} eq 'in table body') { |
| 4485 |
$prev_sibling = $next_sibling->previous_sibling; |
## have an element in table scope |
| 4486 |
} else { |
my $i; |
| 4487 |
$foster_parent_element = $self->{open_elements}->[$_ - 1]->[0]; |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4488 |
$prev_sibling = $foster_parent_element->last_child; |
my $node = $self->{open_elements}->[$_]; |
| 4489 |
|
if ({ |
| 4490 |
|
tbody => 1, thead => 1, tfoot => 1, |
| 4491 |
|
}->{$node->[1]}) { |
| 4492 |
|
$i = $_; |
| 4493 |
|
last INSCOPE; |
| 4494 |
|
} elsif ({ |
| 4495 |
|
table => 1, html => 1, |
| 4496 |
|
}->{$node->[1]}) { |
| 4497 |
|
last INSCOPE; |
| 4498 |
} |
} |
| 4499 |
last OE; |
} # INSCOPE |
| 4500 |
|
unless (defined $i) { |
| 4501 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4502 |
|
## Ignore the token |
| 4503 |
|
!!!next-token; |
| 4504 |
|
redo B; |
| 4505 |
|
} |
| 4506 |
|
|
| 4507 |
|
## Clear back to table body context |
| 4508 |
|
while (not { |
| 4509 |
|
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4510 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4511 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4512 |
|
pop @{$self->{open_elements}}; |
| 4513 |
} |
} |
| 4514 |
} # OE |
|
| 4515 |
$foster_parent_element = $self->{open_elements}->[0]->[0] and |
## As if <{current node}> |
| 4516 |
$prev_sibling = $foster_parent_element->last_child |
## have an element in table scope |
| 4517 |
unless defined $foster_parent_element; |
## true by definition |
| 4518 |
if (defined $prev_sibling and |
|
| 4519 |
$prev_sibling->node_type == 3) { |
## Clear back to table body context |
| 4520 |
$prev_sibling->manakai_append_text ($token->{data}); |
## nop by definition |
| 4521 |
} else { |
|
|
$foster_parent_element->insert_before |
|
|
($self->{document}->create_text_node ($token->{data}), |
|
|
$next_sibling); |
|
|
} |
|
|
} else { |
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
|
|
} |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ($token->{tag_name} eq 'th' or |
|
|
$token->{tag_name} eq 'td') { |
|
|
## Clear back to table row context |
|
|
while (not { |
|
|
tr => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4522 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4523 |
|
$self->{insertion_mode} = 'in table'; |
| 4524 |
|
## reprocess in the "in table" insertion mode... |
| 4525 |
} |
} |
|
|
|
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
|
|
$self->{insertion_mode} = 'in cell'; |
|
| 4526 |
|
|
| 4527 |
push @$active_formatting_elements, ['#marker', '']; |
## have a table element in table scope |
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
caption => 1, col => 1, colgroup => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## As if </tr> |
|
|
## have an element in table scope |
|
| 4528 |
my $i; |
my $i; |
| 4529 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4530 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4531 |
if ($node->[1] eq 'tr') { |
if ($node->[1] eq $token->{tag_name}) { |
| 4532 |
$i = $_; |
$i = $_; |
| 4533 |
last INSCOPE; |
last INSCOPE; |
| 4534 |
} elsif ({ |
} elsif ({ |
| 4538 |
} |
} |
| 4539 |
} # INSCOPE |
} # INSCOPE |
| 4540 |
unless (defined $i) { |
unless (defined $i) { |
| 4541 |
!!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4542 |
## Ignore the token |
## Ignore the token |
| 4543 |
!!!next-token; |
!!!next-token; |
| 4544 |
redo B; |
redo B; |
| 4545 |
} |
} |
| 4546 |
|
|
|
## Clear back to table row context |
|
|
while (not { |
|
|
tr => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
|
pop @{$self->{open_elements}}; # tr |
|
|
$self->{insertion_mode} = 'in table body'; |
|
|
## reprocess |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'table') { |
|
|
## NOTE: This is a code clone of "table in table" |
|
|
!!!parse-error (type => 'not closed:table'); |
|
|
|
|
|
## As if </table> |
|
|
## have a table element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq 'table') { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:table'); |
|
|
## Ignore tokens </table><table> |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
| 4547 |
## generate implied end tags |
## generate implied end tags |
| 4548 |
if ({ |
if ({ |
| 4549 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4550 |
td => 1, th => 1, tr => 1, |
td => 1, th => 1, tr => 1, |
| 4551 |
tbody => 1, tfoot=> 1, thead => 1, |
tbody => 1, tfoot=> 1, thead => 1, |
| 4552 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
!!!back-token; # <table> |
|
|
$token = {type => 'end tag', tag_name => 'table'}; |
|
| 4553 |
!!!back-token; |
!!!back-token; |
| 4554 |
$token = {type => 'end tag', |
$token = {type => 'end tag', |
| 4555 |
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
| 4556 |
redo B; |
redo B; |
| 4557 |
} |
} |
| 4558 |
|
|
| 4559 |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
| 4560 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4561 |
} |
} |
| 4562 |
|
|
| 4563 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 4564 |
|
|
| 4565 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 4566 |
|
|
|
## reprocess |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} elsif ($token->{type} eq 'end tag') { |
|
|
if ($token->{tag_name} eq 'tr') { |
|
|
## have an element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq $token->{tag_name}) { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## Clear back to table row context |
|
|
while (not { |
|
|
tr => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
|
pop @{$self->{open_elements}}; # tr |
|
|
$self->{insertion_mode} = 'in table body'; |
|
| 4567 |
!!!next-token; |
!!!next-token; |
| 4568 |
redo B; |
redo B; |
|
} elsif ($token->{tag_name} eq 'table') { |
|
|
## As if </tr> |
|
|
## have an element in table scope |
|
|
my $i; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq 'tr') { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{type}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## Clear back to table row context |
|
|
while (not { |
|
|
tr => 1, html => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
|
pop @{$self->{open_elements}}; # tr |
|
|
$self->{insertion_mode} = 'in table body'; |
|
|
## reprocess |
|
|
redo B; |
|
| 4569 |
} elsif ({ |
} elsif ({ |
| 4570 |
tbody => 1, tfoot => 1, thead => 1, |
tbody => 1, tfoot => 1, thead => 1, |
| 4571 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}} and |
| 4572 |
## have an element in table scope |
($self->{insertion_mode} eq 'in row' or |
| 4573 |
my $i; |
$self->{insertion_mode} eq 'in table body')) { |
| 4574 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
if ($self->{insertion_mode} eq 'in row') { |
| 4575 |
my $node = $self->{open_elements}->[$_]; |
## have an element in table scope |
| 4576 |
if ($node->[1] eq $token->{tag_name}) { |
my $i; |
| 4577 |
$i = $_; |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4578 |
last INSCOPE; |
my $node = $self->{open_elements}->[$_]; |
| 4579 |
} elsif ({ |
if ($node->[1] eq $token->{tag_name}) { |
| 4580 |
table => 1, html => 1, |
$i = $_; |
| 4581 |
}->{$node->[1]}) { |
last INSCOPE; |
| 4582 |
last INSCOPE; |
} elsif ({ |
| 4583 |
|
table => 1, html => 1, |
| 4584 |
|
}->{$node->[1]}) { |
| 4585 |
|
last INSCOPE; |
| 4586 |
|
} |
| 4587 |
|
} # INSCOPE |
| 4588 |
|
unless (defined $i) { |
| 4589 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4590 |
|
## Ignore the token |
| 4591 |
|
!!!next-token; |
| 4592 |
|
redo B; |
| 4593 |
|
} |
| 4594 |
|
|
| 4595 |
|
## As if </tr> |
| 4596 |
|
## have an element in table scope |
| 4597 |
|
my $i; |
| 4598 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4599 |
|
my $node = $self->{open_elements}->[$_]; |
| 4600 |
|
if ($node->[1] eq 'tr') { |
| 4601 |
|
$i = $_; |
| 4602 |
|
last INSCOPE; |
| 4603 |
|
} elsif ({ |
| 4604 |
|
table => 1, html => 1, |
| 4605 |
|
}->{$node->[1]}) { |
| 4606 |
|
last INSCOPE; |
| 4607 |
|
} |
| 4608 |
|
} # INSCOPE |
| 4609 |
|
unless (defined $i) { |
| 4610 |
|
!!!parse-error (type => 'unmatched end tag:tr'); |
| 4611 |
|
## Ignore the token |
| 4612 |
|
!!!next-token; |
| 4613 |
|
redo B; |
| 4614 |
|
} |
| 4615 |
|
|
| 4616 |
|
## Clear back to table row context |
| 4617 |
|
while (not { |
| 4618 |
|
tr => 1, html => 1, |
| 4619 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4620 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4621 |
|
pop @{$self->{open_elements}}; |
| 4622 |
} |
} |
| 4623 |
} # INSCOPE |
|
| 4624 |
unless (defined $i) { |
pop @{$self->{open_elements}}; # tr |
| 4625 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
$self->{insertion_mode} = 'in table body'; |
| 4626 |
## Ignore the token |
## reprocess in the "in table body" insertion mode... |
|
!!!next-token; |
|
|
redo B; |
|
| 4627 |
} |
} |
| 4628 |
|
|
|
## As if </tr> |
|
| 4629 |
## have an element in table scope |
## have an element in table scope |
| 4630 |
my $i; |
my $i; |
| 4631 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4632 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4633 |
if ($node->[1] eq 'tr') { |
if ($node->[1] eq $token->{tag_name}) { |
| 4634 |
$i = $_; |
$i = $_; |
| 4635 |
last INSCOPE; |
last INSCOPE; |
| 4636 |
} elsif ({ |
} elsif ({ |
| 4640 |
} |
} |
| 4641 |
} # INSCOPE |
} # INSCOPE |
| 4642 |
unless (defined $i) { |
unless (defined $i) { |
| 4643 |
!!!parse-error (type => 'unmatched end tag:tr'); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4644 |
## Ignore the token |
## Ignore the token |
| 4645 |
!!!next-token; |
!!!next-token; |
| 4646 |
redo B; |
redo B; |
| 4647 |
} |
} |
| 4648 |
|
|
| 4649 |
## Clear back to table row context |
## Clear back to table body context |
| 4650 |
while (not { |
while (not { |
| 4651 |
tr => 1, html => 1, |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4652 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4653 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4654 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4655 |
} |
} |
| 4656 |
|
|
| 4657 |
pop @{$self->{open_elements}}; # tr |
pop @{$self->{open_elements}}; |
| 4658 |
$self->{insertion_mode} = 'in table body'; |
$self->{insertion_mode} = 'in table'; |
| 4659 |
## reprocess |
!!!next-token; |
| 4660 |
redo B; |
redo B; |
| 4661 |
} elsif ({ |
} elsif ({ |
| 4662 |
body => 1, caption => 1, col => 1, |
body => 1, caption => 1, col => 1, colgroup => 1, |
| 4663 |
colgroup => 1, html => 1, td => 1, th => 1, |
html => 1, td => 1, th => 1, |
| 4664 |
|
tr => 1, # $self->{insertion_mode} eq 'in row' |
| 4665 |
|
tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} eq 'in table' |
| 4666 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4667 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 4668 |
## Ignore the token |
## Ignore the token |
| 4672 |
# |
# |
| 4673 |
} |
} |
| 4674 |
} else { |
} else { |
| 4675 |
# |
die "$0: $token->{type}: Unknown token type"; |
| 4676 |
} |
} |
| 4677 |
|
|
|
## As if in table |
|
| 4678 |
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
| 4679 |
$in_body->($insert_to_foster); |
$in_body->($insert_to_foster); |
| 4680 |
redo B; |
redo B; |
| 4681 |
} elsif ($self->{insertion_mode} eq 'in cell') { |
} elsif ($self->{insertion_mode} eq 'in column group') { |
| 4682 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 4683 |
## NOTE: This is a code clone of "character in body". |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4684 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 4685 |
|
unless (length $token->{data}) { |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ({ |
|
|
caption => 1, col => 1, colgroup => 1, |
|
|
tbody => 1, td => 1, tfoot => 1, th => 1, |
|
|
thead => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## have an element in table scope |
|
|
my $tn; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
|
|
$tn = $node->[1]; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $tn) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
| 4686 |
!!!next-token; |
!!!next-token; |
| 4687 |
redo B; |
redo B; |
| 4688 |
} |
} |
| 4689 |
|
} |
| 4690 |
## Close the cell |
|
| 4691 |
!!!back-token; # <?> |
# |
| 4692 |
$token = {type => 'end tag', tag_name => $tn}; |
} elsif ($token->{type} eq 'start tag') { |
| 4693 |
|
if ($token->{tag_name} eq 'col') { |
| 4694 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4695 |
|
pop @{$self->{open_elements}}; |
| 4696 |
|
!!!next-token; |
| 4697 |
redo B; |
redo B; |
| 4698 |
} else { |
} else { |
| 4699 |
# |
# |
| 4700 |
} |
} |
| 4701 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 4702 |
if ($token->{tag_name} eq 'td' or $token->{tag_name} eq 'th') { |
if ($token->{tag_name} eq 'colgroup') { |
| 4703 |
## have an element in table scope |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
| 4704 |
my $i; |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq $token->{tag_name}) { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
| 4705 |
## Ignore the token |
## Ignore the token |
| 4706 |
!!!next-token; |
!!!next-token; |
| 4707 |
redo B; |
redo B; |
| 4708 |
|
} else { |
| 4709 |
|
pop @{$self->{open_elements}}; # colgroup |
| 4710 |
|
$self->{insertion_mode} = 'in table'; |
| 4711 |
|
!!!next-token; |
| 4712 |
|
redo B; |
| 4713 |
} |
} |
| 4714 |
|
} elsif ($token->{tag_name} eq 'col') { |
| 4715 |
## generate implied end tags |
!!!parse-error (type => 'unmatched end tag:col'); |
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => ($token->{tag_name} eq 'th'), |
|
|
th => ($token->{tag_name} eq 'td'), |
|
|
tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!back-token; |
|
|
$token = {type => 'end tag', |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} |
|
|
|
|
|
splice @{$self->{open_elements}}, $i; |
|
|
|
|
|
$clear_up_to_marker->(); |
|
|
|
|
|
$self->{insertion_mode} = 'in row'; |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
body => 1, caption => 1, col => 1, |
|
|
colgroup => 1, html => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
| 4716 |
## Ignore the token |
## Ignore the token |
| 4717 |
!!!next-token; |
!!!next-token; |
| 4718 |
redo B; |
redo B; |
|
} elsif ({ |
|
|
table => 1, tbody => 1, tfoot => 1, |
|
|
thead => 1, tr => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## have an element in table scope |
|
|
my $i; |
|
|
my $tn; |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq $token->{tag_name}) { |
|
|
$i = $_; |
|
|
last INSCOPE; |
|
|
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
|
|
$tn = $node->[1]; |
|
|
## NOTE: There is exactly one |td| or |th| element |
|
|
## in scope in the stack of open elements by definition. |
|
|
} elsif ({ |
|
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
unless (defined $i) { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
## Close the cell |
|
|
!!!back-token; # </?> |
|
|
$token = {type => 'end tag', tag_name => $tn}; |
|
|
redo B; |
|
| 4719 |
} else { |
} else { |
| 4720 |
# |
# |
| 4721 |
} |
} |
| 4722 |
} else { |
} else { |
| 4723 |
# |
# |
| 4724 |
} |
} |
| 4725 |
|
|
| 4726 |
$in_body->($insert_to_current); |
## As if </colgroup> |
| 4727 |
redo B; |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
| 4728 |
} elsif ($self->{insertion_mode} eq 'in select') { |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
| 4729 |
|
## Ignore the token |
| 4730 |
|
!!!next-token; |
| 4731 |
|
redo B; |
| 4732 |
|
} else { |
| 4733 |
|
pop @{$self->{open_elements}}; # colgroup |
| 4734 |
|
$self->{insertion_mode} = 'in table'; |
| 4735 |
|
## reprocess |
| 4736 |
|
redo B; |
| 4737 |
|
} |
| 4738 |
|
} elsif ($self->{insertion_mode} eq 'in select') { |
| 4739 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 4740 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 4741 |
!!!next-token; |
!!!next-token; |
| 4909 |
## Ignore the token |
## Ignore the token |
| 4910 |
!!!next-token; |
!!!next-token; |
| 4911 |
redo B; |
redo B; |
| 4912 |
} elsif ($self->{insertion_mode} eq 'after body') { |
} elsif ($self->{insertion_mode} eq 'after body' or |
| 4913 |
if ($token->{type} eq 'character') { |
$self->{insertion_mode} eq 'after html body') { |
| 4914 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{type} eq 'character') { |
| 4915 |
my $data = $1; |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4916 |
## As if in body |
my $data = $1; |
| 4917 |
$reconstruct_active_formatting_elements->($insert_to_current); |
## As if in body |
| 4918 |
|
$reconstruct_active_formatting_elements->($insert_to_current); |
| 4919 |
|
|
| 4920 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 4921 |
|
|
| 4922 |
|
unless (length $token->{data}) { |
| 4923 |
|
!!!next-token; |
| 4924 |
|
redo B; |
| 4925 |
|
} |
| 4926 |
|
} |
| 4927 |
|
|
| 4928 |
|
if ($self->{insertion_mode} eq 'after html body') { |
| 4929 |
|
!!!parse-error (type => 'after html:#character'); |
| 4930 |
|
|
| 4931 |
unless (length $token->{data}) { |
## Reprocess in the "main" phase, "after body" insertion mode... |
| 4932 |
!!!next-token; |
} |
| 4933 |
redo B; |
|
| 4934 |
} |
## "after body" insertion mode |
| 4935 |
} |
!!!parse-error (type => 'after body:#character'); |
| 4936 |
|
|
| 4937 |
# |
$self->{insertion_mode} = 'in body'; |
| 4938 |
!!!parse-error (type => 'after body:#character'); |
## reprocess |
| 4939 |
} elsif ($token->{type} eq 'start tag') { |
redo B; |
| 4940 |
!!!parse-error (type => 'after body:'.$token->{tag_name}); |
} elsif ($token->{type} eq 'start tag') { |
| 4941 |
# |
if ($self->{insertion_mode} eq 'after html body') { |
| 4942 |
} elsif ($token->{type} eq 'end tag') { |
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
| 4943 |
if ($token->{tag_name} eq 'html') { |
|
| 4944 |
if (defined $self->{inner_html_node}) { |
## Reprocess in the "main" phase, "after body" insertion mode... |
| 4945 |
!!!parse-error (type => 'unmatched end tag:html'); |
} |
| 4946 |
## Ignore the token |
|
| 4947 |
!!!next-token; |
## "after body" insertion mode |
| 4948 |
redo B; |
!!!parse-error (type => 'after body:'.$token->{tag_name}); |
| 4949 |
} else { |
|
| 4950 |
$previous_insertion_mode = $self->{insertion_mode}; |
$self->{insertion_mode} = 'in body'; |
| 4951 |
$self->{insertion_mode} = 'trailing end'; |
## reprocess |
| 4952 |
!!!next-token; |
redo B; |
| 4953 |
redo B; |
} elsif ($token->{type} eq 'end tag') { |
| 4954 |
} |
if ($self->{insertion_mode} eq 'after html body') { |
| 4955 |
} else { |
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
| 4956 |
!!!parse-error (type => 'after body:/'.$token->{tag_name}); |
|
| 4957 |
} |
$self->{insertion_mode} = 'after body'; |
| 4958 |
|
## Reprocess in the "main" phase, "after body" insertion mode... |
| 4959 |
|
} |
| 4960 |
|
|
| 4961 |
|
## "after body" insertion mode |
| 4962 |
|
if ($token->{tag_name} eq 'html') { |
| 4963 |
|
if (defined $self->{inner_html_node}) { |
| 4964 |
|
!!!parse-error (type => 'unmatched end tag:html'); |
| 4965 |
|
## Ignore the token |
| 4966 |
|
!!!next-token; |
| 4967 |
|
redo B; |
| 4968 |
} else { |
} else { |
| 4969 |
die "$0: $token->{type}: Unknown token type"; |
$self->{insertion_mode} = 'after html body'; |
| 4970 |
|
!!!next-token; |
| 4971 |
|
redo B; |
| 4972 |
} |
} |
| 4973 |
|
} else { |
| 4974 |
|
!!!parse-error (type => 'after body:/'.$token->{tag_name}); |
| 4975 |
|
|
| 4976 |
$self->{insertion_mode} = 'in body'; |
$self->{insertion_mode} = 'in body'; |
| 4977 |
## reprocess |
## reprocess |
| 4978 |
redo B; |
redo B; |
| 4979 |
} elsif ($self->{insertion_mode} eq 'in frameset') { |
} |
| 4980 |
|
} else { |
| 4981 |
|
die "$0: $token->{type}: Unknown token type"; |
| 4982 |
|
} |
| 4983 |
|
} elsif ($self->{insertion_mode} eq 'in frameset' or |
| 4984 |
|
$self->{insertion_mode} eq 'after frameset' or |
| 4985 |
|
$self->{insertion_mode} eq 'after html frameset') { |
| 4986 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 4987 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4988 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 4989 |
|
|
| 4990 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 4991 |
!!!next-token; |
!!!next-token; |
| 4992 |
redo B; |
redo B; |
| 4993 |
} |
} |
| 4994 |
} |
} |
| 4995 |
|
|
| 4996 |
|
if ($token->{data} =~ s/^[^\x09\x0A\x0B\x0C\x20]+//) { |
| 4997 |
|
if ($self->{insertion_mode} eq 'in frameset') { |
| 4998 |
|
!!!parse-error (type => 'in frameset:#character'); |
| 4999 |
|
} elsif ($self->{insertion_mode} eq 'after frameset') { |
| 5000 |
|
!!!parse-error (type => 'after frameset:#character'); |
| 5001 |
|
} else { # "after html frameset" |
| 5002 |
|
!!!parse-error (type => 'after html:#character'); |
| 5003 |
|
|
| 5004 |
!!!parse-error (type => 'in frameset:#character'); |
$self->{insertion_mode} = 'after frameset'; |
| 5005 |
## Ignore the token |
## Reprocess in the "main" phase, "after frameset"... |
| 5006 |
!!!next-token; |
!!!parse-error (type => 'after frameset:#character'); |
| 5007 |
redo B; |
} |
| 5008 |
|
|
| 5009 |
|
## Ignore the token. |
| 5010 |
|
if (length $token->{data}) { |
| 5011 |
|
## reprocess the rest of characters |
| 5012 |
|
} else { |
| 5013 |
|
!!!next-token; |
| 5014 |
|
} |
| 5015 |
|
redo B; |
| 5016 |
|
} |
| 5017 |
|
|
| 5018 |
|
die qq[$0: Character "$token->{data}"]; |
| 5019 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 5020 |
if ($token->{tag_name} eq 'frameset') { |
if ($self->{insertion_mode} eq 'after html frameset') { |
| 5021 |
|
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
| 5022 |
|
|
| 5023 |
|
$self->{insertion_mode} = 'after frameset'; |
| 5024 |
|
## Process in the "main" phase, "after frameset" insertion mode... |
| 5025 |
|
} |
| 5026 |
|
|
| 5027 |
|
if ($token->{tag_name} eq 'frameset' and |
| 5028 |
|
$self->{insertion_mode} eq 'in frameset') { |
| 5029 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 5030 |
!!!next-token; |
!!!next-token; |
| 5031 |
redo B; |
redo B; |
| 5032 |
} elsif ($token->{tag_name} eq 'frame') { |
} elsif ($token->{tag_name} eq 'frame' and |
| 5033 |
|
$self->{insertion_mode} eq 'in frameset') { |
| 5034 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 5035 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5036 |
!!!next-token; |
!!!next-token; |
| 5037 |
redo B; |
redo B; |
| 5038 |
} elsif ($token->{tag_name} eq 'noframes') { |
} elsif ($token->{tag_name} eq 'noframes') { |
| 5039 |
$in_body->($insert_to_current); |
## NOTE: As if in body. |
| 5040 |
|
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current); |
| 5041 |
redo B; |
redo B; |
| 5042 |
} else { |
} else { |
| 5043 |
!!!parse-error (type => 'in frameset:'.$token->{tag_name}); |
if ($self->{insertion_mode} eq 'in frameset') { |
| 5044 |
|
!!!parse-error (type => 'in frameset:'.$token->{tag_name}); |
| 5045 |
|
} else { |
| 5046 |
|
!!!parse-error (type => 'after frameset:'.$token->{tag_name}); |
| 5047 |
|
} |
| 5048 |
## Ignore the token |
## Ignore the token |
| 5049 |
!!!next-token; |
!!!next-token; |
| 5050 |
redo B; |
redo B; |
| 5051 |
} |
} |
| 5052 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 5053 |
if ($token->{tag_name} eq 'frameset') { |
if ($self->{insertion_mode} eq 'after html frameset') { |
| 5054 |
|
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
| 5055 |
|
|
| 5056 |
|
$self->{insertion_mode} = 'after frameset'; |
| 5057 |
|
## Process in the "main" phase, "after frameset" insertion mode... |
| 5058 |
|
} |
| 5059 |
|
|
| 5060 |
|
if ($token->{tag_name} eq 'frameset' and |
| 5061 |
|
$self->{insertion_mode} eq 'in frameset') { |
| 5062 |
if ($self->{open_elements}->[-1]->[1] eq 'html' and |
if ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 5063 |
@{$self->{open_elements}} == 1) { |
@{$self->{open_elements}} == 1) { |
| 5064 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 5074 |
$self->{insertion_mode} = 'after frameset'; |
$self->{insertion_mode} = 'after frameset'; |
| 5075 |
} |
} |
| 5076 |
redo B; |
redo B; |
| 5077 |
} else { |
} elsif ($token->{tag_name} eq 'html' and |
| 5078 |
!!!parse-error (type => 'in frameset:/'.$token->{tag_name}); |
$self->{insertion_mode} eq 'after frameset') { |
| 5079 |
## Ignore the token |
$self->{insertion_mode} = 'after html frameset'; |
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
} else { |
|
|
die "$0: $token->{type}: Unknown token type"; |
|
|
} |
|
|
} elsif ($self->{insertion_mode} eq 'after frameset') { |
|
|
if ($token->{type} eq 'character') { |
|
|
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
|
|
|
|
|
unless (length $token->{data}) { |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
} |
|
|
|
|
|
if ($token->{data} =~ s/^[^\x09\x0A\x0B\x0C\x20]+//) { |
|
|
!!!parse-error (type => 'after frameset:#character'); |
|
|
|
|
|
## Ignore the token. |
|
|
if (length $token->{data}) { |
|
|
## reprocess the rest of characters |
|
|
} else { |
|
|
!!!next-token; |
|
|
} |
|
|
redo B; |
|
|
} |
|
|
|
|
|
die qq[$0: Character "$token->{data}"]; |
|
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ($token->{tag_name} eq 'noframes') { |
|
|
$in_body->($insert_to_current); |
|
|
redo B; |
|
|
} else { |
|
|
!!!parse-error (type => 'after frameset:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
} elsif ($token->{type} eq 'end tag') { |
|
|
if ($token->{tag_name} eq 'html') { |
|
|
$previous_insertion_mode = $self->{insertion_mode}; |
|
|
$self->{insertion_mode} = 'trailing end'; |
|
| 5080 |
!!!next-token; |
!!!next-token; |
| 5081 |
redo B; |
redo B; |
| 5082 |
} else { |
} else { |
| 5083 |
!!!parse-error (type => 'after frameset:/'.$token->{tag_name}); |
if ($self->{insertion_mode} eq 'in frameset') { |
| 5084 |
|
!!!parse-error (type => 'in frameset:/'.$token->{tag_name}); |
| 5085 |
|
} else { |
| 5086 |
|
!!!parse-error (type => 'after frameset:/'.$token->{tag_name}); |
| 5087 |
|
} |
| 5088 |
## Ignore the token |
## Ignore the token |
| 5089 |
!!!next-token; |
!!!next-token; |
| 5090 |
redo B; |
redo B; |
| 5094 |
} |
} |
| 5095 |
|
|
| 5096 |
## ISSUE: An issue in spec here |
## ISSUE: An issue in spec here |
|
} elsif ($self->{insertion_mode} eq 'trailing end') { |
|
|
## states in the main stage is preserved yet # MUST |
|
|
|
|
|
if ($token->{type} eq 'character') { |
|
|
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
|
|
my $data = $1; |
|
|
## As if in the main phase. |
|
|
## NOTE: The insertion mode in the main phase |
|
|
## just before the phase has been changed to the trailing |
|
|
## end phase is either "after body" or "after frameset". |
|
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
|
|
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($data); |
|
|
|
|
|
unless (length $token->{data}) { |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
|
} |
|
|
|
|
|
!!!parse-error (type => 'after html:#character'); |
|
|
$self->{insertion_mode} = $previous_insertion_mode; |
|
|
## reprocess |
|
|
redo B; |
|
|
} elsif ($token->{type} eq 'start tag') { |
|
|
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
|
|
$self->{insertion_mode} = $previous_insertion_mode; |
|
|
## reprocess |
|
|
redo B; |
|
|
} elsif ($token->{type} eq 'end tag') { |
|
|
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
|
|
$self->{insertion_mode} = $previous_insertion_mode; |
|
|
## reprocess |
|
|
redo B; |
|
|
} else { |
|
|
die "$0: $token->{type}: Unknown token"; |
|
|
} |
|
| 5097 |
} else { |
} else { |
| 5098 |
die "$0: $self->{insertion_mode}: Unknown insertion mode"; |
die "$0: $self->{insertion_mode}: Unknown insertion mode"; |
| 5099 |
} |
} |
| 5100 |
} # B |
} # B |
| 5101 |
|
|
| 5102 |
|
## NOTE: The "trailing end" phase in HTML5 is split into |
| 5103 |
|
## two insertion modes: "after html body" and "after html frameset". |
| 5104 |
|
## NOTE: States in the main stage is preserved while |
| 5105 |
|
## the parser stays in the trailing end phase. # MUST |
| 5106 |
|
|
| 5107 |
## Stop parsing # MUST |
## Stop parsing # MUST |
| 5108 |
|
|
| 5109 |
## TODO: script stuffs |
## TODO: script stuffs |