diff options
author | Sam Atkins <atkinssj@serenityos.org> | 2021-10-03 21:32:01 +0100 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-10-04 15:32:27 +0100 |
commit | 02a369a0a319abf72f812a57171db7dc0bd4152b (patch) | |
tree | 5c9129ced92871c6e230400ff4f620bb4bc86d8c /Documentation | |
parent | aca87ce1462fad7c6d19fbffa316280d759da47a (diff) | |
download | serenity-02a369a0a319abf72f812a57171db7dc0bd4152b.zip |
Documentation: Add documentation for adding IDL files
There are several steps involved, which are not at all obvious unless
you already know them. So now they're written down. :^)
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/Browser/AddNewIDLFile.md | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Documentation/Browser/AddNewIDLFile.md b/Documentation/Browser/AddNewIDLFile.md new file mode 100644 index 0000000000..6f9ac6318a --- /dev/null +++ b/Documentation/Browser/AddNewIDLFile.md @@ -0,0 +1,31 @@ +# 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: +```webidl +[Exposed=Window] +interface HTMLDetailsElement : HTMLElement { + [HTMLConstructor] constructor(); + + [CEReactions] attribute boolean open; +}; +``` + +2. If the IDL starts with `[Exposed=Window]`, remove that line from the .idl file, and add the following to [`LibWeb/Bindings/WindowObjectHelper.h`](../../Userland/Libraries/LibWeb/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. + +3. Add a `libweb_js_wrapper()` call to [`LibWeb/CMakeLists.txt`](../../Userland/Libraries/LibWeb/CMakeLists.txt) + +4. Forward declare the generated classes in [`LibWeb/Forward.h`](../../Userland/Libraries/LibWeb/Forward.h): + - `HTMLDetailsElement` in its namespace. + - `HTMLDetailsElementWrapper` in the `Web::Bindings` namespace. + +5. If your interface is an Event type: + - Add `#import <DOM/Event.idl>` at the top of the IDL file. + - Open [`LibWeb/Bindings/EventWrapperFactory.cpp`](../../Userland/Libraries/LibWeb/Bindings/EventWrapperFactory.cpp) and add an `#include` directive and `if` statement for your new Event type. + |