Skip to content

Move list-style-type outside of mako - #19636

Merged
bors-servo merged 2 commits into
servo:masterfrom
jonleighton:issue-19629
Dec 24, 2017
Merged

bors-servo merged 2 commits into
servo:masterfrom
jonleighton:issue-19629

Conversation

@jonleighton

@jonleighton jonleighton commented Dec 23, 2017 •

Copy link
Copy Markdown
Contributor

Closes issue #19629

r? emilio


This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

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

@highfive

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 Dec 23, 2017
@@ -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:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

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.

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

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.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

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.

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!

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.

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.

@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! Thanks for helping out reviewing @CYBAI :)

ListStyleType::CounterStyle(style)
} else {
ListStyleType::String(input.expect_string()?.as_ref().to_owned())
})

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.

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

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.

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

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

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.

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

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.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

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.

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.

@jonleighton

Copy link
Copy Markdown
Contributor Author

The "fetch::test_fetch_with_hsts" CI test failure is due to #19634

@emilio

emilio commented Dec 24, 2017

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 53e868e 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 Dec 24, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 53e868e with merge 46bbfab...

bors-servo pushed a commit that referenced this pull request Dec 24, 2017
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 -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-dev-unit

@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 Dec 24, 2017
@tigercosmos

Copy link
Copy Markdown
Contributor

@bors-servo retry

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 53e868e with merge 864b683...

bors-servo pushed a commit that referenced this pull request Dec 24, 2017
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 -->
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Dec 24, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - mac-dev-unit

@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 Dec 24, 2017
@tigercosmos

tigercosmos commented Dec 24, 2017 •

Copy link
Copy Markdown
Contributor

@bors-servo retry

  • gecko-media

@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 53e868e with merge 9a207d1...

bors-servo pushed a commit that referenced this pull request Dec 24, 2017
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 -->
@highfive highfive added S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. and removed S-tests-failed The changes caused existing tests to fail. labels Dec 24, 2017
@bors-servo

Copy link
Copy Markdown
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 Dec 24, 2017
@emilio

emilio commented Dec 24, 2017

Copy link
Copy Markdown
Member

@bors-servo retry

@bors-servo

Copy link
Copy Markdown
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
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 9a207d1 to master...

@bors-servo
bors-servo merged commit 53e868e into servo:master Dec 24, 2017
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.

6 participants