Bug 1339627 Part 2: Change StyleSheet Loader to attempt to cache ServoStyleSheets. draft
authorBrad Werth <bwerth@mozilla.com>
Mon, 27 Feb 2017 11:20:48 -0800
changeset 494447 8d3063e4d7a70df5a337e0158fbb1c117ffd3e8f
parent 494446 ffa7a4300926baae0322d0198ae75d99e3960df6
child 548097 7f44e216e9c1358fc932dcdb1397013cc9ca9ac0
push id48028
push userbwerth@mozilla.com
push dateTue, 07 Mar 2017 03:31:23 +0000
bugs1339627
milestone55.0a1
Bug 1339627 Part 2: Change StyleSheet Loader to attempt to cache ServoStyleSheets. MozReview-Commit-ID: 55PJm0H9ltv
layout/style/Loader.cpp
--- 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());
         }