mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:17:34 +00:00
LibWeb: Move collapsed table border painting to a separate function
Move painting of cell borders to a separated function since doing it correctly has to consider the entire grid as a whole for the collapsed borders case.
This commit is contained in:
parent
f489d85edd
commit
98c5efc385
2 changed files with 39 additions and 8 deletions
|
@ -72,6 +72,33 @@ static PaintPhase to_paint_phase(StackingContext::StackingContextPaintPhase phas
|
|||
}
|
||||
}
|
||||
|
||||
static void collect_cell_boxes_with_collapsed_borders(Vector<PaintableBox const*>& cell_boxes, Layout::Node const& box)
|
||||
{
|
||||
box.for_each_child([&](auto& child) {
|
||||
if (child.display().is_table_cell() && child.computed_values().border_collapse() == CSS::BorderCollapse::Collapse) {
|
||||
VERIFY(is<Layout::Box>(child) && child.paintable());
|
||||
cell_boxes.append(static_cast<Layout::Box const&>(child).paintable_box());
|
||||
} else {
|
||||
collect_cell_boxes_with_collapsed_borders(cell_boxes, child);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static void paint_table_collapsed_borders(PaintContext& context, Layout::Node const& box)
|
||||
{
|
||||
Vector<PaintableBox const*> cell_boxes;
|
||||
collect_cell_boxes_with_collapsed_borders(cell_boxes, box);
|
||||
for (auto const cell_box : cell_boxes) {
|
||||
auto borders_data = cell_box->override_borders_data().has_value() ? cell_box->override_borders_data().value() : BordersData {
|
||||
.top = cell_box->box_model().border.top == 0 ? CSS::BorderData() : cell_box->computed_values().border_top(),
|
||||
.right = cell_box->box_model().border.right == 0 ? CSS::BorderData() : cell_box->computed_values().border_right(),
|
||||
.bottom = cell_box->box_model().border.bottom == 0 ? CSS::BorderData() : cell_box->computed_values().border_bottom(),
|
||||
.left = cell_box->box_model().border.left == 0 ? CSS::BorderData() : cell_box->computed_values().border_left(),
|
||||
};
|
||||
paint_all_borders(context, cell_box->absolute_border_box_rect(), cell_box->normalized_border_radii_data(), borders_data);
|
||||
}
|
||||
}
|
||||
|
||||
void StackingContext::paint_descendants(PaintContext& context, Layout::Node const& box, StackingContextPaintPhase phase) const
|
||||
{
|
||||
if (auto* paintable = box.paintable()) {
|
||||
|
@ -95,8 +122,11 @@ void StackingContext::paint_descendants(PaintContext& context, Layout::Node cons
|
|||
case StackingContextPaintPhase::BackgroundAndBorders:
|
||||
if (!child_is_inline_or_replaced && !child.is_floating()) {
|
||||
paint_node(child, context, PaintPhase::Background);
|
||||
paint_node(child, context, PaintPhase::Border);
|
||||
if ((!child.display().is_table_cell() && !child.display().is_table_inside()) || child.computed_values().border_collapse() == CSS::BorderCollapse::Separate)
|
||||
paint_node(child, context, PaintPhase::Border);
|
||||
paint_descendants(context, child, phase);
|
||||
if (child.computed_values().border_collapse() == CSS::BorderCollapse::Collapse)
|
||||
paint_table_collapsed_borders(context, child);
|
||||
}
|
||||
break;
|
||||
case StackingContextPaintPhase::Floats:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue