Index: third_party/WebKit/Source/core/css/StyleSheetContents.cpp |
diff --git a/third_party/WebKit/Source/core/css/StyleSheetContents.cpp b/third_party/WebKit/Source/core/css/StyleSheetContents.cpp |
index 2545e41d3cbe37909b5d63a978e8145ea927b356..42640f3030fefa184c8bc75851df6b6d9a54bd7e 100644 |
--- a/third_party/WebKit/Source/core/css/StyleSheetContents.cpp |
+++ b/third_party/WebKit/Source/core/css/StyleSheetContents.cpp |
@@ -87,8 +87,6 @@ StyleSheetContents::StyleSheetContents(const StyleSheetContents& o) |
, m_hasSingleOwnerDocument(true) |
, m_parserContext(o.m_parserContext) |
{ |
- ASSERT(o.isCacheable()); |
- |
// FIXME: Copy import rules. |
ASSERT(o.m_importRules.isEmpty()); |
@@ -109,7 +107,7 @@ void StyleSheetContents::setHasSyntacticallyValidCSSHeader(bool isValidCss) |
m_hasSyntacticallyValidCSSHeader = isValidCss; |
} |
-bool StyleSheetContents::isCacheable() const |
+bool StyleSheetContents::isCacheableForResource() const |
{ |
// This would require dealing with multiple clients for load callbacks. |
if (!loadCompleted()) |
@@ -139,6 +137,22 @@ bool StyleSheetContents::isCacheable() const |
return true; |
} |
+bool StyleSheetContents::isCacheableForStyleElement() const |
+{ |
+ // FIXME: Support copying import rules. |
+ if (!importRules().isEmpty()) |
+ return false; |
+ // Until import rules are supported in cached sheets it's not possible for loading to fail. |
+ DCHECK(!didLoadErrorOccur()); |
+ // It is not the original sheet anymore. |
+ if (isMutable()) |
+ return false; |
+ if (!hasSyntacticallyValidCSSHeader()) |
+ return false; |
+ return true; |
+} |
+ |
+ |
void StyleSheetContents::parserAppendRule(StyleRuleBase* rule) |
{ |
if (rule->isImportRule()) { |
@@ -500,7 +514,7 @@ static bool childRulesHaveFailedOrCanceledSubresources(const HeapVector<Member<S |
bool StyleSheetContents::hasFailedOrCanceledSubresources() const |
{ |
- ASSERT(isCacheable()); |
+ ASSERT(isCacheableForResource()); |
return childRulesHaveFailedOrCanceledSubresources(m_childRules); |
} |
@@ -575,7 +589,7 @@ void StyleSheetContents::removeSheetFromCache(Document* document) |
void StyleSheetContents::setReferencedFromResource(bool referenced) |
{ |
ASSERT(referenced != m_isReferencedFromResource); |
- ASSERT(isCacheable()); |
+ ASSERT(isCacheableForResource()); |
m_isReferencedFromResource = referenced; |
} |