169 |
$node_ns = '' unless defined $node_ns; |
$node_ns = '' unless defined $node_ns; |
170 |
my $node_ln = $node->manakai_local_name; |
my $node_ln = $node->manakai_local_name; |
171 |
my $not_allowed = $self->{minuses}->{$node_ns}->{$node_ln}; |
my $not_allowed = $self->{minuses}->{$node_ns}->{$node_ln}; |
172 |
if ($node->manakai_element_type_match ($HTML_NS, 'style')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'style') { |
173 |
$not_allowed = 1 if $has_non_style; |
$not_allowed = 1 if $has_non_style; |
174 |
} elsif ($HTMLBlockLevelElements->{$node_ns}->{$node_ln}) { |
} elsif ($HTMLBlockLevelElements->{$node_ns}->{$node_ln}) { |
175 |
$has_non_style = 1; |
$has_non_style = 1; |
444 |
$node_ns = '' unless defined $node_ns; |
$node_ns = '' unless defined $node_ns; |
445 |
my $node_ln = $node->manakai_local_name; |
my $node_ln = $node->manakai_local_name; |
446 |
my $not_allowed = $self->{minuses}->{$node_ns}->{$node_ln}; |
my $not_allowed = $self->{minuses}->{$node_ns}->{$node_ln}; |
447 |
if ($node->manakai_element_type_match ($elnsuri, $ellname)) { |
if ($node_ns eq $elnsuri and $node_ln eq $ellname) { |
448 |
$not_allowed = 1 if $has_non_style; |
$not_allowed = 1 if $has_non_style; |
449 |
} elsif ($content eq 'block') { |
} elsif ($content eq 'block') { |
450 |
$has_non_style = 1; |
$has_non_style = 1; |
524 |
my $node_ln = $node->manakai_local_name; |
my $node_ln = $node->manakai_local_name; |
525 |
my $not_allowed = $self->{minuses}->{$node_ns}->{$node_ln}; |
my $not_allowed = $self->{minuses}->{$node_ns}->{$node_ln}; |
526 |
if ($phase eq 'before head') { |
if ($phase eq 'before head') { |
527 |
if ($node->manakai_element_type_match ($HTML_NS, 'head')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'head') { |
528 |
$phase = 'after head'; |
$phase = 'after head'; |
529 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'body')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'body') { |
530 |
$self->{onerror} |
$self->{onerror}->(node => $node, type => 'ps element missing:head'); |
|
->(node => $node, type => 'ps element missing:head'); |
|
531 |
$phase = 'after body'; |
$phase = 'after body'; |
532 |
} else { |
} else { |
533 |
$not_allowed = 1; |
$not_allowed = 1; |
534 |
# before head |
# before head |
535 |
} |
} |
536 |
} elsif ($phase eq 'after head') { |
} elsif ($phase eq 'after head') { |
537 |
if ($node->manakai_element_type_match ($HTML_NS, 'body')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'body') { |
538 |
$phase = 'after body'; |
$phase = 'after body'; |
539 |
} else { |
} else { |
540 |
$not_allowed = 1; |
$not_allowed = 1; |
588 |
$node_ns = '' unless defined $node_ns; |
$node_ns = '' unless defined $node_ns; |
589 |
my $node_ln = $node->manakai_local_name; |
my $node_ln = $node->manakai_local_name; |
590 |
my $not_allowed = $self->{minuses}->{$node_ns}->{$node_ln}; |
my $not_allowed = $self->{minuses}->{$node_ns}->{$node_ln}; |
591 |
if ($node->manakai_element_type_match ($HTML_NS, 'title')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'title') { |
592 |
$phase = 'after base'; |
$phase = 'after base'; |
593 |
unless ($has_title) { |
unless ($has_title) { |
594 |
$has_title = 1; |
$has_title = 1; |
595 |
} else { |
} else { |
596 |
$not_allowed = 1; |
$not_allowed = 1; |
597 |
} |
} |
598 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'meta')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'meta') { |
599 |
if ($node->has_attribute_ns (undef, 'charset')) { |
if ($node->has_attribute_ns (undef, 'charset')) { |
600 |
if ($phase eq 'initial') { |
if ($phase eq 'initial') { |
601 |
$phase = 'after charset'; |
$phase = 'after charset'; |
606 |
} else { |
} else { |
607 |
$phase = 'after base'; |
$phase = 'after base'; |
608 |
} |
} |
609 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'base')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'base') { |
610 |
if ($phase eq 'initial' or $phase eq 'after charset') { |
if ($phase eq 'initial' or $phase eq 'after charset') { |
611 |
$phase = 'after base'; |
$phase = 'after base'; |
612 |
} else { |
} else { |
826 |
|
|
827 |
my $nt = $node->node_type; |
my $nt = $node->node_type; |
828 |
if ($nt == 1) { |
if ($nt == 1) { |
829 |
|
my $node_ns = $node->namespace_uri; |
830 |
|
$node_ns = '' unless defined $node_ns; |
831 |
|
my $node_ln = $node->manakai_local_name; |
832 |
## NOTE: |minuses| list is not checked since redundant |
## NOTE: |minuses| list is not checked since redundant |
833 |
if ($phase eq 'before dt') { |
if ($phase eq 'before dt') { |
834 |
if ($node->manakai_element_type_match ($HTML_NS, 'dt')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'dt') { |
835 |
$phase = 'before dd'; |
$phase = 'before dd'; |
836 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'dd')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'dd') { |
837 |
$self->{onerror} |
$self->{onerror} |
838 |
->(node => $node, type => 'ps element missing:dt'); |
->(node => $node, type => 'ps element missing:dt'); |
839 |
$phase = 'before dt'; |
$phase = 'before dt'; |
841 |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
842 |
} |
} |
843 |
} else { # before dd |
} else { # before dd |
844 |
if ($node->manakai_element_type_match ($HTML_NS, 'dd')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'dd') { |
845 |
$phase = 'before dt'; |
$phase = 'before dt'; |
846 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'dt')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'dt') { |
847 |
$self->{onerror} |
$self->{onerror} |
848 |
->(node => $node, type => 'ps element missing:dd'); |
->(node => $node, type => 'ps element missing:dd'); |
849 |
$phase = 'before dd'; |
$phase = 'before dd'; |
886 |
|
|
887 |
my $nt = $node->node_type; |
my $nt = $node->node_type; |
888 |
if ($nt == 1) { |
if ($nt == 1) { |
889 |
|
my $node_ns = $node->namespace_uri; |
890 |
|
$node_ns = '' unless defined $node_ns; |
891 |
|
my $node_ln = $node->manakai_local_name; |
892 |
## NOTE: |minuses| list is not checked since redundant |
## NOTE: |minuses| list is not checked since redundant |
893 |
unless ($node->manakai_element_type_match ($HTML_NS, 'li')) { |
unless ($node_ns eq $HTML_NS and $node_ln eq 'li') { |
894 |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
895 |
} |
} |
896 |
my ($sib, $ch) = $self->_check_get_children ($node); |
my ($sib, $ch) = $self->_check_get_children ($node); |
944 |
|
|
945 |
my $nt = $node->node_type; |
my $nt = $node->node_type; |
946 |
if ($nt == 1) { |
if ($nt == 1) { |
947 |
|
my $node_ns = $node->namespace_uri; |
948 |
|
$node_ns = '' unless defined $node_ns; |
949 |
|
my $node_ln = $node->manakai_local_name; |
950 |
## NOTE: |minuses| list is not checked since redundant |
## NOTE: |minuses| list is not checked since redundant |
951 |
if ($phase eq 'in dds') { |
if ($phase eq 'in dds') { |
952 |
if ($node->manakai_element_type_match ($HTML_NS, 'dd')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'dd') { |
953 |
#$phase = 'in dds'; |
#$phase = 'in dds'; |
954 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'dt')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'dt') { |
955 |
$phase = 'in dts'; |
$phase = 'in dts'; |
956 |
} else { |
} else { |
957 |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
958 |
} |
} |
959 |
} elsif ($phase eq 'in dts') { |
} elsif ($phase eq 'in dts') { |
960 |
if ($node->manakai_element_type_match ($HTML_NS, 'dt')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'dt') { |
961 |
#$phase = 'in dts'; |
#$phase = 'in dts'; |
962 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'dd')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'dd') { |
963 |
$phase = 'in dds'; |
$phase = 'in dds'; |
964 |
} else { |
} else { |
965 |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
966 |
} |
} |
967 |
} else { # before dt |
} else { # before dt |
968 |
if ($node->manakai_element_type_match ($HTML_NS, 'dt')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'dt') { |
969 |
$phase = 'in dts'; |
$phase = 'in dts'; |
970 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'dd')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'dd') { |
971 |
$self->{onerror} |
$self->{onerror} |
972 |
->(node => $node, type => 'ps element missing:dt'); |
->(node => $node, type => 'ps element missing:dt'); |
973 |
$phase = 'in dds'; |
$phase = 'in dds'; |
1202 |
|
|
1203 |
my $nt = $node->node_type; |
my $nt = $node->node_type; |
1204 |
if ($nt == 1) { |
if ($nt == 1) { |
1205 |
|
my $node_ns = $node->namespace_uri; |
1206 |
|
$node_ns = '' unless defined $node_ns; |
1207 |
|
my $node_ln = $node->manakai_local_name; |
1208 |
## NOTE: |minuses| list is not checked since redundant |
## NOTE: |minuses| list is not checked since redundant |
1209 |
if ($phase eq 'in tbodys') { |
if ($phase eq 'in tbodys') { |
1210 |
if ($node->manakai_element_type_match ($HTML_NS, 'tbody')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'tbody') { |
1211 |
#$phase = 'in tbodys'; |
#$phase = 'in tbodys'; |
1212 |
} elsif (not $has_tfoot and |
} elsif (not $has_tfoot and |
1213 |
$node->manakai_element_type_match ($HTML_NS, 'tfoot')) { |
$node_ns eq $HTML_NS and $node_ln eq 'tfoot') { |
1214 |
$phase = 'after tfoot'; |
$phase = 'after tfoot'; |
1215 |
$has_tfoot = 1; |
$has_tfoot = 1; |
1216 |
} else { |
} else { |
1217 |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
1218 |
} |
} |
1219 |
} elsif ($phase eq 'in trs') { |
} elsif ($phase eq 'in trs') { |
1220 |
if ($node->manakai_element_type_match ($HTML_NS, 'tr')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'tr') { |
1221 |
#$phase = 'in trs'; |
#$phase = 'in trs'; |
1222 |
} elsif (not $has_tfoot and |
} elsif (not $has_tfoot and |
1223 |
$node->manakai_element_type_match ($HTML_NS, 'tfoot')) { |
$node_ns eq $HTML_NS and $node_ln eq 'tfoot') { |
1224 |
$phase = 'after tfoot'; |
$phase = 'after tfoot'; |
1225 |
$has_tfoot = 1; |
$has_tfoot = 1; |
1226 |
} else { |
} else { |
1227 |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
1228 |
} |
} |
1229 |
} elsif ($phase eq 'after thead') { |
} elsif ($phase eq 'after thead') { |
1230 |
if ($node->manakai_element_type_match ($HTML_NS, 'tbody')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'tbody') { |
1231 |
$phase = 'in tbodys'; |
$phase = 'in tbodys'; |
1232 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'tr')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'tr') { |
1233 |
$phase = 'in trs'; |
$phase = 'in trs'; |
1234 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'tfoot')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'tfoot') { |
1235 |
$phase = 'in tbodys'; |
$phase = 'in tbodys'; |
1236 |
$has_tfoot = 1; |
$has_tfoot = 1; |
1237 |
} else { |
} else { |
1238 |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
1239 |
} |
} |
1240 |
} elsif ($phase eq 'in colgroup') { |
} elsif ($phase eq 'in colgroup') { |
1241 |
if ($node->manakai_element_type_match ($HTML_NS, 'colgroup')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'colgroup') { |
1242 |
$phase = 'in colgroup'; |
$phase = 'in colgroup'; |
1243 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'thead')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'thead') { |
1244 |
$phase = 'after thead'; |
$phase = 'after thead'; |
1245 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'tbody')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'tbody') { |
1246 |
$phase = 'in tbodys'; |
$phase = 'in tbodys'; |
1247 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'tr')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'tr') { |
1248 |
$phase = 'in trs'; |
$phase = 'in trs'; |
1249 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'tfoot')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'tfoot') { |
1250 |
$phase = 'in tbodys'; |
$phase = 'in tbodys'; |
1251 |
$has_tfoot = 1; |
$has_tfoot = 1; |
1252 |
} else { |
} else { |
1253 |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
1254 |
} |
} |
1255 |
} elsif ($phase eq 'before caption') { |
} elsif ($phase eq 'before caption') { |
1256 |
if ($node->manakai_element_type_match ($HTML_NS, 'caption')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'caption') { |
1257 |
$phase = 'in colgroup'; |
$phase = 'in colgroup'; |
1258 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'colgroup')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'colgroup') { |
1259 |
$phase = 'in colgroup'; |
$phase = 'in colgroup'; |
1260 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'thead')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'thead') { |
1261 |
$phase = 'after thead'; |
$phase = 'after thead'; |
1262 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'tbody')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'tbody') { |
1263 |
$phase = 'in tbodys'; |
$phase = 'in tbodys'; |
1264 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'tr')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'tr') { |
1265 |
$phase = 'in trs'; |
$phase = 'in trs'; |
1266 |
} elsif ($node->manakai_element_type_match ($HTML_NS, 'tfoot')) { |
} elsif ($node_ns eq $HTML_NS and $node_ln eq 'tfoot') { |
1267 |
$phase = 'in tbodys'; |
$phase = 'in tbodys'; |
1268 |
$has_tfoot = 1; |
$has_tfoot = 1; |
1269 |
} else { |
} else { |
1304 |
|
|
1305 |
my $nt = $node->node_type; |
my $nt = $node->node_type; |
1306 |
if ($nt == 1) { |
if ($nt == 1) { |
1307 |
|
my $node_ns = $node->namespace_uri; |
1308 |
|
$node_ns = '' unless defined $node_ns; |
1309 |
|
my $node_ln = $node->manakai_local_name; |
1310 |
## NOTE: |minuses| list is not checked since redundant |
## NOTE: |minuses| list is not checked since redundant |
1311 |
unless ($node->manakai_element_type_match ($HTML_NS, 'col')) { |
unless ($node_ns eq $HTML_NS and $node_ln eq 'col') { |
1312 |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
1313 |
} |
} |
1314 |
my ($sib, $ch) = $self->_check_get_children ($node); |
my ($sib, $ch) = $self->_check_get_children ($node); |
1344 |
|
|
1345 |
my $nt = $node->node_type; |
my $nt = $node->node_type; |
1346 |
if ($nt == 1) { |
if ($nt == 1) { |
1347 |
|
my $node_ns = $node->namespace_uri; |
1348 |
|
$node_ns = '' unless defined $node_ns; |
1349 |
|
my $node_ln = $node->manakai_local_name; |
1350 |
## NOTE: |minuses| list is not checked since redundant |
## NOTE: |minuses| list is not checked since redundant |
1351 |
if ($node->manakai_element_type_match ($HTML_NS, 'tr')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'tr') { |
1352 |
$has_tr = 1; |
$has_tr = 1; |
1353 |
} else { |
} else { |
1354 |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
1393 |
|
|
1394 |
my $nt = $node->node_type; |
my $nt = $node->node_type; |
1395 |
if ($nt == 1) { |
if ($nt == 1) { |
1396 |
|
my $node_ns = $node->namespace_uri; |
1397 |
|
$node_ns = '' unless defined $node_ns; |
1398 |
|
my $node_ln = $node->manakai_local_name; |
1399 |
## NOTE: |minuses| list is not checked since redundant |
## NOTE: |minuses| list is not checked since redundant |
1400 |
if ($node->manakai_element_type_match ($HTML_NS, 'td') or |
if ($node_ns eq $HTML_NS and ($node_ln eq 'td' or $node_ln eq 'th')) { |
|
$node->manakai_element_type_match ($HTML_NS, 'th')) { |
|
1401 |
$has_td = 1; |
$has_td = 1; |
1402 |
} else { |
} else { |
1403 |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
$self->{onerror}->(node => $node, type => 'element not allowed'); |
1505 |
$node_ns = '' unless defined $node_ns; |
$node_ns = '' unless defined $node_ns; |
1506 |
my $node_ln = $node->manakai_local_name; |
my $node_ln = $node->manakai_local_name; |
1507 |
my $not_allowed = $self->{minuses}->{$node_ns}->{$node_ln}; |
my $not_allowed = $self->{minuses}->{$node_ns}->{$node_ln}; |
1508 |
if ($node->manakai_element_type_match ($HTML_NS, 'li')) { |
if ($node_ns eq $HTML_NS and $node_ln eq 'li') { |
1509 |
if ($content eq 'inline') { |
if ($content eq 'inline') { |
1510 |
$not_allowed = 1; |
$not_allowed = 1; |
1511 |
} elsif ($content eq 'li or inline') { |
} elsif ($content eq 'li or inline') { |
1651 |
unshift @$sib, @{$node->child_nodes}; |
unshift @$sib, @{$node->child_nodes}; |
1652 |
last TP; |
last TP; |
1653 |
} |
} |
1654 |
if ($node->manakai_element_type_match ($HTML_NS, 'video') or |
if ($node_ns eq $HTML_NS and ($node_ln eq 'video' or $node_ln eq 'audio')) { |
|
$node->manakai_element_type_match ($HTML_NS, 'audio')) { |
|
1655 |
if ($node->has_attribute_ns (undef, 'src')) { |
if ($node->has_attribute_ns (undef, 'src')) { |
1656 |
unshift @$sib, @{$node->child_nodes}; |
unshift @$sib, @{$node->child_nodes}; |
1657 |
last TP; |
last TP; |
1661 |
my $cn = shift @cn; |
my $cn = shift @cn; |
1662 |
my $cnt = $cn->node_type; |
my $cnt = $cn->node_type; |
1663 |
if ($cnt == 1) { |
if ($cnt == 1) { |
1664 |
if ($cn->manakai_element_type_match ($HTML_NS, 'source')) { |
my $cn_nsuri = $cn->namespace_uri; |
1665 |
|
$cn_nsuri = '' unless defined $cn_nsuri; |
1666 |
|
if ($cn_nsuri eq $HTML_NS and $cn->manakai_local_name eq 'source') { |
1667 |
# |
# |
1668 |
} else { |
} else { |
1669 |
last CN; |
last CN; |