#[allow(clippy::match_same_arms)] // enum/value mapping/dispatch table: one arm per input variant (or cross-type bindings that can't merge)
const fn minmax(min: MinTrackSizingFunction, max: MaxTrackSizingFunction) -> taffy::TrackSizingFunction {
#[allow(clippy::match_same_arms)] // enum/value mapping/dispatch table: one arm per input variant (or cross-type bindings that can't merge)
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)] // bounded layout/render numeric cast
LayoutAlignSelf::Auto => None, // Auto means inherit from parent's align-items (for non-abspos; abspos auto computes to itself per spec)
let (padding_width, padding_height, border_width, border_height, border_left, border_top) = tree
ContentSizeOrigin::BorderBox => (border_left + padding_width, border_top + padding_height),
crate::solver3::cache::compute_scrollbar_info_core(ctx, dom_id, &styled_node_state, content_size, container_size);
#[allow(clippy::match_same_arms)] // enum/value mapping/dispatch table: one arm per input variant (or cross-type bindings that can't merge)
const fn azul_overflow_to_taffy(ov: MultiValue<azul_css::props::layout::LayoutOverflow>) -> taffy::Overflow {
MultiValue::Exact(LayoutOverflow::Auto) => taffy::Overflow::Scroll, // Auto acts like scroll for layout
#[allow(clippy::trivially_copy_pass_by_ref)] // <=8B Copy param kept by-ref intentionally (hot pixel/coord path or to avoid churning call sites for a perf-neutral change)
#[allow(clippy::field_reassign_with_default)] // struct built incrementally / test setup; a struct literal is not clearer here
#[allow(clippy::too_many_lines)] // large but cohesive: single-purpose layout/render/parse routine (one branch per case)
taffy_style.box_sizing = match get_css_box_sizing(styled_dom, id, node_state).unwrap_or_default() {
let em_size = crate::solver3::getters::get_element_font_size(styled_dom, id, node_state);
let taffy_width = from_layout_width(width.unwrap_or_default(), &self.calc_storage, em_size, rem_size);
let taffy_height = from_layout_height(height.unwrap_or_default(), &self.calc_storage, em_size, rem_size);
let (self_is_grid, parent_is_grid) = cache.compact_cache.as_ref().map_or((false, false), |cc| {
#[allow(clippy::wildcard_imports)] // widget/render module pulls in the css property/value types it builds with
#[allow(clippy::wildcard_imports)] // widget/render module pulls in the css property/value types it builds with
let bits = ((cc.tier1_enums[id.index()] >> GRID_AUTO_FLOW_SHIFT) & GRID_AUTO_FLOW_MASK) as u8;
.and_then(|p| if let CssProperty::GridColumn(v) = p { v.get_property().cloned() } else { None })
.and_then(|p| if let CssProperty::GridRow(v) = p { v.get_property().cloned() } else { None })
taffy_style.grid_column = Line { start: decode_compact_grid_line(cs), end: decode_compact_grid_line(ce) };
taffy_style.grid_row = Line { start: decode_compact_grid_line(rs), end: decode_compact_grid_line(re) };
#[allow(clippy::wildcard_imports)] // widget/render module pulls in the css property/value types it builds with
let bits = ((cc.tier1_enums[id.index()] >> JUSTIFY_ITEMS_SHIFT) & JUSTIFY_ITEMS_MASK) as u8;
#[allow(clippy::wildcard_imports)] // widget/render module pulls in the css property/value types it builds with
let bits = ((cc.tier1_enums[id.index()] >> JUSTIFY_CONTENT_SHIFT) & JUSTIFY_MASK) as u8;
.and_then(|p| if let CssProperty::AlignSelf(v) = p { layout_align_self_to_taffy(*v) } else { None }), |cc| {
#[allow(clippy::wildcard_imports)] // widget/render module pulls in the css property/value types it builds with
#[allow(clippy::wildcard_imports)] // widget/render module pulls in the css property/value types it builds with
let bits = ((cc.tier1_enums[id.index()] >> JUSTIFY_SELF_SHIFT) & JUSTIFY_SELF_MASK) as u8;
MultiValue::Exact(v) => Some(layout_align_content_to_taffy(CssPropertyValue::Exact(v))),
let is_root = self.tree.get(LayoutNodeId::new(node_idx)).is_some_and(|n| n.parent.is_none());
let (suppress_width, suppress_height) = self.should_suppress_cross_intrinsic(node_idx, &style);
#[allow(clippy::match_same_arms)] // enum/value mapping/dispatch table: one arm per input variant (or cross-type bindings that can't merge)
fn should_suppress_cross_intrinsic(&self, node_idx: usize, style: &Style) -> (bool, bool) {
let Some(parent_fc) = self.tree.warm(LayoutNodeId::new(node_idx)).and_then(|w| w.parent_formatting_context) else {
let parent_dom_id = self.tree.get(LayoutNodeId::new(parent_idx)).and_then(|n| n.dom_node_id);
let text_cache_ptr = core::ptr::from_mut::<crate::font_traits::TextLayoutCache>(text_cache);
child_idx, child.used_size, bridge.tree.warm(LayoutNodeId::new(child_idx)).and_then(|w| w.relative_position)
fn get_core_container_style(&self, node_id: taffy::NodeId) -> Self::CoreContainerStyle<'_> {
let (parent_border_left, parent_border_top, parent_padding_left, parent_padding_top) = {
let mut result = compute_cached_layout(self, node_id, inputs, |tree, node_id, inputs| {
#[allow(clippy::match_same_arms)] // enum/value mapping/dispatch table: one arm per input variant (or cross-type bindings that can't merge)
#[allow(clippy::too_many_lines)] // large but cohesive: single-purpose layout/render/parse routine (one branch per case)
fn compute_non_flex_layout(&mut self, node_idx: usize, inputs: LayoutInput) -> LayoutOutput {
let (node_padding_width, node_padding_height, node_border_width, node_border_height) = self
let final_width = inputs.known_dimensions.width.map_or(border_box_width, |border_box_w| border_box_w);
let final_height = if let Some(border_box_h) = inputs.known_dimensions.height { border_box_h } else {
let intrinsic = self.tree.warm(LayoutNodeId::new(node_idx)).and_then(|w| w.intrinsic_sizes).unwrap_or_default();
fn get_flexbox_child_style(&self, child_node_id: taffy::NodeId) -> Self::FlexboxItemStyle<'_> {
fn get_grid_container_style(&self, node_id: taffy::NodeId) -> Self::GridContainerStyle<'_> {
#[allow(clippy::match_same_arms)] // enum/value mapping/dispatch table: one arm per input variant (or cross-type bindings that can't merge)
LayoutWidth::MinContent | LayoutWidth::MaxContent | LayoutWidth::FitContent(_) => Dimension::auto(),
LayoutWidth::Calc(items) => store_calc_and_make_dimension(items, calc_storage, em_size, rem_size),
#[allow(clippy::match_same_arms)] // enum/value mapping/dispatch table: one arm per input variant (or cross-type bindings that can't merge)
LayoutHeight::MinContent | LayoutHeight::MaxContent | LayoutHeight::FitContent(_) => Dimension::auto(),
LayoutHeight::Calc(items) => store_calc_and_make_dimension(items, calc_storage, em_size, rem_size),
#[allow(clippy::match_same_arms)] // enum/value mapping/dispatch table: one arm per input variant (or cross-type bindings that can't merge)
assert!(grid_template_rows_to_taffy(CssPropertyValue::Exact(template(Vec::new()))).is_empty());
#[allow(clippy::vec_box)] // return type must mirror the production calc_storage (Box = stable element addresses)