blib/lib/HTML/HTML5/Parser/TagSoupParser.pm

filter: Statementstmt 76.3% 2386 / 3125 Branchbran 69.0% 1087 / 1574 Conditioncond 61.0% 314 / 514 MC/DCmcdc 32.0% 92 / 287 Subroutinesub 73.3% 44 / 60 Podpod 0.0% 0 / 8 totaltotal 70.4% 3923 / 5568 CC 1077 SCAR 88.8
CC
1077
Cov
73%
_tree_construction_main
9907.8
set_inner_html
650.0
__ANON__
110.0
CRAP 7191.5
« blib/lib/HTML/HTML5/Parser/Charset/DecodeHandle.pm ↑ Summary blib/lib/HTML/HTML5/Parser/Charset/Info.pm »
1 package HTML::HTML5::Parser::TagSoupParser;
2  
3 ## skip Test::Tabs
4  
5 # This is a port of the Whatpm::HTML package away from dependencies
6 # on manakai, and towards CPAN and XML::LibXML.
7  
8 # http://suika.fam.cx/gate/git/wi/manakai.git/history/HEAD:/lib/Whatpm/HTML.pm
9 # CAUGHT UP TO d81fcb920a1a3c351149cd66a64bf1b8ae14a172 (2011-08-21)
10  
11 11 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 11 ▶no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 11 our $VERSION = '0.991';
16  
17 11 ▶use IO::Handle;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 11 ▶use HTML::HTML5::Parser::Tokenizer;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 11 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
20 11 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 11 ▶use XML::LibXML ':libxml';
Subroutine BEGIN: called CC=1 SCAR=0.0
22 11 ▶use XML::LibXML::Devel;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 BEGIN
25 {
26 11 ▶ if (eval { require XML::LibXML::Devel::SetLineNumber; 1 })
Subroutine BEGIN: called CC=2 SCAR=8.4
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require XML::LibXML::Devel::SetLineNumber; 1 } }) { } 0 11 11
27 {
28 0 *HAS_XLXDSLN = sub () { 1 };
29 }
30 else
31 {
32 11 *HAS_XLXDSLN = sub () { 0 };
33 }
34 }
35  
36 *XML::LibXML::Element::appendTextFromUnicode = sub
37 {
38 1259 ▶ my $element = shift;
Subroutine __ANON__: called CC=9 SCAR=22.0
39 1259 ▶ my $parser = shift if ref $_[0];
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] 1259 0 1259
40 1259 my $text = shift; utf8::encode($text);
41 1259 my $token = shift;
42
43 # This prevents adjacent text nodes.
44 1259 ▶ if (defined $element->lastChild
Branch: 1 branch
BranchTrueFalseTotal
if (defined $element->lastChild and $element->lastChild->nodeType == 3) 524 735 1259
Condition100%3/3
defined $element->lastChild and $element->lastChild->nodeType == 3
!ll&&!rl&&r
580155524
MC/DC100%2/2
defined $element->lastChild and $element->lastChild->nodeType == 3
defined $element->lastChild $element->lastChild->nodeType == 3
Truth table100%3/3
A and B
A= defined $element->lastChildB= $element->lastChild->nodeType == 3
ABresult
0X0
100
111
45 and $element->lastChild->nodeType == XML_TEXT_NODE)
46 {
47 524 $element->appendText($text);
48 524 return;
49 }
50  
51 735 my $textnode = XML::LibXML::Text->new($text);
52  
53 735 ▶ if ($token)
Branch: 1 branch
BranchTrueFalseTotal
if ($token) 687 48 735
54 {
55 $parser->_data($textnode, manakai_source_line => $token->{line})
56 687 ▶ if $parser and defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if $parser and defined $token->{"line"} 680 7 687
Condition66%2/3
$parser and defined $token->{"line"}
!ll&&!rl&&r
07680
MC/DC50%1/2
$parser and defined $token->{"line"}
$parser defined $token->{"line"}
Truth table66%2/3
A and B
A= $parserB= defined $token->{"line"}
ABresult
0X0
100
111
57 $parser->_data($textnode, manakai_source_column => $token->{column})
58 687 ▶ if $parser and defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if $parser and defined $token->{"column"} 680 7 687
Condition66%2/3
$parser and defined $token->{"column"}
!ll&&!rl&&r
07680
MC/DC50%1/2
$parser and defined $token->{"column"}
$parser defined $token->{"column"}
Truth table66%2/3
A and B
A= $parserB= defined $token->{"column"}
ABresult
0X0
100
111
59  
60 687 if (HAS_XLXDSLN
61 and exists $token->{line}
62 and int($token->{line})
63 and int($token->{line}) eq $token->{line})
64 {
65 $textnode->XML::LibXML::Devel::SetLineNumber::set_line_number($token->{line});
66 }
67 }
68  
69 735 return $element->appendChild($textnode);
70 11 };
71  
72 11 our $DATA = {};
73 sub DATA {
74 10 ▶ _data(undef, @_);
Subroutine DATA: called CC=1 SCAR=0.0
Pod undocumented
75 }
76  
77 sub _data
78 {
79 20019 ▶ my $self = shift;
Subroutine _data: called CC=9 SCAR=23.3
80 20019 my ($object, $k, $v) = @_;
81 20019 my $argc = @_;
82 # This method doesn't work for non XLxN things. Fail silently.
83 20019 ▶ unless (blessed($object) and $object->isa('XML::LibXML::Node'))
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($object) and $object->isa("XML::LibXML::Node")) 0 20019 20019
Condition33%1/3
builtin::blessed($object) and $object->isa("XML::LibXML::Node")
!ll&&!rl&&r
0020019
MC/DC0%0/2
builtin::blessed($object) and $object->isa("XML::LibXML::Node")
builtin::blessed($object) $object->isa("XML::LibXML::Node")
Truth table33%1/3
A and B
A= builtin::blessed($object)B= $object->isa("XML::LibXML::Node")
ABresult
0X0
100
111
84 {
85 0 ▶ return {} if $argc==1;
Branch: 1 branch
BranchTrueFalseTotal
if $argc == 1 0 0 0
86 0 return;
87 }
88  
89 # This seems to work much better as a unique identifier for a
90 # node than refaddr does. However, it's not a supported use
91 # for XML::LibXML::Devel, so it might cause failures. We'll see.
92 20019 my $oaddr = XML::LibXML::Devel::node_from_perl($object);
93 20019 my $data;
94 20019 ▶ if (ref $self) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 20009 10 20019
95 20009 ▶ $data = $self->{_debug_cache}{$oaddr} ||= {};
Condition100%2/2
$self->{"_debug_cache"}{$oaddr} ||= {}
l!l
148375172
MC/DC100%1/1
$self->{"_debug_cache"}{$oaddr} ||= {}
$self->{"_debug_cache"}{$oaddr}
Truth table100%2/2
A
A= $self->{"_debug_cache"}{$oaddr}
Aresult
11
00
96 }
97 else {
98 10 ▶ $data = $DATA->{$oaddr} ||= {};
Condition50%1/2
$HTML::HTML5::Parser::TagSoupParser::DATA->{$oaddr} ||= {}
l!l
100
MC/DC0%0/1
$HTML::HTML5::Parser::TagSoupParser::DATA->{$oaddr} ||= {}
$HTML::HTML5::Parser::TagSoupParser::DATA->{$oaddr}
Truth table50%1/2
A
A= $HTML::HTML5::Parser::TagSoupParser::DATA->{$oaddr}
Aresult
11
00
99 }
100  
101 20019 if (HAS_XLXDSLN
102 and defined $k
103 and $k eq 'manakai_source_line'
104 and defined $v
105 and int($v)
106 and int($v) eq $v
107 and $object->nodeType == XML_ELEMENT_NODE) # does not work well for attrs
108 {
109 $object->XML::LibXML::Devel::SetLineNumber::set_line_number($v);
110 }
111  
112 20019 ▶ $data->{$k} = $v if $argc==3;
Branch: 1 branch
BranchTrueFalseTotal
if $argc == 3 14423 5596 20019
113 20019 ▶ return $data->{$k} if $argc==2;
Branch: 1 branch
BranchTrueFalseTotal
if $argc == 2 198 19821 20019
114 19821 return $data;
115 }
116  
117 ## NOTE: This module don't check all HTML5 parse errors; character
118 ## encoding related parse errors are expected to be handled by relevant
119 ## modules.
120 ## Parse errors for control characters that are not allowed in HTML5
121 ## documents, for surrogate code points, and for noncharacter code
122 ## points, as well as U+FFFD substitions for characters whose code points
123 ## is higher than U+10FFFF may be detected by combining the parser with
124 ## the checker implemented by HTML::HTML5::Parser::Charset::UnicodeChecker (for its
125 ## usage example, see |t/HTML-tree.t| in the Whatpm package or the
126 ## WebHACC::Language::HTML module in the WebHACC package).
127  
128 ## ISSUE:
129 ## var doc = implementation.createDocument (null, null, null);
130 ## doc.write ('');
131 ## alert (doc.compatMode);
132  
133 ## Namespace URLs
134  
135 sub HTML_NS () { q <http://www.w3.org/1999/xhtml> }
136 sub MML_NS () { q <http://www.w3.org/1998/Math/MathML> }
137 sub SVG_NS () { q <http://www.w3.org/2000/svg> }
138 sub XLINK_NS () { q <http://www.w3.org/1999/xlink> }
139 sub XML_NS () { q <http://www.w3.org/XML/1998/namespace> }
140 sub XMLNS_NS () { q <http://www.w3.org/2000/xmlns/> }
141  
142 ## Element categories
143  
144 ## Bits 14-18
145 sub BUTTON_SCOPING_EL () { 0b1_000000000000000000 } ## Special
146 sub SPECIAL_EL () { 0b1_00000000000000000 } ## Special
147 sub SCOPING_EL () { 0b1_0000000000000000 } ## Special
148 sub FORMATTING_EL () { 0b1_000000000000000 } ## Formatting
149 sub PHRASING_EL () { 0b1_00000000000000 } ## Ordinary
150  
151 ## Bits 10-13
152 sub SVG_EL () { 0b1_0000000000000 }
153 sub MML_EL () { 0b1_000000000000 }
154 #sub FOREIGN_EL () { 0b1_00000000000 } # see HTML::HTML5::Parser::Tokenizer
155 sub FOREIGN_FLOW_CONTENT_EL () { 0b1_0000000000 }
156  
157 ## Bits 6-9
158 sub TABLE_SCOPING_EL () { 0b1_000000000 }
159 sub TABLE_ROWS_SCOPING_EL () { 0b1_00000000 }
160 sub TABLE_ROW_SCOPING_EL () { 0b1_0000000 }
161 sub TABLE_ROWS_EL () { 0b1_000000 }
162  
163 ## Bit 5
164 sub ADDRESS_DIV_P_EL () { 0b1_00000 }
165  
166 ## NOTE: Used in </body> and EOF algorithms.
167 ## Bit 4
168 sub ALL_END_TAG_OPTIONAL_EL () { 0b1_0000 }
169  
170 ## NOTE: Used in "generate implied end tags" algorithm.
171 ## NOTE: There is a code where a modified version of
172 ## END_TAG_OPTIONAL_EL is used in "generate implied end tags"
173 ## implementation (search for the algorithm name).
174 ## Bit 3
175 sub END_TAG_OPTIONAL_EL () { 0b1_000 }
176  
177 ## Bits 0-2
178  
179 sub MISC_SPECIAL_EL () { SPECIAL_EL | 0b000 }
180 sub FORM_EL () { SPECIAL_EL | 0b001 }
181 sub FRAMESET_EL () { SPECIAL_EL | 0b010 }
182 sub HEADING_EL () { SPECIAL_EL | 0b011 }
183 sub SELECT_EL () { SPECIAL_EL | 0b100 }
184 sub SCRIPT_EL () { SPECIAL_EL | 0b101 }
185 sub BUTTON_EL () { SPECIAL_EL | BUTTON_SCOPING_EL | 0b110 }
186  
187 sub ADDRESS_DIV_EL () { SPECIAL_EL | ADDRESS_DIV_P_EL | 0b001 }
188 sub BODY_EL () { SPECIAL_EL | ALL_END_TAG_OPTIONAL_EL | 0b001 }
189  
190 sub DTDD_EL () {
191 SPECIAL_EL |
192 END_TAG_OPTIONAL_EL |
193 ALL_END_TAG_OPTIONAL_EL |
194 0b010
195 }
196 sub LI_EL () {
197 SPECIAL_EL |
198 END_TAG_OPTIONAL_EL |
199 ALL_END_TAG_OPTIONAL_EL |
200 0b100
201 }
202 sub P_EL () {
203 SPECIAL_EL |
204 ADDRESS_DIV_P_EL |
205 END_TAG_OPTIONAL_EL |
206 ALL_END_TAG_OPTIONAL_EL |
207 0b001
208 }
209  
210 sub TABLE_ROW_EL () {
211 SPECIAL_EL |
212 TABLE_ROWS_EL |
213 TABLE_ROW_SCOPING_EL |
214 ALL_END_TAG_OPTIONAL_EL |
215 0b001
216 }
217 sub TABLE_ROW_GROUP_EL () {
218 SPECIAL_EL |
219 TABLE_ROWS_EL |
220 TABLE_ROWS_SCOPING_EL |
221 ALL_END_TAG_OPTIONAL_EL |
222 0b001
223 }
224  
225 sub MISC_SCOPING_EL () { SCOPING_EL | BUTTON_SCOPING_EL | 0b000 }
226 sub CAPTION_EL () { SCOPING_EL | BUTTON_SCOPING_EL | 0b010 }
227 sub HTML_EL () {
228 SCOPING_EL |
229 BUTTON_SCOPING_EL |
230 TABLE_SCOPING_EL |
231 TABLE_ROWS_SCOPING_EL |
232 TABLE_ROW_SCOPING_EL |
233 ALL_END_TAG_OPTIONAL_EL |
234 0b001
235 }
236 sub TABLE_EL () {
237 SCOPING_EL |
238 BUTTON_SCOPING_EL |
239 TABLE_ROWS_EL |
240 TABLE_SCOPING_EL |
241 0b001
242 }
243 sub TABLE_CELL_EL () {
244 SCOPING_EL |
245 BUTTON_SCOPING_EL |
246 ALL_END_TAG_OPTIONAL_EL |
247 0b001
248 }
249  
250 sub MISC_FORMATTING_EL () { FORMATTING_EL | 0b000 }
251 sub A_EL () { FORMATTING_EL | 0b001 }
252 sub NOBR_EL () { FORMATTING_EL | 0b010 }
253  
254 sub RUBY_EL () { PHRASING_EL | 0b001 }
255  
256 ## NOTE: These elements are not included in |ALL_END_TAG_OPTIONAL_EL|.
257 sub OPTGROUP_EL () { PHRASING_EL | END_TAG_OPTIONAL_EL | 0b001 }
258 sub OPTION_EL () { PHRASING_EL | END_TAG_OPTIONAL_EL | 0b010 }
259 sub RUBY_COMPONENT_EL () { PHRASING_EL | END_TAG_OPTIONAL_EL | 0b100 }
260  
261 ## "MathML text integration point" elements.
262 sub MML_TEXT_INTEGRATION_EL () {
263 MML_EL |
264 SCOPING_EL |
265 BUTTON_SCOPING_EL |
266 FOREIGN_EL |
267 FOREIGN_FLOW_CONTENT_EL
268 } # MML_TEXT_INTEGRATION_EL
269  
270 sub MML_AXML_EL () {
271 MML_EL |
272 SCOPING_EL |
273 BUTTON_SCOPING_EL |
274 FOREIGN_EL |
275 0b001
276 } # MML_AXML_EL
277  
278 ## "HTML integration point" elements in SVG namespace.
279 sub SVG_INTEGRATION_EL () {
280 SVG_EL |
281 SCOPING_EL |
282 BUTTON_SCOPING_EL |
283 FOREIGN_EL |
284 FOREIGN_FLOW_CONTENT_EL
285 } # SVG_INTEGRATION_EL
286  
287 sub SVG_SCRIPT_EL () {
288 SVG_EL |
289 FOREIGN_EL |
290 0b101
291 } # SVG_SCRIPT_EL
292  
293 11 my $el_category = {
294 a => A_EL,
295 address => ADDRESS_DIV_EL,
296 applet => MISC_SCOPING_EL,
297 area => MISC_SPECIAL_EL,
298 article => MISC_SPECIAL_EL,
299 aside => MISC_SPECIAL_EL,
300 b => FORMATTING_EL,
301 base => MISC_SPECIAL_EL,
302 basefont => MISC_SPECIAL_EL,
303 bgsound => MISC_SPECIAL_EL,
304 big => FORMATTING_EL,
305 blockquote => MISC_SPECIAL_EL,
306 body => BODY_EL,
307 br => MISC_SPECIAL_EL,
308 button => BUTTON_EL,
309 caption => CAPTION_EL,
310 center => MISC_SPECIAL_EL,
311 code => FORMATTING_EL,
312 col => MISC_SPECIAL_EL,
313 colgroup => MISC_SPECIAL_EL,
314 command => MISC_SPECIAL_EL,
315 #datagrid => MISC_SPECIAL_EL,
316 dd => DTDD_EL,
317 details => MISC_SPECIAL_EL,
318 dir => MISC_SPECIAL_EL,
319 div => ADDRESS_DIV_EL,
320 dl => MISC_SPECIAL_EL,
321 dt => DTDD_EL,
322 em => FORMATTING_EL,
323 embed => MISC_SPECIAL_EL,
324 fieldset => MISC_SPECIAL_EL,
325 figure => MISC_SPECIAL_EL,
326 figcaption => MISC_SPECIAL_EL,
327 font => FORMATTING_EL,
328 footer => MISC_SPECIAL_EL,
329 form => FORM_EL,
330 frame => MISC_SPECIAL_EL,
331 frameset => FRAMESET_EL,
332 h1 => HEADING_EL,
333 h2 => HEADING_EL,
334 h3 => HEADING_EL,
335 h4 => HEADING_EL,
336 h5 => HEADING_EL,
337 h6 => HEADING_EL,
338 head => MISC_SPECIAL_EL,
339 header => MISC_SPECIAL_EL,
340 hgroup => MISC_SPECIAL_EL,
341 hr => MISC_SPECIAL_EL,
342 html => HTML_EL,
343 i => FORMATTING_EL,
344 iframe => MISC_SPECIAL_EL,
345 img => MISC_SPECIAL_EL,
346 #image => MISC_SPECIAL_EL, ## NOTE: Commented out in the spec.
347 input => MISC_SPECIAL_EL,
348 isindex => MISC_SPECIAL_EL,
349 ## XXX keygen? (Whether a void element is in Special or not does not
350 ## affect to the processing, however.)
351 li => LI_EL,
352 link => MISC_SPECIAL_EL,
353 listing => MISC_SPECIAL_EL,
354 marquee => MISC_SCOPING_EL,
355 menu => MISC_SPECIAL_EL,
356 meta => MISC_SPECIAL_EL,
357 nav => MISC_SPECIAL_EL,
358 nobr => NOBR_EL,
359 noembed => MISC_SPECIAL_EL,
360 noframes => MISC_SPECIAL_EL,
361 noscript => MISC_SPECIAL_EL,
362 object => MISC_SCOPING_EL,
363 ol => MISC_SPECIAL_EL,
364 optgroup => OPTGROUP_EL,
365 option => OPTION_EL,
366 p => P_EL,
367 param => MISC_SPECIAL_EL,
368 plaintext => MISC_SPECIAL_EL,
369 pre => MISC_SPECIAL_EL,
370 rp => RUBY_COMPONENT_EL,
371 rt => RUBY_COMPONENT_EL,
372 ruby => RUBY_EL,
373 s => FORMATTING_EL,
374 script => MISC_SPECIAL_EL,
375 select => SELECT_EL,
376 section => MISC_SPECIAL_EL,
377 small => FORMATTING_EL,
378 strike => FORMATTING_EL,
379 strong => FORMATTING_EL,
380 style => MISC_SPECIAL_EL,
381 summary => MISC_SPECIAL_EL,
382 table => TABLE_EL,
383 tbody => TABLE_ROW_GROUP_EL,
384 td => TABLE_CELL_EL,
385 textarea => MISC_SPECIAL_EL,
386 tfoot => TABLE_ROW_GROUP_EL,
387 th => TABLE_CELL_EL,
388 thead => TABLE_ROW_GROUP_EL,
389 title => MISC_SPECIAL_EL,
390 tr => TABLE_ROW_EL,
391 tt => FORMATTING_EL,
392 u => FORMATTING_EL,
393 ul => MISC_SPECIAL_EL,
394 wbr => MISC_SPECIAL_EL,
395 xmp => MISC_SPECIAL_EL,
396 };
397  
398 11 my $el_category_f = {
399 (MML_NS) => {
400 'annotation-xml' => MML_AXML_EL,
401 mi => MML_TEXT_INTEGRATION_EL,
402 mo => MML_TEXT_INTEGRATION_EL,
403 mn => MML_TEXT_INTEGRATION_EL,
404 ms => MML_TEXT_INTEGRATION_EL,
405 mtext => MML_TEXT_INTEGRATION_EL,
406 },
407 (SVG_NS) => {
408 foreignObject => SVG_INTEGRATION_EL,
409 desc => SVG_INTEGRATION_EL,
410 title => SVG_INTEGRATION_EL,
411 script => SVG_SCRIPT_EL,
412 },
413 ## NOTE: In addition, FOREIGN_EL is set to non-HTML elements, MML_EL
414 ## is set to MathML elements, and SVG_EL is set to SVG elements.
415 };
416  
417 11 my $svg_attr_name = {
418 attributename => 'attributeName',
419 attributetype => 'attributeType',
420 basefrequency => 'baseFrequency',
421 baseprofile => 'baseProfile',
422 calcmode => 'calcMode',
423 clippathunits => 'clipPathUnits',
424 contentscripttype => 'contentScriptType',
425 contentstyletype => 'contentStyleType',
426 diffuseconstant => 'diffuseConstant',
427 edgemode => 'edgeMode',
428 externalresourcesrequired => 'externalResourcesRequired',
429 filterres => 'filterRes',
430 filterunits => 'filterUnits',
431 glyphref => 'glyphRef',
432 gradienttransform => 'gradientTransform',
433 gradientunits => 'gradientUnits',
434 kernelmatrix => 'kernelMatrix',
435 kernelunitlength => 'kernelUnitLength',
436 keypoints => 'keyPoints',
437 keysplines => 'keySplines',
438 keytimes => 'keyTimes',
439 lengthadjust => 'lengthAdjust',
440 limitingconeangle => 'limitingConeAngle',
441 markerheight => 'markerHeight',
442 markerunits => 'markerUnits',
443 markerwidth => 'markerWidth',
444 maskcontentunits => 'maskContentUnits',
445 maskunits => 'maskUnits',
446 numoctaves => 'numOctaves',
447 pathlength => 'pathLength',
448 patterncontentunits => 'patternContentUnits',
449 patterntransform => 'patternTransform',
450 patternunits => 'patternUnits',
451 pointsatx => 'pointsAtX',
452 pointsaty => 'pointsAtY',
453 pointsatz => 'pointsAtZ',
454 preservealpha => 'preserveAlpha',
455 preserveaspectratio => 'preserveAspectRatio',
456 primitiveunits => 'primitiveUnits',
457 refx => 'refX',
458 refy => 'refY',
459 repeatcount => 'repeatCount',
460 repeatdur => 'repeatDur',
461 requiredextensions => 'requiredExtensions',
462 requiredfeatures => 'requiredFeatures',
463 specularconstant => 'specularConstant',
464 specularexponent => 'specularExponent',
465 spreadmethod => 'spreadMethod',
466 startoffset => 'startOffset',
467 stddeviation => 'stdDeviation',
468 stitchtiles => 'stitchTiles',
469 surfacescale => 'surfaceScale',
470 systemlanguage => 'systemLanguage',
471 tablevalues => 'tableValues',
472 targetx => 'targetX',
473 targety => 'targetY',
474 textlength => 'textLength',
475 viewbox => 'viewBox',
476 viewtarget => 'viewTarget',
477 xchannelselector => 'xChannelSelector',
478 ychannelselector => 'yChannelSelector',
479 zoomandpan => 'zoomAndPan',
480 };
481  
482 11 my $foreign_attr_xname = {
483 'xlink:actuate' => [(XLINK_NS), ['xlink', 'actuate']],
484 'xlink:arcrole' => [(XLINK_NS), ['xlink', 'arcrole']],
485 'xlink:href' => [(XLINK_NS), ['xlink', 'href']],
486 'xlink:role' => [(XLINK_NS), ['xlink', 'role']],
487 'xlink:show' => [(XLINK_NS), ['xlink', 'show']],
488 'xlink:title' => [(XLINK_NS), ['xlink', 'title']],
489 'xlink:type' => [(XLINK_NS), ['xlink', 'type']],
490 'xml:base' => [(XML_NS), ['xml', 'base']],
491 'xml:lang' => [(XML_NS), ['xml', 'lang']],
492 'xml:space' => [(XML_NS), ['xml', 'space']],
493 'xmlns' => [(XMLNS_NS), [undef, 'xmlns']],
494 'xmlns:xlink' => [(XMLNS_NS), ['xmlns', 'xlink']],
495 };
496  
497 ## TODO: Invoke the reset algorithm when a resettable element is
498 ## created (cf. HTML5 revision 2259).
499  
500 sub parse_byte_string ($$$$;$) {
501 708 ▶ my $self = shift;
Subroutine parse_byte_string: called CC=2 SCAR=7.0
Pod undocumented
502 708 my $charset_name = shift;
503 708 ▶ open my $input, '<', ref $_[0] ? $_[0] : \($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 708 708
504 708 return $self->parse_byte_stream ($charset_name, $input, @_[1..$#_]);
505 } # parse_byte_string
506  
507 sub parse_byte_stream ($$$$;$$) {
508 # my ($self, $charset_name, $byte_stream, $doc, $onerror, $get_wrapper) = @_;
509 708 ▶ my $self = ref $_[0] ? shift : shift->new;
Subroutine parse_byte_stream: called CC=16 SCAR=36.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 708 0 708
510 708 my $charset_name = shift;
511 708 my $byte_stream = $_[0];
512  
513 my $onerror = $_[2] || sub {
514 0 ▶ my (%opt) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
515 0 warn "Parse error ($opt{type})\n";
516 708 ▶ };
Condition33%1/3
$_[2] || sub { my(%opt) = @_; warn "Parse error ($opt{'type'})\n"; }
l!l&&r!l&&!r
70800
MC/DC0%0/2
$_[2] || sub { my(%opt) = @_; warn "Parse error ($opt{'type'})\n"; }
$_[2] sub { my(%opt) = @_; warn "Parse error ($opt{'type'})\n"; }
Truth table33%1/3
A || B
A= $_[2]B= sub { my(%opt) = @_; warn "Parse error ($opt{'type'})\n"; }
ABresult
1X1
011
000
517 708 $self->{parse_error} = $onerror; # updated later by parse_char_string
518  
519 my $get_wrapper = $_[3] || sub ($) {
520 711 ▶ return $_[0]; # $_[0] = byte stream handle, returned = arg to char handle
Subroutine __ANON__: called CC=1 SCAR=0.0
521 708 ▶ };
Condition33%1/3
$_[3] || sub ($) { return $_[0]; }
l!l&&r!l&&!r
07080
MC/DC0%0/2
$_[3] || sub ($) { return $_[0]; }
$_[3] sub ($) { return $_[0]; }
Truth table33%1/3
A || B
A= $_[3]B= sub ($) { return $_[0]; }
ABresult
1X1
011
000
522  
523 ## HTML5 encoding sniffing algorithm
524 708 require HTML::HTML5::Parser::Charset::Info;
525 708 my $charset;
526 my $buffer;
527 708 my ($char_stream, $e_status);
528  
529 SNIFFING: {
530 ## NOTE: By setting |allow_fallback| option true when the
531 ## |get_decode_handle| method is invoked, we ignore what the HTML5
532 ## spec requires, i.e. unsupported encoding should be ignored.
533 ## TODO: We should not do this unless the parser is invoked
534 ## in the conformance checking mode, in which this behavior
535 ## would be useful.
536  
537 ## Step 1
538 708 ▶ if (defined $charset_name) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $charset_name) 0 708 708
539 0 $charset = HTML::HTML5::Parser::Charset::Info->get_by_html_name ($charset_name);
540 ## TODO: Is this ok? Transfer protocol's parameter should be
541 ## interpreted in its semantics?
542  
543 0 ($char_stream, $e_status) = $charset->get_decode_handle
544 ($byte_stream, allow_error_reporting => 1,
545 allow_fallback => 1);
546 0 ▶ if ($char_stream) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char_stream) { } 0 0 0
547 0 $self->{confident} = 1;
548 0 last SNIFFING;
549 } else {
550 $self->{parse_error}->(level => $self->{level}->{must}, type => 'charset:not supported',
551 layer => 'encode',
552 line => 1, column => 1,
553 value => $charset_name,
554 0 level => $self->{level}->{uncertain});
555 }
556 }
557  
558 ## Step 2
559 708 my $byte_buffer = '';
560 708 for (1..1024) {
561 29516 my $char = $byte_stream->getc;
562 29516 ▶ last unless defined $char;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $char 708 28808 29516
563 28808 $byte_buffer .= $char;
564 } ## TODO: timeout
565  
566 ## Step 3
567 708 ▶ if ($byte_buffer =~ /^\xFE\xFF/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($byte_buffer =~ /^\xFE\xFF/) { } 0 708 708
elsif ($byte_buffer =~ /^\xFF\xFE/) { } 0 708 708
elsif ($byte_buffer =~ /^\xEF\xBB\xBF/) { } 0 708 708
568 0 $charset = HTML::HTML5::Parser::Charset::Info->get_by_html_name ('utf-16be');
569 0 ($char_stream, $e_status) = $charset->get_decode_handle
570 ($byte_stream, allow_error_reporting => 1,
571 allow_fallback => 1, byte_buffer => \$byte_buffer);
572 0 $self->{confident} = 1;
573 0 last SNIFFING;
574 } elsif ($byte_buffer =~ /^\xFF\xFE/) {
575 0 $charset = HTML::HTML5::Parser::Charset::Info->get_by_html_name ('utf-16le');
576 0 ($char_stream, $e_status) = $charset->get_decode_handle
577 ($byte_stream, allow_error_reporting => 1,
578 allow_fallback => 1, byte_buffer => \$byte_buffer);
579 0 $self->{confident} = 1;
580 0 last SNIFFING;
581 } elsif ($byte_buffer =~ /^\xEF\xBB\xBF/) {
582 0 $charset = HTML::HTML5::Parser::Charset::Info->get_by_html_name ('utf-8');
583 0 ($char_stream, $e_status) = $charset->get_decode_handle
584 ($byte_stream, allow_error_reporting => 1,
585 allow_fallback => 1, byte_buffer => \$byte_buffer);
586 0 $self->{confident} = 1;
587 0 last SNIFFING;
588 }
589  
590 ## Step 4
591 ## TODO: <meta charset>
592  
593 ## Step 5
594 ## TODO: from history
595  
596 ## Step 6
597 708 require HTML::HTML5::Parser::Charset::UniversalCharDet;
598 708 ▶ $charset_name = HTML::HTML5::Parser::Charset::UniversalCharDet->detect_byte_string($byte_buffer)
Branch: 1 branch
BranchTrueFalseTotal
if $byte_buffer 708 0 708
599 if $byte_buffer;
600 708 ▶ if (defined $charset_name) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $charset_name) 708 0 708
601 708 $charset = HTML::HTML5::Parser::Charset::Info->get_by_html_name ($charset_name);
602  
603 708 require HTML::HTML5::Parser::Charset::DecodeHandle;
604 708 $buffer = HTML::HTML5::Parser::Charset::DecodeHandle::ByteBuffer->new
605 ($byte_stream);
606 708 ($char_stream, $e_status) = $charset->get_decode_handle
607 ($buffer, allow_error_reporting => 1,
608 allow_fallback => 1, byte_buffer => \$byte_buffer);
609 708 ▶ if ($char_stream) {
Branch: 1 branch
BranchTrueFalseTotal
if ($char_stream) 708 0 708
610 708 $buffer->{buffer} = $byte_buffer;
611 $self->{parse_error}->(level => $self->{level}->{must}, type => 'sniffing:chardet',
612 text => $charset_name,
613 level => $self->{level}->{info},
614 708 layer => 'encode',
615 line => 1, column => 1);
616 708 $self->{confident} = 0;
617 708 last SNIFFING;
618 }
619 }
620  
621 ## Step 7: default
622 ## TODO: Make this configurable.
623 0 $charset = HTML::HTML5::Parser::Charset::Info->get_by_html_name ('windows-1252');
624 ## NOTE: We choose |windows-1252| here, since |utf-8| should be
625 ## detectable in the step 6.
626 0 require HTML::HTML5::Parser::Charset::DecodeHandle;
627 0 $buffer = HTML::HTML5::Parser::Charset::DecodeHandle::ByteBuffer->new
628 ($byte_stream);
629 0 ($char_stream, $e_status)
630 = $charset->get_decode_handle ($buffer,
631 allow_error_reporting => 1,
632 allow_fallback => 1,
633 byte_buffer => \$byte_buffer);
634 0 $buffer->{buffer} = $byte_buffer;
635 $self->{parse_error}->(level => $self->{level}->{must}, type => 'sniffing:default',
636 text => 'windows-1252',
637 level => $self->{level}->{info},
638 0 line => 1, column => 1,
639 layer => 'encode');
640 0 $self->{confident} = 0;
641 } # SNIFFING
642  
643 708 ▶ if ($e_status & HTML::HTML5::Parser::Charset::Info::FALLBACK_ENCODING_IMPL ()) {
Branch: 2 branches
BranchTrueFalseTotal
if ($e_status & HTML::HTML5::Parser::Charset::Info::FALLBACK_ENCODING_IMPL()) { } 0 708 708
elsif (not $e_status & HTML::HTML5::Parser::Charset::Info::ERROR_REPORTING_ENCODING_IMPL()) { } 0 708 708
644 0 $self->{input_encoding} = $charset->get_iana_name; ## TODO: Should we set actual charset decoder's encoding name?
645 $self->{parse_error}->(level => $self->{level}->{must}, type => 'chardecode:fallback',
646 #text => $self->{input_encoding},
647 level => $self->{level}->{uncertain},
648 0 line => 1, column => 1,
649 layer => 'encode');
650 } elsif (not ($e_status &
651 HTML::HTML5::Parser::Charset::Info::ERROR_REPORTING_ENCODING_IMPL ())) {
652 0 $self->{input_encoding} = $charset->get_iana_name;
653 $self->{parse_error}->(level => $self->{level}->{must}, type => 'chardecode:no error',
654 text => $self->{input_encoding},
655 level => $self->{level}->{uncertain},
656 0 line => 1, column => 1,
657 layer => 'encode');
658 } else {
659 708 $self->{input_encoding} = $charset->get_iana_name;
660 }
661  
662 $self->{change_encoding} = sub {
663 5 ▶ my $self = shift;
Subroutine __ANON__: called CC=9 SCAR=25.4
664 5 $charset_name = shift;
665 5 my $token = shift;
666 5 my $orig_char_stream = $char_stream;
667  
668 5 $charset = HTML::HTML5::Parser::Charset::Info->get_by_html_name ($charset_name);
669 ($char_stream, $e_status) = $charset->get_decode_handle
670 ($byte_stream, allow_error_reporting => 1, allow_fallback => 1,
671 5 byte_buffer => \ $buffer->{buffer});
672
673 5 ▶ if ($char_stream) { # if supported
Branch: 1 branch
BranchTrueFalseTotal
if ($char_stream) { } 5 0 5
674 5 ▶ if ($charset->{category} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_ASCII_COMPAT () or
Branch: 1 branch
BranchTrueFalseTotal
if ($charset->{'category'} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_ASCII_COMPAT() or $charset->{'category'} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_UTF16()) { } 5 0 5
Condition33%1/3
$charset->{"category"} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_ASCII_COMPAT() or $charset->{"category"} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_UTF16()
l!l&&r!l&&!r
500
MC/DC0%0/2
$charset->{"category"} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_ASCII_COMPAT() or $charset->{"category"} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_UTF16()
$charset->{"category"} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_ASCII_COMPAT() $charset->{"category"} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_UTF16()
Truth table33%1/3
A or B
A= $charset->{"category"} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_ASCII_COMPAT()B= $charset->{"category"} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_UTF16()
ABresult
1X1
011
000
675 $charset->{category} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_UTF16 ()) {
676 #
677 } else {
678 0 return;
679 }
680
681 ## "Change the encoding" algorithm:
682
683 ## Step 1
684 5 ▶ if (defined $self->{input_encoding} and
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"input_encoding"} and $self->{"input_encoding"} eq $charset_name) 2 3 5
Condition66%2/3
defined $self->{"input_encoding"} and $self->{"input_encoding"} eq $charset_name
!ll&&!rl&&r
032
MC/DC50%1/2
defined $self->{"input_encoding"} and $self->{"input_encoding"} eq $charset_name
defined $self->{"input_encoding"} $self->{"input_encoding"} eq $charset_name
Truth table66%2/3
A and B
A= defined $self->{"input_encoding"}B= $self->{"input_encoding"} eq $charset_name
ABresult
0X0
100
111
685 $self->{input_encoding} eq $charset_name) {
686 $self->{parse_error}->(level => $self->{level}->{must}, type => 'charset label:matching',
687 text => $charset_name,
688 2 level => $self->{level}->{info});
689 2 $self->{confident} = 1;
690 2 return;
691 }
692  
693 ## Step 2 (HTML5 revision 3205)
694 3 ▶ if (defined $self->{input_encoding} and
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"input_encoding"} and "HTML::HTML5::Parser::Charset::Info"->get_by_html_name($self->{"input_encoding"})->{"category"} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_UTF16()) 0 3 3
Condition33%1/3
defined $self->{"input_encoding"} and "HTML::HTML5::Parser::Charset::Info"->get_by_html_name($self->{"input_encoding"})->{"category"} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_UTF16()
!ll&&!rl&&r
030
MC/DC0%0/2
defined $self->{"input_encoding"} and "HTML::HTML5::Parser::Charset::Info"->get_by_html_name($self->{"input_encoding"})->{"category"} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_UTF16()
defined $self->{"input_encoding"} "HTML::HTML5::Parser::Charset::Info"->get_by_html_name($self->{"input_encoding"})->{"category"} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_UTF16()
Truth table33%1/3
A and B
A= defined $self->{"input_encoding"}B= "HTML::HTML5::Parser::Charset::Info"->get_by_html_name($self->{"input_encoding"})->{"category"} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_UTF16()
ABresult
0X0
100
111
695 HTML::HTML5::Parser::Charset::Info->get_by_html_name ($self->{input_encoding})
696 ->{category} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_UTF16 ()) {
697 0 $self->{confident} = 1;
698 0 return;
699 }
700  
701 ## Step 3
702 3 ▶ if ($charset->{category} &
Branch: 1 branch
BranchTrueFalseTotal
if ($charset->{"category"} & HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_UTF16()) 0 3 3
703 HTML::HTML5::Parser::Charset::Info::CHARSET_CATEGORY_UTF16 ()) {
704 0 $charset = HTML::HTML5::Parser::Charset::Info->get_by_html_name ('utf-8');
705 ($char_stream, $e_status) = $charset->get_decode_handle
706 ($byte_stream,
707 allow_error_reporting => 1,
708 0 byte_buffer => \ $buffer->{buffer});
709 }
710 3 $charset_name = $charset->get_iana_name;
711  
712 $self->{parse_error}->(level => $self->{level}->{must}, type => 'charset label detected',
713 text => $self->{input_encoding},
714 value => $charset_name,
715 level => $self->{level}->{warn},
716 3 token => $token);
717
718 ## Step 4
719 # if (can) {
720 ## change the encoding on the fly.
721 #$self->{confident} = 1;
722 #return;
723 # }
724
725 ## Step 5
726 3 HTML::HTML5::Parser::TagSoupParser::RestartParser->throw;
727 } else {
728 0 $char_stream = $orig_char_stream;
729 }
730 708 }; # $self->{change_encoding}
731  
732 # XXX IF YOU PUT $SELF IN HERE YOU GET HUGE FAT MEMORY LEAKS
733 my %x = (
734 level => $self->{level}{must},
735 layer => 'encode',
736 line => $self->{line},
737 column => $self->{column} + 1,
738 error => $self->{parse_error},
739 708 );
740 my $char_onerror = sub {
741 0 ▶ my (undef, $type, %opt) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
742 $x{error}->(
743 level => $x{level}, layer => $x{layer},
744 line => $x{line}, column => $x{column},
745 0 %opt, type => $type);
746 0 ▶ if ($opt{octets}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt{"octets"}) 0 0 0
747 0 ${$opt{octets}} = "\x{FFFD}"; # relacement character
748 }
749 708 };
750  
751 708 my $wrapped_char_stream = $get_wrapper->($char_stream);
752 708 $wrapped_char_stream->onerror ($char_onerror);
753  
754 708 my @args = ($_[1], $_[2]); # $doc, $onerror - $get_wrapper = undef;
755 708 my $return;
756 try {
757 708 ▶ $return = $self->parse_char_stream ($wrapped_char_stream, @args);
Subroutine __ANON__: called CC=1 SCAR=0.0
758 }
759 ## NOTE: Invoked after {change_encoding}.
760 catch {
761 3 ▶ unless (blessed($_)
Subroutine __ANON__: called CC=5 SCAR=20.4
Branch: 1 branch
BranchTrueFalseTotal
unless (builtin::blessed($_) and $_->isa("HTML::HTML5::Parser::TagSoupParser::RestartParser")) 0 3 3
Condition33%1/3
builtin::blessed($_) and $_->isa("HTML::HTML5::Parser::TagSoupParser::RestartParser")
!ll&&!rl&&r
003
MC/DC0%0/2
builtin::blessed($_) and $_->isa("HTML::HTML5::Parser::TagSoupParser::RestartParser")
builtin::blessed($_) $_->isa("HTML::HTML5::Parser::TagSoupParser::RestartParser")
Truth table33%1/3
A and B
A= builtin::blessed($_)B= $_->isa("HTML::HTML5::Parser::TagSoupParser::RestartParser")
ABresult
0X0
100
111
762 and $_->isa('HTML::HTML5::Parser::TagSoupParser::RestartParser'))
763 {
764 0 die $_;
765 }
766
767 3 ▶ if ($e_status & HTML::HTML5::Parser::Charset::Info::FALLBACK_ENCODING_IMPL ()) {
Branch: 2 branches
BranchTrueFalseTotal
if ($e_status & HTML::HTML5::Parser::Charset::Info::FALLBACK_ENCODING_IMPL()) { } 0 3 3
elsif (not $e_status & HTML::HTML5::Parser::Charset::Info::ERROR_REPORTING_ENCODING_IMPL()) { } 0 3 3
768 0 $self->{input_encoding} = $charset->get_iana_name; ## TODO: Should we set actual charset decoder's encoding name?
769 $self->{parse_error}->(level => $self->{level}->{must}, type => 'chardecode:fallback',
770 level => $self->{level}->{uncertain},
771 #text => $self->{input_encoding},
772 0 line => 1, column => 1,
773 layer => 'encode');
774 } elsif (not ($e_status &
775 HTML::HTML5::Parser::Charset::Info::ERROR_REPORTING_ENCODING_IMPL ())) {
776 0 $self->{input_encoding} = $charset->get_iana_name;
777 $self->{parse_error}->(level => $self->{level}->{must}, type => 'chardecode:no error',
778 text => $self->{input_encoding},
779 level => $self->{level}->{uncertain},
780 0 line => 1, column => 1,
781 layer => 'encode');
782 } else {
783 3 $self->{input_encoding} = $charset->get_iana_name;
784 }
785 3 $self->{confident} = 1;
786  
787 3 $wrapped_char_stream = $get_wrapper->($char_stream);
788 3 $wrapped_char_stream->onerror ($char_onerror);
789  
790 3 $return = $self->parse_char_stream ($wrapped_char_stream, @args);
791 708 };
792 708 $self->_data($return, charset => $charset_name);
793 708 return $return;
794 } # parse_byte_stream
795  
796 ## NOTE: HTML5 spec says that the encoding layer MUST NOT strip BOM
797 ## and the HTML layer MUST ignore it. However, we does strip BOM in
798 ## the encoding layer and the HTML layer does not ignore any U+FEFF,
799 ## because the core part of our HTML parser expects a string of character,
800 ## not a string of bytes or code units or anything which might contain a BOM.
801 ## Therefore, any parser interface that accepts a string of bytes,
802 ## such as |parse_byte_string| in this module, must ensure that it does
803 ## strip the BOM and never strip any ZWNBSP.
804  
805 sub parse_char_string ($$$;$$) {
806 #my ($self, $s, $doc, $onerror, $get_wrapper) = @_;
807 0 ▶ my $self = shift;
Subroutine parse_char_string: not called CC=2 SCAR=17.9
Pod undocumented
808 0 ▶ my $s = ref $_[0] ? $_[0] : \($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 0 0 0
809 0 require HTML::HTML5::Parser::Charset::DecodeHandle;
810 0 my $input = HTML::HTML5::Parser::Charset::DecodeHandle::CharString->new ($s);
811 0 return $self->parse_char_stream ($input, @_[1..$#_]);
812 } # parse_char_string
813 11 *parse_string = \&parse_char_string; ## NOTE: Alias for backward compatibility.
814  
815 sub parse_char_stream ($$$;$$) {
816 711 ▶ my $self = ref $_[0] ? shift : shift->new;
Subroutine parse_char_stream: called CC=7 SCAR=21.2
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
ref $_[0] ? : 711 0 711
817 711 my $input = $_[0];
818 711 my $doc = $self->{document} = $_[1];
819 711 $self->{document}->removeChildNodes;
820  
821 ## NOTE: |set_inner_html| copies most of this method's code
822  
823 ## Confidence: irrelevant.
824 711 ▶ $self->{confident} = 1 unless exists $self->{confident};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"confident"} 0 711 711
825  
826 $self->{document}->setEncoding($self->{input_encoding})
827 711 ▶ if defined $self->{input_encoding};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"input_encoding"} 711 0 711
828 ## TODO: |{input_encoding}| is needless?
829  
830 711 $self->{line_prev} = $self->{line} = 1;
831 711 $self->{column_prev} = -1;
832 711 $self->{column} = 0;
833 $self->{set_nc} = sub {
834 1678 ▶ my $self = shift;
Subroutine __ANON__: called CC=8 SCAR=24.9
835  
836 1678 my $char = '';
837 1678 ▶ if (defined $self->{next_nc}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'next_nc'}) { } 0 1678 1678
838 0 $char = $self->{next_nc};
839 0 delete $self->{next_nc};
840 0 $self->{nc} = ord $char;
841 } else {
842 1678 $self->{char_buffer} = '';
843 1678 $self->{char_buffer_pos} = 0;
844  
845 my $count = $input->manakai_read_until
846 1678 ($self->{char_buffer}, qr/[^\x0A\x0D]/, $self->{char_buffer_pos});
847 1678 ▶ if ($count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count) 832 846 1678
848 832 $self->{line_prev} = $self->{line};
849 832 $self->{column_prev} = $self->{column};
850 832 $self->{column}++;
851 $self->{nc}
852 832 = ord substr ($self->{char_buffer}, $self->{char_buffer_pos}++, 1);
853 832 return;
854 }
855  
856 846 ▶ if ($input->read ($char, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input->read($char, 1)) { } 135 711 846
857 135 $self->{nc} = ord $char;
858 } else {
859 711 $self->{nc} = -1;
860 711 return;
861 }
862 }
863  
864 ($self->{line_prev}, $self->{column_prev})
865 135 = ($self->{line}, $self->{column});
866 135 $self->{column}++;
867
868 135 ▶ if ($self->{nc} == 0x000A) { # LF
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'nc'} == 10) { } 135 0 135
elsif ($self->{'nc'} == 13) { } 0 0 0
869
870 135 $self->{line}++;
871 135 $self->{column} = 0;
872 } elsif ($self->{nc} == 0x000D) { # CR
873
874 ## TODO: support for abort/streaming
875 0 my $next = '';
876 0 ▶ if ($input->read ($next, 1) and $next ne "\x0A") {
Branch: 1 branch
BranchTrueFalseTotal
if ($input->read($next, 1) and $next ne "\n") 0 0 0
Condition0%0/3
$input->read($next, 1) and $next ne "\n"
!ll&&!rl&&r
000
MC/DC0%0/2
$input->read($next, 1) and $next ne "\n"
$input->read($next, 1) $next ne "\n"
Truth table0%0/3
A and B
A= $input->read($next, 1)B= $next ne "\n"
ABresult
0X0
100
111
877 0 $self->{next_nc} = $next;
878 }
879 0 $self->{nc} = 0x000A; # LF # MUST
880 0 $self->{line}++;
881 0 $self->{column} = 0;
882 }
883 711 };
884  
885 $self->{read_until} = sub {
886 #my ($scalar, $specials_range, $offset) = @_;
887 1125 ▶ return 0 if defined $self->{next_nc};
Subroutine __ANON__: called CC=7 SCAR=19.5
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"next_nc"} 0 1125 1125
888  
889 1125 my $pattern = qr/[^$_[1]\x0A\x0D]/;
890 1125 ▶ my $offset = $_[2] || 0;
Condition100%2/2
$_[2] || 0
l!l
111114
MC/DC100%1/1
$_[2] || 0
$_[2]
Truth table100%2/2
A
A= $_[2]
Aresult
11
00
891  
892 1125 ▶ if ($self->{char_buffer_pos} < length $self->{char_buffer}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'char_buffer_pos'} < length $self->{'char_buffer'}) { } 909 216 1125
893 909 pos ($self->{char_buffer}) = $self->{char_buffer_pos};
894 909 ▶ if ($self->{char_buffer} =~ /\G(?>$pattern)+/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'char_buffer'} =~ /\G(?>$pattern)+/) { } 671 238 909
895 substr ($_[0], $offset)
896 671 = substr ($self->{char_buffer}, $-[0], $+[0] - $-[0]);
897 671 my $count = $+[0] - $-[0];
898 671 ▶ if ($count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count) 671 0 671
899 671 $self->{column} += $count;
900 671 $self->{char_buffer_pos} += $count;
901 671 $self->{line_prev} = $self->{line};
902 671 $self->{column_prev} = $self->{column} - 1;
903 671 $self->{nc} = -1;
904 }
905 671 return $count;
906 } else {
907 238 return 0;
908 }
909 } else {
910 216 my $count = $input->manakai_read_until ($_[0], $pattern, $_[2]);
911 216 ▶ if ($count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count) 51 165 216
912 51 $self->{column} += $count;
913 51 $self->{line_prev} = $self->{line};
914 51 $self->{column_prev} = $self->{column} - 1;
915 51 $self->{nc} = -1;
916 }
917 216 return $count;
918 }
919 711 }; # $self->{read_until}
920  
921 my $onerror = $_[2] || sub {
922 0 ▶ my (%opt) = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
923 0 ▶ my $line = $opt{token} ? $opt{token}->{line} : $opt{line};
Branch: 1 branch
BranchTrueFalseTotal
$opt{'token'} ? : 0 0 0
924 0 ▶ my $column = $opt{token} ? $opt{token}->{column} : $opt{column};
Branch: 1 branch
BranchTrueFalseTotal
$opt{'token'} ? : 0 0 0
925 0 warn "Parse error ($opt{type}) at line $line column $column\n";
926 711 ▶ };
Condition33%1/3
$_[2] || sub { my(%opt) = @_; my $line = $opt{'token'} ? $opt{'token'}{'line'} : $opt{'line'}; my $column = $opt{'token'} ? $opt{'token'}{'column'} : $opt{'column'}; warn "Parse error ($opt{'type'}) at line $line column $column\n"; }
l!l&&r!l&&!r
71100
MC/DC0%0/2
$_[2] || sub { my(%opt) = @_; my $line = $opt{'token'} ? $opt{'token'}{'line'} : $opt{'line'}; my $column = $opt{'token'} ? $opt{'token'}{'column'} : $opt{'column'}; warn "Parse error ($opt{'type'}) at line $line column $column\n"; }
$_[2] sub { my(%opt) = @_; my $line = $opt{'token'} ? $opt{'token'}{'line'} : $opt{'line'}; my $column = $opt{'token'} ? $opt{'token'}{'column'} : $opt{'column'}; warn "Parse error ($opt{'type'}) at line $line column $column\n"; }
Truth table33%1/3
A || B
A= $_[2]B= sub { my(%opt) = @_; my $line = $opt{'token'} ? $opt{'token'}{'line'} : $opt{'line'}; my $column = $opt{'token'} ? $opt{'token'}{'column'} : $opt{'column'}; warn "Parse error ($opt{'type'}) at line $line column $column\n"; }
ABresult
1X1
011
000
927 $self->{parse_error} = sub {
928 1439 ▶ $onerror->(line => $self->{line}, column => $self->{column}, @_);
Subroutine __ANON__: called CC=1 SCAR=0.0
929 711 };
930  
931 my $char_onerror = sub {
932 0 ▶ my (undef, $type, %opt) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
933 $self->{parse_error}->(level => $self->{level}->{must}, layer => 'encode',
934 0 line => $self->{line}, column => $self->{column} + 1,
935 %opt, type => $type);
936 711 }; # $char_onerror
937  
938 711 ▶ if ($_[3]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[3]) { } 0 711 711
939 0 $input = $_[3]->($input);
940 0 $input->onerror ($char_onerror);
941 } else {
942 711 ▶ $input->onerror ($char_onerror) unless defined $input->onerror;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $input->onerror 0 711 711
943 }
944  
945 711 $self->_initialize_tokenizer;
946 711 $self->_initialize_tree_constructor;
947 711 $self->_construct_tree;
948 708 $self->_terminate_tree_constructor;
949  
950 ## Remove self-references
951 708 delete $self->{set_nc};
952 708 delete $self->{read_until};
953 708 delete $self->{parse_error};
954 708 delete $self->{document};
955  
956 708 return $doc;
957 } # parse_char_stream
958  
959 sub new ($;@) {
960 705 ▶ my $class = shift;
Subroutine new: called CC=2 SCAR=7.1
Pod undocumented
961 705 my %p = @_;
962 my $self = bless {
963 level => {
964 must => 'm',
965 should => 's',
966 obsconforming => 's',
967 warn => 'w',
968 info => 'i',
969 uncertain => 'u',
970 },
971 705 ▶ _debug_cache => $p{no_cache} ? {} : $DATA,
Branch: 1 branch
BranchTrueFalseTotal
$p{'no_cache'} ? : 0 705 705
972 }, $class;
973 $self->{set_nc} = sub {
974 0 ▶ $self->{nc} = -1;
Subroutine __ANON__: not called CC=1 SCAR=6.9
975 705 };
976 ▶ $self->{parse_error} = sub {
Subroutine __ANON__: not called CC=1 SCAR=0.0
977 #
978 705 };
979 ▶ $self->{change_encoding} = sub {
Subroutine __ANON__: not called CC=1 SCAR=0.0
980 # if ($_[0] is a supported encoding) {
981 # run "change the encoding" algorithm;
982 # throw Whatpm::HTML::RestartParser (charset => $new_encoding);
983 # }
984 705 };
985 ▶ $self->{application_cache_selection} = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
986 #
987 705 };
988 705 return $self;
989 } # new
990  
991 ## Insertion modes
992  
993 sub AFTER_HTML_IMS () { 0b100 }
994 sub HEAD_IMS () { 0b1000 }
995 sub BODY_IMS () { 0b10000 }
996 sub BODY_TABLE_IMS () { 0b100000 }
997 sub TABLE_IMS () { 0b1000000 }
998 sub ROW_IMS () { 0b10000000 }
999 sub BODY_AFTER_IMS () { 0b100000000 }
1000 sub FRAME_IMS () { 0b1000000000 }
1001 sub SELECT_IMS () { 0b10000000000 }
1002 sub IN_CDATA_RCDATA_IM () { 0b1000000000000 }
1003 ## NOTE: "in CDATA/RCDATA" insertion mode is also special; it is
1004 ## combined with the original insertion mode. In thie parser,
1005 ## they are stored together in the bit-or'ed form.
1006  
1007 sub IM_MASK () { 0b11111111111 }
1008  
1009 ## NOTE: "initial" and "before html" insertion modes have no constants.
1010  
1011 ## NOTE: "after after body" insertion mode.
1012 sub AFTER_HTML_BODY_IM () { AFTER_HTML_IMS | BODY_AFTER_IMS }
1013  
1014 ## NOTE: "after after frameset" insertion mode.
1015 sub AFTER_HTML_FRAMESET_IM () { AFTER_HTML_IMS | FRAME_IMS }
1016  
1017 sub IN_HEAD_IM () { HEAD_IMS | 0b00 }
1018 sub IN_HEAD_NOSCRIPT_IM () { HEAD_IMS | 0b01 }
1019 sub AFTER_HEAD_IM () { HEAD_IMS | 0b10 }
1020 sub BEFORE_HEAD_IM () { HEAD_IMS | 0b11 }
1021 sub IN_BODY_IM () { BODY_IMS }
1022 sub IN_CELL_IM () { BODY_IMS | BODY_TABLE_IMS | 0b01 }
1023 sub IN_CAPTION_IM () { BODY_IMS | BODY_TABLE_IMS | 0b10 }
1024 sub IN_ROW_IM () { TABLE_IMS | ROW_IMS | 0b01 }
1025 sub IN_TABLE_BODY_IM () { TABLE_IMS | ROW_IMS | 0b10 }
1026 sub IN_TABLE_IM () { TABLE_IMS }
1027 sub AFTER_BODY_IM () { BODY_AFTER_IMS }
1028 sub IN_FRAMESET_IM () { FRAME_IMS | 0b01 }
1029 sub AFTER_FRAMESET_IM () { FRAME_IMS | 0b10 }
1030 sub IN_SELECT_IM () { SELECT_IMS | 0b01 }
1031 sub IN_SELECT_IN_TABLE_IM () { SELECT_IMS | 0b10 }
1032 sub IN_COLUMN_GROUP_IM () { 0b10 }
1033  
1034 sub _initialize_tree_constructor ($) {
1035 711 ▶ my $self = shift;
Subroutine _initialize_tree_constructor: called CC=1 SCAR=0.0
1036 ## NOTE: $self->{document} MUST be specified before this method is called
1037 711 $self->_data($self->{document})->{strict_error_checking} = 0;
1038 ## TODO: Turn mutation events off # MUST
1039 ## TODO: Turn loose Document option (manakai extension) on
1040 711 $self->_data($self->{document})->{manakai_is_html} = 1; # MUST
1041 711 $self->_data($self->{document})->{manakai_source_line} = 1;
1042 711 $self->_data($self->{document})->{manakai_source_column} = 1;
1043  
1044 711 $self->{frameset_ok} = 1;
1045 } # _initialize_tree_constructor
1046  
1047 sub _terminate_tree_constructor ($) {
1048 708 ▶ my $self = shift;
Subroutine _terminate_tree_constructor: called CC=1 SCAR=0.0
1049 708 $self->_data($self->{document}, strict_error_checking => 1);
1050 ## TODO: Turn mutation events on
1051 } # _terminate_tree_constructor
1052  
1053 ## ISSUE: Should appendChild (for example) in script executed in tree construction stage fire mutation events?
1054  
1055 { # tree construction stage
1056 11 my $token;
1057  
1058 sub _construct_tree ($) {
1059 711 ▶ my ($self) = @_;
Subroutine _construct_tree: called CC=1 SCAR=0.0
1060  
1061 ## When an interactive UA render the $self->{document} available
1062 ## to the user, or when it begin accepting user input, are
1063 ## not defined.
1064
1065 711 $self->{insertion_mode} = 0; # dummy
1066 711 $token = $self->_get_next_token;
1067  
1068 711 undef $self->{form_element};
1069 711 undef $self->{head_element};
1070 711 $self->{open_elements} = [];
1071 711 undef $self->{inner_html_node};
1072 711 undef $self->{ignore_newline};
1073  
1074 ## NOTE: The "initial" insertion mode.
1075 711 $self->_tree_construction_initial; # MUST
1076  
1077 ## NOTE: The "before html" insertion mode.
1078 711 $self->_tree_construction_root_element;
1079 711 $self->{insertion_mode} = BEFORE_HEAD_IM;
1080  
1081 ## NOTE: The "before head" insertion mode and so on.
1082 711 $self->_tree_construction_main;
1083 } # _construct_tree
1084  
1085 sub _tree_construction_initial ($) {
1086 711 ▶ my $self = shift;
Subroutine _tree_construction_initial: called CC=39 SCAR=40.1
1087  
1088 ## NOTE: "initial" insertion mode
1089  
1090 INITIAL: {
1091 711 ▶ if ($token->{type} == DOCTYPE_TOKEN) {
Branch: 4 branches
BranchTrueFalseTotal
if ($token->{'type'} == 1) { } 392 330 722
elsif ({3, 1, 4, 1, 5, 1}->{$token->{'type'}}) { } 193 137 330
elsif ($token->{'type'} == 6) { } 128 9 137
elsif ($token->{'type'} == 2) { } 9 0 9
1092 ## NOTE: Conformance checkers MAY, instead of reporting "not
1093 ## HTML5" error, switch to a conformance checking mode for
1094 ## another language. (We don't support such mode switchings; it
1095 ## is nonsense to do anything different from what browsers do.)
1096 392 my $doctype_name = $token->{name};
1097 392 ▶ $doctype_name = '' unless defined $doctype_name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $doctype_name 2 390 392
1098  
1099 392 ▶ if ($doctype_name ne 'html') {
Branch: 3 branches
BranchTrueFalseTotal
if ($doctype_name ne 'html') { } 26 366 392
elsif (defined $token->{'pubid'}) { } 9 357 366
elsif (defined $token->{'sysid'}) { } 2 355 357
1100
1101 26 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not HTML5', token => $token);
1102 } elsif (defined $token->{pubid}) {
1103 ## Obsolete permitted DOCTYPEs (case-sensitive)
1104 my $xsysid = {
1105 '-//W3C//DTD HTML 4.0//EN' => 'http://www.w3.org/TR/REC-html40/strict.dtd',
1106 '-//W3C//DTD HTML 4.01//EN' => 'http://www.w3.org/TR/html4/strict.dtd',
1107 '-//W3C//DTD XHTML 1.0 Strict//EN' => 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd',
1108 '-//W3C//DTD XHTML 1.1//EN' => 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd',
1109 9 }->{$token->{pubid}};
1110 9 ▶ if (defined $xsysid and
Branch: 1 branch
BranchTrueFalseTotal
if (defined $xsysid and !defined($token->{'sysid'}) || $token->{'sysid'} eq $xsysid) { } 5 4 9
Condition50%3/6
defined $xsysid and !defined($token->{"sysid"}) || $token->{"sysid"} eq $xsysid
!ll&&!rl&&r
405
not defined $token->{"sysid"} or $token->{"sysid"} eq $xsysid
l!l&&r!l&&!r
050
MC/DC33%1/3
defined $xsysid and !defined($token->{"sysid"}) || $token->{"sysid"} eq $xsysid
defined $xsysid not defined $token->{"sysid"} $token->{"sysid"} eq $xsysid
Truth table50%2/4
A and not(B) or C
A= defined $xsysidB= not defined $token->{"sysid"}C= $token->{"sysid"} eq $xsysid
ABCresult
0XX0
1000
11X1
1011
1111 (not defined $token->{sysid} or $token->{sysid} eq $xsysid)) {
1112
1113 $self->{parse_error}->(level => $self->{level}->{must}, type => 'obs DOCTYPE', token => $token,
1114 5 level => $self->{level}->{obsconforming});
1115 } else {
1116
1117 4 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not HTML5', token => $token);
1118 }
1119 } elsif (defined $token->{sysid}) {
1120 2 ▶ if ($token->{sysid} eq 'about:legacy-compat') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'sysid'} eq 'about:legacy-compat') { } 0 2 2
1121 ## <!DOCTYPE HTML SYSTEM "about:legacy-compat">
1122 $self->{parse_error}->(level => $self->{level}->{must}, type => 'XSLT-compat', token => $token,
1123 0 level => $self->{level}->{should});
1124 } else {
1125 2 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not HTML5', token => $token);
1126 }
1127 } else { ## <!DOCTYPE HTML>
1128
1129 #
1130 }
1131
1132 392 $self->_data($self->{'document'}, 'DTD_PUBLIC_ID', $token->{pubid});
1133 392 $self->_data($self->{'document'}, 'DTD_SYSTEM_ID', $token->{sysid});
1134 392 ▶ $self->_data($self->{'document'}, 'DTD_ELEMENT', (defined $token->{name}?$token->{name}:''));
Branch: 1 branch
BranchTrueFalseTotal
defined $token->{'name'} ? : 390 2 392
1135 392 $self->_data($self->{'document'}, 'DTD_COLUMN', $token->{column});
1136 392 $self->_data($self->{'document'}, 'DTD_LINE', $token->{line});
1137  
1138 # TOBYINK
1139 $self->_data($self->{'document'}, isHTML4 => 1)
1140 392 ▶ if (($token->{pubid}||'') =~ /html 4/i or ($token->{sysid}||'') =~ /html4/i);
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"pubid"} || "") =~ /html 4/i or ($token->{"sysid"} || "") =~ /html4/i 7 385 392
Condition100%7/7
($token->{"pubid"} || "") =~ /html 4/i or ($token->{"sysid"} || "") =~ /html4/i
l!l&&r!l&&!r
52385
$token->{'pubid'} || ''
l!l
13379
$token->{'sysid'} || ''
l!l
8379
MC/DC100%2/2
($token->{"pubid"} || "") =~ /html 4/i or ($token->{"sysid"} || "") =~ /html4/i
$token->{'pubid'} $token->{'sysid'}
Truth table100%3/3
A or B
A= $token->{'pubid'}B= $token->{'sysid'}
ABresult
1X1
011
000
1141  
1142 392 ▶ if ($token->{quirks} or $doctype_name ne 'html') {
Branch: 2 branches
BranchTrueFalseTotal
if ($token->{'quirks'} or $doctype_name ne 'html') { } 26 366 392
elsif (defined $token->{'pubid'}) { } 9 357 366
Condition100%3/3
$token->{"quirks"} or $doctype_name ne "html"
l!l&&r!l&&!r
188366
MC/DC100%2/2
$token->{"quirks"} or $doctype_name ne "html"
$token->{"quirks"} $doctype_name ne "html"
Truth table100%3/3
A or B
A= $token->{"quirks"}B= $doctype_name ne "html"
ABresult
1X1
011
000
1143
1144 26 $self->_data($self->{document})->{'manakai_compat_mode'} = 'quirks';
1145 } elsif (defined $token->{pubid}) {
1146 9 my $pubid = $token->{pubid};
1147 9 $pubid =~ tr/a-z/A-Z/; ## ASCII case-insensitive.
1148 9 my $prefix = [
1149 "+//SILMARIL//DTD HTML PRO V0R11 19970101//",
1150 "-//ADVASOFT LTD//DTD HTML 3.0 ASWEDIT + EXTENSIONS//",
1151 "-//AS//DTD HTML 3.0 ASWEDIT + EXTENSIONS//",
1152 "-//IETF//DTD HTML 2.0 LEVEL 1//",
1153 "-//IETF//DTD HTML 2.0 LEVEL 2//",
1154 "-//IETF//DTD HTML 2.0 STRICT LEVEL 1//",
1155 "-//IETF//DTD HTML 2.0 STRICT LEVEL 2//",
1156 "-//IETF//DTD HTML 2.0 STRICT//",
1157 "-//IETF//DTD HTML 2.0//",
1158 "-//IETF//DTD HTML 2.1E//",
1159 "-//IETF//DTD HTML 3.0//",
1160 "-//IETF//DTD HTML 3.2 FINAL//",
1161 "-//IETF//DTD HTML 3.2//",
1162 "-//IETF//DTD HTML 3//",
1163 "-//IETF//DTD HTML LEVEL 0//",
1164 "-//IETF//DTD HTML LEVEL 1//",
1165 "-//IETF//DTD HTML LEVEL 2//",
1166 "-//IETF//DTD HTML LEVEL 3//",
1167 "-//IETF//DTD HTML STRICT LEVEL 0//",
1168 "-//IETF//DTD HTML STRICT LEVEL 1//",
1169 "-//IETF//DTD HTML STRICT LEVEL 2//",
1170 "-//IETF//DTD HTML STRICT LEVEL 3//",
1171 "-//IETF//DTD HTML STRICT//",
1172 "-//IETF//DTD HTML//",
1173 "-//METRIUS//DTD METRIUS PRESENTATIONAL//",
1174 "-//MICROSOFT//DTD INTERNET EXPLORER 2.0 HTML STRICT//",
1175 "-//MICROSOFT//DTD INTERNET EXPLORER 2.0 HTML//",
1176 "-//MICROSOFT//DTD INTERNET EXPLORER 2.0 TABLES//",
1177 "-//MICROSOFT//DTD INTERNET EXPLORER 3.0 HTML STRICT//",
1178 "-//MICROSOFT//DTD INTERNET EXPLORER 3.0 HTML//",
1179 "-//MICROSOFT//DTD INTERNET EXPLORER 3.0 TABLES//",
1180 "-//NETSCAPE COMM. CORP.//DTD HTML//",
1181 "-//NETSCAPE COMM. CORP.//DTD STRICT HTML//",
1182 "-//O'REILLY AND ASSOCIATES//DTD HTML 2.0//",
1183 "-//O'REILLY AND ASSOCIATES//DTD HTML EXTENDED 1.0//",
1184 "-//O'REILLY AND ASSOCIATES//DTD HTML EXTENDED RELAXED 1.0//",
1185 "-//SOFTQUAD SOFTWARE//DTD HOTMETAL PRO 6.0::19990601::EXTENSIONS TO HTML 4.0//",
1186 "-//SOFTQUAD//DTD HOTMETAL PRO 4.0::19971010::EXTENSIONS TO HTML 4.0//",
1187 "-//SPYGLASS//DTD HTML 2.0 EXTENDED//",
1188 "-//SQ//DTD HTML 2.0 HOTMETAL + EXTENSIONS//",
1189 "-//SUN MICROSYSTEMS CORP.//DTD HOTJAVA HTML//",
1190 "-//SUN MICROSYSTEMS CORP.//DTD HOTJAVA STRICT HTML//",
1191 "-//W3C//DTD HTML 3 1995-03-24//",
1192 "-//W3C//DTD HTML 3.2 DRAFT//",
1193 "-//W3C//DTD HTML 3.2 FINAL//",
1194 "-//W3C//DTD HTML 3.2//",
1195 "-//W3C//DTD HTML 3.2S DRAFT//",
1196 "-//W3C//DTD HTML 4.0 FRAMESET//",
1197 "-//W3C//DTD HTML 4.0 TRANSITIONAL//",
1198 "-//W3C//DTD HTML EXPERIMETNAL 19960712//",
1199 "-//W3C//DTD HTML EXPERIMENTAL 970421//",
1200 "-//W3C//DTD W3 HTML//",
1201 "-//W3O//DTD W3 HTML 3.0//",
1202 "-//WEBTECHS//DTD MOZILLA HTML 2.0//",
1203 "-//WEBTECHS//DTD MOZILLA HTML//",
1204 ]; # $prefix
1205 9 my $match;
1206 9 for (@$prefix) {
1207 495 ▶ if (substr ($prefix, 0, length $_) eq $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($prefix, 0, length $_) eq $_) 0 495 495
1208 0 $match = 1;
1209 0 last;
1210 }
1211 }
1212 9 ▶ if ($match or
Branch: 3 branches
BranchTrueFalseTotal
if ($match or $pubid eq '-//W3O//DTD W3 HTML STRICT 3.0//EN//' or $pubid eq '-/W3C/DTD HTML 4.0 TRANSITIONAL/EN' or $pubid eq 'HTML') { } 0 9 9
elsif ($pubid =~ m[^-//W3C//DTD HTML 4.01 FRAMESET//] or $pubid =~ m[^-//W3C//DTD HTML 4.01 TRANSITIONAL//]) { } 0 9 9
elsif ($pubid =~ m[^-//W3C//DTD XHTML 1.0 FRAMESET//] or $pubid =~ m[^-//W3C//DTD XHTML 1.0 TRANSITIONAL//]) { } 2 7 9
Condition33%3/9
$match or $pubid eq "-//W3O//DTD W3 HTML STRICT 3.0//EN//" or $pubid eq "-/W3C/DTD HTML 4.0 TRANSITIONAL/EN" or $pubid eq "HTML"
l!l&&r!l&&!r
009
$match or $pubid eq "-//W3O//DTD W3 HTML STRICT 3.0//EN//" or $pubid eq "-/W3C/DTD HTML 4.0 TRANSITIONAL/EN"
l!l&&r!l&&!r
009
$match or $pubid eq "-//W3O//DTD W3 HTML STRICT 3.0//EN//"
l!l&&r!l&&!r
009
MC/DC0%0/4
$match or $pubid eq "-//W3O//DTD W3 HTML STRICT 3.0//EN//" or $pubid eq "-/W3C/DTD HTML 4.0 TRANSITIONAL/EN" or $pubid eq "HTML"
$match $pubid eq "-//W3O//DTD W3 HTML STRICT 3.0//EN//" $pubid eq "-/W3C/DTD HTML 4.0 TRANSITIONAL/EN" $pubid eq "HTML"
Truth table20%1/5
A or B or C or D
A= $matchB= $pubid eq "-//W3O//DTD W3 HTML STRICT 3.0//EN//"C= $pubid eq "-/W3C/DTD HTML 4.0 TRANSITIONAL/EN"D= $pubid eq "HTML"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
1213 $pubid eq "-//W3O//DTD W3 HTML STRICT 3.0//EN//" or
1214 $pubid eq "-/W3C/DTD HTML 4.0 TRANSITIONAL/EN" or
1215 $pubid eq "HTML") {
1216
1217 0 $self->_data($self->{document})->{'manakai_compat_mode'} = 'quirks';
1218 ▶ } elsif ($pubid =~ m[^-//W3C//DTD HTML 4.01 FRAMESET//] or
Condition33%1/3
$pubid =~ m[^-//W3C//DTD HTML 4.01 FRAMESET//] or $pubid =~ m[^-//W3C//DTD HTML 4.01 TRANSITIONAL//]
l!l&&r!l&&!r
009
MC/DC0%0/2
$pubid =~ m[^-//W3C//DTD HTML 4.01 FRAMESET//] or $pubid =~ m[^-//W3C//DTD HTML 4.01 TRANSITIONAL//]
$pubid =~ m[^-//W3C//DTD HTML 4.01 FRAMESET//] $pubid =~ m[^-//W3C//DTD HTML 4.01 TRANSITIONAL//]
Truth table33%1/3
A or B
A= $pubid =~ m[^-//W3C//DTD HTML 4.01 FRAMESET//]B= $pubid =~ m[^-//W3C//DTD HTML 4.01 TRANSITIONAL//]
ABresult
1X1
011
000
1219 $pubid =~ m[^-//W3C//DTD HTML 4.01 TRANSITIONAL//]) {
1220 0 ▶ if (defined $token->{sysid}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token->{'sysid'}) { } 0 0 0
1221
1222 0 $self->_data($self->{document})->{'manakai_compat_mode'} = 'quirks';
1223 } else {
1224
1225 0 $self->_data($self->{document})->{'manakai_compat_mode'} = 'limited quirks';
1226 }
1227 ▶ } elsif ($pubid =~ m[^-//W3C//DTD XHTML 1.0 FRAMESET//] or
Condition100%3/3
$pubid =~ m[^-//W3C//DTD XHTML 1.0 FRAMESET//] or $pubid =~ m[^-//W3C//DTD XHTML 1.0 TRANSITIONAL//]
l!l&&r!l&&!r
117
MC/DC100%2/2
$pubid =~ m[^-//W3C//DTD XHTML 1.0 FRAMESET//] or $pubid =~ m[^-//W3C//DTD XHTML 1.0 TRANSITIONAL//]
$pubid =~ m[^-//W3C//DTD XHTML 1.0 FRAMESET//] $pubid =~ m[^-//W3C//DTD XHTML 1.0 TRANSITIONAL//]
Truth table100%3/3
A or B
A= $pubid =~ m[^-//W3C//DTD XHTML 1.0 FRAMESET//]B= $pubid =~ m[^-//W3C//DTD XHTML 1.0 TRANSITIONAL//]
ABresult
1X1
011
000
1228 $pubid =~ m[^-//W3C//DTD XHTML 1.0 TRANSITIONAL//]) {
1229
1230 2 $self->_data($self->{document})->{'manakai_compat_mode'} ='limited quirks';
1231 } else {
1232
1233 }
1234 } else {
1235
1236 }
1237 392 ▶ if (defined $token->{sysid}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $token->{'sysid'}) { } 13 379 392
1238 13 my $sysid = $token->{sysid};
1239 13 $sysid =~ tr/A-Z/a-z/; ## ASCII case-insensitive.
1240 13 ▶ if ($sysid eq "http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd") {
Branch: 1 branch
BranchTrueFalseTotal
if ($sysid eq 'http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd') { } 0 13 13
1241 ## NOTE: Ensure that |PUBLIC "(limited quirks)" "(quirks)"|
1242 ## is signaled as in quirks mode!
1243 0 $self->_data($self->{document})->{'manakai_compat_mode'} = 'quirks';
1244
1245 } else {
1246
1247 }
1248 } else {
1249
1250 }
1251
1252 ## Go to the "before html" insertion mode.
1253 392 $token = $self->_get_next_token;
1254 392 return;
1255 } elsif ({
1256 START_TAG_TOKEN, 1,
1257 END_TAG_TOKEN, 1,
1258 END_OF_FILE_TOKEN, 1,
1259 }->{$token->{type}}) {
1260
1261 193 ▶ unless ($self->_data($self->{'document'}, 'manakai_is_srcdoc'))
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_data($self->{"document"}, "manakai_is_srcdoc")) 193 0 193
1262 {
1263 193 $self->{parse_error}->(level => $self->{level}->{must}, type => 'no DOCTYPE', token => $token);
1264 193 $self->_data($self->{document})->{'manakai_compat_mode'} = 'quirks';
1265 }
1266 ## Go to the "before html" insertion mode.
1267 ## reprocess
1268
1269 193 return;
1270 } elsif ($token->{type} == CHARACTER_TOKEN) {
1271 128 ▶ if ($token->{data} =~ s/^([\x09\x0A\x0C\x20]+)//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'data'} =~ s/^([\x09\x0A\x0C\x20]+)//) { } 4 124 128
1272 ## Ignore the token
1273  
1274 4 ▶ unless (length $token->{data}) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $token->{'data'}) { } 2 2 4
1275
1276 ## Stay in the insertion mode.
1277 2 $token = $self->_get_next_token;
1278 2 redo INITIAL;
1279 } else {
1280
1281 }
1282 } else {
1283
1284 }
1285  
1286 126 $self->{parse_error}->(level => $self->{level}->{must}, type => 'no DOCTYPE', token => $token);
1287 126 $self->_data($self->{document})->{'manakai_compat_mode'} = 'quirks';
1288 ## Go to the "before html" insertion mode.
1289 ## reprocess
1290 126 return;
1291 } elsif ($token->{type} == COMMENT_TOKEN) {
1292
1293 9 my $comment = $self->{document}->createComment($token->{data});
1294 $self->_data($comment, manakai_source_line => $token->{line})
1295 9 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 9 0 9
1296 $self->_data($comment, manakai_source_column => $token->{column})
1297 9 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 9 0 9
1298 9 $self->{document}->appendChild($comment);
1299
1300 ## Stay in the insertion mode.
1301 9 $token = $self->_get_next_token;
1302 9 redo INITIAL;
1303 } else {
1304 0 die "$0: $token->{type}: Unknown token type";
1305 }
1306 } # INITIAL
1307  
1308 0 die "$0: _tree_construction_initial: This should be never reached";
1309 } # _tree_construction_initial
1310  
1311 sub _tree_construction_root_element ($) {
1312 711 ▶ my $self = shift;
Subroutine _tree_construction_root_element: called CC=20 SCAR=31.0
1313  
1314 ## NOTE: The "before html" insertion mode.
1315
1316 B: {
1317 711 ▶ if ($token->{type} == DOCTYPE_TOKEN) {
Branch: 6 branches
BranchTrueFalseTotal
if ($token->{'type'} == 1) { } 0 735 735
elsif ($token->{'type'} == 2) { } 5 730 735
elsif ($token->{'type'} == 6) { } 191 539 730
elsif ($token->{'type'} == 3) { } 512 27 539
elsif ($token->{'type'} == 4) { } 5 22 27
elsif ($token->{'type'} == 5) { } 22 0 22
1318
1319 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in html:#DOCTYPE', token => $token);
1320 ## Ignore the token
1321 0 $token = $self->_get_next_token;
1322 0 redo B;
1323 } elsif ($token->{type} == COMMENT_TOKEN) {
1324
1325 5 my $comment = $self->{document}->createComment($token->{data});
1326 $self->_data($comment, manakai_source_line => $token->{line})
1327 5 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 5 0 5
1328 $self->_data($comment, manakai_source_column => $token->{column})
1329 5 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 5 0 5
1330 5 $self->{document}->appendChild($comment);
1331 ## Stay in the insertion mode.
1332 5 $token = $self->_get_next_token;
1333 5 redo B;
1334 } elsif ($token->{type} == CHARACTER_TOKEN) {
1335 191 ▶ if ($token->{data} =~ s/^([\x09\x0A\x0C\x20]+)//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'data'} =~ s/^([\x09\x0A\x0C\x20]+)//) { } 19 172 191
1336 ## Ignore the token.
1337  
1338 19 ▶ unless (length $token->{data}) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $token->{'data'}) { } 1 18 19
1339
1340 ## Stay in the insertion mode.
1341 18 $token = $self->_get_next_token;
1342 18 redo B;
1343 } else {
1344
1345 }
1346 } else {
1347
1348 }
1349  
1350 173 $self->{application_cache_selection}->(undef);
1351  
1352 #
1353 } elsif ($token->{type} == START_TAG_TOKEN) {
1354 512 ▶ if ($token->{tag_name} eq 'html') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'html') { } 56 456 512
1355 56 my $root_element;
1356
1357 56 $root_element = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
1358
1359 56 for my $attr_name (keys %{ $token->{attributes}}) {
1360 5 my $attr_t = $token->{attributes}->{$attr_name};
1361 5 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
1362 5 ▶ next unless $attr;
Branch: 1 branch
BranchTrueFalseTotal
unless $attr 0 5 5
1363 5 $attr->setValue ($attr_t->{value});
1364 5 $self->_data($attr, manakai_source_line => $attr_t->{line});
1365 5 $self->_data($attr, manakai_source_column => $attr_t->{column});
1366 5 $root_element->setAttributeNodeNS($attr);
1367 }
1368
1369 $self->_data($root_element, manakai_source_line => $token->{line})
1370 56 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 56 0 56
1371 $self->_data($root_element, manakai_source_column => $token->{column})
1372 56 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 56 0 56
1373
1374 56 $self->{document}->setDocumentElement($root_element);
1375 56 push @{$self->{open_elements}},
1376 56 [$root_element, $el_category->{html}];
1377  
1378 56 ▶ if ($token->{attributes}->{manifest}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'attributes'}{'manifest'}) { } 0 56 56
1379
1380 ## XXX resolve URL and drop fragment
1381 ## <http://html5.org/tools/web-apps-tracker?from=3479&to=3480>
1382 ## <http://manakai.g.hatena.ne.jp/task/2/95>
1383 $self->{application_cache_selection}
1384 0 ->($token->{attributes}->{manifest}->{value});
1385 } else {
1386
1387 56 $self->{application_cache_selection}->(undef);
1388 }
1389  
1390
1391  
1392 56 $token = $self->_get_next_token;
1393 56 return; ## Go to the "before head" insertion mode.
1394 } else {
1395
1396 #
1397 }
1398 } elsif ($token->{type} == END_TAG_TOKEN) {
1399 5 ▶ if ({
Branch: 1 branch
BranchTrueFalseTotal
if ({'head', 1, 'body', 1, 'html', 1, 'br', 1}->{$token->{'tag_name'}}) { } 4 1 5
1400 head => 1, body => 1, html => 1, br => 1,
1401 }->{$token->{tag_name}}) {
1402
1403 #
1404 } else {
1405
1406 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
1407 text => $token->{tag_name},
1408 1 token => $token);
1409 ## Ignore the token.
1410 1 $token = $self->_get_next_token;
1411 1 redo B;
1412 }
1413 } elsif ($token->{type} == END_OF_FILE_TOKEN) {
1414
1415 #
1416 } else {
1417 0 die "$0: $token->{type}: Unknown token type";
1418 }
1419  
1420 655 my $root_element;
1421
1422 655 $root_element = $self->{document}->createElementNS((HTML_NS), 'html');
1423
1424 $self->_data($root_element, manakai_source_line => $token->{line})
1425 655 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 655 0 655
1426 $self->_data($root_element, manakai_source_column => $token->{column})
1427 655 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 655 0 655
1428 655 $self->_data($root_element, implied => __LINE__);
1429
1430 655 $self->{document}->setDocumentElement($root_element);
1431 655 push @{$self->{open_elements}}, [$root_element, $el_category->{html}];
1432  
1433 655 $self->{application_cache_selection}->(undef);
1434  
1435 ## NOTE: Reprocess the token.
1436
1437 655 return; ## Go to the "before head" insertion mode.
1438 } # B
1439  
1440 0 die "$0: _tree_construction_root_element: This should never be reached";
1441 } # _tree_construction_root_element
1442  
1443 sub _reset_insertion_mode ($) {
1444 86 ▶ my $self = shift;
Subroutine _reset_insertion_mode: called CC=10 SCAR=26.5
1445  
1446 ## Step 1
1447 86 my $last;
1448
1449 ## Step 2
1450 86 my $i = -1;
1451 86 my $node = $self->{open_elements}->[$i];
1452
1453 ## LOOP: Step 3
1454 LOOP: {
1455 86 ▶ if ($self->{open_elements}->[0]->[0] eq $node->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[0][0] eq $node->[0]) 0 103 103
1456 0 $last = 1;
1457 0 ▶ if (defined $self->{inner_html_node}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'inner_html_node'}) { } 0 0 0
1458
1459 0 $node = $self->{inner_html_node};
1460 } else {
1461 0 die "_reset_insertion_mode: t27";
1462 }
1463 }
1464
1465 ## Step 4..13
1466 103 my $new_mode;
1467 103 ▶ if ($node->[1] == TABLE_CELL_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 327697) { } 4 99 103
elsif ($node->[1] & 2048) { } 10 89 99
1468 4 ▶ if ($last) {
Branch: 1 branch
BranchTrueFalseTotal
if ($last) { } 0 4 4
1469
1470 #
1471 } else {
1472
1473 4 $new_mode = IN_CELL_IM;
1474 }
1475 } elsif ($node->[1] & FOREIGN_EL) {
1476 #
1477 } else {
1478
1479 $new_mode = {
1480 select => IN_SELECT_IM,
1481 ## NOTE: |option| and |optgroup| do not set
1482 ## insertion mode to "in select" by themselves.
1483 tr => IN_ROW_IM,
1484 tbody => IN_TABLE_BODY_IM,
1485 thead => IN_TABLE_BODY_IM,
1486 tfoot => IN_TABLE_BODY_IM,
1487 caption => IN_CAPTION_IM,
1488 colgroup => IN_COLUMN_GROUP_IM,
1489 table => IN_TABLE_IM,
1490 head => IN_BODY_IM, # not in head!
1491 body => IN_BODY_IM,
1492 frameset => IN_FRAMESET_IM,
1493 89 }->{$node->[0]->tagName};
1494 }
1495 103 ▶ $self->{insertion_mode} = $new_mode and last LOOP if defined $new_mode;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_mode 86 17 103
Condition60%3/5
defined $new_mode && (($self->{'insertion_mode'} = $new_mode) && (last LOOP))
!ll&&!rl&&r
17860
$self->{"insertion_mode"} = $new_mode and last LOOP
!ll
086
MC/DC0%0/2
defined $new_mode && (($self->{'insertion_mode'} = $new_mode) && (last LOOP))
defined $new_mode $self->{"insertion_mode"} = $new_mode
Truth table33%1/3
A && B
A= defined $new_modeB= $self->{"insertion_mode"} = $new_mode
ABresult
0X0
100
111
1496
1497 ## Step 14
1498 17 ▶ if ($node->[1] == HTML_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->[1] == 328593) { } 0 17 17
1499 ## NOTE: Commented out in the spec (HTML5 revision 3894).
1500 #unless (defined $self->{head_element}) {
1501
1502 0 $self->{insertion_mode} = BEFORE_HEAD_IM;
1503 #} else {
1504 ## ISSUE: Can this state be reached?
1505
1506 # $self->{insertion_mode} = AFTER_HEAD_IM;
1507 #}
1508 0 last LOOP;
1509 } else {
1510
1511 }
1512
1513 ## Step 15
1514 17 ▶ if ($last)
Branch: 1 branch
BranchTrueFalseTotal
if ($last) 0 17 17
1515 {
1516 0 $self->{insertion_mode} = IN_BODY_IM;
1517 0 last LOOP;
1518 }
1519
1520 ## Step 16
1521 17 $i--;
1522 17 $node = $self->{open_elements}->[$i];
1523
1524 ## Step 17
1525 17 redo LOOP;
1526 } # LOOP
1527  
1528 ## END
1529 } # _reset_insertion_mode
1530  
1531 my $parse_rcdata = sub ($$$$) {
1532 47 ▶ my ($self, $insert, $open_tables, $parse_refs) = @_;
Subroutine __ANON__: called CC=6 SCAR=18.0
1533  
1534 ## Step 1
1535 47 my $start_tag_name = $token->{tag_name};
1536
1537 {
1538 47 my $el;
1539
1540 47 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
1541
1542 47 for my $attr_name (keys %{ $token->{attributes}}) {
1543 1 my $attr_t = $token->{attributes}->{$attr_name};
1544 1 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
1545 1 $attr->setValue ($attr_t->{value});
1546 1 $self->_data($attr, manakai_source_line => $attr_t->{line});
1547 1 $self->_data($attr, manakai_source_column => $attr_t->{column});
1548 1 $el->setAttributeNodeNS ($attr);
1549 }
1550
1551 $self->_data($el, manakai_source_line => $token->{line})
1552 47 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 47 0 47
1553 $self->_data($el, manakai_source_column => $token->{column})
1554 47 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 47 0 47
1555
1556 47 $insert->($self, $el, $open_tables);
1557 47 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
470
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
1558 }
1559
1560  
1561 ## Step 2
1562 47 ▶ if ($parse_refs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parse_refs) { } 21 26 47
1563 21 $self->{state} = RCDATA_STATE;
1564 } else {
1565 26 $self->{state} = RAWTEXT_STATE;
1566 }
1567 47 delete $self->{escape}; # MUST
1568  
1569 ## Step 3, 4
1570 47 $self->{insertion_mode} |= IN_CDATA_RCDATA_IM;
1571  
1572
1573 47 $token = $self->_get_next_token;
1574 11 }; # $parse_rcdata
1575  
1576 my $script_start_tag = sub ($$$) {
1577 39 ▶ my ($self, $insert, $open_tables) = @_;
Subroutine __ANON__: called CC=4 SCAR=13.9
1578
1579 ## Step 1
1580 39 my $script_el;
1581
1582 39 $script_el = $self->{document}->createElementNS((HTML_NS), 'script');
1583
1584 39 for my $attr_name (keys %{ $token->{attributes}}) {
1585 11 my $attr_t = $token->{attributes}->{$attr_name};
1586 11 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
1587 11 $attr->setValue($attr_t->{value});
1588 11 $self->_data($attr, manakai_source_line => $attr_t->{line});
1589 11 $self->_data($attr, manakai_source_column => $attr_t->{column});
1590 11 $script_el->setAttributeNodeNS($attr);
1591 }
1592
1593 $self->_data($script_el, manakai_source_line => $token->{line})
1594 39 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 39 0 39
1595 $self->_data($script_el, manakai_source_column => $token->{column})
1596 39 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 39 0 39
1597
1598  
1599 ## Step 2
1600 ## TODO: mark as "parser-inserted"
1601  
1602 ## Step 3
1603 ## TODO: Mark as "already executed", if ...
1604  
1605 ## Step 4 (HTML5 revision 2702)
1606 39 $insert->($self, $script_el, $open_tables);
1607 39 push @{$self->{open_elements}}, [$script_el, $el_category->{script}];
1608  
1609 ## Step 5
1610 39 $self->{state} = SCRIPT_DATA_STATE;
1611 39 delete $self->{escape}; # MUST
1612  
1613 ## Step 6-7
1614 39 $self->{insertion_mode} |= IN_CDATA_RCDATA_IM;
1615  
1616
1617 39 $token = $self->_get_next_token;
1618 11 }; # $script_start_tag
1619  
1620 sub push_afe ($$)
1621 {
1622 0 ▶ my ($item => $afes) = @_;
Subroutine push_afe: not called CC=9 SCAR=45.0
Pod undocumented
1623 0 my $item_token = $item->[2];
1624  
1625 0 my $depth = 0;
1626 0 OUTER: for my $i (reverse 0..$#$afes)
1627 {
1628 0 my $afe = $afes->[$i];
1629 0 ▶ if ($afe->[0] eq '#marker')
Branch: 1 branch
BranchTrueFalseTotal
if ($afe->[0] eq '#marker') { } 0 0 0
1630 {
1631 0 last OUTER;
1632 }
1633 else
1634 {
1635 0 my $token = $afe->[2];
1636 ## Both |$token| and |$item_token| should be start tag tokens.
1637 0 ▶ if ($token->{tag_name} eq $item_token->{tag_name})
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"tag_name"} eq $item_token->{"tag_name"}) 0 0 0
1638 {
1639 0 ▶ if ((keys %{$token->{attributes}}) !=
Branch: 1 branch
BranchTrueFalseTotal
if (keys %{$$token{"attributes"};} != keys %{$$item_token{"attributes"};}) 0 0 0
1640 0 (keys %{$item_token->{attributes}}))
1641 {
1642 0 next OUTER;
1643 }
1644 0 for my $attr_name (keys %{$item_token->{attributes}})
1645 {
1646 0 ▶ next OUTER unless $token->{attributes}->{$attr_name};
Branch: 1 branch
BranchTrueFalseTotal
unless $token->{"attributes"}{$attr_name} 0 0 0
1647 next OUTER unless
1648 $token->{attributes}->{$attr_name}->{value} eq
1649 0 ▶ $item_token->{attributes}->{$attr_name}->{value};
Branch: 1 branch
BranchTrueFalseTotal
unless $token->{"attributes"}{$attr_name}{"value"} eq $item_token->{"attributes"}{$attr_name}{"value"} 0 0 0
1650 }
1651 0 $depth++;
1652 0 ▶ if ($depth == 3)
Branch: 1 branch
BranchTrueFalseTotal
if ($depth == 3) 0 0 0
1653 {
1654 0 splice @$afes, $i, 1 => ();
1655 0 last OUTER;
1656 }
1657 }
1658  
1659 ## We don't have to check namespaces of elements and attributes,
1660 ## nevertheless the spec requires it, because |$afes| could
1661 ## never contain a non-HTML element at the time of writing. In
1662 ## addition, scripted changes would never change the original
1663 ## start tag token.
1664 }
1665 } # OUTER
1666  
1667 0 push @$afes, $item;
1668 } # push_afe
1669  
1670  
1671 my $formatting_end_tag = sub {
1672 120 ▶ my ($self, $active_formatting_elements, $open_tables, $end_tag_token) = @_;
Subroutine __ANON__: called CC=46 SCAR=39.9
1673 120 my $tag_name = $end_tag_token->{tag_name};
1674  
1675 ## NOTE: The adoption agency algorithm (AAA).
1676  
1677 ## Step 1
1678 120 my $outer_loop_counter = 0;
1679
1680 OUTER: {
1681 120 ▶ if ($outer_loop_counter >= 8)
Branch: 1 branch
BranchTrueFalseTotal
if ($outer_loop_counter >= 8) 0 159 159
1682 {
1683 0 $token = $self->_get_next_token;
1684 0 last OUTER;
1685 }
1686  
1687 ## Step 3
1688 159 $outer_loop_counter++;
1689
1690 ## Step 4
1691 159 my $formatting_element;
1692 my $formatting_element_i_in_active;
1693 159 AFE: for (reverse 0..$#$active_formatting_elements) {
1694 218 ▶ if ($active_formatting_elements->[$_]->[0] eq '#marker') {
Branch: 2 branches
BranchTrueFalseTotal
if ($active_formatting_elements->[$_][0] eq '#marker') { } 1 217 218
elsif ($active_formatting_elements->[$_][0]->tagName eq $tag_name) { } 157 60 217
1695
1696 1 last AFE;
1697 } elsif ($active_formatting_elements->[$_]->[0]->tagName
1698 eq $tag_name) {
1699
1700 157 $formatting_element = $active_formatting_elements->[$_];
1701 157 $formatting_element_i_in_active = $_;
1702 157 last AFE;
1703 }
1704 } # AFE
1705 159 ▶ unless (defined $formatting_element) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $formatting_element) 2 157 159
1706
1707 2 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag', text => $tag_name, token => $end_tag_token);
1708 ## Ignore the token
1709 2 $token = $self->_get_next_token;
1710 2 return;
1711 }
1712 ## has an element in scope
1713 157 my $in_scope = 1;
1714 157 my $formatting_element_i_in_open;
1715 157 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
1716 272 my $node = $self->{open_elements}->[$_];
1717 272 ▶ if ($node->[0] eq $formatting_element->[0]) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[0] eq $formatting_element->[0]) { } 157 115 272
elsif ($node->[1] & 65536) { } 2 113 115
1718 157 ▶ if ($in_scope) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_scope) { } 155 2 157
1719
1720 155 $formatting_element_i_in_open = $_;
1721 155 last INSCOPE;
1722 } else { # in open elements but not in scope
1723
1724 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
1725 text => $token->{tag_name},
1726 2 token => $end_tag_token);
1727 ## Ignore the token
1728 2 $token = $self->_get_next_token;
1729 2 return;
1730 }
1731 } elsif ($node->[1] & SCOPING_EL) {
1732
1733 2 $in_scope = 0;
1734 }
1735 } # INSCOPE
1736 155 ▶ unless (defined $formatting_element_i_in_open) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $formatting_element_i_in_open) 0 155 155
1737
1738 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
1739 text => $token->{tag_name},
1740 0 token => $end_tag_token);
1741 0 pop @$active_formatting_elements; # $formatting_element
1742 0 $token = $self->_get_next_token; ## TODO: ok?
1743 0 return;
1744 }
1745 155 ▶ if (not $self->{open_elements}->[-1]->[0] eq $formatting_element->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"open_elements"}[-1][0] eq $formatting_element->[0]) 84 71 155
1746
1747 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
1748 84 text => $self->{open_elements}->[-1]->[0]
1749 ->tagName,
1750 token => $end_tag_token);
1751 }
1752
1753 ## Step 5
1754 155 my $furthest_block;
1755 my $furthest_block_i_in_open;
1756 155 OE: for (reverse 0..$#{$self->{open_elements}}) {
1757 265 my $node = $self->{open_elements}->[$_];
1758 265 ▶ if ($node->[1] & SPECIAL_EL or $node->[1] & SCOPING_EL) { ## "Special"
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] & 131072 or $node->[1] & 65536) { } 42 223 265
elsif ($node->[0] eq $formatting_element->[0]) { } 155 68 223
Condition66%2/3
$node->[1] & 131072 or $node->[1] & 65536
l!l&&r!l&&!r
420223
MC/DC50%1/2
$node->[1] & 131072 or $node->[1] & 65536
$node->[1] & 131072 $node->[1] & 65536
Truth table66%2/3
A or B
A= $node->[1] & 131072B= $node->[1] & 65536
ABresult
1X1
011
000
1759 42 $furthest_block = $node;
1760 42 $furthest_block_i_in_open = $_;
1761 ## NOTE: The topmost (eldest) node.
1762 } elsif ($node->[0] eq $formatting_element->[0]) {
1763
1764 155 last OE;
1765 }
1766 } # OE
1767
1768 ## Step 6
1769 155 ▶ unless (defined $furthest_block) { # MUST
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $furthest_block) 116 39 155
1770
1771 116 splice @{$self->{open_elements}}, $formatting_element_i_in_open;
1772 116 splice @$active_formatting_elements, $formatting_element_i_in_active, 1;
1773 116 $token = $self->_get_next_token;
1774 116 return;
1775 }
1776
1777 ## Step 7
1778 39 my $common_ancestor_node = $self->{open_elements}->[$formatting_element_i_in_open - 1];
1779
1780 ## Step 8
1781 39 my $bookmark_prev_el
1782 = $active_formatting_elements->[$formatting_element_i_in_active - 1]
1783 ->[0];
1784
1785 ## Step 9
1786 39 my $node = $furthest_block;
1787 39 my $node_i_in_open = $furthest_block_i_in_open;
1788 39 my $last_node = $furthest_block;
1789
1790 ## Step 9.1
1791 39 my $inner_loop_counter = 0;
1792
1793 INNER: {
1794 ## Step 9.2
1795 39 ▶ if ($inner_loop_counter >= 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($inner_loop_counter >= 3) 0 49 49
1796 0 $token = $self->_get_next_token;
1797 0 last OUTER;
1798 }
1799  
1800 ## Step 9.3
1801 49 $inner_loop_counter++;
1802
1803 ## Step 9.4
1804 49 $node_i_in_open--;
1805 49 $node = $self->{open_elements}->[$node_i_in_open];
1806
1807 ## Step 9.5
1808 49 my $node_i_in_active;
1809 my $node_token;
1810 S7S2: {
1811 49 for (reverse 0..$#$active_formatting_elements) {
1812 73 ▶ if ($active_formatting_elements->[$_]->[0] eq $node->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($active_formatting_elements->[$_][0] eq $node->[0]) 49 24 73
1813
1814 49 $node_i_in_active = $_;
1815 49 $node_token = $active_formatting_elements->[$_]->[2];
1816 49 last S7S2;
1817 }
1818 }
1819 0 splice @{$self->{open_elements}}, $node_i_in_open, 1;
1820 0 redo INNER;
1821 } # S7S2
1822
1823 ## Step 9.6
1824 49 ▶ last INNER if $node->[0] eq $formatting_element->[0];
Branch: 1 branch
BranchTrueFalseTotal
if $node->[0] eq $formatting_element->[0] 39 10 49
1825
1826 ## Step 9.7
1827 10 ▶ if ($node->[0]->hasChildNodes ()) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->[0]->hasChildNodes) 10 0 10
1828
1829 10 my $new_element = [];
1830
1831 10 $new_element->[0] = $self->{document}->createElementNS((HTML_NS), $node_token->{tag_name});
1832
1833 10 for my $attr_name (keys %{ $node_token->{attributes}}) {
1834 0 my $attr_t = $node_token->{attributes}->{$attr_name};
1835 0 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
1836 0 $attr->setValue ($attr_t->{value});
1837 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
1838 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
1839 0 $new_element->[0]->setAttributeNodeNS($attr);
1840 }
1841
1842 $self->_data($new_element->[0], manakai_source_line => $node_token->{line})
1843 10 ▶ if defined $node_token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $node_token->{"line"} 10 0 10
1844 $self->_data($new_element->[0], manakai_source_column => $node_token->{column})
1845 10 ▶ if defined $node_token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $node_token->{"column"} 10 0 10
1846
1847 10 $new_element->[1] = $node->[1];
1848 10 $new_element->[2] = $node_token;
1849 10 $active_formatting_elements->[$node_i_in_active] = $new_element;
1850 10 $self->{open_elements}->[$node_i_in_open] = $new_element;
1851 10 $node = $new_element;
1852 }
1853  
1854 ## Step 9.8
1855 10 ▶ if ($last_node->[0] eq $furthest_block->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($last_node->[0] eq $furthest_block->[0]) 9 1 10
1856
1857 9 $bookmark_prev_el = $node->[0];
1858 }
1859
1860 ## Step 9.9
1861 10 $node->[0]->appendChild ($last_node->[0]);
1862
1863 ## Step 9.10
1864 10 $last_node = $node;
1865
1866 ## Step 9.11
1867 10 redo INNER;
1868 } # INNER
1869
1870 ## Step 10
1871 39 ▶ if ($common_ancestor_node->[1] & TABLE_ROWS_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($common_ancestor_node->[1] & 64) { } 7 32 39
1872 ## Foster parenting.
1873 7 my $foster_parent_element;
1874 my $next_sibling;
1875 7 OE: for (reverse 0..$#{$self->{open_elements}}) {
1876 29 ▶ if ($self->{open_elements}->[$_]->[1] == TABLE_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[$_][1] == 328257) 7 22 29
1877
1878 7 $foster_parent_element = $self->{open_elements}->[$_ - 1]->[0];
1879 7 $next_sibling = $self->{open_elements}->[$_]->[0];
1880 7 ▶ undef $next_sibling
Branch: 1 branch
BranchTrueFalseTotal
unless $next_sibling->parentNode eq $foster_parent_element 0 7 7
1881 unless $next_sibling->parentNode eq $foster_parent_element;
1882 7 last OE;
1883 }
1884 } # OE
1885 7 ▶ $foster_parent_element ||= $self->{open_elements}->[0]->[0];
Condition33%1/3
$foster_parent_element ||= $self->{"open_elements"}[0][0]
l!l&&r!l&&!r
700
MC/DC0%0/2
$foster_parent_element ||= $self->{"open_elements"}[0][0]
$foster_parent_element $self->{"open_elements"}[0][0]
Truth table33%1/3
A ||= B
A= $foster_parent_elementB= $self->{"open_elements"}[0][0]
ABresult
1X1
011
000
1886  
1887 7 $foster_parent_element->insertBefore ($last_node->[0], $next_sibling);
1888 7 $open_tables->[-1]->[1] = 1; # tainted
1889 } else {
1890
1891 32 $common_ancestor_node->[0]->appendChild ($last_node->[0]);
1892 }
1893
1894 ## Step 11
1895 39 my $new_element = [];
1896
1897 39 $new_element->[0] = $self->{document}->createElementNS((HTML_NS), $formatting_element->[2]->{tag_name});
1898
1899 39 for my $attr_name (keys %{ $formatting_element->[2]->{attributes}}) {
1900 2 my $attr_t = $formatting_element->[2]->{attributes}->{$attr_name};
1901 2 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
1902 2 $attr->setValue ($attr_t->{value});
1903 2 $self->_data($attr, manakai_source_line => $attr_t->{line});
1904 2 $self->_data($attr, manakai_source_column => $attr_t->{column});
1905 2 $new_element->[0]->setAttributeNodeNS($attr);
1906 }
1907
1908 $self->_data($new_element->[0], manakai_source_line => $formatting_element->[2]->{line})
1909 39 ▶ if defined $formatting_element->[2]->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $formatting_element->[2]{"line"} 39 0 39
1910 $self->_data($new_element->[0], manakai_source_column => $formatting_element->[2]->{column})
1911 39 ▶ if defined $formatting_element->[2]->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $formatting_element->[2]{"column"} 39 0 39
1912
1913 39 $new_element->[1] = $formatting_element->[1];
1914 39 $new_element->[2] = $formatting_element->[2];
1915
1916 ## Step 12
1917 39 my @cn = $furthest_block->[0]->childNodes;
1918 39 $new_element->[0]->appendChild($_) for @cn;
1919
1920 ## Step 13
1921 39 $furthest_block->[0]->appendChild ($new_element->[0]);
1922
1923 ## Step 14
1924 39 my $i;
1925 39 AFE: for (reverse 0..$#$active_formatting_elements) {
1926 65 ▶ if ($active_formatting_elements->[$_]->[0] eq $formatting_element->[0]) {
Branch: 2 branches
BranchTrueFalseTotal
if ($active_formatting_elements->[$_][0] eq $formatting_element->[0]) { } 39 26 65
elsif ($active_formatting_elements->[$_][0] eq $bookmark_prev_el) { } 20 6 26
1927
1928 39 splice @$active_formatting_elements, $_, 1;
1929 39 ▶ $i-- and last AFE if defined $i;
Branch: 1 branch
BranchTrueFalseTotal
if defined $i 15 24 39
Condition60%3/5
defined $i && ($i-- && (last AFE))
!ll&&!rl&&r
24150
$i-- and last AFE
!ll
015
MC/DC0%0/2
defined $i && ($i-- && (last AFE))
defined $i $i--
Truth table33%1/3
A && B
A= defined $iB= $i--
ABresult
0X0
100
111
1930 } elsif ($active_formatting_elements->[$_]->[0] eq $bookmark_prev_el) {
1931
1932 20 $i = $_;
1933 }
1934 } # AFE
1935 39 ▶ splice @$active_formatting_elements, (defined $i ? $i : 0) + 1, 0, $new_element;
Branch: 1 branch
BranchTrueFalseTotal
defined $i ? : 20 19 39
1936
1937 ## Step 15
1938 39 undef $i;
1939 39 OE: for (reverse 0..$#{$self->{open_elements}}) {
1940 101 ▶ if ($self->{open_elements}->[$_]->[0] eq $formatting_element->[0]) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'open_elements'}[$_][0] eq $formatting_element->[0]) { } 39 62 101
elsif ($self->{'open_elements'}[$_][0] eq $furthest_block->[0]) { } 39 23 62
1941
1942 39 splice @{$self->{open_elements}}, $_, 1;
1943 39 ▶ $i-- and last OE if defined $i;
Branch: 1 branch
BranchTrueFalseTotal
if defined $i 39 0 39
Condition40%2/5
defined $i && ($i-- && (last OE))
!ll&&!rl&&r
0390
$i-- and last OE
!ll
039
MC/DC0%0/2
defined $i && ($i-- && (last OE))
defined $i $i--
Truth table0%0/3
A && B
A= defined $iB= $i--
ABresult
0X0
100
111
1944 } elsif ($self->{open_elements}->[$_]->[0] eq $furthest_block->[0]) {
1945
1946 39 $i = $_;
1947 }
1948 } # OE
1949 39 splice @{$self->{open_elements}}, $i + 1, 0, $new_element;
1950
1951 ## Step 16
1952 39 redo OUTER;
1953 } # OUTER
1954 11 }; # $formatting_end_tag
1955  
1956 my $reconstruct_active_formatting_elements = sub ($$$$) { # MUST
1957 1281 ▶ my ($self, $insert, $active_formatting_elements, $open_tables) = @_;
Subroutine __ANON__: called CC=11 SCAR=24.0
1958  
1959 ## Step 1
1960 1281 ▶ return unless @$active_formatting_elements;
Branch: 1 branch
BranchTrueFalseTotal
unless @$active_formatting_elements 952 329 1281
1961  
1962 ## Step 3
1963 329 my $i = -1;
1964 329 my $entry = $active_formatting_elements->[$i];
1965  
1966 ## Step 2
1967 329 ▶ return if $entry->[0] eq '#marker';
Branch: 1 branch
BranchTrueFalseTotal
if $entry->[0] eq "#marker" 55 274 329
1968 274 for (@{$self->{open_elements}}) {
1969 1113 ▶ if ($entry->[0] eq $_->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->[0] eq $_->[0]) 215 898 1113
1970
1971 215 return;
1972 }
1973 }
1974
1975 S4: {
1976 ## Step 4
1977 59 ▶ last S4 if $active_formatting_elements->[0]->[0] eq $entry->[0];
Branch: 1 branch
BranchTrueFalseTotal
if $active_formatting_elements->[0][0] eq $entry->[0] 49 16 65
1978  
1979 ## Step 5
1980 16 $i--;
1981 16 $entry = $active_formatting_elements->[$i];
1982  
1983 ## Step 6
1984 16 ▶ if ($entry->[0] eq '#marker') {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->[0] eq '#marker') { } 5 11 16
1985
1986 #
1987 } else {
1988 11 my $in_open_elements;
1989 11 OE: for (@{$self->{open_elements}}) {
1990 31 ▶ if ($entry->[0] eq $_->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->[0] eq $_->[0]) 5 26 31
1991
1992 5 $in_open_elements = 1;
1993 5 last OE;
1994 }
1995 }
1996 11 ▶ if ($in_open_elements) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_open_elements) { } 5 6 11
1997
1998 #
1999 } else {
2000 ## NOTE: <!DOCTYPE HTML><p><b><i><u></p> <p>X
2001
2002 6 redo S4;
2003 }
2004 }
2005  
2006 ## Step 7
2007 10 $i++;
2008 10 $entry = $active_formatting_elements->[$i];
2009 } # S4
2010  
2011 S7: {
2012 ## Step 8
2013 59 my $clone = [$entry->[0]->cloneNode(0), $entry->[1], $entry->[2]];
2014
2015 ## Step 9
2016 65 $insert->($self, $clone->[0], $open_tables);
2017 65 push @{$self->{open_elements}}, $clone;
2018
2019 ## Step 10
2020 65 $active_formatting_elements->[$i] = $self->{open_elements}->[-1];
2021  
2022 ## Step 11
2023 65 ▶ unless ($clone->[0] eq $active_formatting_elements->[-1]->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($clone->[0] eq $active_formatting_elements->[-1][0]) 6 59 65
2024
2025 ## Step 7'
2026 6 $i++;
2027 6 $entry = $active_formatting_elements->[$i];
2028
2029 6 redo S7;
2030 }
2031  
2032
2033 } # S7
2034 11 }; # $reconstruct_active_formatting_elements
2035  
2036 my $clear_up_to_marker = sub ($) {
2037 39 ▶ my $active_formatting_elements = $_[0];
Subroutine __ANON__: called CC=3 SCAR=11.1
2038 39 for (reverse 0..$#$active_formatting_elements) {
2039 39 ▶ if ($active_formatting_elements->[$_]->[0] eq '#marker') {
Branch: 1 branch
BranchTrueFalseTotal
if ($active_formatting_elements->[$_][0] eq "#marker") 39 0 39
2040
2041 39 splice @$active_formatting_elements, $_;
2042 39 return;
2043 }
2044 }
2045  
2046
2047 11 }; # $clear_up_to_marker
2048  
2049 my $insert_to_current = sub {
2050 #my ($self, $child, $open_tables) = @_;
2051 1177 ▶ $_[0]->{open_elements}->[-1]->[0]->appendChild ($_[1]);
Subroutine __ANON__: called CC=1 SCAR=0.0
2052 11 }; # insert_to_current
2053  
2054 ## Foster parenting. Note that there are three "foster parenting"
2055 ## code in the parser: for elements (this one), for texts, and for
2056 ## elements in the AAA code.
2057 my $insert_to_foster = sub {
2058 99 ▶ my ($self, $child, $open_tables) = @_;
Subroutine __ANON__: called CC=7 SCAR=19.9
2059 99 ▶ if ($self->{open_elements}->[-1]->[1] & TABLE_ROWS_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] & 64) { } 61 38 99
2060 # MUST
2061 61 my $foster_parent_element;
2062 my $next_sibling;
2063 61 OE: for (reverse 0..$#{$self->{open_elements}}) {
2064 92 ▶ if ($self->{open_elements}->[$_]->[1] == TABLE_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[$_][1] == 328257) 61 31 92
2065
2066 61 $foster_parent_element = $self->{open_elements}->[$_ - 1]->[0];
2067 61 $next_sibling = $self->{open_elements}->[$_]->[0];
2068 61 ▶ undef $next_sibling
Branch: 1 branch
BranchTrueFalseTotal
unless $next_sibling->parentNode eq $foster_parent_element 0 61 61
2069 unless $next_sibling->parentNode eq $foster_parent_element;
2070 61 last OE;
2071 }
2072 } # OE
2073 61 ▶ $foster_parent_element ||= $self->{open_elements}->[0]->[0];
Condition33%1/3
$foster_parent_element ||= $self->{"open_elements"}[0][0]
l!l&&r!l&&!r
6100
MC/DC0%0/2
$foster_parent_element ||= $self->{"open_elements"}[0][0]
$foster_parent_element $self->{"open_elements"}[0][0]
Truth table33%1/3
A ||= B
A= $foster_parent_elementB= $self->{"open_elements"}[0][0]
ABresult
1X1
011
000
2074  
2075 # This conditional bit is by TOBY
2076 61 ▶ if ($next_sibling)
Branch: 1 branch
BranchTrueFalseTotal
if ($next_sibling) { } 61 0 61
2077 {
2078 61 $foster_parent_element->insertBefore ($child, $next_sibling);
2079 }
2080 else
2081 {
2082 0 $foster_parent_element->appendChild($child);
2083 }
2084 61 $open_tables->[-1]->[1] = 1; # tainted
2085 } else {
2086
2087 38 $self->{open_elements}->[-1]->[0]->appendChild ($child);
2088 }
2089 11 }; # $insert_to_foster
2090  
2091 sub _tree_construction_main ($) {
2092 711 ▶ my $self = shift;
Subroutine _tree_construction_main: called CC=822 SCAR=92.0
2093  
2094 ## "List of active formatting elements". Each item in this array is
2095 ## an array reference, which contains: [0] - the element node; [1] -
2096 ## the local name of the element; [2] - the token that is used to
2097 ## create [0].
2098 711 my $active_formatting_elements = [];
2099  
2100 711 my $insert;
2101  
2102 ## NOTE: $open_tables->[-1]->[0] is the "current table" element node.
2103 ## NOTE: $open_tables->[-1]->[1] is the "tainted" flag (OBSOLETE; unused).
2104 ## NOTE: $open_tables->[-1]->[2] is set false when non-Text node inserted.
2105 711 my $open_tables = [[$self->{open_elements}->[0]->[0]]];
2106  
2107 711 $insert = $insert_to_current;
2108  
2109 ## NOTE: Insert a character (MUST): When a character is inserted, if
2110 ## the last node that was inserted by the parser is a Text node and
2111 ## the character has to be inserted after that node, then the
2112 ## character is appended to the Text node. However, if any other
2113 ## node is inserted by the parser, then a new Text node is created
2114 ## and the character is appended as that Text node. If I'm not
2115 ## wrong, for a parser with scripting disabled, there are only two
2116 ## cases where this occurs. It is the case where an element or
2117 ## comment is inserted into the |table| subtree while foster
2118 ## parenting happens. This is covered by using the [2] flag of the
2119 ## |$open_tables| structure. All other cases are handled simply by
2120 ## calling |manakai_append_text| method.
2121
2122 711 B: while (1) {
2123 5216 ▶ if ($token->{n}++ == 100) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"n"}++ == 100) 0 5216 5216
2124 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'parser impl error', # XXXtest
2125 token => $token);
2126 0 require Data::Dumper;
2127 0 warn "====== HTML Parser Error ======\n";
2128 0 warn join (' ', map { $_->[0]->tagName } @{$self->{open_elements}}) . ' #' . $self->{insertion_mode} . "\n";
2129 0 warn Data::Dumper::Dumper ($token);
2130 0 $token = $self->_get_next_token;
2131 0 next B;
2132 }
2133 ## <http://c.whatwg.org/#tree-construction>
2134 5216 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (not @{$self->{'open_elements'};} && $self->{'open_elements'}[-1][1] & 2048 or $self->{'open_elements'}[-1][1] == 334848 and $token->{'type'} == 3 && $token->{'tag_name'} ne 'mglyph' && $token->{'tag_name'} ne 'malignmark' || $token->{'type'} == 6 or $self->{'open_elements'}[-1][1] & 333825 and $token->{'type'} == 3 and $token->{'tag_name'} eq 'svg' or $self->{'open_elements'}[-1][1] == 338944 and $token->{'type'} == 3 || $token->{'type'} == 6 or $self->{'open_elements'}[-1][1] == 333825 and $token->{'type'} == 3 || $token->{'type'} == 6 and do { my $encoding = $self->{'open_elements'}[-1][0]->getAttributeNS(undef, 'encoding') || ''; $encoding =~ tr/A-Z/a-z/; if ($encoding eq 'text/html' or $encoding eq 'application/xhtml+xml') { 1; } else { 0; } } or $token->{'type'} == 5) { } 4947 269 5216
Condition94%17/18
not @{$self->{"open_elements"};} && $self->{"open_elements"}[-1][1] & 2048 or $self->{"open_elements"}[-1][1] == 334848 and $token->{"type"} == 3 && $token->{"tag_name"} ne "mglyph" && $token->{"tag_name"} ne "malignmark" || $token->{"type"} == 6 or $self->{"open_elements"}[-1][1] & 333825 and $token->{"type"} == 3 and $token->{"tag_name"} eq "svg" or $self->{"open_elements"}[-1][1] == 338944 and $token->{"type"} == 3 || $token->{"type"} == 6 or $self->{"open_elements"}[-1][1] == 333825 and $token->{"type"} == 3 || $token->{"type"} == 6 and do { my $encoding = $self->{"open_elements"}[-1][0]->getAttributeNS(undef, "encoding") || ""; $encoding =~ tr/A-Z/a-z/; if ($encoding eq "text/html" or $encoding eq "application/xhtml+xml") { 1; } else { 0; } } or $token->{"type"} == 5
l!l&&r!l&&!r
492423269
not @{$self->{"open_elements"};} && $self->{"open_elements"}[-1][1] & 2048 or $self->{"open_elements"}[-1][1] == 334848 and $token->{"type"} == 3 && $token->{"tag_name"} ne "mglyph" && $token->{"tag_name"} ne "malignmark" || $token->{"type"} == 6 or $self->{"open_elements"}[-1][1] & 333825 and $token->{"type"} == 3 and $token->{"tag_name"} eq "svg" or $self->{"open_elements"}[-1][1] == 338944 and $token->{"type"} == 3 || $token->{"type"} == 6 or $self->{"open_elements"}[-1][1] == 333825 and $token->{"type"} == 3 || $token->{"type"} == 6 and do { my $encoding = $self->{"open_elements"}[-1][0]->getAttributeNS(undef, "encoding") || ""; $encoding =~ tr/A-Z/a-z/; if ($encoding eq "text/html" or $encoding eq "application/xhtml+xml") { 1; } else { 0; } }
l!l&&r!l&&!r
49204292
not @{$self->{"open_elements"};} && $self->{"open_elements"}[-1][1] & 2048 or $self->{"open_elements"}[-1][1] == 334848 and $token->{"type"} == 3 && $token->{"tag_name"} ne "mglyph" && $token->{"tag_name"} ne "malignmark" || $token->{"type"} == 6 or $self->{"open_elements"}[-1][1] & 333825 and $token->{"type"} == 3 and $token->{"tag_name"} eq "svg" or $self->{"open_elements"}[-1][1] == 338944 and $token->{"type"} == 3 || $token->{"type"} == 6
l!l&&r!l&&!r
48905321
not @{$self->{"open_elements"};} && $self->{"open_elements"}[-1][1] & 2048 or $self->{"open_elements"}[-1][1] == 334848 and $token->{"type"} == 3 && $token->{"tag_name"} ne "mglyph" && $token->{"tag_name"} ne "malignmark" || $token->{"type"} == 6 or $self->{"open_elements"}[-1][1] & 333825 and $token->{"type"} == 3 and $token->{"tag_name"} eq "svg"
l!l&&r!l&&!r
48837326
not @{$self->{"open_elements"};} && $self->{"open_elements"}[-1][1] & 2048 or $self->{"open_elements"}[-1][1] == 334848 and $token->{"type"} == 3 && $token->{"tag_name"} ne "mglyph" && $token->{"tag_name"} ne "malignmark" || $token->{"type"} == 6
l!l&&r!l&&!r
48616349
@{$self->{'open_elements'};} && $self->{'open_elements'}[-1][1] & 2048
!ll&&!rl&&r
04861355
MC/DC0%0/7
not @{$self->{"open_elements"};} && $self->{"open_elements"}[-1][1] & 2048 or $self->{"open_elements"}[-1][1] == 334848 and $token->{"type"} == 3 && $token->{"tag_name"} ne "mglyph" && $token->{"tag_name"} ne "malignmark" || $token->{"type"} == 6 or $self->{"open_elements"}[-1][1] & 333825 and $token->{"type"} == 3 and $token->{"tag_name"} eq "svg" or $self->{"open_elements"}[-1][1] == 338944 and $token->{"type"} == 3 || $token->{"type"} == 6 or $self->{"open_elements"}[-1][1] == 333825 and $token->{"type"} == 3 || $token->{"type"} == 6 and do { my $encoding = $self->{"open_elements"}[-1][0]->getAttributeNS(undef, "encoding") || ""; $encoding =~ tr/A-Z/a-z/; if ($encoding eq "text/html" or $encoding eq "application/xhtml+xml") { 1; } else { 0; } } or $token->{"type"} == 5
@{$self->{'open_elements'};} $self->{'open_elements'}[-1][1] & 2048 $self->{"open_elements"}[-1][1] == 334848 and $token->{"type"} == 3 && $token->{"tag_name"} ne "mglyph" && $token->{"tag_name"} ne "malignmark" || $token->{"type"} == 6 $self->{"open_elements"}[-1][1] & 333825 and $token->{"type"} == 3 and $token->{"tag_name"} eq "svg" $self->{"open_elements"}[-1][1] == 338944 and $token->{"type"} == 3 || $token->{"type"} == 6 $self->{"open_elements"}[-1][1] == 333825 and $token->{"type"} == 3 || $token->{"type"} == 6 and do { my $encoding = $self->{"open_elements"}[-1][0]->getAttributeNS(undef, "encoding") || ""; $encoding =~ tr/A-Z/a-z/; if ($encoding eq "text/html" or $encoding eq "application/xhtml+xml") { 1; } else { 0; } } $token->{"type"} == 5
Truth table0%0/8
not(A && B) or C or D or E or F or G
A= @{$self->{'open_elements'};}B= $self->{'open_elements'}[-1][1] & 2048C= $self->{"open_elements"}[-1][1] == 334848 and $token->{"type"} == 3 && $token->{"tag_name"} ne "mglyph" && $token->{"tag_name"} ne "malignmark" || $token->{"type"} == 6D= $self->{"open_elements"}[-1][1] & 333825 and $token->{"type"} == 3 and $token->{"tag_name"} eq "svg"E= $self->{"open_elements"}[-1][1] == 338944 and $token->{"type"} == 3 || $token->{"type"} == 6F= $self->{"open_elements"}[-1][1] == 333825 and $token->{"type"} == 3 || $token->{"type"} == 6 and do { my $encoding = $self->{"open_elements"}[-1][0]->getAttributeNS(undef, "encoding") || ""; $encoding =~ tr/A-Z/a-z/; if ($encoding eq "text/html" or $encoding eq "application/xhtml+xml") { 1; } else { 0; } }G= $token->{"type"} == 5
ABCDEFGresult
0XXXXXX1
10XXXXX1
111XXXX1
1101XXX1
11001XX1
110001X1
11000011
11000000
2135 5216 ▶ (not @{$self->{open_elements}}) or
Condition93%31/33
$self->{"open_elements"}[-1][1] == 334848 and $token->{"type"} == 3 && $token->{"tag_name"} ne "mglyph" && $token->{"tag_name"} ne "malignmark" || $token->{"type"} == 6
!ll&&!rl&&r
308416
$token->{"type"} == 3 and $token->{"tag_name"} ne "mglyph" and $token->{"tag_name"} ne "malignmark" or $token->{"type"} == 6
l!l&&r!l&&!r
18425
$token->{"type"} == 3 and $token->{"tag_name"} ne "mglyph" and $token->{"tag_name"} ne "malignmark"
!ll&&!rl&&r
24518
$token->{"type"} == 3 and $token->{"tag_name"} ne "mglyph"
!ll&&!rl&&r
19523
$self->{"open_elements"}[-1][1] & 333825 and $token->{"type"} == 3 and $token->{"tag_name"} eq "svg"
!ll&&!rl&&r
1601667
$self->{"open_elements"}[-1][1] & 333825 and $token->{"type"} == 3
!ll&&!rl&&r
0160173
$self->{"open_elements"}[-1][1] == 338944 and $token->{"type"} == 3 || $token->{"type"} == 6
!ll&&!rl&&r
286355
$token->{"type"} == 3 or $token->{"type"} == 6
l!l&&r!l&&!r
27310
$self->{"open_elements"}[-1][1] == 333825 and $token->{"type"} == 3 || $token->{"type"} == 6 and do { my $encoding = $self->{"open_elements"}[-1][0]->getAttributeNS(undef, "encoding") || ""; $encoding =~ tr/A-Z/a-z/; if ($encoding eq "text/html" or $encoding eq "application/xhtml+xml") { 1; } else { 0; } }
!ll&&!rl&&r
28934
$self->{"open_elements"}[-1][1] == 333825 and $token->{"type"} == 3 || $token->{"type"} == 6
!ll&&!rl&&r
28457
$token->{"type"} == 3 or $token->{"type"} == 6
l!l&&r!l&&!r
705
MC/DC0%0/5
$self->{"open_elements"}[-1][1] == 334848 and $token->{"type"} == 3 && $token->{"tag_name"} ne "mglyph" && $token->{"tag_name"} ne "malignmark" || $token->{"type"} == 6
$self->{"open_elements"}[-1][1] == 334848 $token->{"type"} == 3 $token->{"tag_name"} ne "mglyph" $token->{"tag_name"} ne "malignmark" $token->{"type"} == 6
MC/DC0%0/3
$self->{"open_elements"}[-1][1] & 333825 and $token->{"type"} == 3 and $token->{"tag_name"} eq "svg"
$self->{"open_elements"}[-1][1] & 333825 $token->{"type"} == 3 $token->{"tag_name"} eq "svg"
MC/DC0%0/3
$self->{"open_elements"}[-1][1] == 338944 and $token->{"type"} == 3 || $token->{"type"} == 6
$self->{"open_elements"}[-1][1] == 338944 $token->{"type"} == 3 $token->{"type"} == 6
MC/DC0%0/4
$self->{"open_elements"}[-1][1] == 333825 and $token->{"type"} == 3 || $token->{"type"} == 6 and do { my $encoding = $self->{"open_elements"}[-1][0]->getAttributeNS(undef, "encoding") || ""; $encoding =~ tr/A-Z/a-z/; if ($encoding eq "text/html" or $encoding eq "application/xhtml+xml") { 1; } else { 0; } }
$self->{"open_elements"}[-1][1] == 333825 $token->{"type"} == 3 $token->{"type"} == 6 do { my $encoding = $self->{"open_elements"}[-1][0]->getAttributeNS(undef, "encoding") || ""; $encoding =~ tr/A-Z/a-z/; if ($encoding eq "text/html" or $encoding eq "application/xhtml+xml") { 1; } else { 0; } }
Truth table0%0/8
A and B and C and D or E
A= $self->{"open_elements"}[-1][1] == 334848B= $token->{"type"} == 3C= $token->{"tag_name"} ne "mglyph"D= $token->{"tag_name"} ne "malignmark"E= $token->{"type"} == 6
ABCDEresult
0XXXX0
10XX00
110X00
111000
1111X1
10XX11
110X11
111011
Truth table0%0/4
A and B and C
A= $self->{"open_elements"}[-1][1] & 333825B= $token->{"type"} == 3C= $token->{"tag_name"} eq "svg"
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/4
A and B or C
A= $self->{"open_elements"}[-1][1] == 338944B= $token->{"type"} == 3C= $token->{"type"} == 6
ABCresult
0XX0
1000
11X1
1011
Truth table0%0/6
A and B or C and D
A= $self->{"open_elements"}[-1][1] == 333825B= $token->{"type"} == 3C= $token->{"type"} == 6D= do { my $encoding = $self->{"open_elements"}[-1][0]->getAttributeNS(undef, "encoding") || ""; $encoding =~ tr/A-Z/a-z/; if ($encoding eq "text/html" or $encoding eq "application/xhtml+xml") { 1; } else { 0; } }
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
2136 (not $self->{open_elements}->[-1]->[1] & FOREIGN_EL) or ## HTML element
2137 ($self->{open_elements}->[-1]->[1] == MML_TEXT_INTEGRATION_EL and
2138 (($token->{type} == START_TAG_TOKEN and
2139 $token->{tag_name} ne 'mglyph' and
2140 $token->{tag_name} ne 'malignmark') or
2141 $token->{type} == CHARACTER_TOKEN)) or
2142 ($self->{open_elements}->[-1]->[1] & MML_AXML_EL and
2143 $token->{type} == START_TAG_TOKEN and
2144 $token->{tag_name} eq 'svg') or
2145 ( ## If the current node is an HTML integration point (other
2146 ## than |annotation-xml|).
2147 $self->{open_elements}->[-1]->[1] == SVG_INTEGRATION_EL and
2148 ($token->{type} == START_TAG_TOKEN or
2149 $token->{type} == CHARACTER_TOKEN)) or
2150 ( ## If the current node is an |annotation-xml| whose |encoding|
2151 ## is |text/html| or |application/xhtml+xml| (HTML integration
2152 ## point).
2153 $self->{open_elements}->[-1]->[1] == MML_AXML_EL and
2154 ($token->{type} == START_TAG_TOKEN or
2155 $token->{type} == CHARACTER_TOKEN) and
2156 do {
2157 7 ▶ my $encoding = $self->{open_elements}->[-1]->[0]->getAttributeNS(undef, 'encoding') || '';
Condition100%2/2
$self->{'open_elements'}[-1][0]->getAttributeNS(undef, 'encoding') || ''
l!l
61
MC/DC100%1/1
$self->{'open_elements'}[-1][0]->getAttributeNS(undef, 'encoding') || ''
$self->{'open_elements'}[-1][0]->getAttributeNS(undef, 'encoding')
Truth table100%2/2
A
A= $self->{'open_elements'}[-1][0]->getAttributeNS(undef, 'encoding')
Aresult
11
00
2158 7 $encoding =~ tr/A-Z/a-z/; ## ASCII case-insensitive.
2159 7 ▶ if ($encoding eq 'text/html' or
Branch: 1 branch
BranchTrueFalseTotal
if ($encoding eq 'text/html' or $encoding eq 'application/xhtml+xml') { } 4 3 7
Condition100%3/3
$encoding eq "text/html" or $encoding eq "application/xhtml+xml"
l!l&&r!l&&!r
223
MC/DC100%2/2
$encoding eq "text/html" or $encoding eq "application/xhtml+xml"
$encoding eq "text/html" $encoding eq "application/xhtml+xml"
Truth table100%3/3
A or B
A= $encoding eq "text/html"B= $encoding eq "application/xhtml+xml"
ABresult
1X1
011
000
2160 $encoding eq 'application/xhtml+xml') {
2161 4 1;
2162 } else {
2163 3 0;
2164 }
2165 }) or
2166 ($token->{type} == END_OF_FILE_TOKEN)) {
2167
2168 ## Use the rules for the current insertion mode in HTML content.
2169 #
2170 } else {
2171 ## Use the rules for the foreign content.
2172 269 ▶ if ($token->{type} == CHARACTER_TOKEN) {
Branch: 5 branches
BranchTrueFalseTotal
if ($token->{'type'} == 6) { } 31 238 269
elsif ($token->{'type'} == 3) { } 135 103 238
elsif ($token->{'type'} == 4) { } 103 0 103
elsif ($token->{'type'} == 2) { } 0 0 0
elsif ($token->{'type'} == 1) { } 0 0 0
2173 ## "In foreign content", character tokens.
2174 31 my $data = $token->{data};
2175 31 ▶ while ($data =~ s/\x00/\x{FFFD}/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/\x00/\x{fffd}/) 0 31 31
2176 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'NULL', token => $token);
2177 }
2178 31 $self->{open_elements}->[-1]->[0]->appendTextFromUnicode($self, $data, $token);
2179 31 ▶ if ($data =~ /[^\x09\x0A\x0C\x0D\x20]/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ /[^\x09\x0A\x0C\x0D\x20]/) 30 1 31
2180 30 delete $self->{frameset_ok};
2181 }
2182
2183 31 $token = $self->_get_next_token;
2184 31 next B;
2185 } elsif ($token->{type} == START_TAG_TOKEN) {
2186 ## "In foreign content", start tag token.
2187  
2188 135 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ({'b', 1, 'big', 1, 'blockquote', 1, 'body', 1, 'br', 1, 'center', 1, 'code', 1, 'dd', 1, 'div', 1, 'dl', 1, 'dt', 1, 'em', 1, 'embed', 1, 'h1', 1, 'h2', 1, 'h3', 1, 'h4', 1, 'h5', 1, 'h6', 1, 'head', 1, 'hr', 1, 'i', 1, 'img', 1, 'li', 1, 'listing', 1, 'menu', 1, 'meta', 1, 'nobr', 1, 'ol', 1, 'p', 1, 'pre', 1, 'ruby', 1, 's', 1, 'small', 1, 'span', 1, 'strong', 1, 'strike', 1, 'sub', 1, 'sup', 1, 'table', 1, 'tt', 1, 'u', 1, 'ul', 1, 'var', 1}->{$token->{'tag_name'}} or $token->{'tag_name'} eq 'font' and $token->{'attributes'}{'color'} || $token->{'attributes'}{'face'} || $token->{'attributes'}{'size'}) { } 11 124 135
Condition25%3/12
{"b", 1, "big", 1, "blockquote", 1, "body", 1, "br", 1, "center", 1, "code", 1, "dd", 1, "div", 1, "dl", 1, "dt", 1, "em", 1, "embed", 1, "h1", 1, "h2", 1, "h3", 1, "h4", 1, "h5", 1, "h6", 1, "head", 1, "hr", 1, "i", 1, "img", 1, "li", 1, "listing", 1, "menu", 1, "meta", 1, "nobr", 1, "ol", 1, "p", 1, "pre", 1, "ruby", 1, "s", 1, "small", 1, "span", 1, "strong", 1, "strike", 1, "sub", 1, "sup", 1, "table", 1, "tt", 1, "u", 1, "ul", 1, "var", 1}->{$token->{"tag_name"}} or $token->{"tag_name"} eq "font" and $token->{"attributes"}{"color"} || $token->{"attributes"}{"face"} || $token->{"attributes"}{"size"}
l!l&&r!l&&!r
110124
$token->{"tag_name"} eq "font" and $token->{"attributes"}{"color"} || $token->{"attributes"}{"face"} || $token->{"attributes"}{"size"}
!ll&&!rl&&r
12400
$token->{"attributes"}{"color"} or $token->{"attributes"}{"face"} or $token->{"attributes"}{"size"}
l!l&&r!l&&!r
000
$token->{"attributes"}{"color"} or $token->{"attributes"}{"face"}
l!l&&r!l&&!r
000
MC/DC20%1/5
{"b", 1, "big", 1, "blockquote", 1, "body", 1, "br", 1, "center", 1, "code", 1, "dd", 1, "div", 1, "dl", 1, "dt", 1, "em", 1, "embed", 1, "h1", 1, "h2", 1, "h3", 1, "h4", 1, "h5", 1, "h6", 1, "head", 1, "hr", 1, "i", 1, "img", 1, "li", 1, "listing", 1, "menu", 1, "meta", 1, "nobr", 1, "ol", 1, "p", 1, "pre", 1, "ruby", 1, "s", 1, "small", 1, "span", 1, "strong", 1, "strike", 1, "sub", 1, "sup", 1, "table", 1, "tt", 1, "u", 1, "ul", 1, "var", 1}->{$token->{"tag_name"}} or $token->{"tag_name"} eq "font" and $token->{"attributes"}{"color"} || $token->{"attributes"}{"face"} || $token->{"attributes"}{"size"}
{"b", 1, "big", 1, "blockquote", 1, "body", 1, "br", 1, "center", 1, "code", 1, "dd", 1, "div", 1, "dl", 1, "dt", 1, "em", 1, "embed", 1, "h1", 1, "h2", 1, "h3", 1, "h4", 1, "h5", 1, "h6", 1, "head", 1, "hr", 1, "i", 1, "img", 1, "li", 1, "listing", 1, "menu", 1, "meta", 1, "nobr", 1, "ol", 1, "p", 1, "pre", 1, "ruby", 1, "s", 1, "small", 1, "span", 1, "strong", 1, "strike", 1, "sub", 1, "sup", 1, "table", 1, "tt", 1, "u", 1, "ul", 1, "var", 1}->{$token->{"tag_name"}} $token->{"tag_name"} eq "font" $token->{"attributes"}{"color"} $token->{"attributes"}{"face"} $token->{"attributes"}{"size"}
Truth table33%2/6
A or B and C or D or E
A= {"b", 1, "big", 1, "blockquote", 1, "body", 1, "br", 1, "center", 1, "code", 1, "dd", 1, "div", 1, "dl", 1, "dt", 1, "em", 1, "embed", 1, "h1", 1, "h2", 1, "h3", 1, "h4", 1, "h5", 1, "h6", 1, "head", 1, "hr", 1, "i", 1, "img", 1, "li", 1, "listing", 1, "menu", 1, "meta", 1, "nobr", 1, "ol", 1, "p", 1, "pre", 1, "ruby", 1, "s", 1, "small", 1, "span", 1, "strong", 1, "strike", 1, "sub", 1, "sup", 1, "table", 1, "tt", 1, "u", 1, "ul", 1, "var", 1}->{$token->{"tag_name"}}B= $token->{"tag_name"} eq "font"C= $token->{"attributes"}{"color"}D= $token->{"attributes"}{"face"}E= $token->{"attributes"}{"size"}
ABCDEresult
1XXXX1
011XX1
0101X1
010011
00XXX0
010000
2189 {
2190 b => 1, big => 1, blockquote => 1, body => 1, br => 1,
2191 center => 1, code => 1, dd => 1, div => 1, dl => 1, dt => 1,
2192 em => 1, embed => 1, h1 => 1, h2 => 1, h3 => 1, h4 => 1,
2193 h5 => 1, h6 => 1, head => 1, hr => 1, i => 1, img => 1, li => 1,
2194 listing => 1, menu => 1, meta => 1, nobr => 1, ol => 1,
2195 p => 1, pre => 1, ruby => 1, s => 1, small => 1, span => 1,
2196 strong => 1, strike => 1, sub => 1, sup => 1, table => 1,
2197 tt => 1, u => 1, ul => 1, var => 1,
2198 }->{$token->{tag_name}} or
2199 ($token->{tag_name} eq 'font' and
2200 ($token->{attributes}->{color} or
2201 $token->{attributes}->{face} or
2202 $token->{attributes}->{size}))
2203 ) {
2204
2205 ## "In foreign content", HTML-only start tag.
2206 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
2207 11 text => $self->{open_elements}->[-1]->[0]
2208 ->localname,
2209 token => $token);
2210  
2211 11 pop @{$self->{open_elements}};
2212 V: {
2213 11 my $current_node = $self->{open_elements}->[-1];
2214 14 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if (not $current_node->[1] & 2048 or $current_node->[1] == 334848 or $current_node->[1] == 338944 or $current_node->[1] == 333825 and do { my $encoding = $current_node->[0]->getAttributeNS(undef, "encoding") || ""; $encoding =~ tr/A-Z/a-z/; $encoding eq "text/html" or $encoding eq "application/xhtml+xml" }) 2 3 5
Condition66%8/12
not $current_node->[1] & 2048 or $current_node->[1] == 334848 or $current_node->[1] == 338944 or $current_node->[1] == 333825 and do { my $encoding = $current_node->[0]->getAttributeNS(undef, "encoding") || ""; $encoding =~ tr/A-Z/a-z/; $encoding eq "text/html" or $encoding eq "application/xhtml+xml" }
l!l&&r!l&&!r
1103
not $current_node->[1] & 2048 or $current_node->[1] == 334848 or $current_node->[1] == 338944
l!l&&r!l&&!r
923
not $current_node->[1] & 2048 or $current_node->[1] == 334848
l!l&&r!l&&!r
905
$current_node->[1] == 333825 and do { my $encoding = $current_node->[0]->getAttributeNS(undef, "encoding") || ""; $encoding =~ tr/A-Z/a-z/; $encoding eq "text/html" or $encoding eq "application/xhtml+xml" }
!ll&&!rl&&r
300
MC/DC0%0/5
not $current_node->[1] & 2048 or $current_node->[1] == 334848 or $current_node->[1] == 338944 or $current_node->[1] == 333825 and do { my $encoding = $current_node->[0]->getAttributeNS(undef, "encoding") || ""; $encoding =~ tr/A-Z/a-z/; $encoding eq "text/html" or $encoding eq "application/xhtml+xml" }
not $current_node->[1] & 2048 $current_node->[1] == 334848 $current_node->[1] == 338944 $current_node->[1] == 333825 do { my $encoding = $current_node->[0]->getAttributeNS(undef, "encoding") || ""; $encoding =~ tr/A-Z/a-z/; $encoding eq "text/html" or $encoding eq "application/xhtml+xml" }
Truth table33%2/6
not(A) or B or C or D and E
A= not $current_node->[1] & 2048B= $current_node->[1] == 334848C= $current_node->[1] == 338944D= $current_node->[1] == 333825E= do { my $encoding = $current_node->[0]->getAttributeNS(undef, "encoding") || ""; $encoding =~ tr/A-Z/a-z/; $encoding eq "text/html" or $encoding eq "application/xhtml+xml" }
ABCDEresult
1XXXX1
01XXX1
001XX1
000111
0000X0
000100
2215 ## An HTML element.
2216 not $current_node->[1] & FOREIGN_EL or
2217  
2218 ## An MathML text integration point.
2219 $current_node->[1] == MML_TEXT_INTEGRATION_EL or
2220
2221 ## An HTML integration point.
2222 $current_node->[1] == SVG_INTEGRATION_EL or
2223 ($current_node->[1] == MML_AXML_EL and
2224 do {
2225 0 ▶ my $encoding = $current_node->[0]->getAttributeNS(undef, 'encoding') || '';
Condition0%0/2
$current_node->[0]->getAttributeNS(undef, 'encoding') || ''
l!l
00
MC/DC0%0/1
$current_node->[0]->getAttributeNS(undef, 'encoding') || ''
$current_node->[0]->getAttributeNS(undef, 'encoding')
Truth table0%0/2
A
A= $current_node->[0]->getAttributeNS(undef, 'encoding')
Aresult
11
00
2226 0 $encoding =~ tr/A-Z/a-z/; ## ASCII case-insensitive.
2227 0 ▶ ($encoding eq 'text/html' or
Branch: 1 branch
BranchTrueFalseTotal
$encoding eq "text/html" or $encoding eq "application/xhtml+xml" 0 0 0
2228 $encoding eq 'application/xhtml+xml');
2229 })
2230 ) {
2231 11 last V;
2232 }
2233
2234 3 pop @{$self->{open_elements}};
2235 3 redo V;
2236 }
2237
2238 ## Reprocess the token.
2239 11 next B;
2240  
2241 } else {
2242 ## "In foreign content", foreign start tag.
2243 124 my $nsuri = $self->{open_elements}->[-1]->[0]->namespaceURI;
2244 124 my $tag_name = $token->{tag_name};
2245 124 ▶ if ($nsuri eq (SVG_NS)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nsuri eq "http://www.w3.org/2000/svg") 67 57 124
2246 $tag_name = {
2247 altglyph => 'altGlyph',
2248 altglyphdef => 'altGlyphDef',
2249 altglyphitem => 'altGlyphItem',
2250 animatecolor => 'animateColor',
2251 animatemotion => 'animateMotion',
2252 animatetransform => 'animateTransform',
2253 clippath => 'clipPath',
2254 feblend => 'feBlend',
2255 fecolormatrix => 'feColorMatrix',
2256 fecomponenttransfer => 'feComponentTransfer',
2257 fecomposite => 'feComposite',
2258 feconvolvematrix => 'feConvolveMatrix',
2259 fediffuselighting => 'feDiffuseLighting',
2260 fedisplacementmap => 'feDisplacementMap',
2261 fedistantlight => 'feDistantLight',
2262 feflood => 'feFlood',
2263 fefunca => 'feFuncA',
2264 fefuncb => 'feFuncB',
2265 fefuncg => 'feFuncG',
2266 fefuncr => 'feFuncR',
2267 fegaussianblur => 'feGaussianBlur',
2268 feimage => 'feImage',
2269 femerge => 'feMerge',
2270 femergenode => 'feMergeNode',
2271 femorphology => 'feMorphology',
2272 feoffset => 'feOffset',
2273 fepointlight => 'fePointLight',
2274 fespecularlighting => 'feSpecularLighting',
2275 fespotlight => 'feSpotLight',
2276 fetile => 'feTile',
2277 feturbulence => 'feTurbulence',
2278 foreignobject => 'foreignObject',
2279 glyphref => 'glyphRef',
2280 lineargradient => 'linearGradient',
2281 radialgradient => 'radialGradient',
2282 #solidcolor => 'solidColor', ## NOTE: Commented in spec (SVG1.2)
2283 textpath => 'textPath',
2284 67 ▶ }->{$tag_name} || $tag_name;
Condition66%2/3
{'altglyph', 'altGlyph', 'altglyphdef', 'altGlyphDef', 'altglyphitem', 'altGlyphItem', 'animatecolor', 'animateColor', 'animatemotion', 'animateMotion', 'animatetransform', 'animateTransform', 'clippath', 'clipPath', 'feblend', 'feBlend', 'fecolormatrix', 'feColorMatrix', 'fecomponenttransfer', 'feComponentTransfer', 'fecomposite', 'feComposite', 'feconvolvematrix', 'feConvolveMatrix', 'fediffuselighting', 'feDiffuseLighting', 'fedisplacementmap', 'feDisplacementMap', 'fedistantlight', 'feDistantLight', 'feflood', 'feFlood', 'fefunca', 'feFuncA', 'fefuncb', 'feFuncB', 'fefuncg', 'feFuncG', 'fefuncr', 'feFuncR', 'fegaussianblur', 'feGaussianBlur', 'feimage', 'feImage', 'femerge', 'feMerge', 'femergenode', 'feMergeNode', 'femorphology', 'feMorphology', 'feoffset', 'feOffset', 'fepointlight', 'fePointLight', 'fespecularlighting', 'feSpecularLighting', 'fespotlight', 'feSpotLight', 'fetile', 'feTile', 'feturbulence', 'feTurbulence', 'foreignobject', 'foreignObject', 'glyphref', 'glyphRef', 'lineargradient', 'linearGradient', 'radialgradient', 'radialGradient', 'textpath', 'textPath'}->{$tag_name} || $tag_name
l!l&&r!l&&!r
12550
MC/DC0%0/2
{'altglyph', 'altGlyph', 'altglyphdef', 'altGlyphDef', 'altglyphitem', 'altGlyphItem', 'animatecolor', 'animateColor', 'animatemotion', 'animateMotion', 'animatetransform', 'animateTransform', 'clippath', 'clipPath', 'feblend', 'feBlend', 'fecolormatrix', 'feColorMatrix', 'fecomponenttransfer', 'feComponentTransfer', 'fecomposite', 'feComposite', 'feconvolvematrix', 'feConvolveMatrix', 'fediffuselighting', 'feDiffuseLighting', 'fedisplacementmap', 'feDisplacementMap', 'fedistantlight', 'feDistantLight', 'feflood', 'feFlood', 'fefunca', 'feFuncA', 'fefuncb', 'feFuncB', 'fefuncg', 'feFuncG', 'fefuncr', 'feFuncR', 'fegaussianblur', 'feGaussianBlur', 'feimage', 'feImage', 'femerge', 'feMerge', 'femergenode', 'feMergeNode', 'femorphology', 'feMorphology', 'feoffset', 'feOffset', 'fepointlight', 'fePointLight', 'fespecularlighting', 'feSpecularLighting', 'fespotlight', 'feSpotLight', 'fetile', 'feTile', 'feturbulence', 'feTurbulence', 'foreignobject', 'foreignObject', 'glyphref', 'glyphRef', 'lineargradient', 'linearGradient', 'radialgradient', 'radialGradient', 'textpath', 'textPath'}->{$tag_name} || $tag_name
{'altglyph', 'altGlyph', 'altglyphdef', 'altGlyphDef', 'altglyphitem', 'altGlyphItem', 'animatecolor', 'animateColor', 'animatemotion', 'animateMotion', 'animatetransform', 'animateTransform', 'clippath', 'clipPath', 'feblend', 'feBlend', 'fecolormatrix', 'feColorMatrix', 'fecomponenttransfer', 'feComponentTransfer', 'fecomposite', 'feComposite', 'feconvolvematrix', 'feConvolveMatrix', 'fediffuselighting', 'feDiffuseLighting', 'fedisplacementmap', 'feDisplacementMap', 'fedistantlight', 'feDistantLight', 'feflood', 'feFlood', 'fefunca', 'feFuncA', 'fefuncb', 'feFuncB', 'fefuncg', 'feFuncG', 'fefuncr', 'feFuncR', 'fegaussianblur', 'feGaussianBlur', 'feimage', 'feImage', 'femerge', 'feMerge', 'femergenode', 'feMergeNode', 'femorphology', 'feMorphology', 'feoffset', 'feOffset', 'fepointlight', 'fePointLight', 'fespecularlighting', 'feSpecularLighting', 'fespotlight', 'feSpotLight', 'fetile', 'feTile', 'feturbulence', 'feTurbulence', 'foreignobject', 'foreignObject', 'glyphref', 'glyphRef', 'lineargradient', 'linearGradient', 'radialgradient', 'radialGradient', 'textpath', 'textPath'}->{$tag_name} $tag_name
Truth table66%2/3
A || B
A= {'altglyph', 'altGlyph', 'altglyphdef', 'altGlyphDef', 'altglyphitem', 'altGlyphItem', 'animatecolor', 'animateColor', 'animatemotion', 'animateMotion', 'animatetransform', 'animateTransform', 'clippath', 'clipPath', 'feblend', 'feBlend', 'fecolormatrix', 'feColorMatrix', 'fecomponenttransfer', 'feComponentTransfer', 'fecomposite', 'feComposite', 'feconvolvematrix', 'feConvolveMatrix', 'fediffuselighting', 'feDiffuseLighting', 'fedisplacementmap', 'feDisplacementMap', 'fedistantlight', 'feDistantLight', 'feflood', 'feFlood', 'fefunca', 'feFuncA', 'fefuncb', 'feFuncB', 'fefuncg', 'feFuncG', 'fefuncr', 'feFuncR', 'fegaussianblur', 'feGaussianBlur', 'feimage', 'feImage', 'femerge', 'feMerge', 'femergenode', 'feMergeNode', 'femorphology', 'feMorphology', 'feoffset', 'feOffset', 'fepointlight', 'fePointLight', 'fespecularlighting', 'feSpecularLighting', 'fespotlight', 'feSpotLight', 'fetile', 'feTile', 'feturbulence', 'feTurbulence', 'foreignobject', 'foreignObject', 'glyphref', 'glyphRef', 'lineargradient', 'linearGradient', 'radialgradient', 'radialGradient', 'textpath', 'textPath'}->{$tag_name}B= $tag_name
ABresult
1X1
011
000
2285 }
2286  
2287 ## "adjust SVG attributes" (SVG only) - done in insert-element-f
2288  
2289 ## "adjust foreign attributes" - done in insert-element-f
2290  
2291
2292 {
2293 124 my $el;
2294
2295 124 $el = $self->{document}->createElementNS($nsuri, $tag_name);
2296
2297 124 for my $attr_name (keys %{ $token->{attributes}}) {
2298 13 my $attr_t = $token->{attributes}->{$attr_name};
2299 13 my $attr;
2300 13 ▶ if (defined $foreign_attr_xname->{ $attr_name })
Branch: 4 branches
BranchTrueFalseTotal
if (defined $foreign_attr_xname->{$attr_name}) { } 6 7 13
elsif ($nsuri eq 'http://www.w3.org/1998/Math/MathML' and $attr_name eq 'definitionurl') { } 1 6 7
elsif ($nsuri eq 'http://www.w3.org/1998/Math/MathML') { } 6 0 6
elsif ($nsuri eq 'http://www.w3.org/2000/svg') { } 0 0 0
2301 {
2302 6 my $xmlnsuri = $foreign_attr_xname->{ $attr_name }->[0];
2303 6 my $qname = join ':', @{$foreign_attr_xname->{ $attr_name }->[1]};
2304 6 $qname =~ s/(^:)|(:$)//;
2305 6 $attr = $self->{document}->createAttributeNS($xmlnsuri, $qname);
2306 }
2307 ▶ elsif ($nsuri eq (MML_NS) && $attr_name eq 'definitionurl')
Condition66%2/3
$nsuri eq "http://www.w3.org/1998/Math/MathML" and $attr_name eq "definitionurl"
!ll&&!rl&&r
061
MC/DC50%1/2
$nsuri eq "http://www.w3.org/1998/Math/MathML" and $attr_name eq "definitionurl"
$nsuri eq "http://www.w3.org/1998/Math/MathML" $attr_name eq "definitionurl"
Truth table66%2/3
A and B
A= $nsuri eq "http://www.w3.org/1998/Math/MathML"B= $attr_name eq "definitionurl"
ABresult
0X0
100
111
2308 {
2309 1 $attr = $self->{document}->createAttributeNS((MML_NS), 'math:definitionURL');
2310 }
2311 elsif ($nsuri eq (MML_NS) )
2312 {
2313 6 $attr = $self->{document}->createAttributeNS((MML_NS), "math:$attr_name");
2314 }
2315 elsif ($nsuri eq (SVG_NS) )
2316 {
2317 $attr = $self->{document}->createAttributeNS(
2318 0 ▶ (SVG_NS), "svg:".($svg_attr_name->{$attr_name} || $attr_name));
Condition0%0/3
$svg_attr_name->{$attr_name} || $attr_name
l!l&&r!l&&!r
000
MC/DC0%0/2
$svg_attr_name->{$attr_name} || $attr_name
$svg_attr_name->{$attr_name} $attr_name
Truth table0%0/3
A || B
A= $svg_attr_name->{$attr_name}B= $attr_name
ABresult
1X1
011
000
2319 }
2320 13 ▶ unless (defined $attr)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $attr) 0 13 13
2321 {
2322 0 $attr = $self->{document}->createAttributeNS($nsuri, $attr_name);
2323 }
2324 13 ▶ unless (defined $attr)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $attr) 0 13 13
2325 {
2326 0 $attr = $self->{document}->createAttribute($attr_name);
2327 }
2328 13 ▶ if ($attr)
Branch: 1 branch
BranchTrueFalseTotal
if ($attr) 13 0 13
2329 {
2330 13 $attr->setValue($attr_t->{value});
2331 13 $self->_data($attr, manakai_source_line => $attr_t->{line});
2332 13 $self->_data($attr, manakai_source_column => $attr_t->{column});
2333 13 $el->setAttributeNodeNS($attr);
2334 }
2335 }
2336
2337 $self->_data($el, manakai_source_line => $token->{line})
2338 124 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 124 0 124
2339 $self->_data($el, manakai_source_column => $token->{column})
2340 124 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 124 0 124
2341
2342 124 $insert->($self, $el, $open_tables);
2343 124 ▶ push @{$self->{open_elements}}, [$el, ($el_category_f->{$nsuri}->{ $tag_name} || 0) | FOREIGN_EL | (($nsuri) eq SVG_NS ? SVG_EL : ($nsuri) eq MML_NS ? MML_EL : 0)];
Branch: 2 branches
BranchTrueFalseTotal
$nsuri eq 'http://www.w3.org/2000/svg' ? : 67 57 124
$nsuri eq 'http://www.w3.org/1998/Math/MathML' ? : 57 0 57
Condition100%2/2
$el_category_f->{$nsuri}{$tag_name} || 0
l!l
7054
MC/DC100%1/1
$el_category_f->{$nsuri}{$tag_name} || 0
$el_category_f->{$nsuri}{$tag_name}
Truth table100%2/2
A
A= $el_category_f->{$nsuri}{$tag_name}
Aresult
11
00
2344
2345 124 ▶ if ( $token->{attributes}->{xmlns} and $token->{attributes}->{xmlns}->{value} ne ($nsuri)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"attributes"}{"xmlns"} and $token->{"attributes"}{"xmlns"}{"value"} ne $nsuri) 0 124 124
Condition33%1/3
$token->{"attributes"}{"xmlns"} and $token->{"attributes"}{"xmlns"}{"value"} ne $nsuri
!ll&&!rl&&r
12400
MC/DC0%0/2
$token->{"attributes"}{"xmlns"} and $token->{"attributes"}{"xmlns"}{"value"} ne $nsuri
$token->{"attributes"}{"xmlns"} $token->{"attributes"}{"xmlns"}{"value"} ne $nsuri
Truth table33%1/3
A and B
A= $token->{"attributes"}{"xmlns"}B= $token->{"attributes"}{"xmlns"}{"value"} ne $nsuri
ABresult
0X0
100
111
2346 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'bad namespace', token => $token);
2347 ## TODO: Error type documentation
2348 }
2349 124 ▶ if ( $token->{attributes}->{'xmlns:xlink'} and
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"attributes"}{"xmlns:xlink"} and $token->{"attributes"}{"xmlns:xlink"}{"value"} ne "http://www.w3.org/1999/xlink") 0 124 124
Condition33%1/3
$token->{"attributes"}{"xmlns:xlink"} and $token->{"attributes"}{"xmlns:xlink"}{"value"} ne "http://www.w3.org/1999/xlink"
!ll&&!rl&&r
12400
MC/DC0%0/2
$token->{"attributes"}{"xmlns:xlink"} and $token->{"attributes"}{"xmlns:xlink"}{"value"} ne "http://www.w3.org/1999/xlink"
$token->{"attributes"}{"xmlns:xlink"} $token->{"attributes"}{"xmlns:xlink"}{"value"} ne "http://www.w3.org/1999/xlink"
Truth table33%1/3
A and B
A= $token->{"attributes"}{"xmlns:xlink"}B= $token->{"attributes"}{"xmlns:xlink"}{"value"} ne "http://www.w3.org/1999/xlink"
ABresult
0X0
100
111
2350 $token->{attributes}->{'xmlns:xlink'}->{value} ne q<http://www.w3.org/1999/xlink>) {
2351 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'bad namespace', token => $token);
2352 }
2353 }
2354
2355  
2356 124 ▶ if ($self->{self_closing}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'self_closing'}) { } 2 122 124
2357 2 pop @{$self->{open_elements}};
2358 2 delete $self->{self_closing};
2359 } else {
2360
2361 }
2362  
2363 124 $token = $self->_get_next_token;
2364 124 next B;
2365 }
2366
2367 } elsif ($token->{type} == END_TAG_TOKEN) {
2368 ## "In foreign content", end tag.
2369
2370 103 ▶ if ($token->{tag_name} eq 'script' and
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'script' and $self->{'open_elements'}[-1][1] == 10245) { } 1 102 103
Condition66%2/3
$token->{"tag_name"} eq "script" and $self->{"open_elements"}[-1][1] == 10245
!ll&&!rl&&r
10201
MC/DC50%1/2
$token->{"tag_name"} eq "script" and $self->{"open_elements"}[-1][1] == 10245
$token->{"tag_name"} eq "script" $self->{"open_elements"}[-1][1] == 10245
Truth table66%2/3
A and B
A= $token->{"tag_name"} eq "script"B= $self->{"open_elements"}[-1][1] == 10245
ABresult
0X0
100
111
2371 $self->{open_elements}->[-1]->[1] == SVG_SCRIPT_EL) {
2372 ## "In foreign content", "script" end tag, if the current
2373 ## node is an SVG |script| element.
2374
2375 1 pop @{$self->{open_elements}};
2376
2377 ## XXXscript: Execute script here.
2378 1 $token = $self->_get_next_token;
2379 1 next B;
2380
2381 } else {
2382 ## "In foreign content", end tag.
2383
2384 ## 1.
2385 102 my $i = -1;
2386 102 my $node = $self->{open_elements}->[$i];
2387
2388 ## 2.
2389 102 my $tag_name = $node->[0]->localname;
2390 102 $tag_name =~ tr/A-Z/a-z/; ## ASCII case-insensitive.
2391 102 ▶ if ($tag_name ne $token->{tag_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag_name ne $token->{"tag_name"}) 14 88 102
2392 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
2393 text => $token->{tag_name},
2394 14 level => $self->{level}->{must});
2395 }
2396  
2397 ## 3.
2398 LOOP: {
2399 102 my $tag_name = $node->[0]->localname;
2400 112 $tag_name =~ tr/A-Z/a-z/; ## ASCII case-insensitive.
2401 112 ▶ if ($tag_name eq $token->{tag_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag_name eq $token->{"tag_name"}) 89 23 112
2402 89 splice @{$self->{open_elements}}, $i, -$i, ();
2403 89 $token = $self->_get_next_token;
2404 89 next B;
2405 }
2406
2407 ## 4.
2408 23 $i--;
2409 23 $node = $self->{open_elements}->[$i];
2410  
2411 ## 5.
2412 23 ▶ if ($node->[1] & FOREIGN_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->[1] & 2048) 10 13 23
2413 10 redo LOOP;
2414 }
2415 } # LOOP
2416  
2417 ## Step 6 (Use the current insertion mode in HTML content)
2418 #
2419 }
2420  
2421 } elsif ($token->{type} == COMMENT_TOKEN) {
2422 ## "In foreign content", comment token.
2423 0 my $comment = $self->{document}->createComment($token->{data});
2424 $self->_data($comment, manakai_source_line => $token->{line})
2425 0 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 0 0 0
2426 $self->_data($comment, manakai_source_column => $token->{column})
2427 0 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 0 0 0
2428 0 $self->{open_elements}->[-1]->[0]->appendChild ($comment);
2429 0 $token = $self->_get_next_token;
2430 0 next B;
2431 } elsif ($token->{type} == DOCTYPE_TOKEN) {
2432
2433 ## "In foreign content", DOCTYPE token.
2434 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in html:#DOCTYPE', token => $token);
2435 ## Ignore the token.
2436 0 $token = $self->_get_next_token;
2437 0 next B;
2438 } else {
2439 0 die "$0: $token->{type}: Unknown token type";
2440 }
2441 } # foreign
2442  
2443 ## The "in table text" insertion mode.
2444 4960 ▶ if ($self->{insertion_mode} & TABLE_IMS and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"insertion_mode"} & 64 and not $self->{"insertion_mode"} & 4096) 504 4456 4960
Condition100%3/3
$self->{"insertion_mode"} & 64 and not $self->{"insertion_mode"} & 4096
!ll&&!rl&&r
443620504
MC/DC100%2/2
$self->{"insertion_mode"} & 64 and not $self->{"insertion_mode"} & 4096
$self->{"insertion_mode"} & 64 not $self->{"insertion_mode"} & 4096
Truth table100%3/3
A and not(B)
A= $self->{"insertion_mode"} & 64B= not $self->{"insertion_mode"} & 4096
ABresult
0X0
100
111
2445 not $self->{insertion_mode} & IN_CDATA_RCDATA_IM) {
2446 C: {
2447 504 my $s;
2448 504 ▶ if ($token->{type} == CHARACTER_TOKEN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'type'} == 6) { } 104 400 504
2449
2450 104 ▶ $self->{pending_chars} ||= [];
Condition100%2/2
$self->{"pending_chars"} ||= []
l!l
4100
MC/DC100%1/1
$self->{"pending_chars"} ||= []
$self->{"pending_chars"}
Truth table100%2/2
A
A= $self->{"pending_chars"}
Aresult
11
00
2451 104 push @{$self->{pending_chars}}, $token;
2452 104 $token = $self->_get_next_token;
2453 104 next B;
2454 } else {
2455 ## There is an "insert pending chars" code clone.
2456 400 ▶ if ($self->{pending_chars}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'pending_chars'}) { } 100 300 400
2457 100 $s = join '', map { $_->{data} } @{$self->{pending_chars}};
2458 100 delete $self->{pending_chars};
2459 100 ▶ while ($s =~ s/\x00//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s =~ s/\x00//) 3 100 103
2460 3 $self->{parse_error}->(level => $self->{level}->{must}, type => 'NULL', token => $token);
2461 }
2462 100 ▶ if ($s eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if ($s eq '') { } 0 100 100
elsif ($s =~ /[^\x09\x0A\x0C\x0D\x20]/) { } 75 25 100
2463 0 last C;
2464 } elsif ($s =~ /[^\x09\x0A\x0C\x0D\x20]/) {
2465 #
2466 } else {
2467
2468 25 $self->{open_elements}->[-1]->[0]->appendTextFromUnicode($self, $s, $token);
2469 25 last C;
2470 }
2471 } else {
2472
2473 300 last C;
2474 }
2475 }
2476  
2477 ## "in table" insertion mode, "Anything else".
2478  
2479 ## Foster parenting.
2480 75 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in table:#text', token => $token);
2481  
2482 ## NOTE: As if in body, but insert into the foster parent element.
2483 75 $reconstruct_active_formatting_elements
2484 ->($self, $insert_to_foster, $active_formatting_elements,
2485 $open_tables);
2486
2487 75 ▶ if ($self->{open_elements}->[-1]->[1] & TABLE_ROWS_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] & 64) { } 25 50 75
2488 # MUST
2489 25 my $foster_parent_element;
2490 my $next_sibling;
2491 25 OE: for (reverse 0..$#{$self->{open_elements}}) {
2492 41 ▶ if ($self->{open_elements}->[$_]->[1] == TABLE_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[$_][1] == 328257) 25 16 41
2493
2494 25 $foster_parent_element = $self->{open_elements}->[$_ - 1]->[0];
2495 25 $next_sibling = $self->{open_elements}->[$_]->[0];
2496 25 ▶ undef $next_sibling
Branch: 1 branch
BranchTrueFalseTotal
unless $next_sibling->parentNode eq $foster_parent_element 0 25 25
2497 unless $next_sibling->parentNode eq $foster_parent_element;
2498 25 last OE;
2499 }
2500 } # OE
2501 25 ▶ $foster_parent_element ||= $self->{open_elements}->[0]->[0];
Condition33%1/3
$foster_parent_element ||= $self->{"open_elements"}[0][0]
l!l&&r!l&&!r
2500
MC/DC0%0/2
$foster_parent_element ||= $self->{"open_elements"}[0][0]
$foster_parent_element $self->{"open_elements"}[0][0]
Truth table33%1/3
A ||= B
A= $foster_parent_elementB= $self->{"open_elements"}[0][0]
ABresult
1X1
011
000
2502
2503 $foster_parent_element->insertBefore
2504 25 ($self->{document}->createTextNode($s), $next_sibling);
2505  
2506 25 $open_tables->[-1]->[1] = 1; # tainted
2507 25 $open_tables->[-1]->[2] = 1; # ~node inserted
2508 } else {
2509 ## NOTE: Fragment case or in a foster parent'ed element
2510 ## (e.g. |<table><span>a|). In fragment case, whether the
2511 ## character is appended to existing node or a new node is
2512 ## created is irrelevant, since the foster parent'ed nodes
2513 ## are discarded and fragment parsing does not invoke any
2514 ## script.
2515
2516 50 $self->{open_elements}->[-1]->[0]->appendTextFromUnicode($self, $s);
2517 }
2518 } # C
2519 } # TABLE_IMS
2520  
2521 4856 ▶ if ($token->{type} == DOCTYPE_TOKEN) {
Branch: 4 branches
BranchTrueFalseTotal
if ($token->{'type'} == 1) { } 2 4854 4856
elsif ($token->{'type'} == 3 and $token->{'tag_name'} eq 'html') { } 9 4845 4854
elsif ($token->{'type'} == 2) { } 43 4802 4845
elsif ($self->{'insertion_mode'} & 4096) { } 510 4292 4802
2522
2523 2 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in html:#DOCTYPE', token => $token);
2524 ## Ignore the token
2525 ## Stay in the phase
2526 2 $token = $self->_get_next_token;
2527 2 next B;
2528 ▶ } elsif ($token->{type} == START_TAG_TOKEN and
Condition100%3/3
$token->{"type"} == 3 and $token->{"tag_name"} eq "html"
!ll&&!rl&&r
290319429
MC/DC100%2/2
$token->{"type"} == 3 and $token->{"tag_name"} eq "html"
$token->{"type"} == 3 $token->{"tag_name"} eq "html"
Truth table100%3/3
A and B
A= $token->{"type"} == 3B= $token->{"tag_name"} eq "html"
ABresult
0X0
100
111
2529 $token->{tag_name} eq 'html') {
2530 9 ▶ if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 260) { } 1 8 9
elsif ($self->{'insertion_mode'} == 516) { } 1 7 8
2531
2532 1 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after html', text => 'html', token => $token);
2533 1 $self->{insertion_mode} = AFTER_BODY_IM;
2534 } elsif ($self->{insertion_mode} == AFTER_HTML_FRAMESET_IM) {
2535
2536 1 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after html', text => 'html', token => $token);
2537 1 $self->{insertion_mode} = AFTER_FRAMESET_IM;
2538 } else {
2539
2540 }
2541  
2542
2543 9 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not first start tag', token => $token);
2544 9 my $top_el = $self->{open_elements}->[0]->[0];
2545 9 for my $attr_name (keys %{$token->{attributes}}) {
2546 9 ▶ unless ($top_el->hasAttribute($attr_name)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($top_el->hasAttribute($attr_name)) 9 0 9
2547 $top_el->setAttribute
2548 ($attr_name,
2549 9 $token->{attributes}->{$attr_name}->{value});
2550 }
2551 }
2552
2553 9 $token = $self->_get_next_token;
2554 9 next B;
2555 } elsif ($token->{type} == COMMENT_TOKEN) {
2556 43 my $comment = $self->{document}->createComment ($token->{data});
2557 $self->_data($comment, manakai_source_line => $token->{line})
2558 43 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 43 0 43
2559 $self->_data($comment, manakai_source_column => $token->{column})
2560 43 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 43 0 43
2561 43 ▶ if ($self->{insertion_mode} & AFTER_HTML_IMS) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} & 4) { } 8 35 43
elsif ($self->{'insertion_mode'} == 256) { } 1 34 35
2562
2563 8 $self->{document}->appendChild ($comment);
2564 } elsif ($self->{insertion_mode} == AFTER_BODY_IM) {
2565
2566 1 $self->{open_elements}->[0]->[0]->appendChild($comment);
2567 } else {
2568 34 $self->{open_elements}->[-1]->[0]->appendChild($comment);
2569 34 ▶ $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
Branch: 1 branch
BranchTrueFalseTotal
if @$open_tables 34 0 34
2570 }
2571 43 $token = $self->_get_next_token;
2572 43 next B;
2573 } elsif ($self->{insertion_mode} & IN_CDATA_RCDATA_IM) {
2574 510 ▶ if ($token->{type} == CHARACTER_TOKEN) {
Branch: 3 branches
BranchTrueFalseTotal
if ($token->{'type'} == 6) { } 414 96 510
elsif ($token->{'type'} == 4) { } 76 20 96
elsif ($token->{'type'} == 5) { } 20 0 20
2575 414 ▶ $token->{data} =~ s/^\x0A// if $self->{ignore_newline};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ignore_newline"} 9 405 414
2576 414 delete $self->{ignore_newline};
2577  
2578 414 ▶ if (length $token->{data}) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $token->{'data'}) { } 412 2 414
2579
2580 ## NOTE: NULLs are replaced into U+FFFDs in tokenizer.
2581 $self->{open_elements}->[-1]->[0]->appendTextFromUnicode
2582 412 ($self, $token->{data}, $token);
2583 } else {
2584
2585 }
2586 414 $token = $self->_get_next_token;
2587 414 next B;
2588 } elsif ($token->{type} == END_TAG_TOKEN) {
2589 76 delete $self->{ignore_newline};
2590  
2591 76 ▶ if ($token->{tag_name} eq 'script') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'script') { } 29 47 76
2592
2593
2594 ## Para 1-2
2595 29 my $script = pop @{$self->{open_elements}};
2596
2597 ## Para 3
2598 29 $self->{insertion_mode} &= ~ IN_CDATA_RCDATA_IM;
2599  
2600 ## Para 4
2601 ## TODO: $old_insertion_point = $current_insertion_point;
2602 ## TODO: $current_insertion_point = just before $self->{nc};
2603  
2604 ## Para 5
2605 ## TODO: Run the $script->[0].
2606  
2607 ## Para 6
2608 ## TODO: $current_insertion_point = $old_insertion_point;
2609  
2610 ## Para 7
2611 ## TODO: if ($pending_external_script) {
2612 ## TODO: ...
2613 ## TODO: }
2614  
2615 29 $token = $self->_get_next_token;
2616 29 next B;
2617 } else {
2618
2619
2620 47 pop @{$self->{open_elements}};
2621  
2622 47 $self->{insertion_mode} &= ~ IN_CDATA_RCDATA_IM;
2623 47 $token = $self->_get_next_token;
2624 47 next B;
2625 }
2626 } elsif ($token->{type} == END_OF_FILE_TOKEN) {
2627 20 delete $self->{ignore_newline};
2628  
2629
2630 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
2631 20 text => $self->{open_elements}->[-1]->[0]
2632 ->localname,
2633 token => $token);
2634  
2635 #if ($self->{open_elements}->[-1]->[1] == SCRIPT_EL) {
2636 # ## TODO: Mark as "already executed"
2637 #}
2638  
2639 20 pop @{$self->{open_elements}};
2640
2641 20 $self->{insertion_mode} &= ~ IN_CDATA_RCDATA_IM;
2642 ## Reprocess.
2643 20 next B;
2644 } else {
2645 0 die "$0: $token->{type}: In CDATA/RCDATA: Unknown token type";
2646 }
2647 } # insertion_mode
2648  
2649 # BEGIN:TOBYINK
2650 4292 ▶ if ($self->{insertion_mode} == IN_HEAD_IM and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"insertion_mode"} == 8 and ($token->{"tag_name"} || "") eq "object" and $token->{"type"} == 4 and $self->_data($self->{"document"}, "isHTML4")) 1 4291 4292
Condition90%10/11
$self->{"insertion_mode"} == 8 and ($token->{"tag_name"} || "") eq "object" and $token->{"type"} == 4 and $self->_data($self->{"document"}, "isHTML4")
!ll&&!rl&&r
429101
$self->{"insertion_mode"} == 8 and ($token->{"tag_name"} || "") eq "object" and $token->{"type"} == 4
!ll&&!rl&&r
428921
$self->{"insertion_mode"} == 8 and ($token->{"tag_name"} || "") eq "object"
!ll&&!rl&&r
4232573
$token->{'tag_name'} || ''
l!l
3822
MC/DC75%3/4
$self->{"insertion_mode"} == 8 and ($token->{"tag_name"} || "") eq "object" and $token->{"type"} == 4 and $self->_data($self->{"document"}, "isHTML4")
$self->{"insertion_mode"} == 8 $token->{'tag_name'} $token->{"type"} == 4 $self->_data($self->{"document"}, "isHTML4")
Truth table80%4/5
A and B and C and D
A= $self->{"insertion_mode"} == 8B= $token->{'tag_name'}C= $token->{"type"} == 4D= $self->_data($self->{"document"}, "isHTML4")
ABCDresult
0XXX0
10XX0
110X0
11100
11111
2651 ($token->{tag_name}||'') eq 'object' and
2652 $token->{type} == END_TAG_TOKEN and
2653 $self->_data($self->{'document'}, 'isHTML4')) {
2654
2655 1 pop @{$self->{open_elements}}
2656 1 ▶ if $self->{open_elements}->[-1]->[0]->localname eq 'object';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"open_elements"}[-1][0]->localname eq "object" 1 0 1
2657 }
2658 # END:TOBYINK
2659  
2660 4292 ▶ if ($self->{insertion_mode} & HEAD_IMS) {
Branch: 7 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} & 8) { } 811 3481 4292
elsif ($self->{'insertion_mode'} & 16) { } 2762 719 3481
elsif ($self->{'insertion_mode'} & 64) { } 397 322 719
elsif (($self->{'insertion_mode'} & 2047) == 2) { } 8 314 322
elsif ($self->{'insertion_mode'} & 1024) { } 131 183 314
elsif ($self->{'insertion_mode'} & 256) { } 93 90 183
elsif ($self->{'insertion_mode'} & 512) { } 90 0 90
2661 811 ▶ if ($token->{type} == CHARACTER_TOKEN) {
Branch: 4 branches
BranchTrueFalseTotal
if ($token->{'type'} == 6) { } 198 613 811
elsif ($token->{'type'} == 3) { } 536 77 613
elsif ($token->{'type'} == 4) { } 34 43 77
elsif ($token->{'type'} == 5) { } 43 0 43
2662 198 ▶ if ($token->{data} =~ s/^([\x09\x0A\x0C\x20]+)//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"data"} =~ s/^([\x09\x0A\x0C\x20]+)//) 19 179 198
2663 19 ▶ unless ($self->{insertion_mode} == BEFORE_HEAD_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 11) { } 8 11 19
2664
2665 11 $self->{open_elements}->[-1]->[0]->appendTextFromUnicode($self, $1, $token);
2666 } else {
2667
2668 ## Ignore the token.
2669 #
2670 }
2671 19 ▶ unless (length $token->{data}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (length $token->{"data"}) 18 1 19
2672
2673 18 $token = $self->_get_next_token;
2674 18 next B;
2675 }
2676 ## TODO: set $token->{column} appropriately
2677 }
2678  
2679 180 ▶ if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 11) { } 176 4 180
elsif ($self->{'insertion_mode'} == 9) { } 0 4 4
elsif ($self->{'insertion_mode'} == 8) { } 2 2 4
2680
2681 ## As if <head>
2682
2683 176 $self->{head_element} = $self->{document}->createElementNS((HTML_NS), 'head');
2684
2685 $self->_data($self->{head_element}, manakai_source_line => $token->{line})
2686 176 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 176 0 176
2687 $self->_data($self->{head_element}, manakai_source_column => $token->{column})
2688 176 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 176 0 176
2689 176 $self->_data($self->{head_element}, implied => __LINE__);
2690
2691 176 $self->{open_elements}->[-1]->[0]->appendChild ($self->{head_element});
2692 176 push @{$self->{open_elements}},
2693 176 [$self->{head_element}, $el_category->{head}];
2694  
2695 ## Reprocess in the "in head" insertion mode...
2696 176 pop @{$self->{open_elements}};
2697  
2698 ## Reprocess in the "after head" insertion mode...
2699 } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
2700
2701 ## As if </noscript>
2702 0 pop @{$self->{open_elements}};
2703 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in noscript:#text', token => $token);
2704
2705 ## Reprocess in the "in head" insertion mode...
2706 ## As if </head>
2707 0 pop @{$self->{open_elements}};
2708  
2709 ## Reprocess in the "after head" insertion mode...
2710 } elsif ($self->{insertion_mode} == IN_HEAD_IM) {
2711
2712 2 pop @{$self->{open_elements}};
2713  
2714 ## Reprocess in the "after head" insertion mode...
2715 } else {
2716
2717 }
2718  
2719 ## "after head" insertion mode
2720 ## As if <body>
2721
2722 {
2723 180 my $el;
2724
2725 180 $el = $self->{document}->createElementNS((HTML_NS), 'body');
2726
2727 $self->_data($el, manakai_source_line => $token->{line})
2728 180 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 180 0 180
2729 $self->_data($el, manakai_source_column => $token->{column})
2730 180 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 180 0 180
2731 180 $self->_data($el, implied => __LINE__);
2732
2733 180 $self->{open_elements}->[-1]->[0]->appendChild ($el);
2734 180 ▶ push @{$self->{open_elements}}, [$el, $el_category->{'body'} || 0];
Condition50%1/2
$el_category->{'body'} || 0
l!l
1800
MC/DC0%0/1
$el_category->{'body'} || 0
$el_category->{'body'}
Truth table50%1/2
A
A= $el_category->{'body'}
Aresult
11
00
2735 }
2736
2737 180 $self->{insertion_mode} = IN_BODY_IM;
2738 ## The "frameset-ok" flag is left unchanged in this case.
2739 ## Reporcess the token.
2740 180 next B;
2741 } elsif ($token->{type} == START_TAG_TOKEN) {
2742 536 ▶ if ($token->{tag_name} eq 'head') {
Branch: 2 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'head') { } 28 508 536
elsif ($self->{'insertion_mode'} == 11) { } 477 31 508
2743 28 ▶ if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 11) { } 26 2 28
elsif ($self->{'insertion_mode'} == 10) { } 0 2 2
2744
2745
2746 26 $self->{head_element} = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
2747
2748 26 for my $attr_name (keys %{ $token->{attributes}}) {
2749 1 my $attr_t = $token->{attributes}->{$attr_name};
2750 1 my $attr = $self->{document}->createAttributeNS (undef, $attr_name);
2751 1 $attr->setValue ($attr_t->{value});
2752 1 $self->_data($attr,manakai_source_line => $attr_t->{line});
2753 1 $self->_data($attr,manakai_source_column => $attr_t->{column});
2754 1 $self->{head_element}->setAttributeNodeNS ($attr);
2755 }
2756
2757 $self->_data($self->{head_element}, manakai_source_line => $token->{line})
2758 26 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 26 0 26
2759 $self->_data($self->{head_element}, manakai_source_column => $token->{column})
2760 26 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 26 0 26
2761
2762 26 $self->{open_elements}->[-1]->[0]->appendChild($self->{head_element});
2763 26 push @{$self->{open_elements}},
2764 26 [$self->{head_element}, $el_category->{head}];
2765 26 $self->{insertion_mode} = IN_HEAD_IM;
2766
2767 26 $token = $self->_get_next_token;
2768 26 next B;
2769 } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
2770
2771 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after head', text => 'head',
2772 token => $token);
2773 ## Ignore the token
2774
2775 0 $token = $self->_get_next_token;
2776 0 next B;
2777 } else {
2778
2779 2 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in head:head',
2780 token => $token); # or in head noscript
2781 ## Ignore the token
2782
2783 2 $token = $self->_get_next_token;
2784 2 next B;
2785 }
2786 } elsif ($self->{insertion_mode} == BEFORE_HEAD_IM) {
2787
2788 ## As if <head>
2789
2790 477 $self->{head_element} = $self->{document}->createElementNS((HTML_NS), 'head');
2791
2792 $self->_data($self->{head_element}, manakai_source_line => $token->{line})
2793 477 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 477 0 477
2794 $self->_data($self->{head_element}, manakai_source_column => $token->{column})
2795 477 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 477 0 477
2796 477 $self->_data($self->{head_element}, implied => __LINE__);
2797
2798 477 $self->{open_elements}->[-1]->[0]->appendChild ($self->{head_element});
2799 477 push @{$self->{open_elements}},
2800 477 [$self->{head_element}, $el_category->{head}];
2801  
2802 477 $self->{insertion_mode} = IN_HEAD_IM;
2803 ## Reprocess in the "in head" insertion mode...
2804 } else {
2805
2806 }
2807  
2808 508 ▶ if ($token->{tag_name} eq 'base') {
Branch: 10 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'base') { } 0 508 508
elsif ({'link', 1, 'basefont', 1, 'bgsound', 1}->{$token->{'tag_name'}}) { } 2 506 508
elsif ($token->{'tag_name'} eq 'command') { } 0 506 506
elsif ($token->{'tag_name'} eq 'meta') { } 7 499 506
elsif ($token->{'tag_name'} eq 'title') { } 11 488 499
elsif ($token->{'tag_name'} eq 'style' or $token->{'tag_name'} eq 'noframes') { } 6 482 488
elsif ($token->{'tag_name'} eq 'noscript') { } 0 482 482
elsif ($token->{'tag_name'} eq 'script') { } 5 477 482
elsif ($token->{'tag_name'} eq 'body' or $token->{'tag_name'} eq 'frameset') { } 119 358 477
elsif ($self->{'insertion_mode'} == 8 and $token->{'tag_name'} =~ /^(object|param)$/ and $self->_data($self->{'document'}, 'isHTML4')) { } 1 357 358
2809 0 ▶ if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 9) { } 0 0 0
2810
2811 ## As if </noscript>
2812 0 pop @{$self->{open_elements}};
2813 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in noscript', text => 'base',
2814 token => $token);
2815
2816 0 $self->{insertion_mode} = IN_HEAD_IM;
2817 ## Reprocess in the "in head" insertion mode...
2818 } else {
2819
2820 }
2821  
2822 ## NOTE: There is a "as if in head" code clone.
2823 0 ▶ if ($self->{insertion_mode} == AFTER_HEAD_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 10) { } 0 0 0
2824
2825 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after head',
2826 0 text => $token->{tag_name}, token => $token);
2827 0 push @{$self->{open_elements}},
2828 0 [$self->{head_element}, $el_category->{head}];
2829 } else {
2830
2831 }
2832
2833 {
2834 0 my $el;
2835
2836 0 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
2837
2838 0 for my $attr_name (keys %{ $token->{attributes}}) {
2839 0 my $attr_t = $token->{attributes}->{$attr_name};
2840 0 my $attr = $self->{document}->createAttributeNS (undef, $attr_name);
2841 0 $attr->setValue ($attr_t->{value});
2842 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
2843 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
2844 0 $el->setAttributeNodeNS($attr);
2845 }
2846
2847 $self->_data($el,manakai_source_line => $token->{line})
2848 0 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 0 0 0
2849 $self->_data($el,manakai_source_column => $token->{column})
2850 0 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 0 0 0
2851
2852 0 $self->{open_elements}->[-1]->[0]->appendChild ($el);
2853 0 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition0%0/2
$$el_category{$token->{'tag_name'}} || 0
l!l
00
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table0%0/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
2854 }
2855
2856 0 pop @{$self->{open_elements}};
2857 0 pop @{$self->{open_elements}} # <head>
2858 0 ▶ if $self->{insertion_mode} == AFTER_HEAD_IM;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"insertion_mode"} == 10 0 0 0
2859
2860 0 $token = $self->_get_next_token;
2861 0 next B;
2862 } elsif ({
2863 link => 1, basefont => 1, bgsound => 1,
2864 }->{$token->{tag_name}}) {
2865 ## NOTE: There is a "as if in head" code clone.
2866 2 ▶ if ($self->{insertion_mode} == AFTER_HEAD_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 10) { } 0 2 2
2867
2868 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after head',
2869 0 text => $token->{tag_name}, token => $token);
2870 0 push @{$self->{open_elements}},
2871 0 [$self->{head_element}, $el_category->{head}];
2872 } else {
2873
2874 }
2875
2876 {
2877 2 my $el;
2878
2879 2 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
2880
2881 2 for my $attr_name (keys %{ $token->{attributes}}) {
2882 0 my $attr_t = $token->{attributes}->{$attr_name};
2883 0 my $attr = $self->{document}->createAttributeNS (undef, $attr_name);
2884 0 $attr->setValue($attr_t->{value});
2885 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
2886 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
2887 0 $el->setAttributeNodeNS($attr);
2888 }
2889
2890 $self->_data($el, manakai_source_line => $token->{line})
2891 2 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 2 0 2
2892 $self->_data($el, manakai_source_column => $token->{column})
2893 2 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 2 0 2
2894
2895 2 $self->{open_elements}->[-1]->[0]->appendChild ($el);
2896 2 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
20
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
2897 }
2898
2899 2 pop @{$self->{open_elements}};
2900 0 pop @{$self->{open_elements}} # <head>
2901 2 ▶ if $self->{insertion_mode} == AFTER_HEAD_IM;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"insertion_mode"} == 10 0 2 2
2902 2 delete $self->{self_closing};
2903 2 $token = $self->_get_next_token;
2904 2 next B;
2905 } elsif ($token->{tag_name} eq 'command') {
2906 0 ▶ if ($self->{insertion_mode} == IN_HEAD_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 8) { } 0 0 0
2907 ## NOTE: If the insertion mode at the time of the emission
2908 ## of the token was "before head", $self->{insertion_mode}
2909 ## is already changed to |IN_HEAD_IM|.
2910  
2911 ## NOTE: There is a "as if in head" code clone.
2912
2913 {
2914 0 my $el;
2915
2916 0 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
2917
2918 0 for my $attr_name (keys %{ $token->{attributes}}) {
2919 0 my $attr_t = $token->{attributes}->{$attr_name};
2920 0 my $attr = $self->{document}->createAttributeNS (undef, $attr_name);
2921 0 $attr->setValue($attr_t->{value});
2922 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
2923 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
2924 0 $el->setAttributeNodeNS($attr);
2925 }
2926
2927 $self->_data($el, manakai_source_line => $token->{line})
2928 0 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 0 0 0
2929 $self->_data($el, manakai_source_column => $token->{column})
2930 0 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 0 0 0
2931
2932 0 $self->{open_elements}->[-1]->[0]->appendChild ($el);
2933 0 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition0%0/2
$$el_category{$token->{'tag_name'}} || 0
l!l
00
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table0%0/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
2934 }
2935
2936 0 pop @{$self->{open_elements}};
2937 0 pop @{$self->{open_elements}} # <head>
2938 0 ▶ if $self->{insertion_mode} == AFTER_HEAD_IM;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"insertion_mode"} == 10 0 0 0
2939 0 delete $self->{self_closing};
2940 0 $token = $self->_get_next_token;
2941 0 next B;
2942 } else {
2943 ## NOTE: "in head noscript" or "after head" insertion mode
2944 ## - in these cases, these tags are treated as same as
2945 ## normal in-body tags.
2946
2947 #
2948 }
2949 } elsif ($token->{tag_name} eq 'meta') {
2950 ## NOTE: There is a "as if in head" code clone.
2951 7 ▶ if ($self->{insertion_mode} == AFTER_HEAD_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 10) { } 0 7 7
2952
2953 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after head',
2954 0 text => $token->{tag_name}, token => $token);
2955 0 push @{$self->{open_elements}},
2956 0 [$self->{head_element}, $el_category->{head}];
2957 } else {
2958
2959 }
2960
2961 {
2962 7 my $el;
2963
2964 7 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
2965
2966 7 for my $attr_name (keys %{ $token->{attributes}}) {
2967 8 my $attr_t = $token->{attributes}->{$attr_name};
2968 8 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
2969 8 $attr->setValue ($attr_t->{value});
2970 8 $self->_data($attr, manakai_source_line => $attr_t->{line});
2971 8 $self->_data($attr, manakai_source_column => $attr_t->{column});
2972 8 $el->setAttributeNodeNS ($attr);
2973 }
2974
2975 $self->_data($el, manakai_source_line => $token->{line})
2976 7 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 7 0 7
2977 $self->_data($el, manakai_source_column => $token->{column})
2978 7 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 7 0 7
2979
2980 7 $self->{open_elements}->[-1]->[0]->appendChild ($el);
2981 7 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
70
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
2982 }
2983
2984 7 my $meta_el = pop @{$self->{open_elements}};
2985  
2986 7 ▶ unless ($self->{confident}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'confident'}) { } 3 4 7
2987 4 ▶ if ($token->{attributes}->{charset}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token->{'attributes'}{'charset'}) { } 2 2 4
elsif ($token->{'attributes'}{'content'} and $token->{'attributes'}{'http-equiv'}) { } 1 2 3
2988
2989 ## NOTE: Whether the encoding is supported or not,
2990 ## an ASCII-compatible charset is not, is handled in
2991 ## the {change_encoding} callback.
2992 $self->{change_encoding}
2993 ->($self, $token->{attributes}->{charset}->{value},
2994 2 $token);
2995
2996 $self->_data($meta_el->[0]->getAttributeNodeNS (undef, 'charset'),
2997 0 manakai_has_reference => $token->{attributes}->{charset}->{has_reference});
2998 ▶ } elsif ($token->{attributes}->{content} and
Condition66%2/3
$token->{"attributes"}{"content"} and $token->{"attributes"}{"http-equiv"}
!ll&&!rl&&r
101
MC/DC50%1/2
$token->{"attributes"}{"content"} and $token->{"attributes"}{"http-equiv"}
$token->{"attributes"}{"content"} $token->{"attributes"}{"http-equiv"}
Truth table66%2/3
A and B
A= $token->{"attributes"}{"content"}B= $token->{"attributes"}{"http-equiv"}
ABresult
0X0
100
111
2999 $token->{attributes}->{'http-equiv'}) {
3000 1 ▶ if ($token->{attributes}->{'http-equiv'}->{value}
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'attributes'}{'http-equiv'}{'value'} =~ /\A[Cc][Oo][Nn][Tt][Ee][Nn][Tt]-[Tt][Yy][Pp][Ee]\z/ and $token->{'attributes'}{'content'}{'value'} =~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt] [\x09\x0A\x0C\x0D\x20]*= [\x09\x0A\x0C\x0D\x20]*(?>"([^"]*)"|'([^']*)'| ([^"'\x09\x0A\x0C\x0D\x20] [^\x09\x0A\x0C\x0D\x20\x3B]*))/x) { } 1 0 1
Condition33%1/3
$token->{"attributes"}{"http-equiv"}{"value"} =~ /\A[Cc][Oo][Nn][Tt][Ee][Nn][Tt]-[Tt][Yy][Pp][Ee]\z/ and $token->{"attributes"}{"content"}{"value"} =~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt] [\x09\x0A\x0C\x0D\x20]*= [\x09\x0A\x0C\x0D\x20]*(?>"([^"]*)"|'([^']*)'| ([^"'\x09\x0A\x0C\x0D\x20] [^\x09\x0A\x0C\x0D\x20\x3B]*))/x
!ll&&!rl&&r
001
MC/DC0%0/2
$token->{"attributes"}{"http-equiv"}{"value"} =~ /\A[Cc][Oo][Nn][Tt][Ee][Nn][Tt]-[Tt][Yy][Pp][Ee]\z/ and $token->{"attributes"}{"content"}{"value"} =~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt] [\x09\x0A\x0C\x0D\x20]*= [\x09\x0A\x0C\x0D\x20]*(?>"([^"]*)"|'([^']*)'| ([^"'\x09\x0A\x0C\x0D\x20] [^\x09\x0A\x0C\x0D\x20\x3B]*))/x
$token->{"attributes"}{"http-equiv"}{"value"} =~ /\A[Cc][Oo][Nn][Tt][Ee][Nn][Tt]-[Tt][Yy][Pp][Ee]\z/ $token->{"attributes"}{"content"}{"value"} =~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt] [\x09\x0A\x0C\x0D\x20]*= [\x09\x0A\x0C\x0D\x20]*(?>"([^"]*)"|'([^']*)'| ([^"'\x09\x0A\x0C\x0D\x20] [^\x09\x0A\x0C\x0D\x20\x3B]*))/x
Truth table33%1/3
A and B
A= $token->{"attributes"}{"http-equiv"}{"value"} =~ /\A[Cc][Oo][Nn][Tt][Ee][Nn][Tt]-[Tt][Yy][Pp][Ee]\z/B= $token->{"attributes"}{"content"}{"value"} =~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt] [\x09\x0A\x0C\x0D\x20]*= [\x09\x0A\x0C\x0D\x20]*(?>"([^"]*)"|'([^']*)'| ([^"'\x09\x0A\x0C\x0D\x20] [^\x09\x0A\x0C\x0D\x20\x3B]*))/x
ABresult
0X0
100
111
3001 =~ /\A[Cc][Oo][Nn][Tt][Ee][Nn][Tt]-[Tt][Yy][Pp][Ee]\z/ and
3002 $token->{attributes}->{content}->{value}
3003 =~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt]
3004 [\x09\x0A\x0C\x0D\x20]*=
3005 [\x09\x0A\x0C\x0D\x20]*(?>"([^"]*)"|'([^']*)'|
3006 ([^"'\x09\x0A\x0C\x0D\x20]
3007 [^\x09\x0A\x0C\x0D\x20\x3B]*))/x) {
3008  
3009 ## NOTE: Whether the encoding is supported or not,
3010 ## an ASCII-compatible charset is not, is handled
3011 ## in the {change_encoding} callback.
3012 $self->{change_encoding}
3013 1 ▶ ->($self, defined $1 ? $1 : defined $2 ? $2 : $3,
Branch: 2 branches
BranchTrueFalseTotal
defined $1 ? : 0 1 1
defined $2 ? : 0 1 1
3014 $token);
3015 $self->_data($meta_el->[0]->getAttributeNodeNS (undef, 'content'),
3016 0 manakai_has_reference => $token->{attributes}->{content}->{has_reference});
3017 } else {
3018
3019 }
3020 }
3021 } else {
3022 3 ▶ if ($token->{attributes}->{charset}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"attributes"}{"charset"}) 2 1 3
3023
3024 $self->_data($meta_el->[0]->getAttributeNodeNS(undef, 'charset'),
3025 2 manakai_has_reference => $token->{attributes}->{charset}->{has_reference});
3026 }
3027 3 ▶ if ($token->{attributes}->{content}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"attributes"}{"content"}) 1 2 3
3028
3029 $self->_data($meta_el->[0]->getAttributeNodeNS(undef, 'content'),
3030 1 manakai_has_reference => $token->{attributes}->{content}->{has_reference});
3031 }
3032 }
3033  
3034 0 pop @{$self->{open_elements}} # <head>
3035 4 ▶ if $self->{insertion_mode} == AFTER_HEAD_IM;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"insertion_mode"} == 10 0 4 4
3036 4 delete $self->{self_closing};
3037 4 $token = $self->_get_next_token;
3038 4 next B;
3039 } elsif ($token->{tag_name} eq 'title') {
3040 11 ▶ if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 9) { } 0 11 11
elsif ($self->{'insertion_mode'} == 10) { } 2 9 11
3041
3042 ## As if </noscript>
3043 0 pop @{$self->{open_elements}};
3044 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in noscript', text => 'title',
3045 token => $token);
3046
3047 0 $self->{insertion_mode} = IN_HEAD_IM;
3048 ## Reprocess in the "in head" insertion mode...
3049 } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
3050
3051 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after head',
3052 2 text => $token->{tag_name}, token => $token);
3053 2 push @{$self->{open_elements}},
3054 2 [$self->{head_element}, $el_category->{head}];
3055 } else {
3056
3057 }
3058  
3059 ## NOTE: There is a "as if in head" code clone.
3060 11 $parse_rcdata->($self, $insert, $open_tables, 1); # RCDATA
3061  
3062 ## NOTE: At this point the stack of open elements contain
3063 ## the |head| element (index == -2) and the |script| element
3064 ## (index == -1). In the "after head" insertion mode the
3065 ## |head| element is inserted only for the purpose of
3066 ## providing the context for the |script| element, and
3067 ## therefore we can now and have to remove the element from
3068 ## the stack.
3069 2 splice @{$self->{open_elements}}, -2, 1, () # <head>
3070 11 ▶ if ($self->{insertion_mode} & IM_MASK) == AFTER_HEAD_IM;
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"insertion_mode"} & 2047) == 10 2 9 11
3071 11 next B;
3072 ▶ } elsif ($token->{tag_name} eq 'style' or
Condition66%2/3
$token->{"tag_name"} eq "style" or $token->{"tag_name"} eq "noframes"
l!l&&r!l&&!r
60482
MC/DC50%1/2
$token->{"tag_name"} eq "style" or $token->{"tag_name"} eq "noframes"
$token->{"tag_name"} eq "style" $token->{"tag_name"} eq "noframes"
Truth table66%2/3
A or B
A= $token->{"tag_name"} eq "style"B= $token->{"tag_name"} eq "noframes"
ABresult
1X1
011
000
3073 $token->{tag_name} eq 'noframes') {
3074 ## NOTE: Or (scripting is enabled and tag_name eq 'noscript' and
3075 ## insertion mode IN_HEAD_IM)
3076 ## NOTE: There is a "as if in head" code clone.
3077 6 ▶ if ($self->{insertion_mode} == AFTER_HEAD_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 10) { } 3 3 6
3078
3079 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after head',
3080 3 text => $token->{tag_name}, token => $token);
3081 3 push @{$self->{open_elements}},
3082 3 [$self->{head_element}, $el_category->{head}];
3083 } else {
3084
3085 }
3086 6 $parse_rcdata->($self, $insert, $open_tables, 0); # RAWTEXT
3087 3 splice @{$self->{open_elements}}, -2, 1, () # <head>
3088 6 ▶ if ($self->{insertion_mode} & IM_MASK) == AFTER_HEAD_IM;
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"insertion_mode"} & 2047) == 10 3 3 6
3089 6 next B;
3090 } elsif ($token->{tag_name} eq 'noscript') {
3091 0 ▶ if ($self->{insertion_mode} == IN_HEAD_IM) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 8) { } 0 0 0
elsif ($self->{'insertion_mode'} == 9) { } 0 0 0
3092
3093 ## NOTE: and scripting is disalbed
3094
3095 {
3096 0 my $el;
3097
3098 0 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
3099
3100 0 for my $attr_name (keys %{ $token->{attributes}}) {
3101 0 my $attr_t = $token->{attributes}->{$attr_name};
3102 0 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
3103 0 $attr->setValue ($attr_t->{value});
3104 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
3105 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
3106 0 $el->setAttributeNodeNS ($attr);
3107 }
3108
3109 $self->_data($el, manakai_source_line => $token->{line})
3110 0 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 0 0 0
3111 $self->_data($el, manakai_source_column => $token->{column})
3112 0 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 0 0 0
3113
3114 0 $self->{open_elements}->[-1]->[0]->appendChild ($el);
3115 0 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition0%0/2
$$el_category{$token->{'tag_name'}} || 0
l!l
00
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table0%0/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
3116 }
3117
3118 0 $self->{insertion_mode} = IN_HEAD_NOSCRIPT_IM;
3119
3120 0 $token = $self->_get_next_token;
3121 0 next B;
3122 } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
3123
3124 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in noscript', text => 'noscript',
3125 token => $token);
3126 ## Ignore the token
3127
3128 0 $token = $self->_get_next_token;
3129 0 next B;
3130 } else {
3131
3132 #
3133 }
3134 } elsif ($token->{tag_name} eq 'script') {
3135 5 ▶ if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 9) { } 0 5 5
elsif ($self->{'insertion_mode'} == 10) { } 2 3 5
3136
3137 ## As if </noscript>
3138 0 pop @{$self->{open_elements}};
3139 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in noscript', text => 'script',
3140 token => $token);
3141
3142 0 $self->{insertion_mode} = IN_HEAD_IM;
3143 ## Reprocess in the "in head" insertion mode...
3144 } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
3145
3146 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after head',
3147 2 text => $token->{tag_name}, token => $token);
3148 2 push @{$self->{open_elements}},
3149 2 [$self->{head_element}, $el_category->{head}];
3150 } else {
3151
3152 }
3153  
3154 ## NOTE: There is a "as if in head" code clone.
3155 5 $script_start_tag->($self, $insert, $open_tables);
3156 ## ISSUE: A spec bug [Bug 6038]
3157 2 splice @{$self->{open_elements}}, -2, 1 # <head>
3158 5 ▶ if ($self->{insertion_mode} & IM_MASK) == AFTER_HEAD_IM;
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"insertion_mode"} & 2047) == 10 2 3 5
3159 5 next B;
3160 ▶ } elsif ($token->{tag_name} eq 'body' or
Condition100%3/3
$token->{"tag_name"} eq "body" or $token->{"tag_name"} eq "frameset"
l!l&&r!l&&!r
10019358
MC/DC100%2/2
$token->{"tag_name"} eq "body" or $token->{"tag_name"} eq "frameset"
$token->{"tag_name"} eq "body" $token->{"tag_name"} eq "frameset"
Truth table100%3/3
A or B
A= $token->{"tag_name"} eq "body"B= $token->{"tag_name"} eq "frameset"
ABresult
1X1
011
000
3161 $token->{tag_name} eq 'frameset') {
3162 119 ▶ if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 9) { } 0 119 119
elsif ($self->{'insertion_mode'} == 8) { } 109 10 119
3163
3164 ## As if </noscript>
3165 0 pop @{$self->{open_elements}};
3166 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in noscript',
3167 0 text => $token->{tag_name}, token => $token);
3168
3169 ## Reprocess in the "in head" insertion mode...
3170 ## As if </head>
3171 0 pop @{$self->{open_elements}};
3172
3173 ## Reprocess in the "after head" insertion mode...
3174 } elsif ($self->{insertion_mode} == IN_HEAD_IM) {
3175
3176 109 pop @{$self->{open_elements}};
3177
3178 ## Reprocess in the "after head" insertion mode...
3179 } else {
3180
3181 }
3182  
3183 ## "after head" insertion mode
3184
3185 {
3186 119 my $el;
3187
3188 119 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
3189
3190 119 for my $attr_name (keys %{ $token->{attributes}}) {
3191 9 my $attr_t = $token->{attributes}->{$attr_name};
3192 9 my $attr = $self->{document}->createAttributeNS (undef, $attr_name);
3193 9 $attr->setValue ($attr_t->{value});
3194 9 $self->_data($attr, manakai_source_line => $attr_t->{line});
3195 9 $self->_data($attr, manakai_source_column => $attr_t->{column});
3196 9 $el->setAttributeNodeNS ($attr);
3197 }
3198
3199 $self->_data($el, manakai_source_line => $token->{line})
3200 119 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 119 0 119
3201 $self->_data($el, manakai_source_column => $token->{column})
3202 119 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 119 0 119
3203
3204 119 $self->{open_elements}->[-1]->[0]->appendChild ($el);
3205 119 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
1190
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
3206 }
3207
3208 119 ▶ if ($token->{tag_name} eq 'body') {
Branch: 2 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'body') { } 100 19 119
elsif ($token->{'tag_name'} eq 'frameset') { } 19 0 19
3209
3210 100 delete $self->{frameset_ok};
3211 100 $self->{insertion_mode} = IN_BODY_IM;
3212 } elsif ($token->{tag_name} eq 'frameset') {
3213
3214 19 $self->{insertion_mode} = IN_FRAMESET_IM;
3215 } else {
3216 0 die "$0: tag name: $self->{tag_name}";
3217 }
3218
3219 119 $token = $self->_get_next_token;
3220 119 next B;
3221 # BEGIN:TOBYINK
3222 ▶ } elsif ($self->{insertion_mode} == IN_HEAD_IM and
Condition83%5/6
$self->{"insertion_mode"} == 8 and $token->{"tag_name"} =~ /^(object|param)$/ and $self->_data($self->{"document"}, "isHTML4")
!ll&&!rl&&r
35431
$self->{"insertion_mode"} == 8 and $token->{"tag_name"} =~ /^(object|param)$/
!ll&&!rl&&r
03544
MC/DC66%2/3
$self->{"insertion_mode"} == 8 and $token->{"tag_name"} =~ /^(object|param)$/ and $self->_data($self->{"document"}, "isHTML4")
$self->{"insertion_mode"} == 8 $token->{"tag_name"} =~ /^(object|param)$/ $self->_data($self->{"document"}, "isHTML4")
Truth table75%3/4
A and B and C
A= $self->{"insertion_mode"} == 8B= $token->{"tag_name"} =~ /^(object|param)$/C= $self->_data($self->{"document"}, "isHTML4")
ABCresult
0XX0
10X0
1100
1111
3223 $token->{tag_name} =~ m'^(object|param)$' and
3224 $self->_data($self->{'document'}, 'isHTML4')) {
3225 {
3226 1 my $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
3227 1 for my $attr_name (keys %{ $token->{attributes}}) {
3228 0 my $attr_t = $token->{attributes}->{$attr_name};
3229 0 my $attr = $self->{document}->createAttributeNS (undef, $attr_name);
3230 0 $attr->setValue($attr_t->{value});
3231 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
3232 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
3233 0 $el->setAttributeNodeNS($attr);
3234 }
3235 1 ▶ $self->_data($el, manakai_source_line => $token->{line}) if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 1 0 1
3236 1 ▶ $self->_data($el, manakai_source_column => $token->{column}) if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 1 0 1
3237 1 $self->{open_elements}->[-1]->[0]->appendChild ($el);
3238 1 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
10
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
3239 }
3240 1 ▶ if ($token->{tag_name} eq 'param')
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"tag_name"} eq "param") 0 1 1
3241 {
3242 0 pop @{$self->{open_elements}};
3243 0 delete $self->{self_closing};
3244 }
3245 1 $token = $self->_get_next_token;
3246 1 next B;
3247 # END:TOBYINK
3248 } else {
3249 #
3250 }
3251  
3252 357 ▶ if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 9) { } 0 357 357
elsif ($self->{'insertion_mode'} == 8) { } 357 0 357
3253
3254 ## As if </noscript>
3255 0 pop @{$self->{open_elements}};
3256 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in noscript:/',
3257 0 text => $token->{tag_name}, token => $token);
3258
3259 ## Reprocess in the "in head" insertion mode...
3260 ## As if </head>
3261 0 pop @{$self->{open_elements}};
3262  
3263 ## Reprocess in the "after head" insertion mode...
3264 } elsif ($self->{insertion_mode} == IN_HEAD_IM) {
3265
3266 ## As if </head>
3267 357 pop @{$self->{open_elements}};
3268  
3269 ## Reprocess in the "after head" insertion mode...
3270 } else {
3271
3272 }
3273  
3274 ## "after head" insertion mode
3275 ## As if <body>
3276
3277 {
3278 357 my $el;
3279
3280 357 $el = $self->{document}->createElementNS((HTML_NS), 'body');
3281
3282 $self->_data($el, manakai_source_line => $token->{line})
3283 357 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 357 0 357
3284 $self->_data($el, manakai_source_column => $token->{column})
3285 357 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 357 0 357
3286 357 $self->_data($el, implied => __LINE__);
3287
3288 357 $self->{open_elements}->[-1]->[0]->appendChild ($el);
3289 357 ▶ push @{$self->{open_elements}}, [$el, $el_category->{'body'} || 0];
Condition50%1/2
$el_category->{'body'} || 0
l!l
3570
MC/DC0%0/1
$el_category->{'body'} || 0
$el_category->{'body'}
Truth table50%1/2
A
A= $el_category->{'body'}
Aresult
11
00
3290 }
3291 357 $self->{insertion_mode} = IN_BODY_IM;
3292 ## The "frameset-ok" flag is not changed in this case.
3293 ## Reprocess the token.
3294
3295 357 next B;
3296 } elsif ($token->{type} == END_TAG_TOKEN) {
3297 ## "Before head", "in head", and "after head" insertion modes
3298 ## ignore most of end tags. Exceptions are "body", "html",
3299 ## and "br" end tags. "Before head" and "in head" insertion
3300 ## modes also recognize "head" end tag. "In head noscript"
3301 ## insertion modes ignore end tags except for "noscript" and
3302 ## "br".
3303  
3304 34 ▶ if ($token->{tag_name} eq 'head') {
Branch: 3 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'head') { } 22 12 34
elsif ($token->{'tag_name'} eq 'noscript') { } 0 12 12
elsif ({'body', $self->{'insertion_mode'} != 9, 'html', $self->{'insertion_mode'} != 9, 'br', 1}->{$token->{'tag_name'}}) { } 9 3 12
3305 22 ▶ if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 11) { } 1 21 22
elsif ($self->{'insertion_mode'} == 9) { } 0 21 21
elsif ($self->{'insertion_mode'} == 8) { } 21 0 21
elsif ($self->{'insertion_mode'} == 10) { } 0 0 0
3306
3307 ## As if <head>
3308
3309 1 $self->{head_element} = $self->{document}->createElementNS((HTML_NS), 'head');
3310
3311 $self->_data($self->{head_element}, manakai_source_line => $token->{line})
3312 1 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 1 0 1
3313 $self->_data($self->{head_element}, manakai_source_column => $token->{column})
3314 1 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 1 0 1
3315
3316 1 $self->{open_elements}->[-1]->[0]->appendChild($self->{head_element});
3317 1 push @{$self->{open_elements}},
3318 1 [$self->{head_element}, $el_category->{head}];
3319  
3320 ## Reprocess in the "in head" insertion mode...
3321 1 pop @{$self->{open_elements}};
3322 1 $self->{insertion_mode} = AFTER_HEAD_IM;
3323 1 $token = $self->_get_next_token;
3324 1 next B;
3325 } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
3326
3327 #
3328 } elsif ($self->{insertion_mode} == IN_HEAD_IM) {
3329
3330 21 pop @{$self->{open_elements}};
3331 21 $self->{insertion_mode} = AFTER_HEAD_IM;
3332 21 $token = $self->_get_next_token;
3333 21 next B;
3334 } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
3335
3336 #
3337 } else {
3338 0 die "$0: $self->{insertion_mode}: Unknown insertion mode";
3339 }
3340 } elsif ($token->{tag_name} eq 'noscript') {
3341 0 ▶ if ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 9) { } 0 0 0
3342
3343 0 pop @{$self->{open_elements}};
3344 0 $self->{insertion_mode} = IN_HEAD_IM;
3345 0 $token = $self->_get_next_token;
3346 0 next B;
3347 } else {
3348
3349 #
3350 }
3351 } elsif ({
3352 body => ($self->{insertion_mode} != IN_HEAD_NOSCRIPT_IM),
3353 html => ($self->{insertion_mode} != IN_HEAD_NOSCRIPT_IM),
3354 br => 1,
3355 }->{$token->{tag_name}}) {
3356 9 ▶ if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
Branch: 4 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 11) { } 7 2 9
elsif ($self->{'insertion_mode'} == 8) { } 0 2 2
elsif ($self->{'insertion_mode'} == 9) { } 0 2 2
elsif ($self->{'insertion_mode'} == 10) { } 2 0 2
3357
3358 ## (before head) as if <head>, (in head) as if </head>
3359
3360 7 $self->{head_element} = $self->{document}->createElementNS((HTML_NS), 'head');
3361
3362 $self->_data($self->{head_element}, manakai_source_line => $token->{line})
3363 7 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 7 0 7
3364 $self->_data($self->{head_element}, manakai_source_column => $token->{column})
3365 7 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 7 0 7
3366 7 $self->_data($self->{head_element}, implied => __LINE__);
3367
3368 7 $self->{open_elements}->[-1]->[0]->appendChild ($self->{head_element});
3369 7 $self->{insertion_mode} = AFTER_HEAD_IM;
3370
3371 ## Reprocess in the "after head" insertion mode...
3372 } elsif ($self->{insertion_mode} == IN_HEAD_IM) {
3373
3374 ## As if </head>
3375 0 pop @{$self->{open_elements}};
3376 0 $self->{insertion_mode} = AFTER_HEAD_IM;
3377
3378 ## Reprocess in the "after head" insertion mode...
3379 } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
3380
3381 ## NOTE: Two parse errors for <head><noscript></br>
3382 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
3383 0 text => $token->{tag_name}, token => $token);
3384 ## As if </noscript>
3385 0 pop @{$self->{open_elements}};
3386 0 $self->{insertion_mode} = IN_HEAD_IM;
3387  
3388 ## Reprocess in the "in head" insertion mode...
3389 ## As if </head>
3390 0 pop @{$self->{open_elements}};
3391 0 $self->{insertion_mode} = AFTER_HEAD_IM;
3392  
3393 ## Reprocess in the "after head" insertion mode...
3394 } elsif ($self->{insertion_mode} == AFTER_HEAD_IM) {
3395
3396 #
3397 } else {
3398 0 die "$0: $self->{insertion_mode}: Unknown insertion mode";
3399 }
3400  
3401 ## "after head" insertion mode
3402 ## As if <body>
3403
3404 {
3405 9 my $el;
3406
3407 9 $el = $self->{document}->createElementNS((HTML_NS), 'body');
3408
3409 $self->_data($el, manakai_source_line => $token->{line})
3410 9 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 9 0 9
3411 $self->_data($el, manakai_source_column => $token->{column})
3412 9 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 9 0 9
3413 9 $self->_data($el, implied => __LINE__);
3414
3415 9 $self->{open_elements}->[-1]->[0]->appendChild ($el);
3416 9 ▶ push @{$self->{open_elements}}, [$el, $el_category->{'body'} || 0];
Condition50%1/2
$el_category->{'body'} || 0
l!l
90
MC/DC0%0/1
$el_category->{'body'} || 0
$el_category->{'body'}
Truth table50%1/2
A
A= $el_category->{'body'}
Aresult
11
00
3417 }
3418
3419 9 $self->{insertion_mode} = IN_BODY_IM;
3420 ## The "frameset-ok" flag is left unchanged in this case.
3421 ## Reprocess the token.
3422 9 next B;
3423 }
3424  
3425 ## End tags are ignored by default.
3426
3427 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
3428 3 text => $token->{tag_name}, token => $token);
3429 ## Ignore the token.
3430 3 $token = $self->_get_next_token;
3431 3 next B;
3432 } elsif ($token->{type} == END_OF_FILE_TOKEN) {
3433 43 ▶ if ($self->{insertion_mode} == BEFORE_HEAD_IM) {
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 11) { } 24 19 43
elsif ($self->{'insertion_mode'} == 8) { } 11 8 19
elsif ($self->{'insertion_mode'} == 9) { } 0 8 8
3434
3435  
3436 ## NOTE: As if <head>
3437
3438 24 $self->{head_element} = $self->{document}->createElementNS((HTML_NS), 'head');
3439
3440 $self->_data($self->{head_element}, manakai_source_line => $token->{line})
3441 24 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 24 0 24
3442 $self->_data($self->{head_element}, manakai_source_column => $token->{column})
3443 24 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 24 0 24
3444 24 $self->_data($self->{head_element}, implied => __LINE__);
3445
3446 24 $self->{open_elements}->[-1]->[0]->appendChild($self->{head_element});
3447
3448 #push @{$self->{open_elements}},
3449 # [$self->{head_element}, $el_category->{head}];
3450 #$self->{insertion_mode} = IN_HEAD_IM;
3451 ## NOTE: Reprocess.
3452  
3453 ## NOTE: As if </head>
3454 #pop @{$self->{open_elements}};
3455 #$self->{insertion_mode} = IN_AFTER_HEAD_IM;
3456 ## NOTE: Reprocess.
3457
3458 #
3459 } elsif ($self->{insertion_mode} == IN_HEAD_IM) {
3460
3461  
3462 ## NOTE: As if </head>
3463 11 pop @{$self->{open_elements}};
3464 #$self->{insertion_mode} = IN_AFTER_HEAD_IM;
3465 ## NOTE: Reprocess.
3466  
3467 #
3468 } elsif ($self->{insertion_mode} == IN_HEAD_NOSCRIPT_IM) {
3469
3470  
3471 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in noscript:#eof', token => $token);
3472  
3473 ## As if </noscript>
3474 0 pop @{$self->{open_elements}};
3475 #$self->{insertion_mode} = IN_HEAD_IM;
3476 ## NOTE: Reprocess.
3477  
3478 ## NOTE: As if </head>
3479 0 pop @{$self->{open_elements}};
3480 #$self->{insertion_mode} = IN_AFTER_HEAD_IM;
3481 ## NOTE: Reprocess.
3482  
3483 #
3484 } else {
3485
3486 #
3487 }
3488  
3489 ## NOTE: As if <body>
3490
3491 {
3492 43 my $el;
3493
3494 43 $el = $self->{document}->createElementNS((HTML_NS), 'body');
3495
3496 $self->_data($el, manakai_source_line => $token->{line})
3497 43 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 43 0 43
3498 $self->_data($el, manakai_source_column => $token->{column})
3499 43 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 43 0 43
3500 43 $self->_data($el, implied => __LINE__);
3501
3502 43 $self->{open_elements}->[-1]->[0]->appendChild ($el);
3503 43 ▶ push @{$self->{open_elements}}, [$el, $el_category->{'body'} || 0];
Condition50%1/2
$el_category->{'body'} || 0
l!l
430
MC/DC0%0/1
$el_category->{'body'} || 0
$el_category->{'body'}
Truth table50%1/2
A
A= $el_category->{'body'}
Aresult
11
00
3504 }
3505
3506 43 $self->{insertion_mode} = IN_BODY_IM;
3507 ## The "frameset-ok" flag is left unchanged in this case.
3508 ## Reprocess the token.
3509 43 next B;
3510 } else {
3511 0 die "$0: $token->{type}: Unknown token type";
3512 }
3513
3514 } elsif ($self->{insertion_mode} & BODY_IMS) {
3515 2762 ▶ if ($token->{type} == CHARACTER_TOKEN) {
Branch: 4 branches
BranchTrueFalseTotal
if ($token->{'type'} == 6) { } 705 2057 2762
elsif ($token->{'type'} == 3) { } 1078 979 2057
elsif ($token->{'type'} == 4) { } 393 586 979
elsif ($token->{'type'} == 5) { } 586 0 586
3516 ## "In body" insertion mode, character token. It is also used
3517 ## for character tokens "in foreign content" insertion
3518 ## mode, for certain cases.
3519
3520 705 ▶ while ($token->{data} =~ s/\x00//g) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"data"} =~ s/\x00//g) 0 705 705
3521 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'NULL', token => $token);
3522 }
3523 705 ▶ if ($token->{data} eq '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"data"} eq "") 0 705 705
3524 0 $token = $self->_get_next_token;
3525 0 next B;
3526 }
3527
3528 $reconstruct_active_formatting_elements
3529 705 ->($self, $insert_to_current, $active_formatting_elements, $open_tables);
3530
3531 705 $self->{open_elements}->[-1]->[0]->appendTextFromUnicode($self, $token->{data}, $token);
3532  
3533 705 ▶ if ($self->{frameset_ok} and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"frameset_ok"} and $token->{"data"} =~ /[^\x09\x0A\x0C\x0D\x20]/) 237 468 705
Condition100%3/3
$self->{"frameset_ok"} and $token->{"data"} =~ /[^\x09\x0A\x0C\x0D\x20]/
!ll&&!rl&&r
4599237
MC/DC100%2/2
$self->{"frameset_ok"} and $token->{"data"} =~ /[^\x09\x0A\x0C\x0D\x20]/
$self->{"frameset_ok"} $token->{"data"} =~ /[^\x09\x0A\x0C\x0D\x20]/
Truth table100%3/3
A and B
A= $self->{"frameset_ok"}B= $token->{"data"} =~ /[^\x09\x0A\x0C\x0D\x20]/
ABresult
0X0
100
111
3534 $token->{data} =~ /[^\x09\x0A\x0C\x0D\x20]/) {
3535 237 delete $self->{frameset_ok};
3536 }
3537  
3538 705 $token = $self->_get_next_token;
3539 705 next B;
3540 } elsif ($token->{type} == START_TAG_TOKEN) {
3541 1078 ▶ if ({
Branch: 1 branch
BranchTrueFalseTotal
if ({'caption', 1, 'col', 1, 'colgroup', 1, 'tbody', 1, 'td', 1, 'tfoot', 1, 'th', 1, 'thead', 1, 'tr', 1}->{$token->{'tag_name'}}) { } 9 1069 1078
3542 caption => 1, col => 1, colgroup => 1, tbody => 1,
3543 td => 1, tfoot => 1, th => 1, thead => 1, tr => 1,
3544 }->{$token->{tag_name}}) {
3545 9 ▶ if (($self->{insertion_mode} & IM_MASK) == IN_CELL_IM) {
Branch: 2 branches
BranchTrueFalseTotal
if (($self->{'insertion_mode'} & 2047) == 49) { } 7 2 9
elsif (($self->{'insertion_mode'} & 2047) == 50) { } 1 1 2
3546 ## have an element in table scope
3547 7 for (reverse 0..$#{$self->{open_elements}}) {
3548 12 my $node = $self->{open_elements}->[$_];
3549 12 ▶ if ($node->[1] == TABLE_CELL_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 327697) { } 7 5 12
elsif ($node->[1] & 512) { } 0 5 5
3550
3551  
3552 ## Close the cell
3553
3554 7 $token->{self_closing} = $self->{self_closing};
3555 7 unshift @{$self->{token}}, $token;
3556 7 delete $self->{self_closing};
3557 # <x>
3558 $token = {type => END_TAG_TOKEN,
3559 tag_name => $node->[0]->tagName,
3560 line => $token->{line},
3561 7 column => $token->{column}};
3562 7 next B;
3563 } elsif ($node->[1] & TABLE_SCOPING_EL) {
3564
3565 ## ISSUE: This case can never be reached, maybe.
3566 0 last;
3567 }
3568 }
3569  
3570
3571 $self->{parse_error}->(level => $self->{level}->{must}, type => 'start tag not allowed',
3572 0 text => $token->{tag_name}, token => $token);
3573 ## Ignore the token
3574
3575 0 $token = $self->_get_next_token;
3576 0 next B;
3577 } elsif (($self->{insertion_mode} & IM_MASK) == IN_CAPTION_IM) {
3578 1 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed', text => 'caption',
3579 token => $token);
3580
3581 ## NOTE: As if </caption>.
3582 ## have a table element in table scope
3583 1 my $i;
3584 INSCOPE: {
3585 1 for (reverse 0..$#{$self->{open_elements}}) {
3586 1 my $node = $self->{open_elements}->[$_];
3587 1 ▶ if ($node->[1] == CAPTION_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 327682) { } 1 0 1
elsif ($node->[1] & 512) { } 0 0 0
3588
3589 1 $i = $_;
3590 1 last INSCOPE;
3591 } elsif ($node->[1] & TABLE_SCOPING_EL) {
3592
3593 0 last;
3594 }
3595 }
3596  
3597
3598 $self->{parse_error}->(level => $self->{level}->{must}, type => 'start tag not allowed',
3599 0 text => $token->{tag_name}, token => $token);
3600 ## Ignore the token
3601
3602 0 $token = $self->_get_next_token;
3603 0 next B;
3604 } # INSCOPE
3605
3606 ## generate implied end tags
3607 1 ▶ while ($self->{open_elements}->[-1]->[1]
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[-1][1] & 8) 0 1 1
3608 & END_TAG_OPTIONAL_EL) {
3609
3610 0 pop @{$self->{open_elements}};
3611 }
3612  
3613 1 ▶ unless ($self->{open_elements}->[-1]->[1] == CAPTION_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 327682) { } 1 0 1
3614
3615 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
3616 0 text => $self->{open_elements}->[-1]->[0]->tagName,
3617 token => $token);
3618 } else {
3619
3620 }
3621
3622 1 splice @{$self->{open_elements}}, $i;
3623
3624 1 $clear_up_to_marker->($active_formatting_elements);
3625
3626 1 $self->{insertion_mode} = IN_TABLE_IM;
3627
3628 ## reprocess
3629
3630 1 next B;
3631 } else {
3632
3633 #
3634 }
3635 } else {
3636
3637 #
3638 }
3639 } elsif ($token->{type} == END_TAG_TOKEN) {
3640 393 ▶ if ($token->{tag_name} eq 'td' or $token->{tag_name} eq 'th') {
Branch: 6 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'td' or $token->{'tag_name'} eq 'th') { } 30 363 393
elsif ($token->{'tag_name'} eq 'caption') { } 4 359 363
elsif ({'table', 1, 'tbody', 1, 'tfoot', 1, 'thead', 1, 'tr', 1}->{$token->{'tag_name'}} and ($self->{'insertion_mode'} & 2047) == 49) { } 11 348 359
elsif ($token->{'tag_name'} eq 'table' and ($self->{'insertion_mode'} & 2047) == 50) { } 3 345 348
elsif ({'body', 1, 'col', 1, 'colgroup', 1, 'html', 1}->{$token->{'tag_name'}}) { } 57 288 345
elsif ({'tbody', 1, 'tfoot', 1, 'thead', 1, 'tr', 1}->{$token->{'tag_name'}} and ($self->{'insertion_mode'} & 2047) == 50) { } 0 288 288
Condition100%3/3
$token->{"tag_name"} eq "td" or $token->{"tag_name"} eq "th"
l!l&&r!l&&!r
291363
MC/DC100%2/2
$token->{"tag_name"} eq "td" or $token->{"tag_name"} eq "th"
$token->{"tag_name"} eq "td" $token->{"tag_name"} eq "th"
Truth table100%3/3
A or B
A= $token->{"tag_name"} eq "td"B= $token->{"tag_name"} eq "th"
ABresult
1X1
011
000
3641 30 ▶ if (($self->{insertion_mode} & IM_MASK) == IN_CELL_IM) {
Branch: 2 branches
BranchTrueFalseTotal
if (($self->{'insertion_mode'} & 2047) == 49) { } 29 1 30
elsif (($self->{'insertion_mode'} & 2047) == 50) { } 0 1 1
3642 ## have an element in table scope
3643 29 my $i;
3644 29 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
3645 35 my $node = $self->{open_elements}->[$_];
3646 35 ▶ if ($node->[0]->tagName eq $token->{tag_name}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[0]->tagName eq $token->{'tag_name'}) { } 29 6 35
elsif ($node->[1] & 512) { } 0 6 6
3647
3648 29 $i = $_;
3649 29 last INSCOPE;
3650 } elsif ($node->[1] & TABLE_SCOPING_EL) {
3651
3652 0 last INSCOPE;
3653 }
3654 } # INSCOPE
3655 29 ▶ unless (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $i) 0 29 29
3656
3657 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
3658 text => $token->{tag_name},
3659 0 token => $token);
3660 ## Ignore the token
3661 0 $token = $self->_get_next_token;
3662 0 next B;
3663 }
3664
3665 ## generate implied end tags
3666 29 ▶ while ($self->{open_elements}->[-1]->[1]
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[-1][1] & 8) 1 29 30
3667 & END_TAG_OPTIONAL_EL) {
3668
3669 1 pop @{$self->{open_elements}};
3670 }
3671  
3672 29 ▶ if ($self->{open_elements}->[-1]->[0]->tagName
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][0]->tagName ne $token->{'tag_name'}) { } 3 26 29
3673 ne $token->{tag_name}) {
3674
3675 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
3676 3 text => $self->{open_elements}->[-1]->[0]->tagName,
3677 token => $token);
3678 } else {
3679
3680 }
3681
3682 29 splice @{$self->{open_elements}}, $i;
3683
3684 29 $clear_up_to_marker->($active_formatting_elements);
3685
3686 29 $self->{insertion_mode} = IN_ROW_IM;
3687
3688 29 $token = $self->_get_next_token;
3689 29 next B;
3690 } elsif (($self->{insertion_mode} & IM_MASK) == IN_CAPTION_IM) {
3691
3692 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
3693 0 text => $token->{tag_name}, token => $token);
3694 ## Ignore the token
3695 0 $token = $self->_get_next_token;
3696 0 next B;
3697 } else {
3698
3699 #
3700 }
3701 } elsif ($token->{tag_name} eq 'caption') {
3702 4 ▶ if (($self->{insertion_mode} & IM_MASK) == IN_CAPTION_IM) {
Branch: 2 branches
BranchTrueFalseTotal
if (($self->{'insertion_mode'} & 2047) == 50) { } 3 1 4
elsif (($self->{'insertion_mode'} & 2047) == 49) { } 1 0 1
3703 ## have a table element in table scope
3704 3 my $i;
3705 INSCOPE: {
3706 3 for (reverse 0..$#{$self->{open_elements}}) {
3707 4 my $node = $self->{open_elements}->[$_];
3708 4 ▶ if ($node->[1] == CAPTION_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 327682) { } 3 1 4
elsif ($node->[1] & 512) { } 0 1 1
3709
3710 3 $i = $_;
3711 3 last INSCOPE;
3712 } elsif ($node->[1] & TABLE_SCOPING_EL) {
3713
3714 0 last;
3715 }
3716 }
3717  
3718
3719 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
3720 0 text => $token->{tag_name}, token => $token);
3721 ## Ignore the token
3722 0 $token = $self->_get_next_token;
3723 0 next B;
3724 } # INSCOPE
3725
3726 ## generate implied end tags
3727 3 ▶ while ($self->{open_elements}->[-1]->[1]
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[-1][1] & 8) 1 3 4
3728 & END_TAG_OPTIONAL_EL) {
3729
3730 1 pop @{$self->{open_elements}};
3731 }
3732
3733 3 ▶ unless ($self->{open_elements}->[-1]->[1] == CAPTION_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 327682) { } 3 0 3
3734
3735 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
3736 0 text => $self->{open_elements}->[-1]->[0]->tagName,
3737 token => $token);
3738 } else {
3739
3740 }
3741
3742 3 splice @{$self->{open_elements}}, $i;
3743
3744 3 $clear_up_to_marker->($active_formatting_elements);
3745
3746 3 $self->{insertion_mode} = IN_TABLE_IM;
3747
3748 3 $token = $self->_get_next_token;
3749 3 next B;
3750 } elsif (($self->{insertion_mode} & IM_MASK) == IN_CELL_IM) {
3751
3752 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
3753 1 text => $token->{tag_name}, token => $token);
3754 ## Ignore the token
3755 1 $token = $self->_get_next_token;
3756 1 next B;
3757 } else {
3758
3759 #
3760 }
3761 ▶ } elsif ({
Condition100%3/3
{"table", 1, "tbody", 1, "tfoot", 1, "thead", 1, "tr", 1}->{$token->{"tag_name"}} and ($self->{"insertion_mode"} & 2047) == 49
!ll&&!rl&&r
343511
MC/DC100%2/2
{"table", 1, "tbody", 1, "tfoot", 1, "thead", 1, "tr", 1}->{$token->{"tag_name"}} and ($self->{"insertion_mode"} & 2047) == 49
{"table", 1, "tbody", 1, "tfoot", 1, "thead", 1, "tr", 1}->{$token->{"tag_name"}} ($self->{"insertion_mode"} & 2047) == 49
Truth table100%3/3
A and B
A= {"table", 1, "tbody", 1, "tfoot", 1, "thead", 1, "tr", 1}->{$token->{"tag_name"}}B= ($self->{"insertion_mode"} & 2047) == 49
ABresult
0X0
100
111
3762 table => 1, tbody => 1, tfoot => 1,
3763 thead => 1, tr => 1,
3764 }->{$token->{tag_name}} and
3765 ($self->{insertion_mode} & IM_MASK) == IN_CELL_IM) {
3766 ## have an element in table scope
3767 11 my $i;
3768 my $tn;
3769 INSCOPE: {
3770 11 for (reverse 0..$#{$self->{open_elements}}) {
3771 42 my $node = $self->{open_elements}->[$_];
3772 42 ▶ if ($node->[0]->localname eq $token->{tag_name}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($node->[0]->localname eq $token->{'tag_name'}) { } 8 34 42
elsif ($node->[1] == 327697) { } 11 23 34
elsif ($node->[1] & 512) { } 3 20 23
3773
3774 8 $i = $_;
3775  
3776 ## Close the cell
3777
3778 8 $token->{self_closing} = $self->{self_closing};
3779 8 unshift @{$self->{token}}, $token;
3780 8 delete $self->{self_closing};
3781 # </x>
3782 $token = {type => END_TAG_TOKEN, tag_name => $tn,
3783 line => $token->{line},
3784 8 column => $token->{column}};
3785 8 next B;
3786 } elsif ($node->[1] == TABLE_CELL_EL) {
3787
3788 11 $tn = $node->[0]->tagName;
3789 ## NOTE: There is exactly one |td| or |th| element
3790 ## in scope in the stack of open elements by definition.
3791 } elsif ($node->[1] & TABLE_SCOPING_EL) {
3792 ## ISSUE: Can this be reached?
3793
3794 3 last;
3795 }
3796 }
3797  
3798
3799 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
3800 3 text => $token->{tag_name}, token => $token);
3801 ## Ignore the token
3802 3 $token = $self->_get_next_token;
3803 3 next B;
3804 } # INSCOPE
3805 ▶ } elsif ($token->{tag_name} eq 'table' and
Condition100%3/3
$token->{"tag_name"} eq "table" and ($self->{"insertion_mode"} & 2047) == 50
!ll&&!rl&&r
34413
MC/DC100%2/2
$token->{"tag_name"} eq "table" and ($self->{"insertion_mode"} & 2047) == 50
$token->{"tag_name"} eq "table" ($self->{"insertion_mode"} & 2047) == 50
Truth table100%3/3
A and B
A= $token->{"tag_name"} eq "table"B= ($self->{"insertion_mode"} & 2047) == 50
ABresult
0X0
100
111
3806 ($self->{insertion_mode} & IM_MASK) == IN_CAPTION_IM) {
3807 3 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed', text => 'caption',
3808 token => $token);
3809  
3810 ## As if </caption>
3811 ## have a table element in table scope
3812 3 my $i;
3813 3 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
3814 6 my $node = $self->{open_elements}->[$_];
3815 6 ▶ if ($node->[1] == CAPTION_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 327682) { } 3 3 6
elsif ($node->[1] & 512) { } 0 3 3
3816
3817 3 $i = $_;
3818 3 last INSCOPE;
3819 } elsif ($node->[1] & TABLE_SCOPING_EL) {
3820
3821 0 last INSCOPE;
3822 }
3823 } # INSCOPE
3824 3 ▶ unless (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $i) 0 3 3
3825
3826 ## TODO: Wrong error type?
3827 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
3828 text => 'caption', token => $token);
3829 ## Ignore the token
3830 0 $token = $self->_get_next_token;
3831 0 next B;
3832 }
3833
3834 ## generate implied end tags
3835 3 ▶ while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[-1][1] & 8) 1 3 4
3836
3837 1 pop @{$self->{open_elements}};
3838 }
3839  
3840 3 ▶ unless ($self->{open_elements}->[-1]->[1] == CAPTION_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 327682) { } 1 2 3
3841
3842 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
3843 2 text => $self->{open_elements}->[-1]->[0]
3844 ->tagName,
3845 token => $token);
3846 } else {
3847
3848 }
3849  
3850 3 splice @{$self->{open_elements}}, $i;
3851  
3852 3 $clear_up_to_marker->($active_formatting_elements);
3853  
3854 3 $self->{insertion_mode} = IN_TABLE_IM;
3855  
3856 ## reprocess
3857 3 next B;
3858 } elsif ({
3859 body => 1, col => 1, colgroup => 1, html => 1,
3860 }->{$token->{tag_name}}) {
3861 57 ▶ if ($self->{insertion_mode} & BODY_TABLE_IMS) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'insertion_mode'} & 32) { } 4 53 57
3862
3863 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
3864 4 text => $token->{tag_name}, token => $token);
3865 ## Ignore the token
3866 4 $token = $self->_get_next_token;
3867 4 next B;
3868 } else {
3869
3870 #
3871 }
3872 ▶ } elsif ({
Condition66%2/3
{"tbody", 1, "tfoot", 1, "thead", 1, "tr", 1}->{$token->{"tag_name"}} and ($self->{"insertion_mode"} & 2047) == 50
!ll&&!rl&&r
28710
MC/DC0%0/2
{"tbody", 1, "tfoot", 1, "thead", 1, "tr", 1}->{$token->{"tag_name"}} and ($self->{"insertion_mode"} & 2047) == 50
{"tbody", 1, "tfoot", 1, "thead", 1, "tr", 1}->{$token->{"tag_name"}} ($self->{"insertion_mode"} & 2047) == 50
Truth table66%2/3
A and B
A= {"tbody", 1, "tfoot", 1, "thead", 1, "tr", 1}->{$token->{"tag_name"}}B= ($self->{"insertion_mode"} & 2047) == 50
ABresult
0X0
100
111
3873 tbody => 1, tfoot => 1,
3874 thead => 1, tr => 1,
3875 }->{$token->{tag_name}} and
3876 ($self->{insertion_mode} & IM_MASK) == IN_CAPTION_IM) {
3877
3878 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
3879 0 text => $token->{tag_name}, token => $token);
3880 ## Ignore the token
3881 0 $token = $self->_get_next_token;
3882 0 next B;
3883 } else {
3884
3885 #
3886 }
3887 } elsif ($token->{type} == END_OF_FILE_TOKEN) {
3888 586 for my $entry (@{$self->{open_elements}}) {
3889 1400 ▶ unless ($entry->[1] & ALL_END_TAG_OPTIONAL_EL) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($entry->[1] & 16) 173 1227 1400
3890
3891 173 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in body:#eof', token => $token);
3892 173 last;
3893 }
3894 }
3895  
3896 ## Stop parsing.
3897 586 last B;
3898 } else {
3899 0 die "$0: $token->{type}: Unknown token type";
3900 }
3901  
3902 1412 $insert = $insert_to_current;
3903 #
3904 } elsif ($self->{insertion_mode} & TABLE_IMS) {
3905 397 ▶ if ($token->{type} == START_TAG_TOKEN) {
Branch: 3 branches
BranchTrueFalseTotal
if ($token->{'type'} == 3) { } 229 168 397
elsif ($token->{'type'} == 4) { } 126 42 168
elsif ($token->{'type'} == 5) { } 42 0 42
3906 229 ▶ if ({
Branch: 7 branches
BranchTrueFalseTotal
if ({'tr', ($self->{'insertion_mode'} & 2047) != 193, 'th', 1, 'td', 1}->{$token->{'tag_name'}}) { } 102 127 229
elsif ({'caption', 1, 'col', 1, 'colgroup', 1, 'tbody', 1, 'tfoot', 1, 'thead', 1, 'tr', 1}->{$token->{'tag_name'}}) { } 30 97 127
elsif ($token->{'tag_name'} eq 'table') { } 3 94 97
elsif ($token->{'tag_name'} eq 'style') { } 3 91 94
elsif ($token->{'tag_name'} eq 'script') { } 2 89 91
elsif ($token->{'tag_name'} eq 'input') { } 8 81 89
elsif ($token->{'tag_name'} eq 'form') { } 5 76 81
3907 tr => (($self->{insertion_mode} & IM_MASK) != IN_ROW_IM),
3908 th => 1, td => 1,
3909 }->{$token->{tag_name}}) {
3910 102 ▶ if (($self->{insertion_mode} & IM_MASK) == IN_TABLE_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if (($self->{"insertion_mode"} & 2047) == 64) 58 44 102
3911 ## Clear back to table context
3912 58 ▶ while (not ($self->{open_elements}->[-1]->[1]
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"open_elements"}[-1][1] & 512) 5 58 63
3913 & TABLE_SCOPING_EL)) {
3914
3915 5 pop @{$self->{open_elements}};
3916 }
3917
3918
3919 {
3920 58 my $el;
3921
3922 58 $el = $self->{document}->createElementNS((HTML_NS), 'tbody');
3923
3924 $self->_data($el, manakai_source_line => $token->{line})
3925 58 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 58 0 58
3926 $self->_data($el, manakai_source_column => $token->{column})
3927 58 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 58 0 58
3928 58 $self->_data($el, implied => __LINE__);
3929
3930 58 $self->{open_elements}->[-1]->[0]->appendChild ($el);
3931 58 ▶ push @{$self->{open_elements}}, [$el, $el_category->{'tbody'} || 0];
Condition50%1/2
$el_category->{'tbody'} || 0
l!l
580
MC/DC0%0/1
$el_category->{'tbody'} || 0
$el_category->{'tbody'}
Truth table50%1/2
A
A= $el_category->{'tbody'}
Aresult
11
00
3932 }
3933
3934 58 $self->{insertion_mode} = IN_TABLE_BODY_IM;
3935 ## reprocess in the "in table body" insertion mode...
3936 }
3937
3938 102 ▶ if (($self->{insertion_mode} & IM_MASK) == IN_TABLE_BODY_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if (($self->{'insertion_mode'} & 2047) == 194) { } 70 32 102
3939 70 ▶ unless ($token->{tag_name} eq 'tr') {
Branch: 1 branch
BranchTrueFalseTotal
unless ($token->{"tag_name"} eq "tr") 20 50 70
3940
3941 20 $self->{parse_error}->(level => $self->{level}->{must}, type => 'missing start tag:tr', token => $token);
3942 }
3943
3944 ## Clear back to table body context
3945 70 ▶ while (not ($self->{open_elements}->[-1]->[1]
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"open_elements"}[-1][1] & 256) 0 70 70
3946 & TABLE_ROWS_SCOPING_EL)) {
3947
3948 ## ISSUE: Can this case be reached?
3949 0 pop @{$self->{open_elements}};
3950 }
3951
3952 70 $self->{insertion_mode} = IN_ROW_IM;
3953 70 ▶ if ($token->{tag_name} eq 'tr') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'tr') { } 50 20 70
3954
3955
3956 {
3957 50 my $el;
3958
3959 50 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
3960
3961 50 for my $attr_name (keys %{ $token->{attributes}}) {
3962 0 my $attr_t = $token->{attributes}->{$attr_name};
3963 0 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
3964 0 $attr->setValue($attr_t->{value});
3965 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
3966 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
3967 0 $el->setAttributeNodeNS($attr);
3968 }
3969
3970 $self->_data($el, manakai_source_line => $token->{line})
3971 50 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 50 0 50
3972 $self->_data($el, manakai_source_column => $token->{column})
3973 50 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 50 0 50
3974
3975 50 $self->{open_elements}->[-1]->[0]->appendChild ($el);
3976 50 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
500
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
3977 }
3978
3979 50 ▶ $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
Branch: 1 branch
BranchTrueFalseTotal
if @$open_tables 50 0 50
3980
3981 50 $token = $self->_get_next_token;
3982 50 next B;
3983 } else {
3984
3985
3986 {
3987 20 my $el;
3988
3989 $el = $self->{document}->createElementNS
3990 20 ((HTML_NS), 'tr');
3991
3992 $self->_data($el, manakai_source_line => $token->{line})
3993 20 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 20 0 20
3994 $self->_data($el, manakai_source_column => $token->{column})
3995 20 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 20 0 20
3996 20 $self->_data($el, implied => __LINE__);
3997
3998 20 $self->{open_elements}->[-1]->[0]->appendChild ($el);
3999 20 ▶ push @{$self->{open_elements}}, [$el, $el_category->{'tr'} || 0];
Condition50%1/2
$el_category->{'tr'} || 0
l!l
200
MC/DC0%0/1
$el_category->{'tr'} || 0
$el_category->{'tr'}
Truth table50%1/2
A
A= $el_category->{'tr'}
Aresult
11
00
4000 }
4001
4002 ## reprocess in the "in row" insertion mode
4003 }
4004 } else {
4005
4006 }
4007  
4008 ## Clear back to table row context
4009 52 ▶ while (not ($self->{open_elements}->[-1]->[1]
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"open_elements"}[-1][1] & 128) 2 52 54
4010 & TABLE_ROW_SCOPING_EL)) {
4011
4012 2 pop @{$self->{open_elements}};
4013 }
4014
4015
4016 {
4017 52 my $el;
4018
4019 52 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
4020
4021 52 for my $attr_name (keys %{ $token->{attributes}}) {
4022 3 my $attr_t = $token->{attributes}->{$attr_name};
4023 3 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
4024 3 $attr->setValue($attr_t->{value});
4025 3 $self->_data($attr, manakai_source_line => $attr_t->{line});
4026 3 $self->_data($attr, manakai_source_column => $attr_t->{column});
4027 3 $el->setAttributeNodeNS ($attr);
4028 }
4029
4030 $self->_data($el, manakai_source_line => $token->{line})
4031 52 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 52 0 52
4032 $self->_data($el, manakai_source_column => $token->{column})
4033 52 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 52 0 52
4034
4035 52 $self->{open_elements}->[-1]->[0]->appendChild ($el);
4036 52 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
520
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
4037 }
4038
4039 52 ▶ $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
Branch: 1 branch
BranchTrueFalseTotal
if @$open_tables 52 0 52
4040 52 $self->{insertion_mode} = IN_CELL_IM;
4041  
4042 52 push @$active_formatting_elements, ['#marker', '', undef];
4043
4044
4045 52 $token = $self->_get_next_token;
4046 52 next B;
4047 } elsif ({
4048 caption => 1, col => 1, colgroup => 1,
4049 tbody => 1, tfoot => 1, thead => 1,
4050 tr => 1, # $self->{insertion_mode} == IN_ROW_IM
4051 }->{$token->{tag_name}}) {
4052 30 ▶ if (($self->{insertion_mode} & IM_MASK) == IN_ROW_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if (($self->{"insertion_mode"} & 2047) == 193) 2 28 30
4053 ## As if </tr>
4054 ## have an element in table scope
4055 2 my $i;
4056 2 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
4057 2 my $node = $self->{open_elements}->[$_];
4058 2 ▶ if ($node->[1] == TABLE_ROW_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 131281) { } 2 0 2
elsif ($node->[1] & 512) { } 0 0 0
4059
4060 2 $i = $_;
4061 2 last INSCOPE;
4062 } elsif ($node->[1] & TABLE_SCOPING_EL) {
4063
4064 0 last INSCOPE;
4065 }
4066 } # INSCOPE
4067 2 ▶ unless (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $i) 0 2 2
4068
4069 ## TODO: This type is wrong.
4070 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmacthed end tag',
4071 0 text => $token->{tag_name}, token => $token);
4072 ## Ignore the token
4073
4074 0 $token = $self->_get_next_token;
4075 0 next B;
4076 }
4077
4078 ## Clear back to table row context
4079 2 ▶ while (not ($self->{open_elements}->[-1]->[1]
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"open_elements"}[-1][1] & 128) 0 2 2
4080 & TABLE_ROW_SCOPING_EL)) {
4081
4082 ## ISSUE: Can this case be reached?
4083 0 pop @{$self->{open_elements}};
4084 }
4085
4086 2 pop @{$self->{open_elements}}; # tr
4087 2 $self->{insertion_mode} = IN_TABLE_BODY_IM;
4088 2 ▶ if ($token->{tag_name} eq 'tr') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'tr') { } 1 1 2
4089
4090 ## reprocess
4091
4092 1 next B;
4093 } else {
4094
4095 ## reprocess in the "in table body" insertion mode...
4096 }
4097 }
4098  
4099 29 ▶ if (($self->{insertion_mode} & IM_MASK) == IN_TABLE_BODY_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if (($self->{'insertion_mode'} & 2047) == 194) { } 1 28 29
4100 ## have an element in table scope
4101 1 my $i;
4102 1 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
4103 1 my $node = $self->{open_elements}->[$_];
4104 1 ▶ if ($node->[1] == TABLE_ROW_GROUP_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 131409) { } 1 0 1
elsif ($node->[1] & 512) { } 0 0 0
4105
4106 1 $i = $_;
4107 1 last INSCOPE;
4108 } elsif ($node->[1] & TABLE_SCOPING_EL) {
4109
4110 0 last INSCOPE;
4111 }
4112 } # INSCOPE
4113 1 ▶ unless (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $i) 0 1 1
4114
4115 ## TODO: This erorr type is wrong.
4116 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
4117 0 text => $token->{tag_name}, token => $token);
4118 ## Ignore the token
4119
4120 0 $token = $self->_get_next_token;
4121 0 next B;
4122 }
4123  
4124 ## Clear back to table body context
4125 1 ▶ while (not ($self->{open_elements}->[-1]->[1]
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"open_elements"}[-1][1] & 256) 0 1 1
4126 & TABLE_ROWS_SCOPING_EL)) {
4127
4128 ## ISSUE: Can this state be reached?
4129 0 pop @{$self->{open_elements}};
4130 }
4131
4132 ## As if <{current node}>
4133 ## have an element in table scope
4134 ## true by definition
4135
4136 ## Clear back to table body context
4137 ## nop by definition
4138
4139 1 pop @{$self->{open_elements}};
4140 1 $self->{insertion_mode} = IN_TABLE_IM;
4141 ## reprocess in "in table" insertion mode...
4142 } else {
4143
4144 }
4145  
4146 29 ▶ if ($token->{tag_name} eq 'col') {
Branch: 2 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'col') { } 3 26 29
elsif ({'caption', 1, 'colgroup', 1, 'tbody', 1, 'tfoot', 1, 'thead', 1}->{$token->{'tag_name'}}) { } 26 0 26
4147 ## Clear back to table context
4148 3 ▶ while (not ($self->{open_elements}->[-1]->[1]
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"open_elements"}[-1][1] & 512) 0 3 3
4149 & TABLE_SCOPING_EL)) {
4150
4151 ## ISSUE: Can this state be reached?
4152 0 pop @{$self->{open_elements}};
4153 }
4154
4155
4156 {
4157 3 my $el;
4158
4159 3 $el = $self->{document}->createElementNS((HTML_NS), 'colgroup');
4160
4161 $self->_data($el, manakai_source_line => $token->{line})
4162 3 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 3 0 3
4163 $self->_data($el, manakai_source_column => $token->{column})
4164 3 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 3 0 3
4165 3 $self->_data($el, implied => __LINE__);
4166
4167 3 $self->{open_elements}->[-1]->[0]->appendChild ($el);
4168 3 ▶ push @{$self->{open_elements}}, [$el, $el_category->{'colgroup'} || 0];
Condition50%1/2
$el_category->{'colgroup'} || 0
l!l
30
MC/DC0%0/1
$el_category->{'colgroup'} || 0
$el_category->{'colgroup'}
Truth table50%1/2
A
A= $el_category->{'colgroup'}
Aresult
11
00
4169 }
4170
4171 3 $self->{insertion_mode} = IN_COLUMN_GROUP_IM;
4172 ## reprocess
4173 3 ▶ $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
Branch: 1 branch
BranchTrueFalseTotal
if @$open_tables 3 0 3
4174
4175 3 next B;
4176 } elsif ({
4177 caption => 1,
4178 colgroup => 1,
4179 tbody => 1, tfoot => 1, thead => 1,
4180 }->{$token->{tag_name}}) {
4181 ## Clear back to table context
4182 26 ▶ while (not ($self->{open_elements}->[-1]->[1]
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"open_elements"}[-1][1] & 512) 0 26 26
4183 & TABLE_SCOPING_EL)) {
4184
4185 ## ISSUE: Can this state be reached?
4186 0 pop @{$self->{open_elements}};
4187 }
4188
4189 push @$active_formatting_elements, ['#marker', '', undef]
4190 26 ▶ if $token->{tag_name} eq 'caption';
Branch: 1 branch
BranchTrueFalseTotal
if $token->{"tag_name"} eq "caption" 10 16 26
4191
4192
4193 {
4194 26 my $el;
4195
4196 26 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
4197
4198 26 for my $attr_name (keys %{ $token->{attributes}}) {
4199 0 my $attr_t = $token->{attributes}->{$attr_name};
4200 0 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
4201 0 $attr->setValue($attr_t->{value});
4202 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
4203 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
4204 0 $el->setAttributeNodeNS ($attr);
4205 }
4206
4207 $self->_data($el, manakai_source_line => $token->{line})
4208 26 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 26 0 26
4209 $self->_data($el, manakai_source_column => $token->{column})
4210 26 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 26 0 26
4211
4212 26 $self->{open_elements}->[-1]->[0]->appendChild ($el);
4213 26 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
260
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
4214 }
4215
4216 26 ▶ $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
Branch: 1 branch
BranchTrueFalseTotal
if @$open_tables 26 0 26
4217 $self->{insertion_mode} = {
4218 caption => IN_CAPTION_IM,
4219 colgroup => IN_COLUMN_GROUP_IM,
4220 tbody => IN_TABLE_BODY_IM,
4221 tfoot => IN_TABLE_BODY_IM,
4222 thead => IN_TABLE_BODY_IM,
4223 26 }->{$token->{tag_name}};
4224 26 $token = $self->_get_next_token;
4225
4226 26 next B;
4227 } else {
4228 0 die "$0: in table: <>: $token->{tag_name}";
4229 }
4230 } elsif ($token->{tag_name} eq 'table') {
4231 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
4232 3 text => $self->{open_elements}->[-1]->[0]
4233 ->tagName,
4234 token => $token);
4235  
4236 ## As if </table>
4237 ## have a table element in table scope
4238 3 my $i;
4239 3 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
4240 6 my $node = $self->{open_elements}->[$_];
4241 6 ▶ if ($node->[1] == TABLE_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 328257) { } 3 3 6
elsif ($node->[1] & 512) { } 0 3 3
4242
4243 3 $i = $_;
4244 3 last INSCOPE;
4245 } elsif ($node->[1] & TABLE_SCOPING_EL) {
4246
4247 0 last INSCOPE;
4248 }
4249 } # INSCOPE
4250 3 ▶ unless (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $i) 0 3 3
4251
4252 ## TODO: The following is wrong, maybe.
4253 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag', text => 'table',
4254 token => $token);
4255 ## Ignore tokens </table><table>
4256
4257 0 $token = $self->_get_next_token;
4258 0 next B;
4259 }
4260
4261 ## TODO: Followings are removed from the latest spec.
4262 ## generate implied end tags
4263 3 ▶ while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[-1][1] & 8) 0 3 3
4264
4265 0 pop @{$self->{open_elements}};
4266 }
4267  
4268 3 ▶ unless ($self->{open_elements}->[-1]->[1] == TABLE_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 328257) { } 2 1 3
4269
4270 ## NOTE: |<table><tr><table>|
4271 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
4272 1 text => $self->{open_elements}->[-1]->[0]
4273 ->tagName,
4274 token => $token);
4275 } else {
4276
4277 }
4278  
4279 3 splice @{$self->{open_elements}}, $i;
4280 3 pop @{$open_tables};
4281  
4282 3 $self->_reset_insertion_mode;
4283  
4284 ## reprocess
4285
4286 3 next B;
4287 } elsif ($token->{tag_name} eq 'style') {
4288
4289 ## NOTE: This is a "as if in head" code clone.
4290 3 $parse_rcdata->($self, $insert, $open_tables, 0); # RAWTEXT
4291 3 ▶ $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
Branch: 1 branch
BranchTrueFalseTotal
if @$open_tables 3 0 3
4292 3 next B;
4293 } elsif ($token->{tag_name} eq 'script') {
4294
4295 ## NOTE: This is a "as if in head" code clone.
4296 2 $script_start_tag->($self, $insert, $open_tables);
4297 2 ▶ $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
Branch: 1 branch
BranchTrueFalseTotal
if @$open_tables 2 0 2
4298 2 next B;
4299 } elsif ($token->{tag_name} eq 'input') {
4300 8 ▶ if ($token->{attributes}->{type}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'attributes'}{'type'}) { } 7 1 8
4301 7 my $type = $token->{attributes}->{type}->{value};
4302 7 $type =~ tr/A-Z/a-z/; ## ASCII case-insensitive.
4303 7 ▶ if ($type eq 'hidden') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'hidden') { } 6 1 7
4304
4305 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in table',
4306 6 text => $token->{tag_name}, token => $token);
4307  
4308
4309 {
4310 6 my $el;
4311
4312 6 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
4313
4314 6 for my $attr_name (keys %{ $token->{attributes}}) {
4315 6 my $attr_t = $token->{attributes}->{$attr_name};
4316 6 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
4317 6 $attr->setValue($attr_t->{value});
4318 6 $self->_data($attr, manakai_source_line => $attr_t->{line});
4319 6 $self->_data($attr, manakai_source_column => $attr_t->{column});
4320 6 $el->setAttributeNodeNS ($attr);
4321 }
4322
4323 $self->_data($el, manakai_source_line => $token->{line})
4324 6 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 6 0 6
4325 $self->_data($el, manakai_source_column => $token->{column})
4326 6 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 6 0 6
4327
4328 6 $self->{open_elements}->[-1]->[0]->appendChild ($el);
4329 6 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
60
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
4330 }
4331
4332 6 ▶ $open_tables->[-1]->[2] = 0 if @$open_tables; # ~node inserted
Branch: 1 branch
BranchTrueFalseTotal
if @$open_tables 6 0 6
4333  
4334 ## TODO: form element pointer
4335  
4336 6 pop @{$self->{open_elements}};
4337  
4338 6 $token = $self->_get_next_token;
4339 6 delete $self->{self_closing};
4340 6 next B;
4341 } else {
4342
4343 #
4344 }
4345 } else {
4346
4347 #
4348 }
4349 } elsif ($token->{tag_name} eq 'form') {
4350 5 $self->{parse_error}->(level => $self->{level}->{must}, type => 'form in table', token => $token); # XXX documentation
4351
4352 5 ▶ if ($self->{form_element}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'form_element'}) { } 2 3 5
4353 ## Ignore the token.
4354 2 $token = $self->_get_next_token;
4355
4356 2 next B;
4357 } else {
4358
4359 {
4360 3 my $el;
4361
4362 3 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
4363
4364 3 for my $attr_name (keys %{ $token->{attributes}}) {
4365 0 my $attr_t = $token->{attributes}->{$attr_name};
4366 0 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
4367 0 $attr->setValue($attr_t->{value});
4368 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
4369 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
4370 0 $el->setAttributeNodeNS($attr);
4371 }
4372
4373 $self->_data($el, manakai_source_line => $token->{line})
4374 3 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 3 0 3
4375 $self->_data($el, manakai_source_column => $token->{column})
4376 3 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 3 0 3
4377
4378 3 $self->{open_elements}->[-1]->[0]->appendChild ($el);
4379 3 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
30
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
4380 }
4381
4382 3 $self->{form_element} = $self->{open_elements}->[-1]->[0];
4383
4384 3 pop @{$self->{open_elements}};
4385
4386 3 $token = $self->_get_next_token;
4387
4388 3 next B;
4389 }
4390 } else {
4391
4392 #
4393 }
4394  
4395 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in table', text => $token->{tag_name},
4396 78 token => $token);
4397  
4398 78 $insert = $insert_to_foster;
4399 #
4400 } elsif ($token->{type} == END_TAG_TOKEN) {
4401 126 ▶ if ($token->{tag_name} eq 'tr' and
Branch: 4 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'tr' and ($self->{'insertion_mode'} & 2047) == 193) { } 14 112 126
elsif ($token->{'tag_name'} eq 'table') { } 56 56 112
elsif ({'tbody', 1, 'tfoot', 1, 'thead', 1}->{$token->{'tag_name'}} and $self->{'insertion_mode'} & 128) { } 7 49 56
elsif ({'body', 1, 'caption', 1, 'col', 1, 'colgroup', 1, 'html', 1, 'td', 1, 'th', 1, 'tr', 1, 'tbody', 1, 'tfoot', 1, 'thead', 1}->{$token->{'tag_name'}}) { } 19 30 49
Condition100%3/3
$token->{"tag_name"} eq "tr" and ($self->{"insertion_mode"} & 2047) == 193
!ll&&!rl&&r
111114
MC/DC100%2/2
$token->{"tag_name"} eq "tr" and ($self->{"insertion_mode"} & 2047) == 193
$token->{"tag_name"} eq "tr" ($self->{"insertion_mode"} & 2047) == 193
Truth table100%3/3
A and B
A= $token->{"tag_name"} eq "tr"B= ($self->{"insertion_mode"} & 2047) == 193
ABresult
0X0
100
111
4402 ($self->{insertion_mode} & IM_MASK) == IN_ROW_IM) {
4403 ## have an element in table scope
4404 14 my $i;
4405 14 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
4406 14 my $node = $self->{open_elements}->[$_];
4407 14 ▶ if ($node->[1] == TABLE_ROW_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 131281) { } 14 0 14
elsif ($node->[1] & 512) { } 0 0 0
4408
4409 14 $i = $_;
4410 14 last INSCOPE;
4411 } elsif ($node->[1] & TABLE_SCOPING_EL) {
4412
4413 0 last INSCOPE;
4414 }
4415 } # INSCOPE
4416 14 ▶ unless (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $i) { } 14 0 14
4417
4418 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
4419 0 text => $token->{tag_name}, token => $token);
4420 ## Ignore the token
4421
4422 0 $token = $self->_get_next_token;
4423 0 next B;
4424 } else {
4425
4426 }
4427  
4428 ## Clear back to table row context
4429 14 ▶ while (not ($self->{open_elements}->[-1]->[1]
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"open_elements"}[-1][1] & 128) 0 14 14
4430 & TABLE_ROW_SCOPING_EL)) {
4431
4432 ## ISSUE: Can this state be reached?
4433 0 pop @{$self->{open_elements}};
4434 }
4435  
4436 14 pop @{$self->{open_elements}}; # tr
4437 14 $self->{insertion_mode} = IN_TABLE_BODY_IM;
4438 14 $token = $self->_get_next_token;
4439
4440 14 next B;
4441 } elsif ($token->{tag_name} eq 'table') {
4442 56 ▶ if (($self->{insertion_mode} & IM_MASK) == IN_ROW_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if (($self->{"insertion_mode"} & 2047) == 193) 13 43 56
4443 ## As if </tr>
4444 ## have an element in table scope
4445 13 my $i;
4446 13 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
4447 14 my $node = $self->{open_elements}->[$_];
4448 14 ▶ if ($node->[1] == TABLE_ROW_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 131281) { } 13 1 14
elsif ($node->[1] & 512) { } 0 1 1
4449
4450 13 $i = $_;
4451 13 last INSCOPE;
4452 } elsif ($node->[1] & TABLE_SCOPING_EL) {
4453
4454 0 last INSCOPE;
4455 }
4456 } # INSCOPE
4457 13 ▶ unless (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $i) 0 13 13
4458
4459 ## TODO: The following is wrong.
4460 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
4461 0 text => $token->{type}, token => $token);
4462 ## Ignore the token
4463
4464 0 $token = $self->_get_next_token;
4465 0 next B;
4466 }
4467
4468 ## Clear back to table row context
4469 13 ▶ while (not ($self->{open_elements}->[-1]->[1]
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"open_elements"}[-1][1] & 128) 1 13 14
4470 & TABLE_ROW_SCOPING_EL)) {
4471
4472 ## ISSUE: Can this state be reached?
4473 1 pop @{$self->{open_elements}};
4474 }
4475
4476 13 pop @{$self->{open_elements}}; # tr
4477 13 $self->{insertion_mode} = IN_TABLE_BODY_IM;
4478 ## reprocess in the "in table body" insertion mode...
4479 }
4480  
4481 56 ▶ if (($self->{insertion_mode} & IM_MASK) == IN_TABLE_BODY_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if (($self->{"insertion_mode"} & 2047) == 194) 21 35 56
4482 ## have an element in table scope
4483 21 my $i;
4484 21 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
4485 22 my $node = $self->{open_elements}->[$_];
4486 22 ▶ if ($node->[1] == TABLE_ROW_GROUP_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 131409) { } 21 1 22
elsif ($node->[1] & 512) { } 0 1 1
4487
4488 21 $i = $_;
4489 21 last INSCOPE;
4490 } elsif ($node->[1] & TABLE_SCOPING_EL) {
4491
4492 0 last INSCOPE;
4493 }
4494 } # INSCOPE
4495 21 ▶ unless (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $i) 0 21 21
4496
4497 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
4498 0 text => $token->{tag_name}, token => $token);
4499 ## Ignore the token
4500
4501 0 $token = $self->_get_next_token;
4502 0 next B;
4503 }
4504
4505 ## Clear back to table body context
4506 21 ▶ while (not ($self->{open_elements}->[-1]->[1]
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"open_elements"}[-1][1] & 256) 1 21 22
4507 & TABLE_ROWS_SCOPING_EL)) {
4508
4509 1 pop @{$self->{open_elements}};
4510 }
4511
4512 ## As if <{current node}>
4513 ## have an element in table scope
4514 ## true by definition
4515
4516 ## Clear back to table body context
4517 ## nop by definition
4518
4519 21 pop @{$self->{open_elements}};
4520 21 $self->{insertion_mode} = IN_TABLE_IM;
4521 ## reprocess in the "in table" insertion mode...
4522 }
4523  
4524 ## NOTE: </table> in the "in table" insertion mode.
4525 ## When you edit the code fragment below, please ensure that
4526 ## the code for <table> in the "in table" insertion mode
4527 ## is synced with it.
4528  
4529 ## have a table element in table scope
4530 56 my $i;
4531 56 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
4532 57 my $node = $self->{open_elements}->[$_];
4533 57 ▶ if ($node->[1] == TABLE_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 328257) { } 56 1 57
elsif ($node->[1] & 512) { } 0 1 1
4534
4535 56 $i = $_;
4536 56 last INSCOPE;
4537 } elsif ($node->[1] & TABLE_SCOPING_EL) {
4538
4539 0 last INSCOPE;
4540 }
4541 } # INSCOPE
4542 56 ▶ unless (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $i) 0 56 56
4543
4544 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
4545 0 text => $token->{tag_name}, token => $token);
4546 ## Ignore the token
4547
4548 0 $token = $self->_get_next_token;
4549 0 next B;
4550 }
4551
4552 56 splice @{$self->{open_elements}}, $i;
4553 56 pop @{$open_tables};
4554
4555 56 $self->_reset_insertion_mode;
4556
4557 56 $token = $self->_get_next_token;
4558 56 next B;
4559 ▶ } elsif ({
Condition100%3/3
{"tbody", 1, "tfoot", 1, "thead", 1}->{$token->{"tag_name"}} and $self->{"insertion_mode"} & 128
!ll&&!rl&&r
4637
MC/DC100%2/2
{"tbody", 1, "tfoot", 1, "thead", 1}->{$token->{"tag_name"}} and $self->{"insertion_mode"} & 128
{"tbody", 1, "tfoot", 1, "thead", 1}->{$token->{"tag_name"}} $self->{"insertion_mode"} & 128
Truth table100%3/3
A and B
A= {"tbody", 1, "tfoot", 1, "thead", 1}->{$token->{"tag_name"}}B= $self->{"insertion_mode"} & 128
ABresult
0X0
100
111
4560 tbody => 1, tfoot => 1, thead => 1,
4561 }->{$token->{tag_name}} and
4562 $self->{insertion_mode} & ROW_IMS) {
4563 7 ▶ if (($self->{insertion_mode} & IM_MASK) == IN_ROW_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if (($self->{"insertion_mode"} & 2047) == 193) 3 4 7
4564 ## have an element in table scope
4565 3 my $i;
4566 3 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
4567 6 my $node = $self->{open_elements}->[$_];
4568 6 ▶ if ($node->[0]->tagName eq $token->{tag_name}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[0]->tagName eq $token->{'tag_name'}) { } 3 3 6
elsif ($node->[1] & 512) { } 0 3 3
4569
4570 3 $i = $_;
4571 3 last INSCOPE;
4572 } elsif ($node->[1] & TABLE_SCOPING_EL) {
4573
4574 0 last INSCOPE;
4575 }
4576 } # INSCOPE
4577 3 ▶ unless (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $i) 0 3 3
4578
4579 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
4580 0 text => $token->{tag_name}, token => $token);
4581 ## Ignore the token
4582
4583 0 $token = $self->_get_next_token;
4584 0 next B;
4585 }
4586
4587 ## As if </tr>
4588 ## have an element in table scope
4589 11 ▶ no warnings; my $i; use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
4590 3 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
4591 3 my $node = $self->{open_elements}->[$_];
4592 3 ▶ if ($node->[1] == TABLE_ROW_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 131281) { } 3 0 3
elsif ($node->[1] & 512) { } 0 0 0
4593
4594 3 $i = $_;
4595 3 last INSCOPE;
4596 } elsif ($node->[1] & TABLE_SCOPING_EL) {
4597
4598 0 last INSCOPE;
4599 }
4600 } # INSCOPE
4601 3 ▶ unless (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $i) 0 3 3
4602
4603 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
4604 text => 'tr', token => $token);
4605 ## Ignore the token
4606
4607 0 $token = $self->_get_next_token;
4608 0 next B;
4609 }
4610
4611 ## Clear back to table row context
4612 3 ▶ while (not ($self->{open_elements}->[-1]->[1]
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"open_elements"}[-1][1] & 128) 0 3 3
4613 & TABLE_ROW_SCOPING_EL)) {
4614
4615 ## ISSUE: Can this case be reached?
4616 0 pop @{$self->{open_elements}};
4617 }
4618
4619 3 pop @{$self->{open_elements}}; # tr
4620 3 $self->{insertion_mode} = IN_TABLE_BODY_IM;
4621 ## reprocess in the "in table body" insertion mode...
4622 }
4623  
4624 ## have an element in table scope
4625 7 my $i;
4626 7 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
4627 7 my $node = $self->{open_elements}->[$_];
4628 7 ▶ if ($node->[0]->tagName eq $token->{tag_name}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[0]->tagName eq $token->{'tag_name'}) { } 7 0 7
elsif ($node->[1] & 512) { } 0 0 0
4629
4630 7 $i = $_;
4631 7 last INSCOPE;
4632 } elsif ($node->[1] & TABLE_SCOPING_EL) {
4633
4634 0 last INSCOPE;
4635 }
4636 } # INSCOPE
4637 7 ▶ unless (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $i) 0 7 7
4638
4639 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
4640 0 text => $token->{tag_name}, token => $token);
4641 ## Ignore the token
4642
4643 0 $token = $self->_get_next_token;
4644 0 next B;
4645 }
4646  
4647 ## Clear back to table body context
4648 7 ▶ while (not ($self->{open_elements}->[-1]->[1]
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"open_elements"}[-1][1] & 256) 0 7 7
4649 & TABLE_ROWS_SCOPING_EL)) {
4650
4651 ## ISSUE: Can this case be reached?
4652 0 pop @{$self->{open_elements}};
4653 }
4654  
4655 7 pop @{$self->{open_elements}};
4656 7 $self->{insertion_mode} = IN_TABLE_IM;
4657
4658 7 $token = $self->_get_next_token;
4659 7 next B;
4660 } elsif ({
4661 body => 1, caption => 1, col => 1, colgroup => 1,
4662 html => 1, td => 1, th => 1,
4663 tr => 1, # $self->{insertion_mode} == IN_ROW_IM
4664 tbody => 1, tfoot => 1, thead => 1, # $self->{insertion_mode} == IN_TABLE_IM
4665 }->{$token->{tag_name}}) {
4666
4667 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
4668 19 text => $token->{tag_name}, token => $token);
4669 ## Ignore the token
4670
4671 19 $token = $self->_get_next_token;
4672 19 next B;
4673 } else {
4674
4675 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in table:/',
4676 30 text => $token->{tag_name}, token => $token);
4677  
4678 30 $insert = $insert_to_foster;
4679 #
4680 }
4681 } elsif ($token->{type} == END_OF_FILE_TOKEN) {
4682 42 ▶ unless ($self->{open_elements}->[-1]->[1] == HTML_EL and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 328593 and @{$self->{'open_elements'};} == 1) { } 0 42 42
Condition33%1/3
$self->{"open_elements"}[-1][1] == 328593 and @{$self->{"open_elements"};} == 1
!ll&&!rl&&r
4200
MC/DC0%0/2
$self->{"open_elements"}[-1][1] == 328593 and @{$self->{"open_elements"};} == 1
$self->{"open_elements"}[-1][1] == 328593 @{$self->{"open_elements"};} == 1
Truth table33%1/3
A and B
A= $self->{"open_elements"}[-1][1] == 328593B= @{$self->{"open_elements"};} == 1
ABresult
0X0
100
111
4683 0 @{$self->{open_elements}} == 1) { # redundant, maybe
4684 42 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in body:#eof', token => $token);
4685
4686 #
4687 } else {
4688
4689 #
4690 }
4691  
4692 ## Stop parsing
4693 42 last B;
4694 } else {
4695 0 die "$0: $token->{type}: Unknown token type";
4696 }
4697 } elsif (($self->{insertion_mode} & IM_MASK) == IN_COLUMN_GROUP_IM) {
4698 8 ▶ if ($token->{type} == CHARACTER_TOKEN) {
Branch: 4 branches
BranchTrueFalseTotal
if ($token->{'type'} == 6) { } 0 8 8
elsif ($token->{'type'} == 3) { } 6 2 8
elsif ($token->{'type'} == 4) { } 1 1 2
elsif ($token->{'type'} == 5) { } 1 0 1
4699 0 ▶ if ($token->{data} =~ s/^([\x09\x0A\x0C\x20]+)//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"data"} =~ s/^([\x09\x0A\x0C\x20]+)//) 0 0 0
4700 0 $self->{open_elements}->[-1]->[0]->appendTextFromUnicode($self, $1, $token);
4701 0 ▶ unless (length $token->{data}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (length $token->{"data"}) 0 0 0
4702
4703 0 $token = $self->_get_next_token;
4704 0 next B;
4705 }
4706 }
4707
4708
4709 #
4710 } elsif ($token->{type} == START_TAG_TOKEN) {
4711 6 ▶ if ($token->{tag_name} eq 'col') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'col') { } 3 3 6
4712
4713
4714 {
4715 3 my $el;
4716
4717 3 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
4718
4719 3 for my $attr_name (keys %{ $token->{attributes}}) {
4720 1 my $attr_t = $token->{attributes}->{$attr_name};
4721 1 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
4722 1 $attr->setValue($attr_t->{value});
4723 1 $self->_data($attr, manakai_source_line => $attr_t->{line});
4724 1 $self->_data($attr, manakai_source_column => $attr_t->{column});
4725 1 $el->setAttributeNodeNS ($attr);
4726 }
4727
4728 $self->_data($el, manakai_source_line => $token->{line})
4729 3 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 3 0 3
4730 $self->_data($el, manakai_source_column => $token->{column})
4731 3 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 3 0 3
4732
4733 3 $self->{open_elements}->[-1]->[0]->appendChild ($el);
4734 3 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
30
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
4735 }
4736
4737 3 pop @{$self->{open_elements}};
4738 3 delete $self->{self_closing};
4739 3 $token = $self->_get_next_token;
4740 3 next B;
4741 } else {
4742
4743 #
4744 }
4745 } elsif ($token->{type} == END_TAG_TOKEN) {
4746 1 ▶ if ($token->{tag_name} eq 'colgroup') {
Branch: 2 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'colgroup') { } 0 1 1
elsif ($token->{'tag_name'} eq 'col') { } 0 1 1
4747 0 ▶ if ($self->{open_elements}->[-1]->[1] == HTML_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 328593) { } 0 0 0
4748
4749 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
4750 text => 'colgroup', token => $token);
4751 ## Ignore the token
4752 0 $token = $self->_get_next_token;
4753 0 next B;
4754 } else {
4755
4756 0 pop @{$self->{open_elements}}; # colgroup
4757 0 $self->{insertion_mode} = IN_TABLE_IM;
4758 0 $token = $self->_get_next_token;
4759 0 next B;
4760 }
4761 } elsif ($token->{tag_name} eq 'col') {
4762
4763 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
4764 text => 'col', token => $token);
4765 ## Ignore the token
4766 0 $token = $self->_get_next_token;
4767 0 next B;
4768 } else {
4769
4770 #
4771 }
4772 } elsif ($token->{type} == END_OF_FILE_TOKEN) {
4773 1 ▶ if ($self->{open_elements}->[-1]->[1] == HTML_EL and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 328593 and @{$self->{'open_elements'};} == 1) { } 0 1 1
Condition33%1/3
$self->{"open_elements"}[-1][1] == 328593 and @{$self->{"open_elements"};} == 1
!ll&&!rl&&r
100
MC/DC0%0/2
$self->{"open_elements"}[-1][1] == 328593 and @{$self->{"open_elements"};} == 1
$self->{"open_elements"}[-1][1] == 328593 @{$self->{"open_elements"};} == 1
Truth table33%1/3
A and B
A= $self->{"open_elements"}[-1][1] == 328593B= @{$self->{"open_elements"};} == 1
ABresult
0X0
100
111
4774 0 @{$self->{open_elements}} == 1) { # redundant, maybe
4775
4776 ## Stop parsing.
4777 0 last B;
4778 } else {
4779 ## NOTE: As if </colgroup>.
4780
4781 1 pop @{$self->{open_elements}}; # colgroup
4782 1 $self->{insertion_mode} = IN_TABLE_IM;
4783 ## Reprocess.
4784 1 next B;
4785 }
4786 } else {
4787 0 die "$0: $token->{type}: Unknown token type";
4788 }
4789  
4790 ## As if </colgroup>
4791 4 ▶ if ($self->{open_elements}->[-1]->[1] == HTML_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 328593) { } 0 4 4
4792
4793 ## TODO: Wrong error type?
4794 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
4795 text => 'colgroup', token => $token);
4796 ## Ignore the token
4797
4798 0 $token = $self->_get_next_token;
4799 0 next B;
4800 } else {
4801
4802 4 pop @{$self->{open_elements}}; # colgroup
4803 4 $self->{insertion_mode} = IN_TABLE_IM;
4804
4805 ## reprocess
4806 4 next B;
4807 }
4808 } elsif ($self->{insertion_mode} & SELECT_IMS) {
4809 131 ▶ if ($token->{type} == CHARACTER_TOKEN) {
Branch: 4 branches
BranchTrueFalseTotal
if ($token->{'type'} == 6) { } 17 114 131
elsif ($token->{'type'} == 3) { } 58 56 114
elsif ($token->{'type'} == 4) { } 41 15 56
elsif ($token->{'type'} == 5) { } 15 0 15
4810
4811 17 my $data = $token->{data};
4812 17 ▶ while ($data =~ s/\x00//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data =~ s/\x00//) 0 17 17
4813 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'NULL', token => $token);
4814 }
4815 17 ▶ $self->{open_elements}->[-1]->[0]->appendTextFromUnicode($self, $data, $token)
Branch: 1 branch
BranchTrueFalseTotal
if $data ne "" 17 0 17
4816 if $data ne '';
4817 17 $token = $self->_get_next_token;
4818 17 next B;
4819 } elsif ($token->{type} == START_TAG_TOKEN) {
4820 58 ▶ if ($token->{tag_name} eq 'option') {
Branch: 6 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'option') { } 15 43 58
elsif ($token->{'tag_name'} eq 'optgroup') { } 5 38 43
elsif ($token->{'tag_name'} eq 'select') { } 6 32 38
elsif ({'input', 1, 'textarea', 1, 'keygen', 1}->{$token->{'tag_name'}}) { } 2 30 32
elsif (($self->{'insertion_mode'} & 2047) == 1026 and {'caption', 1, 'table', 1, 'tbody', 1, 'tfoot', 1, 'thead', 1, 'tr', 1, 'td', 1, 'th', 1}->{$token->{'tag_name'}}) { } 10 20 30
elsif ($token->{'tag_name'} eq 'script') { } 3 17 20
4821 15 ▶ if ($self->{open_elements}->[-1]->[1] == OPTION_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 16394) { } 1 14 15
4822
4823 ## As if </option>
4824 1 pop @{$self->{open_elements}};
4825 } else {
4826
4827 }
4828  
4829
4830 {
4831 15 my $el;
4832
4833 15 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
4834
4835 15 for my $attr_name (keys %{ $token->{attributes}}) {
4836 0 my $attr_t = $token->{attributes}->{$attr_name};
4837 0 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
4838 0 $attr->setValue($attr_t->{value});
4839 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
4840 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
4841 0 $el->setAttributeNodeNS ($attr);
4842 }
4843
4844 $self->_data($el, manakai_source_line => $token->{line})
4845 15 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 15 0 15
4846 $self->_data($el, manakai_source_column => $token->{column})
4847 15 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 15 0 15
4848
4849 15 $self->{open_elements}->[-1]->[0]->appendChild ($el);
4850 15 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
150
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
4851 }
4852
4853
4854 15 $token = $self->_get_next_token;
4855 15 next B;
4856 } elsif ($token->{tag_name} eq 'optgroup') {
4857 5 ▶ if ($self->{open_elements}->[-1]->[1] == OPTION_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 16394) { } 2 3 5
4858
4859 ## As if </option>
4860 2 pop @{$self->{open_elements}};
4861 } else {
4862
4863 }
4864  
4865 5 ▶ if ($self->{open_elements}->[-1]->[1] == OPTGROUP_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 16393) { } 1 4 5
4866
4867 ## As if </optgroup>
4868 1 pop @{$self->{open_elements}};
4869 } else {
4870
4871 }
4872  
4873
4874 {
4875 5 my $el;
4876
4877 5 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
4878
4879 5 for my $attr_name (keys %{ $token->{attributes}}) {
4880 0 my $attr_t = $token->{attributes}->{$attr_name};
4881 0 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
4882 0 $attr->setValue($attr_t->{value});
4883 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
4884 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
4885 0 $el->setAttributeNodeNS ($attr);
4886 }
4887
4888 $self->_data($el, manakai_source_line => $token->{line})
4889 5 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 5 0 5
4890 $self->_data($el, manakai_source_column => $token->{column})
4891 5 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 5 0 5
4892
4893 5 $self->{open_elements}->[-1]->[0]->appendChild ($el);
4894 5 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
50
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
4895 }
4896
4897
4898 5 $token = $self->_get_next_token;
4899 5 next B;
4900  
4901 } elsif ($token->{tag_name} eq 'select') {
4902 ## "In select" / "in select in table" insertion mode,
4903 ## "select" start tag.
4904
4905  
4906 6 $self->{parse_error}->(level => $self->{level}->{must}, type => 'select in select', ## XXX: documentation
4907 token => $token);
4908  
4909 ## Act as if the token were </select>.
4910 $token = {type => END_TAG_TOKEN, tag_name => 'select',
4911 6 line => $token->{line}, column => $token->{column}};
4912 6 next B;
4913  
4914 } elsif ({
4915 input => 1, textarea => 1, keygen => 1,
4916 }->{$token->{tag_name}}) {
4917 ## "In select" / "in select in table" insertion mode,
4918 ## "input", "keygen", "textarea" start tag.
4919
4920 ## Parse error.
4921 2 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed', text => 'select',
4922 token => $token);
4923
4924 ## If there "have an element in select scope" where element
4925 ## is a |select| element.
4926 2 my $i;
4927 2 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
4928 2 my $node = $self->{open_elements}->[$_];
4929 2 ▶ if ($node->[1] == SELECT_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 131076) { } 2 0 2
elsif ($node->[1] == 16393 or $node->[1] == 16394) { } 0 0 0
4930
4931 2 $i = $_;
4932 2 last INSCOPE;
4933 ▶ } elsif ($node->[1] == OPTGROUP_EL or
Condition0%0/3
$node->[1] == 16393 or $node->[1] == 16394
l!l&&r!l&&!r
000
MC/DC0%0/2
$node->[1] == 16393 or $node->[1] == 16394
$node->[1] == 16393 $node->[1] == 16394
Truth table0%0/3
A or B
A= $node->[1] == 16393B= $node->[1] == 16394
ABresult
1X1
011
000
4934 $node->[1] == OPTION_EL) {
4935
4936 #
4937 } else {
4938
4939 0 last INSCOPE;
4940 }
4941 } # INSCOPE
4942 2 ▶ unless (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $i) 0 2 2
4943 ## Ignore the token.
4944
4945 0 $token = $self->_get_next_token;
4946 0 next B;
4947 }
4948  
4949 ## Otherwise, act as if there were </select>, then reprocess
4950 ## the token.
4951 2 $token->{self_closing} = $self->{self_closing};
4952 2 unshift @{$self->{token}}, $token;
4953 2 delete $self->{self_closing};
4954
4955 $token = {type => END_TAG_TOKEN, tag_name => 'select',
4956 2 line => $token->{line}, column => $token->{column}};
4957 2 next B;
4958
4959 ▶ } elsif (
Condition100%3/3
($self->{"insertion_mode"} & 2047) == 1026 and {"caption", 1, "table", 1, "tbody", 1, "tfoot", 1, "thead", 1, "tr", 1, "td", 1, "th", 1}->{$token->{"tag_name"}}
!ll&&!rl&&r
101010
MC/DC100%2/2
($self->{"insertion_mode"} & 2047) == 1026 and {"caption", 1, "table", 1, "tbody", 1, "tfoot", 1, "thead", 1, "tr", 1, "td", 1, "th", 1}->{$token->{"tag_name"}}
($self->{"insertion_mode"} & 2047) == 1026 {"caption", 1, "table", 1, "tbody", 1, "tfoot", 1, "thead", 1, "tr", 1, "td", 1, "th", 1}->{$token->{"tag_name"}}
Truth table100%3/3
A and B
A= ($self->{"insertion_mode"} & 2047) == 1026B= {"caption", 1, "table", 1, "tbody", 1, "tfoot", 1, "thead", 1, "tr", 1, "td", 1, "th", 1}->{$token->{"tag_name"}}
ABresult
0X0
100
111
4960 ($self->{insertion_mode} & IM_MASK) == IN_SELECT_IN_TABLE_IM and
4961 {
4962 caption => 1, table => 1, tbody => 1, tfoot => 1, thead => 1,
4963 tr => 1, td => 1, th => 1,
4964 }->{$token->{tag_name}}
4965 ) {
4966 ## "In select in table" insertion mode, table-related start
4967 ## tags.
4968  
4969 ## Parse error.
4970 10 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed', text => 'select',
4971 token => $token);
4972  
4973 ## Act as if there were </select>, then reprocess the token.
4974
4975 10 $token->{self_closing} = $self->{self_closing};
4976 10 unshift @{$self->{token}}, $token;
4977 10 delete $self->{self_closing};
4978
4979 $token = {type => END_TAG_TOKEN, tag_name => 'select',
4980 10 line => $token->{line}, column => $token->{column}};
4981 10 next B;
4982
4983 } elsif ($token->{tag_name} eq 'script') {
4984
4985 ## NOTE: This is an "as if in head" code clone
4986 3 $script_start_tag->($self, $insert, $open_tables);
4987 3 next B;
4988 } else {
4989
4990 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in select',
4991 17 text => $token->{tag_name}, token => $token);
4992 ## Ignore the token
4993
4994 17 $token = $self->_get_next_token;
4995 17 next B;
4996 }
4997
4998 } elsif ($token->{type} == END_TAG_TOKEN) {
4999 41 ▶ if ($token->{tag_name} eq 'optgroup') {
Branch: 4 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'optgroup') { } 4 37 41
elsif ($token->{'tag_name'} eq 'option') { } 1 36 37
elsif ($token->{'tag_name'} eq 'select') { } 27 9 36
elsif (($self->{'insertion_mode'} & 2047) == 1026 and {'caption', 1, 'table', 1, 'tbody', 1, 'tfoot', 1, 'thead', 1, 'tr', 1, 'td', 1, 'th', 1}->{$token->{'tag_name'}}) { } 3 6 9
5000 4 ▶ if ($self->{open_elements}->[-1]->[1] == OPTION_EL and
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 16394 and $self->{'open_elements'}[-2][1] == 16393) { } 1 3 4
elsif ($self->{'open_elements'}[-1][1] == 16393) { } 1 2 3
Condition100%3/3
$self->{"open_elements"}[-1][1] == 16394 and $self->{"open_elements"}[-2][1] == 16393
!ll&&!rl&&r
121
MC/DC100%2/2
$self->{"open_elements"}[-1][1] == 16394 and $self->{"open_elements"}[-2][1] == 16393
$self->{"open_elements"}[-1][1] == 16394 $self->{"open_elements"}[-2][1] == 16393
Truth table100%3/3
A and B
A= $self->{"open_elements"}[-1][1] == 16394B= $self->{"open_elements"}[-2][1] == 16393
ABresult
0X0
100
111
5001 $self->{open_elements}->[-2]->[1] == OPTGROUP_EL) {
5002
5003 ## As if </option>
5004 1 splice @{$self->{open_elements}}, -2;
5005 } elsif ($self->{open_elements}->[-1]->[1] == OPTGROUP_EL) {
5006
5007 1 pop @{$self->{open_elements}};
5008 } else {
5009
5010 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
5011 2 text => $token->{tag_name}, token => $token);
5012 ## Ignore the token
5013 }
5014
5015 4 $token = $self->_get_next_token;
5016 4 next B;
5017 } elsif ($token->{tag_name} eq 'option') {
5018 1 ▶ if ($self->{open_elements}->[-1]->[1] == OPTION_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 16394) { } 1 0 1
5019
5020 1 pop @{$self->{open_elements}};
5021 } else {
5022
5023 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
5024 0 text => $token->{tag_name}, token => $token);
5025 ## Ignore the token
5026 }
5027
5028 1 $token = $self->_get_next_token;
5029 1 next B;
5030
5031 } elsif ($token->{tag_name} eq 'select') {
5032 ## "In select" / "in select in table" insertion mode,
5033 ## "select" end tag.
5034
5035 ## There "have an element in select scope" where the element
5036 ## is |select|.
5037 27 my $i;
5038 27 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
5039 34 my $node = $self->{open_elements}->[$_];
5040 34 ▶ if ($node->[1] == SELECT_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 131076) { } 27 7 34
elsif ($node->[1] == 16394 or $node->[1] == 16393) { } 7 0 7
5041
5042 27 $i = $_;
5043 27 last INSCOPE;
5044 ▶ } elsif ($node->[1] == OPTION_EL or
Condition33%1/3
$node->[1] == 16394 or $node->[1] == 16393
l!l&&r!l&&!r
700
MC/DC0%0/2
$node->[1] == 16394 or $node->[1] == 16393
$node->[1] == 16394 $node->[1] == 16393
Truth table33%1/3
A or B
A= $node->[1] == 16394B= $node->[1] == 16393
ABresult
1X1
011
000
5045 $node->[1] == OPTGROUP_EL) {
5046
5047 #
5048 } else {
5049
5050 0 last INSCOPE;
5051 }
5052 } # INSCOPE
5053 27 ▶ unless (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $i) 0 27 27
5054
5055 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
5056 0 text => $token->{tag_name}, token => $token);
5057 ## Ignore the token.
5058
5059 0 $token = $self->_get_next_token;
5060 0 next B;
5061 }
5062
5063 ## Otherwise,
5064
5065 27 splice @{$self->{open_elements}}, $i;
5066  
5067 27 $self->_reset_insertion_mode;
5068  
5069
5070 27 $token = $self->_get_next_token;
5071 27 next B;
5072
5073 ▶ } elsif (
Condition100%3/3
($self->{"insertion_mode"} & 2047) == 1026 and {"caption", 1, "table", 1, "tbody", 1, "tfoot", 1, "thead", 1, "tr", 1, "td", 1, "th", 1}->{$token->{"tag_name"}}
!ll&&!rl&&r
243
MC/DC100%2/2
($self->{"insertion_mode"} & 2047) == 1026 and {"caption", 1, "table", 1, "tbody", 1, "tfoot", 1, "thead", 1, "tr", 1, "td", 1, "th", 1}->{$token->{"tag_name"}}
($self->{"insertion_mode"} & 2047) == 1026 {"caption", 1, "table", 1, "tbody", 1, "tfoot", 1, "thead", 1, "tr", 1, "td", 1, "th", 1}->{$token->{"tag_name"}}
Truth table100%3/3
A and B
A= ($self->{"insertion_mode"} & 2047) == 1026B= {"caption", 1, "table", 1, "tbody", 1, "tfoot", 1, "thead", 1, "tr", 1, "td", 1, "th", 1}->{$token->{"tag_name"}}
ABresult
0X0
100
111
5074 ($self->{insertion_mode} & IM_MASK) == IN_SELECT_IN_TABLE_IM and
5075 {
5076 caption => 1, table => 1, tbody => 1, tfoot => 1, thead => 1,
5077 tr => 1, td => 1, th => 1,
5078 }->{$token->{tag_name}}
5079 ) {
5080 ## "In select in table" insertion mode, table-related end
5081 ## tags.
5082
5083 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
5084 3 text => $token->{tag_name}, token => $token);
5085  
5086  
5087 ## There "have an element in table scope" where the element
5088 ## is same tag name as |$token|.
5089 3 my $i;
5090 3 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
5091 9 my $node = $self->{open_elements}->[$_];
5092 9 ▶ if ($node->[0]->tagName eq $token->{tag_name}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[0]->tagName eq $token->{'tag_name'}) { } 3 6 9
elsif ($node->[1] & 512) { } 0 6 6
5093
5094 3 $i = $_;
5095 3 last INSCOPE;
5096 } elsif ($node->[1] & TABLE_SCOPING_EL) {
5097
5098 0 last INSCOPE;
5099 }
5100 } # INSCOPE
5101 3 ▶ unless (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $i) 0 3 3
5102
5103 ## Ignore the token
5104
5105 0 $token = $self->_get_next_token;
5106 0 next B;
5107 }
5108  
5109 ## Act as if there were </select>, then reprocess the token.
5110 3 $token->{self_closing} = $self->{self_closing};
5111 3 unshift @{$self->{token}}, $token;
5112 3 delete $self->{self_closing};
5113
5114 $token = {type => END_TAG_TOKEN, tag_name => 'select',
5115 3 line => $token->{line}, column => $token->{column}};
5116 3 next B;
5117
5118 } else {
5119
5120 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in select:/',
5121 6 text => $token->{tag_name}, token => $token);
5122 ## Ignore the token
5123
5124 6 $token = $self->_get_next_token;
5125 6 next B;
5126 }
5127 } elsif ($token->{type} == END_OF_FILE_TOKEN) {
5128 15 ▶ unless ($self->{open_elements}->[-1]->[1] == HTML_EL and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 328593 and @{$self->{'open_elements'};} == 1) { } 0 15 15
Condition33%1/3
$self->{"open_elements"}[-1][1] == 328593 and @{$self->{"open_elements"};} == 1
!ll&&!rl&&r
1500
MC/DC0%0/2
$self->{"open_elements"}[-1][1] == 328593 and @{$self->{"open_elements"};} == 1
$self->{"open_elements"}[-1][1] == 328593 @{$self->{"open_elements"};} == 1
Truth table33%1/3
A and B
A= $self->{"open_elements"}[-1][1] == 328593B= @{$self->{"open_elements"};} == 1
ABresult
0X0
100
111
5129 0 @{$self->{open_elements}} == 1) { # redundant, maybe
5130
5131 15 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in body:#eof', token => $token);
5132 } else {
5133
5134 }
5135  
5136 ## Stop parsing.
5137 15 last B;
5138 } else {
5139 0 die "$0: $token->{type}: Unknown token type";
5140 }
5141 } elsif ($self->{insertion_mode} & BODY_AFTER_IMS) {
5142 93 ▶ if ($token->{type} == CHARACTER_TOKEN) {
Branch: 4 branches
BranchTrueFalseTotal
if ($token->{'type'} == 6) { } 12 81 93
elsif ($token->{'type'} == 3) { } 7 74 81
elsif ($token->{'type'} == 4) { } 38 36 74
elsif ($token->{'type'} == 5) { } 36 0 36
5143 12 ▶ if ($token->{data} =~ s/^([\x09\x0A\x0C\x20]+)//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"data"} =~ s/^([\x09\x0A\x0C\x20]+)//) 7 5 12
5144 7 my $data = $1;
5145 ## As if in body
5146 7 $reconstruct_active_formatting_elements
5147 ->($self, $insert_to_current, $active_formatting_elements, $open_tables);
5148
5149 7 $self->{open_elements}->[-1]->[0]->appendTextFromUnicode($self, $1, $token);
5150
5151 7 ▶ unless (length $token->{data}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (length $token->{"data"}) 5 2 7
5152
5153 5 $token = $self->_get_next_token;
5154 5 next B;
5155 }
5156 }
5157
5158 7 ▶ if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 260) { } 4 3 7
5159
5160 4 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after html:#text', token => $token);
5161 #
5162 } else {
5163
5164 ## "after body" insertion mode
5165 3 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after body:#text', token => $token);
5166 #
5167 }
5168  
5169 7 $self->{insertion_mode} = IN_BODY_IM;
5170 ## reprocess
5171 7 next B;
5172 } elsif ($token->{type} == START_TAG_TOKEN) {
5173 7 ▶ if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 260) { } 3 4 7
5174
5175 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after html',
5176 3 text => $token->{tag_name}, token => $token);
5177 #
5178 } else {
5179
5180 ## "after body" insertion mode
5181 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after body',
5182 4 text => $token->{tag_name}, token => $token);
5183 #
5184 }
5185  
5186 7 $self->{insertion_mode} = IN_BODY_IM;
5187
5188 ## reprocess
5189 7 next B;
5190 } elsif ($token->{type} == END_TAG_TOKEN) {
5191 38 ▶ if ($self->{insertion_mode} == AFTER_HTML_BODY_IM) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 260) { } 0 38 38
5192
5193 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after html:/',
5194 0 text => $token->{tag_name}, token => $token);
5195
5196 0 $self->{insertion_mode} = IN_BODY_IM;
5197 ## Reprocess.
5198 0 next B;
5199 } else {
5200
5201 }
5202  
5203 ## "after body" insertion mode
5204 38 ▶ if ($token->{tag_name} eq 'html') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'html') { } 36 2 38
5205 36 ▶ if (defined $self->{inner_html_node}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'inner_html_node'}) { } 0 36 36
5206
5207 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
5208 text => 'html', token => $token);
5209 ## Ignore the token
5210 0 $token = $self->_get_next_token;
5211 0 next B;
5212 } else {
5213
5214 36 $self->{insertion_mode} = AFTER_HTML_BODY_IM;
5215 36 $token = $self->_get_next_token;
5216 36 next B;
5217 }
5218 } else {
5219
5220 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after body:/',
5221 2 text => $token->{tag_name}, token => $token);
5222  
5223 2 $self->{insertion_mode} = IN_BODY_IM;
5224 ## reprocess
5225 2 next B;
5226 }
5227 } elsif ($token->{type} == END_OF_FILE_TOKEN) {
5228
5229 ## Stop parsing
5230 36 last B;
5231 } else {
5232 0 die "$0: $token->{type}: Unknown token type";
5233 }
5234 } elsif ($self->{insertion_mode} & FRAME_IMS) {
5235 90 ▶ if ($token->{type} == CHARACTER_TOKEN) {
Branch: 4 branches
BranchTrueFalseTotal
if ($token->{'type'} == 6) { } 3 87 90
elsif ($token->{'type'} == 3) { } 28 59 87
elsif ($token->{'type'} == 4) { } 30 29 59
elsif ($token->{'type'} == 5) { } 29 0 29
5236 3 ▶ if ($token->{data} =~ s/^([\x09\x0A\x0C\x20]+)//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"data"} =~ s/^([\x09\x0A\x0C\x20]+)//) 1 2 3
5237 1 $self->{open_elements}->[-1]->[0]->appendTextFromUnicode($self, $1, $token);
5238
5239 1 ▶ unless (length $token->{data}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (length $token->{"data"}) 1 0 1
5240
5241 1 $token = $self->_get_next_token;
5242 1 next B;
5243 }
5244 }
5245
5246 2 ▶ if ($token->{data} =~ s/^[^\x09\x0A\x0C\x20]+//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"data"} =~ s/^[^\x09\x0A\x0C\x20]+//) 2 0 2
5247 2 ▶ if ($self->{insertion_mode} == IN_FRAMESET_IM) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 513) { } 1 1 2
elsif ($self->{'insertion_mode'} == 514) { } 0 1 1
5248
5249 1 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in frameset:#text', token => $token);
5250 } elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) {
5251
5252 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after frameset:#text', token => $token);
5253 } else { # "after after frameset"
5254
5255 1 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after html:#text', token => $token);
5256 }
5257
5258 ## Ignore the token.
5259 2 ▶ if (length $token->{data}) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $token->{'data'}) { } 0 2 2
5260
5261 ## reprocess the rest of characters
5262 } else {
5263
5264 2 $token = $self->_get_next_token;
5265 }
5266 2 next B;
5267 }
5268
5269 0 die qq[$0: Character "$token->{data}"];
5270 } elsif ($token->{type} == START_TAG_TOKEN) {
5271 28 ▶ if ($token->{tag_name} eq 'frameset' and
Branch: 3 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'frameset' and $self->{'insertion_mode'} == 513) { } 1 27 28
elsif ($token->{'tag_name'} eq 'frame' and $self->{'insertion_mode'} == 513) { } 8 19 27
elsif ($token->{'tag_name'} eq 'noframes') { } 8 11 19
Condition66%2/3
$token->{"tag_name"} eq "frameset" and $self->{"insertion_mode"} == 513
!ll&&!rl&&r
2701
MC/DC50%1/2
$token->{"tag_name"} eq "frameset" and $self->{"insertion_mode"} == 513
$token->{"tag_name"} eq "frameset" $self->{"insertion_mode"} == 513
Truth table66%2/3
A and B
A= $token->{"tag_name"} eq "frameset"B= $self->{"insertion_mode"} == 513
ABresult
0X0
100
111
5272 $self->{insertion_mode} == IN_FRAMESET_IM) {
5273
5274
5275 {
5276 1 my $el;
5277
5278 1 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
5279
5280 1 for my $attr_name (keys %{ $token->{attributes}}) {
5281 0 my $attr_t = $token->{attributes}->{$attr_name};
5282 0 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
5283 0 $attr->setValue($attr_t->{value});
5284 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
5285 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
5286 0 $el->setAttributeNodeNS ($attr);
5287 }
5288
5289 $self->_data($el, manakai_source_line => $token->{line})
5290 1 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 1 0 1
5291 $self->_data($el, manakai_source_column => $token->{column})
5292 1 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 1 0 1
5293
5294 1 $self->{open_elements}->[-1]->[0]->appendChild ($el);
5295 1 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
10
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
5296 }
5297
5298
5299 1 $token = $self->_get_next_token;
5300 1 next B;
5301 ▶ } elsif ($token->{tag_name} eq 'frame' and
Condition66%2/3
$token->{"tag_name"} eq "frame" and $self->{"insertion_mode"} == 513
!ll&&!rl&&r
1908
MC/DC50%1/2
$token->{"tag_name"} eq "frame" and $self->{"insertion_mode"} == 513
$token->{"tag_name"} eq "frame" $self->{"insertion_mode"} == 513
Truth table66%2/3
A and B
A= $token->{"tag_name"} eq "frame"B= $self->{"insertion_mode"} == 513
ABresult
0X0
100
111
5302 $self->{insertion_mode} == IN_FRAMESET_IM) {
5303
5304
5305 {
5306 8 my $el;
5307
5308 8 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
5309
5310 8 for my $attr_name (keys %{ $token->{attributes}}) {
5311 0 my $attr_t = $token->{attributes}->{$attr_name};
5312 0 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
5313 0 $attr->setValue($attr_t->{value});
5314 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
5315 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
5316 0 $el->setAttributeNodeNS ($attr);
5317 }
5318
5319 $self->_data($el, manakai_source_line => $token->{line})
5320 8 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 8 0 8
5321 $self->_data($el, manakai_source_column => $token->{column})
5322 8 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 8 0 8
5323
5324 8 $self->{open_elements}->[-1]->[0]->appendChild ($el);
5325 8 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
80
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
5326 }
5327
5328 8 pop @{$self->{open_elements}};
5329 8 delete $self->{self_closing};
5330 8 $token = $self->_get_next_token;
5331 8 next B;
5332 } elsif ($token->{tag_name} eq 'noframes') {
5333
5334 ## NOTE: As if in head.
5335 8 $parse_rcdata->($self, $insert, $open_tables, 0); # RAWTEXT
5336 8 next B;
5337  
5338 ## NOTE: |<!DOCTYPE HTML><frameset></frameset></html><noframes></noframes>|
5339 ## has no parse error.
5340 } else {
5341 11 ▶ if ($self->{insertion_mode} == IN_FRAMESET_IM) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 513) { } 5 6 11
elsif ($self->{'insertion_mode'} == 514) { } 5 1 6
5342
5343 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in frameset',
5344 5 text => $token->{tag_name}, token => $token);
5345 } elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) {
5346
5347 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after frameset',
5348 5 text => $token->{tag_name}, token => $token);
5349 } else { # "after after frameset"
5350
5351 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after after frameset',
5352 1 text => $token->{tag_name}, token => $token);
5353 }
5354 ## Ignore the token
5355
5356 11 $token = $self->_get_next_token;
5357 11 next B;
5358 }
5359 } elsif ($token->{type} == END_TAG_TOKEN) {
5360 30 ▶ if ($token->{tag_name} eq 'frameset' and
Branch: 2 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'frameset' and $self->{'insertion_mode'} == 513) { } 14 16 30
elsif ($token->{'tag_name'} eq 'html' and $self->{'insertion_mode'} == 514) { } 10 6 16
Condition66%2/3
$token->{"tag_name"} eq "frameset" and $self->{"insertion_mode"} == 513
!ll&&!rl&&r
16014
MC/DC50%1/2
$token->{"tag_name"} eq "frameset" and $self->{"insertion_mode"} == 513
$token->{"tag_name"} eq "frameset" $self->{"insertion_mode"} == 513
Truth table66%2/3
A and B
A= $token->{"tag_name"} eq "frameset"B= $self->{"insertion_mode"} == 513
ABresult
0X0
100
111
5361 $self->{insertion_mode} == IN_FRAMESET_IM) {
5362 14 ▶ if ($self->{open_elements}->[-1]->[1] == HTML_EL and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 328593 and @{$self->{'open_elements'};} == 1) { } 0 14 14
Condition33%1/3
$self->{"open_elements"}[-1][1] == 328593 and @{$self->{"open_elements"};} == 1
!ll&&!rl&&r
1400
MC/DC0%0/2
$self->{"open_elements"}[-1][1] == 328593 and @{$self->{"open_elements"};} == 1
$self->{"open_elements"}[-1][1] == 328593 @{$self->{"open_elements"};} == 1
Truth table33%1/3
A and B
A= $self->{"open_elements"}[-1][1] == 328593B= @{$self->{"open_elements"};} == 1
ABresult
0X0
100
111
5363 0 @{$self->{open_elements}} == 1) {
5364
5365 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
5366 0 text => $token->{tag_name}, token => $token);
5367 ## Ignore the token
5368 0 $token = $self->_get_next_token;
5369 } else {
5370
5371 14 pop @{$self->{open_elements}};
5372 14 $token = $self->_get_next_token;
5373 }
5374  
5375 14 ▶ if (not defined $self->{inner_html_node} and
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $self->{'inner_html_node'} || $self->{'open_elements'}[-1][1] == 131074) { } 13 1 14
Condition66%2/3
defined $self->{'inner_html_node'} || $self->{'open_elements'}[-1][1] == 131074
l!l&&r!l&&!r
0113
MC/DC50%1/2
defined $self->{'inner_html_node'} || $self->{'open_elements'}[-1][1] == 131074
defined $self->{'inner_html_node'} $self->{'open_elements'}[-1][1] == 131074
Truth table66%2/3
A || B
A= defined $self->{'inner_html_node'}B= $self->{'open_elements'}[-1][1] == 131074
ABresult
1X1
011
000
5376 not ($self->{open_elements}->[-1]->[1] == FRAMESET_EL)) {
5377
5378 13 $self->{insertion_mode} = AFTER_FRAMESET_IM;
5379 } else {
5380
5381 }
5382 14 next B;
5383 ▶ } elsif ($token->{tag_name} eq 'html' and
Condition66%2/3
$token->{"tag_name"} eq "html" and $self->{"insertion_mode"} == 514
!ll&&!rl&&r
6010
MC/DC50%1/2
$token->{"tag_name"} eq "html" and $self->{"insertion_mode"} == 514
$token->{"tag_name"} eq "html" $self->{"insertion_mode"} == 514
Truth table66%2/3
A and B
A= $token->{"tag_name"} eq "html"B= $self->{"insertion_mode"} == 514
ABresult
0X0
100
111
5384 $self->{insertion_mode} == AFTER_FRAMESET_IM) {
5385
5386 10 $self->{insertion_mode} = AFTER_HTML_FRAMESET_IM;
5387 10 $token = $self->_get_next_token;
5388 10 next B;
5389 } else {
5390 6 ▶ if ($self->{insertion_mode} == IN_FRAMESET_IM) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'insertion_mode'} == 513) { } 3 3 6
elsif ($self->{'insertion_mode'} == 514) { } 2 1 3
5391
5392 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in frameset:/',
5393 3 text => $token->{tag_name}, token => $token);
5394 } elsif ($self->{insertion_mode} == AFTER_FRAMESET_IM) {
5395
5396 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after frameset:/',
5397 2 text => $token->{tag_name}, token => $token);
5398 } else { # "after after html"
5399
5400 $self->{parse_error}->(level => $self->{level}->{must}, type => 'after after frameset:/',
5401 1 text => $token->{tag_name}, token => $token);
5402 }
5403 ## Ignore the token
5404 6 $token = $self->_get_next_token;
5405 6 next B;
5406 }
5407 } elsif ($token->{type} == END_OF_FILE_TOKEN) {
5408 29 ▶ unless ($self->{open_elements}->[-1]->[1] == HTML_EL and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][1] == 328593 and @{$self->{'open_elements'};} == 1) { } 13 16 29
Condition66%2/3
$self->{"open_elements"}[-1][1] == 328593 and @{$self->{"open_elements"};} == 1
!ll&&!rl&&r
16013
MC/DC50%1/2
$self->{"open_elements"}[-1][1] == 328593 and @{$self->{"open_elements"};} == 1
$self->{"open_elements"}[-1][1] == 328593 @{$self->{"open_elements"};} == 1
Truth table66%2/3
A and B
A= $self->{"open_elements"}[-1][1] == 328593B= @{$self->{"open_elements"};} == 1
ABresult
0X0
100
111
5409 13 @{$self->{open_elements}} == 1) { # redundant, maybe
5410
5411 16 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in body:#eof', token => $token);
5412 } else {
5413
5414 }
5415
5416 ## Stop parsing
5417 29 last B;
5418 } else {
5419 0 die "$0: $token->{type}: Unknown token type";
5420 }
5421 } else {
5422 0 die "$0: $self->{insertion_mode}: Unknown insertion mode";
5423 }
5424  
5425 ## "in body" insertion mode
5426 1520 ▶ if ($token->{type} == START_TAG_TOKEN) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token->{'type'} == 3) { } 1148 372 1520
elsif ($token->{'type'} == 4) { } 372 0 372
5427 1148 ▶ if ($token->{tag_name} eq 'script') {
Branch: 22 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'script') { } 29 1119 1148
elsif ($token->{'tag_name'} eq 'style') { } 6 1113 1119
elsif ({'base', 1, 'command', 1, 'link', 1, 'basefont', 1, 'bgsound', 1}->{$token->{'tag_name'}}) { } 10 1103 1113
elsif ($token->{'tag_name'} eq 'meta') { } 9 1094 1103
elsif ($token->{'tag_name'} eq 'title') { } 10 1084 1094
elsif ($token->{'tag_name'} eq 'body') { } 7 1077 1084
elsif ($token->{'tag_name'} eq 'frameset') { } 39 1038 1077
elsif ({'address', 1, 'article', 1, 'aside', 1, 'blockquote', 1, 'center', 1, 'details', 1, 'dir', 1, 'div', 1, 'dl', 1, 'fieldset', 1, 'figcaption', 1, 'figure', 1, 'footer', 1, 'header', 1, 'hgroup', 1, 'menu', 1, 'nav', 1, 'ol', 1, 'p', 1, 'section', 1, 'ul', 1, 'summary', 1, 'h1', 1, 'h2', 1, 'h3', 1, 'h4', 1, 'h5', 1, 'h6', 1, 'pre', 1, 'listing', 1, 'form', 1, 'table', 1, 'hr', 1}->{$token->{'tag_name'}}) { } 455 583 1038
elsif ($token->{'tag_name'} eq 'li') { } 15 568 583
elsif ($token->{'tag_name'} eq 'dt' or $token->{'tag_name'} eq 'dd') { } 19 549 568
elsif ($token->{'tag_name'} eq 'plaintext') { } 15 534 549
elsif ($token->{'tag_name'} eq 'a') { } 34 500 534
elsif ($token->{'tag_name'} eq 'nobr') { } 68 432 500
elsif ($token->{'tag_name'} eq 'button') { } 27 405 432
elsif ({'xmp', 1, 'iframe', 1, 'noembed', 1, 'noframes', 1, 'noscript', 0}->{$token->{'tag_name'}}) { } 3 402 405
elsif ($token->{'tag_name'} eq 'isindex') { } 9 393 402
elsif ($token->{'tag_name'} eq 'textarea') { } 10 383 393
elsif ($token->{'tag_name'} eq 'optgroup' or $token->{'tag_name'} eq 'option') { } 12 371 383
elsif ($token->{'tag_name'} eq 'rt' or $token->{'tag_name'} eq 'rp') { } 8 363 371
elsif ($token->{'tag_name'} eq 'math' or $token->{'tag_name'} eq 'svg') { } 106 257 363
elsif ({'caption', 1, 'col', 1, 'colgroup', 1, 'frame', 1, 'head', 1, 'tbody', 1, 'td', 1, 'tfoot', 1, 'th', 1, 'thead', 1, 'tr', 1}->{$token->{'tag_name'}}) { } 8 249 257
elsif ($token->{'tag_name'} eq 'param' or $token->{'tag_name'} eq 'source' or $token->{'tag_name'} eq 'track') { } 3 246 249
5428
5429 ## NOTE: This is an "as if in head" code clone
5430 29 $script_start_tag->($self, $insert, $open_tables);
5431 29 next B;
5432 } elsif ($token->{tag_name} eq 'style') {
5433
5434 ## NOTE: This is an "as if in head" code clone
5435 6 $parse_rcdata->($self, $insert, $open_tables, 0); # RAWTEXT
5436 6 next B;
5437 } elsif ({
5438 base => 1, command => 1, link => 1, basefont => 1, bgsound => 1,
5439 }->{$token->{tag_name}}) {
5440
5441 ## NOTE: This is an "as if in head" code clone, only "-t" differs
5442
5443 {
5444 10 my $el;
5445
5446 10 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
5447
5448 10 for my $attr_name (keys %{ $token->{attributes}}) {
5449 1 my $attr_t = $token->{attributes}->{$attr_name};
5450 1 my $attr = $self->{document}->createAttributeNS (undef, $attr_name);
5451 1 $attr->setValue($attr_t->{value});
5452 1 $self->_data($attr, manakai_source_line => $attr_t->{line});
5453 1 $self->_data($attr, manakai_source_column => $attr_t->{column});
5454 1 $el->setAttributeNodeNS ($attr);
5455 }
5456
5457 $self->_data($el, manakai_source_line => $token->{line})
5458 10 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 10 0 10
5459 $self->_data($el, manakai_source_column => $token->{column})
5460 10 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 10 0 10
5461
5462 10 $insert->($self, $el, $open_tables);
5463 10 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
100
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
5464 }
5465
5466 10 pop @{$self->{open_elements}};
5467 10 delete $self->{self_closing};
5468 10 $token = $self->_get_next_token;
5469 10 next B;
5470 } elsif ($token->{tag_name} eq 'meta') {
5471 ## NOTE: This is an "as if in head" code clone, only "-t" differs
5472
5473 {
5474 9 my $el;
5475
5476 9 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
5477
5478 9 for my $attr_name (keys %{ $token->{attributes}}) {
5479 5 my $attr_t = $token->{attributes}->{$attr_name};
5480 5 my $attr = $self->{document}->createAttributeNS (undef, $attr_name);
5481 5 $attr->setValue($attr_t->{value});
5482 5 $self->_data($attr, manakai_source_line => $attr_t->{line});
5483 5 $self->_data($attr, manakai_source_column => $attr_t->{column});
5484 5 $el->setAttributeNodeNS ($attr);
5485 }
5486
5487 $self->_data($el, manakai_source_line => $token->{line})
5488 9 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 9 0 9
5489 $self->_data($el, manakai_source_column => $token->{column})
5490 9 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 9 0 9
5491
5492 9 $insert->($self, $el, $open_tables);
5493 9 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
90
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
5494 }
5495
5496 9 my $meta_el = pop @{$self->{open_elements}};
5497  
5498 9 ▶ unless ($self->{confident}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'confident'}) { } 0 9 9
5499 9 ▶ if ($token->{attributes}->{charset}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token->{'attributes'}{'charset'}) { } 0 9 9
elsif ($token->{'attributes'}{'content'} and $token->{'attributes'}{'http-equiv'}) { } 2 14 16
5500
5501 ## NOTE: Whether the encoding is supported or not is
5502 ## handled in the {change_encoding} callback.
5503 $self->{change_encoding}
5504 0 ->($self, $token->{attributes}->{charset}->{value}, $token);
5505
5506 $self->_data($meta_el->[0]->getAttributeNodeNS(undef, 'charset'),
5507 0 manakai_has_reference => $token->{attributes}->{charset}->{has_reference});
5508
5509 ▶ } elsif ($token->{attributes}->{content} and
Condition66%2/3
$token->{"attributes"}{"content"} and $token->{"attributes"}{"http-equiv"}
!ll&&!rl&&r
702
MC/DC50%1/2
$token->{"attributes"}{"content"} and $token->{"attributes"}{"http-equiv"}
$token->{"attributes"}{"content"} $token->{"attributes"}{"http-equiv"}
Truth table66%2/3
A and B
A= $token->{"attributes"}{"content"}B= $token->{"attributes"}{"http-equiv"}
ABresult
0X0
100
111
5510 $token->{attributes}->{'http-equiv'}) {
5511 2 ▶ if ($token->{attributes}->{'http-equiv'}->{value}
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"attributes"}{"http-equiv"}{"value"} =~ /\A[Cc][Oo][Nn][Tt][Ee][Nn][Tt]-[Tt][Yy][Pp][Ee]\z/ and $token->{"attributes"}{"content"}{"value"} =~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt] [\x09\x0A\x0C\x0D\x20]*= [\x09\x0A\x0C\x0D\x20]*(?>"([^"]*)"|'([^']*)'| ([^"'\x09\x0A\x0C\x0D\x20][^\x09\x0A\x0C\x0D\x20\x3B]*)) /x) 2 0 2
Condition33%1/3
$token->{"attributes"}{"http-equiv"}{"value"} =~ /\A[Cc][Oo][Nn][Tt][Ee][Nn][Tt]-[Tt][Yy][Pp][Ee]\z/ and $token->{"attributes"}{"content"}{"value"} =~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt] [\x09\x0A\x0C\x0D\x20]*= [\x09\x0A\x0C\x0D\x20]*(?>"([^"]*)"|'([^']*)'| ([^"'\x09\x0A\x0C\x0D\x20][^\x09\x0A\x0C\x0D\x20\x3B]*)) /x
!ll&&!rl&&r
002
MC/DC0%0/2
$token->{"attributes"}{"http-equiv"}{"value"} =~ /\A[Cc][Oo][Nn][Tt][Ee][Nn][Tt]-[Tt][Yy][Pp][Ee]\z/ and $token->{"attributes"}{"content"}{"value"} =~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt] [\x09\x0A\x0C\x0D\x20]*= [\x09\x0A\x0C\x0D\x20]*(?>"([^"]*)"|'([^']*)'| ([^"'\x09\x0A\x0C\x0D\x20][^\x09\x0A\x0C\x0D\x20\x3B]*)) /x
$token->{"attributes"}{"http-equiv"}{"value"} =~ /\A[Cc][Oo][Nn][Tt][Ee][Nn][Tt]-[Tt][Yy][Pp][Ee]\z/ $token->{"attributes"}{"content"}{"value"} =~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt] [\x09\x0A\x0C\x0D\x20]*= [\x09\x0A\x0C\x0D\x20]*(?>"([^"]*)"|'([^']*)'| ([^"'\x09\x0A\x0C\x0D\x20][^\x09\x0A\x0C\x0D\x20\x3B]*)) /x
Truth table33%1/3
A and B
A= $token->{"attributes"}{"http-equiv"}{"value"} =~ /\A[Cc][Oo][Nn][Tt][Ee][Nn][Tt]-[Tt][Yy][Pp][Ee]\z/B= $token->{"attributes"}{"content"}{"value"} =~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt] [\x09\x0A\x0C\x0D\x20]*= [\x09\x0A\x0C\x0D\x20]*(?>"([^"]*)"|'([^']*)'| ([^"'\x09\x0A\x0C\x0D\x20][^\x09\x0A\x0C\x0D\x20\x3B]*)) /x
ABresult
0X0
100
111
5512 =~ /\A[Cc][Oo][Nn][Tt][Ee][Nn][Tt]-[Tt][Yy][Pp][Ee]\z/ and
5513 $token->{attributes}->{content}->{value}
5514 =~ /[Cc][Hh][Aa][Rr][Ss][Ee][Tt]
5515 [\x09\x0A\x0C\x0D\x20]*=
5516 [\x09\x0A\x0C\x0D\x20]*(?>"([^"]*)"|'([^']*)'|
5517 ([^"'\x09\x0A\x0C\x0D\x20][^\x09\x0A\x0C\x0D\x20\x3B]*))
5518 /x) {
5519
5520 ## NOTE: Whether the encoding is supported or not is handled
5521 ## in the {change_encoding} callback.
5522 $self->{change_encoding}
5523 2 ▶ ->($self, defined $1 ? $1 : defined $2 ? $2 : $3, $token);
Branch: 2 branches
BranchTrueFalseTotal
defined $1 ? : 0 2 2
defined $2 ? : 0 2 2
5524 $self->_data($meta_el->[0]->getAttributeNodeNS(undef, 'content'),
5525 2 manakai_has_reference => $token->{attributes}->{content}->{has_reference});
5526 }
5527 }
5528 } else {
5529 0 ▶ if ($token->{attributes}->{charset}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"attributes"}{"charset"}) 0 0 0
5530
5531 $self->_data($meta_el->[0]->getAttributeNodeNS(undef, 'charset'),
5532 0 manakai_has_reference => $token->{attributes}->{charset}->{has_reference});
5533 }
5534 0 ▶ if ($token->{attributes}->{content}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"attributes"}{"content"}) 0 0 0
5535
5536 $self->_data($meta_el->[0]->getAttributeNodeNS (undef, 'content'),
5537 0 manakai_has_reference => $token->{attributes}->{content}->{has_reference});
5538 }
5539 }
5540  
5541 9 delete $self->{self_closing};
5542 9 $token = $self->_get_next_token;
5543 9 next B;
5544 } elsif ($token->{tag_name} eq 'title') {
5545
5546 ## NOTE: This is an "as if in head" code clone
5547 10 $parse_rcdata->($self, $insert, $open_tables, 1); # RCDATA
5548 10 next B;
5549
5550 } elsif ($token->{tag_name} eq 'body') {
5551 ## "In body" insertion mode, "body" start tag token.
5552 7 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in body', text => 'body', token => $token);
5553
5554 7 ▶ if (@{$self->{open_elements}} == 1 or
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{'open_elements'};} == 1 or not $self->{'open_elements'}[1][1] == 131089) { } 0 7 7
Condition33%1/3
@{$self->{"open_elements"};} == 1 or not $self->{"open_elements"}[1][1] == 131089
l!l&&r!l&&!r
007
MC/DC0%0/2
@{$self->{"open_elements"};} == 1 or not $self->{"open_elements"}[1][1] == 131089
@{$self->{"open_elements"};} == 1 not $self->{"open_elements"}[1][1] == 131089
Truth table33%1/3
A or not(B)
A= @{$self->{"open_elements"};} == 1B= not $self->{"open_elements"}[1][1] == 131089
ABresult
1X1
011
000
5555 not ($self->{open_elements}->[1]->[1] == BODY_EL)) {
5556
5557 ## Ignore the token
5558 } else {
5559 7 delete $self->{frameset_ok};
5560 7 my $body_el = $self->{open_elements}->[1]->[0];
5561 7 for my $attr_name (keys %{$token->{attributes}}) {
5562 6 ▶ unless ($body_el->hasAttribute($attr_name)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($body_el->hasAttribute($attr_name)) 5 1 6
5563
5564 $body_el->setAttribute($attr_name,
5565 5 $token->{attributes}->{$attr_name}->{value});
5566 }
5567 }
5568 }
5569
5570 7 $token = $self->_get_next_token;
5571 7 next B;
5572 } elsif ($token->{tag_name} eq 'frameset') {
5573 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in body', text => $token->{tag_name},
5574 39 token => $token);
5575  
5576 39 ▶ if (@{$self->{open_elements}} == 1 or
Branch: 2 branches
BranchTrueFalseTotal
if (@{$self->{'open_elements'};} == 1 or not $self->{'open_elements'}[1][1] == 131089) { } 0 39 39
elsif (not $self->{'frameset_ok'}) { } 29 10 39
Condition33%1/3
@{$self->{"open_elements"};} == 1 or not $self->{"open_elements"}[1][1] == 131089
l!l&&r!l&&!r
0039
MC/DC0%0/2
@{$self->{"open_elements"};} == 1 or not $self->{"open_elements"}[1][1] == 131089
@{$self->{"open_elements"};} == 1 not $self->{"open_elements"}[1][1] == 131089
Truth table33%1/3
A or not(B)
A= @{$self->{"open_elements"};} == 1B= not $self->{"open_elements"}[1][1] == 131089
ABresult
1X1
011
000
5577 not ($self->{open_elements}->[1]->[1] == BODY_EL)) {
5578
5579 ## Ignore the token.
5580 } elsif (not $self->{frameset_ok}) {
5581
5582 ## Ignore the token.
5583 } else {
5584
5585
5586 ## 1. Remove the second element.
5587 10 my $body = $self->{open_elements}->[1]->[0];
5588 10 my $body_parent = $body->parentNode;
5589 10 ▶ $body_parent->removeChild ($body) if $body_parent;
Branch: 1 branch
BranchTrueFalseTotal
if $body_parent 10 0 10
5590  
5591 ## 2. Pop nodes.
5592 10 splice @{$self->{open_elements}}, 1;
5593  
5594 ## 3. Insert.
5595
5596 {
5597 10 my $el;
5598
5599 10 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
5600
5601 10 for my $attr_name (keys %{ $token->{attributes}}) {
5602 0 my $attr_t = $token->{attributes}->{$attr_name};
5603 0 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
5604 0 $attr->setValue($attr_t->{value});
5605 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
5606 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
5607 0 $el->setAttributeNodeNS ($attr);
5608 }
5609
5610 $self->_data($el, manakai_source_line => $token->{line})
5611 10 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 10 0 10
5612 $self->_data($el, manakai_source_column => $token->{column})
5613 10 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 10 0 10
5614
5615 10 $insert->($self, $el, $open_tables);
5616 10 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
100
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
5617 }
5618
5619  
5620 ## 4. Switch.
5621 10 $self->{insertion_mode} = IN_FRAMESET_IM;
5622 }
5623  
5624
5625 39 $token = $self->_get_next_token;
5626 39 next B;
5627
5628 } elsif ({
5629 ## "In body" insertion mode, non-phrasing flow-content
5630 ## elements start tags.
5631 address => 1, article => 1, aside => 1, blockquote => 1,
5632 center => 1, details => 1, dir => 1, div => 1, dl => 1,
5633 fieldset => 1, figcaption => 1, figure => 1, footer => 1,
5634 header => 1, hgroup => 1, menu => 1, nav => 1, ol => 1,
5635 p => 1, section => 1, ul => 1, summary => 1,
5636 # datagrid => 1,
5637  
5638 ## Closing any heading element
5639 h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,
5640  
5641 ## Ignoring any leading newline in content
5642 pre => 1, listing => 1,
5643  
5644 ## Form element pointer
5645 form => 1,
5646
5647 ## A quirk & switching of insertion mode
5648 table => 1,
5649  
5650 ## Void element
5651 hr => 1,
5652 }->{$token->{tag_name}}) {
5653  
5654 ## 1. When there is an opening |form| element:
5655 455 ▶ if ($token->{tag_name} eq 'form' and defined $self->{form_element}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"tag_name"} eq "form" and defined $self->{"form_element"}) 1 454 455
Condition100%3/3
$token->{"tag_name"} eq "form" and defined $self->{"form_element"}
!ll&&!rl&&r
438161
MC/DC100%2/2
$token->{"tag_name"} eq "form" and defined $self->{"form_element"}
$token->{"tag_name"} eq "form" defined $self->{"form_element"}
Truth table100%3/3
A and B
A= $token->{"tag_name"} eq "form"B= defined $self->{"form_element"}
ABresult
0X0
100
111
5656
5657 1 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in form:form', token => $token);
5658 ## Ignore the token
5659
5660 1 $token = $self->_get_next_token;
5661 1 next B;
5662 }
5663  
5664 ## 2. Close the |p| element, if any.
5665 454 ▶ if ($token->{tag_name} ne 'table' or # The Hixie Quirk
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"tag_name"} ne "table" or ($self->_data($self->{"document"})->{"manakai_compat_mode"} || "") ne "quirks") 406 48 454
Condition100%5/5
$token->{"tag_name"} ne "table" or ($self->_data($self->{"document"})->{"manakai_compat_mode"} || "") ne "quirks"
l!l&&r!l&&!r
3218548
$self->_data($self->{'document'})->{'manakai_compat_mode'} || ''
l!l
4885
MC/DC100%2/2
$token->{"tag_name"} ne "table" or ($self->_data($self->{"document"})->{"manakai_compat_mode"} || "") ne "quirks"
$token->{"tag_name"} ne "table" $self->_data($self->{'document'})->{'manakai_compat_mode'}
Truth table100%3/3
A or B
A= $token->{"tag_name"} ne "table"B= $self->_data($self->{'document'})->{'manakai_compat_mode'}
ABresult
1X1
011
000
5666 ($self->_data($self->{document})->{'manakai_compat_mode'}||'') ne 'quirks') {
5667 ## "have a |p| element in button scope"
5668 406 INSCOPE: for (reverse @{$self->{open_elements}}) {
5669 859 ▶ if ($_->[1] == P_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_->[1] == 131129) { } 19 840 859
elsif ($_->[1] & 262144) { } 387 453 840
5670
5671
5672 19 $token->{self_closing} = $self->{self_closing};
5673 19 unshift @{$self->{token}}, $token;
5674 19 delete $self->{self_closing};
5675 # <form>
5676 $token = {type => END_TAG_TOKEN, tag_name => 'p',
5677 19 line => $token->{line}, column => $token->{column}};
5678 19 next B;
5679 } elsif ($_->[1] & BUTTON_SCOPING_EL) {
5680
5681 387 last INSCOPE;
5682 }
5683 } # INSCOPE
5684 }
5685  
5686 ## 3. Close the opening <hn> element, if any.
5687 435 ▶ if ({h1 => 1, h2 => 1, h3 => 1,
Branch: 1 branch
BranchTrueFalseTotal
if ({"h1", 1, "h2", 1, "h3", 1, "h4", 1, "h5", 1, "h6", 1}->{$token->{"tag_name"}}) 11 424 435
5688 h4 => 1, h5 => 1, h6 => 1}->{$token->{tag_name}}) {
5689 11 ▶ if ($self->{open_elements}->[-1]->[1] == HEADING_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[-1][1] == 131075) 0 11 11
5690 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
5691 0 text => $self->{open_elements}->[-1]->[0]->tagName,
5692 token => $token);
5693 0 pop @{$self->{open_elements}};
5694 }
5695 }
5696  
5697 ## 4. Insertion.
5698
5699 {
5700 435 my $el;
5701
5702 435 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
5703
5704 435 for my $attr_name (keys %{ $token->{attributes}}) {
5705 16 $attr_name =~ s/[^A-Za-z0-9:_-]//g;
5706 16 my $attr_t = $token->{attributes}->{$attr_name};
5707 16 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
5708 16 $attr->setValue($attr_t->{value});
5709 16 $self->_data($attr, manakai_source_line => $attr_t->{line});
5710 16 $self->_data($attr, manakai_source_column => $attr_t->{column});
5711 16 $el->setAttributeNodeNS($attr);
5712 }
5713
5714 $self->_data($el, manakai_source_line => $token->{line})
5715 435 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 435 0 435
5716 $self->_data($el, manakai_source_column => $token->{column})
5717 435 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 435 0 435
5718
5719 435 $insert->($self, $el, $open_tables);
5720 435 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
4350
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
5721 }
5722
5723 435 ▶ if ($token->{tag_name} eq 'pre' or $token->{tag_name} eq 'listing') {
Branch: 4 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'pre' or $token->{'tag_name'} eq 'listing') { } 16 419 435
elsif ($token->{'tag_name'} eq 'form') { } 15 404 419
elsif ($token->{'tag_name'} eq 'table') { } 129 275 404
elsif ($token->{'tag_name'} eq 'hr') { } 17 258 275
Condition100%3/3
$token->{"tag_name"} eq "pre" or $token->{"tag_name"} eq "listing"
l!l&&r!l&&!r
124419
MC/DC100%2/2
$token->{"tag_name"} eq "pre" or $token->{"tag_name"} eq "listing"
$token->{"tag_name"} eq "pre" $token->{"tag_name"} eq "listing"
Truth table100%3/3
A or B
A= $token->{"tag_name"} eq "pre"B= $token->{"tag_name"} eq "listing"
ABresult
1X1
011
000
5724
5725 16 $token = $self->_get_next_token;
5726 16 ▶ if ($token->{type} == CHARACTER_TOKEN) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'type'} == 6) { } 10 6 16
5727 10 $token->{data} =~ s/^\x0A//;
5728 10 ▶ unless (length $token->{data}) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $token->{'data'}) { } 7 3 10
5729
5730 3 $token = $self->_get_next_token;
5731 } else {
5732
5733 }
5734 } else {
5735
5736 }
5737  
5738 16 delete $self->{frameset_ok};
5739 } elsif ($token->{tag_name} eq 'form') {
5740
5741 15 $self->{form_element} = $self->{open_elements}->[-1]->[0];
5742  
5743
5744 15 $token = $self->_get_next_token;
5745 } elsif ($token->{tag_name} eq 'table') {
5746
5747 129 push @{$open_tables}, [$self->{open_elements}->[-1]->[0]];
5748  
5749 129 delete $self->{frameset_ok};
5750
5751 129 $self->{insertion_mode} = IN_TABLE_IM;
5752  
5753
5754 129 $token = $self->_get_next_token;
5755 } elsif ($token->{tag_name} eq 'hr') {
5756
5757 17 pop @{$self->{open_elements}};
5758
5759 17 delete $self->{self_closing};
5760  
5761 17 delete $self->{frameset_ok};
5762  
5763 17 $token = $self->_get_next_token;
5764 } else {
5765
5766 258 $token = $self->_get_next_token;
5767 }
5768 435 next B;
5769 } elsif ($token->{tag_name} eq 'li') {
5770 ## "In body" insertion mode, "li" start tag. As normal, but
5771 ## imply </li> when there's another <li>.
5772  
5773 ## NOTE: Special, Scope (<li><foo><li> == <li><foo><li/></foo></li>)::
5774 ## Interpreted as <li><foo/></li><li/> (non-conforming):
5775 ## blockquote (O9.27), center (O), dd (Fx3, O, S3.1.2, IE7),
5776 ## dt (Fx, O, S, IE), dl (O), fieldset (O, S, IE), form (Fx, O, S),
5777 ## hn (O), pre (O), applet (O, S), button (O, S), marquee (Fx, O, S),
5778 ## object (Fx)
5779 ## Generate non-tree (non-conforming):
5780 ## basefont (IE7 (where basefont is non-void)), center (IE),
5781 ## form (IE), hn (IE)
5782 ## address, div, p (<li><foo><li> == <li><foo/></li><li/>)::
5783 ## Interpreted as <li><foo><li/></foo></li> (non-conforming):
5784 ## div (Fx, S)
5785  
5786 ## 1. Frameset-ng
5787 15 delete $self->{frameset_ok};
5788  
5789 15 my $non_optional;
5790 15 my $i = -1;
5791  
5792 ## 2.
5793 15 for my $node (reverse @{$self->{open_elements}}) {
5794 19 ▶ if ($node->[1] == LI_EL) {
Branch: 3 branches
BranchTrueFalseTotal
if ($node->[1] == 131100) { } 2 17 19
elsif ($node->[1] & 131072 || $node->[1] & 65536 and not $node->[1] & 32) { } 13 4 17
elsif ($node->[1] & 8) { } 2 2 4
5795 ## 3. (a) As if </li>
5796 {
5797 ## If no </li> - not applied
5798 #
5799  
5800 ## Otherwise
5801  
5802 ## 1. generate implied end tags, except for </li>
5803 #
5804  
5805 ## 2. If current node != "li", parse error
5806 2 ▶ if ($non_optional) {
Branch: 1 branch
BranchTrueFalseTotal
if ($non_optional) { } 1 1 2
5807 1 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
5808 text => $non_optional->[0]->tagName,
5809 token => $token);
5810
5811 } else {
5812
5813 }
5814  
5815 ## 3. Pop
5816 2 splice @{$self->{open_elements}}, $i;
5817 }
5818  
5819 2 last; ## 3. (b) goto 5.
5820 ▶ } elsif (
Condition83%5/6
$node->[1] & 131072 || $node->[1] & 65536 and not $node->[1] & 32
!ll&&!rl&&r
1313
$node->[1] & 131072 or $node->[1] & 65536
l!l&&r!l&&!r
1601
MC/DC66%2/3
$node->[1] & 131072 || $node->[1] & 65536 and not $node->[1] & 32
$node->[1] & 131072 $node->[1] & 65536 not $node->[1] & 32
Truth table60%3/5
A or B and not(C)
A= $node->[1] & 131072B= $node->[1] & 65536C= not $node->[1] & 32
ABCresult
00X0
1X00
0100
1X11
0111
5821 ## NOTE: "special" category
5822 ($node->[1] & SPECIAL_EL or
5823 $node->[1] & SCOPING_EL) and
5824 ## NOTE: "li", "dt", and "dd" are in |SPECIAL_EL|.
5825 (not $node->[1] & ADDRESS_DIV_P_EL)
5826 ) {
5827 ## 4.
5828
5829 13 last; ## goto 6.
5830 } elsif ($node->[1] & END_TAG_OPTIONAL_EL) {
5831
5832 #
5833 } else {
5834
5835 2 ▶ $non_optional ||= $node;
Condition33%1/3
$non_optional ||= $node
l!l&&r!l&&!r
020
MC/DC0%0/2
$non_optional ||= $node
$non_optional $node
Truth table33%1/3
A ||= B
A= $non_optionalB= $node
ABresult
1X1
011
000
5836 #
5837 }
5838 ## 5.
5839 ## goto 3.
5840 4 $i--;
5841 }
5842  
5843 ## 6. (a) "have a |p| element in button scope".
5844 15 INSCOPE: for (reverse @{$self->{open_elements}}) {
5845 39 ▶ if ($_->[1] == P_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_->[1] == 131129) { } 1 38 39
elsif ($_->[1] & 262144) { } 14 24 38
5846
5847  
5848 ## NOTE: |<p><li>|, for example.
5849  
5850
5851 1 $token->{self_closing} = $self->{self_closing};
5852 1 unshift @{$self->{token}}, $token;
5853 1 delete $self->{self_closing};
5854 # <x>
5855 $token = {type => END_TAG_TOKEN, tag_name => 'p',
5856 1 line => $token->{line}, column => $token->{column}};
5857 1 next B;
5858 } elsif ($_->[1] & BUTTON_SCOPING_EL) {
5859
5860 14 last INSCOPE;
5861 }
5862 } # INSCOPE
5863  
5864 ## 6. (b) insert
5865
5866 {
5867 14 my $el;
5868
5869 14 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
5870
5871 14 for my $attr_name (keys %{ $token->{attributes}}) {
5872 0 my $attr_t = $token->{attributes}->{$attr_name};
5873 0 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
5874 0 $attr->setValue($attr_t->{value});
5875 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
5876 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
5877 0 $el->setAttributeNodeNS ($attr);
5878 }
5879
5880 $self->_data($el, manakai_source_line => $token->{line})
5881 14 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 14 0 14
5882 $self->_data($el, manakai_source_column => $token->{column})
5883 14 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 14 0 14
5884
5885 14 $insert->($self, $el, $open_tables);
5886 14 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
140
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
5887 }
5888
5889
5890 14 $token = $self->_get_next_token;
5891 14 next B;
5892  
5893 ▶ } elsif ($token->{tag_name} eq 'dt' or $token->{tag_name} eq 'dd') {
Condition100%3/3
$token->{"tag_name"} eq "dt" or $token->{"tag_name"} eq "dd"
l!l&&r!l&&!r
811549
MC/DC100%2/2
$token->{"tag_name"} eq "dt" or $token->{"tag_name"} eq "dd"
$token->{"tag_name"} eq "dt" $token->{"tag_name"} eq "dd"
Truth table100%3/3
A or B
A= $token->{"tag_name"} eq "dt"B= $token->{"tag_name"} eq "dd"
ABresult
1X1
011
000
5894 ## "In body" insertion mode, "dt" or "dd" start tag. As
5895 ## normal, but imply </dt> or </dd> when there's antoher <dt>
5896 ## or <dd>.
5897  
5898 ## 1. Frameset-ng
5899 19 delete $self->{frameset_ok};
5900  
5901 19 my $non_optional;
5902 19 my $i = -1;
5903  
5904 ## 2.
5905 19 for my $node (reverse @{$self->{open_elements}}) {
5906 24 ▶ if ($node->[1] == DTDD_EL) {
Branch: 3 branches
BranchTrueFalseTotal
if ($node->[1] == 131098) { } 6 18 24
elsif ($node->[1] & 131072 || $node->[1] & 65536 and not $node->[1] & 32) { } 13 5 18
elsif ($node->[1] & 8) { } 2 3 5
5907 ## 3. (a) As if </li>
5908 {
5909 ## If no </li> - not applied
5910 #
5911  
5912 ## Otherwise
5913  
5914 ## 1. generate implied end tags, except for </dt> or </dd>
5915 #
5916  
5917 ## 2. If current node != "dt"|"dd", parse error
5918 6 ▶ if ($non_optional) {
Branch: 1 branch
BranchTrueFalseTotal
if ($non_optional) { } 2 4 6
5919 2 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
5920 text => $non_optional->[0]->tagName,
5921 token => $token);
5922
5923 } else {
5924
5925 }
5926  
5927 ## 3. Pop
5928 6 splice @{$self->{open_elements}}, $i;
5929 }
5930  
5931 6 last; ## 3. (b) goto 5.
5932 ▶ } elsif (
Condition83%5/6
$node->[1] & 131072 || $node->[1] & 65536 and not $node->[1] & 32
!ll&&!rl&&r
2313
$node->[1] & 131072 or $node->[1] & 65536
l!l&&r!l&&!r
1602
MC/DC66%2/3
$node->[1] & 131072 || $node->[1] & 65536 and not $node->[1] & 32
$node->[1] & 131072 $node->[1] & 65536 not $node->[1] & 32
Truth table60%3/5
A or B and not(C)
A= $node->[1] & 131072B= $node->[1] & 65536C= not $node->[1] & 32
ABCresult
00X0
1X00
0100
1X11
0111
5933 ## NOTE: "special" category
5934 ($node->[1] & SPECIAL_EL or $node->[1] & SCOPING_EL) and
5935 ## NOTE: "li", "dt", and "dd" are in |SPECIAL_EL|.
5936  
5937 (not $node->[1] & ADDRESS_DIV_P_EL)
5938 ) {
5939 ## 4.
5940
5941 13 last; ## goto 5.
5942 } elsif ($node->[1] & END_TAG_OPTIONAL_EL) {
5943
5944 #
5945 } else {
5946
5947 3 ▶ $non_optional ||= $node;
Condition33%1/3
$non_optional ||= $node
l!l&&r!l&&!r
030
MC/DC0%0/2
$non_optional ||= $node
$non_optional $node
Truth table33%1/3
A ||= B
A= $non_optionalB= $node
ABresult
1X1
011
000
5948 #
5949 }
5950 ## 5.
5951 ## goto 3.
5952 5 $i--;
5953 }
5954  
5955 ## 6. (a) "have a |p| element in button scope".
5956 19 INSCOPE: for (reverse @{$self->{open_elements}}) {
5957 37 ▶ if ($_->[1] == P_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_->[1] == 131129) { } 2 35 37
elsif ($_->[1] & 262144) { } 17 18 35
5958
5959
5960 2 $token->{self_closing} = $self->{self_closing};
5961 2 unshift @{$self->{token}}, $token;
5962 2 delete $self->{self_closing};
5963 # <x>
5964 $token = {type => END_TAG_TOKEN, tag_name => 'p',
5965 2 line => $token->{line}, column => $token->{column}};
5966 2 next B;
5967 } elsif ($_->[1] & BUTTON_SCOPING_EL) {
5968
5969 17 last INSCOPE;
5970 }
5971 } # INSCOPE
5972  
5973 ## 6. (b) insert
5974
5975 {
5976 17 my $el;
5977
5978 17 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
5979
5980 17 for my $attr_name (keys %{ $token->{attributes}}) {
5981 0 my $attr_t = $token->{attributes}->{$attr_name};
5982 0 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
5983 0 $attr->setValue($attr_t->{value});
5984 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
5985 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
5986 0 $el->setAttributeNodeNS ($attr);
5987 }
5988
5989 $self->_data($el, manakai_source_line => $token->{line})
5990 17 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 17 0 17
5991 $self->_data($el, manakai_source_column => $token->{column})
5992 17 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 17 0 17
5993
5994 17 $insert->($self, $el, $open_tables);
5995 17 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
170
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
5996 }
5997
5998
5999 17 $token = $self->_get_next_token;
6000 17 next B;
6001
6002 } elsif ($token->{tag_name} eq 'plaintext') {
6003 ## "In body" insertion mode, "plaintext" start tag. As
6004 ## normal, but effectively ends parsing.
6005  
6006 ## has a p element in scope
6007 15 INSCOPE: for (reverse @{$self->{open_elements}}) {
6008 27 ▶ if ($_->[1] == P_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_->[1] == 131129) { } 2 25 27
elsif ($_->[1] & 262144) { } 13 12 25
6009
6010
6011 2 $token->{self_closing} = $self->{self_closing};
6012 2 unshift @{$self->{token}}, $token;
6013 2 delete $self->{self_closing};
6014 # <plaintext>
6015 $token = {type => END_TAG_TOKEN, tag_name => 'p',
6016 2 line => $token->{line}, column => $token->{column}};
6017 2 next B;
6018 } elsif ($_->[1] & BUTTON_SCOPING_EL) {
6019
6020 13 last INSCOPE;
6021 }
6022 } # INSCOPE
6023
6024
6025 {
6026 13 my $el;
6027
6028 13 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
6029
6030 13 for my $attr_name (keys %{ $token->{attributes}}) {
6031 1 my $attr_t = $token->{attributes}->{$attr_name};
6032 1 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
6033 1 $attr->setValue($attr_t->{value});
6034 1 $self->_data($attr, manakai_source_line => $attr_t->{line});
6035 1 $self->_data($attr, manakai_source_column => $attr_t->{column});
6036 1 $el->setAttributeNodeNS ($attr);
6037 }
6038
6039 $self->_data($el, manakai_source_line => $token->{line})
6040 13 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 13 0 13
6041 $self->_data($el, manakai_source_column => $token->{column})
6042 13 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 13 0 13
6043
6044 13 $insert->($self, $el, $open_tables);
6045 13 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
130
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
6046 }
6047
6048 13 $self->{state} = PLAINTEXT_STATE;
6049
6050
6051 13 $token = $self->_get_next_token;
6052 13 next B;
6053
6054 } elsif ($token->{tag_name} eq 'a') {
6055 34 AFE: for my $i (reverse 0..$#$active_formatting_elements) {
6056 14 my $node = $active_formatting_elements->[$i];
6057 11 ▶ no warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6058 14 ▶ if ($node->[1] == A_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 32769) { } 2 12 14
elsif ($node->[0] eq '#marker') { } 0 12 12
6059
6060 2 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in a:a', token => $token);
6061
6062
6063 2 $token->{self_closing} = $self->{self_closing};
6064 2 unshift @{$self->{token}}, $token;
6065 2 delete $self->{self_closing};
6066 # <a>
6067 $token = {type => END_TAG_TOKEN, tag_name => 'a',
6068 2 line => $token->{line}, column => $token->{column}};
6069 2 $formatting_end_tag->($self, $active_formatting_elements,
6070 $open_tables, $token);
6071
6072 2 AFE2: for (reverse 0..$#$active_formatting_elements) {
6073 0 ▶ if ($active_formatting_elements->[$_]->[0] eq $node->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($active_formatting_elements->[$_][0] eq $node->[0]) 0 0 0
6074
6075 0 splice @$active_formatting_elements, $_, 1;
6076 0 last AFE2;
6077 }
6078 } # AFE2
6079 2 OE: for (reverse 0..$#{$self->{open_elements}}) {
6080 7 ▶ if ($self->{open_elements}->[$_]->[0] eq $node->[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[$_][0] eq $node->[0]) 0 7 7
6081
6082 0 splice @{$self->{open_elements}}, $_, 1;
6083 0 last OE;
6084 }
6085 } # OE
6086 2 last AFE;
6087 } elsif ($node->[0] eq '#marker') {
6088
6089 0 last AFE;
6090 }
6091 } # AFE
6092
6093 34 ▶ my $insert = $self->{insertion_mode} & TABLE_IMS
Branch: 1 branch
BranchTrueFalseTotal
$self->{'insertion_mode'} & 64 ? : 6 28 34
6094 ? $insert_to_foster : $insert_to_current;
6095 34 $reconstruct_active_formatting_elements
6096 ->($self, $insert, $active_formatting_elements, $open_tables);
6097  
6098
6099 {
6100 34 my $el;
6101
6102 34 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
6103
6104 34 for my $attr_name (keys %{ $token->{attributes}}) {
6105 5 my $attr_t = $token->{attributes}->{$attr_name};
6106 5 my $attr = $self->{document}->createAttributeNS (undef, $attr_name);
6107 5 ▶ if ($attr)
Branch: 1 branch
BranchTrueFalseTotal
if ($attr) 5 0 5
6108 {
6109 5 $attr->setValue($attr_t->{value});
6110 5 $self->_data($attr, manakai_source_line => $attr_t->{line});
6111 5 $self->_data($attr, manakai_source_column => $attr_t->{column});
6112 5 $el->setAttributeNodeNS($attr);
6113 }
6114 }
6115
6116 $self->_data($el, manakai_source_line => $token->{line})
6117 34 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 34 0 34
6118 $self->_data($el, manakai_source_column => $token->{column})
6119 34 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 34 0 34
6120
6121 34 $insert->($self, $el, $open_tables);
6122 34 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
340
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
6123 }
6124
6125 push @$active_formatting_elements,
6126 [$self->{open_elements}->[-1]->[0],
6127 34 $self->{open_elements}->[-1]->[1],
6128 $token];
6129  
6130
6131 34 $token = $self->_get_next_token;
6132 34 next B;
6133 } elsif ($token->{tag_name} eq 'nobr') {
6134 68 ▶ my $insert = $self->{insertion_mode} & TABLE_IMS
Branch: 1 branch
BranchTrueFalseTotal
$self->{'insertion_mode'} & 64 ? : 5 63 68
6135 ? $insert_to_foster : $insert_to_current;
6136 68 $reconstruct_active_formatting_elements
6137 ->($self, $insert, $active_formatting_elements, $open_tables);
6138  
6139 ## has a |nobr| element in scope
6140 68 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
6141 156 my $node = $self->{open_elements}->[$_];
6142 156 ▶ if ($node->[1] == NOBR_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 32770) { } 26 130 156
elsif ($node->[1] & 65536) { } 42 88 130
6143
6144 26 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in nobr:nobr', token => $token);
6145
6146 26 $token->{self_closing} = $self->{self_closing};
6147 26 unshift @{$self->{token}}, $token;
6148 26 delete $self->{self_closing};
6149 # <nobr>
6150 $token = {type => END_TAG_TOKEN, tag_name => 'nobr',
6151 26 line => $token->{line}, column => $token->{column}};
6152 26 next B;
6153 } elsif ($node->[1] & SCOPING_EL) {
6154
6155 42 last INSCOPE;
6156 }
6157 } # INSCOPE
6158
6159
6160 {
6161 42 my $el;
6162
6163 42 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
6164
6165 42 for my $attr_name (keys %{ $token->{attributes}}) {
6166 0 my $attr_t = $token->{attributes}->{$attr_name};
6167 0 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
6168 0 $attr->setValue($attr_t->{value});
6169 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
6170 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
6171 0 $el->setAttributeNodeNS ($attr);
6172 }
6173
6174 $self->_data($el, manakai_source_line => $token->{line})
6175 42 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 42 0 42
6176 $self->_data($el, manakai_source_column => $token->{column})
6177 42 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 42 0 42
6178
6179 42 $insert->($self, $el, $open_tables);
6180 42 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
420
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
6181 }
6182
6183 push @$active_formatting_elements,
6184 [$self->{open_elements}->[-1]->[0],
6185 42 $self->{open_elements}->[-1]->[1],
6186 $token];
6187
6188 42 $token = $self->_get_next_token;
6189 42 next B;
6190 } elsif ($token->{tag_name} eq 'button') {
6191 ## has a button element in scope
6192 27 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
6193 75 my $node = $self->{open_elements}->[$_];
6194 75 ▶ if ($node->[1] == BUTTON_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 393222) { } 1 74 75
elsif ($node->[1] & 65536) { } 26 48 74
6195
6196 1 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in button:button', token => $token);
6197
6198 1 $token->{self_closing} = $self->{self_closing};
6199 1 unshift @{$self->{token}}, $token;
6200 1 delete $self->{self_closing};
6201 # <button>
6202 $token = {type => END_TAG_TOKEN, tag_name => 'button',
6203 1 line => $token->{line}, column => $token->{column}};
6204 1 next B;
6205 } elsif ($node->[1] & SCOPING_EL) {
6206
6207 26 last INSCOPE;
6208 }
6209 } # INSCOPE
6210
6211 26 ▶ my $insert = $self->{insertion_mode} & TABLE_IMS
Branch: 1 branch
BranchTrueFalseTotal
$self->{'insertion_mode'} & 64 ? : 0 26 26
6212 ? $insert_to_foster : $insert_to_current;
6213 26 $reconstruct_active_formatting_elements
6214 ->($self, $insert, $active_formatting_elements, $open_tables);
6215
6216
6217 {
6218 26 my $el;
6219
6220 26 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
6221
6222 26 for my $attr_name (keys %{ $token->{attributes}}) {
6223 0 my $attr_t = $token->{attributes}->{$attr_name};
6224 0 my $attr = $self->{document}->createAttributeNS (undef, $attr_name);
6225 0 $attr->setValue($attr_t->{value});
6226 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
6227 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
6228 0 $el->setAttributeNodeNS ($attr);
6229 }
6230
6231 $self->_data($el, manakai_source_line => $token->{line})
6232 26 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 26 0 26
6233 $self->_data($el, manakai_source_column => $token->{column})
6234 26 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 26 0 26
6235
6236 26 $insert->($self, $el, $open_tables);
6237 26 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
260
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
6238 }
6239
6240  
6241 ## TODO: associate with $self->{form_element} if defined
6242  
6243 26 delete $self->{frameset_ok};
6244  
6245
6246 26 $token = $self->_get_next_token;
6247 26 next B;
6248 } elsif ({
6249 xmp => 1,
6250 iframe => 1,
6251 noembed => 1,
6252 noframes => 1, ## NOTE: This is an "as if in head" code clone.
6253 noscript => 0, ## TODO: 1 if scripting is enabled
6254 }->{$token->{tag_name}}) {
6255 3 ▶ if ($token->{tag_name} eq 'xmp') {
Branch: 2 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'xmp') { } 2 1 3
elsif ($token->{'tag_name'} eq 'iframe') { } 1 0 1
6256 ## "In body" insertion mode, "xmp" start tag. As normal
6257 ## flow-content element start tag, but CDATA parsing.
6258
6259
6260 ## "have a |p| element in button scope".
6261 2 INSCOPE: for (reverse @{$self->{open_elements}}) {
6262 3 ▶ if ($_->[1] == P_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_->[1] == 131129) { } 0 3 3
elsif ($_->[1] & 262144) { } 2 1 3
6263
6264
6265 0 $token->{self_closing} = $self->{self_closing};
6266 0 unshift @{$self->{token}}, $token;
6267 0 delete $self->{self_closing};
6268 # <xmp>
6269 $token = {type => END_TAG_TOKEN, tag_name => 'p',
6270 0 line => $token->{line}, column => $token->{column}};
6271 0 next B;
6272 } elsif ($_->[1] & BUTTON_SCOPING_EL) {
6273
6274 2 last INSCOPE;
6275 }
6276 } # INSCOPE
6277
6278 2 ▶ my $insert = $self->{insertion_mode} & TABLE_IMS
Branch: 1 branch
BranchTrueFalseTotal
$self->{'insertion_mode'} & 64 ? : 0 2 2
6279 ? $insert_to_foster : $insert_to_current;
6280 2 $reconstruct_active_formatting_elements
6281 ->($self, $insert, $active_formatting_elements, $open_tables);
6282  
6283 2 delete $self->{frameset_ok};
6284 } elsif ($token->{tag_name} eq 'iframe') {
6285
6286 1 delete $self->{frameset_ok};
6287 } else {
6288
6289 }
6290 ## NOTE: There is an "as if in body" code clone.
6291 3 $parse_rcdata->($self, $insert, $open_tables, 0); # RAWTEXT
6292 3 next B;
6293 } elsif ($token->{tag_name} eq 'isindex') {
6294 9 $self->{parse_error}->(level => $self->{level}->{must}, type => 'isindex', token => $token);
6295
6296 9 ▶ if (defined $self->{form_element}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'form_element'}) { } 2 7 9
6297
6298 ## Ignore the token
6299 ## NOTE: Not acknowledged.
6300 2 $token = $self->_get_next_token;
6301 2 next B;
6302 } else {
6303 7 delete $self->{self_closing};
6304  
6305 7 my $at = $token->{attributes};
6306 7 my $form_attrs;
6307 7 ▶ $form_attrs->{action} = $at->{action} if $at->{action};
Branch: 1 branch
BranchTrueFalseTotal
if $at->{"action"} 2 5 7
6308 7 my $prompt_attr = $at->{prompt};
6309 7 $at->{name} = {name => 'name', value => 'isindex'};
6310 7 delete $at->{action};
6311 7 delete $at->{prompt};
6312 my @tokens = (
6313 {type => START_TAG_TOKEN, tag_name => 'form',
6314 attributes => $form_attrs,
6315 line => $token->{line}, column => $token->{column}},
6316 {type => START_TAG_TOKEN, tag_name => 'hr',
6317 line => $token->{line}, column => $token->{column}},
6318 {type => START_TAG_TOKEN, tag_name => 'label',
6319 line => $token->{line}, column => $token->{column}},
6320 7 );
6321 7 ▶ if ($prompt_attr) {
Branch: 1 branch
BranchTrueFalseTotal
if ($prompt_attr) { } 2 5 7
6322
6323 push @tokens, {type => CHARACTER_TOKEN, data => $prompt_attr->{value},
6324 #line => $token->{line}, column => $token->{column},
6325 2 };
6326 } else {
6327
6328 5 push @tokens, {type => CHARACTER_TOKEN,
6329 data => 'This is a searchable index. Enter search keywords: ',
6330 #line => $token->{line}, column => $token->{column},
6331 }; # SHOULD
6332 ## TODO: make this configurable
6333 }
6334 push @tokens,
6335 {type => START_TAG_TOKEN, tag_name => 'input', attributes => $at,
6336 line => $token->{line}, column => $token->{column}},
6337 #{type => CHARACTER_TOKEN, data => ''}, # SHOULD
6338 {type => END_TAG_TOKEN, tag_name => 'label',
6339 line => $token->{line}, column => $token->{column}},
6340 {type => START_TAG_TOKEN, tag_name => 'hr',
6341 line => $token->{line}, column => $token->{column}},
6342 {type => END_TAG_TOKEN, tag_name => 'form',
6343 7 line => $token->{line}, column => $token->{column}};
6344 7 unshift @{$self->{token}}, (@tokens);
6345 7 $token = $self->_get_next_token;
6346 7 next B;
6347 }
6348 } elsif ($token->{tag_name} eq 'textarea') {
6349 ## 1. Insert
6350
6351 {
6352 10 my $el;
6353
6354 10 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
6355
6356 10 for my $attr_name (keys %{ $token->{attributes}}) {
6357 2 my $attr_t = $token->{attributes}->{$attr_name};
6358 2 my $attr = $self->{document}->createAttributeNS (undef, $attr_name);
6359 2 $attr->setValue($attr_t->{value});
6360 2 $self->_data($attr, manakai_source_line => $attr_t->{line});
6361 2 $self->_data($attr, manakai_source_column => $attr_t->{column});
6362 2 $el->setAttributeNodeNS ($attr);
6363 }
6364
6365 $self->_data($el, manakai_source_line => $token->{line})
6366 10 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 10 0 10
6367 $self->_data($el, manakai_source_column => $token->{column})
6368 10 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 10 0 10
6369
6370 10 $insert->($self, $el, $open_tables);
6371 10 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
100
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
6372 }
6373
6374
6375 ## Step 2 # XXX
6376 ## TODO: $self->{form_element} if defined
6377  
6378 ## 2. Drop U+000A LINE FEED
6379 10 $self->{ignore_newline} = 1;
6380  
6381 ## 3. RCDATA
6382 10 $self->{state} = RCDATA_STATE;
6383 10 delete $self->{escape}; # MUST
6384  
6385 ## 4., 6. Insertion mode
6386 10 $self->{insertion_mode} |= IN_CDATA_RCDATA_IM;
6387  
6388 ## 5. Frameset-ng.
6389 10 delete $self->{frameset_ok};
6390  
6391
6392 10 $token = $self->_get_next_token;
6393 10 next B;
6394 ▶ } elsif ($token->{tag_name} eq 'optgroup' or
Condition66%2/3
$token->{"tag_name"} eq "optgroup" or $token->{"tag_name"} eq "option"
l!l&&r!l&&!r
012371
MC/DC50%1/2
$token->{"tag_name"} eq "optgroup" or $token->{"tag_name"} eq "option"
$token->{"tag_name"} eq "optgroup" $token->{"tag_name"} eq "option"
Truth table66%2/3
A or B
A= $token->{"tag_name"} eq "optgroup"B= $token->{"tag_name"} eq "option"
ABresult
1X1
011
000
6395 $token->{tag_name} eq 'option') {
6396 12 ▶ if ($self->{open_elements}->[-1]->[1] == OPTION_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[-1][1] == 16394) 3 9 12
6397
6398 ## NOTE: As if </option>
6399
6400 3 $token->{self_closing} = $self->{self_closing};
6401 3 unshift @{$self->{token}}, $token;
6402 3 delete $self->{self_closing};
6403 # <option> or <optgroup>
6404 $token = {type => END_TAG_TOKEN, tag_name => 'option',
6405 3 line => $token->{line}, column => $token->{column}};
6406 3 next B;
6407 }
6408  
6409 9 ▶ my $insert = $self->{insertion_mode} & TABLE_IMS
Branch: 1 branch
BranchTrueFalseTotal
$self->{'insertion_mode'} & 64 ? : 0 9 9
6410 ? $insert_to_foster : $insert_to_current;
6411 9 $reconstruct_active_formatting_elements
6412 ->($self, $insert, $active_formatting_elements, $open_tables);
6413  
6414
6415 {
6416 9 my $el;
6417
6418 9 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
6419
6420 9 for my $attr_name (keys %{ $token->{attributes}}) {
6421 0 my $attr_t = $token->{attributes}->{$attr_name};
6422 0 my $attr = $self->{document}->createAttributeNS (undef, $attr_name);
6423 0 $attr->setValue($attr_t->{value});
6424 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
6425 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
6426 0 $el->setAttributeNodeNS ($attr);
6427 }
6428
6429 $self->_data($el, manakai_source_line => $token->{line})
6430 9 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 9 0 9
6431 $self->_data($el, manakai_source_column => $token->{column})
6432 9 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 9 0 9
6433
6434 9 $insert->($self, $el, $open_tables);
6435 9 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
90
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
6436 }
6437
6438  
6439
6440 9 $token = $self->_get_next_token;
6441 9 redo B;
6442 ▶ } elsif ($token->{tag_name} eq 'rt' or
Condition100%3/3
$token->{"tag_name"} eq "rt" or $token->{"tag_name"} eq "rp"
l!l&&r!l&&!r
44363
MC/DC100%2/2
$token->{"tag_name"} eq "rt" or $token->{"tag_name"} eq "rp"
$token->{"tag_name"} eq "rt" $token->{"tag_name"} eq "rp"
Truth table100%3/3
A or B
A= $token->{"tag_name"} eq "rt"B= $token->{"tag_name"} eq "rp"
ABresult
1X1
011
000
6443 $token->{tag_name} eq 'rp') {
6444 ## has a |ruby| element in scope
6445 8 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
6446 20 my $node = $self->{open_elements}->[$_];
6447 20 ▶ if ($node->[1] == RUBY_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 16385) { } 8 12 20
elsif ($node->[1] & 65536) { } 0 12 12
6448
6449 ## generate implied end tags
6450 8 ▶ while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[-1][1] & 8) 4 8 12
6451
6452 4 pop @{$self->{open_elements}};
6453 }
6454 8 ▶ unless ($self->{open_elements}->[-1]->[1] == RUBY_EL) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"open_elements"}[-1][1] == 16385) 6 2 8
6455
6456 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
6457 6 text => $self->{open_elements}->[-1]->[0]
6458 ->tagName,
6459 token => $token);
6460 }
6461 8 last INSCOPE;
6462 } elsif ($node->[1] & SCOPING_EL) {
6463
6464 0 last INSCOPE;
6465 }
6466 } # INSCOPE
6467  
6468
6469 {
6470 8 my $el;
6471
6472 8 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
6473
6474 8 for my $attr_name (keys %{ $token->{attributes}}) {
6475 0 my $attr_t = $token->{attributes}->{$attr_name};
6476 0 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
6477 0 $attr->setValue($attr_t->{value});
6478 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
6479 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
6480 0 $el->setAttributeNodeNS ($attr);
6481 }
6482
6483 $self->_data($el, manakai_source_line => $token->{line})
6484 8 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 8 0 8
6485 $self->_data($el, manakai_source_column => $token->{column})
6486 8 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 8 0 8
6487
6488 8 $insert->($self, $el, $open_tables);
6489 8 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition50%1/2
$$el_category{$token->{'tag_name'}} || 0
l!l
80
MC/DC0%0/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
6490 }
6491
6492  
6493
6494 8 $token = $self->_get_next_token;
6495 8 redo B;
6496 ▶ } elsif ($token->{tag_name} eq 'math' or
Condition100%3/3
$token->{"tag_name"} eq "math" or $token->{"tag_name"} eq "svg"
l!l&&r!l&&!r
4264257
MC/DC100%2/2
$token->{"tag_name"} eq "math" or $token->{"tag_name"} eq "svg"
$token->{"tag_name"} eq "math" $token->{"tag_name"} eq "svg"
Truth table100%3/3
A or B
A= $token->{"tag_name"} eq "math"B= $token->{"tag_name"} eq "svg"
ABresult
1X1
011
000
6497 $token->{tag_name} eq 'svg') {
6498 106 ▶ my $insert = $self->{insertion_mode} & TABLE_IMS
Branch: 1 branch
BranchTrueFalseTotal
$self->{'insertion_mode'} & 64 ? : 7 99 106
6499 ? $insert_to_foster : $insert_to_current;
6500 106 $reconstruct_active_formatting_elements
6501 ->($self, $insert, $active_formatting_elements, $open_tables);
6502  
6503 ## "Adjust MathML attributes" ('math' only) - done in insert-element-f
6504  
6505 ## "adjust SVG attributes" ('svg' only) - done in insert-element-f
6506  
6507 ## "adjust foreign attributes" - done in insert-element-f
6508
6509
6510 {
6511 106 my $el;
6512
6513 $el = $self->{document}->createElementNS
6514 106 ▶ ($token->{tag_name} eq 'math' ? (MML_NS) : (SVG_NS), $token->{tag_name});
Branch: 1 branch
BranchTrueFalseTotal
$token->{'tag_name'} eq 'math' ? : 42 64 106
6515
6516 106 for my $attr_name (keys %{ $token->{attributes}}) {
6517 1 my $attr_t = $token->{attributes}->{$attr_name};
6518 1 my $attr;
6519 1 ▶ if (defined $foreign_attr_xname->{ $attr_name })
Branch: 4 branches
BranchTrueFalseTotal
if (defined $foreign_attr_xname->{$attr_name}) { } 1 0 1
elsif ($token->{'tag_name'} eq 'math' and $attr_name eq 'definitionurl') { } 0 0 0
elsif ($token->{'tag_name'} eq 'math') { } 0 0 0
elsif ($token->{'tag_name'} eq 'svg') { } 0 0 0
6520 {
6521 1 my $xmlnsuri = $foreign_attr_xname->{ $attr_name }->[0];
6522 1 my $qname = join ':', @{$foreign_attr_xname->{ $attr_name }->[1]};
6523 1 $qname =~ s/(^:)|(:$)//;
6524 1 $attr = $self->{document}->createAttributeNS($xmlnsuri, $qname);
6525 }
6526 ▶ elsif ($token->{tag_name} eq 'math' && $attr_name eq 'definitionurl')
Condition0%0/3
$token->{"tag_name"} eq "math" and $attr_name eq "definitionurl"
!ll&&!rl&&r
000
MC/DC0%0/2
$token->{"tag_name"} eq "math" and $attr_name eq "definitionurl"
$token->{"tag_name"} eq "math" $attr_name eq "definitionurl"
Truth table0%0/3
A and B
A= $token->{"tag_name"} eq "math"B= $attr_name eq "definitionurl"
ABresult
0X0
100
111
6527 {
6528 0 $attr = $self->{document}->createAttributeNS((MML_NS), 'definitionURL');
6529 }
6530 elsif ($token->{tag_name} eq 'math')
6531 {
6532 0 $attr = $self->{document}->createAttributeNS((MML_NS), $attr_name);
6533 }
6534 elsif ($token->{tag_name} eq 'svg')
6535 {
6536 $attr = $self->{document}->createAttributeNS(
6537 0 ▶ (SVG_NS), ($svg_attr_name->{$attr_name} || $attr_name));
Condition0%0/3
$svg_attr_name->{$attr_name} || $attr_name
l!l&&r!l&&!r
000
MC/DC0%0/2
$svg_attr_name->{$attr_name} || $attr_name
$svg_attr_name->{$attr_name} $attr_name
Truth table0%0/3
A || B
A= $svg_attr_name->{$attr_name}B= $attr_name
ABresult
1X1
011
000
6538 }
6539 1 ▶ unless ($attr)
Branch: 1 branch
BranchTrueFalseTotal
unless ($attr) 0 1 1
6540 {
6541 0 $attr = $self->{document}->createAttribute($attr_name);
6542 }
6543 1 ▶ if ($attr)
Branch: 1 branch
BranchTrueFalseTotal
if ($attr) 1 0 1
6544 {
6545 1 $attr->setValue($attr_t->{value});
6546 1 $self->_data($attr, manakai_source_line => $attr_t->{line});
6547 1 $self->_data($attr, manakai_source_column => $attr_t->{column});
6548 1 $el->setAttributeNodeNS ($attr);
6549 }
6550 }
6551
6552 $self->_data($el, manakai_source_line => $token->{line})
6553 106 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 106 0 106
6554 $self->_data($el, manakai_source_column => $token->{column})
6555 106 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 106 0 106
6556
6557 106 $insert->($self, $el, $open_tables);
6558 106 ▶ push @{$self->{open_elements}}, [$el, ($el_category_f->{$token->{tag_name} eq 'math' ? MML_NS : SVG_NS}->{ $token->{tag_name}} || 0) | FOREIGN_EL | (($token->{tag_name} eq 'math' ? MML_NS : SVG_NS) eq SVG_NS ? SVG_EL : ($token->{tag_name} eq 'math' ? MML_NS : SVG_NS) eq MML_NS ? MML_EL : 0)];
Branch: 5 branches
BranchTrueFalseTotal
$token->{'tag_name'} eq 'math' ? : 42 64 106
($token->{'tag_name'} eq 'math' ? 'http://www.w3.org/1998/Math/MathML' : 'http://www.w3.org/2000/svg') eq 'http://www.w3.org/2000/svg' ? : 64 42 106
$token->{'tag_name'} eq 'math' ? : 42 64 106
($token->{'tag_name'} eq 'math' ? 'http://www.w3.org/1998/Math/MathML' : 'http://www.w3.org/2000/svg') eq 'http://www.w3.org/1998/Math/MathML' ? : 42 0 42
$token->{'tag_name'} eq 'math' ? : 42 0 42
Condition50%1/2
$$el_category_f{$token->{'tag_name'} eq 'math' ? 'http://www.w3.org/1998/Math/MathML' : 'http://www.w3.org/2000/svg'}{$token->{'tag_name'}} || 0
l!l
0106
MC/DC0%0/1
$$el_category_f{$token->{'tag_name'} eq 'math' ? 'http://www.w3.org/1998/Math/MathML' : 'http://www.w3.org/2000/svg'}{$token->{'tag_name'}} || 0
$$el_category_f{$token->{'tag_name'} eq 'math' ? 'http://www.w3.org/1998/Math/MathML' : 'http://www.w3.org/2000/svg'}{$token->{'tag_name'}}
Truth table50%1/2
A
A= $$el_category_f{$token->{'tag_name'} eq 'math' ? 'http://www.w3.org/1998/Math/MathML' : 'http://www.w3.org/2000/svg'}{$token->{'tag_name'}}
Aresult
11
00
6559  
6560 106 ▶ if ( $token->{attributes}->{xmlns} and $token->{attributes}->{xmlns}->{value} ne ($token->{tag_name} eq 'math' ? (MML_NS) : (SVG_NS))) {
Branch: 2 branches
BranchTrueFalseTotal
if ($token->{"attributes"}{"xmlns"} and $token->{"attributes"}{"xmlns"}{"value"} ne ($token->{"tag_name"} eq "math" ? "http://www.w3.org/1998/Math/MathML" : "http://www.w3.org/2000/svg")) 0 106 106
$token->{'tag_name'} eq 'math' ? : 0 0 0
Condition33%1/3
$token->{"attributes"}{"xmlns"} and $token->{"attributes"}{"xmlns"}{"value"} ne ($token->{"tag_name"} eq "math" ? "http://www.w3.org/1998/Math/MathML" : "http://www.w3.org/2000/svg")
!ll&&!rl&&r
10600
MC/DC0%0/2
$token->{"attributes"}{"xmlns"} and $token->{"attributes"}{"xmlns"}{"value"} ne ($token->{"tag_name"} eq "math" ? "http://www.w3.org/1998/Math/MathML" : "http://www.w3.org/2000/svg")
$token->{"attributes"}{"xmlns"} $token->{"attributes"}{"xmlns"}{"value"} ne ($token->{"tag_name"} eq "math" ? "http://www.w3.org/1998/Math/MathML" : "http://www.w3.org/2000/svg")
Truth table33%1/3
A and B
A= $token->{"attributes"}{"xmlns"}B= $token->{"attributes"}{"xmlns"}{"value"} ne ($token->{"tag_name"} eq "math" ? "http://www.w3.org/1998/Math/MathML" : "http://www.w3.org/2000/svg")
ABresult
0X0
100
111
6561 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'bad namespace', token => $token);
6562 ## TODO: Error type documentation
6563 }
6564 106 ▶ if ( $token->{attributes}->{'xmlns:xlink'} and
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"attributes"}{"xmlns:xlink"} and $token->{"attributes"}{"xmlns:xlink"}{"value"} ne "http://www.w3.org/1999/xlink") 0 106 106
Condition33%1/3
$token->{"attributes"}{"xmlns:xlink"} and $token->{"attributes"}{"xmlns:xlink"}{"value"} ne "http://www.w3.org/1999/xlink"
!ll&&!rl&&r
10600
MC/DC0%0/2
$token->{"attributes"}{"xmlns:xlink"} and $token->{"attributes"}{"xmlns:xlink"}{"value"} ne "http://www.w3.org/1999/xlink"
$token->{"attributes"}{"xmlns:xlink"} $token->{"attributes"}{"xmlns:xlink"}{"value"} ne "http://www.w3.org/1999/xlink"
Truth table33%1/3
A and B
A= $token->{"attributes"}{"xmlns:xlink"}B= $token->{"attributes"}{"xmlns:xlink"}{"value"} ne "http://www.w3.org/1999/xlink"
ABresult
0X0
100
111
6565 $token->{attributes}->{'xmlns:xlink'}->{value} ne q<http://www.w3.org/1999/xlink>) {
6566 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'bad namespace', token => $token);
6567 }
6568 }
6569
6570
6571 106 ▶ if ($self->{self_closing}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'self_closing'}) { } 2 104 106
6572 2 pop @{$self->{open_elements}};
6573 2 delete $self->{self_closing};
6574 } else {
6575
6576 }
6577  
6578 106 $token = $self->_get_next_token;
6579 106 next B;
6580 } elsif ({
6581 caption => 1, col => 1, colgroup => 1, frame => 1,
6582 head => 1,
6583 tbody => 1, td => 1, tfoot => 1, th => 1,
6584 thead => 1, tr => 1,
6585 }->{$token->{tag_name}}) {
6586
6587 $self->{parse_error}->(level => $self->{level}->{must}, type => 'in body',
6588 8 text => $token->{tag_name}, token => $token);
6589 ## Ignore the token
6590 ## NOTE: |<col/>| or |<frame/>| here is an error.
6591 8 $token = $self->_get_next_token;
6592 8 next B;
6593 ▶ } elsif ($token->{tag_name} eq 'param' or
Condition100%6/6
$token->{"tag_name"} eq "param" or $token->{"tag_name"} eq "source" or $token->{"tag_name"} eq "track"
l!l&&r!l&&!r
21246
$token->{"tag_name"} eq "param" or $token->{"tag_name"} eq "source"
l!l&&r!l&&!r
11247
MC/DC100%3/3
$token->{"tag_name"} eq "param" or $token->{"tag_name"} eq "source" or $token->{"tag_name"} eq "track"
$token->{"tag_name"} eq "param" $token->{"tag_name"} eq "source" $token->{"tag_name"} eq "track"
Truth table100%4/4
A or B or C
A= $token->{"tag_name"} eq "param"B= $token->{"tag_name"} eq "source"C= $token->{"tag_name"} eq "track"
ABCresult
1XX1
01X1
0011
0000
6594 $token->{tag_name} eq 'source' or
6595 $token->{tag_name} eq 'track') {
6596
6597 {
6598 3 my $el;
6599
6600 3 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
6601
6602 3 for my $attr_name (keys %{ $token->{attributes}}) {
6603 0 my $attr_t = $token->{attributes}->{$attr_name};
6604 0 my $attr = $self->{document}->createAttributeNS(undef, $attr_name);
6605 0 $attr->setValue($attr_t->{value});
6606 0 $self->_data($attr, manakai_source_line => $attr_t->{line});
6607 0 $self->_data($attr, manakai_source_column => $attr_t->{column});
6608 0 $el->setAttributeNodeNS ($attr);
6609 }
6610
6611 $self->_data($el, manakai_source_line => $token->{line})
6612 3 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 3 0 3
6613 $self->_data($el, manakai_source_column => $token->{column})
6614 3 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 3 0 3
6615
6616 3 $insert->($self, $el, $open_tables);
6617 3 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition100%2/2
$$el_category{$token->{'tag_name'}} || 0
l!l
12
MC/DC100%1/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table100%2/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
6618 }
6619
6620 3 pop @{$self->{open_elements}};
6621  
6622 3 delete $self->{self_closing};
6623 3 $token = $self->_get_next_token;
6624 3 redo B;
6625 } else {
6626 246 ▶ if ($token->{tag_name} eq 'image') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'image') { } 1 245 246
6627
6628 1 $self->{parse_error}->(level => $self->{level}->{must}, type => 'image', token => $token);
6629 1 $token->{tag_name} = 'img';
6630 } else {
6631
6632 }
6633  
6634 ## NOTE: There is an "as if <br>" code clone.
6635 246 ▶ my $insert = $self->{insertion_mode} & TABLE_IMS
Branch: 1 branch
BranchTrueFalseTotal
$self->{'insertion_mode'} & 64 ? : 33 213 246
6636 ? $insert_to_foster : $insert_to_current;
6637 246 $reconstruct_active_formatting_elements
6638 ->($self, $insert, $active_formatting_elements, $open_tables);
6639
6640
6641 {
6642 246 my $el;
6643 246 $token->{tag_name} =~ s/[^A-Za-z0-9:_-]//g;
6644 246 $el = $self->{document}->createElementNS((HTML_NS), $token->{tag_name});
6645
6646 246 ATR: for my $attr_name (keys %{ $token->{attributes}}) {
6647 35 my $attr_t = $token->{attributes}->{$attr_name};
6648 35 my $attr = $self->{document}->createAttributeNS (undef, $attr_name);
6649 35 ▶ next ATR unless ref($attr);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $attr 3 32 35
6650 32 $attr->setValue ($attr_t->{value});
6651 32 $self->_data($attr, manakai_source_line => $attr_t->{line});
6652 32 $self->_data($attr, manakai_source_column => $attr_t->{column});
6653 32 $el->setAttributeNodeNS ($attr);
6654 }
6655
6656 $self->_data($el, manakai_source_line => $token->{line})
6657 246 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 246 0 246
6658 $self->_data($el, manakai_source_column => $token->{column})
6659 246 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 246 0 246
6660
6661 246 $insert->($self, $el, $open_tables);
6662 246 ▶ push @{$self->{open_elements}}, [$el, $el_category->{$token->{tag_name}} || 0];
Condition100%2/2
$$el_category{$token->{'tag_name'}} || 0
l!l
19749
MC/DC100%1/1
$$el_category{$token->{'tag_name'}} || 0
$$el_category{$token->{'tag_name'}}
Truth table100%2/2
A
A= $$el_category{$token->{'tag_name'}}
Aresult
11
00
6663 }
6664
6665  
6666 246 ▶ if ({
Branch: 5 branches
BranchTrueFalseTotal
if ({'applet', 1, 'marquee', 1, 'object', 1}->{$token->{'tag_name'}}) { } 7 239 246
elsif ({'b', 1, 'big', 1, 'code', 1, 'em', 1, 'font', 1, 'i', 1, 's', 1, 'small', 1, 'strike', 1, 'strong', 1, 'tt', 1, 'u', 1}->{$token->{'tag_name'}}) { } 99 140 239
elsif ($token->{'tag_name'} eq 'input') { } 17 123 140
elsif ({'area', 1, 'br', 1, 'embed', 1, 'img', 1, 'wbr', 1, 'keygen', 1}->{$token->{'tag_name'}}) { } 26 97 123
elsif ($token->{'tag_name'} eq 'select') { } 42 55 97
6667 applet => 1, marquee => 1, object => 1,
6668 }->{$token->{tag_name}}) {
6669
6670  
6671 7 push @$active_formatting_elements, ['#marker', '', undef];
6672  
6673 7 delete $self->{frameset_ok};
6674  
6675
6676 } elsif ({
6677 b => 1, big => 1, code=>1, em => 1, font => 1, i => 1,
6678 s => 1, small => 1, strike => 1,
6679 strong => 1, tt => 1, u => 1,
6680 }->{$token->{tag_name}}) {
6681
6682 push @$active_formatting_elements,
6683 [$self->{open_elements}->[-1]->[0],
6684 99 $self->{open_elements}->[-1]->[1],
6685 $token];
6686
6687 } elsif ($token->{tag_name} eq 'input') {
6688
6689 ## TODO: associate with $self->{form_element} if defined
6690
6691 17 pop @{$self->{open_elements}};
6692
6693 17 ▶ if ($token->{attributes}->{type}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'attributes'}{'type'}) { } 5 12 17
6694 5 my $type = $token->{attributes}->{type}->{value};
6695 5 $type =~ tr/A-Z/a-z/; ## ASCII case-insensitive.
6696 5 ▶ if ($type eq 'hidden') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'hidden') { } 3 2 5
6697 #
6698 } else {
6699 2 delete $self->{frameset_ok};
6700 }
6701 } else {
6702 12 delete $self->{frameset_ok};
6703 }
6704
6705 17 delete $self->{self_closing};
6706 } elsif ({
6707 area => 1, br => 1, embed => 1, img => 1, wbr => 1, keygen => 1,
6708 }->{$token->{tag_name}}) {
6709
6710  
6711 26 pop @{$self->{open_elements}};
6712  
6713 26 delete $self->{frameset_ok};
6714  
6715 26 delete $self->{self_closing};
6716 } elsif ($token->{tag_name} eq 'select') {
6717 ## TODO: associate with $self->{form_element} if defined
6718  
6719 42 delete $self->{frameset_ok};
6720
6721 42 ▶ if ($self->{insertion_mode} & TABLE_IMS or
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'insertion_mode'} & 64 or $self->{'insertion_mode'} & 32) { } 16 26 42
Condition100%3/3
$self->{"insertion_mode"} & 64 or $self->{"insertion_mode"} & 32
l!l&&r!l&&!r
12426
MC/DC100%2/2
$self->{"insertion_mode"} & 64 or $self->{"insertion_mode"} & 32
$self->{"insertion_mode"} & 64 $self->{"insertion_mode"} & 32
Truth table100%3/3
A or B
A= $self->{"insertion_mode"} & 64B= $self->{"insertion_mode"} & 32
ABresult
1X1
011
000
6722 $self->{insertion_mode} & BODY_TABLE_IMS) {
6723 16 $self->{insertion_mode} = IN_SELECT_IN_TABLE_IM;
6724 } else {
6725
6726 26 $self->{insertion_mode} = IN_SELECT_IM;
6727 }
6728
6729 } else {
6730
6731 }
6732
6733 246 $token = $self->_get_next_token;
6734 246 next B;
6735 }
6736 } elsif ($token->{type} == END_TAG_TOKEN) {
6737 372 ▶ if ($token->{tag_name} eq 'body' or $token->{tag_name} eq 'html') {
Branch: 7 branches
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'body' or $token->{'tag_name'} eq 'html') { } 53 319 372
elsif ({'address', 1, 'article', 1, 'aside', 1, 'blockquote', 1, 'center', 1, 'details', 1, 'dir', 1, 'div', 1, 'dl', 1, 'fieldset', 1, 'figure', 1, 'footer', 1, 'header', 1, 'hgroup', 1, 'listing', 1, 'menu', 1, 'nav', 1, 'ol', 1, 'pre', 1, 'section', 1, 'ul', 1, 'figcaption', 1, 'summary', 1, 'dd', 1, 'dt', 1, 'li', 1, 'applet', 1, 'button', 1, 'marquee', 1, 'object', 1}->{$token->{'tag_name'}}) { } 67 252 319
elsif ($token->{'tag_name'} eq 'form') { } 9 243 252
elsif ({'h1', 1, 'h2', 1, 'h3', 1, 'h4', 1, 'h5', 1, 'h6', 1}->{$token->{'tag_name'}}) { } 3 240 243
elsif ($token->{'tag_name'} eq 'p') { } 61 179 240
elsif ({'a', 1, 'b', 1, 'big', 1, 'code', 1, 'em', 1, 'font', 1, 'i', 1, 'nobr', 1, 's', 1, 'small', 1, 'strike', 1, 'strong', 1, 'tt', 1, 'u', 1}->{$token->{'tag_name'}}) { } 118 61 179
elsif ($token->{'tag_name'} eq 'br') { } 3 58 61
Condition100%3/3
$token->{"tag_name"} eq "body" or $token->{"tag_name"} eq "html"
l!l&&r!l&&!r
3518319
MC/DC100%2/2
$token->{"tag_name"} eq "body" or $token->{"tag_name"} eq "html"
$token->{"tag_name"} eq "body" $token->{"tag_name"} eq "html"
Truth table100%3/3
A or B
A= $token->{"tag_name"} eq "body"B= $token->{"tag_name"} eq "html"
ABresult
1X1
011
000
6738  
6739 ## 1. If not "have an element in scope":
6740 ## "has a |body| element in scope"
6741 53 my $i;
6742 INSCOPE: {
6743 53 for (reverse @{$self->{open_elements}}) {
6744 62 ▶ if ($_->[1] == BODY_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_->[1] == 131089) { } 52 10 62
elsif ($_->[1] & 65536) { } 1 9 10
6745
6746 52 $i = $_;
6747 52 last INSCOPE;
6748 } elsif ($_->[1] & SCOPING_EL) {
6749
6750 1 last;
6751 }
6752 }
6753  
6754 ## NOTE: |<marquee></body>|, |<svg><foreignobject></body>|,
6755 ## and fragment cases.
6756  
6757 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
6758 1 text => $token->{tag_name}, token => $token);
6759 ## Ignore the token. (</body> or </html>)
6760 1 $token = $self->_get_next_token;
6761 1 next B;
6762 } # INSCOPE
6763  
6764 ## 2. If unclosed elements:
6765 52 for (@{$self->{open_elements}}) {
6766 112 ▶ unless ($_->[1] & ALL_END_TAG_OPTIONAL_EL ||
Branch: 1 branch
BranchTrueFalseTotal
if ($_->[1] & 16 or $_->[1] == 16393 or $_->[1] == 16394 or $_->[1] == 16396) { } 105 7 112
Condition66%6/9
$_->[1] & 16 or $_->[1] == 16393 or $_->[1] == 16394 or $_->[1] == 16396
l!l&&r!l&&!r
10507
$_->[1] & 16 or $_->[1] == 16393 or $_->[1] == 16394
l!l&&r!l&&!r
10507
$_->[1] & 16 or $_->[1] == 16393
l!l&&r!l&&!r
10507
MC/DC25%1/4
$_->[1] & 16 or $_->[1] == 16393 or $_->[1] == 16394 or $_->[1] == 16396
$_->[1] & 16 $_->[1] == 16393 $_->[1] == 16394 $_->[1] == 16396
Truth table40%2/5
A or B or C or D
A= $_->[1] & 16B= $_->[1] == 16393C= $_->[1] == 16394D= $_->[1] == 16396
ABCDresult
1XXX1
01XX1
001X1
00011
00000
6767 $_->[1] == OPTGROUP_EL ||
6768 $_->[1] == OPTION_EL ||
6769 $_->[1] == RUBY_COMPONENT_EL) {
6770
6771 7 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
6772 text => $_->[0]->tagName,
6773 token => $token);
6774 7 last;
6775 } else {
6776
6777 }
6778 }
6779  
6780 ## 3. Switch the insertion mode.
6781 52 $self->{insertion_mode} = AFTER_BODY_IM;
6782 52 ▶ if ($token->{tag_name} eq 'body') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{'tag_name'} eq 'body') { } 35 17 52
6783 35 $token = $self->_get_next_token;
6784 } else { # html
6785 ## Reprocess.
6786 }
6787 52 next B;
6788 } elsif ({
6789 ## "In body" insertion mode, end tags for non-phrasing flow
6790 ## content elements.
6791
6792 address => 1, article => 1, aside => 1, blockquote => 1,
6793 center => 1,
6794 #datagrid => 1,
6795 details => 1,
6796 dir => 1, div => 1, dl => 1, fieldset => 1, figure => 1,
6797 footer => 1, header => 1, hgroup => 1,
6798 listing => 1, menu => 1, nav => 1,
6799 ol => 1, pre => 1, section => 1, ul => 1,
6800 figcaption => 1, summary => 1,
6801  
6802 ## NOTE: As normal, but ... optional tags
6803 dd => 1, dt => 1, li => 1,
6804  
6805 applet => 1, button => 1, marquee => 1, object => 1,
6806 }->{$token->{tag_name}}) {
6807 ## NOTE: Code for <li> start tags includes "as if </li>" code.
6808 ## Code for <dt> or <dd> start tags includes "as if </dt> or
6809 ## </dd>" code.
6810  
6811 ## has an element in scope
6812 67 my $i;
6813 67 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
6814 85 my $node = $self->{open_elements}->[$_];
6815 85 ▶ if ($node->[0]->tagName eq $token->{tag_name}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($node->[0]->tagName eq $token->{'tag_name'}) { } 65 20 85
elsif ($node->[1] & 65536) { } 2 18 20
elsif ($token->{'tag_name'} eq 'li' and {'ul', 1, 'ol', 1}->{$node->[0]->localname}) { } 0 35 35
6816
6817 65 $i = $_;
6818 65 last INSCOPE;
6819 } elsif ($node->[1] & SCOPING_EL) {
6820
6821 2 last INSCOPE;
6822 }
6823 ▶ elsif ($token->{tag_name} eq 'li' and
Condition66%2/3
$token->{"tag_name"} eq "li" and {"ul", 1, "ol", 1}->{$node->[0]->localname}
!ll&&!rl&&r
1710
MC/DC0%0/2
$token->{"tag_name"} eq "li" and {"ul", 1, "ol", 1}->{$node->[0]->localname}
$token->{"tag_name"} eq "li" {"ul", 1, "ol", 1}->{$node->[0]->localname}
Truth table66%2/3
A and B
A= $token->{"tag_name"} eq "li"B= {"ul", 1, "ol", 1}->{$node->[0]->localname}
ABresult
0X0
100
111
6824 {ul => 1, ol => 1}->{$node->[0]->localname}) {
6825 ## Has an element in list item scope
6826
6827 0 last INSCOPE;
6828 }
6829 } # INSCOPE
6830  
6831 67 ▶ unless (defined $i) { # has an element in scope
Branch: 1 branch
BranchTrueFalseTotal
if (defined $i) { } 65 2 67
6832
6833 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
6834 2 text => $token->{tag_name}, token => $token);
6835 ## NOTE: Ignore the token.
6836 } else {
6837 ## Step 1. generate implied end tags
6838 65 ▶ while ({
Branch: 1 branch
BranchTrueFalseTotal
if ({"dd", $token->{"tag_name"} ne "dd", "dt", $token->{"tag_name"} ne "dt", "li", $token->{"tag_name"} ne "li", "option", 1, "optgroup", 1, "p", 1, "rt", 1, "rp", 1}->{$self->{"open_elements"}[-1][0]->tagName}) 2 65 67
6839 ## END_TAG_OPTIONAL_EL
6840 dd => ($token->{tag_name} ne 'dd'),
6841 dt => ($token->{tag_name} ne 'dt'),
6842 li => ($token->{tag_name} ne 'li'),
6843 option => 1,
6844 optgroup => 1,
6845 p => 1,
6846 rt => 1,
6847 rp => 1,
6848 }->{$self->{open_elements}->[-1]->[0]->tagName}) {
6849
6850 2 pop @{$self->{open_elements}};
6851 }
6852  
6853 ## Step 2.
6854 65 ▶ if ($self->{open_elements}->[-1]->[0]->tagName
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][0]->tagName ne $token->{'tag_name'}) { } 12 53 65
6855 ne $token->{tag_name}) {
6856
6857 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
6858 12 text => $self->{open_elements}->[-1]->[0]
6859 ->tagName,
6860 token => $token);
6861 } else {
6862
6863 }
6864  
6865 ## Step 3.
6866 65 splice @{$self->{open_elements}}, $i;
6867  
6868 ## Step 4.
6869 $clear_up_to_marker->($active_formatting_elements)
6870 if {
6871 applet => 1, marquee => 1, object => 1,
6872 65 ▶ }->{$token->{tag_name}};
Branch: 1 branch
BranchTrueFalseTotal
if {"applet", 1, "marquee", 1, "object", 1}->{$token->{"tag_name"}} 3 62 65
6873 }
6874 67 $token = $self->_get_next_token;
6875 67 next B;
6876 } elsif ($token->{tag_name} eq 'form') {
6877 ## NOTE: As normal, but interacts with the form element pointer
6878  
6879 9 undef $self->{form_element};
6880  
6881 ## has an element in scope
6882 9 my $i;
6883 9 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
6884 9 my $node = $self->{open_elements}->[$_];
6885 9 ▶ if ($node->[1] == FORM_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 131073) { } 8 1 9
elsif ($node->[1] & 65536) { } 1 0 1
6886
6887 8 $i = $_;
6888 8 last INSCOPE;
6889 } elsif ($node->[1] & SCOPING_EL) {
6890
6891 1 last INSCOPE;
6892 }
6893 } # INSCOPE
6894  
6895 9 ▶ unless (defined $i) { # has an element in scope
Branch: 1 branch
BranchTrueFalseTotal
if (defined $i) { } 8 1 9
6896
6897 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
6898 1 text => $token->{tag_name}, token => $token);
6899 ## NOTE: Ignore the token.
6900 } else {
6901 ## Step 1. generate implied end tags
6902 8 ▶ while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[-1][1] & 8) 0 8 8
6903
6904 0 pop @{$self->{open_elements}};
6905 }
6906
6907 ## Step 2.
6908 8 ▶ if ($self->{open_elements}->[-1]->[0]->tagName
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][0]->tagName ne $token->{'tag_name'}) { } 0 8 8
6909 ne $token->{tag_name}) {
6910
6911 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
6912 0 text => $self->{open_elements}->[-1]->[0]
6913 ->tagName,
6914 token => $token);
6915 } else {
6916
6917 }
6918
6919 ## Step 3.
6920 8 splice @{$self->{open_elements}}, $i;
6921 }
6922  
6923 9 $token = $self->_get_next_token;
6924 9 next B;
6925 } elsif ({
6926 ## NOTE: As normal, except acts as a closer for any ...
6927 h1 => 1, h2 => 1, h3 => 1, h4 => 1, h5 => 1, h6 => 1,
6928 }->{$token->{tag_name}}) {
6929 ## has an element in scope
6930 3 my $i;
6931 3 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
6932 7 my $node = $self->{open_elements}->[$_];
6933 7 ▶ if ($node->[1] == HEADING_EL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($node->[1] == 131075) { } 2 5 7
elsif ($node->[1] & 65536) { } 1 4 5
6934
6935 2 $i = $_;
6936 2 last INSCOPE;
6937 } elsif ($node->[1] & SCOPING_EL) {
6938
6939 1 last INSCOPE;
6940 }
6941 } # INSCOPE
6942  
6943 3 ▶ unless (defined $i) { # has an element in scope
Branch: 1 branch
BranchTrueFalseTotal
if (defined $i) { } 2 1 3
6944
6945 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
6946 1 text => $token->{tag_name}, token => $token);
6947 ## NOTE: Ignore the token.
6948 } else {
6949 ## Step 1. generate implied end tags
6950 2 ▶ while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[-1][1] & 8) 1 2 3
6951
6952 1 pop @{$self->{open_elements}};
6953 }
6954
6955 ## Step 2.
6956 2 ▶ if ($self->{open_elements}->[-1]->[0]->tagName
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'open_elements'}[-1][0]->tagName ne $token->{'tag_name'}) { } 2 0 2
6957 ne $token->{tag_name}) {
6958
6959 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
6960 2 text => $token->{tag_name}, token => $token);
6961 } else {
6962
6963 }
6964  
6965 ## Step 3.
6966 2 splice @{$self->{open_elements}}, $i;
6967 }
6968
6969 3 $token = $self->_get_next_token;
6970 3 next B;
6971 } elsif ($token->{tag_name} eq 'p') {
6972 ## "In body" insertion mode, "p" start tag. As normal, except
6973 ## </p> implies <p> and ...
6974
6975 ## "have an element in button scope".
6976 61 my $non_optional;
6977 my $i;
6978 61 INSCOPE: for (reverse 0..$#{$self->{open_elements}}) {
6979 86 my $node = $self->{open_elements}->[$_];
6980 86 ▶ if ($node->[1] == P_EL) {
Branch: 3 branches
BranchTrueFalseTotal
if ($node->[1] == 131129) { } 55 31 86
elsif ($node->[1] & 262144) { } 6 25 31
elsif ($node->[1] & 8) { } 0 25 25
6981
6982 55 $i = $_;
6983 55 last INSCOPE;
6984 } elsif ($node->[1] & BUTTON_SCOPING_EL) {
6985
6986 6 last INSCOPE;
6987 } elsif ($node->[1] & END_TAG_OPTIONAL_EL) {
6988 ## NOTE: |END_TAG_OPTIONAL_EL| includes "p"
6989
6990 #
6991 } else {
6992
6993 25 ▶ $non_optional ||= $node;
Condition66%2/3
$non_optional ||= $node
l!l&&r!l&&!r
8170
MC/DC0%0/2
$non_optional ||= $node
$non_optional $node
Truth table66%2/3
A ||= B
A= $non_optionalB= $node
ABresult
1X1
011
000
6994 #
6995 }
6996 } # INSCOPE
6997  
6998 61 ▶ if (defined $i) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $i) { } 55 6 61
6999 ## 1. Generate implied end tags
7000 #
7001  
7002 ## 2. If current node != "p", parse error
7003 55 ▶ if ($non_optional) {
Branch: 1 branch
BranchTrueFalseTotal
if ($non_optional) { } 14 41 55
7004
7005 14 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
7006 text => $non_optional->[0]->tagName,
7007 token => $token);
7008 } else {
7009
7010 }
7011  
7012 ## 3. Pop
7013 55 splice @{$self->{open_elements}}, $i;
7014 } else {
7015
7016 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
7017 6 text => $token->{tag_name}, token => $token);
7018  
7019
7020 ## As if <p>, then reprocess the current token
7021 6 my $el;
7022
7023 6 $el = $self->{document}->createElementNS((HTML_NS), 'p');
7024
7025 $self->_data($el, manakai_source_line => $token->{line})
7026 6 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 6 0 6
7027 $self->_data($el, manakai_source_column => $token->{column})
7028 6 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 6 0 6
7029 6 $self->_data($el, implied => __LINE__);
7030
7031 6 $insert->($self, $el, $open_tables);
7032 ## NOTE: Not inserted into |$self->{open_elements}|.
7033 }
7034  
7035 61 $token = $self->_get_next_token;
7036 61 next B;
7037 } elsif ({
7038 a => 1,
7039 b => 1, big => 1, code=>1, em => 1, font => 1, i => 1,
7040 nobr => 1, s => 1, small => 1, strike => 1,
7041 strong => 1, tt => 1, u => 1,
7042 }->{$token->{tag_name}}) {
7043
7044 118 $formatting_end_tag->($self, $active_formatting_elements,
7045 $open_tables, $token);
7046 118 next B;
7047 } elsif ($token->{tag_name} eq 'br') {
7048
7049 3 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
7050 text => 'br', token => $token);
7051  
7052 ## As if <br>
7053 3 ▶ my $insert = $self->{insertion_mode} & TABLE_IMS
Branch: 1 branch
BranchTrueFalseTotal
$self->{'insertion_mode'} & 64 ? : 0 3 3
7054 ? $insert_to_foster : $insert_to_current;
7055 3 $reconstruct_active_formatting_elements
7056 ->($self, $insert, $active_formatting_elements, $open_tables);
7057
7058 3 my $el;
7059 3 $el = $self->{document}->createElementNS((HTML_NS), 'br');
7060
7061 $self->_data($el, manakai_source_line => $token->{line})
7062 3 ▶ if defined $token->{line};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"line"} 3 0 3
7063 $self->_data($el, manakai_source_column => $token->{column})
7064 3 ▶ if defined $token->{column};
Branch: 1 branch
BranchTrueFalseTotal
if defined $token->{"column"} 3 0 3
7065
7066 3 $insert->($self, $el, $open_tables);
7067
7068 ## Ignore the token.
7069 3 $token = $self->_get_next_token;
7070 3 next B;
7071 } else {
7072 58 ▶ if ($token->{tag_name} eq 'sarcasm') {
Branch: 1 branch
BranchTrueFalseTotal
if ($token->{"tag_name"} eq "sarcasm") 1 57 58
7073 1 sleep 0.001; # take a deep breath
7074 }
7075  
7076 ## Step 1
7077 58 my $node_i = -1;
7078 58 my $node = $self->{open_elements}->[$node_i];
7079  
7080 ## Step 2
7081 LOOP: {
7082 58 my $node_tag_name = $node->[0]->tagName;
7083 62 $node_tag_name =~ tr/A-Z/a-z/; # for SVG camelCase tag names
7084 62 ▶ if ($node_tag_name eq $token->{tag_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node_tag_name eq $token->{'tag_name'}) { } 28 34 62
7085 ## Step 1
7086 ## generate implied end tags
7087 28 ▶ while ($self->{open_elements}->[-1]->[1] & END_TAG_OPTIONAL_EL and
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"open_elements"}[-1][1] & 8 and $self->{"open_elements"}[-1][0]->localname ne $token->{"tag_name"}) 1 28 29
Condition100%3/3
$self->{"open_elements"}[-1][1] & 8 and $self->{"open_elements"}[-1][0]->localname ne $token->{"tag_name"}
!ll&&!rl&&r
2351
MC/DC100%2/2
$self->{"open_elements"}[-1][1] & 8 and $self->{"open_elements"}[-1][0]->localname ne $token->{"tag_name"}
$self->{"open_elements"}[-1][1] & 8 $self->{"open_elements"}[-1][0]->localname ne $token->{"tag_name"}
Truth table100%3/3
A and B
A= $self->{"open_elements"}[-1][1] & 8B= $self->{"open_elements"}[-1][0]->localname ne $token->{"tag_name"}
ABresult
0X0
100
111
7088 $self->{open_elements}->[-1]->[0]->localname
7089 ne $token->{tag_name}) {
7090
7091 ## NOTE: |<ruby><rt></ruby>|.
7092 1 pop @{$self->{open_elements}};
7093 1 $node_i++;
7094 }
7095
7096 ## Step 2
7097 my $current_tag_name
7098 28 = $self->{open_elements}->[-1]->[0]->tagName;
7099 28 $current_tag_name =~ tr/A-Z/a-z/;
7100 28 ▶ if ($current_tag_name ne $token->{tag_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($current_tag_name ne $token->{'tag_name'}) { } 0 28 28
7101
7102 ## NOTE: <x><y></x>
7103 $self->{parse_error}->(level => $self->{level}->{must}, type => 'not closed',
7104 0 text => $self->{open_elements}->[-1]->[0]
7105 ->tagName,
7106 token => $token);
7107 } else {
7108
7109 }
7110
7111 ## Step 3
7112 28 ▶ splice @{$self->{open_elements}}, $node_i if $node_i < 0;
Branch: 1 branch
BranchTrueFalseTotal
if $node_i < 0 28 0 28
7113  
7114 28 $token = $self->_get_next_token;
7115 28 last LOOP;
7116 } else {
7117 ## Step 3
7118 34 ▶ if ($node->[1] & SPECIAL_EL or $node->[1] & SCOPING_EL) { ## "Special"
Branch: 1 branch
BranchTrueFalseTotal
if ($node->[1] & 131072 or $node->[1] & 65536) 30 4 34
Condition100%3/3
$node->[1] & 131072 or $node->[1] & 65536
l!l&&r!l&&!r
2734
MC/DC100%2/2
$node->[1] & 131072 or $node->[1] & 65536
$node->[1] & 131072 $node->[1] & 65536
Truth table100%3/3
A or B
A= $node->[1] & 131072B= $node->[1] & 65536
ABresult
1X1
011
000
7119
7120 $self->{parse_error}->(level => $self->{level}->{must}, type => 'unmatched end tag',
7121 30 text => $token->{tag_name}, token => $token);
7122 ## Ignore the token
7123 30 $token = $self->_get_next_token;
7124 30 last LOOP;
7125  
7126 ## NOTE: |<span><dd></span>a|: In Safari 3.1.2 and Opera
7127 ## 9.27, "a" is a child of <dd> (conforming). In
7128 ## Firefox 3.0.2, "a" is a child of <body>. In WinIE 7,
7129 ## "a" is a child of both <body> and <dd>.
7130 }
7131
7132
7133 }
7134
7135 ## Step 4
7136 4 $node_i--;
7137 4 $node = $self->{open_elements}->[$node_i];
7138
7139 ## Step 5;
7140 4 redo LOOP;
7141 } # LOOP
7142 58 next B;
7143 }
7144 }
7145 0 next B;
7146 } # B
7147  
7148 ## Stop parsing # MUST
7149
7150 ## TODO: script stuffs
7151 } # _tree_construct_main
7152  
7153 ## XXX: How this method is organized is somewhat out of date, although
7154 ## it still does what the current spec documents.
7155 sub set_inner_html ($$$$;$) {
7156 0 ▶ my ($class, $self);
Subroutine set_inner_html: not called CC=25 SCAR=64.8
Pod undocumented
7157 0 ▶ if (ref $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0]) { } 0 0 0
7158 0 $self = shift;
7159 0 $class = ref $self;
7160 } else {
7161 0 $class = shift;
7162 0 $self = $class->new;
7163 }
7164 0 my $node = shift; # /context/
7165 #my $s = \$_[0];
7166 0 my $onerror = $_[1];
7167 0 ▶ my $get_wrapper = $_[2] || sub ($) { return $_[0] };
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/3
$_[2] || sub ($) { return $_[0]; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$_[2] || sub ($) { return $_[0]; }
$_[2] sub ($) { return $_[0]; }
Truth table0%0/3
A || B
A= $_[2]B= sub ($) { return $_[0]; }
ABresult
1X1
011
000
7168  
7169 0 my $nt = $node->node_type; #TOBY-TODO
7170 0 ▶ if ($nt == 9) { # Document (invoke the algorithm with no /context/ element)
Branch: 2 branches
BranchTrueFalseTotal
if ($nt == 9) { } 0 0 0
elsif ($nt == 1) { } 0 0 0
7171 # MUST
7172
7173 ## Step 1 # MUST
7174 ## TODO: If the document has an active parser, ...
7175 ## ISSUE: There is an issue in the spec.
7176
7177 ## Step 2 # MUST
7178 0 my @cn = $node->childNodes;
7179 0 for (@cn) {
7180 0 $node->removeChild ($_);
7181 }
7182  
7183 ## Step 3, 4, 5 # MUST
7184 0 $self->parse_char_string ($_[0] => $node, $onerror, $get_wrapper);
7185 } elsif ($nt == 1) { # Element (invoke the algorithm with /context/ element)
7186 ## TODO: If non-html element
7187  
7188 ## NOTE: Most of this code is copied from |parse_string|
7189  
7190 ## TODO: Support for $get_wrapper
7191 #TOBY-TODO
7192 ## F1. Create an HTML document.
7193 0 my $this_doc = $node->ownerDocument;
7194 0 my $implementation = ref($this_doc);
7195 0 my $doc = $implementation->createDocument;
7196 0 $self->_data($doc, manakai_is_html => 1);
7197  
7198 ## F2. Propagate quirkness flag
7199 0 my $node_doc = $node->ownerDocument;
7200 0 $self->_data($doc)->{'manakai_compat_mode'} = $self->_data($node_doc, 'manakai_compat_mode');
7201  
7202 ## F3. Create an HTML parser
7203 0 my $p = $self;
7204 0 $p->{document} = $doc;
7205  
7206 ## Step 8 # MUST
7207 0 my $i = 0;
7208 0 $p->{line_prev} = $p->{line} = 1;
7209 0 $p->{column_prev} = $p->{column} = 0;
7210 0 require HTML::HTML5::Parser::Charset::DecodeHandle;
7211 0 my $input = HTML::HTML5::Parser::Charset::DecodeHandle::CharString->new (\($_[0]));
7212 0 $input = $get_wrapper->($input);
7213 $p->{set_nc} = sub {
7214 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=10 SCAR=47.0
7215  
7216 0 my $char = '';
7217 0 ▶ if (defined $self->{next_nc}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'next_nc'}) { } 0 0 0
7218 0 $char = $self->{next_nc};
7219 0 delete $self->{next_nc};
7220 0 $self->{nc} = ord $char;
7221 } else {
7222 0 $self->{char_buffer} = '';
7223 0 $self->{char_buffer_pos} = 0;
7224
7225 my $count = $input->manakai_read_until
7226 ($self->{char_buffer}, qr/[^\x00\x0A\x0D\x{D800}-\x{DFFF}]/,
7227 0 $self->{char_buffer_pos});
7228 0 ▶ if ($count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count) 0 0 0
7229 0 $self->{line_prev} = $self->{line};
7230 0 $self->{column_prev} = $self->{column};
7231 0 $self->{column}++;
7232 $self->{nc}
7233 = ord substr ($self->{char_buffer},
7234 0 $self->{char_buffer_pos}++, 1);
7235 0 return;
7236 }
7237
7238 0 ▶ if ($input->read ($char, 1)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($input->read($char, 1)) { } 0 0 0
7239 0 $self->{nc} = ord $char;
7240 } else {
7241 0 $self->{nc} = -1;
7242 0 return;
7243 }
7244 }
7245  
7246 0 ($p->{line_prev}, $p->{column_prev}) = ($p->{line}, $p->{column});
7247 0 $p->{column}++;
7248  
7249 0 ▶ if ($self->{nc} == 0x000A) { # LF
Branch: 3 branches
BranchTrueFalseTotal
if ($self->{'nc'} == 10) { } 0 0 0
elsif ($self->{'nc'} == 13) { } 0 0 0
elsif (55296 <= $self->{'nc'} and $self->{'nc'} <= 57343) { } 0 0 0
7250 0 $p->{line}++;
7251 0 $p->{column} = 0;
7252
7253 } elsif ($self->{nc} == 0x000D) { # CR
7254 ## TODO: support for abort/streaming
7255 0 my $next = '';
7256 0 ▶ if ($input->read ($next, 1) and $next ne "\x0A") {
Branch: 1 branch
BranchTrueFalseTotal
if ($input->read($next, 1) and $next ne "\n") 0 0 0
Condition0%0/3
$input->read($next, 1) and $next ne "\n"
!ll&&!rl&&r
000
MC/DC0%0/2
$input->read($next, 1) and $next ne "\n"
$input->read($next, 1) $next ne "\n"
Truth table0%0/3
A and B
A= $input->read($next, 1)B= $next ne "\n"
ABresult
0X0
100
111
7257 0 $self->{next_nc} = $next;
7258 }
7259 0 $self->{nc} = 0x000A; # LF # MUST
7260 0 $p->{line}++;
7261 0 $p->{column} = 0;
7262
7263 ▶ } elsif (0xD800 <= $self->{nc} and $self->{nc} <= 0xDFFF) {
Condition0%0/3
55296 <= $self->{"nc"} and $self->{"nc"} <= 57343
!ll&&!rl&&r
000
MC/DC0%0/2
55296 <= $self->{"nc"} and $self->{"nc"} <= 57343
55296 <= $self->{"nc"} $self->{"nc"} <= 57343
Truth table0%0/3
A and B
A= 55296 <= $self->{"nc"}B= $self->{"nc"} <= 57343
ABresult
0X0
100
111
7264
7265 0 $self->{parse_error}->(level => $self->{level}->{must}, type => 'surrogate'); ## XXX documentation
7266 0 $self->{nc} = 0xFFFD; # REPLACEMENT CHARACTER # MUST
7267 }
7268 0 };
7269  
7270 $p->{read_until} = sub {
7271 #my ($scalar, $specials_range, $offset) = @_;
7272 0 ▶ return 0 if defined $p->{next_nc};
Subroutine __ANON__: not called CC=7 SCAR=40.3
Branch: 1 branch
BranchTrueFalseTotal
if defined $p->{"next_nc"} 0 0 0
7273  
7274 0 my $pattern = qr/[^$_[1]\x00\x0A\x0D\x{D800}-\x{DFFF}]/;
7275 0 ▶ my $offset = $_[2] || 0;
Condition0%0/2
$_[2] || 0
l!l
00
MC/DC0%0/1
$_[2] || 0
$_[2]
Truth table0%0/2
A
A= $_[2]
Aresult
11
00
7276
7277 0 ▶ if ($p->{char_buffer_pos} < length $p->{char_buffer}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{'char_buffer_pos'} < length $p->{'char_buffer'}) { } 0 0 0
7278 0 pos ($p->{char_buffer}) = $p->{char_buffer_pos};
7279 0 ▶ if ($p->{char_buffer} =~ /\G(?>$pattern)+/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{'char_buffer'} =~ /\G(?>$pattern)+/) { } 0 0 0
7280 substr ($_[0], $offset)
7281 0 = substr ($p->{char_buffer}, $-[0], $+[0] - $-[0]);
7282 0 my $count = $+[0] - $-[0];
7283 0 ▶ if ($count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count) 0 0 0
7284 0 $p->{column} += $count;
7285 0 $p->{char_buffer_pos} += $count;
7286 0 $p->{line_prev} = $p->{line};
7287 0 $p->{column_prev} = $p->{column} - 1;
7288 0 $p->{nc} = -1;
7289 }
7290 0 return $count;
7291 } else {
7292 0 return 0;
7293 }
7294 } else {
7295 0 my $count = $input->manakai_read_until ($_[0], $pattern, $_[2]);
7296 0 ▶ if ($count) {
Branch: 1 branch
BranchTrueFalseTotal
if ($count) 0 0 0
7297 0 $p->{column} += $count;
7298 0 $p->{column_prev} += $count;
7299 0 $p->{nc} = -1;
7300 }
7301 0 return $count;
7302 }
7303 0 }; # $p->{read_until}
7304  
7305 my $ponerror = $onerror || sub {
7306 0 ▶ my (%opt) = @_;
Subroutine __ANON__: not called CC=3 SCAR=24.8
7307 0 my $line = $opt{line};
7308 0 my $column = $opt{column};
7309 0 ▶ if (defined $opt{token} and defined $opt{token}->{line}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $opt{"token"} and defined $opt{"token"}{"line"}) 0 0 0
Condition0%0/3
defined $opt{"token"} and defined $opt{"token"}{"line"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $opt{"token"} and defined $opt{"token"}{"line"}
defined $opt{"token"} defined $opt{"token"}{"line"}
Truth table0%0/3
A and B
A= defined $opt{"token"}B= defined $opt{"token"}{"line"}
ABresult
0X0
100
111
7310 0 $line = $opt{token}->{line};
7311 0 $column = $opt{token}->{column};
7312 }
7313 0 warn "Parse error ($opt{type}) at line $line column $column\n";
7314 0 ▶ };
Condition0%0/3
$onerror || sub { my(%opt) = @_; my $line = $opt{'line'}; my $column = $opt{'column'}; if (defined $opt{'token'} and defined $opt{'token'}{'line'}) { $line = $opt{'token'}{'line'}; $column = $opt{'token'}{'column'}; } ; warn "Parse error ($opt{'type'}) at line $line column $column\n"; }
l!l&&r!l&&!r
000
MC/DC0%0/2
$onerror || sub { my(%opt) = @_; my $line = $opt{'line'}; my $column = $opt{'column'}; if (defined $opt{'token'} and defined $opt{'token'}{'line'}) { $line = $opt{'token'}{'line'}; $column = $opt{'token'}{'column'}; } ; warn "Parse error ($opt{'type'}) at line $line column $column\n"; }
$onerror sub { my(%opt) = @_; my $line = $opt{'line'}; my $column = $opt{'column'}; if (defined $opt{'token'} and defined $opt{'token'}{'line'}) { $line = $opt{'token'}{'line'}; $column = $opt{'token'}{'column'}; } ; warn "Parse error ($opt{'type'}) at line $line column $column\n"; }
Truth table0%0/3
A || B
A= $onerrorB= sub { my(%opt) = @_; my $line = $opt{'line'}; my $column = $opt{'column'}; if (defined $opt{'token'} and defined $opt{'token'}{'line'}) { $line = $opt{'token'}{'line'}; $column = $opt{'token'}{'column'}; } ; warn "Parse error ($opt{'type'}) at line $line column $column\n"; }
ABresult
1X1
011
000
7315 $p->{parse_error} = sub {
7316 0 ▶ $ponerror->(line => $p->{line}, column => $p->{column}, @_);
Subroutine __ANON__: not called CC=1 SCAR=6.9
7317 0 };
7318
7319 my $char_onerror = sub {
7320 0 ▶ my (undef, $type, %opt) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
7321 $ponerror->(layer => 'encode',
7322 0 line => $p->{line}, column => $p->{column} + 1,
7323 %opt, type => $type);
7324 0 }; # $char_onerror
7325 0 $input->onerror ($char_onerror);
7326  
7327 0 $p->_initialize_tokenizer;
7328 0 $p->_initialize_tree_constructor;
7329  
7330 ## F4. If /context/ is not undef...
7331  
7332 ## F4.1. content model flag
7333 0 ▶ my $node_ns = $node->namespaceURI || '';
Condition0%0/2
$node->namespaceURI || ''
l!l
00
MC/DC0%0/1
$node->namespaceURI || ''
$node->namespaceURI
Truth table0%0/2
A
A= $node->namespaceURI
Aresult
11
00
7334 0 my $node_ln = $node->localname;
7335 0 ▶ if ($node_ns eq HTML_NS) {
Branch: 3 branches
BranchTrueFalseTotal
if ($node_ns eq 'http://www.w3.org/1999/xhtml') { } 0 0 0
elsif ($node_ns eq 'http://www.w3.org/2000/svg') { } 0 0 0
elsif ($node_ns eq 'http://www.w3.org/1998/Math/MathML') { } 0 0 0
7336 0 ▶ if ($node_ln eq 'title' or $node_ln eq 'textarea') {
Branch: 4 branches
BranchTrueFalseTotal
if ($node_ln eq 'title' or $node_ln eq 'textarea') { } 0 0 0
elsif ($node_ln eq 'script') { } 0 0 0
elsif ({'style', 1, 'script', 1, 'xmp', 1, 'iframe', 1, 'noembed', 1, 'noframes', 1, 'noscript', 1}->{$node_ln}) { } 0 0 0
elsif ($node_ln eq 'plaintext') { } 0 0 0
Condition0%0/3
$node_ln eq "title" or $node_ln eq "textarea"
l!l&&r!l&&!r
000
MC/DC0%0/2
$node_ln eq "title" or $node_ln eq "textarea"
$node_ln eq "title" $node_ln eq "textarea"
Truth table0%0/3
A or B
A= $node_ln eq "title"B= $node_ln eq "textarea"
ABresult
1X1
011
000
7337 0 $p->{state} = RCDATA_STATE;
7338 } elsif ($node_ln eq 'script') {
7339 0 $p->{state} = SCRIPT_DATA_STATE;
7340 } elsif ({
7341 style => 1,
7342 script => 1,
7343 xmp => 1,
7344 iframe => 1,
7345 noembed => 1,
7346 noframes => 1,
7347 noscript => 1,
7348 }->{$node_ln}) {
7349 0 $p->{state} = RAWTEXT_STATE;
7350 } elsif ($node_ln eq 'plaintext') {
7351 0 $p->{state} = PLAINTEXT_STATE;
7352 }
7353
7354 0 $p->{inner_html_node} = [$node, $el_category->{$node_ln}];
7355 } elsif ($node_ns eq SVG_NS) {
7356 $p->{inner_html_node} = [$node,
7357 0 ▶ $el_category_f->{$node_ns}->{$node_ln}
Condition0%0/2
$el_category_f->{$node_ns}{$node_ln} || 10240
l!l
00
MC/DC0%0/1
$el_category_f->{$node_ns}{$node_ln} || 10240
$el_category_f->{$node_ns}{$node_ln}
Truth table0%0/2
A
A= $el_category_f->{$node_ns}{$node_ln}
Aresult
11
00
7358 || FOREIGN_EL | SVG_EL];
7359 } elsif ($node_ns eq MML_NS) {
7360 $p->{inner_html_node} = [$node,
7361 0 ▶ $el_category_f->{$node_ns}->{$node_ln}
Condition0%0/2
$el_category_f->{$node_ns}{$node_ln} || 6144
l!l
00
MC/DC0%0/1
$el_category_f->{$node_ns}{$node_ln} || 6144
$el_category_f->{$node_ns}{$node_ln}
Truth table0%0/2
A
A= $el_category_f->{$node_ns}{$node_ln}
Aresult
11
00
7362 || FOREIGN_EL | MML_EL];
7363 } else {
7364 0 $p->{inner_html_node} = [$node, FOREIGN_EL];
7365 }
7366
7367 ## F4.2. Root |html| element
7368 0 my $root = $doc->createElementNS('http://www.w3.org/1999/xhtml', 'html');
7369  
7370 ## F4.3.
7371 0 $doc->appendChild ($root);
7372  
7373 ## F4.4.
7374 0 push @{$p->{open_elements}}, [$root, $el_category->{html}];
7375  
7376 0 undef $p->{head_element};
7377  
7378 ## F4.5.
7379 0 $p->_reset_insertion_mode;
7380  
7381 ## F4.6.
7382 0 my $anode = $node;
7383 0 ▶ AN: while (defined $anode) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $anode) 0 0 0
7384 0 ▶ if ($anode->node_type == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($anode->node_type == 1) 0 0 0
7385 0 my $nsuri = $anode->namespaceURI;
7386 0 ▶ if (defined $nsuri and $nsuri eq 'http://www.w3.org/1999/xhtml') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $nsuri and $nsuri eq "http://www.w3.org/1999/xhtml") 0 0 0
Condition0%0/3
defined $nsuri and $nsuri eq "http://www.w3.org/1999/xhtml"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $nsuri and $nsuri eq "http://www.w3.org/1999/xhtml"
defined $nsuri $nsuri eq "http://www.w3.org/1999/xhtml"
Truth table0%0/3
A and B
A= defined $nsuriB= $nsuri eq "http://www.w3.org/1999/xhtml"
ABresult
0X0
100
111
7387 0 ▶ if ($anode->tagName eq 'form') {
Branch: 1 branch
BranchTrueFalseTotal
if ($anode->tagName eq "form") 0 0 0
7388
7389 0 $p->{form_element} = $anode;
7390 0 last AN;
7391 }
7392 }
7393 }
7394 0 $anode = $anode->parentNode;
7395 } # AN
7396  
7397 ## F.5. Set the input stream.
7398 0 $p->{confident} = 1; ## Confident: irrelevant.
7399  
7400 ## F.6. Start the parser.
7401 {
7402 0 my $self = $p;
7403 0 $token = $self->_get_next_token;
7404 }
7405 0 $p->_tree_construction_main;
7406  
7407 ## F.7.
7408 0 my @cn = $node->childNodes;
7409 0 for (@cn) {
7410 0 $node->removeChild ($_);
7411 }
7412 ## ISSUE: mutation events? read-only?
7413  
7414 ## Step 11 # MUST
7415 0 @cn = $root->childNodes;
7416 0 for (@cn) {
7417 0 $this_doc->adoptNode ($_);
7418 0 $node->appendChild ($_);
7419 }
7420 ## ISSUE: mutation events?
7421  
7422 0 $p->_terminate_tree_constructor;
7423  
7424 ## Remove self references.
7425 0 delete $p->{set_nc};
7426 0 delete $p->{read_until};
7427 0 delete $p->{parse_error};
7428 } else {
7429 0 die "$0: |set_inner_html| is not defined for node of type $nt";
7430 }
7431 } # set_inner_html
7432  
7433 } # tree construction stage
7434  
7435 11 package HTML::HTML5::Parser::TagSoupParser::RestartParser;
7436  
7437 sub new
7438 {
7439 3 ▶ my ($class, %opts) = @_;
Subroutine new: called CC=1 SCAR=0.0
7440 3 bless \%opts => $class;
7441 }
7442  
7443 sub throw
7444 {
7445 3 ▶ my ($class, %opts) = @_;
Subroutine throw: called CC=1 SCAR=0.0
7446 3 die $class->new(%opts);
7447 }
7448  
7449 11 1;
7450 # $Date: 2009/09/06 23:32:06 $
« blib/lib/HTML/HTML5/Parser/Charset/DecodeHandle.pm ↑ Summary blib/lib/HTML/HTML5/Parser/Charset/Info.pm »