mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:28:12 +00:00
LibWeb: Implement top and bottom vertical-align for table cells
This commit is contained in:
parent
4ed7456486
commit
caa24d0805
3 changed files with 82 additions and 6 deletions
|
@ -764,19 +764,27 @@ void TableFormattingContext::position_cell_boxes()
|
|||
CSSPixels const cell_border_box_height = cell_state.content_height() + cell_state.border_box_top() + cell_state.border_box_bottom();
|
||||
CSSPixels const row_content_height = compute_row_content_height(cell);
|
||||
auto const& vertical_align = cell.box->computed_values().vertical_align();
|
||||
// The following image shows various alignment lines of a row:
|
||||
// https://www.w3.org/TR/css-tables-3/images/cell-align-explainer.png
|
||||
if (vertical_align.has<CSS::VerticalAlign>()) {
|
||||
auto height_diff = row_content_height - cell_border_box_height;
|
||||
switch (vertical_align.get<CSS::VerticalAlign>()) {
|
||||
case CSS::VerticalAlign::Middle: {
|
||||
cell_state.padding_top += (row_content_height - cell_border_box_height) / 2;
|
||||
cell_state.padding_bottom += (row_content_height - cell_border_box_height) / 2;
|
||||
cell_state.padding_top += height_diff / 2;
|
||||
cell_state.padding_bottom += height_diff / 2;
|
||||
break;
|
||||
}
|
||||
case CSS::VerticalAlign::Top: {
|
||||
cell_state.padding_bottom += height_diff;
|
||||
break;
|
||||
}
|
||||
case CSS::VerticalAlign::Bottom: {
|
||||
cell_state.padding_top += height_diff;
|
||||
break;
|
||||
}
|
||||
// FIXME: implement actual 'top' and 'bottom' support instead of fall back to 'baseline'
|
||||
case CSS::VerticalAlign::Top:
|
||||
case CSS::VerticalAlign::Bottom:
|
||||
case CSS::VerticalAlign::Baseline: {
|
||||
cell_state.padding_top += m_rows[cell.row_index].baseline - cell.baseline;
|
||||
cell_state.padding_bottom += row_content_height - cell_border_box_height;
|
||||
cell_state.padding_bottom += height_diff;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue