1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-10 18:10:56 +09:00

LibWeb: Add support for "display: contents"

This change makes tree builder omit elements with "display: contents"
from the layout tree during construction. Their child elements are
instead directly appended to the parent element in layout tree.
This commit is contained in:
Aliaksandr Kalenik 2023-07-27 23:31:42 +02:00 committed by Andreas Kling
parent b91af3c6a0
commit 0e8a0a8191
Notes: sideshowbarker 2024-07-17 01:46:43 +09:00
5 changed files with 31 additions and 3 deletions

View file

@ -129,6 +129,9 @@ static Layout::Node& insertion_parent_for_block_node(Layout::NodeWithStyle& layo
void TreeBuilder::insert_node_into_inline_or_block_ancestor(Layout::Node& node, CSS::Display display, AppendOrPrepend mode)
{
if (node.display().is_contents())
return;
if (display.is_inline_outside()) {
// Inlines can be inserted into the nearest ancestor.
auto& insertion_point = insertion_parent_for_inline_node(m_ancestor_stack.last());
@ -141,6 +144,8 @@ void TreeBuilder::insert_node_into_inline_or_block_ancestor(Layout::Node& node,
// Non-inlines can't be inserted into an inline parent, so find the nearest non-inline ancestor.
auto& nearest_non_inline_ancestor = [&]() -> Layout::NodeWithStyle& {
for (auto& ancestor : m_ancestor_stack.in_reverse()) {
if (ancestor->display().is_contents())
continue;
if (!ancestor->display().is_inline_outside())
return ancestor;
if (!ancestor->display().is_flow_inside())