Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667// Admitted candidate `model_1` (qwen3.8-27b, 156/227); provenance: margin.provenance.jsonuse crate::margin::{MarginCollapseInputs, MarginCollapseOutputs};
pub fn classify(inputs: &MarginCollapseInputs) -> MarginCollapseOutputs { // CSS 2.1 8.3.1 case 4: the box's own top and bottom margins collapse into one. // Conditions (all must hold): // - no top border or padding separates the margins // - no bottom border or padding separates the margins // - computed 'min-height' is zero (we don't have this in inputs, but the spec says // "zero computed 'min-height', zero or 'auto' computed 'height', and no in-flow children") // The inputs give us height_is_auto, height_is_explicit_zero, and no_in_flow_content. // - height is zero or auto // - no in-flow children let self_collapsing = !inputs.has_top_border_or_padding && !inputs.has_bottom_border_or_padding && (inputs.height_is_auto || inputs.height_is_explicit_zero) && inputs.no_in_flow_content;
// Case 1: top margin of a box and top margin of its first in-flow child. // The box's top margin is open to adjoin its parent's top margin if: // - the box does not have a top border or padding // - the box does not establish a new BFC (which blocks child margins from escaping) // (establishes_bfc gates only whether a box's own margin-top/bottom may adjoin // its first/last in-flow child's -- it blocks a child's margin from escaping // through this box) let top_open = !inputs.has_top_border_or_padding && !inputs.establishes_bfc;
// Case 2: bottom margin of a last in-flow child and bottom margin of its parent. // The box's bottom margin is open to adjoin its parent's bottom margin if: // - the box does not have a bottom border or padding // - the box does not establish a new BFC let bottom_open = !inputs.has_bottom_border_or_padding && !inputs.establishes_bfc;
// Case 3: bottom margin of a box and top margin of its next in-flow sibling. // Per the spec and the contract: "Unconditionally true in a correct implementation // on this corpus (no floats, no clearance), but exposed as its own decision so a // candidate can get it wrong." let sibling_adjoin = true;
MarginCollapseOutputs { self_collapsing, top_open, bottom_open, sibling_adjoin, }}
pub fn combine(values: &[f64]) -> f64 { let largest_positive = values.iter().fold(0.0f64, |acc, &v| { if v > 0.0 { acc.max(v) } else { acc } });
let most_negative = values.iter().fold(0.0f64, |acc, &v| { if v < 0.0 { acc.min(v) } else { acc } });
largest_positive + most_negative}