| 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 = { |
| 303 |
sub ROW_IMS () { 0b10000000 } |
sub ROW_IMS () { 0b10000000 } |
| 304 |
sub BODY_AFTER_IMS () { 0b100000000 } |
sub BODY_AFTER_IMS () { 0b100000000 } |
| 305 |
sub FRAME_IMS () { 0b1000000000 } |
sub FRAME_IMS () { 0b1000000000 } |
| 306 |
|
sub SELECT_IMS () { 0b10000000000 } |
| 307 |
|
|
| 308 |
|
## NOTE: "initial" and "before html" insertion modes have no constants. |
| 309 |
|
|
| 310 |
|
## NOTE: "after after body" insertion mode. |
| 311 |
sub AFTER_HTML_BODY_IM () { AFTER_HTML_IMS | BODY_AFTER_IMS } |
sub AFTER_HTML_BODY_IM () { AFTER_HTML_IMS | BODY_AFTER_IMS } |
| 312 |
|
|
| 313 |
|
## NOTE: "after after frameset" insertion mode. |
| 314 |
sub AFTER_HTML_FRAMESET_IM () { AFTER_HTML_IMS | FRAME_IMS } |
sub AFTER_HTML_FRAMESET_IM () { AFTER_HTML_IMS | FRAME_IMS } |
| 315 |
|
|
| 316 |
sub IN_HEAD_IM () { HEAD_IMS | 0b00 } |
sub IN_HEAD_IM () { HEAD_IMS | 0b00 } |
| 317 |
sub IN_HEAD_NOSCRIPT_IM () { HEAD_IMS | 0b01 } |
sub IN_HEAD_NOSCRIPT_IM () { HEAD_IMS | 0b01 } |
| 318 |
sub AFTER_HEAD_IM () { HEAD_IMS | 0b10 } |
sub AFTER_HEAD_IM () { HEAD_IMS | 0b10 } |
| 326 |
sub AFTER_BODY_IM () { BODY_AFTER_IMS } |
sub AFTER_BODY_IM () { BODY_AFTER_IMS } |
| 327 |
sub IN_FRAMESET_IM () { FRAME_IMS | 0b01 } |
sub IN_FRAMESET_IM () { FRAME_IMS | 0b01 } |
| 328 |
sub AFTER_FRAMESET_IM () { FRAME_IMS | 0b10 } |
sub AFTER_FRAMESET_IM () { FRAME_IMS | 0b10 } |
| 329 |
sub IN_SELECT_IM () { 0b01 } |
sub IN_SELECT_IM () { SELECT_IMS | 0b01 } |
| 330 |
|
sub IN_SELECT_IN_TABLE_IM () { SELECT_IMS | 0b10 } |
| 331 |
sub IN_COLUMN_GROUP_IM () { 0b10 } |
sub IN_COLUMN_GROUP_IM () { 0b10 } |
| 332 |
|
|
| 333 |
## Implementations MUST act as if state machine in the spec |
## Implementations MUST act as if state machine in the spec |
| 2428 |
|
|
| 2429 |
!!!next-token; |
!!!next-token; |
| 2430 |
|
|
|
$self->{insertion_mode} = BEFORE_HEAD_IM; |
|
| 2431 |
undef $self->{form_element}; |
undef $self->{form_element}; |
| 2432 |
undef $self->{head_element}; |
undef $self->{head_element}; |
| 2433 |
$self->{open_elements} = []; |
$self->{open_elements} = []; |
| 2434 |
undef $self->{inner_html_node}; |
undef $self->{inner_html_node}; |
| 2435 |
|
|
| 2436 |
|
## NOTE: The "initial" insertion mode. |
| 2437 |
$self->_tree_construction_initial; # MUST |
$self->_tree_construction_initial; # MUST |
| 2438 |
|
|
| 2439 |
|
## NOTE: The "before html" insertion mode. |
| 2440 |
$self->_tree_construction_root_element; |
$self->_tree_construction_root_element; |
| 2441 |
|
$self->{insertion_mode} = BEFORE_HEAD_IM; |
| 2442 |
|
|
| 2443 |
|
## NOTE: The "before head" insertion mode and so on. |
| 2444 |
$self->_tree_construction_main; |
$self->_tree_construction_main; |
| 2445 |
} # _construct_tree |
} # _construct_tree |
| 2446 |
|
|
| 2447 |
sub _tree_construction_initial ($) { |
sub _tree_construction_initial ($) { |
| 2448 |
my $self = shift; |
my $self = shift; |
| 2449 |
|
|
| 2450 |
|
## NOTE: "initial" insertion mode |
| 2451 |
|
|
| 2452 |
INITIAL: { |
INITIAL: { |
| 2453 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
| 2454 |
## NOTE: Conformance checkers MAY, instead of reporting "not HTML5" |
## NOTE: Conformance checkers MAY, instead of reporting "not HTML5" |
| 2595 |
!!!cp ('t13'); |
!!!cp ('t13'); |
| 2596 |
} |
} |
| 2597 |
|
|
| 2598 |
## Go to the root element phase. |
## Go to the "before html" insertion mode. |
| 2599 |
!!!next-token; |
!!!next-token; |
| 2600 |
return; |
return; |
| 2601 |
} elsif ({ |
} elsif ({ |
| 2606 |
!!!cp ('t14'); |
!!!cp ('t14'); |
| 2607 |
!!!parse-error (type => 'no DOCTYPE'); |
!!!parse-error (type => 'no DOCTYPE'); |
| 2608 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
| 2609 |
## Go to the root element phase |
## Go to the "before html" insertion mode. |
| 2610 |
## reprocess |
## reprocess |
| 2611 |
return; |
return; |
| 2612 |
} elsif ($token->{type} == CHARACTER_TOKEN) { |
} elsif ($token->{type} == CHARACTER_TOKEN) { |
| 2615 |
|
|
| 2616 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 2617 |
!!!cp ('t15'); |
!!!cp ('t15'); |
| 2618 |
## Stay in the phase |
## Stay in the insertion mode. |
| 2619 |
!!!next-token; |
!!!next-token; |
| 2620 |
redo INITIAL; |
redo INITIAL; |
| 2621 |
} else { |
} else { |
| 2627 |
|
|
| 2628 |
!!!parse-error (type => 'no DOCTYPE'); |
!!!parse-error (type => 'no DOCTYPE'); |
| 2629 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
| 2630 |
## Go to the root element phase |
## Go to the "before html" insertion mode. |
| 2631 |
## reprocess |
## reprocess |
| 2632 |
return; |
return; |
| 2633 |
} elsif ($token->{type} == COMMENT_TOKEN) { |
} elsif ($token->{type} == COMMENT_TOKEN) { |
| 2635 |
my $comment = $self->{document}->create_comment ($token->{data}); |
my $comment = $self->{document}->create_comment ($token->{data}); |
| 2636 |
$self->{document}->append_child ($comment); |
$self->{document}->append_child ($comment); |
| 2637 |
|
|
| 2638 |
## Stay in the phase. |
## Stay in the insertion mode. |
| 2639 |
!!!next-token; |
!!!next-token; |
| 2640 |
redo INITIAL; |
redo INITIAL; |
| 2641 |
} else { |
} else { |
| 2648 |
|
|
| 2649 |
sub _tree_construction_root_element ($) { |
sub _tree_construction_root_element ($) { |
| 2650 |
my $self = shift; |
my $self = shift; |
| 2651 |
|
|
| 2652 |
|
## NOTE: "before html" insertion mode. |
| 2653 |
|
|
| 2654 |
B: { |
B: { |
| 2655 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
| 2656 |
!!!cp ('t19'); |
!!!cp ('t19'); |
| 2657 |
!!!parse-error (type => 'in html:#DOCTYPE'); |
!!!parse-error (type => 'in html:#DOCTYPE'); |
| 2658 |
## Ignore the token |
## Ignore the token |
| 2659 |
## Stay in the phase |
## Stay in the insertion mode. |
| 2660 |
!!!next-token; |
!!!next-token; |
| 2661 |
redo B; |
redo B; |
| 2662 |
} elsif ($token->{type} == COMMENT_TOKEN) { |
} elsif ($token->{type} == COMMENT_TOKEN) { |
| 2663 |
!!!cp ('t20'); |
!!!cp ('t20'); |
| 2664 |
my $comment = $self->{document}->create_comment ($token->{data}); |
my $comment = $self->{document}->create_comment ($token->{data}); |
| 2665 |
$self->{document}->append_child ($comment); |
$self->{document}->append_child ($comment); |
| 2666 |
## Stay in the phase |
## Stay in the insertion mode. |
| 2667 |
!!!next-token; |
!!!next-token; |
| 2668 |
redo B; |
redo B; |
| 2669 |
} elsif ($token->{type} == CHARACTER_TOKEN) { |
} elsif ($token->{type} == CHARACTER_TOKEN) { |
| 2672 |
|
|
| 2673 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 2674 |
!!!cp ('t21'); |
!!!cp ('t21'); |
| 2675 |
## Stay in the phase |
## Stay in the insertion mode. |
| 2676 |
!!!next-token; |
!!!next-token; |
| 2677 |
redo B; |
redo B; |
| 2678 |
} else { |
} else { |
| 2686 |
|
|
| 2687 |
# |
# |
| 2688 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 2689 |
if ($token->{tag_name} eq 'html' and |
if ($token->{tag_name} eq 'html') { |
| 2690 |
$token->{attributes}->{manifest}) { |
my $root_element; |
| 2691 |
!!!cp ('t24'); |
!!!create-element ($root_element, $token->{tag_name}, $token->{attributes}); |
| 2692 |
$self->{application_cache_selection} |
$self->{document}->append_child ($root_element); |
| 2693 |
->($token->{attributes}->{manifest}->{value}); |
push @{$self->{open_elements}}, [$root_element, 'html']; |
| 2694 |
## ISSUE: No relative reference resolution? |
|
| 2695 |
|
if ($token->{attributes}->{manifest}) { |
| 2696 |
|
!!!cp ('t24'); |
| 2697 |
|
$self->{application_cache_selection} |
| 2698 |
|
->($token->{attributes}->{manifest}->{value}); |
| 2699 |
|
## ISSUE: No relative reference resolution? |
| 2700 |
|
} else { |
| 2701 |
|
!!!cp ('t25'); |
| 2702 |
|
$self->{application_cache_selection}->(undef); |
| 2703 |
|
} |
| 2704 |
|
|
| 2705 |
|
!!!next-token; |
| 2706 |
|
return; ## Go to the "before head" insertion mode. |
| 2707 |
} else { |
} else { |
| 2708 |
!!!cp ('t25'); |
!!!cp ('t25.1'); |
| 2709 |
$self->{application_cache_selection}->(undef); |
# |
| 2710 |
} |
} |
|
|
|
|
## ISSUE: There is an issue in the spec |
|
|
# |
|
| 2711 |
} elsif ({ |
} elsif ({ |
| 2712 |
END_TAG_TOKEN, 1, |
END_TAG_TOKEN, 1, |
| 2713 |
END_OF_FILE_TOKEN, 1, |
END_OF_FILE_TOKEN, 1, |
| 2714 |
}->{$token->{type}}) { |
}->{$token->{type}}) { |
| 2715 |
!!!cp ('t26'); |
!!!cp ('t26'); |
|
$self->{application_cache_selection}->(undef); |
|
|
|
|
|
## ISSUE: There is an issue in the spec |
|
| 2716 |
# |
# |
| 2717 |
} else { |
} else { |
| 2718 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 2719 |
} |
} |
| 2720 |
|
|
| 2721 |
my $root_element; !!!create-element ($root_element, 'html'); |
my $root_element; !!!create-element ($root_element, 'html'); |
| 2722 |
$self->{document}->append_child ($root_element); |
$self->{document}->append_child ($root_element); |
| 2723 |
push @{$self->{open_elements}}, [$root_element, 'html']; |
push @{$self->{open_elements}}, [$root_element, 'html']; |
| 2724 |
## reprocess |
|
| 2725 |
#redo B; |
$self->{application_cache_selection}->(undef); |
| 2726 |
return; ## Go to the main phase. |
|
| 2727 |
|
## NOTE: Reprocess the token. |
| 2728 |
|
return; ## Go to the "before head" insertion mode. |
| 2729 |
|
|
| 2730 |
|
## ISSUE: There is an issue in the spec |
| 2731 |
} # B |
} # B |
| 2732 |
|
|
| 2733 |
die "$0: _tree_construction_root_element: This should never be reached"; |
die "$0: _tree_construction_root_element: This should never be reached"; |
| 2745 |
|
|
| 2746 |
## Step 3 |
## Step 3 |
| 2747 |
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"!? |
|
| 2748 |
if ($self->{open_elements}->[0]->[0] eq $node->[0]) { |
if ($self->{open_elements}->[0]->[0] eq $node->[0]) { |
| 2749 |
$last = 1; |
$last = 1; |
| 2750 |
if (defined $self->{inner_html_node}) { |
if (defined $self->{inner_html_node}) { |
| 2762 |
## Step 4..13 |
## Step 4..13 |
| 2763 |
my $new_mode = { |
my $new_mode = { |
| 2764 |
select => IN_SELECT_IM, |
select => IN_SELECT_IM, |
| 2765 |
|
## NOTE: |option| and |optgroup| do not set |
| 2766 |
|
## insertion mode to "in select" by themselves. |
| 2767 |
td => IN_CELL_IM, |
td => IN_CELL_IM, |
| 2768 |
th => IN_CELL_IM, |
th => IN_CELL_IM, |
| 2769 |
tr => IN_ROW_IM, |
tr => IN_ROW_IM, |
| 2905 |
!!!cp ('t39'); |
!!!cp ('t39'); |
| 2906 |
}; # $clear_up_to_marker |
}; # $clear_up_to_marker |
| 2907 |
|
|
| 2908 |
my $parse_rcdata = sub ($$) { |
my $insert; |
| 2909 |
my ($content_model_flag, $insert) = @_; |
|
| 2910 |
|
my $parse_rcdata = sub ($) { |
| 2911 |
|
my ($content_model_flag) = @_; |
| 2912 |
|
|
| 2913 |
## Step 1 |
## Step 1 |
| 2914 |
my $start_tag_name = $token->{tag_name}; |
my $start_tag_name = $token->{tag_name}; |
| 2916 |
!!!create-element ($el, $start_tag_name, $token->{attributes}); |
!!!create-element ($el, $start_tag_name, $token->{attributes}); |
| 2917 |
|
|
| 2918 |
## Step 2 |
## Step 2 |
| 2919 |
$insert->($el); # /context node/->append_child ($el) |
$insert->($el); |
| 2920 |
|
|
| 2921 |
## Step 3 |
## Step 3 |
| 2922 |
$self->{content_model} = $content_model_flag; # CDATA or RCDATA |
$self->{content_model} = $content_model_flag; # CDATA or RCDATA |
| 2946 |
$token->{tag_name} eq $start_tag_name) { |
$token->{tag_name} eq $start_tag_name) { |
| 2947 |
!!!cp ('t42'); |
!!!cp ('t42'); |
| 2948 |
## 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}); |
|
| 2949 |
} else { |
} else { |
| 2950 |
die "$0: $content_model_flag in parse_rcdata"; |
## NOTE: An end-of-file token. |
| 2951 |
|
if ($content_model_flag == CDATA_CONTENT_MODEL) { |
| 2952 |
|
!!!cp ('t43'); |
| 2953 |
|
!!!parse-error (type => 'in CDATA:#'.$token->{type}); |
| 2954 |
|
} elsif ($content_model_flag == RCDATA_CONTENT_MODEL) { |
| 2955 |
|
!!!cp ('t44'); |
| 2956 |
|
!!!parse-error (type => 'in RCDATA:#'.$token->{type}); |
| 2957 |
|
} else { |
| 2958 |
|
die "$0: $content_model_flag in parse_rcdata"; |
| 2959 |
|
} |
| 2960 |
} |
} |
| 2961 |
!!!next-token; |
!!!next-token; |
| 2962 |
}; # $parse_rcdata |
}; # $parse_rcdata |
| 2963 |
|
|
| 2964 |
my $script_start_tag = sub ($) { |
my $script_start_tag = sub () { |
|
my $insert = $_[0]; |
|
| 2965 |
my $script_el; |
my $script_el; |
| 2966 |
!!!create-element ($script_el, 'script', $token->{attributes}); |
!!!create-element ($script_el, 'script', $token->{attributes}); |
| 2967 |
## TODO: mark as "parser-inserted" |
## TODO: mark as "parser-inserted" |
| 3012 |
!!!next-token; |
!!!next-token; |
| 3013 |
}; # $script_start_tag |
}; # $script_start_tag |
| 3014 |
|
|
| 3015 |
|
## NOTE: $open_tables->[-1]->[0] is the "current table" element node. |
| 3016 |
|
## NOTE: $open_tables->[-1]->[1] is the "tainted" flag. |
| 3017 |
|
my $open_tables = [[$self->{open_elements}->[0]->[0]]]; |
| 3018 |
|
|
| 3019 |
my $formatting_end_tag = sub { |
my $formatting_end_tag = sub { |
| 3020 |
my $tag_name = shift; |
my $tag_name = shift; |
| 3021 |
|
|
| 3022 |
|
## NOTE: The adoption agency algorithm (AAA). |
| 3023 |
|
|
| 3024 |
FET: { |
FET: { |
| 3025 |
## Step 1 |
## Step 1 |
| 3026 |
my $formatting_element; |
my $formatting_element; |
| 3061 |
return; |
return; |
| 3062 |
} |
} |
| 3063 |
} elsif ({ |
} elsif ({ |
| 3064 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 3065 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 3066 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 3067 |
!!!cp ('t56'); |
!!!cp ('t56'); |
| 3088 |
if (not $formatting_category->{$node->[1]} and |
if (not $formatting_category->{$node->[1]} and |
| 3089 |
#not $phrasing_category->{$node->[1]} and |
#not $phrasing_category->{$node->[1]} and |
| 3090 |
($special_category->{$node->[1]} or |
($special_category->{$node->[1]} or |
| 3091 |
$scoping_category->{$node->[1]})) { |
$scoping_category->{$node->[1]})) { ## Scoping is redundant, maybe |
| 3092 |
!!!cp ('t59'); |
!!!cp ('t59'); |
| 3093 |
$furthest_block = $node; |
$furthest_block = $node; |
| 3094 |
$furthest_block_i_in_open = $_; |
$furthest_block_i_in_open = $_; |
| 3174 |
} # S7 |
} # S7 |
| 3175 |
|
|
| 3176 |
## Step 8 |
## Step 8 |
| 3177 |
$common_ancestor_node->[0]->append_child ($last_node->[0]); |
if ({ |
| 3178 |
|
table => 1, tbody => 1, tfoot => 1, thead => 1, tr => 1, |
| 3179 |
|
}->{$common_ancestor_node->[1]}) { |
| 3180 |
|
my $foster_parent_element; |
| 3181 |
|
my $next_sibling; |
| 3182 |
|
OE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3183 |
|
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
| 3184 |
|
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
| 3185 |
|
if (defined $parent and $parent->node_type == 1) { |
| 3186 |
|
!!!cp ('t65.1'); |
| 3187 |
|
$foster_parent_element = $parent; |
| 3188 |
|
$next_sibling = $self->{open_elements}->[$_]->[0]; |
| 3189 |
|
} else { |
| 3190 |
|
!!!cp ('t65.2'); |
| 3191 |
|
$foster_parent_element |
| 3192 |
|
= $self->{open_elements}->[$_ - 1]->[0]; |
| 3193 |
|
} |
| 3194 |
|
last OE; |
| 3195 |
|
} |
| 3196 |
|
} # OE |
| 3197 |
|
$foster_parent_element = $self->{open_elements}->[0]->[0] |
| 3198 |
|
unless defined $foster_parent_element; |
| 3199 |
|
$foster_parent_element->insert_before ($last_node->[0], $next_sibling); |
| 3200 |
|
$open_tables->[-1]->[1] = 1; # tainted |
| 3201 |
|
} else { |
| 3202 |
|
!!!cp ('t65.3'); |
| 3203 |
|
$common_ancestor_node->[0]->append_child ($last_node->[0]); |
| 3204 |
|
} |
| 3205 |
|
|
| 3206 |
## Step 9 |
## Step 9 |
| 3207 |
my $clone = [$formatting_element->[0]->clone_node (0), |
my $clone = [$formatting_element->[0]->clone_node (0), |
| 3247 |
} # FET |
} # FET |
| 3248 |
}; # $formatting_end_tag |
}; # $formatting_end_tag |
| 3249 |
|
|
| 3250 |
my $insert_to_current = sub { |
$insert = my $insert_to_current = sub { |
| 3251 |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
$self->{open_elements}->[-1]->[0]->append_child ($_[0]); |
| 3252 |
}; # $insert_to_current |
}; # $insert_to_current |
| 3253 |
|
|
| 3254 |
my $insert_to_foster = sub { |
my $insert_to_foster = sub { |
| 3255 |
my $child = shift; |
my $child = shift; |
| 3256 |
if ({ |
if ({ |
| 3257 |
table => 1, tbody => 1, tfoot => 1, |
table => 1, tbody => 1, tfoot => 1, thead => 1, tr => 1, |
| 3258 |
thead => 1, tr => 1, |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 3259 |
}->{$self->{open_elements}->[-1]->[1]}) { |
# MUST |
| 3260 |
# MUST |
my $foster_parent_element; |
| 3261 |
my $foster_parent_element; |
my $next_sibling; |
|
my $next_sibling; |
|
| 3262 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3263 |
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
| 3264 |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
| 3278 |
unless defined $foster_parent_element; |
unless defined $foster_parent_element; |
| 3279 |
$foster_parent_element->insert_before |
$foster_parent_element->insert_before |
| 3280 |
($child, $next_sibling); |
($child, $next_sibling); |
| 3281 |
} else { |
$open_tables->[-1]->[1] = 1; # tainted |
| 3282 |
!!!cp ('t72'); |
} else { |
| 3283 |
$self->{open_elements}->[-1]->[0]->append_child ($child); |
!!!cp ('t72'); |
| 3284 |
} |
$self->{open_elements}->[-1]->[0]->append_child ($child); |
| 3285 |
|
} |
| 3286 |
}; # $insert_to_foster |
}; # $insert_to_foster |
| 3287 |
|
|
|
my $insert; |
|
|
|
|
| 3288 |
B: { |
B: { |
| 3289 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
| 3290 |
!!!cp ('t73'); |
!!!cp ('t73'); |
| 3293 |
## Stay in the phase |
## Stay in the phase |
| 3294 |
!!!next-token; |
!!!next-token; |
| 3295 |
redo B; |
redo B; |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
|
|
if ($self->{insertion_mode} & AFTER_HTML_IMS) { |
|
|
!!!cp ('t74'); |
|
|
# |
|
|
} else { |
|
|
## Generate implied end tags |
|
|
if ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, td => 1, th => 1, tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!cp ('t75'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, tag_name => $self->{open_elements}->[-1]->[1]}; |
|
|
redo B; |
|
|
} |
|
|
|
|
|
if (@{$self->{open_elements}} > 2 or |
|
|
(@{$self->{open_elements}} == 2 and $self->{open_elements}->[1]->[1] ne 'body')) { |
|
|
!!!cp ('t76'); |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} elsif (defined $self->{inner_html_node} and |
|
|
@{$self->{open_elements}} > 1 and |
|
|
$self->{open_elements}->[1]->[1] ne 'body') { |
|
|
## ISSUE: This case is never reached. |
|
|
!!!cp ('t77'); |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} else { |
|
|
!!!cp ('t78'); |
|
|
} |
|
|
|
|
|
## ISSUE: There is an issue in the spec. |
|
|
} |
|
|
|
|
|
## Stop parsing |
|
|
last B; |
|
| 3296 |
} elsif ($token->{type} == START_TAG_TOKEN and |
} elsif ($token->{type} == START_TAG_TOKEN and |
| 3297 |
$token->{tag_name} eq 'html') { |
$token->{tag_name} eq 'html') { |
| 3298 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 3299 |
!!!cp ('t79'); |
!!!cp ('t79'); |
|
## Turn into the main phase |
|
| 3300 |
!!!parse-error (type => 'after html:html'); |
!!!parse-error (type => 'after html:html'); |
| 3301 |
$self->{insertion_mode} = AFTER_BODY_IM; |
$self->{insertion_mode} = AFTER_BODY_IM; |
| 3302 |
} elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
| 3303 |
!!!cp ('t80'); |
!!!cp ('t80'); |
|
## Turn into the main phase |
|
| 3304 |
!!!parse-error (type => 'after html:html'); |
!!!parse-error (type => 'after html:html'); |
| 3305 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 3306 |
} else { |
} else { |
| 3307 |
!!!cp ('t81'); |
!!!cp ('t81'); |
| 3308 |
} |
} |
| 3309 |
|
|
| 3310 |
## ISSUE: "aa<html>" is not a parse error. |
!!!cp ('t82'); |
| 3311 |
## 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'); |
|
|
} |
|
| 3312 |
my $top_el = $self->{open_elements}->[0]->[0]; |
my $top_el = $self->{open_elements}->[0]->[0]; |
| 3313 |
for my $attr_name (keys %{$token->{attributes}}) { |
for my $attr_name (keys %{$token->{attributes}}) { |
| 3314 |
unless ($top_el->has_attribute_ns (undef, $attr_name)) { |
unless ($top_el->has_attribute_ns (undef, $attr_name)) { |
| 3337 |
} elsif ($self->{insertion_mode} & HEAD_IMS) { |
} elsif ($self->{insertion_mode} & HEAD_IMS) { |
| 3338 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 3339 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 3340 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
unless ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3341 |
|
!!!cp ('t88.2'); |
| 3342 |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 3343 |
|
} else { |
| 3344 |
|
!!!cp ('t88.1'); |
| 3345 |
|
## Ignore the token. |
| 3346 |
|
!!!next-token; |
| 3347 |
|
redo B; |
| 3348 |
|
} |
| 3349 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 3350 |
!!!cp ('t88'); |
!!!cp ('t88'); |
| 3351 |
!!!next-token; |
!!!next-token; |
| 3446 |
} |
} |
| 3447 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 3448 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 3449 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3450 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3451 |
!!!next-token; |
!!!next-token; |
| 3452 |
redo B; |
redo B; |
| 3461 |
} |
} |
| 3462 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 3463 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 3464 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3465 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3466 |
!!!next-token; |
!!!next-token; |
| 3467 |
redo B; |
redo B; |
| 3522 |
} |
} |
| 3523 |
} |
} |
| 3524 |
|
|
| 3525 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3526 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3527 |
!!!next-token; |
!!!next-token; |
| 3528 |
redo B; |
redo B; |
| 3546 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3547 |
my $parent = defined $self->{head_element} ? $self->{head_element} |
my $parent = defined $self->{head_element} ? $self->{head_element} |
| 3548 |
: $self->{open_elements}->[-1]->[0]; |
: $self->{open_elements}->[-1]->[0]; |
| 3549 |
$parse_rcdata->(RCDATA_CONTENT_MODEL, |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
| 3550 |
sub { $parent->append_child ($_[0]) }); |
pop @{$self->{open_elements}} # <head> |
|
pop @{$self->{open_elements}} |
|
| 3551 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3552 |
redo B; |
redo B; |
| 3553 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 3561 |
} else { |
} else { |
| 3562 |
!!!cp ('t115'); |
!!!cp ('t115'); |
| 3563 |
} |
} |
| 3564 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 3565 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3566 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3567 |
redo B; |
redo B; |
| 3568 |
} elsif ($token->{tag_name} eq 'noscript') { |
} elsif ($token->{tag_name} eq 'noscript') { |
| 3601 |
} |
} |
| 3602 |
|
|
| 3603 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 3604 |
$script_start_tag->($insert_to_current); |
$script_start_tag->(); |
| 3605 |
pop @{$self->{open_elements}} |
pop @{$self->{open_elements}} # <head> |
| 3606 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 3607 |
redo B; |
redo B; |
| 3608 |
} elsif ($token->{tag_name} eq 'body' or |
} elsif ($token->{tag_name} eq 'body' or |
| 3811 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 3812 |
## reprocess |
## reprocess |
| 3813 |
redo B; |
redo B; |
| 3814 |
} else { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 3815 |
die "$0: $token->{type}: Unknown token type"; |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 3816 |
} |
!!!cp ('t149.1'); |
| 3817 |
|
|
| 3818 |
|
## NOTE: As if <head> |
| 3819 |
|
!!!create-element ($self->{head_element}, 'head'); |
| 3820 |
|
$self->{open_elements}->[-1]->[0]->append_child |
| 3821 |
|
($self->{head_element}); |
| 3822 |
|
#push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
| 3823 |
|
#$self->{insertion_mode} = IN_HEAD_IM; |
| 3824 |
|
## NOTE: Reprocess. |
| 3825 |
|
|
| 3826 |
|
## NOTE: As if </head> |
| 3827 |
|
#pop @{$self->{open_elements}}; |
| 3828 |
|
#$self->{insertion_mode} = IN_AFTER_HEAD_IM; |
| 3829 |
|
## NOTE: Reprocess. |
| 3830 |
|
|
| 3831 |
|
# |
| 3832 |
|
} elsif ($self->{insertion_mode} == IN_HEAD_IM) { |
| 3833 |
|
!!!cp ('t149.2'); |
| 3834 |
|
|
| 3835 |
|
## NOTE: As if </head> |
| 3836 |
|
pop @{$self->{open_elements}}; |
| 3837 |
|
#$self->{insertion_mode} = IN_AFTER_HEAD_IM; |
| 3838 |
|
## NOTE: Reprocess. |
| 3839 |
|
|
| 3840 |
|
# |
| 3841 |
|
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 3842 |
|
!!!cp ('t149.3'); |
| 3843 |
|
|
| 3844 |
|
!!!parse-error (type => 'in noscript:#eof'); |
| 3845 |
|
|
| 3846 |
|
## As if </noscript> |
| 3847 |
|
pop @{$self->{open_elements}}; |
| 3848 |
|
#$self->{insertion_mode} = IN_HEAD_IM; |
| 3849 |
|
## NOTE: Reprocess. |
| 3850 |
|
|
| 3851 |
|
## NOTE: As if </head> |
| 3852 |
|
pop @{$self->{open_elements}}; |
| 3853 |
|
#$self->{insertion_mode} = IN_AFTER_HEAD_IM; |
| 3854 |
|
## NOTE: Reprocess. |
| 3855 |
|
|
| 3856 |
|
# |
| 3857 |
|
} else { |
| 3858 |
|
!!!cp ('t149.4'); |
| 3859 |
|
# |
| 3860 |
|
} |
| 3861 |
|
|
| 3862 |
|
## NOTE: As if <body> |
| 3863 |
|
!!!insert-element ('body'); |
| 3864 |
|
$self->{insertion_mode} = IN_BODY_IM; |
| 3865 |
|
## NOTE: Reprocess. |
| 3866 |
|
redo B; |
| 3867 |
|
} else { |
| 3868 |
|
die "$0: $token->{type}: Unknown token type"; |
| 3869 |
|
} |
| 3870 |
|
|
| 3871 |
## ISSUE: An issue in the spec. |
## ISSUE: An issue in the spec. |
| 3872 |
} elsif ($self->{insertion_mode} & BODY_IMS) { |
} elsif ($self->{insertion_mode} & BODY_IMS) { |
| 3935 |
} # INSCOPE |
} # INSCOPE |
| 3936 |
unless (defined $i) { |
unless (defined $i) { |
| 3937 |
!!!cp ('t157'); |
!!!cp ('t157'); |
| 3938 |
|
## TODO: this type is wrong. |
| 3939 |
!!!parse-error (type => 'unmatched end tag:caption'); |
!!!parse-error (type => 'unmatched end tag:caption'); |
| 3940 |
## Ignore the token |
## Ignore the token |
| 3941 |
!!!next-token; |
!!!next-token; |
| 3943 |
} |
} |
| 3944 |
|
|
| 3945 |
## generate implied end tags |
## generate implied end tags |
| 3946 |
if ({ |
while ({ |
| 3947 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 3948 |
td => 1, th => 1, tr => 1, |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 3949 |
!!!cp ('t158'); |
!!!cp ('t158'); |
| 3950 |
!!!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; |
|
| 3951 |
} |
} |
| 3952 |
|
|
| 3953 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 4000 |
} |
} |
| 4001 |
|
|
| 4002 |
## generate implied end tags |
## generate implied end tags |
| 4003 |
if ({ |
while ({ |
| 4004 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4005 |
td => ($token->{tag_name} eq 'th'), |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
th => ($token->{tag_name} eq 'td'), |
|
|
tr => 1, |
|
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4006 |
!!!cp ('t166'); |
!!!cp ('t166'); |
| 4007 |
!!!back-token; |
pop @{$self->{open_elements}}; |
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
| 4008 |
} |
} |
| 4009 |
|
|
| 4010 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 4011 |
!!!cp ('t167'); |
!!!cp ('t167'); |
| 4012 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4058 |
} |
} |
| 4059 |
|
|
| 4060 |
## generate implied end tags |
## generate implied end tags |
| 4061 |
if ({ |
while ({ |
| 4062 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4063 |
td => 1, th => 1, tr => 1, |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4064 |
!!!cp ('t174'); |
!!!cp ('t174'); |
| 4065 |
!!!back-token; |
pop @{$self->{open_elements}}; |
|
$token = {type => END_TAG_TOKEN, |
|
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
| 4066 |
} |
} |
| 4067 |
|
|
| 4068 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 4159 |
} |
} |
| 4160 |
|
|
| 4161 |
## generate implied end tags |
## generate implied end tags |
| 4162 |
if ({ |
while ({ |
| 4163 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4164 |
td => 1, th => 1, tr => 1, |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4165 |
!!!cp ('t187'); |
!!!cp ('t187'); |
| 4166 |
!!!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; |
|
| 4167 |
} |
} |
| 4168 |
|
|
| 4169 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
| 4208 |
!!!cp ('t193'); |
!!!cp ('t193'); |
| 4209 |
# |
# |
| 4210 |
} |
} |
| 4211 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 4212 |
|
for my $entry (@{$self->{open_elements}}) { |
| 4213 |
|
if (not { |
| 4214 |
|
dd => 1, dt => 1, li => 1, p => 1, tbody => 1, td => 1, tfoot => 1, |
| 4215 |
|
th => 1, thead => 1, tr => 1, body => 1, html => 1, |
| 4216 |
|
}->{$entry->[1]}) { |
| 4217 |
|
!!!cp ('t75'); |
| 4218 |
|
!!!parse-error (type => 'in body:#eof'); |
| 4219 |
|
last; |
| 4220 |
|
} |
| 4221 |
|
} |
| 4222 |
|
|
| 4223 |
|
## Stop parsing. |
| 4224 |
|
last B; |
| 4225 |
} else { |
} else { |
| 4226 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 4227 |
} |
} |
| 4230 |
# |
# |
| 4231 |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
| 4232 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 4233 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if (not $open_tables->[-1]->[1] and # tainted |
| 4234 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4235 |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 4236 |
|
|
| 4237 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 4238 |
!!!cp ('t194'); |
!!!cp ('t194'); |
| 4239 |
!!!next-token; |
!!!next-token; |
| 4240 |
redo B; |
redo B; |
| 4241 |
} else { |
} else { |
| 4242 |
!!!cp ('t195'); |
!!!cp ('t195'); |
| 4243 |
} |
} |
| 4244 |
} |
} |
| 4245 |
|
|
| 4246 |
!!!parse-error (type => 'in table:#character'); |
!!!parse-error (type => 'in table:#character'); |
| 4247 |
|
|
| 4288 |
($self->{document}->create_text_node ($token->{data}), |
($self->{document}->create_text_node ($token->{data}), |
| 4289 |
$next_sibling); |
$next_sibling); |
| 4290 |
} |
} |
| 4291 |
} else { |
$open_tables->[-1]->[1] = 1; # tainted |
| 4292 |
!!!cp ('t200'); |
} else { |
| 4293 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
!!!cp ('t200'); |
| 4294 |
} |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 4295 |
|
} |
| 4296 |
|
|
| 4297 |
!!!next-token; |
!!!next-token; |
| 4298 |
redo B; |
redo B; |
| 4299 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 4300 |
if ({ |
if ({ |
| 4301 |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
| 4306 |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
| 4307 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4308 |
!!!cp ('t201'); |
!!!cp ('t201'); |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4309 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4310 |
} |
} |
| 4311 |
|
|
| 4325 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4326 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4327 |
!!!cp ('t203'); |
!!!cp ('t203'); |
| 4328 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
## ISSUE: Can this case be reached? |
| 4329 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4330 |
} |
} |
| 4331 |
|
|
| 4349 |
tr => 1, html => 1, |
tr => 1, html => 1, |
| 4350 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4351 |
!!!cp ('t207'); |
!!!cp ('t207'); |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4352 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4353 |
} |
} |
| 4354 |
|
|
| 4375 |
$i = $_; |
$i = $_; |
| 4376 |
last INSCOPE; |
last INSCOPE; |
| 4377 |
} elsif ({ |
} elsif ({ |
| 4378 |
table => 1, html => 1, |
html => 1, |
| 4379 |
|
|
| 4380 |
|
## NOTE: This element does not appear here, maybe. |
| 4381 |
|
table => 1, |
| 4382 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 4383 |
!!!cp ('t209'); |
!!!cp ('t209'); |
| 4384 |
last INSCOPE; |
last INSCOPE; |
| 4386 |
} # INSCOPE |
} # INSCOPE |
| 4387 |
unless (defined $i) { |
unless (defined $i) { |
| 4388 |
!!!cp ('t210'); |
!!!cp ('t210'); |
| 4389 |
|
## TODO: This type is wrong. |
| 4390 |
!!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}); |
| 4391 |
## Ignore the token |
## Ignore the token |
| 4392 |
!!!next-token; |
!!!next-token; |
| 4398 |
tr => 1, html => 1, |
tr => 1, html => 1, |
| 4399 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4400 |
!!!cp ('t211'); |
!!!cp ('t211'); |
| 4401 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
## ISSUE: Can this case be reached? |
| 4402 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4403 |
} |
} |
| 4404 |
|
|
| 4446 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4447 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4448 |
!!!cp ('t217'); |
!!!cp ('t217'); |
| 4449 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
## ISSUE: Can this state be reached? |
| 4450 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4451 |
} |
} |
| 4452 |
|
|
| 4469 |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
| 4470 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4471 |
!!!cp ('t219'); |
!!!cp ('t219'); |
| 4472 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
## ISSUE: Can this state be reached? |
| 4473 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4474 |
} |
} |
| 4475 |
|
|
| 4486 |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
| 4487 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4488 |
!!!cp ('t220'); |
!!!cp ('t220'); |
| 4489 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
## ISSUE: Can this state be reached? |
| 4490 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4491 |
} |
} |
| 4492 |
|
|
| 4519 |
$i = $_; |
$i = $_; |
| 4520 |
last INSCOPE; |
last INSCOPE; |
| 4521 |
} elsif ({ |
} elsif ({ |
| 4522 |
table => 1, html => 1, |
#table => 1, |
| 4523 |
|
html => 1, |
| 4524 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 4525 |
!!!cp ('t222'); |
!!!cp ('t222'); |
| 4526 |
last INSCOPE; |
last INSCOPE; |
| 4528 |
} # INSCOPE |
} # INSCOPE |
| 4529 |
unless (defined $i) { |
unless (defined $i) { |
| 4530 |
!!!cp ('t223'); |
!!!cp ('t223'); |
| 4531 |
|
## TODO: The following is wrong, maybe. |
| 4532 |
!!!parse-error (type => 'unmatched end tag:table'); |
!!!parse-error (type => 'unmatched end tag:table'); |
| 4533 |
## Ignore tokens </table><table> |
## Ignore tokens </table><table> |
| 4534 |
!!!next-token; |
!!!next-token; |
| 4535 |
redo B; |
redo B; |
| 4536 |
} |
} |
| 4537 |
|
|
| 4538 |
|
## TODO: Followings are removed from the latest spec. |
| 4539 |
## generate implied end tags |
## generate implied end tags |
| 4540 |
if ({ |
while ({ |
| 4541 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4542 |
td => 1, th => 1, tr => 1, |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
tbody => 1, tfoot=> 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4543 |
!!!cp ('t224'); |
!!!cp ('t224'); |
| 4544 |
!!!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; |
|
| 4545 |
} |
} |
| 4546 |
|
|
| 4547 |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
| 4548 |
!!!cp ('t225'); |
!!!cp ('t225'); |
| 4549 |
|
## ISSUE: Can this case be reached? |
| 4550 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 4551 |
} else { |
} else { |
| 4552 |
!!!cp ('t226'); |
!!!cp ('t226'); |
| 4553 |
} |
} |
| 4554 |
|
|
| 4555 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 4556 |
|
pop @{$open_tables}; |
| 4557 |
|
|
| 4558 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 4559 |
|
|
| 4560 |
## reprocess |
## reprocess |
| 4561 |
redo B; |
redo B; |
| 4562 |
|
} elsif ($token->{tag_name} eq 'style') { |
| 4563 |
|
if (not $open_tables->[-1]->[1]) { # tainted |
| 4564 |
|
!!!cp ('t227.8'); |
| 4565 |
|
## NOTE: This is a "as if in head" code clone. |
| 4566 |
|
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 4567 |
|
redo B; |
| 4568 |
|
} else { |
| 4569 |
|
!!!cp ('t227.7'); |
| 4570 |
|
# |
| 4571 |
|
} |
| 4572 |
|
} elsif ($token->{tag_name} eq 'script') { |
| 4573 |
|
if (not $open_tables->[-1]->[1]) { # tainted |
| 4574 |
|
!!!cp ('t227.6'); |
| 4575 |
|
## NOTE: This is a "as if in head" code clone. |
| 4576 |
|
$script_start_tag->(); |
| 4577 |
|
redo B; |
| 4578 |
|
} else { |
| 4579 |
|
!!!cp ('t227.5'); |
| 4580 |
|
# |
| 4581 |
|
} |
| 4582 |
|
} elsif ($token->{tag_name} eq 'input') { |
| 4583 |
|
if (not $open_tables->[-1]->[1]) { # tainted |
| 4584 |
|
if ($token->{attributes}->{type}) { ## TODO: case |
| 4585 |
|
my $type = lc $token->{attributes}->{type}->{value}; |
| 4586 |
|
if ($type eq 'hidden') { |
| 4587 |
|
!!!cp ('t227.3'); |
| 4588 |
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
| 4589 |
|
|
| 4590 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4591 |
|
|
| 4592 |
|
## TODO: form element pointer |
| 4593 |
|
|
| 4594 |
|
pop @{$self->{open_elements}}; |
| 4595 |
|
|
| 4596 |
|
!!!next-token; |
| 4597 |
|
redo B; |
| 4598 |
|
} else { |
| 4599 |
|
!!!cp ('t227.2'); |
| 4600 |
|
# |
| 4601 |
|
} |
| 4602 |
|
} else { |
| 4603 |
|
!!!cp ('t227.1'); |
| 4604 |
|
# |
| 4605 |
|
} |
| 4606 |
|
} else { |
| 4607 |
|
!!!cp ('t227.4'); |
| 4608 |
|
# |
| 4609 |
|
} |
| 4610 |
} else { |
} else { |
| 4611 |
!!!cp ('t227'); |
!!!cp ('t227'); |
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
|
|
|
|
|
$insert = $insert_to_foster; |
|
| 4612 |
# |
# |
| 4613 |
} |
} |
| 4614 |
|
|
| 4615 |
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
| 4616 |
|
|
| 4617 |
|
$insert = $insert_to_foster; |
| 4618 |
|
# |
| 4619 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 4620 |
if ($token->{tag_name} eq 'tr' and |
if ($token->{tag_name} eq 'tr' and |
| 4621 |
$self->{insertion_mode} == IN_ROW_IM) { |
$self->{insertion_mode} == IN_ROW_IM) { |
| 4649 |
tr => 1, html => 1, |
tr => 1, html => 1, |
| 4650 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4651 |
!!!cp ('t231'); |
!!!cp ('t231'); |
| 4652 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
## ISSUE: Can this state be reached? |
| 4653 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4654 |
} |
} |
| 4655 |
|
|
| 4677 |
} # INSCOPE |
} # INSCOPE |
| 4678 |
unless (defined $i) { |
unless (defined $i) { |
| 4679 |
!!!cp ('t235'); |
!!!cp ('t235'); |
| 4680 |
|
## TODO: The following is wrong. |
| 4681 |
!!!parse-error (type => 'unmatched end tag:'.$token->{type}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{type}); |
| 4682 |
## Ignore the token |
## Ignore the token |
| 4683 |
!!!next-token; |
!!!next-token; |
| 4689 |
tr => 1, html => 1, |
tr => 1, html => 1, |
| 4690 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4691 |
!!!cp ('t236'); |
!!!cp ('t236'); |
| 4692 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
## ISSUE: Can this state be reached? |
| 4693 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4694 |
} |
} |
| 4695 |
|
|
| 4729 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4730 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4731 |
!!!cp ('t240'); |
!!!cp ('t240'); |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4732 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4733 |
} |
} |
| 4734 |
|
|
| 4744 |
## reprocess in the "in table" insertion mode... |
## reprocess in the "in table" insertion mode... |
| 4745 |
} |
} |
| 4746 |
|
|
| 4747 |
|
## NOTE: </table> in the "in table" insertion mode. |
| 4748 |
|
## When you edit the code fragment below, please ensure that |
| 4749 |
|
## the code for <table> in the "in table" insertion mode |
| 4750 |
|
## is synced with it. |
| 4751 |
|
|
| 4752 |
## have a table element in table scope |
## have a table element in table scope |
| 4753 |
my $i; |
my $i; |
| 4754 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4771 |
!!!next-token; |
!!!next-token; |
| 4772 |
redo B; |
redo B; |
| 4773 |
} |
} |
|
|
|
|
## 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'); |
|
|
!!!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'); |
|
|
} |
|
| 4774 |
|
|
| 4775 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 4776 |
|
pop @{$open_tables}; |
| 4777 |
|
|
| 4778 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 4779 |
|
|
| 4836 |
tr => 1, html => 1, |
tr => 1, html => 1, |
| 4837 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4838 |
!!!cp ('t253'); |
!!!cp ('t253'); |
| 4839 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
## ISSUE: Can this case be reached? |
| 4840 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4841 |
} |
} |
| 4842 |
|
|
| 4873 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4874 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4875 |
!!!cp ('t257'); |
!!!cp ('t257'); |
| 4876 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
## ISSUE: Can this case be reached? |
| 4877 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4878 |
} |
} |
| 4879 |
|
|
| 4899 |
$insert = $insert_to_foster; |
$insert = $insert_to_foster; |
| 4900 |
# |
# |
| 4901 |
} |
} |
| 4902 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 4903 |
|
unless ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 4904 |
|
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 4905 |
|
!!!parse-error (type => 'in body:#eof'); |
| 4906 |
|
!!!cp ('t259.1'); |
| 4907 |
|
# |
| 4908 |
|
} else { |
| 4909 |
|
!!!cp ('t259.2'); |
| 4910 |
|
# |
| 4911 |
|
} |
| 4912 |
|
|
| 4913 |
|
## Stop parsing |
| 4914 |
|
last B; |
| 4915 |
} else { |
} else { |
| 4916 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 4917 |
} |
} |
| 4964 |
!!!cp ('t267'); |
!!!cp ('t267'); |
| 4965 |
# |
# |
| 4966 |
} |
} |
| 4967 |
} else { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 4968 |
!!!cp ('t268'); |
if ($self->{open_elements}->[-1]->[1] eq 'html' or |
| 4969 |
# |
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 4970 |
} |
!!!cp ('t270.2'); |
| 4971 |
|
## Stop parsing. |
| 4972 |
|
last B; |
| 4973 |
|
} else { |
| 4974 |
|
## NOTE: As if </colgroup>. |
| 4975 |
|
!!!cp ('t270.1'); |
| 4976 |
|
pop @{$self->{open_elements}}; # colgroup |
| 4977 |
|
$self->{insertion_mode} = IN_TABLE_IM; |
| 4978 |
|
## Reprocess. |
| 4979 |
|
redo B; |
| 4980 |
|
} |
| 4981 |
|
} else { |
| 4982 |
|
die "$0: $token->{type}: Unknown token type"; |
| 4983 |
|
} |
| 4984 |
|
|
| 4985 |
## As if </colgroup> |
## As if </colgroup> |
| 4986 |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
| 4987 |
!!!cp ('t269'); |
!!!cp ('t269'); |
| 4988 |
|
## TODO: Wrong error type? |
| 4989 |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
| 4990 |
## Ignore the token |
## Ignore the token |
| 4991 |
!!!next-token; |
!!!next-token; |
| 4997 |
## reprocess |
## reprocess |
| 4998 |
redo B; |
redo B; |
| 4999 |
} |
} |
| 5000 |
} elsif ($self->{insertion_mode} == IN_SELECT_IM) { |
} elsif ($self->{insertion_mode} & SELECT_IMS) { |
| 5001 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 5002 |
!!!cp ('t271'); |
!!!cp ('t271'); |
| 5003 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 5036 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 5037 |
!!!next-token; |
!!!next-token; |
| 5038 |
redo B; |
redo B; |
| 5039 |
} elsif ($token->{tag_name} eq 'select') { |
} elsif ($token->{tag_name} eq 'select' or |
| 5040 |
!!!parse-error (type => 'not closed:select'); |
$token->{tag_name} eq 'input' or |
| 5041 |
## As if </select> instead |
($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
| 5042 |
|
{ |
| 5043 |
|
caption => 1, table => 1, |
| 5044 |
|
tbody => 1, tfoot => 1, thead => 1, |
| 5045 |
|
tr => 1, td => 1, th => 1, |
| 5046 |
|
}->{$token->{tag_name}})) { |
| 5047 |
|
## TODO: The type below is not good - <select> is replaced by </select> |
| 5048 |
|
!!!parse-error (type => 'not closed:select'); |
| 5049 |
|
## NOTE: As if the token were </select> (<select> case) or |
| 5050 |
|
## as if there were </select> (otherwise). |
| 5051 |
## have an element in table scope |
## have an element in table scope |
| 5052 |
my $i; |
my $i; |
| 5053 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5054 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5055 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq 'select') { |
| 5056 |
!!!cp ('t278'); |
!!!cp ('t278'); |
| 5057 |
$i = $_; |
$i = $_; |
| 5058 |
last INSCOPE; |
last INSCOPE; |
| 5076 |
|
|
| 5077 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 5078 |
|
|
| 5079 |
!!!next-token; |
if ($token->{tag_name} eq 'select') { |
| 5080 |
redo B; |
!!!cp ('t281.2'); |
| 5081 |
|
!!!next-token; |
| 5082 |
|
redo B; |
| 5083 |
|
} else { |
| 5084 |
|
!!!cp ('t281.1'); |
| 5085 |
|
## Reprocess the token. |
| 5086 |
|
redo B; |
| 5087 |
|
} |
| 5088 |
} else { |
} else { |
| 5089 |
!!!cp ('t282'); |
!!!cp ('t282'); |
| 5090 |
!!!parse-error (type => 'in select:'.$token->{tag_name}); |
!!!parse-error (type => 'in select:'.$token->{tag_name}); |
| 5151 |
|
|
| 5152 |
!!!next-token; |
!!!next-token; |
| 5153 |
redo B; |
redo B; |
| 5154 |
} elsif ({ |
} elsif ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
| 5155 |
caption => 1, table => 1, tbody => 1, |
{ |
| 5156 |
tfoot => 1, thead => 1, tr => 1, td => 1, th => 1, |
caption => 1, table => 1, tbody => 1, |
| 5157 |
}->{$token->{tag_name}}) { |
tfoot => 1, thead => 1, tr => 1, td => 1, th => 1, |
| 5158 |
|
}->{$token->{tag_name}}) { |
| 5159 |
|
## TODO: The following is wrong? |
| 5160 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 5161 |
|
|
| 5162 |
## have an element in table scope |
## have an element in table scope |
| 5193 |
} elsif ({ |
} elsif ({ |
| 5194 |
table => 1, html => 1, |
table => 1, html => 1, |
| 5195 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 5196 |
|
## ISSUE: Can this state be reached? |
| 5197 |
!!!cp ('t296'); |
!!!cp ('t296'); |
| 5198 |
last INSCOPE; |
last INSCOPE; |
| 5199 |
} |
} |
| 5200 |
} # INSCOPE |
} # INSCOPE |
| 5201 |
unless (defined $i) { |
unless (defined $i) { |
| 5202 |
!!!cp ('t297'); |
!!!cp ('t297'); |
| 5203 |
|
## TODO: The following error type is correct? |
| 5204 |
!!!parse-error (type => 'unmatched end tag:select'); |
!!!parse-error (type => 'unmatched end tag:select'); |
| 5205 |
## Ignore the </select> token |
## Ignore the </select> token |
| 5206 |
!!!next-token; ## TODO: ok? |
!!!next-token; ## TODO: ok? |
| 5221 |
!!!next-token; |
!!!next-token; |
| 5222 |
redo B; |
redo B; |
| 5223 |
} |
} |
| 5224 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5225 |
|
unless ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 5226 |
|
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 5227 |
|
!!!cp ('t299.1'); |
| 5228 |
|
!!!parse-error (type => 'in body:#eof'); |
| 5229 |
|
} else { |
| 5230 |
|
!!!cp ('t299.2'); |
| 5231 |
|
} |
| 5232 |
|
|
| 5233 |
|
## Stop parsing. |
| 5234 |
|
last B; |
| 5235 |
} else { |
} else { |
| 5236 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 5237 |
} |
} |
| 5255 |
!!!cp ('t301'); |
!!!cp ('t301'); |
| 5256 |
!!!parse-error (type => 'after html:#character'); |
!!!parse-error (type => 'after html:#character'); |
| 5257 |
|
|
| 5258 |
## Reprocess in the "main" phase, "after body" insertion mode... |
## Reprocess in the "after body" insertion mode. |
| 5259 |
} else { |
} else { |
| 5260 |
!!!cp ('t302'); |
!!!cp ('t302'); |
| 5261 |
} |
} |
| 5271 |
!!!cp ('t303'); |
!!!cp ('t303'); |
| 5272 |
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
| 5273 |
|
|
| 5274 |
## Reprocess in the "main" phase, "after body" insertion mode... |
## Reprocess in the "after body" insertion mode. |
| 5275 |
} else { |
} else { |
| 5276 |
!!!cp ('t304'); |
!!!cp ('t304'); |
| 5277 |
} |
} |
| 5288 |
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
| 5289 |
|
|
| 5290 |
$self->{insertion_mode} = AFTER_BODY_IM; |
$self->{insertion_mode} = AFTER_BODY_IM; |
| 5291 |
## Reprocess in the "main" phase, "after body" insertion mode... |
## Reprocess in the "after body" insertion mode. |
| 5292 |
} else { |
} else { |
| 5293 |
!!!cp ('t306'); |
!!!cp ('t306'); |
| 5294 |
} |
} |
| 5315 |
## reprocess |
## reprocess |
| 5316 |
redo B; |
redo B; |
| 5317 |
} |
} |
| 5318 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5319 |
|
!!!cp ('t309.2'); |
| 5320 |
|
## Stop parsing |
| 5321 |
|
last B; |
| 5322 |
} else { |
} else { |
| 5323 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 5324 |
} |
} |
| 5346 |
!!!parse-error (type => 'after html:#character'); |
!!!parse-error (type => 'after html:#character'); |
| 5347 |
|
|
| 5348 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 5349 |
## Reprocess in the "main" phase, "after frameset"... |
## Reprocess in the "after frameset" insertion mode. |
| 5350 |
!!!parse-error (type => 'after frameset:#character'); |
!!!parse-error (type => 'after frameset:#character'); |
| 5351 |
} |
} |
| 5352 |
|
|
| 5368 |
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
!!!parse-error (type => 'after html:'.$token->{tag_name}); |
| 5369 |
|
|
| 5370 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 5371 |
## Process in the "main" phase, "after frameset" insertion mode... |
## Process in the "after frameset" insertion mode. |
| 5372 |
} else { |
} else { |
| 5373 |
!!!cp ('t317'); |
!!!cp ('t317'); |
| 5374 |
} |
} |
| 5389 |
} elsif ($token->{tag_name} eq 'noframes') { |
} elsif ($token->{tag_name} eq 'noframes') { |
| 5390 |
!!!cp ('t320'); |
!!!cp ('t320'); |
| 5391 |
## NOTE: As if in body. |
## NOTE: As if in body. |
| 5392 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5393 |
redo B; |
redo B; |
| 5394 |
} else { |
} else { |
| 5395 |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
| 5409 |
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
!!!parse-error (type => 'after html:/'.$token->{tag_name}); |
| 5410 |
|
|
| 5411 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 5412 |
## Process in the "main" phase, "after frameset" insertion mode... |
## Process in the "after frameset" insertion mode. |
| 5413 |
} else { |
} else { |
| 5414 |
!!!cp ('t324'); |
!!!cp ('t324'); |
| 5415 |
} |
} |
| 5454 |
!!!next-token; |
!!!next-token; |
| 5455 |
redo B; |
redo B; |
| 5456 |
} |
} |
| 5457 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5458 |
|
unless ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 5459 |
|
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 5460 |
|
!!!cp ('t331.1'); |
| 5461 |
|
!!!parse-error (type => 'in body:#eof'); |
| 5462 |
|
} else { |
| 5463 |
|
!!!cp ('t331.2'); |
| 5464 |
|
} |
| 5465 |
|
|
| 5466 |
|
## Stop parsing |
| 5467 |
|
last B; |
| 5468 |
} else { |
} else { |
| 5469 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 5470 |
} |
} |
| 5479 |
if ($token->{tag_name} eq 'script') { |
if ($token->{tag_name} eq 'script') { |
| 5480 |
!!!cp ('t332'); |
!!!cp ('t332'); |
| 5481 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 5482 |
$script_start_tag->($insert); |
$script_start_tag->(); |
| 5483 |
redo B; |
redo B; |
| 5484 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 5485 |
!!!cp ('t333'); |
!!!cp ('t333'); |
| 5486 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 5487 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5488 |
redo B; |
redo B; |
| 5489 |
} elsif ({ |
} elsif ({ |
| 5490 |
base => 1, link => 1, |
base => 1, link => 1, |
| 5547 |
redo B; |
redo B; |
| 5548 |
} elsif ($token->{tag_name} eq 'title') { |
} elsif ($token->{tag_name} eq 'title') { |
| 5549 |
!!!cp ('t341'); |
!!!cp ('t341'); |
|
!!!parse-error (type => 'in body:title'); |
|
| 5550 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 5551 |
$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]); |
|
|
} |
|
|
}); |
|
| 5552 |
redo B; |
redo B; |
| 5553 |
} elsif ($token->{tag_name} eq 'body') { |
} elsif ($token->{tag_name} eq 'body') { |
| 5554 |
!!!parse-error (type => 'in body:body'); |
!!!parse-error (type => 'in body:body'); |
| 5572 |
redo B; |
redo B; |
| 5573 |
} elsif ({ |
} elsif ({ |
| 5574 |
address => 1, blockquote => 1, center => 1, dir => 1, |
address => 1, blockquote => 1, center => 1, dir => 1, |
| 5575 |
div => 1, dl => 1, fieldset => 1, listing => 1, |
div => 1, dl => 1, fieldset => 1, |
| 5576 |
|
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
| 5577 |
menu => 1, ol => 1, p => 1, ul => 1, |
menu => 1, ol => 1, p => 1, ul => 1, |
| 5578 |
pre => 1, |
pre => 1, listing => 1, |
| 5579 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5580 |
## has a p element in scope |
## has a p element in scope |
| 5581 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 5585 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
| 5586 |
redo B; |
redo B; |
| 5587 |
} elsif ({ |
} elsif ({ |
| 5588 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5589 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5590 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5591 |
!!!cp ('t345'); |
!!!cp ('t345'); |
| 5594 |
} # INSCOPE |
} # INSCOPE |
| 5595 |
|
|
| 5596 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 5597 |
if ($token->{tag_name} eq 'pre') { |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
| 5598 |
!!!next-token; |
!!!next-token; |
| 5599 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 5600 |
$token->{data} =~ s/^\x0A//; |
$token->{data} =~ s/^\x0A//; |
| 5628 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
| 5629 |
redo B; |
redo B; |
| 5630 |
} elsif ({ |
} elsif ({ |
| 5631 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5632 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5633 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5634 |
!!!cp ('t352'); |
!!!cp ('t352'); |
| 5650 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
| 5651 |
redo B; |
redo B; |
| 5652 |
} elsif ({ |
} elsif ({ |
| 5653 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5654 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5655 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5656 |
!!!cp ('t354'); |
!!!cp ('t354'); |
| 5706 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
| 5707 |
redo B; |
redo B; |
| 5708 |
} elsif ({ |
} elsif ({ |
| 5709 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5710 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5711 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5712 |
!!!cp ('t361'); |
!!!cp ('t361'); |
| 5762 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
| 5763 |
redo B; |
redo B; |
| 5764 |
} elsif ({ |
} elsif ({ |
| 5765 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5766 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5767 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5768 |
!!!cp ('t368'); |
!!!cp ('t368'); |
| 5776 |
|
|
| 5777 |
!!!next-token; |
!!!next-token; |
| 5778 |
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; |
|
| 5779 |
} elsif ($token->{tag_name} eq 'a') { |
} elsif ($token->{tag_name} eq 'a') { |
| 5780 |
AFE: for my $i (reverse 0..$#$active_formatting_elements) { |
AFE: for my $i (reverse 0..$#$active_formatting_elements) { |
| 5781 |
my $node = $active_formatting_elements->[$i]; |
my $node = $active_formatting_elements->[$i]; |
| 5841 |
$token = {type => END_TAG_TOKEN, tag_name => 'nobr'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'nobr'}; |
| 5842 |
redo B; |
redo B; |
| 5843 |
} elsif ({ |
} elsif ({ |
| 5844 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5845 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5846 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 5847 |
!!!cp ('t377'); |
!!!cp ('t377'); |
| 5865 |
$token = {type => END_TAG_TOKEN, tag_name => 'button'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'button'}; |
| 5866 |
redo B; |
redo B; |
| 5867 |
} elsif ({ |
} elsif ({ |
| 5868 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5869 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5870 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 5871 |
!!!cp ('t379'); |
!!!cp ('t379'); |
| 5876 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 5877 |
|
|
| 5878 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 5879 |
|
|
| 5880 |
|
## TODO: associate with $self->{form_element} if defined |
| 5881 |
|
|
| 5882 |
push @$active_formatting_elements, ['#marker', '']; |
push @$active_formatting_elements, ['#marker', '']; |
| 5883 |
|
|
| 5884 |
!!!next-token; |
!!!next-token; |
| 5885 |
redo B; |
redo B; |
| 5886 |
} elsif ($token->{tag_name} eq 'marquee' or |
} elsif ({ |
| 5887 |
$token->{tag_name} eq 'object') { |
applet => 1, marquee => 1, object => 1, |
| 5888 |
|
}->{$token->{tag_name}}) { |
| 5889 |
!!!cp ('t380'); |
!!!cp ('t380'); |
| 5890 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 5891 |
|
|
| 5897 |
} elsif ($token->{tag_name} eq 'xmp') { |
} elsif ($token->{tag_name} eq 'xmp') { |
| 5898 |
!!!cp ('t381'); |
!!!cp ('t381'); |
| 5899 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 5900 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5901 |
redo B; |
redo B; |
| 5902 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 5903 |
## has a p element in scope |
## has a p element in scope |
| 5908 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
| 5909 |
redo B; |
redo B; |
| 5910 |
} elsif ({ |
} elsif ({ |
| 5911 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5912 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5913 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5914 |
!!!cp ('t383'); |
!!!cp ('t383'); |
| 5917 |
} # INSCOPE |
} # INSCOPE |
| 5918 |
|
|
| 5919 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 5920 |
|
push @{$open_tables}, [$self->{open_elements}->[-1]->[0]]; |
| 5921 |
|
|
| 5922 |
$self->{insertion_mode} = IN_TABLE_IM; |
$self->{insertion_mode} = IN_TABLE_IM; |
| 5923 |
|
|
| 5924 |
!!!next-token; |
!!!next-token; |
| 5953 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
| 5954 |
redo B; |
redo B; |
| 5955 |
} elsif ({ |
} elsif ({ |
| 5956 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5957 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5958 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5959 |
!!!cp ('t387'); |
!!!cp ('t387'); |
| 6073 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6074 |
!!!cp ('t399'); |
!!!cp ('t399'); |
| 6075 |
## NOTE: There is an "as if in body" code clone. |
## NOTE: There is an "as if in body" code clone. |
| 6076 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 6077 |
redo B; |
redo B; |
| 6078 |
} elsif ($token->{tag_name} eq 'select') { |
} elsif ($token->{tag_name} eq 'select') { |
| 6079 |
!!!cp ('t400'); |
!!!cp ('t400'); |
| 6080 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 6081 |
|
|
| 6082 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 6083 |
|
|
| 6084 |
|
## TODO: associate with $self->{form_element} if defined |
| 6085 |
|
|
| 6086 |
$self->{insertion_mode} = IN_SELECT_IM; |
if ($self->{insertion_mode} & TABLE_IMS or |
| 6087 |
|
$self->{insertion_mode} & BODY_TABLE_IMS or |
| 6088 |
|
$self->{insertion_mode} == IN_COLUMN_GROUP_IM) { |
| 6089 |
|
!!!cp ('t400.1'); |
| 6090 |
|
$self->{insertion_mode} = IN_SELECT_IN_TABLE_IM; |
| 6091 |
|
} else { |
| 6092 |
|
!!!cp ('t400.2'); |
| 6093 |
|
$self->{insertion_mode} = IN_SELECT_IM; |
| 6094 |
|
} |
| 6095 |
!!!next-token; |
!!!next-token; |
| 6096 |
redo B; |
redo B; |
| 6097 |
} elsif ({ |
} elsif ({ |
| 6166 |
address => 1, blockquote => 1, center => 1, dir => 1, |
address => 1, blockquote => 1, center => 1, dir => 1, |
| 6167 |
div => 1, dl => 1, fieldset => 1, listing => 1, |
div => 1, dl => 1, fieldset => 1, listing => 1, |
| 6168 |
menu => 1, ol => 1, pre => 1, ul => 1, |
menu => 1, ol => 1, pre => 1, ul => 1, |
|
p => 1, |
|
| 6169 |
dd => 1, dt => 1, li => 1, |
dd => 1, dt => 1, li => 1, |
| 6170 |
button => 1, marquee => 1, object => 1, |
applet => 1, button => 1, marquee => 1, object => 1, |
| 6171 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6172 |
## has an element in scope |
## has an element in scope |
| 6173 |
my $i; |
my $i; |
| 6174 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6175 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 6176 |
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; |
|
|
} |
|
|
|
|
| 6177 |
!!!cp ('t410'); |
!!!cp ('t410'); |
| 6178 |
$i = $_; |
$i = $_; |
| 6179 |
last INSCOPE unless $token->{tag_name} eq 'p'; |
last INSCOPE; |
| 6180 |
} elsif ({ |
} elsif ({ |
| 6181 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6182 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 6183 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 6184 |
!!!cp ('t411'); |
!!!cp ('t411'); |
| 6185 |
last INSCOPE; |
last INSCOPE; |
| 6186 |
} |
} |
| 6187 |
} # INSCOPE |
} # INSCOPE |
| 6188 |
|
|
| 6189 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
unless (defined $i) { # has an element in scope |
| 6190 |
if (defined $i) { |
!!!cp ('t413'); |
| 6191 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 6192 |
|
} else { |
| 6193 |
|
## Step 1. generate implied end tags |
| 6194 |
|
while ({ |
| 6195 |
|
dd => ($token->{tag_name} ne 'dd'), |
| 6196 |
|
dt => ($token->{tag_name} ne 'dt'), |
| 6197 |
|
li => ($token->{tag_name} ne 'li'), |
| 6198 |
|
p => 1, |
| 6199 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 6200 |
|
!!!cp ('t409'); |
| 6201 |
|
pop @{$self->{open_elements}}; |
| 6202 |
|
} |
| 6203 |
|
|
| 6204 |
|
## Step 2. |
| 6205 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6206 |
!!!cp ('t412'); |
!!!cp ('t412'); |
| 6207 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 6208 |
} else { |
} else { |
| 6209 |
!!!cp ('t413'); |
!!!cp ('t414'); |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
| 6210 |
} |
} |
| 6211 |
} |
|
| 6212 |
|
## Step 3. |
|
if (defined $i) { |
|
|
!!!cp ('t414'); |
|
| 6213 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 6214 |
} elsif ($token->{tag_name} eq 'p') { |
|
| 6215 |
!!!cp ('t415'); |
## Step 4. |
| 6216 |
## As if <p>, then reprocess the current token |
$clear_up_to_marker->() |
| 6217 |
my $el; |
if { |
| 6218 |
!!!create-element ($el, 'p'); |
applet => 1, button => 1, marquee => 1, object => 1, |
| 6219 |
$insert->($el); |
}->{$token->{tag_name}}; |
|
} else { |
|
|
!!!cp ('t416'); |
|
| 6220 |
} |
} |
|
$clear_up_to_marker->() |
|
|
if { |
|
|
button => 1, marquee => 1, object => 1, |
|
|
}->{$token->{tag_name}}; |
|
| 6221 |
!!!next-token; |
!!!next-token; |
| 6222 |
redo B; |
redo B; |
| 6223 |
} elsif ($token->{tag_name} eq 'form') { |
} elsif ($token->{tag_name} eq 'form') { |
| 6224 |
|
undef $self->{form_element}; |
| 6225 |
|
|
| 6226 |
## has an element in scope |
## has an element in scope |
| 6227 |
|
my $i; |
| 6228 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6229 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 6230 |
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, |
|
|
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; |
|
|
} |
|
|
|
|
| 6231 |
!!!cp ('t418'); |
!!!cp ('t418'); |
| 6232 |
|
$i = $_; |
| 6233 |
last INSCOPE; |
last INSCOPE; |
| 6234 |
} elsif ({ |
} elsif ({ |
| 6235 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6236 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 6237 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 6238 |
!!!cp ('t419'); |
!!!cp ('t419'); |
| 6239 |
last INSCOPE; |
last INSCOPE; |
| 6240 |
} |
} |
| 6241 |
} # INSCOPE |
} # INSCOPE |
| 6242 |
|
|
| 6243 |
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 { |
|
| 6244 |
!!!cp ('t421'); |
!!!cp ('t421'); |
| 6245 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 6246 |
|
} else { |
| 6247 |
|
## Step 1. generate implied end tags |
| 6248 |
|
while ({ |
| 6249 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 6250 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 6251 |
|
!!!cp ('t417'); |
| 6252 |
|
pop @{$self->{open_elements}}; |
| 6253 |
|
} |
| 6254 |
|
|
| 6255 |
|
## Step 2. |
| 6256 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6257 |
|
!!!cp ('t417.1'); |
| 6258 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 6259 |
|
} else { |
| 6260 |
|
!!!cp ('t420'); |
| 6261 |
|
} |
| 6262 |
|
|
| 6263 |
|
## Step 3. |
| 6264 |
|
splice @{$self->{open_elements}}, $i; |
| 6265 |
} |
} |
| 6266 |
|
|
|
undef $self->{form_element}; |
|
| 6267 |
!!!next-token; |
!!!next-token; |
| 6268 |
redo B; |
redo B; |
| 6269 |
} elsif ({ |
} elsif ({ |
| 6276 |
if ({ |
if ({ |
| 6277 |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
| 6278 |
}->{$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; |
|
|
} |
|
|
|
|
| 6279 |
!!!cp ('t423'); |
!!!cp ('t423'); |
| 6280 |
$i = $_; |
$i = $_; |
| 6281 |
last INSCOPE; |
last INSCOPE; |
| 6282 |
} elsif ({ |
} elsif ({ |
| 6283 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6284 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 6285 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 6286 |
!!!cp ('t424'); |
!!!cp ('t424'); |
| 6287 |
last INSCOPE; |
last INSCOPE; |
| 6288 |
} |
} |
| 6289 |
} # INSCOPE |
} # INSCOPE |
| 6290 |
|
|
| 6291 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
unless (defined $i) { # has an element in scope |
| 6292 |
!!!cp ('t425'); |
!!!cp ('t425.1'); |
| 6293 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 6294 |
} else { |
} else { |
| 6295 |
!!!cp ('t426'); |
## Step 1. generate implied end tags |
| 6296 |
|
while ({ |
| 6297 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 6298 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 6299 |
|
!!!cp ('t422'); |
| 6300 |
|
pop @{$self->{open_elements}}; |
| 6301 |
|
} |
| 6302 |
|
|
| 6303 |
|
## Step 2. |
| 6304 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6305 |
|
!!!cp ('t425'); |
| 6306 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 6307 |
|
} else { |
| 6308 |
|
!!!cp ('t426'); |
| 6309 |
|
} |
| 6310 |
|
|
| 6311 |
|
## Step 3. |
| 6312 |
|
splice @{$self->{open_elements}}, $i; |
| 6313 |
} |
} |
| 6314 |
|
|
| 6315 |
splice @{$self->{open_elements}}, $i if defined $i; |
!!!next-token; |
| 6316 |
|
redo B; |
| 6317 |
|
} elsif ($token->{tag_name} eq 'p') { |
| 6318 |
|
## has an element in scope |
| 6319 |
|
my $i; |
| 6320 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6321 |
|
my $node = $self->{open_elements}->[$_]; |
| 6322 |
|
if ($node->[1] eq $token->{tag_name}) { |
| 6323 |
|
!!!cp ('t410.1'); |
| 6324 |
|
$i = $_; |
| 6325 |
|
last INSCOPE; |
| 6326 |
|
} elsif ({ |
| 6327 |
|
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6328 |
|
button => 1, marquee => 1, object => 1, html => 1, |
| 6329 |
|
}->{$node->[1]}) { |
| 6330 |
|
!!!cp ('t411.1'); |
| 6331 |
|
last INSCOPE; |
| 6332 |
|
} |
| 6333 |
|
} # INSCOPE |
| 6334 |
|
|
| 6335 |
|
if (defined $i) { |
| 6336 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6337 |
|
!!!cp ('t412.1'); |
| 6338 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 6339 |
|
} else { |
| 6340 |
|
!!!cp ('t414.1'); |
| 6341 |
|
} |
| 6342 |
|
|
| 6343 |
|
splice @{$self->{open_elements}}, $i; |
| 6344 |
|
} else { |
| 6345 |
|
!!!cp ('t413.1'); |
| 6346 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 6347 |
|
|
| 6348 |
|
!!!cp ('t415.1'); |
| 6349 |
|
## As if <p>, then reprocess the current token |
| 6350 |
|
my $el; |
| 6351 |
|
!!!create-element ($el, 'p'); |
| 6352 |
|
$insert->($el); |
| 6353 |
|
## NOTE: Not inserted into |$self->{open_elements}|. |
| 6354 |
|
} |
| 6355 |
|
|
| 6356 |
!!!next-token; |
!!!next-token; |
| 6357 |
redo B; |
redo B; |
| 6358 |
} elsif ({ |
} elsif ({ |
| 6408 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq $token->{tag_name}) { |
| 6409 |
## Step 1 |
## Step 1 |
| 6410 |
## generate implied end tags |
## generate implied end tags |
| 6411 |
if ({ |
while ({ |
| 6412 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 6413 |
td => 1, th => 1, tr => 1, |
}->{$self->{open_elements}->[-1]->[1]}) { |
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 6414 |
!!!cp ('t430'); |
!!!cp ('t430'); |
| 6415 |
!!!back-token; |
## ISSUE: Can this case be reached? |
| 6416 |
$token = {type => END_TAG_TOKEN, |
pop @{$self->{open_elements}}; |
|
tag_name => $self->{open_elements}->[-1]->[1]}; # MUST |
|
|
redo B; |
|
| 6417 |
} |
} |
| 6418 |
|
|
| 6419 |
## Step 2 |
## Step 2 |
| 6459 |
redo B; |
redo B; |
| 6460 |
} # B |
} # B |
| 6461 |
|
|
|
## 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 |
|
|
|
|
| 6462 |
## Stop parsing # MUST |
## Stop parsing # MUST |
| 6463 |
|
|
| 6464 |
## TODO: script stuffs |
## TODO: script stuffs |
| 6500 |
my $p = $class->new; |
my $p = $class->new; |
| 6501 |
$p->{document} = $doc; |
$p->{document} = $doc; |
| 6502 |
|
|
| 6503 |
## Step 9 # MUST |
## Step 8 # MUST |
| 6504 |
my $i = 0; |
my $i = 0; |
| 6505 |
my $line = 1; |
my $line = 1; |
| 6506 |
my $column = 0; |
my $column = 0; |
| 6567 |
|
|
| 6568 |
$p->{inner_html_node} = [$node, $node_ln]; |
$p->{inner_html_node} = [$node, $node_ln]; |
| 6569 |
|
|
| 6570 |
## Step 4 |
## Step 3 |
| 6571 |
my $root = $doc->create_element_ns |
my $root = $doc->create_element_ns |
| 6572 |
('http://www.w3.org/1999/xhtml', [undef, 'html']); |
('http://www.w3.org/1999/xhtml', [undef, 'html']); |
| 6573 |
|
|
| 6574 |
## Step 5 # MUST |
## Step 4 # MUST |
| 6575 |
$doc->append_child ($root); |
$doc->append_child ($root); |
| 6576 |
|
|
| 6577 |
## Step 6 # MUST |
## Step 5 # MUST |
| 6578 |
push @{$p->{open_elements}}, [$root, 'html']; |
push @{$p->{open_elements}}, [$root, 'html']; |
| 6579 |
|
|
| 6580 |
undef $p->{head_element}; |
undef $p->{head_element}; |
| 6581 |
|
|
| 6582 |
## Step 7 # MUST |
## Step 6 # MUST |
| 6583 |
$p->_reset_insertion_mode; |
$p->_reset_insertion_mode; |
| 6584 |
|
|
| 6585 |
## Step 8 # MUST |
## Step 7 # MUST |
| 6586 |
my $anode = $node; |
my $anode = $node; |
| 6587 |
AN: while (defined $anode) { |
AN: while (defined $anode) { |
| 6588 |
if ($anode->node_type == 1) { |
if ($anode->node_type == 1) { |
| 6598 |
$anode = $anode->parent_node; |
$anode = $anode->parent_node; |
| 6599 |
} # AN |
} # AN |
| 6600 |
|
|
| 6601 |
## Step 3 # MUST |
## Step 9 # MUST |
|
## Step 10 # MUST |
|
| 6602 |
{ |
{ |
| 6603 |
my $self = $p; |
my $self = $p; |
| 6604 |
!!!next-token; |
!!!next-token; |
| 6605 |
} |
} |
| 6606 |
$p->_tree_construction_main; |
$p->_tree_construction_main; |
| 6607 |
|
|
| 6608 |
## Step 11 # MUST |
## Step 10 # MUST |
| 6609 |
my @cn = @{$node->child_nodes}; |
my @cn = @{$node->child_nodes}; |
| 6610 |
for (@cn) { |
for (@cn) { |
| 6611 |
$node->remove_child ($_); |
$node->remove_child ($_); |
| 6612 |
} |
} |
| 6613 |
## ISSUE: mutation events? read-only? |
## ISSUE: mutation events? read-only? |
| 6614 |
|
|
| 6615 |
## Step 12 # MUST |
## Step 11 # MUST |
| 6616 |
@cn = @{$root->child_nodes}; |
@cn = @{$root->child_nodes}; |
| 6617 |
for (@cn) { |
for (@cn) { |
| 6618 |
$this_doc->adopt_node ($_); |
$this_doc->adopt_node ($_); |