123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396 |
- # HG changeset patch
- # User Frank-Rainer Grahl <frgrahl@gmx.net>
- # Date 1643851534 -3600
- # Parent c920992f4fe36435f52aed1f1b4eb86c2886b0ce
- Bug 9999999 - Fix cssparser for later rust versions. r=me a=me.
- diff --git a/Cargo.lock b/Cargo.lock
- --- a/Cargo.lock
- +++ b/Cargo.lock
- @@ -344,17 +344,16 @@ checksum = "2760899e32a1d58d5abb31129f8f
- dependencies = [
- "cfg-if 0.1.10",
- ]
-
- [[package]]
- name = "cssparser"
- version = "0.23.9"
- source = "registry+https://github.com/rust-lang/crates.io-index"
- -checksum = "205647ffe2b63a9726a4c3bb6f31c7325e8ceff10e2f1b75a6fb7609e20419ea"
- dependencies = [
- "cssparser-macros",
- "dtoa-short",
- "itoa 0.4.1",
- "matches",
- "phf",
- "proc-macro2 0.3.6",
- "procedural-masquerade",
- diff --git a/Cargo.toml b/Cargo.toml
- --- a/Cargo.toml
- +++ b/Cargo.toml
- @@ -49,8 +49,9 @@ rpath = false
- debug-assertions = false
- panic = "abort"
- codegen-units = 1
-
- [patch.crates-io]
- libudev-sys = { path = "dom/webauthn/libudev-sys" }
- serde_derive = { git = "https://github.com/servo/serde", branch = "deserialize_from_enums6" }
- packed_simd = { package = "packed_simd_2", git = "https://github.com/hsivonen/packed_simd", rev="412f9a0aa556611de021bde89dee8fefe6e0fbbd" }
- +cssparser = { path = "third_party/myrust/cssparser" }
- diff --git a/servo/components/selectors/lib.rs b/servo/components/selectors/lib.rs
- --- a/servo/components/selectors/lib.rs
- +++ b/servo/components/selectors/lib.rs
- @@ -1,14 +1,15 @@
- /* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
- // Make |cargo bench| work.
- #![cfg_attr(feature = "bench", feature(test))]
- +#![warn(proc_macro_back_compat)]
-
- #[macro_use] extern crate bitflags;
- #[macro_use] extern crate cssparser;
- #[macro_use] extern crate log;
- #[macro_use] extern crate matches;
- extern crate fnv;
- extern crate phf;
- extern crate precomputed_hash;
- diff --git a/servo/components/style_traits/lib.rs b/servo/components/style_traits/lib.rs
- --- a/servo/components/style_traits/lib.rs
- +++ b/servo/components/style_traits/lib.rs
- @@ -5,16 +5,17 @@
- //! This module contains shared types and messages for use by devtools/script.
- //! The traits are here instead of in script so that the devtools crate can be
- //! modified independently of the rest of Servo.
-
- #![crate_name = "style_traits"]
- #![crate_type = "rlib"]
-
- #![deny(unsafe_code, missing_docs)]
- +#![warn(proc_macro_back_compat)]
-
- extern crate app_units;
- #[macro_use] extern crate bitflags;
- #[macro_use] extern crate cssparser;
- extern crate euclid;
- extern crate malloc_size_of;
- #[macro_use] extern crate malloc_size_of_derive;
- extern crate selectors;
- diff --git a/servo/components/style_traits/values.rs b/servo/components/style_traits/values.rs
- --- a/servo/components/style_traits/values.rs
- +++ b/servo/components/style_traits/values.rs
- @@ -131,16 +131,17 @@ where
- self.inner.write_str(prefix)?;
- }
- }
- self.inner.write_char(c)
- }
- }
-
- #[macro_export]
- +/// Make rust happy
- macro_rules! serialize_function {
- ($dest: expr, $name: ident($( $arg: expr, )+)) => {
- serialize_function!($dest, $name($($arg),+))
- };
- ($dest: expr, $name: ident($first_arg: expr $( , $arg: expr )*)) => {
- {
- $dest.write_str(concat!(stringify!($name), "("))?;
- $first_arg.to_css($dest)?;
- diff --git a/third_party/rust/cssparser/.cargo-checksum.json b/third_party/myrust/cssparser/.cargo-checksum.json
- rename from third_party/rust/cssparser/.cargo-checksum.json
- rename to third_party/myrust/cssparser/.cargo-checksum.json
- diff --git a/third_party/rust/cssparser/Cargo.toml b/third_party/myrust/cssparser/Cargo.toml
- rename from third_party/rust/cssparser/Cargo.toml
- rename to third_party/myrust/cssparser/Cargo.toml
- diff --git a/third_party/rust/cssparser/LICENSE b/third_party/myrust/cssparser/LICENSE
- rename from third_party/rust/cssparser/LICENSE
- rename to third_party/myrust/cssparser/LICENSE
- diff --git a/third_party/rust/cssparser/README.md b/third_party/myrust/cssparser/README.md
- rename from third_party/rust/cssparser/README.md
- rename to third_party/myrust/cssparser/README.md
- diff --git a/third_party/rust/cssparser/build.rs b/third_party/myrust/cssparser/build.rs
- rename from third_party/rust/cssparser/build.rs
- rename to third_party/myrust/cssparser/build.rs
- diff --git a/third_party/rust/cssparser/build/match_byte.rs b/third_party/myrust/cssparser/build/match_byte.rs
- rename from third_party/rust/cssparser/build/match_byte.rs
- rename to third_party/myrust/cssparser/build/match_byte.rs
- diff --git a/third_party/rust/cssparser/docs/404.html b/third_party/myrust/cssparser/docs/404.html
- rename from third_party/rust/cssparser/docs/404.html
- rename to third_party/myrust/cssparser/docs/404.html
- diff --git a/third_party/rust/cssparser/docs/index.html b/third_party/myrust/cssparser/docs/index.html
- rename from third_party/rust/cssparser/docs/index.html
- rename to third_party/myrust/cssparser/docs/index.html
- diff --git a/third_party/rust/cssparser/src/color.rs b/third_party/myrust/cssparser/src/color.rs
- rename from third_party/rust/cssparser/src/color.rs
- rename to third_party/myrust/cssparser/src/color.rs
- --- a/third_party/rust/cssparser/src/color.rs
- +++ b/third_party/myrust/cssparser/src/color.rs
- @@ -514,19 +514,19 @@ pub fn parse_color_keyword(ident: &str)
- }
- keyword(ident).cloned().ok_or(())
- }
-
-
- #[inline]
- fn from_hex(c: u8) -> Result<u8, ()> {
- match c {
- - b'0' ... b'9' => Ok(c - b'0'),
- - b'a' ... b'f' => Ok(c - b'a' + 10),
- - b'A' ... b'F' => Ok(c - b'A' + 10),
- + b'0' ..= b'9' => Ok(c - b'0'),
- + b'a' ..= b'f' => Ok(c - b'a' + 10),
- + b'A' ..= b'F' => Ok(c - b'A' + 10),
- _ => Err(())
- }
- }
-
- fn clamp_unit_f32(val: f32) -> u8 {
- // Whilst scaling by 256 and flooring would provide
- // an equal distribution of integers to percentage inputs,
- // this is not what Gecko does so we instead multiply by 255
- diff --git a/third_party/rust/cssparser/src/cow_rc_str.rs b/third_party/myrust/cssparser/src/cow_rc_str.rs
- rename from third_party/rust/cssparser/src/cow_rc_str.rs
- rename to third_party/myrust/cssparser/src/cow_rc_str.rs
- diff --git a/third_party/rust/cssparser/src/from_bytes.rs b/third_party/myrust/cssparser/src/from_bytes.rs
- rename from third_party/rust/cssparser/src/from_bytes.rs
- rename to third_party/myrust/cssparser/src/from_bytes.rs
- diff --git a/third_party/rust/cssparser/src/lib.rs b/third_party/myrust/cssparser/src/lib.rs
- rename from third_party/rust/cssparser/src/lib.rs
- rename to third_party/myrust/cssparser/src/lib.rs
- --- a/third_party/rust/cssparser/src/lib.rs
- +++ b/third_party/myrust/cssparser/src/lib.rs
- @@ -2,17 +2,17 @@
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
- #![crate_name = "cssparser"]
- #![crate_type = "rlib"]
-
- #![cfg_attr(feature = "bench", feature(test))]
- #![deny(missing_docs)]
- -
- +#![warn(proc_macro_back_compat)]
- /*!
-
- Implementation of [CSS Syntax Module Level 3](https://drafts.csswg.org/css-syntax/) for Rust.
-
- # Input
-
- Everything is based on `Parser` objects, which borrow a `&str` input.
- If you have bytes (from a file, the network, or something)
- diff --git a/third_party/rust/cssparser/src/macros.rs b/third_party/myrust/cssparser/src/macros.rs
- rename from third_party/rust/cssparser/src/macros.rs
- rename to third_party/myrust/cssparser/src/macros.rs
- --- a/third_party/rust/cssparser/src/macros.rs
- +++ b/third_party/myrust/cssparser/src/macros.rs
- @@ -127,17 +127,17 @@ macro_rules! cssparser_internal__to_lowe
- /// **This function is not part of the public API. It can change or be removed between any verisons.**
- ///
- /// If `input` is larger than buffer, return `None`.
- /// Otherwise, return `input` ASCII-lowercased, using `buffer` as temporary space if necessary.
- #[doc(hidden)]
- #[allow(non_snake_case)]
- pub fn _internal__to_lowercase<'a>(buffer: &'a mut [u8], input: &'a str) -> Option<&'a str> {
- if let Some(buffer) = buffer.get_mut(..input.len()) {
- - if let Some(first_uppercase) = input.bytes().position(|byte| matches!(byte, b'A'...b'Z')) {
- + if let Some(first_uppercase) = input.bytes().position(|byte| matches!(byte, b'A'..=b'Z')) {
- buffer.copy_from_slice(input.as_bytes());
- ::std::ascii::AsciiExt::make_ascii_lowercase(&mut buffer[first_uppercase..]);
- // `buffer` was initialized to a copy of `input` (which is &str so well-formed UTF-8)
- // then lowercased (which preserves UTF-8 well-formedness)
- unsafe {
- Some(::std::str::from_utf8_unchecked(buffer))
- }
- } else {
- diff --git a/third_party/rust/cssparser/src/nth.rs b/third_party/myrust/cssparser/src/nth.rs
- rename from third_party/rust/cssparser/src/nth.rs
- rename to third_party/myrust/cssparser/src/nth.rs
- --- a/third_party/rust/cssparser/src/nth.rs
- +++ b/third_party/myrust/cssparser/src/nth.rs
- @@ -88,17 +88,17 @@ fn parse_signless_b<'i, 't>(input: &mut
- token => Err(input.new_basic_unexpected_token_error(token))
- }
- }
-
- fn parse_n_dash_digits(string: &str) -> Result<i32, ()> {
- let bytes = string.as_bytes();
- if bytes.len() >= 3
- && bytes[..2].eq_ignore_ascii_case(b"n-")
- - && bytes[2..].iter().all(|&c| matches!(c, b'0'...b'9'))
- + && bytes[2..].iter().all(|&c| matches!(c, b'0'..=b'9'))
- {
- Ok(parse_number_saturate(&string[1..]).unwrap()) // Include the minus sign
- } else {
- Err(())
- }
- }
-
- fn parse_number_saturate(string: &str) -> Result<i32, ()> {
- diff --git a/third_party/rust/cssparser/src/parser.rs b/third_party/myrust/cssparser/src/parser.rs
- rename from third_party/rust/cssparser/src/parser.rs
- rename to third_party/myrust/cssparser/src/parser.rs
- --- a/third_party/rust/cssparser/src/parser.rs
- +++ b/third_party/myrust/cssparser/src/parser.rs
- @@ -550,38 +550,44 @@ impl<'i: 't, 't> Parser<'i, 't> {
- }
-
- let byte = self.input.tokenizer.next_byte();
- if self.stop_before.contains(Delimiters::from_byte(byte)) {
- return Err(self.new_basic_error(BasicParseErrorKind::EndOfInput))
- }
-
- let token_start_position = self.input.tokenizer.position();
- - let token;
- - match self.input.cached_token {
- - Some(ref cached_token)
- - if cached_token.start_position == token_start_position => {
- - self.input.tokenizer.reset(&cached_token.end_state);
- - match cached_token.token {
- - Token::Function(ref name) => self.input.tokenizer.see_function(name),
- - _ => {}
- - }
- - token = &cached_token.token
- + let using_cached_token = self
- + .input
- + .cached_token
- + .as_ref()
- + .map_or(false, |cached_token| {
- + cached_token.start_position == token_start_position
- + });
- + let token = if using_cached_token {
- + let cached_token = self.input.cached_token.as_ref().unwrap();
- + self.input.tokenizer.reset(&cached_token.end_state);
- + match cached_token.token {
- + Token::Function(ref name) => self.input.tokenizer.see_function(name),
- + _ => {}
- }
- - _ => {
- - let new_token = self.input.tokenizer.next()
- - .map_err(|()| self.new_basic_error(BasicParseErrorKind::EndOfInput))?;
- - self.input.cached_token = Some(CachedToken {
- - token: new_token,
- - start_position: token_start_position,
- - end_state: self.input.tokenizer.state(),
- - });
- - token = self.input.cached_token_ref()
- - }
- - }
- + &cached_token.token
- + } else {
- + let new_token = self
- + .input
- + .tokenizer
- + .next()
- + .map_err(|()| self.new_basic_error(BasicParseErrorKind::EndOfInput))?;
- + self.input.cached_token = Some(CachedToken {
- + token: new_token,
- + start_position: token_start_position,
- + end_state: self.input.tokenizer.state(),
- + });
- + self.input.cached_token_ref()
- + };
-
- if let Some(block_type) = BlockType::opening(token) {
- self.at_start_of = Some(block_type);
- }
- Ok(token)
- }
-
- /// Have the given closure parse something, then check the the input is exhausted.
- diff --git a/third_party/rust/cssparser/src/rules_and_declarations.rs b/third_party/myrust/cssparser/src/rules_and_declarations.rs
- rename from third_party/rust/cssparser/src/rules_and_declarations.rs
- rename to third_party/myrust/cssparser/src/rules_and_declarations.rs
- diff --git a/third_party/rust/cssparser/src/serializer.rs b/third_party/myrust/cssparser/src/serializer.rs
- rename from third_party/rust/cssparser/src/serializer.rs
- rename to third_party/myrust/cssparser/src/serializer.rs
- --- a/third_party/rust/cssparser/src/serializer.rs
- +++ b/third_party/myrust/cssparser/src/serializer.rs
- @@ -175,33 +175,33 @@ pub fn serialize_identifier<W>(mut value
- serialize_name(&value[2..], dest)
- } else if value == "-" {
- dest.write_str("\\-")
- } else {
- if value.as_bytes()[0] == b'-' {
- dest.write_str("-")?;
- value = &value[1..];
- }
- - if let digit @ b'0'...b'9' = value.as_bytes()[0] {
- + if let digit @ b'0'..=b'9' = value.as_bytes()[0] {
- hex_escape(digit, dest)?;
- value = &value[1..];
- }
- serialize_name(value, dest)
- }
- }
-
- /// Write a CSS name, like a custom property name.
- ///
- /// You should only use this when you know what you're doing, when in doubt,
- /// consider using `serialize_identifier`.
- pub fn serialize_name<W>(value: &str, dest: &mut W) -> fmt::Result where W:fmt::Write {
- let mut chunk_start = 0;
- for (i, b) in value.bytes().enumerate() {
- let escaped = match b {
- - b'0'...b'9' | b'A'...b'Z' | b'a'...b'z' | b'_' | b'-' => continue,
- + b'0'..=b'9' | b'A'..=b'Z' | b'a'..=b'z' | b'_' | b'-' => continue,
- _ if !b.is_ascii() => continue,
- b'\0' => Some("\u{FFFD}"),
- _ => None,
- };
- dest.write_str(&value[chunk_start..i])?;
- if let Some(escaped) = escaped {
- dest.write_str(escaped)?;
- } else if (b >= b'\x01' && b <= b'\x1F') || b == b'\x7F' {
- @@ -214,17 +214,17 @@ pub fn serialize_name<W>(value: &str, de
- dest.write_str(&value[chunk_start..])
- }
-
-
- fn serialize_unquoted_url<W>(value: &str, dest: &mut W) -> fmt::Result where W:fmt::Write {
- let mut chunk_start = 0;
- for (i, b) in value.bytes().enumerate() {
- let hex = match b {
- - b'\0' ... b' ' | b'\x7F' => true,
- + b'\0' ..= b' ' | b'\x7F' => true,
- b'(' | b')' | b'"' | b'\'' | b'\\' => false,
- _ => continue
- };
- dest.write_str(&value[chunk_start..i])?;
- if hex {
- hex_escape(b, dest)?;
- } else {
- char_escape(b, dest)?;
- @@ -274,17 +274,17 @@ impl<'a, W> CssStringWriter<'a, W> where
- impl<'a, W> fmt::Write for CssStringWriter<'a, W> where W: fmt::Write {
- fn write_str(&mut self, s: &str) -> fmt::Result {
- let mut chunk_start = 0;
- for (i, b) in s.bytes().enumerate() {
- let escaped = match b {
- b'"' => Some("\\\""),
- b'\\' => Some("\\\\"),
- b'\0' => Some("\u{FFFD}"),
- - b'\x01'...b'\x1F' | b'\x7F' => None,
- + b'\x01'..=b'\x1F' | b'\x7F' => None,
- _ => continue,
- };
- self.inner.write_str(&s[chunk_start..i])?;
- match escaped {
- Some(x) => self.inner.write_str(x)?,
- None => hex_escape(b, self.inner)?,
- };
- chunk_start = i + 1;
- diff --git a/third_party/rust/cssparser/src/size_of_tests.rs b/third_party/myrust/cssparser/src/size_of_tests.rs
- rename from third_party/rust/cssparser/src/size_of_tests.rs
- rename to third_party/myrust/cssparser/src/size_of_tests.rs
- diff --git a/third_party/rust/cssparser/src/tests.rs b/third_party/myrust/cssparser/src/tests.rs
- rename from third_party/rust/cssparser/src/tests.rs
- rename to third_party/myrust/cssparser/src/tests.rs
- diff --git a/third_party/rust/cssparser/src/tokenizer.rs b/third_party/myrust/cssparser/src/tokenizer.rs
- rename from third_party/rust/cssparser/src/tokenizer.rs
- rename to third_party/myrust/cssparser/src/tokenizer.rs
- diff --git a/third_party/rust/cssparser/src/unicode_range.rs b/third_party/myrust/cssparser/src/unicode_range.rs
- rename from third_party/rust/cssparser/src/unicode_range.rs
- rename to third_party/myrust/cssparser/src/unicode_range.rs
|