mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 00:42:44 +00:00 
			
		
		
		
	LibWeb: Start building the tree building part of the new HTML parser
This patch adds a new HTMLDocumentParser class. It keeps a tokenizer object internally and feeds itself with one token at a time from it. The names and idioms in this class are expressed as closely to the actual HTML parsing spec as possible, to make development as easy and bug free as possible. :^) This is going to become pretty large, but it's pretty cool!
This commit is contained in:
		
							parent
							
								
									0b61e21873
								
							
						
					
					
						commit
						fd1b31d0ff
					
				
					 8 changed files with 515 additions and 76 deletions
				
			
		|  | @ -34,6 +34,7 @@ | |||
| namespace Web { | ||||
| 
 | ||||
| class HTMLToken { | ||||
|     friend class HTMLDocumentParser; | ||||
|     friend class HTMLTokenizer; | ||||
| 
 | ||||
| public: | ||||
|  | @ -46,8 +47,29 @@ public: | |||
|         EndOfFile, | ||||
|     }; | ||||
| 
 | ||||
|     bool is_doctype() const { return m_type == Type::DOCTYPE; } | ||||
|     bool is_start_tag() const { return m_type == Type::StartTag; } | ||||
|     bool is_end_tag() const { return m_type == Type::EndTag; } | ||||
|     bool is_comment() const { return m_type == Type::Comment; } | ||||
|     bool is_character() const { return m_type == Type::Character; } | ||||
|     bool is_end_of_file() const { return m_type == Type::EndOfFile; } | ||||
| 
 | ||||
|     String tag_name() const | ||||
|     { | ||||
|         ASSERT(is_start_tag() || is_end_tag()); | ||||
|         return m_tag.tag_name.to_string(); | ||||
|     } | ||||
| 
 | ||||
|     bool is_self_closing() const | ||||
|     { | ||||
|         ASSERT(is_start_tag() || is_end_tag()); | ||||
|         return m_tag.self_closing; | ||||
|     } | ||||
| 
 | ||||
|     Type type() const { return m_type; } | ||||
| 
 | ||||
|     String to_string() const; | ||||
| 
 | ||||
| private: | ||||
|     struct AttributeBuilder { | ||||
|         StringBuilder name_builder; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling