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

Remove usage of 'keyword_list' #13917

Merged
merged 2 commits into from Nov 17, 2016
Merged

Remove usage of 'keyword_list' #13917

merged 2 commits into from Nov 17, 2016

Conversation

@wafflespeanut
Copy link
Member

wafflespeanut commented Oct 25, 2016

We're using keyword_list to generate code for some of the animation properties. This could be achieved with single_keyword (passing vector=True).


  • ./mach build -d does not report any errors
  • ./mach build-geckolib does not report any errors
  • These changes do not require tests because it's a cleanup

r? @emilio


This change is Reviewable

@highfive
Copy link

highfive commented Oct 25, 2016

Heads up! This PR modifies the following files:

  • @bholley: components/style/properties/helpers.mako.rs, components/style/properties/longhand/box.mako.rs
  • @emilio: components/style/properties/helpers.mako.rs, components/style/properties/longhand/box.mako.rs
@highfive
Copy link

highfive commented Oct 25, 2016

warning Warning warning

  • These commits modify style code, but no tests are modified. Please consider adding a test!
@@ -75,6 +75,10 @@
}
pub mod computed_value {
pub use super::single_value::computed_value as single_value;
% if requires_single:
pub use super::single_value::computed_value::T as SingleComputedValue;

This comment has been minimized.

@Manishearth

Manishearth Oct 25, 2016

Member

I don't think we need requires_single. Refactor the code that needs SingleFoo to use single_value::computed_value::Foo. Alternatively, unconditionally add the reexport.

@@ -145,6 +151,19 @@
}).map(SpecifiedValue)
% endif
}

% if requires_single:

This comment has been minimized.

@Manishearth

Manishearth Oct 25, 2016

Member

We should get rid of this and refactor code using these functions to use the single_value functions instead

@wafflespeanut
Copy link
Member Author

wafflespeanut commented Oct 25, 2016

I really thought I could escape from refactoring a lot of code 😆

@bors-servo
Copy link
Contributor

bors-servo commented Nov 7, 2016

The latest upstream changes (presumably #14089) made this pull request unmergeable. Please resolve the merge conflicts.

@wafflespeanut wafflespeanut force-pushed the wafflespeanut:keywords branch from c0c0c76 to bfd4a0e Nov 16, 2016
@wafflespeanut wafflespeanut reopened this Nov 16, 2016
@wafflespeanut
Copy link
Member Author

wafflespeanut commented Nov 16, 2016

@wafflespeanut wafflespeanut force-pushed the wafflespeanut:keywords branch from 66470c9 to 7ccb868 Nov 16, 2016
Copy link
Member

emilio left a comment

Just one question, that I think @SimonSapin should be able to answer.

So the idea of not having T::get_initial_value, as far as I understand, is that you might want to properties with the same type, but different initial values for each of them, right?

If that's the case, that change probably should be reverted. Otherwise the simplification looks pretty neat :)

@@ -75,6 +74,7 @@
}
pub mod computed_value {
pub use super::single_value::computed_value as single_value;
pub use super::single_value::computed_value::T as SingleComputedValue;

This comment has been minimized.

@emilio

emilio Nov 16, 2016

Member

nit: pub use single_value::T as SingleComputedValue is shorter.

This comment has been minimized.

@wafflespeanut

wafflespeanut Nov 17, 2016

Author Member

Re-exporting as self::single_value::T works, nvm :)

<%call expr="longhand(name, **kwargs)">
% if product == "gecko" or not gecko_only:

This comment has been minimized.

@emilio

emilio Nov 16, 2016

Member

Deindent?

@Manishearth
Copy link
Member

Manishearth commented Nov 16, 2016

If that's the case, that change probably should be reverted.

Yeah, that could be the case. In that case I guess you can just wrap in a struct.

@SimonSapin
Copy link
Member

SimonSapin commented Nov 16, 2016

Just one question, that I think @SimonSapin should be able to answer.

I have no idea what is the context or motivation for this PR. (By the way, it would be nicer to include that in the PR message.) But yes, in CSS specs initial values are define per individual property, even if some properties may share some syntax / grammar.

@Manishearth
Copy link
Member

Manishearth commented Nov 16, 2016

I have no idea what is the context or motivation for this PR.

We have both helpers.keyword(vector=True) and helpers.keyword_list() which do the same thing but slightly differently.

I guess we shouldn't move get_initial to a method, then.

@wafflespeanut wafflespeanut force-pushed the wafflespeanut:keywords branch from 7ccb868 to 8749862 Nov 16, 2016
@wafflespeanut
Copy link
Member Author

wafflespeanut commented Nov 16, 2016

So the idea of not having T::get_initial_value, as far as I understand, is that you might want to properties with the same type, but different initial values for each of them, right?

No, it was because initially, I was unable to have the get_initial_value function in each module. Now, I've done a workaround. T::get_initial_value is no longer a method :)

@Manishearth
Copy link
Member

Manishearth commented Nov 16, 2016

No, it was because initially, I was unable to have the get_initial_value function in each module. Now, I've done a workaround. T::get_initial_value is no longer a method :)

I still don't get why this is necessary. The vector=True helper creates a single_value mod, just put the second function inside that?

@wafflespeanut
Copy link
Member Author

wafflespeanut commented Nov 16, 2016

Updated the PR message :)

@Manishearth
Copy link
Member

Manishearth commented Nov 16, 2016

You should rewrite callers to use property::single_value::computed_value::get_initial. Don't add a conflicting alias.

@Manishearth
Copy link
Member

Manishearth commented Nov 16, 2016

Or, property::computed_value::single_value::get_initial. Both work.

@wafflespeanut wafflespeanut force-pushed the wafflespeanut:keywords branch from 8749862 to 5a6b8db Nov 16, 2016
use style_traits::ToCss;

pub use Atom as SingleComputedValue;

impl Parse for Atom {

This comment has been minimized.

@Manishearth

Manishearth Nov 16, 2016

Member

I don't think this should be there. Atom is too generic to be tied to the parsing details for a single property.

This comment has been minimized.

@emilio

emilio Nov 16, 2016

Member

Yes, writing a newtype for this is adequate I think

This comment has been minimized.

@wafflespeanut

wafflespeanut Nov 17, 2016

Author Member

Okay, I've gone for a new type AnimationName(pub Atom) and impl'd the necessary traits.

impl Parse for AnimationIterationCount {
fn parse(input: &mut ::cssparser::Parser) -> Result<Self, ()> {
if input.try(|input| input.expect_ident_matching("infinite")).is_ok() {
Ok(AnimationIterationCount::Infinite)

This comment has been minimized.

@emilio

emilio Nov 16, 2016

Member

nit: return early and deindent the next block if you wish.

use style_traits::ToCss;

pub use Atom as SingleComputedValue;

impl Parse for Atom {

This comment has been minimized.

@emilio

emilio Nov 16, 2016

Member

Yes, writing a newtype for this is adequate I think

@wafflespeanut wafflespeanut force-pushed the wafflespeanut:keywords branch 3 times, most recently from 3c7122d to df8d9da Nov 17, 2016
@wafflespeanut
Copy link
Member Author

wafflespeanut commented Nov 17, 2016

Updated the PR.

}
}

impl Deref for AnimationName {

This comment has been minimized.

@Manishearth

Manishearth Nov 17, 2016

Member

In general try to use deref for things that involve actual dereferencing. Just refactor everything else to use .0 here

This comment has been minimized.

@wafflespeanut

wafflespeanut Nov 17, 2016

Author Member

Removed the impls.

@wafflespeanut wafflespeanut force-pushed the wafflespeanut:keywords branch from df8d9da to b5bc2a1 Nov 17, 2016
@Manishearth
Copy link
Member

Manishearth commented Nov 17, 2016

@bors-servo
Copy link
Contributor

bors-servo commented Nov 17, 2016

📌 Commit b5bc2a1 has been approved by Manishearth

@highfive highfive assigned Manishearth and unassigned emilio Nov 17, 2016
bors-servo added a commit that referenced this pull request Nov 17, 2016
Remove usage of 'keyword_list'

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

We're using `keyword_list` to generate code for some of the animation properties. This could be achieved with `single_keyword` (passing `vector=True`).

---

<!-- 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 build-geckolib` does not report any errors

<!-- Either: -->
- [x] These changes do not require tests because it's a cleanup

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

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

<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 17, 2016

Testing commit b5bc2a1 with merge b3ad713...

@bors-servo
Copy link
Contributor

bors-servo commented Nov 17, 2016

@bors-servo bors-servo merged commit b5bc2a1 into servo:master Nov 17, 2016
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
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.

None yet

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