Skip to content

Truly independent web browser

LibWeb: Keep hidden children waiting for their subtree to show

sideshowbarker01afcb5f629a
diff --git a/Libraries/LibWeb/Rust/src/css/style/pipeline/main_effects.rs b/Libraries/LibWeb/Rust/src/css/style/pipeline/main_effects.rs
index 8a28aed9c89..823877b0ad9 100644
--- a/Libraries/LibWeb/Rust/src/css/style/pipeline/main_effects.rs
+++ b/Libraries/LibWeb/Rust/src/css/style/pipeline/main_effects.rs
@@ -350,7 +350,10 @@ impl RetainedState {
MainEffects::ROOT_FONT_METRICS,
adjustment_facts & element_adjustment_fact::IS_DOCUMENT_ELEMENT != 0,
)
- .with(MainEffects::REVEAL_WAITING, was_none && !is_none(new_values))
+ .with(
+ MainEffects::REVEAL_WAITING,
+ was_none && new.dependency_flags & computed::IN_DISPLAY_NONE_SUBTREE == 0,
+ )
.with(
MainEffects::SVG_REFERENCES,
adjustment_facts & element_adjustment_fact::IS_SVG_ELEMENT != 0,
diff --git a/Tests/LibWeb/Text/expected/css/hidden-container-query-waiting-children.txt b/Tests/LibWeb/Text/expected/css/hidden-container-query-waiting-children.txt
new file mode 100644
index 00000000000..bcfa33d7147
--- /dev/null
+++ b/Tests/LibWeb/Text/expected/css/hidden-container-query-waiting-children.txt
@@ -0,0 +1,3 @@
+Hidden child: 0 x 0
+Visible child: 30 x 20
+Visible container query: rgb(0, 128, 0)
diff --git a/Tests/LibWeb/Text/input/css/hidden-container-query-waiting-children.html b/Tests/LibWeb/Text/input/css/hidden-container-query-waiting-children.html
new file mode 100644
index 00000000000..171e408ce71
--- /dev/null
+++ b/Tests/LibWeb/Text/input/css/hidden-container-query-waiting-children.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html>
+<script src="../include.js"></script>
+<div id="hidden" style="display: none"></div>
+<script>
+ test(() => {
+ hidden.getBoundingClientRect();
+ hidden.innerHTML = `
+ <style>
+ .container { container-type: inline-size; width: 200px; }
+ @container (width > 0px) { .subject { color: green; } }
+ .child { width: 30px; height: 20px; }
+ </style>
+ <div class="container">
+ <div class="subject">
+ <svg><linearGradient id="gradient"><stop /></linearGradient></svg>
+ </div>
+ </div>`;
+ document.body.getBoundingClientRect();
+ const subject = hidden.querySelector(".subject");
+ subject.insertAdjacentHTML("beforeend", '<div class="child"><span>child</span></div>');
+ document.body.getBoundingClientRect();
+ const child = subject.lastElementChild;
+ println(`Hidden child: ${child.getBoundingClientRect().width} x ${child.getBoundingClientRect().height}`);
+ hidden.style.display = "block";
+ println(`Visible child: ${child.getBoundingClientRect().width} x ${child.getBoundingClientRect().height}`);
+ println(`Visible container query: ${getComputedStyle(subject).color}`);
+ });
+</script>