Chromium Code Reviews| Index: Source/core/dom/StyleEngine.cpp |
| diff --git a/Source/core/dom/StyleEngine.cpp b/Source/core/dom/StyleEngine.cpp |
| index 65ed280169245b6df8811c6e0c8bccecdd1dbd00..8766944e343c41f06a5c8795a283aec3082f0279 100644 |
| --- a/Source/core/dom/StyleEngine.cpp |
| +++ b/Source/core/dom/StyleEngine.cpp |
| @@ -562,6 +562,21 @@ void StyleEngine::markDocumentDirty() |
| m_document.import()->master()->styleEngine()->markDocumentDirty(); |
| } |
| +static bool isCacheableForInlineStyle(const StyleSheetContents& contents) |
|
esprehn
2014/03/19 22:32:14
inline style actually means the style attribute, I
adamk
2014/03/19 22:40:17
You're right, when I re-read this name it sounded
|
| +{ |
| + // FIXME: Support copying import rules. |
| + if (!contents.importRules().isEmpty()) |
| + return false; |
| + // Until import rules are supported in cached sheets it's not possible for loading to fail. |
| + ASSERT(!contents.didLoadErrorOccur()); |
| + // It is not the original sheet anymore. |
| + if (contents.isMutable()) |
| + return false; |
| + if (!contents.hasSyntacticallyValidCSSHeader()) |
| + return false; |
| + return true; |
| +} |
| + |
| PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& text, TextPosition startPosition, bool createdByParser) |
| { |
| RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet; |
| @@ -574,14 +589,16 @@ PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const |
| HashMap<AtomicString, StyleSheetContents*>::AddResult result = m_textToSheetCache.add(textContent, 0); |
| if (result.isNewEntry || !result.storedValue->value) { |
| styleSheet = StyleEngine::parseSheet(e, text, startPosition, createdByParser); |
| - if (result.isNewEntry && styleSheet->contents()->maybeCacheable()) { |
| + if (result.isNewEntry && isCacheableForInlineStyle(*styleSheet->contents())) { |
| result.storedValue->value = styleSheet->contents(); |
| m_sheetToTextCache.add(styleSheet->contents(), textContent); |
| } |
| } else { |
| - ASSERT(result.storedValue->value->maybeCacheable()); |
| - ASSERT(result.storedValue->value->singleOwnerDocument() == e->document()); |
| - styleSheet = CSSStyleSheet::createInline(result.storedValue->value, e, startPosition); |
| + StyleSheetContents* contents = result.storedValue->value; |
| + ASSERT(contents); |
| + ASSERT(isCacheableForInlineStyle(*contents)); |
| + ASSERT(contents->singleOwnerDocument() == e->document()); |
| + styleSheet = CSSStyleSheet::createInline(contents, e, startPosition); |
| } |
| } else { |
| // FIXME: currently we don't cache StyleSheetContents inQuirksMode. |