Rust cssparser code walk 2013 08 02
Josh Matthews edited this page Aug 2, 2013
·
5 revisions
Notes were not taken during the meeting, but here is a summary of what was discussed.
- rust-cssparser is based on the CSS3 Syntax Module.
- Currently rust-cssparser consumes a
~str
and returns a tree ofComponentValue
. The tokenizer and the component value parser are intertwined, in that when a(
,[
, or{
token is encountered, it parses the block and then continues tokenizing. - The unit of
Dimension
component values (eg.em
in1.4em
) is stored as a~str
. It could be an enum of known units. - Component values can be parsed into generic rules and declarations that contain component values themselves.
- Further parsing is required by a style system to parse specific rules and properties from the
ComponentValue
parts. Each property will need a custom parser. For examplefont-family
andfont-weight
accept very different things.
- It would be good to move from expecting
~str
as input to using aReader
. The tokenizer/parser need 2 characters of lookahead. This seems reasonably easy to do. - There is no string interning, but this will need to be in place later for performance reasons.
- There is a desire to make the CSS parser and selector matching system usable by other projects, but it's not quite clear how to do this yet, since selector matching is a pretty core component of the browser.
- Parallelism: if subparsers are needed for the
ComponentValue
s then we could run these in parallel. This will need testing to see if it is a win. - Numeric literals can be stored as i32 and f32.
- Style system including parsers for properties, etc.
- String interning
- Performance comparison against netsurfcss - suggestion of jQuery UI and bootstrap.