Skip to content

The headless browser for AI agents and web scraping

fix(render): honor table row and group display

SGavrl7bf782b53e23
diff --git a/crates/obscura-render/src/dom.rs b/crates/obscura-render/src/dom.rs
index 187ca719..16279c17 100644
--- a/crates/obscura-render/src/dom.rs
+++ b/crates/obscura-render/src/dom.rs
@@ -5336,6 +5336,7 @@ fn layout_dom_once(
flow_root: bool,
is_table_box: bool,
is_table_cell_box: bool,
+ table_row_display: Option<crate::TableRowDisplay>,
color: Option<[u8; 4]>,
font_size: Option<f32>,
font_weight: u16,
@@ -5399,6 +5400,7 @@ fn layout_dom_once(
flow_root: false,
is_table_box: false,
is_table_cell_box: false,
+ table_row_display: None,
color: None,
font_size: None,
font_weight: 400,
@@ -5524,6 +5526,7 @@ fn layout_dom_once(
inh.flow_root = style.flow_root;
inh.is_table_box = style.is_table_box;
inh.is_table_cell_box = style.is_table_cell_box;
+ inh.table_row_display = style.table_row_display;
inh.color = style.color.or(inh.color);
inh.font_size = style.font_size.or(inh.font_size);
inh.font_weight = crate::style::used_font_weight(style);
@@ -5704,6 +5707,7 @@ fn layout_dom_once(
style.flow_root = inh.flow_root;
style.is_table_box = inh.is_table_box;
style.is_table_cell_box = inh.is_table_cell_box;
+ style.table_row_display = inh.table_row_display;
// Reconstruct the internal cell-content wrapper only when
// the inherited computed display is table-cell.
style.internal_flex_container = style.is_table_cell_box;
@@ -5724,6 +5728,7 @@ fn layout_dom_once(
inh.flow_root = style.flow_root;
inh.is_table_box = style.is_table_box;
inh.is_table_cell_box = style.is_table_cell_box;
+ inh.table_row_display = style.table_row_display;
match style.color {
Some(c) => inh.color = Some(c),
None => style.color = inh.color,
@@ -6195,6 +6200,7 @@ fn layout_dom_once(
let host_flow_root = style.flow_root;
let host_is_table_box = style.is_table_box;
let host_is_table_cell_box = style.is_table_cell_box;
+ let host_table_row_display = style.table_row_display;
let host_grid_auto_columns = style.grid_auto_columns.clone();
let host_grid_auto_rows = style.grid_auto_rows.clone();
let host_grid_auto_column_calcs = style.grid_calc_expressions[2].clone();
@@ -6223,6 +6229,7 @@ fn layout_dom_once(
pseudo.flow_root = host_flow_root;
pseudo.is_table_box = host_is_table_box;
pseudo.is_table_cell_box = host_is_table_cell_box;
+ pseudo.table_row_display = host_table_row_display;
pseudo.internal_flex_container = pseudo.is_table_cell_box;
if pseudo.is_table_cell_box {
pseudo.flex_direction = Some(taffy::FlexDirection::Column);
@@ -7694,7 +7701,7 @@ fn layout_dom_once(
&mut generated_rects,
);
inline_fragments = synthesize_ordinary_inline_fragments(&mut rects, &styles, &engine);
- synthesize_row_rects(tree, &mut rects);
+ synthesize_row_rects(tree, &styles, &mut rects);
}
}
sync_positioned_pseudo_percentage_padding(&rects, &mut styles);
@@ -10760,28 +10767,22 @@ fn tokenize_with_spaces(text: &str) -> Vec<String> {
/// extent must ignore the portion of a `rowspan` that continues through later
/// rows. Nested-table cells must not participate at all. Sections are then the
/// union of their already-synthesized direct rows.
-fn synthesize_row_rects(tree: &DomTree, rects: &mut HashMap<NodeId, Rect>) {
+fn synthesize_row_rects(tree: &DomTree, styles: &HashMap<NodeId, crate::LayoutStyle>,
+ rects: &mut HashMap<NodeId, Rect>) {
let mut rows = Vec::new();
let mut sections = Vec::new();
let mut table_inline: HashMap<NodeId, Rect> = HashMap::new();
+ let is_cell = |id| styles.get(&id).is_some_and(|style| style.is_table_cell_box)
+ || tree.with_node(id, |node| node.as_element().is_some_and(|name|
+ matches!(name.local.as_ref(), "td" | "th"))).unwrap_or(false);
for id in rendered_descendants(tree, tree.document()) {
- let local = match tree
- .borrow_node(id)
- .and_then(|n| n.as_element().map(|e| e.local.to_string()))
- {
- Some(l) => l,
- None => continue,
- };
- match local.as_str() {
- "tr" => rows.push(id),
- "tbody" | "thead" | "tfoot" => sections.push(id),
- "td" | "th" => {
+ match table_row_display(tree, id, styles) {
+ Some(crate::TableRowDisplay::Row) => rows.push(id),
+ Some(_) => sections.push(id),
+ None if is_cell(id) => {
let mut ancestor = rendered_parent(tree, id);
while let Some(parent) = ancestor {
- let is_table = tree.borrow_node(parent).map_or(false, |node| {
- node.as_element()
- .map_or(false, |element| element.local.as_ref() == "table")
- });
+ let is_table = styles.get(&parent).is_some_and(|style| style.is_table_box);
if is_table {
if let Some(rect) = rects.get(&id) {
table_inline
@@ -10804,15 +10805,8 @@ fn synthesize_row_rects(tree: &DomTree, rects: &mut HashMap<NodeId, Rect>) {
}
let mut inline: Option<Rect> = None;
let mut block: Option<Rect> = None;
- for cell in tree.children(id) {
- let is_cell = tree
- .borrow_node(cell)
- .and_then(|n| {
- n.as_element()
- .map(|e| matches!(e.local.as_ref(), "td" | "th"))
- })
- .unwrap_or(false);
- if !is_cell {
+ for cell in rendered_children(tree, id) {
+ if !is_cell(cell) {
continue;
}
let Some(r) = rects.get(&cell) else {
@@ -10864,11 +10858,8 @@ fn synthesize_row_rects(tree: &DomTree, rects: &mut HashMap<NodeId, Rect>) {
continue;
}
let mut section: Option<Rect> = None;
- for row in tree.children(id) {
- let is_row = tree.borrow_node(row).map_or(false, |node| {
- node.as_element()
- .map_or(false, |element| element.local.as_ref() == "tr")
- });
+ for row in rendered_children(tree, id) {
+ let is_row = table_row_display(tree, row, styles) == Some(crate::TableRowDisplay::Row);
if !is_row {
continue;
}
@@ -11314,25 +11305,44 @@ where
changed
}
-/// Collect rows together with the exclusive end of their originating row
-/// group. HTML rowspans never cross a thead/tbody/tfoot boundary; `rowspan=0`
-/// means the remainder of that group, not the remainder of the whole table.
+fn table_row_display(tree: &DomTree, id: NodeId, styles: &HashMap<NodeId, crate::LayoutStyle>)
+ -> Option<crate::TableRowDisplay> {
+ styles.get(&id).and_then(|style| style.table_row_display).or_else(|| {
+ // shortcut: preserve native display-override fixup until anonymous table boxes exist.
+ tree.with_node(id, |node| match node.as_element()?.local.as_ref() {
+ "tr" => Some(crate::TableRowDisplay::Row),
+ "tbody" => Some(crate::TableRowDisplay::Group),
+ "thead" => Some(crate::TableRowDisplay::Header),
+ "tfoot" => Some(crate::TableRowDisplay::Footer),
+ _ => None,
+ }).flatten()
+ })
+}
+
+/// Collect rows with the exclusive end of their originating group. Rowspans
+/// never cross a group boundary; rowspan=0 means the rest of that group.
fn collect_table_rows(tree: &DomTree, id: NodeId, styles: &HashMap<NodeId, crate::LayoutStyle>,
rows: &mut Vec<(NodeId, usize)>) {
+ use crate::TableRowDisplay::{Row, Header, Footer};
let mut direct_start: Option<usize> = None;
- for cid in tree.children(id) {
+ let children = rendered_children(tree, id);
+ let first_group = |role| children.iter().copied().find(|child| {
+ !styles.get(child).is_some_and(|style| style.display == crate::Display::None)
+ && table_row_display(tree, *child, styles) == Some(role)
+ });
+ let header = first_group(Header);
+ let footer = first_group(Footer);
+ for cid in header.into_iter().chain(children.iter().copied()
+ .filter(|child| Some(*child) != header && Some(*child) != footer)).chain(footer) {
if styles.get(&cid).is_some_and(|style| style.display == crate::Display::None) {
continue;
}
- let local = tree
- .borrow_node(cid)
- .and_then(|n| n.as_element().map(|e| e.local.to_string()));
- match local.as_deref() {
- Some("tr") => {
+ match table_row_display(tree, cid, styles) {
+ Some(Row) => {
direct_start.get_or_insert(rows.len());
rows.push((cid, 0));
}
- Some("thead") | Some("tbody") | Some("tfoot") => {
+ Some(_) => {
if let Some(start) = direct_start.take() {
let end = rows.len();
for entry in &mut rows[start..end] {
@@ -11340,12 +11350,9 @@ fn collect_table_rows(tree: &DomTree, id: NodeId, styles: &HashMap<NodeId, crate
}
}
let start = rows.len();
- for row in tree.children(cid) {
+ for row in rendered_children(tree, cid) {
if !styles.get(&row).is_some_and(|style| style.display == crate::Display::None)
- && tree.borrow_node(row).is_some_and(|node| {
- node.as_element()
- .is_some_and(|element| element.local.as_ref() == "tr")
- }) {
+ && table_row_display(tree, row, styles) == Some(Row) {
rows.push((row, 0));
}
}
@@ -11688,7 +11695,10 @@ fn build_table(
node.as_element()
.is_some_and(|element| element.local.as_ref() == "table")
});
+ let mut rows: Vec<(NodeId, usize)> = Vec::new();
let authored_row_children = if native_html_table {
+ collect_table_rows(tree, id, styles, &mut rows);
+ if rows.is_empty() { return None; }
None
} else {
let children = rendered_children(tree, id);
@@ -11698,31 +11708,38 @@ fn build_table(
// ordinary box construction preserves every child; partially taking
// the dedicated path would silently discard direct text/non-cell
// boxes once one real table cell made the build succeed.
- let all_rendered_children_are_cells = flattened.iter().all(|child| {
- let hidden = styles
- .get(child)
- .is_some_and(|child_style| child_style.display == crate::Display::None);
- let ignorable_whitespace = tree.borrow_node(*child).is_some_and(|node| {
- !node.is_element() && tree.text_content(*child).trim().is_empty()
+ let ignorable = |child: NodeId| {
+ styles.get(&child).is_some_and(|style| style.display == crate::Display::None)
+ || tree.with_node(child, |node| !node.is_element()
+ && tree.text_content(child).trim().is_empty()).unwrap_or(false)
+ };
+ let all_rendered_children_are_cells = flattened.iter().all(|child|
+ ignorable(*child) || styles.get(child).is_some_and(|style| style.is_table_cell_box));
+ if all_rendered_children_are_cells {
+ Some(flattened)
+ } else {
+ let valid_row = |row| rendered_children(tree, row).into_iter().all(|child| {
+ ignorable(child) || styles.get(&child).is_some_and(|style| style.is_table_cell_box)
});
- hidden
- || ignorable_whitespace
- || styles
- .get(child)
- .is_some_and(|child_style| child_style.is_table_cell_box)
- });
- if !all_rendered_children_are_cells {
- return None;
+ let valid = flattened.iter().copied().all(|child| {
+ if ignorable(child) { return true; }
+ match styles.get(&child).and_then(|style| style.table_row_display) {
+ Some(crate::TableRowDisplay::Row) => valid_row(child),
+ Some(_) => rendered_children(tree, child).into_iter().all(|row| {
+ ignorable(row) || (styles.get(&row).is_some_and(|style|
+ style.table_row_display == Some(crate::TableRowDisplay::Row)) && valid_row(row))
+ }),
+ None => false,
+ }
+ });
+ if !valid { return None; }
+ collect_table_rows(tree, id, styles, &mut rows);
+ if rows.is_empty() { return None; }
+ None
}
- Some(flattened)
};
- let mut rows: Vec<(NodeId, usize)> = Vec::new();
- if native_html_table {
- collect_table_rows(tree, id, styles, &mut rows);
- if rows.is_empty() {
- return None;
- }
- } else {
+ let explicit_rows = authored_row_children.is_none();
+ if !explicit_rows {
// CSS table fixup inserts an anonymous row around table-cell children
// that are direct children of a table. The grid representation does
// not need a material row node, but retaining one logical row gives
@@ -11758,8 +11775,8 @@ fn build_table(
let mut ncols = 0usize;
for (r, &(tr, group_end)) in rows.iter().enumerate() {
let mut c = 0usize;
- let row_children = if native_html_table {
- tree.children(tr)
+ let row_children = if explicit_rows {
+ rendered_children(tree, tr)
} else {
authored_row_children.clone().unwrap_or_default()
};
@@ -12031,7 +12048,7 @@ fn build_table(
// Row sizing: a `height` on the row or a rowspan-1 cell is a MINIMUM
// (content can always grow a row), matching how tables treat heights.
let mut row_min: Vec<Option<f32>> = vec![None; nrows];
- if native_html_table {
+ if explicit_rows {
for (r, &(tr, _)) in rows.iter().enumerate() {
if let Some(crate::Dimension::Px(h)) = styles.get(&tr).map(|s| s.height) {
if h > 0.0 {
diff --git a/crates/obscura-render/src/lib.rs b/crates/obscura-render/src/lib.rs
index 4f6e859d..bbddd9b7 100644
--- a/crates/obscura-render/src/lib.rs
+++ b/crates/obscura-render/src/lib.rs
@@ -948,6 +948,14 @@ pub(crate) enum RadialGradientSize {
Explicit(Dimension, Dimension),
}
+#[derive(Debug, Clone, Copy, PartialEq, Eq)]
+pub(crate) enum TableRowDisplay {
+ Row,
+ Group,
+ Header,
+ Footer,
+}
+
/// One computed CSS counter operation.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CounterDirective {
@@ -1051,6 +1059,8 @@ pub struct LayoutStyle {
/// `<td>`/`<th>` elements even though Taffy represents their cell-content
/// wrapper as an internal column flexbox.
pub(crate) is_table_cell_box: bool,
+ /// Table row/group provenance, independent of the internal layout stand-in.
+ pub(crate) table_row_display: Option<TableRowDisplay>,
/// The HTML UA sheet's vendor `text-align` behavior for `<center>`.
/// Unlike ordinary `text-align:center`, it also centers fixed-width block
/// descendants while leaving auto-width blocks fill-available.
@@ -1735,6 +1745,10 @@ pub(crate) fn is_inline_level_box(style: &LayoutStyle) -> bool {
/// Thus inline-flex becomes flex and inline-grid becomes grid, while
/// inline-block/plain inline become block.
pub(crate) fn blockify_outer_display(style: &mut LayoutStyle) {
+ if style.display != Display::None && style.table_row_display.take().is_some() {
+ style.display = Display::Block;
+ style.internal_flex_container = false;
+ }
if !is_inline_level_box(style) {
return;
}
diff --git a/crates/obscura-render/src/paint.rs b/crates/obscura-render/src/paint.rs
index 320d0413..76f8b46b 100644
--- a/crates/obscura-render/src/paint.rs
+++ b/crates/obscura-render/src/paint.rs
@@ -2389,6 +2389,13 @@ fn computed_display(style: &crate::LayoutStyle) -> &'static str {
"contents"
} else if style.display == crate::Display::None {
"none"
+ } else if let Some(display) = style.table_row_display {
+ match display {
+ crate::TableRowDisplay::Row => "table-row",
+ crate::TableRowDisplay::Group => "table-row-group",
+ crate::TableRowDisplay::Header => "table-header-group",
+ crate::TableRowDisplay::Footer => "table-footer-group",
+ }
} else if active_webkit_clamp && style.webkit_box_display == Some(false) {
"flow-root"
} else if style.webkit_box_display == Some(false) && !active_webkit_clamp {
diff --git a/crates/obscura-render/src/style.rs b/crates/obscura-render/src/style.rs
index 572b6012..9524a82d 100644
--- a/crates/obscura-render/src/style.rs
+++ b/crates/obscura-render/src/style.rs
@@ -296,12 +296,18 @@ pub fn ua_style(tag: &str) -> LayoutStyle {
style.border_spacing = Some((2.0, 2.0));
style.border_collapse = Some(false);
} else {
+ style.table_row_display = Some(match tag {
+ "thead" => crate::TableRowDisplay::Header,
+ "tfoot" => crate::TableRowDisplay::Footer,
+ _ => crate::TableRowDisplay::Group,
+ });
style.width = crate::Dimension::Percent(1.0);
// The row-group UA rule is the source of the effective default
// middle alignment; rows and cells inherit it below.
style.vertical_align = Some(crate::VerticalAlign::Middle);
}
} else if tag == "tr" {
+ style.table_row_display = Some(crate::TableRowDisplay::Row);
style.internal_flex_container = true;
// Rows fill the table width and can shrink below content min-content;
// this is exactly why Wikipedia's own responsive CSS uses
@@ -854,6 +860,10 @@ fn apply_value(style: &mut LayoutStyle, name: &str, value: &str) {
| "table"
| "inline-table"
| "table-cell"
+ | "table-row"
+ | "table-row-group"
+ | "table-header-group"
+ | "table-footer-group"
| "-webkit-box"
| "-webkit-inline-box"
| "contents"
@@ -868,6 +878,7 @@ fn apply_value(style: &mut LayoutStyle, name: &str, value: &str) {
style.internal_flex_container = false;
style.is_table_box = false;
style.is_table_cell_box = false;
+ style.table_row_display = None;
style.is_inline_block = false;
style.flow_root = false;
style.display_contents = false;
@@ -911,6 +922,15 @@ fn apply_value(style: &mut LayoutStyle, name: &str, value: &str) {
style.flow_root = true;
style.is_table_box = true;
}
+ "table-row" | "table-row-group" | "table-header-group" | "table-footer-group" => {
+ style.table_row_display = Some(match value.as_str() {
+ "table-row" => crate::TableRowDisplay::Row,
+ "table-header-group" => crate::TableRowDisplay::Header,
+ "table-footer-group" => crate::TableRowDisplay::Footer,
+ _ => crate::TableRowDisplay::Group,
+ });
+ style.display = crate::Display::Block;
+ }
"table-cell" => {
// A table cell establishes an internal flow container. A
// column flexbox is our cell-content wrapper stand-in; it
@@ -2313,6 +2333,10 @@ pub fn supports_declaration(name: &str, value: &str) -> bool {
| "flow-root"
| "table"
| "inline-table"
+ | "table-row"
+ | "table-row-group"
+ | "table-header-group"
+ | "table-footer-group"
| "-webkit-box"
| "-webkit-inline-box"
| "contents"
diff --git a/crates/obscura-render/tests/layout_test.rs b/crates/obscura-render/tests/layout_test.rs
index 91e0ae3b..830f10ea 100644
--- a/crates/obscura-render/tests/layout_test.rs
+++ b/crates/obscura-render/tests/layout_test.rs
@@ -371,6 +371,122 @@ fn hidden_table_sections_do_not_contribute_rows_or_cell_widths() {
}
}
+#[cfg(feature = "paint")]
+#[test]
+fn table_display_keywords_restore_hidden_native_rows_and_groups() {
+ for (tag, display) in [("tr", "table-row"), ("tbody", "table-row-group"),
+ ("thead", "table-header-group"), ("tfoot", "table-footer-group")] {
+ let content = if tag == "tr" { "<td id='cell'></td>" }
+ else { "<tr><td id='cell'></td></tr>" };
+ let tree = parse_html(&format!(r#"<style>html,body{{margin:0}}
+ table{{border-spacing:0}}td{{width:40px;height:20px;padding:0}}</style>
+ <table id="table"><{tag} id="restored" style="display:none;display:{display}">
+ {content}</{tag}></table>"#));
+ let layout = layout_dom(&tree, (600.0, 400.0));
+ for id in ["table", "restored", "cell"] {
+ let rect = layout.rects.get(&tree.get_element_by_id(id).unwrap())
+ .unwrap_or_else(|| panic!("{display}: missing {id} box"));
+ assert_eq!((rect.width, rect.height), (40.0, 20.0), "{display}: {id}");
+ }
+ }
+}
+
+#[cfg(feature = "paint")]
+#[test]
+fn css_table_rows_share_tracks_and_generate_row_and_group_boxes() {
+ let tree = parse_html(r#"<style>html,body{margin:0}.table{display:table;border-spacing:0}
+ .group{display:table-row-group}.row{display:table-row}.cell{display:table-cell;height:20px}
+ .a{width:30px}.b{width:40px}</style><div id="table" class="table"><div id="group" class="group">
+ <div id="row1" class="row"><div id="a1" class="cell a"></div><div id="b1" class="cell b"></div></div>
+ <div id="row2" class="row"><div id="a2" class="cell a"></div><div id="b2" class="cell b"></div></div>
+ </div></div>"#);
+ let layout = layout_dom(&tree, (600.0, 400.0));
+ let rect = |id| layout.rects[&tree.get_element_by_id(id).unwrap()];
+ for id in ["table", "group"] {
+ assert_eq!((rect(id).width, rect(id).height), (70.0, 40.0), "{id}");
+ }
+ for (id, x, y, width, height) in [("row1",0.0,0.0,70.0,20.0), ("row2",0.0,20.0,70.0,20.0),
+ ("a1",0.0,0.0,30.0,20.0), ("b1",30.0,0.0,40.0,20.0),
+ ("a2",0.0,20.0,30.0,20.0), ("b2",30.0,20.0,40.0,20.0)] {
+ let r = rect(id);
+ assert_eq!((r.x,r.y,r.width,r.height), (x,y,width,height), "{id}");
+ }
+}
+
+#[cfg(feature = "paint")]
+#[test]
+fn table_display_keywords_compute_inherit_reset_and_blockify() {
+ for display in ["table-row", "table-row-group", "table-header-group", "table-footer-group"] {
+ let tree = parse_html(&format!(r#"<div id="parent" style="display:{display}">
+ <span id="inherited" style="display:inherit"></span></div>
+ <div style="display:flex"><div id="item" style="display:{display}"></div></div>
+ <div id="reset" style="display:{display};display:block"></div>
+ <div id="invalid" style="display:{display};display:invalid"></div>"#));
+ let mut resources = obscura_render::RenderResourceCache::default();
+ let prepared = obscura_render::prepare_dom(&tree, (600.0,400.0), None, &mut resources).unwrap();
+ for (id, expected) in [("parent",display), ("inherited",display), ("item","block"),
+ ("reset","block"), ("invalid",display)] {
+ assert_eq!(prepared.computed_style(tree.get_element_by_id(id).unwrap()).unwrap()["display"],
+ expected, "{display}: {id}");
+ }
+ assert!(obscura_render::style::supports_declaration("display",display));
+ }
+}
+
+#[cfg(feature = "paint")]
+#[test]
+fn css_table_header_and_footer_groups_use_visual_order() {
+ let tree = parse_html(r#"<style>html,body{margin:0}.table{display:table;border-spacing:0}
+ .row{display:table-row}.cell{display:table-cell;width:30px;height:20px}</style>
+ <div class="table"><div style="display:table-footer-group"><div class="row"><div id="footer" class="cell"></div></div></div>
+ <div class="row"><div id="body" class="cell"></div></div>
+ <div style="display:table-header-group"><div class="row"><div id="header" class="cell"></div></div></div></div>"#);
+ let layout = layout_dom(&tree, (600.0,400.0));
+ for (id,y) in [("header",0.0), ("body",20.0), ("footer",40.0)] {
+ assert_eq!(layout.rects[&tree.get_element_by_id(id).unwrap()].y,y,"{id}");
+ }
+}
+
+#[cfg(feature = "paint")]
+#[test]
+fn native_row_geometry_retains_cells_with_authored_block_display() {
+ let tree = parse_html(r#"<style>html,body{margin:0}table{border-spacing:0}
+ td{display:block;width:40px;height:20px;padding:0}</style><table><tr id="row"><td></td></tr></table>"#);
+ let layout = layout_dom(&tree,(600.0,400.0));
+ let row = layout.rects.get(&tree.get_element_by_id("row").unwrap()).expect("native row box");
+ assert_eq!((row.width,row.height),(40.0,20.0));
+}
+
+#[cfg(feature = "paint")]
+#[test]
+fn table_row_display_does_not_unhide_native_hidden_inputs() {
+ let tree = parse_html(r#"<div style="display:flex">
+ <input id="flex" type="hidden" style="display:table-row;width:40px;height:20px"></div>
+ <input id="absolute" type="hidden" style="display:table-row-group;position:absolute;width:40px;height:20px">
+ <table style="display:flex"><tbody id="attribute" hidden><tr><td></td></tr></tbody></table>"#);
+ let layout = layout_dom(&tree,(600.0,400.0));
+ for id in ["flex","absolute","attribute"] {
+ assert!(!layout.rects.contains_key(&tree.get_element_by_id(id).unwrap()), "{id} became visible");
+ }
+}
+
+#[cfg(feature = "paint")]
+#[test]
+fn css_table_mixed_children_are_not_discarded() {
+ for content in [
+ "<div class='row'><div class='cell'></div></div><div id='keep'></div>",
+ "<div class='group'><div class='row'><div class='cell'></div></div><div id='keep'></div></div>",
+ "<div class='row'><div class='cell'></div><div id='keep'></div></div>",
+ ] {
+ let tree = parse_html(&format!(r#"<style>.table{{display:table}}.group{{display:table-row-group}}
+ .row{{display:table-row}}.cell{{display:table-cell;width:30px;height:20px}}
+ #keep{{width:40px;height:17px}}</style><div class="table">{content}</div>"#));
+ let layout = layout_dom(&tree,(600.0,400.0));
+ let kept = layout.rects.get(&tree.get_element_by_id("keep").unwrap()).expect("mixed child box");
+ assert_eq!((kept.width,kept.height),(40.0,17.0));
+ }
+}
+
#[test]
fn table_rowspans_are_clipped_to_the_originating_row_group() {
let tree = parse_html(
diff --git a/docs/Connect-Puppeteer-or-Playwright.md b/docs/Connect-Puppeteer-or-Playwright.md
index 09ad38f6..560798ef 100644
--- a/docs/Connect-Puppeteer-or-Playwright.md
+++ b/docs/Connect-Puppeteer-or-Playwright.md
@@ -130,6 +130,13 @@ rendering, only inline styles are checked. CSS `content-visibility: hidden` and
Listbox option/optgroup boxes are also not rendered, so their visibility queries
currently return `false` even when Chromium returns `true`.
+Native table rows and sections can be revealed with explicit `display: table-row`,
+`table-row-group`, `table-header-group`, and `table-footer-group` declarations.
+CSS-created tables with explicit rows/groups share column tracks and expose row
+and group geometry. Full anonymous-table fixup for mixed content is not implemented;
+unsupported CSS table structures retain ordinary box layout rather than dropping
+their non-table children.
+
## Current limits
- Pages share one V8 isolate. CPU-bound JavaScript on one page can delay others.
diff --git a/render-repros/checks.json b/render-repros/checks.json
index b722504d..e2c7e117 100644
--- a/render-repros/checks.json
+++ b/render-repros/checks.json
@@ -408,6 +408,11 @@
"reduced-motion-emulation": [
{"name": "normal motion keeps the default width", "color": "#22aa66", "width": 100, "height": 30}
],
+ "table-display-keywords": [
+ {"name": "explicit row and group display override display none", "color": "#1971c2", "x": 20, "y": 20, "width": 40, "height": 20},
+ {"name": "CSS rows share their first column", "color": "#087f5b", "x": 150, "y": 20, "width": 30, "height": 40},
+ {"name": "CSS rows share their second column", "color": "#7048e8", "x": 180, "y": 20, "width": 40, "height": 40}
+ ],
"z-index": [
{"name": "positive layer", "color": "#008000", "width": 200, "height": 100},
{"name": "negative layer", "color": "#ffa500", "width": 260, "height": 110}
diff --git a/render-repros/table-display-keywords.html b/render-repros/table-display-keywords.html
new file mode 100644
index 00000000..e89dde99
--- /dev/null
+++ b/render-repros/table-display-keywords.html
@@ -0,0 +1,26 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>CSS table row and group display</title>
+<style>
+ html, body { margin: 0; background: white; }
+ table, .table { border-spacing: 0; position: absolute; top: 20px; }
+ table { left: 20px; }
+ td { width: 40px; height: 20px; padding: 0; }
+ .hidden { display: none; }
+ #native-group { display: table-row-group; }
+ #native-row { display: table-row; }
+ #native-cell { background: #1971c2; }
+ .table { display: table; left: 150px; }
+ .group { display: table-row-group; }
+ .row { display: table-row; }
+ .cell { display: table-cell; height: 20px; }
+ .a { width: 30px; background: #087f5b; }
+ .b { width: 40px; background: #7048e8; }
+</style>
+<table><tbody id="native-group" class="hidden"><tr id="native-row" class="hidden">
+ <td id="native-cell"></td>
+</tr></tbody></table>
+<div class="table"><div class="group">
+ <div class="row"><div class="cell a"></div><div class="cell b"></div></div>
+ <div class="row"><div class="cell a"></div><div class="cell b"></div></div>
+</div></div>