| 304 |
sub BODY_AFTER_IMS () { 0b100000000 } |
sub BODY_AFTER_IMS () { 0b100000000 } |
| 305 |
sub FRAME_IMS () { 0b1000000000 } |
sub FRAME_IMS () { 0b1000000000 } |
| 306 |
|
|
| 307 |
|
## NOTE: "initial" and "before html" insertion modes have no constants. |
| 308 |
|
|
| 309 |
|
## NOTE: "after after body" insertion mode. |
| 310 |
sub AFTER_HTML_BODY_IM () { AFTER_HTML_IMS | BODY_AFTER_IMS } |
sub AFTER_HTML_BODY_IM () { AFTER_HTML_IMS | BODY_AFTER_IMS } |
| 311 |
|
|
| 312 |
|
## NOTE: "after after frameset" insertion mode. |
| 313 |
sub AFTER_HTML_FRAMESET_IM () { AFTER_HTML_IMS | FRAME_IMS } |
sub AFTER_HTML_FRAMESET_IM () { AFTER_HTML_IMS | FRAME_IMS } |
| 314 |
|
|
| 315 |
sub IN_HEAD_IM () { HEAD_IMS | 0b00 } |
sub IN_HEAD_IM () { HEAD_IMS | 0b00 } |
| 316 |
sub IN_HEAD_NOSCRIPT_IM () { HEAD_IMS | 0b01 } |
sub IN_HEAD_NOSCRIPT_IM () { HEAD_IMS | 0b01 } |
| 317 |
sub AFTER_HEAD_IM () { HEAD_IMS | 0b10 } |
sub AFTER_HEAD_IM () { HEAD_IMS | 0b10 } |
| 2426 |
|
|
| 2427 |
!!!next-token; |
!!!next-token; |
| 2428 |
|
|
|
$self->{insertion_mode} = BEFORE_HEAD_IM; |
|
| 2429 |
undef $self->{form_element}; |
undef $self->{form_element}; |
| 2430 |
undef $self->{head_element}; |
undef $self->{head_element}; |
| 2431 |
$self->{open_elements} = []; |
$self->{open_elements} = []; |
| 2432 |
undef $self->{inner_html_node}; |
undef $self->{inner_html_node}; |
| 2433 |
|
|
| 2434 |
|
## NOTE: The "initial" insertion mode. |
| 2435 |
$self->_tree_construction_initial; # MUST |
$self->_tree_construction_initial; # MUST |
| 2436 |
|
|
| 2437 |
|
## NOTE: The "before html" insertion mode. |
| 2438 |
$self->_tree_construction_root_element; |
$self->_tree_construction_root_element; |
| 2439 |
|
$self->{insertion_mode} = BEFORE_HEAD_IM; |
| 2440 |
|
|
| 2441 |
|
## NOTE: The "before head" insertion mode and so on. |
| 2442 |
$self->_tree_construction_main; |
$self->_tree_construction_main; |
| 2443 |
} # _construct_tree |
} # _construct_tree |
| 2444 |
|
|
| 2445 |
sub _tree_construction_initial ($) { |
sub _tree_construction_initial ($) { |
| 2446 |
my $self = shift; |
my $self = shift; |
| 2447 |
|
|
| 2448 |
|
## NOTE: "initial" insertion mode |
| 2449 |
|
|
| 2450 |
INITIAL: { |
INITIAL: { |
| 2451 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
| 2452 |
## NOTE: Conformance checkers MAY, instead of reporting "not HTML5" |
## NOTE: Conformance checkers MAY, instead of reporting "not HTML5" |
| 2593 |
!!!cp ('t13'); |
!!!cp ('t13'); |
| 2594 |
} |
} |
| 2595 |
|
|
| 2596 |
## Go to the root element phase. |
## Go to the "before html" insertion mode. |
| 2597 |
!!!next-token; |
!!!next-token; |
| 2598 |
return; |
return; |
| 2599 |
} elsif ({ |
} elsif ({ |
| 2604 |
!!!cp ('t14'); |
!!!cp ('t14'); |
| 2605 |
!!!parse-error (type => 'no DOCTYPE'); |
!!!parse-error (type => 'no DOCTYPE'); |
| 2606 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
| 2607 |
## Go to the root element phase |
## Go to the "before html" insertion mode. |
| 2608 |
## reprocess |
## reprocess |
| 2609 |
return; |
return; |
| 2610 |
} elsif ($token->{type} == CHARACTER_TOKEN) { |
} elsif ($token->{type} == CHARACTER_TOKEN) { |
| 2613 |
|
|
| 2614 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 2615 |
!!!cp ('t15'); |
!!!cp ('t15'); |
| 2616 |
## Stay in the phase |
## Stay in the insertion mode. |
| 2617 |
!!!next-token; |
!!!next-token; |
| 2618 |
redo INITIAL; |
redo INITIAL; |
| 2619 |
} else { |
} else { |
| 2625 |
|
|
| 2626 |
!!!parse-error (type => 'no DOCTYPE'); |
!!!parse-error (type => 'no DOCTYPE'); |
| 2627 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
| 2628 |
## Go to the root element phase |
## Go to the "before html" insertion mode. |
| 2629 |
## reprocess |
## reprocess |
| 2630 |
return; |
return; |
| 2631 |
} elsif ($token->{type} == COMMENT_TOKEN) { |
} elsif ($token->{type} == COMMENT_TOKEN) { |
| 2633 |
my $comment = $self->{document}->create_comment ($token->{data}); |
my $comment = $self->{document}->create_comment ($token->{data}); |
| 2634 |
$self->{document}->append_child ($comment); |
$self->{document}->append_child ($comment); |
| 2635 |
|
|
| 2636 |
## Stay in the phase. |
## Stay in the insertion mode. |
| 2637 |
!!!next-token; |
!!!next-token; |
| 2638 |
redo INITIAL; |
redo INITIAL; |
| 2639 |
} else { |
} else { |
| 2646 |
|
|
| 2647 |
sub _tree_construction_root_element ($) { |
sub _tree_construction_root_element ($) { |
| 2648 |
my $self = shift; |
my $self = shift; |
| 2649 |
|
|
| 2650 |
|
## NOTE: "before html" insertion mode. |
| 2651 |
|
|
| 2652 |
B: { |
B: { |
| 2653 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
| 2654 |
!!!cp ('t19'); |
!!!cp ('t19'); |
| 2655 |
!!!parse-error (type => 'in html:#DOCTYPE'); |
!!!parse-error (type => 'in html:#DOCTYPE'); |
| 2656 |
## Ignore the token |
## Ignore the token |
| 2657 |
## Stay in the phase |
## Stay in the insertion mode. |
| 2658 |
!!!next-token; |
!!!next-token; |
| 2659 |
redo B; |
redo B; |
| 2660 |
} elsif ($token->{type} == COMMENT_TOKEN) { |
} elsif ($token->{type} == COMMENT_TOKEN) { |
| 2661 |
!!!cp ('t20'); |
!!!cp ('t20'); |
| 2662 |
my $comment = $self->{document}->create_comment ($token->{data}); |
my $comment = $self->{document}->create_comment ($token->{data}); |
| 2663 |
$self->{document}->append_child ($comment); |
$self->{document}->append_child ($comment); |
| 2664 |
## Stay in the phase |
## Stay in the insertion mode. |
| 2665 |
!!!next-token; |
!!!next-token; |
| 2666 |
redo B; |
redo B; |
| 2667 |
} elsif ($token->{type} == CHARACTER_TOKEN) { |
} elsif ($token->{type} == CHARACTER_TOKEN) { |
| 2670 |
|
|
| 2671 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 2672 |
!!!cp ('t21'); |
!!!cp ('t21'); |
| 2673 |
## Stay in the phase |
## Stay in the insertion mode. |
| 2674 |
!!!next-token; |
!!!next-token; |
| 2675 |
redo B; |
redo B; |
| 2676 |
} else { |
} else { |
| 2684 |
|
|
| 2685 |
# |
# |
| 2686 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 2687 |
if ($token->{tag_name} eq 'html' and |
if ($token->{tag_name} eq 'html') { |
| 2688 |
$token->{attributes}->{manifest}) { |
my $root_element; |
| 2689 |
!!!cp ('t24'); |
!!!create-element ($root_element, $token->{tag_name}, $token->{attributes}); |
| 2690 |
$self->{application_cache_selection} |
$self->{document}->append_child ($root_element); |
| 2691 |
->($token->{attributes}->{manifest}->{value}); |
push @{$self->{open_elements}}, [$root_element, 'html']; |
| 2692 |
## ISSUE: No relative reference resolution? |
|
| 2693 |
|
if ($token->{attributes}->{manifest}) { |
| 2694 |
|
!!!cp ('t24'); |
| 2695 |
|
$self->{application_cache_selection} |
| 2696 |
|
->($token->{attributes}->{manifest}->{value}); |
| 2697 |
|
## ISSUE: No relative reference resolution? |
| 2698 |
|
} else { |
| 2699 |
|
!!!cp ('t25'); |
| 2700 |
|
$self->{application_cache_selection}->(undef); |
| 2701 |
|
} |
| 2702 |
|
|
| 2703 |
|
!!!next-token; |
| 2704 |
|
return; ## Go to the "before head" insertion mode. |
| 2705 |
} else { |
} else { |
| 2706 |
!!!cp ('t25'); |
!!!cp ('t25.1'); |
| 2707 |
$self->{application_cache_selection}->(undef); |
# |
| 2708 |
} |
} |
|
|
|
|
## ISSUE: There is an issue in the spec |
|
|
# |
|
| 2709 |
} elsif ({ |
} elsif ({ |
| 2710 |
END_TAG_TOKEN, 1, |
END_TAG_TOKEN, 1, |
| 2711 |
END_OF_FILE_TOKEN, 1, |
END_OF_FILE_TOKEN, 1, |
| 2712 |
}->{$token->{type}}) { |
}->{$token->{type}}) { |
| 2713 |
!!!cp ('t26'); |
!!!cp ('t26'); |
|
$self->{application_cache_selection}->(undef); |
|
|
|
|
|
## ISSUE: There is an issue in the spec |
|
| 2714 |
# |
# |
| 2715 |
} else { |
} else { |
| 2716 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 2717 |
} |
} |
| 2718 |
|
|
| 2719 |
my $root_element; !!!create-element ($root_element, 'html'); |
my $root_element; !!!create-element ($root_element, 'html'); |
| 2720 |
$self->{document}->append_child ($root_element); |
$self->{document}->append_child ($root_element); |
| 2721 |
push @{$self->{open_elements}}, [$root_element, 'html']; |
push @{$self->{open_elements}}, [$root_element, 'html']; |
| 2722 |
## reprocess |
|
| 2723 |
#redo B; |
$self->{application_cache_selection}->(undef); |
| 2724 |
return; ## Go to the main phase. |
|
| 2725 |
|
## NOTE: Reprocess the token. |
| 2726 |
|
return; ## Go to the "before head" insertion mode. |
| 2727 |
|
|
| 2728 |
|
## ISSUE: There is an issue in the spec |
| 2729 |
} # B |
} # B |
| 2730 |
|
|
| 2731 |
die "$0: _tree_construction_root_element: This should never be reached"; |
die "$0: _tree_construction_root_element: This should never be reached"; |
| 2743 |
|
|
| 2744 |
## Step 3 |
## Step 3 |
| 2745 |
S3: { |
S3: { |
|
## ISSUE: Oops! "If node is the first node in the stack of open |
|
|
## elements, then set last to true. If the context element of the |
|
|
## HTML fragment parsing algorithm is neither a td element nor a |
|
|
## th element, then set node to the context element. (fragment case)": |
|
|
## The second "if" is in the scope of the first "if"!? |
|
| 2746 |
if ($self->{open_elements}->[0]->[0] eq $node->[0]) { |
if ($self->{open_elements}->[0]->[0] eq $node->[0]) { |
| 2747 |
$last = 1; |
$last = 1; |
| 2748 |
if (defined $self->{inner_html_node}) { |
if (defined $self->{inner_html_node}) { |
| 2903 |
!!!cp ('t39'); |
!!!cp ('t39'); |
| 2904 |
}; # $clear_up_to_marker |
}; # $clear_up_to_marker |
| 2905 |
|
|
| 2906 |
my $parse_rcdata = sub ($$) { |
my $insert; |
| 2907 |
my ($content_model_flag, $insert) = @_; |
|
| 2908 |
|
my $parse_rcdata = sub ($) { |
| 2909 |
|
my ($content_model_flag) = @_; |
| 2910 |
|
|
| 2911 |
## Step 1 |
## Step 1 |
| 2912 |
my $start_tag_name = $token->{tag_name}; |
my $start_tag_name = $token->{tag_name}; |
| 2914 |
!!!create-element ($el, $start_tag_name, $token->{attributes}); |
!!!create-element ($el, $start_tag_name, $token->{attributes}); |
| 2915 |
|
|
| 2916 |
## Step 2 |
## Step 2 |
| 2917 |
$insert->($el); # /context node/->append_child ($el) |
$insert->($el); |
| 2918 |
|
|
| 2919 |
## Step 3 |
## Step 3 |
| 2920 |
$self->{content_model} = $content_model_flag; # CDATA or RCDATA |
$self->{content_model} = $content_model_flag; # CDATA or RCDATA |
| 2944 |
$token->{tag_name} eq $start_tag_name) { |
$token->{tag_name} eq $start_tag_name) { |
| 2945 |
!!!cp ('t42'); |
!!!cp ('t42'); |
| 2946 |
## Ignore the token |
## Ignore the token |
|
} elsif ($content_model_flag == CDATA_CONTENT_MODEL) { |
|
|
!!!cp ('t43'); |
|
|
!!!parse-error (type => 'in CDATA:#'.$token->{type}); |
|
|
} elsif ($content_model_flag == RCDATA_CONTENT_MODEL) { |
|
|
!!!cp ('t44'); |
|
|
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
|
| 2947 |
} else { |
} else { |
| 2948 |
die "$0: $content_model_flag in parse_rcdata"; |
## NOTE: An end-of-file token. |
| 2949 |
|
if ($content_model_flag == CDATA_CONTENT_MODEL) { |
| 2950 |
|
!!!cp ('t43'); |
| 2951 |
|
!!!parse-error (type => 'in CDATA:#'.$token->{type}); |
| 2952 |
|
} elsif ($content_model_flag == RCDATA_CONTENT_MODEL) { |
| 2953 |
|
!!!cp ('t44'); |
| 2954 |
|
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
| 2955 |
|
} else { |
| 2956 |
|
die "$0: $content_model_flag in parse_rcdata"; |
| 2957 |
|
} |
| 2958 |
} |
} |
| 2959 |
!!!next-token; |
!!!next-token; |
| 2960 |
}; # $parse_rcdata |
}; # $parse_rcdata |
| 2961 |
|
|
| 2962 |
my $script_start_tag = sub ($) { |
my $script_start_tag = sub () { |
|
my $insert = $_[0]; |
|
| 2963 |
my $script_el; |
my $script_el; |
| 2964 |
!!!create-element ($script_el, 'script', $token->{attributes}); |
!!!create-element ($script_el, 'script', $token->{attributes}); |
| 2965 |
## TODO: mark as "parser-inserted" |
## TODO: mark as "parser-inserted" |
| 3212 |
} # FET |
} # FET |
| 3213 |
}; # $formatting_end_tag |
}; # $formatting_end_tag |
| 3214 |
|
|
| 3215 |
my $insert_to_current = sub { |
## NOTE: $open_tables->[-1]->[0] is the "current table". |
| 3216 |
|
## NOTE: $open_tables->[-1]->[1] is the "tainted" flag. |
| 3217 |
|
my $open_tables = [[$self->{open_elements}->[0]->[0]]]; |
| 3218 |
|
|
| 3219 |
|
$insert = my $insert_to_current = sub { |
| 3220 |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
| 3221 |
}; # $insert_to_current |
}; # $insert_to_current |
| 3222 |
|
|
| 3223 |
my $insert_to_foster = sub { |
my $insert_to_foster = sub { |
| 3224 |
my $child = shift; |
my $child = shift; |
| 3225 |
if ({ |
if ({ |
| 3226 |
table => 1, tbody => 1, tfoot => 1, |
table => 1, tbody => 1, tfoot => 1, thead => 1, tr => 1, |
| 3227 |
thead => 1, tr => 1, |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3228 |
}->{$self->{open_elements}->[-1]->[1]}) { |
# MUST |
| 3229 |
# MUST |
my $foster_parent_element; |
| 3230 |
my $foster_parent_element; |
my $next_sibling; |
|
my $next_sibling; |
|
| 3231 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3232 |
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
| 3233 |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
| 3247 |
unless defined $foster_parent_element; |
unless defined $foster_parent_element; |
| 3248 |
$foster_parent_element->insert_before |
$foster_parent_element->insert_before |
| 3249 |
($child, $next_sibling); |
($child, $next_sibling); |
| 3250 |
} else { |
$open_tables->[-1]->[1] = 1; # tainted |
| 3251 |
!!!cp ('t72'); |
} else { |
| 3252 |
$self->{open_elements}->[-1]->[0]->append_child ($child); |
!!!cp ('t72'); |
| 3253 |
} |
$self->{open_elements}->[-1]->[0]->append_child ($child); |
| 3254 |
|
} |
| 3255 |
}; # $insert_to_foster |
}; # $insert_to_foster |
| 3256 |
|
|
|
my $insert; |
|
|
|
|
| 3257 |
B: { |
B: { |
| 3258 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
| 3259 |
!!!cp ('t73'); |
!!!cp ('t73'); |
| 3268 |
# |
# |
| 3269 |
} else { |
} else { |
| 3270 |
## Generate implied end tags |
## Generate implied end tags |
| 3271 |
if ({ |
while ({ |
| 3272 |
dd => 1, dt => 1, li => 1, p => 1, td => 1, th => 1, tr => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 3273 |
tbody => 1, tfoot=> 1, thead => 1, |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 3274 |
!!!cp ('t75'); |
!!!cp ('t75'); |
| 3275 |
!!!back-token; |
pop @{$self->{open_elements}}; |
|
$token = {type => END_TAG_TOKEN, tag_name => $self->{open_elements}->[-1]->[1]}; |
|
|
redo B; |
|
| 3276 |
} |
} |
| 3277 |
|
|
| 3278 |
if (@{$self->{open_elements}} > 2 or |
if (@{$self->{open_elements}} > 2 or |
| 3298 |
$token->{tag_name} eq 'html') { |
$token->{tag_name} eq 'html') { |
| 3299 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 3300 |
!!!cp ('t79'); |
!!!cp ('t79'); |
|
## Turn into the main phase |
|
| 3301 |
!!!parse-error (type => 'after html:html'); |
!!!parse-error (type => 'after html:html'); |
| 3302 |
$self->{insertion_mode} = AFTER_BODY_IM; |
$self->{insertion_mode} = AFTER_BODY_IM; |
| 3303 |
} elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
| 3304 |
!!!cp ('t80'); |
!!!cp ('t80'); |
|
## Turn into the main phase |
|
| 3305 |
!!!parse-error (type => 'after html:html'); |
!!!parse-error (type => 'after html:html'); |
| 3306 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 3307 |
} else { |
} else { |
| 3308 |
!!!cp ('t81'); |
!!!cp ('t81'); |
| 3309 |
} |
} |
| 3310 |
|
|
| 3311 |
## ISSUE: "aa<html>" is not a parse error. |
!!!cp ('t82'); |
| 3312 |
## ISSUE: "<html>" in fragment is not a parse error. |
!!!parse-error (type => 'not first start tag'); |
|
unless ($token->{first_start_tag}) { |
|
|
!!!cp ('t82'); |
|
|
!!!parse-error (type => 'not first start tag'); |
|
|
} else { |
|
|
!!!cp ('t83'); |
|
|
} |
|
| 3313 |
my $top_el = $self->{open_elements}->[0]->[0]; |
my $top_el = $self->{open_elements}->[0]->[0]; |
| 3314 |
for my $attr_name (keys %{$token->{attributes}}) { |
for my $attr_name (keys %{$token->{attributes}}) { |
| 3315 |
unless ($top_el->has_attribute_ns (undef, $attr_name)) { |
unless ($top_el->has_attribute_ns (undef, $attr_name)) { |
| 3338 |
} elsif ($self->{insertion_mode} & HEAD_IMS) { |
} elsif ($self->{insertion_mode} & HEAD_IMS) { |
| 3339 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 3340 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 3341 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
unless ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3342 |
|
!!!cp ('t88.2'); |
| 3343 |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 3344 |
|
} else { |
| 3345 |
|
!!!cp ('t88.1'); |
| 3346 |
|
## Ignore the token. |
| 3347 |
|
!!!next-token; |
| 3348 |
|
redo B; |
| 3349 |
|
} |
| 3350 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 3351 |
!!!cp ('t88'); |
!!!cp ('t88'); |
| 3352 |
!!!next-token; |
!!!next-token; |
| 3547 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3548 |
my $parent = defined $self->{head_element} ? $self->{head_element} |
my $parent = defined $self->{head_element} ? $self->{head_element} |
| 3549 |
: $self->{open_elements}->[-1]->[0]; |
: $self->{open_elements}->[-1]->[0]; |
| 3550 |
$parse_rcdata->(RCDATA_CONTENT_MODEL, |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
|
sub { $parent->append_child ($_[0]) }); |
|
| 3551 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} |
| 3552 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3553 |
redo B; |
redo B; |
| 3562 |
} else { |
} else { |
| 3563 |
!!!cp ('t115'); |
!!!cp ('t115'); |
| 3564 |
} |
} |
| 3565 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 3566 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} |
| 3567 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3568 |
redo B; |
redo B; |
| 3891 |
} |
} |
| 3892 |
|
|
| 3893 |
## generate implied end tags |
## generate implied end tags |
| 3894 |
if ({ |
while ({ |
| 3895 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 3896 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
## NOTE: Maybe the following elements never appear here. |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 3897 |
!!!cp ('t158'); |
!!!cp ('t158'); |
| 3898 |
!!!back-token; # <?> |
pop @{$self->{open_elements}}; |
|
$token = {type => END_TAG_TOKEN, tag_name => 'caption'}; |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
| 3899 |
} |
} |
| 3900 |
|
|
| 3901 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 3948 |
} |
} |
| 3949 |
|
|
| 3950 |
## generate implied end tags |
## generate implied end tags |
| 3951 |
if ({ |
while ({ |
| 3952 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 3953 |
td => ($token->{tag_name} eq 'th'), |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
th => ($token->{tag_name} eq 'td'), |
|
|
|
|
|
## NOTE: Maybe the following elements never appear here. |
|
|
tr => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 3954 |
!!!cp ('t166'); |
!!!cp ('t166'); |
| 3955 |
!!!back-token; |
pop @{$self->{open_elements}}; |
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
| 3956 |
} |
} |
| 3957 |
|
|
| 3958 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 3959 |
!!!cp ('t167'); |
!!!cp ('t167'); |
| 3960 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4006 |
} |
} |
| 4007 |
|
|
| 4008 |
## generate implied end tags |
## generate implied end tags |
| 4009 |
if ({ |
while ({ |
| 4010 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4011 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
## NOTE: The following elements never appear here, maybe. |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4012 |
!!!cp ('t174'); |
!!!cp ('t174'); |
| 4013 |
!!!back-token; |
pop @{$self->{open_elements}}; |
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
| 4014 |
} |
} |
| 4015 |
|
|
| 4016 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 4107 |
} |
} |
| 4108 |
|
|
| 4109 |
## generate implied end tags |
## generate implied end tags |
| 4110 |
if ({ |
while ({ |
| 4111 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4112 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
## NOTE: The following elements never appear, maybe. |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4113 |
!!!cp ('t187'); |
!!!cp ('t187'); |
| 4114 |
!!!back-token; # </table> |
pop @{$self->{open_elements}}; |
|
$token = {type => END_TAG_TOKEN, tag_name => 'caption'}; |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
| 4115 |
} |
} |
| 4116 |
|
|
| 4117 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 4164 |
# |
# |
| 4165 |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
| 4166 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 4167 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if (not $open_tables->[-1]->[1] and # tainted |
| 4168 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4169 |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 4170 |
|
|
| 4171 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 4172 |
!!!cp ('t194'); |
!!!cp ('t194'); |
| 4173 |
!!!next-token; |
!!!next-token; |
| 4174 |
redo B; |
redo B; |
| 4175 |
} else { |
} else { |
| 4176 |
!!!cp ('t195'); |
!!!cp ('t195'); |
| 4177 |
} |
} |
| 4178 |
} |
} |
| 4179 |
|
|
| 4180 |
!!!parse-error (type => 'in table:#character'); |
!!!parse-error (type => 'in table:#character'); |
| 4181 |
|
|
| 4222 |
($self->{document}->create_text_node ($token->{data}), |
($self->{document}->create_text_node ($token->{data}), |
| 4223 |
$next_sibling); |
$next_sibling); |
| 4224 |
} |
} |
| 4225 |
} else { |
$open_tables->[-1]->[1] = 1; # tainted |
| 4226 |
!!!cp ('t200'); |
} else { |
| 4227 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
!!!cp ('t200'); |
| 4228 |
} |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 4229 |
|
} |
| 4230 |
|
|
| 4231 |
!!!next-token; |
!!!next-token; |
| 4232 |
redo B; |
redo B; |
| 4233 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 4234 |
if ({ |
if ({ |
| 4235 |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
| 4240 |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
| 4241 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4242 |
!!!cp ('t201'); |
!!!cp ('t201'); |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4243 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4244 |
} |
} |
| 4245 |
|
|
| 4260 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4261 |
!!!cp ('t203'); |
!!!cp ('t203'); |
| 4262 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4263 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4264 |
} |
} |
| 4265 |
|
|
| 4283 |
tr => 1, html => 1, |
tr => 1, html => 1, |
| 4284 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4285 |
!!!cp ('t207'); |
!!!cp ('t207'); |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4286 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4287 |
} |
} |
| 4288 |
|
|
| 4333 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4334 |
!!!cp ('t211'); |
!!!cp ('t211'); |
| 4335 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4336 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4337 |
} |
} |
| 4338 |
|
|
| 4381 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4382 |
!!!cp ('t217'); |
!!!cp ('t217'); |
| 4383 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4384 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4385 |
} |
} |
| 4386 |
|
|
| 4404 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4405 |
!!!cp ('t219'); |
!!!cp ('t219'); |
| 4406 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4407 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4408 |
} |
} |
| 4409 |
|
|
| 4421 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4422 |
!!!cp ('t220'); |
!!!cp ('t220'); |
| 4423 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4424 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4425 |
} |
} |
| 4426 |
|
|
| 4470 |
} |
} |
| 4471 |
|
|
| 4472 |
## generate implied end tags |
## generate implied end tags |
| 4473 |
if ({ |
while ({ |
| 4474 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4475 |
td => 1, th => 1, tr => 1, |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4476 |
!!!cp ('t224'); |
!!!cp ('t224'); |
| 4477 |
!!!back-token; # <table> |
pop @{$self->{open_elements}}; |
|
$token = {type => END_TAG_TOKEN, tag_name => 'table'}; |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
| 4478 |
} |
} |
| 4479 |
|
|
| 4480 |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
| 4486 |
} |
} |
| 4487 |
|
|
| 4488 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 4489 |
|
pop @{$open_tables}; |
| 4490 |
|
|
| 4491 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 4492 |
|
|
| 4493 |
## reprocess |
## reprocess |
| 4494 |
redo B; |
redo B; |
| 4495 |
|
} elsif ($token->{tag_name} eq 'input') { |
| 4496 |
|
if (not $open_tables->[-1]->[1]) { # tainted |
| 4497 |
|
if ($token->{attributes}->{type}) { ## TODO: case |
| 4498 |
|
my $type = lc $token->{attributes}->{type}->{value}; |
| 4499 |
|
if ($type eq 'hidden') { |
| 4500 |
|
!!!cp ('t227.3'); |
| 4501 |
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
| 4502 |
|
|
| 4503 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4504 |
|
|
| 4505 |
|
## TODO: form element pointer |
| 4506 |
|
|
| 4507 |
|
pop @{$self->{open_elements}}; |
| 4508 |
|
|
| 4509 |
|
!!!next-token; |
| 4510 |
|
redo B; |
| 4511 |
|
} else { |
| 4512 |
|
!!!cp ('t227.2'); |
| 4513 |
|
# |
| 4514 |
|
} |
| 4515 |
|
} else { |
| 4516 |
|
!!!cp ('t227.1'); |
| 4517 |
|
# |
| 4518 |
|
} |
| 4519 |
|
} else { |
| 4520 |
|
!!!cp ('t227.4'); |
| 4521 |
|
# |
| 4522 |
|
} |
| 4523 |
} else { |
} else { |
| 4524 |
!!!cp ('t227'); |
!!!cp ('t227'); |
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
|
|
|
|
|
$insert = $insert_to_foster; |
|
| 4525 |
# |
# |
| 4526 |
} |
} |
| 4527 |
|
|
| 4528 |
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
| 4529 |
|
|
| 4530 |
|
$insert = $insert_to_foster; |
| 4531 |
|
# |
| 4532 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 4533 |
if ($token->{tag_name} eq 'tr' and |
if ($token->{tag_name} eq 'tr' and |
| 4534 |
$self->{insertion_mode} == IN_ROW_IM) { |
$self->{insertion_mode} == IN_ROW_IM) { |
| 4563 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4564 |
!!!cp ('t231'); |
!!!cp ('t231'); |
| 4565 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4566 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4567 |
} |
} |
| 4568 |
|
|
| 4603 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4604 |
!!!cp ('t236'); |
!!!cp ('t236'); |
| 4605 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4606 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4607 |
} |
} |
| 4608 |
|
|
| 4642 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4643 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4644 |
!!!cp ('t240'); |
!!!cp ('t240'); |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4645 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4646 |
} |
} |
| 4647 |
|
|
| 4657 |
## reprocess in the "in table" insertion mode... |
## reprocess in the "in table" insertion mode... |
| 4658 |
} |
} |
| 4659 |
|
|
| 4660 |
|
## NOTE: </table> in the "in table" insertion mode. |
| 4661 |
|
## When you edit the code fragment below, please ensure that |
| 4662 |
|
## the code for <table> in the "in table" insertion mode |
| 4663 |
|
## is synced with it. |
| 4664 |
|
|
| 4665 |
## have a table element in table scope |
## have a table element in table scope |
| 4666 |
my $i; |
my $i; |
| 4667 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4684 |
!!!next-token; |
!!!next-token; |
| 4685 |
redo B; |
redo B; |
| 4686 |
} |
} |
|
|
|
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!cp ('t244'); |
|
|
## ISSUE: Can this case be reached? |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
|
|
!!!cp ('t245'); |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} else { |
|
|
!!!cp ('t246'); |
|
|
} |
|
| 4687 |
|
|
| 4688 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 4689 |
|
pop @{$open_tables}; |
| 4690 |
|
|
| 4691 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 4692 |
|
|
| 4750 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4751 |
!!!cp ('t253'); |
!!!cp ('t253'); |
| 4752 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4753 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4754 |
} |
} |
| 4755 |
|
|
| 4787 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4788 |
!!!cp ('t257'); |
!!!cp ('t257'); |
| 4789 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4790 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4791 |
} |
} |
| 4792 |
|
|
| 5113 |
!!!cp ('t301'); |
!!!cp ('t301'); |
| 5114 |
!!!parse-error (type => 'after html:#character'); |
!!!parse-error (type => 'after html:#character'); |
| 5115 |
|
|
| 5116 |
## Reprocess in the "main" phase, "after body" insertion mode... |
## Reprocess in the "after body" insertion mode. |
| 5117 |
} else { |
} else { |
| 5118 |
!!!cp ('t302'); |
!!!cp ('t302'); |
| 5119 |
} |
} |
| 5129 |
!!!cp ('t303'); |
!!!cp ('t303'); |
| 5130 |
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
| 5131 |
|
|
| 5132 |
## Reprocess in the "main" phase, "after body" insertion mode... |
## Reprocess in the "after body" insertion mode. |
| 5133 |
} else { |
} else { |
| 5134 |
!!!cp ('t304'); |
!!!cp ('t304'); |
| 5135 |
} |
} |
| 5146 |
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
| 5147 |
|
|
| 5148 |
$self->{insertion_mode} = AFTER_BODY_IM; |
$self->{insertion_mode} = AFTER_BODY_IM; |
| 5149 |
## Reprocess in the "main" phase, "after body" insertion mode... |
## Reprocess in the "after body" insertion mode. |
| 5150 |
} else { |
} else { |
| 5151 |
!!!cp ('t306'); |
!!!cp ('t306'); |
| 5152 |
} |
} |
| 5200 |
!!!parse-error (type => 'after html:#character'); |
!!!parse-error (type => 'after html:#character'); |
| 5201 |
|
|
| 5202 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 5203 |
## Reprocess in the "main" phase, "after frameset"... |
## Reprocess in the "after frameset" insertion mode. |
| 5204 |
!!!parse-error (type => 'after frameset:#character'); |
!!!parse-error (type => 'after frameset:#character'); |
| 5205 |
} |
} |
| 5206 |
|
|
| 5222 |
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
| 5223 |
|
|
| 5224 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 5225 |
## Process in the "main" phase, "after frameset" insertion mode... |
## Process in the "after frameset" insertion mode. |
| 5226 |
} else { |
} else { |
| 5227 |
!!!cp ('t317'); |
!!!cp ('t317'); |
| 5228 |
} |
} |
| 5243 |
} elsif ($token->{tag_name} eq 'noframes') { |
} elsif ($token->{tag_name} eq 'noframes') { |
| 5244 |
!!!cp ('t320'); |
!!!cp ('t320'); |
| 5245 |
## NOTE: As if in body. |
## NOTE: As if in body. |
| 5246 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5247 |
redo B; |
redo B; |
| 5248 |
} else { |
} else { |
| 5249 |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
| 5263 |
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
| 5264 |
|
|
| 5265 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 5266 |
## Process in the "main" phase, "after frameset" insertion mode... |
## Process in the "after frameset" insertion mode. |
| 5267 |
} else { |
} else { |
| 5268 |
!!!cp ('t324'); |
!!!cp ('t324'); |
| 5269 |
} |
} |
| 5327 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 5328 |
!!!cp ('t333'); |
!!!cp ('t333'); |
| 5329 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 5330 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5331 |
redo B; |
redo B; |
| 5332 |
} elsif ({ |
} elsif ({ |
| 5333 |
base => 1, link => 1, |
base => 1, link => 1, |
| 5390 |
redo B; |
redo B; |
| 5391 |
} elsif ($token->{tag_name} eq 'title') { |
} elsif ($token->{tag_name} eq 'title') { |
| 5392 |
!!!cp ('t341'); |
!!!cp ('t341'); |
|
!!!parse-error (type => 'in body:title'); |
|
| 5393 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 5394 |
$parse_rcdata->(RCDATA_CONTENT_MODEL, sub { |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
|
if (defined $self->{head_element}) { |
|
|
!!!cp ('t339'); |
|
|
$self->{head_element}->append_child ($_[0]); |
|
|
} else { |
|
|
!!!cp ('t340'); |
|
|
$insert->($_[0]); |
|
|
} |
|
|
}); |
|
| 5395 |
redo B; |
redo B; |
| 5396 |
} elsif ($token->{tag_name} eq 'body') { |
} elsif ($token->{tag_name} eq 'body') { |
| 5397 |
!!!parse-error (type => 'in body:body'); |
!!!parse-error (type => 'in body:body'); |
| 5415 |
redo B; |
redo B; |
| 5416 |
} elsif ({ |
} elsif ({ |
| 5417 |
address => 1, blockquote => 1, center => 1, dir => 1, |
address => 1, blockquote => 1, center => 1, dir => 1, |
| 5418 |
div => 1, dl => 1, fieldset => 1, listing => 1, |
div => 1, dl => 1, fieldset => 1, |
| 5419 |
|
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
| 5420 |
menu => 1, ol => 1, p => 1, ul => 1, |
menu => 1, ol => 1, p => 1, ul => 1, |
| 5421 |
pre => 1, |
pre => 1, listing => 1, |
| 5422 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5423 |
## has a p element in scope |
## has a p element in scope |
| 5424 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 5437 |
} # INSCOPE |
} # INSCOPE |
| 5438 |
|
|
| 5439 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 5440 |
if ($token->{tag_name} eq 'pre') { |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
| 5441 |
!!!next-token; |
!!!next-token; |
| 5442 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 5443 |
$token->{data} =~ s/^\x0A//; |
$token->{data} =~ s/^\x0A//; |
| 5619 |
|
|
| 5620 |
!!!next-token; |
!!!next-token; |
| 5621 |
redo B; |
redo B; |
|
} elsif ({ |
|
|
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
## has a p element in scope |
|
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
my $node = $self->{open_elements}->[$_]; |
|
|
if ($node->[1] eq 'p') { |
|
|
!!!cp ('t369'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
|
!!!cp ('t370'); |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
|
|
|
## NOTE: See <http://html5.org/tools/web-apps-tracker?from=925&to=926> |
|
|
## has an element in scope |
|
|
#my $i; |
|
|
#INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
|
# my $node = $self->{open_elements}->[$_]; |
|
|
# if ({ |
|
|
# h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
|
|
# }->{$node->[1]}) { |
|
|
# $i = $_; |
|
|
# last INSCOPE; |
|
|
# } elsif ({ |
|
|
# table => 1, caption => 1, td => 1, th => 1, |
|
|
# button => 1, marquee => 1, object => 1, html => 1, |
|
|
# }->{$node->[1]}) { |
|
|
# last INSCOPE; |
|
|
# } |
|
|
#} # INSCOPE |
|
|
# |
|
|
#if (defined $i) { |
|
|
# !!! parse-error (type => 'in hn:hn'); |
|
|
# splice @{$self->{open_elements}}, $i; |
|
|
#} |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
| 5622 |
} elsif ($token->{tag_name} eq 'a') { |
} elsif ($token->{tag_name} eq 'a') { |
| 5623 |
AFE: for my $i (reverse 0..$#$active_formatting_elements) { |
AFE: for my $i (reverse 0..$#$active_formatting_elements) { |
| 5624 |
my $node = $active_formatting_elements->[$i]; |
my $node = $active_formatting_elements->[$i]; |
| 5719 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 5720 |
|
|
| 5721 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 5722 |
|
|
| 5723 |
|
## TODO: associate with $self->{form_element} if defined |
| 5724 |
|
|
| 5725 |
push @$active_formatting_elements, ['#marker', '']; |
push @$active_formatting_elements, ['#marker', '']; |
| 5726 |
|
|
| 5727 |
!!!next-token; |
!!!next-token; |
| 5739 |
} elsif ($token->{tag_name} eq 'xmp') { |
} elsif ($token->{tag_name} eq 'xmp') { |
| 5740 |
!!!cp ('t381'); |
!!!cp ('t381'); |
| 5741 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 5742 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5743 |
redo B; |
redo B; |
| 5744 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 5745 |
## has a p element in scope |
## has a p element in scope |
| 5759 |
} # INSCOPE |
} # INSCOPE |
| 5760 |
|
|
| 5761 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 5762 |
|
push @{$open_tables}, [$self->{open_elements}->[-1]->[0]]; |
| 5763 |
|
|
| 5764 |
$self->{insertion_mode} = IN_TABLE_IM; |
$self->{insertion_mode} = IN_TABLE_IM; |
| 5765 |
|
|
| 5766 |
!!!next-token; |
!!!next-token; |
| 5915 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5916 |
!!!cp ('t399'); |
!!!cp ('t399'); |
| 5917 |
## NOTE: There is an "as if in body" code clone. |
## NOTE: There is an "as if in body" code clone. |
| 5918 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5919 |
redo B; |
redo B; |
| 5920 |
} elsif ($token->{tag_name} eq 'select') { |
} elsif ($token->{tag_name} eq 'select') { |
| 5921 |
!!!cp ('t400'); |
!!!cp ('t400'); |
| 5922 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 5923 |
|
|
| 5924 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 5925 |
|
|
| 5926 |
|
## TODO: associate with $self->{form_element} if defined |
| 5927 |
|
|
| 5928 |
$self->{insertion_mode} = IN_SELECT_IM; |
$self->{insertion_mode} = IN_SELECT_IM; |
| 5929 |
!!!next-token; |
!!!next-token; |
| 6000 |
address => 1, blockquote => 1, center => 1, dir => 1, |
address => 1, blockquote => 1, center => 1, dir => 1, |
| 6001 |
div => 1, dl => 1, fieldset => 1, listing => 1, |
div => 1, dl => 1, fieldset => 1, listing => 1, |
| 6002 |
menu => 1, ol => 1, pre => 1, ul => 1, |
menu => 1, ol => 1, pre => 1, ul => 1, |
|
p => 1, |
|
| 6003 |
dd => 1, dt => 1, li => 1, |
dd => 1, dt => 1, li => 1, |
| 6004 |
button => 1, marquee => 1, object => 1, |
button => 1, marquee => 1, object => 1, |
| 6005 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6008 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6009 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 6010 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq $token->{tag_name}) { |
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => ($token->{tag_name} ne 'dd'), |
|
|
dt => ($token->{tag_name} ne 'dt'), |
|
|
li => ($token->{tag_name} ne 'li'), |
|
|
p => ($token->{tag_name} ne 'p'), |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!cp ('t409'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
| 6011 |
!!!cp ('t410'); |
!!!cp ('t410'); |
| 6012 |
$i = $_; |
$i = $_; |
| 6013 |
last INSCOPE unless $token->{tag_name} eq 'p'; |
last INSCOPE; |
| 6014 |
} elsif ({ |
} elsif ({ |
| 6015 |
table => 1, caption => 1, td => 1, th => 1, |
table => 1, caption => 1, td => 1, th => 1, |
| 6016 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 6019 |
last INSCOPE; |
last INSCOPE; |
| 6020 |
} |
} |
| 6021 |
} # INSCOPE |
} # INSCOPE |
| 6022 |
|
|
| 6023 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
unless (defined $i) { # has an element in scope |
| 6024 |
if (defined $i) { |
!!!cp ('t413'); |
| 6025 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 6026 |
|
} else { |
| 6027 |
|
## Step 1. generate implied end tags |
| 6028 |
|
while ({ |
| 6029 |
|
dd => ($token->{tag_name} ne 'dd'), |
| 6030 |
|
dt => ($token->{tag_name} ne 'dt'), |
| 6031 |
|
li => ($token->{tag_name} ne 'li'), |
| 6032 |
|
p => 1, |
| 6033 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 6034 |
|
!!!cp ('t409'); |
| 6035 |
|
pop @{$self->{open_elements}}; |
| 6036 |
|
} |
| 6037 |
|
|
| 6038 |
|
## Step 2. |
| 6039 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6040 |
!!!cp ('t412'); |
!!!cp ('t412'); |
| 6041 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 6042 |
} else { |
} else { |
| 6043 |
!!!cp ('t413'); |
!!!cp ('t414'); |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
| 6044 |
} |
} |
| 6045 |
} |
|
| 6046 |
|
## Step 3. |
|
if (defined $i) { |
|
|
!!!cp ('t414'); |
|
| 6047 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 6048 |
} elsif ($token->{tag_name} eq 'p') { |
|
| 6049 |
!!!cp ('t415'); |
## Step 4. |
| 6050 |
## As if <p>, then reprocess the current token |
$clear_up_to_marker->() |
| 6051 |
my $el; |
if { |
| 6052 |
!!!create-element ($el, 'p'); |
button => 1, marquee => 1, object => 1, |
| 6053 |
$insert->($el); |
}->{$token->{tag_name}}; |
|
} else { |
|
|
!!!cp ('t416'); |
|
| 6054 |
} |
} |
|
$clear_up_to_marker->() |
|
|
if { |
|
|
button => 1, marquee => 1, object => 1, |
|
|
}->{$token->{tag_name}}; |
|
| 6055 |
!!!next-token; |
!!!next-token; |
| 6056 |
redo B; |
redo B; |
| 6057 |
} elsif ($token->{tag_name} eq 'form') { |
} elsif ($token->{tag_name} eq 'form') { |
| 6058 |
|
undef $self->{form_element}; |
| 6059 |
|
|
| 6060 |
## has an element in scope |
## has an element in scope |
| 6061 |
|
my $i; |
| 6062 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6063 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 6064 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq $token->{tag_name}) { |
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
|
|
|
## NOTE: The following elements never appear here, maybe. |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!cp ('t417'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
| 6065 |
!!!cp ('t418'); |
!!!cp ('t418'); |
| 6066 |
|
$i = $_; |
| 6067 |
last INSCOPE; |
last INSCOPE; |
| 6068 |
} elsif ({ |
} elsif ({ |
| 6069 |
table => 1, caption => 1, td => 1, th => 1, |
table => 1, caption => 1, td => 1, th => 1, |
| 6073 |
last INSCOPE; |
last INSCOPE; |
| 6074 |
} |
} |
| 6075 |
} # INSCOPE |
} # INSCOPE |
| 6076 |
|
|
| 6077 |
if ($self->{open_elements}->[-1]->[1] eq $token->{tag_name}) { |
unless (defined $i) { # has an element in scope |
|
!!!cp ('t420'); |
|
|
pop @{$self->{open_elements}}; |
|
|
} else { |
|
| 6078 |
!!!cp ('t421'); |
!!!cp ('t421'); |
| 6079 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 6080 |
|
} else { |
| 6081 |
|
## Step 1. generate implied end tags |
| 6082 |
|
while ({ |
| 6083 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 6084 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 6085 |
|
!!!cp ('t417'); |
| 6086 |
|
pop @{$self->{open_elements}}; |
| 6087 |
|
} |
| 6088 |
|
|
| 6089 |
|
## Step 2. |
| 6090 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6091 |
|
!!!cp ('t417.1'); |
| 6092 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 6093 |
|
} else { |
| 6094 |
|
!!!cp ('t420'); |
| 6095 |
|
} |
| 6096 |
|
|
| 6097 |
|
## Step 3. |
| 6098 |
|
splice @{$self->{open_elements}}, $i; |
| 6099 |
} |
} |
| 6100 |
|
|
|
undef $self->{form_element}; |
|
| 6101 |
!!!next-token; |
!!!next-token; |
| 6102 |
redo B; |
redo B; |
| 6103 |
} elsif ({ |
} elsif ({ |
| 6110 |
if ({ |
if ({ |
| 6111 |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
| 6112 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
|
## generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!cp ('t422'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
|
} |
|
|
|
|
| 6113 |
!!!cp ('t423'); |
!!!cp ('t423'); |
| 6114 |
$i = $_; |
$i = $_; |
| 6115 |
last INSCOPE; |
last INSCOPE; |
| 6121 |
last INSCOPE; |
last INSCOPE; |
| 6122 |
} |
} |
| 6123 |
} # INSCOPE |
} # INSCOPE |
| 6124 |
|
|
| 6125 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
unless (defined $i) { # has an element in scope |
| 6126 |
!!!cp ('t425'); |
!!!cp ('t425.1'); |
| 6127 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 6128 |
} else { |
} else { |
| 6129 |
!!!cp ('t426'); |
## Step 1. generate implied end tags |
| 6130 |
|
while ({ |
| 6131 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 6132 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 6133 |
|
!!!cp ('t422'); |
| 6134 |
|
pop @{$self->{open_elements}}; |
| 6135 |
|
} |
| 6136 |
|
|
| 6137 |
|
## Step 2. |
| 6138 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6139 |
|
!!!cp ('t425'); |
| 6140 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 6141 |
|
} else { |
| 6142 |
|
!!!cp ('t426'); |
| 6143 |
|
} |
| 6144 |
|
|
| 6145 |
|
## Step 3. |
| 6146 |
|
splice @{$self->{open_elements}}, $i; |
| 6147 |
} |
} |
| 6148 |
|
|
| 6149 |
splice @{$self->{open_elements}}, $i if defined $i; |
!!!next-token; |
| 6150 |
|
redo B; |
| 6151 |
|
} elsif ($token->{tag_name} eq 'p') { |
| 6152 |
|
## has an element in scope |
| 6153 |
|
my $i; |
| 6154 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6155 |
|
my $node = $self->{open_elements}->[$_]; |
| 6156 |
|
if ($node->[1] eq $token->{tag_name}) { |
| 6157 |
|
!!!cp ('t410.1'); |
| 6158 |
|
$i = $_; |
| 6159 |
|
last INSCOPE; |
| 6160 |
|
} elsif ({ |
| 6161 |
|
table => 1, caption => 1, td => 1, th => 1, |
| 6162 |
|
button => 1, marquee => 1, object => 1, html => 1, |
| 6163 |
|
}->{$node->[1]}) { |
| 6164 |
|
!!!cp ('t411.1'); |
| 6165 |
|
last INSCOPE; |
| 6166 |
|
} |
| 6167 |
|
} # INSCOPE |
| 6168 |
|
|
| 6169 |
|
if (defined $i) { |
| 6170 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6171 |
|
!!!cp ('t412.1'); |
| 6172 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 6173 |
|
} else { |
| 6174 |
|
!!!cp ('t414.1'); |
| 6175 |
|
} |
| 6176 |
|
|
| 6177 |
|
splice @{$self->{open_elements}}, $i; |
| 6178 |
|
} else { |
| 6179 |
|
!!!cp ('t413.1'); |
| 6180 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 6181 |
|
|
| 6182 |
|
!!!cp ('t415.1'); |
| 6183 |
|
## As if <p>, then reprocess the current token |
| 6184 |
|
my $el; |
| 6185 |
|
!!!create-element ($el, 'p'); |
| 6186 |
|
$insert->($el); |
| 6187 |
|
## NOTE: Not inserted into |$self->{open_elements}|. |
| 6188 |
|
} |
| 6189 |
|
|
| 6190 |
!!!next-token; |
!!!next-token; |
| 6191 |
redo B; |
redo B; |
| 6192 |
} elsif ({ |
} elsif ({ |
| 6242 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq $token->{tag_name}) { |
| 6243 |
## Step 1 |
## Step 1 |
| 6244 |
## generate implied end tags |
## generate implied end tags |
| 6245 |
if ({ |
while ({ |
| 6246 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 6247 |
td => 1, th => 1, tr => 1, |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 6248 |
!!!cp ('t430'); |
!!!cp ('t430'); |
| 6249 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
| 6250 |
!!!back-token; |
pop @{$self->{open_elements}}; |
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
| 6251 |
} |
} |
| 6252 |
|
|
| 6253 |
## Step 2 |
## Step 2 |
| 6293 |
redo B; |
redo B; |
| 6294 |
} # B |
} # B |
| 6295 |
|
|
|
## NOTE: The "trailing end" phase in HTML5 is split into |
|
|
## two insertion modes: "after html body" and "after html frameset". |
|
|
## NOTE: States in the main stage is preserved while |
|
|
## the parser stays in the trailing end phase. # MUST |
|
|
|
|
| 6296 |
## Stop parsing # MUST |
## Stop parsing # MUST |
| 6297 |
|
|
| 6298 |
## TODO: script stuffs |
## TODO: script stuffs |
| 6334 |
my $p = $class->new; |
my $p = $class->new; |
| 6335 |
$p->{document} = $doc; |
$p->{document} = $doc; |
| 6336 |
|
|
| 6337 |
## Step 9 # MUST |
## Step 8 # MUST |
| 6338 |
my $i = 0; |
my $i = 0; |
| 6339 |
my $line = 1; |
my $line = 1; |
| 6340 |
my $column = 0; |
my $column = 0; |
| 6401 |
|
|
| 6402 |
$p->{inner_html_node} = [$node, $node_ln]; |
$p->{inner_html_node} = [$node, $node_ln]; |
| 6403 |
|
|
| 6404 |
## Step 4 |
## Step 3 |
| 6405 |
my $root = $doc->create_element_ns |
my $root = $doc->create_element_ns |
| 6406 |
('http://www.w3.org/1999/xhtml', [undef, 'html']); |
('http://www.w3.org/1999/xhtml', [undef, 'html']); |
| 6407 |
|
|
| 6408 |
## Step 5 # MUST |
## Step 4 # MUST |
| 6409 |
$doc->append_child ($root); |
$doc->append_child ($root); |
| 6410 |
|
|
| 6411 |
## Step 6 # MUST |
## Step 5 # MUST |
| 6412 |
push @{$p->{open_elements}}, [$root, 'html']; |
push @{$p->{open_elements}}, [$root, 'html']; |
| 6413 |
|
|
| 6414 |
undef $p->{head_element}; |
undef $p->{head_element}; |
| 6415 |
|
|
| 6416 |
## Step 7 # MUST |
## Step 6 # MUST |
| 6417 |
$p->_reset_insertion_mode; |
$p->_reset_insertion_mode; |
| 6418 |
|
|
| 6419 |
## Step 8 # MUST |
## Step 7 # MUST |
| 6420 |
my $anode = $node; |
my $anode = $node; |
| 6421 |
AN: while (defined $anode) { |
AN: while (defined $anode) { |
| 6422 |
if ($anode->node_type == 1) { |
if ($anode->node_type == 1) { |
| 6432 |
$anode = $anode->parent_node; |
$anode = $anode->parent_node; |
| 6433 |
} # AN |
} # AN |
| 6434 |
|
|
| 6435 |
## Step 3 # MUST |
## Step 9 # MUST |
|
## Step 10 # MUST |
|
| 6436 |
{ |
{ |
| 6437 |
my $self = $p; |
my $self = $p; |
| 6438 |
!!!next-token; |
!!!next-token; |
| 6439 |
} |
} |
| 6440 |
$p->_tree_construction_main; |
$p->_tree_construction_main; |
| 6441 |
|
|
| 6442 |
## Step 11 # MUST |
## Step 10 # MUST |
| 6443 |
my @cn = @{$node->child_nodes}; |
my @cn = @{$node->child_nodes}; |
| 6444 |
for (@cn) { |
for (@cn) { |
| 6445 |
$node->remove_child ($_); |
$node->remove_child ($_); |
| 6446 |
} |
} |
| 6447 |
## ISSUE: mutation events? read-only? |
## ISSUE: mutation events? read-only? |
| 6448 |
|
|
| 6449 |
## Step 12 # MUST |
## Step 11 # MUST |
| 6450 |
@cn = @{$root->child_nodes}; |
@cn = @{$root->child_nodes}; |
| 6451 |
for (@cn) { |
for (@cn) { |
| 6452 |
$this_doc->adopt_node ($_); |
$this_doc->adopt_node ($_); |