summaryrefslogtreecommitdiffstats
path: root/third_party/rust/cssparser/README.md
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /third_party/rust/cssparser/README.md
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/cssparser/README.md')
-rw-r--r--third_party/rust/cssparser/README.md57
1 files changed, 57 insertions, 0 deletions
diff --git a/third_party/rust/cssparser/README.md b/third_party/rust/cssparser/README.md
new file mode 100644
index 0000000000..84d47d9e04
--- /dev/null
+++ b/third_party/rust/cssparser/README.md
@@ -0,0 +1,57 @@
+rust-cssparser
+==============
+
+[![Build Status](https://github.com/servo/rust-cssparser/actions/workflows/main.yml/badge.svg)](https://github.com/servo/rust-cssparser/actions)
+
+[Documentation](https://docs.rs/cssparser/)
+
+Rust implementation of
+[CSS Syntax Module Level 3](https://drafts.csswg.org/css-syntax/)
+
+
+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 `Token` enum](src/tokenizer.rs) for the data structure.
+
+* The last step of a full CSS parser is
+ parsing the remaining component values
+ into [Selectors](https://drafts.csswg.org/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](src/color.rs)
+ and [An+B](src/nth.rs) (the argument to `:nth-child()` and related selectors.
+
+ See [Servo’s `style` crate](https://github.com/servo/servo/tree/master/components/style)
+ for an example of a parser based on rust-cssparser.