mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 14:42:44 +00:00 
			
		
		
		
	LibWeb: Add CDATASection
Not used for anything currently other than exposing it on the Window object. This allows Web Components Polyfills to patch its prototype.
This commit is contained in:
		
							parent
							
								
									2916b3bebf
								
							
						
					
					
						commit
						1ceba560f4
					
				
					 10 changed files with 68 additions and 1 deletions
				
			
		
							
								
								
									
										20
									
								
								Userland/Libraries/LibWeb/DOM/CDATASection.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								Userland/Libraries/LibWeb/DOM/CDATASection.cpp
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,20 @@ | |||
| /*
 | ||||
|  * Copyright (c) 2022, Luke Wilde <lukew@serenityos.org> | ||||
|  * | ||||
|  * SPDX-License-Identifier: BSD-2-Clause | ||||
|  */ | ||||
| 
 | ||||
| #include <LibWeb/DOM/CDATASection.h> | ||||
| 
 | ||||
| namespace Web::DOM { | ||||
| 
 | ||||
| CDATASection::CDATASection(Document& document, String const& data) | ||||
|     : Text(document, NodeType::CDATA_SECTION_NODE, data) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| CDATASection::~CDATASection() | ||||
| { | ||||
| } | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										28
									
								
								Userland/Libraries/LibWeb/DOM/CDATASection.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								Userland/Libraries/LibWeb/DOM/CDATASection.h
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,28 @@ | |||
| /*
 | ||||
|  * Copyright (c) 2022, Luke Wilde <lukew@serenityos.org> | ||||
|  * | ||||
|  * SPDX-License-Identifier: BSD-2-Clause | ||||
|  */ | ||||
| 
 | ||||
| #pragma once | ||||
| 
 | ||||
| #include <AK/RefCounted.h> | ||||
| #include <LibWeb/DOM/Text.h> | ||||
| 
 | ||||
| namespace Web::DOM { | ||||
| 
 | ||||
| class CDATASection final : public Text { | ||||
| public: | ||||
|     using WrapperType = Bindings::CDATASectionWrapper; | ||||
| 
 | ||||
|     CDATASection(Document&, String const&); | ||||
|     virtual ~CDATASection() override; | ||||
| 
 | ||||
|     // ^Node
 | ||||
|     virtual FlyString node_name() const override { return "#cdata-section"; } | ||||
| }; | ||||
| 
 | ||||
| template<> | ||||
| inline bool Node::fast_is<CDATASection>() const { return is_cdata_section(); } | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										3
									
								
								Userland/Libraries/LibWeb/DOM/CDATASection.idl
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								Userland/Libraries/LibWeb/DOM/CDATASection.idl
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,3 @@ | |||
| [Exposed=Window] | ||||
| interface CDATASection : Text { | ||||
| }; | ||||
|  | @ -72,6 +72,7 @@ public: | |||
|     bool is_parent_node() const { return is_element() || is_document() || is_document_fragment(); } | ||||
|     bool is_slottable() const { return is_element() || is_text(); } | ||||
|     bool is_attribute() const { return type() == NodeType::ATTRIBUTE_NODE; } | ||||
|     bool is_cdata_section() const { return type() == NodeType::CDATA_SECTION_NODE; } | ||||
|     virtual bool is_shadow_root() const { return false; } | ||||
| 
 | ||||
|     virtual bool requires_svg_container() const { return false; } | ||||
|  |  | |||
|  | @ -17,6 +17,11 @@ Text::Text(Document& document, String const& data) | |||
| { | ||||
| } | ||||
| 
 | ||||
| Text::Text(Document& document, NodeType type, String const& data) | ||||
|     : CharacterData(document, type, data) | ||||
| { | ||||
| } | ||||
| 
 | ||||
| // https://dom.spec.whatwg.org/#dom-text-text
 | ||||
| NonnullRefPtr<Text> Text::create_with_global_object(Bindings::WindowObject& window, String const& data) | ||||
| { | ||||
|  |  | |||
|  | @ -12,7 +12,7 @@ | |||
| 
 | ||||
| namespace Web::DOM { | ||||
| 
 | ||||
| class Text final : public CharacterData { | ||||
| class Text : public CharacterData { | ||||
| public: | ||||
|     using WrapperType = Bindings::TextWrapper; | ||||
| 
 | ||||
|  | @ -32,6 +32,9 @@ public: | |||
| 
 | ||||
|     ExceptionOr<NonnullRefPtr<Text>> split_text(size_t offset); | ||||
| 
 | ||||
| protected: | ||||
|     Text(Document&, NodeType, String const&); | ||||
| 
 | ||||
| private: | ||||
|     WeakPtr<HTML::HTMLInputElement> m_owner_input_element; | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Luke Wilde
						Luke Wilde