Skip to content

Autogeneration of style structs

Emilio Cobos Álvarez edited this page Mar 20, 2018 · 7 revisions

Contact: Emilio Cobos Álvarez

The style system generates a set of Structs as the output of the styling process.

These structs are autogenerated in Servo using python.

But they're maintained manually in Firefox, and there's a lot of unsafe conversion code to make C++ understand the Rust data structures.

The goal of this project is prototype a way to make these structs autogenerated in Firefox. For that, the plan is to make C++ understand Rust types, using the same tool that WebRender's Firefox integration uses, cbindgen, presumably on a crate containing the current style::values module.

To prototype it, a good idea would be to start with a struct that is small and that doesn't have any fancyness, like nsStyleColor / color.mako.rs.

It may be interesting to finally ditch the mako.rs file and use a toml manifest that can be read by multiple programs. But the specifics can be discussed further :).

For ease of discussion, and to make hacking on the problem easier, a simplified version of it that doesn't require a Firefox build can be found in emilio/structs-playground.

Feel free to ask questions either:

Clone this wiki locally