mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 03:08:13 +00:00
LibWeb: Skip out-of-flow boxes when wrapping inlines in anonymous block
Out-of-flow boxes (floating and absolutely-positioned elements) were previously collected and put in the anonymous block wrapper as well, but this actually made hit testing not able to find them, since they were breaking expectations about tree structure that hit testing relies on. After this change, we simply let out-of-flow boxes stay in their original parent, preserving the author's intended box tree structure.
This commit is contained in:
parent
11354dbf9e
commit
6994ea5885
10 changed files with 86 additions and 40 deletions
|
@ -121,9 +121,16 @@ static Layout::Node& insertion_parent_for_block_node(Layout::NodeWithStyle& layo
|
|||
// Parent block has inline-level children (our siblings).
|
||||
// First move these siblings into an anonymous wrapper block.
|
||||
Vector<JS::Handle<Layout::Node>> children;
|
||||
while (JS::GCPtr<Layout::Node> child = layout_parent.first_child()) {
|
||||
layout_parent.remove_child(*child);
|
||||
children.append(*child);
|
||||
{
|
||||
JS::GCPtr<Layout::Node> next;
|
||||
for (JS::GCPtr<Layout::Node> child = layout_parent.first_child(); child; child = next) {
|
||||
next = child->next_sibling();
|
||||
// NOTE: We let out-of-flow children stay in the parent, to preserve tree structure.
|
||||
if (child->is_floating() || child->is_absolutely_positioned())
|
||||
continue;
|
||||
layout_parent.remove_child(*child);
|
||||
children.append(*child);
|
||||
}
|
||||
}
|
||||
layout_parent.append_child(layout_parent.create_anonymous_wrapper());
|
||||
layout_parent.set_children_are_inline(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue