Auto merge of #16741 - Manishearth:stylo-fixup-generic, r=heycam

Handle fallback to default variable font in case of nonexistant generic

<!-- 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/16741)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-05-05 13:39:19 -05:00 committed by GitHub
commit 943e7595d5
3 changed files with 19 additions and 0 deletions

View file

@ -1173,6 +1173,11 @@ extern "C" {
pub fn Gecko_nsStyleFont_CopyLangFrom(aFont: *mut nsStyleFont,
aSource: *const nsStyleFont);
}
extern "C" {
pub fn Gecko_nsStyleFont_FixupNoneGeneric(font: *mut nsStyleFont,
pres_context:
RawGeckoPresContextBorrowed);
}
extern "C" {
pub fn Gecko_GetBaseSize(lang: *mut nsIAtom) -> FontSizePrefs;
}

View file

@ -54,6 +54,7 @@ use gecko::values::convert_rgba_to_nscolor;
use gecko::values::GeckoStyleCoordConvertible;
use gecko::values::round_border_to_device_pixels;
use logical_geometry::WritingMode;
use media_queries::Device;
use properties::animated_properties::TransitionProperty;
use properties::longhands;
use properties::{Importance, LonghandId};
@ -1374,6 +1375,12 @@ fn static_assert() {
}
}
pub fn fixup_none_generic(&mut self, device: &Device) {
unsafe {
bindings::Gecko_nsStyleFont_FixupNoneGeneric(&mut self.gecko, &*device.pres_context)
}
}
pub fn set_font_family(&mut self, v: longhands::font_family::computed_value::T) {
use properties::longhands::font_family::computed_value::FontFamily;
use gecko_bindings::structs::FontFamilyType;
@ -1381,6 +1388,8 @@ fn static_assert() {
let list = &mut self.gecko.mFont.fontlist;
unsafe { Gecko_FontFamilyList_Clear(list); }
self.gecko.mGenericID = structs::kGenericFont_NONE;
for family in &v.0 {
match *family {
FontFamily::FamilyName(ref f) => {
@ -1428,6 +1437,7 @@ fn static_assert() {
pub fn copy_font_family_from(&mut self, other: &Self) {
unsafe { Gecko_CopyFontFamilyFrom(&mut self.gecko.mFont, &other.gecko.mFont); }
self.gecko.mGenericID = other.gecko.mGenericID;
}
// FIXME(bholley): Gecko has two different sizes, one of which (mSize) is the

View file

@ -2609,7 +2609,11 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
&mut cacheable,
&mut cascade_info,
error_reporter);
% if product == "gecko":
context.style.mutate_font().fixup_none_generic(context.device);
% endif
}
if let Some(declaration) = font_size {
let discriminant = LonghandId::FontSize as usize;
(CASCADE_PROPERTY[discriminant])(declaration,