-
Notifications
You must be signed in to change notification settings - Fork 189
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
Implement CSS OM spec #5
Comments
This seems like a great idea. We want to do the same for Deno (implement I did a little investigating on this last week, and came to the conclusion that we'd likely want to use The primary things I have found that need to be tackled to make this work:
|
This makes sense. I think we can expose
Yeah. Firefox/Servo retains a reference to the original color string as written in addition to the parsed RGBA value. We could either do that, or perhaps have a different parsing mode that has enum variants for each color type. The current representation is optimized for memory usage which I found to have a big impact on performance, so we'll want to test a bit here.
I think it should mostly, at least with |
Another thing I found hard when attempting this before (#10) was that CSSOM is a mutable, reference-based API, which is a little at odds with the rust borrow checking system. For example, you can have a rule that is not attached to a stylesheet, or removed from a parsed stylesheet but retained by the JS garbage collector. One way to solve that would be to use Rc/RefCell for each rule, but this impacts performance in our main use case which is minification/compilation of entire stylesheets. So we'll need to figure out a way to have both. Any ideas there would be useful! |
So for the Deno, we don't actually have any "live" bindings between Rust and JS. All our communication with Rust happens through "ops" which are essentially JS -> Rust RPC calls. To implement this we'd have a couple of All that is to say, that for Deno's use case we don't actually need a full Rust implementation of CSSOM with live bindings and references and stuff. We only need the parse and serialize primitives. For a nice Rust API though, you'd probably need |
Ah that's a nice idea... I'm not sure a full Rust implementation of CSSOM is necessary since the exposed structs here are already higher granularity. I was mainly looking at exposing it for the JS API. But implementing it in JS and using lower level bindings might be a nice idea. |
Just dug into this some more, |
Experimented with this a bit more on my side. A few complexities that will need to be handled:
|
This could be the JS API for manipulating CSS, rather than inventing our own.
The text was updated successfully, but these errors were encountered: