The headless browser for AI agents and web scraping
Expose float geometry through computed style
SGavrl4b4854a60bfa
diff --git a/crates/obscura-render/src/paint.rs b/crates/obscura-render/src/paint.rsindex 9eeec75b..32264443 100644--- a/crates/obscura-render/src/paint.rs+++ b/crates/obscura-render/src/paint.rs@@ -1152,6 +1152,25 @@ impl PreparedRender {}};out.insert("display", display.to_string());+ out.insert(+ "float",+ match style.float {+ Some(crate::Float::Left) => "left",+ Some(crate::Float::Right) => "right",+ None => "none",+ }+ .to_string(),+ );+ out.insert(+ "clear",+ match style.clear {+ Some(crate::Clear::Left) => "left",+ Some(crate::Clear::Right) => "right",+ Some(crate::Clear::Both) => "both",+ None => "none",+ }+ .to_string(),+ );out.insert("position",if style.position_fixed {@@ -13905,6 +13924,29 @@ mod tests {);}+ #[test]+ fn computed_style_exposes_float_and_clear() {+ let tree = parse_html(+ r#"<style>#left{float:left} #right{float:right;clear:both}</style>+ <div id="left"></div><div id="right"></div><div id="plain"></div>"#,+ );+ let mut resources = RenderResourceCache::default();+ let prepared =+ prepare_dom(&tree, (320.0, 200.0), None, &mut resources).expect("prepared render");+ let computed = |id| {+ prepared+ .computed_style(tree.get_element_by_id(id).unwrap())+ .expect("computed style")+ };++ assert_eq!(computed("left")["float"], "left");+ assert_eq!(computed("left")["clear"], "none");+ assert_eq!(computed("right")["float"], "right");+ assert_eq!(computed("right")["clear"], "both");+ assert_eq!(computed("plain")["float"], "none");+ assert_eq!(computed("plain")["clear"], "none");+ }+#[test]fn paints_inline_svg_with_framework_colon_attribute() {let tree = obscura_dom::parse_html(