gecko-dev/third_party/rust/cssparser
Emilio Cobos Álvarez 24cbad8b67 Bug 1341102: Revendor rust dependencies to unbust tree. r=me
MozReview-Commit-ID: 6ChbWFfPHGS


--HG--
rename : third_party/rust/cssparser/.cargo-checksum.json => third_party/rust/cssparser-0.19.0/.cargo-checksum.json
rename : third_party/rust/cssparser/Cargo.toml => third_party/rust/cssparser-0.19.0/Cargo.toml
rename : third_party/rust/cssparser/src/parser.rs => third_party/rust/cssparser-0.19.0/src/parser.rs
rename : third_party/rust/cssparser/src/size_of_tests.rs => third_party/rust/cssparser-0.19.0/src/size_of_tests.rs
rename : third_party/rust/cssparser/src/tests.rs => third_party/rust/cssparser-0.19.0/src/tests.rs
rename : third_party/rust/cssparser/src/tokenizer.rs => third_party/rust/cssparser-0.19.0/src/tokenizer.rs
2017-08-17 20:51:43 +02:00
..
build Bug 1341102: Revendor rust dependencies; r=bustage 2017-02-28 09:23:59 -08:00
docs
src Bug 1341102: Revendor rust dependencies to unbust tree. r=me 2017-08-17 20:51:43 +02:00
.cargo-checksum.json Bug 1341102: Revendor rust dependencies to unbust tree. r=me 2017-08-17 20:51:43 +02:00
.cargo-ok
.travis.yml
Cargo.toml Bug 1341102: Revendor rust dependencies to unbust tree. r=me 2017-08-17 20:51:43 +02:00
LICENSE
README.md No bug - Revendor rust dependencies 2017-07-11 02:17:43 +00:00
build.rs Bug 1341102: Revendor rust dependencies; r=bustage 2017-02-28 09:23:59 -08:00

README.md

rust-cssparser

Build Status

Documentation

Rust implementation of CSS Syntax Module Level 3

Overview

Parsing CSS involves a series of steps:

  • When parsing from bytes, (e.g. reading a file or fetching an URL from the network,) detect the character encoding (based on a Content-Type HTTP header, an @charset rule, a BOM, etc.) and decode to Unicode text.

    rust-cssparser does not do this yet and just assumes UTF-8.

    This step is skipped when parsing from Unicode, e.g. in an HTML <style> element.

  • Tokenization, a.k.a. lexing. The input, a stream of Unicode text, is transformed into a stream of tokens. Tokenization never fails, although the output may contain error tokens.

  • This flat stream of tokens is then transformed into a tree of component values, which are either preserved tokens, or blocks/functions ({ … }, [ … ], ( … ), foo( … )) that contain more component values.

    rust-cssparser does this at the same time as tokenization: raw tokens are never materialized, you only get component values.

  • Component values can then be parsed into generic rules or declarations. The header and body of rules as well as the value of declarations are still just lists of component values at this point. See the ast module for the data structures.

  • The last step of a full CSS parser is parsing the remaining component values into Selectors, specific CSS properties, etc.

    By design, rust-cssparser does not do this last step which depends a lot on what you want to do: which properties you want to support, what you want to do with selectors, etc.

    It does however provide some helper functions to parse CSS colors and An+B (the argument to :nth-child() and related selectors.

    See Servos style crate for an example of a parser based on rust-cssparser.