mirror of
				https://github.com/LadybirdBrowser/ladybird.git
				synced 2025-11-04 07:10:57 +00:00 
			
		
		
		
	This patch adds the CharacterData subclass of Node, which is now the parent class of Text and a new Comment class. A Comment node is one of these in HTML: <!--hello friends--> Since these occur somewhat frequently on the web, we need to be able to parse them. This patch also adds a child rejection mechanism to the DOM tree. Nodes can now override is_child_allowed(Node) and return false if they don't want a particular Node to become a child of theirs. This is used to prevent Document from taking on unwanted children.
		
			
				
	
	
		
			18 lines
		
	
	
	
		
			371 B
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
	
		
			371 B
		
	
	
	
		
			C++
		
	
	
	
	
	
#pragma once
 | 
						|
 | 
						|
#include <AK/String.h>
 | 
						|
#include <LibHTML/DOM/CharacterData.h>
 | 
						|
 | 
						|
class Comment final : public CharacterData {
 | 
						|
public:
 | 
						|
    explicit Comment(Document&, const String&);
 | 
						|
    virtual ~Comment() override;
 | 
						|
 | 
						|
    virtual String tag_name() const override { return "#comment"; }
 | 
						|
};
 | 
						|
 | 
						|
template<>
 | 
						|
inline bool is<Comment>(const Node& node)
 | 
						|
{
 | 
						|
    return node.is_comment();
 | 
						|
}
 |