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

@emilio
emilio approved these changes Aug 21, 2017
Copy link
Member

emilio left a comment

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.

This comment has been minimized.

@emilio

emilio Aug 21, 2017

Member

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.

This comment has been minimized.

@SimonSapin

SimonSapin Aug 21, 2017

Author Member

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) {

This comment has been minimized.

@emilio

emilio Aug 21, 2017

Member

nit: I'd just use match, but no big deal.

@SimonSapin
Copy link
Member Author

SimonSapin commented Aug 23, 2017

@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

bors-servo commented Aug 23, 2017

📌 Commit 9dbeabf has been approved by emilio

@bors-servo
Copy link
Contributor

bors-servo commented Aug 23, 2017

Testing commit 9dbeabf with merge 93d2073...

bors-servo added 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
Member

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

bors-servo commented Aug 23, 2017

💔 Test failed - linux-rel-wpt

@bors-servo
Copy link
Contributor

bors-servo commented Aug 23, 2017

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

@SimonSapin SimonSapin force-pushed the skip_whitespace branch from 9dbeabf to 45b8cd0 Aug 23, 2017
@SimonSapin
Copy link
Member Author

SimonSapin commented Aug 23, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Aug 23, 2017

Trying commit 45b8cd0 with merge c04c77e...

bors-servo added 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

bors-servo commented Aug 23, 2017

💔 Test failed - mac-rel-css2

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
@SimonSapin SimonSapin force-pushed the skip_whitespace branch from 45b8cd0 to 13035c1 Aug 23, 2017
@SimonSapin
Copy link
Member Author

SimonSapin commented Aug 23, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Aug 23, 2017

Trying commit 13035c1 with merge 0623e31...

bors-servo added 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

bors-servo commented Aug 23, 2017

💔 Test failed - mac-rel-wpt3

bors-servo added 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 added 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

bors-servo commented Aug 25, 2017

💔 Test failed - linux-rel-wpt

@SimonSapin
Copy link
Member Author

SimonSapin commented Aug 25, 2017

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
```
@SimonSapin SimonSapin force-pushed the skip_whitespace branch from 4cd6ec7 to dc5dfaf Aug 25, 2017
@SimonSapin
Copy link
Member Author

SimonSapin commented Aug 25, 2017

@bors-servo r=emilio p=1

@bors-servo
Copy link
Contributor

bors-servo commented Aug 25, 2017

📌 Commit dc5dfaf has been approved by emilio

@bors-servo
Copy link
Contributor

bors-servo commented Aug 25, 2017

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

  • There's another pull request that is currently being tested, blocking this pull request: #18244
@bors-servo
Copy link
Contributor

bors-servo commented Aug 25, 2017

📌 Commit dc5dfaf has been approved by emilio

@bors-servo
Copy link
Contributor

bors-servo commented Aug 26, 2017

Testing commit dc5dfaf with merge 0193b2c...

bors-servo added 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

bors-servo commented Aug 26, 2017

💔 Test failed - mac-rel-wpt2

@SimonSapin
Copy link
Member Author

SimonSapin commented Aug 26, 2017

@bors-servo retry

exceptions.Exception: Actual commit (f3f80c0dca7408863cfa1a6276862f0927b7947a) differs from requested commit (0193b2c2ecb79edee62d1b06b0f1f2b363e009b7)
@bors-servo
Copy link
Contributor

bors-servo commented Aug 26, 2017

Testing commit dc5dfaf with merge 8812422...

bors-servo added 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

bors-servo commented Aug 26, 2017

@bors-servo bors-servo merged commit dc5dfaf into master Aug 26, 2017
3 of 4 checks passed
3 of 4 checks passed
dependency-ci Checking Dependencies
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@bors-servo bors-servo mentioned this pull request Aug 26, 2017
2 of 12 tasks complete
@SimonSapin SimonSapin deleted the skip_whitespace branch Aug 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants
You can’t perform that action at this time.