Repository navigation
Enabled use of FontFamily enum type - #8420
Conversation
|
Thanks for the pull request, and welcome! The Servo team is excited to review your changes, and you should hear from @glennw (or someone else) soon. |
|
While the I really don’t know our font code at all, so I’d rather that someone who does suggests what to do here. @glennw maybe? Reviewed 1 of 2 files at r1. components/gfx/font_cache_task.rs, line 107 [r1] (raw file): components/gfx/font_cache_task.rs, line 119 [r1] (raw file): components/style/properties.mako.rs, line 1722 [r1] (raw file): components/style/properties.mako.rs, line 1735 [r1] (raw file): match *self {
FontFamily::FamilyName(ref name) => ::cssparser::serialize_string(name, dest),
FontFamily::Serif => dest.write_str("serif"),
FontFamily::SansSerif => dest.write_str("sans-serif"),
FontFamily::Cursive => dest.write_str("cursive"),
FontFamily::Fantasy => dest.write_str("fantasy"),
FontFamily::Monospace => dest.write_str("monospace"),
}… which writes a quoted string for non-generic names. Comments from the review on Reviewable.io |
|
components/gfx/font_cache_task.rs, line 107 [r1] (raw file): Comments from the review on Reviewable.io |
|
@SimonSapin I may be missing the context here, but it sounds like the font cache should take the FontFamily enum as input in its public APIs (rather than a string as it does now). Once this is changed, the internal font cache code could be updated to distinguish between them, by only transforming the font name to a generic one when the specified type is not a FontFamily::FamilyName(Atom). Does that sound right to you? |
|
@SimonSapin ping |
|
@glennw I don’t know anything about our font code beyond parsing in the Fixing this should make |
|
☔ The latest upstream changes (presumably #8667) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Should I resolve the merge conflicts or should I close the PR? |
|
There shouldn't be any need to close this PR. Any changes to address the previous comments and the merge conflicts can be force pushed to the same branch. |
54cc7b7 to
c3cf40a
Compare
3a66914 to
ac38845
Compare
|
Added correct email address to commits |
There was a problem hiding this comment.
Since this converts the family to a string here, I don't see how it can differentiate between the enum value and 'serif' as a string when selecting which font to return?
There was a problem hiding this comment.
When I did this a while ago, I originally tried to pass around the enum FontFamily version instead of using a string, but I ran into problems with some functions that are being called from another module that depend on using a string (they were unsafe blocks that depended on c-like strings). I will look around again to see if there is anything I can do, and I will post my findings.
ac38845 to
4b667af
Compare
|
Please let me know if anything else is missing. |
|
I ran the WPT tests on this PR and got 33 test failures - they seem to be related to our mozilla tests that use the css/ahem.css file. |
4b667af to
8c08b7b
Compare
There was a problem hiding this comment.
Should I do this instead in order to avoid a clone?
pub fn from_atom(input: Atom) -> FontFamily {
let option = match_ignore_ascii_case! { &input,
super::SERIF => Some(FontFamily::Serif),
super::SANS_SERIF => Some(FontFamily::SansSerif),
super::CURSIVE => Some(FontFamily::Cursive),
super::FANTASY => Some(FontFamily::Fantasy),
super::MONOSPACE => Some(FontFamily::Monospace)
_ => None
};
match option {
Some(family) => family,
None => FontFamily::FamilyName(input)
}
}There was a problem hiding this comment.
Cloning an atom isn't very expensive (it's atomically reference counted), so it's probably fine. @SimonSapin is there a better way to do this while using that macro?
There was a problem hiding this comment.
It's not expensive, but we have the opportunity to not clone here, so let's do it I guess?
|
Thanks for the changes. One minor question for Simon to reply with, after that it looks good to me once squashed. |
|
Thank you for the review. |
0b6fcf5 to
e536883
Compare
|
☔ The latest upstream changes (presumably #9019) made this pull request unmergeable. Please resolve the merge conflicts. |
e536883 to
d2dfe3d
Compare
|
@craftytrickster Fix that clone and I'll r=glennw. |
d2dfe3d to
d942bfb
Compare
|
@nox thanks for checking in on this, I made the change as requested. |
|
@bors-servo r=glennw Reviewed 2 of 4 files at r5, 3 of 3 files at r6. Comments from the review on Reviewable.io |
|
📌 Commit d942bfb has been approved by |
Enabled use of FontFamily enum type #8371 In addition to replacing loose strings with the FontFamily enum in `font_cache_task.rs`, I also centralized the add_generic_font calls into one single function. If centralizing into one function is not desired or if anything else needs to be changed, please let me know. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8420) <!-- Reviewable:end -->
|
⛄ The build was interrupted to prioritize another pull request. |
Enabled use of FontFamily enum type #8371 In addition to replacing loose strings with the FontFamily enum in `font_cache_task.rs`, I also centralized the add_generic_font calls into one single function. If centralizing into one function is not desired or if anything else needs to be changed, please let me know. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/8420) <!-- Reviewable:end -->
|
☀️ Test successful - android, gonk, linux-dev, linux-rel, mac-dev-ref-unit, mac-rel-css, mac-rel-wpt |
#8371
In addition to replacing loose strings with the FontFamily enum in
font_cache_task.rs, I also centralized the add_generic_font calls into one single function. If centralizing into one function is not desired or if anything else needs to be changed, please let me know.