mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:12:43 +00:00 
			
		
		
		
	 1682f0b760
			
		
	
	
		1682f0b760
		
	
	
	
	
		
			
			SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
		
			
				
	
	
		
			49 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
	
		
			1.1 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| /*
 | |
|  * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
 | |
|  *
 | |
|  * SPDX-License-Identifier: BSD-2-Clause
 | |
|  */
 | |
| 
 | |
| #pragma once
 | |
| 
 | |
| #include <AK/NonnullRefPtrVector.h>
 | |
| #include <LibWeb/DOM/Node.h>
 | |
| 
 | |
| namespace Web::DOM {
 | |
| 
 | |
| class ParentNode : public Node {
 | |
| public:
 | |
|     template<typename F>
 | |
|     void for_each_child(F) const;
 | |
|     template<typename F>
 | |
|     void for_each_child(F);
 | |
| 
 | |
|     RefPtr<Element> first_element_child();
 | |
|     RefPtr<Element> last_element_child();
 | |
|     u32 child_element_count() const;
 | |
| 
 | |
|     RefPtr<Element> query_selector(const StringView&);
 | |
|     NonnullRefPtrVector<Element> query_selector_all(const StringView&);
 | |
| 
 | |
| protected:
 | |
|     ParentNode(Document& document, NodeType type)
 | |
|         : Node(document, type)
 | |
|     {
 | |
|     }
 | |
| };
 | |
| 
 | |
| template<typename Callback>
 | |
| inline void ParentNode::for_each_child(Callback callback) const
 | |
| {
 | |
|     for (auto* node = first_child(); node; node = node->next_sibling())
 | |
|         callback(*node);
 | |
| }
 | |
| 
 | |
| template<typename Callback>
 | |
| inline void ParentNode::for_each_child(Callback callback)
 | |
| {
 | |
|     for (auto* node = first_child(); node; node = node->next_sibling())
 | |
|         callback(*node);
 | |
| }
 | |
| 
 | |
| }
 |