Skip to content

style: Move text-align outside of the mako file. - #19576

Merged
bors-servo merged 2 commits into
servo:masterfrom
canova:text-align
Dec 18, 2017
Merged

bors-servo merged 2 commits into
servo:masterfrom
canova:text-align

Conversation

@canova

@canova canova commented Dec 15, 2017 •

Copy link
Copy Markdown
Contributor

I will need this refactoring before my next job. I didn't actually fix the FIXME's along the way. My other PR probably will cover these.


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors

This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @bholley: components/style/properties/longhand/inherited_text.mako.rs, components/style/values/computed/text.rs, components/style/values/specified/mod.rs, components/style/values/computed/mod.rs, components/style/values/specified/text.rs and 1 more
  • @emilio: components/style/properties/longhand/inherited_text.mako.rs, components/style/values/computed/text.rs, components/style/values/specified/mod.rs, components/style/values/computed/mod.rs, components/style/values/specified/text.rs and 1 more

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

Copy link
Copy Markdown

warning Warning warning

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

@canova

canova commented Dec 15, 2017

Copy link
Copy Markdown
Contributor Author

r? @emilio or @Manishearth

@highfive highfive assigned emilio and unassigned jdm Dec 15, 2017
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum TextAlign {
/// Keyword value of text-align property.
Keyword(ComputedTextAlign),

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.

Given that ComputedTextAlign is used in the specified value I'd prefer if it were in this file as TextAlignKeyword and computed::TextAlign is an alias

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

r=me with @Manishearth's comment addressed and mine.

}
#[cfg(feature = "gecko")]
{
if let Ok(_) = input.try(|i| i.expect_ident_matching("match-parent")) {

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 doesn't need to use if let, just:

input.expect_ident_matching("match_parent")?;
return Ok(TextAlign::MatchParent);

impl TextAlign {
/// Convert computed TextAlign into u32
pub fn to_u32(self) -> u32 {
match self {

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 super stupid btw (not your fault of course). I should just land the patch to derive(Parse) for keywords and use self as u32.

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'll actually land it, gimme a sec :)

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.

bors-servo pushed a commit that referenced this pull request Dec 15, 2017
Allow deriving Parse on keywords.

This makes patches like #19576 much easier.

<!-- 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/19578)
<!-- Reviewable:end -->
@canova

canova commented Dec 16, 2017

Copy link
Copy Markdown
Contributor Author

@emilio Added a small commit to do that Parse derive. Could you look at it?

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

Arrg, still unfortunate we need the macros just for from_u32, but it's fine for now. We can maybe auto-generate that in the future.

input.expect_ident_matching("match_parent")?;
return Ok(TextAlign::MatchParent);
}
return Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError));

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.

Travis has failed because this is unreachable on Gecko.

@canova

canova commented Dec 17, 2017

Copy link
Copy Markdown
Contributor Author

Actually let me create a ToKeywordEnum proc macro to implement from_u32. So we can get rid of that macro.

@canova

canova commented Dec 17, 2017

Copy link
Copy Markdown
Contributor Author

Can you look at it again to the new commit?


// TODO(canaltinova): We can create a trait for that.
quote! {
impl #name {

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.

It'd be nice to make it a real trait if possible. also, it's kind of unfortunate that we fix this to u32 enums, isn't it?

I think the macro is ok for now if there's only one use case.

@canova

canova commented Dec 18, 2017

Copy link
Copy Markdown
Contributor Author

Nvm, it doesn't worth the effort. Changed back to macro.
@bors-servo r=Manishearth,emilio

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 8c2c478 has been approved by Manishearth,emilio

@highfive highfive assigned Manishearth and unassigned emilio Dec 18, 2017
@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 18, 2017
}
#[cfg(feature = "gecko")]
{
input.expect_ident_matching("match_parent")?;

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.

match-parent (s/_/-/)

@emilio

emilio commented Dec 18, 2017

Copy link
Copy Markdown
Member

@bors-servo r-

@emilio

emilio commented Dec 18, 2017

Copy link
Copy Markdown
Member

(Feel free to land with that fixed and the rest of the patch sanity-checked, thanks!)

@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. labels Dec 18, 2017
@canova

canova commented Dec 18, 2017

Copy link
Copy Markdown
Contributor Author

Oops, thanks!
@bors-servo r=Manishearth,emilio

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 9882d0b has been approved by Manishearth,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 18, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 9882d0b with merge a9c1797...

bors-servo pushed a commit that referenced this pull request Dec 18, 2017
style: Move text-align outside of the mako file.

I will need this refactoring before my next job. I didn't actually fix the FIXME's along the way. My other PR probably will cover these.

---
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors

<!-- 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/19576)
<!-- 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: Manishearth,emilio
Pushing a9c1797 to master...

@bors-servo
bors-servo merged commit 9882d0b into servo:master Dec 18, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Dec 18, 2017
@canova
canova deleted the text-align branch December 22, 2017 06:16
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.

6 participants