mirror of
https://github.com/servo/servo.git
synced 2025-10-04 02:29:12 +01:00
style: Use first generic rather than only generic to determine fallback font family
This seems like more sensible behavior. We have another use of only_generic(), but that affects font sizing and other browsers agree with us there: <div style="font-family: monospace">Should be 13px</div> <div style="font-family: something, monospace">Should be 16px</div> So not touching that one. Differential Revision: https://phabricator.services.mozilla.com/D130732
This commit is contained in:
parent
88b82f569b
commit
a9baf5fe3d
2 changed files with 15 additions and 7 deletions
|
@ -627,12 +627,20 @@ impl FontFamilyList {
|
|||
self.list = crate::ArcSlice::from_iter(new_list.into_iter());
|
||||
}
|
||||
|
||||
/// Returns whether we need to prioritize user fonts.
|
||||
pub (crate) fn needs_user_font_prioritization(&self) -> bool {
|
||||
self.iter().next().map_or(true, |f| match f {
|
||||
SingleFontFamily::Generic(f) => !f.valid_for_user_font_prioritization(),
|
||||
_ => true,
|
||||
})
|
||||
}
|
||||
|
||||
/// Return the generic ID if it is a single generic font
|
||||
pub fn single_generic(&self) -> Option<GenericFontFamily> {
|
||||
let mut iter = self.iter();
|
||||
if let Some(SingleFontFamily::Generic(f)) = iter.next() {
|
||||
if iter.next().is_none() {
|
||||
return Some(f.clone());
|
||||
return Some(*f);
|
||||
}
|
||||
}
|
||||
None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue