mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
layout: Add *very* basic support for table layout (#31121)
* layout: Add *very* basic support for table layout This is the first step to proper table layout. It implements a naive layout algorithm, notably only taking into account the preferred widths of the first table row. Still, it causes some float tests to start passing, so turn on the `layout.tables.enabled` preference for those directories. Co-authored-by: Oriol Brufau <obrufau@igalia.com> * Address review comments * Fix a crash with rowspan=0 * Turn on pref and update results for `/css/css-tables` and `/css/CSS2/tables` --------- Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
3d520f2668
commit
fc31e69f79
115 changed files with 842 additions and 315 deletions
|
@ -12,9 +12,9 @@ mod tables {
|
|||
table.slots.iter().map(|row| row.len()).collect()
|
||||
}
|
||||
|
||||
fn slot_is_cell_with_id(slot: &TableSlot, id: u8) -> bool {
|
||||
fn slot_is_cell_with_id(slot: &TableSlot, id: usize) -> bool {
|
||||
match slot {
|
||||
TableSlot::Cell(TableSlotCell { id: cell_id, .. }) if id == *cell_id => true,
|
||||
TableSlot::Cell(cell) if cell.node_id() == id => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -41,14 +41,14 @@ mod tables {
|
|||
|
||||
#[test]
|
||||
fn test_empty_table() {
|
||||
let table_builder = TableBuilder::default();
|
||||
let table_builder = TableBuilder::new_for_tests();
|
||||
let table = table_builder.finish();
|
||||
assert!(table.slots.is_empty())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_simple_table() {
|
||||
let mut table_builder = TableBuilder::default();
|
||||
let mut table_builder = TableBuilder::new_for_tests();
|
||||
|
||||
table_builder.start_row();
|
||||
table_builder.add_cell(TableSlotCell::mock_for_testing(1, 1, 1));
|
||||
|
@ -71,7 +71,7 @@ mod tables {
|
|||
|
||||
#[test]
|
||||
fn test_simple_rowspan() {
|
||||
let mut table_builder = TableBuilder::default();
|
||||
let mut table_builder = TableBuilder::new_for_tests();
|
||||
|
||||
table_builder.start_row();
|
||||
table_builder.add_cell(TableSlotCell::mock_for_testing(1, 1, 1));
|
||||
|
@ -100,7 +100,7 @@ mod tables {
|
|||
|
||||
#[test]
|
||||
fn test_simple_colspan() {
|
||||
let mut table_builder = TableBuilder::default();
|
||||
let mut table_builder = TableBuilder::new_for_tests();
|
||||
|
||||
table_builder.start_row();
|
||||
table_builder.add_cell(TableSlotCell::mock_for_testing(1, 3, 1));
|
||||
|
@ -162,7 +162,7 @@ mod tables {
|
|||
|
||||
#[test]
|
||||
fn test_simple_table_model_error() {
|
||||
let mut table_builder = TableBuilder::default();
|
||||
let mut table_builder = TableBuilder::new_for_tests();
|
||||
|
||||
table_builder.start_row();
|
||||
table_builder.add_cell(TableSlotCell::mock_for_testing(1, 1, 1));
|
||||
|
@ -194,7 +194,7 @@ mod tables {
|
|||
|
||||
#[test]
|
||||
fn test_simple_rowspan_0() {
|
||||
let mut table_builder = TableBuilder::default();
|
||||
let mut table_builder = TableBuilder::new_for_tests();
|
||||
|
||||
table_builder.start_row();
|
||||
table_builder.add_cell(TableSlotCell::mock_for_testing(1, 1, 1));
|
||||
|
@ -232,7 +232,7 @@ mod tables {
|
|||
|
||||
#[test]
|
||||
fn test_incoming_rowspans() {
|
||||
let mut table_builder = TableBuilder::default();
|
||||
let mut table_builder = TableBuilder::new_for_tests();
|
||||
|
||||
table_builder.start_row();
|
||||
table_builder.add_cell(TableSlotCell::mock_for_testing(1, 1, 1));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue