mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-08 05:27:14 +09:00
LibWeb: Invalidate layout tree at nearest non-anonymous ancestor
When marking a part of the layout tree for rebuild, if the subtree root that we're marking has an anonymous parent, we now mark from the nearest non-anonymous ancestor instead. This ensures that subtrees inside anonymous wrappers don't just get duplicated (i.e recreated but inserted instead of replaced).
This commit is contained in:
parent
93cd17db74
commit
6dba720370
Notes:
github-actions[bot]
2025-06-03 22:44:28 +00:00
Author: https://github.com/awesomekling
Commit: 6dba720370
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4987
3 changed files with 52 additions and 1 deletions
|
@ -1634,8 +1634,19 @@ void Node::set_needs_layout_tree_update(bool value, SetNeedsLayoutTreeUpdateReas
|
||||||
break;
|
break;
|
||||||
ancestor->m_child_needs_layout_tree_update = true;
|
ancestor->m_child_needs_layout_tree_update = true;
|
||||||
}
|
}
|
||||||
if (auto layout_node = this->layout_node())
|
if (auto layout_node = this->layout_node()) {
|
||||||
layout_node->set_needs_layout_update(SetNeedsLayoutReason::LayoutTreeUpdate);
|
layout_node->set_needs_layout_update(SetNeedsLayoutReason::LayoutTreeUpdate);
|
||||||
|
|
||||||
|
// If the layout node has an anonymous parent, rebuild from the nearest non-anonymous ancestor.
|
||||||
|
// FIXME: This is not optimal, and we should figure out how to rebuild a smaller part of the tree.
|
||||||
|
if (layout_node->parent() && layout_node->parent()->is_anonymous()) {
|
||||||
|
GC::Ptr<Layout::Node> ancestor = layout_node->parent();
|
||||||
|
while (ancestor && ancestor->is_anonymous())
|
||||||
|
ancestor = ancestor->parent();
|
||||||
|
if (ancestor)
|
||||||
|
ancestor->dom_node()->set_needs_layout_tree_update(true, reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||||
|
BlockContainer <html> at (0,0) content-size 800x79.875 [BFC] children: not-inline
|
||||||
|
BlockContainer <body> at (8,21.4375) content-size 784x37 children: not-inline
|
||||||
|
BlockContainer <(anonymous)> at (8,21.4375) content-size 784x0 children: inline
|
||||||
|
InlineNode <a>
|
||||||
|
InlineNode <span#foo>
|
||||||
|
BlockContainer <(anonymous)> at (8,21.4375) content-size 784x37 children: not-inline continuation
|
||||||
|
BlockContainer <h1> at (8,21.4375) content-size 784x37 children: inline
|
||||||
|
frag 0 from TextNode start: 0, length: 4, rect: [8,21.4375 63.5625x37] baseline: 28.09375
|
||||||
|
"test"
|
||||||
|
TextNode <#text>
|
||||||
|
BlockContainer <(anonymous)> at (8,79.875) content-size 784x0 children: inline
|
||||||
|
InlineNode <a> continuation
|
||||||
|
TextNode <#text>
|
||||||
|
|
||||||
|
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||||
|
PaintableWithLines (BlockContainer<HTML>) [0,0 800x79.875]
|
||||||
|
PaintableWithLines (BlockContainer<BODY>) [8,21.4375 784x37]
|
||||||
|
PaintableWithLines (BlockContainer(anonymous)) [8,21.4375 784x0]
|
||||||
|
PaintableWithLines (InlineNode<A>)
|
||||||
|
PaintableWithLines (InlineNode<SPAN>#foo)
|
||||||
|
PaintableWithLines (BlockContainer(anonymous)) [8,21.4375 784x37]
|
||||||
|
PaintableWithLines (BlockContainer<H1>) [8,21.4375 784x37]
|
||||||
|
TextPaintable (TextNode<#text>)
|
||||||
|
PaintableWithLines (BlockContainer(anonymous)) [8,79.875 784x0]
|
||||||
|
PaintableWithLines (InlineNode<A>)
|
|
@ -0,0 +1,14 @@
|
||||||
|
<!doctype html>
|
||||||
|
<script>
|
||||||
|
function flipFlop() {
|
||||||
|
foo.style.position = 'relative';
|
||||||
|
foo.offsetWidth;
|
||||||
|
foo.style.position = '';
|
||||||
|
foo.offsetWidth;
|
||||||
|
}
|
||||||
|
onload = function() {
|
||||||
|
flipFlop();
|
||||||
|
flipFlop();
|
||||||
|
flipFlop();
|
||||||
|
};
|
||||||
|
</script><body><a><span id="foo"></span><h1>test</h1>
|
Loading…
Add table
Add a link
Reference in a new issue