servo: Merge #16741 - Handle fallback to default variable font in case of nonexistant generic (from Manishearth:stylo-fixup-generic); r=heycam
authorManish Goregaokar <manishearth@gmail.com>
Fri, 05 May 2017 13:39:19 -0500
changeset 356849 832a7bbcea613eff31d8afa8930034af48e34793
parent 356848 62b03dd84117bf8795643dfe96aa0a50119e6c2c
child 356850 b820c22816054fb93270d66375862913054bee7c
push id31775
push userihsiao@mozilla.com
push dateMon, 08 May 2017 03:10:38 +0000
treeherdermozilla-central@22aaf8bad4df [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #16741 - Handle fallback to default variable font in case of nonexistant generic (from Manishearth:stylo-fixup-generic); r=heycam Source-Repo: https://github.com/servo/servo Source-Revision: 943e7595d52d42a34f73e8fef98cd2dc4247714b
servo/components/style/gecko_bindings/bindings.rs
servo/components/style/properties/gecko.mako.rs
servo/components/style/properties/properties.mako.rs
--- a/servo/components/style/gecko_bindings/bindings.rs
+++ b/servo/components/style/gecko_bindings/bindings.rs
@@ -1169,16 +1169,21 @@ extern "C" {
     pub fn Gecko_nsStyleFont_SetLang(font: *mut nsStyleFont,
                                      atom: *mut nsIAtom);
 }
 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;
 }
 extern "C" {
     pub fn Gecko_GetFontMetrics(pres_context: RawGeckoPresContextBorrowed,
                                 is_vertical: bool, font: *const nsStyleFont,
                                 font_size: nscoord, use_user_font_set: bool)
      -> GeckoFontMetrics;
 }
--- a/servo/components/style/properties/gecko.mako.rs
+++ b/servo/components/style/properties/gecko.mako.rs
@@ -49,16 +49,17 @@ use gecko_bindings::structs::nsCSSProper
 use gecko_bindings::structs::nsStyleVariables;
 use gecko_bindings::sugar::ns_style_coord::{CoordDataValue, CoordData, CoordDataMut};
 use gecko_bindings::sugar::ownership::HasArcFFI;
 use gecko::values::convert_nscolor_to_rgba;
 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};
 use properties::{PropertyDeclaration, PropertyDeclarationBlock, PropertyDeclarationId};
 use std::fmt::{self, Debug};
 use std::mem::{forget, transmute, zeroed};
 use std::ptr;
 use stylearc::Arc;
@@ -1369,23 +1370,31 @@ fn static_assert() {
         unsafe { current_settings.set_len_pod(settings_length) };
 
         for (current, feature) in current_settings.iter_mut().zip(feature_settings.iter()) {
             current.mTag = feature.mTag;
             current.mValue = feature.mValue;
         }
     }
 
+    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;
 
         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) => {
                     unsafe { Gecko_FontFamilyList_AppendNamed(list, f.name.as_ptr(), f.quoted); }
                 }
                 FontFamily::Generic(ref name) => {
                     let (family_type, generic) =
                         if name == &atom!("serif") {
@@ -1423,16 +1432,17 @@ fn static_assert() {
     }
 
     pub fn font_family_at(&self, _: usize) -> longhands::font_family::computed_value::FontFamily {
         unimplemented!()
     }
 
     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
     // actual computed size, and the other of which (mFont.size) is the 'display
     // size' which takes font zooming into account. We don't handle font zooming yet.
     pub fn set_font_size(&mut self, v: longhands::font_size::computed_value::T) {
         self.gecko.mFont.size = v.0;
         self.gecko.mSize = v.0;
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -2604,17 +2604,21 @@ pub fn apply_declarations<'a, F, I>(devi
                 let discriminant = LonghandId::FontFamily as usize;
                 (CASCADE_PROPERTY[discriminant])(declaration,
                                                  inherited_style,
                                                  default_style,
                                                  &mut context,
                                                  &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,
                                                  inherited_style,
                                                  default_style,
                                                  &mut context,
                                                  &mut cacheable,
                                                  &mut cascade_info,