Skip to content

style: Move font-language-override outside of mako - #19188

Merged
bors-servo merged 1 commit into
servo:masterfrom
CYBAI:font-language-override-out-of-mako
Nov 13, 2017
Merged

bors-servo merged 1 commit into
servo:masterfrom
CYBAI:font-language-override-out-of-mako

Conversation

@CYBAI

@CYBAI CYBAI commented Nov 12, 2017 •

Copy link
Copy Markdown
Member

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



This change is Reviewable

@highfive

Copy link
Copy Markdown

Heads up! This PR modifies the following files:

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

@highfive

Copy link
Copy Markdown

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!
  • 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 12, 2017
FontLanguageOverride::Override(ref lang) => lang.to_css(dest),
FontLanguageOverride::System(sys) => sys.to_css(dest),
}
}

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.

After checking #19186 , I think I can remove this impl and derive ToCss instead?

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.

Indeed this can just be derived, mind doing that? Thanks! :)

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.

Sure, I'll change it to use derive in the late today :)

@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! A couple of nits, other than that looks good, thanks a lot @CYBAI!

impl FontLanguageOverride {
#[inline]
/// Get computed default value of `font-language-override` with 0
pub fn get_initial_value() -> FontLanguageOverride {

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 fn zero(), and use that instead.

if input.try(|input| input.expect_ident_matching("normal")).is_ok() {
Ok(FontLanguageOverride::Normal)
} else {
input.expect_string().map(|s| {

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 can just be:

let string = input.expect_string()?;
Ok(FontLanguageOverride::Override(string.to_owned()))

/// normal | <string>
fn parse<'i, 't>(_: &ParserContext, input: &mut Parser<'i, 't>) -> Result<FontLanguageOverride, ParseError<'i>> {
if input.try(|input| input.expect_ident_matching("normal")).is_ok() {
Ok(FontLanguageOverride::Normal)

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 add a return here:

return Ok(FontLanguageOverride::Normal)

And remove the } else { below.

FontLanguageOverride::Override(ref lang) => lang.to_css(dest),
FontLanguageOverride::System(sys) => sys.to_css(dest),
}
}

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.

Indeed this can just be derived, mind doing that? Thanks! :)

/// Single three-letter case-sensitive OpenType language system tag,
/// specifies the OpenType language system to be used instead of
/// the language system implied by the language of the element
Override(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 feel like it, you can use Box<str> to save some memory (using into_boxed_string) during parsing.

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.

Thanks! I'll try it! I'd like to try Box<str>!

@CYBAI
CYBAI force-pushed the font-language-override-out-of-mako branch from 59467c1 to efebd1c Compare November 13, 2017 13:57

@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 good!

@emilio

emilio commented Nov 13, 2017

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit efebd1c 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 Nov 13, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit efebd1c with merge ad91962...

bors-servo pushed a commit that referenced this pull request Nov 13, 2017
…ilio

style: Move font-language-override 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 #19187
- [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/19188)
<!-- Reviewable:end -->
@bors-servo

Copy link
Copy Markdown
Contributor

💔 Test failed - linux-dev

@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 Nov 13, 2017
@CYBAI
CYBAI force-pushed the font-language-override-out-of-mako branch from efebd1c to 38eae70 Compare November 13, 2017 15:15
@highfive highfive added S-awaiting-review There is new code that needs to be reviewed. and removed S-tests-failed The changes caused existing tests to fail. labels Nov 13, 2017
@emilio

emilio commented Nov 13, 2017

Copy link
Copy Markdown
Member

@bors-servo r+

@bors-servo

Copy link
Copy Markdown
Contributor

📌 Commit 38eae70 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 Nov 13, 2017
@bors-servo

Copy link
Copy Markdown
Contributor

⌛ Testing commit 38eae70 with merge c261ff3...

bors-servo pushed a commit that referenced this pull request Nov 13, 2017
…ilio

style: Move font-language-override 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 #19187
- [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/19188)
<!-- 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 c261ff3 to master...

@bors-servo
bors-servo merged commit 38eae70 into servo:master Nov 13, 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 13, 2017
@CYBAI
CYBAI deleted the font-language-override-out-of-mako branch November 14, 2017 00:52
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-language-override outside of mako.

4 participants