Issue #2112 - Part 7: Remove Servo CSS Loader support

This commit is contained in:
FranklinDM 2024-03-25 16:57:34 +08:00 committed by roytam1
commit 14764253a5
17 changed files with 37 additions and 87 deletions

View file

@ -237,8 +237,7 @@ nsLayoutStylesheetCache::DesignModeSheet()
void
nsLayoutStylesheetCache::Shutdown()
{
gCSSLoader_Gecko = nullptr;
gCSSLoader_Servo = nullptr;
gCSSLoader = nullptr;
gStyleCache_Gecko = nullptr;
gStyleCache_Servo = nullptr;
MOZ_ASSERT(!gUserContentSheetURL, "Got the URL but never used?");
@ -295,14 +294,12 @@ nsLayoutStylesheetCache::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf
// Measurement of the following members may be added later if DMD finds it is
// worthwhile:
// - gCSSLoader_Gecko
// - gCSSLoader_Servo
// - gCSSLoader
return n;
}
nsLayoutStylesheetCache::nsLayoutStylesheetCache(StyleBackendType aType)
: mBackendType(aType)
nsLayoutStylesheetCache::nsLayoutStylesheetCache()
{
nsCOMPtr<nsIObserverService> obsSvc =
mozilla::services::GetObserverService();
@ -353,16 +350,15 @@ nsLayoutStylesheetCache::InitMemoryReporter()
}
/* static */ nsLayoutStylesheetCache*
nsLayoutStylesheetCache::For(StyleBackendType aType)
nsLayoutStylesheetCache::Get()
{
MOZ_ASSERT(NS_IsMainThread());
bool mustInit = !gStyleCache_Gecko && !gStyleCache_Servo;
auto& cache = aType == StyleBackendType::Gecko ? gStyleCache_Gecko :
gStyleCache_Servo;
auto& cache = gStyleCache_Gecko;
if (!cache) {
cache = new nsLayoutStylesheetCache(aType);
cache = new nsLayoutStylesheetCache();
cache->InitMemoryReporter();
}
@ -475,19 +471,15 @@ nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI,
return;
}
auto& loader = mBackendType == StyleBackendType::Gecko ?
gCSSLoader_Gecko :
gCSSLoader_Servo;
if (!loader) {
loader = new mozilla::css::Loader(mBackendType);
if (!loader) {
if (!gCSSLoader) {
gCSSLoader = new mozilla::css::Loader();
if (!gCSSLoader) {
ErrorLoadingSheet(aURI, "no Loader", eCrash);
return;
}
}
nsresult rv = loader->LoadSheetSync(aURI, aParsingMode, true, aSheet);
nsresult rv = gCSSLoader->LoadSheetSync(aURI, aParsingMode, true, aSheet);
if (NS_FAILED(rv)) {
ErrorLoadingSheet(aURI,
nsPrintfCString("LoadSheetSync failed with error %x", rv).get(),
@ -499,8 +491,7 @@ nsLayoutStylesheetCache::LoadSheet(nsIURI* aURI,
nsLayoutStylesheetCache::InvalidateSheet(RefPtr<StyleSheet>* aGeckoSheet,
RefPtr<StyleSheet>* aServoSheet)
{
MOZ_ASSERT(gCSSLoader_Gecko || gCSSLoader_Servo,
"pref changed before we loaded a sheet?");
MOZ_ASSERT(gCSSLoader, "pref changed before we loaded a sheet?");
const bool gotGeckoSheet = aGeckoSheet && *aGeckoSheet;
const bool gotServoSheet = aServoSheet && *aServoSheet;
@ -519,11 +510,8 @@ nsLayoutStylesheetCache::InvalidateSheet(RefPtr<StyleSheet>* aGeckoSheet,
return;
}
if (gCSSLoader_Gecko) {
gCSSLoader_Gecko->ObsoleteSheet(uri);
}
if (gCSSLoader_Servo) {
gCSSLoader_Servo->ObsoleteSheet(uri);
if (gCSSLoader) {
gCSSLoader->ObsoleteSheet(uri);
}
if (gotGeckoSheet) {
*aGeckoSheet = nullptr;
@ -540,7 +528,7 @@ nsLayoutStylesheetCache::DependentPrefChanged(const char* aPref, void* aData)
"pref changed after shutdown?");
// Cause any UA style sheets whose parsing depends on the value of prefs
// to be re-parsed by dropping the sheet from gCSSLoader_{Gecko,Servo}'s cache
// 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.
@ -679,10 +667,7 @@ mozilla::StaticRefPtr<nsLayoutStylesheetCache>
nsLayoutStylesheetCache::gStyleCache_Servo;
mozilla::StaticRefPtr<mozilla::css::Loader>
nsLayoutStylesheetCache::gCSSLoader_Gecko;
mozilla::StaticRefPtr<mozilla::css::Loader>
nsLayoutStylesheetCache::gCSSLoader_Servo;
nsLayoutStylesheetCache::gCSSLoader;
mozilla::StaticRefPtr<nsIURI>
nsLayoutStylesheetCache::gUserContentSheetURL;