Skip to content

LibWeb: Generate some more code for serializable objects #5497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

shannonbooth
Copy link
Member

Sitting on top of #5492.

Makes use of the IDL generator to reduce some of the boilerplate of serializable objects and makes it a bit easier to check if a given platform object is exposed for a given realm.

@@ -1105,16 +1064,15 @@ WebIDL::ExceptionOr<SerializedTransferRecord> structured_serialize_with_transfer

static bool is_transferable_interface_exposed_on_target_realm(TransferType name, JS::Realm& realm)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could probably also replace the TransferType enum with InterfaceName, which will also allow us to get rid of this function as well, but we would need to add ArrayBuffer and ResizableArrayBuffer to InterfaceName. Maybe that is fine though?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that seems fine to me. we could hardcode it in the generator.

though, it seems like we've got a couple uses for all this type metadata. one is "is this object exposed on a global of type X". Another is "can we serialize or transfer this type". Is it correct to use the same generic-sounding "interface name" enum for all those?

@github-actions github-actions bot added the conflicts Pull request has merge conflicts that need resolution label Jul 18, 2025
Copy link

Your pull request has conflicts that need to be resolved before it can be reviewed and merged. Make sure to rebase your branch on top of the latest master.

@shannonbooth shannonbooth force-pushed the interface-name branch 3 times, most recently from 5f8c415 to d5fb498 Compare July 19, 2025 00:49
@github-actions github-actions bot removed the conflicts Pull request has merge conflicts that need resolution label Jul 19, 2025
@shannonbooth shannonbooth force-pushed the interface-name branch 5 times, most recently from 4ed618c to fb991ae Compare July 20, 2025 00:35
@github-actions github-actions bot added the conflicts Pull request has merge conflicts that need resolution label Jul 20, 2025
Copy link

Your pull request has conflicts that need to be resolved before it can be reviewed and merged. Make sure to rebase your branch on top of the latest master.

While this does cost us an extra byte to serialize as it
contains _all_ interface names instead of the set of serializable
types, doing this will allow us to remove to use the same
enum for checking whether that interface is exposed in a future
commit.
The actual name of the web interface is "URL", not "DOMURL. We
only call it DOMURL to avoid name conflicts with URL::URL.
By making use of the WEB_PLATFORM_OBJECT macro we can remove
the boilerplate of needing to add this override for every
serializable platform object so that we can check whether they
are exposed or not.
`interface_name` is implemented for every platform object,
so we no longer need this boilerplate for every serializable
platform object.
This ends up having no effect since we're falling back to DOM::Event
(which is always exposed) for `TouchEvent`, which is the platform
object that a user agent may chose to not expose. But since this
is trivial to implement, let's just add this in now.
@github-actions github-actions bot removed the conflicts Pull request has merge conflicts that need resolution label Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants