mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
LibWeb: Recompute child style when parent's display changes
When a parent element's display property changes (e.g., to flex or grid), children may need to be blockified or un-blockified. Previously, children only received a recompute_inherited_style() call which doesn't run the blockification logic. This patch adds a parent_display_changed flag to the recursive style update that forces children to get a full style recompute when their parent's display change triggers a layout tree rebuild.
This commit is contained in:
committed by
Andreas Kling
parent
5fc276872a
commit
3b90eb1d49
Notes:
github-actions[bot]
2026-02-06 11:06:45 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/3b90eb1d49c Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7623 Reviewed-by: https://github.com/tcl3
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<link rel="author" href="mailto:kling@ladybird.org">
|
||||
<script src="../include.js"></script>
|
||||
<style>
|
||||
#container { display: block; }
|
||||
</style>
|
||||
<div id="container">
|
||||
<span id="child">test</span>
|
||||
</div>
|
||||
<script>
|
||||
test(() => {
|
||||
const container = document.getElementById("container");
|
||||
const child = document.getElementById("child");
|
||||
|
||||
// Initially, span should be inline
|
||||
println(`Initial child display: ${getComputedStyle(child).display}`);
|
||||
|
||||
// Change parent to flex - child should get blockified
|
||||
container.style.display = "flex";
|
||||
|
||||
// Query color first (doesn't need layout) to trigger only update_style()
|
||||
println(`Color after flex: ${getComputedStyle(child).color}`);
|
||||
println(`Display after flex: ${getComputedStyle(child).display}`);
|
||||
|
||||
// Change parent back to block - child should un-blockify
|
||||
container.style.display = "block";
|
||||
println(`Display after block: ${getComputedStyle(child).display}`);
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user