| 3433 |
$self->{insertion_mode} = 'in head'; |
$self->{insertion_mode} = 'in head'; |
| 3434 |
if ($token->{tag_name} eq 'head') { |
if ($token->{tag_name} eq 'head') { |
| 3435 |
!!!next-token; |
!!!next-token; |
|
#} elsif ({ |
|
|
# base => 1, link => 1, meta => 1, |
|
|
# script => 1, style => 1, title => 1, |
|
|
# }->{$token->{tag_name}}) { |
|
|
# ## reprocess |
|
| 3436 |
} else { |
} else { |
| 3437 |
## reprocess |
## reprocess |
| 3438 |
} |
} |
| 3470 |
} |
} |
| 3471 |
} |
} |
| 3472 |
|
|
| 3473 |
# |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3474 |
|
## As if </noscript> |
| 3475 |
|
pop @{$self->{open_elements}}; |
| 3476 |
|
!!!parse-error (type => 'in noscript:#character'); |
| 3477 |
|
|
| 3478 |
|
## Reprocess in the "in head" insertion mode... |
| 3479 |
|
## As if </head> |
| 3480 |
|
pop @{$self->{open_elements}}; |
| 3481 |
|
|
| 3482 |
|
## Reprocess in the "after head" insertion mode... |
| 3483 |
|
} elsif ($self->{insertion_mode} eq 'in head') { |
| 3484 |
|
pop @{$self->{open_elements}}; |
| 3485 |
|
|
| 3486 |
|
## Reprocess in the "after head" insertion mode... |
| 3487 |
|
} |
| 3488 |
|
|
| 3489 |
|
## 'after head' insertion mode |
| 3490 |
|
## As if <body> |
| 3491 |
|
!!!insert-element ('body'); |
| 3492 |
|
$self->{insertion_mode} = 'in body'; |
| 3493 |
|
## reprocess |
| 3494 |
|
redo B; |
| 3495 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 3496 |
if ({base => ($self->{insertion_mode} eq 'in head' or |
if ($token->{tag_name} eq 'base') { |
| 3497 |
$self->{insertion_mode} eq 'after head'), |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3498 |
link => 1}->{$token->{tag_name}}) { |
## As if </noscript> |
| 3499 |
|
pop @{$self->{open_elements}}; |
| 3500 |
|
!!!parse-error (type => 'in noscript:base'); |
| 3501 |
|
|
| 3502 |
|
$self->{insertion_mode} = 'in head'; |
| 3503 |
|
## Reprocess in the "in head" insertion mode... |
| 3504 |
|
} |
| 3505 |
|
|
| 3506 |
|
## NOTE: There is a "as if in head" code clone. |
| 3507 |
|
if ($self->{insertion_mode} eq 'after head') { |
| 3508 |
|
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3509 |
|
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3510 |
|
} |
| 3511 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 3512 |
|
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 3513 |
|
pop @{$self->{open_elements}} |
| 3514 |
|
if $self->{insertion_mode} eq 'after head'; |
| 3515 |
|
!!!next-token; |
| 3516 |
|
redo B; |
| 3517 |
|
} elsif ($token->{tag_name} eq 'link') { |
| 3518 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3519 |
if ($self->{insertion_mode} eq 'after head') { |
if ($self->{insertion_mode} eq 'after head') { |
| 3520 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3557 |
if $self->{insertion_mode} eq 'after head'; |
if $self->{insertion_mode} eq 'after head'; |
| 3558 |
!!!next-token; |
!!!next-token; |
| 3559 |
redo B; |
redo B; |
| 3560 |
} elsif ($token->{tag_name} eq 'title' and |
} elsif ($token->{tag_name} eq 'title') { |
| 3561 |
$self->{insertion_mode} eq 'in head') { |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3562 |
## NOTE: There is a "as if in head" code clone. |
## As if </noscript> |
| 3563 |
if ($self->{insertion_mode} eq 'after head') { |
pop @{$self->{open_elements}}; |
| 3564 |
|
!!!parse-error (type => 'in noscript:title'); |
| 3565 |
|
|
| 3566 |
|
$self->{insertion_mode} = 'in head'; |
| 3567 |
|
## Reprocess in the "in head" insertion mode... |
| 3568 |
|
} elsif ($self->{insertion_mode} eq 'after head') { |
| 3569 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3570 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3571 |
} |
} |
| 3572 |
|
|
| 3573 |
|
## NOTE: There is a "as if in head" code clone. |
| 3574 |
my $parent = defined $self->{head_element} ? $self->{head_element} |
my $parent = defined $self->{head_element} ? $self->{head_element} |
| 3575 |
: $self->{open_elements}->[-1]->[0]; |
: $self->{open_elements}->[-1]->[0]; |
| 3576 |
$parse_rcdata->(RCDATA_CONTENT_MODEL, |
$parse_rcdata->(RCDATA_CONTENT_MODEL, |
| 3605 |
} else { |
} else { |
| 3606 |
# |
# |
| 3607 |
} |
} |
| 3608 |
} elsif ($token->{tag_name} eq 'head' and |
} elsif ($token->{tag_name} eq 'head') { |
| 3609 |
$self->{insertion_mode} ne 'after head') { |
if ($self->{insertion_mode} ne 'after head') { |
| 3610 |
!!!parse-error (type => 'in head:head'); # or in head noscript |
!!!parse-error (type => 'in head:head'); # or in head noscript |
| 3611 |
## Ignore the token |
## Ignore the token |
| 3612 |
!!!next-token; |
!!!next-token; |
| 3613 |
redo B; |
redo B; |
| 3614 |
} elsif ($self->{insertion_mode} ne 'in head noscript' and |
} else { |
| 3615 |
$token->{tag_name} eq 'script') { |
# |
| 3616 |
if ($self->{insertion_mode} eq 'after head') { |
} |
| 3617 |
|
} elsif ($token->{tag_name} eq 'script') { |
| 3618 |
|
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3619 |
|
## As if </noscript> |
| 3620 |
|
pop @{$self->{open_elements}}; |
| 3621 |
|
!!!parse-error (type => 'in noscript:script'); |
| 3622 |
|
|
| 3623 |
|
$self->{insertion_mode} = 'in head'; |
| 3624 |
|
## Reprocess in the "in head" insertion mode... |
| 3625 |
|
} elsif ($self->{insertion_mode} eq 'after head') { |
| 3626 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3627 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3628 |
} |
} |
| 3629 |
|
|
| 3630 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3631 |
$script_start_tag->($insert_to_current); |
$script_start_tag->($insert_to_current); |
| 3632 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} |
| 3633 |
if $self->{insertion_mode} eq 'after head'; |
if $self->{insertion_mode} eq 'after head'; |
| 3634 |
redo B; |
redo B; |
| 3635 |
} 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 |
|
| 3636 |
$token->{tag_name} eq 'frameset') { |
$token->{tag_name} eq 'frameset') { |
| 3637 |
!!!insert-element ('frameset', $token->{attributes}); |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3638 |
$self->{insertion_mode} = 'in frameset'; |
## As if </noscript> |
| 3639 |
|
pop @{$self->{open_elements}}; |
| 3640 |
|
!!!parse-error (type => 'in noscript:'.$token->{tag_name}); |
| 3641 |
|
|
| 3642 |
|
## Reprocess in the "in head" insertion mode... |
| 3643 |
|
## As if </head> |
| 3644 |
|
pop @{$self->{open_elements}}; |
| 3645 |
|
|
| 3646 |
|
## Reprocess in the "after head" insertion mode... |
| 3647 |
|
} elsif ($self->{insertion_mode} eq 'in head') { |
| 3648 |
|
pop @{$self->{open_elements}}; |
| 3649 |
|
|
| 3650 |
|
## Reprocess in the "after head" insertion mode... |
| 3651 |
|
} |
| 3652 |
|
|
| 3653 |
|
## "after head" insertion mode |
| 3654 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 3655 |
|
$self->{insertion_mode} = 'in '.$token->{tag_name}; |
| 3656 |
!!!next-token; |
!!!next-token; |
| 3657 |
redo B; |
redo B; |
| 3658 |
} else { |
} else { |
| 3659 |
# |
# |
| 3660 |
} |
} |
| 3661 |
} elsif ($token->{type} eq 'end tag') { |
|
| 3662 |
if ($self->{insertion_mode} eq 'in head' and |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3663 |
$token->{tag_name} eq 'head') { |
## As if </noscript> |
| 3664 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3665 |
$self->{insertion_mode} = 'after head'; |
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}); |
| 3666 |
!!!next-token; |
|
| 3667 |
redo B; |
## Reprocess in the "in head" insertion mode... |
| 3668 |
} elsif ($self->{insertion_mode} eq 'in head noscript' and |
## As if </head> |
|
$token->{tag_name} eq 'noscript') { |
|
| 3669 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3670 |
$self->{insertion_mode} = 'in head'; |
|
| 3671 |
!!!next-token; |
## Reprocess in the "after head" insertion mode... |
| 3672 |
redo B; |
} elsif ($self->{insertion_mode} eq 'in head') { |
| 3673 |
} elsif ($self->{insertion_mode} eq 'in head' and |
## As if </head> |
| 3674 |
{ |
pop @{$self->{open_elements}}; |
| 3675 |
|
|
| 3676 |
|
## Reprocess in the "after head" insertion mode... |
| 3677 |
|
} |
| 3678 |
|
|
| 3679 |
|
## "after head" insertion mode |
| 3680 |
|
## As if <body> |
| 3681 |
|
!!!insert-element ('body'); |
| 3682 |
|
$self->{insertion_mode} = 'in body'; |
| 3683 |
|
## reprocess |
| 3684 |
|
redo B; |
| 3685 |
|
} elsif ($token->{type} eq 'end tag') { |
| 3686 |
|
if ($token->{tag_name} eq 'head') { |
| 3687 |
|
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3688 |
|
## As if </noscript> |
| 3689 |
|
pop @{$self->{open_elements}}; |
| 3690 |
|
!!!parse-error (type => 'in noscript:script'); |
| 3691 |
|
|
| 3692 |
|
$self->{insertion_mode} = 'in head'; |
| 3693 |
|
## Reprocess in the "in head" insertion mode... |
| 3694 |
|
} |
| 3695 |
|
|
| 3696 |
|
if ($self->{insertion_mode} eq 'in head') { |
| 3697 |
|
pop @{$self->{open_elements}}; |
| 3698 |
|
$self->{insertion_mode} = 'after head'; |
| 3699 |
|
!!!next-token; |
| 3700 |
|
redo B; |
| 3701 |
|
} else { |
| 3702 |
|
# |
| 3703 |
|
} |
| 3704 |
|
} elsif ($token->{tag_name} eq 'noscript') { |
| 3705 |
|
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3706 |
|
pop @{$self->{open_elements}}; |
| 3707 |
|
$self->{insertion_mode} = 'in head'; |
| 3708 |
|
!!!next-token; |
| 3709 |
|
redo B; |
| 3710 |
|
} else { |
| 3711 |
|
# |
| 3712 |
|
} |
| 3713 |
|
} elsif ({ |
| 3714 |
body => 1, html => 1, |
body => 1, html => 1, |
|
p => 1, br => 1, |
|
| 3715 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 3716 |
# |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3717 |
} elsif ($self->{insertion_mode} eq 'in head noscript' and |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3718 |
{ |
## Ignore the token |
| 3719 |
|
!!!next-token; |
| 3720 |
|
redo B; |
| 3721 |
|
} else { # 'in head', 'after head' |
| 3722 |
|
# |
| 3723 |
|
} |
| 3724 |
|
} elsif ({ |
| 3725 |
p => 1, br => 1, |
p => 1, br => 1, |
| 3726 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 3727 |
# |
# |
|
} elsif ($self->{insertion_mode} ne 'after head') { |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
| 3728 |
} else { |
} else { |
| 3729 |
# |
if ($self->{insertion_mode} ne 'after head') { |
| 3730 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3731 |
|
## Ignore the token |
| 3732 |
|
!!!next-token; |
| 3733 |
|
redo B; |
| 3734 |
|
} else { |
| 3735 |
|
# |
| 3736 |
|
} |
| 3737 |
} |
} |
|
} else { |
|
|
# |
|
|
} |
|
| 3738 |
|
|
| 3739 |
## As if </head> or </noscript> or <body> |
if ($self->{insertion_mode} eq 'in head noscript') { |
| 3740 |
if ($self->{insertion_mode} eq 'in head') { |
## As if </noscript> |
| 3741 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3742 |
$self->{insertion_mode} = 'after head'; |
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}); |
| 3743 |
} elsif ($self->{insertion_mode} eq 'in head noscript') { |
|
| 3744 |
pop @{$self->{open_elements}}; |
## Reprocess in the "in head" insertion mode... |
| 3745 |
!!!parse-error (type => 'in noscript:'.(defined $token->{tag_name} ? ($token->{type} eq 'end tag' ? '/' : '') . $token->{tag_name} : '#' . $token->{type})); |
## As if </head> |
| 3746 |
$self->{insertion_mode} = 'in head'; |
pop @{$self->{open_elements}}; |
| 3747 |
} else { # 'after head' |
|
| 3748 |
|
## Reprocess in the "after head" insertion mode... |
| 3749 |
|
} elsif ($self->{insertion_mode} eq 'in head') { |
| 3750 |
|
## As if </head> |
| 3751 |
|
pop @{$self->{open_elements}}; |
| 3752 |
|
|
| 3753 |
|
## Reprocess in the "after head" insertion mode... |
| 3754 |
|
} |
| 3755 |
|
|
| 3756 |
|
## "after head" insertion mode |
| 3757 |
|
## As if <body> |
| 3758 |
!!!insert-element ('body'); |
!!!insert-element ('body'); |
| 3759 |
$self->{insertion_mode} = 'in body'; |
$self->{insertion_mode} = 'in body'; |
| 3760 |
|
## reprocess |
| 3761 |
|
redo B; |
| 3762 |
|
} else { |
| 3763 |
|
die "$0: $token->{type}: Unknown token type"; |
| 3764 |
} |
} |
|
## reprocess |
|
|
redo B; |
|
| 3765 |
|
|
| 3766 |
## ISSUE: An issue in the spec. |
## ISSUE: An issue in the spec. |
| 3767 |
} elsif ($self->{insertion_mode} eq 'in body' or |
} elsif ($self->{insertion_mode} eq 'in body' or |