mirror of
https://github.com/RGBCube/serenity
synced 2025-10-24 06:42:07 +00:00
There are several steps involved, which are not at all obvious unless you already know them. So now they're written down. :^)
1.6 KiB
1.6 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 starts with
[Exposed=Window], remove that line from the .idl file, and add the following toLibWeb/Bindings/WindowObjectHelper.h:#include <LibWeb/Bindings/HTMLDetailsElementConstructor.h>and#include <LibWeb/Bindings/HTMLDetailsElementPrototype.h>to the includes list.ADD_WINDOW_OBJECT_INTERFACE(HTMLDetailsElement) \to the macro at the bottom.
-
Add a
libweb_js_wrapper()call toLibWeb/CMakeLists.txt -
Forward declare the generated classes in
LibWeb/Forward.h:HTMLDetailsElementin its namespace.HTMLDetailsElementWrapperin theWeb::Bindingsnamespace.
-
If your interface is an Event type:
- Add
#import <DOM/Event.idl>at the top of the IDL file. - Open
LibWeb/Bindings/EventWrapperFactory.cppand add an#includedirective andifstatement for your new Event type.
- Add