commit d278239b5938108611c7875cafd65d433b3c4eee parent 6a23566eaf3c3808f695976f44acc231eb9694d4 Author: Diego Escalante <descalante@mozilla.com> Date: Mon, 17 Nov 2025 17:06:54 +0000 Bug 2000621 - Update css-parser crate from 0.35.0 to 0.36.0. r=emilio,supply-chain-reviewers,firefox-style-system-reviewers Differential Revision: https://phabricator.services.mozilla.com/D272882 Diffstat:
26 files changed, 343 insertions(+), 188 deletions(-)
diff --git a/.cargo/config.toml.in b/.cargo/config.toml.in @@ -120,11 +120,6 @@ git = "https://github.com/rust-lang/rust-bindgen" rev = "9366e0af8da529c958b4cd4fcbe492d951c86f5c" replace-with = "vendored-sources" -[source."git+https://github.com/servo/rust-cssparser?rev=03f982ed70ce1de67bef02de63b2e11e08a9e111"] -git = "https://github.com/servo/rust-cssparser" -rev = "03f982ed70ce1de67bef02de63b2e11e08a9e111" -replace-with = "vendored-sources" - [source."git+https://github.com/servo/unicode-bidi?rev=ca612daf1c08c53abe07327cb3e6ef6e0a760f0c"] git = "https://github.com/servo/unicode-bidi" rev = "ca612daf1c08c53abe07327cb3e6ef6e0a760f0c" diff --git a/Cargo.lock b/Cargo.lock @@ -1336,8 +1336,9 @@ dependencies = [ [[package]] name = "cssparser" -version = "0.35.0" -source = "git+https://github.com/servo/rust-cssparser?rev=03f982ed70ce1de67bef02de63b2e11e08a9e111#71b7cfe6f1cd85427ca905a41be31ca9f6af29a5" +version = "0.36.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dae61cf9c0abb83bd659dab65b7e4e38d8236824c85f0f804f173567bda257d2" dependencies = [ "cssparser-macros", "dtoa-short", @@ -1349,7 +1350,8 @@ dependencies = [ [[package]] name = "cssparser-macros" version = "0.6.1" -source = "git+https://github.com/servo/rust-cssparser?rev=03f982ed70ce1de67bef02de63b2e11e08a9e111#71b7cfe6f1cd85427ca905a41be31ca9f6af29a5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote", "syn", diff --git a/Cargo.toml b/Cargo.toml @@ -239,9 +239,6 @@ unicode-width = { path = "build/rust/unicode-width" } unicode-bidi = { git = "https://github.com/servo/unicode-bidi", rev = "ca612daf1c08c53abe07327cb3e6ef6e0a760f0c" } nss-gk-api = { git = "https://github.com/beurdouche/nss-gk-api", rev = "e48a946811ffd64abc78de3ee284957d8d1c0d63" } -# Unpublished changes -cssparser = { git = "https://github.com/servo/rust-cssparser", rev = "03f982ed70ce1de67bef02de63b2e11e08a9e111" } - # Other overrides any_all_workaround = { git = "https://github.com/hsivonen/any_all_workaround", rev = "7fb1b7034c9f172aade21ee1c8554e8d8a48af80" } chardetng = { git = "https://github.com/hsivonen/chardetng", rev = "a07d20273ce36146adaf76bd667dd57bd7b3508b" } diff --git a/servo/components/malloc_size_of/Cargo.toml b/servo/components/malloc_size_of/Cargo.toml @@ -15,7 +15,7 @@ servo = ["string_cache"] [dependencies] app_units = "0.7" -cssparser = "0.35" +cssparser = "0.36" euclid = "0.22" selectors = { path = "../selectors" } servo_arc = { path = "../servo_arc" } diff --git a/servo/components/selectors/Cargo.toml b/servo/components/selectors/Cargo.toml @@ -21,7 +21,7 @@ to_shmem = ["dep:to_shmem", "dep:to_shmem_derive"] [dependencies] bitflags = "2" -cssparser = "0.35" +cssparser = "0.36" derive_more = { version = "2", features = ["add", "add_assign"] } rustc-hash = "2.1.1" log = "0.4" diff --git a/servo/components/style/Cargo.toml b/servo/components/style/Cargo.toml @@ -55,7 +55,7 @@ arrayvec = "0.7" atomic_refcell = "0.1" bitflags = "2" byteorder = "1.0" -cssparser = "0.35" +cssparser = "0.36" derive_more = { version = "2", features = ["add", "add_assign", "deref", "deref_mut", "from"] } dom = { path = "../../../dom/base/rust" } new_debug_unreachable = "1.0" diff --git a/servo/components/style/properties/mod.rs b/servo/components/style/properties/mod.rs @@ -747,10 +747,10 @@ fn parse_non_custom_property_declaration_value_into<'i>( }; input.reset(&start); - input.look_for_var_or_env_functions(); + input.look_for_arbitrary_substitution_functions(&["var", "env"]); let err = match parse_entirely_into(declarations, input) { Ok(()) => { - input.seen_var_or_env_functions(); + input.seen_arbitrary_substitution_functions(); return Ok(()); }, Err(e) => e, @@ -772,7 +772,7 @@ fn parse_non_custom_property_declaration_value_into<'i>( } at_start = false; } - if !input.seen_var_or_env_functions() || invalid { + if !input.seen_arbitrary_substitution_functions() || invalid { return Err(err); } input.reset(start); diff --git a/servo/components/style_traits/Cargo.toml b/servo/components/style_traits/Cargo.toml @@ -18,7 +18,7 @@ gecko = ["nsstring"] [dependencies] app_units = "0.7" bitflags = "2" -cssparser = "0.35" +cssparser = "0.36" euclid = "0.22" malloc_size_of = { path = "../malloc_size_of" } malloc_size_of_derive = { path = "../../../xpcom/rust/malloc_size_of_derive" } diff --git a/servo/components/to_shmem/Cargo.toml b/servo/components/to_shmem/Cargo.toml @@ -23,7 +23,7 @@ string_cache = ["dep:string_cache"] thin-vec = ["dep:thin-vec"] [dependencies] -cssparser = { version = "0.35", optional = true } +cssparser = { version = "0.36", optional = true } servo_arc = { version = "0.4.0", path = "../servo_arc", optional = true } smallbitvec = { version = "2.3.0", optional = true } smallvec = { version = "1.13", optional = true } diff --git a/servo/ports/geckolib/Cargo.toml b/servo/ports/geckolib/Cargo.toml @@ -15,7 +15,7 @@ gecko_refcount_logging = ["style/gecko_refcount_logging", "servo_arc/gecko_refco [dependencies] atomic_refcell = "0.1" -cssparser = "0.35" +cssparser = "0.36" cstr = "0.2" dom = { path = "../../../dom/base/rust" } ipdl_utils = { path = "../../../ipc/rust/ipdl_utils" } diff --git a/servo/tests/unit/style/Cargo.toml b/servo/tests/unit/style/Cargo.toml @@ -12,7 +12,7 @@ doctest = false [dependencies] byteorder = "1.0" app_units = "0.7" -cssparser = "0.35" +cssparser = "0.36" euclid = "0.22" html5ever = "0.22" parking_lot = "0.10" diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml @@ -1704,6 +1704,11 @@ criteria = "safe-to-deploy" delta = "0.35.0 -> 0.35.0@git:71b7cfe6f1cd85427ca905a41be31ca9f6af29a5" notes = "Only dependency bumps and one trivial change with no unsafe change." +[[audits.cssparser]] +who = "Diego Escalante <descalante@mozilla.com>" +criteria = "safe-to-deploy" +delta = "0.35.0 -> 0.36.0" + [[audits.cssparser-color]] who = "Emilio Cobos Álvarez <emilio@crisal.io>" criteria = "safe-to-deploy" diff --git a/third_party/rust/cssparser-macros/.cargo-checksum.json b/third_party/rust/cssparser-macros/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"e56b8b43a23c7449e12a742aaa343eb8147ae3b97f96f60f4d600ba1f8376b3a","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","lib.rs":"de5cd771d1388a799dc7aa05fed4f91dc340c4c691fa1bef58612788a68a792a"},"package":null} -\ No newline at end of file +{"files":{"Cargo.toml":"d4a43ad31d5048cf19ee80ec38de90fa98b9b9902b97d61e4edc940246806295","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","lib.rs":"10e68d5a92a053ff498cb1caa8290e508f691e32b73222a5a4737ee9a4097ce2"},"package":"13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"} +\ No newline at end of file diff --git a/third_party/rust/cssparser-macros/Cargo.toml b/third_party/rust/cssparser-macros/Cargo.toml @@ -14,25 +14,17 @@ edition = "2018" name = "cssparser-macros" version = "0.6.1" authors = ["Simon Sapin <simon.sapin@exyr.org>"] -build = false -autolib = false -autobins = false -autoexamples = false -autotests = false -autobenches = false description = "Procedural macros for cssparser" documentation = "https://docs.rs/cssparser-macros/" -readme = false license = "MPL-2.0" repository = "https://github.com/servo/rust-cssparser" [lib] -name = "cssparser_macros" path = "lib.rs" proc-macro = true -[dependencies] -quote = "1.0.29" +[dependencies.quote] +version = "1" [dependencies.syn] version = "2" diff --git a/third_party/rust/cssparser-macros/lib.rs b/third_party/rust/cssparser-macros/lib.rs @@ -48,7 +48,9 @@ fn get_byte_from_lit(lit: &syn::Lit) -> u8 { fn get_byte_from_expr_lit(expr: &syn::Expr) -> u8 { match *expr { - syn::Expr::Lit(syn::ExprLit { ref lit, .. }) => get_byte_from_lit(lit), + syn::Expr::Lit(syn::ExprLit { ref lit, .. }) => { + get_byte_from_lit(lit) + } _ => unreachable!(), } } @@ -61,17 +63,15 @@ fn parse_pat_to_table<'a>( table: &mut [u8; 256], ) { match pat { - syn::Pat::Lit(syn::PatLit { ref lit, .. }) => { + &syn::Pat::Lit(syn::PatLit { ref lit, .. }) => { let value = get_byte_from_lit(lit); if table[value as usize] == 0 { table[value as usize] = case_id; } } - syn::Pat::Range(syn::PatRange { - ref start, ref end, .. - }) => { - let lo = get_byte_from_expr_lit(start.as_ref().unwrap()); - let hi = get_byte_from_expr_lit(end.as_ref().unwrap()); + &syn::Pat::Range(syn::PatRange { ref start, ref end, .. }) => { + let lo = get_byte_from_expr_lit(&start.as_ref().unwrap()); + let hi = get_byte_from_expr_lit(&end.as_ref().unwrap()); for value in lo..hi { if table[value as usize] == 0 { table[value as usize] = case_id; @@ -81,14 +81,14 @@ fn parse_pat_to_table<'a>( table[hi as usize] = case_id; } } - syn::Pat::Wild(_) => { + &syn::Pat::Wild(_) => { for byte in table.iter_mut() { if *byte == 0 { *byte = case_id; } } } - syn::Pat::Ident(syn::PatIdent { ref ident, .. }) => { + &syn::Pat::Ident(syn::PatIdent { ref ident, .. }) => { assert_eq!(*wildcard, None); *wildcard = Some(ident); for byte in table.iter_mut() { @@ -97,7 +97,7 @@ fn parse_pat_to_table<'a>( } } } - syn::Pat::Or(syn::PatOr { ref cases, .. }) => { + &syn::Pat::Or(syn::PatOr { ref cases, .. }) => { for case in cases { parse_pat_to_table(case, case_id, wildcard, table); } @@ -162,7 +162,7 @@ pub fn match_byte(input: TokenStream) -> TokenStream { for (i, ref arm) in arms.iter().enumerate() { let case_id = i + 1; let index = case_id as isize; - let name = syn::Ident::new(&format!("Case{case_id}"), arm.span()); + let name = syn::Ident::new(&format!("Case{}", case_id), arm.span()); let pat = &arm.pat; parse_pat_to_table(pat, case_id as u8, &mut wildcard, &mut table); @@ -177,7 +177,7 @@ pub fn match_byte(input: TokenStream) -> TokenStream { let mut table_content = Vec::new(); for entry in table.iter() { - let name: syn::Path = syn::parse_str(&format!("Case::Case{entry}")).unwrap(); + let name: syn::Path = syn::parse_str(&format!("Case::Case{}", entry)).unwrap(); table_content.push(name); } let table = quote::quote!(static __CASES: [Case; 256] = [#(#table_content),*];); diff --git a/third_party/rust/cssparser/.cargo-checksum.json b/third_party/rust/cssparser/.cargo-checksum.json @@ -1 +1 @@ -{"files":{".github/workflows/main.yml":"1cdb64fe881ec0d0e3fa3c400135af3bf22f33a3e91a71b5176389b86b815412","Cargo.toml":"c996f1d2c7db75e9831a5a75c5d593d628fa01b2654d86909cf0534121701a0a","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"95e81e8f22062ba196eb8229a749327c063620ccf31ce1dd01b7ea0529840280","docs/.nojekyll":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/color.rs":"e0f43f7fd0e4ef2051e55675ae9ca30215382b403472f3d0ebe84f55899e857d","src/cow_rc_str.rs":"88edf6a4a1b3d4338885a8eacc29a9e7115d4fae0f227c9a81a4d53c5a546693","src/from_bytes.rs":"1223c1ccf619735ccf7c28a8d154d516aa117fdbddcf091e2e8952e68fe53a80","src/lib.rs":"846393d814c88f391706568aa697d7f6f8a6325bf4f6a187a8d81be1d1d013cf","src/macros.rs":"64ad9e506e5cea52767a5177779ac4a1cbdac1b2188abaa1291e9feb8f1653bf","src/nth.rs":"972cc94275126e747c95621e8c5f56ce5d869924e60bb0dc990f4c98f3d74890","src/parser.rs":"e7de003f1b42d80e2256972b7b90e39030dc2d362d52ef36fe33562fc4466ddb","src/rules_and_declarations.rs":"19d11c37c523fba34b55ea6dd24b20d80c005e33f514d5922601b3802ff4c06d","src/serializer.rs":"e3aa3e0ca294d34b3850e54680f4475143aa09fcb85129fa85d7084c4c9ea09e","src/size_of_tests.rs":"da0cbcaa304f7800e9122e2bce0a11d42a70b9012e646a723cb23ee74a6b858c","src/tests.rs":"c64f756d126004a47e7534777893db77625e7b27a60ccf5ba9e283319e04acd6","src/tokenizer.rs":"474d8f833ec65cffeda27cc73cb82668f4146cdff13f81cdede46ff5cd84e8d4","src/unicode_range.rs":"7ea876f64e2c83679e9cecccf9f332bebffe512f487da47a0c06e423c8662110"},"package":null} -\ No newline at end of file +{"files":{"Cargo.lock":"e2f8b97f2e23945fdda945aed3d038046fe1e994106bce07b429c42a60fe8b1b","Cargo.toml":"1a1bf623e831c9015a9c91aac6f960825e2d397be3974fcce56ebf73dd9d7aec","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"95e81e8f22062ba196eb8229a749327c063620ccf31ce1dd01b7ea0529840280","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/color.rs":"e0f43f7fd0e4ef2051e55675ae9ca30215382b403472f3d0ebe84f55899e857d","src/cow_rc_str.rs":"88edf6a4a1b3d4338885a8eacc29a9e7115d4fae0f227c9a81a4d53c5a546693","src/from_bytes.rs":"1223c1ccf619735ccf7c28a8d154d516aa117fdbddcf091e2e8952e68fe53a80","src/lib.rs":"817a739180a561f9e7e45c539b4191af1286ca61e29cb2b8a366cd21bd5c7a9e","src/macros.rs":"64ad9e506e5cea52767a5177779ac4a1cbdac1b2188abaa1291e9feb8f1653bf","src/nth.rs":"972cc94275126e747c95621e8c5f56ce5d869924e60bb0dc990f4c98f3d74890","src/parser.rs":"88dd21884a5f46edcd5687a6f64e5ca83f41562bf536f40704d26455f46b3bcd","src/rules_and_declarations.rs":"b9e2a9b8b6c52b0fc18237f71432ed37276ba274f1c8257570c704bfc05579a3","src/serializer.rs":"e3aa3e0ca294d34b3850e54680f4475143aa09fcb85129fa85d7084c4c9ea09e","src/size_of_tests.rs":"f29de7c5cb681cb36b81d22f6b103df61e3bf1406758fa5606138dbf6b49db58","src/tests.rs":"e7b0658dfdc13717c55dc2d0305ad3e237c3d9df489619bb69685652b9f7d482","src/tokenizer.rs":"952c763521e34572590c30539b9673f55cf567ac44cf8fb54dbfb864800f7e1a","src/unicode_range.rs":"7ea876f64e2c83679e9cecccf9f332bebffe512f487da47a0c06e423c8662110"},"package":"dae61cf9c0abb83bd659dab65b7e4e38d8236824c85f0f804f173567bda257d2"} +\ No newline at end of file diff --git a/third_party/rust/cssparser/.github/workflows/main.yml b/third_party/rust/cssparser/.github/workflows/main.yml @@ -1,82 +0,0 @@ -name: CI - -on: - push: - branches: [main] - pull_request: - workflow_dispatch: - merge_group: - types: [checks_requested] - -jobs: - linux-ci: - name: Linux - runs-on: ubuntu-latest - strategy: - matrix: - toolchain: - - nightly - - beta - - stable - - 1.68.0 - features: - - - - --features dummy_match_byte - - --features malloc_size_of - include: - - toolchain: nightly - features: --features bench - - toolchain: nightly - features: --features bench,dummy_match_byte - steps: - - uses: actions/checkout@v2 - - - name: Install toolchain - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: ${{ matrix.toolchain }} - override: true - components: rustfmt, clippy, ${{ matrix.toolchain == 'nightly' && 'miri,rust-src' || '' }} - - - name: Cargo format & lint - run: cargo fmt --check && cargo clippy -- -Dwarnings - - - name: Cargo build - run: cargo build ${{ matrix.features }} - - - name: Cargo doc - run: cargo doc ${{ matrix.features }} - - - name: Cargo test - run: cargo test ${{ matrix.features }} - - - name: macros build - run: cargo build - working-directory: macros - - - name: Color build - run: cargo build - working-directory: color - - - name: Color test - run: cargo test - working-directory: color - - - name: Cargo miri test - if: "matrix.toolchain == 'nightly'" - run: cargo miri test --features skip_long_tests ${{ matrix.features }} - - build_result: - name: Result - runs-on: ubuntu-latest - needs: - - "linux-ci" - - steps: - - name: Mark the job as successful - run: exit 0 - if: success() - - name: Mark the job as unsuccessful - run: exit 1 - if: "!success()" diff --git a/third_party/rust/cssparser/Cargo.lock b/third_party/rust/cssparser/Cargo.lock @@ -0,0 +1,228 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "cfg-if" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" + +[[package]] +name = "cssparser" +version = "0.36.0" +dependencies = [ + "cssparser-macros", + "difference", + "dtoa-short", + "encoding_rs", + "itoa", + "malloc_size_of", + "phf", + "serde", + "serde_json", + "smallvec", +] + +[[package]] +name = "cssparser-macros" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "difference" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198" + +[[package]] +name = "dtoa" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6add3b8cff394282be81f3fc1a0605db594ed69890078ca6e2cab1c408bcf04" + +[[package]] +name = "dtoa-short" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd1511a7b6a56299bd043a9c167a6d2bfb37bf84a6dfceaba651168adfb43c87" +dependencies = [ + "dtoa", +] + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "malloc_size_of" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d719de8b8f230028cf8192ae4c1b25267cd6b8a99d2747d345a70b8c81aa13" + +[[package]] +name = "memchr" +version = "2.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" + +[[package]] +name = "phf" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1562dc717473dbaa4c1f85a36410e03c047b2e7df7f45ee938fbef64ae7fadf" +dependencies = [ + "phf_macros", + "phf_shared", + "serde", +] + +[[package]] +name = "phf_generator" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "135ace3a761e564ec88c03a77317a7c6b80bb7f7135ef2544dbe054243b89737" +dependencies = [ + "fastrand", + "phf_shared", +] + +[[package]] +name = "phf_macros" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "812f032b54b1e759ccd5f8b6677695d5268c588701effba24601f6932f8269ef" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "phf_shared" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e57fef6bc5981e38c2ce2d63bfa546861309f875b8a75f092d1d54ae2d64f266" +dependencies = [ + "siphasher", +] + +[[package]] +name = "proc-macro2" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ee95bc4ef87b8d5ba32e8b7714ccc834865276eab0aed5c9958d00ec45f49e8" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "serde" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.228" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.145" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", + "serde_core", +] + +[[package]] +name = "siphasher" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56199f7ddabf13fe5074ce809e7d3f42b42ae711800501b5b16ea82ad029c39d" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "syn" +version = "2.0.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da58917d35242480a05c2897064da0a80589a2a0476c9a3f2fdc83b53502e917" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "462eeb75aeb73aea900253ce739c8e18a67423fadf006037cd3ff27e82748a06" diff --git a/third_party/rust/cssparser/Cargo.toml b/third_party/rust/cssparser/Cargo.toml @@ -13,7 +13,7 @@ edition = "2018" rust-version = "1.68" name = "cssparser" -version = "0.35.0" +version = "0.36.0" authors = ["Simon Sapin <simon.sapin@exyr.org>"] build = false exclude = [ @@ -45,14 +45,14 @@ skip_long_tests = [] name = "cssparser" path = "src/lib.rs" -[dependencies] -dtoa-short = "0.3" -itoa = "1.0" -smallvec = "1.0" - [dependencies.cssparser-macros] version = "0.6.1" -path = "./macros" + +[dependencies.dtoa-short] +version = "0.3" + +[dependencies.itoa] +version = "1.0" [dependencies.malloc_size_of] version = "0.1" @@ -68,17 +68,17 @@ version = "1.0" features = ["derive"] optional = true -[dev-dependencies] -difference = "2.0" -encoding_rs = "0.8" -serde_json = "1.0.25" +[dependencies.smallvec] +version = "1.0" -[workspace] -members = [ - ".", - "./macros", - "./color", -] +[dev-dependencies.difference] +version = "2.0" + +[dev-dependencies.encoding_rs] +version = "0.8" + +[dev-dependencies.serde_json] +version = "1.0.25" [profile.profiling] debug = 2 diff --git a/third_party/rust/cssparser/docs/.nojekyll b/third_party/rust/cssparser/docs/.nojekyll diff --git a/third_party/rust/cssparser/src/lib.rs b/third_party/rust/cssparser/src/lib.rs @@ -102,7 +102,7 @@ mod parser; mod serializer; mod unicode_range; -#[cfg(test)] +#[cfg(all(test, target_pointer_width = "64"))] mod size_of_tests; #[cfg(test)] mod tests; diff --git a/third_party/rust/cssparser/src/parser.rs b/third_party/rust/cssparser/src/parser.rs @@ -380,6 +380,10 @@ macro_rules! expect { } } +/// A list of arbitrary substitution functions. Should be lowercase ascii. +/// See https://drafts.csswg.org/css-values-5/#arbitrary-substitution +pub type ArbitrarySubstitutionFunctions<'a> = &'a [&'static str]; + impl<'i: 't, 't> Parser<'i, 't> { /// Create a new parser #[inline] @@ -546,19 +550,23 @@ impl<'i: 't, 't> Parser<'i, 't> { self.at_start_of = state.at_start_of; } - /// Start looking for `var()` / `env()` functions. (See the - /// `.seen_var_or_env_functions()` method.) + /// Start looking for arbitrary substitution functions like `var()` / `env()` functions. + /// (See the `.seen_arbitrary_substitution_functions()` method.) #[inline] - pub fn look_for_var_or_env_functions(&mut self) { - self.input.tokenizer.look_for_var_or_env_functions() + pub fn look_for_arbitrary_substitution_functions( + &mut self, + fns: ArbitrarySubstitutionFunctions<'i>, + ) { + self.input + .tokenizer + .look_for_arbitrary_substitution_functions(fns) } - /// Return whether a `var()` or `env()` function has been seen by the - /// tokenizer since either `look_for_var_or_env_functions` was called, and - /// stop looking. + /// Return whether a relevant function has been seen by the tokenizer since + /// `look_for_arbitrary_substitution_functions` was called, and stop looking. #[inline] - pub fn seen_var_or_env_functions(&mut self) -> bool { - self.input.tokenizer.seen_var_or_env_functions() + pub fn seen_arbitrary_substitution_functions(&mut self) -> bool { + self.input.tokenizer.seen_arbitrary_substitution_functions() } /// The old name of `try_parse`, which requires raw identifiers in the Rust 2018 edition. diff --git a/third_party/rust/cssparser/src/rules_and_declarations.rs b/third_party/rust/cssparser/src/rules_and_declarations.rs @@ -31,7 +31,7 @@ pub trait DeclarationParser<'i> { /// Parse the value of a declaration with the given `name`. /// /// Return the finished representation for the declaration - /// as returned by `DeclarationListParser::next`, + /// as returned by `RuleBodyParser::next`, /// or an `Err(..)` to ignore the entire declaration as invalid. /// /// Declaration name matching should be case-insensitive in the ASCII range. @@ -63,7 +63,7 @@ pub trait DeclarationParser<'i> { /// /// Default implementations that reject all at-rules are provided, /// so that `impl AtRuleParser<(), ()> for ... {}` can be used -/// for using `DeclarationListParser` to parse a declarations list with only qualified rules. +/// for using `RuleBodyParser` to parse a declarations list with only qualified rules. pub trait AtRuleParser<'i> { /// The intermediate representation of prelude of an at-rule. type Prelude; @@ -121,7 +121,7 @@ pub trait AtRuleParser<'i> { /// The location passed in is source location of the start of the prelude. /// /// Return the finished representation of the at-rule - /// as returned by `RuleListParser::next` or `DeclarationListParser::next`, + /// as returned by `StyleSheetParser::next` or `RuleBodyParser::next`, /// or an `Err(..)` to ignore the entire at-rule as invalid. /// /// This is only called when `parse_prelude` returned `WithBlock`, and a block @@ -146,7 +146,7 @@ pub trait AtRuleParser<'i> { /// /// Default implementations that reject all qualified rules are provided, so that /// `impl QualifiedRuleParser<(), ()> for ... {}` can be used for example for using -/// `RuleListParser` to parse a rule list with only at-rules (such as inside +/// `StyleSheetParser` to parse a rule list with only at-rules (such as inside /// `@font-feature-values`). pub trait QualifiedRuleParser<'i> { /// The intermediate representation of a qualified rule prelude. @@ -179,7 +179,7 @@ pub trait QualifiedRuleParser<'i> { /// The location passed in is source location of the start of the prelude. /// /// Return the finished representation of the qualified rule - /// as returned by `RuleListParser::next`, + /// as returned by `StyleSheetParser::next`, /// or an `Err(..)` to ignore the entire at-rule as invalid. fn parse_block<'t>( &mut self, @@ -197,7 +197,7 @@ pub trait QualifiedRuleParser<'i> { pub struct RuleBodyParser<'i, 't, 'a, P, I, E> { /// The input given to the parser. pub input: &'a mut Parser<'i, 't>, - /// The parser given to `DeclarationListParser::new` + /// The parser given to `RuleBodyParser::new` pub parser: &'a mut P, _phantom: std::marker::PhantomData<(I, E)>, @@ -218,7 +218,7 @@ pub trait RuleBodyItemParser<'i, DeclOrRule, Error: 'i>: } impl<'i, 't, 'a, P, I, E> RuleBodyParser<'i, 't, 'a, P, I, E> { - /// Create a new `DeclarationListParser` for the given `input` and `parser`. + /// Create a new `RuleBodyParser` for the given `input` and `parser`. /// /// Note that all CSS declaration lists can on principle contain at-rules. /// Even if no such valid at-rule exists (yet), @@ -230,7 +230,7 @@ impl<'i, 't, 'a, P, I, E> RuleBodyParser<'i, 't, 'a, P, I, E> { /// since `AtRuleParser` provides default implementations of its methods. /// /// The return type for finished declarations and at-rules also needs to be the same, - /// since `<DeclarationListParser as Iterator>::next` can return either. + /// since `<RuleBodyParser as Iterator>::next` can return either. /// It could be a custom enum. pub fn new(input: &'a mut Parser<'i, 't>, parser: &'a mut P) -> Self { Self { @@ -339,7 +339,7 @@ where /// implementations of their methods. /// /// The return type for finished qualified rules and at-rules also needs to be the same, - /// since `<RuleListParser as Iterator>::next` can return either. It could be a custom enum. + /// since `<StyleSheetParser as Iterator>::next` can return either. It could be a custom enum. pub fn new(input: &'a mut Parser<'i, 't>, parser: &'a mut P) -> Self { Self { input, @@ -349,7 +349,7 @@ where } } -/// `RuleListParser` is an iterator that yields `Ok(_)` for a rule or an `Err(..)` for an invalid one. +/// `StyleSheetParser` is an iterator that yields `Ok(_)` for a rule or an `Err(..)` for an invalid one. impl<'i, R, P, E: 'i> Iterator for StyleSheetParser<'i, '_, '_, P> where P: QualifiedRuleParser<'i, QualifiedRule = R, Error = E> diff --git a/third_party/rust/cssparser/src/size_of_tests.rs b/third_party/rust/cssparser/src/size_of_tests.rs @@ -42,8 +42,8 @@ size_of_test!(token, Token, 32); size_of_test!(std_cow_str, std::borrow::Cow<'static, str>, 24, 32); size_of_test!(cow_rc_str, CowRcStr, 16); -size_of_test!(tokenizer, crate::tokenizer::Tokenizer, 72); -size_of_test!(parser_input, crate::parser::ParserInput, 136); +size_of_test!(tokenizer, crate::tokenizer::Tokenizer, 96); +size_of_test!(parser_input, crate::parser::ParserInput, 160); size_of_test!(parser, crate::parser::Parser, 16); size_of_test!(source_position, crate::SourcePosition, 8); size_of_test!(parser_state, crate::ParserState, 24); diff --git a/third_party/rust/cssparser/src/tests.rs b/third_party/rust/cssparser/src/tests.rs @@ -8,6 +8,9 @@ extern crate test; use serde_json::{json, Map, Value}; #[cfg(feature = "bench")] +use crate::parser::ArbitrarySubstitutionFunctions; + +#[cfg(feature = "bench")] use self::test::Bencher; use super::{ @@ -24,7 +27,7 @@ macro_rules! JArray { } fn almost_equals(a: &Value, b: &Value) -> bool { - let var_name = match (a, b) { + match (a, b) { (Value::Number(a), Value::Number(b)) => { let a = a.as_f64().unwrap(); let b = b.as_f64().unwrap(); @@ -39,8 +42,7 @@ fn almost_equals(a: &Value, b: &Value) -> bool { (&Value::Object(_), &Value::Object(_)) => panic!("Not implemented"), (&Value::Null, &Value::Null) => true, _ => false, - }; - var_name + } } fn normalize(json: &mut Value) { @@ -797,19 +799,24 @@ fn delimiter_from_byte(b: &mut Bencher) { const BACKGROUND_IMAGE: &str = include_str!("big-data-url.css"); #[cfg(feature = "bench")] +const ARBITRARY_SUBSTITUTION_FUNCTIONS: ArbitrarySubstitutionFunctions = &["var", "env"]; + +#[cfg(feature = "bench")] #[bench] fn unquoted_url(b: &mut Bencher) { b.iter(|| { let mut input = ParserInput::new(BACKGROUND_IMAGE); let mut input = Parser::new(&mut input); - input.look_for_var_or_env_functions(); + input.look_for_arbitrary_substitution_functions(ARBITRARY_SUBSTITUTION_FUNCTIONS); let result = input.try_parse(|input| input.expect_url()); assert!(result.is_ok()); - input.seen_var_or_env_functions(); - (result.is_ok(), input.seen_var_or_env_functions()) + ( + result.is_ok(), + input.seen_arbitrary_substitution_functions(), + ) }) } diff --git a/third_party/rust/cssparser/src/tokenizer.rs b/third_party/rust/cssparser/src/tokenizer.rs @@ -6,7 +6,7 @@ use self::Token::*; use crate::cow_rc_str::CowRcStr; -use crate::parser::ParserState; +use crate::parser::{ArbitrarySubstitutionFunctions, ParserState}; use std::char; use std::ops::Range; @@ -215,15 +215,15 @@ pub struct Tokenizer<'a> { /// of UTF-16 characters. current_line_start_position: usize, current_line_number: u32, - var_or_env_functions: SeenStatus, + arbitrary_substitution_functions: SeenStatus<'a>, source_map_url: Option<&'a str>, source_url: Option<&'a str>, } #[derive(Copy, Clone, PartialEq, Eq)] -enum SeenStatus { +enum SeenStatus<'a> { DontCare, - LookingForThem, + LookingForThem(ArbitrarySubstitutionFunctions<'a>), SeenAtLeastOne, } @@ -235,30 +235,33 @@ impl<'a> Tokenizer<'a> { position: 0, current_line_start_position: 0, current_line_number: 0, - var_or_env_functions: SeenStatus::DontCare, + arbitrary_substitution_functions: SeenStatus::DontCare, source_map_url: None, source_url: None, } } #[inline] - pub fn look_for_var_or_env_functions(&mut self) { - self.var_or_env_functions = SeenStatus::LookingForThem; + pub fn look_for_arbitrary_substitution_functions( + &mut self, + fns: ArbitrarySubstitutionFunctions<'a>, + ) { + self.arbitrary_substitution_functions = SeenStatus::LookingForThem(fns); } #[inline] - pub fn seen_var_or_env_functions(&mut self) -> bool { - let seen = self.var_or_env_functions == SeenStatus::SeenAtLeastOne; - self.var_or_env_functions = SeenStatus::DontCare; + pub fn seen_arbitrary_substitution_functions(&mut self) -> bool { + let seen = self.arbitrary_substitution_functions == SeenStatus::SeenAtLeastOne; + self.arbitrary_substitution_functions = SeenStatus::DontCare; seen } #[inline] pub fn see_function(&mut self, name: &str) { - if self.var_or_env_functions == SeenStatus::LookingForThem - && (name.eq_ignore_ascii_case("var") || name.eq_ignore_ascii_case("env")) - { - self.var_or_env_functions = SeenStatus::SeenAtLeastOne; + if let SeenStatus::LookingForThem(fns) = self.arbitrary_substitution_functions { + if fns.iter().any(|a| name.eq_ignore_ascii_case(a)) { + self.arbitrary_substitution_functions = SeenStatus::SeenAtLeastOne; + } } }