Bug 1367860 (part 4) - Update CSS fallback font when lang changes (stylo). r?dbaron draft
authorNazim Can Altinova <canaltinova@gmail.com>
Wed, 16 Aug 2017 19:22:53 -0700
changeset 647897 b8662036f3dd1aeace25b431d88c85ac1d1147de
parent 647821 5fb80cb7210254a3639f72f30a7525e366749f2c
child 647898 0560d8c1653aa5dac693d725cd255fc6c5144362
push id74573
push userbmo:kevin.hsieh@ucla.edu
push dateThu, 17 Aug 2017 02:25:28 +0000
reviewersdbaron
bugs1367860
milestone56.0a1
Bug 1367860 (part 4) - Update CSS fallback font when lang changes (stylo). r?dbaron MozReview-Commit-ID: AeBHXc0mIVn
layout/style/ServoBindings.cpp
servo/components/style/properties/properties.mako.rs
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -2337,17 +2337,24 @@ Gecko_nsStyleFont_FixupNoneGeneric(nsSty
 
 void
 Gecko_nsStyleFont_PrefillDefaultForGeneric(nsStyleFont* aFont,
                                            RawGeckoPresContextBorrowed aPresContext,
                                            uint8_t aGenericId)
 {
   const nsFont* defaultFont = ThreadSafeGetDefaultFontHelper(aPresContext, aFont->mLanguage,
                                                              aGenericId);
-   aFont->mFont.fontlist = defaultFont->fontlist;
+  // In case of just the language changing, the parent could have had no generic,
+  // which Gecko just does regular cascading with. Do the same.
+  // This can only happen in the case where the language changed but the family did not
+  if (aGenericId != kGenericFont_NONE) {
+    aFont->mFont.fontlist = defaultFont->fontlist;
+  } else {
+    aFont->mFont.fontlist.SetDefaultFontType(defaultFont->fontlist.GetDefaultFontType());
+  }
 }
 
 void
 Gecko_nsStyleFont_FixupMinFontSize(nsStyleFont* aFont,
                                    RawGeckoPresContextBorrowed aPresContext)
 {
   nscoord minFontSize;
   bool needsCache = false;
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -21,17 +21,17 @@ use app_units::Au;
 use cssparser::{Parser, TokenSerializationType, serialize_identifier};
 use cssparser::ParserInput;
 #[cfg(feature = "servo")] use euclid::SideOffsets2D;
 use computed_values;
 use context::QuirksMode;
 use error_reporting::NullReporter;
 use font_metrics::FontMetricsProvider;
 #[cfg(feature = "gecko")] use gecko_bindings::bindings;
-#[cfg(feature = "gecko")] use gecko_bindings::structs::{self, nsCSSPropertyID};
+#[cfg(feature = "gecko")] use gecko_bindings::structs::{nsCSSPropertyID};
 #[cfg(feature = "servo")] use logical_geometry::{LogicalMargin, PhysicalSide};
 use logical_geometry::WritingMode;
 use media_queries::Device;
 use parser::{Parse, ParserContext};
 use properties::animated_properties::AnimatableLonghand;
 #[cfg(feature = "gecko")] use properties::longhands::system_font::SystemFont;
 use selector_parser::PseudoElement;
 use selectors::parser::SelectorParseError;
@@ -3214,30 +3214,25 @@ where
                                 //
                                 // In case of the language changing, we wish for a specified font-
                                 // family to override this, so we do not skip cascading then.
                                 _skip_font_family = true;
                             }
                         }
                     }
 
-                    // In case of just the language changing, the parent could have had no generic,
-                    // which Gecko just does regular cascading with. Do the same.
-                    // This can only happen in the case where the language changed but the family did not
-                    if generic != structs::kGenericFont_NONE {
-                        let pres_context = context.builder.device.pres_context();
-                        let gecko_font = context.builder.mutate_font().gecko_mut();
-                        gecko_font.mGenericID = generic;
-                        unsafe {
-                            bindings::Gecko_nsStyleFont_PrefillDefaultForGeneric(
-                                gecko_font,
-                                pres_context,
-                                generic,
-                            );
-                        }
+                    let pres_context = context.builder.device.pres_context();
+                    let gecko_font = context.builder.mutate_font().gecko_mut();
+                    gecko_font.mGenericID = generic;
+                    unsafe {
+                        bindings::Gecko_nsStyleFont_PrefillDefaultForGeneric(
+                            gecko_font,
+                            pres_context,
+                            generic,
+                        );
                     }
                 }
             % endif
 
             // It is important that font_size is computed before
             // the late properties (for em units), but after font-family
             // (for the base-font-size dependence for default and keyword font-sizes)
             // Additionally, when we support system fonts they will have to be