Skip to content

The headless browser for AI agents and web scraping

Merge remote-tracking branch 'github/main' into integrate/pr-1179-main-20261004

SGavrl16ae94339ad8
diff --cc crates/obscura-render/src/dom.rs
index f7994a85,6085822e..0571f7ba
--- a/crates/obscura-render/src/dom.rs
+++ b/crates/obscura-render/src/dom.rs
@@@ -7381,9 -7413,9 +7415,9 @@@ fn layout_dom_once
},
)
{
- let _ = taffy_tree.compute_layout(taffy_root, available);
+ let _ = taffy_tree.compute_layout_with_measure(taffy_root, available, &mut measure);
}
- if resolve_atomic_percentage_heights(
+ if resolve_inline_percentage_heights(
tree,
&mut taffy_tree,
taffy_root,
diff --cc crates/obscura-render/tests/layout_test.rs
index 6f6030bb,f86dfe16..c21686e3
--- a/crates/obscura-render/tests/layout_test.rs
+++ b/crates/obscura-render/tests/layout_test.rs
@@@ -4485,34 -4515,28 +4515,56 @@@ fn grid_replaced_classification_keeps_c
assert_eq!(auto_button.x + auto_button.width, auto_button_grid.x + auto_button_grid.width);
}
+#[test]
+fn inline_block_percentage_height_uses_definite_block_content_height() {
+ let tree = parse_html(r#"<!doctype html>
+ <style>
+ html, body { margin:0 }
+ .switch { position:relative; width:32px; height:16px; line-height:1 }
+ input { position:absolute; width:100%; height:100%; margin:0; opacity:0; z-index:-1000 }
+ label { display:inline-block; box-sizing:border-box; width:100%; height:100%; border:1px solid }
+ .padded { height:30px; box-sizing:border-box; padding:4px; border:1px solid }
+ .indefinite { height:auto; min-height:40px }
+ </style>
+ <div class="switch"><input type="checkbox"><label id="percentage"></label></div>
+ <div class="switch"><input type="checkbox"><label id="pixels" style="height:16px"></label></div>
+ <div class="switch padded"><label id="content-box"></label></div>
+ <div class="switch padded"><label id="half" style="height:50%"></label></div>
+ <div class="switch indefinite"><label id="indefinite"></label></div>
+ "#);
+ let layout = layout_dom(&tree, (800.0, 600.0));
+ for (name, width, height) in [
+ ("percentage", 32.0, 16.0), ("pixels", 32.0, 16.0),
+ ("content-box", 22.0, 20.0), ("half", 22.0, 10.0), ("indefinite", 32.0, 2.0),
+ ] {
+ let rect = layout.rects[&tree.get_element_by_id(name).unwrap()];
+ assert_eq!(rect.width, width, "{name}");
+ assert_eq!(rect.height, height, "{name}");
+ }
+}
+
+ #[test]
+ fn inherited_font_shorthand_overrides_native_control_typography() {
+ let tree = parse_html(r#"
+ <style>
+ body { font:700 20px/30px Arial }
+ input { display:block; border:0; padding:0 }
+ </style>
+ <input id="inherit" style="font:inherit">
+ <input id="unset" style="font:unset">
+ "#);
+ let layout = layout_dom(&tree, (800.0, 600.0));
+ for name in ["inherit", "unset"] {
+ let node = tree.get_element_by_id(name).unwrap();
+ let style = &layout.styles[&node];
+ assert_eq!(style.font_size, Some(20.0), "{name}");
+ assert_eq!(style.line_height, Some(obscura_render::LineHeight::Px(30.0)), "{name}");
+ assert_eq!(style.font_weight.as_deref(), Some("700"), "{name}");
+ assert_eq!(style.font_family.as_deref(), Some("arial"), "{name}");
+ assert_eq!(layout.rects[&node].height, 30.0, "{name}");
+ }
+ }
+
#[test]
fn grid_ordinary_aspect_ratio_preserves_normal_alignment_provenance() {
let tree = parse_html(