The headless browser for AI agents and web scraping
render: honor container item alignment
SGavrl051e8e956e76
diff --git a/crates/obscura-render/src/lib.rs b/crates/obscura-render/src/lib.rsindex 73056a33..6cf1870a 100644--- a/crates/obscura-render/src/lib.rs+++ b/crates/obscura-render/src/lib.rs@@ -287,6 +287,7 @@ pub struct LayoutStyle {/// one field for both made `text-align:left` shrink-wrap flex children.pub text_align: Option<taffy::AlignItems>,pub align_items: Option<taffy::AlignItems>,+ pub justify_items: Option<taffy::JustifyItems>,pub align_self: Option<taffy::AlignSelf>,pub justify_self: Option<taffy::JustifySelf>,pub flex_direction: Option<taffy::FlexDirection>,@@ -719,6 +720,7 @@ pub(crate) fn to_taffy_style(style: &LayoutStyle) -> Style {// `align-items` has no effect on a block formatting context.s.align_items = None;}+ s.justify_items = style.justify_items;s.align_self = style.align_self;s.justify_self = style.justify_self;if let Some(jc) = style.justify_content {diff --git a/crates/obscura-render/src/style.rs b/crates/obscura-render/src/style.rsindex f728b36b..de17f27e 100644--- a/crates/obscura-render/src/style.rs+++ b/crates/obscura-render/src/style.rs@@ -422,13 +422,19 @@ fn apply_value(style: &mut LayoutStyle, name: &str, value: &str) {_ => {}},"align-items" => {- match value {- "center" => style.align_items = Some(taffy::AlignItems::CENTER),- "flex-start" | "start" => style.align_items = Some(taffy::AlignItems::FLEX_START),- "flex-end" | "end" => style.align_items = Some(taffy::AlignItems::FLEX_END),- "stretch" => style.align_items = Some(taffy::AlignItems::STRETCH),- "baseline" => style.align_items = Some(taffy::AlignItems::BASELINE),- _ => {}+ if let Some(Some(value)) = self_alignment_value(value) {+ style.align_items = Some(value);+ }+ },+ "justify-items" => {+ if let Some(Some(value)) = self_alignment_value(value) {+ style.justify_items = Some(value);+ }+ },+ "place-items" => {+ if let Some((Some(align), Some(justify))) = self_alignment_pair(value) {+ style.align_items = Some(align);+ style.justify_items = Some(justify);}},"align-self" => {@@ -2699,6 +2705,13 @@ mod tests {let shorthand = compute_style("div", Some("place-self:safe center flex-end"));assert_eq!(shorthand.align_self, Some(taffy::AlignSelf::SAFE_CENTER));assert_eq!(shorthand.justify_self, Some(taffy::JustifySelf::FLEX_END));++ let parent = compute_style(+ "div",+ Some("align-items:start;justify-items:safe end;place-items:end center"),+ );+ assert_eq!(parent.align_items, Some(taffy::AlignItems::END));+ assert_eq!(parent.justify_items, Some(taffy::JustifyItems::CENTER));}#[test]