| 7 |
## doc.write (''); |
## doc.write (''); |
| 8 |
## alert (doc.compatMode); |
## alert (doc.compatMode); |
| 9 |
|
|
| 10 |
|
## ISSUE: HTML5 revision 967 says that the encoding layer MUST NOT |
| 11 |
|
## strip BOM and the HTML layer MUST ignore it. Whether we can do it |
| 12 |
|
## is not yet clear. |
| 13 |
|
## "{U+FEFF}..." in UTF-16BE/UTF-16LE is three or four characters? |
| 14 |
|
## "{U+FEFF}..." in GB18030? |
| 15 |
|
|
| 16 |
my $permitted_slash_tag_name = { |
my $permitted_slash_tag_name = { |
| 17 |
base => 1, |
base => 1, |
| 18 |
link => 1, |
link => 1, |
| 253 |
} elsif ($self->{state} eq 'entity data') { |
} elsif ($self->{state} eq 'entity data') { |
| 254 |
## (cannot happen in CDATA state) |
## (cannot happen in CDATA state) |
| 255 |
|
|
| 256 |
my $token = $self->_tokenize_attempt_to_consume_an_entity; |
my $token = $self->_tokenize_attempt_to_consume_an_entity (0); |
| 257 |
|
|
| 258 |
$self->{state} = 'data'; |
$self->{state} = 'data'; |
| 259 |
# next-input-character is already done |
# next-input-character is already done |
| 333 |
if ($self->{content_model_flag} eq 'RCDATA' or |
if ($self->{content_model_flag} eq 'RCDATA' or |
| 334 |
$self->{content_model_flag} eq 'CDATA') { |
$self->{content_model_flag} eq 'CDATA') { |
| 335 |
if (defined $self->{last_emitted_start_tag_name}) { |
if (defined $self->{last_emitted_start_tag_name}) { |
| 336 |
|
## NOTE: <http://krijnhoetmer.nl/irc-logs/whatwg/20070626#l-564> |
| 337 |
my @next_char; |
my @next_char; |
| 338 |
TAGNAME: for (my $i = 0; $i < length $self->{last_emitted_start_tag_name}; $i++) { |
TAGNAME: for (my $i = 0; $i < length $self->{last_emitted_start_tag_name}; $i++) { |
| 339 |
push @next_char, $self->{next_input_character}; |
push @next_char, $self->{next_input_character}; |
| 425 |
redo A; |
redo A; |
| 426 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 427 |
if ($self->{current_token}->{type} eq 'start tag') { |
if ($self->{current_token}->{type} eq 'start tag') { |
| 428 |
|
$self->{current_token}->{first_start_tag} |
| 429 |
|
= not defined $self->{last_emitted_start_tag_name}; |
| 430 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 431 |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
| 432 |
$self->{content_model_flag} = 'PCDATA'; # MUST |
$self->{content_model_flag} = 'PCDATA'; # MUST |
| 452 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 453 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 454 |
if ($self->{current_token}->{type} eq 'start tag') { |
if ($self->{current_token}->{type} eq 'start tag') { |
| 455 |
|
$self->{current_token}->{first_start_tag} |
| 456 |
|
= not defined $self->{last_emitted_start_tag_name}; |
| 457 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 458 |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
| 459 |
$self->{content_model_flag} = 'PCDATA'; # MUST |
$self->{content_model_flag} = 'PCDATA'; # MUST |
| 500 |
redo A; |
redo A; |
| 501 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 502 |
if ($self->{current_token}->{type} eq 'start tag') { |
if ($self->{current_token}->{type} eq 'start tag') { |
| 503 |
|
$self->{current_token}->{first_start_tag} |
| 504 |
|
= not defined $self->{last_emitted_start_tag_name}; |
| 505 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 506 |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
| 507 |
$self->{content_model_flag} = 'PCDATA'; # MUST |
$self->{content_model_flag} = 'PCDATA'; # MUST |
| 540 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 541 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 542 |
if ($self->{current_token}->{type} eq 'start tag') { |
if ($self->{current_token}->{type} eq 'start tag') { |
| 543 |
|
$self->{current_token}->{first_start_tag} |
| 544 |
|
= not defined $self->{last_emitted_start_tag_name}; |
| 545 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 546 |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
| 547 |
$self->{content_model_flag} = 'PCDATA'; # MUST |
$self->{content_model_flag} = 'PCDATA'; # MUST |
| 593 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 594 |
$before_leave->(); |
$before_leave->(); |
| 595 |
if ($self->{current_token}->{type} eq 'start tag') { |
if ($self->{current_token}->{type} eq 'start tag') { |
| 596 |
|
$self->{current_token}->{first_start_tag} |
| 597 |
|
= not defined $self->{last_emitted_start_tag_name}; |
| 598 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 599 |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
| 600 |
$self->{content_model_flag} = 'PCDATA'; # MUST |
$self->{content_model_flag} = 'PCDATA'; # MUST |
| 634 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 635 |
$before_leave->(); |
$before_leave->(); |
| 636 |
if ($self->{current_token}->{type} eq 'start tag') { |
if ($self->{current_token}->{type} eq 'start tag') { |
| 637 |
|
$self->{current_token}->{first_start_tag} |
| 638 |
|
= not defined $self->{last_emitted_start_tag_name}; |
| 639 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 640 |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
| 641 |
$self->{content_model_flag} = 'PCDATA'; # MUST |
$self->{content_model_flag} = 'PCDATA'; # MUST |
| 672 |
redo A; |
redo A; |
| 673 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 674 |
if ($self->{current_token}->{type} eq 'start tag') { |
if ($self->{current_token}->{type} eq 'start tag') { |
| 675 |
|
$self->{current_token}->{first_start_tag} |
| 676 |
|
= not defined $self->{last_emitted_start_tag_name}; |
| 677 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 678 |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
| 679 |
$self->{content_model_flag} = 'PCDATA'; # MUST |
$self->{content_model_flag} = 'PCDATA'; # MUST |
| 705 |
# |
# |
| 706 |
} else { |
} else { |
| 707 |
!!!parse-error (type => 'nestc'); |
!!!parse-error (type => 'nestc'); |
| 708 |
|
## TODO: Different error type for <aa / bb> than <aa/> |
| 709 |
} |
} |
| 710 |
$self->{state} = 'before attribute name'; |
$self->{state} = 'before attribute name'; |
| 711 |
# next-input-character is already done |
# next-input-character is already done |
| 713 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 714 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 715 |
if ($self->{current_token}->{type} eq 'start tag') { |
if ($self->{current_token}->{type} eq 'start tag') { |
| 716 |
|
$self->{current_token}->{first_start_tag} |
| 717 |
|
= not defined $self->{last_emitted_start_tag_name}; |
| 718 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 719 |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
| 720 |
$self->{content_model_flag} = 'PCDATA'; # MUST |
$self->{content_model_flag} = 'PCDATA'; # MUST |
| 760 |
redo A; |
redo A; |
| 761 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 762 |
if ($self->{current_token}->{type} eq 'start tag') { |
if ($self->{current_token}->{type} eq 'start tag') { |
| 763 |
|
$self->{current_token}->{first_start_tag} |
| 764 |
|
= not defined $self->{last_emitted_start_tag_name}; |
| 765 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 766 |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
| 767 |
$self->{content_model_flag} = 'PCDATA'; # MUST |
$self->{content_model_flag} = 'PCDATA'; # MUST |
| 780 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 781 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 782 |
if ($self->{current_token}->{type} eq 'start tag') { |
if ($self->{current_token}->{type} eq 'start tag') { |
| 783 |
|
$self->{current_token}->{first_start_tag} |
| 784 |
|
= not defined $self->{last_emitted_start_tag_name}; |
| 785 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 786 |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
| 787 |
$self->{content_model_flag} = 'PCDATA'; # MUST |
$self->{content_model_flag} = 'PCDATA'; # MUST |
| 816 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 817 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
| 818 |
if ($self->{current_token}->{type} eq 'start tag') { |
if ($self->{current_token}->{type} eq 'start tag') { |
| 819 |
|
$self->{current_token}->{first_start_tag} |
| 820 |
|
= not defined $self->{last_emitted_start_tag_name}; |
| 821 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 822 |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
| 823 |
$self->{content_model_flag} = 'PCDATA'; # MUST |
$self->{content_model_flag} = 'PCDATA'; # MUST |
| 852 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 853 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
| 854 |
if ($self->{current_token}->{type} eq 'start tag') { |
if ($self->{current_token}->{type} eq 'start tag') { |
| 855 |
|
$self->{current_token}->{first_start_tag} |
| 856 |
|
= not defined $self->{last_emitted_start_tag_name}; |
| 857 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 858 |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
| 859 |
$self->{content_model_flag} = 'PCDATA'; # MUST |
$self->{content_model_flag} = 'PCDATA'; # MUST |
| 891 |
redo A; |
redo A; |
| 892 |
} elsif ($self->{next_input_character} == 0x003E) { # > |
} elsif ($self->{next_input_character} == 0x003E) { # > |
| 893 |
if ($self->{current_token}->{type} eq 'start tag') { |
if ($self->{current_token}->{type} eq 'start tag') { |
| 894 |
|
$self->{current_token}->{first_start_tag} |
| 895 |
|
= not defined $self->{last_emitted_start_tag_name}; |
| 896 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 897 |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
| 898 |
$self->{content_model_flag} = 'PCDATA'; # MUST |
$self->{content_model_flag} = 'PCDATA'; # MUST |
| 911 |
} elsif ($self->{next_input_character} == -1) { |
} elsif ($self->{next_input_character} == -1) { |
| 912 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 913 |
if ($self->{current_token}->{type} eq 'start tag') { |
if ($self->{current_token}->{type} eq 'start tag') { |
| 914 |
|
$self->{current_token}->{first_start_tag} |
| 915 |
|
= not defined $self->{last_emitted_start_tag_name}; |
| 916 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 917 |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
} elsif ($self->{current_token}->{type} eq 'end tag') { |
| 918 |
$self->{content_model_flag} = 'PCDATA'; # MUST |
$self->{content_model_flag} = 'PCDATA'; # MUST |
| 935 |
redo A; |
redo A; |
| 936 |
} |
} |
| 937 |
} elsif ($self->{state} eq 'entity in attribute value') { |
} elsif ($self->{state} eq 'entity in attribute value') { |
| 938 |
my $token = $self->_tokenize_attempt_to_consume_an_entity; |
my $token = $self->_tokenize_attempt_to_consume_an_entity (1); |
| 939 |
|
|
| 940 |
unless (defined $token) { |
unless (defined $token) { |
| 941 |
$self->{current_attribute}->{value} .= '&'; |
$self->{current_attribute}->{value} .= '&'; |
| 1026 |
} |
} |
| 1027 |
} |
} |
| 1028 |
|
|
| 1029 |
!!!parse-error (type => 'bogus comment open'); |
!!!parse-error (type => 'bogus comment'); |
| 1030 |
$self->{next_input_character} = shift @next_char; |
$self->{next_input_character} = shift @next_char; |
| 1031 |
!!!back-next-input-character (@next_char); |
!!!back-next-input-character (@next_char); |
| 1032 |
$self->{state} = 'bogus comment'; |
$self->{state} = 'bogus comment'; |
| 1085 |
redo A; |
redo A; |
| 1086 |
} else { |
} else { |
| 1087 |
$self->{current_token}->{data} # comment |
$self->{current_token}->{data} # comment |
| 1088 |
.= chr ($self->{next_input_character}); |
.= '-' . chr ($self->{next_input_character}); |
| 1089 |
$self->{state} = 'comment'; |
$self->{state} = 'comment'; |
| 1090 |
!!!next-input-character; |
!!!next-input-character; |
| 1091 |
redo A; |
redo A; |
| 1445 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1446 |
|
|
| 1447 |
$self->{state} = 'data'; |
$self->{state} = 'data'; |
| 1448 |
## recomsume |
## reconsume |
| 1449 |
|
|
| 1450 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1451 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1488 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1489 |
|
|
| 1490 |
$self->{state} = 'data'; |
$self->{state} = 'data'; |
| 1491 |
## recomsume |
## reconsume |
| 1492 |
|
|
| 1493 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1494 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1495 |
|
|
| 1496 |
redo A; |
redo A; |
| 1497 |
} else { |
} else { |
| 1498 |
!!!parse-error (type => 'string after PUBLIC literal'); |
!!!parse-error (type => 'string after SYSTEM'); |
| 1499 |
$self->{state} = 'bogus DOCTYPE'; |
$self->{state} = 'bogus DOCTYPE'; |
| 1500 |
!!!next-input-character; |
!!!next-input-character; |
| 1501 |
redo A; |
redo A; |
| 1563 |
!!!parse-error (type => 'unclosed DOCTYPE'); |
!!!parse-error (type => 'unclosed DOCTYPE'); |
| 1564 |
|
|
| 1565 |
$self->{state} = 'data'; |
$self->{state} = 'data'; |
| 1566 |
## recomsume |
## reconsume |
| 1567 |
|
|
| 1568 |
delete $self->{current_token}->{correct}; |
delete $self->{current_token}->{correct}; |
| 1569 |
!!!emit ($self->{current_token}); # DOCTYPE |
!!!emit ($self->{current_token}); # DOCTYPE |
| 1606 |
die "$0: _get_next_token: unexpected case"; |
die "$0: _get_next_token: unexpected case"; |
| 1607 |
} # _get_next_token |
} # _get_next_token |
| 1608 |
|
|
| 1609 |
sub _tokenize_attempt_to_consume_an_entity ($) { |
sub _tokenize_attempt_to_consume_an_entity ($$) { |
| 1610 |
my $self = shift; |
my ($self, $in_attr) = @_; |
| 1611 |
|
|
| 1612 |
if ({ |
if ({ |
| 1613 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, # HT, LF, VT, FF, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, # HT, LF, VT, FF, |
| 1620 |
!!!next-input-character; |
!!!next-input-character; |
| 1621 |
if ($self->{next_input_character} == 0x0078 or # x |
if ($self->{next_input_character} == 0x0078 or # x |
| 1622 |
$self->{next_input_character} == 0x0058) { # X |
$self->{next_input_character} == 0x0058) { # X |
| 1623 |
my $num; |
my $code; |
| 1624 |
X: { |
X: { |
| 1625 |
my $x_char = $self->{next_input_character}; |
my $x_char = $self->{next_input_character}; |
| 1626 |
!!!next-input-character; |
!!!next-input-character; |
| 1627 |
if (0x0030 <= $self->{next_input_character} and |
if (0x0030 <= $self->{next_input_character} and |
| 1628 |
$self->{next_input_character} <= 0x0039) { # 0..9 |
$self->{next_input_character} <= 0x0039) { # 0..9 |
| 1629 |
$num ||= 0; |
$code ||= 0; |
| 1630 |
$num *= 0x10; |
$code *= 0x10; |
| 1631 |
$num += $self->{next_input_character} - 0x0030; |
$code += $self->{next_input_character} - 0x0030; |
| 1632 |
redo X; |
redo X; |
| 1633 |
} elsif (0x0061 <= $self->{next_input_character} and |
} elsif (0x0061 <= $self->{next_input_character} and |
| 1634 |
$self->{next_input_character} <= 0x0066) { # a..f |
$self->{next_input_character} <= 0x0066) { # a..f |
| 1635 |
## ISSUE: the spec says U+0078, which is apparently incorrect |
$code ||= 0; |
| 1636 |
$num ||= 0; |
$code *= 0x10; |
| 1637 |
$num *= 0x10; |
$code += $self->{next_input_character} - 0x0060 + 9; |
|
$num += $self->{next_input_character} - 0x0060 + 9; |
|
| 1638 |
redo X; |
redo X; |
| 1639 |
} elsif (0x0041 <= $self->{next_input_character} and |
} elsif (0x0041 <= $self->{next_input_character} and |
| 1640 |
$self->{next_input_character} <= 0x0046) { # A..F |
$self->{next_input_character} <= 0x0046) { # A..F |
| 1641 |
## ISSUE: the spec says U+0058, which is apparently incorrect |
$code ||= 0; |
| 1642 |
$num ||= 0; |
$code *= 0x10; |
| 1643 |
$num *= 0x10; |
$code += $self->{next_input_character} - 0x0040 + 9; |
|
$num += $self->{next_input_character} - 0x0040 + 9; |
|
| 1644 |
redo X; |
redo X; |
| 1645 |
} elsif (not defined $num) { # no hexadecimal digit |
} elsif (not defined $code) { # no hexadecimal digit |
| 1646 |
!!!parse-error (type => 'bare hcro'); |
!!!parse-error (type => 'bare hcro'); |
| 1647 |
$self->{next_input_character} = 0x0023; # # |
$self->{next_input_character} = 0x0023; # # |
| 1648 |
!!!back-next-input-character ($x_char); |
!!!back-next-input-character ($x_char); |
| 1653 |
!!!parse-error (type => 'no refc'); |
!!!parse-error (type => 'no refc'); |
| 1654 |
} |
} |
| 1655 |
|
|
| 1656 |
## TODO: check the definition for |a valid Unicode character|. |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
| 1657 |
## <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2006-December/thread.html#8189> |
!!!parse-error (type => sprintf 'invalid character reference:U+%04X', $code); |
| 1658 |
if ($num > 1114111 or $num == 0) { |
$code = 0xFFFD; |
| 1659 |
$num = 0xFFFD; # REPLACEMENT CHARACTER |
} elsif ($code > 0x10FFFF) { |
| 1660 |
## ISSUE: Why this is not an error? |
!!!parse-error (type => sprintf 'invalid character reference:U-%08X', $code); |
| 1661 |
} elsif (0x80 <= $num and $num <= 0x9F) { |
$code = 0xFFFD; |
| 1662 |
!!!parse-error (type => sprintf 'c1 entity:U+%04X', $num); |
} elsif ($code == 0x000D) { |
| 1663 |
$num = $c1_entity_char->{$num}; |
!!!parse-error (type => 'CR character reference'); |
| 1664 |
|
$code = 0x000A; |
| 1665 |
|
} elsif (0x80 <= $code and $code <= 0x9F) { |
| 1666 |
|
!!!parse-error (type => sprintf 'C1 character reference:U+%04X', $code); |
| 1667 |
|
$code = $c1_entity_char->{$code}; |
| 1668 |
} |
} |
| 1669 |
|
|
| 1670 |
return {type => 'character', data => chr $num}; |
return {type => 'character', data => chr $code}; |
| 1671 |
} # X |
} # X |
| 1672 |
} elsif (0x0030 <= $self->{next_input_character} and |
} elsif (0x0030 <= $self->{next_input_character} and |
| 1673 |
$self->{next_input_character} <= 0x0039) { # 0..9 |
$self->{next_input_character} <= 0x0039) { # 0..9 |
| 1688 |
!!!parse-error (type => 'no refc'); |
!!!parse-error (type => 'no refc'); |
| 1689 |
} |
} |
| 1690 |
|
|
| 1691 |
## TODO: check the definition for |a valid Unicode character|. |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
| 1692 |
if ($code > 1114111 or $code == 0) { |
!!!parse-error (type => sprintf 'invalid character reference:U+%04X', $code); |
| 1693 |
$code = 0xFFFD; # REPLACEMENT CHARACTER |
$code = 0xFFFD; |
| 1694 |
## ISSUE: Why this is not an error? |
} elsif ($code > 0x10FFFF) { |
| 1695 |
|
!!!parse-error (type => sprintf 'invalid character reference:U-%08X', $code); |
| 1696 |
|
$code = 0xFFFD; |
| 1697 |
|
} elsif ($code == 0x000D) { |
| 1698 |
|
!!!parse-error (type => 'CR character reference'); |
| 1699 |
|
$code = 0x000A; |
| 1700 |
} elsif (0x80 <= $code and $code <= 0x9F) { |
} elsif (0x80 <= $code and $code <= 0x9F) { |
| 1701 |
!!!parse-error (type => sprintf 'c1 entity:U+%04X', $code); |
!!!parse-error (type => sprintf 'C1 character reference:U+%04X', $code); |
| 1702 |
$code = $c1_entity_char->{$code}; |
$code = $c1_entity_char->{$code}; |
| 1703 |
} |
} |
| 1704 |
|
|
| 1732 |
$self->{next_input_character} == 0x003B)) { # ; |
$self->{next_input_character} == 0x003B)) { # ; |
| 1733 |
$entity_name .= chr $self->{next_input_character}; |
$entity_name .= chr $self->{next_input_character}; |
| 1734 |
if (defined $EntityChar->{$entity_name}) { |
if (defined $EntityChar->{$entity_name}) { |
|
$value = $EntityChar->{$entity_name}; |
|
| 1735 |
if ($self->{next_input_character} == 0x003B) { # ; |
if ($self->{next_input_character} == 0x003B) { # ; |
| 1736 |
|
$value = $EntityChar->{$entity_name}; |
| 1737 |
$match = 1; |
$match = 1; |
| 1738 |
!!!next-input-character; |
!!!next-input-character; |
| 1739 |
last; |
last; |
| 1740 |
} else { |
} elsif (not $in_attr) { |
| 1741 |
|
$value = $EntityChar->{$entity_name}; |
| 1742 |
$match = -1; |
$match = -1; |
| 1743 |
|
} else { |
| 1744 |
|
$value .= chr $self->{next_input_character}; |
| 1745 |
} |
} |
| 1746 |
} else { |
} else { |
| 1747 |
$value .= chr $self->{next_input_character}; |
$value .= chr $self->{next_input_character}; |
| 1752 |
if ($match > 0) { |
if ($match > 0) { |
| 1753 |
return {type => 'character', data => $value}; |
return {type => 'character', data => $value}; |
| 1754 |
} elsif ($match < 0) { |
} elsif ($match < 0) { |
| 1755 |
!!!parse-error (type => 'refc'); |
!!!parse-error (type => 'no refc'); |
| 1756 |
return {type => 'character', data => $value}; |
return {type => 'character', data => $value}; |
| 1757 |
} else { |
} else { |
| 1758 |
!!!parse-error (type => 'bare ero'); |
!!!parse-error (type => 'bare ero'); |
| 1759 |
## NOTE: No characters are consumed in the spec. |
## NOTE: No characters are consumed in the spec. |
| 1760 |
!!!back-token ({type => 'character', data => $value}); |
return {type => 'character', data => '&'.$value}; |
|
return undef; |
|
| 1761 |
} |
} |
| 1762 |
} else { |
} else { |
| 1763 |
## no characters are consumed |
## no characters are consumed |
| 1952 |
} elsif ($token->{type} eq 'character') { |
} elsif ($token->{type} eq 'character') { |
| 1953 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { # \x0D |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { # \x0D |
| 1954 |
## Ignore the token |
## Ignore the token |
| 1955 |
|
|
| 1956 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 1957 |
## Stay in the phase |
## Stay in the phase |
| 1958 |
!!!next-token; |
!!!next-token; |
| 1995 |
!!!next-token; |
!!!next-token; |
| 1996 |
redo B; |
redo B; |
| 1997 |
} elsif ($token->{type} eq 'character') { |
} elsif ($token->{type} eq 'character') { |
| 1998 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { # \x0D |
| 1999 |
$self->{document}->manakai_append_text ($1); |
## Ignore the token. |
| 2000 |
## ISSUE: DOM3 Core does not allow Document > Text |
|
| 2001 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 2002 |
## Stay in the phase |
## Stay in the phase |
| 2003 |
!!!next-token; |
!!!next-token; |
| 2037 |
|
|
| 2038 |
## Step 3 |
## Step 3 |
| 2039 |
S3: { |
S3: { |
| 2040 |
$last = 1 if $self->{open_elements}->[0]->[0] eq $node->[0]; |
## ISSUE: Oops! "If node is the first node in the stack of open |
| 2041 |
if (defined $self->{inner_html_node}) { |
## elements, then set last to true. If the context element of the |
| 2042 |
if ($self->{inner_html_node}->[1] eq 'td' or |
## HTML fragment parsing algorithm is neither a td element nor a |
| 2043 |
$self->{inner_html_node}->[1] eq 'th') { |
## th element, then set node to the context element. (fragment case)": |
| 2044 |
# |
## The second "if" is in the scope of the first "if"!? |
| 2045 |
} else { |
if ($self->{open_elements}->[0]->[0] eq $node->[0]) { |
| 2046 |
$node = $self->{inner_html_node}; |
$last = 1; |
| 2047 |
|
if (defined $self->{inner_html_node}) { |
| 2048 |
|
if ($self->{inner_html_node}->[1] eq 'td' or |
| 2049 |
|
$self->{inner_html_node}->[1] eq 'th') { |
| 2050 |
|
# |
| 2051 |
|
} else { |
| 2052 |
|
$node = $self->{inner_html_node}; |
| 2053 |
|
} |
| 2054 |
} |
} |
| 2055 |
} |
} |
| 2056 |
|
|
| 2181 |
} |
} |
| 2182 |
}; # $clear_up_to_marker |
}; # $clear_up_to_marker |
| 2183 |
|
|
| 2184 |
my $style_start_tag = sub { |
my $parse_rcdata = sub ($$) { |
| 2185 |
my $style_el; !!!create-element ($style_el, 'style', $token->{attributes}); |
my ($content_model_flag, $insert) = @_; |
| 2186 |
## $self->{insertion_mode} eq 'in head' and ... (always true) |
|
| 2187 |
(($self->{insertion_mode} eq 'in head' and defined $self->{head_element}) |
## Step 1 |
| 2188 |
? $self->{head_element} : $self->{open_elements}->[-1]->[0]) |
my $start_tag_name = $token->{tag_name}; |
| 2189 |
->append_child ($style_el); |
my $el; |
| 2190 |
$self->{content_model_flag} = 'CDATA'; |
!!!create-element ($el, $start_tag_name, $token->{attributes}); |
| 2191 |
|
|
| 2192 |
|
## Step 2 |
| 2193 |
|
$insert->($el); # /context node/->append_child ($el) |
| 2194 |
|
|
| 2195 |
|
## Step 3 |
| 2196 |
|
$self->{content_model_flag} = $content_model_flag; # CDATA or RCDATA |
| 2197 |
delete $self->{escape}; # MUST |
delete $self->{escape}; # MUST |
| 2198 |
|
|
| 2199 |
|
## Step 4 |
| 2200 |
my $text = ''; |
my $text = ''; |
| 2201 |
!!!next-token; |
!!!next-token; |
| 2202 |
while ($token->{type} eq 'character') { |
while ($token->{type} eq 'character') { # or until stop tokenizing |
| 2203 |
$text .= $token->{data}; |
$text .= $token->{data}; |
| 2204 |
!!!next-token; |
!!!next-token; |
| 2205 |
} # stop if non-character token or tokenizer stops tokenising |
} |
| 2206 |
|
|
| 2207 |
|
## Step 5 |
| 2208 |
if (length $text) { |
if (length $text) { |
| 2209 |
$style_el->manakai_append_text ($text); |
my $text = $self->{document}->create_text_node ($text); |
| 2210 |
|
$el->append_child ($text); |
| 2211 |
} |
} |
| 2212 |
|
|
| 2213 |
|
## Step 6 |
| 2214 |
$self->{content_model_flag} = 'PCDATA'; |
$self->{content_model_flag} = 'PCDATA'; |
| 2215 |
|
|
| 2216 |
if ($token->{type} eq 'end tag' and $token->{tag_name} eq 'style') { |
## Step 7 |
| 2217 |
|
if ($token->{type} eq 'end tag' and $token->{tag_name} eq $start_tag_name) { |
| 2218 |
## Ignore the token |
## Ignore the token |
| 2219 |
} else { |
} else { |
| 2220 |
!!!parse-error (type => 'in CDATA:#'.$token->{type}); |
!!!parse-error (type => 'in '.$content_model_flag.':#'.$token->{type}); |
|
## ISSUE: And ignore? |
|
| 2221 |
} |
} |
| 2222 |
!!!next-token; |
!!!next-token; |
| 2223 |
}; # $style_start_tag |
}; # $parse_rcdata |
| 2224 |
|
|
| 2225 |
my $script_start_tag = sub { |
my $script_start_tag = sub ($) { |
| 2226 |
|
my $insert = $_[0]; |
| 2227 |
my $script_el; |
my $script_el; |
| 2228 |
!!!create-element ($script_el, 'script', $token->{attributes}); |
!!!create-element ($script_el, 'script', $token->{attributes}); |
| 2229 |
## TODO: mark as "parser-inserted" |
## TODO: mark as "parser-inserted" |
| 2257 |
} else { |
} else { |
| 2258 |
## TODO: $old_insertion_point = current insertion point |
## TODO: $old_insertion_point = current insertion point |
| 2259 |
## TODO: insertion point = just before the next input character |
## TODO: insertion point = just before the next input character |
| 2260 |
|
|
| 2261 |
(($self->{insertion_mode} eq 'in head' and defined $self->{head_element}) |
$insert->($script_el); |
|
? $self->{head_element} : $self->{open_elements}->[-1]->[0])->append_child ($script_el); |
|
| 2262 |
|
|
| 2263 |
## TODO: insertion point = $old_insertion_point (might be "undefined") |
## TODO: insertion point = $old_insertion_point (might be "undefined") |
| 2264 |
|
|
| 2452 |
}; # $formatting_end_tag |
}; # $formatting_end_tag |
| 2453 |
|
|
| 2454 |
my $insert_to_current = sub { |
my $insert_to_current = sub { |
| 2455 |
$self->{open_elements}->[-1]->[0]->append_child (shift); |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
| 2456 |
}; # $insert_to_current |
}; # $insert_to_current |
| 2457 |
|
|
| 2458 |
my $insert_to_foster = sub { |
my $insert_to_foster = sub { |
| 2490 |
my $insert = shift; |
my $insert = shift; |
| 2491 |
if ($token->{type} eq 'start tag') { |
if ($token->{type} eq 'start tag') { |
| 2492 |
if ($token->{tag_name} eq 'script') { |
if ($token->{tag_name} eq 'script') { |
| 2493 |
$script_start_tag->(); |
## NOTE: This is an "as if in head" code clone |
| 2494 |
|
$script_start_tag->($insert); |
| 2495 |
return; |
return; |
| 2496 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 2497 |
$style_start_tag->(); |
## NOTE: This is an "as if in head" code clone |
| 2498 |
|
$parse_rcdata->('CDATA', $insert); |
| 2499 |
return; |
return; |
| 2500 |
} elsif ({ |
} elsif ({ |
| 2501 |
base => 1, link => 1, meta => 1, |
base => 1, link => 1, meta => 1, |
| 2502 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 2503 |
!!!parse-error (type => 'in body:'.$token->{tag_name}); |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
| 2504 |
## NOTE: This is an "as if in head" code clone |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 2505 |
my $el; |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
|
!!!create-element ($el, $token->{tag_name}, $token->{attributes}); |
|
|
if (defined $self->{head_element}) { |
|
|
$self->{head_element}->append_child ($el); |
|
|
} else { |
|
|
$insert->($el); |
|
|
} |
|
|
|
|
| 2506 |
!!!next-token; |
!!!next-token; |
| 2507 |
|
## TODO: Extracting |charset| from |meta|. |
| 2508 |
return; |
return; |
| 2509 |
} elsif ($token->{tag_name} eq 'title') { |
} elsif ($token->{tag_name} eq 'title') { |
| 2510 |
!!!parse-error (type => 'in body:title'); |
!!!parse-error (type => 'in body:title'); |
| 2511 |
## NOTE: There is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 2512 |
my $title_el; |
$parse_rcdata->('RCDATA', sub { |
| 2513 |
!!!create-element ($title_el, 'title', $token->{attributes}); |
if (defined $self->{head_element}) { |
| 2514 |
(defined $self->{head_element} ? $self->{head_element} : $self->{open_elements}->[-1]->[0]) |
$self->{head_element}->append_child ($_[0]); |
| 2515 |
->append_child ($title_el); |
} else { |
| 2516 |
$self->{content_model_flag} = 'RCDATA'; |
$insert->($_[0]); |
| 2517 |
delete $self->{escape}; # MUST |
} |
| 2518 |
|
}); |
|
my $text = ''; |
|
|
!!!next-token; |
|
|
while ($token->{type} eq 'character') { |
|
|
$text .= $token->{data}; |
|
|
!!!next-token; |
|
|
} |
|
|
if (length $text) { |
|
|
$title_el->manakai_append_text ($text); |
|
|
} |
|
|
|
|
|
$self->{content_model_flag} = 'PCDATA'; |
|
|
|
|
|
if ($token->{type} eq 'end tag' and |
|
|
$token->{tag_name} eq 'title') { |
|
|
## Ignore the token |
|
|
} else { |
|
|
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
|
|
## ISSUE: And ignore? |
|
|
} |
|
|
!!!next-token; |
|
| 2519 |
return; |
return; |
| 2520 |
} elsif ($token->{tag_name} eq 'body') { |
} elsif ($token->{tag_name} eq 'body') { |
| 2521 |
!!!parse-error (type => 'in body:body'); |
!!!parse-error (type => 'in body:body'); |
| 2618 |
if ($i != -1) { |
if ($i != -1) { |
| 2619 |
!!!parse-error (type => 'end tag missing:'. |
!!!parse-error (type => 'end tag missing:'. |
| 2620 |
$self->{open_elements}->[-1]->[1]); |
$self->{open_elements}->[-1]->[1]); |
|
## TODO: test |
|
| 2621 |
} |
} |
| 2622 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 2623 |
last LI; |
last LI; |
| 2665 |
if ($i != -1) { |
if ($i != -1) { |
| 2666 |
!!!parse-error (type => 'end tag missing:'. |
!!!parse-error (type => 'end tag missing:'. |
| 2667 |
$self->{open_elements}->[-1]->[1]); |
$self->{open_elements}->[-1]->[1]); |
|
## TODO: test |
|
| 2668 |
} |
} |
| 2669 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 2670 |
last LI; |
last LI; |
| 2808 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 2809 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 2810 |
if ($node->[1] eq 'nobr') { |
if ($node->[1] eq 'nobr') { |
| 2811 |
|
!!!parse-error (type => 'not closed:nobr'); |
| 2812 |
!!!back-token; |
!!!back-token; |
| 2813 |
$token = {type => 'end tag', tag_name => 'nobr'}; |
$token = {type => 'end tag', tag_name => 'nobr'}; |
| 2814 |
return; |
return; |
| 2860 |
return; |
return; |
| 2861 |
} elsif ($token->{tag_name} eq 'xmp') { |
} elsif ($token->{tag_name} eq 'xmp') { |
| 2862 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 2863 |
|
$parse_rcdata->('CDATA', $insert); |
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
|
|
|
$self->{content_model_flag} = 'CDATA'; |
|
|
delete $self->{escape}; # MUST |
|
|
|
|
|
!!!next-token; |
|
| 2864 |
return; |
return; |
| 2865 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 2866 |
## has a p element in scope |
## has a p element in scope |
| 2892 |
!!!parse-error (type => 'image'); |
!!!parse-error (type => 'image'); |
| 2893 |
$token->{tag_name} = 'img'; |
$token->{tag_name} = 'img'; |
| 2894 |
} |
} |
| 2895 |
|
|
| 2896 |
|
## NOTE: There is an "as if <br>" code clone. |
| 2897 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 2898 |
|
|
| 2899 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 2970 |
!!!back-token (@tokens); |
!!!back-token (@tokens); |
| 2971 |
return; |
return; |
| 2972 |
} |
} |
| 2973 |
} elsif ({ |
} elsif ($token->{tag_name} eq 'textarea') { |
|
textarea => 1, |
|
|
iframe => 1, |
|
|
noembed => 1, |
|
|
noframes => 1, |
|
|
noscript => 0, ## TODO: 1 if scripting is enabled |
|
|
}->{$token->{tag_name}}) { |
|
| 2974 |
my $tag_name = $token->{tag_name}; |
my $tag_name = $token->{tag_name}; |
| 2975 |
my $el; |
my $el; |
| 2976 |
!!!create-element ($el, $token->{tag_name}, $token->{attributes}); |
!!!create-element ($el, $token->{tag_name}, $token->{attributes}); |
| 2977 |
|
|
| 2978 |
if ($token->{tag_name} eq 'textarea') { |
## TODO: $self->{form_element} if defined |
| 2979 |
## TODO: $self->{form_element} if defined |
$self->{content_model_flag} = 'RCDATA'; |
|
$self->{content_model_flag} = 'RCDATA'; |
|
|
} else { |
|
|
$self->{content_model_flag} = 'CDATA'; |
|
|
} |
|
| 2980 |
delete $self->{escape}; # MUST |
delete $self->{escape}; # MUST |
| 2981 |
|
|
| 2982 |
$insert->($el); |
$insert->($el); |
| 2983 |
|
|
| 2984 |
my $text = ''; |
my $text = ''; |
| 2985 |
if ($token->{tag_name} eq 'textarea') { |
!!!next-token; |
| 2986 |
!!!next-token; |
if ($token->{type} eq 'character') { |
| 2987 |
if ($token->{type} eq 'character') { |
$token->{data} =~ s/^\x0A//; |
| 2988 |
$token->{data} =~ s/^\x0A//; |
unless (length $token->{data}) { |
| 2989 |
unless (length $token->{data}) { |
!!!next-token; |
|
!!!next-token; |
|
|
} |
|
| 2990 |
} |
} |
|
} else { |
|
|
!!!next-token; |
|
| 2991 |
} |
} |
| 2992 |
while ($token->{type} eq 'character') { |
while ($token->{type} eq 'character') { |
| 2993 |
$text .= $token->{data}; |
$text .= $token->{data}; |
| 3003 |
$token->{tag_name} eq $tag_name) { |
$token->{tag_name} eq $tag_name) { |
| 3004 |
## Ignore the token |
## Ignore the token |
| 3005 |
} else { |
} else { |
| 3006 |
if ($token->{tag_name} eq 'textarea') { |
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
|
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
|
|
} else { |
|
|
!!!parse-error (type => 'in CDATA:#'.$token->{type}); |
|
|
} |
|
|
## ISSUE: And ignore? |
|
| 3007 |
} |
} |
| 3008 |
!!!next-token; |
!!!next-token; |
| 3009 |
return; |
return; |
| 3010 |
|
} elsif ({ |
| 3011 |
|
iframe => 1, |
| 3012 |
|
noembed => 1, |
| 3013 |
|
noframes => 1, |
| 3014 |
|
noscript => 0, ## TODO: 1 if scripting is enabled |
| 3015 |
|
}->{$token->{tag_name}}) { |
| 3016 |
|
$parse_rcdata->('CDATA', $insert); |
| 3017 |
|
return; |
| 3018 |
} elsif ($token->{tag_name} eq 'select') { |
} elsif ($token->{tag_name} eq 'select') { |
| 3019 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 3020 |
|
|
| 3051 |
unless ({ |
unless ({ |
| 3052 |
dd => 1, dt => 1, li => 1, p => 1, td => 1, |
dd => 1, dt => 1, li => 1, p => 1, td => 1, |
| 3053 |
th => 1, tr => 1, body => 1, html => 1, |
th => 1, tr => 1, body => 1, html => 1, |
| 3054 |
|
tbody => 1, tfoot => 1, thead => 1, |
| 3055 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 3056 |
!!!parse-error (type => 'not closed:'.$_->[1]); |
!!!parse-error (type => 'not closed:'.$_->[1]); |
| 3057 |
} |
} |
| 3101 |
li => ($token->{tag_name} ne 'li'), |
li => ($token->{tag_name} ne 'li'), |
| 3102 |
p => ($token->{tag_name} ne 'p'), |
p => ($token->{tag_name} ne 'p'), |
| 3103 |
td => 1, th => 1, tr => 1, |
td => 1, th => 1, tr => 1, |
| 3104 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3105 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3106 |
!!!back-token; |
!!!back-token; |
| 3107 |
$token = {type => 'end tag', |
$token = {type => 'end tag', |
| 3119 |
} # INSCOPE |
} # INSCOPE |
| 3120 |
|
|
| 3121 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 3122 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
if (defined $i) { |
| 3123 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 3124 |
|
} else { |
| 3125 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3126 |
|
} |
| 3127 |
} |
} |
| 3128 |
|
|
| 3129 |
splice @{$self->{open_elements}}, $i if defined $i; |
if (defined $i) { |
| 3130 |
|
splice @{$self->{open_elements}}, $i; |
| 3131 |
|
} elsif ($token->{tag_name} eq 'p') { |
| 3132 |
|
## As if <p>, then reprocess the current token |
| 3133 |
|
my $el; |
| 3134 |
|
!!!create-element ($el, 'p'); |
| 3135 |
|
$insert->($el); |
| 3136 |
|
} |
| 3137 |
$clear_up_to_marker->() |
$clear_up_to_marker->() |
| 3138 |
if { |
if { |
| 3139 |
button => 1, marquee => 1, object => 1, |
button => 1, marquee => 1, object => 1, |
| 3149 |
if ({ |
if ({ |
| 3150 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 3151 |
td => 1, th => 1, tr => 1, |
td => 1, th => 1, tr => 1, |
| 3152 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3153 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3154 |
!!!back-token; |
!!!back-token; |
| 3155 |
$token = {type => 'end tag', |
$token = {type => 'end tag', |
| 3188 |
if ({ |
if ({ |
| 3189 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 3190 |
td => 1, th => 1, tr => 1, |
td => 1, th => 1, tr => 1, |
| 3191 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3192 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3193 |
!!!back-token; |
!!!back-token; |
| 3194 |
$token = {type => 'end tag', |
$token = {type => 'end tag', |
| 3219 |
strong => 1, tt => 1, u => 1, |
strong => 1, tt => 1, u => 1, |
| 3220 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 3221 |
$formatting_end_tag->($token->{tag_name}); |
$formatting_end_tag->($token->{tag_name}); |
| 3222 |
## TODO: <http://html5.org/tools/web-apps-tracker?from=883&to=884> |
return; |
| 3223 |
|
} elsif ($token->{tag_name} eq 'br') { |
| 3224 |
|
!!!parse-error (type => 'unmatched end tag:br'); |
| 3225 |
|
|
| 3226 |
|
## As if <br> |
| 3227 |
|
$reconstruct_active_formatting_elements->($insert_to_current); |
| 3228 |
|
|
| 3229 |
|
my $el; |
| 3230 |
|
!!!create-element ($el, 'br'); |
| 3231 |
|
$insert->($el); |
| 3232 |
|
|
| 3233 |
|
## Ignore the token. |
| 3234 |
|
!!!next-token; |
| 3235 |
return; |
return; |
| 3236 |
} elsif ({ |
} elsif ({ |
| 3237 |
caption => 1, col => 1, colgroup => 1, frame => 1, |
caption => 1, col => 1, colgroup => 1, frame => 1, |
| 3238 |
frameset => 1, head => 1, option => 1, optgroup => 1, |
frameset => 1, head => 1, option => 1, optgroup => 1, |
| 3239 |
tbody => 1, td => 1, tfoot => 1, th => 1, |
tbody => 1, td => 1, tfoot => 1, th => 1, |
| 3240 |
thead => 1, tr => 1, |
thead => 1, tr => 1, |
| 3241 |
area => 1, basefont => 1, bgsound => 1, br => 1, |
area => 1, basefont => 1, bgsound => 1, |
| 3242 |
embed => 1, hr => 1, iframe => 1, image => 1, |
embed => 1, hr => 1, iframe => 1, image => 1, |
| 3243 |
img => 1, input => 1, isindex => 1, noembed => 1, |
img => 1, input => 1, isindex => 1, noembed => 1, |
| 3244 |
noframes => 1, param => 1, select => 1, spacer => 1, |
noframes => 1, param => 1, select => 1, spacer => 1, |
| 3265 |
if ({ |
if ({ |
| 3266 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 3267 |
td => 1, th => 1, tr => 1, |
td => 1, th => 1, tr => 1, |
| 3268 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3269 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3270 |
!!!back-token; |
!!!back-token; |
| 3271 |
$token = {type => 'end tag', |
$token = {type => 'end tag', |
| 3289 |
#not $phrasing_category->{$node->[1]} and |
#not $phrasing_category->{$node->[1]} and |
| 3290 |
($special_category->{$node->[1]} or |
($special_category->{$node->[1]} or |
| 3291 |
$scoping_category->{$node->[1]})) { |
$scoping_category->{$node->[1]})) { |
| 3292 |
!!!parse-error (type => 'not closed:'.$node->[1]); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3293 |
## Ignore the token |
## Ignore the token |
| 3294 |
!!!next-token; |
!!!next-token; |
| 3295 |
last S2; |
last S2; |
| 3318 |
redo B; |
redo B; |
| 3319 |
} elsif ($token->{type} eq 'start tag' and |
} elsif ($token->{type} eq 'start tag' and |
| 3320 |
$token->{tag_name} eq 'html') { |
$token->{tag_name} eq 'html') { |
| 3321 |
## TODO: unless it is the first start tag token, parse-error |
## ISSUE: "aa<html>" is not a parse error. |
| 3322 |
|
## ISSUE: "<html>" in fragment is not a parse error. |
| 3323 |
|
unless ($token->{first_start_tag}) { |
| 3324 |
|
!!!parse-error (type => 'not first start tag'); |
| 3325 |
|
} |
| 3326 |
my $top_el = $self->{open_elements}->[0]->[0]; |
my $top_el = $self->{open_elements}->[0]->[0]; |
| 3327 |
for my $attr_name (keys %{$token->{attributes}}) { |
for my $attr_name (keys %{$token->{attributes}}) { |
| 3328 |
unless ($top_el->has_attribute_ns (undef, $attr_name)) { |
unless ($top_el->has_attribute_ns (undef, $attr_name)) { |
| 3337 |
## Generate implied end tags |
## Generate implied end tags |
| 3338 |
if ({ |
if ({ |
| 3339 |
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, |
| 3340 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3341 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3342 |
!!!back-token; |
!!!back-token; |
| 3343 |
$token = {type => 'end tag', tag_name => $self->{open_elements}->[-1]->[1]}; |
$token = {type => 'end tag', tag_name => $self->{open_elements}->[-1]->[1]}; |
| 3397 |
} |
} |
| 3398 |
redo B; |
redo B; |
| 3399 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 3400 |
if ({head => 1, body => 1, html => 1}->{$token->{tag_name}}) { |
if ({ |
| 3401 |
|
head => 1, body => 1, html => 1, |
| 3402 |
|
p => 1, br => 1, |
| 3403 |
|
}->{$token->{tag_name}}) { |
| 3404 |
## As if <head> |
## As if <head> |
| 3405 |
!!!create-element ($self->{head_element}, 'head'); |
!!!create-element ($self->{head_element}, 'head'); |
| 3406 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3417 |
} else { |
} else { |
| 3418 |
die "$0: $token->{type}: Unknown type"; |
die "$0: $token->{type}: Unknown type"; |
| 3419 |
} |
} |
| 3420 |
} elsif ($self->{insertion_mode} eq 'in head') { |
} elsif ($self->{insertion_mode} eq 'in head' or |
| 3421 |
|
$self->{insertion_mode} eq 'in head noscript' or |
| 3422 |
|
$self->{insertion_mode} eq 'after head') { |
| 3423 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 3424 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 3425 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 3436 |
!!!next-token; |
!!!next-token; |
| 3437 |
redo B; |
redo B; |
| 3438 |
} elsif ($token->{type} eq 'start tag') { |
} elsif ($token->{type} eq 'start tag') { |
| 3439 |
if ($token->{tag_name} eq 'title') { |
if ({base => ($self->{insertion_mode} eq 'in head' or |
| 3440 |
## NOTE: There is an "as if in head" code clone |
$self->{insertion_mode} eq 'after head'), |
| 3441 |
my $title_el; |
link => 1, meta => 1}->{$token->{tag_name}}) { |
| 3442 |
!!!create-element ($title_el, 'title', $token->{attributes}); |
## NOTE: There is a "as if in head" code clone. |
| 3443 |
(defined $self->{head_element} ? $self->{head_element} : $self->{open_elements}->[-1]->[0]) |
if ($self->{insertion_mode} eq 'after head') { |
| 3444 |
->append_child ($title_el); |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3445 |
$self->{content_model_flag} = 'RCDATA'; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3446 |
delete $self->{escape}; # MUST |
} |
| 3447 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 3448 |
my $text = ''; |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 3449 |
|
## TODO: Extracting |charset| from |meta|. |
| 3450 |
|
pop @{$self->{open_elements}} |
| 3451 |
|
if $self->{insertion_mode} eq 'after head'; |
| 3452 |
!!!next-token; |
!!!next-token; |
| 3453 |
while ($token->{type} eq 'character') { |
redo B; |
| 3454 |
$text .= $token->{data}; |
} elsif ($token->{tag_name} eq 'title' and |
| 3455 |
|
$self->{insertion_mode} eq 'in head') { |
| 3456 |
|
## NOTE: There is a "as if in head" code clone. |
| 3457 |
|
if ($self->{insertion_mode} eq 'after head') { |
| 3458 |
|
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3459 |
|
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3460 |
|
} |
| 3461 |
|
my $parent = defined $self->{head_element} ? $self->{head_element} |
| 3462 |
|
: $self->{open_elements}->[-1]->[0]; |
| 3463 |
|
$parse_rcdata->('RCDATA', sub { $parent->append_child ($_[0]) }); |
| 3464 |
|
pop @{$self->{open_elements}} |
| 3465 |
|
if $self->{insertion_mode} eq 'after head'; |
| 3466 |
|
redo B; |
| 3467 |
|
} elsif ($token->{tag_name} eq 'style') { |
| 3468 |
|
## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and |
| 3469 |
|
## insertion mode 'in head') |
| 3470 |
|
## NOTE: There is a "as if in head" code clone. |
| 3471 |
|
if ($self->{insertion_mode} eq 'after head') { |
| 3472 |
|
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3473 |
|
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3474 |
|
} |
| 3475 |
|
$parse_rcdata->('CDATA', $insert_to_current); |
| 3476 |
|
pop @{$self->{open_elements}} |
| 3477 |
|
if $self->{insertion_mode} eq 'after head'; |
| 3478 |
|
redo B; |
| 3479 |
|
} elsif ($token->{tag_name} eq 'noscript') { |
| 3480 |
|
if ($self->{insertion_mode} eq 'in head') { |
| 3481 |
|
## NOTE: and scripting is disalbed |
| 3482 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 3483 |
|
$self->{insertion_mode} = 'in head noscript'; |
| 3484 |
!!!next-token; |
!!!next-token; |
| 3485 |
} |
redo B; |
| 3486 |
if (length $text) { |
} elsif ($self->{insertion_mode} eq 'in head noscript') { |
| 3487 |
$title_el->manakai_append_text ($text); |
!!!parse-error (type => 'in noscript:noscript'); |
|
} |
|
|
|
|
|
$self->{content_model_flag} = 'PCDATA'; |
|
|
|
|
|
if ($token->{type} eq 'end tag' and |
|
|
$token->{tag_name} eq 'title') { |
|
| 3488 |
## Ignore the token |
## Ignore the token |
| 3489 |
|
redo B; |
| 3490 |
} else { |
} else { |
| 3491 |
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
# |
|
## ISSUE: And ignore? |
|
| 3492 |
} |
} |
| 3493 |
|
} elsif ($token->{tag_name} eq 'head' and |
| 3494 |
|
$self->{insertion_mode} ne 'after head') { |
| 3495 |
|
!!!parse-error (type => 'in head:head'); # or in head noscript |
| 3496 |
|
## Ignore the token |
| 3497 |
!!!next-token; |
!!!next-token; |
| 3498 |
redo B; |
redo B; |
| 3499 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($self->{insertion_mode} ne 'in head noscript' and |
| 3500 |
$style_start_tag->(); |
$token->{tag_name} eq 'script') { |
| 3501 |
redo B; |
if ($self->{insertion_mode} eq 'after head') { |
| 3502 |
} elsif ($token->{tag_name} eq 'script') { |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
| 3503 |
$script_start_tag->(); |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3504 |
|
} |
| 3505 |
|
## NOTE: There is a "as if in head" code clone. |
| 3506 |
|
$script_start_tag->($insert_to_current); |
| 3507 |
|
pop @{$self->{open_elements}} |
| 3508 |
|
if $self->{insertion_mode} eq 'after head'; |
| 3509 |
redo B; |
redo B; |
| 3510 |
} elsif ({base => 1, link => 1, meta => 1}->{$token->{tag_name}}) { |
} elsif ($self->{insertion_mode} eq 'after head' and |
| 3511 |
## NOTE: There are "as if in head" code clones |
$token->{tag_name} eq 'body') { |
| 3512 |
my $el; |
!!!insert-element ('body', $token->{attributes}); |
| 3513 |
!!!create-element ($el, $token->{tag_name}, $token->{attributes}); |
$self->{insertion_mode} = 'in body'; |
|
(defined $self->{head_element} ? $self->{head_element} : $self->{open_elements}->[-1]->[0]) |
|
|
->append_child ($el); |
|
|
|
|
| 3514 |
!!!next-token; |
!!!next-token; |
| 3515 |
redo B; |
redo B; |
| 3516 |
} elsif ($token->{tag_name} eq 'head') { |
} elsif ($self->{insertion_mode} eq 'after head' and |
| 3517 |
!!!parse-error (type => 'in head:head'); |
$token->{tag_name} eq 'frameset') { |
| 3518 |
## Ignore the token |
!!!insert-element ('frameset', $token->{attributes}); |
| 3519 |
|
$self->{insertion_mode} = 'in frameset'; |
| 3520 |
!!!next-token; |
!!!next-token; |
| 3521 |
redo B; |
redo B; |
| 3522 |
} else { |
} else { |
| 3523 |
# |
# |
| 3524 |
} |
} |
| 3525 |
} elsif ($token->{type} eq 'end tag') { |
} elsif ($token->{type} eq 'end tag') { |
| 3526 |
if ($token->{tag_name} eq 'head') { |
if ($self->{insertion_mode} eq 'in head' and |
| 3527 |
if ($self->{open_elements}->[-1]->[1] eq 'head') { |
$token->{tag_name} eq 'head') { |
| 3528 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
|
} else { |
|
|
!!!parse-error (type => 'unmatched end tag:head'); |
|
|
} |
|
| 3529 |
$self->{insertion_mode} = 'after head'; |
$self->{insertion_mode} = 'after head'; |
| 3530 |
!!!next-token; |
!!!next-token; |
| 3531 |
redo B; |
redo B; |
| 3532 |
} elsif ($token->{tag_name} eq 'body' or |
} elsif ($self->{insertion_mode} eq 'in head noscript' and |
| 3533 |
$token->{tag_name} eq 'html') { |
$token->{tag_name} eq 'noscript') { |
| 3534 |
|
pop @{$self->{open_elements}}; |
| 3535 |
|
$self->{insertion_mode} = 'in head'; |
| 3536 |
|
!!!next-token; |
| 3537 |
|
redo B; |
| 3538 |
|
} elsif ($self->{insertion_mode} eq 'in head' and |
| 3539 |
|
{ |
| 3540 |
|
body => 1, html => 1, |
| 3541 |
|
p => 1, br => 1, |
| 3542 |
|
}->{$token->{tag_name}}) { |
| 3543 |
# |
# |
| 3544 |
} else { |
} elsif ($self->{insertion_mode} eq 'in head noscript' and |
| 3545 |
|
{ |
| 3546 |
|
p => 1, br => 1, |
| 3547 |
|
}->{$token->{tag_name}}) { |
| 3548 |
|
# |
| 3549 |
|
} elsif ($self->{insertion_mode} ne 'after head') { |
| 3550 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 3551 |
## Ignore the token |
## Ignore the token |
| 3552 |
!!!next-token; |
!!!next-token; |
| 3553 |
redo B; |
redo B; |
| 3554 |
|
} else { |
| 3555 |
|
# |
| 3556 |
} |
} |
| 3557 |
} else { |
} else { |
| 3558 |
# |
# |
| 3559 |
} |
} |
| 3560 |
|
|
| 3561 |
if ($self->{open_elements}->[-1]->[1] eq 'head') { |
## As if </head> or </noscript> or <body> |
| 3562 |
## As if </head> |
if ($self->{insertion_mode} eq 'in head') { |
| 3563 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3564 |
|
$self->{insertion_mode} = 'after head'; |
| 3565 |
|
} elsif ($self->{insertion_mode} eq 'in head noscript') { |
| 3566 |
|
pop @{$self->{open_elements}}; |
| 3567 |
|
!!!parse-error (type => 'in noscript:'.(defined $token->{tag_name} ? ($token->{type} eq 'end tag' ? '/' : '') . $token->{tag_name} : '#' . $token->{type})); |
| 3568 |
|
$self->{insertion_mode} = 'in head'; |
| 3569 |
|
} else { # 'after head' |
| 3570 |
|
!!!insert-element ('body'); |
| 3571 |
|
$self->{insertion_mode} = 'in body'; |
| 3572 |
} |
} |
|
$self->{insertion_mode} = 'after head'; |
|
| 3573 |
## reprocess |
## reprocess |
| 3574 |
redo B; |
redo B; |
| 3575 |
|
|
| 3576 |
## ISSUE: An issue in the spec. |
## ISSUE: An issue in the spec. |
|
} elsif ($self->{insertion_mode} eq 'after head') { |
|
|
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 'comment') { |
|
|
my $comment = $self->{document}->create_comment ($token->{data}); |
|
|
$self->{open_elements}->[-1]->[0]->append_child ($comment); |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{type} eq 'start tag') { |
|
|
if ($token->{tag_name} eq 'body') { |
|
|
!!!insert-element ('body', $token->{attributes}); |
|
|
$self->{insertion_mode} = 'in body'; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'frameset') { |
|
|
!!!insert-element ('frameset', $token->{attributes}); |
|
|
$self->{insertion_mode} = 'in frameset'; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
base => 1, link => 1, meta => 1, |
|
|
script => 1, style => 1, title => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
|
|
$self->{insertion_mode} = 'in head'; |
|
|
## reprocess |
|
|
redo B; |
|
|
} else { |
|
|
# |
|
|
} |
|
|
} else { |
|
|
# |
|
|
} |
|
|
|
|
|
## As if <body> |
|
|
!!!insert-element ('body'); |
|
|
$self->{insertion_mode} = 'in body'; |
|
|
## reprocess |
|
|
redo B; |
|
| 3577 |
} elsif ($self->{insertion_mode} eq 'in body') { |
} elsif ($self->{insertion_mode} eq 'in body') { |
| 3578 |
if ($token->{type} eq 'character') { |
if ($token->{type} eq 'character') { |
| 3579 |
## NOTE: There is a code clone of "character in body". |
## NOTE: There is a code clone of "character in body". |
| 3728 |
if ({ |
if ({ |
| 3729 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 3730 |
td => 1, th => 1, tr => 1, |
td => 1, th => 1, tr => 1, |
| 3731 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3732 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3733 |
!!!back-token; # <table> |
!!!back-token; # <table> |
| 3734 |
$token = {type => 'end tag', tag_name => 'table'}; |
$token = {type => 'end tag', tag_name => 'table'}; |
| 3777 |
if ({ |
if ({ |
| 3778 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 3779 |
td => 1, th => 1, tr => 1, |
td => 1, th => 1, tr => 1, |
| 3780 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3781 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3782 |
!!!back-token; |
!!!back-token; |
| 3783 |
$token = {type => 'end tag', |
$token = {type => 'end tag', |
| 3861 |
if ({ |
if ({ |
| 3862 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 3863 |
td => 1, th => 1, tr => 1, |
td => 1, th => 1, tr => 1, |
| 3864 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3865 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3866 |
!!!back-token; # <?> |
!!!back-token; # <?> |
| 3867 |
$token = {type => 'end tag', tag_name => 'caption'}; |
$token = {type => 'end tag', tag_name => 'caption'}; |
| 3912 |
if ({ |
if ({ |
| 3913 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 3914 |
td => 1, th => 1, tr => 1, |
td => 1, th => 1, tr => 1, |
| 3915 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3916 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3917 |
!!!back-token; |
!!!back-token; |
| 3918 |
$token = {type => 'end tag', |
$token = {type => 'end tag', |
| 3960 |
if ({ |
if ({ |
| 3961 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 3962 |
td => 1, th => 1, tr => 1, |
td => 1, th => 1, tr => 1, |
| 3963 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 3964 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3965 |
!!!back-token; # </table> |
!!!back-token; # </table> |
| 3966 |
$token = {type => 'end tag', tag_name => 'caption'}; |
$token = {type => 'end tag', tag_name => 'caption'}; |
| 4226 |
if ({ |
if ({ |
| 4227 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4228 |
td => 1, th => 1, tr => 1, |
td => 1, th => 1, tr => 1, |
| 4229 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 4230 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4231 |
!!!back-token; # <table> |
!!!back-token; # <table> |
| 4232 |
$token = {type => 'end tag', tag_name => 'table'}; |
$token = {type => 'end tag', tag_name => 'table'}; |
| 4495 |
if ({ |
if ({ |
| 4496 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4497 |
td => 1, th => 1, tr => 1, |
td => 1, th => 1, tr => 1, |
| 4498 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 4499 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4500 |
!!!back-token; # <table> |
!!!back-token; # <table> |
| 4501 |
$token = {type => 'end tag', tag_name => 'table'}; |
$token = {type => 'end tag', tag_name => 'table'}; |
| 4737 |
td => ($token->{tag_name} eq 'th'), |
td => ($token->{tag_name} eq 'th'), |
| 4738 |
th => ($token->{tag_name} eq 'td'), |
th => ($token->{tag_name} eq 'td'), |
| 4739 |
tr => 1, |
tr => 1, |
| 4740 |
|
tbody => 1, tfoot=> 1, thead => 1, |
| 4741 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4742 |
!!!back-token; |
!!!back-token; |
| 4743 |
$token = {type => 'end tag', |
$token = {type => 'end tag', |
| 5090 |
} |
} |
| 5091 |
|
|
| 5092 |
if (defined $token->{tag_name}) { |
if (defined $token->{tag_name}) { |
| 5093 |
!!!parse-error (type => 'in frameset:'.$token->{tag_name}); |
!!!parse-error (type => 'in frameset:'.($token->{type} eq 'end tag' ? '/' : '').$token->{tag_name}); |
| 5094 |
} else { |
} else { |
| 5095 |
!!!parse-error (type => 'in frameset:#'.$token->{type}); |
!!!parse-error (type => 'in frameset:#'.$token->{type}); |
| 5096 |
} |
} |
| 5134 |
} |
} |
| 5135 |
|
|
| 5136 |
if (defined $token->{tag_name}) { |
if (defined $token->{tag_name}) { |
| 5137 |
!!!parse-error (type => 'after frameset:'.$token->{tag_name}); |
!!!parse-error (type => 'after frameset:'.($token->{tag_name} eq 'end tag' ? '/' : '').$token->{tag_name}); |
| 5138 |
} else { |
} else { |
| 5139 |
!!!parse-error (type => 'after frameset:#'.$token->{type}); |
!!!parse-error (type => 'after frameset:#'.$token->{type}); |
| 5140 |
} |
} |
| 5184 |
redo B; |
redo B; |
| 5185 |
} elsif ($token->{type} eq 'start tag' or |
} elsif ($token->{type} eq 'start tag' or |
| 5186 |
$token->{type} eq 'end tag') { |
$token->{type} eq 'end tag') { |
| 5187 |
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
!!!parse-error (type => 'after html:'.($token->{type} eq 'end tag' ? '/' : '').$token->{tag_name}); |
| 5188 |
$phase = 'main'; |
$phase = 'main'; |
| 5189 |
## reprocess |
## reprocess |
| 5190 |
redo B; |
redo B; |
| 5393 |
|
|
| 5394 |
my $nt = $child->node_type; |
my $nt = $child->node_type; |
| 5395 |
if ($nt == 1) { # Element |
if ($nt == 1) { # Element |
| 5396 |
my $tag_name = lc $child->tag_name; ## ISSUE: Definition of "lowercase" |
my $tag_name = $child->tag_name; ## TODO: manakai_tag_name |
| 5397 |
$s .= '<' . $tag_name; |
$s .= '<' . $tag_name; |
| 5398 |
|
## NOTE: Non-HTML case: |
| 5399 |
## ISSUE: Non-html elements |
## <http://permalink.gmane.org/gmane.org.w3c.whatwg.discuss/11191> |
| 5400 |
|
|
| 5401 |
my @attrs = @{$child->attributes}; # sort order MUST be stable |
my @attrs = @{$child->attributes}; # sort order MUST be stable |
| 5402 |
for my $attr (@attrs) { # order is implementation dependent |
for my $attr (@attrs) { # order is implementation dependent |
| 5403 |
my $attr_name = lc $attr->name; ## ISSUE: Definition of "lowercase" |
my $attr_name = $attr->name; ## TODO: manakai_name |
| 5404 |
$s .= ' ' . $attr_name . '="'; |
$s .= ' ' . $attr_name . '="'; |
| 5405 |
my $attr_value = $attr->value; |
my $attr_value = $attr->value; |
| 5406 |
## escape |
## escape |
| 5424 |
if (not $in_cdata and { |
if (not $in_cdata and { |
| 5425 |
style => 1, script => 1, xmp => 1, iframe => 1, |
style => 1, script => 1, xmp => 1, iframe => 1, |
| 5426 |
noembed => 1, noframes => 1, noscript => 1, |
noembed => 1, noframes => 1, noscript => 1, |
| 5427 |
|
plaintext => 1, |
| 5428 |
}->{$tag_name}) { |
}->{$tag_name}) { |
| 5429 |
unshift @node, 'cdata-out'; |
unshift @node, 'cdata-out'; |
| 5430 |
$in_cdata = 1; |
$in_cdata = 1; |