| 8 |
## doc.write (''); |
## doc.write (''); |
| 9 |
## alert (doc.compatMode); |
## alert (doc.compatMode); |
| 10 |
|
|
|
## TODO: Control charcters and noncharacters are not allowed (HTML5 revision 1263) |
|
| 11 |
## TODO: 1252 parse error (revision 1264) |
## TODO: 1252 parse error (revision 1264) |
| 12 |
## TODO: 8859-11 = 874 (revision 1271) |
## TODO: 8859-11 = 874 (revision 1271) |
| 13 |
|
|
| 14 |
my $permitted_slash_tag_name = { |
my $HTML_NS = q<http://www.w3.org/1999/xhtml>; |
| 15 |
base => 1, |
my $MML_NS = q<http://www.w3.org/1998/Math/MathML>; |
| 16 |
link => 1, |
my $SVG_NS = q<http://www.w3.org/2000/svg>; |
| 17 |
meta => 1, |
my $XLINK_NS = q<http://www.w3.org/1999/xlink>; |
| 18 |
hr => 1, |
my $XML_NS = q<http://www.w3.org/XML/1998/namespace>; |
| 19 |
br => 1, |
my $XMLNS_NS = q<http://www.w3.org/2000/xmlns/>; |
| 20 |
img => 1, |
|
| 21 |
embed => 1, |
sub A_EL () { 0b1 } |
| 22 |
param => 1, |
sub ADDRESS_EL () { 0b10 } |
| 23 |
area => 1, |
sub BODY_EL () { 0b100 } |
| 24 |
col => 1, |
sub BUTTON_EL () { 0b1000 } |
| 25 |
input => 1, |
sub CAPTION_EL () { 0b10000 } |
| 26 |
|
sub DD_EL () { 0b100000 } |
| 27 |
|
sub DIV_EL () { 0b1000000 } |
| 28 |
|
sub DT_EL () { 0b10000000 } |
| 29 |
|
sub FORM_EL () { 0b100000000 } |
| 30 |
|
sub FORMATTING_EL () { 0b1000000000 } |
| 31 |
|
sub FRAMESET_EL () { 0b10000000000 } |
| 32 |
|
sub HEADING_EL () { 0b100000000000 } |
| 33 |
|
sub HTML_EL () { 0b1000000000000 } |
| 34 |
|
sub LI_EL () { 0b10000000000000 } |
| 35 |
|
sub NOBR_EL () { 0b100000000000000 } |
| 36 |
|
sub OPTION_EL () { 0b1000000000000000 } |
| 37 |
|
sub OPTGROUP_EL () { 0b10000000000000000 } |
| 38 |
|
sub P_EL () { 0b100000000000000000 } |
| 39 |
|
sub SELECT_EL () { 0b1000000000000000000 } |
| 40 |
|
sub TABLE_EL () { 0b10000000000000000000 } |
| 41 |
|
sub TABLE_CELL_EL () { 0b100000000000000000000 } |
| 42 |
|
sub TABLE_ROW_EL () { 0b1000000000000000000000 } |
| 43 |
|
sub TABLE_ROW_GROUP_EL () { 0b10000000000000000000000 } |
| 44 |
|
sub MISC_SCOPING_EL () { 0b100000000000000000000000 } |
| 45 |
|
sub MISC_SPECIAL_EL () { 0b1000000000000000000000000 } |
| 46 |
|
sub FOREIGN_EL () { 0b10000000000000000000000000 } |
| 47 |
|
sub FOREIGN_FLOW_CONTENT_EL () { 0b100000000000000000000000000 } |
| 48 |
|
sub MML_AXML_EL () { 0b1000000000000000000000000000 } |
| 49 |
|
|
| 50 |
|
sub TABLE_ROWS_EL () { |
| 51 |
|
TABLE_EL | |
| 52 |
|
TABLE_ROW_EL | |
| 53 |
|
TABLE_ROW_GROUP_EL |
| 54 |
|
} |
| 55 |
|
|
| 56 |
|
sub END_TAG_OPTIONAL_EL () { |
| 57 |
|
DD_EL | |
| 58 |
|
DT_EL | |
| 59 |
|
LI_EL | |
| 60 |
|
P_EL |
| 61 |
|
} |
| 62 |
|
|
| 63 |
|
sub ALL_END_TAG_OPTIONAL_EL () { |
| 64 |
|
END_TAG_OPTIONAL_EL | |
| 65 |
|
BODY_EL | |
| 66 |
|
HTML_EL | |
| 67 |
|
TABLE_CELL_EL | |
| 68 |
|
TABLE_ROW_EL | |
| 69 |
|
TABLE_ROW_GROUP_EL |
| 70 |
|
} |
| 71 |
|
|
| 72 |
|
sub SCOPING_EL () { |
| 73 |
|
BUTTON_EL | |
| 74 |
|
CAPTION_EL | |
| 75 |
|
HTML_EL | |
| 76 |
|
TABLE_EL | |
| 77 |
|
TABLE_CELL_EL | |
| 78 |
|
MISC_SCOPING_EL |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
sub TABLE_SCOPING_EL () { |
| 82 |
|
HTML_EL | |
| 83 |
|
TABLE_EL |
| 84 |
|
} |
| 85 |
|
|
| 86 |
|
sub TABLE_ROWS_SCOPING_EL () { |
| 87 |
|
HTML_EL | |
| 88 |
|
TABLE_ROW_GROUP_EL |
| 89 |
|
} |
| 90 |
|
|
| 91 |
|
sub TABLE_ROW_SCOPING_EL () { |
| 92 |
|
HTML_EL | |
| 93 |
|
TABLE_ROW_EL |
| 94 |
|
} |
| 95 |
|
|
| 96 |
|
sub SPECIAL_EL () { |
| 97 |
|
ADDRESS_EL | |
| 98 |
|
BODY_EL | |
| 99 |
|
DIV_EL | |
| 100 |
|
END_TAG_OPTIONAL_EL | |
| 101 |
|
FORM_EL | |
| 102 |
|
FRAMESET_EL | |
| 103 |
|
HEADING_EL | |
| 104 |
|
OPTION_EL | |
| 105 |
|
OPTGROUP_EL | |
| 106 |
|
SELECT_EL | |
| 107 |
|
TABLE_ROW_EL | |
| 108 |
|
TABLE_ROW_GROUP_EL | |
| 109 |
|
MISC_SPECIAL_EL |
| 110 |
|
} |
| 111 |
|
|
| 112 |
|
my $el_category = { |
| 113 |
|
a => A_EL | FORMATTING_EL, |
| 114 |
|
address => ADDRESS_EL, |
| 115 |
|
applet => MISC_SCOPING_EL, |
| 116 |
|
area => MISC_SPECIAL_EL, |
| 117 |
|
b => FORMATTING_EL, |
| 118 |
|
base => MISC_SPECIAL_EL, |
| 119 |
|
basefont => MISC_SPECIAL_EL, |
| 120 |
|
bgsound => MISC_SPECIAL_EL, |
| 121 |
|
big => FORMATTING_EL, |
| 122 |
|
blockquote => MISC_SPECIAL_EL, |
| 123 |
|
body => BODY_EL, |
| 124 |
|
br => MISC_SPECIAL_EL, |
| 125 |
|
button => BUTTON_EL, |
| 126 |
|
caption => CAPTION_EL, |
| 127 |
|
center => MISC_SPECIAL_EL, |
| 128 |
|
col => MISC_SPECIAL_EL, |
| 129 |
|
colgroup => MISC_SPECIAL_EL, |
| 130 |
|
dd => DD_EL, |
| 131 |
|
dir => MISC_SPECIAL_EL, |
| 132 |
|
div => DIV_EL, |
| 133 |
|
dl => MISC_SPECIAL_EL, |
| 134 |
|
dt => DT_EL, |
| 135 |
|
em => FORMATTING_EL, |
| 136 |
|
embed => MISC_SPECIAL_EL, |
| 137 |
|
fieldset => MISC_SPECIAL_EL, |
| 138 |
|
font => FORMATTING_EL, |
| 139 |
|
form => FORM_EL, |
| 140 |
|
frame => MISC_SPECIAL_EL, |
| 141 |
|
frameset => FRAMESET_EL, |
| 142 |
|
h1 => HEADING_EL, |
| 143 |
|
h2 => HEADING_EL, |
| 144 |
|
h3 => HEADING_EL, |
| 145 |
|
h4 => HEADING_EL, |
| 146 |
|
h5 => HEADING_EL, |
| 147 |
|
h6 => HEADING_EL, |
| 148 |
|
head => MISC_SPECIAL_EL, |
| 149 |
|
hr => MISC_SPECIAL_EL, |
| 150 |
|
html => HTML_EL, |
| 151 |
|
i => FORMATTING_EL, |
| 152 |
|
iframe => MISC_SPECIAL_EL, |
| 153 |
|
img => MISC_SPECIAL_EL, |
| 154 |
|
input => MISC_SPECIAL_EL, |
| 155 |
|
isindex => MISC_SPECIAL_EL, |
| 156 |
|
li => LI_EL, |
| 157 |
|
link => MISC_SPECIAL_EL, |
| 158 |
|
listing => MISC_SPECIAL_EL, |
| 159 |
|
marquee => MISC_SCOPING_EL, |
| 160 |
|
menu => MISC_SPECIAL_EL, |
| 161 |
|
meta => MISC_SPECIAL_EL, |
| 162 |
|
nobr => NOBR_EL | FORMATTING_EL, |
| 163 |
|
noembed => MISC_SPECIAL_EL, |
| 164 |
|
noframes => MISC_SPECIAL_EL, |
| 165 |
|
noscript => MISC_SPECIAL_EL, |
| 166 |
|
object => MISC_SCOPING_EL, |
| 167 |
|
ol => MISC_SPECIAL_EL, |
| 168 |
|
optgroup => OPTGROUP_EL, |
| 169 |
|
option => OPTION_EL, |
| 170 |
|
p => P_EL, |
| 171 |
|
param => MISC_SPECIAL_EL, |
| 172 |
|
plaintext => MISC_SPECIAL_EL, |
| 173 |
|
pre => MISC_SPECIAL_EL, |
| 174 |
|
s => FORMATTING_EL, |
| 175 |
|
script => MISC_SPECIAL_EL, |
| 176 |
|
select => SELECT_EL, |
| 177 |
|
small => FORMATTING_EL, |
| 178 |
|
spacer => MISC_SPECIAL_EL, |
| 179 |
|
strike => FORMATTING_EL, |
| 180 |
|
strong => FORMATTING_EL, |
| 181 |
|
style => MISC_SPECIAL_EL, |
| 182 |
|
table => TABLE_EL, |
| 183 |
|
tbody => TABLE_ROW_GROUP_EL, |
| 184 |
|
td => TABLE_CELL_EL, |
| 185 |
|
textarea => MISC_SPECIAL_EL, |
| 186 |
|
tfoot => TABLE_ROW_GROUP_EL, |
| 187 |
|
th => TABLE_CELL_EL, |
| 188 |
|
thead => TABLE_ROW_GROUP_EL, |
| 189 |
|
title => MISC_SPECIAL_EL, |
| 190 |
|
tr => TABLE_ROW_EL, |
| 191 |
|
tt => FORMATTING_EL, |
| 192 |
|
u => FORMATTING_EL, |
| 193 |
|
ul => MISC_SPECIAL_EL, |
| 194 |
|
wbr => MISC_SPECIAL_EL, |
| 195 |
}; |
}; |
| 196 |
|
|
| 197 |
|
my $el_category_f = { |
| 198 |
|
$MML_NS => { |
| 199 |
|
'annotation-xml' => MML_AXML_EL, |
| 200 |
|
mi => FOREIGN_FLOW_CONTENT_EL, |
| 201 |
|
mo => FOREIGN_FLOW_CONTENT_EL, |
| 202 |
|
mn => FOREIGN_FLOW_CONTENT_EL, |
| 203 |
|
ms => FOREIGN_FLOW_CONTENT_EL, |
| 204 |
|
mtext => FOREIGN_FLOW_CONTENT_EL, |
| 205 |
|
}, |
| 206 |
|
$SVG_NS => { |
| 207 |
|
foreignObject => FOREIGN_FLOW_CONTENT_EL, |
| 208 |
|
desc => FOREIGN_FLOW_CONTENT_EL, |
| 209 |
|
title => FOREIGN_FLOW_CONTENT_EL, |
| 210 |
|
}, |
| 211 |
|
## NOTE: In addition, FOREIGN_EL is set to non-HTML elements. |
| 212 |
|
}; |
| 213 |
|
|
| 214 |
|
my $svg_attr_name = { |
| 215 |
|
attributetype => 'attributeType', |
| 216 |
|
basefrequency => 'baseFrequency', |
| 217 |
|
baseprofile => 'baseProfile', |
| 218 |
|
calcmode => 'calcMode', |
| 219 |
|
clippathunits => 'clipPathUnits', |
| 220 |
|
contentscripttype => 'contentScriptType', |
| 221 |
|
contentstyletype => 'contentStyleType', |
| 222 |
|
diffuseconstant => 'diffuseConstant', |
| 223 |
|
edgemode => 'edgeMode', |
| 224 |
|
externalresourcesrequired => 'externalResourcesRequired', |
| 225 |
|
fecolormatrix => 'feColorMatrix', |
| 226 |
|
fecomposite => 'feComposite', |
| 227 |
|
fegaussianblur => 'feGaussianBlur', |
| 228 |
|
femorphology => 'feMorphology', |
| 229 |
|
fetile => 'feTile', |
| 230 |
|
filterres => 'filterRes', |
| 231 |
|
filterunits => 'filterUnits', |
| 232 |
|
glyphref => 'glyphRef', |
| 233 |
|
gradienttransform => 'gradientTransform', |
| 234 |
|
gradientunits => 'gradientUnits', |
| 235 |
|
kernelmatrix => 'kernelMatrix', |
| 236 |
|
kernelunitlength => 'kernelUnitLength', |
| 237 |
|
keypoints => 'keyPoints', |
| 238 |
|
keysplines => 'keySplines', |
| 239 |
|
keytimes => 'keyTimes', |
| 240 |
|
lengthadjust => 'lengthAdjust', |
| 241 |
|
limitingconeangle => 'limitingConeAngle', |
| 242 |
|
markerheight => 'markerHeight', |
| 243 |
|
markerunits => 'markerUnits', |
| 244 |
|
markerwidth => 'markerWidth', |
| 245 |
|
maskcontentunits => 'maskContentUnits', |
| 246 |
|
maskunits => 'maskUnits', |
| 247 |
|
numoctaves => 'numOctaves', |
| 248 |
|
pathlength => 'pathLength', |
| 249 |
|
patterncontentunits => 'patternContentUnits', |
| 250 |
|
patterntransform => 'patternTransform', |
| 251 |
|
patternunits => 'patternUnits', |
| 252 |
|
pointsatx => 'pointsAtX', |
| 253 |
|
pointsaty => 'pointsAtY', |
| 254 |
|
pointsatz => 'pointsAtZ', |
| 255 |
|
preservealpha => 'preserveAlpha', |
| 256 |
|
preserveaspectratio => 'preserveAspectRatio', |
| 257 |
|
primitiveunits => 'primitiveUnits', |
| 258 |
|
refx => 'refX', |
| 259 |
|
refy => 'refY', |
| 260 |
|
repeatcount => 'repeatCount', |
| 261 |
|
repeatdur => 'repeatDur', |
| 262 |
|
requiredextensions => 'requiredExtensions', |
| 263 |
|
specularconstant => 'specularConstant', |
| 264 |
|
specularexponent => 'specularExponent', |
| 265 |
|
spreadmethod => 'spreadMethod', |
| 266 |
|
startoffset => 'startOffset', |
| 267 |
|
stddeviation => 'stdDeviation', |
| 268 |
|
stitchtiles => 'stitchTiles', |
| 269 |
|
surfacescale => 'surfaceScale', |
| 270 |
|
systemlanguage => 'systemLanguage', |
| 271 |
|
tablevalues => 'tableValues', |
| 272 |
|
targetx => 'targetX', |
| 273 |
|
targety => 'targetY', |
| 274 |
|
textlength => 'textLength', |
| 275 |
|
viewbox => 'viewBox', |
| 276 |
|
viewtarget => 'viewTarget', |
| 277 |
|
xchannelselector => 'xChannelSelector', |
| 278 |
|
ychannelselector => 'yChannelSelector', |
| 279 |
|
zoomandpan => 'zoomAndPan', |
| 280 |
|
}; |
| 281 |
|
|
| 282 |
|
my $foreign_attr_xname = { |
| 283 |
|
'xlink:actuate' => [$XLINK_NS, ['xlink', 'actuate']], |
| 284 |
|
'xlink:arcrole' => [$XLINK_NS, ['xlink', 'arcrole']], |
| 285 |
|
'xlink:href' => [$XLINK_NS, ['xlink', 'href']], |
| 286 |
|
'xlink:role' => [$XLINK_NS, ['xlink', 'role']], |
| 287 |
|
'xlink:show' => [$XLINK_NS, ['xlink', 'show']], |
| 288 |
|
'xlink:title' => [$XLINK_NS, ['xlink', 'title']], |
| 289 |
|
'xlink:type' => [$XLINK_NS, ['xlink', 'type']], |
| 290 |
|
'xml:base' => [$XML_NS, ['xml', 'base']], |
| 291 |
|
'xml:lang' => [$XML_NS, ['xml', 'lang']], |
| 292 |
|
'xml:space' => [$XML_NS, ['xml', 'space']], |
| 293 |
|
'xmlns' => [$XMLNS_NS, [undef, 'xmlns']], |
| 294 |
|
'xmlns:xlink' => [$XMLNS_NS, ['xmlns', 'xlink']], |
| 295 |
|
}; |
| 296 |
|
|
| 297 |
|
## ISSUE: xmlns:xlink="non-xlink-ns" is not an error. |
| 298 |
|
|
| 299 |
my $c1_entity_char = { |
my $c1_entity_char = { |
| 300 |
0x80 => 0x20AC, |
0x80 => 0x20AC, |
| 301 |
0x81 => 0xFFFD, |
0x81 => 0xFFFD, |
| 331 |
0x9F => 0x0178, |
0x9F => 0x0178, |
| 332 |
}; # $c1_entity_char |
}; # $c1_entity_char |
| 333 |
|
|
|
my $special_category = { |
|
|
address => 1, area => 1, base => 1, basefont => 1, bgsound => 1, |
|
|
blockquote => 1, body => 1, br => 1, center => 1, col => 1, colgroup => 1, |
|
|
dd => 1, dir => 1, div => 1, dl => 1, dt => 1, embed => 1, fieldset => 1, |
|
|
form => 1, frame => 1, frameset => 1, h1 => 1, h2 => 1, h3 => 1, |
|
|
h4 => 1, h5 => 1, h6 => 1, head => 1, hr => 1, iframe => 1, image => 1, |
|
|
img => 1, input => 1, isindex => 1, li => 1, link => 1, listing => 1, |
|
|
menu => 1, meta => 1, noembed => 1, noframes => 1, noscript => 1, |
|
|
ol => 1, optgroup => 1, option => 1, p => 1, param => 1, plaintext => 1, |
|
|
pre => 1, script => 1, select => 1, spacer => 1, style => 1, tbody => 1, |
|
|
textarea => 1, tfoot => 1, thead => 1, title => 1, tr => 1, ul => 1, wbr => 1, |
|
|
}; |
|
|
my $scoping_category = { |
|
|
applet => 1, button => 1, caption => 1, html => 1, marquee => 1, object => 1, |
|
|
table => 1, td => 1, th => 1, |
|
|
}; |
|
|
my $formatting_category = { |
|
|
a => 1, b => 1, big => 1, em => 1, font => 1, i => 1, nobr => 1, |
|
|
s => 1, small => 1, strile => 1, strong => 1, tt => 1, u => 1, |
|
|
}; |
|
|
# $phrasing_category: all other elements |
|
|
|
|
| 334 |
sub parse_byte_string ($$$$;$) { |
sub parse_byte_string ($$$$;$) { |
| 335 |
my $self = ref $_[0] ? shift : shift->new; |
my $self = ref $_[0] ? shift : shift->new; |
| 336 |
my $charset = shift; |
my $charset_name = shift; |
| 337 |
my $bytes_s = ref $_[0] ? $_[0] : \($_[0]); |
my $bytes_s = ref $_[0] ? $_[0] : \($_[0]); |
| 338 |
my $s; |
my $s; |
| 339 |
|
|
| 340 |
if (defined $charset) { |
my $onerror = $_[2] || sub { |
| 341 |
require Encode; ## TODO: decode(utf8) don't delete BOM |
my (%opt) = @_; |
| 342 |
$s = \ (Encode::decode ($charset, $$bytes_s)); |
warn "Parse error ($opt{type})\n"; |
| 343 |
$self->{input_encoding} = lc $charset; ## TODO: normalize name |
}; |
| 344 |
$self->{confident} = 1; |
$self->{parse_error} = $onerror; # updated later by parse_char_string |
| 345 |
} else { |
|
| 346 |
## TODO: Implement HTML5 detection algorithm |
## HTML5 encoding sniffing algorithm |
| 347 |
|
require Message::Charset::Info; |
| 348 |
|
my $charset; |
| 349 |
|
my ($e, $e_status); |
| 350 |
|
|
| 351 |
|
SNIFFING: { |
| 352 |
|
|
| 353 |
|
## Step 1 |
| 354 |
|
if (defined $charset_name) { |
| 355 |
|
$charset = Message::Charset::Info->get_by_iana_name ($charset_name); |
| 356 |
|
|
| 357 |
|
## ISSUE: Unsupported encoding is not ignored according to the spec. |
| 358 |
|
($e, $e_status) = $charset->get_perl_encoding |
| 359 |
|
(allow_error_reporting => 1, |
| 360 |
|
allow_fallback => 1); |
| 361 |
|
if ($e) { |
| 362 |
|
$self->{confident} = 1; |
| 363 |
|
last SNIFFING; |
| 364 |
|
} |
| 365 |
|
} |
| 366 |
|
|
| 367 |
|
## Step 2 |
| 368 |
|
# wait |
| 369 |
|
|
| 370 |
|
## Step 3 |
| 371 |
|
my $head = substr ($$bytes_s, 0, 3); |
| 372 |
|
if ($head =~ /^\xFE\xFF/) { |
| 373 |
|
$charset = Message::Charset::Info->get_by_iana_name ('utf-16be'); |
| 374 |
|
($e, $e_status) = $charset->get_perl_encoding |
| 375 |
|
(allow_error_reporting => 1, |
| 376 |
|
allow_fallback => 1); |
| 377 |
|
$self->{confident} = 1; |
| 378 |
|
last SNIFFING; |
| 379 |
|
} elsif ($head =~ /^\xFF\xFE/) { |
| 380 |
|
$charset = Message::Charset::Info->get_by_iana_name ('utf-16le'); |
| 381 |
|
($e, $e_status) = $charset->get_perl_encoding |
| 382 |
|
(allow_error_reporting => 1, |
| 383 |
|
allow_fallback => 1); |
| 384 |
|
$self->{confident} = 1; |
| 385 |
|
last SNIFFING; |
| 386 |
|
} elsif ($head eq "\xEF\xBB\xBF") { |
| 387 |
|
$charset = Message::Charset::Info->get_by_iana_name ('utf-8'); |
| 388 |
|
($e, $e_status) = $charset->get_perl_encoding |
| 389 |
|
(allow_error_reporting => 1, |
| 390 |
|
allow_fallback => 1); |
| 391 |
|
$self->{confident} = 1; |
| 392 |
|
last SNIFFING; |
| 393 |
|
} |
| 394 |
|
|
| 395 |
|
## Step 4 |
| 396 |
|
## TODO: <meta charset> |
| 397 |
|
|
| 398 |
|
## Step 5 |
| 399 |
|
## TODO: from history |
| 400 |
|
|
| 401 |
|
## Step 6 |
| 402 |
require Whatpm::Charset::UniversalCharDet; |
require Whatpm::Charset::UniversalCharDet; |
| 403 |
$charset = Whatpm::Charset::UniversalCharDet->detect_byte_string |
$charset_name = Whatpm::Charset::UniversalCharDet->detect_byte_string |
| 404 |
(substr ($$bytes_s, 0, 1024)); |
(substr ($$bytes_s, 0, 1024)); |
| 405 |
$charset ||= 'windows-1252'; |
if (defined $charset_name) { |
| 406 |
$s = \ (Encode::decode ($charset, $$bytes_s)); |
$charset = Message::Charset::Info->get_by_iana_name ($charset_name); |
| 407 |
$self->{input_encoding} = $charset; |
|
| 408 |
|
## ISSUE: Unsupported encoding is not ignored according to the spec. |
| 409 |
|
($e, $e_status) = $charset->get_perl_encoding |
| 410 |
|
(allow_error_reporting => 1, |
| 411 |
|
allow_fallback => 1); |
| 412 |
|
if ($e) { |
| 413 |
|
!!!parse-error (type => 'sniffing:chardet', ## TODO: type name |
| 414 |
|
value => $charset_name, |
| 415 |
|
level => $self->{info_level}, |
| 416 |
|
line => 1, column => 1); |
| 417 |
|
$self->{confident} = 0; |
| 418 |
|
last SNIFFING; |
| 419 |
|
} |
| 420 |
|
} |
| 421 |
|
|
| 422 |
|
## Step 7: default |
| 423 |
|
## TODO: Make this configurable. |
| 424 |
|
$charset = Message::Charset::Info->get_by_iana_name ('windows-1252'); |
| 425 |
|
## NOTE: We choose |windows-1252| here, since |utf-8| should be |
| 426 |
|
## detectable in the step 6. |
| 427 |
|
($e, $e_status) = $charset->get_perl_encoding (allow_error_reporting => 1, |
| 428 |
|
allow_fallback => 1); |
| 429 |
|
!!!parse-error (type => 'sniffing:default', ## TODO: type name |
| 430 |
|
value => 'windows-1252', |
| 431 |
|
level => $self->{info_level}, |
| 432 |
|
line => 1, column => 1); |
| 433 |
$self->{confident} = 0; |
$self->{confident} = 0; |
| 434 |
|
} # SNIFFING |
| 435 |
|
|
| 436 |
|
$self->{input_encoding} = $charset->get_iana_name; |
| 437 |
|
if ($e_status & Message::Charset::Info::FALLBACK_ENCODING_IMPL ()) { |
| 438 |
|
!!!parse-error (type => 'chardecode:fallback', ## TODO: type name |
| 439 |
|
value => $e->name, |
| 440 |
|
level => $self->{unsupported_level}, |
| 441 |
|
line => 1, column => 1); |
| 442 |
|
} elsif (not ($e_status & |
| 443 |
|
Message::Charset::Info::ERROR_REPORTING_ENCODING_IMPL())) { |
| 444 |
|
!!!parse-error (type => 'chardecode:no error', ## TODO: type name |
| 445 |
|
value => $self->{input_encoding}, |
| 446 |
|
level => $self->{unsupported_level}, |
| 447 |
|
line => 1, column => 1); |
| 448 |
} |
} |
| 449 |
|
$s = \ $e->decode ($$bytes_s); |
| 450 |
|
|
| 451 |
$self->{change_encoding} = sub { |
$self->{change_encoding} = sub { |
| 452 |
my $self = shift; |
my $self = shift; |
| 453 |
my $charset = lc shift; |
$charset_name = shift; |
| 454 |
my $token = shift; |
my $token = shift; |
|
## TODO: if $charset is supported |
|
|
## TODO: normalize charset name |
|
| 455 |
|
|
| 456 |
## "Change the encoding" algorithm: |
$charset = Message::Charset::Info->get_by_iana_name ($charset_name); |
| 457 |
|
($e, $e_status) = $charset->get_perl_encoding |
| 458 |
|
(allow_error_reporting => 1, allow_fallback => 1); |
| 459 |
|
|
| 460 |
|
if ($e) { # if supported |
| 461 |
|
## "Change the encoding" algorithm: |
| 462 |
|
|
| 463 |
## Step 1 |
## Step 1 |
| 464 |
if ($charset eq 'utf-16') { ## ISSUE: UTF-16BE -> UTF-8? UTF-16LE -> UTF-8? |
if ($charset->{iana_names}->{'utf-16'}) { ## ISSUE: UTF-16BE -> UTF-8? UTF-16LE -> UTF-8? |
| 465 |
$charset = 'utf-8'; |
$charset = Message::Charset::Info->get_by_iana_name ('utf-8'); |
| 466 |
} |
($e, $e_status) = $charset->get_perl_encoding; |
| 467 |
|
} |
| 468 |
|
$charset_name = $charset->get_iana_name; |
| 469 |
|
|
| 470 |
|
## Step 2 |
| 471 |
|
if (defined $self->{input_encoding} and |
| 472 |
|
$self->{input_encoding} eq $charset_name) { |
| 473 |
|
!!!parse-error (type => 'charset label:matching', ## TODO: type |
| 474 |
|
value => $charset_name, |
| 475 |
|
level => $self->{info_level}); |
| 476 |
|
$self->{confident} = 1; |
| 477 |
|
return; |
| 478 |
|
} |
| 479 |
|
|
| 480 |
## Step 2 |
!!!parse-error (type => 'charset label detected:'.$self->{input_encoding}. |
| 481 |
if (defined $self->{input_encoding} and |
':'.$charset_name, level => 'w', token => $token); |
| 482 |
$self->{input_encoding} eq $charset) { |
|
| 483 |
$self->{confident} = 1; |
## Step 3 |
| 484 |
return; |
# if (can) { |
| 485 |
|
## change the encoding on the fly. |
| 486 |
|
#$self->{confident} = 1; |
| 487 |
|
#return; |
| 488 |
|
# } |
| 489 |
|
|
| 490 |
|
## Step 4 |
| 491 |
|
throw Whatpm::HTML::RestartParser (); |
| 492 |
} |
} |
|
|
|
|
!!!parse-error (type => 'charset label detected:'.$self->{input_encoding}. |
|
|
':'.$charset, level => 'w', token => $token); |
|
|
|
|
|
## Step 3 |
|
|
# if (can) { |
|
|
## change the encoding on the fly. |
|
|
#$self->{confident} = 1; |
|
|
#return; |
|
|
# } |
|
|
|
|
|
## Step 4 |
|
|
throw Whatpm::HTML::RestartParser (charset => $charset); |
|
| 493 |
}; # $self->{change_encoding} |
}; # $self->{change_encoding} |
| 494 |
|
|
| 495 |
my @args = @_; shift @args; # $s |
my @args = @_; shift @args; # $s |
| 497 |
try { |
try { |
| 498 |
$return = $self->parse_char_string ($s, @args); |
$return = $self->parse_char_string ($s, @args); |
| 499 |
} catch Whatpm::HTML::RestartParser with { |
} catch Whatpm::HTML::RestartParser with { |
| 500 |
my $charset = shift->{charset}; |
## NOTE: Invoked after {change_encoding}. |
| 501 |
$s = \ (Encode::decode ($charset, $$bytes_s)); |
|
| 502 |
$self->{input_encoding} = $charset; ## TODO: normalize |
$self->{input_encoding} = $charset->get_iana_name; |
| 503 |
|
if ($e_status & Message::Charset::Info::FALLBACK_ENCODING_IMPL ()) { |
| 504 |
|
!!!parse-error (type => 'chardecode:fallback', ## TODO: type name |
| 505 |
|
value => $e->name, |
| 506 |
|
level => $self->{unsupported_level}, |
| 507 |
|
line => 1, column => 1); |
| 508 |
|
} elsif (not ($e_status & |
| 509 |
|
Message::Charset::Info::ERROR_REPORTING_ENCODING_IMPL())) { |
| 510 |
|
!!!parse-error (type => 'chardecode:no error', ## TODO: type name |
| 511 |
|
value => $self->{input_encoding}, |
| 512 |
|
level => $self->{unsupported_level}, |
| 513 |
|
line => 1, column => 1); |
| 514 |
|
} |
| 515 |
|
$s = \ $e->decode ($$bytes_s); |
| 516 |
$self->{confident} = 1; |
$self->{confident} = 1; |
| 517 |
$return = $self->parse_char_string ($s, @args); |
$return = $self->parse_char_string ($s, @args); |
| 518 |
}; |
}; |
| 559 |
$self->{column}++; |
$self->{column}++; |
| 560 |
|
|
| 561 |
if ($self->{next_char} == 0x000A) { # LF |
if ($self->{next_char} == 0x000A) { # LF |
| 562 |
|
!!!cp ('j1'); |
| 563 |
$self->{line}++; |
$self->{line}++; |
| 564 |
$self->{column} = 0; |
$self->{column} = 0; |
| 565 |
} elsif ($self->{next_char} == 0x000D) { # CR |
} elsif ($self->{next_char} == 0x000D) { # CR |
| 566 |
|
!!!cp ('j2'); |
| 567 |
$i++ if substr ($$s, $i, 1) eq "\x0A"; |
$i++ if substr ($$s, $i, 1) eq "\x0A"; |
| 568 |
$self->{next_char} = 0x000A; # LF # MUST |
$self->{next_char} = 0x000A; # LF # MUST |
| 569 |
$self->{line}++; |
$self->{line}++; |
| 570 |
$self->{column} = 0; |
$self->{column} = 0; |
| 571 |
} elsif ($self->{next_char} > 0x10FFFF) { |
} elsif ($self->{next_char} > 0x10FFFF) { |
| 572 |
|
!!!cp ('j3'); |
| 573 |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
| 574 |
} elsif ($self->{next_char} == 0x0000) { # NULL |
} elsif ($self->{next_char} == 0x0000) { # NULL |
| 575 |
|
!!!cp ('j4'); |
| 576 |
!!!parse-error (type => 'NULL'); |
!!!parse-error (type => 'NULL'); |
| 577 |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
| 578 |
|
} elsif ($self->{next_char} <= 0x0008 or |
| 579 |
|
(0x000E <= $self->{next_char} and $self->{next_char} <= 0x001F) or |
| 580 |
|
(0x007F <= $self->{next_char} and $self->{next_char} <= 0x009F) or |
| 581 |
|
(0xD800 <= $self->{next_char} and $self->{next_char} <= 0xDFFF) or |
| 582 |
|
(0xFDD0 <= $self->{next_char} and $self->{next_char} <= 0xFDDF) or |
| 583 |
|
{ |
| 584 |
|
0xFFFE => 1, 0xFFFF => 1, 0x1FFFE => 1, 0x1FFFF => 1, |
| 585 |
|
0x2FFFE => 1, 0x2FFFF => 1, 0x3FFFE => 1, 0x3FFFF => 1, |
| 586 |
|
0x4FFFE => 1, 0x4FFFF => 1, 0x5FFFE => 1, 0x5FFFF => 1, |
| 587 |
|
0x6FFFE => 1, 0x6FFFF => 1, 0x7FFFE => 1, 0x7FFFF => 1, |
| 588 |
|
0x8FFFE => 1, 0x8FFFF => 1, 0x9FFFE => 1, 0x9FFFF => 1, |
| 589 |
|
0xAFFFE => 1, 0xAFFFF => 1, 0xBFFFE => 1, 0xBFFFF => 1, |
| 590 |
|
0xCFFFE => 1, 0xCFFFF => 1, 0xDFFFE => 1, 0xDFFFF => 1, |
| 591 |
|
0xEFFFE => 1, 0xEFFFF => 1, 0xFFFFE => 1, 0xFFFFF => 1, |
| 592 |
|
0x10FFFE => 1, 0x10FFFF => 1, |
| 593 |
|
}->{$self->{next_char}}) { |
| 594 |
|
!!!cp ('j5'); |
| 595 |
|
!!!parse-error (type => 'control char', level => $self->{must_level}); |
| 596 |
|
## TODO: error type documentation |
| 597 |
} |
} |
| 598 |
}; |
}; |
| 599 |
$self->{prev_char} = [-1, -1, -1]; |
$self->{prev_char} = [-1, -1, -1]; |
| 621 |
|
|
| 622 |
sub new ($) { |
sub new ($) { |
| 623 |
my $class = shift; |
my $class = shift; |
| 624 |
my $self = bless {}, $class; |
my $self = bless { |
| 625 |
|
must_level => 'm', |
| 626 |
|
should_level => 's', |
| 627 |
|
good_level => 'w', |
| 628 |
|
warn_level => 'w', |
| 629 |
|
info_level => 'i', |
| 630 |
|
unsupported_level => 'u', |
| 631 |
|
}, $class; |
| 632 |
$self->{set_next_char} = sub { |
$self->{set_next_char} = sub { |
| 633 |
$self->{next_char} = -1; |
$self->{next_char} = -1; |
| 634 |
}; |
}; |
| 690 |
sub AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE () { 31 } |
sub AFTER_DOCTYPE_SYSTEM_IDENTIFIER_STATE () { 31 } |
| 691 |
sub BOGUS_DOCTYPE_STATE () { 32 } |
sub BOGUS_DOCTYPE_STATE () { 32 } |
| 692 |
sub AFTER_ATTRIBUTE_VALUE_QUOTED_STATE () { 33 } |
sub AFTER_ATTRIBUTE_VALUE_QUOTED_STATE () { 33 } |
| 693 |
|
sub SELF_CLOSING_START_TAG_STATE () { 34 } |
| 694 |
|
sub CDATA_BLOCK_STATE () { 35 } |
| 695 |
|
|
| 696 |
sub DOCTYPE_TOKEN () { 1 } |
sub DOCTYPE_TOKEN () { 1 } |
| 697 |
sub COMMENT_TOKEN () { 2 } |
sub COMMENT_TOKEN () { 2 } |
| 709 |
sub BODY_AFTER_IMS () { 0b100000000 } |
sub BODY_AFTER_IMS () { 0b100000000 } |
| 710 |
sub FRAME_IMS () { 0b1000000000 } |
sub FRAME_IMS () { 0b1000000000 } |
| 711 |
sub SELECT_IMS () { 0b10000000000 } |
sub SELECT_IMS () { 0b10000000000 } |
| 712 |
|
sub IN_FOREIGN_CONTENT_IM () { 0b100000000000 } |
| 713 |
|
## NOTE: "in foreign content" insertion mode is special; it is combined |
| 714 |
|
## with the secondary insertion mode. In this parser, they are stored |
| 715 |
|
## together in the bit-or'ed form. |
| 716 |
|
|
| 717 |
## NOTE: "initial" and "before html" insertion modes have no constants. |
## NOTE: "initial" and "before html" insertion modes have no constants. |
| 718 |
|
|
| 749 |
undef $self->{current_attribute}; |
undef $self->{current_attribute}; |
| 750 |
undef $self->{last_emitted_start_tag_name}; |
undef $self->{last_emitted_start_tag_name}; |
| 751 |
undef $self->{last_attribute_value_state}; |
undef $self->{last_attribute_value_state}; |
| 752 |
|
delete $self->{self_closing}; |
| 753 |
$self->{char} = []; |
$self->{char} = []; |
| 754 |
# $self->{next_char} |
# $self->{next_char} |
| 755 |
!!!next-input-character; |
!!!next-input-character; |
| 770 |
## ->{value} |
## ->{value} |
| 771 |
## ->{has_reference} == 1 or 0 |
## ->{has_reference} == 1 or 0 |
| 772 |
## ->{data} (COMMENT_TOKEN, CHARACTER_TOKEN) |
## ->{data} (COMMENT_TOKEN, CHARACTER_TOKEN) |
| 773 |
|
## NOTE: The "self-closing flag" is hold as |$self->{self_closing}|. |
| 774 |
|
## |->{self_closing}| is used to save the value of |$self->{self_closing}| |
| 775 |
|
## while the token is pushed back to the stack. |
| 776 |
|
|
| 777 |
|
## ISSUE: "When a DOCTYPE token is created, its |
| 778 |
|
## <i>self-closing flag</i> must be unset (its other state is that it |
| 779 |
|
## be set), and its attributes list must be empty.": Wrong subject? |
| 780 |
|
|
| 781 |
## Emitted token MUST immediately be handled by the tree construction state. |
## Emitted token MUST immediately be handled by the tree construction state. |
| 782 |
|
|
| 803 |
|
|
| 804 |
sub _get_next_token ($) { |
sub _get_next_token ($) { |
| 805 |
my $self = shift; |
my $self = shift; |
| 806 |
|
|
| 807 |
|
if ($self->{self_closing}) { |
| 808 |
|
!!!parse-error (type => 'nestc', token => $self->{current_token}); |
| 809 |
|
## NOTE: The |self_closing| flag is only set by start tag token. |
| 810 |
|
## In addition, when a start tag token is emitted, it is always set to |
| 811 |
|
## |current_token|. |
| 812 |
|
delete $self->{self_closing}; |
| 813 |
|
} |
| 814 |
|
|
| 815 |
if (@{$self->{token}}) { |
if (@{$self->{token}}) { |
| 816 |
|
$self->{self_closing} = $self->{token}->[0]->{self_closing}; |
| 817 |
return shift @{$self->{token}}; |
return shift @{$self->{token}}; |
| 818 |
} |
} |
| 819 |
|
|
| 1184 |
|
|
| 1185 |
redo A; |
redo A; |
| 1186 |
} elsif ($self->{next_char} == 0x002F) { # / |
} elsif ($self->{next_char} == 0x002F) { # / |
| 1187 |
|
!!!cp (42); |
| 1188 |
|
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
| 1189 |
!!!next-input-character; |
!!!next-input-character; |
|
if ($self->{next_char} == 0x003E and # > |
|
|
$self->{current_token}->{type} == START_TAG_TOKEN and |
|
|
$permitted_slash_tag_name->{$self->{current_token}->{tag_name}}) { |
|
|
# permitted slash |
|
|
!!!cp (42); |
|
|
# |
|
|
} else { |
|
|
!!!cp (43); |
|
|
!!!parse-error (type => 'nestc'); |
|
|
} |
|
|
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
|
|
# next-input-character is already done |
|
| 1190 |
redo A; |
redo A; |
| 1191 |
} else { |
} else { |
| 1192 |
!!!cp (44); |
!!!cp (44); |
| 1238 |
!!!next-input-character; |
!!!next-input-character; |
| 1239 |
redo A; |
redo A; |
| 1240 |
} elsif ($self->{next_char} == 0x002F) { # / |
} elsif ($self->{next_char} == 0x002F) { # / |
| 1241 |
|
!!!cp (50); |
| 1242 |
|
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
| 1243 |
!!!next-input-character; |
!!!next-input-character; |
|
if ($self->{next_char} == 0x003E and # > |
|
|
$self->{current_token}->{type} == START_TAG_TOKEN and |
|
|
$permitted_slash_tag_name->{$self->{current_token}->{tag_name}}) { |
|
|
# permitted slash |
|
|
!!!cp (50); |
|
|
# |
|
|
} else { |
|
|
!!!cp (51); |
|
|
!!!parse-error (type => 'nestc'); |
|
|
} |
|
|
## Stay in the state |
|
|
# next-input-character is already done |
|
| 1244 |
redo A; |
redo A; |
| 1245 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1246 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 1341 |
!!!next-input-character; |
!!!next-input-character; |
| 1342 |
redo A; |
redo A; |
| 1343 |
} elsif ($self->{next_char} == 0x002F) { # / |
} elsif ($self->{next_char} == 0x002F) { # / |
| 1344 |
|
!!!cp (64); |
| 1345 |
$before_leave->(); |
$before_leave->(); |
| 1346 |
|
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
| 1347 |
!!!next-input-character; |
!!!next-input-character; |
|
if ($self->{next_char} == 0x003E and # > |
|
|
$self->{current_token}->{type} == START_TAG_TOKEN and |
|
|
$permitted_slash_tag_name->{$self->{current_token}->{tag_name}}) { |
|
|
# permitted slash |
|
|
!!!cp (64); |
|
|
# |
|
|
} else { |
|
|
!!!cp (65); |
|
|
!!!parse-error (type => 'nestc'); |
|
|
} |
|
|
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
|
|
# next-input-character is already done |
|
| 1348 |
redo A; |
redo A; |
| 1349 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1350 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 1431 |
!!!next-input-character; |
!!!next-input-character; |
| 1432 |
redo A; |
redo A; |
| 1433 |
} elsif ($self->{next_char} == 0x002F) { # / |
} elsif ($self->{next_char} == 0x002F) { # / |
| 1434 |
|
!!!cp (77); |
| 1435 |
|
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
| 1436 |
!!!next-input-character; |
!!!next-input-character; |
|
if ($self->{next_char} == 0x003E and # > |
|
|
$self->{current_token}->{type} == START_TAG_TOKEN and |
|
|
$permitted_slash_tag_name->{$self->{current_token}->{tag_name}}) { |
|
|
# permitted slash |
|
|
!!!cp (77); |
|
|
# |
|
|
} else { |
|
|
!!!cp (78); |
|
|
!!!parse-error (type => 'nestc'); |
|
|
## TODO: Different error type for <aa / bb> than <aa/> |
|
|
} |
|
|
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
|
|
# next-input-character is already done |
|
| 1437 |
redo A; |
redo A; |
| 1438 |
} elsif ($self->{next_char} == -1) { |
} elsif ($self->{next_char} == -1) { |
| 1439 |
!!!parse-error (type => 'unclosed tag'); |
!!!parse-error (type => 'unclosed tag'); |
| 1766 |
|
|
| 1767 |
redo A; |
redo A; |
| 1768 |
} elsif ($self->{next_char} == 0x002F) { # / |
} elsif ($self->{next_char} == 0x002F) { # / |
| 1769 |
|
!!!cp (122); |
| 1770 |
|
$self->{state} = SELF_CLOSING_START_TAG_STATE; |
| 1771 |
!!!next-input-character; |
!!!next-input-character; |
|
if ($self->{next_char} == 0x003E and # > |
|
|
$self->{current_token}->{type} == START_TAG_TOKEN and |
|
|
$permitted_slash_tag_name->{$self->{current_token}->{tag_name}}) { |
|
|
# permitted slash |
|
|
!!!cp (122); |
|
|
# |
|
|
} else { |
|
|
!!!cp (123); |
|
|
!!!parse-error (type => 'nestc'); |
|
|
} |
|
|
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
|
|
# next-input-character is already done |
|
| 1772 |
redo A; |
redo A; |
| 1773 |
} else { |
} else { |
| 1774 |
!!!cp (124); |
!!!cp ('124.1'); |
| 1775 |
!!!parse-error (type => 'no space between attributes'); |
!!!parse-error (type => 'no space between attributes'); |
| 1776 |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 1777 |
## reconsume |
## reconsume |
| 1778 |
redo A; |
redo A; |
| 1779 |
} |
} |
| 1780 |
|
} elsif ($self->{state} == SELF_CLOSING_START_TAG_STATE) { |
| 1781 |
|
if ($self->{next_char} == 0x003E) { # > |
| 1782 |
|
if ($self->{current_token}->{type} == END_TAG_TOKEN) { |
| 1783 |
|
!!!cp ('124.2'); |
| 1784 |
|
!!!parse-error (type => 'nestc', token => $self->{current_token}); |
| 1785 |
|
## TODO: Different type than slash in start tag |
| 1786 |
|
$self->{content_model} = PCDATA_CONTENT_MODEL; # MUST |
| 1787 |
|
if ($self->{current_token}->{attributes}) { |
| 1788 |
|
!!!cp ('124.4'); |
| 1789 |
|
!!!parse-error (type => 'end tag attribute'); |
| 1790 |
|
} else { |
| 1791 |
|
!!!cp ('124.5'); |
| 1792 |
|
} |
| 1793 |
|
## TODO: Test |<title></title/>| |
| 1794 |
|
} else { |
| 1795 |
|
!!!cp ('124.3'); |
| 1796 |
|
$self->{self_closing} = 1; |
| 1797 |
|
} |
| 1798 |
|
|
| 1799 |
|
$self->{state} = DATA_STATE; |
| 1800 |
|
!!!next-input-character; |
| 1801 |
|
|
| 1802 |
|
!!!emit ($self->{current_token}); # start tag or end tag |
| 1803 |
|
|
| 1804 |
|
redo A; |
| 1805 |
|
} else { |
| 1806 |
|
!!!cp ('124.4'); |
| 1807 |
|
!!!parse-error (type => 'nestc'); |
| 1808 |
|
## TODO: This error type is wrong. |
| 1809 |
|
$self->{state} = BEFORE_ATTRIBUTE_NAME_STATE; |
| 1810 |
|
## Reconsume. |
| 1811 |
|
redo A; |
| 1812 |
|
} |
| 1813 |
} elsif ($self->{state} == BOGUS_COMMENT_STATE) { |
} elsif ($self->{state} == BOGUS_COMMENT_STATE) { |
| 1814 |
## (only happen if PCDATA state) |
## (only happen if PCDATA state) |
| 1815 |
|
|
| 1917 |
} else { |
} else { |
| 1918 |
!!!cp (135); |
!!!cp (135); |
| 1919 |
} |
} |
| 1920 |
|
} elsif ($self->{insertion_mode} & IN_FOREIGN_CONTENT_IM and |
| 1921 |
|
$self->{open_elements}->[-1]->[1] & FOREIGN_EL and |
| 1922 |
|
$self->{next_char} == 0x005B) { # [ |
| 1923 |
|
!!!next-input-character; |
| 1924 |
|
push @next_char, $self->{next_char}; |
| 1925 |
|
if ($self->{next_char} == 0x0043) { # C |
| 1926 |
|
!!!next-input-character; |
| 1927 |
|
push @next_char, $self->{next_char}; |
| 1928 |
|
if ($self->{next_char} == 0x0044) { # D |
| 1929 |
|
!!!next-input-character; |
| 1930 |
|
push @next_char, $self->{next_char}; |
| 1931 |
|
if ($self->{next_char} == 0x0041) { # A |
| 1932 |
|
!!!next-input-character; |
| 1933 |
|
push @next_char, $self->{next_char}; |
| 1934 |
|
if ($self->{next_char} == 0x0054) { # T |
| 1935 |
|
!!!next-input-character; |
| 1936 |
|
push @next_char, $self->{next_char}; |
| 1937 |
|
if ($self->{next_char} == 0x0041) { # A |
| 1938 |
|
!!!next-input-character; |
| 1939 |
|
push @next_char, $self->{next_char}; |
| 1940 |
|
if ($self->{next_char} == 0x005B) { # [ |
| 1941 |
|
!!!cp (135.1); |
| 1942 |
|
$self->{state} = CDATA_BLOCK_STATE; |
| 1943 |
|
!!!next-input-character; |
| 1944 |
|
redo A; |
| 1945 |
|
} else { |
| 1946 |
|
!!!cp (135.2); |
| 1947 |
|
} |
| 1948 |
|
} else { |
| 1949 |
|
!!!cp (135.3); |
| 1950 |
|
} |
| 1951 |
|
} else { |
| 1952 |
|
!!!cp (135.4); |
| 1953 |
|
} |
| 1954 |
|
} else { |
| 1955 |
|
!!!cp (135.5); |
| 1956 |
|
} |
| 1957 |
|
} else { |
| 1958 |
|
!!!cp (135.6); |
| 1959 |
|
} |
| 1960 |
|
} else { |
| 1961 |
|
!!!cp (135.7); |
| 1962 |
|
} |
| 1963 |
} else { |
} else { |
| 1964 |
!!!cp (136); |
!!!cp (136); |
| 1965 |
} |
} |
| 2684 |
!!!next-input-character; |
!!!next-input-character; |
| 2685 |
redo A; |
redo A; |
| 2686 |
} |
} |
| 2687 |
|
} elsif ($self->{state} == CDATA_BLOCK_STATE) { |
| 2688 |
|
my $s = ''; |
| 2689 |
|
|
| 2690 |
|
my ($l, $c) = ($self->{line}, $self->{column}); |
| 2691 |
|
|
| 2692 |
|
CS: while ($self->{next_char} != -1) { |
| 2693 |
|
if ($self->{next_char} == 0x005D) { # ] |
| 2694 |
|
!!!next-input-character; |
| 2695 |
|
if ($self->{next_char} == 0x005D) { # ] |
| 2696 |
|
!!!next-input-character; |
| 2697 |
|
MDC: { |
| 2698 |
|
if ($self->{next_char} == 0x003E) { # > |
| 2699 |
|
!!!cp (221.1); |
| 2700 |
|
!!!next-input-character; |
| 2701 |
|
last CS; |
| 2702 |
|
} elsif ($self->{next_char} == 0x005D) { # ] |
| 2703 |
|
!!!cp (221.2); |
| 2704 |
|
$s .= ']'; |
| 2705 |
|
!!!next-input-character; |
| 2706 |
|
redo MDC; |
| 2707 |
|
} else { |
| 2708 |
|
!!!cp (221.3); |
| 2709 |
|
$s .= ']]'; |
| 2710 |
|
# |
| 2711 |
|
} |
| 2712 |
|
} # MDC |
| 2713 |
|
} else { |
| 2714 |
|
!!!cp (221.4); |
| 2715 |
|
$s .= ']'; |
| 2716 |
|
# |
| 2717 |
|
} |
| 2718 |
|
} else { |
| 2719 |
|
!!!cp (221.5); |
| 2720 |
|
# |
| 2721 |
|
} |
| 2722 |
|
$s .= chr $self->{next_char}; |
| 2723 |
|
!!!next-input-character; |
| 2724 |
|
} # CS |
| 2725 |
|
|
| 2726 |
|
$self->{state} = DATA_STATE; |
| 2727 |
|
## next-input-character done or EOF, which is reconsumed. |
| 2728 |
|
|
| 2729 |
|
if (length $s) { |
| 2730 |
|
!!!cp (221.6); |
| 2731 |
|
!!!emit ({type => CHARACTER_TOKEN, data => $s, |
| 2732 |
|
line => $l, column => $c}); |
| 2733 |
|
} else { |
| 2734 |
|
!!!cp (221.7); |
| 2735 |
|
} |
| 2736 |
|
|
| 2737 |
|
redo A; |
| 2738 |
|
|
| 2739 |
|
## ISSUE: "text tokens" in spec. |
| 2740 |
|
## TODO: Streaming support |
| 2741 |
} else { |
} else { |
| 2742 |
die "$0: $self->{state}: Unknown state"; |
die "$0: $self->{state}: Unknown state"; |
| 2743 |
} |
} |
| 2888 |
require Whatpm::_NamedEntityList; |
require Whatpm::_NamedEntityList; |
| 2889 |
our $EntityChar; |
our $EntityChar; |
| 2890 |
|
|
| 2891 |
while (length $entity_name < 10 and |
while (length $entity_name < 30 and |
| 2892 |
## NOTE: Some number greater than the maximum length of entity name |
## NOTE: Some number greater than the maximum length of entity name |
| 2893 |
((0x0041 <= $self->{next_char} and # a |
((0x0041 <= $self->{next_char} and # a |
| 2894 |
$self->{next_char} <= 0x005A) or # x |
$self->{next_char} <= 0x005A) or # x |
| 3030 |
|
|
| 3031 |
my $doctype = $self->{document}->create_document_type_definition |
my $doctype = $self->{document}->create_document_type_definition |
| 3032 |
($token->{name}); ## ISSUE: If name is missing (e.g. <!DOCTYPE>)? |
($token->{name}); ## ISSUE: If name is missing (e.g. <!DOCTYPE>)? |
| 3033 |
|
## NOTE: Default value for both |public_id| and |system_id| attributes |
| 3034 |
|
## are empty strings, so that we don't set any value in missing cases. |
| 3035 |
$doctype->public_id ($token->{public_identifier}) |
$doctype->public_id ($token->{public_identifier}) |
| 3036 |
if defined $token->{public_identifier}; |
if defined $token->{public_identifier}; |
| 3037 |
$doctype->system_id ($token->{system_identifier}) |
$doctype->system_id ($token->{system_identifier}) |
| 3168 |
$self->{document}->manakai_compat_mode ('quirks'); |
$self->{document}->manakai_compat_mode ('quirks'); |
| 3169 |
## Go to the "before html" insertion mode. |
## Go to the "before html" insertion mode. |
| 3170 |
## reprocess |
## reprocess |
| 3171 |
|
!!!ack-later; |
| 3172 |
return; |
return; |
| 3173 |
} elsif ($token->{type} == CHARACTER_TOKEN) { |
} elsif ($token->{type} == CHARACTER_TOKEN) { |
| 3174 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { # \x0D |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { # \x0D |
| 3249 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 3250 |
if ($token->{tag_name} eq 'html') { |
if ($token->{tag_name} eq 'html') { |
| 3251 |
my $root_element; |
my $root_element; |
| 3252 |
!!!create-element ($root_element, $token->{tag_name}, $token->{attributes}, $token); |
!!!create-element ($root_element, $HTML_NS, $token->{tag_name}, $token->{attributes}, $token); |
| 3253 |
$self->{document}->append_child ($root_element); |
$self->{document}->append_child ($root_element); |
| 3254 |
push @{$self->{open_elements}}, [$root_element, 'html']; |
push @{$self->{open_elements}}, |
| 3255 |
|
[$root_element, $el_category->{html}]; |
| 3256 |
|
|
| 3257 |
if ($token->{attributes}->{manifest}) { |
if ($token->{attributes}->{manifest}) { |
| 3258 |
!!!cp ('t24'); |
!!!cp ('t24'); |
| 3267 |
$self->{application_cache_selection}->(undef); |
$self->{application_cache_selection}->(undef); |
| 3268 |
} |
} |
| 3269 |
|
|
| 3270 |
|
!!!nack ('t25c'); |
| 3271 |
|
|
| 3272 |
!!!next-token; |
!!!next-token; |
| 3273 |
return; ## Go to the "before head" insertion mode. |
return; ## Go to the "before head" insertion mode. |
| 3274 |
} else { |
} else { |
| 3285 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 3286 |
} |
} |
| 3287 |
|
|
| 3288 |
my $root_element; !!!create-element ($root_element, 'html',, $token); |
my $root_element; |
| 3289 |
|
!!!create-element ($root_element, $HTML_NS, 'html',, $token); |
| 3290 |
$self->{document}->append_child ($root_element); |
$self->{document}->append_child ($root_element); |
| 3291 |
push @{$self->{open_elements}}, [$root_element, 'html']; |
push @{$self->{open_elements}}, [$root_element, $el_category->{html}]; |
| 3292 |
|
|
| 3293 |
$self->{application_cache_selection}->(undef); |
$self->{application_cache_selection}->(undef); |
| 3294 |
|
|
| 3295 |
## NOTE: Reprocess the token. |
## NOTE: Reprocess the token. |
| 3296 |
|
!!!ack-later; |
| 3297 |
return; ## Go to the "before head" insertion mode. |
return; ## Go to the "before head" insertion mode. |
| 3298 |
|
|
| 3299 |
## ISSUE: There is an issue in the spec |
## ISSUE: There is an issue in the spec |
| 3317 |
if ($self->{open_elements}->[0]->[0] eq $node->[0]) { |
if ($self->{open_elements}->[0]->[0] eq $node->[0]) { |
| 3318 |
$last = 1; |
$last = 1; |
| 3319 |
if (defined $self->{inner_html_node}) { |
if (defined $self->{inner_html_node}) { |
| 3320 |
if ($self->{inner_html_node}->[1] eq 'td' or |
if ($self->{inner_html_node}->[1] & TABLE_CELL_EL) { |
|
$self->{inner_html_node}->[1] eq 'th') { |
|
| 3321 |
!!!cp ('t27'); |
!!!cp ('t27'); |
| 3322 |
# |
# |
| 3323 |
} else { |
} else { |
| 3327 |
} |
} |
| 3328 |
} |
} |
| 3329 |
|
|
| 3330 |
## Step 4..13 |
## Step 4..14 |
| 3331 |
my $new_mode = { |
my $new_mode; |
| 3332 |
|
if ($node->[1] & FOREIGN_EL) { |
| 3333 |
|
## NOTE: Strictly spaking, the line below only applies to MathML and |
| 3334 |
|
## SVG elements. Currently the HTML syntax supports only MathML and |
| 3335 |
|
## SVG elements as foreigners. |
| 3336 |
|
$new_mode = $self->{insertion_mode} | IN_FOREIGN_CONTENT_IM; |
| 3337 |
|
## ISSUE: What is set as the secondary insertion mode? |
| 3338 |
|
} else { |
| 3339 |
|
$new_mode = { |
| 3340 |
select => IN_SELECT_IM, |
select => IN_SELECT_IM, |
| 3341 |
## NOTE: |option| and |optgroup| do not set |
## NOTE: |option| and |optgroup| do not set |
| 3342 |
## insertion mode to "in select" by themselves. |
## insertion mode to "in select" by themselves. |
| 3352 |
head => IN_BODY_IM, # not in head! |
head => IN_BODY_IM, # not in head! |
| 3353 |
body => IN_BODY_IM, |
body => IN_BODY_IM, |
| 3354 |
frameset => IN_FRAMESET_IM, |
frameset => IN_FRAMESET_IM, |
| 3355 |
}->{$node->[1]}; |
}->{$node->[0]->manakai_local_name}; |
| 3356 |
$self->{insertion_mode} = $new_mode and return if defined $new_mode; |
} |
| 3357 |
|
$self->{insertion_mode} = $new_mode and return if defined $new_mode; |
| 3358 |
|
|
| 3359 |
## Step 14 |
## Step 15 |
| 3360 |
if ($node->[1] eq 'html') { |
if ($node->[1] & HTML_EL) { |
| 3361 |
unless (defined $self->{head_element}) { |
unless (defined $self->{head_element}) { |
| 3362 |
!!!cp ('t29'); |
!!!cp ('t29'); |
| 3363 |
$self->{insertion_mode} = BEFORE_HEAD_IM; |
$self->{insertion_mode} = BEFORE_HEAD_IM; |
| 3371 |
!!!cp ('t31'); |
!!!cp ('t31'); |
| 3372 |
} |
} |
| 3373 |
|
|
| 3374 |
## Step 15 |
## Step 16 |
| 3375 |
$self->{insertion_mode} = IN_BODY_IM and return if $last; |
$self->{insertion_mode} = IN_BODY_IM and return if $last; |
| 3376 |
|
|
| 3377 |
## Step 16 |
## Step 17 |
| 3378 |
$i--; |
$i--; |
| 3379 |
$node = $self->{open_elements}->[$i]; |
$node = $self->{open_elements}->[$i]; |
| 3380 |
|
|
| 3381 |
## Step 17 |
## Step 18 |
| 3382 |
redo S3; |
redo S3; |
| 3383 |
} # S3 |
} # S3 |
| 3384 |
|
|
| 3490 |
## Step 1 |
## Step 1 |
| 3491 |
my $start_tag_name = $token->{tag_name}; |
my $start_tag_name = $token->{tag_name}; |
| 3492 |
my $el; |
my $el; |
| 3493 |
!!!create-element ($el, $start_tag_name, $token->{attributes}, $token); |
!!!create-element ($el, $HTML_NS, $start_tag_name, $token->{attributes}, $token); |
| 3494 |
|
|
| 3495 |
## Step 2 |
## Step 2 |
| 3496 |
$insert->($el); |
$insert->($el); |
| 3501 |
|
|
| 3502 |
## Step 4 |
## Step 4 |
| 3503 |
my $text = ''; |
my $text = ''; |
| 3504 |
|
!!!nack ('t40.1'); |
| 3505 |
!!!next-token; |
!!!next-token; |
| 3506 |
while ($token->{type} == CHARACTER_TOKEN) { # or until stop tokenizing |
while ($token->{type} == CHARACTER_TOKEN) { # or until stop tokenizing |
| 3507 |
!!!cp ('t40'); |
!!!cp ('t40'); |
| 3541 |
|
|
| 3542 |
my $script_start_tag = sub () { |
my $script_start_tag = sub () { |
| 3543 |
my $script_el; |
my $script_el; |
| 3544 |
!!!create-element ($script_el, 'script', $token->{attributes}, $token); |
!!!create-element ($script_el, $HTML_NS, 'script', $token->{attributes}, $token); |
| 3545 |
## TODO: mark as "parser-inserted" |
## TODO: mark as "parser-inserted" |
| 3546 |
|
|
| 3547 |
$self->{content_model} = CDATA_CONTENT_MODEL; |
$self->{content_model} = CDATA_CONTENT_MODEL; |
| 3548 |
delete $self->{escape}; # MUST |
delete $self->{escape}; # MUST |
| 3549 |
|
|
| 3550 |
my $text = ''; |
my $text = ''; |
| 3551 |
|
!!!nack ('t45.1'); |
| 3552 |
!!!next-token; |
!!!next-token; |
| 3553 |
while ($token->{type} == CHARACTER_TOKEN) { |
while ($token->{type} == CHARACTER_TOKEN) { |
| 3554 |
!!!cp ('t45'); |
!!!cp ('t45'); |
| 3606 |
my $formatting_element; |
my $formatting_element; |
| 3607 |
my $formatting_element_i_in_active; |
my $formatting_element_i_in_active; |
| 3608 |
AFE: for (reverse 0..$#$active_formatting_elements) { |
AFE: for (reverse 0..$#$active_formatting_elements) { |
| 3609 |
if ($active_formatting_elements->[$_]->[1] eq $tag_name) { |
if ($active_formatting_elements->[$_]->[0] eq '#marker') { |
| 3610 |
|
!!!cp ('t52'); |
| 3611 |
|
last AFE; |
| 3612 |
|
} elsif ($active_formatting_elements->[$_]->[0]->manakai_local_name |
| 3613 |
|
eq $tag_name) { |
| 3614 |
!!!cp ('t51'); |
!!!cp ('t51'); |
| 3615 |
$formatting_element = $active_formatting_elements->[$_]; |
$formatting_element = $active_formatting_elements->[$_]; |
| 3616 |
$formatting_element_i_in_active = $_; |
$formatting_element_i_in_active = $_; |
| 3617 |
last AFE; |
last AFE; |
|
} elsif ($active_formatting_elements->[$_]->[0] eq '#marker') { |
|
|
!!!cp ('t52'); |
|
|
last AFE; |
|
| 3618 |
} |
} |
| 3619 |
} # AFE |
} # AFE |
| 3620 |
unless (defined $formatting_element) { |
unless (defined $formatting_element) { |
| 3642 |
!!!next-token; |
!!!next-token; |
| 3643 |
return; |
return; |
| 3644 |
} |
} |
| 3645 |
} elsif ({ |
} elsif ($node->[1] & SCOPING_EL) { |
|
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 3646 |
!!!cp ('t56'); |
!!!cp ('t56'); |
| 3647 |
$in_scope = 0; |
$in_scope = 0; |
| 3648 |
} |
} |
| 3657 |
} |
} |
| 3658 |
if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) { |
if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) { |
| 3659 |
!!!cp ('t58'); |
!!!cp ('t58'); |
| 3660 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], |
!!!parse-error (type => 'not closed', |
| 3661 |
|
value => $self->{open_elements}->[-1]->[0] |
| 3662 |
|
->manakai_local_name, |
| 3663 |
token => $end_tag_token); |
token => $end_tag_token); |
| 3664 |
} |
} |
| 3665 |
|
|
| 3668 |
my $furthest_block_i_in_open; |
my $furthest_block_i_in_open; |
| 3669 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3670 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 3671 |
if (not $formatting_category->{$node->[1]} and |
if (not ($node->[1] & FORMATTING_EL) and |
| 3672 |
#not $phrasing_category->{$node->[1]} and |
#not $phrasing_category->{$node->[1]} and |
| 3673 |
($special_category->{$node->[1]} or |
($node->[1] & SPECIAL_EL or |
| 3674 |
$scoping_category->{$node->[1]})) { ## Scoping is redundant, maybe |
$node->[1] & SCOPING_EL)) { ## Scoping is redundant, maybe |
| 3675 |
!!!cp ('t59'); |
!!!cp ('t59'); |
| 3676 |
$furthest_block = $node; |
$furthest_block = $node; |
| 3677 |
$furthest_block_i_in_open = $_; |
$furthest_block_i_in_open = $_; |
| 3757 |
} # S7 |
} # S7 |
| 3758 |
|
|
| 3759 |
## Step 8 |
## Step 8 |
| 3760 |
if ({ |
if ($common_ancestor_node->[1] & TABLE_ROWS_EL) { |
|
table => 1, tbody => 1, tfoot => 1, thead => 1, tr => 1, |
|
|
}->{$common_ancestor_node->[1]}) { |
|
| 3761 |
my $foster_parent_element; |
my $foster_parent_element; |
| 3762 |
my $next_sibling; |
my $next_sibling; |
| 3763 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3764 |
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
if ($self->{open_elements}->[$_]->[1] & TABLE_EL) { |
| 3765 |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
| 3766 |
if (defined $parent and $parent->node_type == 1) { |
if (defined $parent and $parent->node_type == 1) { |
| 3767 |
!!!cp ('t65.1'); |
!!!cp ('t65.1'); |
| 3834 |
|
|
| 3835 |
my $insert_to_foster = sub { |
my $insert_to_foster = sub { |
| 3836 |
my $child = shift; |
my $child = shift; |
| 3837 |
if ({ |
if ($self->{open_elements}->[-1]->[1] & TABLE_ROWS_EL) { |
|
table => 1, tbody => 1, tfoot => 1, thead => 1, tr => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 3838 |
# MUST |
# MUST |
| 3839 |
my $foster_parent_element; |
my $foster_parent_element; |
| 3840 |
my $next_sibling; |
my $next_sibling; |
| 3841 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
| 3842 |
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
if ($self->{open_elements}->[$_]->[1] & TABLE_EL) { |
| 3843 |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
| 3844 |
if (defined $parent and $parent->node_type == 1) { |
if (defined $parent and $parent->node_type == 1) { |
| 3845 |
!!!cp ('t70'); |
!!!cp ('t70'); |
| 3864 |
} |
} |
| 3865 |
}; # $insert_to_foster |
}; # $insert_to_foster |
| 3866 |
|
|
| 3867 |
B: { |
B: while (1) { |
| 3868 |
if ($token->{type} == DOCTYPE_TOKEN) { |
if ($token->{type} == DOCTYPE_TOKEN) { |
| 3869 |
!!!cp ('t73'); |
!!!cp ('t73'); |
| 3870 |
!!!parse-error (type => 'DOCTYPE in the middle', token => $token); |
!!!parse-error (type => 'DOCTYPE in the middle', token => $token); |
| 3871 |
## Ignore the token |
## Ignore the token |
| 3872 |
## Stay in the phase |
## Stay in the phase |
| 3873 |
!!!next-token; |
!!!next-token; |
| 3874 |
redo B; |
next B; |
| 3875 |
} elsif ($token->{type} == START_TAG_TOKEN and |
} elsif ($token->{type} == START_TAG_TOKEN and |
| 3876 |
$token->{tag_name} eq 'html') { |
$token->{tag_name} eq 'html') { |
| 3877 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 3897 |
$token->{attributes}->{$attr_name}->{value}); |
$token->{attributes}->{$attr_name}->{value}); |
| 3898 |
} |
} |
| 3899 |
} |
} |
| 3900 |
|
!!!nack ('t84.1'); |
| 3901 |
!!!next-token; |
!!!next-token; |
| 3902 |
redo B; |
next B; |
| 3903 |
} elsif ($token->{type} == COMMENT_TOKEN) { |
} elsif ($token->{type} == COMMENT_TOKEN) { |
| 3904 |
my $comment = $self->{document}->create_comment ($token->{data}); |
my $comment = $self->{document}->create_comment ($token->{data}); |
| 3905 |
if ($self->{insertion_mode} & AFTER_HTML_IMS) { |
if ($self->{insertion_mode} & AFTER_HTML_IMS) { |
| 3913 |
$self->{open_elements}->[-1]->[0]->append_child ($comment); |
$self->{open_elements}->[-1]->[0]->append_child ($comment); |
| 3914 |
} |
} |
| 3915 |
!!!next-token; |
!!!next-token; |
| 3916 |
redo B; |
next B; |
| 3917 |
} elsif ($self->{insertion_mode} & HEAD_IMS) { |
} elsif ($self->{insertion_mode} & IN_FOREIGN_CONTENT_IM) { |
| 3918 |
|
if ($token->{type} == CHARACTER_TOKEN) { |
| 3919 |
|
!!!cp ('t87.1'); |
| 3920 |
|
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 3921 |
|
!!!next-token; |
| 3922 |
|
next B; |
| 3923 |
|
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 3924 |
|
if ((not {mglyph => 1, malignmark => 1}->{$token->{tag_name}} and |
| 3925 |
|
$self->{open_elements}->[-1]->[1] & FOREIGN_FLOW_CONTENT_EL) or |
| 3926 |
|
not ($self->{open_elements}->[-1]->[1] & FOREIGN_EL) or |
| 3927 |
|
($token->{tag_name} eq 'svg' and |
| 3928 |
|
$self->{open_elements}->[-1]->[1] & MML_AXML_EL)) { |
| 3929 |
|
## NOTE: "using the rules for secondary insertion mode"then"continue" |
| 3930 |
|
!!!cp ('t87.2'); |
| 3931 |
|
# |
| 3932 |
|
} elsif ({ |
| 3933 |
|
b => 1, big => 1, blockquote => 1, body => 1, br => 1, |
| 3934 |
|
center => 1, code => 1, dd => 1, div => 1, dl => 1, em => 1, |
| 3935 |
|
embed => 1, font => 1, h1 => 1, h2 => 1, h3 => 1, ## No h4! |
| 3936 |
|
h5 => 1, h6 => 1, head => 1, hr => 1, i => 1, img => 1, |
| 3937 |
|
li => 1, menu => 1, meta => 1, nobr => 1, p => 1, pre => 1, |
| 3938 |
|
ruby => 1, s => 1, small => 1, span => 1, strong => 1, |
| 3939 |
|
sub => 1, sup => 1, table => 1, tt => 1, u => 1, ul => 1, |
| 3940 |
|
var => 1, |
| 3941 |
|
}->{$token->{tag_name}}) { |
| 3942 |
|
!!!cp ('t87.2'); |
| 3943 |
|
!!!parse-error (type => 'not closed', |
| 3944 |
|
value => $self->{open_elements}->[-1]->[0] |
| 3945 |
|
->manakai_local_name, |
| 3946 |
|
token => $token); |
| 3947 |
|
|
| 3948 |
|
pop @{$self->{open_elements}} |
| 3949 |
|
while $self->{open_elements}->[-1]->[1] & FOREIGN_EL; |
| 3950 |
|
|
| 3951 |
|
$self->{insertion_mode} &= ~ IN_FOREIGN_CONTENT_IM; |
| 3952 |
|
## Reprocess. |
| 3953 |
|
next B; |
| 3954 |
|
} else { |
| 3955 |
|
my $nsuri = $self->{open_elements}->[-1]->[0]->namespace_uri; |
| 3956 |
|
my $tag_name = $token->{tag_name}; |
| 3957 |
|
if ($nsuri eq $SVG_NS) { |
| 3958 |
|
$tag_name = { |
| 3959 |
|
altglyph => 'altGlyph', |
| 3960 |
|
altglyphdef => 'altGlyphDef', |
| 3961 |
|
altglyphitem => 'altGlyphItem', |
| 3962 |
|
animatecolor => 'animateColor', |
| 3963 |
|
animatemotion => 'animateMotion', |
| 3964 |
|
animatetransform => 'animateTransform', |
| 3965 |
|
clippath => 'clipPath', |
| 3966 |
|
feblend => 'feBlend', |
| 3967 |
|
fecolormatrix => 'feColorMatrix', |
| 3968 |
|
fecomponenttransfer => 'feComponentTransfer', |
| 3969 |
|
fecomposite => 'feComposite', |
| 3970 |
|
feconvolvematrix => 'feConvolveMatrix', |
| 3971 |
|
fediffuselighting => 'feDiffuseLighting', |
| 3972 |
|
fedisplacementmap => 'feDisplacementMap', |
| 3973 |
|
fedistantlight => 'feDistantLight', |
| 3974 |
|
feflood => 'feFlood', |
| 3975 |
|
fefunca => 'feFuncA', |
| 3976 |
|
fefuncb => 'feFuncB', |
| 3977 |
|
fefuncg => 'feFuncG', |
| 3978 |
|
fefuncr => 'feFuncR', |
| 3979 |
|
fegaussianblur => 'feGaussianBlur', |
| 3980 |
|
feimage => 'feImage', |
| 3981 |
|
femerge => 'feMerge', |
| 3982 |
|
femergenode => 'feMergeNode', |
| 3983 |
|
femorphology => 'feMorphology', |
| 3984 |
|
feoffset => 'feOffset', |
| 3985 |
|
fepointlight => 'fePointLight', |
| 3986 |
|
fespecularlighting => 'feSpecularLighting', |
| 3987 |
|
fespotlight => 'feSpotLight', |
| 3988 |
|
fetile => 'feTile', |
| 3989 |
|
feturbulence => 'feTurbulence', |
| 3990 |
|
foreignobject => 'foreignObject', |
| 3991 |
|
glyphref => 'glyphRef', |
| 3992 |
|
lineargradient => 'linearGradient', |
| 3993 |
|
radialgradient => 'radialGradient', |
| 3994 |
|
#solidcolor => 'solidColor', ## NOTE: Commented in spec (SVG1.2) |
| 3995 |
|
textpath => 'textPath', |
| 3996 |
|
}->{$tag_name} || $tag_name; |
| 3997 |
|
} |
| 3998 |
|
|
| 3999 |
|
## "adjust SVG attributes" (SVG only) - done in insert-element-f |
| 4000 |
|
|
| 4001 |
|
## "adjust foreign attributes" - done in insert-element-f |
| 4002 |
|
|
| 4003 |
|
!!!insert-element-f ($nsuri, $tag_name, $token->{attributes}, $token); |
| 4004 |
|
|
| 4005 |
|
if ($self->{self_closing}) { |
| 4006 |
|
pop @{$self->{open_elements}}; |
| 4007 |
|
!!!ack ('t87.3'); |
| 4008 |
|
} else { |
| 4009 |
|
!!!cp ('t87.4'); |
| 4010 |
|
} |
| 4011 |
|
|
| 4012 |
|
!!!next-token; |
| 4013 |
|
next B; |
| 4014 |
|
} |
| 4015 |
|
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 4016 |
|
## NOTE: "using the rules for secondary insertion mode" then "continue" |
| 4017 |
|
!!!cp ('t87.5'); |
| 4018 |
|
# |
| 4019 |
|
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 4020 |
|
## NOTE: "using the rules for secondary insertion mode" then "continue" |
| 4021 |
|
!!!cp ('t87.6'); |
| 4022 |
|
# |
| 4023 |
|
## TODO: ... |
| 4024 |
|
} else { |
| 4025 |
|
die "$0: $token->{type}: Unknown token type"; |
| 4026 |
|
} |
| 4027 |
|
} |
| 4028 |
|
|
| 4029 |
|
if ($self->{insertion_mode} & HEAD_IMS) { |
| 4030 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 4031 |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
if ($token->{data} =~ s/^([\x09\x0A\x0B\x0C\x20]+)//) { |
| 4032 |
unless ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
unless ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 4036 |
!!!cp ('t88.1'); |
!!!cp ('t88.1'); |
| 4037 |
## Ignore the token. |
## Ignore the token. |
| 4038 |
!!!next-token; |
!!!next-token; |
| 4039 |
redo B; |
next B; |
| 4040 |
} |
} |
| 4041 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 4042 |
!!!cp ('t88'); |
!!!cp ('t88'); |
| 4043 |
!!!next-token; |
!!!next-token; |
| 4044 |
redo B; |
next B; |
| 4045 |
} |
} |
| 4046 |
} |
} |
| 4047 |
|
|
| 4048 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 4049 |
!!!cp ('t89'); |
!!!cp ('t89'); |
| 4050 |
## As if <head> |
## As if <head> |
| 4051 |
!!!create-element ($self->{head_element}, 'head',, $token); |
!!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token); |
| 4052 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 4053 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, |
| 4054 |
|
[$self->{head_element}, $el_category->{head}]; |
| 4055 |
|
|
| 4056 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 4057 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4077 |
!!!cp ('t92'); |
!!!cp ('t92'); |
| 4078 |
} |
} |
| 4079 |
|
|
| 4080 |
## "after head" insertion mode |
## "after head" insertion mode |
| 4081 |
## As if <body> |
## As if <body> |
| 4082 |
!!!insert-element ('body',, $token); |
!!!insert-element ('body',, $token); |
| 4083 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 4084 |
## reprocess |
## reprocess |
| 4085 |
redo B; |
next B; |
| 4086 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 4087 |
if ($token->{tag_name} eq 'head') { |
if ($token->{tag_name} eq 'head') { |
| 4088 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 4089 |
!!!cp ('t93'); |
!!!cp ('t93'); |
| 4090 |
!!!create-element ($self->{head_element}, $token->{tag_name}, $token->{attributes}, $token); |
!!!create-element ($self->{head_element}, $HTML_NS, $token->{tag_name}, $token->{attributes}, $token); |
| 4091 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child |
| 4092 |
push @{$self->{open_elements}}, [$self->{head_element}, $token->{tag_name}]; |
($self->{head_element}); |
| 4093 |
$self->{insertion_mode} = IN_HEAD_IM; |
push @{$self->{open_elements}}, |
| 4094 |
!!!next-token; |
[$self->{head_element}, $el_category->{head}]; |
| 4095 |
redo B; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 4096 |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
!!!nack ('t93.1'); |
| 4097 |
!!!cp ('t94'); |
!!!next-token; |
| 4098 |
# |
next B; |
| 4099 |
} else { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4100 |
!!!cp ('t95'); |
!!!cp ('t94'); |
| 4101 |
!!!parse-error (type => 'in head:head', token => $token); # or in head noscript |
# |
| 4102 |
## Ignore the token |
} else { |
| 4103 |
!!!next-token; |
!!!cp ('t95'); |
| 4104 |
redo B; |
!!!parse-error (type => 'in head:head', token => $token); # or in head noscript |
| 4105 |
} |
## Ignore the token |
| 4106 |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
!!!nack ('t95.1'); |
| 4107 |
!!!cp ('t96'); |
!!!next-token; |
| 4108 |
## As if <head> |
next B; |
| 4109 |
!!!create-element ($self->{head_element}, 'head',, $token); |
} |
| 4110 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 4111 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
!!!cp ('t96'); |
| 4112 |
|
## As if <head> |
| 4113 |
|
!!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token); |
| 4114 |
|
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 4115 |
|
push @{$self->{open_elements}}, |
| 4116 |
|
[$self->{head_element}, $el_category->{head}]; |
| 4117 |
|
|
| 4118 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 4119 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 4120 |
} else { |
} else { |
| 4121 |
!!!cp ('t97'); |
!!!cp ('t97'); |
| 4122 |
} |
} |
| 4123 |
|
|
| 4124 |
if ($token->{tag_name} eq 'base') { |
if ($token->{tag_name} eq 'base') { |
| 4125 |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 4138 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4139 |
!!!cp ('t100'); |
!!!cp ('t100'); |
| 4140 |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 4141 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, |
| 4142 |
|
[$self->{head_element}, $el_category->{head}]; |
| 4143 |
} else { |
} else { |
| 4144 |
!!!cp ('t101'); |
!!!cp ('t101'); |
| 4145 |
} |
} |
| 4147 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 4148 |
pop @{$self->{open_elements}} # <head> |
pop @{$self->{open_elements}} # <head> |
| 4149 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 4150 |
|
!!!nack ('t101.1'); |
| 4151 |
!!!next-token; |
!!!next-token; |
| 4152 |
redo B; |
next B; |
| 4153 |
} elsif ($token->{tag_name} eq 'link') { |
} elsif ($token->{tag_name} eq 'link') { |
| 4154 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 4155 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4156 |
!!!cp ('t102'); |
!!!cp ('t102'); |
| 4157 |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 4158 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, |
| 4159 |
|
[$self->{head_element}, $el_category->{head}]; |
| 4160 |
} else { |
} else { |
| 4161 |
!!!cp ('t103'); |
!!!cp ('t103'); |
| 4162 |
} |
} |
| 4164 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 4165 |
pop @{$self->{open_elements}} # <head> |
pop @{$self->{open_elements}} # <head> |
| 4166 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 4167 |
|
!!!ack ('t103.1'); |
| 4168 |
!!!next-token; |
!!!next-token; |
| 4169 |
redo B; |
next B; |
| 4170 |
} elsif ($token->{tag_name} eq 'meta') { |
} elsif ($token->{tag_name} eq 'meta') { |
| 4171 |
## NOTE: There is a "as if in head" code clone. |
## NOTE: There is a "as if in head" code clone. |
| 4172 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4173 |
!!!cp ('t104'); |
!!!cp ('t104'); |
| 4174 |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 4175 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, |
| 4176 |
|
[$self->{head_element}, $el_category->{head}]; |
| 4177 |
} else { |
} else { |
| 4178 |
!!!cp ('t105'); |
!!!cp ('t105'); |
| 4179 |
} |
} |
| 4181 |
my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 4182 |
|
|
| 4183 |
unless ($self->{confident}) { |
unless ($self->{confident}) { |
| 4184 |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
if ($token->{attributes}->{charset}) { |
| 4185 |
!!!cp ('t106'); |
!!!cp ('t106'); |
| 4186 |
|
## NOTE: Whether the encoding is supported or not is handled |
| 4187 |
|
## in the {change_encoding} callback. |
| 4188 |
$self->{change_encoding} |
$self->{change_encoding} |
| 4189 |
->($self, $token->{attributes}->{charset}->{value}, |
->($self, $token->{attributes}->{charset}->{value}, |
| 4190 |
$token); |
$token); |
| 4194 |
$token->{attributes}->{charset} |
$token->{attributes}->{charset} |
| 4195 |
->{has_reference}); |
->{has_reference}); |
| 4196 |
} elsif ($token->{attributes}->{content}) { |
} elsif ($token->{attributes}->{content}) { |
|
## ISSUE: Algorithm name in the spec was incorrect so that not linked to the definition. |
|
| 4197 |
if ($token->{attributes}->{content}->{value} |
if ($token->{attributes}->{content}->{value} |
| 4198 |
=~ /\A[^;]*;[\x09-\x0D\x20]*[Cc][Hh][Aa][Rr][Ss][Ee][Tt] |
=~ /\A[^;]*;[\x09-\x0D\x20]*[Cc][Hh][Aa][Rr][Ss][Ee][Tt] |
| 4199 |
[\x09-\x0D\x20]*= |
[\x09-\x0D\x20]*= |
| 4200 |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
| 4201 |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
| 4202 |
!!!cp ('t107'); |
!!!cp ('t107'); |
| 4203 |
|
## NOTE: Whether the encoding is supported or not is handled |
| 4204 |
|
## in the {change_encoding} callback. |
| 4205 |
$self->{change_encoding} |
$self->{change_encoding} |
| 4206 |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3, |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3, |
| 4207 |
$token); |
$token); |
| 4232 |
|
|
| 4233 |
pop @{$self->{open_elements}} # <head> |
pop @{$self->{open_elements}} # <head> |
| 4234 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 4235 |
|
!!!ack ('t110.1'); |
| 4236 |
!!!next-token; |
!!!next-token; |
| 4237 |
redo B; |
next B; |
| 4238 |
} elsif ($token->{tag_name} eq 'title') { |
} elsif ($token->{tag_name} eq 'title') { |
| 4239 |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 4240 |
!!!cp ('t111'); |
!!!cp ('t111'); |
| 4247 |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4248 |
!!!cp ('t112'); |
!!!cp ('t112'); |
| 4249 |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 4250 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, |
| 4251 |
|
[$self->{head_element}, $el_category->{head}]; |
| 4252 |
} else { |
} else { |
| 4253 |
!!!cp ('t113'); |
!!!cp ('t113'); |
| 4254 |
} |
} |
| 4259 |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
| 4260 |
pop @{$self->{open_elements}} # <head> |
pop @{$self->{open_elements}} # <head> |
| 4261 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 4262 |
redo B; |
next B; |
| 4263 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 4264 |
## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and |
## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and |
| 4265 |
## insertion mode IN_HEAD_IM) |
## insertion mode IN_HEAD_IM) |
| 4267 |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
if ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4268 |
!!!cp ('t114'); |
!!!cp ('t114'); |
| 4269 |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 4270 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, |
| 4271 |
|
[$self->{head_element}, $el_category->{head}]; |
| 4272 |
} else { |
} else { |
| 4273 |
!!!cp ('t115'); |
!!!cp ('t115'); |
| 4274 |
} |
} |
| 4275 |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 4276 |
pop @{$self->{open_elements}} # <head> |
pop @{$self->{open_elements}} # <head> |
| 4277 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 4278 |
redo B; |
next B; |
| 4279 |
} elsif ($token->{tag_name} eq 'noscript') { |
} elsif ($token->{tag_name} eq 'noscript') { |
| 4280 |
if ($self->{insertion_mode} == IN_HEAD_IM) { |
if ($self->{insertion_mode} == IN_HEAD_IM) { |
| 4281 |
!!!cp ('t116'); |
!!!cp ('t116'); |
| 4282 |
## NOTE: and scripting is disalbed |
## NOTE: and scripting is disalbed |
| 4283 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 4284 |
$self->{insertion_mode} = IN_HEAD_NOSCRIPT_IM; |
$self->{insertion_mode} = IN_HEAD_NOSCRIPT_IM; |
| 4285 |
|
!!!nack ('t116.1'); |
| 4286 |
!!!next-token; |
!!!next-token; |
| 4287 |
redo B; |
next B; |
| 4288 |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 4289 |
!!!cp ('t117'); |
!!!cp ('t117'); |
| 4290 |
!!!parse-error (type => 'in noscript:noscript', token => $token); |
!!!parse-error (type => 'in noscript:noscript', token => $token); |
| 4291 |
## Ignore the token |
## Ignore the token |
| 4292 |
|
!!!nack ('t117.1'); |
| 4293 |
!!!next-token; |
!!!next-token; |
| 4294 |
redo B; |
next B; |
| 4295 |
} else { |
} else { |
| 4296 |
!!!cp ('t118'); |
!!!cp ('t118'); |
| 4297 |
# |
# |
| 4308 |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
} elsif ($self->{insertion_mode} == AFTER_HEAD_IM) { |
| 4309 |
!!!cp ('t120'); |
!!!cp ('t120'); |
| 4310 |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after head:'.$token->{tag_name}, token => $token); |
| 4311 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, |
| 4312 |
|
[$self->{head_element}, $el_category->{head}]; |
| 4313 |
} else { |
} else { |
| 4314 |
!!!cp ('t121'); |
!!!cp ('t121'); |
| 4315 |
} |
} |
| 4318 |
$script_start_tag->(); |
$script_start_tag->(); |
| 4319 |
pop @{$self->{open_elements}} # <head> |
pop @{$self->{open_elements}} # <head> |
| 4320 |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
if $self->{insertion_mode} == AFTER_HEAD_IM; |
| 4321 |
redo B; |
next B; |
| 4322 |
} elsif ($token->{tag_name} eq 'body' or |
} elsif ($token->{tag_name} eq 'body' or |
| 4323 |
$token->{tag_name} eq 'frameset') { |
$token->{tag_name} eq 'frameset') { |
| 4324 |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 4352 |
} else { |
} else { |
| 4353 |
die "$0: tag name: $self->{tag_name}"; |
die "$0: tag name: $self->{tag_name}"; |
| 4354 |
} |
} |
| 4355 |
|
!!!nack ('t127.1'); |
| 4356 |
!!!next-token; |
!!!next-token; |
| 4357 |
redo B; |
next B; |
| 4358 |
} else { |
} else { |
| 4359 |
!!!cp ('t128'); |
!!!cp ('t128'); |
| 4360 |
# |
# |
| 4386 |
!!!insert-element ('body',, $token); |
!!!insert-element ('body',, $token); |
| 4387 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 4388 |
## reprocess |
## reprocess |
| 4389 |
redo B; |
!!!ack-later; |
| 4390 |
|
next B; |
| 4391 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 4392 |
if ($token->{tag_name} eq 'head') { |
if ($token->{tag_name} eq 'head') { |
| 4393 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 4394 |
!!!cp ('t132'); |
!!!cp ('t132'); |
| 4395 |
## As if <head> |
## As if <head> |
| 4396 |
!!!create-element ($self->{head_element}, 'head',, $token); |
!!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token); |
| 4397 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 4398 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, |
| 4399 |
|
[$self->{head_element}, $el_category->{head}]; |
| 4400 |
|
|
| 4401 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 4402 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4403 |
$self->{insertion_mode} = AFTER_HEAD_IM; |
$self->{insertion_mode} = AFTER_HEAD_IM; |
| 4404 |
!!!next-token; |
!!!next-token; |
| 4405 |
redo B; |
next B; |
| 4406 |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
} elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) { |
| 4407 |
!!!cp ('t133'); |
!!!cp ('t133'); |
| 4408 |
## As if </noscript> |
## As if </noscript> |
| 4413 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4414 |
$self->{insertion_mode} = AFTER_HEAD_IM; |
$self->{insertion_mode} = AFTER_HEAD_IM; |
| 4415 |
!!!next-token; |
!!!next-token; |
| 4416 |
redo B; |
next B; |
| 4417 |
} elsif ($self->{insertion_mode} == IN_HEAD_IM) { |
} elsif ($self->{insertion_mode} == IN_HEAD_IM) { |
| 4418 |
!!!cp ('t134'); |
!!!cp ('t134'); |
| 4419 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4420 |
$self->{insertion_mode} = AFTER_HEAD_IM; |
$self->{insertion_mode} = AFTER_HEAD_IM; |
| 4421 |
!!!next-token; |
!!!next-token; |
| 4422 |
redo B; |
next B; |
| 4423 |
} else { |
} else { |
| 4424 |
!!!cp ('t135'); |
!!!cp ('t135'); |
| 4425 |
# |
# |
| 4430 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4431 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 4432 |
!!!next-token; |
!!!next-token; |
| 4433 |
redo B; |
next B; |
| 4434 |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
} elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 4435 |
!!!cp ('t137'); |
!!!cp ('t137'); |
| 4436 |
!!!parse-error (type => 'unmatched end tag:noscript', token => $token); |
!!!parse-error (type => 'unmatched end tag:noscript', token => $token); |
| 4437 |
## Ignore the token ## ISSUE: An issue in the spec. |
## Ignore the token ## ISSUE: An issue in the spec. |
| 4438 |
!!!next-token; |
!!!next-token; |
| 4439 |
redo B; |
next B; |
| 4440 |
} else { |
} else { |
| 4441 |
!!!cp ('t138'); |
!!!cp ('t138'); |
| 4442 |
# |
# |
| 4447 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 4448 |
!!!cp ('t139'); |
!!!cp ('t139'); |
| 4449 |
## As if <head> |
## As if <head> |
| 4450 |
!!!create-element ($self->{head_element}, 'head',, $token); |
!!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token); |
| 4451 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 4452 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, |
| 4453 |
|
[$self->{head_element}, $el_category->{head}]; |
| 4454 |
|
|
| 4455 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 4456 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 4459 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4460 |
## Ignore the token |
## Ignore the token |
| 4461 |
!!!next-token; |
!!!next-token; |
| 4462 |
redo B; |
next B; |
| 4463 |
} else { |
} else { |
| 4464 |
!!!cp ('t141'); |
!!!cp ('t141'); |
| 4465 |
} |
} |
| 4471 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 4472 |
!!!cp ('t142'); |
!!!cp ('t142'); |
| 4473 |
## As if <head> |
## As if <head> |
| 4474 |
!!!create-element ($self->{head_element}, 'head',, $token); |
!!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token); |
| 4475 |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
$self->{open_elements}->[-1]->[0]->append_child ($self->{head_element}); |
| 4476 |
push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
push @{$self->{open_elements}}, |
| 4477 |
|
[$self->{head_element}, $el_category->{head}]; |
| 4478 |
|
|
| 4479 |
$self->{insertion_mode} = IN_HEAD_IM; |
$self->{insertion_mode} = IN_HEAD_IM; |
| 4480 |
## Reprocess in the "in head" insertion mode... |
## Reprocess in the "in head" insertion mode... |
| 4492 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4493 |
## Ignore the token |
## Ignore the token |
| 4494 |
!!!next-token; |
!!!next-token; |
| 4495 |
redo B; |
next B; |
| 4496 |
} |
} |
| 4497 |
} |
} |
| 4498 |
|
|
| 4519 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4520 |
## Ignore the token ## ISSUE: An issue in the spec. |
## Ignore the token ## ISSUE: An issue in the spec. |
| 4521 |
!!!next-token; |
!!!next-token; |
| 4522 |
redo B; |
next B; |
| 4523 |
} else { |
} else { |
| 4524 |
!!!cp ('t149'); |
!!!cp ('t149'); |
| 4525 |
} |
} |
| 4529 |
!!!insert-element ('body',, $token); |
!!!insert-element ('body',, $token); |
| 4530 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 4531 |
## reprocess |
## reprocess |
| 4532 |
redo B; |
next B; |
| 4533 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 4534 |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
if ($self->{insertion_mode} == BEFORE_HEAD_IM) { |
| 4535 |
!!!cp ('t149.1'); |
!!!cp ('t149.1'); |
| 4536 |
|
|
| 4537 |
## NOTE: As if <head> |
## NOTE: As if <head> |
| 4538 |
!!!create-element ($self->{head_element}, 'head',, $token); |
!!!create-element ($self->{head_element}, $HTML_NS, 'head',, $token); |
| 4539 |
$self->{open_elements}->[-1]->[0]->append_child |
$self->{open_elements}->[-1]->[0]->append_child |
| 4540 |
($self->{head_element}); |
($self->{head_element}); |
| 4541 |
#push @{$self->{open_elements}}, [$self->{head_element}, 'head']; |
#push @{$self->{open_elements}}, |
| 4542 |
|
# [$self->{head_element}, $el_category->{head}]; |
| 4543 |
#$self->{insertion_mode} = IN_HEAD_IM; |
#$self->{insertion_mode} = IN_HEAD_IM; |
| 4544 |
## NOTE: Reprocess. |
## NOTE: Reprocess. |
| 4545 |
|
|
| 4583 |
!!!insert-element ('body',, $token); |
!!!insert-element ('body',, $token); |
| 4584 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 4585 |
## NOTE: Reprocess. |
## NOTE: Reprocess. |
| 4586 |
redo B; |
next B; |
| 4587 |
} else { |
} else { |
| 4588 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 4589 |
} |
} |
| 4598 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 4599 |
|
|
| 4600 |
!!!next-token; |
!!!next-token; |
| 4601 |
redo B; |
next B; |
| 4602 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 4603 |
if ({ |
if ({ |
| 4604 |
caption => 1, col => 1, colgroup => 1, tbody => 1, |
caption => 1, col => 1, colgroup => 1, tbody => 1, |
| 4608 |
## have an element in table scope |
## have an element in table scope |
| 4609 |
for (reverse 0..$#{$self->{open_elements}}) { |
for (reverse 0..$#{$self->{open_elements}}) { |
| 4610 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4611 |
if ($node->[1] eq 'td' or $node->[1] eq 'th') { |
if ($node->[1] & TABLE_CELL_EL) { |
| 4612 |
!!!cp ('t151'); |
!!!cp ('t151'); |
| 4613 |
|
|
| 4614 |
## Close the cell |
## Close the cell |
| 4615 |
!!!back-token; # <?> |
!!!back-token; # <x> |
| 4616 |
$token = {type => END_TAG_TOKEN, tag_name => $node->[1], |
$token = {type => END_TAG_TOKEN, |
| 4617 |
|
tag_name => $node->[0]->manakai_local_name, |
| 4618 |
line => $token->{line}, |
line => $token->{line}, |
| 4619 |
column => $token->{column}}; |
column => $token->{column}}; |
| 4620 |
redo B; |
next B; |
| 4621 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 4622 |
!!!cp ('t152'); |
!!!cp ('t152'); |
| 4623 |
## ISSUE: This case can never be reached, maybe. |
## ISSUE: This case can never be reached, maybe. |
| 4624 |
last; |
last; |
| 4629 |
!!!parse-error (type => 'start tag not allowed', |
!!!parse-error (type => 'start tag not allowed', |
| 4630 |
value => $token->{tag_name}, token => $token); |
value => $token->{tag_name}, token => $token); |
| 4631 |
## Ignore the token |
## Ignore the token |
| 4632 |
|
!!!nack ('t153.1'); |
| 4633 |
!!!next-token; |
!!!next-token; |
| 4634 |
redo B; |
next B; |
| 4635 |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
| 4636 |
!!!parse-error (type => 'not closed:caption', token => $token); |
!!!parse-error (type => 'not closed:caption', token => $token); |
| 4637 |
|
|
| 4641 |
INSCOPE: { |
INSCOPE: { |
| 4642 |
for (reverse 0..$#{$self->{open_elements}}) { |
for (reverse 0..$#{$self->{open_elements}}) { |
| 4643 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4644 |
if ($node->[1] eq 'caption') { |
if ($node->[1] & CAPTION_EL) { |
| 4645 |
!!!cp ('t155'); |
!!!cp ('t155'); |
| 4646 |
$i = $_; |
$i = $_; |
| 4647 |
last INSCOPE; |
last INSCOPE; |
| 4648 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 4649 |
!!!cp ('t156'); |
!!!cp ('t156'); |
| 4650 |
last; |
last; |
| 4651 |
} |
} |
| 4655 |
!!!parse-error (type => 'start tag not allowed', |
!!!parse-error (type => 'start tag not allowed', |
| 4656 |
value => $token->{tag_name}, token => $token); |
value => $token->{tag_name}, token => $token); |
| 4657 |
## Ignore the token |
## Ignore the token |
| 4658 |
|
!!!nack ('t157.1'); |
| 4659 |
!!!next-token; |
!!!next-token; |
| 4660 |
redo B; |
next B; |
| 4661 |
} # INSCOPE |
} # INSCOPE |
| 4662 |
|
|
| 4663 |
## generate implied end tags |
## generate implied end tags |
| 4664 |
while ({ |
while ($self->{open_elements}->[-1]->[1] |
| 4665 |
dd => 1, dt => 1, li => 1, p => 1, |
& END_TAG_OPTIONAL_EL) { |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4666 |
!!!cp ('t158'); |
!!!cp ('t158'); |
| 4667 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4668 |
} |
} |
| 4669 |
|
|
| 4670 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) { |
| 4671 |
!!!cp ('t159'); |
!!!cp ('t159'); |
| 4672 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
!!!parse-error (type => 'not closed', |
| 4673 |
|
value => $self->{open_elements}->[-1]->[0] |
| 4674 |
|
->manakai_local_name, |
| 4675 |
|
token => $token); |
| 4676 |
} else { |
} else { |
| 4677 |
!!!cp ('t160'); |
!!!cp ('t160'); |
| 4678 |
} |
} |
| 4684 |
$self->{insertion_mode} = IN_TABLE_IM; |
$self->{insertion_mode} = IN_TABLE_IM; |
| 4685 |
|
|
| 4686 |
## reprocess |
## reprocess |
| 4687 |
redo B; |
!!!ack-later; |
| 4688 |
|
next B; |
| 4689 |
} else { |
} else { |
| 4690 |
!!!cp ('t161'); |
!!!cp ('t161'); |
| 4691 |
# |
# |
| 4701 |
my $i; |
my $i; |
| 4702 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4703 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4704 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[0]->manakai_local_name eq $token->{tag_name}) { |
| 4705 |
!!!cp ('t163'); |
!!!cp ('t163'); |
| 4706 |
$i = $_; |
$i = $_; |
| 4707 |
last INSCOPE; |
last INSCOPE; |
| 4708 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 4709 |
!!!cp ('t164'); |
!!!cp ('t164'); |
| 4710 |
last INSCOPE; |
last INSCOPE; |
| 4711 |
} |
} |
| 4715 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4716 |
## Ignore the token |
## Ignore the token |
| 4717 |
!!!next-token; |
!!!next-token; |
| 4718 |
redo B; |
next B; |
| 4719 |
} |
} |
| 4720 |
|
|
| 4721 |
## generate implied end tags |
## generate implied end tags |
| 4722 |
while ({ |
while ($self->{open_elements}->[-1]->[1] |
| 4723 |
dd => 1, dt => 1, li => 1, p => 1, |
& END_TAG_OPTIONAL_EL) { |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4724 |
!!!cp ('t166'); |
!!!cp ('t166'); |
| 4725 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4726 |
} |
} |
| 4727 |
|
|
| 4728 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[0]->manakai_local_name |
| 4729 |
|
ne $token->{tag_name}) { |
| 4730 |
!!!cp ('t167'); |
!!!cp ('t167'); |
| 4731 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
!!!parse-error (type => 'not closed', |
| 4732 |
|
value => $self->{open_elements}->[-1]->[0] |
| 4733 |
|
->manakai_local_name, |
| 4734 |
|
token => $token); |
| 4735 |
} else { |
} else { |
| 4736 |
!!!cp ('t168'); |
!!!cp ('t168'); |
| 4737 |
} |
} |
| 4743 |
$self->{insertion_mode} = IN_ROW_IM; |
$self->{insertion_mode} = IN_ROW_IM; |
| 4744 |
|
|
| 4745 |
!!!next-token; |
!!!next-token; |
| 4746 |
redo B; |
next B; |
| 4747 |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
} elsif ($self->{insertion_mode} == IN_CAPTION_IM) { |
| 4748 |
!!!cp ('t169'); |
!!!cp ('t169'); |
| 4749 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4750 |
## Ignore the token |
## Ignore the token |
| 4751 |
!!!next-token; |
!!!next-token; |
| 4752 |
redo B; |
next B; |
| 4753 |
} else { |
} else { |
| 4754 |
!!!cp ('t170'); |
!!!cp ('t170'); |
| 4755 |
# |
# |
| 4761 |
INSCOPE: { |
INSCOPE: { |
| 4762 |
for (reverse 0..$#{$self->{open_elements}}) { |
for (reverse 0..$#{$self->{open_elements}}) { |
| 4763 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4764 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] & CAPTION_EL) { |
| 4765 |
!!!cp ('t171'); |
!!!cp ('t171'); |
| 4766 |
$i = $_; |
$i = $_; |
| 4767 |
last INSCOPE; |
last INSCOPE; |
| 4768 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 4769 |
!!!cp ('t172'); |
!!!cp ('t172'); |
| 4770 |
last; |
last; |
| 4771 |
} |
} |
| 4776 |
value => $token->{tag_name}, token => $token); |
value => $token->{tag_name}, token => $token); |
| 4777 |
## Ignore the token |
## Ignore the token |
| 4778 |
!!!next-token; |
!!!next-token; |
| 4779 |
redo B; |
next B; |
| 4780 |
} # INSCOPE |
} # INSCOPE |
| 4781 |
|
|
| 4782 |
## generate implied end tags |
## generate implied end tags |
| 4783 |
while ({ |
while ($self->{open_elements}->[-1]->[1] |
| 4784 |
dd => 1, dt => 1, li => 1, p => 1, |
& END_TAG_OPTIONAL_EL) { |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4785 |
!!!cp ('t174'); |
!!!cp ('t174'); |
| 4786 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4787 |
} |
} |
| 4788 |
|
|
| 4789 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) { |
| 4790 |
!!!cp ('t175'); |
!!!cp ('t175'); |
| 4791 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
!!!parse-error (type => 'not closed', |
| 4792 |
|
value => $self->{open_elements}->[-1]->[0] |
| 4793 |
|
->manakai_local_name, |
| 4794 |
|
token => $token); |
| 4795 |
} else { |
} else { |
| 4796 |
!!!cp ('t176'); |
!!!cp ('t176'); |
| 4797 |
} |
} |
| 4803 |
$self->{insertion_mode} = IN_TABLE_IM; |
$self->{insertion_mode} = IN_TABLE_IM; |
| 4804 |
|
|
| 4805 |
!!!next-token; |
!!!next-token; |
| 4806 |
redo B; |
next B; |
| 4807 |
} elsif ($self->{insertion_mode} == IN_CELL_IM) { |
} elsif ($self->{insertion_mode} == IN_CELL_IM) { |
| 4808 |
!!!cp ('t177'); |
!!!cp ('t177'); |
| 4809 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4810 |
## Ignore the token |
## Ignore the token |
| 4811 |
!!!next-token; |
!!!next-token; |
| 4812 |
redo B; |
next B; |
| 4813 |
} else { |
} else { |
| 4814 |
!!!cp ('t178'); |
!!!cp ('t178'); |
| 4815 |
# |
# |
| 4825 |
INSCOPE: { |
INSCOPE: { |
| 4826 |
for (reverse 0..$#{$self->{open_elements}}) { |
for (reverse 0..$#{$self->{open_elements}}) { |
| 4827 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4828 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[0]->manakai_local_name eq $token->{tag_name}) { |
| 4829 |
!!!cp ('t179'); |
!!!cp ('t179'); |
| 4830 |
$i = $_; |
$i = $_; |
| 4831 |
|
|
| 4832 |
## Close the cell |
## Close the cell |
| 4833 |
!!!back-token; # </?> |
!!!back-token; # </x> |
| 4834 |
$token = {type => END_TAG_TOKEN, tag_name => $tn, |
$token = {type => END_TAG_TOKEN, tag_name => $tn, |
| 4835 |
line => $token->{line}, |
line => $token->{line}, |
| 4836 |
column => $token->{column}}; |
column => $token->{column}}; |
| 4837 |
redo B; |
next B; |
| 4838 |
} elsif ($node->[1] eq 'td' or $node->[1] eq 'th') { |
} elsif ($node->[1] & TABLE_CELL_EL) { |
| 4839 |
!!!cp ('t180'); |
!!!cp ('t180'); |
| 4840 |
$tn = $node->[1]; |
$tn = $node->[0]->manakai_local_name; |
| 4841 |
## NOTE: There is exactly one |td| or |th| element |
## NOTE: There is exactly one |td| or |th| element |
| 4842 |
## in scope in the stack of open elements by definition. |
## in scope in the stack of open elements by definition. |
| 4843 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 4844 |
## ISSUE: Can this be reached? |
## ISSUE: Can this be reached? |
| 4845 |
!!!cp ('t181'); |
!!!cp ('t181'); |
| 4846 |
last; |
last; |
| 4852 |
value => $token->{tag_name}, token => $token); |
value => $token->{tag_name}, token => $token); |
| 4853 |
## Ignore the token |
## Ignore the token |
| 4854 |
!!!next-token; |
!!!next-token; |
| 4855 |
redo B; |
next B; |
| 4856 |
} # INSCOPE |
} # INSCOPE |
| 4857 |
} elsif ($token->{tag_name} eq 'table' and |
} elsif ($token->{tag_name} eq 'table' and |
| 4858 |
$self->{insertion_mode} == IN_CAPTION_IM) { |
$self->{insertion_mode} == IN_CAPTION_IM) { |
| 4863 |
my $i; |
my $i; |
| 4864 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4865 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 4866 |
if ($node->[1] eq 'caption') { |
if ($node->[1] & CAPTION_EL) { |
| 4867 |
!!!cp ('t184'); |
!!!cp ('t184'); |
| 4868 |
$i = $_; |
$i = $_; |
| 4869 |
last INSCOPE; |
last INSCOPE; |
| 4870 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 4871 |
!!!cp ('t185'); |
!!!cp ('t185'); |
| 4872 |
last INSCOPE; |
last INSCOPE; |
| 4873 |
} |
} |
| 4877 |
!!!parse-error (type => 'unmatched end tag:caption', token => $token); |
!!!parse-error (type => 'unmatched end tag:caption', token => $token); |
| 4878 |
## Ignore the token |
## Ignore the token |
| 4879 |
!!!next-token; |
!!!next-token; |
| 4880 |
redo B; |
next B; |
| 4881 |
} |
} |
| 4882 |
|
|
| 4883 |
## generate implied end tags |
## generate implied end tags |
| 4884 |
while ({ |
while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) { |
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4885 |
!!!cp ('t187'); |
!!!cp ('t187'); |
| 4886 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 4887 |
} |
} |
| 4888 |
|
|
| 4889 |
if ($self->{open_elements}->[-1]->[1] ne 'caption') { |
unless ($self->{open_elements}->[-1]->[1] & CAPTION_EL) { |
| 4890 |
!!!cp ('t188'); |
!!!cp ('t188'); |
| 4891 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
!!!parse-error (type => 'not closed', |
| 4892 |
|
value => $self->{open_elements}->[-1]->[0] |
| 4893 |
|
->manakai_local_name, |
| 4894 |
|
token => $token); |
| 4895 |
} else { |
} else { |
| 4896 |
!!!cp ('t189'); |
!!!cp ('t189'); |
| 4897 |
} |
} |
| 4903 |
$self->{insertion_mode} = IN_TABLE_IM; |
$self->{insertion_mode} = IN_TABLE_IM; |
| 4904 |
|
|
| 4905 |
## reprocess |
## reprocess |
| 4906 |
redo B; |
next B; |
| 4907 |
} elsif ({ |
} elsif ({ |
| 4908 |
body => 1, col => 1, colgroup => 1, html => 1, |
body => 1, col => 1, colgroup => 1, html => 1, |
| 4909 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 4912 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4913 |
## Ignore the token |
## Ignore the token |
| 4914 |
!!!next-token; |
!!!next-token; |
| 4915 |
redo B; |
next B; |
| 4916 |
} else { |
} else { |
| 4917 |
!!!cp ('t191'); |
!!!cp ('t191'); |
| 4918 |
# |
# |
| 4926 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 4927 |
## Ignore the token |
## Ignore the token |
| 4928 |
!!!next-token; |
!!!next-token; |
| 4929 |
redo B; |
next B; |
| 4930 |
} else { |
} else { |
| 4931 |
!!!cp ('t193'); |
!!!cp ('t193'); |
| 4932 |
# |
# |
| 4933 |
} |
} |
| 4934 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 4935 |
for my $entry (@{$self->{open_elements}}) { |
for my $entry (@{$self->{open_elements}}) { |
| 4936 |
if (not { |
unless ($entry->[1] & ALL_END_TAG_OPTIONAL_EL) { |
|
dd => 1, dt => 1, li => 1, p => 1, tbody => 1, td => 1, tfoot => 1, |
|
|
th => 1, thead => 1, tr => 1, body => 1, html => 1, |
|
|
}->{$entry->[1]}) { |
|
| 4937 |
!!!cp ('t75'); |
!!!cp ('t75'); |
| 4938 |
!!!parse-error (type => 'in body:#eof', token => $token); |
!!!parse-error (type => 'in body:#eof', token => $token); |
| 4939 |
last; |
last; |
| 4957 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 4958 |
!!!cp ('t194'); |
!!!cp ('t194'); |
| 4959 |
!!!next-token; |
!!!next-token; |
| 4960 |
redo B; |
next B; |
| 4961 |
} else { |
} else { |
| 4962 |
!!!cp ('t195'); |
!!!cp ('t195'); |
| 4963 |
} |
} |
| 4971 |
## result in a new Text node. |
## result in a new Text node. |
| 4972 |
$reconstruct_active_formatting_elements->($insert_to_foster); |
$reconstruct_active_formatting_elements->($insert_to_foster); |
| 4973 |
|
|
| 4974 |
if ({ |
if ($self->{open_elements}->[-1]->[1] & TABLE_ROWS_EL) { |
|
table => 1, tbody => 1, tfoot => 1, |
|
|
thead => 1, tr => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 4975 |
# MUST |
# MUST |
| 4976 |
my $foster_parent_element; |
my $foster_parent_element; |
| 4977 |
my $next_sibling; |
my $next_sibling; |
| 4978 |
my $prev_sibling; |
my $prev_sibling; |
| 4979 |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
OE: for (reverse 0..$#{$self->{open_elements}}) { |
| 4980 |
if ($self->{open_elements}->[$_]->[1] eq 'table') { |
if ($self->{open_elements}->[$_]->[1] & TABLE_EL) { |
| 4981 |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
my $parent = $self->{open_elements}->[$_]->[0]->parent_node; |
| 4982 |
if (defined $parent and $parent->node_type == 1) { |
if (defined $parent and $parent->node_type == 1) { |
| 4983 |
!!!cp ('t196'); |
!!!cp ('t196'); |
| 5012 |
} |
} |
| 5013 |
|
|
| 5014 |
!!!next-token; |
!!!next-token; |
| 5015 |
redo B; |
next B; |
| 5016 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 5017 |
if ({ |
if ({ |
| 5018 |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
tr => ($self->{insertion_mode} != IN_ROW_IM), |
| 5020 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5021 |
if ($self->{insertion_mode} == IN_TABLE_IM) { |
if ($self->{insertion_mode} == IN_TABLE_IM) { |
| 5022 |
## Clear back to table context |
## Clear back to table context |
| 5023 |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
while (not ($self->{open_elements}->[-1]->[1] |
| 5024 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
& TABLE_SCOPING_EL)) { |
| 5025 |
!!!cp ('t201'); |
!!!cp ('t201'); |
| 5026 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5027 |
} |
} |
| 5038 |
} |
} |
| 5039 |
|
|
| 5040 |
## Clear back to table body context |
## Clear back to table body context |
| 5041 |
while (not { |
while (not ($self->{open_elements}->[-1]->[1] |
| 5042 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
& TABLE_ROWS_SCOPING_EL)) { |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 5043 |
!!!cp ('t203'); |
!!!cp ('t203'); |
| 5044 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
| 5045 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5049 |
if ($token->{tag_name} eq 'tr') { |
if ($token->{tag_name} eq 'tr') { |
| 5050 |
!!!cp ('t204'); |
!!!cp ('t204'); |
| 5051 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 5052 |
|
!!!nack ('t204'); |
| 5053 |
!!!next-token; |
!!!next-token; |
| 5054 |
redo B; |
next B; |
| 5055 |
} else { |
} else { |
| 5056 |
!!!cp ('t205'); |
!!!cp ('t205'); |
| 5057 |
!!!insert-element ('tr',, $token); |
!!!insert-element ('tr',, $token); |
| 5062 |
} |
} |
| 5063 |
|
|
| 5064 |
## Clear back to table row context |
## Clear back to table row context |
| 5065 |
while (not { |
while (not ($self->{open_elements}->[-1]->[1] |
| 5066 |
tr => 1, html => 1, |
& TABLE_ROW_SCOPING_EL)) { |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 5067 |
!!!cp ('t207'); |
!!!cp ('t207'); |
| 5068 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5069 |
} |
} |
| 5073 |
|
|
| 5074 |
push @$active_formatting_elements, ['#marker', '']; |
push @$active_formatting_elements, ['#marker', '']; |
| 5075 |
|
|
| 5076 |
|
!!!nack ('t207.1'); |
| 5077 |
!!!next-token; |
!!!next-token; |
| 5078 |
redo B; |
next B; |
| 5079 |
} elsif ({ |
} elsif ({ |
| 5080 |
caption => 1, col => 1, colgroup => 1, |
caption => 1, col => 1, colgroup => 1, |
| 5081 |
tbody => 1, tfoot => 1, thead => 1, |
tbody => 1, tfoot => 1, thead => 1, |
| 5087 |
my $i; |
my $i; |
| 5088 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5089 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5090 |
if ($node->[1] eq 'tr') { |
if ($node->[1] & TABLE_ROW_EL) { |
| 5091 |
!!!cp ('t208'); |
!!!cp ('t208'); |
| 5092 |
$i = $_; |
$i = $_; |
| 5093 |
last INSCOPE; |
last INSCOPE; |
| 5094 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
html => 1, |
|
|
|
|
|
## NOTE: This element does not appear here, maybe. |
|
|
table => 1, |
|
|
}->{$node->[1]}) { |
|
| 5095 |
!!!cp ('t209'); |
!!!cp ('t209'); |
| 5096 |
last INSCOPE; |
last INSCOPE; |
| 5097 |
} |
} |
| 5098 |
} # INSCOPE |
} # INSCOPE |
| 5099 |
unless (defined $i) { |
unless (defined $i) { |
| 5100 |
!!!cp ('t210'); |
!!!cp ('t210'); |
| 5101 |
## TODO: This type is wrong. |
## TODO: This type is wrong. |
| 5102 |
!!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmacthed end tag:'.$token->{tag_name}, token => $token); |
| 5103 |
## Ignore the token |
## Ignore the token |
| 5104 |
|
!!!nack ('t210.1'); |
| 5105 |
!!!next-token; |
!!!next-token; |
| 5106 |
redo B; |
next B; |
| 5107 |
} |
} |
| 5108 |
|
|
| 5109 |
## Clear back to table row context |
## Clear back to table row context |
| 5110 |
while (not { |
while (not ($self->{open_elements}->[-1]->[1] |
| 5111 |
tr => 1, html => 1, |
& TABLE_ROW_SCOPING_EL)) { |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 5112 |
!!!cp ('t211'); |
!!!cp ('t211'); |
| 5113 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
| 5114 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5119 |
if ($token->{tag_name} eq 'tr') { |
if ($token->{tag_name} eq 'tr') { |
| 5120 |
!!!cp ('t212'); |
!!!cp ('t212'); |
| 5121 |
## reprocess |
## reprocess |
| 5122 |
redo B; |
!!!ack-later; |
| 5123 |
|
next B; |
| 5124 |
} else { |
} else { |
| 5125 |
!!!cp ('t213'); |
!!!cp ('t213'); |
| 5126 |
## reprocess in the "in table body" insertion mode... |
## reprocess in the "in table body" insertion mode... |
| 5132 |
my $i; |
my $i; |
| 5133 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5134 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5135 |
if ({ |
if ($node->[1] & TABLE_ROW_GROUP_EL) { |
|
tbody => 1, thead => 1, tfoot => 1, |
|
|
}->{$node->[1]}) { |
|
| 5136 |
!!!cp ('t214'); |
!!!cp ('t214'); |
| 5137 |
$i = $_; |
$i = $_; |
| 5138 |
last INSCOPE; |
last INSCOPE; |
| 5139 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 5140 |
!!!cp ('t215'); |
!!!cp ('t215'); |
| 5141 |
last INSCOPE; |
last INSCOPE; |
| 5142 |
} |
} |
| 5146 |
## TODO: This erorr type ios wrong. |
## TODO: This erorr type ios wrong. |
| 5147 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5148 |
## Ignore the token |
## Ignore the token |
| 5149 |
|
!!!nack ('t216.1'); |
| 5150 |
!!!next-token; |
!!!next-token; |
| 5151 |
redo B; |
next B; |
| 5152 |
} |
} |
| 5153 |
|
|
| 5154 |
## Clear back to table body context |
## Clear back to table body context |
| 5155 |
while (not { |
while (not ($self->{open_elements}->[-1]->[1] |
| 5156 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
& TABLE_ROWS_SCOPING_EL)) { |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 5157 |
!!!cp ('t217'); |
!!!cp ('t217'); |
| 5158 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
| 5159 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5175 |
|
|
| 5176 |
if ($token->{tag_name} eq 'col') { |
if ($token->{tag_name} eq 'col') { |
| 5177 |
## Clear back to table context |
## Clear back to table context |
| 5178 |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
while (not ($self->{open_elements}->[-1]->[1] |
| 5179 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
& TABLE_SCOPING_EL)) { |
| 5180 |
!!!cp ('t219'); |
!!!cp ('t219'); |
| 5181 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
| 5182 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5185 |
!!!insert-element ('colgroup',, $token); |
!!!insert-element ('colgroup',, $token); |
| 5186 |
$self->{insertion_mode} = IN_COLUMN_GROUP_IM; |
$self->{insertion_mode} = IN_COLUMN_GROUP_IM; |
| 5187 |
## reprocess |
## reprocess |
| 5188 |
redo B; |
!!!ack-later; |
| 5189 |
|
next B; |
| 5190 |
} elsif ({ |
} elsif ({ |
| 5191 |
caption => 1, |
caption => 1, |
| 5192 |
colgroup => 1, |
colgroup => 1, |
| 5193 |
tbody => 1, tfoot => 1, thead => 1, |
tbody => 1, tfoot => 1, thead => 1, |
| 5194 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5195 |
## Clear back to table context |
## Clear back to table context |
| 5196 |
while ($self->{open_elements}->[-1]->[1] ne 'table' and |
while (not ($self->{open_elements}->[-1]->[1] |
| 5197 |
$self->{open_elements}->[-1]->[1] ne 'html') { |
& TABLE_SCOPING_EL)) { |
| 5198 |
!!!cp ('t220'); |
!!!cp ('t220'); |
| 5199 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
| 5200 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5212 |
thead => IN_TABLE_BODY_IM, |
thead => IN_TABLE_BODY_IM, |
| 5213 |
}->{$token->{tag_name}}; |
}->{$token->{tag_name}}; |
| 5214 |
!!!next-token; |
!!!next-token; |
| 5215 |
redo B; |
!!!nack ('t220.1'); |
| 5216 |
|
next B; |
| 5217 |
} else { |
} else { |
| 5218 |
die "$0: in table: <>: $token->{tag_name}"; |
die "$0: in table: <>: $token->{tag_name}"; |
| 5219 |
} |
} |
| 5220 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 5221 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
!!!parse-error (type => 'not closed', |
| 5222 |
|
value => $self->{open_elements}->[-1]->[0] |
| 5223 |
|
->manakai_local_name, |
| 5224 |
|
token => $token); |
| 5225 |
|
|
| 5226 |
## As if </table> |
## As if </table> |
| 5227 |
## have a table element in table scope |
## have a table element in table scope |
| 5228 |
my $i; |
my $i; |
| 5229 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5230 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5231 |
if ($node->[1] eq 'table') { |
if ($node->[1] & TABLE_EL) { |
| 5232 |
!!!cp ('t221'); |
!!!cp ('t221'); |
| 5233 |
$i = $_; |
$i = $_; |
| 5234 |
last INSCOPE; |
last INSCOPE; |
| 5235 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
#table => 1, |
|
|
html => 1, |
|
|
}->{$node->[1]}) { |
|
| 5236 |
!!!cp ('t222'); |
!!!cp ('t222'); |
| 5237 |
last INSCOPE; |
last INSCOPE; |
| 5238 |
} |
} |
| 5242 |
## TODO: The following is wrong, maybe. |
## TODO: The following is wrong, maybe. |
| 5243 |
!!!parse-error (type => 'unmatched end tag:table', token => $token); |
!!!parse-error (type => 'unmatched end tag:table', token => $token); |
| 5244 |
## Ignore tokens </table><table> |
## Ignore tokens </table><table> |
| 5245 |
|
!!!nack ('t223.1'); |
| 5246 |
!!!next-token; |
!!!next-token; |
| 5247 |
redo B; |
next B; |
| 5248 |
} |
} |
| 5249 |
|
|
| 5250 |
## TODO: Followings are removed from the latest spec. |
## TODO: Followings are removed from the latest spec. |
| 5251 |
## generate implied end tags |
## generate implied end tags |
| 5252 |
while ({ |
while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) { |
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 5253 |
!!!cp ('t224'); |
!!!cp ('t224'); |
| 5254 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5255 |
} |
} |
| 5256 |
|
|
| 5257 |
if ($self->{open_elements}->[-1]->[1] ne 'table') { |
unless ($self->{open_elements}->[-1]->[1] & TABLE_EL) { |
| 5258 |
!!!cp ('t225'); |
!!!cp ('t225'); |
| 5259 |
## ISSUE: Can this case be reached? |
## NOTE: |<table><tr><table>| |
| 5260 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
!!!parse-error (type => 'not closed', |
| 5261 |
|
value => $self->{open_elements}->[-1]->[0] |
| 5262 |
|
->manakai_local_name, |
| 5263 |
|
token => $token); |
| 5264 |
} else { |
} else { |
| 5265 |
!!!cp ('t226'); |
!!!cp ('t226'); |
| 5266 |
} |
} |
| 5270 |
|
|
| 5271 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 5272 |
|
|
| 5273 |
## reprocess |
## reprocess |
| 5274 |
redo B; |
!!!ack-later; |
| 5275 |
|
next B; |
| 5276 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 5277 |
if (not $open_tables->[-1]->[1]) { # tainted |
if (not $open_tables->[-1]->[1]) { # tainted |
| 5278 |
!!!cp ('t227.8'); |
!!!cp ('t227.8'); |
| 5279 |
## NOTE: This is a "as if in head" code clone. |
## NOTE: This is a "as if in head" code clone. |
| 5280 |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 5281 |
redo B; |
next B; |
| 5282 |
} else { |
} else { |
| 5283 |
!!!cp ('t227.7'); |
!!!cp ('t227.7'); |
| 5284 |
# |
# |
| 5288 |
!!!cp ('t227.6'); |
!!!cp ('t227.6'); |
| 5289 |
## NOTE: This is a "as if in head" code clone. |
## NOTE: This is a "as if in head" code clone. |
| 5290 |
$script_start_tag->(); |
$script_start_tag->(); |
| 5291 |
redo B; |
next B; |
| 5292 |
} else { |
} else { |
| 5293 |
!!!cp ('t227.5'); |
!!!cp ('t227.5'); |
| 5294 |
# |
# |
| 5308 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5309 |
|
|
| 5310 |
!!!next-token; |
!!!next-token; |
| 5311 |
redo B; |
!!!ack ('t227.2.1'); |
| 5312 |
|
next B; |
| 5313 |
} else { |
} else { |
| 5314 |
!!!cp ('t227.2'); |
!!!cp ('t227.2'); |
| 5315 |
# |
# |
| 5338 |
my $i; |
my $i; |
| 5339 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5340 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5341 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] & TABLE_ROW_EL) { |
| 5342 |
!!!cp ('t228'); |
!!!cp ('t228'); |
| 5343 |
$i = $_; |
$i = $_; |
| 5344 |
last INSCOPE; |
last INSCOPE; |
| 5345 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 5346 |
!!!cp ('t229'); |
!!!cp ('t229'); |
| 5347 |
last INSCOPE; |
last INSCOPE; |
| 5348 |
} |
} |
| 5351 |
!!!cp ('t230'); |
!!!cp ('t230'); |
| 5352 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5353 |
## Ignore the token |
## Ignore the token |
| 5354 |
|
!!!nack ('t230.1'); |
| 5355 |
!!!next-token; |
!!!next-token; |
| 5356 |
redo B; |
next B; |
| 5357 |
} else { |
} else { |
| 5358 |
!!!cp ('t232'); |
!!!cp ('t232'); |
| 5359 |
} |
} |
| 5360 |
|
|
| 5361 |
## Clear back to table row context |
## Clear back to table row context |
| 5362 |
while (not { |
while (not ($self->{open_elements}->[-1]->[1] |
| 5363 |
tr => 1, html => 1, |
& TABLE_ROW_SCOPING_EL)) { |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 5364 |
!!!cp ('t231'); |
!!!cp ('t231'); |
| 5365 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
| 5366 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5369 |
pop @{$self->{open_elements}}; # tr |
pop @{$self->{open_elements}}; # tr |
| 5370 |
$self->{insertion_mode} = IN_TABLE_BODY_IM; |
$self->{insertion_mode} = IN_TABLE_BODY_IM; |
| 5371 |
!!!next-token; |
!!!next-token; |
| 5372 |
redo B; |
!!!nack ('t231.1'); |
| 5373 |
|
next B; |
| 5374 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 5375 |
if ($self->{insertion_mode} == IN_ROW_IM) { |
if ($self->{insertion_mode} == IN_ROW_IM) { |
| 5376 |
## As if </tr> |
## As if </tr> |
| 5378 |
my $i; |
my $i; |
| 5379 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5380 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5381 |
if ($node->[1] eq 'tr') { |
if ($node->[1] & TABLE_ROW_EL) { |
| 5382 |
!!!cp ('t233'); |
!!!cp ('t233'); |
| 5383 |
$i = $_; |
$i = $_; |
| 5384 |
last INSCOPE; |
last INSCOPE; |
| 5385 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 5386 |
!!!cp ('t234'); |
!!!cp ('t234'); |
| 5387 |
last INSCOPE; |
last INSCOPE; |
| 5388 |
} |
} |
| 5392 |
## TODO: The following is wrong. |
## TODO: The following is wrong. |
| 5393 |
!!!parse-error (type => 'unmatched end tag:'.$token->{type}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{type}, token => $token); |
| 5394 |
## Ignore the token |
## Ignore the token |
| 5395 |
|
!!!nack ('t236.1'); |
| 5396 |
!!!next-token; |
!!!next-token; |
| 5397 |
redo B; |
next B; |
| 5398 |
} |
} |
| 5399 |
|
|
| 5400 |
## Clear back to table row context |
## Clear back to table row context |
| 5401 |
while (not { |
while (not ($self->{open_elements}->[-1]->[1] |
| 5402 |
tr => 1, html => 1, |
& TABLE_ROW_SCOPING_EL)) { |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 5403 |
!!!cp ('t236'); |
!!!cp ('t236'); |
| 5404 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
| 5405 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5415 |
my $i; |
my $i; |
| 5416 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5417 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5418 |
if ({ |
if ($node->[1] & TABLE_ROW_GROUP_EL) { |
|
tbody => 1, thead => 1, tfoot => 1, |
|
|
}->{$node->[1]}) { |
|
| 5419 |
!!!cp ('t237'); |
!!!cp ('t237'); |
| 5420 |
$i = $_; |
$i = $_; |
| 5421 |
last INSCOPE; |
last INSCOPE; |
| 5422 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 5423 |
!!!cp ('t238'); |
!!!cp ('t238'); |
| 5424 |
last INSCOPE; |
last INSCOPE; |
| 5425 |
} |
} |
| 5428 |
!!!cp ('t239'); |
!!!cp ('t239'); |
| 5429 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5430 |
## Ignore the token |
## Ignore the token |
| 5431 |
|
!!!nack ('t239.1'); |
| 5432 |
!!!next-token; |
!!!next-token; |
| 5433 |
redo B; |
next B; |
| 5434 |
} |
} |
| 5435 |
|
|
| 5436 |
## Clear back to table body context |
## Clear back to table body context |
| 5437 |
while (not { |
while (not ($self->{open_elements}->[-1]->[1] |
| 5438 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
& TABLE_ROWS_SCOPING_EL)) { |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 5439 |
!!!cp ('t240'); |
!!!cp ('t240'); |
| 5440 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5441 |
} |
} |
| 5461 |
my $i; |
my $i; |
| 5462 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5463 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5464 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] & TABLE_EL) { |
| 5465 |
!!!cp ('t241'); |
!!!cp ('t241'); |
| 5466 |
$i = $_; |
$i = $_; |
| 5467 |
last INSCOPE; |
last INSCOPE; |
| 5468 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 5469 |
!!!cp ('t242'); |
!!!cp ('t242'); |
| 5470 |
last INSCOPE; |
last INSCOPE; |
| 5471 |
} |
} |
| 5474 |
!!!cp ('t243'); |
!!!cp ('t243'); |
| 5475 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5476 |
## Ignore the token |
## Ignore the token |
| 5477 |
|
!!!nack ('t243.1'); |
| 5478 |
!!!next-token; |
!!!next-token; |
| 5479 |
redo B; |
next B; |
| 5480 |
} |
} |
| 5481 |
|
|
| 5482 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 5485 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 5486 |
|
|
| 5487 |
!!!next-token; |
!!!next-token; |
| 5488 |
redo B; |
next B; |
| 5489 |
} elsif ({ |
} elsif ({ |
| 5490 |
tbody => 1, tfoot => 1, thead => 1, |
tbody => 1, tfoot => 1, thead => 1, |
| 5491 |
}->{$token->{tag_name}} and |
}->{$token->{tag_name}} and |
| 5495 |
my $i; |
my $i; |
| 5496 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5497 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5498 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[0]->manakai_local_name eq $token->{tag_name}) { |
| 5499 |
!!!cp ('t247'); |
!!!cp ('t247'); |
| 5500 |
$i = $_; |
$i = $_; |
| 5501 |
last INSCOPE; |
last INSCOPE; |
| 5502 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 5503 |
!!!cp ('t248'); |
!!!cp ('t248'); |
| 5504 |
last INSCOPE; |
last INSCOPE; |
| 5505 |
} |
} |
| 5508 |
!!!cp ('t249'); |
!!!cp ('t249'); |
| 5509 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5510 |
## Ignore the token |
## Ignore the token |
| 5511 |
|
!!!nack ('t249.1'); |
| 5512 |
!!!next-token; |
!!!next-token; |
| 5513 |
redo B; |
next B; |
| 5514 |
} |
} |
| 5515 |
|
|
| 5516 |
## As if </tr> |
## As if </tr> |
| 5518 |
my $i; |
my $i; |
| 5519 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5520 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5521 |
if ($node->[1] eq 'tr') { |
if ($node->[1] & TABLE_ROW_EL) { |
| 5522 |
!!!cp ('t250'); |
!!!cp ('t250'); |
| 5523 |
$i = $_; |
$i = $_; |
| 5524 |
last INSCOPE; |
last INSCOPE; |
| 5525 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 5526 |
!!!cp ('t251'); |
!!!cp ('t251'); |
| 5527 |
last INSCOPE; |
last INSCOPE; |
| 5528 |
} |
} |
| 5531 |
!!!cp ('t252'); |
!!!cp ('t252'); |
| 5532 |
!!!parse-error (type => 'unmatched end tag:tr', token => $token); |
!!!parse-error (type => 'unmatched end tag:tr', token => $token); |
| 5533 |
## Ignore the token |
## Ignore the token |
| 5534 |
|
!!!nack ('t252.1'); |
| 5535 |
!!!next-token; |
!!!next-token; |
| 5536 |
redo B; |
next B; |
| 5537 |
} |
} |
| 5538 |
|
|
| 5539 |
## Clear back to table row context |
## Clear back to table row context |
| 5540 |
while (not { |
while (not ($self->{open_elements}->[-1]->[1] |
| 5541 |
tr => 1, html => 1, |
& TABLE_ROW_SCOPING_EL)) { |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 5542 |
!!!cp ('t253'); |
!!!cp ('t253'); |
| 5543 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
| 5544 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5553 |
my $i; |
my $i; |
| 5554 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5555 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5556 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[0]->manakai_local_name eq $token->{tag_name}) { |
| 5557 |
!!!cp ('t254'); |
!!!cp ('t254'); |
| 5558 |
$i = $_; |
$i = $_; |
| 5559 |
last INSCOPE; |
last INSCOPE; |
| 5560 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 5561 |
!!!cp ('t255'); |
!!!cp ('t255'); |
| 5562 |
last INSCOPE; |
last INSCOPE; |
| 5563 |
} |
} |
| 5566 |
!!!cp ('t256'); |
!!!cp ('t256'); |
| 5567 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5568 |
## Ignore the token |
## Ignore the token |
| 5569 |
|
!!!nack ('t256.1'); |
| 5570 |
!!!next-token; |
!!!next-token; |
| 5571 |
redo B; |
next B; |
| 5572 |
} |
} |
| 5573 |
|
|
| 5574 |
## Clear back to table body context |
## Clear back to table body context |
| 5575 |
while (not { |
while (not ($self->{open_elements}->[-1]->[1] |
| 5576 |
tbody => 1, tfoot => 1, thead => 1, html => 1, |
& TABLE_ROWS_SCOPING_EL)) { |
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 5577 |
!!!cp ('t257'); |
!!!cp ('t257'); |
| 5578 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
| 5579 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5581 |
|
|
| 5582 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5583 |
$self->{insertion_mode} = IN_TABLE_IM; |
$self->{insertion_mode} = IN_TABLE_IM; |
| 5584 |
|
!!!nack ('t257.1'); |
| 5585 |
!!!next-token; |
!!!next-token; |
| 5586 |
redo B; |
next B; |
| 5587 |
} elsif ({ |
} elsif ({ |
| 5588 |
body => 1, caption => 1, col => 1, colgroup => 1, |
body => 1, caption => 1, col => 1, colgroup => 1, |
| 5589 |
html => 1, td => 1, th => 1, |
html => 1, td => 1, th => 1, |
| 5590 |
tr => 1, # $self->{insertion_mode} == IN_ROW_IM |
tr => 1, # $self->{insertion_mode} == IN_ROW_IM |
| 5591 |
tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM |
tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM |
| 5592 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5593 |
!!!cp ('t258'); |
!!!cp ('t258'); |
| 5594 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5595 |
## Ignore the token |
## Ignore the token |
| 5596 |
!!!next-token; |
!!!nack ('t258.1'); |
| 5597 |
redo B; |
!!!next-token; |
| 5598 |
|
next B; |
| 5599 |
} else { |
} else { |
| 5600 |
!!!cp ('t259'); |
!!!cp ('t259'); |
| 5601 |
!!!parse-error (type => 'in table:/'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'in table:/'.$token->{tag_name}, token => $token); |
| 5604 |
# |
# |
| 5605 |
} |
} |
| 5606 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5607 |
unless ($self->{open_elements}->[-1]->[1] eq 'html' and |
unless ($self->{open_elements}->[-1]->[1] & HTML_EL and |
| 5608 |
@{$self->{open_elements}} == 1) { # redundant, maybe |
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 5609 |
!!!parse-error (type => 'in body:#eof', token => $token); |
!!!parse-error (type => 'in body:#eof', token => $token); |
| 5610 |
!!!cp ('t259.1'); |
!!!cp ('t259.1'); |
| 5626 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 5627 |
!!!cp ('t260'); |
!!!cp ('t260'); |
| 5628 |
!!!next-token; |
!!!next-token; |
| 5629 |
redo B; |
next B; |
| 5630 |
} |
} |
| 5631 |
} |
} |
| 5632 |
|
|
| 5637 |
!!!cp ('t262'); |
!!!cp ('t262'); |
| 5638 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 5639 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5640 |
|
!!!ack ('t262.1'); |
| 5641 |
!!!next-token; |
!!!next-token; |
| 5642 |
redo B; |
next B; |
| 5643 |
} else { |
} else { |
| 5644 |
!!!cp ('t263'); |
!!!cp ('t263'); |
| 5645 |
# |
# |
| 5646 |
} |
} |
| 5647 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 5648 |
if ($token->{tag_name} eq 'colgroup') { |
if ($token->{tag_name} eq 'colgroup') { |
| 5649 |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
if ($self->{open_elements}->[-1]->[1] & HTML_EL) { |
| 5650 |
!!!cp ('t264'); |
!!!cp ('t264'); |
| 5651 |
!!!parse-error (type => 'unmatched end tag:colgroup', token => $token); |
!!!parse-error (type => 'unmatched end tag:colgroup', token => $token); |
| 5652 |
## Ignore the token |
## Ignore the token |
| 5653 |
!!!next-token; |
!!!next-token; |
| 5654 |
redo B; |
next B; |
| 5655 |
} else { |
} else { |
| 5656 |
!!!cp ('t265'); |
!!!cp ('t265'); |
| 5657 |
pop @{$self->{open_elements}}; # colgroup |
pop @{$self->{open_elements}}; # colgroup |
| 5658 |
$self->{insertion_mode} = IN_TABLE_IM; |
$self->{insertion_mode} = IN_TABLE_IM; |
| 5659 |
!!!next-token; |
!!!next-token; |
| 5660 |
redo B; |
next B; |
| 5661 |
} |
} |
| 5662 |
} elsif ($token->{tag_name} eq 'col') { |
} elsif ($token->{tag_name} eq 'col') { |
| 5663 |
!!!cp ('t266'); |
!!!cp ('t266'); |
| 5664 |
!!!parse-error (type => 'unmatched end tag:col', token => $token); |
!!!parse-error (type => 'unmatched end tag:col', token => $token); |
| 5665 |
## Ignore the token |
## Ignore the token |
| 5666 |
!!!next-token; |
!!!next-token; |
| 5667 |
redo B; |
next B; |
| 5668 |
} else { |
} else { |
| 5669 |
!!!cp ('t267'); |
!!!cp ('t267'); |
| 5670 |
# |
# |
| 5671 |
} |
} |
| 5672 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5673 |
if ($self->{open_elements}->[-1]->[1] eq 'html' or |
if ($self->{open_elements}->[-1]->[1] & HTML_EL and |
| 5674 |
@{$self->{open_elements}} == 1) { # redundant, maybe |
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 5675 |
!!!cp ('t270.2'); |
!!!cp ('t270.2'); |
| 5676 |
## Stop parsing. |
## Stop parsing. |
| 5681 |
pop @{$self->{open_elements}}; # colgroup |
pop @{$self->{open_elements}}; # colgroup |
| 5682 |
$self->{insertion_mode} = IN_TABLE_IM; |
$self->{insertion_mode} = IN_TABLE_IM; |
| 5683 |
## Reprocess. |
## Reprocess. |
| 5684 |
redo B; |
next B; |
| 5685 |
} |
} |
| 5686 |
} else { |
} else { |
| 5687 |
die "$0: $token->{type}: Unknown token type"; |
die "$0: $token->{type}: Unknown token type"; |
| 5688 |
} |
} |
| 5689 |
|
|
| 5690 |
## As if </colgroup> |
## As if </colgroup> |
| 5691 |
if ($self->{open_elements}->[-1]->[1] eq 'html') { |
if ($self->{open_elements}->[-1]->[1] & HTML_EL) { |
| 5692 |
!!!cp ('t269'); |
!!!cp ('t269'); |
| 5693 |
## TODO: Wrong error type? |
## TODO: Wrong error type? |
| 5694 |
!!!parse-error (type => 'unmatched end tag:colgroup', token => $token); |
!!!parse-error (type => 'unmatched end tag:colgroup', token => $token); |
| 5695 |
## Ignore the token |
## Ignore the token |
| 5696 |
|
!!!nack ('t269.1'); |
| 5697 |
!!!next-token; |
!!!next-token; |
| 5698 |
redo B; |
next B; |
| 5699 |
} else { |
} else { |
| 5700 |
!!!cp ('t270'); |
!!!cp ('t270'); |
| 5701 |
pop @{$self->{open_elements}}; # colgroup |
pop @{$self->{open_elements}}; # colgroup |
| 5702 |
$self->{insertion_mode} = IN_TABLE_IM; |
$self->{insertion_mode} = IN_TABLE_IM; |
| 5703 |
|
!!!ack-later; |
| 5704 |
## reprocess |
## reprocess |
| 5705 |
redo B; |
next B; |
| 5706 |
} |
} |
| 5707 |
} elsif ($self->{insertion_mode} & SELECT_IMS) { |
} elsif ($self->{insertion_mode} & SELECT_IMS) { |
| 5708 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 5709 |
!!!cp ('t271'); |
!!!cp ('t271'); |
| 5710 |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
$self->{open_elements}->[-1]->[0]->manakai_append_text ($token->{data}); |
| 5711 |
!!!next-token; |
!!!next-token; |
| 5712 |
redo B; |
next B; |
| 5713 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 5714 |
if ($token->{tag_name} eq 'option') { |
if ($token->{tag_name} eq 'option') { |
| 5715 |
if ($self->{open_elements}->[-1]->[1] eq 'option') { |
if ($self->{open_elements}->[-1]->[1] & OPTION_EL) { |
| 5716 |
!!!cp ('t272'); |
!!!cp ('t272'); |
| 5717 |
## As if </option> |
## As if </option> |
| 5718 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5719 |
} else { |
} else { |
| 5720 |
!!!cp ('t273'); |
!!!cp ('t273'); |
| 5721 |
} |
} |
| 5722 |
|
|
| 5723 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 5724 |
!!!next-token; |
!!!nack ('t273.1'); |
| 5725 |
redo B; |
!!!next-token; |
| 5726 |
} elsif ($token->{tag_name} eq 'optgroup') { |
next B; |
| 5727 |
if ($self->{open_elements}->[-1]->[1] eq 'option') { |
} elsif ($token->{tag_name} eq 'optgroup') { |
| 5728 |
!!!cp ('t274'); |
if ($self->{open_elements}->[-1]->[1] & OPTION_EL) { |
| 5729 |
## As if </option> |
!!!cp ('t274'); |
| 5730 |
pop @{$self->{open_elements}}; |
## As if </option> |
| 5731 |
} else { |
pop @{$self->{open_elements}}; |
| 5732 |
!!!cp ('t275'); |
} else { |
| 5733 |
} |
!!!cp ('t275'); |
| 5734 |
|
} |
| 5735 |
|
|
| 5736 |
if ($self->{open_elements}->[-1]->[1] eq 'optgroup') { |
if ($self->{open_elements}->[-1]->[1] & OPTGROUP_EL) { |
| 5737 |
!!!cp ('t276'); |
!!!cp ('t276'); |
| 5738 |
## As if </optgroup> |
## As if </optgroup> |
| 5739 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5740 |
} else { |
} else { |
| 5741 |
!!!cp ('t277'); |
!!!cp ('t277'); |
| 5742 |
} |
} |
| 5743 |
|
|
| 5744 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 5745 |
!!!next-token; |
!!!nack ('t277.1'); |
| 5746 |
redo B; |
!!!next-token; |
| 5747 |
|
next B; |
| 5748 |
} elsif ($token->{tag_name} eq 'select' or |
} elsif ($token->{tag_name} eq 'select' or |
| 5749 |
$token->{tag_name} eq 'input' or |
$token->{tag_name} eq 'input' or |
| 5750 |
($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
| 5757 |
!!!parse-error (type => 'not closed:select', token => $token); |
!!!parse-error (type => 'not closed:select', token => $token); |
| 5758 |
## NOTE: As if the token were </select> (<select> case) or |
## NOTE: As if the token were </select> (<select> case) or |
| 5759 |
## as if there were </select> (otherwise). |
## as if there were </select> (otherwise). |
| 5760 |
## have an element in table scope |
## have an element in table scope |
| 5761 |
my $i; |
my $i; |
| 5762 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5763 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5764 |
if ($node->[1] eq 'select') { |
if ($node->[1] & SELECT_EL) { |
| 5765 |
!!!cp ('t278'); |
!!!cp ('t278'); |
| 5766 |
$i = $_; |
$i = $_; |
| 5767 |
last INSCOPE; |
last INSCOPE; |
| 5768 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
| 5769 |
table => 1, html => 1, |
!!!cp ('t279'); |
| 5770 |
}->{$node->[1]}) { |
last INSCOPE; |
| 5771 |
!!!cp ('t279'); |
} |
| 5772 |
last INSCOPE; |
} # INSCOPE |
| 5773 |
} |
unless (defined $i) { |
| 5774 |
} # INSCOPE |
!!!cp ('t280'); |
| 5775 |
unless (defined $i) { |
!!!parse-error (type => 'unmatched end tag:select', token => $token); |
| 5776 |
!!!cp ('t280'); |
## Ignore the token |
| 5777 |
!!!parse-error (type => 'unmatched end tag:select', token => $token); |
!!!nack ('t280.1'); |
| 5778 |
## Ignore the token |
!!!next-token; |
| 5779 |
!!!next-token; |
next B; |
| 5780 |
redo B; |
} |
|
} |
|
| 5781 |
|
|
| 5782 |
!!!cp ('t281'); |
!!!cp ('t281'); |
| 5783 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 5784 |
|
|
| 5785 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 5786 |
|
|
| 5787 |
if ($token->{tag_name} eq 'select') { |
if ($token->{tag_name} eq 'select') { |
| 5788 |
!!!cp ('t281.2'); |
!!!nack ('t281.2'); |
| 5789 |
!!!next-token; |
!!!next-token; |
| 5790 |
redo B; |
next B; |
| 5791 |
} else { |
} else { |
| 5792 |
!!!cp ('t281.1'); |
!!!cp ('t281.1'); |
| 5793 |
|
!!!ack-later; |
| 5794 |
## Reprocess the token. |
## Reprocess the token. |
| 5795 |
redo B; |
next B; |
| 5796 |
} |
} |
| 5797 |
} else { |
} else { |
| 5798 |
!!!cp ('t282'); |
!!!cp ('t282'); |
| 5799 |
!!!parse-error (type => 'in select:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'in select:'.$token->{tag_name}, token => $token); |
| 5800 |
## Ignore the token |
## Ignore the token |
| 5801 |
|
!!!nack ('t282.1'); |
| 5802 |
!!!next-token; |
!!!next-token; |
| 5803 |
redo B; |
next B; |
| 5804 |
} |
} |
| 5805 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 5806 |
if ($token->{tag_name} eq 'optgroup') { |
if ($token->{tag_name} eq 'optgroup') { |
| 5807 |
if ($self->{open_elements}->[-1]->[1] eq 'option' and |
if ($self->{open_elements}->[-1]->[1] & OPTION_EL and |
| 5808 |
$self->{open_elements}->[-2]->[1] eq 'optgroup') { |
$self->{open_elements}->[-2]->[1] & OPTGROUP_EL) { |
| 5809 |
!!!cp ('t283'); |
!!!cp ('t283'); |
| 5810 |
## As if </option> |
## As if </option> |
| 5811 |
splice @{$self->{open_elements}}, -2; |
splice @{$self->{open_elements}}, -2; |
| 5812 |
} elsif ($self->{open_elements}->[-1]->[1] eq 'optgroup') { |
} elsif ($self->{open_elements}->[-1]->[1] & OPTGROUP_EL) { |
| 5813 |
!!!cp ('t284'); |
!!!cp ('t284'); |
| 5814 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 5815 |
} else { |
} else { |
| 5816 |
!!!cp ('t285'); |
!!!cp ('t285'); |
| 5817 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5818 |
## Ignore the token |
## Ignore the token |
| 5819 |
} |
} |
| 5820 |
!!!next-token; |
!!!nack ('t285.1'); |
| 5821 |
redo B; |
!!!next-token; |
| 5822 |
} elsif ($token->{tag_name} eq 'option') { |
next B; |
| 5823 |
if ($self->{open_elements}->[-1]->[1] eq 'option') { |
} elsif ($token->{tag_name} eq 'option') { |
| 5824 |
!!!cp ('t286'); |
if ($self->{open_elements}->[-1]->[1] & OPTION_EL) { |
| 5825 |
pop @{$self->{open_elements}}; |
!!!cp ('t286'); |
| 5826 |
} else { |
pop @{$self->{open_elements}}; |
| 5827 |
!!!cp ('t287'); |
} else { |
| 5828 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!cp ('t287'); |
| 5829 |
## Ignore the token |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5830 |
} |
## Ignore the token |
| 5831 |
!!!next-token; |
} |
| 5832 |
redo B; |
!!!nack ('t287.1'); |
| 5833 |
} elsif ($token->{tag_name} eq 'select') { |
!!!next-token; |
| 5834 |
## have an element in table scope |
next B; |
| 5835 |
my $i; |
} elsif ($token->{tag_name} eq 'select') { |
| 5836 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
## have an element in table scope |
| 5837 |
my $node = $self->{open_elements}->[$_]; |
my $i; |
| 5838 |
if ($node->[1] eq $token->{tag_name}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5839 |
!!!cp ('t288'); |
my $node = $self->{open_elements}->[$_]; |
| 5840 |
$i = $_; |
if ($node->[1] & SELECT_EL) { |
| 5841 |
last INSCOPE; |
!!!cp ('t288'); |
| 5842 |
} elsif ({ |
$i = $_; |
| 5843 |
table => 1, html => 1, |
last INSCOPE; |
| 5844 |
}->{$node->[1]}) { |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
| 5845 |
!!!cp ('t289'); |
!!!cp ('t289'); |
| 5846 |
last INSCOPE; |
last INSCOPE; |
| 5847 |
} |
} |
| 5848 |
} # INSCOPE |
} # INSCOPE |
| 5849 |
unless (defined $i) { |
unless (defined $i) { |
| 5850 |
!!!cp ('t290'); |
!!!cp ('t290'); |
| 5851 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5852 |
## Ignore the token |
## Ignore the token |
| 5853 |
!!!next-token; |
!!!nack ('t290.1'); |
| 5854 |
redo B; |
!!!next-token; |
| 5855 |
} |
next B; |
| 5856 |
|
} |
| 5857 |
|
|
| 5858 |
!!!cp ('t291'); |
!!!cp ('t291'); |
| 5859 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 5860 |
|
|
| 5861 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 5862 |
|
|
| 5863 |
!!!next-token; |
!!!nack ('t291.1'); |
| 5864 |
redo B; |
!!!next-token; |
| 5865 |
|
next B; |
| 5866 |
} elsif ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
} elsif ($self->{insertion_mode} == IN_SELECT_IN_TABLE_IM and |
| 5867 |
{ |
{ |
| 5868 |
caption => 1, table => 1, tbody => 1, |
caption => 1, table => 1, tbody => 1, |
| 5869 |
tfoot => 1, thead => 1, tr => 1, td => 1, th => 1, |
tfoot => 1, thead => 1, tr => 1, td => 1, th => 1, |
| 5870 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 5871 |
## TODO: The following is wrong? |
## TODO: The following is wrong? |
| 5872 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 5873 |
|
|
| 5874 |
## have an element in table scope |
## have an element in table scope |
| 5875 |
my $i; |
my $i; |
| 5876 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5877 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5878 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[0]->manakai_local_name eq $token->{tag_name}) { |
| 5879 |
!!!cp ('t292'); |
!!!cp ('t292'); |
| 5880 |
$i = $_; |
$i = $_; |
| 5881 |
last INSCOPE; |
last INSCOPE; |
| 5882 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
| 5883 |
table => 1, html => 1, |
!!!cp ('t293'); |
| 5884 |
}->{$node->[1]}) { |
last INSCOPE; |
| 5885 |
!!!cp ('t293'); |
} |
| 5886 |
last INSCOPE; |
} # INSCOPE |
| 5887 |
} |
unless (defined $i) { |
| 5888 |
} # INSCOPE |
!!!cp ('t294'); |
| 5889 |
unless (defined $i) { |
## Ignore the token |
| 5890 |
!!!cp ('t294'); |
!!!nack ('t294.1'); |
| 5891 |
## Ignore the token |
!!!next-token; |
| 5892 |
!!!next-token; |
next B; |
| 5893 |
redo B; |
} |
|
} |
|
| 5894 |
|
|
| 5895 |
## As if </select> |
## As if </select> |
| 5896 |
## have an element in table scope |
## have an element in table scope |
| 5897 |
undef $i; |
undef $i; |
| 5898 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 5899 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 5900 |
if ($node->[1] eq 'select') { |
if ($node->[1] & SELECT_EL) { |
| 5901 |
!!!cp ('t295'); |
!!!cp ('t295'); |
| 5902 |
$i = $_; |
$i = $_; |
| 5903 |
last INSCOPE; |
last INSCOPE; |
| 5904 |
} elsif ({ |
} elsif ($node->[1] & TABLE_SCOPING_EL) { |
|
table => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 5905 |
## ISSUE: Can this state be reached? |
## ISSUE: Can this state be reached? |
| 5906 |
!!!cp ('t296'); |
!!!cp ('t296'); |
| 5907 |
last INSCOPE; |
last INSCOPE; |
| 5908 |
} |
} |
| 5909 |
} # INSCOPE |
} # INSCOPE |
| 5910 |
unless (defined $i) { |
unless (defined $i) { |
| 5911 |
!!!cp ('t297'); |
!!!cp ('t297'); |
| 5912 |
## TODO: The following error type is correct? |
## TODO: The following error type is correct? |
| 5913 |
!!!parse-error (type => 'unmatched end tag:select', token => $token); |
!!!parse-error (type => 'unmatched end tag:select', token => $token); |
| 5914 |
## Ignore the </select> token |
## Ignore the </select> token |
| 5915 |
!!!next-token; ## TODO: ok? |
!!!nack ('t297.1'); |
| 5916 |
redo B; |
!!!next-token; ## TODO: ok? |
| 5917 |
} |
next B; |
| 5918 |
|
} |
| 5919 |
|
|
| 5920 |
!!!cp ('t298'); |
!!!cp ('t298'); |
| 5921 |
splice @{$self->{open_elements}}, $i; |
splice @{$self->{open_elements}}, $i; |
| 5922 |
|
|
| 5923 |
$self->_reset_insertion_mode; |
$self->_reset_insertion_mode; |
| 5924 |
|
|
| 5925 |
## reprocess |
!!!ack-later; |
| 5926 |
redo B; |
## reprocess |
| 5927 |
|
next B; |
| 5928 |
} else { |
} else { |
| 5929 |
!!!cp ('t299'); |
!!!cp ('t299'); |
| 5930 |
!!!parse-error (type => 'in select:/'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'in select:/'.$token->{tag_name}, token => $token); |
| 5931 |
## Ignore the token |
## Ignore the token |
| 5932 |
|
!!!nack ('t299.3'); |
| 5933 |
!!!next-token; |
!!!next-token; |
| 5934 |
redo B; |
next B; |
| 5935 |
} |
} |
| 5936 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 5937 |
unless ($self->{open_elements}->[-1]->[1] eq 'html' and |
unless ($self->{open_elements}->[-1]->[1] & HTML_EL and |
| 5938 |
@{$self->{open_elements}} == 1) { # redundant, maybe |
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 5939 |
!!!cp ('t299.1'); |
!!!cp ('t299.1'); |
| 5940 |
!!!parse-error (type => 'in body:#eof', token => $token); |
!!!parse-error (type => 'in body:#eof', token => $token); |
| 5959 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 5960 |
!!!cp ('t300'); |
!!!cp ('t300'); |
| 5961 |
!!!next-token; |
!!!next-token; |
| 5962 |
redo B; |
next B; |
| 5963 |
} |
} |
| 5964 |
} |
} |
| 5965 |
|
|
| 5977 |
|
|
| 5978 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 5979 |
## reprocess |
## reprocess |
| 5980 |
redo B; |
next B; |
| 5981 |
} elsif ($token->{type} == START_TAG_TOKEN) { |
} elsif ($token->{type} == START_TAG_TOKEN) { |
| 5982 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 5983 |
!!!cp ('t303'); |
!!!cp ('t303'); |
| 5992 |
!!!parse-error (type => 'after body:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after body:'.$token->{tag_name}, token => $token); |
| 5993 |
|
|
| 5994 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 5995 |
|
!!!ack-later; |
| 5996 |
## reprocess |
## reprocess |
| 5997 |
redo B; |
next B; |
| 5998 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 5999 |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) { |
| 6000 |
!!!cp ('t305'); |
!!!cp ('t305'); |
| 6013 |
!!!parse-error (type => 'unmatched end tag:html', token => $token); |
!!!parse-error (type => 'unmatched end tag:html', token => $token); |
| 6014 |
## Ignore the token |
## Ignore the token |
| 6015 |
!!!next-token; |
!!!next-token; |
| 6016 |
redo B; |
next B; |
| 6017 |
} else { |
} else { |
| 6018 |
!!!cp ('t308'); |
!!!cp ('t308'); |
| 6019 |
$self->{insertion_mode} = AFTER_HTML_BODY_IM; |
$self->{insertion_mode} = AFTER_HTML_BODY_IM; |
| 6020 |
!!!next-token; |
!!!next-token; |
| 6021 |
redo B; |
next B; |
| 6022 |
} |
} |
| 6023 |
} else { |
} else { |
| 6024 |
!!!cp ('t309'); |
!!!cp ('t309'); |
| 6026 |
|
|
| 6027 |
$self->{insertion_mode} = IN_BODY_IM; |
$self->{insertion_mode} = IN_BODY_IM; |
| 6028 |
## reprocess |
## reprocess |
| 6029 |
redo B; |
next B; |
| 6030 |
} |
} |
| 6031 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 6032 |
!!!cp ('t309.2'); |
!!!cp ('t309.2'); |
| 6043 |
unless (length $token->{data}) { |
unless (length $token->{data}) { |
| 6044 |
!!!cp ('t310'); |
!!!cp ('t310'); |
| 6045 |
!!!next-token; |
!!!next-token; |
| 6046 |
redo B; |
next B; |
| 6047 |
} |
} |
| 6048 |
} |
} |
| 6049 |
|
|
| 6071 |
!!!cp ('t315'); |
!!!cp ('t315'); |
| 6072 |
!!!next-token; |
!!!next-token; |
| 6073 |
} |
} |
| 6074 |
redo B; |
next B; |
| 6075 |
} |
} |
| 6076 |
|
|
| 6077 |
die qq[$0: Character "$token->{data}"]; |
die qq[$0: Character "$token->{data}"]; |
| 6090 |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
| 6091 |
!!!cp ('t318'); |
!!!cp ('t318'); |
| 6092 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 6093 |
|
!!!nack ('t318.1'); |
| 6094 |
!!!next-token; |
!!!next-token; |
| 6095 |
redo B; |
next B; |
| 6096 |
} elsif ($token->{tag_name} eq 'frame' and |
} elsif ($token->{tag_name} eq 'frame' and |
| 6097 |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
| 6098 |
!!!cp ('t319'); |
!!!cp ('t319'); |
| 6099 |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element ($token->{tag_name}, $token->{attributes}, $token); |
| 6100 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 6101 |
|
!!!ack ('t319.1'); |
| 6102 |
!!!next-token; |
!!!next-token; |
| 6103 |
redo B; |
next B; |
| 6104 |
} elsif ($token->{tag_name} eq 'noframes') { |
} elsif ($token->{tag_name} eq 'noframes') { |
| 6105 |
!!!cp ('t320'); |
!!!cp ('t320'); |
| 6106 |
## NOTE: As if in body. |
## NOTE: As if in body. |
| 6107 |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 6108 |
redo B; |
next B; |
| 6109 |
} else { |
} else { |
| 6110 |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
| 6111 |
!!!cp ('t321'); |
!!!cp ('t321'); |
| 6115 |
!!!parse-error (type => 'after frameset:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'after frameset:'.$token->{tag_name}, token => $token); |
| 6116 |
} |
} |
| 6117 |
## Ignore the token |
## Ignore the token |
| 6118 |
|
!!!nack ('t322.1'); |
| 6119 |
!!!next-token; |
!!!next-token; |
| 6120 |
redo B; |
next B; |
| 6121 |
} |
} |
| 6122 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 6123 |
if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
if ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) { |
| 6132 |
|
|
| 6133 |
if ($token->{tag_name} eq 'frameset' and |
if ($token->{tag_name} eq 'frameset' and |
| 6134 |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
$self->{insertion_mode} == IN_FRAMESET_IM) { |
| 6135 |
if ($self->{open_elements}->[-1]->[1] eq 'html' and |
if ($self->{open_elements}->[-1]->[1] & HTML_EL and |
| 6136 |
@{$self->{open_elements}} == 1) { |
@{$self->{open_elements}} == 1) { |
| 6137 |
!!!cp ('t325'); |
!!!cp ('t325'); |
| 6138 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6145 |
} |
} |
| 6146 |
|
|
| 6147 |
if (not defined $self->{inner_html_node} and |
if (not defined $self->{inner_html_node} and |
| 6148 |
$self->{open_elements}->[-1]->[1] ne 'frameset') { |
not ($self->{open_elements}->[-1]->[1] & FRAMESET_EL)) { |
| 6149 |
!!!cp ('t327'); |
!!!cp ('t327'); |
| 6150 |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_FRAMESET_IM; |
| 6151 |
} else { |
} else { |
| 6152 |
!!!cp ('t328'); |
!!!cp ('t328'); |
| 6153 |
} |
} |
| 6154 |
redo B; |
next B; |
| 6155 |
} elsif ($token->{tag_name} eq 'html' and |
} elsif ($token->{tag_name} eq 'html' and |
| 6156 |
$self->{insertion_mode} == AFTER_FRAMESET_IM) { |
$self->{insertion_mode} == AFTER_FRAMESET_IM) { |
| 6157 |
!!!cp ('t329'); |
!!!cp ('t329'); |
| 6158 |
$self->{insertion_mode} = AFTER_HTML_FRAMESET_IM; |
$self->{insertion_mode} = AFTER_HTML_FRAMESET_IM; |
| 6159 |
!!!next-token; |
!!!next-token; |
| 6160 |
redo B; |
next B; |
| 6161 |
} else { |
} else { |
| 6162 |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
if ($self->{insertion_mode} == IN_FRAMESET_IM) { |
| 6163 |
!!!cp ('t330'); |
!!!cp ('t330'); |
| 6168 |
} |
} |
| 6169 |
## Ignore the token |
## Ignore the token |
| 6170 |
!!!next-token; |
!!!next-token; |
| 6171 |
redo B; |
next B; |
| 6172 |
} |
} |
| 6173 |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
} elsif ($token->{type} == END_OF_FILE_TOKEN) { |
| 6174 |
unless ($self->{open_elements}->[-1]->[1] eq 'html' and |
unless ($self->{open_elements}->[-1]->[1] & HTML_EL and |
| 6175 |
@{$self->{open_elements}} == 1) { # redundant, maybe |
@{$self->{open_elements}} == 1) { # redundant, maybe |
| 6176 |
!!!cp ('t331.1'); |
!!!cp ('t331.1'); |
| 6177 |
!!!parse-error (type => 'in body:#eof', token => $token); |
!!!parse-error (type => 'in body:#eof', token => $token); |
| 6196 |
!!!cp ('t332'); |
!!!cp ('t332'); |
| 6197 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 6198 |
$script_start_tag->(); |
$script_start_tag->(); |
| 6199 |
redo B; |
next B; |
| 6200 |
} elsif ($token->{tag_name} eq 'style') { |
} elsif ($token->{tag_name} eq 'style') { |
| 6201 |
!!!cp ('t333'); |
!!!cp ('t333'); |
| 6202 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 6203 |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 6204 |
redo B; |
next B; |
| 6205 |
} elsif ({ |
} elsif ({ |
| 6206 |
base => 1, link => 1, |
base => 1, link => 1, |
| 6207 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6209 |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
| 6210 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 6211 |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 6212 |
|
!!!ack ('t334.1'); |
| 6213 |
!!!next-token; |
!!!next-token; |
| 6214 |
redo B; |
next B; |
| 6215 |
} elsif ($token->{tag_name} eq 'meta') { |
} elsif ($token->{tag_name} eq 'meta') { |
| 6216 |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
## NOTE: This is an "as if in head" code clone, only "-t" differs |
| 6217 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 6218 |
my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
my $meta_el = pop @{$self->{open_elements}}; ## ISSUE: This step is missing in the spec. |
| 6219 |
|
|
| 6220 |
unless ($self->{confident}) { |
unless ($self->{confident}) { |
| 6221 |
if ($token->{attributes}->{charset}) { ## TODO: And if supported |
if ($token->{attributes}->{charset}) { |
| 6222 |
!!!cp ('t335'); |
!!!cp ('t335'); |
| 6223 |
|
## NOTE: Whether the encoding is supported or not is handled |
| 6224 |
|
## in the {change_encoding} callback. |
| 6225 |
$self->{change_encoding} |
$self->{change_encoding} |
| 6226 |
->($self, $token->{attributes}->{charset}->{value}, $token); |
->($self, $token->{attributes}->{charset}->{value}, $token); |
| 6227 |
|
|
| 6230 |
$token->{attributes}->{charset} |
$token->{attributes}->{charset} |
| 6231 |
->{has_reference}); |
->{has_reference}); |
| 6232 |
} elsif ($token->{attributes}->{content}) { |
} elsif ($token->{attributes}->{content}) { |
|
## ISSUE: Algorithm name in the spec was incorrect so that not linked to the definition. |
|
| 6233 |
if ($token->{attributes}->{content}->{value} |
if ($token->{attributes}->{content}->{value} |
| 6234 |
=~ /\A[^;]*;[\x09-\x0D\x20]*[Cc][Hh][Aa][Rr][Ss][Ee][Tt] |
=~ /\A[^;]*;[\x09-\x0D\x20]*[Cc][Hh][Aa][Rr][Ss][Ee][Tt] |
| 6235 |
[\x09-\x0D\x20]*= |
[\x09-\x0D\x20]*= |
| 6236 |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
[\x09-\x0D\x20]*(?>"([^"]*)"|'([^']*)'| |
| 6237 |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
([^"'\x09-\x0D\x20][^\x09-\x0D\x20]*))/x) { |
| 6238 |
!!!cp ('t336'); |
!!!cp ('t336'); |
| 6239 |
|
## NOTE: Whether the encoding is supported or not is handled |
| 6240 |
|
## in the {change_encoding} callback. |
| 6241 |
$self->{change_encoding} |
$self->{change_encoding} |
| 6242 |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3, $token); |
->($self, defined $1 ? $1 : defined $2 ? $2 : $3, $token); |
| 6243 |
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
$meta_el->[0]->get_attribute_node_ns (undef, 'content') |
| 6263 |
} |
} |
| 6264 |
} |
} |
| 6265 |
|
|
| 6266 |
|
!!!ack ('t338.1'); |
| 6267 |
!!!next-token; |
!!!next-token; |
| 6268 |
redo B; |
next B; |
| 6269 |
} elsif ($token->{tag_name} eq 'title') { |
} elsif ($token->{tag_name} eq 'title') { |
| 6270 |
!!!cp ('t341'); |
!!!cp ('t341'); |
| 6271 |
## NOTE: This is an "as if in head" code clone |
## NOTE: This is an "as if in head" code clone |
| 6272 |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
$parse_rcdata->(RCDATA_CONTENT_MODEL); |
| 6273 |
redo B; |
next B; |
| 6274 |
} elsif ($token->{tag_name} eq 'body') { |
} elsif ($token->{tag_name} eq 'body') { |
| 6275 |
!!!parse-error (type => 'in body:body', token => $token); |
!!!parse-error (type => 'in body:body', token => $token); |
| 6276 |
|
|
| 6277 |
if (@{$self->{open_elements}} == 1 or |
if (@{$self->{open_elements}} == 1 or |
| 6278 |
$self->{open_elements}->[1]->[1] ne 'body') { |
not ($self->{open_elements}->[1]->[1] & BODY_EL)) { |
| 6279 |
!!!cp ('t342'); |
!!!cp ('t342'); |
| 6280 |
## Ignore the token |
## Ignore the token |
| 6281 |
} else { |
} else { |
| 6289 |
} |
} |
| 6290 |
} |
} |
| 6291 |
} |
} |
| 6292 |
|
!!!nack ('t343.1'); |
| 6293 |
!!!next-token; |
!!!next-token; |
| 6294 |
redo B; |
next B; |
| 6295 |
} elsif ({ |
} elsif ({ |
| 6296 |
address => 1, blockquote => 1, center => 1, dir => 1, |
address => 1, blockquote => 1, center => 1, dir => 1, |
| 6297 |
div => 1, dl => 1, fieldset => 1, |
div => 1, dl => 1, fieldset => 1, |
| 6306 |
!!!cp ('t350'); |
!!!cp ('t350'); |
| 6307 |
!!!parse-error (type => 'in form:form', token => $token); |
!!!parse-error (type => 'in form:form', token => $token); |
| 6308 |
## Ignore the token |
## Ignore the token |
| 6309 |
|
!!!nack ('t350.1'); |
| 6310 |
!!!next-token; |
!!!next-token; |
| 6311 |
redo B; |
next B; |
| 6312 |
} |
} |
| 6313 |
|
|
| 6314 |
## has a p element in scope |
## has a p element in scope |
| 6315 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 6316 |
if ($_->[1] eq 'p') { |
if ($_->[1] & P_EL) { |
| 6317 |
!!!cp ('t344'); |
!!!cp ('t344'); |
| 6318 |
!!!back-token; |
!!!back-token; # <form> |
| 6319 |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
| 6320 |
line => $token->{line}, column => $token->{column}}; |
line => $token->{line}, column => $token->{column}}; |
| 6321 |
redo B; |
next B; |
| 6322 |
} elsif ({ |
} elsif ($_->[1] & SCOPING_EL) { |
|
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$_->[1]}) { |
|
| 6323 |
!!!cp ('t345'); |
!!!cp ('t345'); |
| 6324 |
last INSCOPE; |
last INSCOPE; |
| 6325 |
} |
} |
| 6327 |
|
|
| 6328 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 6329 |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') { |
| 6330 |
|
!!!nack ('t346.1'); |
| 6331 |
!!!next-token; |
!!!next-token; |
| 6332 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 6333 |
$token->{data} =~ s/^\x0A//; |
$token->{data} =~ s/^\x0A//; |
| 6344 |
!!!cp ('t347.1'); |
!!!cp ('t347.1'); |
| 6345 |
$self->{form_element} = $self->{open_elements}->[-1]->[0]; |
$self->{form_element} = $self->{open_elements}->[-1]->[0]; |
| 6346 |
|
|
| 6347 |
|
!!!nack ('t347.2'); |
| 6348 |
!!!next-token; |
!!!next-token; |
| 6349 |
} elsif ($token->{tag_name} eq 'table') { |
} elsif ($token->{tag_name} eq 'table') { |
| 6350 |
!!!cp ('t382'); |
!!!cp ('t382'); |
| 6352 |
|
|
| 6353 |
$self->{insertion_mode} = IN_TABLE_IM; |
$self->{insertion_mode} = IN_TABLE_IM; |
| 6354 |
|
|
| 6355 |
|
!!!nack ('t382.1'); |
| 6356 |
!!!next-token; |
!!!next-token; |
| 6357 |
} elsif ($token->{tag_name} eq 'hr') { |
} elsif ($token->{tag_name} eq 'hr') { |
| 6358 |
!!!cp ('t386'); |
!!!cp ('t386'); |
| 6359 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 6360 |
|
|
| 6361 |
|
!!!nack ('t386.1'); |
| 6362 |
!!!next-token; |
!!!next-token; |
| 6363 |
} else { |
} else { |
| 6364 |
!!!cp ('t347'); |
!!!nack ('t347.1'); |
| 6365 |
!!!next-token; |
!!!next-token; |
| 6366 |
} |
} |
| 6367 |
redo B; |
next B; |
| 6368 |
} elsif ({li => 1, dt => 1, dd => 1}->{$token->{tag_name}}) { |
} elsif ({li => 1, dt => 1, dd => 1}->{$token->{tag_name}}) { |
| 6369 |
## has a p element in scope |
## has a p element in scope |
| 6370 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 6371 |
if ($_->[1] eq 'p') { |
if ($_->[1] & P_EL) { |
| 6372 |
!!!cp ('t353'); |
!!!cp ('t353'); |
| 6373 |
!!!back-token; |
!!!back-token; # <x> |
| 6374 |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
| 6375 |
line => $token->{line}, column => $token->{column}}; |
line => $token->{line}, column => $token->{column}}; |
| 6376 |
redo B; |
next B; |
| 6377 |
} elsif ({ |
} elsif ($_->[1] & SCOPING_EL) { |
|
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$_->[1]}) { |
|
| 6378 |
!!!cp ('t354'); |
!!!cp ('t354'); |
| 6379 |
last INSCOPE; |
last INSCOPE; |
| 6380 |
} |
} |
| 6388 |
dd => {dt => 1, dd => 1}}->{$token->{tag_name}}; |
dd => {dt => 1, dd => 1}}->{$token->{tag_name}}; |
| 6389 |
LI: { |
LI: { |
| 6390 |
## Step 2 |
## Step 2 |
| 6391 |
if ($li_or_dtdd->{$node->[1]}) { |
if ($li_or_dtdd->{$node->[0]->manakai_local_name}) { |
| 6392 |
if ($i != -1) { |
if ($i != -1) { |
| 6393 |
!!!cp ('t355'); |
!!!cp ('t355'); |
| 6394 |
!!!parse-error (type => 'end tag missing:'. |
!!!parse-error (type => 'not closed', |
| 6395 |
$self->{open_elements}->[-1]->[1], token => $token); |
value => $self->{open_elements}->[-1]->[0] |
| 6396 |
|
->manakai_local_name, |
| 6397 |
|
token => $token); |
| 6398 |
} else { |
} else { |
| 6399 |
!!!cp ('t356'); |
!!!cp ('t356'); |
| 6400 |
} |
} |
| 6405 |
} |
} |
| 6406 |
|
|
| 6407 |
## Step 3 |
## Step 3 |
| 6408 |
if (not $formatting_category->{$node->[1]} and |
if (not ($node->[1] & FORMATTING_EL) and |
| 6409 |
#not $phrasing_category->{$node->[1]} and |
#not $phrasing_category->{$node->[1]} and |
| 6410 |
($special_category->{$node->[1]} or |
($node->[1] & SPECIAL_EL or |
| 6411 |
$scoping_category->{$node->[1]}) and |
$node->[1] & SCOPING_EL) and |
| 6412 |
$node->[1] ne 'address' and $node->[1] ne 'div') { |
not ($node->[1] & ADDRESS_EL) and |
| 6413 |
|
not ($node->[1] & DIV_EL)) { |
| 6414 |
!!!cp ('t358'); |
!!!cp ('t358'); |
| 6415 |
last LI; |
last LI; |
| 6416 |
} |
} |
| 6423 |
} # LI |
} # LI |
| 6424 |
|
|
| 6425 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 6426 |
|
!!!nack ('t359.1'); |
| 6427 |
!!!next-token; |
!!!next-token; |
| 6428 |
redo B; |
next B; |
| 6429 |
} elsif ($token->{tag_name} eq 'plaintext') { |
} elsif ($token->{tag_name} eq 'plaintext') { |
| 6430 |
## has a p element in scope |
## has a p element in scope |
| 6431 |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
INSCOPE: for (reverse @{$self->{open_elements}}) { |
| 6432 |
if ($_->[1] eq 'p') { |
if ($_->[1] & P_EL) { |
| 6433 |
!!!cp ('t367'); |
!!!cp ('t367'); |
| 6434 |
!!!back-token; |
!!!back-token; # <plaintext> |
| 6435 |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
$token = {type => END_TAG_TOKEN, tag_name => 'p', |
| 6436 |
line => $token->{line}, column => $token->{column}}; |
line => $token->{line}, column => $token->{column}}; |
| 6437 |
redo B; |
next B; |
| 6438 |
} elsif ({ |
} elsif ($_->[1] & SCOPING_EL) { |
|
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$_->[1]}) { |
|
| 6439 |
!!!cp ('t368'); |
!!!cp ('t368'); |
| 6440 |
last INSCOPE; |
last INSCOPE; |
| 6441 |
} |
} |
| 6445 |
|
|
| 6446 |
$self->{content_model} = PLAINTEXT_CONTENT_MODEL; |
$self->{content_model} = PLAINTEXT_CONTENT_MODEL; |
| 6447 |
|
|
| 6448 |
|
!!!nack ('t368.1'); |
| 6449 |
!!!next-token; |
!!!next-token; |
| 6450 |
redo B; |
next B; |
| 6451 |
} elsif ($token->{tag_name} eq 'a') { |
} elsif ($token->{tag_name} eq 'a') { |
| 6452 |
AFE: for my $i (reverse 0..$#$active_formatting_elements) { |
AFE: for my $i (reverse 0..$#$active_formatting_elements) { |
| 6453 |
my $node = $active_formatting_elements->[$i]; |
my $node = $active_formatting_elements->[$i]; |
| 6454 |
if ($node->[1] eq 'a') { |
if ($node->[1] & A_EL) { |
| 6455 |
!!!cp ('t371'); |
!!!cp ('t371'); |
| 6456 |
!!!parse-error (type => 'in a:a', token => $token); |
!!!parse-error (type => 'in a:a', token => $token); |
| 6457 |
|
|
| 6458 |
!!!back-token; |
!!!back-token; # <a> |
| 6459 |
$token = {type => END_TAG_TOKEN, tag_name => 'a', |
$token = {type => END_TAG_TOKEN, tag_name => 'a', |
| 6460 |
line => $token->{line}, column => $token->{column}}; |
line => $token->{line}, column => $token->{column}}; |
| 6461 |
$formatting_end_tag->($token); |
$formatting_end_tag->($token); |
| 6486 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 6487 |
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
| 6488 |
|
|
| 6489 |
|
!!!nack ('t374.1'); |
| 6490 |
!!!next-token; |
!!!next-token; |
| 6491 |
redo B; |
next B; |
| 6492 |
} elsif ($token->{tag_name} eq 'nobr') { |
} elsif ($token->{tag_name} eq 'nobr') { |
| 6493 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 6494 |
|
|
| 6495 |
## has a |nobr| element in scope |
## has a |nobr| element in scope |
| 6496 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6497 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 6498 |
if ($node->[1] eq 'nobr') { |
if ($node->[1] & NOBR_EL) { |
| 6499 |
!!!cp ('t376'); |
!!!cp ('t376'); |
| 6500 |
!!!parse-error (type => 'in nobr:nobr', token => $token); |
!!!parse-error (type => 'in nobr:nobr', token => $token); |
| 6501 |
!!!back-token; |
!!!back-token; # <nobr> |
| 6502 |
$token = {type => END_TAG_TOKEN, tag_name => 'nobr', |
$token = {type => END_TAG_TOKEN, tag_name => 'nobr', |
| 6503 |
line => $token->{line}, column => $token->{column}}; |
line => $token->{line}, column => $token->{column}}; |
| 6504 |
redo B; |
next B; |
| 6505 |
} elsif ({ |
} elsif ($node->[1] & SCOPING_EL) { |
|
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 6506 |
!!!cp ('t377'); |
!!!cp ('t377'); |
| 6507 |
last INSCOPE; |
last INSCOPE; |
| 6508 |
} |
} |
| 6511 |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
!!!insert-element-t ($token->{tag_name}, $token->{attributes}, $token); |
| 6512 |
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
| 6513 |
|
|
| 6514 |
|
!!!nack ('t377.1'); |
| 6515 |
!!!next-token; |
!!!next-token; |
| 6516 |
redo B; |
next B; |
| 6517 |
} elsif ($token->{tag_name} eq 'button') { |
} elsif ($token->{tag_name} eq 'button') { |
| 6518 |
## has a button element in scope |
## has a button element in scope |
| 6519 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6520 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 6521 |
if ($node->[1] eq 'button') { |
if ($node->[1] & BUTTON_EL) { |
| 6522 |
!!!cp ('t378'); |
!!!cp ('t378'); |
| 6523 |
!!!parse-error (type => 'in button:button', token => $token); |
!!!parse-error (type => 'in button:button', token => $token); |
| 6524 |
!!!back-token; |
!!!back-token; # <button> |
| 6525 |
$token = {type => END_TAG_TOKEN, tag_name => 'button', |
$token = {type => END_TAG_TOKEN, tag_name => 'button', |
| 6526 |
line => $token->{line}, column => $token->{column}}; |
line => $token->{line}, column => $token->{column}}; |
| 6527 |
redo B; |
next B; |
| 6528 |
} elsif ({ |
} elsif ($node->[1] & SCOPING_EL) { |
|
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 6529 |
!!!cp ('t379'); |
!!!cp ('t379'); |
| 6530 |
last INSCOPE; |
last INSCOPE; |
| 6531 |
} |
} |
| 6539 |
|
|
| 6540 |
push @$active_formatting_elements, ['#marker', '']; |
push @$active_formatting_elements, ['#marker', '']; |
| 6541 |
|
|
| 6542 |
|
!!!nack ('t379.1'); |
| 6543 |
!!!next-token; |
!!!next-token; |
| 6544 |
redo B; |
next B; |
| 6545 |
} elsif ({ |
} elsif ({ |
| 6546 |
xmp => 1, |
xmp => 1, |
| 6547 |
iframe => 1, |
iframe => 1, |
| 6557 |
} |
} |
| 6558 |
## NOTE: There is an "as if in body" code clone. |
## NOTE: There is an "as if in body" code clone. |
| 6559 |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
$parse_rcdata->(CDATA_CONTENT_MODEL); |
| 6560 |
redo B; |
next B; |
| 6561 |
} elsif ($token->{tag_name} eq 'isindex') { |
} elsif ($token->{tag_name} eq 'isindex') { |
| 6562 |
!!!parse-error (type => 'isindex', token => $token); |
!!!parse-error (type => 'isindex', token => $token); |
| 6563 |
|
|
| 6564 |
if (defined $self->{form_element}) { |
if (defined $self->{form_element}) { |
| 6565 |
!!!cp ('t389'); |
!!!cp ('t389'); |
| 6566 |
## Ignore the token |
## Ignore the token |
| 6567 |
|
!!!nack ('t389'); ## NOTE: Not acknowledged. |
| 6568 |
!!!next-token; |
!!!next-token; |
| 6569 |
redo B; |
next B; |
| 6570 |
} else { |
} else { |
| 6571 |
my $at = $token->{attributes}; |
my $at = $token->{attributes}; |
| 6572 |
my $form_attrs; |
my $form_attrs; |
| 6611 |
line => $token->{line}, column => $token->{column}}, |
line => $token->{line}, column => $token->{column}}, |
| 6612 |
{type => END_TAG_TOKEN, tag_name => 'form', |
{type => END_TAG_TOKEN, tag_name => 'form', |
| 6613 |
line => $token->{line}, column => $token->{column}}; |
line => $token->{line}, column => $token->{column}}; |
| 6614 |
$token = shift @tokens; |
!!!nack ('t391.1'); ## NOTE: Not acknowledged. |
| 6615 |
!!!back-token (@tokens); |
!!!back-token (@tokens); |
| 6616 |
redo B; |
!!!next-token; |
| 6617 |
|
next B; |
| 6618 |
} |
} |
| 6619 |
} elsif ($token->{tag_name} eq 'textarea') { |
} elsif ($token->{tag_name} eq 'textarea') { |
| 6620 |
my $tag_name = $token->{tag_name}; |
my $tag_name = $token->{tag_name}; |
| 6621 |
my $el; |
my $el; |
| 6622 |
!!!create-element ($el, $token->{tag_name}, $token->{attributes}, $token); |
!!!create-element ($el, $HTML_NS, $token->{tag_name}, $token->{attributes}, $token); |
| 6623 |
|
|
| 6624 |
## TODO: $self->{form_element} if defined |
## TODO: $self->{form_element} if defined |
| 6625 |
$self->{content_model} = RCDATA_CONTENT_MODEL; |
$self->{content_model} = RCDATA_CONTENT_MODEL; |
| 6628 |
$insert->($el); |
$insert->($el); |
| 6629 |
|
|
| 6630 |
my $text = ''; |
my $text = ''; |
| 6631 |
|
!!!nack ('t392.1'); |
| 6632 |
!!!next-token; |
!!!next-token; |
| 6633 |
if ($token->{type} == CHARACTER_TOKEN) { |
if ($token->{type} == CHARACTER_TOKEN) { |
| 6634 |
$token->{data} =~ s/^\x0A//; |
$token->{data} =~ s/^\x0A//; |
| 6662 |
!!!parse-error (type => 'in RCDATA:#'.$token->{type}, token => $token); |
!!!parse-error (type => 'in RCDATA:#'.$token->{type}, token => $token); |
| 6663 |
} |
} |
| 6664 |
!!!next-token; |
!!!next-token; |
| 6665 |
redo B; |
next B; |
| 6666 |
|
} elsif ($token->{tag_name} eq 'math' or |
| 6667 |
|
$token->{tag_name} eq 'svg') { |
| 6668 |
|
$reconstruct_active_formatting_elements->($insert_to_current); |
| 6669 |
|
|
| 6670 |
|
## "adjust SVG attributes" ('svg' only) - done in insert-element-f |
| 6671 |
|
|
| 6672 |
|
## "adjust foreign attributes" - done in insert-element-f |
| 6673 |
|
|
| 6674 |
|
!!!insert-element-f ($token->{tag_name} eq 'math' ? $MML_NS : $SVG_NS, $token->{tag_name}, $token->{attributes}, $token); |
| 6675 |
|
|
| 6676 |
|
if ($self->{self_closing}) { |
| 6677 |
|
pop @{$self->{open_elements}}; |
| 6678 |
|
!!!ack ('t398.1'); |
| 6679 |
|
} else { |
| 6680 |
|
!!!cp ('t398.2'); |
| 6681 |
|
$self->{insertion_mode} |= IN_FOREIGN_CONTENT_IM; |
| 6682 |
|
## NOTE: |<body><math><mi><svg>| -> "in foreign content" insertion |
| 6683 |
|
## mode, "in body" (not "in foreign content") secondary insertion |
| 6684 |
|
## mode, maybe. |
| 6685 |
|
} |
| 6686 |
|
|
| 6687 |
|
!!!next-token; |
| 6688 |
|
next B; |
| 6689 |
} elsif ({ |
} elsif ({ |
| 6690 |
caption => 1, col => 1, colgroup => 1, frame => 1, |
caption => 1, col => 1, colgroup => 1, frame => 1, |
| 6691 |
frameset => 1, head => 1, option => 1, optgroup => 1, |
frameset => 1, head => 1, option => 1, optgroup => 1, |
| 6695 |
!!!cp ('t401'); |
!!!cp ('t401'); |
| 6696 |
!!!parse-error (type => 'in body:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'in body:'.$token->{tag_name}, token => $token); |
| 6697 |
## Ignore the token |
## Ignore the token |
| 6698 |
|
!!!nack ('t401.1'); ## NOTE: |<col/>| or |<frame/>| here is an error. |
| 6699 |
!!!next-token; |
!!!next-token; |
| 6700 |
redo B; |
next B; |
| 6701 |
|
|
| 6702 |
## ISSUE: An issue on HTML5 new elements in the spec. |
## ISSUE: An issue on HTML5 new elements in the spec. |
| 6703 |
} else { |
} else { |
| 6719 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6720 |
!!!cp ('t380'); |
!!!cp ('t380'); |
| 6721 |
push @$active_formatting_elements, ['#marker', '']; |
push @$active_formatting_elements, ['#marker', '']; |
| 6722 |
|
!!!nack ('t380.1'); |
| 6723 |
} elsif ({ |
} elsif ({ |
| 6724 |
b => 1, big => 1, em => 1, font => 1, i => 1, |
b => 1, big => 1, em => 1, font => 1, i => 1, |
| 6725 |
s => 1, small => 1, strile => 1, |
s => 1, small => 1, strile => 1, |
| 6727 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6728 |
!!!cp ('t375'); |
!!!cp ('t375'); |
| 6729 |
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
push @$active_formatting_elements, $self->{open_elements}->[-1]; |
| 6730 |
|
!!!nack ('t375.1'); |
| 6731 |
} elsif ($token->{tag_name} eq 'input') { |
} elsif ($token->{tag_name} eq 'input') { |
| 6732 |
!!!cp ('t388'); |
!!!cp ('t388'); |
| 6733 |
## TODO: associate with $self->{form_element} if defined |
## TODO: associate with $self->{form_element} if defined |
| 6734 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 6735 |
|
!!!ack ('t388.2'); |
| 6736 |
} elsif ({ |
} elsif ({ |
| 6737 |
area => 1, basefont => 1, bgsound => 1, br => 1, |
area => 1, basefont => 1, bgsound => 1, br => 1, |
| 6738 |
embed => 1, img => 1, param => 1, spacer => 1, wbr => 1, |
embed => 1, img => 1, param => 1, spacer => 1, wbr => 1, |
| 6740 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6741 |
!!!cp ('t388.1'); |
!!!cp ('t388.1'); |
| 6742 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 6743 |
|
!!!ack ('t388.3'); |
| 6744 |
} elsif ($token->{tag_name} eq 'select') { |
} elsif ($token->{tag_name} eq 'select') { |
| 6745 |
## TODO: associate with $self->{form_element} if defined |
## TODO: associate with $self->{form_element} if defined |
| 6746 |
|
|
| 6753 |
!!!cp ('t400.2'); |
!!!cp ('t400.2'); |
| 6754 |
$self->{insertion_mode} = IN_SELECT_IM; |
$self->{insertion_mode} = IN_SELECT_IM; |
| 6755 |
} |
} |
| 6756 |
|
!!!nack ('t400.3'); |
| 6757 |
} else { |
} else { |
| 6758 |
!!!cp ('t402'); |
!!!nack ('t402'); |
| 6759 |
} |
} |
| 6760 |
|
|
| 6761 |
!!!next-token; |
!!!next-token; |
| 6762 |
redo B; |
next B; |
| 6763 |
} |
} |
| 6764 |
} elsif ($token->{type} == END_TAG_TOKEN) { |
} elsif ($token->{type} == END_TAG_TOKEN) { |
| 6765 |
if ($token->{tag_name} eq 'body') { |
if ($token->{tag_name} eq 'body') { |
| 6767 |
my $i; |
my $i; |
| 6768 |
INSCOPE: { |
INSCOPE: { |
| 6769 |
for (reverse @{$self->{open_elements}}) { |
for (reverse @{$self->{open_elements}}) { |
| 6770 |
if ($_->[1] eq 'body') { |
if ($_->[1] & BODY_EL) { |
| 6771 |
!!!cp ('t405'); |
!!!cp ('t405'); |
| 6772 |
$i = $_; |
$i = $_; |
| 6773 |
last INSCOPE; |
last INSCOPE; |
| 6774 |
} elsif ({ |
} elsif ($_->[1] & SCOPING_EL) { |
|
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$_->[1]}) { |
|
| 6775 |
!!!cp ('t405.1'); |
!!!cp ('t405.1'); |
| 6776 |
last; |
last; |
| 6777 |
} |
} |
| 6781 |
value => $token->{tag_name}, token => $token); |
value => $token->{tag_name}, token => $token); |
| 6782 |
## NOTE: Ignore the token. |
## NOTE: Ignore the token. |
| 6783 |
!!!next-token; |
!!!next-token; |
| 6784 |
redo B; |
next B; |
| 6785 |
} # INSCOPE |
} # INSCOPE |
| 6786 |
|
|
| 6787 |
for (@{$self->{open_elements}}) { |
for (@{$self->{open_elements}}) { |
| 6788 |
unless ({ |
unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL) { |
|
dd => 1, dt => 1, li => 1, p => 1, td => 1, |
|
|
th => 1, tr => 1, body => 1, html => 1, |
|
|
tbody => 1, tfoot => 1, thead => 1, |
|
|
}->{$_->[1]}) { |
|
| 6789 |
!!!cp ('t403'); |
!!!cp ('t403'); |
| 6790 |
!!!parse-error (type => 'not closed:'.$_->[1], token => $token); |
!!!parse-error (type => 'not closed', |
| 6791 |
|
value => $_->[0]->manakai_local_name, |
| 6792 |
|
token => $token); |
| 6793 |
last; |
last; |
| 6794 |
} else { |
} else { |
| 6795 |
!!!cp ('t404'); |
!!!cp ('t404'); |
| 6798 |
|
|
| 6799 |
$self->{insertion_mode} = AFTER_BODY_IM; |
$self->{insertion_mode} = AFTER_BODY_IM; |
| 6800 |
!!!next-token; |
!!!next-token; |
| 6801 |
redo B; |
next B; |
| 6802 |
} elsif ($token->{tag_name} eq 'html') { |
} elsif ($token->{tag_name} eq 'html') { |
| 6803 |
if (@{$self->{open_elements}} > 1 and $self->{open_elements}->[1]->[1] eq 'body') { |
## TODO: Update this code. It seems that the code below is not |
| 6804 |
|
## up-to-date, though it has same effect as speced. |
| 6805 |
|
if (@{$self->{open_elements}} > 1 and |
| 6806 |
|
$self->{open_elements}->[1]->[1] & BODY_EL) { |
| 6807 |
## ISSUE: There is an issue in the spec. |
## ISSUE: There is an issue in the spec. |
| 6808 |
if ($self->{open_elements}->[-1]->[1] ne 'body') { |
unless ($self->{open_elements}->[-1]->[1] & BODY_EL) { |
| 6809 |
!!!cp ('t406'); |
!!!cp ('t406'); |
| 6810 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[1]->[1], token => $token); |
!!!parse-error (type => 'not closed', |
| 6811 |
|
value => $self->{open_elements}->[1]->[0] |
| 6812 |
|
->manakai_local_name, |
| 6813 |
|
token => $token); |
| 6814 |
} else { |
} else { |
| 6815 |
!!!cp ('t407'); |
!!!cp ('t407'); |
| 6816 |
} |
} |
| 6817 |
$self->{insertion_mode} = AFTER_BODY_IM; |
$self->{insertion_mode} = AFTER_BODY_IM; |
| 6818 |
## reprocess |
## reprocess |
| 6819 |
redo B; |
next B; |
| 6820 |
} else { |
} else { |
| 6821 |
!!!cp ('t408'); |
!!!cp ('t408'); |
| 6822 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6823 |
## Ignore the token |
## Ignore the token |
| 6824 |
!!!next-token; |
!!!next-token; |
| 6825 |
redo B; |
next B; |
| 6826 |
} |
} |
| 6827 |
} elsif ({ |
} elsif ({ |
| 6828 |
address => 1, blockquote => 1, center => 1, dir => 1, |
address => 1, blockquote => 1, center => 1, dir => 1, |
| 6835 |
my $i; |
my $i; |
| 6836 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6837 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 6838 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[0]->manakai_local_name eq $token->{tag_name}) { |
| 6839 |
!!!cp ('t410'); |
!!!cp ('t410'); |
| 6840 |
$i = $_; |
$i = $_; |
| 6841 |
last INSCOPE; |
last INSCOPE; |
| 6842 |
} elsif ({ |
} elsif ($node->[1] & SCOPING_EL) { |
|
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 6843 |
!!!cp ('t411'); |
!!!cp ('t411'); |
| 6844 |
last INSCOPE; |
last INSCOPE; |
| 6845 |
} |
} |
| 6855 |
dt => ($token->{tag_name} ne 'dt'), |
dt => ($token->{tag_name} ne 'dt'), |
| 6856 |
li => ($token->{tag_name} ne 'li'), |
li => ($token->{tag_name} ne 'li'), |
| 6857 |
p => 1, |
p => 1, |
| 6858 |
}->{$self->{open_elements}->[-1]->[1]}) { |
}->{$self->{open_elements}->[-1]->[0]->manakai_local_name}) { |
| 6859 |
!!!cp ('t409'); |
!!!cp ('t409'); |
| 6860 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 6861 |
} |
} |
| 6862 |
|
|
| 6863 |
## Step 2. |
## Step 2. |
| 6864 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[0]->manakai_local_name |
| 6865 |
|
ne $token->{tag_name}) { |
| 6866 |
!!!cp ('t412'); |
!!!cp ('t412'); |
| 6867 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
!!!parse-error (type => 'not closed', |
| 6868 |
|
value => $self->{open_elements}->[-1]->[0] |
| 6869 |
|
->manakai_local_name, |
| 6870 |
|
token => $token); |
| 6871 |
} else { |
} else { |
| 6872 |
!!!cp ('t414'); |
!!!cp ('t414'); |
| 6873 |
} |
} |
| 6882 |
}->{$token->{tag_name}}; |
}->{$token->{tag_name}}; |
| 6883 |
} |
} |
| 6884 |
!!!next-token; |
!!!next-token; |
| 6885 |
redo B; |
next B; |
| 6886 |
} elsif ($token->{tag_name} eq 'form') { |
} elsif ($token->{tag_name} eq 'form') { |
| 6887 |
undef $self->{form_element}; |
undef $self->{form_element}; |
| 6888 |
|
|
| 6890 |
my $i; |
my $i; |
| 6891 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6892 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 6893 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] & FORM_EL) { |
| 6894 |
!!!cp ('t418'); |
!!!cp ('t418'); |
| 6895 |
$i = $_; |
$i = $_; |
| 6896 |
last INSCOPE; |
last INSCOPE; |
| 6897 |
} elsif ({ |
} elsif ($node->[1] & SCOPING_EL) { |
|
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 6898 |
!!!cp ('t419'); |
!!!cp ('t419'); |
| 6899 |
last INSCOPE; |
last INSCOPE; |
| 6900 |
} |
} |
| 6905 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6906 |
} else { |
} else { |
| 6907 |
## Step 1. generate implied end tags |
## Step 1. generate implied end tags |
| 6908 |
while ({ |
while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) { |
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 6909 |
!!!cp ('t417'); |
!!!cp ('t417'); |
| 6910 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 6911 |
} |
} |
| 6912 |
|
|
| 6913 |
## Step 2. |
## Step 2. |
| 6914 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[0]->manakai_local_name |
| 6915 |
|
ne $token->{tag_name}) { |
| 6916 |
!!!cp ('t417.1'); |
!!!cp ('t417.1'); |
| 6917 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
!!!parse-error (type => 'not closed', |
| 6918 |
|
value => $self->{open_elements}->[-1]->[0] |
| 6919 |
|
->manakai_local_name, |
| 6920 |
|
token => $token); |
| 6921 |
} else { |
} else { |
| 6922 |
!!!cp ('t420'); |
!!!cp ('t420'); |
| 6923 |
} |
} |
| 6927 |
} |
} |
| 6928 |
|
|
| 6929 |
!!!next-token; |
!!!next-token; |
| 6930 |
redo B; |
next B; |
| 6931 |
} elsif ({ |
} elsif ({ |
| 6932 |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
| 6933 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 6935 |
my $i; |
my $i; |
| 6936 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6937 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 6938 |
if ({ |
if ($node->[1] & HEADING_EL) { |
|
h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1, |
|
|
}->{$node->[1]}) { |
|
| 6939 |
!!!cp ('t423'); |
!!!cp ('t423'); |
| 6940 |
$i = $_; |
$i = $_; |
| 6941 |
last INSCOPE; |
last INSCOPE; |
| 6942 |
} elsif ({ |
} elsif ($node->[1] & SCOPING_EL) { |
|
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 6943 |
!!!cp ('t424'); |
!!!cp ('t424'); |
| 6944 |
last INSCOPE; |
last INSCOPE; |
| 6945 |
} |
} |
| 6950 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6951 |
} else { |
} else { |
| 6952 |
## Step 1. generate implied end tags |
## Step 1. generate implied end tags |
| 6953 |
while ({ |
while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) { |
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 6954 |
!!!cp ('t422'); |
!!!cp ('t422'); |
| 6955 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 6956 |
} |
} |
| 6957 |
|
|
| 6958 |
## Step 2. |
## Step 2. |
| 6959 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[0]->manakai_local_name |
| 6960 |
|
ne $token->{tag_name}) { |
| 6961 |
!!!cp ('t425'); |
!!!cp ('t425'); |
| 6962 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 6963 |
} else { |
} else { |
| 6969 |
} |
} |
| 6970 |
|
|
| 6971 |
!!!next-token; |
!!!next-token; |
| 6972 |
redo B; |
next B; |
| 6973 |
} elsif ($token->{tag_name} eq 'p') { |
} elsif ($token->{tag_name} eq 'p') { |
| 6974 |
## has an element in scope |
## has an element in scope |
| 6975 |
my $i; |
my $i; |
| 6976 |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
INSCOPE: for (reverse 0..$#{$self->{open_elements}}) { |
| 6977 |
my $node = $self->{open_elements}->[$_]; |
my $node = $self->{open_elements}->[$_]; |
| 6978 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[1] & P_EL) { |
| 6979 |
!!!cp ('t410.1'); |
!!!cp ('t410.1'); |
| 6980 |
$i = $_; |
$i = $_; |
| 6981 |
last INSCOPE; |
last INSCOPE; |
| 6982 |
} elsif ({ |
} elsif ($node->[1] & SCOPING_EL) { |
|
applet => 1, table => 1, caption => 1, td => 1, th => 1, |
|
|
button => 1, marquee => 1, object => 1, html => 1, |
|
|
}->{$node->[1]}) { |
|
| 6983 |
!!!cp ('t411.1'); |
!!!cp ('t411.1'); |
| 6984 |
last INSCOPE; |
last INSCOPE; |
| 6985 |
} |
} |
| 6986 |
} # INSCOPE |
} # INSCOPE |
| 6987 |
|
|
| 6988 |
if (defined $i) { |
if (defined $i) { |
| 6989 |
if ($self->{open_elements}->[-1]->[1] ne $token->{tag_name}) { |
if ($self->{open_elements}->[-1]->[0]->manakai_local_name |
| 6990 |
|
ne $token->{tag_name}) { |
| 6991 |
!!!cp ('t412.1'); |
!!!cp ('t412.1'); |
| 6992 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
!!!parse-error (type => 'not closed', |
| 6993 |
|
value => $self->{open_elements}->[-1]->[0] |
| 6994 |
|
->manakai_local_name, |
| 6995 |
|
token => $token); |
| 6996 |
} else { |
} else { |
| 6997 |
!!!cp ('t414.1'); |
!!!cp ('t414.1'); |
| 6998 |
} |
} |
| 7005 |
!!!cp ('t415.1'); |
!!!cp ('t415.1'); |
| 7006 |
## As if <p>, then reprocess the current token |
## As if <p>, then reprocess the current token |
| 7007 |
my $el; |
my $el; |
| 7008 |
!!!create-element ($el, 'p',, $token); |
!!!create-element ($el, $HTML_NS, 'p',, $token); |
| 7009 |
$insert->($el); |
$insert->($el); |
| 7010 |
## NOTE: Not inserted into |$self->{open_elements}|. |
## NOTE: Not inserted into |$self->{open_elements}|. |
| 7011 |
} |
} |
| 7012 |
|
|
| 7013 |
!!!next-token; |
!!!next-token; |
| 7014 |
redo B; |
next B; |
| 7015 |
} elsif ({ |
} elsif ({ |
| 7016 |
a => 1, |
a => 1, |
| 7017 |
b => 1, big => 1, em => 1, font => 1, i => 1, |
b => 1, big => 1, em => 1, font => 1, i => 1, |
| 7020 |
}->{$token->{tag_name}}) { |
}->{$token->{tag_name}}) { |
| 7021 |
!!!cp ('t427'); |
!!!cp ('t427'); |
| 7022 |
$formatting_end_tag->($token); |
$formatting_end_tag->($token); |
| 7023 |
redo B; |
next B; |
| 7024 |
} elsif ($token->{tag_name} eq 'br') { |
} elsif ($token->{tag_name} eq 'br') { |
| 7025 |
!!!cp ('t428'); |
!!!cp ('t428'); |
| 7026 |
!!!parse-error (type => 'unmatched end tag:br', token => $token); |
!!!parse-error (type => 'unmatched end tag:br', token => $token); |
| 7029 |
$reconstruct_active_formatting_elements->($insert_to_current); |
$reconstruct_active_formatting_elements->($insert_to_current); |
| 7030 |
|
|
| 7031 |
my $el; |
my $el; |
| 7032 |
!!!create-element ($el, 'br',, $token); |
!!!create-element ($el, $HTML_NS, 'br',, $token); |
| 7033 |
$insert->($el); |
$insert->($el); |
| 7034 |
|
|
| 7035 |
## Ignore the token. |
## Ignore the token. |
| 7036 |
!!!next-token; |
!!!next-token; |
| 7037 |
redo B; |
next B; |
| 7038 |
} elsif ({ |
} elsif ({ |
| 7039 |
caption => 1, col => 1, colgroup => 1, frame => 1, |
caption => 1, col => 1, colgroup => 1, frame => 1, |
| 7040 |
frameset => 1, head => 1, option => 1, optgroup => 1, |
frameset => 1, head => 1, option => 1, optgroup => 1, |
| 7051 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 7052 |
## Ignore the token |
## Ignore the token |
| 7053 |
!!!next-token; |
!!!next-token; |
| 7054 |
redo B; |
next B; |
| 7055 |
|
|
| 7056 |
## ISSUE: Issue on HTML5 new elements in spec |
## ISSUE: Issue on HTML5 new elements in spec |
| 7057 |
|
|
| 7062 |
|
|
| 7063 |
## Step 2 |
## Step 2 |
| 7064 |
S2: { |
S2: { |
| 7065 |
if ($node->[1] eq $token->{tag_name}) { |
if ($node->[0]->manakai_local_name eq $token->{tag_name}) { |
| 7066 |
## Step 1 |
## Step 1 |
| 7067 |
## generate implied end tags |
## generate implied end tags |
| 7068 |
while ({ |
while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) { |
|
dd => 1, dt => 1, li => 1, p => 1, |
|
|
}->{$self->{open_elements}->[-1]->[1]}) { |
|
| 7069 |
!!!cp ('t430'); |
!!!cp ('t430'); |
| 7070 |
## ISSUE: Can this case be reached? |
## ISSUE: Can this case be reached? |
| 7071 |
pop @{$self->{open_elements}}; |
pop @{$self->{open_elements}}; |
| 7072 |
} |
} |
| 7073 |
|
|
| 7074 |
## Step 2 |
## Step 2 |
| 7075 |
if ($token->{tag_name} ne $self->{open_elements}->[-1]->[1]) { |
if ($self->{open_elements}->[-1]->[0]->manakai_local_name |
| 7076 |
|
ne $token->{tag_name}) { |
| 7077 |
!!!cp ('t431'); |
!!!cp ('t431'); |
| 7078 |
## NOTE: <x><y></x> |
## NOTE: <x><y></x> |
| 7079 |
!!!parse-error (type => 'not closed:'.$self->{open_elements}->[-1]->[1], token => $token); |
!!!parse-error (type => 'not closed', |
| 7080 |
|
value => $self->{open_elements}->[-1]->[0] |
| 7081 |
|
->manakai_local_name, |
| 7082 |
|
token => $token); |
| 7083 |
} else { |
} else { |
| 7084 |
!!!cp ('t432'); |
!!!cp ('t432'); |
| 7085 |
} |
} |
| 7091 |
last S2; |
last S2; |
| 7092 |
} else { |
} else { |
| 7093 |
## Step 3 |
## Step 3 |
| 7094 |
if (not $formatting_category->{$node->[1]} and |
if (not ($node->[1] & FORMATTING_EL) and |
| 7095 |
#not $phrasing_category->{$node->[1]} and |
#not $phrasing_category->{$node->[1]} and |
| 7096 |
($special_category->{$node->[1]} or |
($node->[1] & SPECIAL_EL or |
| 7097 |
$scoping_category->{$node->[1]})) { |
$node->[1] & SCOPING_EL)) { |
| 7098 |
!!!cp ('t433'); |
!!!cp ('t433'); |
| 7099 |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
!!!parse-error (type => 'unmatched end tag:'.$token->{tag_name}, token => $token); |
| 7100 |
## Ignore the token |
## Ignore the token |
| 7112 |
## Step 5; |
## Step 5; |
| 7113 |
redo S2; |
redo S2; |
| 7114 |
} # S2 |
} # S2 |
| 7115 |
redo B; |
next B; |
| 7116 |
} |
} |
| 7117 |
} |
} |
| 7118 |
redo B; |
next B; |
| 7119 |
|
} continue { # B |
| 7120 |
|
if ($self->{insertion_mode} & IN_FOREIGN_CONTENT_IM) { |
| 7121 |
|
## NOTE: The code below is executed in cases where it does not have |
| 7122 |
|
## to be, but it it is harmless even in those cases. |
| 7123 |
|
## has an element in scope |
| 7124 |
|
INSCOPE: { |
| 7125 |
|
for (reverse 0..$#{$self->{open_elements}}) { |
| 7126 |
|
my $node = $self->{open_elements}->[$_]; |
| 7127 |
|
if ($node->[1] & FOREIGN_EL) { |
| 7128 |
|
last INSCOPE; |
| 7129 |
|
} elsif ($node->[1] & SCOPING_EL) { |
| 7130 |
|
last; |
| 7131 |
|
} |
| 7132 |
|
} |
| 7133 |
|
|
| 7134 |
|
## NOTE: No foreign element in scope. |
| 7135 |
|
$self->{insertion_mode} &= ~ IN_FOREIGN_CONTENT_IM; |
| 7136 |
|
} # INSCOPE |
| 7137 |
|
} |
| 7138 |
} # B |
} # B |
| 7139 |
|
|
| 7140 |
## Stop parsing # MUST |
## Stop parsing # MUST |
| 7180 |
|
|
| 7181 |
## Step 8 # MUST |
## Step 8 # MUST |
| 7182 |
my $i = 0; |
my $i = 0; |
| 7183 |
my $line = 1; |
$p->{line_prev} = $p->{line} = 1; |
| 7184 |
my $column = 0; |
$p->{column_prev} = $p->{column} = 0; |
| 7185 |
$p->{set_next_char} = sub { |
$p->{set_next_char} = sub { |
| 7186 |
my $self = shift; |
my $self = shift; |
| 7187 |
|
|
| 7190 |
|
|
| 7191 |
$self->{next_char} = -1 and return if $i >= length $$s; |
$self->{next_char} = -1 and return if $i >= length $$s; |
| 7192 |
$self->{next_char} = ord substr $$s, $i++, 1; |
$self->{next_char} = ord substr $$s, $i++, 1; |
| 7193 |
$column++; |
|
| 7194 |
|
($p->{line_prev}, $p->{column_prev}) = ($p->{line}, $p->{column}); |
| 7195 |
|
$p->{column}++; |
| 7196 |
|
|
| 7197 |
if ($self->{next_char} == 0x000A) { # LF |
if ($self->{next_char} == 0x000A) { # LF |
| 7198 |
$line++; |
$p->{line}++; |
| 7199 |
$column = 0; |
$p->{column} = 0; |
| 7200 |
!!!cp ('i1'); |
!!!cp ('i1'); |
| 7201 |
} elsif ($self->{next_char} == 0x000D) { # CR |
} elsif ($self->{next_char} == 0x000D) { # CR |
| 7202 |
$i++ if substr ($$s, $i, 1) eq "\x0A"; |
$i++ if substr ($$s, $i, 1) eq "\x0A"; |
| 7203 |
$self->{next_char} = 0x000A; # LF # MUST |
$self->{next_char} = 0x000A; # LF # MUST |
| 7204 |
$line++; |
$p->{line}++; |
| 7205 |
$column = 0; |
$p->{column} = 0; |
| 7206 |
!!!cp ('i2'); |
!!!cp ('i2'); |
| 7207 |
} elsif ($self->{next_char} > 0x10FFFF) { |
} elsif ($self->{next_char} > 0x10FFFF) { |
| 7208 |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
| 7211 |
!!!cp ('i4'); |
!!!cp ('i4'); |
| 7212 |
!!!parse-error (type => 'NULL'); |
!!!parse-error (type => 'NULL'); |
| 7213 |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
| 7214 |
|
} elsif ($self->{next_char} <= 0x0008 or |
| 7215 |
|
(0x000E <= $self->{next_char} and |
| 7216 |
|
$self->{next_char} <= 0x001F) or |
| 7217 |
|
(0x007F <= $self->{next_char} and |
| 7218 |
|
$self->{next_char} <= 0x009F) or |
| 7219 |
|
(0xD800 <= $self->{next_char} and |
| 7220 |
|
$self->{next_char} <= 0xDFFF) or |
| 7221 |
|
(0xFDD0 <= $self->{next_char} and |
| 7222 |
|
$self->{next_char} <= 0xFDDF) or |
| 7223 |
|
{ |
| 7224 |
|
0xFFFE => 1, 0xFFFF => 1, 0x1FFFE => 1, 0x1FFFF => 1, |
| 7225 |
|
0x2FFFE => 1, 0x2FFFF => 1, 0x3FFFE => 1, 0x3FFFF => 1, |
| 7226 |
|
0x4FFFE => 1, 0x4FFFF => 1, 0x5FFFE => 1, 0x5FFFF => 1, |
| 7227 |
|
0x6FFFE => 1, 0x6FFFF => 1, 0x7FFFE => 1, 0x7FFFF => 1, |
| 7228 |
|
0x8FFFE => 1, 0x8FFFF => 1, 0x9FFFE => 1, 0x9FFFF => 1, |
| 7229 |
|
0xAFFFE => 1, 0xAFFFF => 1, 0xBFFFE => 1, 0xBFFFF => 1, |
| 7230 |
|
0xCFFFE => 1, 0xCFFFF => 1, 0xDFFFE => 1, 0xDFFFF => 1, |
| 7231 |
|
0xEFFFE => 1, 0xEFFFF => 1, 0xFFFFE => 1, 0xFFFFF => 1, |
| 7232 |
|
0x10FFFE => 1, 0x10FFFF => 1, |
| 7233 |
|
}->{$self->{next_char}}) { |
| 7234 |
|
!!!cp ('i4.1'); |
| 7235 |
|
!!!parse-error (type => 'control char', level => $self->{must_level}); |
| 7236 |
|
## TODO: error type documentation |
| 7237 |
} |
} |
| 7238 |
}; |
}; |
| 7239 |
$p->{prev_char} = [-1, -1, -1]; |
$p->{prev_char} = [-1, -1, -1]; |
| 7241 |
|
|
| 7242 |
my $ponerror = $onerror || sub { |
my $ponerror = $onerror || sub { |
| 7243 |
my (%opt) = @_; |
my (%opt) = @_; |
| 7244 |
warn "Parse error ($opt{type}) at line $opt{line} column $opt{column}\n"; |
my $line = $opt{line}; |
| 7245 |
|
my $column = $opt{column}; |
| 7246 |
|
if (defined $opt{token} and defined $opt{token}->{line}) { |
| 7247 |
|
$line = $opt{token}->{line}; |
| 7248 |
|
$column = $opt{token}->{column}; |
| 7249 |
|
} |
| 7250 |
|
warn "Parse error ($opt{type}) at line $line column $column\n"; |
| 7251 |
}; |
}; |
| 7252 |
$p->{parse_error} = sub { |
$p->{parse_error} = sub { |
| 7253 |
$ponerror->(@_, line => $line, column => $column); |
$ponerror->(line => $p->{line}, column => $p->{column}, @_); |
| 7254 |
}; |
}; |
| 7255 |
|
|
| 7256 |
$p->_initialize_tokenizer; |
$p->_initialize_tokenizer; |
| 7274 |
unless defined $p->{content_model}; |
unless defined $p->{content_model}; |
| 7275 |
## ISSUE: What is "the name of the element"? local name? |
## ISSUE: What is "the name of the element"? local name? |
| 7276 |
|
|
| 7277 |
$p->{inner_html_node} = [$node, $node_ln]; |
$p->{inner_html_node} = [$node, $el_category->{$node_ln}]; |
| 7278 |
|
## TODO: Foreign element OK? |
| 7279 |
|
|
| 7280 |
## Step 3 |
## Step 3 |
| 7281 |
my $root = $doc->create_element_ns |
my $root = $doc->create_element_ns |
| 7285 |
$doc->append_child ($root); |
$doc->append_child ($root); |
| 7286 |
|
|
| 7287 |
## Step 5 # MUST |
## Step 5 # MUST |
| 7288 |
push @{$p->{open_elements}}, [$root, 'html']; |
push @{$p->{open_elements}}, [$root, $el_category->{html}]; |
| 7289 |
|
|
| 7290 |
undef $p->{head_element}; |
undef $p->{head_element}; |
| 7291 |
|
|
| 7331 |
## ISSUE: mutation events? |
## ISSUE: mutation events? |
| 7332 |
|
|
| 7333 |
$p->_terminate_tree_constructor; |
$p->_terminate_tree_constructor; |
| 7334 |
|
|
| 7335 |
|
delete $p->{parse_error}; # delete loop |
| 7336 |
} else { |
} else { |
| 7337 |
die "$0: |set_inner_html| is not defined for node of type $nt"; |
die "$0: |set_inner_html| is not defined for node of type $nt"; |
| 7338 |
} |
} |