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

LibWeb: Fix style updates for table box nodes

On style update, we have to preserve the invariant established when we
built the layout tree - some properties are applied to the table wrapper
and the table box values are reset to their initial values.

This also ensures that the containing block of a table box is always a
table wrapper, which isn't the case if we set absolute position on the
box instead of the wrapper.

Fixes #19452.
This commit is contained in:
Andi Gallo 2023-06-22 12:22:29 +00:00 committed by Andreas Kling
parent e28578363a
commit 55f1a70577
5 changed files with 57 additions and 15 deletions

View file

@ -592,20 +592,7 @@ void TreeBuilder::generate_missing_parents(NodeWithStyle& root)
auto& parent = *table_box->parent();
CSS::ComputedValues wrapper_computed_values;
// The computed values of properties 'position', 'float', 'margin-*', 'top', 'right', 'bottom', and 'left' on the table element are used on the table wrapper box and not the table box;
// all other values of non-inheritable properties are used on the table box and not the table wrapper box.
// (Where the table element's values are not used on the table and table wrapper boxes, the initial values are used instead.)
auto& mutable_wrapper_computed_values = static_cast<CSS::MutableComputedValues&>(wrapper_computed_values);
if (table_box->display().is_inline_outside())
mutable_wrapper_computed_values.set_display(CSS::Display::from_short(CSS::Display::Short::InlineBlock));
else
mutable_wrapper_computed_values.set_display(CSS::Display::from_short(CSS::Display::Short::FlowRoot));
mutable_wrapper_computed_values.set_position(table_box->computed_values().position());
mutable_wrapper_computed_values.set_inset(table_box->computed_values().inset());
mutable_wrapper_computed_values.set_float(table_box->computed_values().float_());
mutable_wrapper_computed_values.set_clear(table_box->computed_values().clear());
mutable_wrapper_computed_values.set_margin(table_box->computed_values().margin());
table_box->reset_table_box_computed_values_used_by_wrapper_to_init_values();
table_box->transfer_table_box_computed_values_to_wrapper_computed_values(wrapper_computed_values);
auto wrapper = parent.heap().allocate_without_realm<TableWrapper>(parent.document(), nullptr, move(wrapper_computed_values));