Commit 9ea74b3f authored by rune's avatar rune Committed by Commit bot

Use setNeedsActiveStyleUpdate instead of markTreeScopeDirty.

setNeedsActiveStyleUpdate checks if the document is active before
calling markTreeScopeDirty. This avoids marking shadow root tree scopes
dirty for non-active documents which caused a DCHECK fail in
markTreeScopeDirty.

R=esprehn@chromium.org
BUG=676441

Review-Url: https://codereview.chromium.org/2611053004
Cr-Commit-Position: refs/heads/master@{#442028}
parent d0aa1ff2
<!DOCTYPE html>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
<div id="host">
<iframe id="iframe"></iframe>
</div>
<script>
test(() => {
host.attachShadow({mode:"open"}).innerHTML = "<style></style>";
iframe.contentDocument.documentElement.appendChild(host);
}, "Inserting a shadow host with an iframe child into that iframes document should not crash or assert.");
</script>
...@@ -169,7 +169,7 @@ void StyleEngine::addPendingSheet(StyleEngineContext& context) { ...@@ -169,7 +169,7 @@ void StyleEngine::addPendingSheet(StyleEngineContext& context) {
void StyleEngine::removePendingSheet(Node& styleSheetCandidateNode, void StyleEngine::removePendingSheet(Node& styleSheetCandidateNode,
const StyleEngineContext& context) { const StyleEngineContext& context) {
if (styleSheetCandidateNode.isConnected()) if (styleSheetCandidateNode.isConnected())
markTreeScopeDirty(styleSheetCandidateNode.treeScope()); setNeedsActiveStyleUpdate(styleSheetCandidateNode.treeScope());
if (context.addedPendingSheetBeforeBody()) { if (context.addedPendingSheetBeforeBody()) {
DCHECK_GT(m_pendingRenderBlockingStylesheets, 0); DCHECK_GT(m_pendingRenderBlockingStylesheets, 0);
...@@ -203,7 +203,7 @@ void StyleEngine::addStyleSheetCandidateNode(Node& node) { ...@@ -203,7 +203,7 @@ void StyleEngine::addStyleSheetCandidateNode(Node& node) {
DCHECK(collection); DCHECK(collection);
collection->addStyleSheetCandidateNode(node); collection->addStyleSheetCandidateNode(node);
markTreeScopeDirty(treeScope); setNeedsActiveStyleUpdate(treeScope);
if (treeScope != m_document) if (treeScope != m_document)
m_activeTreeScopes.add(&treeScope); m_activeTreeScopes.add(&treeScope);
} }
...@@ -227,12 +227,12 @@ void StyleEngine::removeStyleSheetCandidateNode(Node& node, ...@@ -227,12 +227,12 @@ void StyleEngine::removeStyleSheetCandidateNode(Node& node,
return; return;
collection->removeStyleSheetCandidateNode(node); collection->removeStyleSheetCandidateNode(node);
markTreeScopeDirty(treeScope); setNeedsActiveStyleUpdate(treeScope);
} }
void StyleEngine::modifiedStyleSheetCandidateNode(Node& node) { void StyleEngine::modifiedStyleSheetCandidateNode(Node& node) {
if (node.isConnected()) if (node.isConnected())
markTreeScopeDirty(node.treeScope()); setNeedsActiveStyleUpdate(node.treeScope());
} }
void StyleEngine::mediaQueriesChangedInScope(TreeScope& treeScope) { void StyleEngine::mediaQueriesChangedInScope(TreeScope& treeScope) {
......
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