Skip to content

Commit d28fef9

Browse files
committed
Bug 1563892 - Update cssparser to fix correctness issue with serialization. r=heycam
This issue was also exposed via CSS variables, and I've added a test for that since it's how it was originally found in bug 1498188. See w3c/csswg-drafts#4088 and servo/rust-cssparser#251 Differential Revision: https://phabricator.services.mozilla.com/D37148 --HG-- extra : moz-landing-system : lando
1 parent 70b2a0c commit d28fef9

File tree

8 files changed

+39
-16
lines changed

8 files changed

+39
-16
lines changed

Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testing/web-platform/tests/css/css-variables/variable-substitution-basic.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
expectedValue:"0px 0px",
3939
style:"--gap: 20;border-spacing: var(--gap)px;"
4040
},
41+
{
42+
testName:"You can't build up a single token where part of it is provided by a variable (percentages)",
43+
propertyName:"text-indent",
44+
expectedValue:"0px",
45+
style:"--v: 20;text-indent: var(--v)%;"
46+
},
4147
{
4248
testName:"Multiple variable references in a single property",
4349
propertyName:"border-spacing",
@@ -115,4 +121,4 @@
115121
});
116122
</script>
117123
</body>
118-
</html>
124+
</html>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"files":{"Cargo.toml":"26e11f3e55baf0de8784dc3ec88771411ceae587c64e162fed3939b87c3cc591","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"b9d6c5dc56ccc267db9e0e2389061dc2524daefa4baed88b36c98efc7a51c2a9","build.rs":"08e4a99d5184b2f22ab93bc0a024fec18dbd8fd38b9db638f19d4defede858ee","build/match_byte.rs":"e8537833ff1599a1bdbd0167f6295af7bd21e42024f32b982af32d58c156685c","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/color.rs":"8d3017ba8d644172908bd80d35e9be1081db477d2e0b0ea13971e29a466d451f","src/cow_rc_str.rs":"89b5dff5cf80eef3fcff0c11799e54a978d02d8b8963a621fbb999d35e7c03a3","src/from_bytes.rs":"b1cf15c4e975523fef46b575598737a39f3c63e5ce0b2bfd6ec627c69c6ea54a","src/lib.rs":"98b28ca7c72b8d20b3d76ae5b841be87bcadfc89e433ecc95fcf37aa15731442","src/macros.rs":"a50a0a7afa43e099dc008e54956e4c1fdfba2e9795d006b22e9eb45065fed61e","src/nth.rs":"a9d5fa0bd2c3ae7c48c851b9f5508ebdb07affdf5d0737bb8d85a7befab2ef9c","src/parser.rs":"fe2eb2be084923bf362de4b95c029beb21f172ad972a6452c400f640b43a583e","src/rules_and_declarations.rs":"712a5e893169e715bbcd18aac87a18ae728dc6bb922e79b237d34ce7a4548fcf","src/serializer.rs":"151305364cb1f20ea2dc0b3ebfbb77937e616ef4441d5dd3c9abda232f79a7af","src/size_of_tests.rs":"a628cacc876f240ac1bb9e287cdae293bffc4b86d45d9307e4fc2f822e8f3e84","src/tests.rs":"bf97071b691c0b0c932af5813e876142ce707ba57774742dbe60889b1dc54069","src/tokenizer.rs":"0450c38d140382161408a8fca5aac343f5a9405603234095dccd93f680831cb7","src/unicode_range.rs":"c4655c817db0dabb1d55669ac61a56ecf7f6a6c4353cf5b539b13bea6511c3dd"},"package":"e06795910fc2f585a75bdc9690fbcc51e83519f07b6eb981db43944643c04933"}
1+
{"files":{"Cargo.toml":"435243ec516989de48ba8715497f53c86efdd24b776e64d3667c3c9630f74695","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","README.md":"a533b45a9c43083c6a6000a9c99a1acfed123d6430b232352ae02f1144a09f12","build.rs":"08e4a99d5184b2f22ab93bc0a024fec18dbd8fd38b9db638f19d4defede858ee","build/match_byte.rs":"e8537833ff1599a1bdbd0167f6295af7bd21e42024f32b982af32d58c156685c","docs/404.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","docs/index.html":"025861f76f8d1f6d67c20ab624c6e418f4f824385e2dd8ad8732c4ea563c6a2e","src/color.rs":"8d3017ba8d644172908bd80d35e9be1081db477d2e0b0ea13971e29a466d451f","src/cow_rc_str.rs":"89b5dff5cf80eef3fcff0c11799e54a978d02d8b8963a621fbb999d35e7c03a3","src/from_bytes.rs":"b1cf15c4e975523fef46b575598737a39f3c63e5ce0b2bfd6ec627c69c6ea54a","src/lib.rs":"98b28ca7c72b8d20b3d76ae5b841be87bcadfc89e433ecc95fcf37aa15731442","src/macros.rs":"a50a0a7afa43e099dc008e54956e4c1fdfba2e9795d006b22e9eb45065fed61e","src/nth.rs":"a9d5fa0bd2c3ae7c48c851b9f5508ebdb07affdf5d0737bb8d85a7befab2ef9c","src/parser.rs":"fe2eb2be084923bf362de4b95c029beb21f172ad972a6452c400f640b43a583e","src/rules_and_declarations.rs":"b0288def4392faad529296ea7850895470dce8322a712056c5232699688df67a","src/serializer.rs":"4f47d46d0d056baa1dbbef3168c5d400645062eaff5dd637b0172bd2af784ed4","src/size_of_tests.rs":"a628cacc876f240ac1bb9e287cdae293bffc4b86d45d9307e4fc2f822e8f3e84","src/tests.rs":"bf97071b691c0b0c932af5813e876142ce707ba57774742dbe60889b1dc54069","src/tokenizer.rs":"483c6629a4b057d56be6aada97689aa03a914702d4e78618fb095b4ee5b6f90d","src/unicode_range.rs":"c4655c817db0dabb1d55669ac61a56ecf7f6a6c4353cf5b539b13bea6511c3dd"},"package":"a921abc45ea75c2c817d951caeda31b94539d09a6b5e8d58a857b3b35c9c3894"}

third_party/rust/cssparser/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
[package]
1414
name = "cssparser"
15-
version = "0.25.5"
15+
version = "0.25.7"
1616
authors = ["Simon Sapin <[email protected]>"]
1717
build = "build.rs"
1818
exclude = ["src/css-parsing-tests/**", "src/big-data-url.css"]

third_party/rust/cssparser/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
rust-cssparser
22
==============
33

4-
[![Build Status](https://travis-ci.org/servo/rust-cssparser.svg?branch=travis)](https://travis-ci.org/servo/rust-cssparser)
4+
[![Build Status](https://travis-ci.com/servo/rust-cssparser.svg)](https://travis-ci.com/servo/rust-cssparser)
55

66
[Documentation](https://docs.rs/cssparser/)
77

third_party/rust/cssparser/src/rules_and_declarations.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub trait DeclarationParser<'i> {
7777
///
7878
/// Default implementations that reject all at-rules are provided,
7979
/// so that `impl AtRuleParser<(), ()> for ... {}` can be used
80-
/// for using `DeclarationListParser` to parse a declartions list with only qualified rules.
80+
/// for using `DeclarationListParser` to parse a declarations list with only qualified rules.
8181
pub trait AtRuleParser<'i> {
8282
/// The intermediate representation of prelude of an at-rule without block;
8383
type PreludeNoBlock;

third_party/rust/cssparser/src/serializer.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,9 @@ impl TokenSerializationType {
423423
/// so that they are not re-parsed as a single token.
424424
///
425425
/// See https://drafts.csswg.org/css-syntax/#serialization
426+
///
427+
/// See https://github.com/w3c/csswg-drafts/issues/4088 for the
428+
/// `DelimPercent` bits.
426429
pub fn needs_separator_when_before(self, other: TokenSerializationType) -> bool {
427430
use self::TokenSerializationTypeVariants::*;
428431
match self.0 {
@@ -442,17 +445,21 @@ impl TokenSerializationType {
442445
other.0,
443446
Ident | Function | UrlOrBadUrl | DelimMinus | Number | Percentage | Dimension | CDC
444447
),
445-
DelimHash | DelimMinus | Number => matches!(
448+
DelimHash | DelimMinus => matches!(
446449
other.0,
447450
Ident | Function | UrlOrBadUrl | DelimMinus | Number | Percentage | Dimension
448451
),
452+
Number => matches!(
453+
other.0,
454+
Ident | Function | UrlOrBadUrl | DelimMinus | Number | Percentage | DelimPercent | Dimension
455+
),
449456
DelimAt => matches!(other.0, Ident | Function | UrlOrBadUrl | DelimMinus),
450457
DelimDotOrPlus => matches!(other.0, Number | Percentage | Dimension),
451458
DelimAssorted | DelimAsterisk => matches!(other.0, DelimEquals),
452459
DelimBar => matches!(other.0, DelimEquals | DelimBar | DashMatch),
453460
DelimSlash => matches!(other.0, DelimAsterisk | SubstringMatch),
454461
Nothing | WhiteSpace | Percentage | UrlOrBadUrl | Function | CDC | OpenParen
455-
| DashMatch | SubstringMatch | DelimQuestion | DelimEquals | Other => false,
462+
| DashMatch | SubstringMatch | DelimQuestion | DelimEquals | DelimPercent | Other => false,
456463
}
457464
}
458465
}
@@ -482,6 +489,7 @@ enum TokenSerializationTypeVariants {
482489
DelimBar, // '|'
483490
DelimSlash, // '/'
484491
DelimAsterisk, // '*'
492+
DelimPercent, // '%'
485493
Other, // anything else
486494
}
487495

@@ -502,6 +510,7 @@ impl<'a> Token<'a> {
502510
Token::Delim('-') => DelimMinus,
503511
Token::Delim('?') => DelimQuestion,
504512
Token::Delim('$') | Token::Delim('^') | Token::Delim('~') => DelimAssorted,
513+
Token::Delim('%') => DelimPercent,
505514
Token::Delim('=') => DelimEquals,
506515
Token::Delim('|') => DelimBar,
507516
Token::Delim('/') => DelimSlash,

third_party/rust/cssparser/src/tokenizer.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,14 @@ impl<'a> Tokenizer<'a> {
520520
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug, Clone, Copy)]
521521
pub struct SourcePosition(pub(crate) usize);
522522

523+
impl SourcePosition {
524+
/// Returns the current byte index in the original input.
525+
#[inline]
526+
pub fn byte_index(&self) -> usize {
527+
self.0
528+
}
529+
}
530+
523531
/// The line and column number for a given position within the input.
524532
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
525533
pub struct SourceLocation {

0 commit comments

Comments
 (0)