Bug 1339627 Part 2: Change StyleSheet Loader to attempt to cache ServoStyleSheets.
MozReview-Commit-ID: 55PJm0H9ltv
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -1110,26 +1110,21 @@ Loader::CreateSheet(nsIURI* aURI,
*aIsAlternate = IsAlternate(aTitle, aHasAlternateRel);
if (aURI) {
aSheetState = eSheetComplete;
RefPtr<StyleSheet> sheet;
// First, the XUL cache
#ifdef MOZ_XUL
- // The XUL cache is a singleton that only holds Gecko-style sheets, so
- // only use the cache if the loader is also Gecko.
- if (IsChromeURI(aURI) &&
- GetStyleBackendType() == StyleBackendType::Gecko) {
+ if (IsChromeURI(aURI)) {
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
- if (cache) {
- if (cache->IsEnabled()) {
- sheet = cache->GetStyleSheet(aURI, GetStyleBackendType());
- LOG((" From XUL cache: %p", sheet.get()));
- }
+ if (cache && cache->IsEnabled()) {
+ sheet = cache->GetStyleSheet(aURI, GetStyleBackendType());
+ LOG((" From XUL cache: %p", sheet.get()));
}
}
#endif
bool fromCompleteSheets = false;
if (!sheet) {
// Then our per-document complete sheets.
URIPrincipalReferrerPolicyAndCORSModeHashKey key(aURI, aLoaderPrincipal, aCORSMode, aReferrerPolicy);
@@ -1952,18 +1947,17 @@ Loader::DoSheetComplete(SheetLoadData* a
while (data) {
if (data->mSheet->GetParentSheet() || data->mSheet->GetOwnerNode()) {
sheet = data->mSheet;
break;
}
data = data->mNext;
}
#ifdef MOZ_XUL
- if (IsChromeURI(aLoadData->mURI) &&
- GetStyleBackendType() == StyleBackendType::Gecko) {
+ if (IsChromeURI(aLoadData->mURI)) {
nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
if (cache && cache->IsEnabled()) {
if (!cache->GetStyleSheet(aLoadData->mURI, GetStyleBackendType())) {
LOG((" Putting sheet in XUL prototype cache"));
NS_ASSERTION(sheet->IsComplete(),
"Should only be caching complete sheets");
cache->PutStyleSheet(sheet, GetStyleBackendType());
}