Skip to content
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

Merged
merged 1 commit into from Aug 26, 2017

Conversation

SimonSapin
Copy link
Member

@SimonSapin SimonSapin commented Aug 21, 2017

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

This change is Reviewable

Copy link
Member

@emilio emilio left a 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.
Copy link
Member

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.

Copy link
Member Author

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) {
Copy link
Member

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.

@SimonSapin
Copy link
Member Author

@bors-servo r=emilio

cssparser 0.19.3 is in autoland, with dtoa 0.4.2 without the unnecessary PNG file.

@bors-servo
Copy link
Contributor

📌 Commit 9dbeabf has been approved by emilio

@highfive highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Aug 23, 2017
@bors-servo
Copy link
Contributor

⌛ Testing commit 9dbeabf with merge 93d2073...

bors-servo pushed a commit that referenced this pull request Aug 23, 2017
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 -->
@upsuper
Copy link
Contributor

upsuper commented Aug 23, 2017

@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.

https://treeherder.mozilla.org/#/jobs?repo=autoland&revision=a203d42085eae79a6ef106a178a8df4a9e36478e&selectedJob=125065270

@bors-servo
Copy link
Contributor

💔 Test failed - linux-rel-wpt

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Aug 23, 2017
@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #18201) made this pull request unmergeable. Please resolve the merge conflicts.

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Aug 23, 2017
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Aug 23, 2017
@SimonSapin
Copy link
Member Author

@bors-servo try

@bors-servo
Copy link
Contributor

⌛ Trying commit 45b8cd0 with merge c04c77e...

bors-servo pushed a commit that referenced this pull request Aug 23, 2017
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
Copy link
Contributor

💔 Test failed - mac-rel-css2

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Aug 23, 2017
SimonSapin added a commit to servo/rust-cssparser that referenced this pull request Aug 23, 2017
This fixes (at least some of) the test failures at servo/servo#18171
@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label Aug 23, 2017
@SimonSapin
Copy link
Member Author

@bors-servo try

@bors-servo
Copy link
Contributor

⌛ Trying commit 13035c1 with merge 0623e31...

bors-servo pushed a commit that referenced this pull request Aug 23, 2017
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
Copy link
Contributor

💔 Test failed - mac-rel-wpt3

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Aug 23, 2017
bors-servo pushed a commit to servo/rust-cssparser that referenced this pull request Aug 25, 2017
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 -->
bors-servo pushed a commit to servo/rust-cssparser that referenced this pull request Aug 25, 2017
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 -->
@bors-servo
Copy link
Contributor

💔 Test failed - linux-rel-wpt

@highfive highfive added the S-tests-failed The changes caused existing tests to fail. label Aug 25, 2017
@SimonSapin
Copy link
Member Author

Legit failures:

  ▶ Unexpected subtest result in /cssom/serialize-variable-reference.html:
  │ FAIL [expected PASS] Shorthand with variable preserves original serialization: with withespace
  │   → assert_equals: expected "font: var(--a);" but got "font:var(--a);"
  │ 
  │ @http://web-platform.test:8000/cssom/serialize-variable-reference.html:20:9
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1406:20
  │ test@http://web-platform.test:8000/resources/testharness.js:497:9
  └ @http://web-platform.test:8000/cssom/serialize-variable-reference.html:17:5

  ▶ Unexpected subtest result in /cssom/serialize-variable-reference.html:
  │ FAIL [expected PASS] Longhand with variable preserves original serialization: with withespace
  │   → assert_equals: expected "font-size: var(--a);" but got "font-size:var(--a);"
  │ 
  │ @http://web-platform.test:8000/cssom/serialize-variable-reference.html:14:9
  │ Test.prototype.step@http://web-platform.test:8000/resources/testharness.js:1406:20
  │ test@http://web-platform.test:8000/resources/testharness.js:497:9
  └ @http://web-platform.test:8000/cssom/serialize-variable-reference.html:11:5

…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
```
@highfive highfive removed the S-tests-failed The changes caused existing tests to fail. label Aug 25, 2017
@SimonSapin
Copy link
Member Author

SimonSapin commented Aug 25, 2017

@bors-servo r=emilio p=1

@bors-servo
Copy link
Contributor

📌 Commit dc5dfaf has been approved by emilio

@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-awaiting-review There is new code that needs to be reviewed. S-needs-rebase There are merge conflict errors. labels Aug 25, 2017
@bors-servo
Copy link
Contributor

💡 This pull request was already approved, no need to approve it again.

@bors-servo
Copy link
Contributor

📌 Commit dc5dfaf has been approved by emilio

@bors-servo
Copy link
Contributor

⌛ Testing commit dc5dfaf with merge 0193b2c...

bors-servo pushed a commit that referenced this pull request Aug 26, 2017
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
Copy link
Contributor

💔 Test failed - mac-rel-wpt2

@highfive highfive added S-tests-failed The changes caused existing tests to fail. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Aug 26, 2017
@SimonSapin
Copy link
Member Author

@bors-servo retry

exceptions.Exception: Actual commit (f3f80c0dca7408863cfa1a6276862f0927b7947a) differs from requested commit (0193b2c2ecb79edee62d1b06b0f1f2b363e009b7)

@bors-servo
Copy link
Contributor

⌛ Testing commit dc5dfaf with merge 8812422...

bors-servo pushed a commit that referenced this pull request Aug 26, 2017
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 -->
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Aug 26, 2017
@bors-servo
Copy link
Contributor

☀️ 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
Approved by: emilio
Pushing 8812422 to master...

@bors-servo bors-servo merged commit dc5dfaf into master Aug 26, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Aug 26, 2017
@SimonSapin SimonSapin deleted the skip_whitespace branch August 26, 2017 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants