mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 18:52:45 +00:00 
			
		
		
		
	
		
			
				
	
	
	
	
		
			1.4 KiB
		
	
	
	
	
	
	
	
			
		
		
	
	
			1.4 KiB
		
	
	
	
	
	
	
	
Adding a new IDL file
Serenity's build system does a lot of work of turning the IDL from a Web spec into code, but there are a few things you'll need to do yourself.
For the sake of example, let's say you're wanting to add the HTMLDetailsElement.
- Create LibWeb/HTML/HTMLDetailsElement.idlwith the contents of the IDL section of the spec. In this case, that would be:
[Exposed=Window]
interface HTMLDetailsElement : HTMLElement {
    [HTMLConstructor] constructor();
    [CEReactions] attribute boolean open;
};
- If the IDL refers to other IDL types, you need to import those. For example, CSSRulehas an attribute that returns aCSSStyleSheet, so that needs to be imported:
#import <CSS/CSSStyleSheet.idl>
interface CSSRule {
    readonly attribute CSSStyleSheet? parentStyleSheet;
};
- 
Add a libweb_js_bindings(HTML/HTMLDetailsElement)call toLibWeb/idl_files.cmake
- 
Forward declare the generated class in LibWeb/Forward.h:- HTMLDetailsElementin its namespace.
 
- 
If your type isn't an Event or Element, you will need to add it to is_platform_object()so that it can be accepted as an IDL parameter, attribute or return type.
