| 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 |
} |
} |
| 1423 |
} elsif ($self->{state} == BOGUS_COMMENT_STATE) { |
} elsif ($self->{state} == BOGUS_COMMENT_STATE) { |
| 1424 |
## (only happen if PCDATA state) |
## (only happen if PCDATA state) |
| 1425 |
|
|
| 1426 |
my $token = {type => COMMENT_TOKEN, data => ''}; |
## NOTE: Set by the previous state |
| 1427 |
|
#my $token = {type => COMMENT_TOKEN, data => ''}; |
| 1428 |
|
|
| 1429 |
BC: { |
BC: { |
| 1430 |
if ($self->{next_char} == 0x003E) { # > |
if ($self->{next_char} == 0x003E) { # > |
| 1432 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 1433 |
!!!next-input-character; |
!!!next-input-character; |
| 1434 |
|
|
| 1435 |
!!!emit ($token); |
!!!emit ($self->{current_token}); # comment |
| 1436 |
|
|
| 1437 |
redo A; |
redo A; |
| 1438 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1440 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 1441 |
## reconsume |
## reconsume |
| 1442 |
|
|
| 1443 |
!!!emit ($token); |
!!!emit ($self->{current_token}); # comment |
| 1444 |
|
|
| 1445 |
redo A; |
redo A; |
| 1446 |
} else { |
} else { |
| 1447 |
!!!cp (126); |
!!!cp (126); |
| 1448 |
$token->{data} .= chr ($self->{next_char}); |
$self->{current_token}->{data} .= chr ($self->{next_char}); # comment |
| 1449 |
!!!next-input-character; |
!!!next-input-character; |
| 1450 |
redo BC; |
redo BC; |
| 1451 |
} |
} |
| 1455 |
} elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) { |
} elsif ($self->{state} == MARKUP_DECLARATION_OPEN_STATE) { |
| 1456 |
## (only happen if PCDATA state) |
## (only happen if PCDATA state) |
| 1457 |
|
|
| 1458 |
|
my ($l, $c) = ($self->{line_prev}, $self->{column_prev} - 1); |
| 1459 |
|
|
| 1460 |
my @next_char; |
my @next_char; |
| 1461 |
push @next_char, $self->{next_char}; |
push @next_char, $self->{next_char}; |
| 1462 |
|
|
| 1465 |
push @next_char, $self->{next_char}; |
push @next_char, $self->{next_char}; |
| 1466 |
if ($self->{next_char} == 0x002D) { # - |
if ($self->{next_char} == 0x002D) { # - |
| 1467 |
!!!cp (127); |
!!!cp (127); |
| 1468 |
$self->{current_token} = {type => COMMENT_TOKEN, data => ''}; |
$self->{current_token} = {type => COMMENT_TOKEN, data => '', |
| 1469 |
|
line => $l, column => $c}; |
| 1470 |
$self->{state} = COMMENT_START_STATE; |
$self->{state} = COMMENT_START_STATE; |
| 1471 |
!!!next-input-character; |
!!!next-input-character; |
| 1472 |
redo A; |
redo A; |
| 1502 |
!!!cp (129); |
!!!cp (129); |
| 1503 |
## TODO: What a stupid code this is! |
## TODO: What a stupid code this is! |
| 1504 |
$self->{state} = DOCTYPE_STATE; |
$self->{state} = DOCTYPE_STATE; |
| 1505 |
|
$self->{current_token} = {type => DOCTYPE_TOKEN, |
| 1506 |
|
quirks => 1, |
| 1507 |
|
line => $l, column => $c}; |
| 1508 |
!!!next-input-character; |
!!!next-input-character; |
| 1509 |
redo A; |
redo A; |
| 1510 |
} else { |
} else { |
| 1533 |
$self->{next_char} = shift @next_char; |
$self->{next_char} = shift @next_char; |
| 1534 |
!!!back-next-input-character (@next_char); |
!!!back-next-input-character (@next_char); |
| 1535 |
$self->{state} = BOGUS_COMMENT_STATE; |
$self->{state} = BOGUS_COMMENT_STATE; |
| 1536 |
|
$self->{current_token} = {type => COMMENT_TOKEN, data => '', |
| 1537 |
|
line => $l, column => $c}; |
| 1538 |
redo A; |
redo A; |
| 1539 |
|
|
| 1540 |
## ISSUE: typos in spec: chacacters, is is a parse error |
## ISSUE: typos in spec: chacacters, is is a parse error |
| 1658 |
redo A; |
redo A; |
| 1659 |
} elsif ($self->{next_char} == 0x002D) { # - |
} elsif ($self->{next_char} == 0x002D) { # - |
| 1660 |
!!!cp (152); |
!!!cp (152); |
| 1661 |
!!!parse-error (type => 'dash in comment'); |
!!!parse-error (type => 'dash in comment', |
| 1662 |
|
line => $self->{line_prev}, |
| 1663 |
|
column => $self->{column_prev}); |
| 1664 |
$self->{current_token}->{data} .= '-'; # comment |
$self->{current_token}->{data} .= '-'; # comment |
| 1665 |
## Stay in the state |
## Stay in the state |
| 1666 |
!!!next-input-character; |
!!!next-input-character; |
| 1676 |
redo A; |
redo A; |
| 1677 |
} else { |
} else { |
| 1678 |
!!!cp (154); |
!!!cp (154); |
| 1679 |
!!!parse-error (type => 'dash in comment'); |
!!!parse-error (type => 'dash in comment', |
| 1680 |
|
line => $self->{line_prev}, |
| 1681 |
|
column => $self->{column_prev}); |
| 1682 |
$self->{current_token}->{data} .= '--' . chr ($self->{next_char}); # comment |
$self->{current_token}->{data} .= '--' . chr ($self->{next_char}); # comment |
| 1683 |
$self->{state} = COMMENT_STATE; |
$self->{state} = COMMENT_STATE; |
| 1684 |
!!!next-input-character; |
!!!next-input-character; |
| 1717 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 1718 |
!!!next-input-character; |
!!!next-input-character; |
| 1719 |
|
|
| 1720 |
!!!emit ({type => DOCTYPE_TOKEN, quirks => 1}); |
!!!emit ($self->{current_token}); # DOCTYPE (quirks) |
| 1721 |
|
|
| 1722 |
redo A; |
redo A; |
| 1723 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1726 |
$self->{state} = DATA_STATE; |
$self->{state} = DATA_STATE; |
| 1727 |
## reconsume |
## reconsume |
| 1728 |
|
|
| 1729 |
!!!emit ({type => DOCTYPE_TOKEN, quirks => 1}); |
!!!emit ($self->{current_token}); # DOCTYPE (quirks) |
| 1730 |
|
|
| 1731 |
redo A; |
redo A; |
| 1732 |
} else { |
} else { |
| 1733 |
!!!cp (160); |
!!!cp (160); |
| 1734 |
$self->{current_token} |
$self->{current_token}->{name} = chr $self->{next_char}; |
| 1735 |
= {type => DOCTYPE_TOKEN, |
delete $self->{current_token}->{quirks}; |
|
name => chr ($self->{next_char}), |
|
|
#quirks => 0, |
|
|
}; |
|
| 1736 |
## ISSUE: "Set the token's name name to the" in the spec |
## ISSUE: "Set the token's name name to the" in the spec |
| 1737 |
$self->{state} = DOCTYPE_NAME_STATE; |
$self->{state} = DOCTYPE_NAME_STATE; |
| 1738 |
!!!next-input-character; |
!!!next-input-character; |
| 2259 |
sub _tokenize_attempt_to_consume_an_entity ($$$) { |
sub _tokenize_attempt_to_consume_an_entity ($$$) { |
| 2260 |
my ($self, $in_attr, $additional) = @_; |
my ($self, $in_attr, $additional) = @_; |
| 2261 |
|
|
| 2262 |
|
my ($l, $c) = ($self->{line_prev}, $self->{column_prev}); |
| 2263 |
|
|
| 2264 |
if ({ |
if ({ |
| 2265 |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, # HT, LF, VT, FF, |
0x0009 => 1, 0x000A => 1, 0x000B => 1, 0x000C => 1, # HT, LF, VT, FF, |
| 2266 |
0x0020 => 1, 0x003C => 1, 0x0026 => 1, -1 => 1, # SP, <, & # 0x000D # CR |
0x0020 => 1, 0x003C => 1, 0x0026 => 1, -1 => 1, # SP, <, & # 0x000D # CR |
| 2301 |
redo X; |
redo X; |
| 2302 |
} elsif (not defined $code) { # no hexadecimal digit |
} elsif (not defined $code) { # no hexadecimal digit |
| 2303 |
!!!cp (1005); |
!!!cp (1005); |
| 2304 |
!!!parse-error (type => 'bare hcro'); |
!!!parse-error (type => 'bare hcro', line => $l, column => $c); |
| 2305 |
!!!back-next-input-character ($x_char, $self->{next_char}); |
!!!back-next-input-character ($x_char, $self->{next_char}); |
| 2306 |
$self->{next_char} = 0x0023; # # |
$self->{next_char} = 0x0023; # # |
| 2307 |
return undef; |
return undef; |
| 2310 |
!!!next-input-character; |
!!!next-input-character; |
| 2311 |
} else { |
} else { |
| 2312 |
!!!cp (1007); |
!!!cp (1007); |
| 2313 |
!!!parse-error (type => 'no refc'); |
!!!parse-error (type => 'no refc', line => $l, column => $c); |
| 2314 |
} |
} |
| 2315 |
|
|
| 2316 |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
| 2317 |
!!!cp (1008); |
!!!cp (1008); |
| 2318 |
!!!parse-error (type => sprintf 'invalid character reference:U+%04X', $code); |
!!!parse-error (type => (sprintf 'invalid character reference:U+%04X', $code), line => $l, column => $c); |
| 2319 |
$code = 0xFFFD; |
$code = 0xFFFD; |
| 2320 |
} elsif ($code > 0x10FFFF) { |
} elsif ($code > 0x10FFFF) { |
| 2321 |
!!!cp (1009); |
!!!cp (1009); |
| 2322 |
!!!parse-error (type => sprintf 'invalid character reference:U-%08X', $code); |
!!!parse-error (type => (sprintf 'invalid character reference:U-%08X', $code), line => $l, column => $c); |
| 2323 |
$code = 0xFFFD; |
$code = 0xFFFD; |
| 2324 |
} elsif ($code == 0x000D) { |
} elsif ($code == 0x000D) { |
| 2325 |
!!!cp (1010); |
!!!cp (1010); |
| 2326 |
!!!parse-error (type => 'CR character reference'); |
!!!parse-error (type => 'CR character reference', line => $l, column => $c); |
| 2327 |
$code = 0x000A; |
$code = 0x000A; |
| 2328 |
} elsif (0x80 <= $code and $code <= 0x9F) { |
} elsif (0x80 <= $code and $code <= 0x9F) { |
| 2329 |
!!!cp (1011); |
!!!cp (1011); |
| 2330 |
!!!parse-error (type => sprintf 'C1 character reference:U+%04X', $code); |
!!!parse-error (type => (sprintf 'C1 character reference:U+%04X', $code), line => $l, column => $c); |
| 2331 |
$code = $c1_entity_char->{$code}; |
$code = $c1_entity_char->{$code}; |
| 2332 |
} |
} |
| 2333 |
|
|
| 2334 |
return {type => CHARACTER_TOKEN, data => chr $code, |
return {type => CHARACTER_TOKEN, data => chr $code, |
| 2335 |
has_reference => 1}; |
has_reference => 1, line => $l, column => $c}; |
| 2336 |
} # X |
} # X |
| 2337 |
} elsif (0x0030 <= $self->{next_char} and |
} elsif (0x0030 <= $self->{next_char} and |
| 2338 |
$self->{next_char} <= 0x0039) { # 0..9 |
$self->{next_char} <= 0x0039) { # 0..9 |
| 2353 |
!!!next-input-character; |
!!!next-input-character; |
| 2354 |
} else { |
} else { |
| 2355 |
!!!cp (1014); |
!!!cp (1014); |
| 2356 |
!!!parse-error (type => 'no refc'); |
!!!parse-error (type => 'no refc', line => $l, column => $c); |
| 2357 |
} |
} |
| 2358 |
|
|
| 2359 |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
if ($code == 0 or (0xD800 <= $code and $code <= 0xDFFF)) { |
| 2360 |
!!!cp (1015); |
!!!cp (1015); |
| 2361 |
!!!parse-error (type => sprintf 'invalid character reference:U+%04X', $code); |
!!!parse-error (type => (sprintf 'invalid character reference:U+%04X', $code), line => $l, column => $c); |
| 2362 |
$code = 0xFFFD; |
$code = 0xFFFD; |
| 2363 |
} elsif ($code > 0x10FFFF) { |
} elsif ($code > 0x10FFFF) { |
| 2364 |
!!!cp (1016); |
!!!cp (1016); |
| 2365 |
!!!parse-error (type => sprintf 'invalid character reference:U-%08X', $code); |
!!!parse-error (type => (sprintf 'invalid character reference:U-%08X', $code), line => $l, column => $c); |
| 2366 |
$code = 0xFFFD; |
$code = 0xFFFD; |
| 2367 |
} elsif ($code == 0x000D) { |
} elsif ($code == 0x000D) { |
| 2368 |
!!!cp (1017); |
!!!cp (1017); |
| 2369 |
!!!parse-error (type => 'CR character reference'); |
!!!parse-error (type => 'CR character reference', line => $l, column => $c); |
| 2370 |
$code = 0x000A; |
$code = 0x000A; |
| 2371 |
} elsif (0x80 <= $code and $code <= 0x9F) { |
} elsif (0x80 <= $code and $code <= 0x9F) { |
| 2372 |
!!!cp (1018); |
!!!cp (1018); |
| 2373 |
!!!parse-error (type => sprintf 'C1 character reference:U+%04X', $code); |
!!!parse-error (type => (sprintf 'C1 character reference:U+%04X', $code), line => $l, column => $c); |
| 2374 |
$code = $c1_entity_char->{$code}; |
$code = $c1_entity_char->{$code}; |
| 2375 |
} |
} |
| 2376 |
|
|
| 2377 |
return {type => CHARACTER_TOKEN, data => chr $code, has_reference => 1}; |
return {type => CHARACTER_TOKEN, data => chr $code, has_reference => 1, |
| 2378 |
|
line => $l, column => $c}; |
| 2379 |
} else { |
} else { |
| 2380 |
!!!cp (1019); |
!!!cp (1019); |
| 2381 |
!!!parse-error (type => 'bare nero'); |
!!!parse-error (type => 'bare nero', line => $l, column => $c); |
| 2382 |
!!!back-next-input-character ($self->{next_char}); |
!!!back-next-input-character ($self->{next_char}); |
| 2383 |
$self->{next_char} = 0x0023; # # |
$self->{next_char} = 0x0023; # # |
| 2384 |
return undef; |
return undef; |
| 2428 |
|
|
| 2429 |
if ($match > 0) { |
if ($match > 0) { |
| 2430 |
!!!cp (1023); |
!!!cp (1023); |
| 2431 |
return {type => CHARACTER_TOKEN, data => $value, has_reference => 1}; |
return {type => CHARACTER_TOKEN, data => $value, has_reference => 1, |
| 2432 |
|
line => $l, column => $c}; |
| 2433 |
} elsif ($match < 0) { |
} elsif ($match < 0) { |
| 2434 |
!!!parse-error (type => 'no refc'); |
!!!parse-error (type => 'no refc', line => $l, column => $c); |
| 2435 |
if ($in_attr and $match < -1) { |
if ($in_attr and $match < -1) { |
| 2436 |
!!!cp (1024); |
!!!cp (1024); |
| 2437 |
return {type => CHARACTER_TOKEN, data => '&'.$entity_name}; |
return {type => CHARACTER_TOKEN, data => '&'.$entity_name, |
| 2438 |
|
line => $l, column => $c}; |
| 2439 |
} else { |
} else { |
| 2440 |
!!!cp (1025); |
!!!cp (1025); |
| 2441 |
return {type => CHARACTER_TOKEN, data => $value, has_reference => 1}; |
return {type => CHARACTER_TOKEN, data => $value, has_reference => 1, |
| 2442 |
|
line => $l, column => $c}; |
| 2443 |
} |
} |
| 2444 |
} else { |
} else { |
| 2445 |
!!!cp (1026); |
!!!cp (1026); |
| 2446 |
!!!parse-error (type => 'bare ero'); |
!!!parse-error (type => 'bare ero', line => $l, column => $c); |
| 2447 |
## NOTE: "No characters are consumed" in the spec. |
## NOTE: "No characters are consumed" in the spec. |
| 2448 |
return {type => CHARACTER_TOKEN, data => '&'.$value}; |
return {type => CHARACTER_TOKEN, data => '&'.$value, |
| 2449 |
|
line => $l, column => $c}; |
| 2450 |
} |
} |
| 2451 |
} else { |
} else { |
| 2452 |
!!!cp (1027); |
!!!cp (1027); |
| 2453 |
## no characters are consumed |
## no characters are consumed |
| 2454 |
!!!parse-error (type => 'bare ero'); |
!!!parse-error (type => 'bare ero', line => $l, column => $c); |
| 2455 |
return undef; |
return undef; |
| 2456 |
} |
} |
| 2457 |
} # _tokenize_attempt_to_consume_an_entity |
} # _tokenize_attempt_to_consume_an_entity |
| 2522 |
defined $token->{public_identifier} or |
defined $token->{public_identifier} or |
| 2523 |
defined $token->{system_identifier}) { |
defined $token->{system_identifier}) { |
| 2524 |
!!!cp ('t1'); |
!!!cp ('t1'); |
| 2525 |
!!!parse-error (type => 'not HTML5'); |
!!!parse-error (type => 'not HTML5', token => $token); |
| 2526 |
} elsif ($doctype_name ne 'HTML') { |
} elsif ($doctype_name ne 'HTML') { |
| 2527 |
!!!cp ('t2'); |
!!!cp ('t2'); |
| 2528 |
## ISSUE: ASCII case-insensitive? (in fact it does not matter) |
## ISSUE: ASCII case-insensitive? (in fact it does not matter) |
| 2529 |
!!!parse-error (type => 'not HTML5'); |
!!!parse-error (type => 'not HTML5', token => $token); |
| 2530 |
} else { |
} else { |
| 2531 |
!!!cp ('t3'); |
!!!cp ('t3'); |
| 2532 |
} |
} |
| 2665 |
END_OF_FILE_TOKEN, 1, |
END_OF_FILE_TOKEN, 1, |
| 2666 |
}->{$token->{type}}) { |
}->{$token->{type}}) { |
| 2667 |
!!!cp ('t14'); |
!!!cp ('t14'); |
| 2668 |
!!!parse-error (type => 'no DOCTYPE'); |
!!!parse-error (type => 'no DOCTYPE', token => $token); |
| 2669 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
| 2670 |
## Go to the "before html" insertion mode. |
## Go to the "before html" insertion mode. |
| 2671 |
## reprocess |
## reprocess |
| 2686 |
!!!cp ('t17'); |
!!!cp ('t17'); |
| 2687 |
} |
} |
| 2688 |
|
|
| 2689 |
!!!parse-error (type => 'no DOCTYPE'); |
!!!parse-error (type => 'no DOCTYPE', token => $token); |
| 2690 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
| 2691 |
## Go to the "before html" insertion mode. |
## Go to the "before html" insertion mode. |
| 2692 |
## reprocess |
## reprocess |
| 2715 |
B: { |
B: { |
| 2716 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
| 2717 |
!!!cp ('t19'); |
!!!cp ('t19'); |
| 2718 |
!!!parse-error (type => 'in html:#DOCTYPE'); |
!!!parse-error (type => 'in html:#DOCTYPE', token => $token); |
| 2719 |
## Ignore the token |
## Ignore the token |
| 2720 |
## Stay in the insertion mode. |
## Stay in the insertion mode. |
| 2721 |
!!!next-token; |
!!!next-token; |
| 2749 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 2750 |
if ($token->{tag_name} eq 'html') { |
if ($token->{tag_name} eq 'html') { |
| 2751 |
my $root_element; |
my $root_element; |
| 2752 |
!!!create-element ($root_element, $token->{tag_name}, $token->{attributes}); |
!!!create-element ($root_element, $token->{tag_name}, $token->{attributes}, $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 |
|
|
| 2779 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 2780 |
} |
} |
| 2781 |
|
|
| 2782 |
my $root_element; !!!create-element ($root_element, 'html'); |
my $root_element; !!!create-element ($root_element, 'html',, $token); |
| 2783 |
$self->{document}->append_child ($root_element); |
$self->{document}->append_child ($root_element); |
| 2784 |
push @{$self->{open_elements}}, [$root_element, 'html']; |
push @{$self->{open_elements}}, [$root_element, 'html']; |
| 2785 |
|
|
| 2974 |
## Step 1 |
## Step 1 |
| 2975 |
my $start_tag_name = $token->{tag_name}; |
my $start_tag_name = $token->{tag_name}; |
| 2976 |
my $el; |
my $el; |
| 2977 |
!!!create-element ($el, $start_tag_name, $token->{attributes}); |
!!!create-element ($el, $start_tag_name, $token->{attributes}, $token); |
| 2978 |
|
|
| 2979 |
## Step 2 |
## Step 2 |
| 2980 |
$insert->($el); |
$insert->($el); |
| 3011 |
## NOTE: An end-of-file token. |
## NOTE: An end-of-file token. |
| 3012 |
if ($content_model_flag == CDATA_CONTENT_MODEL) { |
if ($content_model_flag == CDATA_CONTENT_MODEL) { |
| 3013 |
!!!cp ('t43'); |
!!!cp ('t43'); |
| 3014 |
!!!parse-error (type => 'in CDATA:#'.$token->{type}); |
!!!parse-error (type => 'in CDATA:#'.$token->{type}, token => $token); |
| 3015 |
} elsif ($content_model_flag == RCDATA_CONTENT_MODEL) { |
} elsif ($content_model_flag == RCDATA_CONTENT_MODEL) { |
| 3016 |
!!!cp ('t44'); |
!!!cp ('t44'); |
| 3017 |
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
!!!parse-error (type => 'in RCDATA:#'.$token->{type}, token => $token); |
| 3018 |
} else { |
} else { |
| 3019 |
die "$0: $content_model_flag in parse_rcdata"; |
die "$0: $content_model_flag in parse_rcdata"; |
| 3020 |
} |
} |
| 3024 |
|
|
| 3025 |
my $script_start_tag = sub () { |
my $script_start_tag = sub () { |
| 3026 |
my $script_el; |
my $script_el; |
| 3027 |
!!!create-element ($script_el, 'script', $token->{attributes}); |
!!!create-element ($script_el, 'script', $token->{attributes}, $token); |
| 3028 |
## TODO: mark as "parser-inserted" |
## TODO: mark as "parser-inserted" |
| 3029 |
|
|
| 3030 |
$self->{content_model} = CDATA_CONTENT_MODEL; |
$self->{content_model} = CDATA_CONTENT_MODEL; |
| 3050 |
## Ignore the token |
## Ignore the token |
| 3051 |
} else { |
} else { |
| 3052 |
!!!cp ('t48'); |
!!!cp ('t48'); |
| 3053 |
!!!parse-error (type => 'in CDATA:#'.$token->{type}); |
!!!parse-error (type => 'in CDATA:#'.$token->{type}, token => $token); |
| 3054 |
## ISSUE: And ignore? |
## ISSUE: And ignore? |
| 3055 |
## TODO: mark as "already executed" |
## TODO: mark as "already executed" |
| 3056 |
} |
} |
| 3073 |
!!!next-token; |
!!!next-token; |
| 3074 |
}; # $script_start_tag |
}; # $script_start_tag |
| 3075 |
|
|
| 3076 |
|
## NOTE: $open_tables->[-1]->[0] is the "current table" element node. |
| 3077 |
|
## NOTE: $open_tables->[-1]->[1] is the "tainted" flag. |
| 3078 |
|
my $open_tables = [[$self->{open_elements}->[0]->[0]]]; |
| 3079 |
|
|
| 3080 |
my $formatting_end_tag = sub { |
my $formatting_end_tag = sub { |
| 3081 |
my $tag_name = shift; |
my $end_tag_token = shift; |
| 3082 |
|
my $tag_name = $end_tag_token->{tag_name}; |
| 3083 |
|
|
| 3084 |
|
## NOTE: The adoption agency algorithm (AAA). |
| 3085 |
|
|
| 3086 |
FET: { |
FET: { |
| 3087 |
## Step 1 |
## Step 1 |
| 3100 |
} # AFE |
} # AFE |
| 3101 |
unless (defined $formatting_element) { |
unless (defined $formatting_element) { |
| 3102 |
!!!cp ('t53'); |
!!!cp ('t53'); |
| 3103 |
!!!parse-error (type => 'unmatched end tag:'.$tag_name); |
!!!parse-error (type => 'unmatched end tag:'.$tag_name, token => $end_tag_token); |
| 3104 |
## Ignore the token |
## Ignore the token |
| 3105 |
!!!next-token; |
!!!next-token; |
| 3106 |
return; |
return; |
| 3117 |
last INSCOPE; |
last INSCOPE; |
| 3118 |
} else { # in open elements but not in scope |
} else { # in open elements but not in scope |
| 3119 |
!!!cp ('t55'); |
!!!cp ('t55'); |
| 3120 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, |
| 3121 |
|
token => $end_tag_token); |
| 3122 |
## Ignore the token |
## Ignore the token |
| 3123 |
!!!next-token; |
!!!next-token; |
| 3124 |
return; |
return; |
| 3125 |
} |
} |
| 3126 |
} elsif ({ |
} elsif ({ |
| 3127 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 3128 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 3129 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 3130 |
!!!cp ('t56'); |
!!!cp ('t56'); |
| 3133 |
} # INSCOPE |
} # INSCOPE |
| 3134 |
unless (defined $formatting_element_i_in_open) { |
unless (defined $formatting_element_i_in_open) { |
| 3135 |
!!!cp ('t57'); |
!!!cp ('t57'); |
| 3136 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, |
| 3137 |
|
token => $end_tag_token); |
| 3138 |
pop @$active_formatting_elements; # $formatting_element |
pop @$active_formatting_elements; # $formatting_element |
| 3139 |
!!!next-token; ## TODO: ok? |
!!!next-token; ## TODO: ok? |
| 3140 |
return; |
return; |
| 3141 |
} |
} |
| 3142 |
if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) { |
if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) { |
| 3143 |
!!!cp ('t58'); |
!!!cp ('t58'); |
| 3144 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], |
| 3145 |
|
token => $end_tag_token); |
| 3146 |
} |
} |
| 3147 |
|
|
| 3148 |
## Step 2 |
## Step 2 |
| 3153 |
if (not $formatting_category->{$node->[1]} and |
if (not $formatting_category->{$node->[1]} and |
| 3154 |
#not $phrasing_category->{$node->[1]} and |
#not $phrasing_category->{$node->[1]} and |
| 3155 |
($special_category->{$node->[1]} or |
($special_category->{$node->[1]} or |
| 3156 |
$scoping_category->{$node->[1]})) { |
$scoping_category->{$node->[1]})) { ## Scoping is redundant, maybe |
| 3157 |
!!!cp ('t59'); |
!!!cp ('t59'); |
| 3158 |
$furthest_block = $node; |
$furthest_block = $node; |
| 3159 |
$furthest_block_i_in_open = $_; |
$furthest_block_i_in_open = $_; |
| 3239 |
} # S7 |
} # S7 |
| 3240 |
|
|
| 3241 |
## Step 8 |
## Step 8 |
| 3242 |
$common_ancestor_node->[0]->append_child ($last_node->[0]); |
if ({ |
| 3243 |
|
table => 1, tbody => 1, tfoot => 1, thead => 1, tr => 1, |
| 3244 |
|
}->{$common_ancestor_node->[1]}) { |
| 3245 |
|
my $foster_parent_element; |
| 3246 |
|
my $next_sibling; |
| 3247 |
|
OE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3248 |
|
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
| 3249 |
|
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
| 3250 |
|
if (defined $parent and $parent->node_type == 1) { |
| 3251 |
|
!!!cp ('t65.1'); |
| 3252 |
|
$foster_parent_element = $parent; |
| 3253 |
|
$next_sibling = $self->{open_elements}->[$_]->[0]; |
| 3254 |
|
} else { |
| 3255 |
|
!!!cp ('t65.2'); |
| 3256 |
|
$foster_parent_element |
| 3257 |
|
= $self->{open_elements}->[$_ - 1]->[0]; |
| 3258 |
|
} |
| 3259 |
|
last OE; |
| 3260 |
|
} |
| 3261 |
|
} # OE |
| 3262 |
|
$foster_parent_element = $self->{open_elements}->[0]->[0] |
| 3263 |
|
unless defined $foster_parent_element; |
| 3264 |
|
$foster_parent_element->insert_before ($last_node->[0], $next_sibling); |
| 3265 |
|
$open_tables->[-1]->[1] = 1; # tainted |
| 3266 |
|
} else { |
| 3267 |
|
!!!cp ('t65.3'); |
| 3268 |
|
$common_ancestor_node->[0]->append_child ($last_node->[0]); |
| 3269 |
|
} |
| 3270 |
|
|
| 3271 |
## Step 9 |
## Step 9 |
| 3272 |
my $clone = [$formatting_element->[0]->clone_node (0), |
my $clone = [$formatting_element->[0]->clone_node (0), |
| 3312 |
} # FET |
} # FET |
| 3313 |
}; # $formatting_end_tag |
}; # $formatting_end_tag |
| 3314 |
|
|
|
## NOTE: $open_tables->[-1]->[0] is the "current table". |
|
|
## NOTE: $open_tables->[-1]->[1] is the "tainted" flag. |
|
|
my $open_tables = [[$self->{open_elements}->[0]->[0]]]; |
|
|
|
|
| 3315 |
$insert = my $insert_to_current = sub { |
$insert = my $insert_to_current = sub { |
| 3316 |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
| 3317 |
}; # $insert_to_current |
}; # $insert_to_current |
| 3353 |
B: { |
B: { |
| 3354 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
| 3355 |
!!!cp ('t73'); |
!!!cp ('t73'); |
| 3356 |
!!!parse-error (type => 'DOCTYPE in the middle'); |
!!!parse-error (type => 'DOCTYPE in the middle', token => $token); |
| 3357 |
## Ignore the token |
## Ignore the token |
| 3358 |
## Stay in the phase |
## Stay in the phase |
| 3359 |
!!!next-token; |
!!!next-token; |
| 3360 |
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 |
|
|
while ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!cp ('t75'); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
|
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; |
|
| 3361 |
} elsif ($token->{type} == START_TAG_TOKEN and |
} elsif ($token->{type} == START_TAG_TOKEN and |
| 3362 |
$token->{tag_name} eq 'html') { |
$token->{tag_name} eq 'html') { |
| 3363 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 3364 |
!!!cp ('t79'); |
!!!cp ('t79'); |
| 3365 |
!!!parse-error (type => 'after html:html'); |
!!!parse-error (type => 'after html:html', token => $token); |
| 3366 |
$self->{insertion_mode} = AFTER_BODY_IM; |
$self->{insertion_mode} = AFTER_BODY_IM; |
| 3367 |
} elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
| 3368 |
!!!cp ('t80'); |
!!!cp ('t80'); |
| 3369 |
!!!parse-error (type => 'after html:html'); |
!!!parse-error (type => 'after html:html', token => $token); |
| 3370 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 3371 |
} else { |
} else { |
| 3372 |
!!!cp ('t81'); |
!!!cp ('t81'); |
| 3373 |
} |
} |
| 3374 |
|
|
| 3375 |
!!!cp ('t82'); |
!!!cp ('t82'); |
| 3376 |
!!!parse-error (type => 'not first start tag'); |
!!!parse-error (type => 'not first start tag', token => $token); |
| 3377 |
my $top_el = $self->{open_elements}->[0]->[0]; |
my $top_el = $self->{open_elements}->[0]->[0]; |
| 3378 |
for my $attr_name (keys %{$token->{attributes}}) { |
for my $attr_name (keys %{$token->{attributes}}) { |
| 3379 |
unless ($top_el->has_attribute_ns (undef, $attr_name)) { |
unless ($top_el->has_attribute_ns (undef, $attr_name)) { |
| 3402 |
} elsif ($self->{insertion_mode} & HEAD_IMS) { |
} elsif ($self->{insertion_mode} & HEAD_IMS) { |
| 3403 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 3404 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 3405 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
unless ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3406 |
|
!!!cp ('t88.2'); |
| 3407 |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 3408 |
|
} else { |
| 3409 |
|
!!!cp ('t88.1'); |
| 3410 |
|
## Ignore the token. |
| 3411 |
|
!!!next-token; |
| 3412 |
|
redo B; |
| 3413 |
|
} |
| 3414 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 3415 |
!!!cp ('t88'); |
!!!cp ('t88'); |
| 3416 |
!!!next-token; |
!!!next-token; |
| 3421 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3422 |
!!!cp ('t89'); |
!!!cp ('t89'); |
| 3423 |
## As if <head> |
## As if <head> |
| 3424 |
!!!create-element ($self->{head_element}, 'head'); |
!!!create-element ($self->{head_element}, 'head',, $token); |
| 3425 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3426 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3427 |
|
|
| 3433 |
!!!cp ('t90'); |
!!!cp ('t90'); |
| 3434 |
## As if </noscript> |
## As if </noscript> |
| 3435 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3436 |
!!!parse-error (type => 'in noscript:#character'); |
!!!parse-error (type => 'in noscript:#character', token => $token); |
| 3437 |
|
|
| 3438 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3439 |
## As if </head> |
## As if </head> |
| 3451 |
|
|
| 3452 |
## "after head" insertion mode |
## "after head" insertion mode |
| 3453 |
## As if <body> |
## As if <body> |
| 3454 |
!!!insert-element ('body'); |
!!!insert-element ('body',, $token); |
| 3455 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 3456 |
## reprocess |
## reprocess |
| 3457 |
redo B; |
redo B; |
| 3459 |
if ($token->{tag_name} eq 'head') { |
if ($token->{tag_name} eq 'head') { |
| 3460 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3461 |
!!!cp ('t93'); |
!!!cp ('t93'); |
| 3462 |
!!!create-element ($self->{head_element}, $token->{tag_name}, $token->{attributes}); |
!!!create-element ($self->{head_element}, $token->{tag_name}, $token->{attributes}, $token); |
| 3463 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3464 |
push @{$self->{open_elements}}, [$self->{head_element}, $token->{tag_name}]; |
push @{$self->{open_elements}}, [$self->{head_element}, $token->{tag_name}]; |
| 3465 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 3470 |
# |
# |
| 3471 |
} else { |
} else { |
| 3472 |
!!!cp ('t95'); |
!!!cp ('t95'); |
| 3473 |
!!!parse-error (type => 'in head:head'); # or in head noscript |
!!!parse-error (type => 'in head:head', token => $token); # or in head noscript |
| 3474 |
## Ignore the token |
## Ignore the token |
| 3475 |
!!!next-token; |
!!!next-token; |
| 3476 |
redo B; |
redo B; |
| 3478 |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3479 |
!!!cp ('t96'); |
!!!cp ('t96'); |
| 3480 |
## As if <head> |
## As if <head> |
| 3481 |
!!!create-element ($self->{head_element}, 'head'); |
!!!create-element ($self->{head_element}, 'head',, $token); |
| 3482 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3483 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3484 |
|
|
| 3493 |
!!!cp ('t98'); |
!!!cp ('t98'); |
| 3494 |
## As if </noscript> |
## As if </noscript> |
| 3495 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3496 |
!!!parse-error (type => 'in noscript:base'); |
!!!parse-error (type => 'in noscript:base', token => $token); |
| 3497 |
|
|
| 3498 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 3499 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 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 ('t100'); |
!!!cp ('t100'); |
| 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 ('t101'); |
!!!cp ('t101'); |
| 3511 |
} |
} |
| 3512 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 3513 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 3514 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3515 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3516 |
!!!next-token; |
!!!next-token; |
| 3517 |
redo B; |
redo B; |
| 3519 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3520 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 3521 |
!!!cp ('t102'); |
!!!cp ('t102'); |
| 3522 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 3523 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3524 |
} else { |
} else { |
| 3525 |
!!!cp ('t103'); |
!!!cp ('t103'); |
| 3526 |
} |
} |
| 3527 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 3528 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 3529 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3530 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3531 |
!!!next-token; |
!!!next-token; |
| 3532 |
redo B; |
redo B; |
| 3534 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3535 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 3536 |
!!!cp ('t104'); |
!!!cp ('t104'); |
| 3537 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 3538 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3539 |
} else { |
} else { |
| 3540 |
!!!cp ('t105'); |
!!!cp ('t105'); |
| 3541 |
} |
} |
| 3542 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 3543 |
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. |
| 3544 |
|
|
| 3545 |
unless ($self->{confident}) { |
unless ($self->{confident}) { |
| 3546 |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
| 3547 |
!!!cp ('t106'); |
!!!cp ('t106'); |
| 3548 |
$self->{change_encoding} |
$self->{change_encoding} |
| 3549 |
->($self, $token->{attributes}->{charset}->{value}); |
->($self, $token->{attributes}->{charset}->{value}, |
| 3550 |
|
$token); |
| 3551 |
|
|
| 3552 |
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
| 3553 |
->set_user_data (manakai_has_reference => |
->set_user_data (manakai_has_reference => |
| 3562 |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
| 3563 |
!!!cp ('t107'); |
!!!cp ('t107'); |
| 3564 |
$self->{change_encoding} |
$self->{change_encoding} |
| 3565 |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3); |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3, |
| 3566 |
|
$token); |
| 3567 |
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
| 3568 |
->set_user_data (manakai_has_reference => |
->set_user_data (manakai_has_reference => |
| 3569 |
$token->{attributes}->{content} |
$token->{attributes}->{content} |
| 3589 |
} |
} |
| 3590 |
} |
} |
| 3591 |
|
|
| 3592 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3593 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3594 |
!!!next-token; |
!!!next-token; |
| 3595 |
redo B; |
redo B; |
| 3598 |
!!!cp ('t111'); |
!!!cp ('t111'); |
| 3599 |
## As if </noscript> |
## As if </noscript> |
| 3600 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3601 |
!!!parse-error (type => 'in noscript:title'); |
!!!parse-error (type => 'in noscript:title', token => $token); |
| 3602 |
|
|
| 3603 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 3604 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3605 |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 3606 |
!!!cp ('t112'); |
!!!cp ('t112'); |
| 3607 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 3608 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3609 |
} else { |
} else { |
| 3610 |
!!!cp ('t113'); |
!!!cp ('t113'); |
| 3614 |
my $parent = defined $self->{head_element} ? $self->{head_element} |
my $parent = defined $self->{head_element} ? $self->{head_element} |
| 3615 |
: $self->{open_elements}->[-1]->[0]; |
: $self->{open_elements}->[-1]->[0]; |
| 3616 |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
| 3617 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3618 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3619 |
redo B; |
redo B; |
| 3620 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 3623 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3624 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 3625 |
!!!cp ('t114'); |
!!!cp ('t114'); |
| 3626 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 3627 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3628 |
} else { |
} else { |
| 3629 |
!!!cp ('t115'); |
!!!cp ('t115'); |
| 3630 |
} |
} |
| 3631 |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 3632 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3633 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3634 |
redo B; |
redo B; |
| 3635 |
} elsif ($token->{tag_name} eq 'noscript') { |
} elsif ($token->{tag_name} eq 'noscript') { |
| 3636 |
if ($self->{insertion_mode} == IN_HEAD_IM) { |
if ($self->{insertion_mode} == IN_HEAD_IM) { |
| 3637 |
!!!cp ('t116'); |
!!!cp ('t116'); |
| 3638 |
## NOTE: and scripting is disalbed |
## NOTE: and scripting is disalbed |
| 3639 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 3640 |
$self->{insertion_mode} = IN_HEAD_NOSCRIPT_IM; |
$self->{insertion_mode} = IN_HEAD_NOSCRIPT_IM; |
| 3641 |
!!!next-token; |
!!!next-token; |
| 3642 |
redo B; |
redo B; |
| 3643 |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 3644 |
!!!cp ('t117'); |
!!!cp ('t117'); |
| 3645 |
!!!parse-error (type => 'in noscript:noscript'); |
!!!parse-error (type => 'in noscript:noscript', token => $token); |
| 3646 |
## Ignore the token |
## Ignore the token |
| 3647 |
!!!next-token; |
!!!next-token; |
| 3648 |
redo B; |
redo B; |
| 3655 |
!!!cp ('t119'); |
!!!cp ('t119'); |
| 3656 |
## As if </noscript> |
## As if </noscript> |
| 3657 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3658 |
!!!parse-error (type => 'in noscript:script'); |
!!!parse-error (type => 'in noscript:script', token => $token); |
| 3659 |
|
|
| 3660 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 3661 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3662 |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 3663 |
!!!cp ('t120'); |
!!!cp ('t120'); |
| 3664 |
!!!parse-error (type => 'after head:'.$token->{tag_name}); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 3665 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3666 |
} else { |
} else { |
| 3667 |
!!!cp ('t121'); |
!!!cp ('t121'); |
| 3668 |
} |
} |
| 3669 |
|
|
| 3670 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3671 |
$script_start_tag->($insert_to_current); |
$script_start_tag->(); |
| 3672 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3673 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3674 |
redo B; |
redo B; |
| 3675 |
} elsif ($token->{tag_name} eq 'body' or |
} elsif ($token->{tag_name} eq 'body' or |
| 3678 |
!!!cp ('t122'); |
!!!cp ('t122'); |
| 3679 |
## As if </noscript> |
## As if </noscript> |
| 3680 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3681 |
!!!parse-error (type => 'in noscript:'.$token->{tag_name}); |
!!!parse-error (type => 'in noscript:'.$token->{tag_name}, token => $token); |
| 3682 |
|
|
| 3683 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3684 |
## As if </head> |
## As if </head> |
| 3695 |
} |
} |
| 3696 |
|
|
| 3697 |
## "after head" insertion mode |
## "after head" insertion mode |
| 3698 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 3699 |
if ($token->{tag_name} eq 'body') { |
if ($token->{tag_name} eq 'body') { |
| 3700 |
!!!cp ('t126'); |
!!!cp ('t126'); |
| 3701 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 3716 |
!!!cp ('t129'); |
!!!cp ('t129'); |
| 3717 |
## As if </noscript> |
## As if </noscript> |
| 3718 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3719 |
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}); |
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}, token => $token); |
| 3720 |
|
|
| 3721 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3722 |
## As if </head> |
## As if </head> |
| 3735 |
|
|
| 3736 |
## "after head" insertion mode |
## "after head" insertion mode |
| 3737 |
## As if <body> |
## As if <body> |
| 3738 |
!!!insert-element ('body'); |
!!!insert-element ('body',, $token); |
| 3739 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 3740 |
## reprocess |
## reprocess |
| 3741 |
redo B; |
redo B; |
| 3744 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3745 |
!!!cp ('t132'); |
!!!cp ('t132'); |
| 3746 |
## As if <head> |
## As if <head> |
| 3747 |
!!!create-element ($self->{head_element}, 'head'); |
!!!create-element ($self->{head_element}, 'head',, $token); |
| 3748 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3749 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3750 |
|
|
| 3757 |
!!!cp ('t133'); |
!!!cp ('t133'); |
| 3758 |
## As if </noscript> |
## As if </noscript> |
| 3759 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3760 |
!!!parse-error (type => 'in noscript:/head'); |
!!!parse-error (type => 'in noscript:/head', token => $token); |
| 3761 |
|
|
| 3762 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3763 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3783 |
redo B; |
redo B; |
| 3784 |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3785 |
!!!cp ('t137'); |
!!!cp ('t137'); |
| 3786 |
!!!parse-error (type => 'unmatched end tag:noscript'); |
!!!parse-error (type => 'unmatched end tag:noscript', token => $token); |
| 3787 |
## Ignore the token ## ISSUE: An issue in the spec. |
## Ignore the token ## ISSUE: An issue in the spec. |
| 3788 |
!!!next-token; |
!!!next-token; |
| 3789 |
redo B; |
redo B; |
| 3797 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3798 |
!!!cp ('t139'); |
!!!cp ('t139'); |
| 3799 |
## As if <head> |
## As if <head> |
| 3800 |
!!!create-element ($self->{head_element}, 'head'); |
!!!create-element ($self->{head_element}, 'head',, $token); |
| 3801 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3802 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3803 |
|
|
| 3805 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3806 |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 3807 |
!!!cp ('t140'); |
!!!cp ('t140'); |
| 3808 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 3809 |
## Ignore the token |
## Ignore the token |
| 3810 |
!!!next-token; |
!!!next-token; |
| 3811 |
redo B; |
redo B; |
| 3820 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3821 |
!!!cp ('t142'); |
!!!cp ('t142'); |
| 3822 |
## As if <head> |
## As if <head> |
| 3823 |
!!!create-element ($self->{head_element}, 'head'); |
!!!create-element ($self->{head_element}, 'head',, $token); |
| 3824 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 3825 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3826 |
|
|
| 3837 |
# |
# |
| 3838 |
} else { |
} else { |
| 3839 |
!!!cp ('t145'); |
!!!cp ('t145'); |
| 3840 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 3841 |
## Ignore the token |
## Ignore the token |
| 3842 |
!!!next-token; |
!!!next-token; |
| 3843 |
redo B; |
redo B; |
| 3848 |
!!!cp ('t146'); |
!!!cp ('t146'); |
| 3849 |
## As if </noscript> |
## As if </noscript> |
| 3850 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 3851 |
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}); |
!!!parse-error (type => 'in noscript:/'.$token->{tag_name}, token => $token); |
| 3852 |
|
|
| 3853 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 3854 |
## As if </head> |
## As if </head> |
| 3864 |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3865 |
## ISSUE: This case cannot be reached? |
## ISSUE: This case cannot be reached? |
| 3866 |
!!!cp ('t148'); |
!!!cp ('t148'); |
| 3867 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 3868 |
## Ignore the token ## ISSUE: An issue in the spec. |
## Ignore the token ## ISSUE: An issue in the spec. |
| 3869 |
!!!next-token; |
!!!next-token; |
| 3870 |
redo B; |
redo B; |
| 3874 |
|
|
| 3875 |
## "after head" insertion mode |
## "after head" insertion mode |
| 3876 |
## As if <body> |
## As if <body> |
| 3877 |
!!!insert-element ('body'); |
!!!insert-element ('body',, $token); |
| 3878 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 3879 |
## reprocess |
## reprocess |
| 3880 |
redo B; |
redo B; |
| 3881 |
} else { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 3882 |
die "$0: $token->{type}: Unknown token type"; |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3883 |
} |
!!!cp ('t149.1'); |
| 3884 |
|
|
| 3885 |
|
## NOTE: As if <head> |
| 3886 |
|
!!!create-element ($self->{head_element}, 'head',, $token); |
| 3887 |
|
$self->{open_elements}->[-1]->[0]->append_child |
| 3888 |
|
($self->{head_element}); |
| 3889 |
|
#push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3890 |
|
#$self->{insertion_mode} = IN_HEAD_IM; |
| 3891 |
|
## NOTE: Reprocess. |
| 3892 |
|
|
| 3893 |
|
## NOTE: As if </head> |
| 3894 |
|
#pop @{$self->{open_elements}}; |
| 3895 |
|
#$self->{insertion_mode} = IN_AFTER_HEAD_IM; |
| 3896 |
|
## NOTE: Reprocess. |
| 3897 |
|
|
| 3898 |
|
# |
| 3899 |
|
} elsif ($self->{insertion_mode} == IN_HEAD_IM) { |
| 3900 |
|
!!!cp ('t149.2'); |
| 3901 |
|
|
| 3902 |
|
## NOTE: As if </head> |
| 3903 |
|
pop @{$self->{open_elements}}; |
| 3904 |
|
#$self->{insertion_mode} = IN_AFTER_HEAD_IM; |
| 3905 |
|
## NOTE: Reprocess. |
| 3906 |
|
|
| 3907 |
|
# |
| 3908 |
|
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 3909 |
|
!!!cp ('t149.3'); |
| 3910 |
|
|
| 3911 |
|
!!!parse-error (type => 'in noscript:#eof', token => $token); |
| 3912 |
|
|
| 3913 |
|
## As if </noscript> |
| 3914 |
|
pop @{$self->{open_elements}}; |
| 3915 |
|
#$self->{insertion_mode} = IN_HEAD_IM; |
| 3916 |
|
## NOTE: Reprocess. |
| 3917 |
|
|
| 3918 |
|
## NOTE: As if </head> |
| 3919 |
|
pop @{$self->{open_elements}}; |
| 3920 |
|
#$self->{insertion_mode} = IN_AFTER_HEAD_IM; |
| 3921 |
|
## NOTE: Reprocess. |
| 3922 |
|
|
| 3923 |
|
# |
| 3924 |
|
} else { |
| 3925 |
|
!!!cp ('t149.4'); |
| 3926 |
|
# |
| 3927 |
|
} |
| 3928 |
|
|
| 3929 |
|
## NOTE: As if <body> |
| 3930 |
|
!!!insert-element ('body',, $token); |
| 3931 |
|
$self->{insertion_mode} = IN_BODY_IM; |
| 3932 |
|
## NOTE: Reprocess. |
| 3933 |
|
redo B; |
| 3934 |
|
} else { |
| 3935 |
|
die "$0: $token->{type}: Unknown token type"; |
| 3936 |
|
} |
| 3937 |
|
|
| 3938 |
## ISSUE: An issue in the spec. |
## ISSUE: An issue in the spec. |
| 3939 |
} elsif ($self->{insertion_mode} & BODY_IMS) { |
} elsif ($self->{insertion_mode} & BODY_IMS) { |
| 3953 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 3954 |
if ($self->{insertion_mode} == IN_CELL_IM) { |
if ($self->{insertion_mode} == IN_CELL_IM) { |
| 3955 |
## have an element in table scope |
## have an element in table scope |
| 3956 |
my $tn; |
for (reverse 0..$#{$self->{open_elements}}) { |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
| 3957 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 3958 |
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
| 3959 |
!!!cp ('t151'); |
!!!cp ('t151'); |
| 3960 |
$tn = $node->[1]; |
|
| 3961 |
last INSCOPE; |
## Close the cell |
| 3962 |
|
!!!back-token; # <?> |
| 3963 |
|
$token = {type => END_TAG_TOKEN, tag_name => $node->[1], |
| 3964 |
|
line => $token->{line}, |
| 3965 |
|
column => $token->{column}}; |
| 3966 |
|
redo B; |
| 3967 |
} elsif ({ |
} elsif ({ |
| 3968 |
table => 1, html => 1, |
table => 1, html => 1, |
| 3969 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 3970 |
!!!cp ('t152'); |
!!!cp ('t152'); |
| 3971 |
last INSCOPE; |
## ISSUE: This case can never be reached, maybe. |
| 3972 |
|
last; |
| 3973 |
} |
} |
| 3974 |
} # INSCOPE |
} |
| 3975 |
unless (defined $tn) { |
|
| 3976 |
!!!cp ('t153'); |
!!!cp ('t153'); |
| 3977 |
## TODO: This error type is wrong. |
!!!parse-error (type => 'start tag not allowed', |
| 3978 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
value => $token->{tag_name}, token => $token); |
| 3979 |
## Ignore the token |
## Ignore the token |
| 3980 |
!!!next-token; |
!!!next-token; |
|
redo B; |
|
|
} |
|
|
|
|
|
!!!cp ('t154'); |
|
|
## Close the cell |
|
|
!!!back-token; # <?> |
|
|
$token = {type => END_TAG_TOKEN, tag_name => $tn}; |
|
| 3981 |
redo B; |
redo B; |
| 3982 |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
| 3983 |
!!!parse-error (type => 'not closed:caption'); |
!!!parse-error (type => 'not closed:caption', token => $token); |
| 3984 |
|
|
| 3985 |
## As if </caption> |
## NOTE: As if </caption>. |
| 3986 |
## have a table element in table scope |
## have a table element in table scope |
| 3987 |
my $i; |
my $i; |
| 3988 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: { |
| 3989 |
my $node = $self->{open_elements}->[$_]; |
for (reverse 0..$#{$self->{open_elements}}) { |
| 3990 |
if ($node->[1] eq 'caption') { |
my $node = $self->{open_elements}->[$_]; |
| 3991 |
!!!cp ('t155'); |
if ($node->[1] eq 'caption') { |
| 3992 |
$i = $_; |
!!!cp ('t155'); |
| 3993 |
last INSCOPE; |
$i = $_; |
| 3994 |
} elsif ({ |
last INSCOPE; |
| 3995 |
table => 1, html => 1, |
} elsif ({ |
| 3996 |
}->{$node->[1]}) { |
table => 1, html => 1, |
| 3997 |
!!!cp ('t156'); |
}->{$node->[1]}) { |
| 3998 |
last INSCOPE; |
!!!cp ('t156'); |
| 3999 |
|
last; |
| 4000 |
|
} |
| 4001 |
} |
} |
| 4002 |
|
|
| 4003 |
|
!!!cp ('t157'); |
| 4004 |
|
!!!parse-error (type => 'start tag not allowed', |
| 4005 |
|
value => $token->{tag_name}, token => $token); |
| 4006 |
|
## Ignore the token |
| 4007 |
|
!!!next-token; |
| 4008 |
|
redo B; |
| 4009 |
} # 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; |
|
|
} |
|
| 4010 |
|
|
| 4011 |
## generate implied end tags |
## generate implied end tags |
| 4012 |
while ({ |
while ({ |
| 4018 |
|
|
| 4019 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 4020 |
!!!cp ('t159'); |
!!!cp ('t159'); |
| 4021 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 4022 |
} else { |
} else { |
| 4023 |
!!!cp ('t160'); |
!!!cp ('t160'); |
| 4024 |
} |
} |
| 4059 |
} # INSCOPE |
} # INSCOPE |
| 4060 |
unless (defined $i) { |
unless (defined $i) { |
| 4061 |
!!!cp ('t165'); |
!!!cp ('t165'); |
| 4062 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4063 |
## Ignore the token |
## Ignore the token |
| 4064 |
!!!next-token; |
!!!next-token; |
| 4065 |
redo B; |
redo B; |
| 4075 |
|
|
| 4076 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 4077 |
!!!cp ('t167'); |
!!!cp ('t167'); |
| 4078 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 4079 |
} else { |
} else { |
| 4080 |
!!!cp ('t168'); |
!!!cp ('t168'); |
| 4081 |
} |
} |
| 4090 |
redo B; |
redo B; |
| 4091 |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
| 4092 |
!!!cp ('t169'); |
!!!cp ('t169'); |
| 4093 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4094 |
## Ignore the token |
## Ignore the token |
| 4095 |
!!!next-token; |
!!!next-token; |
| 4096 |
redo B; |
redo B; |
| 4102 |
if ($self->{insertion_mode} == IN_CAPTION_IM) { |
if ($self->{insertion_mode} == IN_CAPTION_IM) { |
| 4103 |
## have a table element in table scope |
## have a table element in table scope |
| 4104 |
my $i; |
my $i; |
| 4105 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: { |
| 4106 |
my $node = $self->{open_elements}->[$_]; |
for (reverse 0..$#{$self->{open_elements}}) { |
| 4107 |
if ($node->[1] eq $token->{tag_name}) { |
my $node = $self->{open_elements}->[$_]; |
| 4108 |
!!!cp ('t171'); |
if ($node->[1] eq $token->{tag_name}) { |
| 4109 |
$i = $_; |
!!!cp ('t171'); |
| 4110 |
last INSCOPE; |
$i = $_; |
| 4111 |
} elsif ({ |
last INSCOPE; |
| 4112 |
table => 1, html => 1, |
} elsif ({ |
| 4113 |
}->{$node->[1]}) { |
table => 1, html => 1, |
| 4114 |
!!!cp ('t172'); |
}->{$node->[1]}) { |
| 4115 |
last INSCOPE; |
!!!cp ('t172'); |
| 4116 |
|
last; |
| 4117 |
|
} |
| 4118 |
} |
} |
| 4119 |
|
|
| 4120 |
|
!!!cp ('t173'); |
| 4121 |
|
!!!parse-error (type => 'unmatched end tag', |
| 4122 |
|
value => $token->{tag_name}, token => $token); |
| 4123 |
|
## Ignore the token |
| 4124 |
|
!!!next-token; |
| 4125 |
|
redo B; |
| 4126 |
} # INSCOPE |
} # INSCOPE |
|
unless (defined $i) { |
|
|
!!!cp ('t173'); |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
| 4127 |
|
|
| 4128 |
## generate implied end tags |
## generate implied end tags |
| 4129 |
while ({ |
while ({ |
| 4135 |
|
|
| 4136 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 4137 |
!!!cp ('t175'); |
!!!cp ('t175'); |
| 4138 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 4139 |
} else { |
} else { |
| 4140 |
!!!cp ('t176'); |
!!!cp ('t176'); |
| 4141 |
} |
} |
| 4150 |
redo B; |
redo B; |
| 4151 |
} elsif ($self->{insertion_mode} == IN_CELL_IM) { |
} elsif ($self->{insertion_mode} == IN_CELL_IM) { |
| 4152 |
!!!cp ('t177'); |
!!!cp ('t177'); |
| 4153 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4154 |
## Ignore the token |
## Ignore the token |
| 4155 |
!!!next-token; |
!!!next-token; |
| 4156 |
redo B; |
redo B; |
| 4166 |
## have an element in table scope |
## have an element in table scope |
| 4167 |
my $i; |
my $i; |
| 4168 |
my $tn; |
my $tn; |
| 4169 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: { |
| 4170 |
my $node = $self->{open_elements}->[$_]; |
for (reverse 0..$#{$self->{open_elements}}) { |
| 4171 |
if ($node->[1] eq $token->{tag_name}) { |
my $node = $self->{open_elements}->[$_]; |
| 4172 |
!!!cp ('t179'); |
if ($node->[1] eq $token->{tag_name}) { |
| 4173 |
$i = $_; |
!!!cp ('t179'); |
| 4174 |
last INSCOPE; |
$i = $_; |
| 4175 |
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
|
| 4176 |
!!!cp ('t180'); |
## Close the cell |
| 4177 |
$tn = $node->[1]; |
!!!back-token; # </?> |
| 4178 |
## NOTE: There is exactly one |td| or |th| element |
$token = {type => END_TAG_TOKEN, tag_name => $tn, |
| 4179 |
## in scope in the stack of open elements by definition. |
line => $token->{line}, |
| 4180 |
} elsif ({ |
column => $token->{column}}; |
| 4181 |
table => 1, html => 1, |
redo B; |
| 4182 |
}->{$node->[1]}) { |
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
| 4183 |
!!!cp ('t181'); |
!!!cp ('t180'); |
| 4184 |
last INSCOPE; |
$tn = $node->[1]; |
| 4185 |
|
## NOTE: There is exactly one |td| or |th| element |
| 4186 |
|
## in scope in the stack of open elements by definition. |
| 4187 |
|
} elsif ({ |
| 4188 |
|
table => 1, html => 1, |
| 4189 |
|
}->{$node->[1]}) { |
| 4190 |
|
## ISSUE: Can this be reached? |
| 4191 |
|
!!!cp ('t181'); |
| 4192 |
|
last; |
| 4193 |
|
} |
| 4194 |
} |
} |
| 4195 |
} # INSCOPE |
|
|
unless (defined $i) { |
|
| 4196 |
!!!cp ('t182'); |
!!!cp ('t182'); |
| 4197 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag', |
| 4198 |
|
value => $token->{tag_name}, token => $token); |
| 4199 |
## Ignore the token |
## Ignore the token |
| 4200 |
!!!next-token; |
!!!next-token; |
| 4201 |
redo B; |
redo B; |
| 4202 |
} else { |
} # INSCOPE |
|
!!!cp ('t183'); |
|
|
} |
|
|
|
|
|
## Close the cell |
|
|
!!!back-token; # </?> |
|
|
$token = {type => END_TAG_TOKEN, tag_name => $tn}; |
|
|
redo B; |
|
| 4203 |
} elsif ($token->{tag_name} eq 'table' and |
} elsif ($token->{tag_name} eq 'table' and |
| 4204 |
$self->{insertion_mode} == IN_CAPTION_IM) { |
$self->{insertion_mode} == IN_CAPTION_IM) { |
| 4205 |
!!!parse-error (type => 'not closed:caption'); |
!!!parse-error (type => 'not closed:caption', token => $token); |
| 4206 |
|
|
| 4207 |
## As if </caption> |
## As if </caption> |
| 4208 |
## have a table element in table scope |
## have a table element in table scope |
| 4222 |
} # INSCOPE |
} # INSCOPE |
| 4223 |
unless (defined $i) { |
unless (defined $i) { |
| 4224 |
!!!cp ('t186'); |
!!!cp ('t186'); |
| 4225 |
!!!parse-error (type => 'unmatched end tag:caption'); |
!!!parse-error (type => 'unmatched end tag:caption', token => $token); |
| 4226 |
## Ignore the token |
## Ignore the token |
| 4227 |
!!!next-token; |
!!!next-token; |
| 4228 |
redo B; |
redo B; |
| 4238 |
|
|
| 4239 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 4240 |
!!!cp ('t188'); |
!!!cp ('t188'); |
| 4241 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 4242 |
} else { |
} else { |
| 4243 |
!!!cp ('t189'); |
!!!cp ('t189'); |
| 4244 |
} |
} |
| 4256 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4257 |
if ($self->{insertion_mode} & BODY_TABLE_IMS) { |
if ($self->{insertion_mode} & BODY_TABLE_IMS) { |
| 4258 |
!!!cp ('t190'); |
!!!cp ('t190'); |
| 4259 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4260 |
## Ignore the token |
## Ignore the token |
| 4261 |
!!!next-token; |
!!!next-token; |
| 4262 |
redo B; |
redo B; |
| 4270 |
}->{$token->{tag_name}} and |
}->{$token->{tag_name}} and |
| 4271 |
$self->{insertion_mode} == IN_CAPTION_IM) { |
$self->{insertion_mode} == IN_CAPTION_IM) { |
| 4272 |
!!!cp ('t192'); |
!!!cp ('t192'); |
| 4273 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4274 |
## Ignore the token |
## Ignore the token |
| 4275 |
!!!next-token; |
!!!next-token; |
| 4276 |
redo B; |
redo B; |
| 4278 |
!!!cp ('t193'); |
!!!cp ('t193'); |
| 4279 |
# |
# |
| 4280 |
} |
} |
| 4281 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 4282 |
|
for my $entry (@{$self->{open_elements}}) { |
| 4283 |
|
if (not { |
| 4284 |
|
dd => 1, dt => 1, li => 1, p => 1, tbody => 1, td => 1, tfoot => 1, |
| 4285 |
|
th => 1, thead => 1, tr => 1, body => 1, html => 1, |
| 4286 |
|
}->{$entry->[1]}) { |
| 4287 |
|
!!!cp ('t75'); |
| 4288 |
|
!!!parse-error (type => 'in body:#eof', token => $token); |
| 4289 |
|
last; |
| 4290 |
|
} |
| 4291 |
|
} |
| 4292 |
|
|
| 4293 |
|
## Stop parsing. |
| 4294 |
|
last B; |
| 4295 |
} else { |
} else { |
| 4296 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 4297 |
} |
} |
| 4313 |
} |
} |
| 4314 |
} |
} |
| 4315 |
|
|
| 4316 |
!!!parse-error (type => 'in table:#character'); |
!!!parse-error (type => 'in table:#character', token => $token); |
| 4317 |
|
|
| 4318 |
## As if in body, but insert into foster parent element |
## As if in body, but insert into foster parent element |
| 4319 |
## ISSUE: Spec says that "whenever a node would be inserted |
## ISSUE: Spec says that "whenever a node would be inserted |
| 4379 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4380 |
} |
} |
| 4381 |
|
|
| 4382 |
!!!insert-element ('tbody'); |
!!!insert-element ('tbody',, $token); |
| 4383 |
$self->{insertion_mode} = IN_TABLE_BODY_IM; |
$self->{insertion_mode} = IN_TABLE_BODY_IM; |
| 4384 |
## reprocess in the "in table body" insertion mode... |
## reprocess in the "in table body" insertion mode... |
| 4385 |
} |
} |
| 4387 |
if ($self->{insertion_mode} == IN_TABLE_BODY_IM) { |
if ($self->{insertion_mode} == IN_TABLE_BODY_IM) { |
| 4388 |
unless ($token->{tag_name} eq 'tr') { |
unless ($token->{tag_name} eq 'tr') { |
| 4389 |
!!!cp ('t202'); |
!!!cp ('t202'); |
| 4390 |
!!!parse-error (type => 'missing start tag:tr'); |
!!!parse-error (type => 'missing start tag:tr', token => $token); |
| 4391 |
} |
} |
| 4392 |
|
|
| 4393 |
## Clear back to table body context |
## Clear back to table body context |
| 4402 |
$self->{insertion_mode} = IN_ROW_IM; |
$self->{insertion_mode} = IN_ROW_IM; |
| 4403 |
if ($token->{tag_name} eq 'tr') { |
if ($token->{tag_name} eq 'tr') { |
| 4404 |
!!!cp ('t204'); |
!!!cp ('t204'); |
| 4405 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 4406 |
!!!next-token; |
!!!next-token; |
| 4407 |
redo B; |
redo B; |
| 4408 |
} else { |
} else { |
| 4409 |
!!!cp ('t205'); |
!!!cp ('t205'); |
| 4410 |
!!!insert-element ('tr'); |
!!!insert-element ('tr',, $token); |
| 4411 |
## reprocess in the "in row" insertion mode |
## reprocess in the "in row" insertion mode |
| 4412 |
} |
} |
| 4413 |
} else { |
} else { |
| 4422 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4423 |
} |
} |
| 4424 |
|
|
| 4425 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 4426 |
$self->{insertion_mode} = IN_CELL_IM; |
$self->{insertion_mode} = IN_CELL_IM; |
| 4427 |
|
|
| 4428 |
push @$active_formatting_elements, ['#marker', '']; |
push @$active_formatting_elements, ['#marker', '']; |
| 4457 |
unless (defined $i) { |
unless (defined $i) { |
| 4458 |
!!!cp ('t210'); |
!!!cp ('t210'); |
| 4459 |
## TODO: This type is wrong. |
## TODO: This type is wrong. |
| 4460 |
!!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}, token => $token); |
| 4461 |
## Ignore the token |
## Ignore the token |
| 4462 |
!!!next-token; |
!!!next-token; |
| 4463 |
redo B; |
redo B; |
| 4505 |
unless (defined $i) { |
unless (defined $i) { |
| 4506 |
!!!cp ('t216'); |
!!!cp ('t216'); |
| 4507 |
## TODO: This erorr type ios wrong. |
## TODO: This erorr type ios wrong. |
| 4508 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4509 |
## Ignore the token |
## Ignore the token |
| 4510 |
!!!next-token; |
!!!next-token; |
| 4511 |
redo B; |
redo B; |
| 4543 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4544 |
} |
} |
| 4545 |
|
|
| 4546 |
!!!insert-element ('colgroup'); |
!!!insert-element ('colgroup',, $token); |
| 4547 |
$self->{insertion_mode} = IN_COLUMN_GROUP_IM; |
$self->{insertion_mode} = IN_COLUMN_GROUP_IM; |
| 4548 |
## reprocess |
## reprocess |
| 4549 |
redo B; |
redo B; |
| 4563 |
push @$active_formatting_elements, ['#marker', ''] |
push @$active_formatting_elements, ['#marker', ''] |
| 4564 |
if $token->{tag_name} eq 'caption'; |
if $token->{tag_name} eq 'caption'; |
| 4565 |
|
|
| 4566 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 4567 |
$self->{insertion_mode} = { |
$self->{insertion_mode} = { |
| 4568 |
caption => IN_CAPTION_IM, |
caption => IN_CAPTION_IM, |
| 4569 |
colgroup => IN_COLUMN_GROUP_IM, |
colgroup => IN_COLUMN_GROUP_IM, |
| 4577 |
die "$0: in table: <>: $token->{tag_name}"; |
die "$0: in table: <>: $token->{tag_name}"; |
| 4578 |
} |
} |
| 4579 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 4580 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 4581 |
|
|
| 4582 |
## As if </table> |
## As if </table> |
| 4583 |
## have a table element in table scope |
## have a table element in table scope |
| 4599 |
unless (defined $i) { |
unless (defined $i) { |
| 4600 |
!!!cp ('t223'); |
!!!cp ('t223'); |
| 4601 |
## TODO: The following is wrong, maybe. |
## TODO: The following is wrong, maybe. |
| 4602 |
!!!parse-error (type => 'unmatched end tag:table'); |
!!!parse-error (type => 'unmatched end tag:table', token => $token); |
| 4603 |
## Ignore tokens </table><table> |
## Ignore tokens </table><table> |
| 4604 |
!!!next-token; |
!!!next-token; |
| 4605 |
redo B; |
redo B; |
| 4606 |
} |
} |
| 4607 |
|
|
| 4608 |
|
## TODO: Followings are removed from the latest spec. |
| 4609 |
## generate implied end tags |
## generate implied end tags |
| 4610 |
while ({ |
while ({ |
| 4611 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4617 |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
| 4618 |
!!!cp ('t225'); |
!!!cp ('t225'); |
| 4619 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
| 4620 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 4621 |
} else { |
} else { |
| 4622 |
!!!cp ('t226'); |
!!!cp ('t226'); |
| 4623 |
} |
} |
| 4629 |
|
|
| 4630 |
## reprocess |
## reprocess |
| 4631 |
redo B; |
redo B; |
| 4632 |
|
} elsif ($token->{tag_name} eq 'style') { |
| 4633 |
|
if (not $open_tables->[-1]->[1]) { # tainted |
| 4634 |
|
!!!cp ('t227.8'); |
| 4635 |
|
## NOTE: This is a "as if in head" code clone. |
| 4636 |
|
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 4637 |
|
redo B; |
| 4638 |
|
} else { |
| 4639 |
|
!!!cp ('t227.7'); |
| 4640 |
|
# |
| 4641 |
|
} |
| 4642 |
|
} elsif ($token->{tag_name} eq 'script') { |
| 4643 |
|
if (not $open_tables->[-1]->[1]) { # tainted |
| 4644 |
|
!!!cp ('t227.6'); |
| 4645 |
|
## NOTE: This is a "as if in head" code clone. |
| 4646 |
|
$script_start_tag->(); |
| 4647 |
|
redo B; |
| 4648 |
|
} else { |
| 4649 |
|
!!!cp ('t227.5'); |
| 4650 |
|
# |
| 4651 |
|
} |
| 4652 |
} elsif ($token->{tag_name} eq 'input') { |
} elsif ($token->{tag_name} eq 'input') { |
| 4653 |
if (not $open_tables->[-1]->[1]) { # tainted |
if (not $open_tables->[-1]->[1]) { # tainted |
| 4654 |
if ($token->{attributes}->{type}) { ## TODO: case |
if ($token->{attributes}->{type}) { ## TODO: case |
| 4655 |
my $type = lc $token->{attributes}->{type}->{value}; |
my $type = lc $token->{attributes}->{type}->{value}; |
| 4656 |
if ($type eq 'hidden') { |
if ($type eq 'hidden') { |
| 4657 |
!!!cp ('t227.3'); |
!!!cp ('t227.3'); |
| 4658 |
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
!!!parse-error (type => 'in table:'.$token->{tag_name}, token => $token); |
| 4659 |
|
|
| 4660 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 4661 |
|
|
| 4662 |
## TODO: form element pointer |
## TODO: form element pointer |
| 4663 |
|
|
| 4682 |
# |
# |
| 4683 |
} |
} |
| 4684 |
|
|
| 4685 |
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
!!!parse-error (type => 'in table:'.$token->{tag_name}, token => $token); |
| 4686 |
|
|
| 4687 |
$insert = $insert_to_foster; |
$insert = $insert_to_foster; |
| 4688 |
# |
# |
| 4706 |
} # INSCOPE |
} # INSCOPE |
| 4707 |
unless (defined $i) { |
unless (defined $i) { |
| 4708 |
!!!cp ('t230'); |
!!!cp ('t230'); |
| 4709 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4710 |
## Ignore the token |
## Ignore the token |
| 4711 |
!!!next-token; |
!!!next-token; |
| 4712 |
redo B; |
redo B; |
| 4748 |
unless (defined $i) { |
unless (defined $i) { |
| 4749 |
!!!cp ('t235'); |
!!!cp ('t235'); |
| 4750 |
## TODO: The following is wrong. |
## TODO: The following is wrong. |
| 4751 |
!!!parse-error (type => 'unmatched end tag:'.$token->{type}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{type}, token => $token); |
| 4752 |
## Ignore the token |
## Ignore the token |
| 4753 |
!!!next-token; |
!!!next-token; |
| 4754 |
redo B; |
redo B; |
| 4788 |
} # INSCOPE |
} # INSCOPE |
| 4789 |
unless (defined $i) { |
unless (defined $i) { |
| 4790 |
!!!cp ('t239'); |
!!!cp ('t239'); |
| 4791 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4792 |
## Ignore the token |
## Ignore the token |
| 4793 |
!!!next-token; |
!!!next-token; |
| 4794 |
redo B; |
redo B; |
| 4836 |
} # INSCOPE |
} # INSCOPE |
| 4837 |
unless (defined $i) { |
unless (defined $i) { |
| 4838 |
!!!cp ('t243'); |
!!!cp ('t243'); |
| 4839 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4840 |
## Ignore the token |
## Ignore the token |
| 4841 |
!!!next-token; |
!!!next-token; |
| 4842 |
redo B; |
redo B; |
| 4871 |
} # INSCOPE |
} # INSCOPE |
| 4872 |
unless (defined $i) { |
unless (defined $i) { |
| 4873 |
!!!cp ('t249'); |
!!!cp ('t249'); |
| 4874 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4875 |
## Ignore the token |
## Ignore the token |
| 4876 |
!!!next-token; |
!!!next-token; |
| 4877 |
redo B; |
redo B; |
| 4895 |
} # INSCOPE |
} # INSCOPE |
| 4896 |
unless (defined $i) { |
unless (defined $i) { |
| 4897 |
!!!cp ('t252'); |
!!!cp ('t252'); |
| 4898 |
!!!parse-error (type => 'unmatched end tag:tr'); |
!!!parse-error (type => 'unmatched end tag:tr', token => $token); |
| 4899 |
## Ignore the token |
## Ignore the token |
| 4900 |
!!!next-token; |
!!!next-token; |
| 4901 |
redo B; |
redo B; |
| 4932 |
} # INSCOPE |
} # INSCOPE |
| 4933 |
unless (defined $i) { |
unless (defined $i) { |
| 4934 |
!!!cp ('t256'); |
!!!cp ('t256'); |
| 4935 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4936 |
## Ignore the token |
## Ignore the token |
| 4937 |
!!!next-token; |
!!!next-token; |
| 4938 |
redo B; |
redo B; |
| 4958 |
tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM |
tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM |
| 4959 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4960 |
!!!cp ('t258'); |
!!!cp ('t258'); |
| 4961 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4962 |
## Ignore the token |
## Ignore the token |
| 4963 |
!!!next-token; |
!!!next-token; |
| 4964 |
redo B; |
redo B; |
| 4965 |
} else { |
} else { |
| 4966 |
!!!cp ('t259'); |
!!!cp ('t259'); |
| 4967 |
!!!parse-error (type => 'in table:/'.$token->{tag_name}); |
!!!parse-error (type => 'in table:/'.$token->{tag_name}, token => $token); |
| 4968 |
|
|
| 4969 |
$insert = $insert_to_foster; |
$insert = $insert_to_foster; |
| 4970 |
# |
# |
| 4971 |
} |
} |
| 4972 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 4973 |
|
unless ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 4974 |
|
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 4975 |
|
!!!parse-error (type => 'in body:#eof', token => $token); |
| 4976 |
|
!!!cp ('t259.1'); |
| 4977 |
|
# |
| 4978 |
|
} else { |
| 4979 |
|
!!!cp ('t259.2'); |
| 4980 |
|
# |
| 4981 |
|
} |
| 4982 |
|
|
| 4983 |
|
## Stop parsing |
| 4984 |
|
last B; |
| 4985 |
} else { |
} else { |
| 4986 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 4987 |
} |
} |
| 5001 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 5002 |
if ($token->{tag_name} eq 'col') { |
if ($token->{tag_name} eq 'col') { |
| 5003 |
!!!cp ('t262'); |
!!!cp ('t262'); |
| 5004 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 5005 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5006 |
!!!next-token; |
!!!next-token; |
| 5007 |
redo B; |
redo B; |
| 5013 |
if ($token->{tag_name} eq 'colgroup') { |
if ($token->{tag_name} eq 'colgroup') { |
| 5014 |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
| 5015 |
!!!cp ('t264'); |
!!!cp ('t264'); |
| 5016 |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
!!!parse-error (type => 'unmatched end tag:colgroup', token => $token); |
| 5017 |
## Ignore the token |
## Ignore the token |
| 5018 |
!!!next-token; |
!!!next-token; |
| 5019 |
redo B; |
redo B; |
| 5026 |
} |
} |
| 5027 |
} elsif ($token->{tag_name} eq 'col') { |
} elsif ($token->{tag_name} eq 'col') { |
| 5028 |
!!!cp ('t266'); |
!!!cp ('t266'); |
| 5029 |
!!!parse-error (type => 'unmatched end tag:col'); |
!!!parse-error (type => 'unmatched end tag:col', token => $token); |
| 5030 |
## Ignore the token |
## Ignore the token |
| 5031 |
!!!next-token; |
!!!next-token; |
| 5032 |
redo B; |
redo B; |
| 5034 |
!!!cp ('t267'); |
!!!cp ('t267'); |
| 5035 |
# |
# |
| 5036 |
} |
} |
| 5037 |
} else { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5038 |
die "$0: $token->{type}: Unknown token type"; |
if ($self->{open_elements}->[-1]->[1] eq 'html' or |
| 5039 |
} |
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 5040 |
|
!!!cp ('t270.2'); |
| 5041 |
|
## Stop parsing. |
| 5042 |
|
last B; |
| 5043 |
|
} else { |
| 5044 |
|
## NOTE: As if </colgroup>. |
| 5045 |
|
!!!cp ('t270.1'); |
| 5046 |
|
pop @{$self->{open_elements}}; # colgroup |
| 5047 |
|
$self->{insertion_mode} = IN_TABLE_IM; |
| 5048 |
|
## Reprocess. |
| 5049 |
|
redo B; |
| 5050 |
|
} |
| 5051 |
|
} else { |
| 5052 |
|
die "$0: $token->{type}: Unknown token type"; |
| 5053 |
|
} |
| 5054 |
|
|
| 5055 |
## As if </colgroup> |
## As if </colgroup> |
| 5056 |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
| 5057 |
!!!cp ('t269'); |
!!!cp ('t269'); |
| 5058 |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
## TODO: Wrong error type? |
| 5059 |
|
!!!parse-error (type => 'unmatched end tag:colgroup', token => $token); |
| 5060 |
## Ignore the token |
## Ignore the token |
| 5061 |
!!!next-token; |
!!!next-token; |
| 5062 |
redo B; |
redo B; |
| 5067 |
## reprocess |
## reprocess |
| 5068 |
redo B; |
redo B; |
| 5069 |
} |
} |
| 5070 |
} elsif ($self->{insertion_mode} == IN_SELECT_IM) { |
} elsif ($self->{insertion_mode} & SELECT_IMS) { |
| 5071 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 5072 |
!!!cp ('t271'); |
!!!cp ('t271'); |
| 5073 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 5083 |
!!!cp ('t273'); |
!!!cp ('t273'); |
| 5084 |
} |
} |
| 5085 |
|
|
| 5086 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 5087 |
!!!next-token; |
!!!next-token; |
| 5088 |
redo B; |
redo B; |
| 5089 |
} elsif ($token->{tag_name} eq 'optgroup') { |
} elsif ($token->{tag_name} eq 'optgroup') { |
| 5103 |
!!!cp ('t277'); |
!!!cp ('t277'); |
| 5104 |
} |
} |
| 5105 |
|
|
| 5106 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 5107 |
!!!next-token; |
!!!next-token; |
| 5108 |
redo B; |
redo B; |
| 5109 |
} elsif ($token->{tag_name} eq 'select') { |
} elsif ($token->{tag_name} eq 'select' or |
| 5110 |
## TODO: The type below is not good - <select> is replaced by </select> |
$token->{tag_name} eq 'input' or |
| 5111 |
!!!parse-error (type => 'not closed:select'); |
($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
| 5112 |
## As if </select> instead |
{ |
| 5113 |
|
caption => 1, table => 1, |
| 5114 |
|
tbody => 1, tfoot => 1, thead => 1, |
| 5115 |
|
tr => 1, td => 1, th => 1, |
| 5116 |
|
}->{$token->{tag_name}})) { |
| 5117 |
|
## TODO: The type below is not good - <select> is replaced by </select> |
| 5118 |
|
!!!parse-error (type => 'not closed:select', token => $token); |
| 5119 |
|
## NOTE: As if the token were </select> (<select> case) or |
| 5120 |
|
## as if there were </select> (otherwise). |
| 5121 |
## have an element in table scope |
## have an element in table scope |
| 5122 |
my $i; |
my $i; |
| 5123 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5124 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5125 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq 'select') { |
| 5126 |
!!!cp ('t278'); |
!!!cp ('t278'); |
| 5127 |
$i = $_; |
$i = $_; |
| 5128 |
last INSCOPE; |
last INSCOPE; |
| 5135 |
} # INSCOPE |
} # INSCOPE |
| 5136 |
unless (defined $i) { |
unless (defined $i) { |
| 5137 |
!!!cp ('t280'); |
!!!cp ('t280'); |
| 5138 |
!!!parse-error (type => 'unmatched end tag:select'); |
!!!parse-error (type => 'unmatched end tag:select', token => $token); |
| 5139 |
## Ignore the token |
## Ignore the token |
| 5140 |
!!!next-token; |
!!!next-token; |
| 5141 |
redo B; |
redo B; |
| 5146 |
|
|
| 5147 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 5148 |
|
|
| 5149 |
!!!next-token; |
if ($token->{tag_name} eq 'select') { |
| 5150 |
redo B; |
!!!cp ('t281.2'); |
| 5151 |
|
!!!next-token; |
| 5152 |
|
redo B; |
| 5153 |
|
} else { |
| 5154 |
|
!!!cp ('t281.1'); |
| 5155 |
|
## Reprocess the token. |
| 5156 |
|
redo B; |
| 5157 |
|
} |
| 5158 |
} else { |
} else { |
| 5159 |
!!!cp ('t282'); |
!!!cp ('t282'); |
| 5160 |
!!!parse-error (type => 'in select:'.$token->{tag_name}); |
!!!parse-error (type => 'in select:'.$token->{tag_name}, token => $token); |
| 5161 |
## Ignore the token |
## Ignore the token |
| 5162 |
!!!next-token; |
!!!next-token; |
| 5163 |
redo B; |
redo B; |
| 5174 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5175 |
} else { |
} else { |
| 5176 |
!!!cp ('t285'); |
!!!cp ('t285'); |
| 5177 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5178 |
## Ignore the token |
## Ignore the token |
| 5179 |
} |
} |
| 5180 |
!!!next-token; |
!!!next-token; |
| 5185 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5186 |
} else { |
} else { |
| 5187 |
!!!cp ('t287'); |
!!!cp ('t287'); |
| 5188 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5189 |
## Ignore the token |
## Ignore the token |
| 5190 |
} |
} |
| 5191 |
!!!next-token; |
!!!next-token; |
| 5208 |
} # INSCOPE |
} # INSCOPE |
| 5209 |
unless (defined $i) { |
unless (defined $i) { |
| 5210 |
!!!cp ('t290'); |
!!!cp ('t290'); |
| 5211 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5212 |
## Ignore the token |
## Ignore the token |
| 5213 |
!!!next-token; |
!!!next-token; |
| 5214 |
redo B; |
redo B; |
| 5221 |
|
|
| 5222 |
!!!next-token; |
!!!next-token; |
| 5223 |
redo B; |
redo B; |
| 5224 |
} elsif ({ |
} elsif ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
| 5225 |
caption => 1, table => 1, tbody => 1, |
{ |
| 5226 |
tfoot => 1, thead => 1, tr => 1, td => 1, th => 1, |
caption => 1, table => 1, tbody => 1, |
| 5227 |
}->{$token->{tag_name}}) { |
tfoot => 1, thead => 1, tr => 1, td => 1, th => 1, |
| 5228 |
|
}->{$token->{tag_name}}) { |
| 5229 |
## TODO: The following is wrong? |
## TODO: The following is wrong? |
| 5230 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5231 |
|
|
| 5232 |
## have an element in table scope |
## have an element in table scope |
| 5233 |
my $i; |
my $i; |
| 5271 |
unless (defined $i) { |
unless (defined $i) { |
| 5272 |
!!!cp ('t297'); |
!!!cp ('t297'); |
| 5273 |
## TODO: The following error type is correct? |
## TODO: The following error type is correct? |
| 5274 |
!!!parse-error (type => 'unmatched end tag:select'); |
!!!parse-error (type => 'unmatched end tag:select', token => $token); |
| 5275 |
## Ignore the </select> token |
## Ignore the </select> token |
| 5276 |
!!!next-token; ## TODO: ok? |
!!!next-token; ## TODO: ok? |
| 5277 |
redo B; |
redo B; |
| 5286 |
redo B; |
redo B; |
| 5287 |
} else { |
} else { |
| 5288 |
!!!cp ('t299'); |
!!!cp ('t299'); |
| 5289 |
!!!parse-error (type => 'in select:/'.$token->{tag_name}); |
!!!parse-error (type => 'in select:/'.$token->{tag_name}, token => $token); |
| 5290 |
## Ignore the token |
## Ignore the token |
| 5291 |
!!!next-token; |
!!!next-token; |
| 5292 |
redo B; |
redo B; |
| 5293 |
} |
} |
| 5294 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5295 |
|
unless ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 5296 |
|
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 5297 |
|
!!!cp ('t299.1'); |
| 5298 |
|
!!!parse-error (type => 'in body:#eof', token => $token); |
| 5299 |
|
} else { |
| 5300 |
|
!!!cp ('t299.2'); |
| 5301 |
|
} |
| 5302 |
|
|
| 5303 |
|
## Stop parsing. |
| 5304 |
|
last B; |
| 5305 |
} else { |
} else { |
| 5306 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 5307 |
} |
} |
| 5323 |
|
|
| 5324 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 5325 |
!!!cp ('t301'); |
!!!cp ('t301'); |
| 5326 |
!!!parse-error (type => 'after html:#character'); |
!!!parse-error (type => 'after html:#character', token => $token); |
| 5327 |
|
|
| 5328 |
## Reprocess in the "after body" insertion mode. |
## Reprocess in the "after body" insertion mode. |
| 5329 |
} else { |
} else { |
| 5331 |
} |
} |
| 5332 |
|
|
| 5333 |
## "after body" insertion mode |
## "after body" insertion mode |
| 5334 |
!!!parse-error (type => 'after body:#character'); |
!!!parse-error (type => 'after body:#character', token => $token); |
| 5335 |
|
|
| 5336 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 5337 |
## reprocess |
## reprocess |
| 5339 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 5340 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 5341 |
!!!cp ('t303'); |
!!!cp ('t303'); |
| 5342 |
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
!!!parse-error (type => 'after html:'.$token->{tag_name}, token => $token); |
| 5343 |
|
|
| 5344 |
## Reprocess in the "after body" insertion mode. |
## Reprocess in the "after body" insertion mode. |
| 5345 |
} else { |
} else { |
| 5347 |
} |
} |
| 5348 |
|
|
| 5349 |
## "after body" insertion mode |
## "after body" insertion mode |
| 5350 |
!!!parse-error (type => 'after body:'.$token->{tag_name}); |
!!!parse-error (type => 'after body:'.$token->{tag_name}, token => $token); |
| 5351 |
|
|
| 5352 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 5353 |
## reprocess |
## reprocess |
| 5355 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 5356 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 5357 |
!!!cp ('t305'); |
!!!cp ('t305'); |
| 5358 |
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
!!!parse-error (type => 'after html:/'.$token->{tag_name}, token => $token); |
| 5359 |
|
|
| 5360 |
$self->{insertion_mode} = AFTER_BODY_IM; |
$self->{insertion_mode} = AFTER_BODY_IM; |
| 5361 |
## Reprocess in the "after body" insertion mode. |
## Reprocess in the "after body" insertion mode. |
| 5367 |
if ($token->{tag_name} eq 'html') { |
if ($token->{tag_name} eq 'html') { |
| 5368 |
if (defined $self->{inner_html_node}) { |
if (defined $self->{inner_html_node}) { |
| 5369 |
!!!cp ('t307'); |
!!!cp ('t307'); |
| 5370 |
!!!parse-error (type => 'unmatched end tag:html'); |
!!!parse-error (type => 'unmatched end tag:html', token => $token); |
| 5371 |
## Ignore the token |
## Ignore the token |
| 5372 |
!!!next-token; |
!!!next-token; |
| 5373 |
redo B; |
redo B; |
| 5379 |
} |
} |
| 5380 |
} else { |
} else { |
| 5381 |
!!!cp ('t309'); |
!!!cp ('t309'); |
| 5382 |
!!!parse-error (type => 'after body:/'.$token->{tag_name}); |
!!!parse-error (type => 'after body:/'.$token->{tag_name}, token => $token); |
| 5383 |
|
|
| 5384 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 5385 |
## reprocess |
## reprocess |
| 5386 |
redo B; |
redo B; |
| 5387 |
} |
} |
| 5388 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5389 |
|
!!!cp ('t309.2'); |
| 5390 |
|
## Stop parsing |
| 5391 |
|
last B; |
| 5392 |
} else { |
} else { |
| 5393 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 5394 |
} |
} |
| 5407 |
if ($token->{data} =~ s/^[^\x09\x0A\x0B\x0C\x20]+//) { |
if ($token->{data} =~ s/^[^\x09\x0A\x0B\x0C\x20]+//) { |
| 5408 |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
| 5409 |
!!!cp ('t311'); |
!!!cp ('t311'); |
| 5410 |
!!!parse-error (type => 'in frameset:#character'); |
!!!parse-error (type => 'in frameset:#character', token => $token); |
| 5411 |
} elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) { |
} elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) { |
| 5412 |
!!!cp ('t312'); |
!!!cp ('t312'); |
| 5413 |
!!!parse-error (type => 'after frameset:#character'); |
!!!parse-error (type => 'after frameset:#character', token => $token); |
| 5414 |
} else { # "after html frameset" |
} else { # "after html frameset" |
| 5415 |
!!!cp ('t313'); |
!!!cp ('t313'); |
| 5416 |
!!!parse-error (type => 'after html:#character'); |
!!!parse-error (type => 'after html:#character', token => $token); |
| 5417 |
|
|
| 5418 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 5419 |
## Reprocess in the "after frameset" insertion mode. |
## Reprocess in the "after frameset" insertion mode. |
| 5420 |
!!!parse-error (type => 'after frameset:#character'); |
!!!parse-error (type => 'after frameset:#character', token => $token); |
| 5421 |
} |
} |
| 5422 |
|
|
| 5423 |
## Ignore the token. |
## Ignore the token. |
| 5435 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 5436 |
if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
| 5437 |
!!!cp ('t316'); |
!!!cp ('t316'); |
| 5438 |
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
!!!parse-error (type => 'after html:'.$token->{tag_name}, token => $token); |
| 5439 |
|
|
| 5440 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 5441 |
## Process in the "after frameset" insertion mode. |
## Process in the "after frameset" insertion mode. |
| 5446 |
if ($token->{tag_name} eq 'frameset' and |
if ($token->{tag_name} eq 'frameset' and |
| 5447 |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
| 5448 |
!!!cp ('t318'); |
!!!cp ('t318'); |
| 5449 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 5450 |
!!!next-token; |
!!!next-token; |
| 5451 |
redo B; |
redo B; |
| 5452 |
} elsif ($token->{tag_name} eq 'frame' and |
} elsif ($token->{tag_name} eq 'frame' and |
| 5453 |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
| 5454 |
!!!cp ('t319'); |
!!!cp ('t319'); |
| 5455 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 5456 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5457 |
!!!next-token; |
!!!next-token; |
| 5458 |
redo B; |
redo B; |
| 5464 |
} else { |
} else { |
| 5465 |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
| 5466 |
!!!cp ('t321'); |
!!!cp ('t321'); |
| 5467 |
!!!parse-error (type => 'in frameset:'.$token->{tag_name}); |
!!!parse-error (type => 'in frameset:'.$token->{tag_name}, token => $token); |
| 5468 |
} else { |
} else { |
| 5469 |
!!!cp ('t322'); |
!!!cp ('t322'); |
| 5470 |
!!!parse-error (type => 'after frameset:'.$token->{tag_name}); |
!!!parse-error (type => 'after frameset:'.$token->{tag_name}, token => $token); |
| 5471 |
} |
} |
| 5472 |
## Ignore the token |
## Ignore the token |
| 5473 |
!!!next-token; |
!!!next-token; |
| 5476 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 5477 |
if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
| 5478 |
!!!cp ('t323'); |
!!!cp ('t323'); |
| 5479 |
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
!!!parse-error (type => 'after html:/'.$token->{tag_name}, token => $token); |
| 5480 |
|
|
| 5481 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 5482 |
## Process in the "after frameset" insertion mode. |
## Process in the "after frameset" insertion mode. |
| 5489 |
if ($self->{open_elements}->[-1]->[1] eq 'html' and |
if ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 5490 |
@{$self->{open_elements}} == 1) { |
@{$self->{open_elements}} == 1) { |
| 5491 |
!!!cp ('t325'); |
!!!cp ('t325'); |
| 5492 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5493 |
## Ignore the token |
## Ignore the token |
| 5494 |
!!!next-token; |
!!!next-token; |
| 5495 |
} else { |
} else { |
| 5515 |
} else { |
} else { |
| 5516 |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
| 5517 |
!!!cp ('t330'); |
!!!cp ('t330'); |
| 5518 |
!!!parse-error (type => 'in frameset:/'.$token->{tag_name}); |
!!!parse-error (type => 'in frameset:/'.$token->{tag_name}, token => $token); |
| 5519 |
} else { |
} else { |
| 5520 |
!!!cp ('t331'); |
!!!cp ('t331'); |
| 5521 |
!!!parse-error (type => 'after frameset:/'.$token->{tag_name}); |
!!!parse-error (type => 'after frameset:/'.$token->{tag_name}, token => $token); |
| 5522 |
} |
} |
| 5523 |
## Ignore the token |
## Ignore the token |
| 5524 |
!!!next-token; |
!!!next-token; |
| 5525 |
redo B; |
redo B; |
| 5526 |
} |
} |
| 5527 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5528 |
|
unless ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 5529 |
|
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 5530 |
|
!!!cp ('t331.1'); |
| 5531 |
|
!!!parse-error (type => 'in body:#eof', token => $token); |
| 5532 |
|
} else { |
| 5533 |
|
!!!cp ('t331.2'); |
| 5534 |
|
} |
| 5535 |
|
|
| 5536 |
|
## Stop parsing |
| 5537 |
|
last B; |
| 5538 |
} else { |
} else { |
| 5539 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 5540 |
} |
} |
| 5549 |
if ($token->{tag_name} eq 'script') { |
if ($token->{tag_name} eq 'script') { |
| 5550 |
!!!cp ('t332'); |
!!!cp ('t332'); |
| 5551 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 5552 |
$script_start_tag->($insert); |
$script_start_tag->(); |
| 5553 |
redo B; |
redo B; |
| 5554 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 5555 |
!!!cp ('t333'); |
!!!cp ('t333'); |
| 5561 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5562 |
!!!cp ('t334'); |
!!!cp ('t334'); |
| 5563 |
## 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 |
| 5564 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 5565 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 5566 |
!!!next-token; |
!!!next-token; |
| 5567 |
redo B; |
redo B; |
| 5568 |
} elsif ($token->{tag_name} eq 'meta') { |
} elsif ($token->{tag_name} eq 'meta') { |
| 5569 |
## 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 |
| 5570 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 5571 |
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. |
| 5572 |
|
|
| 5573 |
unless ($self->{confident}) { |
unless ($self->{confident}) { |
| 5574 |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
| 5575 |
!!!cp ('t335'); |
!!!cp ('t335'); |
| 5576 |
$self->{change_encoding} |
$self->{change_encoding} |
| 5577 |
->($self, $token->{attributes}->{charset}->{value}); |
->($self, $token->{attributes}->{charset}->{value}, $token); |
| 5578 |
|
|
| 5579 |
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
$meta_el->[0]->get_attribute_node_ns (undef, 'charset') |
| 5580 |
->set_user_data (manakai_has_reference => |
->set_user_data (manakai_has_reference => |
| 5589 |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
| 5590 |
!!!cp ('t336'); |
!!!cp ('t336'); |
| 5591 |
$self->{change_encoding} |
$self->{change_encoding} |
| 5592 |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3); |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3, $token); |
| 5593 |
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
| 5594 |
->set_user_data (manakai_has_reference => |
->set_user_data (manakai_has_reference => |
| 5595 |
$token->{attributes}->{content} |
$token->{attributes}->{content} |
| 5621 |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
| 5622 |
redo B; |
redo B; |
| 5623 |
} elsif ($token->{tag_name} eq 'body') { |
} elsif ($token->{tag_name} eq 'body') { |
| 5624 |
!!!parse-error (type => 'in body:body'); |
!!!parse-error (type => 'in body:body', token => $token); |
| 5625 |
|
|
| 5626 |
if (@{$self->{open_elements}} == 1 or |
if (@{$self->{open_elements}} == 1 or |
| 5627 |
$self->{open_elements}->[1]->[1] ne 'body') { |
$self->{open_elements}->[1]->[1] ne 'body') { |
| 5646 |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
| 5647 |
menu => 1, ol => 1, p => 1, ul => 1, |
menu => 1, ol => 1, p => 1, ul => 1, |
| 5648 |
pre => 1, listing => 1, |
pre => 1, listing => 1, |
| 5649 |
|
form => 1, |
| 5650 |
|
table => 1, |
| 5651 |
|
hr => 1, |
| 5652 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5653 |
|
if ($token->{tag_name} eq 'form' and defined $self->{form_element}) { |
| 5654 |
|
!!!cp ('t350'); |
| 5655 |
|
!!!parse-error (type => 'in form:form', token => $token); |
| 5656 |
|
## Ignore the token |
| 5657 |
|
!!!next-token; |
| 5658 |
|
redo B; |
| 5659 |
|
} |
| 5660 |
|
|
| 5661 |
## has a p element in scope |
## has a p element in scope |
| 5662 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 5663 |
if ($_->[1] eq 'p') { |
if ($_->[1] eq 'p') { |
| 5664 |
!!!cp ('t344'); |
!!!cp ('t344'); |
| 5665 |
!!!back-token; |
!!!back-token; |
| 5666 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
| 5667 |
|
line => $token->{line}, column => $token->{column}}; |
| 5668 |
redo B; |
redo B; |
| 5669 |
} elsif ({ |
} elsif ({ |
| 5670 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5671 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5672 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5673 |
!!!cp ('t345'); |
!!!cp ('t345'); |
| 5675 |
} |
} |
| 5676 |
} # INSCOPE |
} # INSCOPE |
| 5677 |
|
|
| 5678 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 5679 |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
| 5680 |
!!!next-token; |
!!!next-token; |
| 5681 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 5689 |
} else { |
} else { |
| 5690 |
!!!cp ('t348'); |
!!!cp ('t348'); |
| 5691 |
} |
} |
| 5692 |
} else { |
} elsif ($token->{tag_name} eq 'form') { |
| 5693 |
!!!cp ('t347'); |
!!!cp ('t347.1'); |
| 5694 |
|
$self->{form_element} = $self->{open_elements}->[-1]->[0]; |
| 5695 |
|
|
| 5696 |
!!!next-token; |
!!!next-token; |
| 5697 |
} |
} elsif ($token->{tag_name} eq 'table') { |
| 5698 |
redo B; |
!!!cp ('t382'); |
| 5699 |
} elsif ($token->{tag_name} eq 'form') { |
push @{$open_tables}, [$self->{open_elements}->[-1]->[0]]; |
| 5700 |
if (defined $self->{form_element}) { |
|
| 5701 |
!!!cp ('t350'); |
$self->{insertion_mode} = IN_TABLE_IM; |
| 5702 |
!!!parse-error (type => 'in form:form'); |
|
| 5703 |
## Ignore the token |
!!!next-token; |
| 5704 |
|
} elsif ($token->{tag_name} eq 'hr') { |
| 5705 |
|
!!!cp ('t386'); |
| 5706 |
|
pop @{$self->{open_elements}}; |
| 5707 |
|
|
| 5708 |
!!!next-token; |
!!!next-token; |
|
redo B; |
|
| 5709 |
} else { |
} else { |
| 5710 |
## 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]; |
|
| 5711 |
!!!next-token; |
!!!next-token; |
|
redo B; |
|
| 5712 |
} |
} |
| 5713 |
} elsif ($token->{tag_name} eq 'li') { |
redo B; |
| 5714 |
|
} elsif ({li => 1, dt => 1, dd => 1}->{$token->{tag_name}}) { |
| 5715 |
## has a p element in scope |
## has a p element in scope |
| 5716 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 5717 |
if ($_->[1] eq 'p') { |
if ($_->[1] eq 'p') { |
| 5718 |
!!!cp ('t353'); |
!!!cp ('t353'); |
| 5719 |
!!!back-token; |
!!!back-token; |
| 5720 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
| 5721 |
|
line => $token->{line}, column => $token->{column}}; |
| 5722 |
redo B; |
redo B; |
| 5723 |
} elsif ({ |
} elsif ({ |
| 5724 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5725 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5726 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5727 |
!!!cp ('t354'); |
!!!cp ('t354'); |
| 5732 |
## Step 1 |
## Step 1 |
| 5733 |
my $i = -1; |
my $i = -1; |
| 5734 |
my $node = $self->{open_elements}->[$i]; |
my $node = $self->{open_elements}->[$i]; |
| 5735 |
|
my $li_or_dtdd = {li => {li => 1}, |
| 5736 |
|
dt => {dt => 1, dd => 1}, |
| 5737 |
|
dd => {dt => 1, dd => 1}}->{$token->{tag_name}}; |
| 5738 |
LI: { |
LI: { |
| 5739 |
## Step 2 |
## Step 2 |
| 5740 |
if ($node->[1] eq 'li') { |
if ($li_or_dtdd->{$node->[1]}) { |
| 5741 |
if ($i != -1) { |
if ($i != -1) { |
| 5742 |
!!!cp ('t355'); |
!!!cp ('t355'); |
| 5743 |
!!!parse-error (type => 'end tag missing:'. |
!!!parse-error (type => 'end tag missing:'. |
| 5744 |
$self->{open_elements}->[-1]->[1]); |
$self->{open_elements}->[-1]->[1], token => $token); |
| 5745 |
} else { |
} else { |
| 5746 |
!!!cp ('t356'); |
!!!cp ('t356'); |
| 5747 |
} |
} |
| 5768 |
redo LI; |
redo LI; |
| 5769 |
} # LI |
} # LI |
| 5770 |
|
|
| 5771 |
!!!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}); |
|
| 5772 |
!!!next-token; |
!!!next-token; |
| 5773 |
redo B; |
redo B; |
| 5774 |
} elsif ($token->{tag_name} eq 'plaintext') { |
} elsif ($token->{tag_name} eq 'plaintext') { |
| 5777 |
if ($_->[1] eq 'p') { |
if ($_->[1] eq 'p') { |
| 5778 |
!!!cp ('t367'); |
!!!cp ('t367'); |
| 5779 |
!!!back-token; |
!!!back-token; |
| 5780 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
| 5781 |
|
line => $token->{line}, column => $token->{column}}; |
| 5782 |
redo B; |
redo B; |
| 5783 |
} elsif ({ |
} elsif ({ |
| 5784 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5785 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5786 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5787 |
!!!cp ('t368'); |
!!!cp ('t368'); |
| 5789 |
} |
} |
| 5790 |
} # INSCOPE |
} # INSCOPE |
| 5791 |
|
|
| 5792 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 5793 |
|
|
| 5794 |
$self->{content_model} = PLAINTEXT_CONTENT_MODEL; |
$self->{content_model} = PLAINTEXT_CONTENT_MODEL; |
| 5795 |
|
|
| 5800 |
my $node = $active_formatting_elements->[$i]; |
my $node = $active_formatting_elements->[$i]; |
| 5801 |
if ($node->[1] eq 'a') { |
if ($node->[1] eq 'a') { |
| 5802 |
!!!cp ('t371'); |
!!!cp ('t371'); |
| 5803 |
!!!parse-error (type => 'in a:a'); |
!!!parse-error (type => 'in a:a', token => $token); |
| 5804 |
|
|
| 5805 |
!!!back-token; |
!!!back-token; |
| 5806 |
$token = {type => END_TAG_TOKEN, tag_name => 'a'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'a', |
| 5807 |
$formatting_end_tag->($token->{tag_name}); |
line => $token->{line}, column => $token->{column}}; |
| 5808 |
|
$formatting_end_tag->($token); |
| 5809 |
|
|
| 5810 |
AFE2: for (reverse 0..$#$active_formatting_elements) { |
AFE2: for (reverse 0..$#$active_formatting_elements) { |
| 5811 |
if ($active_formatting_elements->[$_]->[0] eq $node->[0]) { |
if ($active_formatting_elements->[$_]->[0] eq $node->[0]) { |
| 5830 |
|
|
| 5831 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 5832 |
|
|
| 5833 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 5834 |
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
| 5835 |
|
|
| 5836 |
!!!next-token; |
!!!next-token; |
| 5837 |
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; |
|
| 5838 |
} elsif ($token->{tag_name} eq 'nobr') { |
} elsif ($token->{tag_name} eq 'nobr') { |
| 5839 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 5840 |
|
|
| 5843 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5844 |
if ($node->[1] eq 'nobr') { |
if ($node->[1] eq 'nobr') { |
| 5845 |
!!!cp ('t376'); |
!!!cp ('t376'); |
| 5846 |
!!!parse-error (type => 'in nobr:nobr'); |
!!!parse-error (type => 'in nobr:nobr', token => $token); |
| 5847 |
!!!back-token; |
!!!back-token; |
| 5848 |
$token = {type => END_TAG_TOKEN, tag_name => 'nobr'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'nobr', |
| 5849 |
|
line => $token->{line}, column => $token->{column}}; |
| 5850 |
redo B; |
redo B; |
| 5851 |
} elsif ({ |
} elsif ({ |
| 5852 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5853 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5854 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 5855 |
!!!cp ('t377'); |
!!!cp ('t377'); |
| 5857 |
} |
} |
| 5858 |
} # INSCOPE |
} # INSCOPE |
| 5859 |
|
|
| 5860 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 5861 |
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
| 5862 |
|
|
| 5863 |
!!!next-token; |
!!!next-token; |
| 5868 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5869 |
if ($node->[1] eq 'button') { |
if ($node->[1] eq 'button') { |
| 5870 |
!!!cp ('t378'); |
!!!cp ('t378'); |
| 5871 |
!!!parse-error (type => 'in button:button'); |
!!!parse-error (type => 'in button:button', token => $token); |
| 5872 |
!!!back-token; |
!!!back-token; |
| 5873 |
$token = {type => END_TAG_TOKEN, tag_name => 'button'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'button', |
| 5874 |
|
line => $token->{line}, column => $token->{column}}; |
| 5875 |
redo B; |
redo B; |
| 5876 |
} elsif ({ |
} elsif ({ |
| 5877 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5878 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5879 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 5880 |
!!!cp ('t379'); |
!!!cp ('t379'); |
| 5884 |
|
|
| 5885 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 5886 |
|
|
| 5887 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 5888 |
|
|
| 5889 |
## TODO: associate with $self->{form_element} if defined |
## TODO: associate with $self->{form_element} if defined |
| 5890 |
|
|
| 5892 |
|
|
| 5893 |
!!!next-token; |
!!!next-token; |
| 5894 |
redo B; |
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}); |
|
|
push @$active_formatting_elements, ['#marker', '']; |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'xmp') { |
|
|
!!!cp ('t381'); |
|
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
$parse_rcdata->(CDATA_CONTENT_MODEL); |
|
|
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}); |
|
|
push @{$open_tables}, [$self->{open_elements}->[-1]->[0]]; |
|
|
|
|
|
$self->{insertion_mode} = IN_TABLE_IM; |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
| 5895 |
} elsif ({ |
} elsif ({ |
| 5896 |
area => 1, basefont => 1, bgsound => 1, br => 1, |
xmp => 1, |
| 5897 |
embed => 1, img => 1, param => 1, spacer => 1, wbr => 1, |
iframe => 1, |
| 5898 |
image => 1, |
noembed => 1, |
| 5899 |
|
noframes => 1, |
| 5900 |
|
noscript => 0, ## TODO: 1 if scripting is enabled |
| 5901 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5902 |
if ($token->{tag_name} eq 'image') { |
if ($token->{tag_name} eq 'xmp') { |
| 5903 |
!!!cp ('t384'); |
!!!cp ('t381'); |
| 5904 |
!!!parse-error (type => 'image'); |
$reconstruct_active_formatting_elements->($insert_to_current); |
|
$token->{tag_name} = 'img'; |
|
| 5905 |
} else { |
} else { |
| 5906 |
!!!cp ('t385'); |
!!!cp ('t399'); |
| 5907 |
} |
} |
| 5908 |
|
## NOTE: There is an "as if in body" code clone. |
| 5909 |
## 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; |
|
| 5910 |
redo B; |
redo B; |
| 5911 |
} elsif ($token->{tag_name} eq 'isindex') { |
} elsif ($token->{tag_name} eq 'isindex') { |
| 5912 |
!!!parse-error (type => 'isindex'); |
!!!parse-error (type => 'isindex', token => $token); |
| 5913 |
|
|
| 5914 |
if (defined $self->{form_element}) { |
if (defined $self->{form_element}) { |
| 5915 |
!!!cp ('t389'); |
!!!cp ('t389'); |
| 5926 |
delete $at->{prompt}; |
delete $at->{prompt}; |
| 5927 |
my @tokens = ( |
my @tokens = ( |
| 5928 |
{type => START_TAG_TOKEN, tag_name => 'form', |
{type => START_TAG_TOKEN, tag_name => 'form', |
| 5929 |
attributes => $form_attrs}, |
attributes => $form_attrs, |
| 5930 |
{type => START_TAG_TOKEN, tag_name => 'hr'}, |
line => $token->{line}, column => $token->{column}}, |
| 5931 |
{type => START_TAG_TOKEN, tag_name => 'p'}, |
{type => START_TAG_TOKEN, tag_name => 'hr', |
| 5932 |
{type => START_TAG_TOKEN, tag_name => 'label'}, |
line => $token->{line}, column => $token->{column}}, |
| 5933 |
|
{type => START_TAG_TOKEN, tag_name => 'p', |
| 5934 |
|
line => $token->{line}, column => $token->{column}}, |
| 5935 |
|
{type => START_TAG_TOKEN, tag_name => 'label', |
| 5936 |
|
line => $token->{line}, column => $token->{column}}, |
| 5937 |
); |
); |
| 5938 |
if ($prompt_attr) { |
if ($prompt_attr) { |
| 5939 |
!!!cp ('t390'); |
!!!cp ('t390'); |
| 5940 |
push @tokens, {type => CHARACTER_TOKEN, data => $prompt_attr->{value}}; |
push @tokens, {type => CHARACTER_TOKEN, data => $prompt_attr->{value}, |
| 5941 |
|
line => $token->{line}, column => $token->{column}}; |
| 5942 |
} else { |
} else { |
| 5943 |
!!!cp ('t391'); |
!!!cp ('t391'); |
| 5944 |
push @tokens, {type => CHARACTER_TOKEN, |
push @tokens, {type => CHARACTER_TOKEN, |
| 5945 |
data => 'This is a searchable index. Insert your search keywords here: '}; # SHOULD |
data => 'This is a searchable index. Insert your search keywords here: ', |
| 5946 |
|
line => $token->{line}, column => $token->{column}}; # SHOULD |
| 5947 |
## TODO: make this configurable |
## TODO: make this configurable |
| 5948 |
} |
} |
| 5949 |
push @tokens, |
push @tokens, |
| 5950 |
{type => START_TAG_TOKEN, tag_name => 'input', attributes => $at}, |
{type => START_TAG_TOKEN, tag_name => 'input', attributes => $at, |
| 5951 |
|
line => $token->{line}, column => $token->{column}}, |
| 5952 |
#{type => CHARACTER_TOKEN, data => ''}, # SHOULD |
#{type => CHARACTER_TOKEN, data => ''}, # SHOULD |
| 5953 |
{type => END_TAG_TOKEN, tag_name => 'label'}, |
{type => END_TAG_TOKEN, tag_name => 'label', |
| 5954 |
{type => END_TAG_TOKEN, tag_name => 'p'}, |
line => $token->{line}, column => $token->{column}}, |
| 5955 |
{type => START_TAG_TOKEN, tag_name => 'hr'}, |
{type => END_TAG_TOKEN, tag_name => 'p', |
| 5956 |
{type => END_TAG_TOKEN, tag_name => 'form'}; |
line => $token->{line}, column => $token->{column}}, |
| 5957 |
|
{type => START_TAG_TOKEN, tag_name => 'hr', |
| 5958 |
|
line => $token->{line}, column => $token->{column}}, |
| 5959 |
|
{type => END_TAG_TOKEN, tag_name => 'form', |
| 5960 |
|
line => $token->{line}, column => $token->{column}}; |
| 5961 |
$token = shift @tokens; |
$token = shift @tokens; |
| 5962 |
!!!back-token (@tokens); |
!!!back-token (@tokens); |
| 5963 |
redo B; |
redo B; |
| 5965 |
} elsif ($token->{tag_name} eq 'textarea') { |
} elsif ($token->{tag_name} eq 'textarea') { |
| 5966 |
my $tag_name = $token->{tag_name}; |
my $tag_name = $token->{tag_name}; |
| 5967 |
my $el; |
my $el; |
| 5968 |
!!!create-element ($el, $token->{tag_name}, $token->{attributes}); |
!!!create-element ($el, $token->{tag_name}, $token->{attributes}, $token); |
| 5969 |
|
|
| 5970 |
## TODO: $self->{form_element} if defined |
## TODO: $self->{form_element} if defined |
| 5971 |
$self->{content_model} = RCDATA_CONTENT_MODEL; |
$self->{content_model} = RCDATA_CONTENT_MODEL; |
| 6004 |
## Ignore the token |
## Ignore the token |
| 6005 |
} else { |
} else { |
| 6006 |
!!!cp ('t398'); |
!!!cp ('t398'); |
| 6007 |
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
!!!parse-error (type => 'in RCDATA:#'.$token->{type}, token => $token); |
| 6008 |
} |
} |
| 6009 |
!!!next-token; |
!!!next-token; |
| 6010 |
redo B; |
redo B; |
| 6011 |
} 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); |
|
|
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}); |
|
|
|
|
|
## TODO: associate with $self->{form_element} if defined |
|
|
|
|
|
$self->{insertion_mode} = IN_SELECT_IM; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ({ |
|
| 6012 |
caption => 1, col => 1, colgroup => 1, frame => 1, |
caption => 1, col => 1, colgroup => 1, frame => 1, |
| 6013 |
frameset => 1, head => 1, option => 1, optgroup => 1, |
frameset => 1, head => 1, option => 1, optgroup => 1, |
| 6014 |
tbody => 1, td => 1, tfoot => 1, th => 1, |
tbody => 1, td => 1, tfoot => 1, th => 1, |
| 6015 |
thead => 1, tr => 1, |
thead => 1, tr => 1, |
| 6016 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6017 |
!!!cp ('t401'); |
!!!cp ('t401'); |
| 6018 |
!!!parse-error (type => 'in body:'.$token->{tag_name}); |
!!!parse-error (type => 'in body:'.$token->{tag_name}, token => $token); |
| 6019 |
## Ignore the token |
## Ignore the token |
| 6020 |
!!!next-token; |
!!!next-token; |
| 6021 |
redo B; |
redo B; |
| 6022 |
|
|
| 6023 |
## ISSUE: An issue on HTML5 new elements in the spec. |
## ISSUE: An issue on HTML5 new elements in the spec. |
| 6024 |
} else { |
} else { |
| 6025 |
!!!cp ('t402'); |
if ($token->{tag_name} eq 'image') { |
| 6026 |
|
!!!cp ('t384'); |
| 6027 |
|
!!!parse-error (type => 'image', token => $token); |
| 6028 |
|
$token->{tag_name} = 'img'; |
| 6029 |
|
} else { |
| 6030 |
|
!!!cp ('t385'); |
| 6031 |
|
} |
| 6032 |
|
|
| 6033 |
|
## NOTE: There is an "as if <br>" code clone. |
| 6034 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 6035 |
|
|
| 6036 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 6037 |
|
|
| 6038 |
|
if ({ |
| 6039 |
|
applet => 1, marquee => 1, object => 1, |
| 6040 |
|
}->{$token->{tag_name}}) { |
| 6041 |
|
!!!cp ('t380'); |
| 6042 |
|
push @$active_formatting_elements, ['#marker', '']; |
| 6043 |
|
} elsif ({ |
| 6044 |
|
b => 1, big => 1, em => 1, font => 1, i => 1, |
| 6045 |
|
s => 1, small => 1, strile => 1, |
| 6046 |
|
strong => 1, tt => 1, u => 1, |
| 6047 |
|
}->{$token->{tag_name}}) { |
| 6048 |
|
!!!cp ('t375'); |
| 6049 |
|
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
| 6050 |
|
} elsif ($token->{tag_name} eq 'input') { |
| 6051 |
|
!!!cp ('t388'); |
| 6052 |
|
## TODO: associate with $self->{form_element} if defined |
| 6053 |
|
pop @{$self->{open_elements}}; |
| 6054 |
|
} elsif ({ |
| 6055 |
|
area => 1, basefont => 1, bgsound => 1, br => 1, |
| 6056 |
|
embed => 1, img => 1, param => 1, spacer => 1, wbr => 1, |
| 6057 |
|
#image => 1, |
| 6058 |
|
}->{$token->{tag_name}}) { |
| 6059 |
|
!!!cp ('t388.1'); |
| 6060 |
|
pop @{$self->{open_elements}}; |
| 6061 |
|
} elsif ($token->{tag_name} eq 'select') { |
| 6062 |
|
## TODO: associate with $self->{form_element} if defined |
| 6063 |
|
|
| 6064 |
|
if ($self->{insertion_mode} & TABLE_IMS or |
| 6065 |
|
$self->{insertion_mode} & BODY_TABLE_IMS or |
| 6066 |
|
$self->{insertion_mode} == IN_COLUMN_GROUP_IM) { |
| 6067 |
|
!!!cp ('t400.1'); |
| 6068 |
|
$self->{insertion_mode} = IN_SELECT_IN_TABLE_IM; |
| 6069 |
|
} else { |
| 6070 |
|
!!!cp ('t400.2'); |
| 6071 |
|
$self->{insertion_mode} = IN_SELECT_IM; |
| 6072 |
|
} |
| 6073 |
|
} else { |
| 6074 |
|
!!!cp ('t402'); |
| 6075 |
|
} |
| 6076 |
|
|
| 6077 |
!!!next-token; |
!!!next-token; |
| 6078 |
redo B; |
redo B; |
| 6079 |
} |
} |
| 6080 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 6081 |
if ($token->{tag_name} eq 'body') { |
if ($token->{tag_name} eq 'body') { |
| 6082 |
if (@{$self->{open_elements}} > 1 and |
## has a |body| element in scope |
| 6083 |
$self->{open_elements}->[1]->[1] eq 'body') { |
my $i; |
| 6084 |
for (@{$self->{open_elements}}) { |
INSCOPE: { |
| 6085 |
unless ({ |
for (reverse @{$self->{open_elements}}) { |
| 6086 |
dd => 1, dt => 1, li => 1, p => 1, td => 1, |
if ($_->[1] eq 'body') { |
| 6087 |
th => 1, tr => 1, body => 1, html => 1, |
!!!cp ('t405'); |
| 6088 |
tbody => 1, tfoot => 1, thead => 1, |
$i = $_; |
| 6089 |
}->{$_->[1]}) { |
last INSCOPE; |
| 6090 |
!!!cp ('t403'); |
} elsif ({ |
| 6091 |
!!!parse-error (type => 'not closed:'.$_->[1]); |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6092 |
} else { |
button => 1, marquee => 1, object => 1, html => 1, |
| 6093 |
!!!cp ('t404'); |
}->{$_->[1]}) { |
| 6094 |
|
!!!cp ('t405.1'); |
| 6095 |
|
last; |
| 6096 |
} |
} |
| 6097 |
} |
} |
| 6098 |
|
|
| 6099 |
$self->{insertion_mode} = AFTER_BODY_IM; |
!!!parse-error (type => 'start tag not allowed', |
| 6100 |
!!!next-token; |
value => $token->{tag_name}, token => $token); |
| 6101 |
redo B; |
## NOTE: Ignore the token. |
|
} else { |
|
|
!!!cp ('t405'); |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
| 6102 |
!!!next-token; |
!!!next-token; |
| 6103 |
redo B; |
redo B; |
| 6104 |
|
} # INSCOPE |
| 6105 |
|
|
| 6106 |
|
for (@{$self->{open_elements}}) { |
| 6107 |
|
unless ({ |
| 6108 |
|
dd => 1, dt => 1, li => 1, p => 1, td => 1, |
| 6109 |
|
th => 1, tr => 1, body => 1, html => 1, |
| 6110 |
|
tbody => 1, tfoot => 1, thead => 1, |
| 6111 |
|
}->{$_->[1]}) { |
| 6112 |
|
!!!cp ('t403'); |
| 6113 |
|
!!!parse-error (type => 'not closed:'.$_->[1], token => $token); |
| 6114 |
|
last; |
| 6115 |
|
} else { |
| 6116 |
|
!!!cp ('t404'); |
| 6117 |
|
} |
| 6118 |
} |
} |
| 6119 |
|
|
| 6120 |
|
$self->{insertion_mode} = AFTER_BODY_IM; |
| 6121 |
|
!!!next-token; |
| 6122 |
|
redo B; |
| 6123 |
} elsif ($token->{tag_name} eq 'html') { |
} elsif ($token->{tag_name} eq 'html') { |
| 6124 |
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') { |
| 6125 |
## ISSUE: There is an issue in the spec. |
## ISSUE: There is an issue in the spec. |
| 6126 |
if ($self->{open_elements}->[-1]->[1] ne 'body') { |
if ($self->{open_elements}->[-1]->[1] ne 'body') { |
| 6127 |
!!!cp ('t406'); |
!!!cp ('t406'); |
| 6128 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[1]->[1], token => $token); |
| 6129 |
} else { |
} else { |
| 6130 |
!!!cp ('t407'); |
!!!cp ('t407'); |
| 6131 |
} |
} |
| 6134 |
redo B; |
redo B; |
| 6135 |
} else { |
} else { |
| 6136 |
!!!cp ('t408'); |
!!!cp ('t408'); |
| 6137 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6138 |
## Ignore the token |
## Ignore the token |
| 6139 |
!!!next-token; |
!!!next-token; |
| 6140 |
redo B; |
redo B; |
| 6144 |
div => 1, dl => 1, fieldset => 1, listing => 1, |
div => 1, dl => 1, fieldset => 1, listing => 1, |
| 6145 |
menu => 1, ol => 1, pre => 1, ul => 1, |
menu => 1, ol => 1, pre => 1, ul => 1, |
| 6146 |
dd => 1, dt => 1, li => 1, |
dd => 1, dt => 1, li => 1, |
| 6147 |
button => 1, marquee => 1, object => 1, |
applet => 1, button => 1, marquee => 1, object => 1, |
| 6148 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6149 |
## has an element in scope |
## has an element in scope |
| 6150 |
my $i; |
my $i; |
| 6155 |
$i = $_; |
$i = $_; |
| 6156 |
last INSCOPE; |
last INSCOPE; |
| 6157 |
} elsif ({ |
} elsif ({ |
| 6158 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6159 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 6160 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 6161 |
!!!cp ('t411'); |
!!!cp ('t411'); |
| 6165 |
|
|
| 6166 |
unless (defined $i) { # has an element in scope |
unless (defined $i) { # has an element in scope |
| 6167 |
!!!cp ('t413'); |
!!!cp ('t413'); |
| 6168 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6169 |
} else { |
} else { |
| 6170 |
## Step 1. generate implied end tags |
## Step 1. generate implied end tags |
| 6171 |
while ({ |
while ({ |
| 6181 |
## Step 2. |
## Step 2. |
| 6182 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6183 |
!!!cp ('t412'); |
!!!cp ('t412'); |
| 6184 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 6185 |
} else { |
} else { |
| 6186 |
!!!cp ('t414'); |
!!!cp ('t414'); |
| 6187 |
} |
} |
| 6192 |
## Step 4. |
## Step 4. |
| 6193 |
$clear_up_to_marker->() |
$clear_up_to_marker->() |
| 6194 |
if { |
if { |
| 6195 |
button => 1, marquee => 1, object => 1, |
applet => 1, button => 1, marquee => 1, object => 1, |
| 6196 |
}->{$token->{tag_name}}; |
}->{$token->{tag_name}}; |
| 6197 |
} |
} |
| 6198 |
!!!next-token; |
!!!next-token; |
| 6209 |
$i = $_; |
$i = $_; |
| 6210 |
last INSCOPE; |
last INSCOPE; |
| 6211 |
} elsif ({ |
} elsif ({ |
| 6212 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6213 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 6214 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 6215 |
!!!cp ('t419'); |
!!!cp ('t419'); |
| 6219 |
|
|
| 6220 |
unless (defined $i) { # has an element in scope |
unless (defined $i) { # has an element in scope |
| 6221 |
!!!cp ('t421'); |
!!!cp ('t421'); |
| 6222 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6223 |
} else { |
} else { |
| 6224 |
## Step 1. generate implied end tags |
## Step 1. generate implied end tags |
| 6225 |
while ({ |
while ({ |
| 6232 |
## Step 2. |
## Step 2. |
| 6233 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6234 |
!!!cp ('t417.1'); |
!!!cp ('t417.1'); |
| 6235 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 6236 |
} else { |
} else { |
| 6237 |
!!!cp ('t420'); |
!!!cp ('t420'); |
| 6238 |
} |
} |
| 6257 |
$i = $_; |
$i = $_; |
| 6258 |
last INSCOPE; |
last INSCOPE; |
| 6259 |
} elsif ({ |
} elsif ({ |
| 6260 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6261 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 6262 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 6263 |
!!!cp ('t424'); |
!!!cp ('t424'); |
| 6267 |
|
|
| 6268 |
unless (defined $i) { # has an element in scope |
unless (defined $i) { # has an element in scope |
| 6269 |
!!!cp ('t425.1'); |
!!!cp ('t425.1'); |
| 6270 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6271 |
} else { |
} else { |
| 6272 |
## Step 1. generate implied end tags |
## Step 1. generate implied end tags |
| 6273 |
while ({ |
while ({ |
| 6280 |
## Step 2. |
## Step 2. |
| 6281 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6282 |
!!!cp ('t425'); |
!!!cp ('t425'); |
| 6283 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6284 |
} else { |
} else { |
| 6285 |
!!!cp ('t426'); |
!!!cp ('t426'); |
| 6286 |
} |
} |
| 6301 |
$i = $_; |
$i = $_; |
| 6302 |
last INSCOPE; |
last INSCOPE; |
| 6303 |
} elsif ({ |
} elsif ({ |
| 6304 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6305 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 6306 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 6307 |
!!!cp ('t411.1'); |
!!!cp ('t411.1'); |
| 6312 |
if (defined $i) { |
if (defined $i) { |
| 6313 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6314 |
!!!cp ('t412.1'); |
!!!cp ('t412.1'); |
| 6315 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 6316 |
} else { |
} else { |
| 6317 |
!!!cp ('t414.1'); |
!!!cp ('t414.1'); |
| 6318 |
} |
} |
| 6320 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 6321 |
} else { |
} else { |
| 6322 |
!!!cp ('t413.1'); |
!!!cp ('t413.1'); |
| 6323 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6324 |
|
|
| 6325 |
!!!cp ('t415.1'); |
!!!cp ('t415.1'); |
| 6326 |
## As if <p>, then reprocess the current token |
## As if <p>, then reprocess the current token |
| 6327 |
my $el; |
my $el; |
| 6328 |
!!!create-element ($el, 'p'); |
!!!create-element ($el, 'p',, $token); |
| 6329 |
$insert->($el); |
$insert->($el); |
| 6330 |
## NOTE: Not inserted into |$self->{open_elements}|. |
## NOTE: Not inserted into |$self->{open_elements}|. |
| 6331 |
} |
} |
| 6339 |
strong => 1, tt => 1, u => 1, |
strong => 1, tt => 1, u => 1, |
| 6340 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6341 |
!!!cp ('t427'); |
!!!cp ('t427'); |
| 6342 |
$formatting_end_tag->($token->{tag_name}); |
$formatting_end_tag->($token); |
| 6343 |
redo B; |
redo B; |
| 6344 |
} elsif ($token->{tag_name} eq 'br') { |
} elsif ($token->{tag_name} eq 'br') { |
| 6345 |
!!!cp ('t428'); |
!!!cp ('t428'); |
| 6346 |
!!!parse-error (type => 'unmatched end tag:br'); |
!!!parse-error (type => 'unmatched end tag:br', token => $token); |
| 6347 |
|
|
| 6348 |
## As if <br> |
## As if <br> |
| 6349 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 6350 |
|
|
| 6351 |
my $el; |
my $el; |
| 6352 |
!!!create-element ($el, 'br'); |
!!!create-element ($el, 'br',, $token); |
| 6353 |
$insert->($el); |
$insert->($el); |
| 6354 |
|
|
| 6355 |
## Ignore the token. |
## Ignore the token. |
| 6368 |
noscript => 0, ## TODO: if scripting is enabled |
noscript => 0, ## TODO: if scripting is enabled |
| 6369 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6370 |
!!!cp ('t429'); |
!!!cp ('t429'); |
| 6371 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6372 |
## Ignore the token |
## Ignore the token |
| 6373 |
!!!next-token; |
!!!next-token; |
| 6374 |
redo B; |
redo B; |
| 6397 |
if ($token->{tag_name} ne $self->{open_elements}->[-1]->[1]) { |
if ($token->{tag_name} ne $self->{open_elements}->[-1]->[1]) { |
| 6398 |
!!!cp ('t431'); |
!!!cp ('t431'); |
| 6399 |
## NOTE: <x><y></x> |
## NOTE: <x><y></x> |
| 6400 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
| 6401 |
} else { |
} else { |
| 6402 |
!!!cp ('t432'); |
!!!cp ('t432'); |
| 6403 |
} |
} |
| 6414 |
($special_category->{$node->[1]} or |
($special_category->{$node->[1]} or |
| 6415 |
$scoping_category->{$node->[1]})) { |
$scoping_category->{$node->[1]})) { |
| 6416 |
!!!cp ('t433'); |
!!!cp ('t433'); |
| 6417 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6418 |
## Ignore the token |
## Ignore the token |
| 6419 |
!!!next-token; |
!!!next-token; |
| 6420 |
last S2; |
last S2; |