From 03e9264ea060be7418b4f35d2a5b7d37f66f3766 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 21 Apr 2017 16:10:50 -0700 Subject: [PATCH] Handle fallback to default variable font in case of nonexistant generic --- components/style/gecko_bindings/bindings.rs | 5 +++++ components/style/properties/gecko.mako.rs | 10 ++++++++++ components/style/properties/properties.mako.rs | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/components/style/gecko_bindings/bindings.rs b/components/style/gecko_bindings/bindings.rs index 026881bf609..1553536b706 100644 --- a/components/style/gecko_bindings/bindings.rs +++ b/components/style/gecko_bindings/bindings.rs @@ -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; } diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index e1a5594f6c0..69365b98082 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -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 diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 566263252fb..e60e7012792 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -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,