mirror of
https://github.com/SerenityOS/serenity
synced 2024-10-15 20:33:10 +00:00
LibWeb: Store table cell indices and spans in PaintableBox
The adjacency information is required to position borders correctly between columns and rows.
This commit is contained in:
parent
98c5efc385
commit
f6d2a21d27
|
@ -125,6 +125,9 @@ void LayoutState::commit()
|
|||
if (used_values.override_borders_data().has_value()) {
|
||||
paintable_box.set_override_borders_data(used_values.override_borders_data().value());
|
||||
}
|
||||
if (used_values.table_cell_coordinates().has_value()) {
|
||||
paintable_box.set_table_cell_coordinates(used_values.table_cell_coordinates().value());
|
||||
}
|
||||
|
||||
if (is<Layout::BlockContainer>(box)) {
|
||||
for (auto& line_box : used_values.line_boxes) {
|
||||
|
|
|
@ -122,6 +122,9 @@ struct LayoutState {
|
|||
void set_override_borders_data(Painting::BordersData const& override_borders_data) { m_override_borders_data = override_borders_data; };
|
||||
auto const& override_borders_data() const { return m_override_borders_data; }
|
||||
|
||||
void set_table_cell_coordinates(Painting::PaintableBox::TableCellCoordinates const& table_cell_coordinates) { m_table_cell_coordinates = table_cell_coordinates; }
|
||||
auto const& table_cell_coordinates() const { return m_table_cell_coordinates; }
|
||||
|
||||
private:
|
||||
AvailableSize available_width_inside() const;
|
||||
AvailableSize available_height_inside() const;
|
||||
|
@ -137,6 +140,7 @@ struct LayoutState {
|
|||
HashTable<JS::GCPtr<Box const>> m_floating_descendants;
|
||||
|
||||
Optional<Painting::BordersData> m_override_borders_data;
|
||||
Optional<Painting::PaintableBox::TableCellCoordinates> m_table_cell_coordinates;
|
||||
};
|
||||
|
||||
void commit();
|
||||
|
|
|
@ -931,13 +931,19 @@ void TableFormattingContext::border_conflict_resolution()
|
|||
// https://www.w3.org/TR/CSS22/tables.html#border-conflict-resolution
|
||||
BorderConflictFinder finder(this);
|
||||
for (auto& cell : m_cells) {
|
||||
auto& cell_state = m_state.get_mutable(cell.box);
|
||||
cell_state.set_table_cell_coordinates(
|
||||
Painting::PaintableBox::TableCellCoordinates {
|
||||
.row_index = cell.row_index,
|
||||
.column_index = cell.column_index,
|
||||
.row_span = cell.row_span,
|
||||
.column_span = cell.column_span });
|
||||
if (cell.box->computed_values().border_collapse() == CSS::BorderCollapse::Separate) {
|
||||
continue;
|
||||
}
|
||||
// Execute steps 1, 2 and 3 of the algorithm for each edge.
|
||||
Painting::BordersData override_borders_data;
|
||||
auto const& cell_style = cell.box->computed_values();
|
||||
auto& cell_state = m_state.get_mutable(cell.box);
|
||||
auto winning_border_left = cell_style.border_left();
|
||||
for (auto const conflicting_edge : finder.conflicting_edges(cell, ConflictingSide::Left)) {
|
||||
winning_border_left = winning_border_style(winning_border_left, border_data_conflicting_edge(conflicting_edge));
|
||||
|
|
|
@ -126,6 +126,16 @@ public:
|
|||
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; }
|
||||
|
||||
struct TableCellCoordinates {
|
||||
size_t row_index;
|
||||
size_t column_index;
|
||||
size_t row_span;
|
||||
size_t column_span;
|
||||
};
|
||||
|
||||
void set_table_cell_coordinates(TableCellCoordinates const& table_cell_coordinates) { m_table_cell_coordinates = table_cell_coordinates; }
|
||||
auto const& table_cell_coordinates() const { return m_table_cell_coordinates; }
|
||||
|
||||
enum class ShrinkRadiiForBorders {
|
||||
Yes,
|
||||
No
|
||||
|
@ -166,6 +176,7 @@ private:
|
|||
Optional<BorderRadiusCornerClipper> mutable m_overflow_corner_radius_clipper;
|
||||
|
||||
Optional<BordersData> m_override_borders_data;
|
||||
Optional<TableCellCoordinates> m_table_cell_coordinates;
|
||||
};
|
||||
|
||||
class PaintableWithLines final : public PaintableBox {
|
||||
|
|
Loading…
Reference in a new issue