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

refactor(counter_style): parse int via parse_non_negative #20368

Merged
merged 1 commit into from Mar 22, 2018

Conversation

kwonoj
Copy link
Contributor

@kwonoj kwonoj commented Mar 20, 2018

Relates to #20332.

This PR intends to refactor counter_style to use parse_non_negative where applicable, mostly which uses expect_integer currently. Change still grabs value from parsed result then assign it into each struct as needed and does not change definition of struct (i.e AdditiveTuple) itself.


  • There are tests for these changes OR
  • These changes do not require tests because _____
  • This PR has locally built & ran unit test on macOS.

This change is Reviewable

@highfive
Copy link

Heads up! This PR modifies the following files:

  • @bholley: components/style/counter_style/mod.rs
  • @canaltinova: components/style/counter_style/mod.rs
  • @emilio: components/style/counter_style/mod.rs

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Mar 20, 2018
@highfive
Copy link

warning Warning warning

  • These commits modify style code, but no tests are modified. Please consider adding a test!

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.

Thanks for working on this!

try_match_ident_ignore_ascii_case! { input,
"cyclic" => Ok(System::Cyclic),
"numeric" => Ok(System::Numeric),
"alphabetic" => Ok(System::Alphabetic),
"symbolic" => Ok(System::Symbolic),
"additive" => Ok(System::Additive),
"fixed" => {
let first_symbol_value = input.try(|i| i.expect_integer()).ok();
let first_symbol_value = Integer::parse_non_negative(context, input)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong, this needs to be:

let first_symbol_value = input.try(|i| Integer::parse_non_negative(context, i)).ok();

instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And first_symbol_value needs to start taking an Integer instead of an i32.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err, and this doesn't really need to be non-negative, so should be:

let first_symbol_value = input.try(|i| Integer::parse(context, i)).ok();

let symbol = symbol.or_else(|_| Symbol::parse(context, input))?;
Ok(AdditiveTuple {
weight: weight as u32,
weight: weight.value() as u32,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weight should become an Integer.

let pad_with = pad_with.or_else(|_| Symbol::parse(context, input))?;
Ok(Pad(min_length as u32, pad_with))
Ok(Pad(min_length.value() as u32, pad_with))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first member of Pad should become an Integer, not a u32.

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.

Err, I meant to request changes above :)

@kwonoj
Copy link
Contributor Author

kwonoj commented Mar 21, 2018

@emilio appreciate for review, tried to update as suggested. Wasn't entirely sure if I could update types to take Integer directly. I tried to update them along with rules in gecko, but might be still incorrect. Let me know anytime to followup further.

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 great! Mind sqashing the commits?

@emilio
Copy link
Member

emilio commented Mar 21, 2018

*squashing, that is :)

@kwonoj
Copy link
Contributor Author

kwonoj commented Mar 21, 2018

@emilio sure, rebased to master and squashed into single commit.

@emilio
Copy link
Member

emilio commented Mar 21, 2018

@bors-servo r+

Thank you!

@bors-servo
Copy link
Contributor

📌 Commit c8592ea has been approved by emilio

@highfive highfive assigned emilio and unassigned asajeffrey Mar 21, 2018
@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. labels Mar 21, 2018
@bors-servo
Copy link
Contributor

⌛ Testing commit c8592ea with merge 4e26212...

bors-servo pushed a commit that referenced this pull request Mar 21, 2018
refactor(counter_style): parse int via parse_non_negative

<!-- Please describe your changes on the following line: -->
Relates to #20332.

This PR intends to refactor `counter_style` to use `parse_non_negative` where applicable, mostly which uses `expect_integer` currently. Change still grabs value from parsed result then assign it into each struct as needed and does not change definition of struct (i.e `AdditiveTuple`) itself.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #20332 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
- This PR has locally built & ran unit test on macOS.

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/20368)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

💔 Test failed - linux-rel-css

@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 Mar 21, 2018
@jdm
Copy link
Member

jdm commented Mar 22, 2018

@bors-servo retry
#13479

@bors-servo
Copy link
Contributor

⚡ Previous build results for android, arm32, arm64, linux-dev, 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 are reusable. Rebuilding only linux-rel-css...

@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 4e26212 to master...

@bors-servo bors-servo merged commit c8592ea into servo:master Mar 22, 2018
@kwonoj kwonoj deleted the refactor-counter-style branch March 22, 2018 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-tests-failed The changes caused existing tests to fail.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A bunch of other @counter-style code should use Integer::parse instead of expect_integer
6 participants