Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upEnabled use of FontFamily enum type #8420
Conversation
highfive
commented
Nov 9, 2015
|
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 |
|
|
|
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
3a66914
to
ac38845
|
Added correct email address to commits |
| -> Option<Arc<FontTemplateData>> { | ||
|
|
||
| let (response_chan, response_port) = ipc::channel().unwrap(); | ||
| self.chan.send(Command::GetFontTemplate(family, desc, response_chan)).unwrap(); | ||
| self.chan.send(Command::GetFontTemplate(family.name().to_owned(), desc, response_chan)).unwrap(); |
This comment has been minimized.
This comment has been minimized.
glennw
Dec 3, 2015
Member
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?
This comment has been minimized.
This comment has been minimized.
craftytrickster
Dec 4, 2015
Author
Contributor
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
|
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
| super::CURSIVE => FontFamily::Cursive, | ||
| super::FANTASY => FontFamily::Fantasy, | ||
| super::MONOSPACE => FontFamily::Monospace | ||
| _ => FontFamily::FamilyName(input.clone()) | ||
| } |
This comment has been minimized.
This comment has been minimized.
craftytrickster
Dec 16, 2015
Author
Contributor
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)
}
}
This comment has been minimized.
This comment has been minimized.
glennw
Dec 17, 2015
Member
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?
This comment has been minimized.
This comment has been minimized.
nox
Dec 30, 2015
Member
It's not expensive, but we have the opportunity to not clone here, so let's do it I guess?
| @@ -198,15 +218,15 @@ impl FontCache { | |||
| for_each_available_family(|family_name| { | |||
| let family_name = LowercaseString::new(&family_name); | |||
| if !self.local_families.contains_key(&family_name) { | |||
This comment has been minimized.
This comment has been minimized.
craftytrickster
Dec 16, 2015
Author
Contributor
It seems inefficient to create a new LowercaseString, just for the purpose of performing a contains_key check. Is there a better way to do this?
This comment has been minimized.
This comment has been minimized.
glennw
Dec 17, 2015
Member
It's only done when the local families are refreshed (which is only on application startup at the moment), so I wouldn't worry about it.
|
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
|
|
e536883
to
d2dfe3d
|
@craftytrickster Fix that clone and I'll r=glennw. |
…ers with enum
d2dfe3d
to
d942bfb
|
@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 |
|
|
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 -->
|
|
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 -->
|
|
craftytrickster commentedNov 9, 2015
#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.