1438 |
}; # $script_start_tag |
}; # $script_start_tag |
1439 |
|
|
1440 |
## NOTE: $open_tables->[-1]->[0] is the "current table" element node. |
## NOTE: $open_tables->[-1]->[0] is the "current table" element node. |
1441 |
## NOTE: $open_tables->[-1]->[1] is the "tainted" flag. |
## NOTE: $open_tables->[-1]->[1] is the "tainted" flag (OBSOLETE; unused). |
1442 |
## NOTE: $open_tables->[-1]->[2] is set false when non-Text node inserted. |
## NOTE: $open_tables->[-1]->[2] is set false when non-Text node inserted. |
1443 |
my $open_tables = [[$self->{open_elements}->[0]->[0]]]; |
my $open_tables = [[$self->{open_elements}->[0]->[0]]]; |
1444 |
|
|
3021 |
$insert = $insert_to_current; |
$insert = $insert_to_current; |
3022 |
# |
# |
3023 |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
} elsif ($self->{insertion_mode} & TABLE_IMS) { |
3024 |
if ($token->{type} == CHARACTER_TOKEN) { |
C: { |
3025 |
if (not $open_tables->[-1]->[1] and # tainted |
my $s; |
3026 |
$token->{data} =~ s/^([\x09\x0A\x0C\x20]+)//) { |
if ($token->{type} == CHARACTER_TOKEN) { |
3027 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($1); |
!!!cp ('t194'); |
3028 |
|
$self->{pending_chars} ||= []; |
3029 |
unless (length $token->{data}) { |
push @{$self->{pending_chars}}, $token; |
3030 |
!!!cp ('t194'); |
!!!next-token; |
3031 |
!!!next-token; |
next B; |
3032 |
next B; |
} else { |
3033 |
|
if ($self->{pending_chars}) { |
3034 |
|
$s = join '', map { $_->{data} } @{$self->{pending_chars}}; |
3035 |
|
delete $self->{pending_chars}; |
3036 |
|
if ($s =~ /[^\x09\x0A\x0C\x0D\x20]/) { |
3037 |
|
!!!cp ('t195'); |
3038 |
|
# |
3039 |
|
} else { |
3040 |
|
!!!cp ('t195.1'); |
3041 |
|
#$self->{open_elements}->[-1]->[0]->manakai_append_text ($s); |
3042 |
|
$self->{open_elements}->[-1]->[0]->append_child |
3043 |
|
($self->{document}->create_text_node ($s)); |
3044 |
|
last C; |
3045 |
|
} |
3046 |
} else { |
} else { |
3047 |
!!!cp ('t195'); |
!!!cp ('t195.2'); |
3048 |
|
last C; |
3049 |
} |
} |
3050 |
} |
} |
3051 |
|
|
3052 |
|
## Foster parenting |
3053 |
!!!parse-error (type => 'in table:#text', token => $token); |
!!!parse-error (type => 'in table:#text', token => $token); |
3054 |
|
|
3055 |
## NOTE: As if in body, but insert into the foster parent element. |
## NOTE: As if in body, but insert into the foster parent element. |
3059 |
# MUST |
# MUST |
3060 |
my $foster_parent_element; |
my $foster_parent_element; |
3061 |
my $next_sibling; |
my $next_sibling; |
3062 |
my $prev_sibling; |
#my $prev_sibling; |
3063 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
3064 |
if ($self->{open_elements}->[$_]->[1] == TABLE_EL) { |
if ($self->{open_elements}->[$_]->[1] == TABLE_EL) { |
3065 |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
3067 |
$foster_parent_element = $parent; |
$foster_parent_element = $parent; |
3068 |
!!!cp ('t196'); |
!!!cp ('t196'); |
3069 |
$next_sibling = $self->{open_elements}->[$_]->[0]; |
$next_sibling = $self->{open_elements}->[$_]->[0]; |
3070 |
$prev_sibling = $next_sibling->previous_sibling; |
# $prev_sibling = $next_sibling->previous_sibling; |
3071 |
# |
# |
3072 |
} else { |
} else { |
3073 |
!!!cp ('t197'); |
!!!cp ('t197'); |
3074 |
$foster_parent_element = $self->{open_elements}->[$_ - 1]->[0]; |
$foster_parent_element = $self->{open_elements}->[$_ - 1]->[0]; |
3075 |
$prev_sibling = $foster_parent_element->last_child; |
# $prev_sibling = $foster_parent_element->last_child; |
3076 |
# |
# |
3077 |
} |
} |
3078 |
last OE; |
last OE; |
3079 |
} |
} |
3080 |
} # OE |
} # OE |
3081 |
$foster_parent_element = $self->{open_elements}->[0]->[0] and |
$foster_parent_element = $self->{open_elements}->[0]->[0] #and |
3082 |
$prev_sibling = $foster_parent_element->last_child |
#$prev_sibling = $foster_parent_element->last_child |
3083 |
unless defined $foster_parent_element; |
unless defined $foster_parent_element; |
3084 |
undef $prev_sibling unless $open_tables->[-1]->[2]; # ~node inserted |
#undef $prev_sibling unless $open_tables->[-1]->[2]; # ~node inserted |
3085 |
if (defined $prev_sibling and |
#if (defined $prev_sibling and |
3086 |
$prev_sibling->node_type == 3) { |
# $prev_sibling->node_type == 3) { |
3087 |
!!!cp ('t198'); |
# !!! cp ('t198'); |
3088 |
$prev_sibling->manakai_append_text ($token->{data}); |
# $prev_sibling->manakai_append_text ($s); |
3089 |
} else { |
#} else { |
3090 |
!!!cp ('t199'); |
!!!cp ('t199'); |
3091 |
$foster_parent_element->insert_before |
$foster_parent_element->insert_before |
3092 |
($self->{document}->create_text_node ($token->{data}), |
($self->{document}->create_text_node ($s), $next_sibling); |
3093 |
$next_sibling); |
#} |
|
} |
|
3094 |
$open_tables->[-1]->[1] = 1; # tainted |
$open_tables->[-1]->[1] = 1; # tainted |
3095 |
$open_tables->[-1]->[2] = 1; # ~node inserted |
$open_tables->[-1]->[2] = 1; # ~node inserted |
3096 |
} else { |
} else { |
3101 |
## are discarded and fragment parsing does not invoke any |
## are discarded and fragment parsing does not invoke any |
3102 |
## script. |
## script. |
3103 |
!!!cp ('t200'); |
!!!cp ('t200'); |
3104 |
$self->{open_elements}->[-1]->[0]->manakai_append_text |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($s); |
|
($token->{data}); |
|
3105 |
} |
} |
3106 |
|
} # C |
3107 |
!!!next-token; |
|
3108 |
next B; |
if ($token->{type} == START_TAG_TOKEN) { |
|
} elsif ($token->{type} == START_TAG_TOKEN) { |
|
3109 |
if ({ |
if ({ |
3110 |
tr => (($self->{insertion_mode} & IM_MASK) != IN_ROW_IM), |
tr => (($self->{insertion_mode} & IM_MASK) != IN_ROW_IM), |
3111 |
th => 1, td => 1, |
th => 1, td => 1, |