1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:57:44 +00:00

LibWeb: Update anonymous wrappers when applying style changes

Anonymous wrapper boxes inherit style from their layout tree parent,
and since style data is per-layout-node, we have to manually sync them
from parent to anonymous children when something changes.

This is not very elegant or efficient, so I've left a FIXME about
solving it in a nicer way.

This fixes horizontal dog alignment on https://waffles.dog/ :^)
This commit is contained in:
Andreas Kling 2023-07-03 12:49:13 +02:00
parent b918ce4022
commit 510dfbb7e6
4 changed files with 36 additions and 0 deletions

View file

@ -739,6 +739,16 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
auto& wrapper_computed_values = static_cast<TableWrapper*>(parent())->m_computed_values;
transfer_table_box_computed_values_to_wrapper_computed_values(wrapper_computed_values);
}
// Update any anonymous children that inherit from this node.
// FIXME: This is pretty hackish. It would be nicer if they shared the inherited style
// data structure somehow, so this wasn't necessary.
for_each_child([&](auto& child) {
if (child.is_anonymous()) {
auto& child_computed_values = static_cast<CSS::MutableComputedValues&>(static_cast<CSS::ComputedValues&>(const_cast<CSS::ImmutableComputedValues&>(child.computed_values())));
child_computed_values.inherit_from(computed_values);
}
});
}
bool Node::is_root_element() const