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


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #20332 (github issue number if applicable).
  • 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

highfive commented Mar 20, 2018

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

highfive commented Mar 20, 2018

warning Warning warning

  • These commits modify style code, but no tests are modified. Please consider adding a test!
@kwonoj kwonoj force-pushed the kwonoj:refactor-counter-style branch from e8c8862 to 9790155 Mar 21, 2018
@emilio
emilio approved these changes Mar 21, 2018
Copy link
Member

emilio left a comment

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)

This comment has been minimized.

@emilio

emilio Mar 21, 2018

Member

This is wrong, this needs to be:

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

instead.

This comment has been minimized.

@emilio

emilio Mar 21, 2018

Member

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

This comment has been minimized.

@emilio

emilio Mar 21, 2018

Member

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,

This comment has been minimized.

@emilio

emilio Mar 21, 2018

Member

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

This comment has been minimized.

@emilio

emilio Mar 21, 2018

Member

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

Copy link
Member

emilio left a comment

Err, I meant to request changes above :)

@kwonoj kwonoj force-pushed the kwonoj:refactor-counter-style branch from 9790155 to 6675e16 Mar 21, 2018
@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.

@kwonoj kwonoj force-pushed the kwonoj:refactor-counter-style branch from 6675e16 to 3d6a625 Mar 21, 2018
@emilio
emilio approved these changes Mar 21, 2018
Copy link
Member

emilio left a comment

Looks great! Mind sqashing the commits?

@emilio
Copy link
Member

emilio commented Mar 21, 2018

*squashing, that is :)

@kwonoj kwonoj force-pushed the kwonoj:refactor-counter-style branch from 3d6a625 to c8592ea Mar 21, 2018
@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

bors-servo commented Mar 21, 2018

📌 Commit c8592ea has been approved by emilio

@bors-servo
Copy link
Contributor

bors-servo commented Mar 21, 2018

Testing commit c8592ea with merge 4e26212...

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

bors-servo commented Mar 21, 2018

💔 Test failed - linux-rel-css

@jdm
Copy link
Member

jdm commented Mar 22, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Mar 22, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Mar 22, 2018

@bors-servo bors-servo merged commit c8592ea into servo:master Mar 22, 2018
3 checks passed
3 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@kwonoj kwonoj deleted the kwonoj:refactor-counter-style branch Mar 22, 2018
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.

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