mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
We had two issues with ::backdrop which this commit fixes: ::backdrop is unique in that it's the previous sibling to its originating element, instead of a child of it. This means when that element's layout node is thrown away, the ::backdrop's is not. A second issue is that if we do a partial layout rebuild, the originating element's layout node replaces its previous one, but we would still append a new layout node for ::backdrop to the root, so it would appear in front of the originating element. A related issue is that clear_pseudo_element_nodes() got called on the element after its ::backdrop had been assigned, so it would immediately lose track of it again. To solve this, we now always remove the ::backdrop's layout node. If we need to create a new one, we insert it before the element's layout node if it has one, otherwise we append as before. This ensures we only ever have up to one layout node for the ::backdrop, and it appears behind its originating element. To support this, create_pseudo_element_if_needed() has a couple of changes: - It returns the node that was created. - The caller can ask it not to insert the node, so that the caller can do so (which we use so that we can insert it in a specific place)
14 lines
295 B
HTML
14 lines
295 B
HTML
<!DOCTYPE html>
|
|
<style>
|
|
dialog::backdrop {
|
|
background: rgba(0,0,0,0.5)
|
|
}
|
|
</style><dialog id="d"><input><div id="x"></div></dialog><script>
|
|
d.showModal();
|
|
|
|
for (let i = 0; i < 5; ++i) {
|
|
x.hidden = !x.hidden;
|
|
document.body.offsetWidth; // force layout
|
|
}
|
|
</script>
|