2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/*
  
						 
					
						
							
								
									
										
										
										
											2021-09-26 12:39:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								 *  Copyright  ( c )  2020 - 2021 ,  Andreas  Kling  < kling @ serenityos . org > 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								 *  Copyright  ( c )  2021 ,  Luke  Wilde  < lukew @ serenityos . org > 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-22 01:24:48 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								 *  SPDX - License - Identifier :  BSD - 2 - Clause 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								 */ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-01-17 16:57:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <AK/Debug.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <AK/SourceLocation.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <AK/Utf32View.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-11-13 11:16:28 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibTextCodec/Decoder.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/Bindings/MainThreadVM.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-05-24 20:29:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/DOM/Comment.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								# include  <LibWeb/DOM/Document.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <LibWeb/DOM/DocumentType.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <LibWeb/DOM/ElementFactory.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:32:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/DOM/Event.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/DOM/ProcessingInstruction.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-07-28 18:20:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/DOM/Text.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-09-09 02:15:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/HTML/EventLoop/EventLoop.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-11-21 19:15:57 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/HTML/EventNames.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-07-26 15:08:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/HTML/HTMLFormElement.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <LibWeb/HTML/HTMLHeadElement.h> 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# include  <LibWeb/HTML/HTMLScriptElement.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-04-06 21:56:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/HTML/HTMLTableElement.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/HTML/HTMLTemplateElement.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-05-12 10:47:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/HTML/Parser/HTMLEncodingDetection.h> 
  
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/HTML/Parser/HTMLParser.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-07-28 19:18:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/HTML/Parser/HTMLToken.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-03-07 23:08:26 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/HTML/Window.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-10-04 21:30:29 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/HighResolutionTime/TimeOrigin.h> 
  
						 
					
						
							
								
									
										
										
										
											2022-10-01 18:14:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/Infra/CharacterTypes.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-10-10 02:48:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/Namespace.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# include  <LibWeb/SVG/TagNames.h> 
  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-28 18:20:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								namespace  Web : : HTML  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:58:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  inline  void  log_parse_error ( SourceLocation  const &  location  =  SourceLocation : : current ( ) )  
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    dbgln ( " Parse error! {} " ,  location ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:02:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								static  Vector < FlyString >  s_quirks_public_ids  =  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " +//Silmaril//dtd html Pro v0r11 19970101// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//AS//DTD HTML 3.0 asWedit + extensions// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//AdvaSoft Ltd//DTD HTML 3.0 asWedit + extensions// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML 2.0 Level 1// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML 2.0 Level 2// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML 2.0 Strict Level 1// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML 2.0 Strict Level 2// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML 2.0 Strict// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML 2.0// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML 2.1E// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML 3.0// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML 3.2 Final// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML 3.2// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML 3// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML Level 0// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML Level 1// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML Level 2// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML Level 3// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML Strict Level 0// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML Strict Level 1// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML Strict Level 2// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML Strict Level 3// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML Strict// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//IETF//DTD HTML// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//Metrius//DTD Metrius Presentational// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//Microsoft//DTD Internet Explorer 2.0 HTML Strict// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//Microsoft//DTD Internet Explorer 2.0 HTML// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//Microsoft//DTD Internet Explorer 2.0 Tables// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//Microsoft//DTD Internet Explorer 3.0 HTML Strict// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//Microsoft//DTD Internet Explorer 3.0 HTML// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//Microsoft//DTD Internet Explorer 3.0 Tables// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//Netscape Comm. Corp.//DTD HTML// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//Netscape Comm. Corp.//DTD Strict HTML// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//O'Reilly and Associates//DTD HTML 2.0// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//O'Reilly and Associates//DTD HTML Extended 1.0// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//O'Reilly and Associates//DTD HTML Extended Relaxed 1.0// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//SQ//DTD HTML 2.0 HoTMetaL + extensions// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//SoftQuad Software//DTD HoTMetaL PRO 6.0::19990601::extensions to HTML 4.0// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//SoftQuad//DTD HoTMetaL PRO 4.0::19971010::extensions to HTML 4.0// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//Spyglass//DTD HTML 2.0 Extended// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//Sun Microsystems Corp.//DTD HotJava HTML// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//Sun Microsystems Corp.//DTD HotJava Strict HTML// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//W3C//DTD HTML 3 1995-03-24// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//W3C//DTD HTML 3.2 Draft// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//W3C//DTD HTML 3.2 Final// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//W3C//DTD HTML 3.2// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//W3C//DTD HTML 3.2S Draft// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//W3C//DTD HTML 4.0 Frameset// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//W3C//DTD HTML 4.0 Transitional// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//W3C//DTD HTML Experimental 19960712// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//W3C//DTD HTML Experimental 970421// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//W3C//DTD W3 HTML// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//W3O//DTD W3 HTML 3.0// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//WebTechs//DTD Mozilla HTML 2.0// " , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    " -//WebTechs//DTD Mozilla HTML// " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-14 23:49:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/parsing.html#mathml-text-integration-point
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  bool  is_mathml_text_integration_point ( DOM : : Element  const & )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: Implement.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/parsing.html#html-integration-point
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  bool  is_html_integration_point ( DOM : : Element  const &  element )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // A node is an HTML integration point if it is one of the following elements:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: A MathML annotation-xml element whose start tag token had an attribute with the name "encoding" whose value was an ASCII case-insensitive match for the string "text/html"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: A MathML annotation-xml element whose start tag token had an attribute with the name "encoding" whose value was an ASCII case-insensitive match for the string "application/xhtml+xml"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // An SVG foreignObject element
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // An SVG desc element
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // An SVG title element
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( element . tag_name ( ) . is_one_of ( SVG : : TagNames : : foreignObject ,  SVG : : TagNames : : desc ,  SVG : : TagNames : : title ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:58:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HTMLParser : : HTMLParser ( DOM : : Document &  document ,  StringView  input ,  String  const &  encoding )  
						 
					
						
							
								
									
										
										
										
											2020-05-28 12:35:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    :  m_tokenizer ( input ,  encoding ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-23 20:43:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ,  m_scripting_enabled ( document . is_scripting_enabled ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ,  m_document ( JS : : make_handle ( document ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-24 21:24:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-02-15 18:45:10 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_tokenizer . set_parser ( { } ,  * this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_document - > set_parser ( { } ,  * this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-12-15 18:53:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_document - > set_should_invalidate_styles_on_attribute_changes ( false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-11 15:52:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  standardized_encoding  =  TextCodec : : get_standardized_encoding ( encoding ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    VERIFY ( standardized_encoding . has_value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_document - > set_encoding ( standardized_encoding . value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-24 21:24:11 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HTMLParser : : HTMLParser ( DOM : : Document &  document )  
						 
					
						
							
								
									
										
										
										
											2022-09-23 20:43:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    :  m_scripting_enabled ( document . is_scripting_enabled ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ,  m_document ( JS : : make_handle ( document ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_document - > set_parser ( { } ,  * this ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_tokenizer . set_parser ( { } ,  * this ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HTMLParser : : ~ HTMLParser ( )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-12-15 18:53:35 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_document - > set_should_invalidate_styles_on_attribute_changes ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : run ( )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  ( ; ; )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // FIXME: Find a better way to say that we come from Document::close() and want to process EOF.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_tokenizer . is_eof_inserted ( )  & &  m_tokenizer . is_insertion_point_reached ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        auto  optional_token  =  m_tokenizer . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! optional_token . has_value ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:32:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        auto &  token  =  optional_token . value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-24 22:06:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        dbgln_if ( HTML_PARSER_DEBUG ,  " [{}] {} " ,  insertion_mode_name ( ) ,  token . to_string ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-17 16:57:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-10-01 02:18:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // As each token is emitted from the tokenizer, the user agent must follow the appropriate steps from the following list, known as the tree construction dispatcher:
 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . is_empty ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            | |  adjusted_current_node ( ) . namespace_ ( )  = =  Namespace : : HTML 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-01 02:18:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            | |  ( is_html_integration_point ( adjusted_current_node ( ) )  & &  ( token . is_start_tag ( )  | |  token . is_character ( ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            | |  token . is_end_of_file ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-01 02:18:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // -> If the stack of open elements is empty
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // -> If the adjusted current node is an element in the HTML namespace
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // FIXME: -> If the adjusted current node is a MathML text integration point and the token is a start tag whose tag name is neither "mglyph" nor "malignmark"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // FIXME: -> If the adjusted current node is a MathML text integration point and the token is a character token
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // FIXME: -> If the adjusted current node is a MathML annotation-xml element and the token is a start tag whose tag name is "svg"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // -> If the adjusted current node is an HTML integration point and the token is a start tag
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // -> If the adjusted current node is an HTML integration point and the token is a character token
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // -> If the token is an end-of-file token
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // Process the token according to the rules given in the section corresponding to the current insertion mode in HTML content.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-01 02:18:55 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // -> Otherwise
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // Process the token according to the rules given in the section for parsing tokens in foreign content.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            process_using_the_rules_for_foreign_content ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 18:55:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( m_stop_parsing )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-24 22:06:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            dbgln_if ( HTML_PARSER_DEBUG ,  " Stop parsing{}! :^) " ,  m_parsing_fragment  ?  "  fragment "  :  " " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 18:55:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:32:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 21:53:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    flush_character_insertions ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-06-03 21:53:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : run ( const  AK : : URL &  url )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_document - > set_url ( url ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_document - > set_source ( m_tokenizer . source ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    run ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:00:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    the_end ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_document - > detach_parser ( { } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:00:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/parsing.html#the-end
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  HTMLParser : : the_end ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // Once the user agent stops parsing the document, the user agent must run the following steps:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 1. If the active speculative HTML parser is not null, then stop the speculative HTML parser and return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 2. Set the insertion point to undefined.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_tokenizer . undefine_insertion_point ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:32:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:00:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 3. Update the current document readiness to "interactive".
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 12:22:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_document - > update_readiness ( HTML : : DocumentReadyState : : Interactive ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-31 13:56:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:00:00 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 4. Pop all the nodes off the stack of open elements.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 17:04:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    while  ( ! m_stack_of_open_elements . is_empty ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 17:04:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 5. While the list of scripts that will execute when the document has finished parsing is not empty:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    while  ( ! m_document - > scripts_to_execute_when_parsing_has_finished ( ) . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 1. Spin the event loop until the first script in the list of scripts that will execute when the document has finished parsing
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //    has its "ready to be parser-executed" flag set and the parser's Document has no style sheet that is blocking scripts.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 17:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        main_thread_event_loop ( ) . spin_until ( [ & ]  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  m_document - > scripts_to_execute_when_parsing_has_finished ( ) . first ( ) - > is_ready_to_be_parser_executed ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                & &  ! m_document - > has_a_style_sheet_that_is_blocking_scripts ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 17:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 2. Execute the first script in the list of scripts that will execute when the document has finished parsing.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_document - > scripts_to_execute_when_parsing_has_finished ( ) . first ( ) - > execute_script ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 3. Remove the first script element from the list of scripts that will execute when the document has finished parsing (i.e. shift out the first entry in the list).
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_document - > scripts_to_execute_when_parsing_has_finished ( ) . take_first ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 12:26:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 6. Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following substeps:
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    old_queue_global_task_with_document ( HTML : : Task : : Source : : DOMManipulation ,  * m_document ,  [ document  =  m_document ] ( )  mutable  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 00:43:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 1. Set the Document's load timing info's DOM content loaded event start time to the current high resolution time given the Document's relevant global object.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-04 21:25:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        document - > load_timing_info ( ) . dom_content_loaded_event_start_time  =  HighResolutionTime : : unsafe_shared_current_time ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 2. Fire an event named DOMContentLoaded at the Document object, with its bubbles attribute initialized to true.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-25 16:38:21 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  content_loaded_event  =  DOM : : Event : : create ( document - > realm ( ) ,  HTML : : EventNames : : DOMContentLoaded ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        content_loaded_event - > set_bubbles ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-08 22:29:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        document - > dispatch_event ( * content_loaded_event ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 00:43:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 3. Set the Document's load timing info's DOM content loaded event end time to the current high resolution time given the Document's relevant global object.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-04 21:25:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        document - > load_timing_info ( ) . dom_content_loaded_event_end_time  =  HighResolutionTime : : unsafe_shared_current_time ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // FIXME: 4. Enable the client message queue of the ServiceWorkerContainer object whose associated service worker client is the Document object's relevant settings object.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // FIXME: 5. Invoke WebDriver BiDi DOM content loaded with the Document's browsing context, and a new WebDriver BiDi navigation status whose id is the Document object's navigation id, status is "pending", and url is the Document object's URL.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-18 13:45:28 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-20 17:06:10 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 7. Spin the event loop until the set of scripts that will execute as soon as possible and the list of scripts that will execute in order as soon as possible are empty.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    main_thread_event_loop ( ) . spin_until ( [ & ]  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  m_document - > scripts_to_execute_as_soon_as_possible ( ) . is_empty ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-31 13:56:16 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 01:03:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 8. Spin the event loop until there is nothing that delays the load event in the Document.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: Track down all the things that are supposed to delay the load event.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    main_thread_event_loop ( ) . spin_until ( [ & ]  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  m_document - > number_of_things_delaying_the_load_event ( )  = =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 9. Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following steps:
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    old_queue_global_task_with_document ( HTML : : Task : : Source : : DOMManipulation ,  * m_document ,  [ document  =  m_document ] ( )  mutable  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 1. Update the current document readiness to "complete".
 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 12:22:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        document - > update_readiness ( HTML : : DocumentReadyState : : Complete ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 2. If the Document object's browsing context is null, then abort these steps.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! document - > browsing_context ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 12:39:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 3. Let window be the Document's relevant global object.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        JS : : NonnullGCPtr < Window >  window  =  document - > window ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 00:43:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 4. Set the Document's load timing info's load event start time to the current high resolution time given window.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-04 21:25:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        document - > load_timing_info ( ) . load_event_start_time  =  HighResolutionTime : : unsafe_shared_current_time ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 5. Fire an event named load at window, with legacy target override flag set.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //        We should reorganize this so that the flag appears explicitly here instead.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-09-25 16:38:21 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        window - > dispatch_event ( * DOM : : Event : : create ( document - > realm ( ) ,  HTML : : EventNames : : load ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // FIXME: 6. Invoke WebDriver BiDi load complete with the Document's browsing context, and a new WebDriver BiDi navigation status whose id is the Document object's navigation id, status is "complete", and url is the Document object's URL.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // FIXME: 7. Set the Document object's navigation id to null.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-21 00:43:38 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 8. Set the Document's load timing info's load event end time to the current high resolution time given window.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-04 21:25:00 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        document - > load_timing_info ( ) . load_event_end_time  =  HighResolutionTime : : unsafe_shared_current_time ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 12:26:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 9. Assert: Document's page showing is false.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        VERIFY ( ! document - > page_showing ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 12:26:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 10. Set the Document's page showing flag to true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        document - > set_page_showing ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 12:39:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 11. Fire a page transition event named pageshow at window with false.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        window - > fire_a_page_transition_event ( HTML : : EventNames : : pageshow ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 12. Completely finish loading the Document.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        document - > completely_finish_loading ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // FIXME: 13. Queue the navigation timing entry for the Document.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-21 18:32:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // FIXME: 10. If the Document's print when loaded flag is set, then run the printing steps.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-21 18:32:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-26 00:51:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 11. The Document is now ready for post-load tasks.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-11-21 18:32:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_document - > set_ready_for_post_load_tasks ( true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : process_using_the_rules_for ( InsertionMode  mode ,  HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    switch  ( mode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : Initial : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_initial ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : BeforeHTML : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_before_html ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : BeforeHead : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_before_head ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : InHead : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_in_head ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : InHeadNoscript : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_in_head_noscript ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : AfterHead : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_after_head ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : InBody : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_in_body ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : AfterBody : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_after_body ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : AfterAfterBody : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_after_after_body ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : Text : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_text ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    case  InsertionMode : : InTable : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_in_table ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    case  InsertionMode : : InTableBody : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_in_table_body ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : InRow : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_in_row ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : InCell : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_in_cell ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 17:57:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    case  InsertionMode : : InTableText : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_in_table_text ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    case  InsertionMode : : InSelectInTable : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_in_select_in_table ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : InSelect : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_in_select ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 05:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    case  InsertionMode : : InCaption : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_in_caption ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 06:22:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    case  InsertionMode : : InColumnGroup : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_in_column_group ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    case  InsertionMode : : InTemplate : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_in_template ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : InFrameset : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_in_frameset ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : AfterFrameset : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_after_frameset ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : AfterAfterFrameset : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        handle_after_after_frameset ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    default : 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:58:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								DOM : : QuirksMode  HTMLParser : : which_quirks_mode ( HTMLToken  const &  doctype_token )  const  
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2021-07-15 00:03:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( doctype_token . doctype_data ( ) . force_quirks ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 19:37:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  DOM : : QuirksMode : : Yes ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // NOTE: The tokenizer puts the name into lower case for us.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 00:03:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( doctype_token . doctype_data ( ) . name  ! =  " html " ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 19:37:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  DOM : : QuirksMode : : Yes ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 00:03:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  const &  public_identifier  =  doctype_token . doctype_data ( ) . public_identifier ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  const &  system_identifier  =  doctype_token . doctype_data ( ) . system_identifier ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( public_identifier . equals_ignoring_case ( " -//W3O//DTD W3 HTML Strict 3.0//EN// " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 19:37:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  DOM : : QuirksMode : : Yes ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( public_identifier . equals_ignoring_case ( " -/W3C/DTD HTML 4.0 Transitional/EN " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 19:37:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  DOM : : QuirksMode : : Yes ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( public_identifier . equals_ignoring_case ( " HTML " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 19:37:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  DOM : : QuirksMode : : Yes ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( system_identifier . equals_ignoring_case ( " http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd " sv ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 19:37:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  DOM : : QuirksMode : : Yes ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  ( auto &  public_id  :  s_quirks_public_ids )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( public_identifier . starts_with ( public_id ,  CaseSensitivity : : CaseInsensitive ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 19:37:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  DOM : : QuirksMode : : Yes ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 00:03:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( doctype_token . doctype_data ( ) . missing_system_identifier )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( public_identifier . starts_with ( " -//W3C//DTD HTML 4.01 Frameset// " sv ,  CaseSensitivity : : CaseInsensitive ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 19:37:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  DOM : : QuirksMode : : Yes ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( public_identifier . starts_with ( " -//W3C//DTD HTML 4.01 Transitional// " sv ,  CaseSensitivity : : CaseInsensitive ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 19:37:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  DOM : : QuirksMode : : Yes ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( public_identifier . starts_with ( " -//W3C//DTD XHTML 1.0 Frameset// " sv ,  CaseSensitivity : : CaseInsensitive ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 19:37:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  DOM : : QuirksMode : : Limited ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( public_identifier . starts_with ( " -//W3C//DTD XHTML 1.0 Transitional// " sv ,  CaseSensitivity : : CaseInsensitive ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 19:37:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  DOM : : QuirksMode : : Limited ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 00:03:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( ! doctype_token . doctype_data ( ) . missing_system_identifier )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( public_identifier . starts_with ( " -//W3C//DTD HTML 4.01 Frameset// " sv ,  CaseSensitivity : : CaseInsensitive ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 19:37:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  DOM : : QuirksMode : : Limited ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( public_identifier . starts_with ( " -//W3C//DTD HTML 4.01 Transitional// " sv ,  CaseSensitivity : : CaseInsensitive ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 19:37:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  DOM : : QuirksMode : : Limited ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 19:37:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  DOM : : QuirksMode : : No ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_initial ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_character ( )  & &  token . is_parser_whitespace ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_comment ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  comment  =  realm ( ) . heap ( ) . allocate < DOM : : Comment > ( realm ( ) ,  document ( ) ,  token . comment ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        document ( ) . append_child ( * comment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  doctype  =  realm ( ) . heap ( ) . allocate < DOM : : DocumentType > ( realm ( ) ,  document ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 00:03:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        doctype - > set_name ( token . doctype_data ( ) . name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        doctype - > set_public_id ( token . doctype_data ( ) . public_identifier ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        doctype - > set_system_id ( token . doctype_data ( ) . system_identifier ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        document ( ) . append_child ( * doctype ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-18 21:17:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        document ( ) . set_quirks_mode ( which_quirks_mode ( token ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : BeforeHTML ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:21:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-26 19:37:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    document ( ) . set_quirks_mode ( DOM : : QuirksMode : : Yes ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:21:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_insertion_mode  =  InsertionMode : : BeforeHTML ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    process_using_the_rules_for ( InsertionMode : : BeforeHTML ,  token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_before_html ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_comment ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  comment  =  realm ( ) . heap ( ) . allocate < DOM : : Comment > ( realm ( ) ,  document ( ) ,  token . comment ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        document ( ) . append_child ( * comment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_character ( )  & &  token . is_parser_whitespace ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-01 21:10:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  element  =  create_element_for ( token ,  Namespace : : HTML ,  document ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        document ( ) . append_child ( * element ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:24:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_stack_of_open_elements . push ( move ( element ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : BeforeHead ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : head ,  HTML : : TagNames : : body ,  HTML : : TagNames : : html ,  HTML : : TagNames : : br ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        goto  AnythingElse ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								AnythingElse :  
						 
					
						
							
								
									
										
										
										
											2020-10-10 02:48:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  element  =  create_element ( document ( ) ,  HTML : : TagNames : : html ,  Namespace : : HTML ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    document ( ) . append_child ( * element ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_stack_of_open_elements . push ( element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: If the Document is being loaded as part of navigation of a browsing context, then: run the application cache selection algorithm with no manifest, passing it the Document object.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_insertion_mode  =  InsertionMode : : BeforeHead ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    process_using_the_rules_for ( InsertionMode : : BeforeHead ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								DOM : : Element &  HTMLParser : : current_node ( )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:24:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  m_stack_of_open_elements . current_node ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								DOM : : Element &  HTMLParser : : adjusted_current_node ( )  
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( m_parsing_fragment  & &  m_stack_of_open_elements . elements ( ) . size ( )  = =  1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  * m_context_element ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  current_node ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								DOM : : Element &  HTMLParser : : node_before_current_node ( )  
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  * m_stack_of_open_elements . elements ( ) . at ( m_stack_of_open_elements . elements ( ) . size ( )  -  2 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 22:19:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/parsing.html#appropriate-place-for-inserting-a-node
  
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HTMLParser : : AdjustedInsertionLocation  HTMLParser : : find_appropriate_place_for_inserting_node ( JS : : GCPtr < DOM : : Element >  override_target )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto &  target  =  override_target  ?  * override_target . ptr ( )  :  current_node ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    HTMLParser : : AdjustedInsertionLocation  adjusted_insertion_location ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 22:19:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 2. Determine the adjusted insertion location using the first matching steps from the following list:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // `-> If foster parenting is enabled and target is a table, tbody, tfoot, thead, or tr element
 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( m_foster_parenting  & &  target . local_name ( ) . is_one_of ( HTML : : TagNames : : table ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tr ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 22:19:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 1. Let last template be the last template element in the stack of open elements, if any.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  last_template  =  m_stack_of_open_elements . last_element_with_tag_name ( HTML : : TagNames : : template_ ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 22:19:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 2. Let last table be the last table element in the stack of open elements, if any.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 17:00:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  last_table  =  m_stack_of_open_elements . last_element_with_tag_name ( HTML : : TagNames : : table ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 22:19:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 3. If there is a last template and either there is no last table,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //    or there is one, but last template is lower (more recently added) than last table in the stack of open elements,
 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( last_template . element  & &  ( ! last_table . element  | |  last_template . index  >  last_table . index ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 22:19:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // then: let adjusted insertion location be inside last template's template contents, after its last child (if any), and abort these steps.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // NOTE: This returns the template content, so no need to check the parent is a template.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  {  verify_cast < HTMLTemplateElement > ( * last_template . element ) . content ( ) . ptr ( ) ,  nullptr  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 22:19:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 4. If there is no last table, then let adjusted insertion location be inside the first element in the stack of open elements (the html element),
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //    after its last child (if any), and abort these steps. (fragment case)
 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! last_table . element )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // Guaranteed not to be a template element (it will be the html element),
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // so no need to check the parent is a template.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  {  * m_stack_of_open_elements . elements ( ) . first ( ) ,  nullptr  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 22:19:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 5. If last table has a parent node, then let adjusted insertion location be inside last table's parent node, immediately before last table, and abort these steps.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( last_table . element - > parent_node ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            adjusted_insertion_location  =  {  last_table . element - > parent_node ( ) ,  last_table . element . ptr ( )  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 22:19:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 6. Let previous element be the element immediately above last table in the stack of open elements.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 22:24:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            auto  previous_element  =  m_stack_of_open_elements . element_immediately_above ( * last_table . element ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 22:19:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 7. Let adjusted insertion location be inside previous element, after its last child (if any).
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            adjusted_insertion_location  =  {  previous_element . ptr ( ) ,  nullptr  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 22:19:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-14 22:19:34 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // `-> Otherwise
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //     Let adjusted insertion location be inside target, after its last child (if any).
 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        adjusted_insertion_location  =  {  target ,  nullptr  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 17:00:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( is < HTMLTemplateElement > ( * adjusted_insertion_location . parent ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  {  verify_cast < HTMLTemplateElement > ( * adjusted_insertion_location . parent ) . content ( ) . ptr ( ) ,  nullptr  } ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  adjusted_insertion_location ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS : : NonnullGCPtr < DOM : : Element >  HTMLParser : : create_element_for ( HTMLToken  const &  token ,  FlyString  const &  namespace_ ,  DOM : : Node  const &  intended_parent )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-01 21:10:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // FIXME: 1. If the active speculative HTML parser is not null, then return the result of creating a speculative mock element given given namespace, the tag name of the given token, and the attributes of the given token.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 2. Otherwise, optionally create a speculative mock element given given namespace, the tag name of the given token, and the attributes of the given token.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 3. Let document be intended parent's node document.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    JS : : NonnullGCPtr < DOM : : Document >  document  =  intended_parent . document ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-01 21:10:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 4. Let local name be the tag name of the token.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  local_name  =  token . tag_name ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 5. Let is be the value of the "is" attribute in the given token, if such an attribute exists, or null otherwise.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 6. Let definition be the result of looking up a custom element definition given document, given namespace, local name, and is.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 7. If definition is non-null and the parser was not created as part of the HTML fragment parsing algorithm, then let will execute script be true. Otherwise, let it be false.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 8. If will execute script is true, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME:    1. Increment document's throw-on-dynamic-markup-insertion counter.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME:    2. If the JavaScript execution context stack is empty, then perform a microtask checkpoint.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME:    3. Push a new element queue onto document's relevant agent's custom element reactions stack.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 9. Let element be the result of creating an element given document, localName, given namespace, null, and is.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: If will execute script is true, set the synchronous custom elements flag; otherwise, leave it unset.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: Pass in `null` and `is`.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  element  =  create_element ( * document ,  local_name ,  namespace_ ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-01 21:10:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 10. Append each attribute in the given token to element.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: This isn't the exact `append` the spec is talking about.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-14 23:53:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    token . for_each_attribute ( [ & ] ( auto &  attribute )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-23 08:50:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        element - > set_attribute ( attribute . local_name ,  attribute . value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-14 23:53:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  IterationDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-01 21:10:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 11. If will execute script is true, then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME:     1. Let queue be the result of popping from document's relevant agent's custom element reactions stack. (This will be the same element queue as was pushed above.)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME:     2. Invoke custom element reactions in queue.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME:     3. Decrement document's throw-on-dynamic-markup-insertion counter.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 12. If element has an xmlns attribute in the XMLNS namespace whose value is not exactly the same as the element's namespace, that is a parse error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    //            Similarly, if element has an xmlns:xlink attribute in the XMLNS namespace whose value is not the XLink Namespace, that is a parse error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 13. If element is a resettable element, invoke its reset algorithm. (This initializes the element's value and checkedness based on the element's attributes.)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 14. If element is a form-associated element and not a form-associated custom element, the form element pointer is not null, there is no template element on the stack of open elements,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    //     element is either not listed or doesn't have a form attribute, and the intended parent is in the same tree as the element pointed to by the form element pointer,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    //     then associate element with the form element pointed to by the form element pointer and set element's parser inserted flag.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: Check if the element is not a form-associated custom element.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( is < FormAssociatedElement > ( * element ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 18:55:54 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto *  form_associated_element  =  dynamic_cast < FormAssociatedElement * > ( element . ptr ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        VERIFY ( form_associated_element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto &  html_element  =  form_associated_element - > form_associated_element_to_html_element ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-01 21:10:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_form_element . ptr ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-01 21:10:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            & &  ! m_stack_of_open_elements . contains ( HTML : : TagNames : : template_ ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 18:55:54 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            & &  ( ! form_associated_element - > is_listed ( )  | |  ! html_element . has_attribute ( HTML : : AttributeNames : : form ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-01 21:10:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            & &  & intended_parent . root ( )  = =  & m_form_element - > root ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form_associated_element - > set_form ( m_form_element . ptr ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-23 18:55:54 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            form_associated_element - > set_parser_inserted ( { } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-01 21:10:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 15. Return element.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    return  element ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 19:35:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/parsing.html#insert-a-foreign-element
  
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS : : NonnullGCPtr < DOM : : Element >  HTMLParser : : insert_foreign_element ( HTMLToken  const &  token ,  FlyString  const &  namespace_ )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  adjusted_insertion_location  =  find_appropriate_place_for_inserting_node ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 19:35:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-01 21:10:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // NOTE: adjusted_insertion_location.parent will be non-null, however, it uses RP to be able to default-initialize HTMLParser::AdjustedInsertionLocation.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  element  =  create_element_for ( token ,  namespace_ ,  * adjusted_insertion_location . parent ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 19:35:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  pre_insertion_validity  =  adjusted_insertion_location . parent - > ensure_pre_insertion_validity ( * element ,  adjusted_insertion_location . insert_before_sibling ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 19:35:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // NOTE: If it's not possible to insert the element at the adjusted insertion location, the element is simply dropped.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ! pre_insertion_validity . is_exception ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_parsing_fragment )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // FIXME: push a new element queue onto element's relevant agent's custom element reactions stack.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        adjusted_insertion_location . parent - > insert_before ( * element ,  adjusted_insertion_location . insert_before_sibling ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 19:35:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_parsing_fragment )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // FIXME: pop the element queue from element's relevant agent's custom element reactions stack, and invoke custom element reactions in that queue.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:24:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_stack_of_open_elements . push ( element ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    return  element ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS : : NonnullGCPtr < DOM : : Element >  HTMLParser : : insert_html_element ( HTMLToken  const &  token )  
						 
					
						
							
								
									
										
										
										
											2020-10-10 02:48:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  insert_foreign_element ( token ,  Namespace : : HTML ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_before_head ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_character ( )  & &  token . is_parser_whitespace ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_comment ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        insert_comment ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : head )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        auto  element  =  insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_head_element  =  JS : : make_handle ( verify_cast < HTMLHeadElement > ( * element ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InHead ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : head ,  HTML : : TagNames : : body ,  HTML : : TagNames : : html ,  HTML : : TagNames : : br ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        goto  AnythingElse ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								AnythingElse :  
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_head_element  =  JS : : make_handle ( verify_cast < HTMLHeadElement > ( * insert_html_element ( HTMLToken : : make_start_tag ( HTML : : TagNames : : head ) ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 01:49:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_insertion_mode  =  InsertionMode : : InHead ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    process_using_the_rules_for ( InsertionMode : : InHead ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : insert_comment ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 20:29:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  adjusted_insertion_location  =  find_appropriate_place_for_inserting_node ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    adjusted_insertion_location . parent - > insert_before ( * realm ( ) . heap ( ) . allocate < DOM : : Comment > ( realm ( ) ,  document ( ) ,  token . comment ( ) ) ,  adjusted_insertion_location . insert_before_sibling ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 20:29:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_in_head ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-05-24 20:24:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_parser_whitespace ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-05 16:31:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        insert_character ( token . code_point ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 20:24:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 20:29:01 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_comment ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        insert_comment ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : base ,  HTML : : TagNames : : basefont ,  HTML : : TagNames : : bgsound ,  HTML : : TagNames : : link ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:16:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        token . acknowledge_self_closing_flag_if_set ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : meta )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 12:28:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        token . acknowledge_self_closing_flag_if_set ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : title )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 20:24:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_tokenizer . switch_to ( { } ,  HTMLTokenizer : : State : : RCDATA ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_original_insertion_mode  =  m_insertion_mode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : Text ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  ( ( token . tag_name ( )  = =  HTML : : TagNames : : noscript  & &  m_scripting_enabled )  | |  token . tag_name ( )  = =  HTML : : TagNames : : noframes  | |  token . tag_name ( )  = =  HTML : : TagNames : : style ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 20:36:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        parse_generic_raw_text_element ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : noscript  & &  ! m_scripting_enabled )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InHeadNoscript ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 17:00:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : script )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:00:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  adjusted_insertion_location  =  find_appropriate_place_for_inserting_node ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-01 21:10:48 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  element  =  create_element_for ( token ,  Namespace : : HTML ,  * adjusted_insertion_location . parent ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-24 19:53:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto &  script_element  =  verify_cast < HTMLScriptElement > ( * element ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:25:17 +04:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        script_element . set_parser_document ( Badge < HTMLParser >  { } ,  document ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        script_element . set_non_blocking ( Badge < HTMLParser >  { } ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-13 23:17:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        script_element . set_source_line_number ( { } ,  token . start_position ( ) . line  +  1 ) ;  // FIXME: This +1 is incorrect for script tags whose script does not start on a new line
 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:00:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( m_parsing_fragment )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:25:17 +04:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            script_element . set_already_started ( Badge < HTMLParser >  { } ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:00:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( m_invoked_via_document_write )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            TODO ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        adjusted_insertion_location . parent - > insert_before ( * element ,  adjusted_insertion_location . insert_before_sibling ,  false ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:00:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_stack_of_open_elements . push ( element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_tokenizer . switch_to ( { } ,  HTMLTokenizer : : State : : ScriptData ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_original_insertion_mode  =  m_insertion_mode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : Text ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : head )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : AfterHead ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 12:28:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : body ,  HTML : : TagNames : : html ,  HTML : : TagNames : : br ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        goto  AnythingElse ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 12:28:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : template_ )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_list_of_active_formatting_elements . add_marker ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InTemplate ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_template_insertion_modes . append ( InsertionMode : : InTemplate ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:23:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 12:28:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : template_ )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . contains ( HTML : : TagNames : : template_ ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        generate_all_implied_end_tags_thoroughly ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  ! =  HTML : : TagNames : : template_ ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : template_ ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_list_of_active_formatting_elements . clear_up_to_the_last_marker ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_template_insertion_modes . take_last ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        reset_the_insertion_mode_appropriately ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:23:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 12:28:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : head )  | |  token . is_end_tag ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 12:28:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								AnythingElse :  
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 12:28:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_insertion_mode  =  InsertionMode : : AfterHead ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_in_head_noscript ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : noscript )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InHead ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_parser_whitespace ( )  | |  token . is_comment ( )  | |  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : basefont ,  HTML : : TagNames : : bgsound ,  HTML : : TagNames : : link ,  HTML : : TagNames : : meta ,  HTML : : TagNames : : noframes ,  HTML : : TagNames : : style ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InHead ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : br )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        goto  AnythingElse ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : head ,  HTML : : TagNames : : noscript ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								AnythingElse :  
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_insertion_mode  =  InsertionMode : : InHead ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : parse_generic_raw_text_element ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 20:36:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 20:36:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_tokenizer . switch_to ( { } ,  HTMLTokenizer : : State : : RAWTEXT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_original_insertion_mode  =  m_insertion_mode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_insertion_mode  =  InsertionMode : : Text ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								DOM : : Text *  HTMLParser : : find_character_insertion_node ( )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  adjusted_insertion_location  =  find_appropriate_place_for_inserting_node ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 17:00:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( adjusted_insertion_location . insert_before_sibling )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        TODO ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( adjusted_insertion_location . parent - > is_document ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 21:53:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 17:00:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( adjusted_insertion_location . parent - > last_child ( )  & &  adjusted_insertion_location . parent - > last_child ( ) - > is_text ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-06-24 19:53:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  verify_cast < DOM : : Text > ( adjusted_insertion_location . parent - > last_child ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  new_text_node  =  realm ( ) . heap ( ) . allocate < DOM : : Text > ( realm ( ) ,  document ( ) ,  " " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    adjusted_insertion_location . parent - > append_child ( * new_text_node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 21:53:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  new_text_node ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : flush_character_insertions ( )  
						 
					
						
							
								
									
										
										
										
											2020-06-03 21:53:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( m_character_insertion_builder . is_empty ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 21:53:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_character_insertion_node - > set_data ( m_character_insertion_builder . to_string ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 22:11:54 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_character_insertion_node - > parent ( ) - > children_changed ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 21:53:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_character_insertion_builder . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : insert_character ( u32  data )  
						 
					
						
							
								
									
										
										
										
											2020-06-03 21:53:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  node  =  find_character_insertion_node ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( node  = =  m_character_insertion_node . ptr ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 21:53:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_character_insertion_builder . append ( Utf32View  {  & data ,  1  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( ! m_character_insertion_node . ptr ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_character_insertion_node  =  JS : : make_handle ( node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 21:53:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_character_insertion_builder . append ( Utf32View  {  & data ,  1  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    flush_character_insertions ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_character_insertion_node  =  JS : : make_handle ( node ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 21:53:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_character_insertion_builder . append ( Utf32View  {  & data ,  1  } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_after_head ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-05-31 19:27:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_character ( )  & &  token . is_parser_whitespace ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-05 16:31:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        insert_character ( token . code_point ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-31 19:27:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_comment ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-31 19:27:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        insert_comment ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-31 19:27:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-31 19:27:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : body )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:49:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InBody ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : frameset )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-31 19:27:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InFrameset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : base ,  HTML : : TagNames : : basefont ,  HTML : : TagNames : : bgsound ,  HTML : : TagNames : : link ,  HTML : : TagNames : : meta ,  HTML : : TagNames : : noframes ,  HTML : : TagNames : : script ,  HTML : : TagNames : : style ,  HTML : : TagNames : : template_ ,  HTML : : TagNames : : title ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:23:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_stack_of_open_elements . push ( * m_head_element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InHead ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_open_elements . elements ( ) . remove_first_matching ( [ & ] ( auto &  entry )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  entry . ptr ( )  = =  m_head_element . ptr ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:23:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : template_ )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InHead ,  token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 17:00:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : body ,  HTML : : TagNames : : html ,  HTML : : TagNames : : br ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        goto  AnythingElse ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : head )  | |  token . is_end_tag ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-31 19:27:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								AnythingElse :  
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ( void ) insert_html_element ( HTMLToken : : make_start_tag ( HTML : : TagNames : : body ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								    m_insertion_mode  =  InsertionMode : : InBody ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-31 19:27:51 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:58:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : generate_implied_end_tags ( FlyString  const &  exception )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    while  ( current_node ( ) . local_name ( )  ! =  exception  & &  current_node ( ) . local_name ( ) . is_one_of ( HTML : : TagNames : : dd ,  HTML : : TagNames : : dt ,  HTML : : TagNames : : li ,  HTML : : TagNames : : optgroup ,  HTML : : TagNames : : option ,  HTML : : TagNames : : p ,  HTML : : TagNames : : rb ,  HTML : : TagNames : : rp ,  HTML : : TagNames : : rt ,  HTML : : TagNames : : rtc ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:49:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : generate_all_implied_end_tags_thoroughly ( )  
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    while  ( current_node ( ) . local_name ( ) . is_one_of ( HTML : : TagNames : : caption ,  HTML : : TagNames : : colgroup ,  HTML : : TagNames : : dd ,  HTML : : TagNames : : dt ,  HTML : : TagNames : : li ,  HTML : : TagNames : : optgroup ,  HTML : : TagNames : : option ,  HTML : : TagNames : : p ,  HTML : : TagNames : : rb ,  HTML : : TagNames : : rp ,  HTML : : TagNames : : rt ,  HTML : : TagNames : : rtc ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : td ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : th ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tr ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : close_a_p_element ( )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    generate_implied_end_tags ( HTML : : TagNames : : p ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( current_node ( ) . local_name ( )  ! =  HTML : : TagNames : : p )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : p ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_after_body ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:49:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_character ( )  & &  token . is_parser_whitespace ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 18:52:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_comment ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto &  insertion_location  =  m_stack_of_open_elements . first ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        insertion_location . append_child ( * realm ( ) . heap ( ) . allocate < DOM : : Comment > ( realm ( ) ,  document ( ) ,  token . comment ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 18:52:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 18:52:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 18:52:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:49:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_parsing_fragment )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:49:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : AfterAfterBody ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 18:52:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_of_file ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        stop_parsing ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 18:52:32 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_insertion_mode  =  InsertionMode : : InBody ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:49:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_after_after_body ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:49:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-06-01 12:38:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_comment ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto  comment  =  realm ( ) . heap ( ) . allocate < DOM : : Comment > ( realm ( ) ,  document ( ) ,  token . comment ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        document ( ) . append_child ( * comment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-01 12:38:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( )  | |  token . is_parser_whitespace ( )  | |  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:49:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_of_file ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 18:55:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        stop_parsing ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:49:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-01 12:38:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-01 12:38:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_insertion_mode  =  InsertionMode : : InBody ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:49:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-20 03:29:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/parsing.html#reconstruct-the-active-formatting-elements
  
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : reconstruct_the_active_formatting_elements ( )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-02-20 03:29:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 1. If there are no entries in the list of active formatting elements, then there is nothing to reconstruct; stop this algorithm.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( m_list_of_active_formatting_elements . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-20 03:29:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 2. If the last (most recently added) entry in the list of active formatting elements is a marker, or if it is an element that is in the stack of open elements,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    //    then there is nothing to reconstruct; stop this algorithm.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( m_list_of_active_formatting_elements . entries ( ) . last ( ) . is_marker ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:22:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( m_stack_of_open_elements . contains ( * m_list_of_active_formatting_elements . entries ( ) . last ( ) . element ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-20 03:29:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 3. Let entry be the last (most recently added) element in the list of active formatting elements.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    size_t  index  =  m_list_of_active_formatting_elements . entries ( ) . size ( )  -  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // NOTE: Entry will never be null, but must be a pointer instead of a reference to allow rebinding.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto *  entry  =  & m_list_of_active_formatting_elements . entries ( ) . at ( index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Rewind :  
						 
					
						
							
								
									
										
										
										
											2022-02-20 03:29:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 4. Rewind: If there are no entries before entry in the list of active formatting elements, then jump to the step labeled create.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( index  = =  0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        goto  Create ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-20 03:29:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 5. Let entry be the entry one earlier than entry in the list of active formatting elements.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    - - index ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-20 03:29:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    entry  =  & m_list_of_active_formatting_elements . entries ( ) . at ( index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-20 03:29:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 6. If entry is neither a marker nor an element that is also in the stack of open elements, go to the step labeled rewind.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ! entry - > is_marker ( )  & &  ! m_stack_of_open_elements . contains ( * entry - > element ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        goto  Rewind ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Advance :  
						 
					
						
							
								
									
										
										
										
											2022-02-20 03:29:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 7. Advance: Let entry be the element one later than entry in the list of active formatting elements.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    + + index ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-20 03:29:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    entry  =  & m_list_of_active_formatting_elements . entries ( ) . at ( index ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Create :  
						 
					
						
							
								
									
										
										
										
											2022-02-20 03:29:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 8. Create: Insert an HTML element for the token for which the element entry was created, to obtain new element.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    VERIFY ( ! entry - > is_marker ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // FIXME: Hold on to the real token!
 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-20 03:29:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  new_element  =  insert_html_element ( HTMLToken : : make_start_tag ( entry - > element - > local_name ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-20 03:29:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 9. Replace the entry for entry in the list with an entry for new element.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_list_of_active_formatting_elements . entries ( ) . at ( index ) . element  =  JS : : make_handle ( new_element . ptr ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-20 03:29:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 10. If the entry for new element in the list of active formatting elements is not the last entry in the list, return to the step labeled advance.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( index  ! =  m_list_of_active_formatting_elements . entries ( ) . size ( )  -  1 ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        goto  Advance ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/parsing.html#adoption-agency-algorithm
  
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								HTMLParser : : AdoptionAgencyAlgorithmOutcome  HTMLParser : : run_the_adoption_agency_algorithm ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:22:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 1. Let subject be token's tag name.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto &  subject  =  token . tag_name ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:22:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 2. If the current node is an HTML element whose tag name is subject,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    //    and the current node is not in the list of active formatting elements,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    //    then pop the current node off the stack of open elements, and return.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( current_node ( ) . local_name ( )  = =  subject  & &  ! m_list_of_active_formatting_elements . contains ( current_node ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 16:22:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  AdoptionAgencyAlgorithmOutcome : : DoNothing ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:22:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 3. Let outer loop counter be 0.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    size_t  outer_loop_counter  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:22:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // 4. While true:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    while  ( true )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 1. If outer loop counter is greater than or equal to 8, then return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( outer_loop_counter  > =  8 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  AdoptionAgencyAlgorithmOutcome : : DoNothing ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:22:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 2. Increment outer loop counter by 1.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        outer_loop_counter + + ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:22:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 3. Let formatting element be the last element in the list of active formatting elements that:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //    - is between the end of the list and the last marker in the list, if any, or the start of the list otherwise, and
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //    - has the tag name subject.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto *  formatting_element  =  m_list_of_active_formatting_elements . last_element_with_tag_name_before_marker ( subject ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // If there is no such element, then return and instead act as described in the "any other end tag" entry above.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! formatting_element ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  AdoptionAgencyAlgorithmOutcome : : RunAnyOtherEndTagSteps ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 4. If formatting element is not in the stack of open elements,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . contains ( * formatting_element ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // then this is a parse error;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // remove the element from the list,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_list_of_active_formatting_elements . remove ( * formatting_element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // and return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  AdoptionAgencyAlgorithmOutcome : : DoNothing ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:22:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 5. If formatting element is in the stack of open elements, but the element is not in scope,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_scope ( * formatting_element ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // then this is a parse error;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  AdoptionAgencyAlgorithmOutcome : : DoNothing ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:22:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 6. If formatting element is not the current node,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( formatting_element  ! =  & current_node ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // this is a parse error. (But do not return.)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 7. Let furthest block be the topmost node in the stack of open elements that is lower in the stack than formatting element,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //    and is an element in the special category. There might not be one.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        JS : : GCPtr < DOM : : Element >  furthest_block  =  m_stack_of_open_elements . topmost_special_node_below ( * formatting_element ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 8. If there is no furthest block
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! furthest_block )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // then the UA must first pop all the nodes from the bottom of the stack of open elements,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // from the current node up to and including formatting element,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            while  ( & current_node ( )  ! =  formatting_element ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:22:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // then remove formatting element from the list of active formatting elements,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_list_of_active_formatting_elements . remove ( * formatting_element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // and finally return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  AdoptionAgencyAlgorithmOutcome : : DoNothing ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 9. Let common ancestor be the element immediately above formatting element in the stack of open elements.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  common_ancestor  =  m_stack_of_open_elements . element_immediately_above ( * formatting_element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 10. Let a bookmark note the position of formatting element in the list of active formatting elements
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //     relative to the elements on either side of it in the list.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  bookmark  =  m_list_of_active_formatting_elements . find_index ( * formatting_element ) . value ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 11. Let node and last node be furthest block.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  node  =  furthest_block ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  last_node  =  furthest_block ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Keep track of this for later
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  node_above_node  =  m_stack_of_open_elements . element_immediately_above ( * node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 12. Let inner loop counter be 0.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        size_t  inner_loop_counter  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 13. While true:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        while  ( true )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 1. Increment inner loop counter by 1.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            inner_loop_counter + + ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 2. Let node be the element immediately above node in the stack of open elements,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            //    or if node is no longer in the stack of open elements (e.g. because it got removed by this algorithm),
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            //    the element that was immediately above node in the stack of open elements before node was removed.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            node  =  node_above_node ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            VERIFY ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // Keep track of this for later
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            node_above_node  =  m_stack_of_open_elements . element_immediately_above ( * node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 3. If node is formatting element, then break.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( node . ptr ( )  = =  formatting_element ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 4. If inner loop counter is greater than 3 and node is in the list of active formatting elements,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( inner_loop_counter  >  3  & &  m_list_of_active_formatting_elements . contains ( * node ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                auto  node_index  =  m_list_of_active_formatting_elements . find_index ( * node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( node_index . has_value ( )  & &  node_index . value ( )  <  bookmark ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    bookmark - - ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // then remove node from the list of active formatting elements.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                m_list_of_active_formatting_elements . remove ( * node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 5. If node is not in the list of active formatting elements
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( ! m_list_of_active_formatting_elements . contains ( * node ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // then remove node from the stack of open elements and continue.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                m_stack_of_open_elements . remove ( * node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 6. Create an element for the token for which the element node was created,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            //    in the HTML namespace, with common ancestor as the intended parent;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // FIXME: hold onto the real token
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  element  =  create_element_for ( HTMLToken : : make_start_tag ( node - > local_name ( ) ) ,  Namespace : : HTML ,  * common_ancestor ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // replace the entry for node in the list of active formatting elements with an entry for the new element,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_list_of_active_formatting_elements . replace ( * node ,  * element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // replace the entry for node in the stack of open elements with an entry for the new element,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_stack_of_open_elements . replace ( * node ,  element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // and let node be the new element.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            node  =  element ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 7. If last node is furthest block,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( last_node  = =  furthest_block )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // then move the aforementioned bookmark to be immediately after the new node in the list of active formatting elements.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                bookmark  =  m_list_of_active_formatting_elements . find_index ( * node ) . value ( )  +  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 8. Append last node to node.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            node - > append_child ( * last_node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 9. Set last node to node.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            last_node  =  node ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 14. Insert whatever last node ended up being in the previous step at the appropriate place for inserting a node,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //     but using common ancestor as the override target.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  adjusted_insertion_location  =  find_appropriate_place_for_inserting_node ( common_ancestor ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        adjusted_insertion_location . parent - > insert_before ( * last_node ,  adjusted_insertion_location . insert_before_sibling ,  false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 15. Create an element for the token for which formatting element was created,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //     in the HTML namespace, with furthest block as the intended parent.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // FIXME: hold onto the real token
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  element  =  create_element_for ( HTMLToken : : make_start_tag ( formatting_element - > local_name ( ) ) ,  Namespace : : HTML ,  * furthest_block ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 16. Take all of the child nodes of furthest block and append them to the element created in the last step.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( auto &  child  :  furthest_block - > children_as_vector ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            element - > append_child ( furthest_block - > remove_child ( * child ) . release_value ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 17. Append that new element to furthest block.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        furthest_block - > append_child ( * element ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 18. Remove formatting element from the list of active formatting elements,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //     and insert the new element into the list of active formatting elements at the position of the aforementioned bookmark.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  formatting_element_index  =  m_list_of_active_formatting_elements . find_index ( * formatting_element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( formatting_element_index . has_value ( )  & &  formatting_element_index . value ( )  <  bookmark ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            bookmark - - ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:22:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_list_of_active_formatting_elements . remove ( * formatting_element ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_list_of_active_formatting_elements . insert_at ( bookmark ,  * element ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:22:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-20 02:11:42 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // 19. Remove formatting element from the stack of open elements, and insert the new element
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //     into the stack of open elements immediately below the position of furthest block in that stack.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_open_elements . remove ( * formatting_element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_open_elements . insert_immediately_below ( * element ,  * furthest_block ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:22:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:58:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								bool  HTMLParser : : is_special_tag ( FlyString  const &  tag_name ,  FlyString  const &  namespace_ )  
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:44:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( namespace_  = =  Namespace : : HTML )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  tag_name . is_one_of ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : address , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : applet , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : area , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : article , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : aside , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : base , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : basefont , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : bgsound , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : blockquote , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : body , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : br , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : button , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : caption , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : center , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : col , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : colgroup , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : dd , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : details , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : dir , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : div , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : dl , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : dt , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : embed , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : fieldset , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : figcaption , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : figure , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : footer , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : form , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : frame , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : frameset , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : h1 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : h2 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : h3 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : h4 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : h5 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : h6 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : head , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : header , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : hgroup , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : hr , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : html , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : iframe , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : img , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : input , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : keygen , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : li , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : link , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : listing , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : main , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : marquee , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : menu , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : meta , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : nav , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : noembed , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : noframes , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : noscript , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : object , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : ol , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : p , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : param , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : plaintext , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : pre , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : script , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : section , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : select , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : source , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : style , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : summary , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : table , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : tbody , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : td , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : template_ , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : textarea , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : tfoot , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : th , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : thead , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : title , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : tr , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : track , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : ul , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : wbr , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            HTML : : TagNames : : xmp ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }  else  if  ( namespace_  = =  Namespace : : SVG )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  tag_name . is_one_of ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            SVG : : TagNames : : desc , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            SVG : : TagNames : : foreignObject , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            SVG : : TagNames : : title ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    }  else  if  ( namespace_  = =  Namespace : : MathML )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        TODO ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:44:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_in_body ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:49:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_character ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-05 16:31:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( token . code_point ( )  = =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 22:37:45 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( token . is_parser_whitespace ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-05 16:31:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            insert_character ( token . code_point ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-05 16:31:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        insert_character ( token . code_point ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 19:51:50 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 18:46:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_comment ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        insert_comment ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . contains ( HTML : : TagNames : : template_ ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-01 12:38:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-14 23:53:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        token . for_each_attribute ( [ & ] ( auto &  attribute )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( ! current_node ( ) . has_attribute ( attribute . local_name ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                current_node ( ) . set_attribute ( attribute . local_name ,  attribute . value ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  IterationDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-01 12:38:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : base ,  HTML : : TagNames : : basefont ,  HTML : : TagNames : : bgsound ,  HTML : : TagNames : : link ,  HTML : : TagNames : : meta ,  HTML : : TagNames : : noframes ,  HTML : : TagNames : : script ,  HTML : : TagNames : : style ,  HTML : : TagNames : : template_ ,  HTML : : TagNames : : title ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InHead ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : template_ )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InHead ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : body )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-01 12:38:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . elements ( ) . size ( )  = =  1 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            | |  m_stack_of_open_elements . elements ( ) . at ( 1 ) - > local_name ( )  ! =  HTML : : TagNames : : body 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            | |  m_stack_of_open_elements . contains ( HTML : : TagNames : : template_ ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-01 12:38:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto &  body_element  =  m_stack_of_open_elements . elements ( ) . at ( 1 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-14 23:53:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        token . for_each_attribute ( [ & ] ( auto &  attribute )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( ! body_element - > has_attribute ( attribute . local_name ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                body_element - > set_attribute ( attribute . local_name ,  attribute . value ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-14 23:53:11 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  IterationDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-01 12:38:17 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : frameset )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . elements ( ) . size ( )  = =  1 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            | |  m_stack_of_open_elements . elements ( ) . at ( 1 ) - > local_name ( )  ! =  HTML : : TagNames : : body )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_frameset_ok ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        TODO ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_of_file ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_template_insertion_modes . is_empty ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            process_using_the_rules_for ( InsertionMode : : InTemplate ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 12:40:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( auto &  node  :  m_stack_of_open_elements . elements ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( ! node - > local_name ( ) . is_one_of ( HTML : : TagNames : : dd ,  HTML : : TagNames : : dt ,  HTML : : TagNames : : li ,  HTML : : TagNames : : optgroup ,  HTML : : TagNames : : option ,  HTML : : TagNames : : p ,  HTML : : TagNames : : rb ,  HTML : : TagNames : : rp ,  HTML : : TagNames : : rt ,  HTML : : TagNames : : rtc ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : td ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : th ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tr ,  HTML : : TagNames : : body ,  HTML : : TagNames : : html ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 12:40:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        stop_parsing ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : body )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_scope ( HTML : : TagNames : : body ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 22:36:08 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:49:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 22:36:08 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( auto &  node  :  m_stack_of_open_elements . elements ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( ! node - > local_name ( ) . is_one_of ( HTML : : TagNames : : dd ,  HTML : : TagNames : : dt ,  HTML : : TagNames : : li ,  HTML : : TagNames : : optgroup ,  HTML : : TagNames : : option ,  HTML : : TagNames : : p ,  HTML : : TagNames : : rb ,  HTML : : TagNames : : rp ,  HTML : : TagNames : : rt ,  HTML : : TagNames : : rtc ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : td ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : th ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tr ,  HTML : : TagNames : : body ,  HTML : : TagNames : : html ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 22:36:08 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:49:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : AfterBody ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_scope ( HTML : : TagNames : : body ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 23:28:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( auto &  node  :  m_stack_of_open_elements . elements ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( ! node - > local_name ( ) . is_one_of ( HTML : : TagNames : : dd ,  HTML : : TagNames : : dt ,  HTML : : TagNames : : li ,  HTML : : TagNames : : optgroup ,  HTML : : TagNames : : option ,  HTML : : TagNames : : p ,  HTML : : TagNames : : rb ,  HTML : : TagNames : : rp ,  HTML : : TagNames : : rt ,  HTML : : TagNames : : rtc ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : td ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : th ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tr ,  HTML : : TagNames : : body ,  HTML : : TagNames : : html ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 23:28:57 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : AfterBody ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : address ,  HTML : : TagNames : : article ,  HTML : : TagNames : : aside ,  HTML : : TagNames : : blockquote ,  HTML : : TagNames : : center ,  HTML : : TagNames : : details ,  HTML : : TagNames : : dialog ,  HTML : : TagNames : : dir ,  HTML : : TagNames : : div ,  HTML : : TagNames : : dl ,  HTML : : TagNames : : fieldset ,  HTML : : TagNames : : figcaption ,  HTML : : TagNames : : figure ,  HTML : : TagNames : : footer ,  HTML : : TagNames : : header ,  HTML : : TagNames : : hgroup ,  HTML : : TagNames : : main ,  HTML : : TagNames : : menu ,  HTML : : TagNames : : nav ,  HTML : : TagNames : : ol ,  HTML : : TagNames : : p ,  HTML : : TagNames : : section ,  HTML : : TagNames : : summary ,  HTML : : TagNames : : ul ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . has_in_button_scope ( HTML : : TagNames : : p ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            close_a_p_element ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : h1 ,  HTML : : TagNames : : h2 ,  HTML : : TagNames : : h3 ,  HTML : : TagNames : : h4 ,  HTML : : TagNames : : h5 ,  HTML : : TagNames : : h6 ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . has_in_button_scope ( HTML : : TagNames : : p ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 12:57:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            close_a_p_element ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( ) . is_one_of ( HTML : : TagNames : : h1 ,  HTML : : TagNames : : h2 ,  HTML : : TagNames : : h3 ,  HTML : : TagNames : : h4 ,  HTML : : TagNames : : h5 ,  HTML : : TagNames : : h6 ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 12:57:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : pre ,  HTML : : TagNames : : listing ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . has_in_button_scope ( HTML : : TagNames : : p ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            close_a_p_element ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // If the next token is a U+000A LINE FEED (LF) character token,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // then ignore that token and move on to the next one.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // (Newlines at the start of pre blocks are ignored as an authoring convenience.)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  next_token  =  m_tokenizer . next_token ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-05 16:31:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( next_token . has_value ( )  & &  next_token . value ( ) . is_character ( )  & &  next_token . value ( ) . code_point ( )  = =  ' \n ' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // Ignore it.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            process_using_the_rules_for ( m_insertion_mode ,  next_token . value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : form )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_form_element . ptr ( )  & &  ! m_stack_of_open_elements . contains ( HTML : : TagNames : : template_ ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 11:13:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . has_in_button_scope ( HTML : : TagNames : : p ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 11:13:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            close_a_p_element ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  element  =  insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . contains ( HTML : : TagNames : : template_ ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_form_element  =  JS : : make_handle ( verify_cast < HTMLFormElement > ( * element ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 11:13:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : li )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:44:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( ssize_t  i  =  m_stack_of_open_elements . elements ( ) . size ( )  -  1 ;  i  > =  0 ;  - - i )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            JS : : GCPtr < DOM : : Element >  node  =  m_stack_of_open_elements . elements ( ) [ i ] . ptr ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:44:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( node - > local_name ( )  = =  HTML : : TagNames : : li )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                generate_implied_end_tags ( HTML : : TagNames : : li ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( current_node ( ) . local_name ( )  ! =  HTML : : TagNames : : li )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:44:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : li ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:44:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( is_special_tag ( node - > local_name ( ) ,  node - > namespace_ ( ) )  & &  ! node - > local_name ( ) . is_one_of ( HTML : : TagNames : : address ,  HTML : : TagNames : : div ,  HTML : : TagNames : : p ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:44:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . has_in_button_scope ( HTML : : TagNames : : p ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:44:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            close_a_p_element ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:44:36 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : dd ,  HTML : : TagNames : : dt ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( ssize_t  i  =  m_stack_of_open_elements . elements ( ) . size ( )  -  1 ;  i  > =  0 ;  - - i )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            JS : : GCPtr < DOM : : Element >  node  =  m_stack_of_open_elements . elements ( ) [ i ] . ptr ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( node - > local_name ( )  = =  HTML : : TagNames : : dd )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                generate_implied_end_tags ( HTML : : TagNames : : dd ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( current_node ( ) . local_name ( )  ! =  HTML : : TagNames : : dd )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : dd ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( node - > local_name ( )  = =  HTML : : TagNames : : dt )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                generate_implied_end_tags ( HTML : : TagNames : : dt ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( current_node ( ) . local_name ( )  ! =  HTML : : TagNames : : dt )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : dt ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( is_special_tag ( node - > local_name ( ) ,  node - > namespace_ ( ) )  & &  ! node - > local_name ( ) . is_one_of ( HTML : : TagNames : : address ,  HTML : : TagNames : : div ,  HTML : : TagNames : : p ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . has_in_button_scope ( HTML : : TagNames : : p ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            close_a_p_element ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : plaintext )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . has_in_button_scope ( HTML : : TagNames : : p ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            close_a_p_element ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_tokenizer . switch_to ( { } ,  HTMLTokenizer : : State : : PLAINTEXT ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : button )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . has_in_button_scope ( HTML : : TagNames : : button ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            generate_implied_end_tags ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : button ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : address ,  HTML : : TagNames : : article ,  HTML : : TagNames : : aside ,  HTML : : TagNames : : blockquote ,  HTML : : TagNames : : button ,  HTML : : TagNames : : center ,  HTML : : TagNames : : details ,  HTML : : TagNames : : dialog ,  HTML : : TagNames : : dir ,  HTML : : TagNames : : div ,  HTML : : TagNames : : dl ,  HTML : : TagNames : : fieldset ,  HTML : : TagNames : : figcaption ,  HTML : : TagNames : : figure ,  HTML : : TagNames : : footer ,  HTML : : TagNames : : header ,  HTML : : TagNames : : hgroup ,  HTML : : TagNames : : listing ,  HTML : : TagNames : : main ,  HTML : : TagNames : : menu ,  HTML : : TagNames : : nav ,  HTML : : TagNames : : ol ,  HTML : : TagNames : : pre ,  HTML : : TagNames : : section ,  HTML : : TagNames : : summary ,  HTML : : TagNames : : ul ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_scope ( token . tag_name ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        generate_implied_end_tags ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  ! =  token . tag_name ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( token . tag_name ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : form )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . contains ( HTML : : TagNames : : template_ ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 11:13:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            auto  node  =  m_form_element ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_form_element  =  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-15 20:29:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( ! node  | |  ! m_stack_of_open_elements . has_in_scope ( * node ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 11:13:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            generate_implied_end_tags ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( & current_node ( )  ! =  node . ptr ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 11:13:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_stack_of_open_elements . elements ( ) . remove_first_matching ( [ & ] ( auto &  entry )  {  return  entry . ptr ( )  = =  node . ptr ( ) ;  } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( ! m_stack_of_open_elements . has_in_scope ( HTML : : TagNames : : form ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 23:03:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            generate_implied_end_tags ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( current_node ( ) . local_name ( )  ! =  HTML : : TagNames : : form )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 23:03:19 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : form ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 11:13:57 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : p )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_button_scope ( HTML : : TagNames : : p ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ( void ) insert_html_element ( HTMLToken : : make_start_tag ( HTML : : TagNames : : p ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        close_a_p_element ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : li )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_list_item_scope ( HTML : : TagNames : : li ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 22:06:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        generate_implied_end_tags ( HTML : : TagNames : : li ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  ! =  HTML : : TagNames : : li )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-17 16:57:17 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            dbgln ( " Expected <li> current node, but had <{}> " ,  current_node ( ) . local_name ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 22:06:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : li ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 22:06:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : dd ,  HTML : : TagNames : : dt ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 22:59:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_scope ( token . tag_name ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 22:59:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        generate_implied_end_tags ( token . tag_name ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  ! =  token . tag_name ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 22:59:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( token . tag_name ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : h1 ,  HTML : : TagNames : : h2 ,  HTML : : TagNames : : h3 ,  HTML : : TagNames : : h4 ,  HTML : : TagNames : : h5 ,  HTML : : TagNames : : h6 ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_scope ( HTML : : TagNames : : h1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ! m_stack_of_open_elements . has_in_scope ( HTML : : TagNames : : h2 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ! m_stack_of_open_elements . has_in_scope ( HTML : : TagNames : : h3 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ! m_stack_of_open_elements . has_in_scope ( HTML : : TagNames : : h4 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ! m_stack_of_open_elements . has_in_scope ( HTML : : TagNames : : h5 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ! m_stack_of_open_elements . has_in_scope ( HTML : : TagNames : : h6 ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 18:18:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 12:57:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 12:57:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        generate_implied_end_tags ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  ! =  token . tag_name ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 12:57:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 12:57:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( ; ; )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto  popped_element  =  m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( popped_element - > local_name ( ) . is_one_of ( HTML : : TagNames : : h1 ,  HTML : : TagNames : : h2 ,  HTML : : TagNames : : h3 ,  HTML : : TagNames : : h4 ,  HTML : : TagNames : : h5 ,  HTML : : TagNames : : h6 ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 12:57:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 12:57:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : a )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( auto *  element  =  m_list_of_active_formatting_elements . last_element_with_tag_name_before_marker ( HTML : : TagNames : : a ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 16:22:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( run_the_adoption_agency_algorithm ( token )  = =  AdoptionAgencyAlgorithmOutcome : : RunAnyOtherEndTagSteps ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                goto  AnyOtherEndTag ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 11:03:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_list_of_active_formatting_elements . remove ( * element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_stack_of_open_elements . elements ( ) . remove_first_matching ( [ & ] ( auto &  entry )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  entry . ptr ( )  = =  element ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 22:06:05 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  element  =  insert_html_element ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_list_of_active_formatting_elements . add ( * element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : b ,  HTML : : TagNames : : big ,  HTML : : TagNames : : code ,  HTML : : TagNames : : em ,  HTML : : TagNames : : font ,  HTML : : TagNames : : i ,  HTML : : TagNames : : s ,  HTML : : TagNames : : small ,  HTML : : TagNames : : strike ,  HTML : : TagNames : : strong ,  HTML : : TagNames : : tt ,  HTML : : TagNames : : u ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:22:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  element  =  insert_html_element ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_list_of_active_formatting_elements . add ( * element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : nobr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 23:03:44 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . has_in_scope ( HTML : : TagNames : : nobr ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 23:03:44 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            run_the_adoption_agency_algorithm ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  element  =  insert_html_element ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_list_of_active_formatting_elements . add ( * element ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : a ,  HTML : : TagNames : : b ,  HTML : : TagNames : : big ,  HTML : : TagNames : : code ,  HTML : : TagNames : : em ,  HTML : : TagNames : : font ,  HTML : : TagNames : : i ,  HTML : : TagNames : : nobr ,  HTML : : TagNames : : s ,  HTML : : TagNames : : small ,  HTML : : TagNames : : strike ,  HTML : : TagNames : : strong ,  HTML : : TagNames : : tt ,  HTML : : TagNames : : u ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 16:22:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( run_the_adoption_agency_algorithm ( token )  = =  AdoptionAgencyAlgorithmOutcome : : RunAnyOtherEndTagSteps ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            goto  AnyOtherEndTag ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:22:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : applet ,  HTML : : TagNames : : marquee ,  HTML : : TagNames : : object ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_list_of_active_formatting_elements . add_marker ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 12:57:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:49:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : applet ,  HTML : : TagNames : : marquee ,  HTML : : TagNames : : object ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 22:33:10 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_scope ( token . tag_name ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 22:33:10 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        generate_implied_end_tags ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  ! =  token . tag_name ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 22:33:10 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( token . tag_name ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_list_of_active_formatting_elements . clear_up_to_the_last_marker ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:49:22 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : table )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! document ( ) . in_quirks_mode ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( m_stack_of_open_elements . has_in_button_scope ( HTML : : TagNames : : p ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                close_a_p_element ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InTable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : br )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 22:34:50 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        token . drop_attributes ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        goto  BRStartTag ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : area ,  HTML : : TagNames : : br ,  HTML : : TagNames : : embed ,  HTML : : TagNames : : img ,  HTML : : TagNames : : keygen ,  HTML : : TagNames : : wbr ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 22:34:50 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    BRStartTag : 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:25:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:25:30 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        token . acknowledge_self_closing_flag_if_set ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : input )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 12:18:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 12:18:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        token . acknowledge_self_closing_flag_if_set ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  type_attribute  =  token . attribute ( HTML : : AttributeNames : : type ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( type_attribute . is_null ( )  | |  ! type_attribute . equals_ignoring_case ( " hidden " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 12:18:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : param ,  HTML : : TagNames : : source ,  HTML : : TagNames : : track ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-05 21:59:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        token . acknowledge_self_closing_flag_if_set ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : hr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . has_in_button_scope ( HTML : : TagNames : : p ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            close_a_p_element ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        token . acknowledge_self_closing_flag_if_set ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : image )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // Parse error. Change the token's tag name to HTML::TagNames::img and reprocess it. (Don't ask.)
 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-07-14 23:37:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        token . set_tag_name ( " img " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : textarea )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 18:40:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-05 12:05:42 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_tokenizer . switch_to ( { } ,  HTMLTokenizer : : State : : RCDATA ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 18:40:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // If the next token is a U+000A LINE FEED (LF) character token,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // then ignore that token and move on to the next one.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // (Newlines at the start of pre blocks are ignored as an authoring convenience.)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  next_token  =  m_tokenizer . next_token ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_original_insertion_mode  =  m_insertion_mode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : Text ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-05 16:31:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( next_token . has_value ( )  & &  next_token . value ( ) . is_character ( )  & &  next_token . value ( ) . code_point ( )  = =  ' \n ' )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 18:40:23 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // Ignore it.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            process_using_the_rules_for ( m_insertion_mode ,  next_token . value ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : xmp )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . has_in_button_scope ( HTML : : TagNames : : p ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-03 23:04:03 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            close_a_p_element ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        parse_generic_raw_text_element ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : iframe )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        parse_generic_raw_text_element ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  ( ( token . tag_name ( )  = =  HTML : : TagNames : : noembed )  | |  ( token . tag_name ( )  = =  HTML : : TagNames : : noscript  & &  m_scripting_enabled ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        parse_generic_raw_text_element ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : select )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        switch  ( m_insertion_mode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        case  InsertionMode : : InTable : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        case  InsertionMode : : InCaption : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        case  InsertionMode : : InTableBody : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        case  InsertionMode : : InRow : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        case  InsertionMode : : InCell : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_insertion_mode  =  InsertionMode : : InSelectInTable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        default : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_insertion_mode  =  InsertionMode : : InSelect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : optgroup ,  HTML : : TagNames : : option ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  = =  HTML : : TagNames : : option ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : rb ,  HTML : : TagNames : : rtc ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . has_in_scope ( HTML : : TagNames : : ruby ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            generate_implied_end_tags ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  ! =  HTML : : TagNames : : ruby ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 17:00:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : rp ,  HTML : : TagNames : : rt ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_stack_of_open_elements . has_in_scope ( HTML : : TagNames : : ruby ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            generate_implied_end_tags ( HTML : : TagNames : : rtc ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  ! =  HTML : : TagNames : : rtc  | |  current_node ( ) . local_name ( )  ! =  HTML : : TagNames : : ruby ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 17:00:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : math )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 18:46:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        adjust_mathml_attributes ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        adjust_foreign_attributes ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_foreign_element ( token ,  Namespace : : MathML ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( token . is_self_closing ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            token . acknowledge_self_closing_flag_if_set ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 18:46:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : svg )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 18:46:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        adjust_svg_attributes ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        adjust_foreign_attributes ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_foreign_element ( token ,  Namespace : : SVG ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( token . is_self_closing ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            token . acknowledge_self_closing_flag_if_set ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 18:46:39 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : caption ,  HTML : : TagNames : : col ,  HTML : : TagNames : : colgroup ,  HTML : : TagNames : : frame ,  HTML : : TagNames : : head ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : td ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : th ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tr ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-29 21:20:49 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // Any other start tag
 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        reconstruct_the_active_formatting_elements ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:21:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 16:22:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    AnyOtherEndTag : 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        JS : : GCPtr < DOM : : Element >  node ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( ssize_t  i  =  m_stack_of_open_elements . elements ( ) . size ( )  -  1 ;  i  > =  0 ;  - - i )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            node  =  m_stack_of_open_elements . elements ( ) [ i ] . ptr ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( node - > local_name ( )  = =  token . tag_name ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                generate_implied_end_tags ( token . tag_name ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( node . ptr ( )  ! =  & current_node ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                while  ( & current_node ( )  ! =  node . ptr ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( is_special_tag ( node - > local_name ( ) ,  node - > namespace_ ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 18:19:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:39:59 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : adjust_mathml_attributes ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " definitionurl " ,  " definitionURL " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : adjust_svg_tag_names ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " altglyph " ,  " altGlyph " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " altglyphdef " ,  " altGlyphDef " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " altglyphitem " ,  " altGlyphItem " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " animatecolor " ,  " animateColor " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " animatemotion " ,  " animateMotion " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " animatetransform " ,  " animateTransform " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " clippath " ,  " clipPath " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " feblend " ,  " feBlend " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " fecolormatrix " ,  " feColorMatrix " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " fecomponenttransfer " ,  " feComponentTransfer " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " fecomposite " ,  " feComposite " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " feconvolvematrix " ,  " feConvolveMatrix " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " fediffuselighting " ,  " feDiffuseLighting " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " fedisplacementmap " ,  " feDisplacementMap " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " fedistantlight " ,  " feDistantLight " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " fedropshadow " ,  " feDropShadow " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " feflood " ,  " feFlood " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " fefunca " ,  " feFuncA " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " fefuncb " ,  " feFuncB " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " fefuncg " ,  " feFuncG " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " fefuncr " ,  " feFuncR " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " fegaussianblur " ,  " feGaussianBlur " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " feimage " ,  " feImage " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " femerge " ,  " feMerge " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " femergenode " ,  " feMergeNode " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " femorphology " ,  " feMorphology " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " feoffset " ,  " feOffset " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " fepointlight " ,  " fePointLight " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " fespecularlighting " ,  " feSpecularLighting " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " fespotlight " ,  " feSpotlight " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " glyphref " ,  " glyphRef " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " lineargradient " ,  " linearGradient " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " radialgradient " ,  " radialGradient " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_tag_name ( " textpath " ,  " textPath " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : adjust_svg_attributes ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " attributename " ,  " attributeName " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " attributetype " ,  " attributeType " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " basefrequency " ,  " baseFrequency " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " baseprofile " ,  " baseProfile " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " calcmode " ,  " calcMode " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " clippathunits " ,  " clipPathUnits " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " diffuseconstant " ,  " diffuseConstant " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " edgemode " ,  " edgeMode " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " filterunits " ,  " filterUnits " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " glyphref " ,  " glyphRef " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " gradienttransform " ,  " gradientTransform " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " gradientunits " ,  " gradientUnits " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " kernelmatrix " ,  " kernelMatrix " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " kernelunitlength " ,  " kernelUnitLength " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " keypoints " ,  " keyPoints " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " keysplines " ,  " keySplines " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " keytimes " ,  " keyTimes " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " lengthadjust " ,  " lengthAdjust " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " limitingconeangle " ,  " limitingConeAngle " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " markerheight " ,  " markerHeight " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " markerunits " ,  " markerUnits " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " markerwidth " ,  " markerWidth " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " maskcontentunits " ,  " maskContentUnits " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " maskunits " ,  " maskUnits " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " numoctaves " ,  " numOctaves " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " pathlength " ,  " pathLength " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " patterncontentunits " ,  " patternContentUnits " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " patterntransform " ,  " patternTransform " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " patternunits " ,  " patternUnits " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " pointsatx " ,  " pointsAtX " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " pointsaty " ,  " pointsAtY " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " pointsatz " ,  " pointsAtZ " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " preservealpha " ,  " preserveAlpha " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " preserveaspectratio " ,  " preserveAspectRatio " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " primitiveunits " ,  " primitiveUnits " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " refx " ,  " refX " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " refy " ,  " refY " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " repeatcount " ,  " repeatCount " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " repeatdur " ,  " repeatDur " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " requiredextensions " ,  " requiredExtensions " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " requiredfeatures " ,  " requiredFeatures " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " specularconstant " ,  " specularConstant " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " specularexponent " ,  " specularExponent " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " spreadmethod " ,  " spreadMethod " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " startoffset " ,  " startOffset " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " stddeviation " ,  " stdDeviation " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " stitchtiles " ,  " stitchTiles " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " surfacescale " ,  " surfaceScale " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " systemlanguage " ,  " systemLanguage " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " tablevalues " ,  " tableValues " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " targetx " ,  " targetX " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " targety " ,  " targetY " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " textlength " ,  " textLength " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " viewbox " ,  " viewBox " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " viewtarget " ,  " viewTarget " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " xchannelselector " ,  " xChannelSelector " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " ychannelselector " ,  " yChannelSelector " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_attribute_name ( " zoomandpan " ,  " zoomAndPan " ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : adjust_foreign_attributes ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    token . adjust_foreign_attribute ( " xlink:actuate " ,  " xlink " ,  " actuate " ,  Namespace : : XLink ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_foreign_attribute ( " xlink:arcrole " ,  " xlink " ,  " arcrole " ,  Namespace : : XLink ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_foreign_attribute ( " xlink:href " ,  " xlink " ,  " href " ,  Namespace : : XLink ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_foreign_attribute ( " xlink:role " ,  " xlink " ,  " role " ,  Namespace : : XLink ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_foreign_attribute ( " xlink:show " ,  " xlink " ,  " show " ,  Namespace : : XLink ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_foreign_attribute ( " xlink:title " ,  " xlink " ,  " title " ,  Namespace : : XLink ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_foreign_attribute ( " xlink:type " ,  " xlink " ,  " type " ,  Namespace : : XLink ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_foreign_attribute ( " xml:lang " ,  " xml " ,  " lang " ,  Namespace : : XML ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_foreign_attribute ( " xml:space " ,  " xml " ,  " space " ,  Namespace : : XML ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_foreign_attribute ( " xmlns " ,  " " ,  " xmlns " ,  Namespace : : XMLNS ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    token . adjust_foreign_attribute ( " xmlns:xlink " ,  " xmlns " ,  " xlink " ,  Namespace : : XMLNS ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : increment_script_nesting_level ( )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:00:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    + + m_script_nesting_level ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : decrement_script_nesting_level ( )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:00:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    VERIFY ( m_script_nesting_level ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:00:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    - - m_script_nesting_level ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-incdata
  
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_text ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-05-24 20:24:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_character ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-05 16:31:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        insert_character ( token . code_point ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 20:24:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-06 16:32:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_of_file ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  = =  HTML : : TagNames : : script ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:25:17 +04:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            verify_cast < HTMLScriptElement > ( current_node ( ) ) . set_already_started ( Badge < HTMLParser >  { } ,  true ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-06 16:32:27 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  m_original_insertion_mode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : script )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-23 16:38:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // Make sure the <script> element has up-to-date text content before preparing the script.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        flush_character_insertions ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        JS : : NonnullGCPtr < HTMLScriptElement >  script  =  verify_cast < HTMLScriptElement > ( current_node ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-19 14:22:46 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:00:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  m_original_insertion_mode ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // Let the old insertion point have the same value as the current insertion point.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_tokenizer . store_insertion_point ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Let the insertion point be just before the next input character.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_tokenizer . update_insertion_point ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:00:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        increment_script_nesting_level ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // FIXME: Check if active speculative HTML parser is null.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-28 16:25:17 +04:30 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        script - > prepare_script ( Badge < HTMLParser >  { } ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:00:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        decrement_script_nesting_level ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( script_nesting_level ( )  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_parser_pause_flag  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // Let the insertion point have the value of the old insertion point.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_tokenizer . restore_insertion_point ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:01:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        while  ( document ( ) . pending_parsing_blocking_script ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( script_nesting_level ( )  ! =  0 )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                m_parser_pause_flag  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // FIXME: Abort the processing of any nested invocations of the tokenizer,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                //        yielding control back to the caller. (Tokenization will resume when
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                //        the caller returns to the "outer" tree construction stage.)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                TODO ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                auto  the_script  =  document ( ) . take_pending_parsing_blocking_script ( { } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                m_tokenizer . set_blocked ( true ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-09 02:15:44 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                // If the parser's Document has a style sheet that is blocking scripts
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // or the script's "ready to be parser-executed" flag is not set:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // spin the event loop until the parser's Document has no style sheet
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // that is blocking scripts and the script's "ready to be parser-executed"
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // flag is set.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( m_document - > has_a_style_sheet_that_is_blocking_scripts ( )  | |  ! script - > is_ready_to_be_parser_executed ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    main_thread_event_loop ( ) . spin_until ( [ & ]  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        return  ! m_document - > has_a_style_sheet_that_is_blocking_scripts ( )  & &  script - > is_ready_to_be_parser_executed ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:01:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-15 18:37:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                if  ( the_script - > failed_to_load ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                VERIFY ( the_script - > is_ready_to_be_parser_executed ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:01:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( m_aborted ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                m_tokenizer . set_blocked ( false ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                // Let the insertion point be just before the next input character.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                m_tokenizer . update_insertion_point ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:01:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                VERIFY ( script_nesting_level ( )  = =  0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:01:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                increment_script_nesting_level ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                the_script - > execute_script ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                decrement_script_nesting_level ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                VERIFY ( script_nesting_level ( )  = =  0 ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:01:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                m_parser_pause_flag  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                // Let the insertion point be undefined again.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                m_tokenizer . undefine_insertion_point ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:01:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 22:00:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 20:24:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-27 23:01:04 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 20:24:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 20:24:43 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  m_original_insertion_mode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 10:35:25 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    TODO ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : clear_the_stack_back_to_a_table_context ( )  
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    while  ( ! current_node ( ) . local_name ( ) . is_one_of ( HTML : : TagNames : : table ,  HTML : : TagNames : : template_ ,  HTML : : TagNames : : html ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( current_node ( ) . local_name ( )  = =  HTML : : TagNames : : html ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : clear_the_stack_back_to_a_table_row_context ( )  
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    while  ( ! current_node ( ) . local_name ( ) . is_one_of ( HTML : : TagNames : : tr ,  HTML : : TagNames : : template_ ,  HTML : : TagNames : : html ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( current_node ( ) . local_name ( )  = =  HTML : : TagNames : : html ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : clear_the_stack_back_to_a_table_body_context ( )  
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    while  ( ! current_node ( ) . local_name ( ) . is_one_of ( HTML : : TagNames : : tbody ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : template_ ,  HTML : : TagNames : : html ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( current_node ( ) . local_name ( )  = =  HTML : : TagNames : : html ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_in_row ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : th ,  HTML : : TagNames : : td ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        clear_the_stack_back_to_a_table_row_context ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InCell ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_list_of_active_formatting_elements . add_marker ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : tr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_table_scope ( HTML : : TagNames : : tr ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        clear_the_stack_back_to_a_table_row_context ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InTableBody ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 17:49:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : caption ,  HTML : : TagNames : : col ,  HTML : : TagNames : : colgroup ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tr ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        | |  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : table ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_table_scope ( HTML : : TagNames : : tr ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        clear_the_stack_back_to_a_table_row_context ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InTableBody ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : tbody ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : thead ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_table_scope ( token . tag_name ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_table_scope ( HTML : : TagNames : : tr ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        clear_the_stack_back_to_a_table_row_context ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InTableBody ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : body ,  HTML : : TagNames : : caption ,  HTML : : TagNames : : col ,  HTML : : TagNames : : colgroup ,  HTML : : TagNames : : html ,  HTML : : TagNames : : td ,  HTML : : TagNames : : th ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    process_using_the_rules_for ( InsertionMode : : InTable ,  token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : close_the_cell ( )  
						 
					
						
							
								
									
										
										
										
											2020-05-28 11:45:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    generate_implied_end_tags ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( ! current_node ( ) . local_name ( ) . is_one_of ( HTML : : TagNames : : td ,  HTML : : TagNames : : th ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 11:45:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    while  ( ! current_node ( ) . local_name ( ) . is_one_of ( HTML : : TagNames : : td ,  HTML : : TagNames : : th ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 11:45:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_list_of_active_formatting_elements . clear_up_to_the_last_marker ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_insertion_mode  =  InsertionMode : : InRow ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_in_cell ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : td ,  HTML : : TagNames : : th ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_table_scope ( token . tag_name ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        generate_implied_end_tags ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  ! =  token . tag_name ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 18:20:55 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( token . tag_name ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_list_of_active_formatting_elements . clear_up_to_the_last_marker ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InRow ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : caption ,  HTML : : TagNames : : col ,  HTML : : TagNames : : colgroup ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : td ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : th ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tr ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_table_scope ( HTML : : TagNames : : td )  & &  ! m_stack_of_open_elements . has_in_table_scope ( HTML : : TagNames : : th ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 11:45:40 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        close_the_cell ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : body ,  HTML : : TagNames : : caption ,  HTML : : TagNames : : col ,  HTML : : TagNames : : colgroup ,  HTML : : TagNames : : html ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : table ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tr ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 17:49:02 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_table_scope ( token . tag_name ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        close_the_cell ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Reprocess the token.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_in_table_text ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-30 17:57:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_character ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-05 16:31:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( token . code_point ( )  = =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 17:57:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-07-15 22:23:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_pending_table_character_tokens . append ( move ( token ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 17:57:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  ( auto &  pending_token  :  m_pending_table_character_tokens )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        VERIFY ( pending_token . is_character ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 17:57:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! pending_token . is_parser_whitespace ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-30 20:10:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // If any of the tokens in the pending table character tokens list
 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 17:57:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // are character tokens that are not ASCII whitespace, then this is a parse error:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // reprocess the character tokens in the pending table character tokens list using
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // the rules given in the "anything else" entry in the "in table" insertion mode.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-30 20:10:19 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_foster_parenting  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_foster_parenting  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 17:57:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  ( auto &  pending_token  :  m_pending_table_character_tokens )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-05 16:31:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        insert_character ( pending_token . code_point ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 17:57:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_insertion_mode  =  m_original_insertion_mode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_in_table_body ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : tr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        clear_the_stack_back_to_a_table_body_context ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InRow ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : th ,  HTML : : TagNames : : td ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-01 22:08:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        clear_the_stack_back_to_a_table_body_context ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( HTMLToken : : make_start_tag ( HTML : : TagNames : : tr ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-01 22:08:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InRow ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 17:57:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : tbody ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : thead ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_table_scope ( token . tag_name ( ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        clear_the_stack_back_to_a_table_body_context ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InTable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 17:57:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : caption ,  HTML : : TagNames : : col ,  HTML : : TagNames : : colgroup ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : thead ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        | |  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : table ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_table_scope ( HTML : : TagNames : : tbody ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 17:30:18 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            & &  ! m_stack_of_open_elements . has_in_table_scope ( HTML : : TagNames : : thead ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ! m_stack_of_open_elements . has_in_table_scope ( HTML : : TagNames : : tfoot ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        clear_the_stack_back_to_a_table_body_context ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InTable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InTable ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 17:57:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : body ,  HTML : : TagNames : : caption ,  HTML : : TagNames : : col ,  HTML : : TagNames : : colgroup ,  HTML : : TagNames : : html ,  HTML : : TagNames : : td ,  HTML : : TagNames : : th ,  HTML : : TagNames : : tr ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 17:57:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    process_using_the_rules_for ( InsertionMode : : InTable ,  token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_in_table ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_character ( )  & &  current_node ( ) . local_name ( ) . is_one_of ( HTML : : TagNames : : table ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tr ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 17:57:41 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_pending_table_character_tokens . clear ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_original_insertion_mode  =  m_insertion_mode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InTableText ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InTableText ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_comment ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        insert_comment ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : caption )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 05:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        clear_the_stack_back_to_a_table_context ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_list_of_active_formatting_elements . add_marker ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 05:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InCaption ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : colgroup )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 06:22:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        clear_the_stack_back_to_a_table_context ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 06:22:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InColumnGroup ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : col )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 06:22:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        clear_the_stack_back_to_a_table_context ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( HTMLToken : : make_start_tag ( HTML : : TagNames : : colgroup ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 06:22:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InColumnGroup ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : tbody ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : thead ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        clear_the_stack_back_to_a_table_context ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 13:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InTableBody ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : td ,  HTML : : TagNames : : th ,  HTML : : TagNames : : tr ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        clear_the_stack_back_to_a_table_context ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( HTMLToken : : make_start_tag ( HTML : : TagNames : : tbody ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InTableBody ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 07:36:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:27:46 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : table )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 07:36:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_table_scope ( HTML : : TagNames : : table ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : table ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        reset_the_insertion_mode_appropriately ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 07:36:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : table )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_table_scope ( HTML : : TagNames : : table ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 18:09:31 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : table ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        reset_the_insertion_mode_appropriately ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 07:36:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : body ,  HTML : : TagNames : : caption ,  HTML : : TagNames : : col ,  HTML : : TagNames : : colgroup ,  HTML : : TagNames : : html ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : td ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : th ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tr ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 07:36:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : style ,  HTML : : TagNames : : script ,  HTML : : TagNames : : template_ ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        | |  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : template_ ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 07:36:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InHead ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : input )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto  type_attribute  =  token . attribute ( HTML : : AttributeNames : : type ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( type_attribute . is_null ( )  | |  ! type_attribute . equals_ignoring_case ( " hidden " sv ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 07:36:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            goto  AnythingElse ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 07:36:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // FIXME: Is this the correct interpretation of "Pop that input element off the stack of open elements."?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //        Because this wording is the first time it's seen in the spec.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //        Other times it's worded as: "Immediately pop the current node off the stack of open elements."
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 07:36:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        token . acknowledge_self_closing_flag_if_set ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : form )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( m_form_element . ptr ( )  | |  m_stack_of_open_elements . contains ( HTML : : TagNames : : template_ ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 07:36:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_form_element  =  JS : : make_handle ( verify_cast < HTMLFormElement > ( * insert_html_element ( token ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 07:36:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // FIXME: See previous FIXME, as this is the same situation but for form.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 07:36:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_of_file ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								AnythingElse :  
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 07:36:09 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_foster_parenting  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_foster_parenting  =  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_in_select_in_table ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : caption ,  HTML : : TagNames : : table ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tr ,  HTML : : TagNames : : td ,  HTML : : TagNames : : th ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : select ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        reset_the_insertion_mode_appropriately ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : caption ,  HTML : : TagNames : : table ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tr ,  HTML : : TagNames : : td ,  HTML : : TagNames : : th ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_table_scope ( token . tag_name ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : select ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        reset_the_insertion_mode_appropriately ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    process_using_the_rules_for ( InsertionMode : : InSelect ,  token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_in_select ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_character ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-05 16:31:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( token . code_point ( )  = =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-05 16:31:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        insert_character ( token . code_point ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_comment ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        insert_comment ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : option )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  = =  HTML : : TagNames : : option )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : optgroup )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  = =  HTML : : TagNames : : option )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  = =  HTML : : TagNames : : optgroup )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : optgroup )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  = =  HTML : : TagNames : : option  & &  node_before_current_node ( ) . local_name ( )  = =  HTML : : TagNames : : optgroup ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  = =  HTML : : TagNames : : optgroup )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : option )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  = =  HTML : : TagNames : : option )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : select )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-15 19:57:20 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_select_scope ( HTML : : TagNames : : select ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : select ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        reset_the_insertion_mode_appropriately ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : select )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_select_scope ( HTML : : TagNames : : select ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : select ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        reset_the_insertion_mode_appropriately ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : input ,  HTML : : TagNames : : keygen ,  HTML : : TagNames : : textarea ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_select_scope ( HTML : : TagNames : : select ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : select ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        reset_the_insertion_mode_appropriately ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : script ,  HTML : : TagNames : : template_ ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InHead ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-07 23:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : template_ )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InHead ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_of_file ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-30 19:58:52 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_in_caption ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-06-13 05:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : caption )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_table_scope ( HTML : : TagNames : : caption ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 05:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        generate_implied_end_tags ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  ! =  HTML : : TagNames : : caption ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 05:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : caption ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_list_of_active_formatting_elements . clear_up_to_the_last_marker ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InTable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : caption ,  HTML : : TagNames : : col ,  HTML : : TagNames : : colgroup ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : td ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : th ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tr ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        | |  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : table ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 05:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . has_in_table_scope ( HTML : : TagNames : : caption ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 05:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        generate_implied_end_tags ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  ! =  HTML : : TagNames : : caption ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 05:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : caption ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_list_of_active_formatting_elements . clear_up_to_the_last_marker ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InTable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : body ,  HTML : : TagNames : : col ,  HTML : : TagNames : : colgroup ,  HTML : : TagNames : : html ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : td ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : th ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tr ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 05:09:54 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_in_column_group ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-06-13 06:22:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_character ( )  & &  token . is_parser_whitespace ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-05 16:31:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        insert_character ( token . code_point ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 06:22:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_comment ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        insert_comment ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 06:22:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : col )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 06:22:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        token . acknowledge_self_closing_flag_if_set ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : colgroup )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( current_node ( ) . local_name ( )  ! =  HTML : : TagNames : : colgroup )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 06:22:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 06:22:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InTable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : col )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 06:22:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ( token . is_start_tag ( )  | |  token . is_end_tag ( ) )  & &  token . tag_name ( )  = =  HTML : : TagNames : : template_ )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InHead ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_of_file ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( current_node ( ) . local_name ( )  ! =  HTML : : TagNames : : colgroup )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 06:22:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 06:22:18 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_insertion_mode  =  InsertionMode : : InTable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_in_template ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_character ( )  | |  token . is_comment ( )  | |  token . is_doctype ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : base ,  HTML : : TagNames : : basefont ,  HTML : : TagNames : : bgsound ,  HTML : : TagNames : : link ,  HTML : : TagNames : : meta ,  HTML : : TagNames : : noframes ,  HTML : : TagNames : : script ,  HTML : : TagNames : : style ,  HTML : : TagNames : : template_ ,  HTML : : TagNames : : title ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InHead ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : template_ )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InHead ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : caption ,  HTML : : TagNames : : colgroup ,  HTML : : TagNames : : tbody ,  HTML : : TagNames : : tfoot ,  HTML : : TagNames : : thead ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_template_insertion_modes . take_last ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_template_insertion_modes . append ( InsertionMode : : InTable ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InTable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : col )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_template_insertion_modes . take_last ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_template_insertion_modes . append ( InsertionMode : : InColumnGroup ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InColumnGroup ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : tr )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_template_insertion_modes . take_last ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_template_insertion_modes . append ( InsertionMode : : InTableBody ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InTableBody ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : td ,  HTML : : TagNames : : th ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_template_insertion_modes . take_last ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_template_insertion_modes . append ( InsertionMode : : InRow ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InRow ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_template_insertion_modes . take_last ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_template_insertion_modes . append ( InsertionMode : : InBody ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : InBody ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_of_file ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( ! m_stack_of_open_elements . contains ( HTML : : TagNames : : template_ ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            stop_parsing ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop_until_an_element_with_tag_name_has_been_popped ( HTML : : TagNames : : template_ ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_list_of_active_formatting_elements . clear_up_to_the_last_marker ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_template_insertion_modes . take_last ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        reset_the_insertion_mode_appropriately ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_in_frameset ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_character ( )  & &  token . is_parser_whitespace ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-05 16:31:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        insert_character ( token . code_point ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_comment ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        insert_comment ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : frameset )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : frameset )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // FIXME: If the current node is the root html element, then this is a parse error; ignore the token. (fragment case)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! m_parsing_fragment  & &  current_node ( ) . local_name ( )  ! =  HTML : : TagNames : : frameset )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_insertion_mode  =  InsertionMode : : AfterFrameset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : frame )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_html_element ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        token . acknowledge_self_closing_flag_if_set ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : noframes )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InHead ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_of_file ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 09:57:07 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // FIXME: If the current node is not the root html element, then this is a parse error.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        stop_parsing ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_after_frameset ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_character ( )  & &  token . is_parser_whitespace ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-05 16:31:20 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        insert_character ( token . code_point ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_comment ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        insert_comment ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_insertion_mode  =  InsertionMode : : AfterAfterFrameset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : noframes )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InHead ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_of_file ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        stop_parsing ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : handle_after_after_frameset ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_comment ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        auto *  comment  =  document ( ) . heap ( ) . allocate < DOM : : Comment > ( document ( ) . realm ( ) ,  document ( ) ,  token . comment ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        document ( ) . append_child ( * comment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( )  | |  token . is_parser_whitespace ( )  | |  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : html ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InBody ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_of_file ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        stop_parsing ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : noframes )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( InsertionMode : : InHead ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-21 06:58:03 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : process_using_the_rules_for_foreign_content ( HTMLToken &  token )  
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_character ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( token . code_point ( )  = =  0 )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            insert_character ( 0xFFFD ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( token . is_parser_whitespace ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            insert_character ( token . code_point ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        insert_character ( token . code_point ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_frameset_ok  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_comment ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        insert_comment ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_doctype ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ( token . is_start_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : b ,  HTML : : TagNames : : big ,  HTML : : TagNames : : blockquote ,  HTML : : TagNames : : body ,  HTML : : TagNames : : br ,  HTML : : TagNames : : center ,  HTML : : TagNames : : code ,  HTML : : TagNames : : dd ,  HTML : : TagNames : : div ,  HTML : : TagNames : : dl ,  HTML : : TagNames : : dt ,  HTML : : TagNames : : em ,  HTML : : TagNames : : embed ,  HTML : : TagNames : : h1 ,  HTML : : TagNames : : h2 ,  HTML : : TagNames : : h3 ,  HTML : : TagNames : : h4 ,  HTML : : TagNames : : h5 ,  HTML : : TagNames : : h6 ,  HTML : : TagNames : : head ,  HTML : : TagNames : : hr ,  HTML : : TagNames : : i ,  HTML : : TagNames : : img ,  HTML : : TagNames : : li ,  HTML : : TagNames : : listing ,  HTML : : TagNames : : menu ,  HTML : : TagNames : : meta ,  HTML : : TagNames : : nobr ,  HTML : : TagNames : : ol ,  HTML : : TagNames : : p ,  HTML : : TagNames : : pre ,  HTML : : TagNames : : ruby ,  HTML : : TagNames : : s ,  HTML : : TagNames : : small ,  HTML : : TagNames : : span ,  HTML : : TagNames : : strong ,  HTML : : TagNames : : strike ,  HTML : : TagNames : : sub ,  HTML : : TagNames : : sup ,  HTML : : TagNames : : table ,  HTML : : TagNames : : tt ,  HTML : : TagNames : : u ,  HTML : : TagNames : : ul ,  HTML : : TagNames : : var ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-14 23:49:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        | |  ( token . is_start_tag ( )  & &  token . tag_name ( )  = =  HTML : : TagNames : : font  & &  ( token . has_attribute ( HTML : : AttributeNames : : color )  | |  token . has_attribute ( HTML : : AttributeNames : : face )  | |  token . has_attribute ( HTML : : AttributeNames : : size ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        | |  ( token . is_end_tag ( )  & &  token . tag_name ( ) . is_one_of ( HTML : : TagNames : : br ,  HTML : : TagNames : : p ) ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-14 23:49:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // While the current node is not a MathML text integration point, an HTML integration point, or an element in the HTML namespace, pop elements from the stack of open elements.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        while  ( ! is_mathml_text_integration_point ( current_node ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  ! is_html_integration_point ( current_node ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            & &  current_node ( ) . namespace_ ( )  ! =  Namespace : : HTML )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-14 23:49:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // Reprocess the token according to the rules given in the section corresponding to the current insertion mode in HTML content.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-14 23:49:45 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    // Any other start tag
 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( token . is_start_tag ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( adjusted_current_node ( ) . namespace_ ( )  = =  Namespace : : MathML )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            adjust_mathml_attributes ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }  else  if  ( adjusted_current_node ( ) . namespace_ ( )  = =  Namespace : : SVG )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            adjust_svg_tag_names ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            adjust_svg_attributes ( token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        adjust_foreign_attributes ( token ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) insert_foreign_element ( token ,  adjusted_current_node ( ) . namespace_ ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( token . is_self_closing ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( token . tag_name ( )  = =  SVG : : TagNames : : script  & &  current_node ( ) . namespace_ ( )  = =  Namespace : : SVG )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                token . acknowledge_self_closing_flag_if_set ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                goto  ScriptEndTag ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            token . acknowledge_self_closing_flag_if_set ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( )  & &  current_node ( ) . namespace_ ( )  = =  Namespace : : SVG  & &  current_node ( ) . tag_name ( )  = =  SVG : : TagNames : : script )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    ScriptEndTag : 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // Pop the current node off the stack of open elements.
 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // Let the old insertion point have the same value as the current insertion point.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_tokenizer . store_insertion_point ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Let the insertion point be just before the next input character.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_tokenizer . update_insertion_point ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Increment the parser's script nesting level by one.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        increment_script_nesting_level ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Set the parser pause flag to true.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_parser_pause_flag  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // FIXME: Implement SVG script parsing.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        TODO ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-19 15:58:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // Decrement the parser's script nesting level by one.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        decrement_script_nesting_level ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // If the parser's script nesting level is zero, then set the parser pause flag to false.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( script_nesting_level ( )  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_parser_pause_flag  =  false ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // Let the insertion point have the value of the old insertion point.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_tokenizer . restore_insertion_point ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( token . is_end_tag ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        JS : : GCPtr < DOM : : Element >  node  =  current_node ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // FIXME: Not sure if this is the correct to_lowercase, as the specification says "to ASCII lowercase"
 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 23:02:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( node - > tag_name ( ) . to_lowercase ( )  ! =  token . tag_name ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-24 20:23:27 -07:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            log_parse_error ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 23:02:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        for  ( ssize_t  i  =  m_stack_of_open_elements . elements ( ) . size ( )  -  1 ;  i  > =  0 ;  - - i )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( node . ptr ( )  = =  & m_stack_of_open_elements . first ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // FIXME: See the above FIXME
 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 23:02:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( node - > tag_name ( ) . to_lowercase ( )  = =  token . tag_name ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                while  ( & current_node ( )  ! =  node . ptr ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-12-02 12:54:34 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ( void ) m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 23:02:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            node  =  m_stack_of_open_elements . elements ( ) . at ( i  -  1 ) . ptr ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-01-02 23:02:23 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( node - > namespace_ ( )  ! =  Namespace : : HTML ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            process_using_the_rules_for ( m_insertion_mode ,  token ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-10-12 01:51:28 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 21:56:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/parsing.html#reset-the-insertion-mode-appropriately
  
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								void  HTMLParser : : reset_the_insertion_mode_appropriately ( )  
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:26:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    for  ( ssize_t  i  =  m_stack_of_open_elements . elements ( ) . size ( )  -  1 ;  i  > =  0 ;  - - i )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        bool  last  =  i  = =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-25 23:42:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // NOTE: When parsing fragments, we substitute the context element for the root of the stack of open elements.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        JS : : GCPtr < DOM : : Element >  node ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( last  & &  m_parsing_fragment )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            node  =  m_context_element . ptr ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-25 23:42:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            node  =  m_stack_of_open_elements . elements ( ) . at ( i ) . ptr ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-25 23:42:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:26:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( node - > local_name ( )  = =  HTML : : TagNames : : select )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 21:56:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( ! last )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                for  ( ssize_t  j  =  i ;  j  >  0 ;  - - j )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    auto &  ancestor  =  m_stack_of_open_elements . elements ( ) . at ( j  -  1 ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    if  ( is < HTMLTemplateElement > ( * ancestor ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 21:56:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                    if  ( is < HTMLTableElement > ( * ancestor ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-04-06 21:56:10 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                        m_insertion_mode  =  InsertionMode : : InSelectInTable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                        return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_insertion_mode  =  InsertionMode : : InSelect ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:26:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! last  & &  node - > local_name ( ) . is_one_of ( HTML : : TagNames : : td ,  HTML : : TagNames : : th ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:26:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_insertion_mode  =  InsertionMode : : InCell ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( node - > local_name ( )  = =  HTML : : TagNames : : tr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:26:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_insertion_mode  =  InsertionMode : : InRow ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( node - > local_name ( ) . is_one_of ( HTML : : TagNames : : tbody ,  HTML : : TagNames : : thead ,  HTML : : TagNames : : tfoot ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:26:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_insertion_mode  =  InsertionMode : : InTableBody ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( node - > local_name ( )  = =  HTML : : TagNames : : caption )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:26:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_insertion_mode  =  InsertionMode : : InCaption ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( node - > local_name ( )  = =  HTML : : TagNames : : colgroup )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:26:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_insertion_mode  =  InsertionMode : : InColumnGroup ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( node - > local_name ( )  = =  HTML : : TagNames : : table )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:26:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_insertion_mode  =  InsertionMode : : InTable ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( node - > local_name ( )  = =  HTML : : TagNames : : template_ )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-19 22:30:33 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_insertion_mode  =  m_stack_of_template_insertion_modes . last ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:26:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( ! last  & &  node - > local_name ( )  = =  HTML : : TagNames : : head )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_insertion_mode  =  InsertionMode : : InHead ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( node - > local_name ( )  = =  HTML : : TagNames : : body )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:26:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_insertion_mode  =  InsertionMode : : InBody ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( node - > local_name ( )  = =  HTML : : TagNames : : frameset )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:26:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            m_insertion_mode  =  InsertionMode : : InFrameset ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( node - > local_name ( )  = =  HTML : : TagNames : : html )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( ! m_head_element )  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-21 19:03:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                m_insertion_mode  =  InsertionMode : : BeforeHead ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m_insertion_mode  =  InsertionMode : : AfterHead ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:26:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    VERIFY ( m_parsing_fragment ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-28 00:26:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    m_insertion_mode  =  InsertionMode : : InBody ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 20:30:34 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:58:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								char  const *  HTMLParser : : insertion_mode_name ( )  const  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    switch  ( m_insertion_mode )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# define __ENUMERATE_INSERTION_MODE(mode) \ 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  InsertionMode : : mode :             \
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  # mode ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ENUMERATE_INSERTION_MODES 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								# undef __ENUMERATE_INSERTION_MODE 
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2021-02-23 20:42:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    VERIFY_NOT_REACHED ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								DOM : : Document &  HTMLParser : : document ( )  
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  * m_document ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2020-06-25 23:42:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								Vector < JS : : Handle < DOM : : Node > >  HTMLParser : : parse_html_fragment ( DOM : : Element &  context_element ,  StringView  markup )  
						 
					
						
							
								
									
										
										
										
											2020-06-25 23:42:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2022-09-25 16:38:21 -06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  temp_document  =  DOM : : Document : : create ( context_element . realm ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  parser  =  HTMLParser : : create ( * temp_document ,  markup ,  " utf-8 " ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser - > m_context_element  =  JS : : make_handle ( context_element ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser - > m_parsing_fragment  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    parser - > document ( ) . set_quirks_mode ( context_element . document ( ) . mode ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-25 23:42:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( context_element . local_name ( ) . is_one_of ( HTML : : TagNames : : title ,  HTML : : TagNames : : textarea ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        parser - > m_tokenizer . switch_to ( { } ,  HTMLTokenizer : : State : : RCDATA ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    }  else  if  ( context_element . local_name ( ) . is_one_of ( HTML : : TagNames : : style ,  HTML : : TagNames : : xmp ,  HTML : : TagNames : : iframe ,  HTML : : TagNames : : noembed ,  HTML : : TagNames : : noframes ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        parser - > m_tokenizer . switch_to ( { } ,  HTMLTokenizer : : State : : RAWTEXT ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    }  else  if  ( context_element . local_name ( ) . is_one_of ( HTML : : TagNames : : script ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        parser - > m_tokenizer . switch_to ( { } ,  HTMLTokenizer : : State : : ScriptData ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    }  else  if  ( context_element . local_name ( ) . is_one_of ( HTML : : TagNames : : noscript ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-25 23:42:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( context_element . document ( ) . is_scripting_enabled ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            parser - > m_tokenizer . switch_to ( { } ,  HTMLTokenizer : : State : : RAWTEXT ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    }  else  if  ( context_element . local_name ( ) . is_one_of ( HTML : : TagNames : : plaintext ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        parser - > m_tokenizer . switch_to ( { } ,  HTMLTokenizer : : State : : PLAINTEXT ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-25 23:42:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-10-10 02:48:05 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  root  =  create_element ( context_element . document ( ) ,  HTML : : TagNames : : html ,  Namespace : : HTML ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser - > document ( ) . append_child ( root ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    parser - > m_stack_of_open_elements . push ( root ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-25 23:42:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-23 18:18:13 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    if  ( context_element . local_name ( )  = =  HTML : : TagNames : : template_ )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        parser - > m_stack_of_template_insertion_modes . append ( InsertionMode : : InTemplate ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-25 23:42:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: Create a start tag token whose name is the local name of context and whose attributes are the attributes of context.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser - > reset_the_insertion_mode_appropriately ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-25 23:42:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    for  ( auto *  form_candidate  =  & context_element ;  form_candidate ;  form_candidate  =  form_candidate - > parent_element ( ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( is < HTMLFormElement > ( * form_candidate ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            parser - > m_form_element  =  JS : : make_handle ( verify_cast < HTMLFormElement > ( * form_candidate ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-25 23:42:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    parser - > run ( context_element . document ( ) . url ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-25 23:42:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    Vector < JS : : Handle < DOM : : Node > >  children ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    while  ( JS : : GCPtr < DOM : : Node >  child  =  root - > first_child ( ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-25 23:42:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        root - > remove_child ( * child ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        context_element . document ( ) . adopt_node ( * child ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        children . append ( JS : : make_handle ( * child ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-25 23:42:08 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  children ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2021-05-12 10:47:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								NonnullRefPtr < HTMLParser >  HTMLParser : : create_for_scripting ( DOM : : Document &  document )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  adopt_ref ( * new  HTMLParser ( document ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-04-01 20:58:27 +03:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								NonnullRefPtr < HTMLParser >  HTMLParser : : create_with_uncertain_encoding ( DOM : : Document &  document ,  ByteBuffer  const &  input )  
						 
					
						
							
								
									
										
										
										
											2021-05-12 10:47:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( document . has_encoding ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        return  adopt_ref ( * new  HTMLParser ( document ,  input ,  document . encoding ( ) . value ( ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-10-15 09:57:07 -04:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  encoding  =  run_encoding_sniffing_algorithm ( document ,  input ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-12 10:47:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    dbgln ( " The encoding sniffing algorithm returned encoding '{}' " ,  encoding ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-02-21 21:54:21 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    return  adopt_ref ( * new  HTMLParser ( document ,  input ,  encoding ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								NonnullRefPtr < HTMLParser >  HTMLParser : : create ( DOM : : Document &  document ,  StringView  input ,  String  const &  encoding )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  adopt_ref ( * new  HTMLParser ( document ,  input ,  encoding ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-05-12 10:47:12 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/parsing.html#html-fragment-serialisation-algorithm
  
						 
					
						
							
								
									
										
										
										
											2021-09-25 23:15:48 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								String  HTMLParser : : serialize_html_fragment ( DOM : : Node  const &  node )  
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // The algorithm takes as input a DOM Element, Document, or DocumentFragment referred to as the node.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    VERIFY ( node . is_element ( )  | |  node . is_document ( )  | |  node . is_document_fragment ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    JS : : NonnullGCPtr < DOM : : Node >  actual_node  =  node ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( is < DOM : : Element > ( node ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        auto &  element  =  verify_cast < DOM : : Element > ( node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 1. If the node serializes as void, then return the empty string.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //    (NOTE: serializes as void is defined only on elements in the spec)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( element . serializes_as_void ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  String : : empty ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 3. If the node is a template element, then let the node instead be the template element's template contents (a DocumentFragment node).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //    (NOTE: This is out of order of the spec to avoid another dynamic cast. The second step just creates a string builder, so it shouldn't matter)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( is < HTML : : HTMLTemplateElement > ( element ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            actual_node  =  verify_cast < HTML : : HTMLTemplateElement > ( element ) . content ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    enum  class  AttributeMode  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        No , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        Yes , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2021-11-11 00:55:02 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    auto  escape_string  =  [ ] ( StringView  string ,  AttributeMode  attribute_mode )  - >  String  { 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        // https://html.spec.whatwg.org/multipage/parsing.html#escapingString
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        StringBuilder  builder ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        for  ( auto &  ch  :  string )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 1. Replace any occurrence of the "&" character by the string "&".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( ch  = =  ' & ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                builder . append ( " & " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // 2. Replace any occurrences of the U+00A0 NO-BREAK SPACE character by the string " ".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            else  if  ( ch  = =  ' \xA0 ' ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                builder . append ( "   " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // 3. If the algorithm was invoked in the attribute mode, replace any occurrences of the """ character by the string """.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            else  if  ( ch  = =  ' " '  & &  attribute_mode  = =  AttributeMode : : Yes ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                builder . append ( " " " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            // 4. If the algorithm was not invoked in the attribute mode, replace any occurrences of the "<" character by the string "<", and any occurrences of the ">" character by the string ">".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            else  if  ( ch  = =  ' < '  & &  attribute_mode  = =  AttributeMode : : No ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                builder . append ( " < " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            else  if  ( ch  = =  ' > '  & &  attribute_mode  = =  AttributeMode : : No ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                builder . append ( " > " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                builder . append ( ch ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  builder . to_string ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Let s be a string, and initialize it to the empty string.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    StringBuilder  builder ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 4. For each child node of the node, in tree order, run the following steps:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    actual_node - > for_each_child ( [ & ] ( DOM : : Node &  current_node )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 1. Let current node be the child node being processed.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 2. Append the appropriate string from the following list to s:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( is < DOM : : Element > ( current_node ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // -> If current node is an Element
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto &  element  =  verify_cast < DOM : : Element > ( current_node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 1. If current node is an element in the HTML namespace, the MathML namespace, or the SVG namespace, then let tagname be current node's local name.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            //    Otherwise, let tagname be current node's qualified name.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            String  tag_name ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( element . namespace_ ( ) . is_one_of ( Namespace : : HTML ,  Namespace : : MathML ,  Namespace : : SVG ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                tag_name  =  element . local_name ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                tag_name  =  element . qualified_name ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 2. Append a U+003C LESS-THAN SIGN character (<), followed by tagname.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            builder . append ( ' < ' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            builder . append ( tag_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // FIXME: 3. If current node's is value is not null, and the element does not have an is attribute in its attribute list,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            //           then append the string " is="", followed by current node's is value escaped as described below in attribute mode,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            //           followed by a U+0022 QUOTATION MARK character (").
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 4. For each attribute that the element has, append a U+0020 SPACE character, the attribute's serialized name as described below, a U+003D EQUALS SIGN character (=),
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            //    a U+0022 QUOTATION MARK character ("), the attribute's value, escaped as described below in attribute mode, and a second U+0022 QUOTATION MARK character (").
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            //    NOTE: The order of attributes is implementation-defined. The only constraint is that the order must be stable.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            element . for_each_attribute ( [ & ] ( auto &  name ,  auto &  value )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                builder . append ( '   ' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // An attribute's serialized name for the purposes of the previous paragraph must be determined as follows:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // FIXME: -> If the attribute has no namespace:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                //              The attribute's serialized name is the attribute's local name.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                //           (We currently always do this)
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                builder . append ( name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // FIXME: -> If the attribute is in the XML namespace:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                //             The attribute's serialized name is the string "xml:" followed by the attribute's local name.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // FIXME: -> If the attribute is in the XMLNS namespace and the attribute's local name is xmlns:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                //             The attribute's serialized name is the string "xmlns".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // FIXME: -> If the attribute is in the XMLNS namespace and the attribute's local name is not xmlns:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                //             The attribute's serialized name is the string "xmlns:" followed by the attribute's local name.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // FIXME: -> If the attribute is in the XLink namespace:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                //             The attribute's serialized name is the string "xlink:" followed by the attribute's local name.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // FIXME: -> If the attribute is in some other namespace:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                //             The attribute's serialized name is the attribute's qualified name.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                builder . append ( " = \" " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								                builder . append ( escape_string ( value ,  AttributeMode : : Yes ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                builder . append ( ' " ' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 5. Append a U+003E GREATER-THAN SIGN character (>).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            builder . append ( ' > ' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 6. If current node serializes as void, then continue on to the next child node at this point.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( element . serializes_as_void ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  IterationDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 7. Append the value of running the HTML fragment serialization algorithm on the current node element (thus recursing into this algorithm for that element),
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            //    followed by a U+003C LESS-THAN SIGN character (<), a U+002F SOLIDUS character (/), tagname again, and finally a U+003E GREATER-THAN SIGN character (>).
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            builder . append ( serialize_html_fragment ( element ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            builder . append ( " </ " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            builder . append ( tag_name ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            builder . append ( ' > ' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  IterationDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( is < DOM : : Text > ( current_node ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // -> If current node is a Text node
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto &  text_node  =  verify_cast < DOM : : Text > ( current_node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto *  parent  =  current_node . parent ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( is < DOM : : Element > ( parent ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                auto &  parent_element  =  verify_cast < DOM : : Element > ( * parent ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                // 1. If the parent of current node is a style, script, xmp, iframe, noembed, noframes, or plaintext element,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                //    or if the parent of current node is a noscript element and scripting is enabled for the node, then append the value of current node's data IDL attribute literally.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                if  ( parent_element . local_name ( ) . is_one_of ( HTML : : TagNames : : style ,  HTML : : TagNames : : script ,  HTML : : TagNames : : xmp ,  HTML : : TagNames : : iframe ,  HTML : : TagNames : : noembed ,  HTML : : TagNames : : noframes ,  HTML : : TagNames : : plaintext ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    | |  ( parent_element . local_name ( )  = =  HTML : : TagNames : : noscript  & &  ! parent_element . is_scripting_disabled ( ) ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    builder . append ( text_node . data ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                    return  IterationDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 2. Otherwise, append the value of current node's data IDL attribute, escaped as described below.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            builder . append ( escape_string ( text_node . data ( ) ,  AttributeMode : : No ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  IterationDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( is < DOM : : Comment > ( current_node ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // -> If current node is a Comment
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto &  comment_node  =  verify_cast < DOM : : Comment > ( current_node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 1. Append the literal string "<!--" (U+003C LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS),
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            //    followed by the value of current node's data IDL attribute, followed by the literal string "-->" (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN).
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            builder . append ( " <!-- " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            builder . append ( comment_node . data ( ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            builder . append ( " --> " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            return  IterationDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( is < DOM : : ProcessingInstruction > ( current_node ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // -> If current node is a ProcessingInstruction
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto &  processing_instruction_node  =  verify_cast < DOM : : ProcessingInstruction > ( current_node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 1. Append the literal string "<?" (U+003C LESS-THAN SIGN, U+003F QUESTION MARK), followed by the value of current node's target IDL attribute,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            //    followed by a single U+0020 SPACE character, followed by the value of current node's data IDL attribute, followed by a single U+003E GREATER-THAN SIGN character (>).
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            builder . append ( " <? " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            builder . append ( processing_instruction_node . target ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            builder . append ( '   ' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            builder . append ( processing_instruction_node . data ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            builder . append ( ' > ' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  IterationDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( is < DOM : : DocumentType > ( current_node ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // -> If current node is a DocumentType
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            auto &  document_type_node  =  verify_cast < DOM : : DocumentType > ( current_node ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 1. Append the literal string "<!DOCTYPE" (U+003C LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+0044 LATIN CAPITAL LETTER D, U+004F LATIN CAPITAL LETTER O,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            //    U+0043 LATIN CAPITAL LETTER C, U+0054 LATIN CAPITAL LETTER T, U+0059 LATIN CAPITAL LETTER Y, U+0050 LATIN CAPITAL LETTER P, U+0045 LATIN CAPITAL LETTER E),
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            //    followed by a space (U+0020 SPACE), followed by the value of current node's name IDL attribute, followed by the literal string ">" (U+003E GREATER-THAN SIGN).
 
							 
						 
					
						
							
								
									
										
										
										
											2022-07-11 17:32:29 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            builder . append ( " <!DOCTYPE  " sv ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2021-09-13 22:42:15 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            builder . append ( document_type_node . name ( ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            builder . append ( ' > ' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  IterationDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  IterationDecision : : Continue ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 5. Return s.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  builder . to_string ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-03-26 14:29:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#current-dimension-value
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								static  RefPtr < CSS : : StyleValue >  parse_current_dimension_value ( float  value ,  Utf8View  input ,  Utf8View : : Iterator  position )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 1. If position is past the end of input, then return value as a length.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( position  = =  input . end ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  CSS : : LengthStyleValue : : create ( CSS : : Length : : make_px ( value ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. If the code point at position within input is U+0025 (%), then return value as a percentage.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( * position  = =  ' % ' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  CSS : : PercentageStyleValue : : create ( CSS : : Percentage ( value ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 3. Return value as a length.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  CSS : : LengthStyleValue : : create ( CSS : : Length : : make_px ( value ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-dimension-values
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								RefPtr < CSS : : StyleValue >  parse_dimension_value ( StringView  string )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 1. Let input be the string being parsed.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  input  =  Utf8View ( string ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ! input . validate ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Let position be a position variable for input, initially pointing at the start of input.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  position  =  input . begin ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 3. Skip ASCII whitespace within input given position.
 
							 
						 
					
						
							
								
									
										
										
										
											2022-10-01 18:14:32 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    while  ( position  ! =  input . end ( )  & &  Infra : : is_ascii_whitespace ( * position ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2022-03-26 14:29:52 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        + + position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 4. If position is past the end of input or the code point at position within input is not an ASCII digit,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    //    then return failure.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( position  = =  input . end ( )  | |  ! is_ascii_digit ( * position ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 5. Collect a sequence of code points that are ASCII digits from input given position,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    //    and interpret the resulting sequence as a base-ten integer. Let value be that number.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    StringBuilder  number_string ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    while  ( position  ! =  input . end ( )  & &  is_ascii_digit ( * position ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        number_string . append ( * position ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        + + position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  integer_value  =  number_string . string_view ( ) . to_int ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 6. If position is past the end of input, then return value as a length.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( position  = =  input . end ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  CSS : : LengthStyleValue : : create ( CSS : : Length : : make_px ( * integer_value ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    float  value  =  * integer_value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 7. If the code point at position within input is U+002E (.), then:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( * position  = =  ' . ' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 1. Advance position by 1.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        + + position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 2. If position is past the end of input or the code point at position within input is not an ASCII digit,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        //    then return the current dimension value with value, input, and position.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  ( position  = =  input . end ( )  | |  ! is_ascii_digit ( * position ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            return  parse_current_dimension_value ( value ,  input ,  position ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 3. Let divisor have the value 1.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        float  divisor  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        // 4. While true:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        while  ( true )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 1. Multiply divisor by ten.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            divisor  * =  10 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 2. Add the value of the code point at position within input,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            //    interpreted as a base-ten digit (0..9) and divided by divisor, to value.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            value  + =  ( * position  -  ' 0 ' )  /  divisor ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 3. Advance position by 1.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            + + position ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 4. If position is past the end of input, then return value as a length.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( position  = =  input . end ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                return  CSS : : LengthStyleValue : : create ( CSS : : Length : : make_px ( value ) ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            // 5. If the code point at position within input is not an ASCII digit, then break.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( ! is_ascii_digit ( * position ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                break ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 8. Return the current dimension value with value, input, and position.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  parse_current_dimension_value ( value ,  input ,  position ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#rules-for-parsing-non-zero-dimension-values
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								RefPtr < CSS : : StyleValue >  parse_nonzero_dimension_value ( StringView  string )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 1. Let input be the string being parsed.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 2. Let value be the result of parsing input using the rules for parsing dimension values.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    auto  value  =  parse_dimension_value ( string ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 3. If value is an error, return an error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( ! value ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 4. If value is zero, return an error.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( value - > is_length ( )  & &  value - > as_length ( ) . length ( ) . raw_value ( )  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    if  ( value - > is_percentage ( )  & &  value - > as_percentage ( ) . percentage ( ) . value ( )  = =  0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  nullptr ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 5. If value is a percentage, return value as a percentage.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 6. Return value as a length.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  value ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-08-28 13:42:07 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								JS : : Realm &  HTMLParser : : realm ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    return  m_document - > realm ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-09-20 21:08:14 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// https://html.spec.whatwg.org/multipage/parsing.html#abort-a-parser
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								void  HTMLParser : : abort ( )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 1. Throw away any pending content in the input stream, and discard any future content that would have been added to it.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_tokenizer . abort ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // FIXME: 2. Stop the speculative HTML parser for this HTML parser.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 3. Update the current document readiness to "interactive".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_document - > update_readiness ( DocumentReadyState : : Interactive ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 4. Pop all the nodes off the stack of open elements.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    while  ( ! m_stack_of_open_elements . is_empty ( ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        m_stack_of_open_elements . pop ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    // 5. Update the current document readiness to "complete".
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_document - > update_readiness ( DocumentReadyState : : Complete ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    m_aborted  =  true ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-24 00:14:23 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}