Skip to content

The headless browser for AI agents and web scraping

test: gate float flow geometry

SGavrl944db4b1044a
diff --git a/crates/obscura-render/tests/layout_test.rs b/crates/obscura-render/tests/layout_test.rs
index ab346174..bcc57d5e 100644
--- a/crates/obscura-render/tests/layout_test.rs
+++ b/crates/obscura-render/tests/layout_test.rs
@@ -332,3 +332,30 @@ fn percentage_flex_overlay_uses_auto_width_parent_content_box() {
assert!((sidebar.x - 16.0).abs() < 0.01, "sidebar: {sidebar:?}");
assert!((sidebar.width - 320.0).abs() < 0.01, "sidebar: {sidebar:?}");
}
+
+#[test]
+fn float_flow_zone_preserves_blocks_inline_runs_and_clearance() {
+ let tree = parse_html(include_str!("../../../render-repros/float-flow-bands.html"));
+ let layout = layout_dom(&tree, (900.0, 1000.0));
+ let rect = |id| layout.rects[&tree.get_element_by_id(id).unwrap()];
+ let float = rect("float");
+ let intro = rect("intro");
+ let release = rect("release");
+ let download = rect("download");
+ let archive = rect("archive");
+ let sponsors = rect("sponsors");
+ let logos = rect("logos");
+ let cleared = rect("cleared");
+ assert!((float.x - 650.0).abs() < 0.01 && (float.height - 400.0).abs() < 0.01, "float: {float:?}");
+ assert!((intro.x - 0.0).abs() < 0.01 && (intro.width - 650.0).abs() < 0.01, "intro: {intro:?}");
+ assert!((release.y - 100.0).abs() < 0.01 && (release.width - 650.0).abs() < 0.01, "release: {release:?}");
+ assert!((download.x - 0.0).abs() < 0.01 && (download.y - 150.0).abs() < 0.01, "download: {download:?}");
+ assert!((archive.x - 60.0).abs() < 0.01 && (archive.y - 150.0).abs() < 0.01, "archive: {archive:?}");
+ assert!((sponsors.y - 180.0).abs() < 0.01, "sponsors: {sponsors:?}");
+ assert!((logos.y - 230.0).abs() < 0.01, "logos: {logos:?}");
+ assert!((cleared.y - 400.0).abs() < 0.01 && (cleared.width - 900.0).abs() < 0.01, "cleared: {cleared:?}");
+ assert!(
+ !layout.rects.contains_key(&tree.get_element_by_id("mobile-duplicate").unwrap()),
+ "display:none duplicate generated a box"
+ );
+}
diff --git a/render-repros/checks.json b/render-repros/checks.json
index ae11772f..9010b363 100644
--- a/render-repros/checks.json
+++ b/render-repros/checks.json
@@ -48,6 +48,16 @@
{"name": "display contents flex sidebar starts at container edge", "color": "#7048e8", "x": 0, "y": 260, "width": 150, "height": 140},
{"name": "display contents flex body keeps its intended inset", "color": "#c2255c", "x": 150, "y": 260, "width": 450, "height": 160}
],
+ "float-flow-bands": [
+ {"name": "right float occupies its band", "color": "#1971c2", "x": 650, "y": 0, "width": 250, "height": 400},
+ {"name": "float-avoiding intro uses available band", "color": "#087f5b", "x": 0, "y": 0, "width": 650, "height": 100},
+ {"name": "heading remains beside float", "color": "#e8590c", "x": 0, "y": 100, "width": 650, "height": 50},
+ {"name": "first inline atomic box shares one line", "color": "#c2255c", "x": 0, "y": 150, "width": 60, "height": 30},
+ {"name": "second inline atomic box shares one line", "color": "#7048e8", "x": 60, "y": 150, "width": 90, "height": 30},
+ {"name": "hidden duplicate consumes no flow height", "color": "#f08c00", "x": 0, "y": 180, "width": 650, "height": 50},
+ {"name": "later block remains in float band", "color": "#1098ad", "x": 0, "y": 230, "width": 650, "height": 70},
+ {"name": "clear moves below float bottom", "color": "#a61e4d", "x": 0, "y": 400, "width": 900, "height": 50}
+ ],
"grid-auto-repeat": [
{"name": "auto-fill creates all fitting tracks", "color": "#087f5b", "width": 210, "height": 60, "count": 4},
{"name": "auto-fit collapses empty tracks", "color": "#1971c2", "width": 287, "height": 60, "count": 3}
diff --git a/render-repros/float-flow-bands.html b/render-repros/float-flow-bands.html
new file mode 100644
index 00000000..b685a0d3
--- /dev/null
+++ b/render-repros/float-flow-bands.html
@@ -0,0 +1,55 @@
+<!doctype html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>float flow bands</title>
+ <style>
+ html, body { margin: 0; }
+ #container { width: 900px; }
+ #float {
+ float: right;
+ width: 250px;
+ height: 400px;
+ background: #1971c2;
+ }
+ .avoids-float {
+ overflow: hidden;
+ margin: 0;
+ width: auto;
+ }
+ #intro { height: 100px; background: #087f5b; }
+ #release { height: 50px; background: #e8590c; }
+ .inline {
+ display: inline-block;
+ vertical-align: top;
+ height: 30px;
+ }
+ #download { width: 60px; background: #c2255c; }
+ #archive { width: 90px; background: #7048e8; }
+ #mobile-duplicate {
+ display: none;
+ height: 300px;
+ }
+ #sponsors { height: 50px; background: #f08c00; }
+ #logos { height: 70px; background: #1098ad; }
+ #cleared {
+ clear: both;
+ width: 900px;
+ height: 50px;
+ background: #a61e4d;
+ }
+ </style>
+</head>
+<body>
+ <div id="container">
+ <aside id="float"></aside>
+ <div id="intro" class="avoids-float"></div>
+ <h2 id="release" class="avoids-float"></h2>
+ <span id="download" class="inline"></span><span id="archive" class="inline"></span>
+ <div id="mobile-duplicate"></div>
+ <h2 id="sponsors" class="avoids-float"></h2>
+ <div id="logos" class="avoids-float"></div>
+ <div id="cleared"></div>
+ </div>
+</body>
+</html>