Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Unified Diff: third_party/WebKit/Source/core/css/StyleSheetContents.cpp

Issue 1961173003: Corrected assert for cacheable stylesheets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
}
« no previous file with comments | « third_party/WebKit/Source/core/css/StyleSheetContents.h ('k') | third_party/WebKit/Source/core/dom/StyleEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698