Commit 7e1e5f27 authored by tasak@google.com's avatar tasak@google.com

Should remove StyleSheetContents from cache even if document is not active.

StyleSheetContents cache works independent of document's active(),
because StyleElement::process() always invokes StyleEngine::createSheet().

So removeSheetFromCache should also remove 'this' from the cache independent of document's active().

BUG=353894
TEST=fast/dom/move-style-element-to-inactive-document-crash.html

Review URL: https://codereview.chromium.org/204423002

git-svn-id: svn://svn.chromium.org/blink/trunk@169595 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e7268dee
<!DOCTYPE html>
<body>
<script>
if (window.testRunner)
testRunner.dumpAsText();
onload = function() {
var style = document.createElement("style");
document.body.appendChild(style);
var option = document.createElement("option");
var newdoc = document.implementation.createDocument("", null);
newdoc.appendChild(document.body);
style.appendChild(option);
document.body = document.createElement('body');
document.body.innerHTML = 'PASS if no crash.';
}
</script>
</body>
...@@ -162,7 +162,8 @@ void CSSStyleSheet::willMutateRules() ...@@ -162,7 +162,8 @@ void CSSStyleSheet::willMutateRules()
// If we are the only client it is safe to mutate. // If we are the only client it is safe to mutate.
if (m_contents->clientSize() <= 1 && !m_contents->isInMemoryCache()) { if (m_contents->clientSize() <= 1 && !m_contents->isInMemoryCache()) {
m_contents->clearRuleSet(); m_contents->clearRuleSet();
m_contents->removeSheetFromCache(ownerDocument()); if (Document* document = ownerDocument())
m_contents->removeSheetFromCache(document);
m_contents->setMutable(); m_contents->setMutable();
return; return;
} }
......
...@@ -588,10 +588,9 @@ void StyleSheetContents::clientLoadStarted(CSSStyleSheet* sheet) ...@@ -588,10 +588,9 @@ void StyleSheetContents::clientLoadStarted(CSSStyleSheet* sheet)
void StyleSheetContents::removeSheetFromCache(Document* document) void StyleSheetContents::removeSheetFromCache(Document* document)
{ {
ASSERT(document);
if (!maybeCacheable()) if (!maybeCacheable())
return; return;
if (!document || !document->isActive())
return;
document->styleEngine()->removeSheet(this); document->styleEngine()->removeSheet(this);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment