Bug 1290218 Part 7: Bypass XULPrototypeCache (which is a singleton) for non-Gecko Loaders. draft
authorBrad Werth <bwerth@mozilla.com>
Tue, 14 Feb 2017 14:44:37 -0800
changeset 488925 2100417a1b0c7ae8cd5c6b06686abfa5b27e451e
parent 488924 901c93de8ea17900460582ca6f4b924561843e64
child 488926 a80f23d967f552c0a10c4e95009e4846826c8c2b
push id46687
push userbwerth@mozilla.com
push dateFri, 24 Feb 2017 01:52:48 +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
@@ -1111,17 +1111,20 @@ 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) &&
+        GetStyleBackendType() == StyleBackendType::Gecko) {
       nsXULPrototypeCache* cache = nsXULPrototypeCache::GetInstance();
       if (cache) {
         if (cache->IsEnabled()) {
           sheet = cache->GetStyleSheet(aURI);
           LOG(("  From XUL cache: %p", sheet.get()));
         }
       }
     }
@@ -1955,17 +1958,18 @@ 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) &&
+          GetStyleBackendType() == 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);
           }