mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 11:52:44 +00:00 
			
		
		
		
	LibWeb: Implement Attribute closer to the spec and with an IDL file
Note our Attribute class is what the spec refers to as just "Attr". The main differences between the existing implementation and the spec are just that the spec defines more fields. Attributes can contain namespace URIs and prefixes. However, note that these are not parsed in HTML documents unless the document content-type is XML. So for now, these are initialized to null. Web pages are able to set the namespace via JavaScript (setAttributeNS), so these fields may be filled in when the corresponding APIs are implemented. The main change to be aware of is that an attribute is a node. This has implications on how attributes are stored in the Element class. Nodes are non-copyable and non-movable because these constructors are deleted by the EventTarget base class. This means attributes cannot be stored in a Vector or HashMap as these containers assume copyability / movability. So for now, the Vector holding attributes is changed to hold RefPtrs to attributes instead. This might change when attribute storage is implemented according to the spec (by way of NamedNodeMap).
This commit is contained in:
		
							parent
							
								
									8d27292fac
								
							
						
					
					
						commit
						e01dfaac9a
					
				
					 11 changed files with 106 additions and 42 deletions
				
			
		|  | @ -926,6 +926,8 @@ static bool is_wrappable_type(IDL::Type const& type) | |||
|         return true; | ||||
|     if (type.name == "Selection") | ||||
|         return true; | ||||
|     if (type.name == "Attribute") | ||||
|         return true; | ||||
|     return false; | ||||
| } | ||||
| 
 | ||||
|  | @ -1628,6 +1630,7 @@ void generate_implementation(IDL::Interface const& interface) | |||
| #include <LibJS/Runtime/Value.h> | ||||
| #include <LibWeb/Bindings/@prototype_class@.h> | ||||
| #include <LibWeb/Bindings/@wrapper_class@.h> | ||||
| #include <LibWeb/Bindings/AttributeWrapper.h> | ||||
| #include <LibWeb/Bindings/CSSRuleListWrapper.h> | ||||
| #include <LibWeb/Bindings/CSSRuleWrapper.h> | ||||
| #include <LibWeb/Bindings/CSSRuleWrapperFactory.h> | ||||
|  | @ -2836,6 +2839,7 @@ void generate_prototype_implementation(IDL::Interface const& interface) | |||
| #include <LibWeb/Bindings/@prototype_class@.h> | ||||
| #include <LibWeb/Bindings/@wrapper_class@.h> | ||||
| #include <LibWeb/Bindings/AbortSignalWrapper.h> | ||||
| #include <LibWeb/Bindings/AttributeWrapper.h> | ||||
| #include <LibWeb/Bindings/CSSRuleListWrapper.h> | ||||
| #include <LibWeb/Bindings/CSSRuleWrapper.h> | ||||
| #include <LibWeb/Bindings/CSSRuleWrapperFactory.h> | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy Flynn
						Timothy Flynn