Bug 1290218 Part 7: Bypass XULPrototypeCache (which is a singleton) for non-Gecko Loaders. draft
authorBrad Werth <bwerth@mozilla.com>
Wed, 01 Feb 2017 16:21:41 -0800
changeset 480746 1e9791e27c1f7837c548689954f8ee09c53df123
parent 480745 76e04a255f32eb344ae78c362f0e7923f07401b8
child 480747 4a8862b9fb6e9d759d01fe91ac8cd4aef69d70af
push id44647
push userbwerth@mozilla.com
push dateWed, 08 Feb 2017 21:49:09 +0000
bugs1290218
milestone54.0a1
Bug 1290218 Part 7: Bypass XULPrototypeCache (which is a singleton) for non-Gecko Loaders. MozReview-Commit-ID: 852rcD2bdYL
layout/style/Loader.cpp
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -1101,17 +1101,21 @@ Loader::CreateSheet(nsIURI* aURI,
 
   // XXXheycam Cached sheets currently must be CSSStyleSheets.
   if (aURI && GetStyleBackendType() == StyleBackendType::Gecko) {
     aSheetState = eSheetComplete;
     RefPtr<StyleSheet> sheet;
 
     // First, the XUL cache
 #ifdef MOZ_XUL
-    if (IsChromeURI(aURI)) {
+    // 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) &&
+        mStyleBackendType.isSome() &&
+        mStyleBackendType.value() == StyleBackendType::Gecko) {
       nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
       if (cache) {
         if (cache->IsEnabled()) {
           sheet = cache->GetStyleSheet(aURI);
           LOG(("  From XUL cache: %p", sheet.get()));
         }
       }
     }
@@ -1945,17 +1949,19 @@ Loader::DoSheetComplete(SheetLoadData* a
       while (data) {
         if (data->mSheet->GetParentSheet() || data->mSheet->GetOwnerNode()) {
           sheet = data->mSheet->AsGecko();
           break;
         }
         data = data->mNext;
       }
 #ifdef MOZ_XUL
-      if (IsChromeURI(aLoadData->mURI)) {
+      if (IsChromeURI(aLoadData->mURI) &&
+              mStyleBackendType.isSome() &&
+              mStyleBackendType.value() == StyleBackendType::Gecko) {
         nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
         if (cache && cache->IsEnabled()) {
           if (!cache->GetStyleSheet(aLoadData->mURI)) {
             LOG(("  Putting sheet in XUL prototype cache"));
             NS_ASSERTION(sheet->IsComplete(),
                          "Should only be caching complete sheets");
             cache->PutStyleSheet(sheet);
           }