mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +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
|
@ -124,6 +124,14 @@ public:
|
||||||
bool is_out_of_view(PaintContext&) const;
|
bool is_out_of_view(PaintContext&) const;
|
||||||
|
|
||||||
void set_override_borders_data(BordersData const& override_borders_data) { m_override_borders_data = override_borders_data; };
|
void set_override_borders_data(BordersData const& override_borders_data) { m_override_borders_data = override_borders_data; };
|
||||||
|
auto const& override_borders_data() const { return m_override_borders_data; }
|
||||||
|
|
||||||
|
enum class ShrinkRadiiForBorders {
|
||||||
|
Yes,
|
||||||
|
No
|
||||||
|
};
|
||||||
|
|
||||||
|
BorderRadiiData normalized_border_radii_data(ShrinkRadiiForBorders shrink = ShrinkRadiiForBorders::No) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit PaintableBox(Layout::Box const&);
|
explicit PaintableBox(Layout::Box const&);
|
||||||
|
@ -136,13 +144,6 @@ protected:
|
||||||
virtual CSSPixelRect compute_absolute_rect() const;
|
virtual CSSPixelRect compute_absolute_rect() const;
|
||||||
virtual CSSPixelRect compute_absolute_paint_rect() const;
|
virtual CSSPixelRect compute_absolute_paint_rect() const;
|
||||||
|
|
||||||
enum class ShrinkRadiiForBorders {
|
|
||||||
Yes,
|
|
||||||
No
|
|
||||||
};
|
|
||||||
|
|
||||||
BorderRadiiData normalized_border_radii_data(ShrinkRadiiForBorders shrink = ShrinkRadiiForBorders::No) const;
|
|
||||||
|
|
||||||
Vector<ShadowData> resolve_box_shadow_data() const;
|
Vector<ShadowData> resolve_box_shadow_data() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -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
|
void StackingContext::paint_descendants(PaintContext& context, Layout::Node const& box, StackingContextPaintPhase phase) const
|
||||||
{
|
{
|
||||||
if (auto* paintable = box.paintable()) {
|
if (auto* paintable = box.paintable()) {
|
||||||
|
@ -95,8 +122,11 @@ void StackingContext::paint_descendants(PaintContext& context, Layout::Node cons
|
||||||
case StackingContextPaintPhase::BackgroundAndBorders:
|
case StackingContextPaintPhase::BackgroundAndBorders:
|
||||||
if (!child_is_inline_or_replaced && !child.is_floating()) {
|
if (!child_is_inline_or_replaced && !child.is_floating()) {
|
||||||
paint_node(child, context, PaintPhase::Background);
|
paint_node(child, context, PaintPhase::Background);
|
||||||
|
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_node(child, context, PaintPhase::Border);
|
||||||
paint_descendants(context, child, phase);
|
paint_descendants(context, child, phase);
|
||||||
|
if (child.computed_values().border_collapse() == CSS::BorderCollapse::Collapse)
|
||||||
|
paint_table_collapsed_borders(context, child);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case StackingContextPaintPhase::Floats:
|
case StackingContextPaintPhase::Floats:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue