Bug 1367860 (part 2) - Update CSS fallback font when lang changes. r?dbaron draft
authorKevin Hsieh <kevin.hsieh@ucla.edu>
Wed, 16 Aug 2017 17:34:36 -0700
changeset 648526 7321279bb40d1487bf1e92c92fc0189fb74b8b45
parent 647819 04e977d06785429a561d717ecfb27b25ada04388
child 648527 f74c0772be2463bd1bbec57e257a280270c74773
push id74781
push userbmo:kevin.hsieh@ucla.edu
push dateThu, 17 Aug 2017 22:10:17 +0000
reviewersdbaron
bugs1367860
milestone56.0a1
Bug 1367860 (part 2) - Update CSS fallback font when lang changes. r?dbaron MozReview-Commit-ID: 1VzxKnJJ1kD
layout/style/nsRuleNode.cpp
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -3725,16 +3725,28 @@ nsRuleNode::SetFont(nsPresContext* aPres
       aFont->mGenericID = kGenericFont_NONE;
       break;
     case eCSSUnit_Inherit:
     case eCSSUnit_Unset:
       aConditions.SetUncacheable();
       aFont->mFont.fontlist = aParentFont->mFont.fontlist;
       aFont->mFont.systemFont = aParentFont->mFont.systemFont;
       aFont->mGenericID = aParentFont->mGenericID;
+      MOZ_FALLTHROUGH;  // Fall through here to check for a lang change.
+    case eCSSUnit_Null:
+      // If we have inheritance (cases eCSSUnit_Inherit, eCSSUnit_Unset, and
+      // eCSSUnit_Null) and a (potentially different) language is explicitly
+      // specified, then we need to overwrite the inherited default generic font
+      // with the default generic from defaultVariableFont, which is computed
+      // using aFont->mLanguage above.
+      if (aRuleData->ValueForLang()->GetUnit() != eCSSUnit_Null) {
+        FontFamilyType defaultGeneric =
+          defaultVariableFont->fontlist.GetDefaultFontType();
+        aFont->mFont.fontlist.SetDefaultFontType(defaultGeneric);
+      }
       break;
     case eCSSUnit_Initial:
       aFont->mFont.fontlist = defaultVariableFont->fontlist;
       aFont->mFont.systemFont = defaultVariableFont->systemFont;
       aFont->mGenericID = kGenericFont_NONE;
       break;
     default:
       MOZ_ASSERT_UNREACHABLE("Unexpected unit for font-family");