Skip to content

Latest commit

 

History

History
32 lines (23 loc) · 1.32 KB

AddNewIDLFile.md

File metadata and controls

32 lines (23 loc) · 1.32 KB

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.

  1. Create LibWeb/HTML/HTMLDetailsElement.idl with 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;
};
  1. If the IDL refers to other IDL types, you need to import those. For example, CSSRule has an attribute that returns a CSSStyleSheet, so that needs to be imported:
#import <CSS/CSSStyleSheet.idl>

interface CSSRule {
    readonly attribute CSSStyleSheet? parentStyleSheet;
};
  1. Add a libweb_js_bindings(HTML/HTMLDetailsElement) call to LibWeb/idl_files.cmake

  2. Forward declare the generated class in LibWeb/Forward.h:

    • HTMLDetailsElement in its namespace.
  3. 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.