Bug 1239496 - Load the UA sheet lazily so we can invalidate it for pref changes. Make it depend on the "layout.css.grid.enabled" pref. r=heycam

This commit is contained in:
Mats Palmgren 2016-01-14 23:11:44 +01:00
parent 2b3cc19822
commit b58fdee852

View File

@ -128,6 +128,12 @@ CSSStyleSheet*
nsLayoutStylesheetCache::UASheet()
{
EnsureGlobal();
if (!gStyleCache->mUASheet) {
LoadSheetURL("resource://gre-resources/ua.css",
gStyleCache->mUASheet, eAgentSheetFeatures);
}
return gStyleCache->mUASheet;
}
@ -346,8 +352,6 @@ nsLayoutStylesheetCache::nsLayoutStylesheetCache()
mQuirkSheet, eAgentSheetFeatures);
LoadSheetURL("resource://gre/res/svg.css",
mSVGSheet, eAgentSheetFeatures);
LoadSheetURL("resource://gre-resources/ua.css",
mUASheet, eAgentSheetFeatures);
LoadSheetURL("chrome://global/content/xul.css",
mXULSheet, eAgentSheetFeatures);
@ -388,6 +392,8 @@ nsLayoutStylesheetCache::EnsureGlobal()
// style sheets will be re-parsed.
// Preferences::RegisterCallback(&DependentPrefChanged,
// "layout.css.example-pref.enabled");
Preferences::RegisterCallback(&DependentPrefChanged,
"layout.css.grid.enabled");
}
void
@ -790,7 +796,7 @@ nsLayoutStylesheetCache::DependentPrefChanged(const char* aPref, void* aData)
// to be re-parsed by dropping the sheet from gCSSLoader's cache then
// setting our cached sheet pointer to null. This will only work for sheets
// that are loaded lazily.
// InvalidateSheet(gStyleCache->mSomeLazilyLoadedSheet);
InvalidateSheet(gStyleCache->mUASheet); // for layout.css.grid.enabled
}
/* static */ void