New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Parser::skip_whitespace in a few places to make Parser::try rewind less #18171
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, r=me when it's ready.
@@ -1552,6 +1552,9 @@ impl PropertyDeclaration { | |||
assert!(declarations.is_empty()); | |||
match id { | |||
PropertyId::Custom(name) => { | |||
// FIXME: fully implement https://github.com/w3c/csswg-drafts/issues/774 | |||
// before adding skip_whitespace here. | |||
// This probably affects some test results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would also imply we should start adding spaces after the colon for a custom property declaration, perhaps worth leaving a note near the relevant code in declaration_block.rs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. I assume tests will catch this.
results.push(item); | ||
loop { | ||
input.skip_whitespace(); // Unnecessary for correctness, but may help try() rewind less. | ||
if let Ok(item) = input.try(&mut parse_one) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'd just use match
, but no big deal.
@bors-servo r=emilio cssparser 0.19.3 is in autoland, with dtoa 0.4.2 without the unnecessary PNG file. |
📌 Commit 9dbeabf has been approved by |
Use Parser::skip_whitespace in a few places to make Parser::try rewind less **Do not merge yet.** This pulls in unrelated cssparser changes which add a dependency to `dota`, and we’d like to resolve dtolnay/dtoa#9 before landing dtoa in mozilla-central. Also, the dependency change may require manually revendoring in mozilla-central. Gecko’s CSS parsing microbenchmarks before: ``` 43.437 ± 0.391 ms Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench 29.244 ± 0.042 ms Stylo.Gecko_nsCSSParser_ParseSheet_Bench 281.884 ± 0.028 ms Stylo.Servo_DeclarationBlock_SetPropertyById_Bench 426.242 ± 0.008 ms Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench ``` After: ``` 29.779 ± 0.254 ms Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench 28.841 ± 0.031 ms Stylo.Gecko_nsCSSParser_ParseSheet_Bench 296.240 ± 4.744 ms Stylo.Servo_DeclarationBlock_SetPropertyById_Bench 293.855 ± 4.304 ms Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench ``` <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18171) <!-- Reviewable:end -->
@bors-servo r- It seems there are multiple failures caused from 0.19.3 which is not fixed by 0.19.4. I suppose this PR doesn't fix them either. In that case, we probably shouldn't land it at this moment. |
💔 Test failed - linux-rel-wpt |
☔ The latest upstream changes (presumably #18201) made this pull request unmergeable. Please resolve the merge conflicts. |
9dbeabf
to
45b8cd0
Compare
@bors-servo try |
Use Parser::skip_whitespace in a few places to make Parser::try rewind less **Do not merge yet.** This pulls in unrelated cssparser changes which add a dependency to `dota`, and we’d like to resolve dtolnay/dtoa#9 before landing dtoa in mozilla-central. Also, the dependency change may require manually revendoring in mozilla-central. Gecko’s CSS parsing microbenchmarks before: ``` 43.437 ± 0.391 ms Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench 29.244 ± 0.042 ms Stylo.Gecko_nsCSSParser_ParseSheet_Bench 281.884 ± 0.028 ms Stylo.Servo_DeclarationBlock_SetPropertyById_Bench 426.242 ± 0.008 ms Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench ``` After: ``` 29.779 ± 0.254 ms Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench 28.841 ± 0.031 ms Stylo.Gecko_nsCSSParser_ParseSheet_Bench 296.240 ± 4.744 ms Stylo.Servo_DeclarationBlock_SetPropertyById_Bench 293.855 ± 4.304 ms Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench ``` <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18171) <!-- Reviewable:end -->
💔 Test failed - mac-rel-css2 |
This fixes (at least some of) the test failures at servo/servo#18171
45b8cd0
to
13035c1
Compare
@bors-servo try |
Use Parser::skip_whitespace in a few places to make Parser::try rewind less **Do not merge yet.** This pulls in unrelated cssparser changes which add a dependency to `dota`, and we’d like to resolve dtolnay/dtoa#9 before landing dtoa in mozilla-central. Also, the dependency change may require manually revendoring in mozilla-central. Gecko’s CSS parsing microbenchmarks before: ``` 43.437 ± 0.391 ms Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench 29.244 ± 0.042 ms Stylo.Gecko_nsCSSParser_ParseSheet_Bench 281.884 ± 0.028 ms Stylo.Servo_DeclarationBlock_SetPropertyById_Bench 426.242 ± 0.008 ms Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench ``` After: ``` 29.779 ± 0.254 ms Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench 28.841 ± 0.031 ms Stylo.Gecko_nsCSSParser_ParseSheet_Bench 296.240 ± 4.744 ms Stylo.Servo_DeclarationBlock_SetPropertyById_Bench 293.855 ± 4.304 ms Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench ``` <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18171) <!-- Reviewable:end -->
💔 Test failed - mac-rel-wpt3 |
Fix interaction of skip_whitespace and nested blocks This fixes (at least some of) the test failures at servo/servo#18171 In code like this: ```css unsupported selector ! { stuff } valid selector { color: green } ``` `rules_and_declarations::parse_qualified_rule` would leave the parser just after the first `{` with `Parser::at_start_of == Some(BlockType::CurlyBracket)`. The latter means that, unless `Parser::parse_nested_block` is called, the parser needs to skip over this block until the matching `}` before doing anything else. This PR makes `Parser::skip_whitespace` and `Parser::skip_cdc_and_cdo` (both added recently in #181) take care of `Parser::at_start_of` correctly the same way `Parser::next` does. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-cssparser/185) <!-- Reviewable:end -->
Fix interaction of skip_whitespace and nested blocks This fixes (at least some of) the test failures at servo/servo#18171 In code like this: ```css unsupported selector ! { stuff } valid selector { color: green } ``` `rules_and_declarations::parse_qualified_rule` would leave the parser just after the first `{` with `Parser::at_start_of == Some(BlockType::CurlyBracket)`. The latter means that, unless `Parser::parse_nested_block` is called, the parser needs to skip over this block until the matching `}` before doing anything else. This PR makes `Parser::skip_whitespace` and `Parser::skip_cdc_and_cdo` (both added recently in #181) take care of `Parser::at_start_of` correctly the same way `Parser::next` does. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-cssparser/185) <!-- Reviewable:end -->
💔 Test failed - linux-rel-wpt |
Legit failures:
|
…d less. Gecko’s CSS parsing microbenchmarks before: ``` 43.437 ± 0.391 ms Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench 29.244 ± 0.042 ms Stylo.Gecko_nsCSSParser_ParseSheet_Bench 281.884 ± 0.028 ms Stylo.Servo_DeclarationBlock_SetPropertyById_Bench 426.242 ± 0.008 ms Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench ``` After: ``` 29.779 ± 0.254 ms Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench 28.841 ± 0.031 ms Stylo.Gecko_nsCSSParser_ParseSheet_Bench 296.240 ± 4.744 ms Stylo.Servo_DeclarationBlock_SetPropertyById_Bench 293.855 ± 4.304 ms Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench ```
4cd6ec7
to
dc5dfaf
Compare
@bors-servo r=emilio p=1 |
📌 Commit dc5dfaf has been approved by |
💡 This pull request was already approved, no need to approve it again.
|
📌 Commit dc5dfaf has been approved by |
Use Parser::skip_whitespace in a few places to make Parser::try rewind less **Do not merge yet.** This pulls in unrelated cssparser changes which add a dependency to `dota`, and we’d like to resolve dtolnay/dtoa#9 before landing dtoa in mozilla-central. Also, the dependency change may require manually revendoring in mozilla-central. Gecko’s CSS parsing microbenchmarks before: ``` 43.437 ± 0.391 ms Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench 29.244 ± 0.042 ms Stylo.Gecko_nsCSSParser_ParseSheet_Bench 281.884 ± 0.028 ms Stylo.Servo_DeclarationBlock_SetPropertyById_Bench 426.242 ± 0.008 ms Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench ``` After: ``` 29.779 ± 0.254 ms Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench 28.841 ± 0.031 ms Stylo.Gecko_nsCSSParser_ParseSheet_Bench 296.240 ± 4.744 ms Stylo.Servo_DeclarationBlock_SetPropertyById_Bench 293.855 ± 4.304 ms Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench ``` <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18171) <!-- Reviewable:end -->
💔 Test failed - mac-rel-wpt2 |
@bors-servo retry
|
Use Parser::skip_whitespace in a few places to make Parser::try rewind less **Do not merge yet.** This pulls in unrelated cssparser changes which add a dependency to `dota`, and we’d like to resolve dtolnay/dtoa#9 before landing dtoa in mozilla-central. Also, the dependency change may require manually revendoring in mozilla-central. Gecko’s CSS parsing microbenchmarks before: ``` 43.437 ± 0.391 ms Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench 29.244 ± 0.042 ms Stylo.Gecko_nsCSSParser_ParseSheet_Bench 281.884 ± 0.028 ms Stylo.Servo_DeclarationBlock_SetPropertyById_Bench 426.242 ± 0.008 ms Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench ``` After: ``` 29.779 ± 0.254 ms Stylo.Servo_StyleSheet_FromUTF8Bytes_Bench 28.841 ± 0.031 ms Stylo.Gecko_nsCSSParser_ParseSheet_Bench 296.240 ± 4.744 ms Stylo.Servo_DeclarationBlock_SetPropertyById_Bench 293.855 ± 4.304 ms Stylo.Servo_DeclarationBlock_SetPropertyById_WithInitialSpace_Bench ``` <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18171) <!-- Reviewable:end -->
☀️ Test successful - android, arm32, arm64, linux-dev, linux-rel-css, linux-rel-wpt, mac-dev-unit, mac-rel-css1, mac-rel-css2, mac-rel-wpt1, mac-rel-wpt2, mac-rel-wpt3, mac-rel-wpt4, windows-msvc-dev |
Do not merge yet. This pulls in unrelated cssparser changes which add a dependency to
dota
, and we’d like to resolve dtolnay/dtoa#9 before landing dtoa in mozilla-central. Also, the dependency change may require manually revendoring in mozilla-central.Gecko’s CSS parsing microbenchmarks before:
After:
This change is