Skip to content

style: Move font-weight outside of mako - #19086

Merged
bors-servo merged 1 commit into
servo:masterfrom
cbrewster:font_weight_nomako
Nov 1, 2017
Merged

bors-servo merged 1 commit into
servo:masterfrom
cbrewster:font_weight_nomako

Conversation

@cbrewster

@cbrewster cbrewster commented Nov 1, 2017 •

Copy link
Copy Markdown
Contributor

  • There are tests for these changes OR
  • These changes do not require tests because refactoring

This change is Reviewable

@highfive

highfive commented Nov 1, 2017

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @bholley: components/style/values/computed/font.rs, components/style/values/specified/mod.rs, components/style/values/specified/font.rs, components/style/properties/longhand/font.mako.rs, components/style/values/computed/mod.rs
  • @canaltinova: components/style/values/computed/font.rs, components/style/values/specified/mod.rs, components/style/values/specified/font.rs, components/style/properties/longhand/font.mako.rs, components/style/values/computed/mod.rs
  • @emilio: components/style/values/computed/font.rs, components/style/values/specified/mod.rs, components/style/values/specified/font.rs, components/style/properties/longhand/font.mako.rs, components/style/values/computed/mod.rs

@highfive

highfive commented Nov 1, 2017

Copy link
Copy Markdown

warning Warning warning

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

@highfive highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 1, 2017

@emilio emilio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks great! I have some suggestions, but given it's pre-existing feel free to file followups if you don't want to address them. Otherwise addressing them would be lovely! :)

FontWeight::Weight(weight) => weight,
FontWeight::Normal => computed::FontWeight::normal(),
FontWeight::Bold => computed::FontWeight::bold(),
FontWeight::Bolder =>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: braces.

}
}

impl Parse for FontWeight {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is pre-existing, but it feels weird to use parse in a computed type, and this can be more efficient if implemented in the specified type directly.


impl Parse for FontWeight {
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
-> Result<FontWeight, ParseError<'i>> {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: indentation should probably be fixed-up here.

impl Parse for FontWeight {
fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
-> Result<FontWeight, ParseError<'i>> {
let result = input.try(|input| {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This could just be something like:

Ok(match *input.next()? {
    Token::Ident(ref ident) => {
        match_ignore_ascii_case! { ident,
            "normal" => FontWeight::Normal,
            // ...
            _ => return Err(input.new_custom_error(..)),
        }
    }
    Token::Number { int_value: Some(value), .. } => {
        computed::FontWeight::from_int(value)?;
    }
})

Which is clearer I think, and also more efficient.

Also, could you note that the grammar of this property intentionally doesn't support calc()?

@cbrewster

Copy link
Copy Markdown
Contributor Author

@bors-servo r=emilio

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 285d8bb 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. labels Nov 1, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 285d8bb with merge 1e0fd7d...

bors-servo pushed a commit that referenced this pull request Nov 1, 2017
style: Move font-weight outside of mako

<!-- Please describe your changes on the following line: -->

---
<!-- 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 are apart of #19015 (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [X] These changes do not require tests because refactoring

<!-- 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/19086)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
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 1e0fd7d to master...

@bors-servo
bors-servo merged commit 285d8bb into servo:master Nov 1, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 1, 2017
@emilio emilio mentioned this pull request Nov 2, 2017
48 of 49 tasks
bors-servo pushed a commit that referenced this pull request Nov 2, 2017
style: Cleanup font-weight parsing.

Followup for #19086

<!-- 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/19093)
<!-- Reviewable:end -->
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.

4 participants