Skip to content
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

Support Serializable WebIDL attribute with build-time code generation #21715

Open
jdm opened this issue Sep 14, 2018 · 0 comments
Open

Support Serializable WebIDL attribute with build-time code generation #21715

jdm opened this issue Sep 14, 2018 · 0 comments

Comments

@jdm
Copy link
Member

@jdm jdm commented Sep 14, 2018

https://html.spec.whatwg.org/multipage/structured-data.html#serializable-objects

There's a bunch of hand-written code in https://github.com/servo/servo/blob/master/components/script/dom/bindings/structuredclone.rs to support serializing Blob values via postMessage that would need to be duplicated to support other types. It would be better to do the following:

  • create a Serializable trait which encompasses the serialization and deserialization steps for a particular interface
  • implement the new trait for the Blob type and rewrite the implementation of structuredclone.rs to use this trait
  • add a method to the DOMObject trait to return an optional Serializable trait object and rewrite the implementation of structuredclone.rs to rely on this method instead of hardcoding Blob support
  • add codegen support for the Serializable WebIDL extended attribute which implements the Serializable trait for the interface by invoking serialization_steps and deserialization_steps methods for the underlying object
  • generate the StructuredCloneTags enum and StructuredCloneHolder struct based on all known serializable interfaces, as well as the read_callback and write_callback functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.