Repository navigation
style: Move font-weight outside of mako - #19086
Conversation
|
Heads up! This PR modifies the following files:
|
emilio
left a comment
There was a problem hiding this comment.
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 => |
| } | ||
| } | ||
|
|
||
| impl Parse for FontWeight { |
There was a problem hiding this comment.
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>> { |
There was a problem hiding this comment.
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| { |
There was a problem hiding this comment.
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()?
|
@bors-servo r=emilio |
|
📌 Commit 285d8bb has been approved by |
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 -->
|
☀️ 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 |
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 -->
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is