Bug 1362599 - Use lock in Gecko_nsStyleFont_FixupNoneGeneric ; r?heycam draft
authorManish Goregaokar <manishearth@gmail.com>
Fri, 05 May 2017 17:10:38 -0700
changeset 573743 4b957d6a48bffd6de892ebaebdfd6dccc31a20e4
parent 573006 621f4c3c7218a66cff30df7220dc318989dcff88
child 573744 d595c1b2716c20e668da10c21e4b203c56353ec5
child 574410 9bad842044484ed6e667008717e00a67735f2832
push id57488
push userbmo:manishearth@gmail.com
push dateSun, 07 May 2017 03:24:30 +0000
reviewersheycam
bugs1362599
milestone55.0a1
Bug 1362599 - Use lock in Gecko_nsStyleFont_FixupNoneGeneric ; r?heycam MozReview-Commit-ID: 7CiR2sZzDgM
intl/locale/nsLanguageAtomService.cpp
js/src/devtools/rootAnalysis/analyzeHeapWrites.js
layout/base/StaticPresData.cpp
layout/style/ServoSpecifiedValues.cpp
--- a/intl/locale/nsLanguageAtomService.cpp
+++ b/intl/locale/nsLanguageAtomService.cpp
@@ -65,16 +65,17 @@ nsIAtom*
 nsLanguageAtomService::GetLanguageGroup(nsIAtom* aLanguage,
                                         nsresult* aError)
 {
   nsIAtom* retVal;
 
   retVal = mLangToGroup.GetWeak(aLanguage);
 
   if (!retVal) {
+    MOZ_ASSERT(NS_IsMainThread(), "Should not append to cache off main thread");
     nsCOMPtr<nsIAtom> uncached = GetUncachedLanguageGroup(aLanguage, aError);
     retVal = uncached.get();
 
     // The hashtable will keep an owning reference to the atom
     mLangToGroup.Put(aLanguage, uncached);
   }
 
   return retVal;
--- a/js/src/devtools/rootAnalysis/analyzeHeapWrites.js
+++ b/js/src/devtools/rootAnalysis/analyzeHeapWrites.js
@@ -207,16 +207,17 @@ function treatAsSafeArgument(entry, varN
         ["Gecko_ClearWillChange", "aDisplay", null],
         ["Gecko_AppendWillChange", "aDisplay", null],
         ["Gecko_CopyWillChangeFrom", "aDest", null],
         ["Gecko_InitializeImageCropRect", "aImage", null],
         ["Gecko_CopyShapeSourceFrom", "aDst", null],
         ["Gecko_DestroyShapeSource", "aShape", null],
         ["Gecko_StyleShapeSource_SetURLValue", "aShape", null],
         ["Gecko_nsFont_InitSystem", "aDest", null],
+        ["Gecko_nsStyleFont_FixupNoneGeneric", "aFont", null],
         ["Gecko_StyleTransition_SetUnsupportedProperty", "aTransition", null],
     ];
     for (var [entryMatch, varMatch, csuMatch] of whitelist) {
         assert(entryMatch || varMatch || csuMatch);
         if (entryMatch && !nameMatches(entry.name, entryMatch))
             continue;
         if (varMatch && !nameMatches(varName, varMatch))
             continue;
--- a/layout/base/StaticPresData.cpp
+++ b/layout/base/StaticPresData.cpp
@@ -277,21 +277,23 @@ StaticPresData::GetFontPrefsForLangHelpe
       if (prefs->mLangGroup == langGroupAtom) {
         return prefs;
       }
       if (!prefs->mNext) {
         break;
       }
       prefs = prefs->mNext;
     }
-
+    MOZ_ASSERT(NS_IsMainThread(), "Should not append to cache off main thread");
     // nothing cached, so go on and fetch the prefs for this lang group:
     prefs = prefs->mNext = new LangGroupFontPrefs;
   }
 
+  MOZ_ASSERT(NS_IsMainThread(), "Should not append to cache off main thread");
+
   prefs->Initialize(langGroupAtom);
 
   return prefs;
 }
 
 const nsFont*
 StaticPresData::GetDefaultFontHelper(uint8_t aFontID, nsIAtom *aLanguage,
                                      const LangGroupFontPrefs* aPrefs) const
--- a/layout/style/ServoSpecifiedValues.cpp
+++ b/layout/style/ServoSpecifiedValues.cpp
@@ -43,16 +43,22 @@ ServoSpecifiedValues::PropertyIsSet(nsCS
 }
 
 void
 ServoSpecifiedValues::SetIdentStringValue(nsCSSPropertyID aId,
                                           const nsString& aValue)
 {
   nsCOMPtr<nsIAtom> atom = NS_Atomize(aValue);
   Servo_DeclarationBlock_SetIdentStringValue(mDecl, aId, atom);
+  if (aId == eCSSProperty__x_lang) {
+    // This forces the lang prefs result to be cached
+    // so that we can access them off main thread during traversal
+    mPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID,
+                                 atom);
+  }
 }
 
 void
 ServoSpecifiedValues::SetKeywordValue(nsCSSPropertyID aId, int32_t aValue)
 {
   Servo_DeclarationBlock_SetKeywordValue(mDecl, aId, aValue);
 }