Skip to content

Truly independent web browser

LibWeb: Offset a relatively positioned table cell

sideshowbarker9903695c5629
diff --git a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs
index 744b04fb709..eb8f375f8da 100644
--- a/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs
+++ b/Libraries/LibWeb/Rust/src/layout/table_formatting_context.rs
@@ -3566,6 +3566,14 @@ impl<'pass> TableFormattingContext<'pass> {
}
}
let collapsed = self.style(self.run.box_).border_collapse() != BORDER_COLLAPSE_SEPARATE;
+ let table_box = self.table_box_cells();
+ let inset_percentage_basis = geometry::LogicalSize {
+ inline_size: table_box.content_inline_size(),
+ block_size: table_box.content_block_size(),
+ };
+ let percentage_block_insets_have_definite_basis = self
+ .run
+ .percentage_block_insets_of_root_children_have_definite_basis(&table_box);
for cell_index in 0..self.cells.len() {
let cell = self.cells[cell_index];
let cell_box = self.cell_box_cells[cell_index];
@@ -3580,10 +3588,19 @@ impl<'pass> TableFormattingContext<'pass> {
+ self.columns[cell.column_index].inline_offset;
let y = row_content_offset.y + cell_box.border_box_top(collapsed);
let fragment_arrival = self.cell_fragment_arrivals[cell_index].take();
+ // A relatively positioned cell is offset from where the table places it, as any in-flow box is.
+ let insets = abspos_engine::compute_inset_native(
+ &self.run,
+ cell.box_,
+ &table_box,
+ inset_percentage_basis,
+ percentage_block_insets_have_definite_basis,
+ );
let placed_cell = self.placed_cells[cell_index]
.take()
.expect("a cell is laid out before it is placed")
- .with_fragment_facts(self.cell_fragment_facts[cell_index]);
+ .with_fragment_facts(self.cell_fragment_facts[cell_index])
+ .with_in_flow_box_insets(insets);
formatting_context::place_child(
&self.run,
cell.box_,
diff --git a/Tests/LibWeb/Layout/expected/table/relatively-positioned-cell.txt b/Tests/LibWeb/Layout/expected/table/relatively-positioned-cell.txt
new file mode 100644
index 00000000000..7cb0ade69eb
--- /dev/null
+++ b/Tests/LibWeb/Layout/expected/table/relatively-positioned-cell.txt
@@ -0,0 +1,16 @@
+Viewport <#document> at [0,0] [0+0+0 800 0+0+0] [0+0+0 600 0+0+0] [BFC] children: not-inline
+ BlockContainer <html> at [0,0] [0+0+0 800 0+0+0] [0+0+0 32 0+0+0] [BFC] children: not-inline
+ BlockContainer <body> at [8,8] [8+0+0 784 0+0+8] [8+0+0 16 0+0+8] children: not-inline
+ TableWrapper <(anonymous)> at [8,8] [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [BFC] children: not-inline
+ Box <(anonymous)> at [8,8] table-box [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] [TFC] children: not-inline
+ Box <(anonymous)> at [8,8] table-row [0+0+0 784 0+0+0] [0+0+0 16 0+0+0] children: not-inline
+ BlockContainer <div> at [8,8] table-cell [0+0+0 51.140625 0+0+0] [0+0+0 16 0+0+0] [BFC] children: inline
+ frag 0 from TextNode start: 0, length: 5, rect: [8,8 51.140625x16] baseline: 12.796875
+ "ITEM_"
+ TextNode <#text> (not painted)
+ BlockContainer <div#line> at [59.140625,0.796875] positioned table-cell [0+0+0 732.859375 0+0+0] [0+0+12.796875 0 2.203125+1+0] [BFC] children: not-inline
+ BlockContainer <(anonymous)> at [8,24] [0+0+0 784 0+0+0] [0+0+0 0 0+0+0] children: inline
+ TextNode <#text> (not painted)
+
+SC for Viewport<#document> [0,0 800x600] (z-index: auto)
+ SC for BlockContainer<HTML> [0,0 800x32] (z-index: auto)
diff --git a/Tests/LibWeb/Layout/input/table/relatively-positioned-cell.html b/Tests/LibWeb/Layout/input/table/relatively-positioned-cell.html
new file mode 100644
index 00000000000..24214505d64
--- /dev/null
+++ b/Tests/LibWeb/Layout/input/table/relatively-positioned-cell.html
@@ -0,0 +1,4 @@
+<!DOCTYPE html><style>
+ div { display: table-cell; }
+ #line { width: 98%; border-bottom: 1px solid black; position: relative; bottom: 20px; }
+</style><div style="width: 1%">ITEM_</div><div id="line"></div>