Skip to content

style: Move font-variant-alternates outside of mako - #19167

Merged
bors-servo merged 1 commit into
servo:masterfrom
CYBAI:font-variant-alternates-out-of-mako
Nov 11, 2017
Merged

bors-servo merged 1 commit into
servo:masterfrom
CYBAI:font-variant-alternates-out-of-mako

Conversation

@CYBAI

@CYBAI CYBAI commented Nov 9, 2017 •

Copy link
Copy Markdown
Member

This is a sub-PR of #19015
r? emilio



This change is Reviewable

@highfive

highfive commented Nov 9, 2017

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

  • @bholley: components/style/properties/gecko.mako.rs, components/style/values/specified/font.rs, components/style/values/specified/mod.rs, components/style/values/computed/mod.rs, components/style/values/computed/font.rs and 1 more
  • @canaltinova: components/style/properties/gecko.mako.rs, components/style/values/specified/font.rs, components/style/values/specified/mod.rs, components/style/values/computed/mod.rs, components/style/values/computed/font.rs and 1 more
  • @emilio: components/style/properties/gecko.mako.rs, components/style/values/specified/font.rs, components/style/values/specified/mod.rs, components/style/values/computed/mod.rs, components/style/values/computed/font.rs and 1 more

@highfive

highfive commented Nov 9, 2017

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 Nov 9, 2017
},
VariantAlternates::HistoricalForms => {
dest.write_str("historical-forms")
},

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Every dest.write_str write with different string for each variant so I just type them by hand.
Not sure if there's any better and graceful way to write this pattern matching.
If yes, I'm willing to update it!

cc @jdm @emilio

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 think you could derive(ToCss) here using #[css(function)] annotations.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'll try to implement ToCss for Box<[CustomIdent]> in another PR.
Then, I'll update this.

@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! Just one bug I noticed, and a couple nits. Thanks as always!

Comment thread components/style/values/computed/mod.rs Outdated
pub use self::border::{BorderImageSlice, BorderImageWidth, BorderImageSideWidth};
pub use self::border::{BorderRadius, BorderCornerRadius, BorderSpacing};
pub use self::font::{FontSize, FontSizeAdjust, FontWeight, MozScriptLevel, MozScriptMinSize, XTextZoom};
pub use self::font::{

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: Use two lines for imports instead of breaking them into multiple lines, see the border imports on the line above.

bitflags! {
#[cfg_attr(feature = "servo", derive(MallocSizeOf))]
/// Flags of variant alternates in bit
pub struct ParsingFlags: u8 {

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.

Let's call this something more specific like VariantAlternatesParsingFlags.

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.

Also, no need for pub I think.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh, sorry for that I forgot to remove the pub. I'll update it!

// FIXME: remove clone() when lifetimes are non-lexical
match input.next()?.clone() {
Token::Ident(ref ident) => {
if *ident == "historical-forms" {

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 should be ident.eq_ignore_ascii_case("historical-forms"), could you add a test for this?

Something in the lines of:

<!doctype html>
<div style="font-variant-alternates: Historical-Forms"></div>
<script>
getComputedStyle(document.querySelector('div')).fontVariantAlternates == "historical-forms"
</script>

Though... I guess it would need to be a test for Firefox, not servo, so let's fix it and I'll land the test in https://bugzilla.mozilla.org/show_bug.cgi?id=1415946

let idents = i.parse_comma_separated(|i| {
let location = i.current_source_location();
CustomIdent::from_ident(location, i.expect_ident()?, &[])
})?;

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.

Hmm, the duplication here is slightly worrying, but it's not too much, so I guess it's fine.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hmm... yes, I also would like to improve them with checking with multiple patterns of pattern matching; however, there're very small different inside the match body. If there's a good way to solve this problem, I think we can reduce this match.

pub use self::border::{BorderImageSideWidth, BorderRadius, BorderSideWidth, BorderSpacing};
pub use self::font::{FontSize, FontSizeAdjust, FontWeight, MozScriptLevel, MozScriptMinSize, XTextZoom};
pub use self::font::{
FontSize, FontSizeAdjust, FontWeight, FontVariantAlternates,

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.

Same regarding multiline imports.

@bors-servo

Copy link
Copy Markdown
Contributor

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

@highfive highfive added the S-needs-rebase There are merge conflict errors. label Nov 10, 2017
@CYBAI
CYBAI force-pushed the font-variant-alternates-out-of-mako branch from 5d96982 to 773e7fc Compare November 10, 2017 18:15
@CYBAI
CYBAI force-pushed the font-variant-alternates-out-of-mako branch from 773e7fc to aeae311 Compare November 10, 2017 18:21
@emilio

emilio commented Nov 10, 2017

Copy link
Copy Markdown
Member

Looks good! Let's try to derive it in a followup.

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit aeae311 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. S-needs-rebase There are merge conflict errors. labels Nov 10, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit aeae311 with merge 33fa728...

bors-servo pushed a commit that referenced this pull request Nov 10, 2017
…milio

style: Move font-variant-alternates outside of mako

This is a sub-PR of #19015
r? emilio

---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #19166  (github issue number if applicable).
- [x] These changes do not require tests

<!-- 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/19167)
<!-- 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: emilio
Pushing 33fa728 to master...

@bors-servo
bors-servo merged commit aeae311 into servo:master Nov 11, 2017
@highfive highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 11, 2017
@CYBAI
CYBAI deleted the font-variant-alternates-out-of-mako branch November 11, 2017 02:45
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.

Move font-variant-alternates outside of mako.

4 participants