| 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. |
## NOTE: "initial" and "before html" insertion modes have no constants. |
| 309 |
|
|
| 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 |
| 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}) { |
| 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 |
|
|
while ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!cp ('t75'); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
|
if (@{$self->{open_elements}} > 2 or |
|
|
(@{$self->{open_elements}} == 2 and $self->{open_elements}->[1]->[1] ne 'body')) { |
|
|
!!!cp ('t76'); |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} elsif (defined $self->{inner_html_node} and |
|
|
@{$self->{open_elements}} > 1 and |
|
|
$self->{open_elements}->[1]->[1] ne 'body') { |
|
|
## ISSUE: This case is never reached. |
|
|
!!!cp ('t77'); |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} else { |
|
|
!!!cp ('t78'); |
|
|
} |
|
|
|
|
|
## ISSUE: There is an issue in the spec. |
|
|
} |
|
|
|
|
|
## Stop parsing |
|
|
last B; |
|
| 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) { |
| 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) { |
| 3886 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 3887 |
if ($self->{insertion_mode} == IN_CELL_IM) { |
if ($self->{insertion_mode} == IN_CELL_IM) { |
| 3888 |
## have an element in table scope |
## have an element in table scope |
| 3889 |
my $tn; |
for (reverse 0..$#{$self->{open_elements}}) { |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
|
| 3890 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 3891 |
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
| 3892 |
!!!cp ('t151'); |
!!!cp ('t151'); |
| 3893 |
$tn = $node->[1]; |
|
| 3894 |
last INSCOPE; |
## Close the cell |
| 3895 |
|
!!!back-token; # <?> |
| 3896 |
|
$token = {type => END_TAG_TOKEN, tag_name => $node->[1]}; |
| 3897 |
|
redo B; |
| 3898 |
} elsif ({ |
} elsif ({ |
| 3899 |
table => 1, html => 1, |
table => 1, html => 1, |
| 3900 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 3901 |
!!!cp ('t152'); |
!!!cp ('t152'); |
| 3902 |
last INSCOPE; |
## ISSUE: This case can never be reached, maybe. |
| 3903 |
|
last; |
| 3904 |
} |
} |
| 3905 |
} # INSCOPE |
} |
| 3906 |
unless (defined $tn) { |
|
| 3907 |
!!!cp ('t153'); |
!!!cp ('t153'); |
| 3908 |
## TODO: This error type is wrong. |
!!!parse-error (type => 'start tag not allowed', |
| 3909 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
value => $token->{tag_name}); |
| 3910 |
## Ignore the token |
## Ignore the token |
| 3911 |
!!!next-token; |
!!!next-token; |
|
redo B; |
|
|
} |
|
|
|
|
|
!!!cp ('t154'); |
|
|
## Close the cell |
|
|
!!!back-token; # <?> |
|
|
$token = {type => END_TAG_TOKEN, tag_name => $tn}; |
|
| 3912 |
redo B; |
redo B; |
| 3913 |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
| 3914 |
!!!parse-error (type => 'not closed:caption'); |
!!!parse-error (type => 'not closed:caption'); |
| 3915 |
|
|
| 3916 |
## As if </caption> |
## NOTE: As if </caption>. |
| 3917 |
## have a table element in table scope |
## have a table element in table scope |
| 3918 |
my $i; |
my $i; |
| 3919 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: { |
| 3920 |
my $node = $self->{open_elements}->[$_]; |
for (reverse 0..$#{$self->{open_elements}}) { |
| 3921 |
if ($node->[1] eq 'caption') { |
my $node = $self->{open_elements}->[$_]; |
| 3922 |
!!!cp ('t155'); |
if ($node->[1] eq 'caption') { |
| 3923 |
$i = $_; |
!!!cp ('t155'); |
| 3924 |
last INSCOPE; |
$i = $_; |
| 3925 |
} elsif ({ |
last INSCOPE; |
| 3926 |
table => 1, html => 1, |
} elsif ({ |
| 3927 |
}->{$node->[1]}) { |
table => 1, html => 1, |
| 3928 |
!!!cp ('t156'); |
}->{$node->[1]}) { |
| 3929 |
last INSCOPE; |
!!!cp ('t156'); |
| 3930 |
|
last; |
| 3931 |
|
} |
| 3932 |
} |
} |
| 3933 |
|
|
| 3934 |
|
!!!cp ('t157'); |
| 3935 |
|
!!!parse-error (type => 'start tag not allowed', |
| 3936 |
|
value => $token->{tag_name}); |
| 3937 |
|
## Ignore the token |
| 3938 |
|
!!!next-token; |
| 3939 |
|
redo B; |
| 3940 |
} # INSCOPE |
} # INSCOPE |
|
unless (defined $i) { |
|
|
!!!cp ('t157'); |
|
|
## TODO: this type is wrong. |
|
|
!!!parse-error (type => 'unmatched end tag:caption'); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
| 3941 |
|
|
| 3942 |
## generate implied end tags |
## generate implied end tags |
| 3943 |
while ({ |
while ({ |
| 4033 |
if ($self->{insertion_mode} == IN_CAPTION_IM) { |
if ($self->{insertion_mode} == IN_CAPTION_IM) { |
| 4034 |
## have a table element in table scope |
## have a table element in table scope |
| 4035 |
my $i; |
my $i; |
| 4036 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: { |
| 4037 |
my $node = $self->{open_elements}->[$_]; |
for (reverse 0..$#{$self->{open_elements}}) { |
| 4038 |
if ($node->[1] eq $token->{tag_name}) { |
my $node = $self->{open_elements}->[$_]; |
| 4039 |
!!!cp ('t171'); |
if ($node->[1] eq $token->{tag_name}) { |
| 4040 |
$i = $_; |
!!!cp ('t171'); |
| 4041 |
last INSCOPE; |
$i = $_; |
| 4042 |
} elsif ({ |
last INSCOPE; |
| 4043 |
table => 1, html => 1, |
} elsif ({ |
| 4044 |
}->{$node->[1]}) { |
table => 1, html => 1, |
| 4045 |
!!!cp ('t172'); |
}->{$node->[1]}) { |
| 4046 |
last INSCOPE; |
!!!cp ('t172'); |
| 4047 |
|
last; |
| 4048 |
|
} |
| 4049 |
} |
} |
| 4050 |
|
|
| 4051 |
|
!!!cp ('t173'); |
| 4052 |
|
!!!parse-error (type => 'unmatched end tag', |
| 4053 |
|
value => $token->{tag_name}); |
| 4054 |
|
## Ignore the token |
| 4055 |
|
!!!next-token; |
| 4056 |
|
redo B; |
| 4057 |
} # INSCOPE |
} # INSCOPE |
|
unless (defined $i) { |
|
|
!!!cp ('t173'); |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} |
|
| 4058 |
|
|
| 4059 |
## generate implied end tags |
## generate implied end tags |
| 4060 |
while ({ |
while ({ |
| 4097 |
## have an element in table scope |
## have an element in table scope |
| 4098 |
my $i; |
my $i; |
| 4099 |
my $tn; |
my $tn; |
| 4100 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: { |
| 4101 |
my $node = $self->{open_elements}->[$_]; |
for (reverse 0..$#{$self->{open_elements}}) { |
| 4102 |
if ($node->[1] eq $token->{tag_name}) { |
my $node = $self->{open_elements}->[$_]; |
| 4103 |
!!!cp ('t179'); |
if ($node->[1] eq $token->{tag_name}) { |
| 4104 |
$i = $_; |
!!!cp ('t179'); |
| 4105 |
last INSCOPE; |
$i = $_; |
| 4106 |
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
|
| 4107 |
!!!cp ('t180'); |
## Close the cell |
| 4108 |
$tn = $node->[1]; |
!!!back-token; # </?> |
| 4109 |
## NOTE: There is exactly one |td| or |th| element |
$token = {type => END_TAG_TOKEN, tag_name => $tn}; |
| 4110 |
## in scope in the stack of open elements by definition. |
redo B; |
| 4111 |
} elsif ({ |
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
| 4112 |
table => 1, html => 1, |
!!!cp ('t180'); |
| 4113 |
}->{$node->[1]}) { |
$tn = $node->[1]; |
| 4114 |
!!!cp ('t181'); |
## NOTE: There is exactly one |td| or |th| element |
| 4115 |
last INSCOPE; |
## in scope in the stack of open elements by definition. |
| 4116 |
|
} elsif ({ |
| 4117 |
|
table => 1, html => 1, |
| 4118 |
|
}->{$node->[1]}) { |
| 4119 |
|
## ISSUE: Can this be reached? |
| 4120 |
|
!!!cp ('t181'); |
| 4121 |
|
last; |
| 4122 |
|
} |
| 4123 |
} |
} |
| 4124 |
} # INSCOPE |
|
|
unless (defined $i) { |
|
| 4125 |
!!!cp ('t182'); |
!!!cp ('t182'); |
| 4126 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag', |
| 4127 |
|
value => $token->{tag_name}); |
| 4128 |
## Ignore the token |
## Ignore the token |
| 4129 |
!!!next-token; |
!!!next-token; |
| 4130 |
redo B; |
redo B; |
| 4131 |
} else { |
} # INSCOPE |
|
!!!cp ('t183'); |
|
|
} |
|
|
|
|
|
## Close the cell |
|
|
!!!back-token; # </?> |
|
|
$token = {type => END_TAG_TOKEN, tag_name => $tn}; |
|
|
redo B; |
|
| 4132 |
} elsif ($token->{tag_name} eq 'table' and |
} elsif ($token->{tag_name} eq 'table' and |
| 4133 |
$self->{insertion_mode} == IN_CAPTION_IM) { |
$self->{insertion_mode} == IN_CAPTION_IM) { |
| 4134 |
!!!parse-error (type => 'not closed:caption'); |
!!!parse-error (type => 'not closed:caption'); |
| 4207 |
!!!cp ('t193'); |
!!!cp ('t193'); |
| 4208 |
# |
# |
| 4209 |
} |
} |
| 4210 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 4211 |
|
for my $entry (@{$self->{open_elements}}) { |
| 4212 |
|
if (not { |
| 4213 |
|
dd => 1, dt => 1, li => 1, p => 1, tbody => 1, td => 1, tfoot => 1, |
| 4214 |
|
th => 1, thead => 1, tr => 1, body => 1, html => 1, |
| 4215 |
|
}->{$entry->[1]}) { |
| 4216 |
|
!!!cp ('t75'); |
| 4217 |
|
!!!parse-error (type => 'in body:#eof'); |
| 4218 |
|
last; |
| 4219 |
|
} |
| 4220 |
|
} |
| 4221 |
|
|
| 4222 |
|
## Stop parsing. |
| 4223 |
|
last B; |
| 4224 |
} else { |
} else { |
| 4225 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 4226 |
} |
} |
| 4229 |
# |
# |
| 4230 |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
| 4231 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 4232 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if (not $open_tables->[-1]->[1] and # tainted |
| 4233 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
$token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4234 |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
| 4235 |
|
|
| 4236 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 4237 |
!!!cp ('t194'); |
!!!cp ('t194'); |
| 4238 |
!!!next-token; |
!!!next-token; |
| 4239 |
redo B; |
redo B; |
| 4240 |
} else { |
} else { |
| 4241 |
!!!cp ('t195'); |
!!!cp ('t195'); |
| 4242 |
} |
} |
| 4243 |
} |
} |
| 4244 |
|
|
| 4245 |
!!!parse-error (type => 'in table:#character'); |
!!!parse-error (type => 'in table:#character'); |
| 4246 |
|
|
| 4287 |
($self->{document}->create_text_node ($token->{data}), |
($self->{document}->create_text_node ($token->{data}), |
| 4288 |
$next_sibling); |
$next_sibling); |
| 4289 |
} |
} |
| 4290 |
} else { |
$open_tables->[-1]->[1] = 1; # tainted |
| 4291 |
!!!cp ('t200'); |
} else { |
| 4292 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
!!!cp ('t200'); |
| 4293 |
} |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 4294 |
|
} |
| 4295 |
|
|
| 4296 |
!!!next-token; |
!!!next-token; |
| 4297 |
redo B; |
redo B; |
| 4298 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 4299 |
if ({ |
if ({ |
| 4300 |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
| 4305 |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
| 4306 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4307 |
!!!cp ('t201'); |
!!!cp ('t201'); |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4308 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4309 |
} |
} |
| 4310 |
|
|
| 4325 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4326 |
!!!cp ('t203'); |
!!!cp ('t203'); |
| 4327 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4328 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4329 |
} |
} |
| 4330 |
|
|
| 4348 |
tr => 1, html => 1, |
tr => 1, html => 1, |
| 4349 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4350 |
!!!cp ('t207'); |
!!!cp ('t207'); |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4351 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4352 |
} |
} |
| 4353 |
|
|
| 4398 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4399 |
!!!cp ('t211'); |
!!!cp ('t211'); |
| 4400 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4401 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4402 |
} |
} |
| 4403 |
|
|
| 4446 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4447 |
!!!cp ('t217'); |
!!!cp ('t217'); |
| 4448 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4449 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4450 |
} |
} |
| 4451 |
|
|
| 4469 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4470 |
!!!cp ('t219'); |
!!!cp ('t219'); |
| 4471 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4472 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4473 |
} |
} |
| 4474 |
|
|
| 4486 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
$self->{open_elements}->[-1]->[1] ne 'html') { |
| 4487 |
!!!cp ('t220'); |
!!!cp ('t220'); |
| 4488 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4489 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4490 |
} |
} |
| 4491 |
|
|
| 4534 |
redo B; |
redo B; |
| 4535 |
} |
} |
| 4536 |
|
|
| 4537 |
|
## TODO: Followings are removed from the latest spec. |
| 4538 |
## generate implied end tags |
## generate implied end tags |
| 4539 |
while ({ |
while ({ |
| 4540 |
dd => 1, dt => 1, li => 1, p => 1, |
dd => 1, dt => 1, li => 1, p => 1, |
| 4552 |
} |
} |
| 4553 |
|
|
| 4554 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 4555 |
|
pop @{$open_tables}; |
| 4556 |
|
|
| 4557 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 4558 |
|
|
| 4559 |
## reprocess |
## reprocess |
| 4560 |
redo B; |
redo B; |
| 4561 |
|
} elsif ($token->{tag_name} eq 'style') { |
| 4562 |
|
if (not $open_tables->[-1]->[1]) { # tainted |
| 4563 |
|
!!!cp ('t227.8'); |
| 4564 |
|
## NOTE: This is a "as if in head" code clone. |
| 4565 |
|
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 4566 |
|
redo B; |
| 4567 |
|
} else { |
| 4568 |
|
!!!cp ('t227.7'); |
| 4569 |
|
# |
| 4570 |
|
} |
| 4571 |
|
} elsif ($token->{tag_name} eq 'script') { |
| 4572 |
|
if (not $open_tables->[-1]->[1]) { # tainted |
| 4573 |
|
!!!cp ('t227.6'); |
| 4574 |
|
## NOTE: This is a "as if in head" code clone. |
| 4575 |
|
$script_start_tag->(); |
| 4576 |
|
redo B; |
| 4577 |
|
} else { |
| 4578 |
|
!!!cp ('t227.5'); |
| 4579 |
|
# |
| 4580 |
|
} |
| 4581 |
|
} elsif ($token->{tag_name} eq 'input') { |
| 4582 |
|
if (not $open_tables->[-1]->[1]) { # tainted |
| 4583 |
|
if ($token->{attributes}->{type}) { ## TODO: case |
| 4584 |
|
my $type = lc $token->{attributes}->{type}->{value}; |
| 4585 |
|
if ($type eq 'hidden') { |
| 4586 |
|
!!!cp ('t227.3'); |
| 4587 |
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
| 4588 |
|
|
| 4589 |
|
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 4590 |
|
|
| 4591 |
|
## TODO: form element pointer |
| 4592 |
|
|
| 4593 |
|
pop @{$self->{open_elements}}; |
| 4594 |
|
|
| 4595 |
|
!!!next-token; |
| 4596 |
|
redo B; |
| 4597 |
|
} else { |
| 4598 |
|
!!!cp ('t227.2'); |
| 4599 |
|
# |
| 4600 |
|
} |
| 4601 |
|
} else { |
| 4602 |
|
!!!cp ('t227.1'); |
| 4603 |
|
# |
| 4604 |
|
} |
| 4605 |
|
} else { |
| 4606 |
|
!!!cp ('t227.4'); |
| 4607 |
|
# |
| 4608 |
|
} |
| 4609 |
} else { |
} else { |
| 4610 |
!!!cp ('t227'); |
!!!cp ('t227'); |
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
|
|
|
|
|
$insert = $insert_to_foster; |
|
| 4611 |
# |
# |
| 4612 |
} |
} |
| 4613 |
|
|
| 4614 |
|
!!!parse-error (type => 'in table:'.$token->{tag_name}); |
| 4615 |
|
|
| 4616 |
|
$insert = $insert_to_foster; |
| 4617 |
|
# |
| 4618 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 4619 |
if ($token->{tag_name} eq 'tr' and |
if ($token->{tag_name} eq 'tr' and |
| 4620 |
$self->{insertion_mode} == IN_ROW_IM) { |
$self->{insertion_mode} == IN_ROW_IM) { |
| 4649 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4650 |
!!!cp ('t231'); |
!!!cp ('t231'); |
| 4651 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4652 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4653 |
} |
} |
| 4654 |
|
|
| 4689 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4690 |
!!!cp ('t236'); |
!!!cp ('t236'); |
| 4691 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4692 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4693 |
} |
} |
| 4694 |
|
|
| 4728 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
| 4729 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4730 |
!!!cp ('t240'); |
!!!cp ('t240'); |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4731 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4732 |
} |
} |
| 4733 |
|
|
| 4743 |
## reprocess in the "in table" insertion mode... |
## reprocess in the "in table" insertion mode... |
| 4744 |
} |
} |
| 4745 |
|
|
| 4746 |
|
## NOTE: </table> in the "in table" insertion mode. |
| 4747 |
|
## When you edit the code fragment below, please ensure that |
| 4748 |
|
## the code for <table> in the "in table" insertion mode |
| 4749 |
|
## is synced with it. |
| 4750 |
|
|
| 4751 |
## have a table element in table scope |
## have a table element in table scope |
| 4752 |
my $i; |
my $i; |
| 4753 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4770 |
!!!next-token; |
!!!next-token; |
| 4771 |
redo B; |
redo B; |
| 4772 |
} |
} |
|
|
|
|
## generate implied end tags |
|
|
while ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!cp ('t244'); |
|
|
## ISSUE: Can this case be reached? |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
|
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
|
|
!!!cp ('t245'); |
|
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
|
} else { |
|
|
!!!cp ('t246'); |
|
|
} |
|
| 4773 |
|
|
| 4774 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 4775 |
|
pop @{$open_tables}; |
| 4776 |
|
|
| 4777 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 4778 |
|
|
| 4836 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4837 |
!!!cp ('t253'); |
!!!cp ('t253'); |
| 4838 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4839 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4840 |
} |
} |
| 4841 |
|
|
| 4873 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[1]}) { |
| 4874 |
!!!cp ('t257'); |
!!!cp ('t257'); |
| 4875 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
|
| 4876 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4877 |
} |
} |
| 4878 |
|
|
| 4898 |
$insert = $insert_to_foster; |
$insert = $insert_to_foster; |
| 4899 |
# |
# |
| 4900 |
} |
} |
| 4901 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 4902 |
|
unless ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 4903 |
|
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 4904 |
|
!!!parse-error (type => 'in body:#eof'); |
| 4905 |
|
!!!cp ('t259.1'); |
| 4906 |
|
# |
| 4907 |
|
} else { |
| 4908 |
|
!!!cp ('t259.2'); |
| 4909 |
|
# |
| 4910 |
|
} |
| 4911 |
|
|
| 4912 |
|
## Stop parsing |
| 4913 |
|
last B; |
| 4914 |
} else { |
} else { |
| 4915 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 4916 |
} |
} |
| 4963 |
!!!cp ('t267'); |
!!!cp ('t267'); |
| 4964 |
# |
# |
| 4965 |
} |
} |
| 4966 |
} else { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 4967 |
die "$0: $token->{type}: Unknown token type"; |
if ($self->{open_elements}->[-1]->[1] eq 'html' or |
| 4968 |
} |
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 4969 |
|
!!!cp ('t270.2'); |
| 4970 |
|
## Stop parsing. |
| 4971 |
|
last B; |
| 4972 |
|
} else { |
| 4973 |
|
## NOTE: As if </colgroup>. |
| 4974 |
|
!!!cp ('t270.1'); |
| 4975 |
|
pop @{$self->{open_elements}}; # colgroup |
| 4976 |
|
$self->{insertion_mode} = IN_TABLE_IM; |
| 4977 |
|
## Reprocess. |
| 4978 |
|
redo B; |
| 4979 |
|
} |
| 4980 |
|
} else { |
| 4981 |
|
die "$0: $token->{type}: Unknown token type"; |
| 4982 |
|
} |
| 4983 |
|
|
| 4984 |
## As if </colgroup> |
## As if </colgroup> |
| 4985 |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
| 4986 |
!!!cp ('t269'); |
!!!cp ('t269'); |
| 4987 |
|
## TODO: Wrong error type? |
| 4988 |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
!!!parse-error (type => 'unmatched end tag:colgroup'); |
| 4989 |
## Ignore the token |
## Ignore the token |
| 4990 |
!!!next-token; |
!!!next-token; |
| 4996 |
## reprocess |
## reprocess |
| 4997 |
redo B; |
redo B; |
| 4998 |
} |
} |
| 4999 |
} elsif ($self->{insertion_mode} == IN_SELECT_IM) { |
} elsif ($self->{insertion_mode} & SELECT_IMS) { |
| 5000 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 5001 |
!!!cp ('t271'); |
!!!cp ('t271'); |
| 5002 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 5035 |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
!!!insert-element ($token->{tag_name}, $token->{attributes}); |
| 5036 |
!!!next-token; |
!!!next-token; |
| 5037 |
redo B; |
redo B; |
| 5038 |
} elsif ($token->{tag_name} eq 'select') { |
} elsif ($token->{tag_name} eq 'select' or |
| 5039 |
## TODO: The type below is not good - <select> is replaced by </select> |
$token->{tag_name} eq 'input' or |
| 5040 |
!!!parse-error (type => 'not closed:select'); |
($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
| 5041 |
## As if </select> instead |
{ |
| 5042 |
|
caption => 1, table => 1, |
| 5043 |
|
tbody => 1, tfoot => 1, thead => 1, |
| 5044 |
|
tr => 1, td => 1, th => 1, |
| 5045 |
|
}->{$token->{tag_name}})) { |
| 5046 |
|
## TODO: The type below is not good - <select> is replaced by </select> |
| 5047 |
|
!!!parse-error (type => 'not closed:select'); |
| 5048 |
|
## NOTE: As if the token were </select> (<select> case) or |
| 5049 |
|
## as if there were </select> (otherwise). |
| 5050 |
## have an element in table scope |
## have an element in table scope |
| 5051 |
my $i; |
my $i; |
| 5052 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5053 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5054 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq 'select') { |
| 5055 |
!!!cp ('t278'); |
!!!cp ('t278'); |
| 5056 |
$i = $_; |
$i = $_; |
| 5057 |
last INSCOPE; |
last INSCOPE; |
| 5075 |
|
|
| 5076 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 5077 |
|
|
| 5078 |
!!!next-token; |
if ($token->{tag_name} eq 'select') { |
| 5079 |
redo B; |
!!!cp ('t281.2'); |
| 5080 |
|
!!!next-token; |
| 5081 |
|
redo B; |
| 5082 |
|
} else { |
| 5083 |
|
!!!cp ('t281.1'); |
| 5084 |
|
## Reprocess the token. |
| 5085 |
|
redo B; |
| 5086 |
|
} |
| 5087 |
} else { |
} else { |
| 5088 |
!!!cp ('t282'); |
!!!cp ('t282'); |
| 5089 |
!!!parse-error (type => 'in select:'.$token->{tag_name}); |
!!!parse-error (type => 'in select:'.$token->{tag_name}); |
| 5150 |
|
|
| 5151 |
!!!next-token; |
!!!next-token; |
| 5152 |
redo B; |
redo B; |
| 5153 |
} elsif ({ |
} elsif ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
| 5154 |
caption => 1, table => 1, tbody => 1, |
{ |
| 5155 |
tfoot => 1, thead => 1, tr => 1, td => 1, th => 1, |
caption => 1, table => 1, tbody => 1, |
| 5156 |
}->{$token->{tag_name}}) { |
tfoot => 1, thead => 1, tr => 1, td => 1, th => 1, |
| 5157 |
|
}->{$token->{tag_name}}) { |
| 5158 |
## TODO: The following is wrong? |
## TODO: The following is wrong? |
| 5159 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 5160 |
|
|
| 5220 |
!!!next-token; |
!!!next-token; |
| 5221 |
redo B; |
redo B; |
| 5222 |
} |
} |
| 5223 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5224 |
|
unless ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 5225 |
|
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 5226 |
|
!!!cp ('t299.1'); |
| 5227 |
|
!!!parse-error (type => 'in body:#eof'); |
| 5228 |
|
} else { |
| 5229 |
|
!!!cp ('t299.2'); |
| 5230 |
|
} |
| 5231 |
|
|
| 5232 |
|
## Stop parsing. |
| 5233 |
|
last B; |
| 5234 |
} else { |
} else { |
| 5235 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 5236 |
} |
} |
| 5314 |
## reprocess |
## reprocess |
| 5315 |
redo B; |
redo B; |
| 5316 |
} |
} |
| 5317 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5318 |
|
!!!cp ('t309.2'); |
| 5319 |
|
## Stop parsing |
| 5320 |
|
last B; |
| 5321 |
} else { |
} else { |
| 5322 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 5323 |
} |
} |
| 5388 |
} elsif ($token->{tag_name} eq 'noframes') { |
} elsif ($token->{tag_name} eq 'noframes') { |
| 5389 |
!!!cp ('t320'); |
!!!cp ('t320'); |
| 5390 |
## NOTE: As if in body. |
## NOTE: As if in body. |
| 5391 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert_to_current); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5392 |
redo B; |
redo B; |
| 5393 |
} else { |
} else { |
| 5394 |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
| 5453 |
!!!next-token; |
!!!next-token; |
| 5454 |
redo B; |
redo B; |
| 5455 |
} |
} |
| 5456 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5457 |
|
unless ($self->{open_elements}->[-1]->[1] eq 'html' and |
| 5458 |
|
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 5459 |
|
!!!cp ('t331.1'); |
| 5460 |
|
!!!parse-error (type => 'in body:#eof'); |
| 5461 |
|
} else { |
| 5462 |
|
!!!cp ('t331.2'); |
| 5463 |
|
} |
| 5464 |
|
|
| 5465 |
|
## Stop parsing |
| 5466 |
|
last B; |
| 5467 |
} else { |
} else { |
| 5468 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 5469 |
} |
} |
| 5478 |
if ($token->{tag_name} eq 'script') { |
if ($token->{tag_name} eq 'script') { |
| 5479 |
!!!cp ('t332'); |
!!!cp ('t332'); |
| 5480 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 5481 |
$script_start_tag->($insert); |
$script_start_tag->(); |
| 5482 |
redo B; |
redo B; |
| 5483 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 5484 |
!!!cp ('t333'); |
!!!cp ('t333'); |
| 5485 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 5486 |
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5487 |
redo B; |
redo B; |
| 5488 |
} elsif ({ |
} elsif ({ |
| 5489 |
base => 1, link => 1, |
base => 1, link => 1, |
| 5546 |
redo B; |
redo B; |
| 5547 |
} elsif ($token->{tag_name} eq 'title') { |
} elsif ($token->{tag_name} eq 'title') { |
| 5548 |
!!!cp ('t341'); |
!!!cp ('t341'); |
|
!!!parse-error (type => 'in body:title'); |
|
| 5549 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 5550 |
$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]); |
|
|
} |
|
|
}); |
|
| 5551 |
redo B; |
redo B; |
| 5552 |
} elsif ($token->{tag_name} eq 'body') { |
} elsif ($token->{tag_name} eq 'body') { |
| 5553 |
!!!parse-error (type => 'in body:body'); |
!!!parse-error (type => 'in body:body'); |
| 5573 |
address => 1, blockquote => 1, center => 1, dir => 1, |
address => 1, blockquote => 1, center => 1, dir => 1, |
| 5574 |
div => 1, dl => 1, fieldset => 1, |
div => 1, dl => 1, fieldset => 1, |
| 5575 |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
| 5576 |
listing => 1, menu => 1, ol => 1, p => 1, ul => 1, |
menu => 1, ol => 1, p => 1, ul => 1, |
| 5577 |
pre => 1, |
pre => 1, listing => 1, |
| 5578 |
|
form => 1, |
| 5579 |
|
table => 1, |
| 5580 |
|
hr => 1, |
| 5581 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5582 |
|
if ($token->{tag_name} eq 'form' and defined $self->{form_element}) { |
| 5583 |
|
!!!cp ('t350'); |
| 5584 |
|
!!!parse-error (type => 'in form:form'); |
| 5585 |
|
## Ignore the token |
| 5586 |
|
!!!next-token; |
| 5587 |
|
redo B; |
| 5588 |
|
} |
| 5589 |
|
|
| 5590 |
## has a p element in scope |
## has a p element in scope |
| 5591 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 5592 |
if ($_->[1] eq 'p') { |
if ($_->[1] eq 'p') { |
| 5595 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
| 5596 |
redo B; |
redo B; |
| 5597 |
} elsif ({ |
} elsif ({ |
| 5598 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5599 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5600 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5601 |
!!!cp ('t345'); |
!!!cp ('t345'); |
| 5604 |
} # INSCOPE |
} # INSCOPE |
| 5605 |
|
|
| 5606 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 5607 |
if ($token->{tag_name} eq 'pre') { |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
| 5608 |
!!!next-token; |
!!!next-token; |
| 5609 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 5610 |
$token->{data} =~ s/^\x0A//; |
$token->{data} =~ s/^\x0A//; |
| 5617 |
} else { |
} else { |
| 5618 |
!!!cp ('t348'); |
!!!cp ('t348'); |
| 5619 |
} |
} |
| 5620 |
} else { |
} elsif ($token->{tag_name} eq 'form') { |
| 5621 |
!!!cp ('t347'); |
!!!cp ('t347.1'); |
| 5622 |
|
$self->{form_element} = $self->{open_elements}->[-1]->[0]; |
| 5623 |
|
|
| 5624 |
!!!next-token; |
!!!next-token; |
| 5625 |
} |
} elsif ($token->{tag_name} eq 'table') { |
| 5626 |
redo B; |
!!!cp ('t382'); |
| 5627 |
} elsif ($token->{tag_name} eq 'form') { |
push @{$open_tables}, [$self->{open_elements}->[-1]->[0]]; |
| 5628 |
if (defined $self->{form_element}) { |
|
| 5629 |
!!!cp ('t350'); |
$self->{insertion_mode} = IN_TABLE_IM; |
| 5630 |
!!!parse-error (type => 'in form:form'); |
|
| 5631 |
## Ignore the token |
!!!next-token; |
| 5632 |
|
} elsif ($token->{tag_name} eq 'hr') { |
| 5633 |
|
!!!cp ('t386'); |
| 5634 |
|
pop @{$self->{open_elements}}; |
| 5635 |
|
|
| 5636 |
!!!next-token; |
!!!next-token; |
|
redo B; |
|
| 5637 |
} else { |
} else { |
| 5638 |
## has a p element in scope |
!!!cp ('t347'); |
|
INSCOPE: for (reverse @{$self->{open_elements}}) { |
|
|
if ($_->[1] eq 'p') { |
|
|
!!!cp ('t351'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$_->[1]}) { |
|
|
!!!cp ('t352'); |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
$self->{form_element} = $self->{open_elements}->[-1]->[0]; |
|
| 5639 |
!!!next-token; |
!!!next-token; |
|
redo B; |
|
| 5640 |
} |
} |
| 5641 |
} elsif ($token->{tag_name} eq 'li') { |
redo B; |
| 5642 |
|
} elsif ({li => 1, dt => 1, dd => 1}->{$token->{tag_name}}) { |
| 5643 |
## has a p element in scope |
## has a p element in scope |
| 5644 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 5645 |
if ($_->[1] eq 'p') { |
if ($_->[1] eq 'p') { |
| 5648 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
| 5649 |
redo B; |
redo B; |
| 5650 |
} elsif ({ |
} elsif ({ |
| 5651 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5652 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5653 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5654 |
!!!cp ('t354'); |
!!!cp ('t354'); |
| 5659 |
## Step 1 |
## Step 1 |
| 5660 |
my $i = -1; |
my $i = -1; |
| 5661 |
my $node = $self->{open_elements}->[$i]; |
my $node = $self->{open_elements}->[$i]; |
| 5662 |
|
my $li_or_dtdd = {li => {li => 1}, |
| 5663 |
|
dt => {dt => 1, dd => 1}, |
| 5664 |
|
dd => {dt => 1, dd => 1}}->{$token->{tag_name}}; |
| 5665 |
LI: { |
LI: { |
| 5666 |
## Step 2 |
## Step 2 |
| 5667 |
if ($node->[1] eq 'li') { |
if ($li_or_dtdd->{$node->[1]}) { |
| 5668 |
if ($i != -1) { |
if ($i != -1) { |
| 5669 |
!!!cp ('t355'); |
!!!cp ('t355'); |
| 5670 |
!!!parse-error (type => 'end tag missing:'. |
!!!parse-error (type => 'end tag missing:'. |
| 5698 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 5699 |
!!!next-token; |
!!!next-token; |
| 5700 |
redo B; |
redo B; |
|
} elsif ($token->{tag_name} eq 'dd' or $token->{tag_name} eq 'dt') { |
|
|
## has a p element in scope |
|
|
INSCOPE: for (reverse @{$self->{open_elements}}) { |
|
|
if ($_->[1] eq 'p') { |
|
|
!!!cp ('t360'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$_->[1]}) { |
|
|
!!!cp ('t361'); |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
|
|
|
## Step 1 |
|
|
my $i = -1; |
|
|
my $node = $self->{open_elements}->[$i]; |
|
|
LI: { |
|
|
## Step 2 |
|
|
if ($node->[1] eq 'dt' or $node->[1] eq 'dd') { |
|
|
if ($i != -1) { |
|
|
!!!cp ('t362'); |
|
|
!!!parse-error (type => 'end tag missing:'. |
|
|
$self->{open_elements}->[-1]->[1]); |
|
|
} else { |
|
|
!!!cp ('t363'); |
|
|
} |
|
|
splice @{$self->{open_elements}}, $i; |
|
|
last LI; |
|
|
} else { |
|
|
!!!cp ('t364'); |
|
|
} |
|
|
|
|
|
## Step 3 |
|
|
if (not $formatting_category->{$node->[1]} and |
|
|
#not $phrasing_category->{$node->[1]} and |
|
|
($special_category->{$node->[1]} or |
|
|
$scoping_category->{$node->[1]}) and |
|
|
$node->[1] ne 'address' and $node->[1] ne 'div') { |
|
|
!!!cp ('t365'); |
|
|
last LI; |
|
|
} |
|
|
|
|
|
!!!cp ('t366'); |
|
|
## Step 4 |
|
|
$i--; |
|
|
$node = $self->{open_elements}->[$i]; |
|
|
redo LI; |
|
|
} # LI |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
!!!next-token; |
|
|
redo B; |
|
| 5701 |
} elsif ($token->{tag_name} eq 'plaintext') { |
} elsif ($token->{tag_name} eq 'plaintext') { |
| 5702 |
## has a p element in scope |
## has a p element in scope |
| 5703 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 5707 |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
| 5708 |
redo B; |
redo B; |
| 5709 |
} elsif ({ |
} elsif ({ |
| 5710 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5711 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5712 |
}->{$_->[1]}) { |
}->{$_->[1]}) { |
| 5713 |
!!!cp ('t368'); |
!!!cp ('t368'); |
| 5760 |
|
|
| 5761 |
!!!next-token; |
!!!next-token; |
| 5762 |
redo B; |
redo B; |
|
} elsif ({ |
|
|
b => 1, big => 1, em => 1, font => 1, i => 1, |
|
|
s => 1, small => 1, strile => 1, |
|
|
strong => 1, tt => 1, u => 1, |
|
|
}->{$token->{tag_name}}) { |
|
|
!!!cp ('t375'); |
|
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
| 5763 |
} elsif ($token->{tag_name} eq 'nobr') { |
} elsif ($token->{tag_name} eq 'nobr') { |
| 5764 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 5765 |
|
|
| 5773 |
$token = {type => END_TAG_TOKEN, tag_name => 'nobr'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'nobr'}; |
| 5774 |
redo B; |
redo B; |
| 5775 |
} elsif ({ |
} elsif ({ |
| 5776 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5777 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5778 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 5779 |
!!!cp ('t377'); |
!!!cp ('t377'); |
| 5797 |
$token = {type => END_TAG_TOKEN, tag_name => 'button'}; |
$token = {type => END_TAG_TOKEN, tag_name => 'button'}; |
| 5798 |
redo B; |
redo B; |
| 5799 |
} elsif ({ |
} elsif ({ |
| 5800 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 5801 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 5802 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 5803 |
!!!cp ('t379'); |
!!!cp ('t379'); |
| 5815 |
|
|
| 5816 |
!!!next-token; |
!!!next-token; |
| 5817 |
redo B; |
redo B; |
|
} elsif ($token->{tag_name} eq 'marquee' or |
|
|
$token->{tag_name} eq 'object') { |
|
|
!!!cp ('t380'); |
|
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
push @$active_formatting_elements, ['#marker', '']; |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'xmp') { |
|
|
!!!cp ('t381'); |
|
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'table') { |
|
|
## has a p element in scope |
|
|
INSCOPE: for (reverse @{$self->{open_elements}}) { |
|
|
if ($_->[1] eq 'p') { |
|
|
!!!cp ('t382'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$_->[1]}) { |
|
|
!!!cp ('t383'); |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
|
|
|
$self->{insertion_mode} = IN_TABLE_IM; |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
| 5818 |
} elsif ({ |
} elsif ({ |
| 5819 |
area => 1, basefont => 1, bgsound => 1, br => 1, |
xmp => 1, |
| 5820 |
embed => 1, img => 1, param => 1, spacer => 1, wbr => 1, |
iframe => 1, |
| 5821 |
image => 1, |
noembed => 1, |
| 5822 |
|
noframes => 1, |
| 5823 |
|
noscript => 0, ## TODO: 1 if scripting is enabled |
| 5824 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5825 |
if ($token->{tag_name} eq 'image') { |
if ($token->{tag_name} eq 'xmp') { |
| 5826 |
!!!cp ('t384'); |
!!!cp ('t381'); |
| 5827 |
!!!parse-error (type => 'image'); |
$reconstruct_active_formatting_elements->($insert_to_current); |
|
$token->{tag_name} = 'img'; |
|
| 5828 |
} else { |
} else { |
| 5829 |
!!!cp ('t385'); |
!!!cp ('t399'); |
| 5830 |
} |
} |
| 5831 |
|
## NOTE: There is an "as if in body" code clone. |
| 5832 |
## NOTE: There is an "as if <br>" code clone. |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
pop @{$self->{open_elements}}; |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'hr') { |
|
|
## has a p element in scope |
|
|
INSCOPE: for (reverse @{$self->{open_elements}}) { |
|
|
if ($_->[1] eq 'p') { |
|
|
!!!cp ('t386'); |
|
|
!!!back-token; |
|
|
$token = {type => END_TAG_TOKEN, tag_name => 'p'}; |
|
|
redo B; |
|
|
} elsif ({ |
|
|
table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$_->[1]}) { |
|
|
!!!cp ('t387'); |
|
|
last INSCOPE; |
|
|
} |
|
|
} # INSCOPE |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
pop @{$self->{open_elements}}; |
|
|
|
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'input') { |
|
|
!!!cp ('t388'); |
|
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
## TODO: associate with $self->{form_element} if defined |
|
|
pop @{$self->{open_elements}}; |
|
|
|
|
|
!!!next-token; |
|
| 5833 |
redo B; |
redo B; |
| 5834 |
} elsif ($token->{tag_name} eq 'isindex') { |
} elsif ($token->{tag_name} eq 'isindex') { |
| 5835 |
!!!parse-error (type => 'isindex'); |
!!!parse-error (type => 'isindex'); |
| 5921 |
!!!next-token; |
!!!next-token; |
| 5922 |
redo B; |
redo B; |
| 5923 |
} elsif ({ |
} elsif ({ |
|
iframe => 1, |
|
|
noembed => 1, |
|
|
noframes => 1, |
|
|
noscript => 0, ## TODO: 1 if scripting is enabled |
|
|
}->{$token->{tag_name}}) { |
|
|
!!!cp ('t399'); |
|
|
## NOTE: There is an "as if in body" code clone. |
|
|
$parse_rcdata->(CDATA_CONTENT_MODEL, $insert); |
|
|
redo B; |
|
|
} elsif ($token->{tag_name} eq 'select') { |
|
|
!!!cp ('t400'); |
|
|
$reconstruct_active_formatting_elements->($insert_to_current); |
|
|
|
|
|
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
|
|
|
|
|
## TODO: associate with $self->{form_element} if defined |
|
|
|
|
|
$self->{insertion_mode} = IN_SELECT_IM; |
|
|
!!!next-token; |
|
|
redo B; |
|
|
} elsif ({ |
|
| 5924 |
caption => 1, col => 1, colgroup => 1, frame => 1, |
caption => 1, col => 1, colgroup => 1, frame => 1, |
| 5925 |
frameset => 1, head => 1, option => 1, optgroup => 1, |
frameset => 1, head => 1, option => 1, optgroup => 1, |
| 5926 |
tbody => 1, td => 1, tfoot => 1, th => 1, |
tbody => 1, td => 1, tfoot => 1, th => 1, |
| 5934 |
|
|
| 5935 |
## ISSUE: An issue on HTML5 new elements in the spec. |
## ISSUE: An issue on HTML5 new elements in the spec. |
| 5936 |
} else { |
} else { |
| 5937 |
!!!cp ('t402'); |
if ($token->{tag_name} eq 'image') { |
| 5938 |
|
!!!cp ('t384'); |
| 5939 |
|
!!!parse-error (type => 'image'); |
| 5940 |
|
$token->{tag_name} = 'img'; |
| 5941 |
|
} else { |
| 5942 |
|
!!!cp ('t385'); |
| 5943 |
|
} |
| 5944 |
|
|
| 5945 |
|
## NOTE: There is an "as if <br>" code clone. |
| 5946 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 5947 |
|
|
| 5948 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}); |
| 5949 |
|
|
| 5950 |
|
if ({ |
| 5951 |
|
applet => 1, marquee => 1, object => 1, |
| 5952 |
|
}->{$token->{tag_name}}) { |
| 5953 |
|
!!!cp ('t380'); |
| 5954 |
|
push @$active_formatting_elements, ['#marker', '']; |
| 5955 |
|
} elsif ({ |
| 5956 |
|
b => 1, big => 1, em => 1, font => 1, i => 1, |
| 5957 |
|
s => 1, small => 1, strile => 1, |
| 5958 |
|
strong => 1, tt => 1, u => 1, |
| 5959 |
|
}->{$token->{tag_name}}) { |
| 5960 |
|
!!!cp ('t375'); |
| 5961 |
|
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
| 5962 |
|
} elsif ($token->{tag_name} eq 'input') { |
| 5963 |
|
!!!cp ('t388'); |
| 5964 |
|
## TODO: associate with $self->{form_element} if defined |
| 5965 |
|
pop @{$self->{open_elements}}; |
| 5966 |
|
} elsif ({ |
| 5967 |
|
area => 1, basefont => 1, bgsound => 1, br => 1, |
| 5968 |
|
embed => 1, img => 1, param => 1, spacer => 1, wbr => 1, |
| 5969 |
|
#image => 1, |
| 5970 |
|
}->{$token->{tag_name}}) { |
| 5971 |
|
!!!cp ('t388.1'); |
| 5972 |
|
pop @{$self->{open_elements}}; |
| 5973 |
|
} elsif ($token->{tag_name} eq 'select') { |
| 5974 |
|
## TODO: associate with $self->{form_element} if defined |
| 5975 |
|
|
| 5976 |
|
if ($self->{insertion_mode} & TABLE_IMS or |
| 5977 |
|
$self->{insertion_mode} & BODY_TABLE_IMS or |
| 5978 |
|
$self->{insertion_mode} == IN_COLUMN_GROUP_IM) { |
| 5979 |
|
!!!cp ('t400.1'); |
| 5980 |
|
$self->{insertion_mode} = IN_SELECT_IN_TABLE_IM; |
| 5981 |
|
} else { |
| 5982 |
|
!!!cp ('t400.2'); |
| 5983 |
|
$self->{insertion_mode} = IN_SELECT_IM; |
| 5984 |
|
} |
| 5985 |
|
} else { |
| 5986 |
|
!!!cp ('t402'); |
| 5987 |
|
} |
| 5988 |
|
|
| 5989 |
!!!next-token; |
!!!next-token; |
| 5990 |
redo B; |
redo B; |
| 5991 |
} |
} |
| 5992 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 5993 |
if ($token->{tag_name} eq 'body') { |
if ($token->{tag_name} eq 'body') { |
| 5994 |
if (@{$self->{open_elements}} > 1 and |
## has a |body| element in scope |
| 5995 |
$self->{open_elements}->[1]->[1] eq 'body') { |
my $i; |
| 5996 |
for (@{$self->{open_elements}}) { |
INSCOPE: { |
| 5997 |
unless ({ |
for (reverse @{$self->{open_elements}}) { |
| 5998 |
dd => 1, dt => 1, li => 1, p => 1, td => 1, |
if ($_->[1] eq 'body') { |
| 5999 |
th => 1, tr => 1, body => 1, html => 1, |
!!!cp ('t405'); |
| 6000 |
tbody => 1, tfoot => 1, thead => 1, |
$i = $_; |
| 6001 |
}->{$_->[1]}) { |
last INSCOPE; |
| 6002 |
!!!cp ('t403'); |
} elsif ({ |
| 6003 |
!!!parse-error (type => 'not closed:'.$_->[1]); |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6004 |
} else { |
button => 1, marquee => 1, object => 1, html => 1, |
| 6005 |
!!!cp ('t404'); |
}->{$_->[1]}) { |
| 6006 |
|
!!!cp ('t405.1'); |
| 6007 |
|
last; |
| 6008 |
} |
} |
| 6009 |
} |
} |
| 6010 |
|
|
| 6011 |
$self->{insertion_mode} = AFTER_BODY_IM; |
!!!parse-error (type => 'start tag not allowed', |
| 6012 |
!!!next-token; |
value => $token->{tag_name}); |
| 6013 |
redo B; |
## NOTE: Ignore the token. |
|
} else { |
|
|
!!!cp ('t405'); |
|
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
|
## Ignore the token |
|
| 6014 |
!!!next-token; |
!!!next-token; |
| 6015 |
redo B; |
redo B; |
| 6016 |
|
} # INSCOPE |
| 6017 |
|
|
| 6018 |
|
for (@{$self->{open_elements}}) { |
| 6019 |
|
unless ({ |
| 6020 |
|
dd => 1, dt => 1, li => 1, p => 1, td => 1, |
| 6021 |
|
th => 1, tr => 1, body => 1, html => 1, |
| 6022 |
|
tbody => 1, tfoot => 1, thead => 1, |
| 6023 |
|
}->{$_->[1]}) { |
| 6024 |
|
!!!cp ('t403'); |
| 6025 |
|
!!!parse-error (type => 'not closed:'.$_->[1]); |
| 6026 |
|
last; |
| 6027 |
|
} else { |
| 6028 |
|
!!!cp ('t404'); |
| 6029 |
|
} |
| 6030 |
} |
} |
| 6031 |
|
|
| 6032 |
|
$self->{insertion_mode} = AFTER_BODY_IM; |
| 6033 |
|
!!!next-token; |
| 6034 |
|
redo B; |
| 6035 |
} elsif ($token->{tag_name} eq 'html') { |
} elsif ($token->{tag_name} eq 'html') { |
| 6036 |
if (@{$self->{open_elements}} > 1 and $self->{open_elements}->[1]->[1] eq 'body') { |
if (@{$self->{open_elements}} > 1 and $self->{open_elements}->[1]->[1] eq 'body') { |
| 6037 |
## ISSUE: There is an issue in the spec. |
## ISSUE: There is an issue in the spec. |
| 6055 |
address => 1, blockquote => 1, center => 1, dir => 1, |
address => 1, blockquote => 1, center => 1, dir => 1, |
| 6056 |
div => 1, dl => 1, fieldset => 1, listing => 1, |
div => 1, dl => 1, fieldset => 1, listing => 1, |
| 6057 |
menu => 1, ol => 1, pre => 1, ul => 1, |
menu => 1, ol => 1, pre => 1, ul => 1, |
|
p => 1, |
|
| 6058 |
dd => 1, dt => 1, li => 1, |
dd => 1, dt => 1, li => 1, |
| 6059 |
button => 1, marquee => 1, object => 1, |
applet => 1, button => 1, marquee => 1, object => 1, |
| 6060 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6061 |
## has an element in scope |
## has an element in scope |
| 6062 |
my $i; |
my $i; |
| 6063 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6064 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 6065 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq $token->{tag_name}) { |
|
## generate implied end tags |
|
|
while ({ |
|
|
dd => ($token->{tag_name} ne 'dd'), |
|
|
dt => ($token->{tag_name} ne 'dt'), |
|
|
li => ($token->{tag_name} ne 'li'), |
|
|
p => ($token->{tag_name} ne 'p'), |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!cp ('t409'); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
| 6066 |
!!!cp ('t410'); |
!!!cp ('t410'); |
| 6067 |
$i = $_; |
$i = $_; |
| 6068 |
last INSCOPE unless $token->{tag_name} eq 'p'; |
last INSCOPE; |
| 6069 |
} elsif ({ |
} elsif ({ |
| 6070 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6071 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 6072 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 6073 |
!!!cp ('t411'); |
!!!cp ('t411'); |
| 6074 |
last INSCOPE; |
last INSCOPE; |
| 6075 |
} |
} |
| 6076 |
} # INSCOPE |
} # INSCOPE |
| 6077 |
|
|
| 6078 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
unless (defined $i) { # has an element in scope |
| 6079 |
if (defined $i) { |
!!!cp ('t413'); |
| 6080 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 6081 |
|
} else { |
| 6082 |
|
## Step 1. generate implied end tags |
| 6083 |
|
while ({ |
| 6084 |
|
dd => ($token->{tag_name} ne 'dd'), |
| 6085 |
|
dt => ($token->{tag_name} ne 'dt'), |
| 6086 |
|
li => ($token->{tag_name} ne 'li'), |
| 6087 |
|
p => 1, |
| 6088 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 6089 |
|
!!!cp ('t409'); |
| 6090 |
|
pop @{$self->{open_elements}}; |
| 6091 |
|
} |
| 6092 |
|
|
| 6093 |
|
## Step 2. |
| 6094 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6095 |
!!!cp ('t412'); |
!!!cp ('t412'); |
| 6096 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 6097 |
} else { |
} else { |
| 6098 |
!!!cp ('t413'); |
!!!cp ('t414'); |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
|
| 6099 |
} |
} |
| 6100 |
} |
|
| 6101 |
|
## Step 3. |
|
if (defined $i) { |
|
|
!!!cp ('t414'); |
|
| 6102 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 6103 |
} elsif ($token->{tag_name} eq 'p') { |
|
| 6104 |
!!!cp ('t415'); |
## Step 4. |
| 6105 |
## As if <p>, then reprocess the current token |
$clear_up_to_marker->() |
| 6106 |
my $el; |
if { |
| 6107 |
!!!create-element ($el, 'p'); |
applet => 1, button => 1, marquee => 1, object => 1, |
| 6108 |
$insert->($el); |
}->{$token->{tag_name}}; |
|
} else { |
|
|
!!!cp ('t416'); |
|
| 6109 |
} |
} |
|
$clear_up_to_marker->() |
|
|
if { |
|
|
button => 1, marquee => 1, object => 1, |
|
|
}->{$token->{tag_name}}; |
|
| 6110 |
!!!next-token; |
!!!next-token; |
| 6111 |
redo B; |
redo B; |
| 6112 |
} elsif ($token->{tag_name} eq 'form') { |
} elsif ($token->{tag_name} eq 'form') { |
| 6113 |
|
undef $self->{form_element}; |
| 6114 |
|
|
| 6115 |
## has an element in scope |
## has an element in scope |
| 6116 |
|
my $i; |
| 6117 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6118 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 6119 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] eq $token->{tag_name}) { |
|
## generate implied end tags |
|
|
while ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!cp ('t417'); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
| 6120 |
!!!cp ('t418'); |
!!!cp ('t418'); |
| 6121 |
|
$i = $_; |
| 6122 |
last INSCOPE; |
last INSCOPE; |
| 6123 |
} elsif ({ |
} elsif ({ |
| 6124 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6125 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 6126 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 6127 |
!!!cp ('t419'); |
!!!cp ('t419'); |
| 6128 |
last INSCOPE; |
last INSCOPE; |
| 6129 |
} |
} |
| 6130 |
} # INSCOPE |
} # INSCOPE |
| 6131 |
|
|
| 6132 |
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 { |
|
| 6133 |
!!!cp ('t421'); |
!!!cp ('t421'); |
| 6134 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 6135 |
|
} else { |
| 6136 |
|
## Step 1. generate implied end tags |
| 6137 |
|
while ({ |
| 6138 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 6139 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 6140 |
|
!!!cp ('t417'); |
| 6141 |
|
pop @{$self->{open_elements}}; |
| 6142 |
|
} |
| 6143 |
|
|
| 6144 |
|
## Step 2. |
| 6145 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6146 |
|
!!!cp ('t417.1'); |
| 6147 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 6148 |
|
} else { |
| 6149 |
|
!!!cp ('t420'); |
| 6150 |
|
} |
| 6151 |
|
|
| 6152 |
|
## Step 3. |
| 6153 |
|
splice @{$self->{open_elements}}, $i; |
| 6154 |
} |
} |
| 6155 |
|
|
|
undef $self->{form_element}; |
|
| 6156 |
!!!next-token; |
!!!next-token; |
| 6157 |
redo B; |
redo B; |
| 6158 |
} elsif ({ |
} elsif ({ |
| 6165 |
if ({ |
if ({ |
| 6166 |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
| 6167 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
|
## generate implied end tags |
|
|
while ({ |
|
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
|
!!!cp ('t422'); |
|
|
pop @{$self->{open_elements}}; |
|
|
} |
|
|
|
|
| 6168 |
!!!cp ('t423'); |
!!!cp ('t423'); |
| 6169 |
$i = $_; |
$i = $_; |
| 6170 |
last INSCOPE; |
last INSCOPE; |
| 6171 |
} elsif ({ |
} elsif ({ |
| 6172 |
table => 1, caption => 1, td => 1, th => 1, |
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6173 |
button => 1, marquee => 1, object => 1, html => 1, |
button => 1, marquee => 1, object => 1, html => 1, |
| 6174 |
}->{$node->[1]}) { |
}->{$node->[1]}) { |
| 6175 |
!!!cp ('t424'); |
!!!cp ('t424'); |
| 6176 |
last INSCOPE; |
last INSCOPE; |
| 6177 |
} |
} |
| 6178 |
} # INSCOPE |
} # INSCOPE |
| 6179 |
|
|
| 6180 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
unless (defined $i) { # has an element in scope |
| 6181 |
!!!cp ('t425'); |
!!!cp ('t425.1'); |
| 6182 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 6183 |
} else { |
} else { |
| 6184 |
!!!cp ('t426'); |
## Step 1. generate implied end tags |
| 6185 |
|
while ({ |
| 6186 |
|
dd => 1, dt => 1, li => 1, p => 1, |
| 6187 |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
| 6188 |
|
!!!cp ('t422'); |
| 6189 |
|
pop @{$self->{open_elements}}; |
| 6190 |
|
} |
| 6191 |
|
|
| 6192 |
|
## Step 2. |
| 6193 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6194 |
|
!!!cp ('t425'); |
| 6195 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 6196 |
|
} else { |
| 6197 |
|
!!!cp ('t426'); |
| 6198 |
|
} |
| 6199 |
|
|
| 6200 |
|
## Step 3. |
| 6201 |
|
splice @{$self->{open_elements}}, $i; |
| 6202 |
} |
} |
| 6203 |
|
|
| 6204 |
splice @{$self->{open_elements}}, $i if defined $i; |
!!!next-token; |
| 6205 |
|
redo B; |
| 6206 |
|
} elsif ($token->{tag_name} eq 'p') { |
| 6207 |
|
## has an element in scope |
| 6208 |
|
my $i; |
| 6209 |
|
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6210 |
|
my $node = $self->{open_elements}->[$_]; |
| 6211 |
|
if ($node->[1] eq $token->{tag_name}) { |
| 6212 |
|
!!!cp ('t410.1'); |
| 6213 |
|
$i = $_; |
| 6214 |
|
last INSCOPE; |
| 6215 |
|
} elsif ({ |
| 6216 |
|
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
| 6217 |
|
button => 1, marquee => 1, object => 1, html => 1, |
| 6218 |
|
}->{$node->[1]}) { |
| 6219 |
|
!!!cp ('t411.1'); |
| 6220 |
|
last INSCOPE; |
| 6221 |
|
} |
| 6222 |
|
} # INSCOPE |
| 6223 |
|
|
| 6224 |
|
if (defined $i) { |
| 6225 |
|
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
| 6226 |
|
!!!cp ('t412.1'); |
| 6227 |
|
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1]); |
| 6228 |
|
} else { |
| 6229 |
|
!!!cp ('t414.1'); |
| 6230 |
|
} |
| 6231 |
|
|
| 6232 |
|
splice @{$self->{open_elements}}, $i; |
| 6233 |
|
} else { |
| 6234 |
|
!!!cp ('t413.1'); |
| 6235 |
|
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}); |
| 6236 |
|
|
| 6237 |
|
!!!cp ('t415.1'); |
| 6238 |
|
## As if <p>, then reprocess the current token |
| 6239 |
|
my $el; |
| 6240 |
|
!!!create-element ($el, 'p'); |
| 6241 |
|
$insert->($el); |
| 6242 |
|
## NOTE: Not inserted into |$self->{open_elements}|. |
| 6243 |
|
} |
| 6244 |
|
|
| 6245 |
!!!next-token; |
!!!next-token; |
| 6246 |
redo B; |
redo B; |
| 6247 |
} elsif ({ |
} elsif ({ |