Repository navigation
Move list-style-type outside of mako - #19636
Conversation
Closes issue servo#19629
|
Heads up! This PR modifies the following files:
|
| @@ -30,69 +30,13 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu | |||
| animation_value_type="discrete", | |||
| spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type")} | |||
| % else: | |||
There was a problem hiding this comment.
Should I try to remove the conditional here? If so, please could I have some pointers? (The two branches seem quite different and therefore tricky to know how to homogenise them).
There was a problem hiding this comment.
Yeah, I agree it's non-trivial to do so, so let's keep this for now.
| ListStyleType::CounterStyle(style) | ||
| } else { | ||
| ListStyleType::String(input.expect_string()?.as_ref().to_owned()) | ||
| }) |
There was a problem hiding this comment.
Will it be better to make this like following?
if let Ok(style) = input.try(|i| CounterStyleOrNone::parse(context, i)) {
return Ok(ListStyleType::CounterStyle(style));
}
Ok(ListStyleType::String(input.expect_string()?.as_ref().to_owned()))Besides, I'm wondering if using pattern matching would work?
↓ I'm not sure if this piece of code will work
match (input.try(|i| CounterStyleOrNone::parse(context, i))) {
Ok(style) => Ok(ListStyleType::CounterStyle(style)),
Err(_) => Ok(ListStyleType::String(input.expect_string()?.as_ref().to_owned()))
}There was a problem hiding this comment.
Yeah I prefer that too, though unsure if it's appropriate to refactor it in this PR? I've just copied the existing code verbatim in this method. I guess I could add a commit with the refactoring, I agree it's nicer.
There was a problem hiding this comment.
I guess it should be okay to have this kind of refactor in this PR but I think we can wait for response from @emilio about this!
There was a problem hiding this comment.
Yeah, making code nicer is great over-all, and if done in separate commits it's even nicer :)
I personally prefer the first option (early-returning) better, but I'd be fine with both.
| ListStyleType::CounterStyle(style) | ||
| } else { | ||
| ListStyleType::String(input.expect_string()?.as_ref().to_owned()) | ||
| }) |
There was a problem hiding this comment.
Yeah, making code nicer is great over-all, and if done in separate commits it's even nicer :)
I personally prefer the first option (early-returning) better, but I'd be fine with both.
| use gecko_bindings::structs; | ||
|
|
||
| let counter_style = if value == structs::NS_STYLE_LIST_STYLE_NONE { | ||
| CounterStyleOrNone::None |
There was a problem hiding this comment.
Similarly, this may be cleaner early-returning here
|
|
||
| #[cfg(feature = "gecko")] | ||
| impl Parse for ListStyleType { | ||
| fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>) |
There was a problem hiding this comment.
nit: Indentation here looks kinda messed up, let's use block indentation for arguments as such:
fn parse<'i, 't>(
context: &ParserContext,
input: &mut Parser<'i, 't>,
) -> Result<Self, ParserError<'i>> {| @@ -30,69 +30,13 @@ ${helpers.single_keyword("list-style-position", "outside inside", animation_valu | |||
| animation_value_type="discrete", | |||
| spec="https://drafts.csswg.org/css-lists/#propdef-list-style-type")} | |||
| % else: | |||
There was a problem hiding this comment.
Yeah, I agree it's non-trivial to do so, so let's keep this for now.
| /// <counter-style> | none | ||
| CounterStyle(CounterStyleOrNone), | ||
| /// <string> | ||
| String(String), |
There was a problem hiding this comment.
If you also want to save a bit of memory (assuming CounterStyleOrNone is smaller than String, which I haven't checked), you could use Box<str>.
There was a problem hiding this comment.
What's the best way to check this sort of thing? Here's the hacky approach I took...
I edited tests/unit/style/size_of.rs to add these lines:
use style::values::specified::list::ListStyleType;
size_of_test!(test_size_of_list_style_type, ListStyleType, 0);Then edited the source to get rid of various #[cfg(feature = "gecko")] lines. Then ran the test with String(String) and String(Box<str>).
In both cases the size was 40 bytes, so I guess CounterStyleOrNone is larger than String.
There was a problem hiding this comment.
Yeah, string should be 32 bytes. I usually just do the math manually. Since CounterStyleOrNone contains a Vec<..> (32 bytes) and the enum tag, that makes sense.
|
The "fetch::test_fetch_with_hsts" CI test failure is due to #19634 |
|
@bors-servo r+
|
|
📌 Commit 53e868e has been approved by |
Move list-style-type outside of mako Closes issue #19629 r? emilio <!-- 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/19636) <!-- Reviewable:end -->
|
💔 Test failed - mac-dev-unit |
|
@bors-servo retry |
Move list-style-type outside of mako Closes issue #19629 r? emilio <!-- 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/19636) <!-- Reviewable:end -->
|
💔 Test failed - mac-dev-unit |
|
@bors-servo retry
|
Move list-style-type outside of mako Closes issue #19629 r? emilio <!-- 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/19636) <!-- Reviewable:end -->
|
💔 Test failed - linux-rel-css |
|
@bors-servo retry |
|
⚡ 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... |
|
☀️ 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 |
Closes issue #19629
r? emilio
This change is