| 74 |
textarea => 1, tfoot => 1, thead => 1, title => 1, tr => 1, ul => 1, wbr => 1, |
textarea => 1, tfoot => 1, thead => 1, title => 1, tr => 1, ul => 1, wbr => 1, |
| 75 |
}; |
}; |
| 76 |
my $scoping_category = { |
my $scoping_category = { |
| 77 |
button => 1, caption => 1, html => 1, marquee => 1, object => 1, |
applet => 1, button => 1, caption => 1, html => 1, marquee => 1, object => 1, |
| 78 |
table => 1, td => 1, th => 1, |
table => 1, td => 1, th => 1, |
| 79 |
}; |
}; |
| 80 |
my $formatting_category = { |
my $formatting_category = { |
| 108 |
$self->{change_encoding} = sub { |
$self->{change_encoding} = sub { |
| 109 |
my $self = shift; |
my $self = shift; |
| 110 |
my $charset = lc shift; |
my $charset = lc shift; |
| 111 |
|
my $token = shift; |
| 112 |
## TODO: if $charset is supported |
## TODO: if $charset is supported |
| 113 |
## TODO: normalize charset name |
## TODO: normalize charset name |
| 114 |
|
|
| 127 |
} |
} |
| 128 |
|
|
| 129 |
!!!parse-error (type => 'charset label detected:'.$self->{input_encoding}. |
!!!parse-error (type => 'charset label detected:'.$self->{input_encoding}. |
| 130 |
':'.$charset, level => 'w'); |
':'.$charset, level => 'w', token => $token); |
| 131 |
|
|
| 132 |
## Step 3 |
## Step 3 |
| 133 |
# if (can) { |
# if (can) { |
| 178 |
if defined $self->{input_encoding}; |
if defined $self->{input_encoding}; |
| 179 |
|
|
| 180 |
my $i = 0; |
my $i = 0; |
| 181 |
my $line = 1; |
$self->{line_prev} = $self->{line} = 1; |
| 182 |
my $column = 0; |
$self->{column_prev} = $self->{column} = 0; |
| 183 |
$self->{set_next_char} = sub { |
$self->{set_next_char} = sub { |
| 184 |
my $self = shift; |
my $self = shift; |
| 185 |
|
|
| 188 |
|
|
| 189 |
$self->{next_char} = -1 and return if $i >= length $$s; |
$self->{next_char} = -1 and return if $i >= length $$s; |
| 190 |
$self->{next_char} = ord substr $$s, $i++, 1; |
$self->{next_char} = ord substr $$s, $i++, 1; |
| 191 |
$column++; |
|
| 192 |
|
($self->{line_prev}, $self->{column_prev}) |
| 193 |
|
= ($self->{line}, $self->{column}); |
| 194 |
|
$self->{column}++; |
| 195 |
|
|
| 196 |
if ($self->{next_char} == 0x000A) { # LF |
if ($self->{next_char} == 0x000A) { # LF |
| 197 |
$line++; |
$self->{line}++; |
| 198 |
$column = 0; |
$self->{column} = 0; |
| 199 |
} elsif ($self->{next_char} == 0x000D) { # CR |
} elsif ($self->{next_char} == 0x000D) { # CR |
| 200 |
$i++ if substr ($$s, $i, 1) eq "\x0A"; |
$i++ if substr ($$s, $i, 1) eq "\x0A"; |
| 201 |
$self->{next_char} = 0x000A; # LF # MUST |
$self->{next_char} = 0x000A; # LF # MUST |
| 202 |
$line++; |
$self->{line}++; |
| 203 |
$column = 0; |
$self->{column} = 0; |
| 204 |
} elsif ($self->{next_char} > 0x10FFFF) { |
} elsif ($self->{next_char} > 0x10FFFF) { |
| 205 |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
| 206 |
} elsif ($self->{next_char} == 0x0000) { # NULL |
} elsif ($self->{next_char} == 0x0000) { # NULL |
| 213 |
|
|
| 214 |
my $onerror = $_[2] || sub { |
my $onerror = $_[2] || sub { |
| 215 |
my (%opt) = @_; |
my (%opt) = @_; |
| 216 |
warn "Parse error ($opt{type}) at line $opt{line} column $opt{column}\n"; |
my $line = $opt{token} ? $opt{token}->{line} : $opt{line}; |
| 217 |
|
my $column = $opt{token} ? $opt{token}->{column} : $opt{column}; |
| 218 |
|
warn "Parse error ($opt{type}) at line $line column $column\n"; |
| 219 |
}; |
}; |
| 220 |
$self->{parse_error} = sub { |
$self->{parse_error} = sub { |
| 221 |
$onerror->(@_, line => $line, column => $column); |
$onerror->(line => $self->{line}, column => $self->{column}, @_); |
| 222 |
}; |
}; |
| 223 |
|
|
| 224 |
$self->_initialize_tokenizer; |
$self->_initialize_tokenizer; |
| 226 |
$self->_construct_tree; |
$self->_construct_tree; |
| 227 |
$self->_terminate_tree_constructor; |
$self->_terminate_tree_constructor; |
| 228 |
|
|
| 229 |
|
delete $self->{parse_error}; # remove loop |
| 230 |
|
|
| 231 |
return $self->{document}; |
return $self->{document}; |
| 232 |
} # parse_string |
} # parse_string |
| 233 |
|
|
| 311 |
sub ROW_IMS () { 0b10000000 } |
sub ROW_IMS () { 0b10000000 } |
| 312 |
sub BODY_AFTER_IMS () { 0b100000000 } |
sub BODY_AFTER_IMS () { 0b100000000 } |
| 313 |
sub FRAME_IMS () { 0b1000000000 } |
sub FRAME_IMS () { 0b1000000000 } |
| 314 |
|
sub SELECT_IMS () { 0b10000000000 } |
| 315 |
|
|
| 316 |
## NOTE: "initial" and "before html" insertion modes have no constants. |
## NOTE: "initial" and "before html" insertion modes have no constants. |
| 317 |
|
|
| 334 |
sub AFTER_BODY_IM () { BODY_AFTER_IMS } |
sub AFTER_BODY_IM () { BODY_AFTER_IMS } |
| 335 |
sub IN_FRAMESET_IM () { FRAME_IMS | 0b01 } |
sub IN_FRAMESET_IM () { FRAME_IMS | 0b01 } |
| 336 |
sub AFTER_FRAMESET_IM () { FRAME_IMS | 0b10 } |
sub AFTER_FRAMESET_IM () { FRAME_IMS | 0b10 } |
| 337 |
sub IN_SELECT_IM () { 0b01 } |
sub IN_SELECT_IM () { SELECT_IMS | 0b01 } |
| 338 |
|
sub IN_SELECT_IN_TABLE_IM () { SELECT_IMS | 0b10 } |
| 339 |
sub IN_COLUMN_GROUP_IM () { 0b10 } |
sub IN_COLUMN_GROUP_IM () { 0b10 } |
| 340 |
|
|
| 341 |
## Implementations MUST act as if state machine in the spec |
## Implementations MUST act as if state machine in the spec |
| 457 |
# |
# |
| 458 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 459 |
!!!cp (11); |
!!!cp (11); |
| 460 |
!!!emit ({type => END_OF_FILE_TOKEN}); |
!!!emit ({type => END_OF_FILE_TOKEN, |
| 461 |
|
line => $self->{line}, column => $self->{column}}); |
| 462 |
last A; ## TODO: ok? |
last A; ## TODO: ok? |
| 463 |
} else { |
} else { |
| 464 |
!!!cp (12); |
!!!cp (12); |
| 465 |
} |
} |
| 466 |
# Anything else |
# Anything else |
| 467 |
my $token = {type => CHARACTER_TOKEN, |
my $token = {type => CHARACTER_TOKEN, |
| 468 |
data => chr $self->{next_char}}; |
data => chr $self->{next_char}, |
| 469 |
|
line => $self->{line}, column => $self->{column}}; |
| 470 |
## Stay in the data state |
## Stay in the data state |
| 471 |
!!!next-input-character; |
!!!next-input-character; |
| 472 |
|
|
| 475 |
redo A; |
redo A; |
| 476 |
} elsif ($self->{state} == ENTITY_DATA_STATE) { |
} elsif ($self->{state} == ENTITY_DATA_STATE) { |
| 477 |
## (cannot happen in CDATA state) |
## (cannot happen in CDATA state) |
| 478 |
|
|
| 479 |
|
my ($l, $c) = ($self->{line_prev}, $self->{column_prev}); |
| 480 |
|
|
| 481 |
my $token = $self->_tokenize_attempt_to_consume_an_entity (0, -1); |
my $token = $self->_tokenize_attempt_to_consume_an_entity (0, -1); |
| 482 |
|
|
| 485 |
|
|
| 486 |
unless (defined $token) { |
unless (defined $token) { |
| 487 |
!!!cp (13); |
!!!cp (13); |
| 488 |
!!!emit ({type => CHARACTER_TOKEN, data => '&'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '&', |
| 489 |
|
line => $l, column => $c}); |
| 490 |
} else { |
} else { |
| 491 |
!!!cp (14); |
!!!cp (14); |
| 492 |
!!!emit ($token); |
!!!emit ($token); |
| 505 |
## reconsume |
## reconsume |
| 506 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 507 |
|
|
| 508 |
!!!emit ({type => CHARACTER_TOKEN, data => '<'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '<', |
| 509 |
|
line => $self->{line_prev}, |
| 510 |
|
column => $self->{column_prev}}); |
| 511 |
|
|
| 512 |
redo A; |
redo A; |
| 513 |
} |
} |
| 527 |
!!!cp (19); |
!!!cp (19); |
| 528 |
$self->{current_token} |
$self->{current_token} |
| 529 |
= {type => START_TAG_TOKEN, |
= {type => START_TAG_TOKEN, |
| 530 |
tag_name => chr ($self->{next_char} + 0x0020)}; |
tag_name => chr ($self->{next_char} + 0x0020), |
| 531 |
|
line => $self->{line_prev}, |
| 532 |
|
column => $self->{column_prev}}; |
| 533 |
$self->{state} = TAG_NAME_STATE; |
$self->{state} = TAG_NAME_STATE; |
| 534 |
!!!next-input-character; |
!!!next-input-character; |
| 535 |
redo A; |
redo A; |
| 537 |
$self->{next_char} <= 0x007A) { # a..z |
$self->{next_char} <= 0x007A) { # a..z |
| 538 |
!!!cp (20); |
!!!cp (20); |
| 539 |
$self->{current_token} = {type => START_TAG_TOKEN, |
$self->{current_token} = {type => START_TAG_TOKEN, |
| 540 |
tag_name => chr ($self->{next_char})}; |
tag_name => chr ($self->{next_char}), |
| 541 |
|
line => $self->{line_prev}, |
| 542 |
|
column => $self->{column_prev}}; |
| 543 |
$self->{state} = TAG_NAME_STATE; |
$self->{state} = TAG_NAME_STATE; |
| 544 |
!!!next-input-character; |
!!!next-input-character; |
| 545 |
redo A; |
redo A; |
| 546 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 547 |
!!!cp (21); |
!!!cp (21); |
| 548 |
!!!parse-error (type => 'empty start tag'); |
!!!parse-error (type => 'empty start tag', |
| 549 |
|
line => $self->{line_prev}, |
| 550 |
|
column => $self->{column_prev}); |
| 551 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 552 |
!!!next-input-character; |
!!!next-input-character; |
| 553 |
|
|
| 554 |
!!!emit ({type => CHARACTER_TOKEN, data => '<>'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '<>', |
| 555 |
|
line => $self->{line_prev}, |
| 556 |
|
column => $self->{column_prev}}); |
| 557 |
|
|
| 558 |
redo A; |
redo A; |
| 559 |
} elsif ($self->{next_char} == 0x003F) { # ? |
} elsif ($self->{next_char} == 0x003F) { # ? |
| 560 |
!!!cp (22); |
!!!cp (22); |
| 561 |
!!!parse-error (type => 'pio'); |
!!!parse-error (type => 'pio', |
| 562 |
|
line => $self->{line_prev}, |
| 563 |
|
column => $self->{column_prev}); |
| 564 |
$self->{state} = BOGUS_COMMENT_STATE; |
$self->{state} = BOGUS_COMMENT_STATE; |
| 565 |
|
$self->{current_token} = {type => COMMENT_TOKEN, data => '', |
| 566 |
|
line => $self->{line_prev}, |
| 567 |
|
column => $self->{column_prev}}; |
| 568 |
## $self->{next_char} is intentionally left as is |
## $self->{next_char} is intentionally left as is |
| 569 |
redo A; |
redo A; |
| 570 |
} else { |
} else { |
| 573 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 574 |
## reconsume |
## reconsume |
| 575 |
|
|
| 576 |
!!!emit ({type => CHARACTER_TOKEN, data => '<'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '<', |
| 577 |
|
line => $self->{line_prev}, |
| 578 |
|
column => $self->{column_prev}}); |
| 579 |
|
|
| 580 |
redo A; |
redo A; |
| 581 |
} |
} |
| 583 |
die "$0: $self->{content_model} in tag open"; |
die "$0: $self->{content_model} in tag open"; |
| 584 |
} |
} |
| 585 |
} elsif ($self->{state} == CLOSE_TAG_OPEN_STATE) { |
} elsif ($self->{state} == CLOSE_TAG_OPEN_STATE) { |
| 586 |
|
my ($l, $c) = ($self->{line_prev}, $self->{column_prev} - 1); # "<"of"</" |
| 587 |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
if ($self->{content_model} & CM_LIMITED_MARKUP) { # RCDATA | CDATA |
| 588 |
if (defined $self->{last_emitted_start_tag_name}) { |
if (defined $self->{last_emitted_start_tag_name}) { |
| 589 |
|
|
| 590 |
## NOTE: <http://krijnhoetmer.nl/irc-logs/whatwg/20070626#l-564> |
## NOTE: <http://krijnhoetmer.nl/irc-logs/whatwg/20070626#l-564> |
| 591 |
my @next_char; |
my @next_char; |
| 592 |
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++) { |
| 603 |
!!!back-next-input-character (@next_char); |
!!!back-next-input-character (@next_char); |
| 604 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 605 |
|
|
| 606 |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '</', |
| 607 |
|
line => $l, column => $c}); |
| 608 |
|
|
| 609 |
redo A; |
redo A; |
| 610 |
} |
} |
| 623 |
$self->{next_char} = shift @next_char; # reconsume |
$self->{next_char} = shift @next_char; # reconsume |
| 624 |
!!!back-next-input-character (@next_char); |
!!!back-next-input-character (@next_char); |
| 625 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 626 |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '</', |
| 627 |
|
line => $l, column => $c}); |
| 628 |
redo A; |
redo A; |
| 629 |
} else { |
} else { |
| 630 |
!!!cp (27); |
!!!cp (27); |
| 637 |
!!!cp (28); |
!!!cp (28); |
| 638 |
# next-input-character is already done |
# next-input-character is already done |
| 639 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 640 |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '</', |
| 641 |
|
line => $l, column => $c}); |
| 642 |
redo A; |
redo A; |
| 643 |
} |
} |
| 644 |
} |
} |
| 646 |
if (0x0041 <= $self->{next_char} and |
if (0x0041 <= $self->{next_char} and |
| 647 |
$self->{next_char} <= 0x005A) { # A..Z |
$self->{next_char} <= 0x005A) { # A..Z |
| 648 |
!!!cp (29); |
!!!cp (29); |
| 649 |
$self->{current_token} = {type => END_TAG_TOKEN, |
$self->{current_token} |
| 650 |
tag_name => chr ($self->{next_char} + 0x0020)}; |
= {type => END_TAG_TOKEN, |
| 651 |
|
tag_name => chr ($self->{next_char} + 0x0020), |
| 652 |
|
line => $l, column => $c}; |
| 653 |
$self->{state} = TAG_NAME_STATE; |
$self->{state} = TAG_NAME_STATE; |
| 654 |
!!!next-input-character; |
!!!next-input-character; |
| 655 |
redo A; |
redo A; |
| 657 |
$self->{next_char} <= 0x007A) { # a..z |
$self->{next_char} <= 0x007A) { # a..z |
| 658 |
!!!cp (30); |
!!!cp (30); |
| 659 |
$self->{current_token} = {type => END_TAG_TOKEN, |
$self->{current_token} = {type => END_TAG_TOKEN, |
| 660 |
tag_name => chr ($self->{next_char})}; |
tag_name => chr ($self->{next_char}), |
| 661 |
|
line => $l, column => $c}; |
| 662 |
$self->{state} = TAG_NAME_STATE; |
$self->{state} = TAG_NAME_STATE; |
| 663 |
!!!next-input-character; |
!!!next-input-character; |
| 664 |
redo A; |
redo A; |
| 665 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 666 |
!!!cp (31); |
!!!cp (31); |
| 667 |
!!!parse-error (type => 'empty end tag'); |
!!!parse-error (type => 'empty end tag', |
| 668 |
|
line => $self->{line_prev}, ## "<" in "</>" |
| 669 |
|
column => $self->{column_prev} - 1); |
| 670 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 671 |
!!!next-input-character; |
!!!next-input-character; |
| 672 |
redo A; |
redo A; |
| 676 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 677 |
# reconsume |
# reconsume |
| 678 |
|
|
| 679 |
!!!emit ({type => CHARACTER_TOKEN, data => '</'}); |
!!!emit ({type => CHARACTER_TOKEN, data => '</', |
| 680 |
|
line => $l, column => $c}); |
| 681 |
|
|
| 682 |
redo A; |
redo A; |
| 683 |
} else { |
} else { |
| 684 |
!!!cp (33); |
!!!cp (33); |
| 685 |
!!!parse-error (type => 'bogus end tag'); |
!!!parse-error (type => 'bogus end tag'); |
| 686 |
$self->{state} = BOGUS_COMMENT_STATE; |
$self->{state} = BOGUS_COMMENT_STATE; |
| 687 |
|
$self->{current_token} = {type => COMMENT_TOKEN, data => '', |
| 688 |
|
line => $self->{line_prev}, # "<" of "</" |
| 689 |
|
column => $self->{column_prev} - 1}; |
| 690 |
## $self->{next_char} is intentionally left as is |
## $self->{next_char} is intentionally left as is |
| 691 |
redo A; |
redo A; |
| 692 |
} |
} |
| 703 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 704 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 705 |
!!!cp (35); |
!!!cp (35); |
|
$self->{current_token}->{first_start_tag} |
|
|
= not defined $self->{last_emitted_start_tag_name}; |
|
| 706 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 707 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 708 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 734 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 735 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 736 |
!!!cp (39); |
!!!cp (39); |
|
$self->{current_token}->{first_start_tag} |
|
|
= not defined $self->{last_emitted_start_tag_name}; |
|
| 737 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 738 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 739 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 789 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 790 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 791 |
!!!cp (46); |
!!!cp (46); |
|
$self->{current_token}->{first_start_tag} |
|
|
= not defined $self->{last_emitted_start_tag_name}; |
|
| 792 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 793 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 794 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 834 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 835 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 836 |
!!!cp (52); |
!!!cp (52); |
|
$self->{current_token}->{first_start_tag} |
|
|
= not defined $self->{last_emitted_start_tag_name}; |
|
| 837 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 838 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 839 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 903 |
$before_leave->(); |
$before_leave->(); |
| 904 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 905 |
!!!cp (61); |
!!!cp (61); |
|
$self->{current_token}->{first_start_tag} |
|
|
= not defined $self->{last_emitted_start_tag_name}; |
|
| 906 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 907 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 908 |
!!!cp (62); |
!!!cp (62); |
| 947 |
$before_leave->(); |
$before_leave->(); |
| 948 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 949 |
!!!cp (66); |
!!!cp (66); |
|
$self->{current_token}->{first_start_tag} |
|
|
= not defined $self->{last_emitted_start_tag_name}; |
|
| 950 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 951 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 952 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 997 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 998 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 999 |
!!!cp (73); |
!!!cp (73); |
|
$self->{current_token}->{first_start_tag} |
|
|
= not defined $self->{last_emitted_start_tag_name}; |
|
| 1000 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1001 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1002 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1044 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 1045 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1046 |
!!!cp (79); |
!!!cp (79); |
|
$self->{current_token}->{first_start_tag} |
|
|
= not defined $self->{last_emitted_start_tag_name}; |
|
| 1047 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1048 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1049 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1099 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 1100 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1101 |
!!!cp (87); |
!!!cp (87); |
|
$self->{current_token}->{first_start_tag} |
|
|
= not defined $self->{last_emitted_start_tag_name}; |
|
| 1102 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1103 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1104 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1122 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 1123 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1124 |
!!!cp (90); |
!!!cp (90); |
|
$self->{current_token}->{first_start_tag} |
|
|
= not defined $self->{last_emitted_start_tag_name}; |
|
| 1125 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1126 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1127 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1169 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
| 1170 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1171 |
!!!cp (97); |
!!!cp (97); |
|
$self->{current_token}->{first_start_tag} |
|
|
= not defined $self->{last_emitted_start_tag_name}; |
|
| 1172 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1173 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1174 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1211 |
!!!parse-error (type => 'unclosed attribute value'); |
!!!parse-error (type => 'unclosed attribute value'); |
| 1212 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1213 |
!!!cp (103); |
!!!cp (103); |
|
$self->{current_token}->{first_start_tag} |
|
|
= not defined $self->{last_emitted_start_tag_name}; |
|
| 1214 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1215 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1216 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1256 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 1257 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1258 |
!!!cp (109); |
!!!cp (109); |
|
$self->{current_token}->{first_start_tag} |
|
|
= not defined $self->{last_emitted_start_tag_name}; |
|
| 1259 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1260 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1261 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1279 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 1280 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1281 |
!!!cp (112); |
!!!cp (112); |
|
$self->{current_token}->{first_start_tag} |
|
|
= not defined $self->{last_emitted_start_tag_name}; |
|
| 1282 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1283 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1284 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1349 |
} elsif ($self->{next_char} == 0x003E) { # > |
} elsif ($self->{next_char} == 0x003E) { # > |
| 1350 |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
if ($self->{current_token}->{type} == START_TAG_TOKEN) { |
| 1351 |
!!!cp (119); |
!!!cp (119); |
|
$self->{current_token}->{first_start_tag} |
|
|
= not defined $self->{last_emitted_start_tag_name}; |
|
| 1352 |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
$self->{last_emitted_start_tag_name} = $self->{current_token}->{tag_name}; |
| 1353 |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
} elsif ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1354 |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1393 |
} elsif ($self->{state} == BOGUS_COMMENT_STATE) { |
} elsif ($self->{state} == BOGUS_COMMENT_STATE) { |
| 1394 |
## (only happen if PCDATA state) |
## (only happen if PCDATA state) |
| 1395 |
|
|
| 1396 |
my $token = {type => COMMENT_TOKEN, data => ''}; |
## NOTE: Set by the previous state |
| 1397 |
|
#my $token = {type => COMMENT_TOKEN, data => ''}; |
| 1398 |
|
|
| 1399 |
BC: { |
BC: { |
| 1400 |
if ($self->{next_char} == 0x003E) { # > |
if ($self->{next_char} == 0x003E) { # > |
| 1402 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 1403 |
!!!next-input-character; |
!!!next-input-character; |
| 1404 |
|
|
| 1405 |
!!!emit ($token); |
!!!emit ($self->{current_token}); # comment |
| 1406 |
|
|
| 1407 |
redo A; |
redo A; |
| 1408 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1410 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 1411 |
## reconsume |
## reconsume |
| 1412 |
|
|
| 1413 |
!!!emit ($token); |
!!!emit ($self->{current_token}); # comment |
| 1414 |
|
|
| 1415 |
redo A; |
redo A; |
| 1416 |
} else { |
} else { |
| 1417 |
!!!cp (126); |
!!!cp (126); |
| 1418 |
$token->{data} .= chr ($self->{next_char}); |
$self->{current_token}->{data} .= chr ($self->{next_char}); # comment |
| 1419 |
!!!next-input-character; |
!!!next-input-character; |
| 1420 |
redo BC; |
redo BC; |
| 1421 |
} |
} |
| 1425 |
} elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) { |
} elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) { |
| 1426 |
## (only happen if PCDATA state) |
## (only happen if PCDATA state) |
| 1427 |
|
|
| 1428 |
|
my ($l, $c) = ($self->{line_prev}, $self->{column_prev} - 1); |
| 1429 |
|
|
| 1430 |
my @next_char; |
my @next_char; |
| 1431 |
push @next_char, $self->{next_char}; |
push @next_char, $self->{next_char}; |
| 1432 |
|
|
| 1435 |
push @next_char, $self->{next_char}; |
push @next_char, $self->{next_char}; |
| 1436 |
if ($self->{next_char} == 0x002D) { # - |
if ($self->{next_char} == 0x002D) { # - |
| 1437 |
!!!cp (127); |
!!!cp (127); |
| 1438 |
$self->{current_token} = {type => COMMENT_TOKEN, data => ''}; |
$self->{current_token} = {type => COMMENT_TOKEN, data => '', |
| 1439 |
|
line => $l, column => $c}; |
| 1440 |
$self->{state} = COMMENT_START_STATE; |
$self->{state} = COMMENT_START_STATE; |
| 1441 |
!!!next-input-character; |
!!!next-input-character; |
| 1442 |
redo A; |
redo A; |
| 1472 |
!!!cp (129); |
!!!cp (129); |
| 1473 |
## TODO: What a stupid code this is! |
## TODO: What a stupid code this is! |
| 1474 |
$self->{state} = DOCTYPE_STATE; |
$self->{state} = DOCTYPE_STATE; |
| 1475 |
|
$self->{current_token} = {type => DOCTYPE_TOKEN, |
| 1476 |
|
quirks => 1, |
| 1477 |
|
line => $l, column => $c}; |
| 1478 |
!!!next-input-character; |
!!!next-input-character; |
| 1479 |
redo A; |
redo A; |
| 1480 |
} else { |
} else { |
| 1503 |
$self->{next_char} = shift @next_char; |
$self->{next_char} = shift @next_char; |
| 1504 |
!!!back-next-input-character (@next_char); |
!!!back-next-input-character (@next_char); |
| 1505 |
$self->{state} = BOGUS_COMMENT_STATE; |
$self->{state} = BOGUS_COMMENT_STATE; |
| 1506 |
|
$self->{current_token} = {type => COMMENT_TOKEN, data => '', |
| 1507 |
|
line => $l, column => $c}; |
| 1508 |
redo A; |
redo A; |
| 1509 |
|
|
| 1510 |
## ISSUE: typos in spec: chacacters, is is a parse error |
## ISSUE: typos in spec: chacacters, is is a parse error |
| 1628 |
redo A; |
redo A; |
| 1629 |
} elsif ($self->{next_char} == 0x002D) { # - |
} elsif ($self->{next_char} == 0x002D) { # - |
| 1630 |
!!!cp (152); |
!!!cp (152); |
| 1631 |
!!!parse-error (type => 'dash in comment'); |
!!!parse-error (type => 'dash in comment', |
| 1632 |
|
line => $self->{line_prev}, |
| 1633 |
|
column => $self->{column_prev}); |
| 1634 |
$self->{current_token}->{data} .= '-'; # comment |
$self->{current_token}->{data} .= '-'; # comment |
| 1635 |
## Stay in the state |
## Stay in the state |
| 1636 |
!!!next-input-character; |
!!!next-input-character; |
| 1646 |
redo A; |
redo A; |
| 1647 |
} else { |
} else { |
| 1648 |
!!!cp (154); |
!!!cp (154); |
| 1649 |
!!!parse-error (type => 'dash in comment'); |
!!!parse-error (type => 'dash in comment', |
| 1650 |
|
line => $self->{line_prev}, |
| 1651 |
|
column => $self->{column_prev}); |
| 1652 |
$self->{current_token}->{data} .= '--' . chr ($self->{next_char}); # comment |
$self->{current_token}->{data} .= '--' . chr ($self->{next_char}); # comment |
| 1653 |
$self->{state} = COMMENT_STATE; |
$self->{state} = COMMENT_STATE; |
| 1654 |
!!!next-input-character; |
!!!next-input-character; |
| 1687 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 1688 |
!!!next-input-character; |
!!!next-input-character; |
| 1689 |
|
|
| 1690 |
!!!emit ({type => DOCTYPE_TOKEN, quirks => 1}); |
!!!emit ($self->{current_token}); # DOCTYPE (quirks) |
| 1691 |
|
|
| 1692 |
redo A; |
redo A; |
| 1693 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1696 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 1697 |
## reconsume |
## reconsume |
| 1698 |
|
|
| 1699 |
!!!emit ({type => DOCTYPE_TOKEN, quirks => 1}); |
!!!emit ($self->{current_token}); # DOCTYPE (quirks) |
| 1700 |
|
|
| 1701 |
redo A; |
redo A; |
| 1702 |
} else { |
} else { |
| 1703 |
!!!cp (160); |
!!!cp (160); |
| 1704 |
$self->{current_token} |
$self->{current_token}->{name} = chr $self->{next_char}; |
| 1705 |
= {type => DOCTYPE_TOKEN, |
delete $self->{current_token}->{quirks}; |
|
name => chr ($self->{next_char}), |
|
|
#quirks => 0, |
|
|
}; |
|
| 1706 |
## ISSUE: "Set the token's name name to the" in the spec |
## ISSUE: "Set the token's name name to the" in the spec |
| 1707 |
$self->{state} = DOCTYPE_NAME_STATE; |
$self->{state} = DOCTYPE_NAME_STATE; |
| 1708 |
!!!next-input-character; |
!!!next-input-character; |
| 2229 |
sub _tokenize_attempt_to_consume_an_entity ($$$) { |
sub _tokenize_attempt_to_consume_an_entity ($$$) { |
| 2230 |
my ($self, $in_attr, $additional) = @_; |
my ($self, $in_attr, $additional) = @_; |
| 2231 |
|
|
| 2232 |
|
my ($l, $c) = ($self->{line_prev}, $self->{column_prev}); |
| 2233 |
|
|
| 2234 |
if ({ |
if ({ |
| 2235 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, # HT, LF, VT, FF, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, # HT, LF, VT, FF, |
| 2236 |
0x0020 => 1, 0x003C => 1, 0x0026 => 1, -1 => 1, # SP, <, & # 0x000D # CR |
0x0020 => 1, 0x003C => 1, 0x0026 => 1, -1 => 1, # SP, <, & # 0x000D # CR |
| 2271 |
redo X; |
redo X; |
| 2272 |
} elsif (not defined $code) { # no hexadecimal digit |
} elsif (not defined $code) { # no hexadecimal digit |
| 2273 |
!!!cp (1005); |
!!!cp (1005); |
| 2274 |
!!!parse-error (type => 'bare hcro'); |
!!!parse-error (type => 'bare hcro', line => $l, column => $c); |
| 2275 |
!!!back-next-input-character ($x_char, $self->{next_char}); |
!!!back-next-input-character ($x_char, $self->{next_char}); |
| 2276 |
$self->{next_char} = 0x0023; # # |
$self->{next_char} = 0x0023; # # |
| 2277 |
return undef; |
return undef; |
| 2280 |
!!!next-input-character; |
!!!next-input-character; |
| 2281 |
} else { |
} else { |
| 2282 |
!!!cp (1007); |
!!!cp (1007); |
| 2283 |
!!!parse-error (type => 'no refc'); |
!!!parse-error (type => 'no refc', line => $l, column => $c); |
| 2284 |
} |
} |
| 2285 |
|
|
| 2286 |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
| 2287 |
!!!cp (1008); |
!!!cp (1008); |
| 2288 |
!!!parse-error (type => sprintf 'invalid character reference:U+%04X', $code); |
!!!parse-error (type => (sprintf 'invalid character reference:U+%04X', $code), line => $l, column => $c); |
| 2289 |
$code = 0xFFFD; |
$code = 0xFFFD; |
| 2290 |
} elsif ($code > 0x10FFFF) { |
} elsif ($code > 0x10FFFF) { |
| 2291 |
!!!cp (1009); |
!!!cp (1009); |
| 2292 |
!!!parse-error (type => sprintf 'invalid character reference:U-%08X', $code); |
!!!parse-error (type => (sprintf 'invalid character reference:U-%08X', $code), line => $l, column => $c); |
| 2293 |
$code = 0xFFFD; |
$code = 0xFFFD; |
| 2294 |
} elsif ($code == 0x000D) { |
} elsif ($code == 0x000D) { |
| 2295 |
!!!cp (1010); |
!!!cp (1010); |
| 2296 |
!!!parse-error (type => 'CR character reference'); |
!!!parse-error (type => 'CR character reference', line => $l, column => $c); |
| 2297 |
$code = 0x000A; |
$code = 0x000A; |
| 2298 |
} elsif (0x80 <= $code and $code <= 0x9F) { |
} elsif (0x80 <= $code and $code <= 0x9F) { |
| 2299 |
!!!cp (1011); |
!!!cp (1011); |
| 2300 |
!!!parse-error (type => sprintf 'C1 character reference:U+%04X', $code); |
!!!parse-error (type => (sprintf 'C1 character reference:U+%04X', $code), line => $l, column => $c); |
| 2301 |
$code = $c1_entity_char->{$code}; |
$code = $c1_entity_char->{$code}; |
| 2302 |
} |
} |
| 2303 |
|
|
| 2304 |
return {type => CHARACTER_TOKEN, data => chr $code, |
return {type => CHARACTER_TOKEN, data => chr $code, |
| 2305 |
has_reference => 1}; |
has_reference => 1, line => $l, column => $c}; |
| 2306 |
} # X |
} # X |
| 2307 |
} elsif (0x0030 <= $self->{next_char} and |
} elsif (0x0030 <= $self->{next_char} and |
| 2308 |
$self->{next_char} <= 0x0039) { # 0..9 |
$self->{next_char} <= 0x0039) { # 0..9 |
| 2323 |
!!!next-input-character; |
!!!next-input-character; |
| 2324 |
} else { |
} else { |
| 2325 |
!!!cp (1014); |
!!!cp (1014); |
| 2326 |
!!!parse-error (type => 'no refc'); |
!!!parse-error (type => 'no refc', line => $l, column => $c); |
| 2327 |
} |
} |
| 2328 |
|
|
| 2329 |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
| 2330 |
!!!cp (1015); |
!!!cp (1015); |
| 2331 |
!!!parse-error (type => sprintf 'invalid character reference:U+%04X', $code); |
!!!parse-error (type => (sprintf 'invalid character reference:U+%04X', $code), line => $l, column => $c); |
| 2332 |
$code = 0xFFFD; |
$code = 0xFFFD; |
| 2333 |
} elsif ($code > 0x10FFFF) { |
} elsif ($code > 0x10FFFF) { |
| 2334 |
!!!cp (1016); |
!!!cp (1016); |
| 2335 |
!!!parse-error (type => sprintf 'invalid character reference:U-%08X', $code); |
!!!parse-error (type => (sprintf 'invalid character reference:U-%08X', $code), line => $l, column => $c); |
| 2336 |
$code = 0xFFFD; |
$code = 0xFFFD; |
| 2337 |
} elsif ($code == 0x000D) { |
} elsif ($code == 0x000D) { |
| 2338 |
!!!cp (1017); |
!!!cp (1017); |
| 2339 |
!!!parse-error (type => 'CR character reference'); |
!!!parse-error (type => 'CR character reference', line => $l, column => $c); |
| 2340 |
$code = 0x000A; |
$code = 0x000A; |
| 2341 |
} elsif (0x80 <= $code and $code <= 0x9F) { |
} elsif (0x80 <= $code and $code <= 0x9F) { |
| 2342 |
!!!cp (1018); |
!!!cp (1018); |
| 2343 |
!!!parse-error (type => sprintf 'C1 character reference:U+%04X', $code); |
!!!parse-error (type => (sprintf 'C1 character reference:U+%04X', $code), line => $l, column => $c); |
| 2344 |
$code = $c1_entity_char->{$code}; |
$code = $c1_entity_char->{$code}; |
| 2345 |
} |
} |
| 2346 |
|
|
| 2347 |
return {type => CHARACTER_TOKEN, data => chr $code, has_reference => 1}; |
return {type => CHARACTER_TOKEN, data => chr $code, has_reference => 1, |
| 2348 |
|
line => $l, column => $c}; |
| 2349 |
} else { |
} else { |
| 2350 |
!!!cp (1019); |
!!!cp (1019); |
| 2351 |
!!!parse-error (type => 'bare nero'); |
!!!parse-error (type => 'bare nero', line => $l, column => $c); |
| 2352 |
!!!back-next-input-character ($self->{next_char}); |
!!!back-next-input-character ($self->{next_char}); |
| 2353 |
$self->{next_char} = 0x0023; # # |
$self->{next_char} = 0x0023; # # |
| 2354 |
return undef; |
return undef; |
| 2398 |
|
|
| 2399 |
if ($match > 0) { |
if ($match > 0) { |
| 2400 |
!!!cp (1023); |
!!!cp (1023); |
| 2401 |
return {type => CHARACTER_TOKEN, data => $value, has_reference => 1}; |
return {type => CHARACTER_TOKEN, data => $value, has_reference => 1, |
| 2402 |
|
line => $l, column => $c}; |
| 2403 |
} elsif ($match < 0) { |
} elsif ($match < 0) { |
| 2404 |
!!!parse-error (type => 'no refc'); |
!!!parse-error (type => 'no refc', line => $l, column => $c); |
| 2405 |
if ($in_attr and $match < -1) { |
if ($in_attr and $match < -1) { |
| 2406 |
!!!cp (1024); |
!!!cp (1024); |
| 2407 |
return {type => CHARACTER_TOKEN, data => '&'.$entity_name}; |
return {type => CHARACTER_TOKEN, data => '&'.$entity_name, |
| 2408 |
|
line => $l, column => $c}; |
| 2409 |
} else { |
} else { |
| 2410 |
!!!cp (1025); |
!!!cp (1025); |
| 2411 |
return {type => CHARACTER_TOKEN, data => $value, has_reference => 1}; |
return {type => CHARACTER_TOKEN, data => $value, has_reference => 1, |
| 2412 |
|
line => $l, column => $c}; |
| 2413 |
} |
} |
| 2414 |
} else { |
} else { |
| 2415 |
!!!cp (1026); |
!!!cp (1026); |
| 2416 |
!!!parse-error (type => 'bare ero'); |
!!!parse-error (type => 'bare ero', line => $l, column => $c); |
| 2417 |
## NOTE: "No characters are consumed" in the spec. |
## NOTE: "No characters are consumed" in the spec. |
| 2418 |
return {type => CHARACTER_TOKEN, data => '&'.$value}; |
return {type => CHARACTER_TOKEN, data => '&'.$value, |
| 2419 |
|
line => $l, column => $c}; |
| 2420 |
} |
} |
| 2421 |
} else { |
} else { |
| 2422 |
!!!cp (1027); |
!!!cp (1027); |
| 2423 |
## no characters are consumed |
## no characters are consumed |
| 2424 |
!!!parse-error (type => 'bare ero'); |
!!!parse-error (type => 'bare ero', line => $l, column => $c); |
| 2425 |
return undef; |
return undef; |
| 2426 |
} |
} |
| 2427 |
} # _tokenize_attempt_to_consume_an_entity |
} # _tokenize_attempt_to_consume_an_entity |
| 2492 |
defined $token->{public_identifier} or |
defined $token->{public_identifier} or |
| 2493 |
defined $token->{system_identifier}) { |
defined $token->{system_identifier}) { |
| 2494 |
!!!cp ('t1'); |
!!!cp ('t1'); |
| 2495 |
!!!parse-error (type => 'not HTML5'); |
!!!parse-error (type => 'not HTML5', token => $token); |
| 2496 |
} elsif ($doctype_name ne 'HTML') { |
} elsif ($doctype_name ne 'HTML') { |
| 2497 |
!!!cp ('t2'); |
!!!cp ('t2'); |
| 2498 |
## ISSUE: ASCII case-insensitive? (in fact it does not matter) |
## ISSUE: ASCII case-insensitive? (in fact it does not matter) |
| 2499 |
!!!parse-error (type => 'not HTML5'); |
!!!parse-error (type => 'not HTML5', token => $token); |
| 2500 |
} else { |
} else { |
| 2501 |
!!!cp ('t3'); |
!!!cp ('t3'); |
| 2502 |
} |
} |
| 2635 |
END_OF_FILE_TOKEN, 1, |
END_OF_FILE_TOKEN, 1, |
| 2636 |
}->{$token->{type}}) { |
}->{$token->{type}}) { |
| 2637 |
!!!cp ('t14'); |
!!!cp ('t14'); |
| 2638 |
!!!parse-error (type => 'no DOCTYPE'); |
!!!parse-error (type => 'no DOCTYPE', token => $token); |
| 2639 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
| 2640 |
## Go to the "before html" insertion mode. |
## Go to the "before html" insertion mode. |
| 2641 |
## reprocess |
## reprocess |
| 2656 |
!!!cp ('t17'); |
!!!cp ('t17'); |
| 2657 |
} |
} |
| 2658 |
|
|
| 2659 |
!!!parse-error (type => 'no DOCTYPE'); |
!!!parse-error (type => 'no DOCTYPE', token => $token); |
| 2660 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
| 2661 |
## Go to the "before html" insertion mode. |
## Go to the "before html" insertion mode. |
| 2662 |
## reprocess |
## reprocess |
| 2685 |
B: { |
B: { |
| 2686 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
| 2687 |
!!!cp ('t19'); |
!!!cp ('t19'); |
| 2688 |
!!!parse-error (type => 'in html:#DOCTYPE'); |
!!!parse-error (type => 'in html:#DOCTYPE', token => $token); |
| 2689 |
## Ignore the token |
## Ignore the token |
| 2690 |
## Stay in the insertion mode. |
## Stay in the insertion mode. |
| 2691 |
!!!next-token; |
!!!next-token; |
| 2719 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 2720 |
if ($token->{tag_name} eq 'html') { |
if ($token->{tag_name} eq 'html') { |
| 2721 |
my $root_element; |
my $root_element; |
| 2722 |
!!!create-element ($root_element, $token->{tag_name}, $token->{attributes}); |
!!!create-element ($root_element, $token->{tag_name}, $token->{attributes}, $token); |
| 2723 |
$self->{document}->append_child ($root_element); |
$self->{document}->append_child ($root_element); |
| 2724 |
push @{$self->{open_elements}}, [$root_element, 'html']; |
push @{$self->{open_elements}}, [$root_element, 'html']; |
| 2725 |
|
|
| 2749 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 2750 |
} |
} |
| 2751 |
|
|
| 2752 |
my $root_element; !!!create-element ($root_element, 'html'); |
my $root_element; !!!create-element ($root_element, 'html',, $token); |
| 2753 |
$self->{document}->append_child ($root_element); |
$self->{document}->append_child ($root_element); |
| 2754 |
push @{$self->{open_elements}}, [$root_element, 'html']; |
push @{$self->{open_elements}}, [$root_element, 'html']; |
| 2755 |
|
|
| 2776 |
|
|
| 2777 |
## Step 3 |
## Step 3 |
| 2778 |
S3: { |
S3: { |
|
## ISSUE: Oops! "If node is the first node in the stack of open |
|
|
## elements, then set last to true. If the context element of the |
|
|
## HTML fragment parsing algorithm is neither a td element nor a |
|
|
## th element, then set node to the context element. (fragment case)": |
|
|
## The second "if" is in the scope of the first "if"!? |
|
| 2779 |
if ($self->{open_elements}->[0]->[0] eq $node->[0]) { |
if ($self->{open_elements}->[0]->[0] eq $node->[0]) { |
| 2780 |
$last = 1; |
$last = 1; |
| 2781 |
if (defined $self->{inner_html_node}) { |
if (defined $self->{inner_html_node}) { |
| 2936 |
!!!cp ('t39'); |
!!!cp ('t39'); |
| 2937 |
}; # $clear_up_to_marker |
}; # $clear_up_to_marker |
| 2938 |
|
|
| 2939 |
my $parse_rcdata = sub ($$) { |
my $insert; |
| 2940 |
my ($content_model_flag, $insert) = @_; |
|
| 2941 |
|
my $parse_rcdata = sub ($) { |
| 2942 |
|
my ($content_model_flag) = @_; |
| 2943 |
|
|
| 2944 |
## Step 1 |
## Step 1 |
| 2945 |
my $start_tag_name = $token->{tag_name}; |
my $start_tag_name = $token->{tag_name}; |
| 2946 |
my $el; |
my $el; |
| 2947 |
!!!create-element ($el, $start_tag_name, $token->{attributes}); |
!!!create-element ($el, $start_tag_name, $token->{attributes}, $token); |
| 2948 |
|
|
| 2949 |
## Step 2 |
## Step 2 |
| 2950 |
$insert->($el); # /context node/->append_child ($el) |
$insert->($el); |
| 2951 |
|
|
| 2952 |
## Step 3 |
## Step 3 |
| 2953 |
$self->{content_model} = $content_model_flag; # CDATA or RCDATA |
$self->{content_model} = $content_model_flag; # CDATA or RCDATA |
| 2977 |
$token->{tag_name} eq $start_tag_name) { |
$token->{tag_name} eq $start_tag_name) { |
| 2978 |
!!!cp ('t42'); |
!!!cp ('t42'); |
| 2979 |
## Ignore the token |
## Ignore the token |
|
} elsif ($content_model_flag == CDATA_CONTENT_MODEL) { |
|
|
!!!cp ('t43'); |
|
|
!!!parse-error (type => 'in CDATA:#'.$token->{type}); |
|
|
} elsif ($content_model_flag == RCDATA_CONTENT_MODEL) { |
|
|
!!!cp ('t44'); |
|
|
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
|
| 2980 |
} else { |
} else { |
| 2981 |
die "$0: $content_model_flag in parse_rcdata"; |
## NOTE: An end-of-file token. |
| 2982 |
|
if ($content_model_flag == CDATA_CONTENT_MODEL) { |
| 2983 |
|
!!!cp ('t43'); |
| 2984 |
|
!!!parse-error (type => 'in CDATA:#'.$token->{type}, token => $token); |
| 2985 |
|
} elsif ($content_model_flag == RCDATA_CONTENT_MODEL) { |
| 2986 |
|
!!!cp ('t44'); |
| 2987 |
|
!!!parse-error (type => 'in RCDATA:#'.$token->{type}, token => $token); |
| 2988 |
|
} else { |
| 2989 |
|
die "$0: $content_model_flag in parse_rcdata"; |
| 2990 |
|
} |
| 2991 |
} |
} |
| 2992 |
!!!next-token; |
!!!next-token; |
| 2993 |
}; # $parse_rcdata |
}; # $parse_rcdata |
| 2994 |
|
|
| 2995 |
my $script_start_tag = sub ($) { |
my $script_start_tag = sub () { |
|
my $insert = $_[0]; |
|
| 2996 |
my $script_el; |
my $script_el; |
| 2997 |
!!!create-element ($script_el, 'script', $token->{attributes}); |
!!!create-element ($script_el, 'script', $token->{attributes}, $token); |
| 2998 |
## TODO: mark as "parser-inserted" |
## TODO: mark as "parser-inserted" |
| 2999 |
|
|
| 3000 |
$self->{content_model} = CDATA_CONTENT_MODEL; |
$self->{content_model} = CDATA_CONTENT_MODEL; |
| 3020 |
## Ignore the token |
## Ignore the token |
| 3021 |
} else { |
} else { |
| 3022 |
!!!cp ('t48'); |
!!!cp ('t48'); |
| 3023 |
!!!parse-error (type => 'in CDATA:#'.$token->{type}); |
!!!parse-error (type => 'in CDATA:#'.$token->{type}, token => $token); |
| 3024 |
## ISSUE: And ignore? |
## ISSUE: And ignore? |
| 3025 |
## TODO: mark as "already executed" |
## TODO: mark as "already executed" |
| 3026 |
} |
} |
| 3043 |
!!!next-token; |
!!!next-token; |
| 3044 |
}; # $script_start_tag |
}; # $script_start_tag |
| 3045 |
|
|
| 3046 |
|
## NOTE: $open_tables->[-1]->[0] is the "current table" element node. |
| 3047 |
|
## NOTE: $open_tables->[-1]->[1] is the "tainted" flag. |
| 3048 |
|
my $open_tables = [[$self->{open_elements}->[0]->[0]]]; |
| 3049 |
|
|
| 3050 |
my $formatting_end_tag = sub { |
my $formatting_end_tag = sub { |
| 3051 |
my $tag_name = shift; |
my $end_tag_token = shift; |
| 3052 |
|
my $tag_name = $end_tag_token->{tag_name}; |
| 3053 |
|
|
| 3054 |
|
## NOTE: The adoption agency algorithm (AAA). |
| 3055 |
|
|
| 3056 |
FET: { |
FET: { |
| 3057 |
## Step 1 |
## Step 1 |
| 3070 |
} # AFE |
} # AFE |
| 3071 |
unless (defined $formatting_element) { |
unless (defined $formatting_element) { |
| 3072 |
!!!cp ('t53'); |
!!!cp ('t53'); |
| 3073 |
!!!parse-error (type => 'unmatched end tag:'.$tag_name); |
!!!parse-error (type => 'unmatched end tag:'.$tag_name, token => $end_tag_token); |
| 3074 |
## Ignore the token |
## Ignore the token |
| 3075 |
!!!next-token; |
!!!next-token; |
| 3076 |
return; |
return; |
| 3087 |
last INSCOPE; |
last INSCOPE; |
| 3088 |
} else { # in open elements but not in scope |
} else { # in open elements but not in scope |
| 3089 |
!!!cp ('t55'); |
!!!cp ('t55'); |
| 3090 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, |
| 3091 |
|
token => $end_tag_token); |
| 3092 |
## Ignore the token |
## Ignore the token |
| 3093 |
!!!next-token; |
!!!next-token; |
| 3094 |
return; |
return; |
| 3095 |
} |
} |
| 3096 |
} elsif ({ |
} elsif ({ |
| 3097 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 3098 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 3099 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 3100 |
!!!cp ('t56'); |
!!!cp ('t56'); |
| 3103 |
} # INSCOPE |
} # INSCOPE |
| 3104 |
unless (defined $formatting_element_i_in_open) { |
unless (defined $formatting_element_i_in_open) { |
| 3105 |
!!!cp ('t57'); |
!!!cp ('t57'); |
| 3106 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, |
| 3107 |
|
token => $end_tag_token); |
| 3108 |
pop @$active_formatting_elements; # $formatting_element |
pop @$active_formatting_elements; # $formatting_element |
| 3109 |
!!!next-token; ## TODO: ok? |
!!!next-token; ## TODO: ok? |
| 3110 |
return; |
return; |
| 3111 |
} |
} |
| 3112 |
if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) { |
if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) { |
| 3113 |
!!!cp ('t58'); |
!!!cp ('t58'); |
| 3114 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], |
| 3115 |
|
token => $end_tag_token); |
| 3116 |
} |
} |
| 3117 |
|
|
| 3118 |
## Step 2 |
## Step 2 |
| 3123 |
if (not $formatting_category->{$node->[1]} and |
if (not $formatting_category->{$node->[1]} and |
| 3124 |
#not $phrasing_category->{$node->[1]} and |
#not $phrasing_category->{$node->[1]} and |
| 3125 |
($special_category->{$node->[1]} or |
($special_category->{$node->[1]} or |
| 3126 |
$scoping_category->{$node->[1]})) { |
$scoping_category->{$node->[1]})) { ## Scoping is redundant, maybe |
| 3127 |
!!!cp ('t59'); |
!!!cp ('t59'); |
| 3128 |
$furthest_block = $node; |
$furthest_block = $node; |
| 3129 |
$furthest_block_i_in_open = $_; |
$furthest_block_i_in_open = $_; |
| 3209 |
} # S7 |
} # S7 |
| 3210 |
|
|
| 3211 |
## Step 8 |
## Step 8 |
| 3212 |
$common_ancestor_node->[0]->append_child ($last_node->[0]); |
if ({ |
| 3213 |
|
table => 1, tbody => 1, tfoot => 1, thead => 1, tr => 1, |
| 3214 |
|
}->{$common_ancestor_node->[1]}) { |
| 3215 |
|
my $foster_parent_element; |
| 3216 |
|
my $next_sibling; |
| 3217 |
|
OE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3218 |
|
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
| 3219 |
|
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
| 3220 |
|
if (defined $parent and $parent->node_type == 1) { |
| 3221 |
|
!!!cp ('t65.1'); |
| 3222 |
|
$foster_parent_element = $parent; |
| 3223 |
|
$next_sibling = $self->{open_elements}->[$_]->[0]; |
| 3224 |
|
} else { |
| 3225 |
|
!!!cp ('t65.2'); |
| 3226 |
|
$foster_parent_element |
| 3227 |
|
= $self->{open_elements}->[$_ - 1]->[0]; |
| 3228 |
|
} |
| 3229 |
|
last OE; |
| 3230 |
|
} |
| 3231 |
|
} # OE |
| 3232 |
|
$foster_parent_element = $self->{open_elements}->[0]->[0] |
| 3233 |
|
unless defined $foster_parent_element; |
| 3234 |
|
$foster_parent_element->insert_before ($last_node->[0], $next_sibling); |
| 3235 |
|
$open_tables->[-1]->[1] = 1; # tainted |
| 3236 |
|
} else { |
| 3237 |
|
!!!cp ('t65.3'); |
| 3238 |
|
$common_ancestor_node->[0]->append_child ($last_node->[0]); |
| 3239 |
|
} |
| 3240 |
|
|
| 3241 |
## Step 9 |
## Step 9 |
| 3242 |
my $clone = [$formatting_element->[0]->clone_node (0), |
my $clone = [$formatting_element->[0]->clone_node (0), |
| 3282 |
} # FET |
} # FET |
| 3283 |
}; # $formatting_end_tag |
}; # $formatting_end_tag |
| 3284 |
|
|
| 3285 |
my $insert_to_current = sub { |
$insert = my $insert_to_current = sub { |
| 3286 |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
| 3287 |
}; # $insert_to_current |
}; # $insert_to_current |
| 3288 |
|
|
| 3289 |
my $insert_to_foster = sub { |
my $insert_to_foster = sub { |
| 3290 |
my $child = shift; |
my $child = shift; |
| 3291 |
if ({ |
if ({ |
| 3292 |
table => 1, tbody => 1, tfoot => 1, |
table => 1, tbody => 1, tfoot => 1, thead => 1, tr => 1, |
| 3293 |
thead => 1, tr => 1, |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3294 |
}->{$self->{open_elements}->[-1]->[1]}) { |
# MUST |
| 3295 |
# MUST |
my $foster_parent_element; |
| 3296 |
my $foster_parent_element; |
my $next_sibling; |
|
my $next_sibling; |
|
| 3297 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3298 |
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
| 3299 |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
| 3313 |
unless defined $foster_parent_element; |
unless defined $foster_parent_element; |
| 3314 |
$foster_parent_element->insert_before |
$foster_parent_element->insert_before |
| 3315 |
($child, $next_sibling); |
($child, $next_sibling); |
| 3316 |
} else { |
$open_tables->[-1]->[1] = 1; # tainted |
| 3317 |
!!!cp ('t72'); |
} else { |
| 3318 |
$self->{open_elements}->[-1]->[0]->append_child ($child); |
!!!cp ('t72'); |
| 3319 |
} |
$self->{open_elements}->[-1]->[0]->append_child ($child); |
| 3320 |
|
} |
| 3321 |
}; # $insert_to_foster |
}; # $insert_to_foster |
| 3322 |
|
|
|
my $insert; |
|
|
|
|
| 3323 |
B: { |
B: { |
| 3324 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
| 3325 |
!!!cp ('t73'); |
!!!cp ('t73'); |
| 3326 |
!!!parse-error (type => 'DOCTYPE in the middle'); |
!!!parse-error (type => 'DOCTYPE in the middle', token => $token); |
| 3327 |
## Ignore the token |
## Ignore the token |
| 3328 |
## Stay in the phase |
## Stay in the phase |
| 3329 |
!!!next-token; |
!!!next-token; |
| 3330 |
redo B; |
redo B; |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
|
|
if ($self->{insertion_mode} & AFTER_HTML_IMS) { |
|
|
!!!cp ('t74'); |
|
|
# |
|
|
} else { |
|
|
## 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]}) { |
|
|
!!!cp ('t75'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, tag_name => $self->{open_elements}->[-1]->[1]}; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
if (@{$self->{open_elements}} > 2 or |
|
|
(@{$self->{open_elements}} == 2 and $self->{open_elements}->[1]->[1] ne 'body')) { |
|
|
!!!cp ('t76'); |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} elsif (defined $self->{inner_html_node} and |
|
|
@{$self->{open_elements}} > 1 and |
|
|
$self->{open_elements}->[1]->[1] ne 'body') { |
|
|
## ISSUE: This case is never reached. |
|
|
!!!cp ('t77'); |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} else { |
|
|
!!!cp ('t78'); |
|
|
} |
|
|
|
|
|
## ISSUE: There is an issue in the spec. |
|
|
} |
|
|
|
|
|
## Stop parsing |
|
|
last B; |
|
| 3331 |
} elsif ($token->{type} == START_TAG_TOKEN and |
} elsif ($token->{type} == START_TAG_TOKEN and |
| 3332 |
$token->{tag_name} eq 'html') { |
$token->{tag_name} eq 'html') { |
| 3333 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 3334 |
!!!cp ('t79'); |
!!!cp ('t79'); |
| 3335 |
!!!parse-error (type => 'after html:html'); |
!!!parse-error (type => 'after html:html', token => $token); |
| 3336 |
$self->{insertion_mode} = AFTER_BODY_IM; |
$self->{insertion_mode} = AFTER_BODY_IM; |
| 3337 |
} elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
| 3338 |
!!!cp ('t80'); |
!!!cp ('t80'); |
| 3339 |
!!!parse-error (type => 'after html:html'); |
!!!parse-error (type => 'after html:html', token => $token); |
| 3340 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 3341 |
} else { |
} else { |
| 3342 |
!!!cp ('t81'); |
!!!cp ('t81'); |
| 3343 |
} |
} |
| 3344 |
|
|
| 3345 |
!!!cp ('t82'); |
!!!cp ('t82'); |
| 3346 |
!!!parse-error (type => 'not first start tag'); |
!!!parse-error (type => 'not first start tag', token => $token); |
| 3347 |
my $top_el = $self->{open_elements}->[0]->[0]; |
my $top_el = $self->{open_elements}->[0]->[0]; |
| 3348 |
for my $attr_name (keys %{$token->{attributes}}) { |
for my $attr_name (keys %{$token->{attributes}}) { |
| 3349 |
unless ($top_el->has_attribute_ns (undef, $attr_name)) { |
unless ($top_el->has_attribute_ns (undef, $attr_name)) { |
| 3372 |
} elsif ($self->{insertion_mode} & HEAD_IMS) { |
} elsif ($self->{insertion_mode} & HEAD_IMS) { |
| 3373 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 3374 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 3375 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
unless ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3376 |
|
!!!cp ('t88.2'); |
| 3377 |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 3378 |
|
} else { |
| 3379 |
|
!!!cp ('t88.1'); |
| 3380 |
|
## Ignore the token. |
| 3381 |
|
!!!next-token; |
| 3382 |
|
redo B; |
| 3383 |
|
} |
| 3384 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 3385 |
!!!cp ('t88'); |
!!!cp ('t88'); |
| 3386 |
!!!next-token; |
!!!next-token; |
| 3391 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3392 |
!!!cp ('t89'); |
!!!cp ('t89'); |
| 3393 |
## As if <head> |
## As if <head> |
| 3394 |
!!!create-element ($self->{head_element}, 'head'); |
!!!create-element ($self->{head_element}, 'head',, $token); |
| 3395 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3396 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3397 |
|
|
| 3403 |
!!!cp ('t90'); |
!!!cp ('t90'); |
| 3404 |
## As if </noscript> |
## As if </noscript> |
| 3405 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3406 |
!!!parse-error (type => 'in noscript:#character'); |
!!!parse-error (type => 'in noscript:#character', token => $token); |
| 3407 |
|
|
| 3408 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3409 |
## As if </head> |
## As if </head> |
| 3421 |
|
|
| 3422 |
## "after head" insertion mode |
## "after head" insertion mode |
| 3423 |
## As if <body> |
## As if <body> |
| 3424 |
!!!insert-element ('body'); |
!!!insert-element ('body',, $token); |
| 3425 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 3426 |
## reprocess |
## reprocess |
| 3427 |
redo B; |
redo B; |
| 3429 |
if ($token->{tag_name} eq 'head') { |
if ($token->{tag_name} eq 'head') { |
| 3430 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3431 |
!!!cp ('t93'); |
!!!cp ('t93'); |
| 3432 |
!!!create-element ($self->{head_element}, $token->{tag_name}, $token->{attributes}); |
!!!create-element ($self->{head_element}, $token->{tag_name}, $token->{attributes}, $token); |
| 3433 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3434 |
push @{$self->{open_elements}}, [$self->{head_element}, $token->{tag_name}]; |
push @{$self->{open_elements}}, [$self->{head_element}, $token->{tag_name}]; |
| 3435 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 3440 |
# |
# |
| 3441 |
} else { |
} else { |
| 3442 |
!!!cp ('t95'); |
!!!cp ('t95'); |
| 3443 |
!!!parse-error (type => 'in head:head'); # or in head noscript |
!!!parse-error (type => 'in head:head', token => $token); # or in head noscript |
| 3444 |
## Ignore the token |
## Ignore the token |
| 3445 |
!!!next-token; |
!!!next-token; |
| 3446 |
redo B; |
redo B; |
| 3448 |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3449 |
!!!cp ('t96'); |
!!!cp ('t96'); |
| 3450 |
## As if <head> |
## As if <head> |
| 3451 |
!!!create-element ($self->{head_element}, 'head'); |
!!!create-element ($self->{head_element}, 'head',, $token); |
| 3452 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3453 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3454 |
|
|
| 3463 |
!!!cp ('t98'); |
!!!cp ('t98'); |
| 3464 |
## As if </noscript> |
## As if </noscript> |
| 3465 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3466 |
!!!parse-error (type => 'in noscript:base'); |
!!!parse-error (type => 'in noscript:base', token => $token); |
| 3467 |
|
|
| 3468 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 3469 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3474 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3475 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 3476 |
!!!cp ('t100'); |
!!!cp ('t100'); |
| 3477 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 3478 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3479 |
} else { |
} else { |
| 3480 |
!!!cp ('t101'); |
!!!cp ('t101'); |
| 3481 |
} |
} |
| 3482 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 3483 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 3484 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3485 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3486 |
!!!next-token; |
!!!next-token; |
| 3487 |
redo B; |
redo B; |
| 3489 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3490 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 3491 |
!!!cp ('t102'); |
!!!cp ('t102'); |
| 3492 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 3493 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3494 |
} else { |
} else { |
| 3495 |
!!!cp ('t103'); |
!!!cp ('t103'); |
| 3496 |
} |
} |
| 3497 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 3498 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 3499 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3500 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3501 |
!!!next-token; |
!!!next-token; |
| 3502 |
redo B; |
redo B; |
| 3504 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3505 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 3506 |
!!!cp ('t104'); |
!!!cp ('t104'); |
| 3507 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 3508 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3509 |
} else { |
} else { |
| 3510 |
!!!cp ('t105'); |
!!!cp ('t105'); |
| 3511 |
} |
} |
| 3512 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 3513 |
my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 3514 |
|
|
| 3515 |
unless ($self->{confident}) { |
unless ($self->{confident}) { |
| 3516 |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
| 3517 |
!!!cp ('t106'); |
!!!cp ('t106'); |
| 3518 |
$self->{change_encoding} |
$self->{change_encoding} |
| 3519 |
->($self, $token->{attributes}->{charset}->{value}); |
->($self, $token->{attributes}->{charset}->{value}, |
| 3520 |
|
$token); |
| 3521 |
|
|
| 3522 |
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
| 3523 |
->set_user_data (manakai_has_reference => |
->set_user_data (manakai_has_reference => |
| 3532 |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
| 3533 |
!!!cp ('t107'); |
!!!cp ('t107'); |
| 3534 |
$self->{change_encoding} |
$self->{change_encoding} |
| 3535 |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3); |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3, |
| 3536 |
|
$token); |
| 3537 |
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
| 3538 |
->set_user_data (manakai_has_reference => |
->set_user_data (manakai_has_reference => |
| 3539 |
$token->{attributes}->{content} |
$token->{attributes}->{content} |
| 3559 |
} |
} |
| 3560 |
} |
} |
| 3561 |
|
|
| 3562 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3563 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3564 |
!!!next-token; |
!!!next-token; |
| 3565 |
redo B; |
redo B; |
| 3568 |
!!!cp ('t111'); |
!!!cp ('t111'); |
| 3569 |
## As if </noscript> |
## As if </noscript> |
| 3570 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3571 |
!!!parse-error (type => 'in noscript:title'); |
!!!parse-error (type => 'in noscript:title', token => $token); |
| 3572 |
|
|
| 3573 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 3574 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3575 |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 3576 |
!!!cp ('t112'); |
!!!cp ('t112'); |
| 3577 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 3578 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3579 |
} else { |
} else { |
| 3580 |
!!!cp ('t113'); |
!!!cp ('t113'); |
| 3583 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3584 |
my $parent = defined $self->{head_element} ? $self->{head_element} |
my $parent = defined $self->{head_element} ? $self->{head_element} |
| 3585 |
: $self->{open_elements}->[-1]->[0]; |
: $self->{open_elements}->[-1]->[0]; |
| 3586 |
$parse_rcdata->(RCDATA_CONTENT_MODEL, |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
| 3587 |
sub { $parent->append_child ($_[0]) }); |
pop @{$self->{open_elements}} # <head> |
|
pop @{$self->{open_elements}} |
|
| 3588 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3589 |
redo B; |
redo B; |
| 3590 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 3593 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3594 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 3595 |
!!!cp ('t114'); |
!!!cp ('t114'); |
| 3596 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 3597 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3598 |
} else { |
} else { |
| 3599 |
!!!cp ('t115'); |
!!!cp ('t115'); |
| 3600 |
} |
} |
| 3601 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 3602 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3603 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3604 |
redo B; |
redo B; |
| 3605 |
} elsif ($token->{tag_name} eq 'noscript') { |
} elsif ($token->{tag_name} eq 'noscript') { |
| 3606 |
if ($self->{insertion_mode} == IN_HEAD_IM) { |
if ($self->{insertion_mode} == IN_HEAD_IM) { |
| 3607 |
!!!cp ('t116'); |
!!!cp ('t116'); |
| 3608 |
## NOTE: and scripting is disalbed |
## NOTE: and scripting is disalbed |
| 3609 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 3610 |
$self->{insertion_mode} = IN_HEAD_NOSCRIPT_IM; |
$self->{insertion_mode} = IN_HEAD_NOSCRIPT_IM; |
| 3611 |
!!!next-token; |
!!!next-token; |
| 3612 |
redo B; |
redo B; |
| 3613 |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 3614 |
!!!cp ('t117'); |
!!!cp ('t117'); |
| 3615 |
!!!parse-error (type => 'in noscript:noscript'); |
!!!parse-error (type => 'in noscript:noscript', token => $token); |
| 3616 |
## Ignore the token |
## Ignore the token |
| 3617 |
!!!next-token; |
!!!next-token; |
| 3618 |
redo B; |
redo B; |
| 3625 |
!!!cp ('t119'); |
!!!cp ('t119'); |
| 3626 |
## As if </noscript> |
## As if </noscript> |
| 3627 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3628 |
!!!parse-error (type => 'in noscript:script'); |
!!!parse-error (type => 'in noscript:script', token => $token); |
| 3629 |
|
|
| 3630 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 3631 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3632 |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 3633 |
!!!cp ('t120'); |
!!!cp ('t120'); |
| 3634 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 3635 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3636 |
} else { |
} else { |
| 3637 |
!!!cp ('t121'); |
!!!cp ('t121'); |
| 3638 |
} |
} |
| 3639 |
|
|
| 3640 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3641 |
$script_start_tag->($insert_to_current); |
$script_start_tag->(); |
| 3642 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3643 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3644 |
redo B; |
redo B; |
| 3645 |
} elsif ($token->{tag_name} eq 'body' or |
} elsif ($token->{tag_name} eq 'body' or |
| 3648 |
!!!cp ('t122'); |
!!!cp ('t122'); |
| 3649 |
## As if </noscript> |
## As if </noscript> |
| 3650 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3651 |
!!!parse-error (type => 'in noscript:'.$token->{tag_name}); |
!!!parse-error (type => 'in noscript:'.$token->{tag_name}, token => $token); |
| 3652 |
|
|
| 3653 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3654 |
## As if </head> |
## As if </head> |
| 3665 |
} |
} |
| 3666 |
|
|
| 3667 |
## "after head" insertion mode |
## "after head" insertion mode |
| 3668 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 3669 |
if ($token->{tag_name} eq 'body') { |
if ($token->{tag_name} eq 'body') { |
| 3670 |
!!!cp ('t126'); |
!!!cp ('t126'); |
| 3671 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 3686 |
!!!cp ('t129'); |
!!!cp ('t129'); |
| 3687 |
## As if </noscript> |
## As if </noscript> |
| 3688 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3689 |
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}); |
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}, token => $token); |
| 3690 |
|
|
| 3691 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3692 |
## As if </head> |
## As if </head> |
| 3705 |
|
|
| 3706 |
## "after head" insertion mode |
## "after head" insertion mode |
| 3707 |
## As if <body> |
## As if <body> |
| 3708 |
!!!insert-element ('body'); |
!!!insert-element ('body',, $token); |
| 3709 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 3710 |
## reprocess |
## reprocess |
| 3711 |
redo B; |
redo B; |
| 3714 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3715 |
!!!cp ('t132'); |
!!!cp ('t132'); |
| 3716 |
## As if <head> |
## As if <head> |
| 3717 |
!!!create-element ($self->{head_element}, 'head'); |
!!!create-element ($self->{head_element}, 'head',, $token); |
| 3718 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3719 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3720 |
|
|
| 3727 |
!!!cp ('t133'); |
!!!cp ('t133'); |
| 3728 |
## As if </noscript> |
## As if </noscript> |
| 3729 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3730 |
!!!parse-error (type => 'in noscript:/head'); |
!!!parse-error (type => 'in noscript:/head', token => $token); |
| 3731 |
|
|
| 3732 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3733 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3753 |
redo B; |
redo B; |
| 3754 |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3755 |
!!!cp ('t137'); |
!!!cp ('t137'); |
| 3756 |
!!!parse-error (type => 'unmatched end tag:noscript'); |
!!!parse-error (type => 'unmatched end tag:noscript', token => $token); |
| 3757 |
## Ignore the token ## ISSUE: An issue in the spec. |
## Ignore the token ## ISSUE: An issue in the spec. |
| 3758 |
!!!next-token; |
!!!next-token; |
| 3759 |
redo B; |
redo B; |
| 3767 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3768 |
!!!cp ('t139'); |
!!!cp ('t139'); |
| 3769 |
## As if <head> |
## As if <head> |
| 3770 |
!!!create-element ($self->{head_element}, 'head'); |
!!!create-element ($self->{head_element}, 'head',, $token); |
| 3771 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3772 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3773 |
|
|
| 3775 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3776 |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 3777 |
!!!cp ('t140'); |
!!!cp ('t140'); |
| 3778 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 3779 |
## Ignore the token |
## Ignore the token |
| 3780 |
!!!next-token; |
!!!next-token; |
| 3781 |
redo B; |
redo B; |
| 3790 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3791 |
!!!cp ('t142'); |
!!!cp ('t142'); |
| 3792 |
## As if <head> |
## As if <head> |
| 3793 |
!!!create-element ($self->{head_element}, 'head'); |
!!!create-element ($self->{head_element}, 'head',, $token); |
| 3794 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3795 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3796 |
|
|
| 3807 |
# |
# |
| 3808 |
} else { |
} else { |
| 3809 |
!!!cp ('t145'); |
!!!cp ('t145'); |
| 3810 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 3811 |
## Ignore the token |
## Ignore the token |
| 3812 |
!!!next-token; |
!!!next-token; |
| 3813 |
redo B; |
redo B; |
| 3818 |
!!!cp ('t146'); |
!!!cp ('t146'); |
| 3819 |
## As if </noscript> |
## As if </noscript> |
| 3820 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3821 |
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}); |
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}, token => $token); |
| 3822 |
|
|
| 3823 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3824 |
## As if </head> |
## As if </head> |
| 3834 |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3835 |
## ISSUE: This case cannot be reached? |
## ISSUE: This case cannot be reached? |
| 3836 |
!!!cp ('t148'); |
!!!cp ('t148'); |
| 3837 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 3838 |
## Ignore the token ## ISSUE: An issue in the spec. |
## Ignore the token ## ISSUE: An issue in the spec. |
| 3839 |
!!!next-token; |
!!!next-token; |
| 3840 |
redo B; |
redo B; |
| 3844 |
|
|
| 3845 |
## "after head" insertion mode |
## "after head" insertion mode |
| 3846 |
## As if <body> |
## As if <body> |
| 3847 |
!!!insert-element ('body'); |
!!!insert-element ('body',, $token); |
| 3848 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 3849 |
## reprocess |
## reprocess |
| 3850 |
redo B; |
redo B; |
| 3851 |
} else { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 3852 |
die "$0: $token->{type}: Unknown token type"; |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3853 |
} |
!!!cp ('t149.1'); |
| 3854 |
|
|
| 3855 |
|
## NOTE: As if <head> |
| 3856 |
|
!!!create-element ($self->{head_element}, 'head',, $token); |
| 3857 |
|
$self->{open_elements}->[-1]->[0]->append_child |
| 3858 |
|
($self->{head_element}); |
| 3859 |
|
#push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3860 |
|
#$self->{insertion_mode} = IN_HEAD_IM; |
| 3861 |
|
## NOTE: Reprocess. |
| 3862 |
|
|
| 3863 |
|
## NOTE: As if </head> |
| 3864 |
|
#pop @{$self->{open_elements}}; |
| 3865 |
|
#$self->{insertion_mode} = IN_AFTER_HEAD_IM; |
| 3866 |
|
## NOTE: Reprocess. |
| 3867 |
|
|
| 3868 |
|
# |
| 3869 |
|
} elsif ($self->{insertion_mode} == IN_HEAD_IM) { |
| 3870 |
|
!!!cp ('t149.2'); |
| 3871 |
|
|
| 3872 |
|
## NOTE: As if </head> |
| 3873 |
|
pop @{$self->{open_elements}}; |
| 3874 |
|
#$self->{insertion_mode} = IN_AFTER_HEAD_IM; |
| 3875 |
|
## NOTE: Reprocess. |
| 3876 |
|
|
| 3877 |
|
# |
| 3878 |
|
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 3879 |
|
!!!cp ('t149.3'); |
| 3880 |
|
|
| 3881 |
|
!!!parse-error (type => 'in noscript:#eof', token => $token); |
| 3882 |
|
|
| 3883 |
|
## As if </noscript> |
| 3884 |
|
pop @{$self->{open_elements}}; |
| 3885 |
|
#$self->{insertion_mode} = IN_HEAD_IM; |
| 3886 |
|
## NOTE: Reprocess. |
| 3887 |
|
|
| 3888 |
|
## NOTE: As if </head> |
| 3889 |
|
pop @{$self->{open_elements}}; |
| 3890 |
|
#$self->{insertion_mode} = IN_AFTER_HEAD_IM; |
| 3891 |
|
## NOTE: Reprocess. |
| 3892 |
|
|
| 3893 |
|
# |
| 3894 |
|
} else { |
| 3895 |
|
!!!cp ('t149.4'); |
| 3896 |
|
# |
| 3897 |
|
} |
| 3898 |
|
|
| 3899 |
|
## NOTE: As if <body> |
| 3900 |
|
!!!insert-element ('body',, $token); |
| 3901 |
|
$self->{insertion_mode} = IN_BODY_IM; |
| 3902 |
|
## NOTE: Reprocess. |
| 3903 |
|
redo B; |
| 3904 |
|
} else { |
| 3905 |
|
die "$0: $token->{type}: Unknown token type"; |
| 3906 |
|
} |
| 3907 |
|
|
| 3908 |
## ISSUE: An issue in the spec. |
## ISSUE: An issue in the spec. |
| 3909 |
} elsif ($self->{insertion_mode} & BODY_IMS) { |
} elsif ($self->{insertion_mode} & BODY_IMS) { |
| 3923 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 3924 |
if ($self->{insertion_mode} == IN_CELL_IM) { |
if ($self->{insertion_mode} == IN_CELL_IM) { |
| 3925 |
## have an element in table scope |
## have an element in table scope |
| 3926 |
my $tn; |
for (reverse 0..$#{$self->{open_elements}}) { |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
| 3927 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 3928 |
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
| 3929 |
!!!cp ('t151'); |
!!!cp ('t151'); |
| 3930 |
$tn = $node->[1]; |
|
| 3931 |
last INSCOPE; |
## Close the cell |
| 3932 |
|
!!!back-token; # <?> |
| 3933 |
|
$token = {type => END_TAG_TOKEN, tag_name => $node->[1], |
| 3934 |
|
line => $token->{line}, |
| 3935 |
|
column => $token->{column}}; |
| 3936 |
|
redo B; |
| 3937 |
} elsif ({ |
} elsif ({ |
| 3938 |
table => 1, html => 1, |
table => 1, html => 1, |
| 3939 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 3940 |
!!!cp ('t152'); |
!!!cp ('t152'); |
| 3941 |
last INSCOPE; |
## ISSUE: This case can never be reached, maybe. |
| 3942 |
|
last; |
| 3943 |
} |
} |
| 3944 |
} # INSCOPE |
} |
| 3945 |
unless (defined $tn) { |
|
| 3946 |
!!!cp ('t153'); |
!!!cp ('t153'); |
| 3947 |
## TODO: This error type is wrong. |
!!!parse-error (type => 'start tag not allowed', |
| 3948 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
value => $token->{tag_name}, token => $token); |
| 3949 |
## Ignore the token |
## Ignore the token |
| 3950 |
!!!next-token; |
!!!next-token; |
|
redo B; |
|
|
} |
|
|
|
|
|
!!!cp ('t154'); |
|
|
## Close the cell |
|
|
!!!back-token; # <?> |
|
|
$token = {type => END_TAG_TOKEN, tag_name => $tn}; |
|
| 3951 |
redo B; |
redo B; |
| 3952 |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
| 3953 |
!!!parse-error (type => 'not closed:caption'); |
!!!parse-error (type => 'not closed:caption', token => $token); |
| 3954 |
|
|
| 3955 |
## As if </caption> |
## NOTE: As if </caption>. |
| 3956 |
## have a table element in table scope |
## have a table element in table scope |
| 3957 |
my $i; |
my $i; |
| 3958 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: { |
| 3959 |
my $node = $self->{open_elements}->[$_]; |
for (reverse 0..$#{$self->{open_elements}}) { |
| 3960 |
if ($node->[1] eq 'caption') { |
my $node = $self->{open_elements}->[$_]; |
| 3961 |
!!!cp ('t155'); |
if ($node->[1] eq 'caption') { |
| 3962 |
$i = $_; |
!!!cp ('t155'); |
| 3963 |
last INSCOPE; |
$i = $_; |
| 3964 |
} elsif ({ |
last INSCOPE; |
| 3965 |
table => 1, html => 1, |
} elsif ({ |
| 3966 |
}->{$node->[1]}) { |
table => 1, html => 1, |
| 3967 |
!!!cp ('t156'); |
}->{$node->[1]}) { |
| 3968 |
last INSCOPE; |
!!!cp ('t156'); |
| 3969 |
|
last; |
| 3970 |
|
} |
| 3971 |
} |
} |
| 3972 |
|
|
| 3973 |
|
!!!cp ('t157'); |
| 3974 |
|
!!!parse-error (type => 'start tag not allowed', |
| 3975 |
|
value => $token->{tag_name}, token => $token); |
| 3976 |
|
## Ignore the token |
| 3977 |
|
!!!next-token; |
| 3978 |
|
redo B; |
| 3979 |
} # INSCOPE |
} # INSCOPE |
|
unless (defined $i) { |
|
|
!!!cp ('t157'); |
|
|
## TODO: this type is wrong. |
|
|
!!!parse-error (type => 'unmatched end tag:caption'); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
| 3980 |
|
|
| 3981 |
## generate implied end tags |
## generate implied end tags |
| 3982 |
if ({ |
while ({ |
| 3983 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 3984 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
## NOTE: Maybe the following elements never appear here. |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 3985 |
!!!cp ('t158'); |
!!!cp ('t158'); |
| 3986 |
!!!back-token; # <?> |
pop @{$self->{open_elements}}; |
|
$token = {type => END_TAG_TOKEN, tag_name => 'caption'}; |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
| 3987 |
} |
} |
| 3988 |
|
|
| 3989 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 3990 |
!!!cp ('t159'); |
!!!cp ('t159'); |
| 3991 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 3992 |
} else { |
} else { |
| 3993 |
!!!cp ('t160'); |
!!!cp ('t160'); |
| 3994 |
} |
} |
| 4029 |
} # INSCOPE |
} # INSCOPE |
| 4030 |
unless (defined $i) { |
unless (defined $i) { |
| 4031 |
!!!cp ('t165'); |
!!!cp ('t165'); |
| 4032 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4033 |
## Ignore the token |
## Ignore the token |
| 4034 |
!!!next-token; |
!!!next-token; |
| 4035 |
redo B; |
redo B; |
| 4036 |
} |
} |
| 4037 |
|
|
| 4038 |
## generate implied end tags |
## generate implied end tags |
| 4039 |
if ({ |
while ({ |
| 4040 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4041 |
td => ($token->{tag_name} eq 'th'), |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
th => ($token->{tag_name} eq 'td'), |
|
|
|
|
|
## NOTE: Maybe the following elements never appear here. |
|
|
tr => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4042 |
!!!cp ('t166'); |
!!!cp ('t166'); |
| 4043 |
!!!back-token; |
pop @{$self->{open_elements}}; |
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
| 4044 |
} |
} |
| 4045 |
|
|
| 4046 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 4047 |
!!!cp ('t167'); |
!!!cp ('t167'); |
| 4048 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 4049 |
} else { |
} else { |
| 4050 |
!!!cp ('t168'); |
!!!cp ('t168'); |
| 4051 |
} |
} |
| 4060 |
redo B; |
redo B; |
| 4061 |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
| 4062 |
!!!cp ('t169'); |
!!!cp ('t169'); |
| 4063 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4064 |
## Ignore the token |
## Ignore the token |
| 4065 |
!!!next-token; |
!!!next-token; |
| 4066 |
redo B; |
redo B; |
| 4072 |
if ($self->{insertion_mode} == IN_CAPTION_IM) { |
if ($self->{insertion_mode} == IN_CAPTION_IM) { |
| 4073 |
## have a table element in table scope |
## have a table element in table scope |
| 4074 |
my $i; |
my $i; |
| 4075 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: { |
| 4076 |
my $node = $self->{open_elements}->[$_]; |
for (reverse 0..$#{$self->{open_elements}}) { |
| 4077 |
if ($node->[1] eq $token->{tag_name}) { |
my $node = $self->{open_elements}->[$_]; |
| 4078 |
!!!cp ('t171'); |
if ($node->[1] eq $token->{tag_name}) { |
| 4079 |
$i = $_; |
!!!cp ('t171'); |
| 4080 |
last INSCOPE; |
$i = $_; |
| 4081 |
} elsif ({ |
last INSCOPE; |
| 4082 |
table => 1, html => 1, |
} elsif ({ |
| 4083 |
}->{$node->[1]}) { |
table => 1, html => 1, |
| 4084 |
!!!cp ('t172'); |
}->{$node->[1]}) { |
| 4085 |
last INSCOPE; |
!!!cp ('t172'); |
| 4086 |
|
last; |
| 4087 |
|
} |
| 4088 |
} |
} |
| 4089 |
|
|
| 4090 |
|
!!!cp ('t173'); |
| 4091 |
|
!!!parse-error (type => 'unmatched end tag', |
| 4092 |
|
value => $token->{tag_name}, token => $token); |
| 4093 |
|
## Ignore the token |
| 4094 |
|
!!!next-token; |
| 4095 |
|
redo B; |
| 4096 |
} # INSCOPE |
} # INSCOPE |
|
unless (defined $i) { |
|
|
!!!cp ('t173'); |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
| 4097 |
|
|
| 4098 |
## generate implied end tags |
## generate implied end tags |
| 4099 |
if ({ |
while ({ |
| 4100 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4101 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
## NOTE: The following elements never appear here, maybe. |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4102 |
!!!cp ('t174'); |
!!!cp ('t174'); |
| 4103 |
!!!back-token; |
pop @{$self->{open_elements}}; |
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
| 4104 |
} |
} |
| 4105 |
|
|
| 4106 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 4107 |
!!!cp ('t175'); |
!!!cp ('t175'); |
| 4108 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 4109 |
} else { |
} else { |
| 4110 |
!!!cp ('t176'); |
!!!cp ('t176'); |
| 4111 |
} |
} |
| 4120 |
redo B; |
redo B; |
| 4121 |
} elsif ($self->{insertion_mode} == IN_CELL_IM) { |
} elsif ($self->{insertion_mode} == IN_CELL_IM) { |
| 4122 |
!!!cp ('t177'); |
!!!cp ('t177'); |
| 4123 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4124 |
## Ignore the token |
## Ignore the token |
| 4125 |
!!!next-token; |
!!!next-token; |
| 4126 |
redo B; |
redo B; |
| 4136 |
## have an element in table scope |
## have an element in table scope |
| 4137 |
my $i; |
my $i; |
| 4138 |
my $tn; |
my $tn; |
| 4139 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: { |
| 4140 |
my $node = $self->{open_elements}->[$_]; |
for (reverse 0..$#{$self->{open_elements}}) { |
| 4141 |
if ($node->[1] eq $token->{tag_name}) { |
my $node = $self->{open_elements}->[$_]; |
| 4142 |
!!!cp ('t179'); |
if ($node->[1] eq $token->{tag_name}) { |
| 4143 |
$i = $_; |
!!!cp ('t179'); |
| 4144 |
last INSCOPE; |
$i = $_; |
| 4145 |
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
|
| 4146 |
!!!cp ('t180'); |
## Close the cell |
| 4147 |
$tn = $node->[1]; |
!!!back-token; # </?> |
| 4148 |
## NOTE: There is exactly one |td| or |th| element |
$token = {type => END_TAG_TOKEN, tag_name => $tn, |
| 4149 |
## in scope in the stack of open elements by definition. |
line => $token->{line}, |
| 4150 |
} elsif ({ |
column => $token->{column}}; |
| 4151 |
table => 1, html => 1, |
redo B; |
| 4152 |
}->{$node->[1]}) { |
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
| 4153 |
!!!cp ('t181'); |
!!!cp ('t180'); |
| 4154 |
last INSCOPE; |
$tn = $node->[1]; |
| 4155 |
|
## NOTE: There is exactly one |td| or |th| element |
| 4156 |
|
## in scope in the stack of open elements by definition. |
| 4157 |
|
} elsif ({ |
| 4158 |
|
table => 1, html => 1, |
| 4159 |
|
}->{$node->[1]}) { |
| 4160 |
|
## ISSUE: Can this be reached? |
| 4161 |
|
!!!cp ('t181'); |
| 4162 |
|
last; |
| 4163 |
|
} |
| 4164 |
} |
} |
| 4165 |
} # INSCOPE |
|
|
unless (defined $i) { |
|
| 4166 |
!!!cp ('t182'); |
!!!cp ('t182'); |
| 4167 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag', |
| 4168 |
|
value => $token->{tag_name}, token => $token); |
| 4169 |
## Ignore the token |
## Ignore the token |
| 4170 |
!!!next-token; |
!!!next-token; |
| 4171 |
redo B; |
redo B; |
| 4172 |
} else { |
} # INSCOPE |
|
!!!cp ('t183'); |
|
|
} |
|
|
|
|
|
## Close the cell |
|
|
!!!back-token; # </?> |
|
|
$token = {type => END_TAG_TOKEN, tag_name => $tn}; |
|
|
redo B; |
|
| 4173 |
} elsif ($token->{tag_name} eq 'table' and |
} elsif ($token->{tag_name} eq 'table' and |
| 4174 |
$self->{insertion_mode} == IN_CAPTION_IM) { |
$self->{insertion_mode} == IN_CAPTION_IM) { |
| 4175 |
!!!parse-error (type => 'not closed:caption'); |
!!!parse-error (type => 'not closed:caption', token => $token); |
| 4176 |
|
|
| 4177 |
## As if </caption> |
## As if </caption> |
| 4178 |
## have a table element in table scope |
## have a table element in table scope |
| 4192 |
} # INSCOPE |
} # INSCOPE |
| 4193 |
unless (defined $i) { |
unless (defined $i) { |
| 4194 |
!!!cp ('t186'); |
!!!cp ('t186'); |
| 4195 |
!!!parse-error (type => 'unmatched end tag:caption'); |
!!!parse-error (type => 'unmatched end tag:caption', token => $token); |
| 4196 |
## Ignore the token |
## Ignore the token |
| 4197 |
!!!next-token; |
!!!next-token; |
| 4198 |
redo B; |
redo B; |
| 4199 |
} |
} |
| 4200 |
|
|
| 4201 |
## generate implied end tags |
## generate implied end tags |
| 4202 |
if ({ |
while ({ |
| 4203 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4204 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
## NOTE: The following elements never appear, maybe. |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4205 |
!!!cp ('t187'); |
!!!cp ('t187'); |
| 4206 |
!!!back-token; # </table> |
pop @{$self->{open_elements}}; |
|
$token = {type => END_TAG_TOKEN, tag_name => 'caption'}; |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
| 4207 |
} |
} |
| 4208 |
|
|
| 4209 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 4210 |
!!!cp ('t188'); |
!!!cp ('t188'); |
| 4211 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 4212 |
} else { |
} else { |
| 4213 |
!!!cp ('t189'); |
!!!cp ('t189'); |
| 4214 |
} |
} |
| 4226 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4227 |
if ($self->{insertion_mode} & BODY_TABLE_IMS) { |
if ($self->{insertion_mode} & BODY_TABLE_IMS) { |
| 4228 |
!!!cp ('t190'); |
!!!cp ('t190'); |
| 4229 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4230 |
## Ignore the token |
## Ignore the token |
| 4231 |
!!!next-token; |
!!!next-token; |
| 4232 |
redo B; |
redo B; |
| 4240 |
}->{$token->{tag_name}} and |
}->{$token->{tag_name}} and |
| 4241 |
$self->{insertion_mode} == IN_CAPTION_IM) { |
$self->{insertion_mode} == IN_CAPTION_IM) { |
| 4242 |
!!!cp ('t192'); |
!!!cp ('t192'); |
| 4243 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4244 |
## Ignore the token |
## Ignore the token |
| 4245 |
!!!next-token; |
!!!next-token; |
| 4246 |
redo B; |
redo B; |
| 4248 |
!!!cp ('t193'); |
!!!cp ('t193'); |
| 4249 |
# |
# |
| 4250 |
} |
} |
| 4251 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 4252 |
|
for my $entry (@{$self->{open_elements}}) { |
| 4253 |
|
if (not { |
| 4254 |
|
dd => 1, dt => 1, li => 1, p => 1, tbody => 1, td => 1, tfoot => 1, |
| 4255 |
|
th => 1, thead => 1, tr => 1, body => 1, html => 1, |
| 4256 |
|
}->{$entry->[1]}) { |
| 4257 |
|
!!!cp ('t75'); |
| 4258 |
|
!!!parse-error (type => 'in body:#eof', token => $token); |
| 4259 |
|
last; |
| 4260 |
|
} |
| 4261 |
|
} |
| 4262 |
|
|
| 4263 |
|
## Stop parsing. |
| 4264 |
|
last B; |
| 4265 |
} else { |
} else { |
| 4266 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 4267 |
} |
} |
| 4270 |
# |
# |
| 4271 |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
| 4272 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 4273 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if (not $open_tables->[-1]->[1] and # tainted |
| 4274 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4275 |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 4276 |
|
|
| 4277 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 4278 |
!!!cp ('t194'); |
!!!cp ('t194'); |
| 4279 |
!!!next-token; |
!!!next-token; |
| 4280 |
redo B; |
redo B; |
| 4281 |
} else { |
} else { |
| 4282 |
!!!cp ('t195'); |
!!!cp ('t195'); |
| 4283 |
} |
} |
| 4284 |
} |
} |
| 4285 |
|
|
| 4286 |
!!!parse-error (type => 'in table:#character'); |
!!!parse-error (type => 'in table:#character', token => $token); |
| 4287 |
|
|
| 4288 |
## As if in body, but insert into foster parent element |
## As if in body, but insert into foster parent element |
| 4289 |
## ISSUE: Spec says that "whenever a node would be inserted |
## ISSUE: Spec says that "whenever a node would be inserted |
| 4328 |
($self->{document}->create_text_node ($token->{data}), |
($self->{document}->create_text_node ($token->{data}), |
| 4329 |
$next_sibling); |
$next_sibling); |
| 4330 |
} |
} |
| 4331 |
} else { |
$open_tables->[-1]->[1] = 1; # tainted |
| 4332 |
!!!cp ('t200'); |
} else { |
| 4333 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
!!!cp ('t200'); |
| 4334 |
} |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 4335 |
|
} |
| 4336 |
|
|
| 4337 |
!!!next-token; |
!!!next-token; |
| 4338 |
redo B; |
redo B; |
| 4339 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 4340 |
if ({ |
if ({ |
| 4341 |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
| 4346 |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
| 4347 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4348 |
!!!cp ('t201'); |
!!!cp ('t201'); |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4349 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4350 |
} |
} |
| 4351 |
|
|
| 4352 |
!!!insert-element ('tbody'); |
!!!insert-element ('tbody',, $token); |
| 4353 |
$self->{insertion_mode} = IN_TABLE_BODY_IM; |
$self->{insertion_mode} = IN_TABLE_BODY_IM; |
| 4354 |
## reprocess in the "in table body" insertion mode... |
## reprocess in the "in table body" insertion mode... |
| 4355 |
} |
} |
| 4357 |
if ($self->{insertion_mode} == IN_TABLE_BODY_IM) { |
if ($self->{insertion_mode} == IN_TABLE_BODY_IM) { |
| 4358 |
unless ($token->{tag_name} eq 'tr') { |
unless ($token->{tag_name} eq 'tr') { |
| 4359 |
!!!cp ('t202'); |
!!!cp ('t202'); |
| 4360 |
!!!parse-error (type => 'missing start tag:tr'); |
!!!parse-error (type => 'missing start tag:tr', token => $token); |
| 4361 |
} |
} |
| 4362 |
|
|
| 4363 |
## Clear back to table body context |
## Clear back to table body context |
| 4366 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4367 |
!!!cp ('t203'); |
!!!cp ('t203'); |
| 4368 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4369 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4370 |
} |
} |
| 4371 |
|
|
| 4372 |
$self->{insertion_mode} = IN_ROW_IM; |
$self->{insertion_mode} = IN_ROW_IM; |
| 4373 |
if ($token->{tag_name} eq 'tr') { |
if ($token->{tag_name} eq 'tr') { |
| 4374 |
!!!cp ('t204'); |
!!!cp ('t204'); |
| 4375 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 4376 |
!!!next-token; |
!!!next-token; |
| 4377 |
redo B; |
redo B; |
| 4378 |
} else { |
} else { |
| 4379 |
!!!cp ('t205'); |
!!!cp ('t205'); |
| 4380 |
!!!insert-element ('tr'); |
!!!insert-element ('tr',, $token); |
| 4381 |
## reprocess in the "in row" insertion mode |
## reprocess in the "in row" insertion mode |
| 4382 |
} |
} |
| 4383 |
} else { |
} else { |
| 4389 |
tr => 1, html => 1, |
tr => 1, html => 1, |
| 4390 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4391 |
!!!cp ('t207'); |
!!!cp ('t207'); |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4392 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4393 |
} |
} |
| 4394 |
|
|
| 4395 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 4396 |
$self->{insertion_mode} = IN_CELL_IM; |
$self->{insertion_mode} = IN_CELL_IM; |
| 4397 |
|
|
| 4398 |
push @$active_formatting_elements, ['#marker', '']; |
push @$active_formatting_elements, ['#marker', '']; |
| 4427 |
unless (defined $i) { |
unless (defined $i) { |
| 4428 |
!!!cp ('t210'); |
!!!cp ('t210'); |
| 4429 |
## TODO: This type is wrong. |
## TODO: This type is wrong. |
| 4430 |
!!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}, token => $token); |
| 4431 |
## Ignore the token |
## Ignore the token |
| 4432 |
!!!next-token; |
!!!next-token; |
| 4433 |
redo B; |
redo B; |
| 4439 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4440 |
!!!cp ('t211'); |
!!!cp ('t211'); |
| 4441 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4442 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4443 |
} |
} |
| 4444 |
|
|
| 4475 |
unless (defined $i) { |
unless (defined $i) { |
| 4476 |
!!!cp ('t216'); |
!!!cp ('t216'); |
| 4477 |
## TODO: This erorr type ios wrong. |
## TODO: This erorr type ios wrong. |
| 4478 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4479 |
## Ignore the token |
## Ignore the token |
| 4480 |
!!!next-token; |
!!!next-token; |
| 4481 |
redo B; |
redo B; |
| 4487 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4488 |
!!!cp ('t217'); |
!!!cp ('t217'); |
| 4489 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4490 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4491 |
} |
} |
| 4492 |
|
|
| 4510 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4511 |
!!!cp ('t219'); |
!!!cp ('t219'); |
| 4512 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4513 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4514 |
} |
} |
| 4515 |
|
|
| 4516 |
!!!insert-element ('colgroup'); |
!!!insert-element ('colgroup',, $token); |
| 4517 |
$self->{insertion_mode} = IN_COLUMN_GROUP_IM; |
$self->{insertion_mode} = IN_COLUMN_GROUP_IM; |
| 4518 |
## reprocess |
## reprocess |
| 4519 |
redo B; |
redo B; |
| 4527 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4528 |
!!!cp ('t220'); |
!!!cp ('t220'); |
| 4529 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4530 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4531 |
} |
} |
| 4532 |
|
|
| 4533 |
push @$active_formatting_elements, ['#marker', ''] |
push @$active_formatting_elements, ['#marker', ''] |
| 4534 |
if $token->{tag_name} eq 'caption'; |
if $token->{tag_name} eq 'caption'; |
| 4535 |
|
|
| 4536 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 4537 |
$self->{insertion_mode} = { |
$self->{insertion_mode} = { |
| 4538 |
caption => IN_CAPTION_IM, |
caption => IN_CAPTION_IM, |
| 4539 |
colgroup => IN_COLUMN_GROUP_IM, |
colgroup => IN_COLUMN_GROUP_IM, |
| 4547 |
die "$0: in table: <>: $token->{tag_name}"; |
die "$0: in table: <>: $token->{tag_name}"; |
| 4548 |
} |
} |
| 4549 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 4550 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 4551 |
|
|
| 4552 |
## As if </table> |
## As if </table> |
| 4553 |
## have a table element in table scope |
## have a table element in table scope |
| 4569 |
unless (defined $i) { |
unless (defined $i) { |
| 4570 |
!!!cp ('t223'); |
!!!cp ('t223'); |
| 4571 |
## TODO: The following is wrong, maybe. |
## TODO: The following is wrong, maybe. |
| 4572 |
!!!parse-error (type => 'unmatched end tag:table'); |
!!!parse-error (type => 'unmatched end tag:table', token => $token); |
| 4573 |
## Ignore tokens </table><table> |
## Ignore tokens </table><table> |
| 4574 |
!!!next-token; |
!!!next-token; |
| 4575 |
redo B; |
redo B; |
| 4576 |
} |
} |
| 4577 |
|
|
| 4578 |
|
## TODO: Followings are removed from the latest spec. |
| 4579 |
## generate implied end tags |
## generate implied end tags |
| 4580 |
if ({ |
while ({ |
| 4581 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4582 |
td => 1, th => 1, tr => 1, |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4583 |
!!!cp ('t224'); |
!!!cp ('t224'); |
| 4584 |
!!!back-token; # <table> |
pop @{$self->{open_elements}}; |
|
$token = {type => END_TAG_TOKEN, tag_name => 'table'}; |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
| 4585 |
} |
} |
| 4586 |
|
|
| 4587 |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
| 4588 |
!!!cp ('t225'); |
!!!cp ('t225'); |
| 4589 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
| 4590 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 4591 |
} else { |
} else { |
| 4592 |
!!!cp ('t226'); |
!!!cp ('t226'); |
| 4593 |
} |
} |
| 4594 |
|
|
| 4595 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 4596 |
|
pop @{$open_tables}; |
| 4597 |
|
|
| 4598 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 4599 |
|
|
| 4600 |
## reprocess |
## reprocess |
| 4601 |
redo B; |
redo B; |
| 4602 |
|
} elsif ($token->{tag_name} eq 'style') { |
| 4603 |
|
if (not $open_tables->[-1]->[1]) { # tainted |
| 4604 |
|
!!!cp ('t227.8'); |
| 4605 |
|
## NOTE: This is a "as if in head" code clone. |
| 4606 |
|
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 4607 |
|
redo B; |
| 4608 |
|
} else { |
| 4609 |
|
!!!cp ('t227.7'); |
| 4610 |
|
# |
| 4611 |
|
} |
| 4612 |
|
} elsif ($token->{tag_name} eq 'script') { |
| 4613 |
|
if (not $open_tables->[-1]->[1]) { # tainted |
| 4614 |
|
!!!cp ('t227.6'); |
| 4615 |
|
## NOTE: This is a "as if in head" code clone. |
| 4616 |
|
$script_start_tag->(); |
| 4617 |
|
redo B; |
| 4618 |
|
} else { |
| 4619 |
|
!!!cp ('t227.5'); |
| 4620 |
|
# |
| 4621 |
|
} |
| 4622 |
|
} elsif ($token->{tag_name} eq 'input') { |
| 4623 |
|
if (not $open_tables->[-1]->[1]) { # tainted |
| 4624 |
|
if ($token->{attributes}->{type}) { ## TODO: case |
| 4625 |
|
my $type = lc $token->{attributes}->{type}->{value}; |
| 4626 |
|
if ($type eq 'hidden') { |
| 4627 |
|
!!!cp ('t227.3'); |
| 4628 |
|
!!!parse-error (type => 'in table:'.$token->{tag_name}, token => $token); |
| 4629 |
|
|
| 4630 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 4631 |
|
|
| 4632 |
|
## TODO: form element pointer |
| 4633 |
|
|
| 4634 |
|
pop @{$self->{open_elements}}; |
| 4635 |
|
|
| 4636 |
|
!!!next-token; |
| 4637 |
|
redo B; |
| 4638 |
|
} else { |
| 4639 |
|
!!!cp ('t227.2'); |
| 4640 |
|
# |
| 4641 |
|
} |
| 4642 |
|
} else { |
| 4643 |
|
!!!cp ('t227.1'); |
| 4644 |
|
# |
| 4645 |
|
} |
| 4646 |
|
} else { |
| 4647 |
|
!!!cp ('t227.4'); |
| 4648 |
|
# |
| 4649 |
|
} |
| 4650 |
} else { |
} else { |
| 4651 |
!!!cp ('t227'); |
!!!cp ('t227'); |
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
|
|
|
|
|
$insert = $insert_to_foster; |
|
| 4652 |
# |
# |
| 4653 |
} |
} |
| 4654 |
|
|
| 4655 |
|
!!!parse-error (type => 'in table:'.$token->{tag_name}, token => $token); |
| 4656 |
|
|
| 4657 |
|
$insert = $insert_to_foster; |
| 4658 |
|
# |
| 4659 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 4660 |
if ($token->{tag_name} eq 'tr' and |
if ($token->{tag_name} eq 'tr' and |
| 4661 |
$self->{insertion_mode} == IN_ROW_IM) { |
$self->{insertion_mode} == IN_ROW_IM) { |
| 4676 |
} # INSCOPE |
} # INSCOPE |
| 4677 |
unless (defined $i) { |
unless (defined $i) { |
| 4678 |
!!!cp ('t230'); |
!!!cp ('t230'); |
| 4679 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4680 |
## Ignore the token |
## Ignore the token |
| 4681 |
!!!next-token; |
!!!next-token; |
| 4682 |
redo B; |
redo B; |
| 4690 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4691 |
!!!cp ('t231'); |
!!!cp ('t231'); |
| 4692 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4693 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4694 |
} |
} |
| 4695 |
|
|
| 4718 |
unless (defined $i) { |
unless (defined $i) { |
| 4719 |
!!!cp ('t235'); |
!!!cp ('t235'); |
| 4720 |
## TODO: The following is wrong. |
## TODO: The following is wrong. |
| 4721 |
!!!parse-error (type => 'unmatched end tag:'.$token->{type}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{type}, token => $token); |
| 4722 |
## Ignore the token |
## Ignore the token |
| 4723 |
!!!next-token; |
!!!next-token; |
| 4724 |
redo B; |
redo B; |
| 4730 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4731 |
!!!cp ('t236'); |
!!!cp ('t236'); |
| 4732 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4733 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4734 |
} |
} |
| 4735 |
|
|
| 4758 |
} # INSCOPE |
} # INSCOPE |
| 4759 |
unless (defined $i) { |
unless (defined $i) { |
| 4760 |
!!!cp ('t239'); |
!!!cp ('t239'); |
| 4761 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4762 |
## Ignore the token |
## Ignore the token |
| 4763 |
!!!next-token; |
!!!next-token; |
| 4764 |
redo B; |
redo B; |
| 4769 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4770 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4771 |
!!!cp ('t240'); |
!!!cp ('t240'); |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4772 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4773 |
} |
} |
| 4774 |
|
|
| 4784 |
## reprocess in the "in table" insertion mode... |
## reprocess in the "in table" insertion mode... |
| 4785 |
} |
} |
| 4786 |
|
|
| 4787 |
|
## NOTE: </table> in the "in table" insertion mode. |
| 4788 |
|
## When you edit the code fragment below, please ensure that |
| 4789 |
|
## the code for <table> in the "in table" insertion mode |
| 4790 |
|
## is synced with it. |
| 4791 |
|
|
| 4792 |
## have a table element in table scope |
## have a table element in table scope |
| 4793 |
my $i; |
my $i; |
| 4794 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4806 |
} # INSCOPE |
} # INSCOPE |
| 4807 |
unless (defined $i) { |
unless (defined $i) { |
| 4808 |
!!!cp ('t243'); |
!!!cp ('t243'); |
| 4809 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4810 |
## Ignore the token |
## Ignore the token |
| 4811 |
!!!next-token; |
!!!next-token; |
| 4812 |
redo B; |
redo B; |
| 4813 |
} |
} |
|
|
|
|
## 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]}) { |
|
|
!!!cp ('t244'); |
|
|
## ISSUE: Can this case be reached? |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
|
|
!!!cp ('t245'); |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} else { |
|
|
!!!cp ('t246'); |
|
|
} |
|
| 4814 |
|
|
| 4815 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 4816 |
|
pop @{$open_tables}; |
| 4817 |
|
|
| 4818 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 4819 |
|
|
| 4841 |
} # INSCOPE |
} # INSCOPE |
| 4842 |
unless (defined $i) { |
unless (defined $i) { |
| 4843 |
!!!cp ('t249'); |
!!!cp ('t249'); |
| 4844 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4845 |
## Ignore the token |
## Ignore the token |
| 4846 |
!!!next-token; |
!!!next-token; |
| 4847 |
redo B; |
redo B; |
| 4865 |
} # INSCOPE |
} # INSCOPE |
| 4866 |
unless (defined $i) { |
unless (defined $i) { |
| 4867 |
!!!cp ('t252'); |
!!!cp ('t252'); |
| 4868 |
!!!parse-error (type => 'unmatched end tag:tr'); |
!!!parse-error (type => 'unmatched end tag:tr', token => $token); |
| 4869 |
## Ignore the token |
## Ignore the token |
| 4870 |
!!!next-token; |
!!!next-token; |
| 4871 |
redo B; |
redo B; |
| 4877 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4878 |
!!!cp ('t253'); |
!!!cp ('t253'); |
| 4879 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4880 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4881 |
} |
} |
| 4882 |
|
|
| 4902 |
} # INSCOPE |
} # INSCOPE |
| 4903 |
unless (defined $i) { |
unless (defined $i) { |
| 4904 |
!!!cp ('t256'); |
!!!cp ('t256'); |
| 4905 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4906 |
## Ignore the token |
## Ignore the token |
| 4907 |
!!!next-token; |
!!!next-token; |
| 4908 |
redo B; |
redo B; |
| 4914 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4915 |
!!!cp ('t257'); |
!!!cp ('t257'); |
| 4916 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4917 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4918 |
} |
} |
| 4919 |
|
|
| 4928 |
tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM |
tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM |
| 4929 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4930 |
!!!cp ('t258'); |
!!!cp ('t258'); |
| 4931 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4932 |
## Ignore the token |
## Ignore the token |
| 4933 |
!!!next-token; |
!!!next-token; |
| 4934 |
redo B; |
redo B; |
| 4935 |
} else { |
} else { |
| 4936 |
!!!cp ('t259'); |
!!!cp ('t259'); |
| 4937 |
!!!parse-error (type => 'in table:/'.$token->{tag_name}); |
!!!parse-error (type => 'in table:/'.$token->{tag_name}, token => $token); |
| 4938 |
|
|
| 4939 |
$insert = $insert_to_foster; |
$insert = $insert_to_foster; |
| 4940 |
# |
# |
| 4941 |
} |
} |
| 4942 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 4943 |
|
unless ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 4944 |
|
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 4945 |
|
!!!parse-error (type => 'in body:#eof', token => $token); |
| 4946 |
|
!!!cp ('t259.1'); |
| 4947 |
|
# |
| 4948 |
|
} else { |
| 4949 |
|
!!!cp ('t259.2'); |
| 4950 |
|
# |
| 4951 |
|
} |
| 4952 |
|
|
| 4953 |
|
## Stop parsing |
| 4954 |
|
last B; |
| 4955 |
} else { |
} else { |
| 4956 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 4957 |
} |
} |
| 4971 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 4972 |
if ($token->{tag_name} eq 'col') { |
if ($token->{tag_name} eq 'col') { |
| 4973 |
!!!cp ('t262'); |
!!!cp ('t262'); |
| 4974 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 4975 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4976 |
!!!next-token; |
!!!next-token; |
| 4977 |
redo B; |
redo B; |
| 4983 |
if ($token->{tag_name} eq 'colgroup') { |
if ($token->{tag_name} eq 'colgroup') { |
| 4984 |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
| 4985 |
!!!cp ('t264'); |
!!!cp ('t264'); |
| 4986 |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
!!!parse-error (type => 'unmatched end tag:colgroup', token => $token); |
| 4987 |
## Ignore the token |
## Ignore the token |
| 4988 |
!!!next-token; |
!!!next-token; |
| 4989 |
redo B; |
redo B; |
| 4996 |
} |
} |
| 4997 |
} elsif ($token->{tag_name} eq 'col') { |
} elsif ($token->{tag_name} eq 'col') { |
| 4998 |
!!!cp ('t266'); |
!!!cp ('t266'); |
| 4999 |
!!!parse-error (type => 'unmatched end tag:col'); |
!!!parse-error (type => 'unmatched end tag:col', token => $token); |
| 5000 |
## Ignore the token |
## Ignore the token |
| 5001 |
!!!next-token; |
!!!next-token; |
| 5002 |
redo B; |
redo B; |
| 5004 |
!!!cp ('t267'); |
!!!cp ('t267'); |
| 5005 |
# |
# |
| 5006 |
} |
} |
| 5007 |
} else { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5008 |
die "$0: $token->{type}: Unknown token type"; |
if ($self->{open_elements}->[-1]->[1] eq 'html' or |
| 5009 |
} |
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 5010 |
|
!!!cp ('t270.2'); |
| 5011 |
|
## Stop parsing. |
| 5012 |
|
last B; |
| 5013 |
|
} else { |
| 5014 |
|
## NOTE: As if </colgroup>. |
| 5015 |
|
!!!cp ('t270.1'); |
| 5016 |
|
pop @{$self->{open_elements}}; # colgroup |
| 5017 |
|
$self->{insertion_mode} = IN_TABLE_IM; |
| 5018 |
|
## Reprocess. |
| 5019 |
|
redo B; |
| 5020 |
|
} |
| 5021 |
|
} else { |
| 5022 |
|
die "$0: $token->{type}: Unknown token type"; |
| 5023 |
|
} |
| 5024 |
|
|
| 5025 |
## As if </colgroup> |
## As if </colgroup> |
| 5026 |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
| 5027 |
!!!cp ('t269'); |
!!!cp ('t269'); |
| 5028 |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
## TODO: Wrong error type? |
| 5029 |
|
!!!parse-error (type => 'unmatched end tag:colgroup', token => $token); |
| 5030 |
## Ignore the token |
## Ignore the token |
| 5031 |
!!!next-token; |
!!!next-token; |
| 5032 |
redo B; |
redo B; |
| 5037 |
## reprocess |
## reprocess |
| 5038 |
redo B; |
redo B; |
| 5039 |
} |
} |
| 5040 |
} elsif ($self->{insertion_mode} == IN_SELECT_IM) { |
} elsif ($self->{insertion_mode} & SELECT_IMS) { |
| 5041 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 5042 |
!!!cp ('t271'); |
!!!cp ('t271'); |
| 5043 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 5053 |
!!!cp ('t273'); |
!!!cp ('t273'); |
| 5054 |
} |
} |
| 5055 |
|
|
| 5056 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 5057 |
!!!next-token; |
!!!next-token; |
| 5058 |
redo B; |
redo B; |
| 5059 |
} elsif ($token->{tag_name} eq 'optgroup') { |
} elsif ($token->{tag_name} eq 'optgroup') { |
| 5073 |
!!!cp ('t277'); |
!!!cp ('t277'); |
| 5074 |
} |
} |
| 5075 |
|
|
| 5076 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 5077 |
!!!next-token; |
!!!next-token; |
| 5078 |
redo B; |
redo B; |
| 5079 |
} elsif ($token->{tag_name} eq 'select') { |
} elsif ($token->{tag_name} eq 'select' or |
| 5080 |
## TODO: The type below is not good - <select> is replaced by </select> |
$token->{tag_name} eq 'input' or |
| 5081 |
!!!parse-error (type => 'not closed:select'); |
($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
| 5082 |
## As if </select> instead |
{ |
| 5083 |
|
caption => 1, table => 1, |
| 5084 |
|
tbody => 1, tfoot => 1, thead => 1, |
| 5085 |
|
tr => 1, td => 1, th => 1, |
| 5086 |
|
}->{$token->{tag_name}})) { |
| 5087 |
|
## TODO: The type below is not good - <select> is replaced by </select> |
| 5088 |
|
!!!parse-error (type => 'not closed:select', token => $token); |
| 5089 |
|
## NOTE: As if the token were </select> (<select> case) or |
| 5090 |
|
## as if there were </select> (otherwise). |
| 5091 |
## have an element in table scope |
## have an element in table scope |
| 5092 |
my $i; |
my $i; |
| 5093 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5094 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5095 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq 'select') { |
| 5096 |
!!!cp ('t278'); |
!!!cp ('t278'); |
| 5097 |
$i = $_; |
$i = $_; |
| 5098 |
last INSCOPE; |
last INSCOPE; |
| 5105 |
} # INSCOPE |
} # INSCOPE |
| 5106 |
unless (defined $i) { |
unless (defined $i) { |
| 5107 |
!!!cp ('t280'); |
!!!cp ('t280'); |
| 5108 |
!!!parse-error (type => 'unmatched end tag:select'); |
!!!parse-error (type => 'unmatched end tag:select', token => $token); |
| 5109 |
## Ignore the token |
## Ignore the token |
| 5110 |
!!!next-token; |
!!!next-token; |
| 5111 |
redo B; |
redo B; |
| 5116 |
|
|
| 5117 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 5118 |
|
|
| 5119 |
!!!next-token; |
if ($token->{tag_name} eq 'select') { |
| 5120 |
redo B; |
!!!cp ('t281.2'); |
| 5121 |
|
!!!next-token; |
| 5122 |
|
redo B; |
| 5123 |
|
} else { |
| 5124 |
|
!!!cp ('t281.1'); |
| 5125 |
|
## Reprocess the token. |
| 5126 |
|
redo B; |
| 5127 |
|
} |
| 5128 |
} else { |
} else { |
| 5129 |
!!!cp ('t282'); |
!!!cp ('t282'); |
| 5130 |
!!!parse-error (type => 'in select:'.$token->{tag_name}); |
!!!parse-error (type => 'in select:'.$token->{tag_name}, token => $token); |
| 5131 |
## Ignore the token |
## Ignore the token |
| 5132 |
!!!next-token; |
!!!next-token; |
| 5133 |
redo B; |
redo B; |
| 5144 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5145 |
} else { |
} else { |
| 5146 |
!!!cp ('t285'); |
!!!cp ('t285'); |
| 5147 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5148 |
## Ignore the token |
## Ignore the token |
| 5149 |
} |
} |
| 5150 |
!!!next-token; |
!!!next-token; |
| 5155 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5156 |
} else { |
} else { |
| 5157 |
!!!cp ('t287'); |
!!!cp ('t287'); |
| 5158 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5159 |
## Ignore the token |
## Ignore the token |
| 5160 |
} |
} |
| 5161 |
!!!next-token; |
!!!next-token; |
| 5178 |
} # INSCOPE |
} # INSCOPE |
| 5179 |
unless (defined $i) { |
unless (defined $i) { |
| 5180 |
!!!cp ('t290'); |
!!!cp ('t290'); |
| 5181 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5182 |
## Ignore the token |
## Ignore the token |
| 5183 |
!!!next-token; |
!!!next-token; |
| 5184 |
redo B; |
redo B; |
| 5191 |
|
|
| 5192 |
!!!next-token; |
!!!next-token; |
| 5193 |
redo B; |
redo B; |
| 5194 |
} elsif ({ |
} elsif ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
| 5195 |
caption => 1, table => 1, tbody => 1, |
{ |
| 5196 |
tfoot => 1, thead => 1, tr => 1, td => 1, th => 1, |
caption => 1, table => 1, tbody => 1, |
| 5197 |
}->{$token->{tag_name}}) { |
tfoot => 1, thead => 1, tr => 1, td => 1, th => 1, |
| 5198 |
|
}->{$token->{tag_name}}) { |
| 5199 |
## TODO: The following is wrong? |
## TODO: The following is wrong? |
| 5200 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5201 |
|
|
| 5202 |
## have an element in table scope |
## have an element in table scope |
| 5203 |
my $i; |
my $i; |
| 5241 |
unless (defined $i) { |
unless (defined $i) { |
| 5242 |
!!!cp ('t297'); |
!!!cp ('t297'); |
| 5243 |
## TODO: The following error type is correct? |
## TODO: The following error type is correct? |
| 5244 |
!!!parse-error (type => 'unmatched end tag:select'); |
!!!parse-error (type => 'unmatched end tag:select', token => $token); |
| 5245 |
## Ignore the </select> token |
## Ignore the </select> token |
| 5246 |
!!!next-token; ## TODO: ok? |
!!!next-token; ## TODO: ok? |
| 5247 |
redo B; |
redo B; |
| 5256 |
redo B; |
redo B; |
| 5257 |
} else { |
} else { |
| 5258 |
!!!cp ('t299'); |
!!!cp ('t299'); |
| 5259 |
!!!parse-error (type => 'in select:/'.$token->{tag_name}); |
!!!parse-error (type => 'in select:/'.$token->{tag_name}, token => $token); |
| 5260 |
## Ignore the token |
## Ignore the token |
| 5261 |
!!!next-token; |
!!!next-token; |
| 5262 |
redo B; |
redo B; |
| 5263 |
} |
} |
| 5264 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5265 |
|
unless ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 5266 |
|
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 5267 |
|
!!!cp ('t299.1'); |
| 5268 |
|
!!!parse-error (type => 'in body:#eof', token => $token); |
| 5269 |
|
} else { |
| 5270 |
|
!!!cp ('t299.2'); |
| 5271 |
|
} |
| 5272 |
|
|
| 5273 |
|
## Stop parsing. |
| 5274 |
|
last B; |
| 5275 |
} else { |
} else { |
| 5276 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 5277 |
} |
} |
| 5293 |
|
|
| 5294 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 5295 |
!!!cp ('t301'); |
!!!cp ('t301'); |
| 5296 |
!!!parse-error (type => 'after html:#character'); |
!!!parse-error (type => 'after html:#character', token => $token); |
| 5297 |
|
|
| 5298 |
## Reprocess in the "after body" insertion mode. |
## Reprocess in the "after body" insertion mode. |
| 5299 |
} else { |
} else { |
| 5301 |
} |
} |
| 5302 |
|
|
| 5303 |
## "after body" insertion mode |
## "after body" insertion mode |
| 5304 |
!!!parse-error (type => 'after body:#character'); |
!!!parse-error (type => 'after body:#character', token => $token); |
| 5305 |
|
|
| 5306 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 5307 |
## reprocess |
## reprocess |
| 5309 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 5310 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 5311 |
!!!cp ('t303'); |
!!!cp ('t303'); |
| 5312 |
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
!!!parse-error (type => 'after html:'.$token->{tag_name}, token => $token); |
| 5313 |
|
|
| 5314 |
## Reprocess in the "after body" insertion mode. |
## Reprocess in the "after body" insertion mode. |
| 5315 |
} else { |
} else { |
| 5317 |
} |
} |
| 5318 |
|
|
| 5319 |
## "after body" insertion mode |
## "after body" insertion mode |
| 5320 |
!!!parse-error (type => 'after body:'.$token->{tag_name}); |
!!!parse-error (type => 'after body:'.$token->{tag_name}, token => $token); |
| 5321 |
|
|
| 5322 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 5323 |
## reprocess |
## reprocess |
| 5325 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 5326 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 5327 |
!!!cp ('t305'); |
!!!cp ('t305'); |
| 5328 |
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
!!!parse-error (type => 'after html:/'.$token->{tag_name}, token => $token); |
| 5329 |
|
|
| 5330 |
$self->{insertion_mode} = AFTER_BODY_IM; |
$self->{insertion_mode} = AFTER_BODY_IM; |
| 5331 |
## Reprocess in the "after body" insertion mode. |
## Reprocess in the "after body" insertion mode. |
| 5337 |
if ($token->{tag_name} eq 'html') { |
if ($token->{tag_name} eq 'html') { |
| 5338 |
if (defined $self->{inner_html_node}) { |
if (defined $self->{inner_html_node}) { |
| 5339 |
!!!cp ('t307'); |
!!!cp ('t307'); |
| 5340 |
!!!parse-error (type => 'unmatched end tag:html'); |
!!!parse-error (type => 'unmatched end tag:html', token => $token); |
| 5341 |
## Ignore the token |
## Ignore the token |
| 5342 |
!!!next-token; |
!!!next-token; |
| 5343 |
redo B; |
redo B; |
| 5349 |
} |
} |
| 5350 |
} else { |
} else { |
| 5351 |
!!!cp ('t309'); |
!!!cp ('t309'); |
| 5352 |
!!!parse-error (type => 'after body:/'.$token->{tag_name}); |
!!!parse-error (type => 'after body:/'.$token->{tag_name}, token => $token); |
| 5353 |
|
|
| 5354 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 5355 |
## reprocess |
## reprocess |
| 5356 |
redo B; |
redo B; |
| 5357 |
} |
} |
| 5358 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5359 |
|
!!!cp ('t309.2'); |
| 5360 |
|
## Stop parsing |
| 5361 |
|
last B; |
| 5362 |
} else { |
} else { |
| 5363 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 5364 |
} |
} |
| 5377 |
if ($token->{data} =~ s/^[^\x09\x0A\x0B\x0C\x20]+//) { |
if ($token->{data} =~ s/^[^\x09\x0A\x0B\x0C\x20]+//) { |
| 5378 |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
| 5379 |
!!!cp ('t311'); |
!!!cp ('t311'); |
| 5380 |
!!!parse-error (type => 'in frameset:#character'); |
!!!parse-error (type => 'in frameset:#character', token => $token); |
| 5381 |
} elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) { |
} elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) { |
| 5382 |
!!!cp ('t312'); |
!!!cp ('t312'); |
| 5383 |
!!!parse-error (type => 'after frameset:#character'); |
!!!parse-error (type => 'after frameset:#character', token => $token); |
| 5384 |
} else { # "after html frameset" |
} else { # "after html frameset" |
| 5385 |
!!!cp ('t313'); |
!!!cp ('t313'); |
| 5386 |
!!!parse-error (type => 'after html:#character'); |
!!!parse-error (type => 'after html:#character', token => $token); |
| 5387 |
|
|
| 5388 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 5389 |
## Reprocess in the "after frameset" insertion mode. |
## Reprocess in the "after frameset" insertion mode. |
| 5390 |
!!!parse-error (type => 'after frameset:#character'); |
!!!parse-error (type => 'after frameset:#character', token => $token); |
| 5391 |
} |
} |
| 5392 |
|
|
| 5393 |
## Ignore the token. |
## Ignore the token. |
| 5405 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 5406 |
if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
| 5407 |
!!!cp ('t316'); |
!!!cp ('t316'); |
| 5408 |
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
!!!parse-error (type => 'after html:'.$token->{tag_name}, token => $token); |
| 5409 |
|
|
| 5410 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 5411 |
## Process in the "after frameset" insertion mode. |
## Process in the "after frameset" insertion mode. |
| 5416 |
if ($token->{tag_name} eq 'frameset' and |
if ($token->{tag_name} eq 'frameset' and |
| 5417 |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
| 5418 |
!!!cp ('t318'); |
!!!cp ('t318'); |
| 5419 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 5420 |
!!!next-token; |
!!!next-token; |
| 5421 |
redo B; |
redo B; |
| 5422 |
} elsif ($token->{tag_name} eq 'frame' and |
} elsif ($token->{tag_name} eq 'frame' and |
| 5423 |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
| 5424 |
!!!cp ('t319'); |
!!!cp ('t319'); |
| 5425 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 5426 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5427 |
!!!next-token; |
!!!next-token; |
| 5428 |
redo B; |
redo B; |
| 5429 |
} elsif ($token->{tag_name} eq 'noframes') { |
} elsif ($token->{tag_name} eq 'noframes') { |
| 5430 |
!!!cp ('t320'); |
!!!cp ('t320'); |
| 5431 |
## NOTE: As if in body. |
## NOTE: As if in body. |
| 5432 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5433 |
redo B; |
redo B; |
| 5434 |
} else { |
} else { |
| 5435 |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
| 5436 |
!!!cp ('t321'); |
!!!cp ('t321'); |
| 5437 |
!!!parse-error (type => 'in frameset:'.$token->{tag_name}); |
!!!parse-error (type => 'in frameset:'.$token->{tag_name}, token => $token); |
| 5438 |
} else { |
} else { |
| 5439 |
!!!cp ('t322'); |
!!!cp ('t322'); |
| 5440 |
!!!parse-error (type => 'after frameset:'.$token->{tag_name}); |
!!!parse-error (type => 'after frameset:'.$token->{tag_name}, token => $token); |
| 5441 |
} |
} |
| 5442 |
## Ignore the token |
## Ignore the token |
| 5443 |
!!!next-token; |
!!!next-token; |
| 5446 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 5447 |
if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
| 5448 |
!!!cp ('t323'); |
!!!cp ('t323'); |
| 5449 |
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
!!!parse-error (type => 'after html:/'.$token->{tag_name}, token => $token); |
| 5450 |
|
|
| 5451 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 5452 |
## Process in the "after frameset" insertion mode. |
## Process in the "after frameset" insertion mode. |
| 5459 |
if ($self->{open_elements}->[-1]->[1] eq 'html' and |
if ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 5460 |
@{$self->{open_elements}} == 1) { |
@{$self->{open_elements}} == 1) { |
| 5461 |
!!!cp ('t325'); |
!!!cp ('t325'); |
| 5462 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5463 |
## Ignore the token |
## Ignore the token |
| 5464 |
!!!next-token; |
!!!next-token; |
| 5465 |
} else { |
} else { |
| 5485 |
} else { |
} else { |
| 5486 |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
| 5487 |
!!!cp ('t330'); |
!!!cp ('t330'); |
| 5488 |
!!!parse-error (type => 'in frameset:/'.$token->{tag_name}); |
!!!parse-error (type => 'in frameset:/'.$token->{tag_name}, token => $token); |
| 5489 |
} else { |
} else { |
| 5490 |
!!!cp ('t331'); |
!!!cp ('t331'); |
| 5491 |
!!!parse-error (type => 'after frameset:/'.$token->{tag_name}); |
!!!parse-error (type => 'after frameset:/'.$token->{tag_name}, token => $token); |
| 5492 |
} |
} |
| 5493 |
## Ignore the token |
## Ignore the token |
| 5494 |
!!!next-token; |
!!!next-token; |
| 5495 |
redo B; |
redo B; |
| 5496 |
} |
} |
| 5497 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5498 |
|
unless ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 5499 |
|
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 5500 |
|
!!!cp ('t331.1'); |
| 5501 |
|
!!!parse-error (type => 'in body:#eof', token => $token); |
| 5502 |
|
} else { |
| 5503 |
|
!!!cp ('t331.2'); |
| 5504 |
|
} |
| 5505 |
|
|
| 5506 |
|
## Stop parsing |
| 5507 |
|
last B; |
| 5508 |
} else { |
} else { |
| 5509 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 5510 |
} |
} |
| 5519 |
if ($token->{tag_name} eq 'script') { |
if ($token->{tag_name} eq 'script') { |
| 5520 |
!!!cp ('t332'); |
!!!cp ('t332'); |
| 5521 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 5522 |
$script_start_tag->($insert); |
$script_start_tag->(); |
| 5523 |
redo B; |
redo B; |
| 5524 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 5525 |
!!!cp ('t333'); |
!!!cp ('t333'); |
| 5526 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 5527 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5528 |
redo B; |
redo B; |
| 5529 |
} elsif ({ |
} elsif ({ |
| 5530 |
base => 1, link => 1, |
base => 1, link => 1, |
| 5531 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5532 |
!!!cp ('t334'); |
!!!cp ('t334'); |
| 5533 |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
| 5534 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 5535 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 5536 |
!!!next-token; |
!!!next-token; |
| 5537 |
redo B; |
redo B; |
| 5538 |
} elsif ($token->{tag_name} eq 'meta') { |
} elsif ($token->{tag_name} eq 'meta') { |
| 5539 |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
| 5540 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 5541 |
my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 5542 |
|
|
| 5543 |
unless ($self->{confident}) { |
unless ($self->{confident}) { |
| 5544 |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
| 5545 |
!!!cp ('t335'); |
!!!cp ('t335'); |
| 5546 |
$self->{change_encoding} |
$self->{change_encoding} |
| 5547 |
->($self, $token->{attributes}->{charset}->{value}); |
->($self, $token->{attributes}->{charset}->{value}, $token); |
| 5548 |
|
|
| 5549 |
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
| 5550 |
->set_user_data (manakai_has_reference => |
->set_user_data (manakai_has_reference => |
| 5559 |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
| 5560 |
!!!cp ('t336'); |
!!!cp ('t336'); |
| 5561 |
$self->{change_encoding} |
$self->{change_encoding} |
| 5562 |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3); |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3, $token); |
| 5563 |
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
| 5564 |
->set_user_data (manakai_has_reference => |
->set_user_data (manakai_has_reference => |
| 5565 |
$token->{attributes}->{content} |
$token->{attributes}->{content} |
| 5587 |
redo B; |
redo B; |
| 5588 |
} elsif ($token->{tag_name} eq 'title') { |
} elsif ($token->{tag_name} eq 'title') { |
| 5589 |
!!!cp ('t341'); |
!!!cp ('t341'); |
|
!!!parse-error (type => 'in body:title'); |
|
| 5590 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 5591 |
$parse_rcdata->(RCDATA_CONTENT_MODEL, sub { |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
|
if (defined $self->{head_element}) { |
|
|
!!!cp ('t339'); |
|
|
$self->{head_element}->append_child ($_[0]); |
|
|
} else { |
|
|
!!!cp ('t340'); |
|
|
$insert->($_[0]); |
|
|
} |
|
|
}); |
|
| 5592 |
redo B; |
redo B; |
| 5593 |
} elsif ($token->{tag_name} eq 'body') { |
} elsif ($token->{tag_name} eq 'body') { |
| 5594 |
!!!parse-error (type => 'in body:body'); |
!!!parse-error (type => 'in body:body', token => $token); |
| 5595 |
|
|
| 5596 |
if (@{$self->{open_elements}} == 1 or |
if (@{$self->{open_elements}} == 1 or |
| 5597 |
$self->{open_elements}->[1]->[1] ne 'body') { |
$self->{open_elements}->[1]->[1] ne 'body') { |
| 5612 |
redo B; |
redo B; |
| 5613 |
} elsif ({ |
} elsif ({ |
| 5614 |
address => 1, blockquote => 1, center => 1, dir => 1, |
address => 1, blockquote => 1, center => 1, dir => 1, |
| 5615 |
div => 1, dl => 1, fieldset => 1, listing => 1, |
div => 1, dl => 1, fieldset => 1, |
| 5616 |
|
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
| 5617 |
menu => 1, ol => 1, p => 1, ul => 1, |
menu => 1, ol => 1, p => 1, ul => 1, |
| 5618 |
pre => 1, |
pre => 1, listing => 1, |
| 5619 |
|
form => 1, |
| 5620 |
|
table => 1, |
| 5621 |
|
hr => 1, |
| 5622 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5623 |
|
if ($token->{tag_name} eq 'form' and defined $self->{form_element}) { |
| 5624 |
|
!!!cp ('t350'); |
| 5625 |
|
!!!parse-error (type => 'in form:form', token => $token); |
| 5626 |
|
## Ignore the token |
| 5627 |
|
!!!next-token; |
| 5628 |
|
redo B; |
| 5629 |
|
} |
| 5630 |
|
|
| 5631 |
## has a p element in scope |
## has a p element in scope |
| 5632 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 5633 |
if ($_->[1] eq 'p') { |
if ($_->[1] eq 'p') { |
| 5634 |
!!!cp ('t344'); |
!!!cp ('t344'); |
| 5635 |
!!!back-token; |
!!!back-token; |
| 5636 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
| 5637 |
|
line => $token->{line}, column => $token->{column}}; |
| 5638 |
redo B; |
redo B; |
| 5639 |
} elsif ({ |
} elsif ({ |
| 5640 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5641 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5642 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5643 |
!!!cp ('t345'); |
!!!cp ('t345'); |
| 5645 |
} |
} |
| 5646 |
} # INSCOPE |
} # INSCOPE |
| 5647 |
|
|
| 5648 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 5649 |
if ($token->{tag_name} eq 'pre') { |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
| 5650 |
!!!next-token; |
!!!next-token; |
| 5651 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 5652 |
$token->{data} =~ s/^\x0A//; |
$token->{data} =~ s/^\x0A//; |
| 5659 |
} else { |
} else { |
| 5660 |
!!!cp ('t348'); |
!!!cp ('t348'); |
| 5661 |
} |
} |
| 5662 |
} else { |
} elsif ($token->{tag_name} eq 'form') { |
| 5663 |
!!!cp ('t347'); |
!!!cp ('t347.1'); |
| 5664 |
|
$self->{form_element} = $self->{open_elements}->[-1]->[0]; |
| 5665 |
|
|
| 5666 |
!!!next-token; |
!!!next-token; |
| 5667 |
} |
} elsif ($token->{tag_name} eq 'table') { |
| 5668 |
redo B; |
!!!cp ('t382'); |
| 5669 |
} elsif ($token->{tag_name} eq 'form') { |
push @{$open_tables}, [$self->{open_elements}->[-1]->[0]]; |
| 5670 |
if (defined $self->{form_element}) { |
|
| 5671 |
!!!cp ('t350'); |
$self->{insertion_mode} = IN_TABLE_IM; |
| 5672 |
!!!parse-error (type => 'in form:form'); |
|
| 5673 |
## Ignore the token |
!!!next-token; |
| 5674 |
|
} elsif ($token->{tag_name} eq 'hr') { |
| 5675 |
|
!!!cp ('t386'); |
| 5676 |
|
pop @{$self->{open_elements}}; |
| 5677 |
|
|
| 5678 |
!!!next-token; |
!!!next-token; |
|
redo B; |
|
| 5679 |
} else { |
} else { |
| 5680 |
## has a p element in scope |
!!!cp ('t347'); |
|
INSCOPE: for (reverse @{$self->{open_elements}}) { |
|
|
if ($_->[1] eq 'p') { |
|
|
!!!cp ('t351'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$_->[1]}) { |
|
|
!!!cp ('t352'); |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
$self->{form_element} = $self->{open_elements}->[-1]->[0]; |
|
| 5681 |
!!!next-token; |
!!!next-token; |
|
redo B; |
|
| 5682 |
} |
} |
| 5683 |
} elsif ($token->{tag_name} eq 'li') { |
redo B; |
| 5684 |
|
} elsif ({li => 1, dt => 1, dd => 1}->{$token->{tag_name}}) { |
| 5685 |
## has a p element in scope |
## has a p element in scope |
| 5686 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 5687 |
if ($_->[1] eq 'p') { |
if ($_->[1] eq 'p') { |
| 5688 |
!!!cp ('t353'); |
!!!cp ('t353'); |
| 5689 |
!!!back-token; |
!!!back-token; |
| 5690 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
| 5691 |
|
line => $token->{line}, column => $token->{column}}; |
| 5692 |
redo B; |
redo B; |
| 5693 |
} elsif ({ |
} elsif ({ |
| 5694 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5695 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5696 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5697 |
!!!cp ('t354'); |
!!!cp ('t354'); |
| 5702 |
## Step 1 |
## Step 1 |
| 5703 |
my $i = -1; |
my $i = -1; |
| 5704 |
my $node = $self->{open_elements}->[$i]; |
my $node = $self->{open_elements}->[$i]; |
| 5705 |
|
my $li_or_dtdd = {li => {li => 1}, |
| 5706 |
|
dt => {dt => 1, dd => 1}, |
| 5707 |
|
dd => {dt => 1, dd => 1}}->{$token->{tag_name}}; |
| 5708 |
LI: { |
LI: { |
| 5709 |
## Step 2 |
## Step 2 |
| 5710 |
if ($node->[1] eq 'li') { |
if ($li_or_dtdd->{$node->[1]}) { |
| 5711 |
if ($i != -1) { |
if ($i != -1) { |
| 5712 |
!!!cp ('t355'); |
!!!cp ('t355'); |
| 5713 |
!!!parse-error (type => 'end tag missing:'. |
!!!parse-error (type => 'end tag missing:'. |
| 5714 |
$self->{open_elements}->[-1]->[1]); |
$self->{open_elements}->[-1]->[1], token => $token); |
| 5715 |
} else { |
} else { |
| 5716 |
!!!cp ('t356'); |
!!!cp ('t356'); |
| 5717 |
} |
} |
| 5738 |
redo LI; |
redo LI; |
| 5739 |
} # LI |
} # LI |
| 5740 |
|
|
| 5741 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'dd' or $token->{tag_name} eq 'dt') { |
|
|
## has a p element in scope |
|
|
INSCOPE: for (reverse @{$self->{open_elements}}) { |
|
|
if ($_->[1] eq 'p') { |
|
|
!!!cp ('t360'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$_->[1]}) { |
|
|
!!!cp ('t361'); |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
|
|
|
## Step 1 |
|
|
my $i = -1; |
|
|
my $node = $self->{open_elements}->[$i]; |
|
|
LI: { |
|
|
## Step 2 |
|
|
if ($node->[1] eq 'dt' or $node->[1] eq 'dd') { |
|
|
if ($i != -1) { |
|
|
!!!cp ('t362'); |
|
|
!!!parse-error (type => 'end tag missing:'. |
|
|
$self->{open_elements}->[-1]->[1]); |
|
|
} else { |
|
|
!!!cp ('t363'); |
|
|
} |
|
|
splice @{$self->{open_elements}}, $i; |
|
|
last LI; |
|
|
} else { |
|
|
!!!cp ('t364'); |
|
|
} |
|
|
|
|
|
## Step 3 |
|
|
if (not $formatting_category->{$node->[1]} and |
|
|
#not $phrasing_category->{$node->[1]} and |
|
|
($special_category->{$node->[1]} or |
|
|
$scoping_category->{$node->[1]}) and |
|
|
$node->[1] ne 'address' and $node->[1] ne 'div') { |
|
|
!!!cp ('t365'); |
|
|
last LI; |
|
|
} |
|
|
|
|
|
!!!cp ('t366'); |
|
|
## Step 4 |
|
|
$i--; |
|
|
$node = $self->{open_elements}->[$i]; |
|
|
redo LI; |
|
|
} # LI |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
| 5742 |
!!!next-token; |
!!!next-token; |
| 5743 |
redo B; |
redo B; |
| 5744 |
} elsif ($token->{tag_name} eq 'plaintext') { |
} elsif ($token->{tag_name} eq 'plaintext') { |
| 5747 |
if ($_->[1] eq 'p') { |
if ($_->[1] eq 'p') { |
| 5748 |
!!!cp ('t367'); |
!!!cp ('t367'); |
| 5749 |
!!!back-token; |
!!!back-token; |
| 5750 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
| 5751 |
|
line => $token->{line}, column => $token->{column}}; |
| 5752 |
redo B; |
redo B; |
| 5753 |
} elsif ({ |
} elsif ({ |
| 5754 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5755 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5756 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5757 |
!!!cp ('t368'); |
!!!cp ('t368'); |
| 5759 |
} |
} |
| 5760 |
} # INSCOPE |
} # INSCOPE |
| 5761 |
|
|
| 5762 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 5763 |
|
|
| 5764 |
$self->{content_model} = PLAINTEXT_CONTENT_MODEL; |
$self->{content_model} = PLAINTEXT_CONTENT_MODEL; |
| 5765 |
|
|
| 5766 |
!!!next-token; |
!!!next-token; |
| 5767 |
redo B; |
redo B; |
|
} elsif ({ |
|
|
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## has a p element in scope |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq 'p') { |
|
|
!!!cp ('t369'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
!!!cp ('t370'); |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
|
|
|
## NOTE: See <http://html5.org/tools/web-apps-tracker?from=925&to=926> |
|
|
## has an element in scope |
|
|
#my $i; |
|
|
#INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
# my $node = $self->{open_elements}->[$_]; |
|
|
# if ({ |
|
|
# h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
|
|
# }->{$node->[1]}) { |
|
|
# $i = $_; |
|
|
# last INSCOPE; |
|
|
# } elsif ({ |
|
|
# table => 1, caption => 1, td => 1, th => 1, |
|
|
# button => 1, marquee => 1, object => 1, html => 1, |
|
|
# }->{$node->[1]}) { |
|
|
# last INSCOPE; |
|
|
# } |
|
|
#} # INSCOPE |
|
|
# |
|
|
#if (defined $i) { |
|
|
# !!! parse-error (type => 'in hn:hn'); |
|
|
# splice @{$self->{open_elements}}, $i; |
|
|
#} |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
| 5768 |
} elsif ($token->{tag_name} eq 'a') { |
} elsif ($token->{tag_name} eq 'a') { |
| 5769 |
AFE: for my $i (reverse 0..$#$active_formatting_elements) { |
AFE: for my $i (reverse 0..$#$active_formatting_elements) { |
| 5770 |
my $node = $active_formatting_elements->[$i]; |
my $node = $active_formatting_elements->[$i]; |
| 5771 |
if ($node->[1] eq 'a') { |
if ($node->[1] eq 'a') { |
| 5772 |
!!!cp ('t371'); |
!!!cp ('t371'); |
| 5773 |
!!!parse-error (type => 'in a:a'); |
!!!parse-error (type => 'in a:a', token => $token); |
| 5774 |
|
|
| 5775 |
!!!back-token; |
!!!back-token; |
| 5776 |
$token = {type => END_TAG_TOKEN, tag_name => 'a'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'a', |
| 5777 |
$formatting_end_tag->($token->{tag_name}); |
line => $token->{line}, column => $token->{column}}; |
| 5778 |
|
$formatting_end_tag->($token); |
| 5779 |
|
|
| 5780 |
AFE2: for (reverse 0..$#$active_formatting_elements) { |
AFE2: for (reverse 0..$#$active_formatting_elements) { |
| 5781 |
if ($active_formatting_elements->[$_]->[0] eq $node->[0]) { |
if ($active_formatting_elements->[$_]->[0] eq $node->[0]) { |
| 5800 |
|
|
| 5801 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 5802 |
|
|
| 5803 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 5804 |
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
| 5805 |
|
|
| 5806 |
!!!next-token; |
!!!next-token; |
| 5807 |
redo B; |
redo B; |
|
} elsif ({ |
|
|
b => 1, big => 1, em => 1, font => 1, i => 1, |
|
|
s => 1, small => 1, strile => 1, |
|
|
strong => 1, tt => 1, u => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
!!!cp ('t375'); |
|
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
| 5808 |
} elsif ($token->{tag_name} eq 'nobr') { |
} elsif ($token->{tag_name} eq 'nobr') { |
| 5809 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 5810 |
|
|
| 5813 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5814 |
if ($node->[1] eq 'nobr') { |
if ($node->[1] eq 'nobr') { |
| 5815 |
!!!cp ('t376'); |
!!!cp ('t376'); |
| 5816 |
!!!parse-error (type => 'in nobr:nobr'); |
!!!parse-error (type => 'in nobr:nobr', token => $token); |
| 5817 |
!!!back-token; |
!!!back-token; |
| 5818 |
$token = {type => END_TAG_TOKEN, tag_name => 'nobr'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'nobr', |
| 5819 |
|
line => $token->{line}, column => $token->{column}}; |
| 5820 |
redo B; |
redo B; |
| 5821 |
} elsif ({ |
} elsif ({ |
| 5822 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5823 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5824 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 5825 |
!!!cp ('t377'); |
!!!cp ('t377'); |
| 5827 |
} |
} |
| 5828 |
} # INSCOPE |
} # INSCOPE |
| 5829 |
|
|
| 5830 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 5831 |
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
| 5832 |
|
|
| 5833 |
!!!next-token; |
!!!next-token; |
| 5838 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5839 |
if ($node->[1] eq 'button') { |
if ($node->[1] eq 'button') { |
| 5840 |
!!!cp ('t378'); |
!!!cp ('t378'); |
| 5841 |
!!!parse-error (type => 'in button:button'); |
!!!parse-error (type => 'in button:button', token => $token); |
| 5842 |
!!!back-token; |
!!!back-token; |
| 5843 |
$token = {type => END_TAG_TOKEN, tag_name => 'button'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'button', |
| 5844 |
|
line => $token->{line}, column => $token->{column}}; |
| 5845 |
redo B; |
redo B; |
| 5846 |
} elsif ({ |
} elsif ({ |
| 5847 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5848 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5849 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 5850 |
!!!cp ('t379'); |
!!!cp ('t379'); |
| 5854 |
|
|
| 5855 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 5856 |
|
|
| 5857 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 5858 |
push @$active_formatting_elements, ['#marker', '']; |
|
| 5859 |
|
## TODO: associate with $self->{form_element} if defined |
| 5860 |
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'marquee' or |
|
|
$token->{tag_name} eq 'object') { |
|
|
!!!cp ('t380'); |
|
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
| 5861 |
push @$active_formatting_elements, ['#marker', '']; |
push @$active_formatting_elements, ['#marker', '']; |
| 5862 |
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'xmp') { |
|
|
!!!cp ('t381'); |
|
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'table') { |
|
|
## has a p element in scope |
|
|
INSCOPE: for (reverse @{$self->{open_elements}}) { |
|
|
if ($_->[1] eq 'p') { |
|
|
!!!cp ('t382'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$_->[1]}) { |
|
|
!!!cp ('t383'); |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
|
|
|
$self->{insertion_mode} = IN_TABLE_IM; |
|
|
|
|
| 5863 |
!!!next-token; |
!!!next-token; |
| 5864 |
redo B; |
redo B; |
| 5865 |
} elsif ({ |
} elsif ({ |
| 5866 |
area => 1, basefont => 1, bgsound => 1, br => 1, |
xmp => 1, |
| 5867 |
embed => 1, img => 1, param => 1, spacer => 1, wbr => 1, |
iframe => 1, |
| 5868 |
image => 1, |
noembed => 1, |
| 5869 |
|
noframes => 1, |
| 5870 |
|
noscript => 0, ## TODO: 1 if scripting is enabled |
| 5871 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5872 |
if ($token->{tag_name} eq 'image') { |
if ($token->{tag_name} eq 'xmp') { |
| 5873 |
!!!cp ('t384'); |
!!!cp ('t381'); |
| 5874 |
!!!parse-error (type => 'image'); |
$reconstruct_active_formatting_elements->($insert_to_current); |
|
$token->{tag_name} = 'img'; |
|
| 5875 |
} else { |
} else { |
| 5876 |
!!!cp ('t385'); |
!!!cp ('t399'); |
| 5877 |
} |
} |
| 5878 |
|
## NOTE: There is an "as if in body" code clone. |
| 5879 |
## NOTE: There is an "as if <br>" code clone. |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
pop @{$self->{open_elements}}; |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'hr') { |
|
|
## has a p element in scope |
|
|
INSCOPE: for (reverse @{$self->{open_elements}}) { |
|
|
if ($_->[1] eq 'p') { |
|
|
!!!cp ('t386'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$_->[1]}) { |
|
|
!!!cp ('t387'); |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
pop @{$self->{open_elements}}; |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'input') { |
|
|
!!!cp ('t388'); |
|
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
## TODO: associate with $self->{form_element} if defined |
|
|
pop @{$self->{open_elements}}; |
|
|
|
|
|
!!!next-token; |
|
| 5880 |
redo B; |
redo B; |
| 5881 |
} elsif ($token->{tag_name} eq 'isindex') { |
} elsif ($token->{tag_name} eq 'isindex') { |
| 5882 |
!!!parse-error (type => 'isindex'); |
!!!parse-error (type => 'isindex', token => $token); |
| 5883 |
|
|
| 5884 |
if (defined $self->{form_element}) { |
if (defined $self->{form_element}) { |
| 5885 |
!!!cp ('t389'); |
!!!cp ('t389'); |
| 5896 |
delete $at->{prompt}; |
delete $at->{prompt}; |
| 5897 |
my @tokens = ( |
my @tokens = ( |
| 5898 |
{type => START_TAG_TOKEN, tag_name => 'form', |
{type => START_TAG_TOKEN, tag_name => 'form', |
| 5899 |
attributes => $form_attrs}, |
attributes => $form_attrs, |
| 5900 |
{type => START_TAG_TOKEN, tag_name => 'hr'}, |
line => $token->{line}, column => $token->{column}}, |
| 5901 |
{type => START_TAG_TOKEN, tag_name => 'p'}, |
{type => START_TAG_TOKEN, tag_name => 'hr', |
| 5902 |
{type => START_TAG_TOKEN, tag_name => 'label'}, |
line => $token->{line}, column => $token->{column}}, |
| 5903 |
|
{type => START_TAG_TOKEN, tag_name => 'p', |
| 5904 |
|
line => $token->{line}, column => $token->{column}}, |
| 5905 |
|
{type => START_TAG_TOKEN, tag_name => 'label', |
| 5906 |
|
line => $token->{line}, column => $token->{column}}, |
| 5907 |
); |
); |
| 5908 |
if ($prompt_attr) { |
if ($prompt_attr) { |
| 5909 |
!!!cp ('t390'); |
!!!cp ('t390'); |
| 5910 |
push @tokens, {type => CHARACTER_TOKEN, data => $prompt_attr->{value}}; |
push @tokens, {type => CHARACTER_TOKEN, data => $prompt_attr->{value}, |
| 5911 |
|
line => $token->{line}, column => $token->{column}}; |
| 5912 |
} else { |
} else { |
| 5913 |
!!!cp ('t391'); |
!!!cp ('t391'); |
| 5914 |
push @tokens, {type => CHARACTER_TOKEN, |
push @tokens, {type => CHARACTER_TOKEN, |
| 5915 |
data => 'This is a searchable index. Insert your search keywords here: '}; # SHOULD |
data => 'This is a searchable index. Insert your search keywords here: ', |
| 5916 |
|
line => $token->{line}, column => $token->{column}}; # SHOULD |
| 5917 |
## TODO: make this configurable |
## TODO: make this configurable |
| 5918 |
} |
} |
| 5919 |
push @tokens, |
push @tokens, |
| 5920 |
{type => START_TAG_TOKEN, tag_name => 'input', attributes => $at}, |
{type => START_TAG_TOKEN, tag_name => 'input', attributes => $at, |
| 5921 |
|
line => $token->{line}, column => $token->{column}}, |
| 5922 |
#{type => CHARACTER_TOKEN, data => ''}, # SHOULD |
#{type => CHARACTER_TOKEN, data => ''}, # SHOULD |
| 5923 |
{type => END_TAG_TOKEN, tag_name => 'label'}, |
{type => END_TAG_TOKEN, tag_name => 'label', |
| 5924 |
{type => END_TAG_TOKEN, tag_name => 'p'}, |
line => $token->{line}, column => $token->{column}}, |
| 5925 |
{type => START_TAG_TOKEN, tag_name => 'hr'}, |
{type => END_TAG_TOKEN, tag_name => 'p', |
| 5926 |
{type => END_TAG_TOKEN, tag_name => 'form'}; |
line => $token->{line}, column => $token->{column}}, |
| 5927 |
|
{type => START_TAG_TOKEN, tag_name => 'hr', |
| 5928 |
|
line => $token->{line}, column => $token->{column}}, |
| 5929 |
|
{type => END_TAG_TOKEN, tag_name => 'form', |
| 5930 |
|
line => $token->{line}, column => $token->{column}}; |
| 5931 |
$token = shift @tokens; |
$token = shift @tokens; |
| 5932 |
!!!back-token (@tokens); |
!!!back-token (@tokens); |
| 5933 |
redo B; |
redo B; |
| 5935 |
} elsif ($token->{tag_name} eq 'textarea') { |
} elsif ($token->{tag_name} eq 'textarea') { |
| 5936 |
my $tag_name = $token->{tag_name}; |
my $tag_name = $token->{tag_name}; |
| 5937 |
my $el; |
my $el; |
| 5938 |
!!!create-element ($el, $token->{tag_name}, $token->{attributes}); |
!!!create-element ($el, $token->{tag_name}, $token->{attributes}, $token); |
| 5939 |
|
|
| 5940 |
## TODO: $self->{form_element} if defined |
## TODO: $self->{form_element} if defined |
| 5941 |
$self->{content_model} = RCDATA_CONTENT_MODEL; |
$self->{content_model} = RCDATA_CONTENT_MODEL; |
| 5974 |
## Ignore the token |
## Ignore the token |
| 5975 |
} else { |
} else { |
| 5976 |
!!!cp ('t398'); |
!!!cp ('t398'); |
| 5977 |
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
!!!parse-error (type => 'in RCDATA:#'.$token->{type}, token => $token); |
| 5978 |
} |
} |
| 5979 |
!!!next-token; |
!!!next-token; |
| 5980 |
redo B; |
redo B; |
| 5981 |
} elsif ({ |
} elsif ({ |
|
iframe => 1, |
|
|
noembed => 1, |
|
|
noframes => 1, |
|
|
noscript => 0, ## TODO: 1 if scripting is enabled |
|
|
}->{$token->{tag_name}}) { |
|
|
!!!cp ('t399'); |
|
|
## NOTE: There is an "as if in body" code clone. |
|
|
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'select') { |
|
|
!!!cp ('t400'); |
|
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
|
|
|
$self->{insertion_mode} = IN_SELECT_IM; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ({ |
|
| 5982 |
caption => 1, col => 1, colgroup => 1, frame => 1, |
caption => 1, col => 1, colgroup => 1, frame => 1, |
| 5983 |
frameset => 1, head => 1, option => 1, optgroup => 1, |
frameset => 1, head => 1, option => 1, optgroup => 1, |
| 5984 |
tbody => 1, td => 1, tfoot => 1, th => 1, |
tbody => 1, td => 1, tfoot => 1, th => 1, |
| 5985 |
thead => 1, tr => 1, |
thead => 1, tr => 1, |
| 5986 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5987 |
!!!cp ('t401'); |
!!!cp ('t401'); |
| 5988 |
!!!parse-error (type => 'in body:'.$token->{tag_name}); |
!!!parse-error (type => 'in body:'.$token->{tag_name}, token => $token); |
| 5989 |
## Ignore the token |
## Ignore the token |
| 5990 |
!!!next-token; |
!!!next-token; |
| 5991 |
redo B; |
redo B; |
| 5992 |
|
|
| 5993 |
## ISSUE: An issue on HTML5 new elements in the spec. |
## ISSUE: An issue on HTML5 new elements in the spec. |
| 5994 |
} else { |
} else { |
| 5995 |
!!!cp ('t402'); |
if ($token->{tag_name} eq 'image') { |
| 5996 |
|
!!!cp ('t384'); |
| 5997 |
|
!!!parse-error (type => 'image', token => $token); |
| 5998 |
|
$token->{tag_name} = 'img'; |
| 5999 |
|
} else { |
| 6000 |
|
!!!cp ('t385'); |
| 6001 |
|
} |
| 6002 |
|
|
| 6003 |
|
## NOTE: There is an "as if <br>" code clone. |
| 6004 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 6005 |
|
|
| 6006 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 6007 |
|
|
| 6008 |
|
if ({ |
| 6009 |
|
applet => 1, marquee => 1, object => 1, |
| 6010 |
|
}->{$token->{tag_name}}) { |
| 6011 |
|
!!!cp ('t380'); |
| 6012 |
|
push @$active_formatting_elements, ['#marker', '']; |
| 6013 |
|
} elsif ({ |
| 6014 |
|
b => 1, big => 1, em => 1, font => 1, i => 1, |
| 6015 |
|
s => 1, small => 1, strile => 1, |
| 6016 |
|
strong => 1, tt => 1, u => 1, |
| 6017 |
|
}->{$token->{tag_name}}) { |
| 6018 |
|
!!!cp ('t375'); |
| 6019 |
|
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
| 6020 |
|
} elsif ($token->{tag_name} eq 'input') { |
| 6021 |
|
!!!cp ('t388'); |
| 6022 |
|
## TODO: associate with $self->{form_element} if defined |
| 6023 |
|
pop @{$self->{open_elements}}; |
| 6024 |
|
} elsif ({ |
| 6025 |
|
area => 1, basefont => 1, bgsound => 1, br => 1, |
| 6026 |
|
embed => 1, img => 1, param => 1, spacer => 1, wbr => 1, |
| 6027 |
|
#image => 1, |
| 6028 |
|
}->{$token->{tag_name}}) { |
| 6029 |
|
!!!cp ('t388.1'); |
| 6030 |
|
pop @{$self->{open_elements}}; |
| 6031 |
|
} elsif ($token->{tag_name} eq 'select') { |
| 6032 |
|
## TODO: associate with $self->{form_element} if defined |
| 6033 |
|
|
| 6034 |
|
if ($self->{insertion_mode} & TABLE_IMS or |
| 6035 |
|
$self->{insertion_mode} & BODY_TABLE_IMS or |
| 6036 |
|
$self->{insertion_mode} == IN_COLUMN_GROUP_IM) { |
| 6037 |
|
!!!cp ('t400.1'); |
| 6038 |
|
$self->{insertion_mode} = IN_SELECT_IN_TABLE_IM; |
| 6039 |
|
} else { |
| 6040 |
|
!!!cp ('t400.2'); |
| 6041 |
|
$self->{insertion_mode} = IN_SELECT_IM; |
| 6042 |
|
} |
| 6043 |
|
} else { |
| 6044 |
|
!!!cp ('t402'); |
| 6045 |
|
} |
| 6046 |
|
|
| 6047 |
!!!next-token; |
!!!next-token; |
| 6048 |
redo B; |
redo B; |
| 6049 |
} |
} |
| 6050 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 6051 |
if ($token->{tag_name} eq 'body') { |
if ($token->{tag_name} eq 'body') { |
| 6052 |
if (@{$self->{open_elements}} > 1 and |
## has a |body| element in scope |
| 6053 |
$self->{open_elements}->[1]->[1] eq 'body') { |
my $i; |
| 6054 |
for (@{$self->{open_elements}}) { |
INSCOPE: { |
| 6055 |
unless ({ |
for (reverse @{$self->{open_elements}}) { |
| 6056 |
dd => 1, dt => 1, li => 1, p => 1, td => 1, |
if ($_->[1] eq 'body') { |
| 6057 |
th => 1, tr => 1, body => 1, html => 1, |
!!!cp ('t405'); |
| 6058 |
tbody => 1, tfoot => 1, thead => 1, |
$i = $_; |
| 6059 |
}->{$_->[1]}) { |
last INSCOPE; |
| 6060 |
!!!cp ('t403'); |
} elsif ({ |
| 6061 |
!!!parse-error (type => 'not closed:'.$_->[1]); |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6062 |
} else { |
button => 1, marquee => 1, object => 1, html => 1, |
| 6063 |
!!!cp ('t404'); |
}->{$_->[1]}) { |
| 6064 |
|
!!!cp ('t405.1'); |
| 6065 |
|
last; |
| 6066 |
} |
} |
| 6067 |
} |
} |
| 6068 |
|
|
| 6069 |
$self->{insertion_mode} = AFTER_BODY_IM; |
!!!parse-error (type => 'start tag not allowed', |
| 6070 |
!!!next-token; |
value => $token->{tag_name}, token => $token); |
| 6071 |
redo B; |
## NOTE: Ignore the token. |
|
} else { |
|
|
!!!cp ('t405'); |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
| 6072 |
!!!next-token; |
!!!next-token; |
| 6073 |
redo B; |
redo B; |
| 6074 |
|
} # INSCOPE |
| 6075 |
|
|
| 6076 |
|
for (@{$self->{open_elements}}) { |
| 6077 |
|
unless ({ |
| 6078 |
|
dd => 1, dt => 1, li => 1, p => 1, td => 1, |
| 6079 |
|
th => 1, tr => 1, body => 1, html => 1, |
| 6080 |
|
tbody => 1, tfoot => 1, thead => 1, |
| 6081 |
|
}->{$_->[1]}) { |
| 6082 |
|
!!!cp ('t403'); |
| 6083 |
|
!!!parse-error (type => 'not closed:'.$_->[1], token => $token); |
| 6084 |
|
last; |
| 6085 |
|
} else { |
| 6086 |
|
!!!cp ('t404'); |
| 6087 |
|
} |
| 6088 |
} |
} |
| 6089 |
|
|
| 6090 |
|
$self->{insertion_mode} = AFTER_BODY_IM; |
| 6091 |
|
!!!next-token; |
| 6092 |
|
redo B; |
| 6093 |
} elsif ($token->{tag_name} eq 'html') { |
} elsif ($token->{tag_name} eq 'html') { |
| 6094 |
if (@{$self->{open_elements}} > 1 and $self->{open_elements}->[1]->[1] eq 'body') { |
if (@{$self->{open_elements}} > 1 and $self->{open_elements}->[1]->[1] eq 'body') { |
| 6095 |
## ISSUE: There is an issue in the spec. |
## ISSUE: There is an issue in the spec. |
| 6096 |
if ($self->{open_elements}->[-1]->[1] ne 'body') { |
if ($self->{open_elements}->[-1]->[1] ne 'body') { |
| 6097 |
!!!cp ('t406'); |
!!!cp ('t406'); |
| 6098 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[1]->[1], token => $token); |
| 6099 |
} else { |
} else { |
| 6100 |
!!!cp ('t407'); |
!!!cp ('t407'); |
| 6101 |
} |
} |
| 6104 |
redo B; |
redo B; |
| 6105 |
} else { |
} else { |
| 6106 |
!!!cp ('t408'); |
!!!cp ('t408'); |
| 6107 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6108 |
## Ignore the token |
## Ignore the token |
| 6109 |
!!!next-token; |
!!!next-token; |
| 6110 |
redo B; |
redo B; |
| 6113 |
address => 1, blockquote => 1, center => 1, dir => 1, |
address => 1, blockquote => 1, center => 1, dir => 1, |
| 6114 |
div => 1, dl => 1, fieldset => 1, listing => 1, |
div => 1, dl => 1, fieldset => 1, listing => 1, |
| 6115 |
menu => 1, ol => 1, pre => 1, ul => 1, |
menu => 1, ol => 1, pre => 1, ul => 1, |
|
p => 1, |
|
| 6116 |
dd => 1, dt => 1, li => 1, |
dd => 1, dt => 1, li => 1, |
| 6117 |
button => 1, marquee => 1, object => 1, |
applet => 1, button => 1, marquee => 1, object => 1, |
| 6118 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6119 |
## has an element in scope |
## has an element in scope |
| 6120 |
my $i; |
my $i; |
| 6121 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6122 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 6123 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq $token->{tag_name}) { |
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => ($token->{tag_name} ne 'dd'), |
|
|
dt => ($token->{tag_name} ne 'dt'), |
|
|
li => ($token->{tag_name} ne 'li'), |
|
|
p => ($token->{tag_name} ne 'p'), |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!cp ('t409'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
| 6124 |
!!!cp ('t410'); |
!!!cp ('t410'); |
| 6125 |
$i = $_; |
$i = $_; |
| 6126 |
last INSCOPE unless $token->{tag_name} eq 'p'; |
last INSCOPE; |
| 6127 |
} elsif ({ |
} elsif ({ |
| 6128 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6129 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 6130 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 6131 |
!!!cp ('t411'); |
!!!cp ('t411'); |
| 6132 |
last INSCOPE; |
last INSCOPE; |
| 6133 |
} |
} |
| 6134 |
} # INSCOPE |
} # INSCOPE |
| 6135 |
|
|
| 6136 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
unless (defined $i) { # has an element in scope |
| 6137 |
if (defined $i) { |
!!!cp ('t413'); |
| 6138 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6139 |
|
} else { |
| 6140 |
|
## Step 1. generate implied end tags |
| 6141 |
|
while ({ |
| 6142 |
|
dd => ($token->{tag_name} ne 'dd'), |
| 6143 |
|
dt => ($token->{tag_name} ne 'dt'), |
| 6144 |
|
li => ($token->{tag_name} ne 'li'), |
| 6145 |
|
p => 1, |
| 6146 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 6147 |
|
!!!cp ('t409'); |
| 6148 |
|
pop @{$self->{open_elements}}; |
| 6149 |
|
} |
| 6150 |
|
|
| 6151 |
|
## Step 2. |
| 6152 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6153 |
!!!cp ('t412'); |
!!!cp ('t412'); |
| 6154 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 6155 |
} else { |
} else { |
| 6156 |
!!!cp ('t413'); |
!!!cp ('t414'); |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
| 6157 |
} |
} |
| 6158 |
} |
|
| 6159 |
|
## Step 3. |
|
if (defined $i) { |
|
|
!!!cp ('t414'); |
|
| 6160 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 6161 |
} elsif ($token->{tag_name} eq 'p') { |
|
| 6162 |
!!!cp ('t415'); |
## Step 4. |
| 6163 |
## As if <p>, then reprocess the current token |
$clear_up_to_marker->() |
| 6164 |
my $el; |
if { |
| 6165 |
!!!create-element ($el, 'p'); |
applet => 1, button => 1, marquee => 1, object => 1, |
| 6166 |
$insert->($el); |
}->{$token->{tag_name}}; |
|
} else { |
|
|
!!!cp ('t416'); |
|
| 6167 |
} |
} |
|
$clear_up_to_marker->() |
|
|
if { |
|
|
button => 1, marquee => 1, object => 1, |
|
|
}->{$token->{tag_name}}; |
|
| 6168 |
!!!next-token; |
!!!next-token; |
| 6169 |
redo B; |
redo B; |
| 6170 |
} elsif ($token->{tag_name} eq 'form') { |
} elsif ($token->{tag_name} eq 'form') { |
| 6171 |
|
undef $self->{form_element}; |
| 6172 |
|
|
| 6173 |
## has an element in scope |
## has an element in scope |
| 6174 |
|
my $i; |
| 6175 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6176 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 6177 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq $token->{tag_name}) { |
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
|
|
|
## NOTE: The following elements never appear here, maybe. |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!cp ('t417'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
| 6178 |
!!!cp ('t418'); |
!!!cp ('t418'); |
| 6179 |
|
$i = $_; |
| 6180 |
last INSCOPE; |
last INSCOPE; |
| 6181 |
} elsif ({ |
} elsif ({ |
| 6182 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6183 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 6184 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 6185 |
!!!cp ('t419'); |
!!!cp ('t419'); |
| 6186 |
last INSCOPE; |
last INSCOPE; |
| 6187 |
} |
} |
| 6188 |
} # INSCOPE |
} # INSCOPE |
| 6189 |
|
|
| 6190 |
if ($self->{open_elements}->[-1]->[1] eq $token->{tag_name}) { |
unless (defined $i) { # has an element in scope |
|
!!!cp ('t420'); |
|
|
pop @{$self->{open_elements}}; |
|
|
} else { |
|
| 6191 |
!!!cp ('t421'); |
!!!cp ('t421'); |
| 6192 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6193 |
|
} else { |
| 6194 |
|
## Step 1. generate implied end tags |
| 6195 |
|
while ({ |
| 6196 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 6197 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 6198 |
|
!!!cp ('t417'); |
| 6199 |
|
pop @{$self->{open_elements}}; |
| 6200 |
|
} |
| 6201 |
|
|
| 6202 |
|
## Step 2. |
| 6203 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6204 |
|
!!!cp ('t417.1'); |
| 6205 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 6206 |
|
} else { |
| 6207 |
|
!!!cp ('t420'); |
| 6208 |
|
} |
| 6209 |
|
|
| 6210 |
|
## Step 3. |
| 6211 |
|
splice @{$self->{open_elements}}, $i; |
| 6212 |
} |
} |
| 6213 |
|
|
|
undef $self->{form_element}; |
|
| 6214 |
!!!next-token; |
!!!next-token; |
| 6215 |
redo B; |
redo B; |
| 6216 |
} elsif ({ |
} elsif ({ |
| 6223 |
if ({ |
if ({ |
| 6224 |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
| 6225 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
|
## 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]}) { |
|
|
!!!cp ('t422'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
| 6226 |
!!!cp ('t423'); |
!!!cp ('t423'); |
| 6227 |
$i = $_; |
$i = $_; |
| 6228 |
last INSCOPE; |
last INSCOPE; |
| 6229 |
} elsif ({ |
} elsif ({ |
| 6230 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6231 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 6232 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 6233 |
!!!cp ('t424'); |
!!!cp ('t424'); |
| 6234 |
last INSCOPE; |
last INSCOPE; |
| 6235 |
} |
} |
| 6236 |
} # INSCOPE |
} # INSCOPE |
| 6237 |
|
|
| 6238 |
|
unless (defined $i) { # has an element in scope |
| 6239 |
|
!!!cp ('t425.1'); |
| 6240 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6241 |
|
} else { |
| 6242 |
|
## Step 1. generate implied end tags |
| 6243 |
|
while ({ |
| 6244 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 6245 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 6246 |
|
!!!cp ('t422'); |
| 6247 |
|
pop @{$self->{open_elements}}; |
| 6248 |
|
} |
| 6249 |
|
|
| 6250 |
|
## Step 2. |
| 6251 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6252 |
|
!!!cp ('t425'); |
| 6253 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6254 |
|
} else { |
| 6255 |
|
!!!cp ('t426'); |
| 6256 |
|
} |
| 6257 |
|
|
| 6258 |
|
## Step 3. |
| 6259 |
|
splice @{$self->{open_elements}}, $i; |
| 6260 |
|
} |
| 6261 |
|
|
| 6262 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
!!!next-token; |
| 6263 |
!!!cp ('t425'); |
redo B; |
| 6264 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
} elsif ($token->{tag_name} eq 'p') { |
| 6265 |
|
## has an element in scope |
| 6266 |
|
my $i; |
| 6267 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6268 |
|
my $node = $self->{open_elements}->[$_]; |
| 6269 |
|
if ($node->[1] eq $token->{tag_name}) { |
| 6270 |
|
!!!cp ('t410.1'); |
| 6271 |
|
$i = $_; |
| 6272 |
|
last INSCOPE; |
| 6273 |
|
} elsif ({ |
| 6274 |
|
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6275 |
|
button => 1, marquee => 1, object => 1, html => 1, |
| 6276 |
|
}->{$node->[1]}) { |
| 6277 |
|
!!!cp ('t411.1'); |
| 6278 |
|
last INSCOPE; |
| 6279 |
|
} |
| 6280 |
|
} # INSCOPE |
| 6281 |
|
|
| 6282 |
|
if (defined $i) { |
| 6283 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6284 |
|
!!!cp ('t412.1'); |
| 6285 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 6286 |
|
} else { |
| 6287 |
|
!!!cp ('t414.1'); |
| 6288 |
|
} |
| 6289 |
|
|
| 6290 |
|
splice @{$self->{open_elements}}, $i; |
| 6291 |
} else { |
} else { |
| 6292 |
!!!cp ('t426'); |
!!!cp ('t413.1'); |
| 6293 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6294 |
|
|
| 6295 |
|
!!!cp ('t415.1'); |
| 6296 |
|
## As if <p>, then reprocess the current token |
| 6297 |
|
my $el; |
| 6298 |
|
!!!create-element ($el, 'p',, $token); |
| 6299 |
|
$insert->($el); |
| 6300 |
|
## NOTE: Not inserted into |$self->{open_elements}|. |
| 6301 |
} |
} |
| 6302 |
|
|
|
splice @{$self->{open_elements}}, $i if defined $i; |
|
| 6303 |
!!!next-token; |
!!!next-token; |
| 6304 |
redo B; |
redo B; |
| 6305 |
} elsif ({ |
} elsif ({ |
| 6309 |
strong => 1, tt => 1, u => 1, |
strong => 1, tt => 1, u => 1, |
| 6310 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6311 |
!!!cp ('t427'); |
!!!cp ('t427'); |
| 6312 |
$formatting_end_tag->($token->{tag_name}); |
$formatting_end_tag->($token); |
| 6313 |
redo B; |
redo B; |
| 6314 |
} elsif ($token->{tag_name} eq 'br') { |
} elsif ($token->{tag_name} eq 'br') { |
| 6315 |
!!!cp ('t428'); |
!!!cp ('t428'); |
| 6316 |
!!!parse-error (type => 'unmatched end tag:br'); |
!!!parse-error (type => 'unmatched end tag:br', token => $token); |
| 6317 |
|
|
| 6318 |
## As if <br> |
## As if <br> |
| 6319 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 6320 |
|
|
| 6321 |
my $el; |
my $el; |
| 6322 |
!!!create-element ($el, 'br'); |
!!!create-element ($el, 'br',, $token); |
| 6323 |
$insert->($el); |
$insert->($el); |
| 6324 |
|
|
| 6325 |
## Ignore the token. |
## Ignore the token. |
| 6338 |
noscript => 0, ## TODO: if scripting is enabled |
noscript => 0, ## TODO: if scripting is enabled |
| 6339 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6340 |
!!!cp ('t429'); |
!!!cp ('t429'); |
| 6341 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6342 |
## Ignore the token |
## Ignore the token |
| 6343 |
!!!next-token; |
!!!next-token; |
| 6344 |
redo B; |
redo B; |
| 6355 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq $token->{tag_name}) { |
| 6356 |
## Step 1 |
## Step 1 |
| 6357 |
## generate implied end tags |
## generate implied end tags |
| 6358 |
if ({ |
while ({ |
| 6359 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 6360 |
td => 1, th => 1, tr => 1, |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 6361 |
!!!cp ('t430'); |
!!!cp ('t430'); |
| 6362 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
| 6363 |
!!!back-token; |
pop @{$self->{open_elements}}; |
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
| 6364 |
} |
} |
| 6365 |
|
|
| 6366 |
## Step 2 |
## Step 2 |
| 6367 |
if ($token->{tag_name} ne $self->{open_elements}->[-1]->[1]) { |
if ($token->{tag_name} ne $self->{open_elements}->[-1]->[1]) { |
| 6368 |
!!!cp ('t431'); |
!!!cp ('t431'); |
| 6369 |
## NOTE: <x><y></x> |
## NOTE: <x><y></x> |
| 6370 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 6371 |
} else { |
} else { |
| 6372 |
!!!cp ('t432'); |
!!!cp ('t432'); |
| 6373 |
} |
} |
| 6384 |
($special_category->{$node->[1]} or |
($special_category->{$node->[1]} or |
| 6385 |
$scoping_category->{$node->[1]})) { |
$scoping_category->{$node->[1]})) { |
| 6386 |
!!!cp ('t433'); |
!!!cp ('t433'); |
| 6387 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6388 |
## Ignore the token |
## Ignore the token |
| 6389 |
!!!next-token; |
!!!next-token; |
| 6390 |
last S2; |
last S2; |