perf(css): Reduce size of tokens (#6384)

This commit is contained in:
Alexander Akait 2022-11-10 04:36:53 +03:00 committed by GitHub
parent c428e82ac6
commit bea6cce0c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
59 changed files with 231 additions and 386 deletions

View File

@ -89,9 +89,7 @@ pub enum Token {
BadString {
#[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))]
value: JsWord,
#[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))]
raw: JsWord,
raw_value: JsWord,
},
/// `url(value)`
@ -101,10 +99,6 @@ pub enum Token {
#[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))]
raw_name: JsWord,
#[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))]
before: JsWord,
#[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))]
after: JsWord,
#[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))]
value: JsWord,
#[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))]
raw_value: JsWord,
@ -116,8 +110,6 @@ pub enum Token {
#[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))]
raw_name: JsWord,
#[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))]
value: JsWord,
#[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))]
raw_value: JsWord,
},
@ -213,11 +205,13 @@ impl Hash for Token {
Token::Ident { value, raw }
| Token::Function { value, raw }
| Token::AtKeyword { value, raw }
| Token::String { value, raw }
| Token::BadString { value, raw } => {
| Token::String { value, raw } => {
value.hash(state);
raw.hash(state);
}
Token::BadString { raw_value } => {
raw_value.hash(state);
}
Token::Hash { value, raw, is_id } => {
value.hash(state);
raw.hash(state);
@ -226,27 +220,21 @@ impl Hash for Token {
Token::Url {
name,
raw_name,
before,
after,
value,
raw_value,
} => {
name.hash(state);
raw_name.hash(state);
before.hash(state);
after.hash(state);
value.hash(state);
raw_value.hash(state);
}
Token::BadUrl {
name,
raw_name,
value,
raw_value,
} => {
name.hash(state);
raw_name.hash(state);
value.hash(state);
raw_value.hash(state);
}
Token::Delim { value } => {

View File

@ -432,11 +432,7 @@ pub struct UrlValueRaw {
#[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))]
pub value: JsWord,
#[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))]
pub before: Option<JsWord>,
#[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))]
pub raw: Option<JsWord>,
#[cfg_attr(feature = "rkyv", with(swc_atoms::EncodeJsWord))]
pub after: Option<JsWord>,
}
#[ast_node]

View File

@ -1978,8 +1978,8 @@ where
write_raw!(self, span, &function);
}
Token::BadString { raw, .. } => {
write_str!(self, span, raw);
Token::BadString { raw_value } => {
write_str!(self, span, raw_value);
}
Token::String { raw, .. } => {
write_str!(self, span, raw);
@ -1987,19 +1987,13 @@ where
Token::Url {
raw_name,
raw_value,
before,
after,
..
} => {
let mut url = String::with_capacity(
raw_name.len() + before.len() + raw_value.len() + after.len() + 2,
);
let mut url = String::with_capacity(raw_name.len() + raw_value.len() + 2);
url.push_str(raw_name);
url.push('(');
url.push_str(before);
url.push_str(raw_value);
url.push_str(after);
url.push(')');
write_str!(self, span, &url);
@ -2009,7 +2003,7 @@ where
raw_value,
..
} => {
let mut bad_url = String::with_capacity(raw_name.len() + raw_value.len() + 2);
let mut bad_url = String::with_capacity(raw_value.len() + 2);
bad_url.push_str(raw_name);
bad_url.push('(');
@ -2097,12 +2091,10 @@ where
url.push_str(&n.value);
write_str!(self, n.span, &url);
} else if let (Some(before), Some(raw), Some(after)) = (&n.before, &n.raw, &n.after) {
let mut url = String::with_capacity(before.len() + raw.len() + after.len());
} else if let Some(raw) = &n.raw {
let mut url = String::with_capacity(raw.len());
url.push_str(before);
url.push_str(raw);
url.push_str(after);
write_str!(self, n.span, &url);
} else {

View File

@ -283,8 +283,6 @@ impl VisitMut for NormalizeTest {
fn visit_mut_url_value_raw(&mut self, n: &mut UrlValueRaw) {
n.visit_mut_children_with(self);
n.before = None;
n.after = None;
n.raw = None;
}

View File

@ -400,7 +400,9 @@ impl VisitMut for Compressor {
| Token::Function { value, .. }
| Token::AtKeyword { value, .. }
| Token::String { value, .. }
| Token::BadString { value, .. }
| Token::BadString {
raw_value: value, ..
}
| Token::Dimension { unit: value, .. }
if !contains_only_ascii_characters(value) =>
{

View File

@ -46,9 +46,7 @@ impl Compressor {
url.value = Some(Box::new(UrlValue::Raw(UrlValueRaw {
span: *span,
value: escaped.into(),
before: None,
raw: None,
after: None,
})));
}
}

View File

@ -730,8 +730,7 @@ where
l.reconsume();
return Ok(Token::BadString {
value: (&**buf).into(),
raw: (&**raw).into(),
raw_value: (&**raw).into(),
});
}
@ -780,15 +779,17 @@ where
// This section describes how to consume a url token from a stream of code
// points. It returns either a <url-token> or a <bad-url-token>.
fn read_url(&mut self, name: (JsWord, JsWord), mut before: String) -> LexResult<Token> {
fn read_url(&mut self, name: (JsWord, JsWord), before: String) -> LexResult<Token> {
// Initially create a <url-token> with its value set to the empty string.
self.with_buf_and_raw_buf(|l, out, raw| {
raw.push_str(&before);
// Consume as much whitespace as possible.
while let Some(c) = l.next() {
if is_whitespace(c) {
l.consume();
before.push(c);
raw.push(c);
} else {
break;
}
@ -807,8 +808,6 @@ where
raw_name: name.1,
value: (&**out).into(),
raw_value: (&**raw).into(),
before: before.into(),
after: js_word!(""),
});
}
@ -822,8 +821,6 @@ where
raw_name: name.1,
value: (&**out).into(),
raw_value: (&**raw).into(),
before: before.into(),
after: js_word!(""),
});
}
@ -853,25 +850,25 @@ where
Some(')') => {
l.consume();
return Ok(Token::Url {
name: name.0,
raw_name: name.1,
value: (&**out).into(),
raw_value: (&**raw).into(),
before: before.into(),
after: whitespaces.into(),
});
}
None => {
l.emit_error(ErrorKind::UnterminatedUrl);
raw.push_str(&whitespaces);
return Ok(Token::Url {
name: name.0,
raw_name: name.1,
value: (&**out).into(),
raw_value: (&**raw).into(),
});
}
None => {
l.emit_error(ErrorKind::UnterminatedUrl);
raw.push_str(&whitespaces);
return Ok(Token::Url {
name: name.0,
raw_name: name.1,
value: (&**out).into(),
raw_value: (&**raw).into(),
before: before.into(),
after: whitespaces.into(),
});
}
_ => {}
@ -890,8 +887,7 @@ where
return Ok(Token::BadUrl {
name: name.0,
raw_name: name.1,
value: (before.clone() + (&**raw)).into(),
raw_value: (before.clone() + (&**raw)).into(),
raw_value: (&**raw).into(),
});
}
@ -914,8 +910,7 @@ where
return Ok(Token::BadUrl {
name: name.0,
raw_name: name.1,
value: (before.clone() + (&**raw)).into(),
raw_value: (before.clone() + (&**raw)).into(),
raw_value: (&**raw).into(),
});
}
@ -946,8 +941,7 @@ where
return Ok(Token::BadUrl {
name: name.0,
raw_name: name.1,
value: (before.clone() + (&**raw)).into(),
raw_value: (before.clone() + (&**raw)).into(),
raw_value: (&**raw).into(),
});
}
}

View File

@ -2870,8 +2870,6 @@ where
raw_name,
value,
raw_value,
before,
after,
} => {
let name_length = raw_name.len() as u32;
let name = Ident {
@ -2890,9 +2888,7 @@ where
Default::default(),
),
value,
before: Some(before),
raw: Some(raw_value),
after: Some(after),
})));
Ok(Url {

View File

@ -589,9 +589,7 @@
"ctxt": 0
},
"value": "https://www.example.com/",
"before": "",
"raw": "https://www.example.com/",
"after": ""
"raw": "https://www.example.com/"
},
"modifiers": null
}

View File

@ -171,9 +171,7 @@
"ctxt": 0
},
"value": "./style.css",
"before": "",
"raw": "./style.css",
"after": ""
"raw": "./style.css"
},
"modifiers": null
},
@ -367,9 +365,7 @@
"ctxt": 0
},
"value": "./style.css",
"before": "",
"raw": "./style.css",
"after": ""
"raw": "./style.css"
},
"modifiers": null
},
@ -1881,9 +1877,7 @@
"ctxt": 0
},
"value": "test.css",
"before": "",
"raw": "test.css",
"after": ""
"raw": "test.css"
},
"modifiers": null
},
@ -2057,9 +2051,7 @@
"ctxt": 0
},
"value": "test.css",
"before": "",
"raw": "test.css",
"after": ""
"raw": "test.css"
},
"modifiers": null
},
@ -2117,9 +2109,7 @@
"ctxt": 0
},
"value": "test.css",
"before": "",
"raw": "test.css",
"after": ""
"raw": "test.css"
},
"modifiers": null
},
@ -2177,9 +2167,7 @@
"ctxt": 0
},
"value": "test.css",
"before": "",
"raw": "test.css",
"after": " "
"raw": "test.css "
},
"modifiers": null
},
@ -2237,9 +2225,7 @@
"ctxt": 0
},
"value": "test.css",
"before": " ",
"raw": "test.css",
"after": ""
"raw": " test.css"
},
"modifiers": null
},
@ -2297,9 +2283,7 @@
"ctxt": 0
},
"value": "test.css",
"before": " ",
"raw": "test.css",
"after": " "
"raw": " test.css "
},
"modifiers": null
},
@ -2357,9 +2341,7 @@
"ctxt": 0
},
"value": "test.css",
"before": "\n",
"raw": "test.css",
"after": "\n"
"raw": "\ntest.css\n"
},
"modifiers": null
},
@ -2417,9 +2399,7 @@
"ctxt": 0
},
"value": "",
"before": "",
"raw": "",
"after": ""
"raw": ""
},
"modifiers": null
},
@ -2827,9 +2807,7 @@
"ctxt": 0
},
"value": "",
"before": "",
"raw": "",
"after": ""
"raw": ""
},
"modifiers": null
},
@ -3003,9 +2981,7 @@
"ctxt": 0
},
"value": "test.css",
"before": "",
"raw": "test.css",
"after": ""
"raw": "test.css"
},
"modifiers": null
},
@ -3148,9 +3124,7 @@
"ctxt": 0
},
"value": "test.css",
"before": "",
"raw": "test.css",
"after": ""
"raw": "test.css"
},
"modifiers": null
},
@ -3293,9 +3267,7 @@
"ctxt": 0
},
"value": "test.css",
"before": "",
"raw": "test.css",
"after": ""
"raw": "test.css"
},
"modifiers": null
},
@ -3438,9 +3410,7 @@
"ctxt": 0
},
"value": "test.css",
"before": "",
"raw": "test.css",
"after": ""
"raw": "test.css"
},
"modifiers": null
},
@ -3583,9 +3553,7 @@
"ctxt": 0
},
"value": "test.css",
"before": "",
"raw": "test.css",
"after": ""
"raw": "test.css"
},
"modifiers": null
},
@ -3786,9 +3754,7 @@
"ctxt": 0
},
"value": "~package/test.css",
"before": "",
"raw": "~package/test.css",
"after": ""
"raw": "~package/test.css"
},
"modifiers": null
},
@ -4136,9 +4102,7 @@
"ctxt": 0
},
"value": "~package/tilde.css",
"before": "",
"raw": "~package/tilde.css",
"after": ""
"raw": "~package/tilde.css"
},
"modifiers": null
},
@ -4196,9 +4160,7 @@
"ctxt": 0
},
"value": "~aliasesImport/alias.css",
"before": "",
"raw": "~aliasesImport/alias.css",
"after": ""
"raw": "~aliasesImport/alias.css"
},
"modifiers": null
},
@ -4314,9 +4276,7 @@
"ctxt": 0
},
"value": "./test.css",
"before": "",
"raw": "./test.css",
"after": ""
"raw": "./test.css"
},
"modifiers": null
},
@ -5247,9 +5207,7 @@
"ctxt": 0
},
"value": "./test test.css",
"before": "",
"raw": "./test\\ test.css",
"after": ""
"raw": "./test\\ test.css"
},
"modifiers": null
},
@ -5307,9 +5265,7 @@
"ctxt": 0
},
"value": "./test%20test.css",
"before": "",
"raw": "./t\\65st%20test.css",
"after": ""
"raw": "./t\\65st%20test.css"
},
"modifiers": null
},
@ -5561,9 +5517,7 @@
"ctxt": 0
},
"value": "test.css",
"before": " ",
"raw": "test.css",
"after": " "
"raw": " test.css "
},
"modifiers": null
},
@ -5718,9 +5672,7 @@
"ctxt": 0
},
"value": "test.css?foo=bar",
"before": "",
"raw": "test.css?foo=bar",
"after": ""
"raw": "test.css?foo=bar"
},
"modifiers": null
},
@ -5778,9 +5730,7 @@
"ctxt": 0
},
"value": "test.css?foo=bar#hash",
"before": "",
"raw": "test.css?foo=bar#hash",
"after": ""
"raw": "test.css?foo=bar#hash"
},
"modifiers": null
},
@ -5838,9 +5788,7 @@
"ctxt": 0
},
"value": "test.css?#hash",
"before": "",
"raw": "test.css?#hash",
"after": ""
"raw": "test.css?#hash"
},
"modifiers": null
},
@ -6441,9 +6389,7 @@
"ctxt": 0
},
"value": "./test.css",
"before": " ",
"raw": "./test.css",
"after": " "
"raw": " ./test.css "
},
"modifiers": null
},
@ -6714,9 +6660,7 @@
"ctxt": 0
},
"value": "data:text/css;charset=utf-8,a%20%7B%0D%0A%20%20color%3A%20red%3B%0D%0A%7D",
"before": "",
"raw": "data:text/css;charset=utf-8,a%20%7B%0D%0A%20%20color%3A%20red%3B%0D%0A%7D",
"after": ""
"raw": "data:text/css;charset=utf-8,a%20%7B%0D%0A%20%20color%3A%20red%3B%0D%0A%7D"
},
"modifiers": null
},
@ -6774,9 +6718,7 @@
"ctxt": 0
},
"value": "package/first.css",
"before": "",
"raw": "package/first.css",
"after": ""
"raw": "package/first.css"
},
"modifiers": null
},
@ -6834,9 +6776,7 @@
"ctxt": 0
},
"value": "package/second.css",
"before": "",
"raw": "package/second.css",
"after": ""
"raw": "package/second.css"
},
"modifiers": null
},
@ -9734,9 +9674,7 @@
"ctxt": 0
},
"value": "test.css",
"before": "",
"raw": "test.css",
"after": ""
"raw": "test.css"
},
"modifiers": null
},
@ -9794,9 +9732,7 @@
"ctxt": 0
},
"value": "test.css",
"before": "",
"raw": "test.css",
"after": ""
"raw": "test.css"
},
"modifiers": null
},
@ -9854,9 +9790,7 @@
"ctxt": 0
},
"value": "test.css",
"before": "",
"raw": "test.css",
"after": ""
"raw": "test.css"
},
"modifiers": null
},
@ -9999,9 +9933,7 @@
"ctxt": 0
},
"value": "test.css",
"before": "",
"raw": "test.css",
"after": ""
"raw": "test.css"
},
"modifiers": null
},
@ -11532,9 +11464,7 @@
"ctxt": 0
},
"value": "bootstrap-base.css",
"before": "",
"raw": "bootstrap-base.css",
"after": ""
"raw": "bootstrap-base.css"
},
"modifiers": null
},
@ -11631,9 +11561,7 @@
"ctxt": 0
},
"value": "base-headings.css",
"before": "",
"raw": "base-headings.css",
"after": ""
"raw": "base-headings.css"
},
"modifiers": null
},

View File

@ -141,9 +141,7 @@
"ctxt": 0
},
"value": "http://www.w3.org/1999/xhtml",
"before": "",
"raw": "http://www.w3.org/1999/xhtml",
"after": ""
"raw": "http://www.w3.org/1999/xhtml"
},
"modifiers": null
}
@ -266,9 +264,7 @@
"ctxt": 0
},
"value": "http://www.w3.org/2000/svg",
"before": "",
"raw": "http://www.w3.org/2000/svg",
"after": ""
"raw": "http://www.w3.org/2000/svg"
},
"modifiers": null
}

View File

@ -1835,9 +1835,7 @@
"ctxt": 0
},
"value": "path/to.png",
"before": "",
"raw": "path/to.png",
"after": ""
"raw": "path/to.png"
},
"modifiers": null
},

View File

@ -782,9 +782,7 @@
"ctxt": 0
},
"value": "value",
"before": "",
"raw": "value",
"after": ""
"raw": "value"
},
"modifiers": null
},
@ -813,9 +811,7 @@
"ctxt": 0
},
"value": "value",
"before": "",
"raw": "value",
"after": ""
"raw": "value"
},
"modifiers": null
}

View File

@ -130,9 +130,7 @@
"ctxt": 0
},
"value": "aج",
"before": "",
"raw": "a\\62c",
"after": ""
"raw": "a\\62c"
},
"modifiers": null
}

View File

@ -55,9 +55,7 @@
"ctxt": 0
},
"value": "foo.css",
"before": "",
"raw": "foo.css",
"after": ""
"raw": "foo.css"
},
"modifiers": null
},

View File

@ -130,9 +130,7 @@
"ctxt": 0
},
"value": "abc",
"before": "",
"raw": "a\\62 c",
"after": ""
"raw": "a\\62 c"
},
"modifiers": null
}

View File

@ -130,9 +130,7 @@
"ctxt": 0
},
"value": ",",
"before": "",
"raw": "\\,",
"after": ""
"raw": "\\,"
},
"modifiers": null
}

View File

@ -55,9 +55,7 @@
"ctxt": 0
},
"value": "foo.css",
"before": "",
"raw": "foo.css",
"after": ""
"raw": "foo.css"
},
"modifiers": null
},

View File

@ -130,9 +130,7 @@
"ctxt": 0
},
"value": ",",
"before": "",
"raw": "\\2c",
"after": ""
"raw": "\\2c"
},
"modifiers": null
}

View File

@ -130,9 +130,7 @@
"ctxt": 0
},
"value": "abc",
"before": "",
"raw": "\\61 bc",
"after": ""
"raw": "\\61 bc"
},
"modifiers": null
}

View File

@ -55,9 +55,7 @@
"ctxt": 0
},
"value": "",
"before": "",
"raw": "",
"after": ""
"raw": ""
},
"modifiers": null
},

View File

@ -130,9 +130,7 @@
"ctxt": 0
},
"value": "憼",
"before": "",
"raw": "\\61bc",
"after": ""
"raw": "\\61bc"
},
"modifiers": null
}

View File

@ -130,9 +130,7 @@
"ctxt": 0
},
"value": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
"before": "",
"raw": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7",
"after": ""
"raw": "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"
},
"modifiers": null
}
@ -532,9 +530,7 @@
"ctxt": 0
},
"value": "",
"before": "",
"raw": "",
"after": ""
"raw": ""
},
"modifiers": null
}
@ -584,9 +580,7 @@
"ctxt": 0
},
"value": "",
"before": " ",
"raw": "",
"after": ""
"raw": " "
},
"modifiers": null
}
@ -886,9 +880,7 @@
"ctxt": 0
},
"value": "./image.png",
"before": "",
"raw": "./image.png",
"after": ""
"raw": "./image.png"
},
"modifiers": null
}
@ -938,9 +930,7 @@
"ctxt": 0
},
"value": "./image.png",
"before": " ",
"raw": "./image.png",
"after": " "
"raw": " ./image.png "
},
"modifiers": null
}
@ -990,9 +980,7 @@
"ctxt": 0
},
"value": "./image2.png",
"before": " ",
"raw": "./image\\32.png",
"after": " "
"raw": " ./image\\32.png "
},
"modifiers": null
}
@ -1042,9 +1030,7 @@
"ctxt": 0
},
"value": "./image2.png",
"before": " \n ",
"raw": "./image\\32.png",
"after": " \n "
"raw": " \n ./image\\32.png \n "
},
"modifiers": null
}
@ -1094,9 +1080,7 @@
"ctxt": 0
},
"value": "./image2.png",
"before": "\n \n \n \n ",
"raw": "./image\\32.png",
"after": "\n \n \n \n "
"raw": "\n \n \n \n ./image\\32.png\n \n \n \n "
},
"modifiers": null
}
@ -1146,9 +1130,7 @@
"ctxt": 0
},
"value": "./image2.png",
"before": " \n\n\n\n ",
"raw": "./image\\32.png",
"after": "\n\n\n\n "
"raw": " \n\n\n\n ./image\\32.png\n\n\n\n "
},
"modifiers": null
}
@ -1198,9 +1180,7 @@
"ctxt": 0
},
"value": "image.png\u0001",
"before": "",
"raw": "image.png\\0001",
"after": ""
"raw": "image.png\\0001"
},
"modifiers": null
}
@ -1250,9 +1230,7 @@
"ctxt": 0
},
"value": "image.png\u0001",
"before": "",
"raw": "image.png\\1",
"after": ""
"raw": "image.png\\1"
},
"modifiers": null
}
@ -1302,9 +1280,7 @@
"ctxt": 0
},
"value": "image.png힙",
"before": "",
"raw": "image.png\\D799",
"after": ""
"raw": "image.png\\D799"
},
"modifiers": null
}
@ -1354,9 +1330,7 @@
"ctxt": 0
},
"value": "image.png",
"before": "",
"raw": "image.png\\E000",
"after": ""
"raw": "image.png\\E000"
},
"modifiers": null
}
@ -1406,9 +1380,7 @@
"ctxt": 0
},
"value": "image.png􏿿",
"before": "",
"raw": "image.png\\10FFFF",
"after": ""
"raw": "image.png\\10FFFF"
},
"modifiers": null
}
@ -1458,9 +1430,7 @@
"ctxt": 0
},
"value": "18",
"before": "",
"raw": "18",
"after": ""
"raw": "18"
},
"modifiers": null
}

View File

@ -14,4 +14,5 @@ a {
color: #FF;
color: #123456789;
color: #xyz;
color: #aa\61;
}

View File

@ -2,7 +2,7 @@
"type": "Stylesheet",
"span": {
"start": 1,
"end": 257,
"end": 274,
"ctxt": 0
},
"rules": [
@ -10,7 +10,7 @@
"type": "QualifiedRule",
"span": {
"start": 1,
"end": 256,
"end": 273,
"ctxt": 0
},
"prelude": {
@ -74,7 +74,7 @@
"type": "SimpleBlock",
"span": {
"start": 3,
"end": 256,
"end": 273,
"ctxt": 0
},
"name": {
@ -551,6 +551,37 @@
}
],
"important": null
},
{
"type": "Declaration",
"span": {
"start": 257,
"end": 270,
"ctxt": 0
},
"name": {
"type": "Ident",
"span": {
"start": 257,
"end": 262,
"ctxt": 0
},
"value": "color",
"raw": "color"
},
"value": [
{
"type": "HexColor",
"span": {
"start": 264,
"end": 270,
"ctxt": 0
},
"value": "aaa",
"raw": "aa\\61"
}
],
"important": null
}
]
}

View File

@ -17,7 +17,8 @@
14 | | color: #FF;
15 | | color: #123456789;
16 | | color: #xyz;
17 | `-> }
17 | | color: #aa\61;
18 | `-> }
`----
x Rule
@ -38,7 +39,8 @@
14 | | color: #FF;
15 | | color: #123456789;
16 | | color: #xyz;
17 | `-> }
17 | | color: #aa\61;
18 | `-> }
`----
x QualifiedRule
@ -59,7 +61,8 @@
14 | | color: #FF;
15 | | color: #123456789;
16 | | color: #xyz;
17 | `-> }
17 | | color: #aa\61;
18 | `-> }
`----
x SelectorList
@ -122,7 +125,8 @@
14 | | color: #FF;
15 | | color: #123456789;
16 | | color: #xyz;
17 | `-> }
17 | | color: #aa\61;
18 | `-> }
`----
x LBrace
@ -850,3 +854,51 @@
16 | color: #xyz;
: ^^^^
`----
x ComponentValue
,-[$DIR/tests/fixture/hex-colors/input.css:17:3]
17 | color: #aa\61;
: ^^^^^^^^^^^^^
`----
x StyleBlock
,-[$DIR/tests/fixture/hex-colors/input.css:17:3]
17 | color: #aa\61;
: ^^^^^^^^^^^^^
`----
x Declaration
,-[$DIR/tests/fixture/hex-colors/input.css:17:3]
17 | color: #aa\61;
: ^^^^^^^^^^^^^
`----
x DeclarationName
,-[$DIR/tests/fixture/hex-colors/input.css:17:3]
17 | color: #aa\61;
: ^^^^^
`----
x Ident
,-[$DIR/tests/fixture/hex-colors/input.css:17:3]
17 | color: #aa\61;
: ^^^^^
`----
x ComponentValue
,-[$DIR/tests/fixture/hex-colors/input.css:17:3]
17 | color: #aa\61;
: ^^^^^^
`----
x Color
,-[$DIR/tests/fixture/hex-colors/input.css:17:3]
17 | color: #aa\61;
: ^^^^^^
`----
x HexColor
,-[$DIR/tests/fixture/hex-colors/input.css:17:3]
17 | color: #aa\61;
: ^^^^^^
`----

View File

@ -1771,8 +1771,6 @@
"Url": {
"name": "url",
"raw_name": "url",
"before": "",
"after": "",
"value": "foo.png",
"raw_value": "foo.png"
}

View File

@ -1541,8 +1541,7 @@
: ^^^^^^^^^^^^
`----
x Url { name: Atom('url' type=static), raw_name: Atom('url' type=static), before: Atom('' type=static), after: Atom('' type=static), value: Atom('foo.png' type=inline), raw_value: Atom('foo.png'
| type=inline) }
x Url { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('foo.png' type=inline), raw_value: Atom('foo.png' type=inline) }
,-[$DIR/tests/fixture/selector/pseudo-class/unknown/input.css:15:1]
15 | :unknown(url(foo.png)) {}
: ^^^^^^^^^^^^

View File

@ -1771,8 +1771,6 @@
"Url": {
"name": "url",
"raw_name": "url",
"before": "",
"after": "",
"value": "foo.png",
"raw_value": "foo.png"
}

View File

@ -1540,8 +1540,7 @@
: ^^^^^^^^^^^^
`----
x Url { name: Atom('url' type=static), raw_name: Atom('url' type=static), before: Atom('' type=static), after: Atom('' type=static), value: Atom('foo.png' type=inline), raw_value: Atom('foo.png'
| type=inline) }
x Url { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('foo.png' type=inline), raw_value: Atom('foo.png' type=inline) }
,-[$DIR/tests/fixture/selector/pseudo-element/unknown/input.css:15:1]
15 | ::unknown(url(foo.png)) {}
: ^^^^^^^^^^^^

View File

@ -148,9 +148,7 @@
"ctxt": 0
},
"value": "foo.jpg",
"before": "",
"raw": "foo.jpg",
"after": ""
"raw": "foo.jpg"
},
"modifiers": null
},

View File

@ -295,9 +295,7 @@
"ctxt": 0
},
"value": "a;a",
"before": "",
"raw": "a;a",
"after": ""
"raw": "a;a"
},
"modifiers": null
}
@ -347,9 +345,7 @@
"ctxt": 0
},
"value": "a/*",
"before": "",
"raw": "a/*",
"after": ""
"raw": "a/*"
},
"modifiers": null
}

View File

@ -130,9 +130,7 @@
"ctxt": 0
},
"value": "https://example.com/image.png",
"before": "",
"raw": "https://example.com/image.png",
"after": ""
"raw": "https://example.com/image.png"
},
"modifiers": null
}
@ -182,9 +180,7 @@
"ctxt": 0
},
"value": "https://example.com/image.png",
"before": "",
"raw": "https://example.com/image.png",
"after": ""
"raw": "https://example.com/image.png"
},
"modifiers": null
}
@ -234,9 +230,7 @@
"ctxt": 0
},
"value": "https://example.com/image.png",
"before": "",
"raw": "https://example.com/image.png",
"after": ""
"raw": "https://example.com/image.png"
},
"modifiers": null
}
@ -486,9 +480,7 @@
"ctxt": 0
},
"value": "data:image/png;base64,iRxVB0",
"before": "",
"raw": "data:image/png;base64,iRxVB0",
"after": ""
"raw": "data:image/png;base64,iRxVB0"
},
"modifiers": null
}
@ -538,9 +530,7 @@
"ctxt": 0
},
"value": "#IDofSVGpath",
"before": "",
"raw": "#IDofSVGpath",
"after": ""
"raw": "#IDofSVGpath"
},
"modifiers": null
}
@ -873,9 +863,7 @@
"ctxt": 0
},
"value": "",
"before": "",
"raw": "",
"after": ""
"raw": ""
},
"modifiers": null
}
@ -1232,9 +1220,7 @@
"ctxt": 0
},
"value": "https://example.com/image.png",
"before": " ",
"raw": "https://example.com/image.png",
"after": " "
"raw": " https://example.com/image.png "
},
"modifiers": null
}
@ -1284,9 +1270,7 @@
"ctxt": 0
},
"value": "https://example.com/image.png",
"before": " ",
"raw": "https://example.com/image.png",
"after": " "
"raw": " https://example.com/image.png "
},
"modifiers": null
}
@ -1336,9 +1320,7 @@
"ctxt": 0
},
"value": "https://example.com/image.png",
"before": " \n ",
"raw": "https://example.com/image.png",
"after": " \n "
"raw": " \n https://example.com/image.png \n "
},
"modifiers": null
}
@ -1388,9 +1370,7 @@
"ctxt": 0
},
"value": "https://example.com/image.png",
"before": "\n\n\n",
"raw": "https://example.com/image.png",
"after": "\n\n\n"
"raw": "\n\n\nhttps://example.com/image.png\n\n\n"
},
"modifiers": null
}
@ -1440,9 +1420,7 @@
"ctxt": 0
},
"value": "https://example.com/ima)ge.png",
"before": "",
"raw": "https://example.com/ima\\)ge.png",
"after": ""
"raw": "https://example.com/ima\\)ge.png"
},
"modifiers": null
}

View File

@ -116,7 +116,6 @@
"BadUrl": {
"name": "url",
"raw_name": "url",
"value": "image\".png",
"raw_value": "image\".png"
}
}

View File

@ -115,7 +115,7 @@
: ^^^^^^^^^^^^^^^
`----
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('image".png' type=dynamic), raw_value: Atom('image".png' type=dynamic) }
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('image".png' type=dynamic) }
,-[$DIR/tests/recovery/bad-url-token/double-quotes/input.css:2:5]
2 | background: url(image".png);
: ^^^^^^^^^^^^^^^

View File

@ -116,7 +116,6 @@
"BadUrl": {
"name": "url",
"raw_name": "url",
"value": "image.png\\\n ",
"raw_value": "image.png\\\n "
}
}

View File

@ -115,8 +115,7 @@
3 | `-> );
`----
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('image.png\
| ' type=dynamic), raw_value: Atom('image.png\
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('image.png\
| ' type=dynamic) }
,-[$DIR/tests/recovery/bad-url-token/invalid-escape/input.css:2:5]
2 | ,-> background: url(image.png\

View File

@ -116,7 +116,6 @@
"BadUrl": {
"name": "url",
"raw_name": "url",
"value": "image(.png",
"raw_value": "image(.png"
}
}

View File

@ -115,7 +115,7 @@
: ^^^^^^^^^^^^^^^
`----
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('image(.png' type=dynamic), raw_value: Atom('image(.png' type=dynamic) }
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('image(.png' type=dynamic) }
,-[$DIR/tests/recovery/bad-url-token/left-parenthesis/input.css:2:5]
2 | background: url(image(.png);
: ^^^^^^^^^^^^^^^

View File

@ -116,7 +116,6 @@
"BadUrl": {
"name": "url",
"raw_name": "url",
"value": "image'.png",
"raw_value": "image'.png"
}
}

View File

@ -115,7 +115,7 @@
: ^^^^^^^^^^^^^^^
`----
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('image'.png' type=dynamic), raw_value: Atom('image'.png' type=dynamic) }
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('image'.png' type=dynamic) }
,-[$DIR/tests/recovery/bad-url-token/single-quotes/input.css:2:5]
2 | background: url(image'.png);
: ^^^^^^^^^^^^^^^

View File

@ -116,7 +116,6 @@
"BadUrl": {
"name": "url",
"raw_name": "url",
"value": " ./image.jpg a ",
"raw_value": " ./image.jpg a "
}
}

View File

@ -111,7 +111,7 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^
`----
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom(' ./image.jpg a ' type=dynamic), raw_value: Atom(' ./image.jpg a ' type=dynamic) }
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom(' ./image.jpg a ' type=dynamic) }
,-[$DIR/tests/recovery/bad-url-token/whitespace-in-middle/input.css:2:5]
2 | background-image: url( ./image.jpg a );
: ^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -116,7 +116,6 @@
"BadUrl": {
"name": "url",
"raw_name": "url",
"value": "image.\n png",
"raw_value": "image.\n png"
}
}

View File

@ -119,8 +119,7 @@
3 | `-> png);
`----
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('image.
| png' type=dynamic), raw_value: Atom('image.
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('image.
| png' type=dynamic) }
,-[$DIR/tests/recovery/bad-url-token/whitespace/input.css:2:5]
2 | ,-> background: url(image.

View File

@ -116,7 +116,6 @@
"BadUrl": {
"name": "url",
"raw_name": "url",
"value": "\n /* test */\n \"test.png\"\n ",
"raw_value": "\n /* test */\n \"test.png\"\n "
}
}

View File

@ -131,10 +131,7 @@
5 | `-> );
`----
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('
| /* test */
| "test.png"
| ' type=dynamic), raw_value: Atom('
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('
| /* test */
| "test.png"
| ' type=dynamic) }

View File

@ -116,7 +116,6 @@
"BadUrl": {
"name": "url",
"raw_name": "url",
"value": "\n /* test */\n test.png\n ",
"raw_value": "\n /* test */\n test.png\n "
}
}

View File

@ -131,10 +131,7 @@
5 | `-> );
`----
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('
| /* test */
| test.png
| ' type=dynamic), raw_value: Atom('
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('
| /* test */
| test.png
| ' type=dynamic) }

View File

@ -134,8 +134,7 @@
},
"token": {
"BadString": {
"value": "tes",
"raw": "\"tes"
"raw_value": "\"tes"
}
}
},
@ -175,8 +174,7 @@
},
"token": {
"BadString": {
"value": ";",
"raw": "\";"
"raw_value": "\";"
}
}
}

View File

@ -136,7 +136,7 @@
: ^^^^
`----
x BadString { value: Atom('tes' type=inline), raw: Atom('"tes' type=inline) }
x BadString { raw_value: Atom('"tes' type=inline) }
,-[$DIR/tests/recovery/value/quotes/input.css:2:5]
2 | content: "tes
: ^^^^
@ -173,7 +173,7 @@
: ^^
`----
x BadString { value: Atom(';' type=inline), raw: Atom('";' type=inline) }
x BadString { raw_value: Atom('";' type=inline) }
,-[$DIR/tests/recovery/value/quotes/input.css:3:5]
3 | t";
: ^^

View File

@ -114,8 +114,7 @@
},
"token": {
"BadString": {
"value": "",
"raw": "\""
"raw_value": "\""
}
}
}

View File

@ -107,7 +107,7 @@
: ^
`----
x BadString { value: Atom('' type=static), raw: Atom('"' type=inline) }
x BadString { raw_value: Atom('"' type=inline) }
,-[$DIR/tests/recovery/value/string/newline/input.css:2:5]
2 | prop: "
: ^

View File

@ -151,7 +151,6 @@
"BadUrl": {
"name": "url",
"raw_name": "url",
"value": "var(--foo",
"raw_value": "var(--foo"
}
}
@ -202,9 +201,7 @@
"ctxt": 0
},
"value": "image.png<6E>",
"before": "",
"raw": "image.png\\999999",
"after": ""
"raw": "image.png\\999999"
},
"modifiers": null
}
@ -254,9 +251,7 @@
"ctxt": 0
},
"value": "image.png<6E>",
"before": "",
"raw": "image.png\\0",
"after": ""
"raw": "image.png\\0"
},
"modifiers": null
}
@ -306,9 +301,7 @@
"ctxt": 0
},
"value": "image.png<6E>",
"before": "",
"raw": "image.png\\D800",
"after": ""
"raw": "image.png\\D800"
},
"modifiers": null
}
@ -358,9 +351,7 @@
"ctxt": 0
},
"value": "image.png<6E>",
"before": "",
"raw": "image.png\\DFFF",
"after": ""
"raw": "image.png\\DFFF"
},
"modifiers": null
}
@ -410,9 +401,7 @@
"ctxt": 0
},
"value": "image.png<6E>",
"before": "",
"raw": "image.png\\11FFFF",
"after": ""
"raw": "image.png\\11FFFF"
},
"modifiers": null
}
@ -556,7 +545,6 @@
"BadUrl": {
"name": "url",
"raw_name": "url",
"value": "image.png param(var(--url",
"raw_value": "image.png param(var(--url"
}
}

View File

@ -189,7 +189,7 @@
: ^^^^^^^^^^^^^^
`----
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('var(--foo' type=dynamic), raw_value: Atom('var(--foo' type=dynamic) }
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('var(--foo' type=dynamic) }
,-[$DIR/tests/recovery/value/url/basic/input.css:3:5]
3 | background: url(var(--foo));
: ^^^^^^^^^^^^^^
@ -636,7 +636,7 @@
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`----
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('image.png param(var(--url' type=dynamic), raw_value: Atom('image.png param(var(--url' type=dynamic) }
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('image.png param(var(--url' type=dynamic) }
,-[$DIR/tests/recovery/value/url/basic/input.css:13:5]
13 | background: url(image.png param(var(--url)));
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -130,9 +130,7 @@
"ctxt": 0
},
"value": "foo.png",
"before": "",
"raw": "foo.png",
"after": ""
"raw": "foo.png"
},
"modifiers": null
}

View File

@ -116,7 +116,6 @@
"BadUrl": {
"name": "url",
"raw_name": "url",
"value": "test\\);\n}",
"raw_value": "test\\);\n}"
}
}

View File

@ -111,8 +111,7 @@
3 | `-> }
`----
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), value: Atom('test\);
| }' type=dynamic), raw_value: Atom('test\);
x BadUrl { name: Atom('url' type=static), raw_name: Atom('url' type=static), raw_value: Atom('test\);
| }' type=dynamic) }
,-[$DIR/tests/recovery/value/url/parenthesis/input.css:2:5]
2 | ,-> background: url(test\);

View File

@ -288,9 +288,7 @@ define!({
pub struct UrlValueRaw {
pub span: Span,
pub value: JsWord,
pub before: Option<JsWord>,
pub raw: Option<JsWord>,
pub after: Option<JsWord>,
}
pub enum UrlModifier {