-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shadow DOM: Toggling class in
.class ::slotted(*)
does not trigger …
…style recalc https://bugs.webkit.org/show_bug.cgi?id=160864 Reviewed by Ryosuke Niwa. Source/WebCore: Also fix similar issue with ::host Test: fast/shadow-dom/css-scoping-host-and-slotted-context-invalidation.html * css/StyleInvalidationAnalysis.cpp: (WebCore::StyleInvalidationAnalysis::invalidateIfNeeded): If we have ::slotted rules and encounter a <slot>, invalidate the slotted host children. (WebCore::StyleInvalidationAnalysis::invalidateStyle): Invalidate the shadow host if we have ::host rules. * css/StyleInvalidationAnalysis.h: * dom/InlineStyleSheetOwner.cpp: (WebCore::InlineStyleSheetOwner::createSheet): Fix a bug where it was possible to mutate stylesheets in the inline stylesheet cache. The included test covers this. * style/StyleScope.cpp: (WebCore::Style::Scope::updateActiveStyleSheets): Handle the full invalidation case. LayoutTests: * fast/shadow-dom/css-scoping-host-and-slotted-context-invalidation-expected.html: Added. * fast/shadow-dom/css-scoping-host-and-slotted-context-invalidation.html: Added. Canonical link: https://commits.webkit.org/182333@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208610 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
8 changed files
with
164 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
LayoutTests/fast/shadow-dom/css-scoping-host-and-slotted-context-invalidation-expected.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<p>Test passes if you see a single 100px by 100px green box below.</p> | ||
<div style="width: 100px; height: 100px; background: green;"></div> | ||
</body> | ||
</html> |
83 changes: 83 additions & 0 deletions
83
LayoutTests/fast/shadow-dom/css-scoping-host-and-slotted-context-invalidation.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<!DOCTYPE html> | ||
<body> | ||
<p>Test passes if you see a single 100px by 100px green box below.</p> | ||
<div id="t1"> | ||
<span>FAIL</span> | ||
</div> | ||
<div id="t2"> | ||
<span slot="second">FAIL</span> | ||
</div> | ||
<div id="t3"> | ||
<span>FAIL</span> | ||
</div> | ||
<div id="t4"> | ||
<span>FAIL</span> | ||
</div> | ||
<div id="t5"> | ||
<span>FAIL</span> | ||
</div> | ||
<script> | ||
|
||
function attachShadow(host) | ||
{ | ||
const shadow = host.attachShadow({mode: 'closed'}); | ||
shadow.innerHTML = ` | ||
<style> | ||
:host { | ||
width: 100px; | ||
height: 20px; | ||
background: green; | ||
color: red; | ||
} | ||
</style> | ||
<div><slot></slot></div> | ||
<div id="second-parent"><slot name="second"></slot></div> | ||
`; | ||
return shadow; | ||
} | ||
|
||
{ | ||
const host = document.querySelector('#t1'); | ||
const shadow = attachShadow(host); | ||
const style = shadow.querySelector('style'); | ||
style.sheet.insertRule(".selected ::slotted(*) { color: green }"); | ||
getComputedStyle(host.querySelector('span')).backgroundColor; | ||
const div = shadow.querySelector('div'); | ||
div.className = 'selected'; | ||
} | ||
|
||
{ | ||
const host = document.querySelector('#t2'); | ||
const shadow = attachShadow(host); | ||
getComputedStyle(host.querySelector('span')).backgroundColor; | ||
const style = shadow.querySelector('style'); | ||
style.sheet.insertRule("#second-parent ::slotted(*) { color: green }"); | ||
} | ||
|
||
{ | ||
const host = document.querySelector('#t3'); | ||
const shadow = attachShadow(host); | ||
getComputedStyle(host.querySelector('span')).backgroundColor; | ||
const style = document.createElement("style"); | ||
style.textContent = "div ::slotted(*) { color: green }"; | ||
shadow.appendChild(style); | ||
} | ||
|
||
{ | ||
const host = document.querySelector('#t4'); | ||
const shadow = attachShadow(host); | ||
getComputedStyle(host.querySelector('span')).backgroundColor; | ||
const style = shadow.querySelector('style'); | ||
style.sheet.insertRule(":host { color: green }", 1); | ||
} | ||
|
||
{ | ||
const host = document.querySelector('#t5'); | ||
const shadow = attachShadow(host); | ||
getComputedStyle(host.querySelector('span')).backgroundColor; | ||
const style = document.createElement("style"); | ||
style.textContent = ":host(div) { color: green }"; | ||
shadow.appendChild(style) | ||
} | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters