Skip to content

The headless browser for AI agents and web scraping

test: gate inline block flex geometry

SGavrlc33361970303
diff --git a/crates/obscura-render/tests/layout_test.rs b/crates/obscura-render/tests/layout_test.rs
index 93281b1d..2d7cc6df 100644
--- a/crates/obscura-render/tests/layout_test.rs
+++ b/crates/obscura-render/tests/layout_test.rs
@@ -450,6 +450,48 @@ fn text_alignment_does_not_shrink_flex_items() {
);
}
+#[test]
+fn inline_block_flex_items_keep_block_inner_flow() {
+ let tree = parse_html(include_str!("../../../render-repros/inline-block-flex-items.html"));
+ let layout = layout_dom(&tree, (900.0, 1000.0));
+ let rect = |id| layout.rects[&tree.get_element_by_id(id).unwrap()];
+ let brand = rect("brand");
+ let title = rect("title");
+ let links = rect("links");
+ let one = rect("one");
+ let two = rect("two");
+ let three = rect("three");
+ let chips = rect("chips");
+ let alpha = rect("alpha");
+ let beta = rect("beta");
+ let gamma = rect("gamma");
+ assert!(
+ (brand.x - 0.0).abs() < 0.01
+ && (brand.width - 382.0).abs() < 0.01
+ && (title.x - 32.0).abs() < 0.01
+ && (title.width - 350.0).abs() < 0.01,
+ "brand: {brand:?}, title: {title:?}"
+ );
+ assert!(
+ (links.x - 525.0).abs() < 0.01
+ && (links.width - 90.0).abs() < 0.01
+ && (one.y - 0.0).abs() < 0.01
+ && (two.y - 20.0).abs() < 0.01
+ && (three.y - 40.0).abs() < 0.01,
+ "links: {links:?}, items: {one:?} {two:?} {three:?}"
+ );
+ assert!(
+ (chips.x - 0.0).abs() < 0.01
+ && (chips.y - 140.0).abs() < 0.01
+ && (chips.width - 90.0).abs() < 0.01
+ && (chips.height - 20.0).abs() < 0.01
+ && (alpha.x - 0.0).abs() < 0.01
+ && (beta.x - 30.0).abs() < 0.01
+ && (gamma.x - 60.0).abs() < 0.01,
+ "chips: {chips:?}, items: {alpha:?} {beta:?} {gamma:?}"
+ );
+}
+
#[test]
fn opposing_floats_share_header_band_through_inline_wrapper() {
let tree = parse_html(include_str!("../../../render-repros/opposing-header-floats.html"));
diff --git a/render-repros/checks.json b/render-repros/checks.json
index d521fd45..c084b1f3 100644
--- a/render-repros/checks.json
+++ b/render-repros/checks.json
@@ -74,6 +74,11 @@
{"name": "grid shorthand creates explicit columns", "color": "#087f5b", "width": 287, "height": 60, "count": 3},
{"name": "custom property grid shorthand creates explicit columns", "color": "#1971c2", "width": 287, "height": 60, "count": 3}
],
+ "inline-block-flex-items": [
+ {"name": "inline block title keeps its max content width", "color": "#087f5b", "x": 32, "y": 0, "width": 350, "height": 20},
+ {"name": "inline block list shrink wraps and stacks children", "color": "#1971c2", "x": 525, "y": 0, "width": 90, "height": 60},
+ {"name": "table stand-in does not blockify inline-block list", "color": "#c2255c", "x": 0, "y": 140, "width": 90, "height": 20}
+ ],
"mixed-content-block": [
{"name": "full-width block child", "color": "#ccddff", "width": 400}
],
diff --git a/render-repros/inline-block-flex-items.html b/render-repros/inline-block-flex-items.html
new file mode 100644
index 00000000..03f104cb
--- /dev/null
+++ b/render-repros/inline-block-flex-items.html
@@ -0,0 +1,71 @@
+<!doctype html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>inline block flex items use block inner flow</title>
+ <style>
+ html, body { margin: 0; }
+ #header {
+ display: flex;
+ justify-content: space-between;
+ width: 650px;
+ height: 120px;
+ background: #f08c00;
+ }
+ #brand {
+ display: inline-block;
+ padding-left: 32px;
+ }
+ #title {
+ display: block;
+ width: 350px;
+ height: 20px;
+ background: #087f5b;
+ }
+ #links {
+ display: inline-block;
+ margin: 0 35px 0 0;
+ padding: 0;
+ }
+ #links li {
+ display: block;
+ height: 20px;
+ margin: 0;
+ background: #1971c2;
+ }
+ #one { width: 90px; }
+ #two { width: 70px; }
+ #three { width: 80px; }
+ #matrix {
+ border-spacing: 0;
+ margin-top: 20px;
+ width: 200px;
+ }
+ #cell { padding: 0; }
+ #chips {
+ display: inline-block;
+ margin: 0;
+ padding: 0;
+ }
+ #chips li {
+ display: inline-block;
+ width: 30px;
+ height: 20px;
+ margin: 0;
+ padding: 0;
+ background: #c2255c;
+ }
+ </style>
+</head>
+<body>
+ <header id="header">
+ <hgroup id="brand"><span id="title"></span></hgroup>
+ <ul id="links">
+ <li id="one"></li>
+ <li id="two"></li>
+ <li id="three"></li>
+ </ul>
+ </header>
+ <table id="matrix"><tbody><tr><td id="cell"><ul id="chips"><li id="alpha"></li><li id="beta"></li><li id="gamma"></li></ul></td></tr></tbody></table>
+</body>
+</html>