From 7aa6b5665132cef8b4858b7ae0b802ab5e2d8ebd Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Sat, 28 Feb 2026 16:41:21 -0500 Subject: [PATCH 01/17] Fixes for absolute blocks with auto --- src/compute/block.rs | 252 ++++++++++++------ .../block/block_absolute_auto_margin.rs | 125 +++++++++ 2 files changed, 300 insertions(+), 77 deletions(-) create mode 100644 tests/generated/block/block_absolute_auto_margin.rs diff --git a/src/compute/block.rs b/src/compute/block.rs index b18c134b3..f2da8c25b 100644 --- a/src/compute/block.rs +++ b/src/compute/block.rs @@ -1,4 +1,5 @@ //! Computes the CSS block layout algorithm in the case that the block container being laid out contains only block-level boxes + use crate::geometry::{Line, Point, Rect, Size}; use crate::style::{AvailableSpace, CoreStyle, LengthPercentageAuto, Overflow, Position}; use crate::style_helpers::TaffyMaxContent; @@ -1121,90 +1122,61 @@ fn perform_absolute_layout_on_absolute_children( Line::FALSE, ); - let non_auto_margin = Rect { - left: if left.is_some() { margin.left.unwrap_or(0.0) } else { 0.0 }, - right: if right.is_some() { margin.right.unwrap_or(0.0) } else { 0.0 }, - top: if top.is_some() { margin.top.unwrap_or(0.0) } else { 0.0 }, - bottom: if bottom.is_some() { margin.bottom.unwrap_or(0.0) } else { 0.0 }, - }; - - // Expand auto margins to fill available space - // https://www.w3.org/TR/CSS21/visudet.html#abs-non-replaced-width - let auto_margin = { - // Auto margins for absolutely positioned elements in block containers only resolve - // if inset is set. Otherwise they resolve to 0. - let absolute_auto_margin_space = Point { - x: right.map(|right| area_size.width - right - left.unwrap_or(0.0)).unwrap_or(final_size.width), - y: bottom.map(|bottom| area_size.height - bottom - top.unwrap_or(0.0)).unwrap_or(final_size.height), - }; - let free_space = Size { - width: absolute_auto_margin_space.x - final_size.width - non_auto_margin.horizontal_axis_sum(), - height: absolute_auto_margin_space.y - final_size.height - non_auto_margin.vertical_axis_sum(), - }; - - let auto_margin_size = Size { - // If all three of 'left', 'width', and 'right' are 'auto': First set any 'auto' values for 'margin-left' and 'margin-right' to 0. - // Then, if the 'direction' property of the element establishing the static-position containing block is 'ltr' set 'left' to the - // static position and apply rule number three below; otherwise, set 'right' to the static position and apply rule number one below. - // - // If none of the three is 'auto': If both 'margin-left' and 'margin-right' are 'auto', solve the equation under the extra constraint - // that the two margins get equal values, unless this would make them negative, in which case when direction of the containing block is - // 'ltr' ('rtl'), set 'margin-left' ('margin-right') to zero and solve for 'margin-right' ('margin-left'). If one of 'margin-left' or - // 'margin-right' is 'auto', solve the equation for that value. If the values are over-constrained, ignore the value for 'left' (in case - // the 'direction' property of the containing block is 'rtl') or 'right' (in case 'direction' is 'ltr') and solve for that value. - width: { - let auto_margin_count = margin.left.is_none() as u8 + margin.right.is_none() as u8; - if auto_margin_count == 2 - && (style_size.width.is_none() || style_size.width.unwrap() >= free_space.width) - { - 0.0 - } else if auto_margin_count > 0 { - free_space.width / auto_margin_count as f32 - } else { - 0.0 - } - }, - height: { - let auto_margin_count = margin.top.is_none() as u8 + margin.bottom.is_none() as u8; - if auto_margin_count == 2 - && (style_size.height.is_none() || style_size.height.unwrap() >= free_space.height) - { - 0.0 - } else if auto_margin_count > 0 { - free_space.height / auto_margin_count as f32 - } else { - 0.0 - } - }, - }; + let (computed_left, _computed_right, computed_margin_left, computed_margin_right) = + resolve_absolute_margin_and_positions( + style_size.width, + area_width, + left, + right, + final_size.width, + margin.left, + margin.right, + border.left, + border.right, + padding.left, + padding.right, + item.static_position.x, + ); - Rect { - left: margin.left.map(|_| 0.0).unwrap_or(auto_margin_size.width), - right: margin.right.map(|_| 0.0).unwrap_or(auto_margin_size.width), - top: margin.top.map(|_| 0.0).unwrap_or(auto_margin_size.height), - bottom: margin.bottom.map(|_| 0.0).unwrap_or(auto_margin_size.height), - } - }; + let (computed_top, _computed_bottom, computed_margin_top, computed_margin_bottom) = + resolve_absolute_margin_and_positions( + style_size.height, + area_height, + top, + bottom, + final_size.height, + margin.top, + margin.bottom, + border.top, + border.bottom, + padding.top, + padding.bottom, + item.static_position.y, + ); let resolved_margin = Rect { - left: margin.left.unwrap_or(auto_margin.left), - right: margin.right.unwrap_or(auto_margin.right), - top: margin.top.unwrap_or(auto_margin.top), - bottom: margin.bottom.unwrap_or(auto_margin.bottom), + left: computed_margin_left, + right: computed_margin_right, + top: computed_margin_top, + bottom: computed_margin_bottom, }; + let is_static_x = left.is_none() && right.is_none(); + let is_static_y = top.is_none() && bottom.is_none(); + let location = Point { - x: left - .map(|left| left + resolved_margin.left) - .or(right.map(|right| area_size.width - final_size.width - right - resolved_margin.right)) - .maybe_add(area_offset.x) - .unwrap_or(item.static_position.x + resolved_margin.left), - y: top - .map(|top| top + resolved_margin.top) - .or(bottom.map(|bottom| area_size.height - final_size.height - bottom - resolved_margin.bottom)) - .maybe_add(area_offset.y) - .unwrap_or(item.static_position.y + resolved_margin.top), + x: if is_static_x { + computed_left + resolved_margin.left + } else { + computed_left + resolved_margin.left + area_offset.x + }, + y: if is_static_y { + computed_top + resolved_margin.top + } else { + computed_top + resolved_margin.top + area_offset.y + }, }; + // Note: axis intentionally switched here as scrollbars take up space in the opposite axis // to the axis in which scrolling is enabled. let scrollbar_size = Size { @@ -1240,3 +1212,129 @@ fn perform_absolute_layout_on_absolute_children( absolute_content_size } +/// Compute margin and positons for absolutely positioned children. +#[inline] +fn resolve_absolute_margin_and_positions( + size: Option, + area_width: f32, + primary: Option, + secondary: Option, + final_size: f32, + margin_primary: Option, + margin_secondary: Option, + border_primary: f32, + border_secondary: f32, + padding_primary: f32, + padding_secondary: f32, + static_position: f32, +) -> (f32, f32, f32, f32) { + // https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width + + let mut computed_margin_primary = margin_primary.unwrap_or(0.0); + let mut computed_margin_secondary = margin_secondary.unwrap_or(0.0); + + let mut _computed_size: f32 = size.unwrap_or(0.0); + + let mut computed_primary: f32 = primary.unwrap_or(0.0); + let mut computed_secondary: f32 = secondary.unwrap_or(0.0); + + // If all three of 'left', 'width', and 'right' are 'auto': First set any 'auto' values for 'margin-left' and 'margin-right' to 0. + if primary.is_none() && size.is_none() && secondary.is_none() { + computed_margin_primary = 0.0; + computed_margin_secondary = 0.0; + + // Then, if the 'direction' property of the element establishing the static-position containing block is 'ltr' set 'left' to the static position and apply rule number three below; otherwise, set 'right' to the static position and apply rule number one below. + // Assume always ltr + + computed_primary = static_position; + + // apply rule number three + + // 'width' and 'right' are 'auto' and 'left' is not 'auto', then the width is shrink-to-fit . Then solve for 'right' + let width = final_size; + + // 'right' = width of containing block - ('left' + 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right') + computed_secondary = area_width - (computed_primary + margin_primary.unwrap() + width) + } + // If none of the three is 'auto' + else if primary.is_some() && size.is_some() && secondary.is_some() { + // If both 'margin-left' and 'margin-right' are 'auto' + if margin_primary.is_none() && margin_secondary.is_none() { + // solve the equation under the extra constraint that the two margins get equal values + + // 'left' + '2M' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'right' = width of containing block + // M = (width of containing block - ('left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'right')) / 2 + let margin = (area_width - (primary.unwrap() + final_size + secondary.unwrap())) / 2.0; + + if margin >= 0.0 { + computed_margin_secondary = margin; + computed_margin_primary = margin; + } else { + // unless this would make them negative, in which case when direction of the + // containing block is 'ltr' ('rtl'), set 'margin-left' ('margin-right') to + // zero and solve for 'margin-right' ('margin-left'). + computed_margin_primary = 0.0; + computed_margin_secondary = area_width - (primary.unwrap() + final_size + secondary.unwrap()); + } + } else if margin_primary.is_some() { + // If one of 'margin-left' or 'margin-right' is 'auto', solve the equation for that + computed_margin_secondary = + area_width - (primary.unwrap() + margin_primary.unwrap() + final_size + secondary.unwrap()); + } else if margin_secondary.is_some() { + // If one of 'margin-left' or 'margin-right' is 'auto', solve the equation for that + computed_margin_primary = + area_width - (primary.unwrap() + final_size + margin_secondary.unwrap() + secondary.unwrap()); + } else { + // If the values are over-constrained, ignore the value for 'left' + // (in case the 'direction' property of the containing block is 'rtl') or 'right' + // (in case 'direction' is 'ltr') and solve for that value. + computed_secondary = + area_width - (primary.unwrap() + margin_primary.unwrap() + final_size + margin_secondary.unwrap()); + } + } else { + // Otherwise, set 'auto' values for 'margin-left' and 'margin-right' to 0, and pick the one of the following six rules that applies. + // These are already our initial values chosen above, so no need to do anything. + + if primary.is_none() && size.is_none() && secondary.is_some() { + // 1. 'left' and 'width' are 'auto' and 'right' is not 'auto', then the width is shrink-to-fit. Then solve for 'left' + computed_primary = + area_width - (computed_margin_primary + final_size + computed_margin_secondary + secondary.unwrap()); + } else if primary.is_none() && secondary.is_none() && size.is_some() { + // 2. 'left' and 'right' are 'auto' and 'width' is not 'auto', + // then if the 'direction' property of the element establishing the static-position + // containing block is 'ltr' set 'left' to the static position, + computed_primary = static_position; + computed_secondary = + area_width - (computed_primary + computed_margin_primary + final_size + computed_margin_secondary); + // otherwise set 'right' to the static position. Then solve for 'left' + // (if 'direction is 'rtl') or 'right' (if 'direction' is 'ltr'). + } else if size.is_none() && secondary.is_none() && primary.is_some() { + // 3. 'width' and 'right' are 'auto' and 'left' is not 'auto', then the width is shrink-to-fit . Then solve for 'right' + computed_secondary = + area_width - (primary.unwrap() + computed_margin_primary + final_size + computed_margin_secondary) + } else if primary.is_none() && size.is_some() && secondary.is_some() { + // 4. 'left' is 'auto', 'width' and 'right' are not 'auto', then solve for 'left' + computed_primary = + area_width - (computed_margin_primary + final_size + computed_margin_secondary + secondary.unwrap()); + } else if size.is_none() && primary.is_some() && secondary.is_some() { + // 5. 'width' is 'auto', 'left' and 'right' are not 'auto', then solve for 'width' + _computed_size = area_width + - (primary.unwrap() + + computed_margin_primary + + border_primary + + padding_primary + + padding_secondary + + border_secondary + + computed_margin_secondary + + secondary.unwrap()); + } else if secondary.is_none() && primary.is_some() && size.is_some() { + // 6. 'right' is 'auto', 'left' and 'width' are not 'auto', then solve for 'right' + computed_secondary = + area_width - (primary.unwrap() + computed_margin_primary + final_size + computed_margin_secondary); + } else { + unreachable!(); + } + } + + (computed_primary, computed_secondary, computed_margin_primary, computed_margin_secondary) +} diff --git a/tests/generated/block/block_absolute_auto_margin.rs b/tests/generated/block/block_absolute_auto_margin.rs new file mode 100644 index 000000000..00c6f94a8 --- /dev/null +++ b/tests/generated/block/block_absolute_auto_margin.rs @@ -0,0 +1,125 @@ +#[test] +#[allow(non_snake_case)] +fn block_absolute_auto_margin__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(100f32), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: length(50f32), + right: length(0f32), + top: length(0f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(200f32), + height: taffy::style::Dimension::from_length(200f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); + assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); + assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node0, 75f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); +} + +#[test] +#[allow(non_snake_case)] +fn block_absolute_auto_margin__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(100f32), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: length(50f32), + right: length(0f32), + top: length(0f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(200f32), + height: taffy::style::Dimension::from_length(200f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); + assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); + assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node0, 75f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); +} From ebca2fd12cdf47e41132138c65952416be4e7d4e Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Sat, 28 Feb 2026 16:42:03 -0500 Subject: [PATCH 02/17] Run GenTests --- tests/generated/block/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/generated/block/mod.rs b/tests/generated/block/mod.rs index 3c788be2b..652ac9668 100644 --- a/tests/generated/block/mod.rs +++ b/tests/generated/block/mod.rs @@ -10,9 +10,17 @@ mod block_absolute_aspect_ratio_fill_width; mod block_absolute_aspect_ratio_fill_width_from_inset; mod block_absolute_aspect_ratio_height_overrides_inset; mod block_absolute_aspect_ratio_width_overrides_inset; +mod block_absolute_auto_margin; +mod block_absolute_auto_margins_and_insets; mod block_absolute_child_with_margin_x; mod block_absolute_child_with_margin_y; mod block_absolute_child_with_max_height; +mod block_absolute_horizontal_left_and_right_auto_width_not_auto; +mod block_absolute_horizontal_left_and_width_auto_right_not_auto; +mod block_absolute_horizontal_left_auto_width_and_right_not_auto; +mod block_absolute_horizontal_right_auto_left_and_width_not_auto; +mod block_absolute_horizontal_width_and_right_auto_left_not_auto; +mod block_absolute_horizontal_width_auto_left_and_right_not_auto; mod block_absolute_layout_child_order; mod block_absolute_layout_no_size; mod block_absolute_layout_percentage_bottom_based_on_parent_height; From a3f4c36ee002d6a6ae589feddf7732de5c9e95af Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Sat, 28 Feb 2026 16:42:30 -0500 Subject: [PATCH 03/17] Add more absolute block tests --- .../block/block_absolute_auto_margin.html | 28 ++++ ...lock_absolute_auto_margins_and_insets.html | 35 ++++ ...al_left_and_right_auto_width_not_auto.html | 32 ++++ ...al_left_and_width_auto_right_not_auto.html | 32 ++++ ...al_left_auto_width_and_right_not_auto.html | 32 ++++ ...al_right_auto_left_and_width_not_auto.html | 32 ++++ ...al_width_and_right_auto_left_not_auto.html | 32 ++++ ...al_width_auto_left_and_right_not_auto.html | 32 ++++ .../block_absolute_auto_margins_and_insets.rs | 151 ++++++++++++++++++ ...ntal_left_and_right_auto_width_not_auto.rs | 125 +++++++++++++++ ...ntal_left_and_width_auto_right_not_auto.rs | 125 +++++++++++++++ ...ntal_left_auto_width_and_right_not_auto.rs | 125 +++++++++++++++ ...ntal_right_auto_left_and_width_not_auto.rs | 125 +++++++++++++++ ...ntal_width_and_right_auto_left_not_auto.rs | 125 +++++++++++++++ ...ntal_width_auto_left_and_right_not_auto.rs | 125 +++++++++++++++ 15 files changed, 1156 insertions(+) create mode 100644 test_fixtures/block/block_absolute_auto_margin.html create mode 100644 test_fixtures/block/block_absolute_auto_margins_and_insets.html create mode 100644 test_fixtures/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.html create mode 100644 test_fixtures/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.html create mode 100644 test_fixtures/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.html create mode 100644 test_fixtures/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.html create mode 100644 test_fixtures/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.html create mode 100644 test_fixtures/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.html create mode 100644 tests/generated/block/block_absolute_auto_margins_and_insets.rs create mode 100644 tests/generated/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.rs create mode 100644 tests/generated/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.rs create mode 100644 tests/generated/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.rs create mode 100644 tests/generated/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.rs create mode 100644 tests/generated/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.rs create mode 100644 tests/generated/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.rs diff --git a/test_fixtures/block/block_absolute_auto_margin.html b/test_fixtures/block/block_absolute_auto_margin.html new file mode 100644 index 000000000..b987da665 --- /dev/null +++ b/test_fixtures/block/block_absolute_auto_margin.html @@ -0,0 +1,28 @@ + + + + + + + Absolute positioning: Horizontal centering with vertical margin interference + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block/block_absolute_auto_margins_and_insets.html b/test_fixtures/block/block_absolute_auto_margins_and_insets.html new file mode 100644 index 000000000..deb01d12d --- /dev/null +++ b/test_fixtures/block/block_absolute_auto_margins_and_insets.html @@ -0,0 +1,35 @@ + + + + + + + Absolute positioning: Border/Padding interference with Auto-Margins and Insets + + + + +
+ +
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.html b/test_fixtures/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.html new file mode 100644 index 000000000..1e6b0a5e4 --- /dev/null +++ b/test_fixtures/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.html @@ -0,0 +1,32 @@ + + + + + + + Absolute positioning: 'left' and 'right' are 'auto' and 'width' is not 'auto', then if the 'direction' property of the element establishing the static-position containing block is 'ltr' set 'left' to the static position, otherwise set 'right' to the static position. Then solve for 'left' (if 'direction is 'rtl') or 'right' (if 'direction' is 'ltr'). + + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.html b/test_fixtures/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.html new file mode 100644 index 000000000..eea337cf3 --- /dev/null +++ b/test_fixtures/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.html @@ -0,0 +1,32 @@ + + + + + + + Absolute positioning: 'left' and 'width' are 'auto' and 'right' is not 'auto', then the width is shrink-to-fit. Then solve for 'left' + + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.html b/test_fixtures/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.html new file mode 100644 index 000000000..f76a22236 --- /dev/null +++ b/test_fixtures/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.html @@ -0,0 +1,32 @@ + + + + + + + Absolute positioning: 'left' is 'auto', 'width' and 'right' are not 'auto', then solve for 'left' + + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.html b/test_fixtures/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.html new file mode 100644 index 000000000..a49d1369d --- /dev/null +++ b/test_fixtures/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.html @@ -0,0 +1,32 @@ + + + + + + + Absolute positioning: 'right' is 'auto', 'left' and 'width' are not 'auto', then solve for 'right' + + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.html b/test_fixtures/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.html new file mode 100644 index 000000000..8319ee459 --- /dev/null +++ b/test_fixtures/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.html @@ -0,0 +1,32 @@ + + + + + + + Absolute positioning: 'width' and 'right' are 'auto' and 'left' is not 'auto', then the width is shrink-to-fit . Then solve for 'right' + + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/test_fixtures/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.html b/test_fixtures/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.html new file mode 100644 index 000000000..6b8818fb7 --- /dev/null +++ b/test_fixtures/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.html @@ -0,0 +1,32 @@ + + + + + + + Absolute positioning: 'width' is 'auto', 'left' and 'right' are not 'auto', then solve for 'width' + + + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/tests/generated/block/block_absolute_auto_margins_and_insets.rs b/tests/generated/block/block_absolute_auto_margins_and_insets.rs new file mode 100644 index 000000000..869ec3135 --- /dev/null +++ b/tests/generated/block/block_absolute_auto_margins_and_insets.rs @@ -0,0 +1,151 @@ +#[test] +#[allow(non_snake_case)] +fn block_absolute_auto_margins_and_insets__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(60f32), + height: taffy::style::Dimension::from_length(60f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: zero(), + bottom: zero(), + }, + inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), top: auto(), bottom: auto() }, + border: taffy::geometry::Rect { + left: length(10f32), + right: length(10f32), + top: length(10f32), + bottom: length(10f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(120f32), + height: taffy::style::Dimension::from_length(120f32), + }, + padding: taffy::geometry::Rect { + left: length(20f32), + right: length(20f32), + top: length(20f32), + bottom: length(20f32), + }, + border: taffy::geometry::Rect { + left: length(20f32), + right: length(20f32), + top: length(20f32), + bottom: length(20f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); + assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); + assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); + assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node0, 30f32, location.x); + assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); +} + +#[test] +#[allow(non_snake_case)] +fn block_absolute_auto_margins_and_insets__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(60f32), + height: taffy::style::Dimension::from_length(60f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: zero(), + bottom: zero(), + }, + inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), top: auto(), bottom: auto() }, + border: taffy::geometry::Rect { + left: length(10f32), + right: length(10f32), + top: length(10f32), + bottom: length(10f32), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(120f32), + height: taffy::style::Dimension::from_length(120f32), + }, + padding: taffy::geometry::Rect { + left: length(20f32), + right: length(20f32), + top: length(20f32), + bottom: length(20f32), + }, + border: taffy::geometry::Rect { + left: length(20f32), + right: length(20f32), + top: length(20f32), + bottom: length(20f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); + assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); + assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); + assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); + assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); +} diff --git a/tests/generated/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.rs b/tests/generated/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.rs new file mode 100644 index 000000000..90f4482f8 --- /dev/null +++ b/tests/generated/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.rs @@ -0,0 +1,125 @@ +#[test] +#[allow(non_snake_case)] +fn block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(100f32), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(0f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(200f32), + height: taffy::style::Dimension::from_length(200f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); + assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); +} + +#[test] +#[allow(non_snake_case)] +fn block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(100f32), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(0f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(200f32), + height: taffy::style::Dimension::from_length(200f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); + assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); +} diff --git a/tests/generated/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.rs b/tests/generated/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.rs new file mode 100644 index 000000000..2aa83ef6c --- /dev/null +++ b/tests/generated/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.rs @@ -0,0 +1,125 @@ +#[test] +#[allow(non_snake_case)] +fn block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::AUTO, + height: taffy::style::Dimension::from_length(100f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(100f32), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: length(20f32), + top: length(0f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(200f32), + height: taffy::style::Dimension::from_length(200f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); + assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); + assert_eq!(location.x, 180f32, "x of node {:?}. Expected {}. Actual {}", node0, 180f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); +} + +#[test] +#[allow(non_snake_case)] +fn block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::AUTO, + height: taffy::style::Dimension::from_length(100f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(100f32), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: length(20f32), + top: length(0f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(200f32), + height: taffy::style::Dimension::from_length(200f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); + assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); + assert_eq!(location.x, 180f32, "x of node {:?}. Expected {}. Actual {}", node0, 180f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); +} diff --git a/tests/generated/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.rs b/tests/generated/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.rs new file mode 100644 index 000000000..65a7a3eb5 --- /dev/null +++ b/tests/generated/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.rs @@ -0,0 +1,125 @@ +#[test] +#[allow(non_snake_case)] +fn block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(100f32), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: length(20f32), + top: length(0f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(200f32), + height: taffy::style::Dimension::from_length(200f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); + assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); + assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); +} + +#[test] +#[allow(non_snake_case)] +fn block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(100f32), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: length(20f32), + top: length(0f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(200f32), + height: taffy::style::Dimension::from_length(200f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); + assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); + assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); +} diff --git a/tests/generated/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.rs b/tests/generated/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.rs new file mode 100644 index 000000000..f2ebe162a --- /dev/null +++ b/tests/generated/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.rs @@ -0,0 +1,125 @@ +#[test] +#[allow(non_snake_case)] +fn block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(100f32), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: length(50f32), + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(0f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(200f32), + height: taffy::style::Dimension::from_length(200f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); + assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); + assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); +} + +#[test] +#[allow(non_snake_case)] +fn block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(100f32), + height: taffy::style::Dimension::from_length(100f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(100f32), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: length(50f32), + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(0f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(200f32), + height: taffy::style::Dimension::from_length(200f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); + assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); + assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); +} diff --git a/tests/generated/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.rs b/tests/generated/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.rs new file mode 100644 index 000000000..8c976b961 --- /dev/null +++ b/tests/generated/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.rs @@ -0,0 +1,125 @@ +#[test] +#[allow(non_snake_case)] +fn block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::AUTO, + height: taffy::style::Dimension::from_length(100f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(100f32), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: length(20f32), + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(0f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(200f32), + height: taffy::style::Dimension::from_length(200f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); + assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); + assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); +} + +#[test] +#[allow(non_snake_case)] +fn block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::AUTO, + height: taffy::style::Dimension::from_length(100f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(100f32), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: length(20f32), + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(0f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(200f32), + height: taffy::style::Dimension::from_length(200f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); + assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); + assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); +} diff --git a/tests/generated/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.rs b/tests/generated/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.rs new file mode 100644 index 000000000..2e0781476 --- /dev/null +++ b/tests/generated/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.rs @@ -0,0 +1,125 @@ +#[test] +#[allow(non_snake_case)] +fn block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::AUTO, + height: taffy::style::Dimension::from_length(100f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(100f32), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: length(50f32), + right: length(20f32), + top: length(0f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(200f32), + height: taffy::style::Dimension::from_length(200f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); + assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node0, 130f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); + assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); +} + +#[test] +#[allow(non_snake_case)] +fn block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box() { + #[allow(unused_imports)] + use taffy::{prelude::*, Layout}; + let mut taffy = crate::new_test_tree(); + let node0 = taffy + .new_leaf_with_context( + taffy::style::Style { + box_sizing: taffy::style::BoxSizing::ContentBox, + position: taffy::style::Position::Absolute, + size: taffy::geometry::Size { + width: taffy::style::Dimension::AUTO, + height: taffy::style::Dimension::from_length(100f32), + }, + margin: taffy::geometry::Rect { + left: taffy::style::LengthPercentageAuto::AUTO, + right: taffy::style::LengthPercentageAuto::AUTO, + top: length(100f32), + bottom: zero(), + }, + inset: taffy::geometry::Rect { + left: length(50f32), + right: length(20f32), + top: length(0f32), + bottom: auto(), + }, + ..Default::default() + }, + crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), + ) + .unwrap(); + let node = taffy + .new_with_children( + taffy::style::Style { + display: taffy::style::Display::Block, + box_sizing: taffy::style::BoxSizing::ContentBox, + size: taffy::geometry::Size { + width: taffy::style::Dimension::from_length(200f32), + height: taffy::style::Dimension::from_length(200f32), + }, + ..Default::default() + }, + &[node0], + ) + .unwrap(); + taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); + println!("\nComputed tree:"); + taffy.print_tree(node); + println!(); + let layout = taffy.layout(node).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); + assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); + assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); + assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); + let layout = taffy.layout(node0).unwrap(); + let Layout { size, location, .. } = layout; + assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node0, 130f32, size.width); + assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); + assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); + assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); +} From 7d0aa68173f42fd1ae5f8f1e6856ef5b49dc5b85 Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Sat, 28 Feb 2026 19:19:12 -0500 Subject: [PATCH 04/17] Do not set margin to 0 --- src/compute/block.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/compute/block.rs b/src/compute/block.rs index f2da8c25b..3fddb569d 100644 --- a/src/compute/block.rs +++ b/src/compute/block.rs @@ -1240,8 +1240,8 @@ fn resolve_absolute_margin_and_positions( // If all three of 'left', 'width', and 'right' are 'auto': First set any 'auto' values for 'margin-left' and 'margin-right' to 0. if primary.is_none() && size.is_none() && secondary.is_none() { - computed_margin_primary = 0.0; - computed_margin_secondary = 0.0; + computed_margin_primary = margin_primary.unwrap_or(0.0); + computed_margin_secondary = margin_secondary.unwrap_or(0.0); // Then, if the 'direction' property of the element establishing the static-position containing block is 'ltr' set 'left' to the static position and apply rule number three below; otherwise, set 'right' to the static position and apply rule number one below. // Assume always ltr @@ -1254,7 +1254,7 @@ fn resolve_absolute_margin_and_positions( let width = final_size; // 'right' = width of containing block - ('left' + 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right') - computed_secondary = area_width - (computed_primary + margin_primary.unwrap() + width) + computed_secondary = area_width - (computed_primary + computed_margin_primary + computed_margin_secondary + width) } // If none of the three is 'auto' else if primary.is_some() && size.is_some() && secondary.is_some() { From 354d8b6c71f00278c34f53037773a06b1e8cd470 Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Fri, 10 Apr 2026 03:05:27 -0400 Subject: [PATCH 05/17] Update generated tests --- .../block/block_absolute_auto_margin.html | 12 +- ...lock_absolute_auto_margins_and_insets.html | 20 +-- ...al_left_and_right_auto_width_not_auto.html | 12 +- ...al_left_and_width_auto_right_not_auto.html | 12 +- ...al_left_auto_width_and_right_not_auto.html | 12 +- ...al_right_auto_left_and_width_not_auto.html | 12 +- ...al_width_and_right_auto_left_not_auto.html | 12 +- ...al_width_auto_left_and_right_not_auto.html | 12 +- ...k_absolute_auto_margin__border_box_ltr.xml | 15 ++ ...k_absolute_auto_margin__border_box_rtl.xml | 15 ++ ..._absolute_auto_margin__content_box_ltr.xml | 15 ++ ..._absolute_auto_margin__content_box_rtl.xml | 15 ++ ...uto_margins_and_insets__border_box_ltr.xml | 15 ++ ...uto_margins_and_insets__border_box_rtl.xml | 15 ++ ...to_margins_and_insets__content_box_ltr.xml | 15 ++ ...to_margins_and_insets__content_box_rtl.xml | 15 ++ ...ht_auto_width_not_auto__border_box_ltr.xml | 15 ++ ...ht_auto_width_not_auto__border_box_rtl.xml | 15 ++ ...t_auto_width_not_auto__content_box_ltr.xml | 15 ++ ...t_auto_width_not_auto__content_box_rtl.xml | 15 ++ ...th_auto_right_not_auto__border_box_ltr.xml | 15 ++ ...th_auto_right_not_auto__border_box_rtl.xml | 15 ++ ...h_auto_right_not_auto__content_box_ltr.xml | 15 ++ ...h_auto_right_not_auto__content_box_rtl.xml | 15 ++ ...dth_and_right_not_auto__border_box_ltr.xml | 15 ++ ...dth_and_right_not_auto__border_box_rtl.xml | 15 ++ ...th_and_right_not_auto__content_box_ltr.xml | 15 ++ ...th_and_right_not_auto__content_box_rtl.xml | 15 ++ ...eft_and_width_not_auto__border_box_ltr.xml | 15 ++ ...eft_and_width_not_auto__border_box_rtl.xml | 15 ++ ...ft_and_width_not_auto__content_box_ltr.xml | 15 ++ ...ft_and_width_not_auto__content_box_rtl.xml | 15 ++ ...ght_auto_left_not_auto__border_box_ltr.xml | 15 ++ ...ght_auto_left_not_auto__border_box_rtl.xml | 15 ++ ...ht_auto_left_not_auto__content_box_ltr.xml | 15 ++ ...ht_auto_left_not_auto__content_box_rtl.xml | 15 ++ ...eft_and_right_not_auto__border_box_ltr.xml | 15 ++ ...eft_and_right_not_auto__border_box_rtl.xml | 15 ++ ...ft_and_right_not_auto__content_box_ltr.xml | 15 ++ ...ft_and_right_not_auto__content_box_rtl.xml | 15 ++ tests/xml/mod.rs | 160 ++++++++++++++++++ 41 files changed, 649 insertions(+), 95 deletions(-) create mode 100644 tests/xml/block/block_absolute_auto_margin__border_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_auto_margin__border_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_auto_margin__content_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_auto_margin__content_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_auto_margins_and_insets__border_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_auto_margins_and_insets__border_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_auto_margins_and_insets__content_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_auto_margins_and_insets__content_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_rtl.xml diff --git a/test_fixtures/block/block_absolute_auto_margin.html b/test_fixtures/block/block_absolute_auto_margin.html index b987da665..dfabda6e1 100644 --- a/test_fixtures/block/block_absolute_auto_margin.html +++ b/test_fixtures/block/block_absolute_auto_margin.html @@ -10,17 +10,7 @@
-
+
diff --git a/test_fixtures/block/block_absolute_auto_margins_and_insets.html b/test_fixtures/block/block_absolute_auto_margins_and_insets.html index deb01d12d..9edc609ac 100644 --- a/test_fixtures/block/block_absolute_auto_margins_and_insets.html +++ b/test_fixtures/block/block_absolute_auto_margins_and_insets.html @@ -9,25 +9,9 @@ -
+
-
+
diff --git a/test_fixtures/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.html b/test_fixtures/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.html index 1e6b0a5e4..684eab37e 100644 --- a/test_fixtures/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.html +++ b/test_fixtures/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.html @@ -14,17 +14,7 @@
-
+
diff --git a/test_fixtures/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.html b/test_fixtures/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.html index eea337cf3..1c11327da 100644 --- a/test_fixtures/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.html +++ b/test_fixtures/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.html @@ -14,17 +14,7 @@
-
+
diff --git a/test_fixtures/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.html b/test_fixtures/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.html index f76a22236..ad864fd8d 100644 --- a/test_fixtures/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.html +++ b/test_fixtures/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.html @@ -14,17 +14,7 @@
-
+
diff --git a/test_fixtures/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.html b/test_fixtures/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.html index a49d1369d..d1eaec779 100644 --- a/test_fixtures/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.html +++ b/test_fixtures/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.html @@ -14,17 +14,7 @@
-
+
diff --git a/test_fixtures/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.html b/test_fixtures/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.html index 8319ee459..cf890f6f5 100644 --- a/test_fixtures/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.html +++ b/test_fixtures/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.html @@ -14,17 +14,7 @@
-
+
diff --git a/test_fixtures/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.html b/test_fixtures/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.html index 6b8818fb7..ee2e911aa 100644 --- a/test_fixtures/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.html +++ b/test_fixtures/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.html @@ -14,17 +14,7 @@
-
+
diff --git a/tests/xml/block/block_absolute_auto_margin__border_box_ltr.xml b/tests/xml/block/block_absolute_auto_margin__border_box_ltr.xml new file mode 100644 index 000000000..a0ea3ada0 --- /dev/null +++ b/tests/xml/block/block_absolute_auto_margin__border_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_auto_margin__border_box_rtl.xml b/tests/xml/block/block_absolute_auto_margin__border_box_rtl.xml new file mode 100644 index 000000000..14e01f051 --- /dev/null +++ b/tests/xml/block/block_absolute_auto_margin__border_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_auto_margin__content_box_ltr.xml b/tests/xml/block/block_absolute_auto_margin__content_box_ltr.xml new file mode 100644 index 000000000..57f63b090 --- /dev/null +++ b/tests/xml/block/block_absolute_auto_margin__content_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_auto_margin__content_box_rtl.xml b/tests/xml/block/block_absolute_auto_margin__content_box_rtl.xml new file mode 100644 index 000000000..d05275c30 --- /dev/null +++ b/tests/xml/block/block_absolute_auto_margin__content_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_auto_margins_and_insets__border_box_ltr.xml b/tests/xml/block/block_absolute_auto_margins_and_insets__border_box_ltr.xml new file mode 100644 index 000000000..acb0f5d8f --- /dev/null +++ b/tests/xml/block/block_absolute_auto_margins_and_insets__border_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_auto_margins_and_insets__border_box_rtl.xml b/tests/xml/block/block_absolute_auto_margins_and_insets__border_box_rtl.xml new file mode 100644 index 000000000..57d5668f2 --- /dev/null +++ b/tests/xml/block/block_absolute_auto_margins_and_insets__border_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_auto_margins_and_insets__content_box_ltr.xml b/tests/xml/block/block_absolute_auto_margins_and_insets__content_box_ltr.xml new file mode 100644 index 000000000..20ab8180a --- /dev/null +++ b/tests/xml/block/block_absolute_auto_margins_and_insets__content_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_auto_margins_and_insets__content_box_rtl.xml b/tests/xml/block/block_absolute_auto_margins_and_insets__content_box_rtl.xml new file mode 100644 index 000000000..80aa5fe2c --- /dev/null +++ b/tests/xml/block/block_absolute_auto_margins_and_insets__content_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_ltr.xml new file mode 100644 index 000000000..44d453ed7 --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_rtl.xml new file mode 100644 index 000000000..ea3e3e962 --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_ltr.xml new file mode 100644 index 000000000..ecdbcc384 --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_rtl.xml new file mode 100644 index 000000000..a27273b11 --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_ltr.xml new file mode 100644 index 000000000..e4748f3a7 --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_rtl.xml new file mode 100644 index 000000000..ca7d0d12e --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_ltr.xml new file mode 100644 index 000000000..aa30f324b --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_rtl.xml new file mode 100644 index 000000000..2aa723abe --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_ltr.xml new file mode 100644 index 000000000..e5d426f1d --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_rtl.xml new file mode 100644 index 000000000..45715d39b --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_ltr.xml new file mode 100644 index 000000000..f3f351031 --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_rtl.xml new file mode 100644 index 000000000..8e56fe1ef --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_ltr.xml new file mode 100644 index 000000000..7a3cc617f --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_rtl.xml new file mode 100644 index 000000000..88c472dee --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_ltr.xml new file mode 100644 index 000000000..46264ec98 --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_rtl.xml new file mode 100644 index 000000000..e51a065fd --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_ltr.xml new file mode 100644 index 000000000..821a8482a --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_rtl.xml new file mode 100644 index 000000000..7dfe2ce89 --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_ltr.xml new file mode 100644 index 000000000..e1cd6cc63 --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_rtl.xml new file mode 100644 index 000000000..026440203 --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_ltr.xml new file mode 100644 index 000000000..254cd8751 --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_rtl.xml new file mode 100644 index 000000000..4c41278af --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_ltr.xml new file mode 100644 index 000000000..01e21ce86 --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_rtl.xml new file mode 100644 index 000000000..2a094587c --- /dev/null +++ b/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/mod.rs b/tests/xml/mod.rs index 7218ac1f7..54cf0ff3b 100644 --- a/tests/xml/mod.rs +++ b/tests/xml/mod.rs @@ -253,6 +253,46 @@ mod block { crate::run_xml_test("block", "block_absolute_aspect_ratio_width_overrides_inset__content_box_rtl"); } + #[test] + fn block_absolute_auto_margin__border_box_ltr() { + crate::run_xml_test("block", "block_absolute_auto_margin__border_box_ltr"); + } + + #[test] + fn block_absolute_auto_margin__content_box_ltr() { + crate::run_xml_test("block", "block_absolute_auto_margin__content_box_ltr"); + } + + #[test] + fn block_absolute_auto_margin__border_box_rtl() { + crate::run_xml_test("block", "block_absolute_auto_margin__border_box_rtl"); + } + + #[test] + fn block_absolute_auto_margin__content_box_rtl() { + crate::run_xml_test("block", "block_absolute_auto_margin__content_box_rtl"); + } + + #[test] + fn block_absolute_auto_margins_and_insets__border_box_ltr() { + crate::run_xml_test("block", "block_absolute_auto_margins_and_insets__border_box_ltr"); + } + + #[test] + fn block_absolute_auto_margins_and_insets__content_box_ltr() { + crate::run_xml_test("block", "block_absolute_auto_margins_and_insets__content_box_ltr"); + } + + #[test] + fn block_absolute_auto_margins_and_insets__border_box_rtl() { + crate::run_xml_test("block", "block_absolute_auto_margins_and_insets__border_box_rtl"); + } + + #[test] + fn block_absolute_auto_margins_and_insets__content_box_rtl() { + crate::run_xml_test("block", "block_absolute_auto_margins_and_insets__content_box_rtl"); + } + #[test] fn block_absolute_child_with_margin_x__border_box_ltr() { crate::run_xml_test("block", "block_absolute_child_with_margin_x__border_box_ltr"); @@ -313,6 +353,126 @@ mod block { crate::run_xml_test("block", "block_absolute_child_with_max_height__content_box_rtl"); } + #[test] + fn block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_ltr() { + crate::run_xml_test("block", "block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_ltr"); + } + + #[test] + fn block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_ltr() { + crate::run_xml_test("block", "block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_ltr"); + } + + #[test] + fn block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_rtl() { + crate::run_xml_test("block", "block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_rtl"); + } + + #[test] + fn block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_rtl() { + crate::run_xml_test("block", "block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_rtl"); + } + + #[test] + fn block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_ltr() { + crate::run_xml_test("block", "block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_ltr"); + } + + #[test] + fn block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_ltr() { + crate::run_xml_test("block", "block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_ltr"); + } + + #[test] + fn block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_rtl() { + crate::run_xml_test("block", "block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_rtl"); + } + + #[test] + fn block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_rtl() { + crate::run_xml_test("block", "block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_rtl"); + } + + #[test] + fn block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_ltr() { + crate::run_xml_test("block", "block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_ltr"); + } + + #[test] + fn block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_ltr() { + crate::run_xml_test("block", "block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_ltr"); + } + + #[test] + fn block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_rtl() { + crate::run_xml_test("block", "block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_rtl"); + } + + #[test] + fn block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_rtl() { + crate::run_xml_test("block", "block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_rtl"); + } + + #[test] + fn block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_ltr() { + crate::run_xml_test("block", "block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_ltr"); + } + + #[test] + fn block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_ltr() { + crate::run_xml_test("block", "block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_ltr"); + } + + #[test] + fn block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_rtl() { + crate::run_xml_test("block", "block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_rtl"); + } + + #[test] + fn block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_rtl() { + crate::run_xml_test("block", "block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_rtl"); + } + + #[test] + fn block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_ltr() { + crate::run_xml_test("block", "block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_ltr"); + } + + #[test] + fn block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_ltr() { + crate::run_xml_test("block", "block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_ltr"); + } + + #[test] + fn block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_rtl() { + crate::run_xml_test("block", "block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_rtl"); + } + + #[test] + fn block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_rtl() { + crate::run_xml_test("block", "block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_rtl"); + } + + #[test] + fn block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_ltr() { + crate::run_xml_test("block", "block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_ltr"); + } + + #[test] + fn block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_ltr() { + crate::run_xml_test("block", "block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_ltr"); + } + + #[test] + fn block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_rtl() { + crate::run_xml_test("block", "block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_rtl"); + } + + #[test] + fn block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_rtl() { + crate::run_xml_test("block", "block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_rtl"); + } + #[test] fn block_absolute_layout_child_order__border_box_ltr() { crate::run_xml_test("block", "block_absolute_layout_child_order__border_box_ltr"); From 2c293f0edc6c5028b83669658d7ddc8b7056c1d0 Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Fri, 10 Apr 2026 03:10:26 -0400 Subject: [PATCH 06/17] Do not start margins to 0 --- src/compute/block.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/compute/block.rs b/src/compute/block.rs index d01e385da..425c9199b 100644 --- a/src/compute/block.rs +++ b/src/compute/block.rs @@ -1602,8 +1602,6 @@ fn resolve_absolute_margin_and_positions_v( // then the height is based on the content per 10.6.7, set 'auto' values for // 'margin-top' and 'margin-bottom' to 0, and solve for 'bottom' // TODO: HANDLE 10.6.7 - computed_margin_top = 0.0; - computed_margin_bottom = 0.0; computed_height = content_height; computed_bottom = height_of_containing_block - (computed_top From 8156872af6dd37e985d54e42e7653eb0723cd590 Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Fri, 10 Apr 2026 03:14:01 -0400 Subject: [PATCH 07/17] Avoid clamp --- src/compute/block.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compute/block.rs b/src/compute/block.rs index 425c9199b..cbbffa2d4 100644 --- a/src/compute/block.rs +++ b/src/compute/block.rs @@ -1185,7 +1185,7 @@ fn perform_absolute_layout_on_absolute_children( max_size.width, ); - final_size.width = computed_width.maybe_clamp(min_size.width, max_size.width); + final_size.width = computed_width; let layout_output = tree.perform_child_layout( item.node_id, From c98228bbede0a028e15ab6aedde3f9cc5d1daaa2 Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Fri, 10 Apr 2026 20:00:06 -0400 Subject: [PATCH 08/17] Use correct containing block sizes. --- src/compute/block.rs | 51 ++++++++++++------- ...solute_nested_shrink_to_fit_max_width.html | 15 ++++++ ...hrink_to_fit_max_width__border_box_ltr.xml | 15 ++++++ ...hrink_to_fit_max_width__border_box_rtl.xml | 15 ++++++ ...rink_to_fit_max_width__content_box_ltr.xml | 15 ++++++ ...rink_to_fit_max_width__content_box_rtl.xml | 15 ++++++ tests/xml/mod.rs | 20 ++++++++ 7 files changed, 129 insertions(+), 17 deletions(-) create mode 100644 test_fixtures/block/block_absolute_nested_shrink_to_fit_max_width.html create mode 100644 tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_rtl.xml create mode 100644 tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_ltr.xml create mode 100644 tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_rtl.xml diff --git a/src/compute/block.rs b/src/compute/block.rs index cbbffa2d4..ecf3ae687 100644 --- a/src/compute/block.rs +++ b/src/compute/block.rs @@ -1099,6 +1099,7 @@ fn perform_absolute_layout_on_absolute_children( let margin = child_style.margin().map(|margin| margin.resolve_to_option(area_width, |val, basis| tree.calc(val, basis))); let padding = child_style.padding().resolve_or_zero(Some(area_width), |val, basis| tree.calc(val, basis)); + let border = child_style.border().resolve_or_zero(Some(area_width), |val, basis| tree.calc(val, basis)); let padding_border_sum = (padding + border).sum_axes(); let box_sizing_adjustment = @@ -1165,14 +1166,14 @@ fn perform_absolute_layout_on_absolute_children( let mut final_size = known_dimensions.unwrap_or(measured_size).maybe_clamp(min_size, max_size); - let content_width = measured_size.width - border.left - padding.left - padding.right - border.right; + let containing_block_width = area_width + border.left + padding.left + padding.right + border.right; let (computed_left, _computed_right, computed_margin_left, computed_margin_right, computed_width) = resolve_absolute_margin_and_positions( style_size.width, - area_width, + containing_block_width, left, right, - content_width, + measured_size.width, margin.left, margin.right, border.left, @@ -1199,14 +1200,14 @@ fn perform_absolute_layout_on_absolute_children( Line::FALSE, ); - let content_height = measured_size.height - border.top - padding.top - padding.bottom - border.bottom; + let containing_block_height = area_height + border.top + padding.top + padding.bottom + border.bottom; let (computed_top, _computed_bottom, computed_margin_top, computed_margin_bottom, computed_height) = resolve_absolute_margin_and_positions_v( known_dimensions.height, // We use known dimensions here to factor in aspect ratio, is that correct? - area_height, + containing_block_height, top, bottom, - content_height, + measured_size.height, margin.top, margin.bottom, border.top, @@ -1334,7 +1335,15 @@ fn resolve_absolute_margin_and_positions( + computed_margin_right) } Direction::Rtl => { - computed_right = width_of_containing_block - static_position; + computed_right = width_of_containing_block + - (static_position + + computed_margin_left + + border_left + + padding_left + + computed_width + + padding_right + + border_right + + computed_margin_right); // 1. 'left' and 'width' are 'auto' and 'right' is not 'auto', then the width is shrink-to-fit. Then solve for 'left' computed_width = content_width; @@ -1358,7 +1367,15 @@ fn resolve_absolute_margin_and_positions( // 'left' + '2M' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'right' = width of containing block // M = (width of containing block - ('left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'right')) / 2 - let margin = (width_of_containing_block - (left.unwrap() + computed_width + right.unwrap())) / 2.0; + let margin = (width_of_containing_block + - (computed_left + + border_left + + padding_left + + computed_width + + padding_right + + border_right + + computed_right)) + / 2.0; if margin >= 0.0 { computed_margin_right = margin; @@ -1620,13 +1637,13 @@ fn resolve_absolute_margin_and_positions_v( // solve the equation under the extra constraint that the two margins get equal values. let margin = (height_of_containing_block - - (top.unwrap() + - (computed_top + border_top + padding_top + computed_height + padding_bottom + border_bottom - + bottom.unwrap())) + + computed_bottom)) / 2.0; computed_margin_bottom = margin; @@ -1634,25 +1651,25 @@ fn resolve_absolute_margin_and_positions_v( } else if margin_top.is_some() { // If one of 'margin-top' or 'margin-bottom' is 'auto', solve the equation for that value computed_margin_bottom = height_of_containing_block - - (top.unwrap() - + margin_top.unwrap() + - (computed_top + + computed_margin_top + border_top + padding_top + computed_height + padding_bottom + border_bottom - + bottom.unwrap()); + + computed_bottom); } else if margin_bottom.is_some() { // If one of 'margin-top' or 'margin-bottom' is 'auto', solve the equation for that value computed_margin_top = height_of_containing_block - - (top.unwrap() + - (computed_top + border_top + padding_top + computed_height + padding_bottom + border_bottom - + margin_bottom.unwrap() - + bottom.unwrap()); + + computed_margin_bottom + + computed_bottom); } else { // If the values are over-constrained, ignore the value for 'bottom' and solve for that value. computed_bottom = height_of_containing_block @@ -1750,7 +1767,7 @@ fn resolve_absolute_margin_and_positions_v( //computed_margin_top = 0.0; //computed_margin_bottom = 0.0; computed_bottom = height_of_containing_block - - (top.unwrap() + - (computed_top + computed_margin_top + border_top + padding_top diff --git a/test_fixtures/block/block_absolute_nested_shrink_to_fit_max_width.html b/test_fixtures/block/block_absolute_nested_shrink_to_fit_max_width.html new file mode 100644 index 000000000..e8e3dcab3 --- /dev/null +++ b/test_fixtures/block/block_absolute_nested_shrink_to_fit_max_width.html @@ -0,0 +1,15 @@ + + + + + + Absolute Position Test: Nested Shrink-to-Fit with Max-Width + + +
+
+ +
+
+ + \ No newline at end of file diff --git a/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_ltr.xml b/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_ltr.xml new file mode 100644 index 000000000..a5addb6a0 --- /dev/null +++ b/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_rtl.xml b/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_rtl.xml new file mode 100644 index 000000000..5cc56a4ec --- /dev/null +++ b/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_ltr.xml b/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_ltr.xml new file mode 100644 index 000000000..bfc5b1b62 --- /dev/null +++ b/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_ltr.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_rtl.xml b/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_rtl.xml new file mode 100644 index 000000000..d045b1b5f --- /dev/null +++ b/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_rtl.xml @@ -0,0 +1,15 @@ + + + +
+ + + +
+ + + + + + +
diff --git a/tests/xml/mod.rs b/tests/xml/mod.rs index 54cf0ff3b..98454249f 100644 --- a/tests/xml/mod.rs +++ b/tests/xml/mod.rs @@ -1285,6 +1285,26 @@ mod block { crate::run_xml_test("block", "block_absolute_minmax_top_left_bottom_right_min_max__content_box_rtl"); } + #[test] + fn block_absolute_nested_shrink_to_fit_max_width__border_box_ltr() { + crate::run_xml_test("block", "block_absolute_nested_shrink_to_fit_max_width__border_box_ltr"); + } + + #[test] + fn block_absolute_nested_shrink_to_fit_max_width__content_box_ltr() { + crate::run_xml_test("block", "block_absolute_nested_shrink_to_fit_max_width__content_box_ltr"); + } + + #[test] + fn block_absolute_nested_shrink_to_fit_max_width__border_box_rtl() { + crate::run_xml_test("block", "block_absolute_nested_shrink_to_fit_max_width__border_box_rtl"); + } + + #[test] + fn block_absolute_nested_shrink_to_fit_max_width__content_box_rtl() { + crate::run_xml_test("block", "block_absolute_nested_shrink_to_fit_max_width__content_box_rtl"); + } + #[test] fn block_absolute_no_styles__border_box_ltr() { crate::run_xml_test("block", "block_absolute_no_styles__border_box_ltr"); From 68f28ce9fa049f15de9e9aeaeeaa3779d4179bd1 Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Sat, 11 Apr 2026 10:52:57 -0400 Subject: [PATCH 09/17] Remove out of scope test --- ...solute_nested_shrink_to_fit_max_width.html | 15 -------------- ...hrink_to_fit_max_width__border_box_ltr.xml | 15 -------------- ...hrink_to_fit_max_width__border_box_rtl.xml | 15 -------------- ...rink_to_fit_max_width__content_box_ltr.xml | 15 -------------- ...rink_to_fit_max_width__content_box_rtl.xml | 15 -------------- tests/xml/mod.rs | 20 ------------------- 6 files changed, 95 deletions(-) delete mode 100644 test_fixtures/block/block_absolute_nested_shrink_to_fit_max_width.html delete mode 100644 tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_ltr.xml delete mode 100644 tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_rtl.xml delete mode 100644 tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_ltr.xml delete mode 100644 tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_rtl.xml diff --git a/test_fixtures/block/block_absolute_nested_shrink_to_fit_max_width.html b/test_fixtures/block/block_absolute_nested_shrink_to_fit_max_width.html deleted file mode 100644 index e8e3dcab3..000000000 --- a/test_fixtures/block/block_absolute_nested_shrink_to_fit_max_width.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - Absolute Position Test: Nested Shrink-to-Fit with Max-Width - - -
-
- -
-
- - \ No newline at end of file diff --git a/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_ltr.xml b/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_ltr.xml deleted file mode 100644 index a5addb6a0..000000000 --- a/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_ltr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_rtl.xml b/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_rtl.xml deleted file mode 100644 index 5cc56a4ec..000000000 --- a/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__border_box_rtl.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_ltr.xml b/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_ltr.xml deleted file mode 100644 index bfc5b1b62..000000000 --- a/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_ltr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_rtl.xml b/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_rtl.xml deleted file mode 100644 index d045b1b5f..000000000 --- a/tests/xml/block/block_absolute_nested_shrink_to_fit_max_width__content_box_rtl.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/mod.rs b/tests/xml/mod.rs index 98454249f..54cf0ff3b 100644 --- a/tests/xml/mod.rs +++ b/tests/xml/mod.rs @@ -1285,26 +1285,6 @@ mod block { crate::run_xml_test("block", "block_absolute_minmax_top_left_bottom_right_min_max__content_box_rtl"); } - #[test] - fn block_absolute_nested_shrink_to_fit_max_width__border_box_ltr() { - crate::run_xml_test("block", "block_absolute_nested_shrink_to_fit_max_width__border_box_ltr"); - } - - #[test] - fn block_absolute_nested_shrink_to_fit_max_width__content_box_ltr() { - crate::run_xml_test("block", "block_absolute_nested_shrink_to_fit_max_width__content_box_ltr"); - } - - #[test] - fn block_absolute_nested_shrink_to_fit_max_width__border_box_rtl() { - crate::run_xml_test("block", "block_absolute_nested_shrink_to_fit_max_width__border_box_rtl"); - } - - #[test] - fn block_absolute_nested_shrink_to_fit_max_width__content_box_rtl() { - crate::run_xml_test("block", "block_absolute_nested_shrink_to_fit_max_width__content_box_rtl"); - } - #[test] fn block_absolute_no_styles__border_box_ltr() { crate::run_xml_test("block", "block_absolute_no_styles__border_box_ltr"); From c03735bc32a75130fcfb644b3b613dfdfbc4be2b Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Sat, 11 Apr 2026 18:44:13 -0400 Subject: [PATCH 10/17] Refactor --- src/compute/block.rs | 736 +++++++++++++++---------------------------- src/geometry.rs | 6 + 2 files changed, 265 insertions(+), 477 deletions(-) diff --git a/src/compute/block.rs b/src/compute/block.rs index ecf3ae687..3e6b515c6 100644 --- a/src/compute/block.rs +++ b/src/compute/block.rs @@ -61,7 +61,7 @@ impl BlockFormattingContext { pub struct BlockContext<'bfc> { /// A mutable reference to the root BlockFormatttingContext that this BlockContext belongs to bfc: &'bfc mut BlockFormattingContext, - /// The y-offset of the border-top of the block node, relative to the to the border-top of the + /// The y-offset of the border-top of the block node, relative to the border-top of the /// root node of the Block Formatting Context it belongs to. y_offset: f32, /// The x-inset of the border-box in from each side of the block node, relative to the root node of the Block Formatting Context it belongs to. @@ -70,10 +70,16 @@ pub struct BlockContext<'bfc> { content_box_insets: [f32; 2], /// The height that floats take up in the element float_content_contribution: f32, - /// Whether the node is the root of the Block Formatting Context is belongs to. + /// Whether the node is the root of the Block Formatting Context it belongs to. is_root: bool, } +struct ResolvedBoxProperties { + size: f32, + inset: Line, + margin: Line, +} + impl BlockContext<'_> { /// Create a sub-`BlockContext` for a child block node pub fn sub_context(&mut self, additional_y_offset: f32, insets: [f32; 2]) -> BlockContext<'_> { @@ -88,7 +94,7 @@ impl BlockContext<'_> { } } - /// Returns whether this block is the root block of it's Block Formatting Context + /// Returns whether this block is the root block of its Block Formatting Context pub fn is_bfc_root(&self) -> bool { self.is_root } @@ -1101,15 +1107,13 @@ fn perform_absolute_layout_on_absolute_children( let padding = child_style.padding().resolve_or_zero(Some(area_width), |val, basis| tree.calc(val, basis)); let border = child_style.border().resolve_or_zero(Some(area_width), |val, basis| tree.calc(val, basis)); - let padding_border_sum = (padding + border).sum_axes(); + let padding_border = (padding + border).sum_axes(); let box_sizing_adjustment = - if child_style.box_sizing() == BoxSizing::ContentBox { padding_border_sum } else { Size::ZERO }; + if child_style.box_sizing() == BoxSizing::ContentBox { padding_border } else { Size::ZERO }; - // Resolve inset - let left = child_style.inset().left.maybe_resolve(area_width, |val, basis| tree.calc(val, basis)); - let right = child_style.inset().right.maybe_resolve(area_width, |val, basis| tree.calc(val, basis)); - let top = child_style.inset().top.maybe_resolve(area_height, |val, basis| tree.calc(val, basis)); - let bottom = child_style.inset().bottom.maybe_resolve(area_height, |val, basis| tree.calc(val, basis)); + let resolved_inset = child_style + .inset() + .zip_size(area_size, |inset, size| inset.maybe_resolve(size, |val, basis| tree.calc(val, basis))); // Compute known dimensions from min/max/inherent size styles let style_size = child_style @@ -1122,8 +1126,8 @@ fn perform_absolute_layout_on_absolute_children( .maybe_resolve(area_size, |val, basis| tree.calc(val, basis)) .maybe_apply_aspect_ratio(aspect_ratio) .maybe_add(box_sizing_adjustment) - .or(padding_border_sum.map(Some)) - .maybe_max(padding_border_sum); + .or(padding_border.map(Some)) + .maybe_max(padding_border); let max_size = child_style .max_size() .maybe_resolve(area_size, |val, basis| tree.calc(val, basis)) @@ -1137,7 +1141,7 @@ fn perform_absolute_layout_on_absolute_children( // Fill in width from left/right and reapply aspect ratio if: // - Width is not already known // - Item has both left and right inset properties set - if let (None, Some(left), Some(right)) = (known_dimensions.width, left, right) { + if let (None, Some(left), Some(right)) = (known_dimensions.width, resolved_inset.left, resolved_inset.right) { let new_width_raw = area_width.maybe_sub(margin.left).maybe_sub(margin.right) - left - right; known_dimensions.width = Some(f32_max(new_width_raw, 0.0)); known_dimensions = known_dimensions.maybe_apply_aspect_ratio(aspect_ratio).maybe_clamp(min_size, max_size); @@ -1146,7 +1150,7 @@ fn perform_absolute_layout_on_absolute_children( // Fill in height from top/bottom and reapply aspect ratio if: // - Height is not already known // - Item has both top and bottom inset properties set - if let (None, Some(top), Some(bottom)) = (known_dimensions.height, top, bottom) { + if let (None, Some(top), Some(bottom)) = (known_dimensions.height, resolved_inset.top, resolved_inset.bottom) { let new_height_raw = area_height.maybe_sub(margin.top).maybe_sub(margin.bottom) - top - bottom; known_dimensions.height = Some(f32_max(new_height_raw, 0.0)); known_dimensions = known_dimensions.maybe_apply_aspect_ratio(aspect_ratio).maybe_clamp(min_size, max_size); @@ -1167,26 +1171,20 @@ fn perform_absolute_layout_on_absolute_children( let mut final_size = known_dimensions.unwrap_or(measured_size).maybe_clamp(min_size, max_size); let containing_block_width = area_width + border.left + padding.left + padding.right + border.right; - let (computed_left, _computed_right, computed_margin_left, computed_margin_right, computed_width) = - resolve_absolute_margin_and_positions( - style_size.width, - containing_block_width, - left, - right, - measured_size.width, - margin.left, - margin.right, - border.left, - border.right, - padding.left, - padding.right, - item.static_position.x, - direction, - min_size.width.unwrap_or(0.0), - max_size.width, - ); + let resolved_box_properties_horizontal = resolve_absolutely_positioned_non_replaced_box_properties_horizontal( + style_size.width, + containing_block_width, + resolved_inset.horizontal_components(), + measured_size.width, + margin.horizontal_components(), + padding_border.width, + item.static_position.x, + direction, + min_size.width.unwrap_or_default(), + max_size.width, + ); - final_size.width = computed_width; + final_size.width = resolved_box_properties_horizontal.size; let layout_output = tree.perform_child_layout( item.node_id, @@ -1201,44 +1199,34 @@ fn perform_absolute_layout_on_absolute_children( ); let containing_block_height = area_height + border.top + padding.top + padding.bottom + border.bottom; - let (computed_top, _computed_bottom, computed_margin_top, computed_margin_bottom, computed_height) = - resolve_absolute_margin_and_positions_v( - known_dimensions.height, // We use known dimensions here to factor in aspect ratio, is that correct? - containing_block_height, - top, - bottom, - measured_size.height, - margin.top, - margin.bottom, - border.top, - border.bottom, - padding.top, - padding.bottom, - item.static_position.y, - min_size.height.unwrap_or(0.0), - max_size.height, - ); - final_size.height = computed_height; + let resolved_box_properties_vertical = resolve_absolutely_positioned_non_replaced_box_properties_vertical( + known_dimensions.height, // We use known dimensions here to factor in aspect ratio, is that correct? + containing_block_height, + resolved_inset.vertical_components(), + measured_size.height, + margin.vertical_components(), + padding_border.height, + item.static_position.y, + min_size.height.unwrap_or(0.0), + max_size.height, + ); + final_size.height = resolved_box_properties_vertical.size; - let resolved_margin = Rect { - left: computed_margin_left, - right: computed_margin_right, - top: computed_margin_top, - bottom: computed_margin_bottom, - }; - let is_static_x = left.is_none() && right.is_none(); - let is_static_y = top.is_none() && bottom.is_none(); + let resolved_margin = + Rect::from_lines(resolved_box_properties_horizontal.margin, resolved_box_properties_vertical.margin); + let is_static_x = resolved_inset.left.is_none() && resolved_inset.right.is_none(); + let is_static_y = resolved_inset.top.is_none() && resolved_inset.bottom.is_none(); let location = Point { x: if is_static_x { - computed_left + resolved_margin.left + resolved_box_properties_horizontal.inset.start + resolved_margin.left } else { - computed_left + resolved_margin.left + area_offset.x + resolved_box_properties_horizontal.inset.start + resolved_margin.left + area_offset.x }, y: if is_static_y { - computed_top + resolved_margin.top + resolved_box_properties_vertical.inset.start + resolved_margin.top } else { - computed_top + resolved_margin.top + area_offset.y + resolved_box_properties_vertical.inset.start + resolved_margin.top + area_offset.y }, }; @@ -1278,260 +1266,161 @@ fn perform_absolute_layout_on_absolute_children( absolute_content_size } -/// Compute margin and positons for absolutely positioned children. +/// Compute the left, margin-left, width, margin-right, and right for non-replaced absolutely positioned boxes. #[inline] -fn resolve_absolute_margin_and_positions( +fn resolve_absolutely_positioned_non_replaced_box_properties_horizontal( width: Option, width_of_containing_block: f32, - left: Option, - right: Option, + inset: Line>, content_width: f32, - margin_left: Option, - margin_right: Option, - border_left: f32, - border_right: f32, - padding_left: f32, - padding_right: f32, + margin: Line>, + padding_border: f32, static_position: f32, direction: Direction, min_width: f32, max_width: Option, -) -> (f32, f32, f32, f32, f32) { +) -> ResolvedBoxProperties { // https://www.w3.org/TR/CSS2/visudet.html#abs-non-replaced-width - + let mut computed_margin = margin.map(Option::unwrap_or_default); + let mut computed_inset = inset.map(Option::unwrap_or_default); let mut computed_width = width.unwrap_or(0.0); - let mut computed_margin_left = margin_left.unwrap_or(0.0); - let mut computed_margin_right = margin_right.unwrap_or(0.0); + // The constraint that determines the used values for these elements is: + // 'left' + 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + + // 'border-right-width' + 'margin-right' + 'right' = width of containing block - let mut computed_left: f32 = left.unwrap_or(0.0); - let mut computed_right: f32 = right.unwrap_or(0.0); + match (inset.start, width, inset.end) { + (None, None, None) => { + // If all three of 'left', 'width', and 'right' are 'auto': First set any 'auto' values for 'margin-left' and 'margin-right' to 0. - // If all three of 'left', 'width', and 'right' are 'auto': First set any 'auto' values for 'margin-left' and 'margin-right' to 0. - if left.is_none() && width.is_none() && right.is_none() { - computed_margin_left = margin_left.unwrap_or(0.0); - computed_margin_right = margin_right.unwrap_or(0.0); + // Then, if the 'direction' property of the element establishing the static-position containing block is 'ltr' + // set 'left' to the static position and apply rule number three below; + // otherwise, set 'right' to the static position and apply rule number one below. + match direction { + Direction::Ltr => { + computed_inset.start = static_position; + // apply rule number three - // Then, if the 'direction' property of the element establishing the static-position containing block is 'ltr' set 'left' to the static position and apply rule number three below; otherwise, set 'right' to the static position and apply rule number one below. + // 3. + // 'width' and 'right' are 'auto' and 'left' is not 'auto', then the width is shrink-to-fit . Then solve for 'right' + computed_width = content_width; - match direction { - Direction::Ltr => { - computed_left = static_position; - // apply rule number three - - // 3. - // 'width' and 'right' are 'auto' and 'left' is not 'auto', then the width is shrink-to-fit . Then solve for 'right' - computed_width = content_width; - - // 'right' = width of containing block - ('left' + 'margin-left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'margin-right') - computed_right = width_of_containing_block - - (computed_left - + computed_margin_left - + border_left - + padding_left - + computed_width - + padding_right - + border_right - + computed_margin_right) - } - Direction::Rtl => { - computed_right = width_of_containing_block - - (static_position - + computed_margin_left - + border_left - + padding_left - + computed_width - + padding_right - + border_right - + computed_margin_right); - - // 1. 'left' and 'width' are 'auto' and 'right' is not 'auto', then the width is shrink-to-fit. Then solve for 'left' - computed_width = content_width; - computed_left = width_of_containing_block - - (computed_margin_left - + border_left - + padding_left - + computed_width - + padding_right - + border_right - + computed_margin_right - + computed_right); + computed_inset.end = width_of_containing_block + - (computed_inset.start + computed_width + computed_margin.sum() + padding_border) + } + Direction::Rtl => { + computed_inset.end = width_of_containing_block + - (static_position + computed_width + padding_border + computed_margin.sum()); + + // 1. 'left' and 'width' are 'auto' and 'right' is not 'auto', then the width is shrink-to-fit. Then solve for 'left' + computed_width = content_width; + computed_inset.start = width_of_containing_block + - (computed_width + computed_inset.end + padding_border + computed_margin.sum()); + } } } - } - // If none of the three is 'auto' - else if left.is_some() && width.is_some() && right.is_some() { - // If both 'margin-left' and 'margin-right' are 'auto' - if margin_left.is_none() && margin_right.is_none() { - // solve the equation under the extra constraint that the two margins get equal values - - // 'left' + '2M' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'right' = width of containing block - // M = (width of containing block - ('left' + 'border-left-width' + 'padding-left' + 'width' + 'padding-right' + 'border-right-width' + 'right')) / 2 - let margin = (width_of_containing_block - - (computed_left - + border_left - + padding_left - + computed_width - + padding_right - + border_right - + computed_right)) - / 2.0; - - if margin >= 0.0 { - computed_margin_right = margin; - computed_margin_left = margin; - } else { - // unless this would make them negative, in which case when direction of the - // containing block is 'ltr' ('rtl'), set 'margin-left' ('margin-right') to - // zero and solve for 'margin-right' ('margin-left'). - match direction { - Direction::Ltr => { - computed_margin_left = 0.0; - computed_margin_right = width_of_containing_block - - (left.unwrap() - + border_left - + padding_left - + computed_width - + padding_right - + border_right - + right.unwrap()); - } - Direction::Rtl => { - computed_margin_right = 0.0; - computed_margin_left = width_of_containing_block - - (left.unwrap() - + border_left - + padding_left - + computed_width - + padding_right - + border_right - + right.unwrap()); + (Some(left), Some(width), Some(right)) => { + // If none of the three is 'auto' + match (margin.start, margin.end) { + (None, None) => { + // If both 'margin-left' and 'margin-right' are 'auto' + // solve the equation under the extra constraint that the two margins get equal values + + let margin = (width_of_containing_block - (left + width + right + padding_border)) / 2.0; + + if margin >= 0.0 { + computed_margin.start = margin; + computed_margin.end = margin; + } else { + // unless this would make them negative, in which case when direction of the + // containing block is 'ltr' ('rtl'), set 'margin-left' ('margin-right') to + // zero and solve for 'margin-right' ('margin-left'). + match direction { + Direction::Ltr => { + computed_margin.start = 0.0; + computed_margin.end = + width_of_containing_block - (left + computed_width + right + padding_border); + } + Direction::Rtl => { + computed_margin.end = 0.0; + computed_margin.start = + width_of_containing_block - (left + computed_width + right + padding_border); + } + } } } - } - } else if margin_right.is_none() { - // If one of 'margin-left' or 'margin-right' is 'auto', solve the equation for that - computed_margin_right = width_of_containing_block - - (left.unwrap() - + margin_left.unwrap() - + border_left - + padding_left - + computed_width - + padding_right - + border_right - + right.unwrap()); - } else if margin_left.is_none() { - // If one of 'margin-left' or 'margin-right' is 'auto', solve the equation for that - computed_margin_left = width_of_containing_block - - (left.unwrap() - + border_left - + padding_left - + computed_width - + padding_right - + border_right - + margin_right.unwrap() - + right.unwrap()); - } else { - // If the values are over-constrained, ignore the value for 'left' - // (in case the 'direction' property of the containing block is 'rtl') or 'right' - // (in case 'direction' is 'ltr') and solve for that value. - match direction { - Direction::Ltr => { - computed_right = width_of_containing_block - - (left.unwrap() + margin_left.unwrap() + computed_width + margin_right.unwrap()); + (Some(margin_left), None) => { + // If one of 'margin-left' or 'margin-right' is 'auto', solve the equation for that + computed_margin.end = + width_of_containing_block - (left + margin_left + computed_width + right + padding_border); } - Direction::Rtl => { - computed_left = width_of_containing_block - - (right.unwrap() + margin_left.unwrap() + computed_width + margin_right.unwrap()); + (None, Some(margin_right)) => { + // If one of 'margin-left' or 'margin-right' is 'auto', solve the equation for that + computed_margin.start = + width_of_containing_block - (left + computed_width + margin_right + right + padding_border); + } + (Some(margin_left), Some(margin_right)) => { + // If the values are over-constrained, ignore the value for 'left' + // (in case the 'direction' property of the containing block is 'rtl') or 'right' + // (in case 'direction' is 'ltr') and solve for that value. + match direction { + Direction::Ltr => { + computed_inset.end = width_of_containing_block + - (left + margin_left + computed_width + padding_border + margin_right); + } + Direction::Rtl => { + computed_inset.start = width_of_containing_block + - (right + margin_left + computed_width + padding_border + margin_right); + } + } } } } - } else { + // The following note applies to all remaining match arms. // Otherwise, set 'auto' values for 'margin-left' and 'margin-right' to 0, and pick the one of the following six rules that applies. // These are already our initial values chosen above, so no need to do anything. - - if left.is_none() && width.is_none() && right.is_some() { + (None, None, Some(right)) => { // 1. 'left' and 'width' are 'auto' and 'right' is not 'auto', then the width is shrink-to-fit. Then solve for 'left' computed_width = content_width; - computed_left = width_of_containing_block - - (computed_margin_left - + border_left - + padding_left - + computed_width - + padding_right - + border_right - + computed_margin_right - + computed_right); - } else if left.is_none() && right.is_none() && width.is_some() { + computed_inset.start = + width_of_containing_block - (computed_width + right + padding_border + computed_margin.sum()); + } + (None, Some(width), None) => { // 2. 'left' and 'right' are 'auto' and 'width' is not 'auto', - // then if the 'direction' property of the element establishing the static-position - // containing block is 'ltr' set 'left' to the static position, match direction { Direction::Ltr => { - computed_left = static_position; - computed_right = width_of_containing_block - - (computed_left - + computed_margin_left - + border_left - + padding_left - + computed_width - + padding_right - + border_right - + computed_margin_right); + // then if the 'direction' property of the element establishing the static-position + // containing block is 'ltr' set 'left' to the static position, + computed_inset.start = static_position; + computed_inset.end = width_of_containing_block + - (computed_inset.start + width + padding_border + computed_margin.sum()); } Direction::Rtl => { - computed_right = width_of_containing_block - static_position; - computed_left = width_of_containing_block - - (computed_right + computed_margin_right + computed_width + computed_margin_left); + // otherwise set 'right' to the static position. Then solve for 'left' + // (if 'direction is 'rtl') or 'right' (if 'direction' is 'ltr'). + computed_inset.end = width_of_containing_block - static_position - padding_border; + computed_inset.start = width_of_containing_block + - (computed_inset.end + computed_width + padding_border + computed_margin.sum()); } } - // otherwise set 'right' to the static position. Then solve for 'left' - // (if 'direction is 'rtl') or 'right' (if 'direction' is 'ltr'). - } else if width.is_none() && right.is_none() && left.is_some() { + } + (Some(left), None, None) => { // 3. 'width' and 'right' are 'auto' and 'left' is not 'auto', then the width is shrink-to-fit . Then solve for 'right' computed_width = content_width; - computed_right = width_of_containing_block - - (left.unwrap() - + computed_margin_left - + border_left - + padding_left - + computed_width - + padding_right - + border_right - + computed_margin_right) - } else if left.is_none() && width.is_some() && right.is_some() { + computed_inset.end = + width_of_containing_block - (left + computed_width + padding_border + computed_margin.sum()) + } + (None, Some(width), Some(right)) => { // 4. 'left' is 'auto', 'width' and 'right' are not 'auto', then solve for 'left' - computed_left = width_of_containing_block - - (computed_margin_left - + border_left - + padding_left - + computed_width - + padding_right - + border_right - + computed_margin_right - + right.unwrap()); - } else if width.is_none() && left.is_some() && right.is_some() { + computed_inset.start = width_of_containing_block - (width + right + padding_border + computed_margin.sum()); + } + (Some(left), None, Some(right)) => { // 5. 'width' is 'auto', 'left' and 'right' are not 'auto', then solve for 'width' - computed_width = width_of_containing_block - - (computed_left - + computed_margin_left - + border_left - + padding_left - + padding_right - + border_right - + computed_margin_right - + computed_right); - } else if right.is_none() && left.is_some() && width.is_some() { + computed_width = width_of_containing_block - (left + right + padding_border + computed_margin.sum()); + } + (Some(left), Some(width), None) => { // 6. 'right' is 'auto', 'left' and 'width' are not 'auto', then solve for 'right' - computed_right = width_of_containing_block - - (left.unwrap() - + computed_margin_left - + border_left - + computed_width - + border_right - + computed_margin_right); - } else { - unreachable!(); + computed_inset.end = width_of_containing_block - (left + width + padding_border + computed_margin.sum()); } } @@ -1540,18 +1429,13 @@ fn resolve_absolute_margin_and_positions( // 2.0 // If the tentative used width is greater than 'max-width', the rules above are applied again, // but this time using the computed value of 'max-width' as the computed value for 'width'. - resolve_absolute_margin_and_positions( + resolve_absolutely_positioned_non_replaced_box_properties_horizontal( max_width, width_of_containing_block, - left, - right, + inset, content_width, - margin_left, - margin_right, - border_left, - border_right, - padding_left, - padding_right, + margin, + padding_border, static_position, direction, min_width, @@ -1561,18 +1445,13 @@ fn resolve_absolute_margin_and_positions( // 3.0 // If the resulting width is smaller than 'min-width', the rules above are applied again, // but this time using the value of 'min-width' as the computed value for 'width'. - resolve_absolute_margin_and_positions( + resolve_absolutely_positioned_non_replaced_box_properties_horizontal( Some(min_width), width_of_containing_block, - left, - right, + inset, content_width, - margin_left, - margin_right, - border_left, - border_right, - padding_left, - padding_right, + margin, + padding_border, static_position, direction, min_width, @@ -1580,203 +1459,116 @@ fn resolve_absolute_margin_and_positions( ) } else { // 1. The tentative used width is calculated (without 'min-width' and 'max-width') following the rules under "Calculating widths and margins" above. - (computed_left, computed_right, computed_margin_left, computed_margin_right, computed_width) + ResolvedBoxProperties { size: computed_width, inset: computed_inset, margin: computed_margin } } } -/// Compute margin and positons for absolutely positioned children. +/// Compute the top, margin-top, height, margin-bottom, and bottom for non-replaced absolutely positioned boxes. #[inline] -fn resolve_absolute_margin_and_positions_v( +fn resolve_absolutely_positioned_non_replaced_box_properties_vertical( height: Option, height_of_containing_block: f32, - top: Option, - bottom: Option, + inset: Line>, content_height: f32, - margin_top: Option, - margin_bottom: Option, - border_top: f32, - border_bottom: f32, - padding_top: f32, - padding_bottom: f32, + margin: Line>, + padding_border: f32, static_position: f32, min_height: f32, max_height: Option, -) -> (f32, f32, f32, f32, f32) { +) -> ResolvedBoxProperties { // https://www.w3.org/TR/2011/REC-CSS2-20110607/visudet.html#abs-non-replaced-height + let mut computed_margin = margin.map(Option::unwrap_or_default); + let mut computed_inset = inset.map(Option::unwrap_or_default); + let mut computed_height: f32 = height.unwrap_or(0.0); - let mut computed_margin_top = margin_top.unwrap_or(0.0); - let mut computed_margin_bottom = margin_bottom.unwrap_or(0.0); + // For absolutely positioned elements, the used values of the vertical dimensions must satisfy this constraint: + // 'top' + 'margin-top' + 'border-top-width' + 'padding-top' + 'height' + 'padding-bottom' + + // 'border-bottom-width' + 'margin-bottom' + 'bottom' = height of containing block - let mut computed_height: f32 = height.unwrap_or(0.0); + match (inset.start, height, inset.end) { + (None, None, None) => { + // If all three of 'top', 'height', and 'bottom' are auto, set 'top' to the static position and apply rule number three below. - let mut computed_top: f32 = top.unwrap_or(0.0); - let mut computed_bottom: f32 = bottom.unwrap_or(0.0); - - // If all three of 'top', 'height', and 'bottom' are auto, set 'top' to the static position and apply rule number three below. - if top.is_none() && height.is_none() && bottom.is_none() { - computed_top = static_position; - // 3. 'height' and 'bottom' are 'auto' and 'top' is not 'auto', - // then the height is based on the content per 10.6.7, set 'auto' values for - // 'margin-top' and 'margin-bottom' to 0, and solve for 'bottom' - // TODO: HANDLE 10.6.7 - computed_height = content_height; - computed_bottom = height_of_containing_block - - (computed_top - + computed_margin_top - + border_top - + padding_top - + content_height - + padding_bottom - + border_bottom - + computed_margin_bottom) - } - // If none of the three are 'auto' - else if top.is_some() && height.is_some() && bottom.is_some() { - // If both 'margin-top' and 'margin-bottom' are 'auto' - if margin_top.is_none() && margin_bottom.is_none() { - // solve the equation under the extra constraint that the two margins get equal values. - - let margin = (height_of_containing_block - - (computed_top - + border_top - + padding_top - + computed_height - + padding_bottom - + border_bottom - + computed_bottom)) - / 2.0; - - computed_margin_bottom = margin; - computed_margin_top = margin; - } else if margin_top.is_some() { - // If one of 'margin-top' or 'margin-bottom' is 'auto', solve the equation for that value - computed_margin_bottom = height_of_containing_block - - (computed_top - + computed_margin_top - + border_top - + padding_top - + computed_height - + padding_bottom - + border_bottom - + computed_bottom); - } else if margin_bottom.is_some() { - // If one of 'margin-top' or 'margin-bottom' is 'auto', solve the equation for that value - computed_margin_top = height_of_containing_block - - (computed_top - + border_top - + padding_top - + computed_height - + padding_bottom - + border_bottom - + computed_margin_bottom - + computed_bottom); - } else { - // If the values are over-constrained, ignore the value for 'bottom' and solve for that value. - computed_bottom = height_of_containing_block - - (computed_top - + computed_margin_top - + border_top - + padding_top - + computed_height - + padding_bottom - + border_bottom - + computed_margin_bottom); + computed_inset.start = static_position; + // 3. 'height' and 'bottom' are 'auto' and 'top' is not 'auto', + // then the height is based on the content per 10.6.7, set 'auto' values for + // 'margin-top' and 'margin-bottom' to 0, and solve for 'bottom' + // TODO: HANDLE 10.6.7 + computed_height = content_height; + computed_inset.end = height_of_containing_block + - (computed_inset.start + content_height + padding_border + computed_margin.sum()) } - } else { - // Otherwise, pick the one of the following six rules that applies. + (Some(top), Some(height), Some(bottom)) => { + // If none of the three are 'auto' + // If both 'margin-top' and 'margin-bottom' are 'auto' + match (margin.start, margin.end) { + (None, None) => { + // solve the equation under the extra constraint that the two margins get equal values. - if top.is_none() && height.is_none() && bottom.is_some() { + let margin = (height_of_containing_block - (top + height + bottom + padding_border)) / 2.0; + + computed_margin.start = margin; + computed_margin.end = margin; + } + (Some(margin_top), None) => { + // If one of 'margin-top' or 'margin-bottom' is 'auto', solve the equation for that value + computed_margin.end = + height_of_containing_block - (top + margin_top + computed_height + bottom + padding_border); + } + (None, Some(margin_bottom)) => { + // If one of 'margin-top' or 'margin-bottom' is 'auto', solve the equation for that value + computed_margin.start = + height_of_containing_block - (top + height + margin_bottom + bottom + padding_border); + } + (Some(margin_top), Some(margin_bottom)) => { + // If the values are over-constrained, ignore the value for 'bottom' and solve for that value. + computed_inset.end = + height_of_containing_block - (top + height + padding_border + margin_top + margin_bottom); + } + } + } + // Otherwise, pick the one of the following six rules that applies. + (None, None, Some(bottom)) => { // 1. 'top' and 'height' are 'auto' and 'bottom' is not 'auto', then the height is based // on the content per 10.6.7, set 'auto' values for 'margin-top' and 'margin-bottom' to 0, and solve for 'top' //computed_margin_top = 0.0; //computed_margin_bottom = 0.0; // TODO: HANDLE 10.6.7 computed_height = content_height; - computed_top = height_of_containing_block - - (computed_margin_top - + border_top - + padding_top - + content_height - + padding_bottom - + border_bottom - + computed_margin_bottom - + bottom.unwrap()); - } else if top.is_none() && bottom.is_none() && height.is_some() { + computed_inset.start = + height_of_containing_block - (content_height + bottom + padding_border + computed_margin.sum()); + } + (None, Some(height), None) => { // 2. 'top' and 'bottom' are 'auto' and 'height' is not 'auto', then set 'top' to the // static position, set 'auto' values for 'margin-top' and 'margin-bottom' to 0, and solve for 'bottom' - computed_top = static_position; - //computed_margin_top = 0.0; - //computed_margin_bottom = 0.0; - computed_bottom = height_of_containing_block - - (computed_top - + computed_margin_top - + border_top - + padding_top - + computed_height - + padding_bottom - + border_bottom - + computed_margin_bottom); - } else if height.is_none() && bottom.is_none() && top.is_some() { + computed_inset.start = static_position; + computed_inset.end = + height_of_containing_block - (computed_inset.start + height + padding_border + computed_margin.sum()); + } + (Some(top), None, None) => { // 3. 'height' and 'bottom' are 'auto' and 'top' is not 'auto', // then the height is based on the content per 10.6.7, set 'auto' values for // 'margin-top' and 'margin-bottom' to 0, and solve for 'bottom' // TODO: HANDLE 10.6.7 - //computed_margin_top = 0.0; - //computed_margin_bottom = 0.0; computed_height = content_height; - computed_bottom = height_of_containing_block - - (computed_top - + computed_margin_top - + border_top - + padding_top - + content_height - + padding_bottom - + border_bottom - + computed_margin_bottom) - } else if top.is_none() && height.is_some() && bottom.is_some() { + computed_inset.end = + height_of_containing_block - (top + computed_height + padding_border + computed_margin.sum()) + } + (None, Some(height), Some(bottom)) => { // 4. 'top' is 'auto', 'height' and 'bottom' are not 'auto', then set 'auto' values for // 'margin-top' and 'margin-bottom' to 0, and solve for 'top' - //computed_margin_top = 0.0; - //computed_margin_bottom = 0.0; - computed_top = height_of_containing_block - - (computed_margin_top - + border_top - + padding_top - + computed_height - + padding_bottom - + border_bottom - + computed_margin_bottom - + computed_bottom); - } else if height.is_none() && top.is_some() && bottom.is_some() { + computed_inset.start = + height_of_containing_block - (height + bottom + padding_border + computed_margin.sum()); + } + (Some(top), None, Some(bottom)) => { // 5. 'height' is 'auto', 'top' and 'bottom' are not 'auto', then 'auto' values for // 'margin-top' and 'margin-bottom' are set to 0 and solve for 'height' - //computed_margin_top = 0.0; - //computed_margin_bottom = 0.0; - computed_height = height_of_containing_block - - (computed_top - + computed_margin_top - + border_top - + padding_top - + padding_bottom - + border_bottom - + computed_margin_bottom - + computed_bottom); - } else if bottom.is_none() && top.is_some() && height.is_some() { + computed_height = height_of_containing_block - (top + bottom + padding_border + computed_margin.sum()); + } + (Some(top), Some(height), None) => { // 6. 'bottom' is 'auto', 'top' and 'height' are not 'auto', then set 'auto' values for // 'margin-top' and 'margin-bottom' to 0 and solve for 'bottom' - //computed_margin_top = 0.0; - //computed_margin_bottom = 0.0; - computed_bottom = height_of_containing_block - - (computed_top - + computed_margin_top - + border_top - + padding_top - + computed_height - + padding_bottom - + border_bottom - + computed_margin_bottom); - } else { - unreachable!(); + computed_inset.end = height_of_containing_block - (top + height + padding_border + computed_margin.sum()); } } @@ -1785,18 +1577,13 @@ fn resolve_absolute_margin_and_positions_v( // 2.0 // If the tentative used width is greater than 'max-width', the rules above are applied again, // but this time using the computed value of 'max-width' as the computed value for 'width'. - resolve_absolute_margin_and_positions_v( + resolve_absolutely_positioned_non_replaced_box_properties_vertical( max_height, height_of_containing_block, - top, - bottom, + inset, content_height, - margin_top, - margin_bottom, - border_top, - border_bottom, - padding_top, - padding_bottom, + margin, + padding_border, static_position, min_height, None, @@ -1805,24 +1592,19 @@ fn resolve_absolute_margin_and_positions_v( // 3.0 // If the resulting height is smaller than 'min-height', the rules above are applied again, // but this time using the value of 'min-height' as the computed value for 'height'. - resolve_absolute_margin_and_positions_v( + resolve_absolutely_positioned_non_replaced_box_properties_vertical( Some(min_height), height_of_containing_block, - top, - bottom, + inset, content_height, - margin_top, - margin_bottom, - border_top, - border_bottom, - padding_top, - padding_bottom, + margin, + padding_border, static_position, min_height, max_height, ) } else { // 1. The tentative used height is calculated (without 'min-height' and 'max-height') following the rules under "Calculating heights and margins" above. - (computed_top, computed_bottom, computed_margin_top, computed_margin_bottom, computed_height) + ResolvedBoxProperties { size: computed_height, inset: computed_inset, margin: computed_margin } } } diff --git a/src/geometry.rs b/src/geometry.rs index 987dc06ae..0804ffe51 100644 --- a/src/geometry.rs +++ b/src/geometry.rs @@ -296,6 +296,12 @@ impl Rect { pub const fn new(start: f32, end: f32, top: f32, bottom: f32) -> Self { Self { left: start, right: end, top, bottom } } + + /// Creates a new Rect from a horizontal and vertical line. + #[must_use] + pub const fn from_lines(horizontal: Line, vertical: Line) -> Self { + Self { left: horizontal.start, right: horizontal.end, top: vertical.start, bottom: vertical.end } + } } /// An abstract "line". Represents any type that has a start and an end From ca6be1f30f391e9d1aba94d46ba9a3f6e2dbbc2f Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Sat, 11 Apr 2026 23:45:32 -0400 Subject: [PATCH 11/17] Normalize size. --- src/compute/block.rs | 105 +++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 64 deletions(-) diff --git a/src/compute/block.rs b/src/compute/block.rs index 3e6b515c6..282bf163f 100644 --- a/src/compute/block.rs +++ b/src/compute/block.rs @@ -1170,14 +1170,12 @@ fn perform_absolute_layout_on_absolute_children( let mut final_size = known_dimensions.unwrap_or(measured_size).maybe_clamp(min_size, max_size); - let containing_block_width = area_width + border.left + padding.left + padding.right + border.right; let resolved_box_properties_horizontal = resolve_absolutely_positioned_non_replaced_box_properties_horizontal( - style_size.width, - containing_block_width, + known_dimensions.width, + area_width, resolved_inset.horizontal_components(), measured_size.width, margin.horizontal_components(), - padding_border.width, item.static_position.x, direction, min_size.width.unwrap_or_default(), @@ -1198,14 +1196,12 @@ fn perform_absolute_layout_on_absolute_children( Line::FALSE, ); - let containing_block_height = area_height + border.top + padding.top + padding.bottom + border.bottom; let resolved_box_properties_vertical = resolve_absolutely_positioned_non_replaced_box_properties_vertical( - known_dimensions.height, // We use known dimensions here to factor in aspect ratio, is that correct? - containing_block_height, + known_dimensions.height, + area_height, resolved_inset.vertical_components(), measured_size.height, margin.vertical_components(), - padding_border.height, item.static_position.y, min_size.height.unwrap_or(0.0), max_size.height, @@ -1274,7 +1270,6 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_horizontal( inset: Line>, content_width: f32, margin: Line>, - padding_border: f32, static_position: f32, direction: Direction, min_width: f32, @@ -1305,17 +1300,17 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_horizontal( // 'width' and 'right' are 'auto' and 'left' is not 'auto', then the width is shrink-to-fit . Then solve for 'right' computed_width = content_width; - computed_inset.end = width_of_containing_block - - (computed_inset.start + computed_width + computed_margin.sum() + padding_border) + computed_inset.end = + width_of_containing_block - (computed_inset.start + computed_width + computed_margin.sum()) } Direction::Rtl => { - computed_inset.end = width_of_containing_block - - (static_position + computed_width + padding_border + computed_margin.sum()); + computed_inset.end = + width_of_containing_block - (static_position + computed_width + computed_margin.sum()); // 1. 'left' and 'width' are 'auto' and 'right' is not 'auto', then the width is shrink-to-fit. Then solve for 'left' computed_width = content_width; - computed_inset.start = width_of_containing_block - - (computed_width + computed_inset.end + padding_border + computed_margin.sum()); + computed_inset.start = + width_of_containing_block - (computed_width + computed_inset.end + computed_margin.sum()); } } } @@ -1326,7 +1321,7 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_horizontal( // If both 'margin-left' and 'margin-right' are 'auto' // solve the equation under the extra constraint that the two margins get equal values - let margin = (width_of_containing_block - (left + width + right + padding_border)) / 2.0; + let margin = (width_of_containing_block - (left + width + right)) / 2.0; if margin >= 0.0 { computed_margin.start = margin; @@ -1338,26 +1333,22 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_horizontal( match direction { Direction::Ltr => { computed_margin.start = 0.0; - computed_margin.end = - width_of_containing_block - (left + computed_width + right + padding_border); + computed_margin.end = width_of_containing_block - (left + computed_width + right); } Direction::Rtl => { computed_margin.end = 0.0; - computed_margin.start = - width_of_containing_block - (left + computed_width + right + padding_border); + computed_margin.start = width_of_containing_block - (left + computed_width + right); } } } } (Some(margin_left), None) => { // If one of 'margin-left' or 'margin-right' is 'auto', solve the equation for that - computed_margin.end = - width_of_containing_block - (left + margin_left + computed_width + right + padding_border); + computed_margin.end = width_of_containing_block - (left + margin_left + computed_width + right); } (None, Some(margin_right)) => { // If one of 'margin-left' or 'margin-right' is 'auto', solve the equation for that - computed_margin.start = - width_of_containing_block - (left + computed_width + margin_right + right + padding_border); + computed_margin.start = width_of_containing_block - (left + computed_width + margin_right + right); } (Some(margin_left), Some(margin_right)) => { // If the values are over-constrained, ignore the value for 'left' @@ -1365,12 +1356,12 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_horizontal( // (in case 'direction' is 'ltr') and solve for that value. match direction { Direction::Ltr => { - computed_inset.end = width_of_containing_block - - (left + margin_left + computed_width + padding_border + margin_right); + computed_inset.end = + width_of_containing_block - (left + margin_left + computed_width + margin_right); } Direction::Rtl => { - computed_inset.start = width_of_containing_block - - (right + margin_left + computed_width + padding_border + margin_right); + computed_inset.start = + width_of_containing_block - (right + margin_left + computed_width + margin_right); } } } @@ -1382,8 +1373,7 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_horizontal( (None, None, Some(right)) => { // 1. 'left' and 'width' are 'auto' and 'right' is not 'auto', then the width is shrink-to-fit. Then solve for 'left' computed_width = content_width; - computed_inset.start = - width_of_containing_block - (computed_width + right + padding_border + computed_margin.sum()); + computed_inset.start = width_of_containing_block - (computed_width + right + computed_margin.sum()); } (None, Some(width), None) => { // 2. 'left' and 'right' are 'auto' and 'width' is not 'auto', @@ -1392,35 +1382,34 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_horizontal( // then if the 'direction' property of the element establishing the static-position // containing block is 'ltr' set 'left' to the static position, computed_inset.start = static_position; - computed_inset.end = width_of_containing_block - - (computed_inset.start + width + padding_border + computed_margin.sum()); + computed_inset.end = + width_of_containing_block - (computed_inset.start + width + computed_margin.sum()); } Direction::Rtl => { // otherwise set 'right' to the static position. Then solve for 'left' // (if 'direction is 'rtl') or 'right' (if 'direction' is 'ltr'). - computed_inset.end = width_of_containing_block - static_position - padding_border; - computed_inset.start = width_of_containing_block - - (computed_inset.end + computed_width + padding_border + computed_margin.sum()); + computed_inset.end = width_of_containing_block - static_position; + computed_inset.start = + width_of_containing_block - (computed_inset.end + computed_width + computed_margin.sum()); } } } (Some(left), None, None) => { // 3. 'width' and 'right' are 'auto' and 'left' is not 'auto', then the width is shrink-to-fit . Then solve for 'right' computed_width = content_width; - computed_inset.end = - width_of_containing_block - (left + computed_width + padding_border + computed_margin.sum()) + computed_inset.end = width_of_containing_block - (left + computed_width + computed_margin.sum()) } (None, Some(width), Some(right)) => { // 4. 'left' is 'auto', 'width' and 'right' are not 'auto', then solve for 'left' - computed_inset.start = width_of_containing_block - (width + right + padding_border + computed_margin.sum()); + computed_inset.start = width_of_containing_block - (width + right + computed_margin.sum()); } (Some(left), None, Some(right)) => { // 5. 'width' is 'auto', 'left' and 'right' are not 'auto', then solve for 'width' - computed_width = width_of_containing_block - (left + right + padding_border + computed_margin.sum()); + computed_width = width_of_containing_block - (left + right + computed_margin.sum()); } (Some(left), Some(width), None) => { // 6. 'right' is 'auto', 'left' and 'width' are not 'auto', then solve for 'right' - computed_inset.end = width_of_containing_block - (left + width + padding_border + computed_margin.sum()); + computed_inset.end = width_of_containing_block - (left + width + computed_margin.sum()); } } @@ -1435,7 +1424,6 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_horizontal( inset, content_width, margin, - padding_border, static_position, direction, min_width, @@ -1451,7 +1439,6 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_horizontal( inset, content_width, margin, - padding_border, static_position, direction, min_width, @@ -1471,7 +1458,6 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_vertical( inset: Line>, content_height: f32, margin: Line>, - padding_border: f32, static_position: f32, min_height: f32, max_height: Option, @@ -1495,8 +1481,8 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_vertical( // 'margin-top' and 'margin-bottom' to 0, and solve for 'bottom' // TODO: HANDLE 10.6.7 computed_height = content_height; - computed_inset.end = height_of_containing_block - - (computed_inset.start + content_height + padding_border + computed_margin.sum()) + computed_inset.end = + height_of_containing_block - (computed_inset.start + content_height + computed_margin.sum()) } (Some(top), Some(height), Some(bottom)) => { // If none of the three are 'auto' @@ -1505,25 +1491,22 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_vertical( (None, None) => { // solve the equation under the extra constraint that the two margins get equal values. - let margin = (height_of_containing_block - (top + height + bottom + padding_border)) / 2.0; + let margin = (height_of_containing_block - (top + height + bottom)) / 2.0; computed_margin.start = margin; computed_margin.end = margin; } (Some(margin_top), None) => { // If one of 'margin-top' or 'margin-bottom' is 'auto', solve the equation for that value - computed_margin.end = - height_of_containing_block - (top + margin_top + computed_height + bottom + padding_border); + computed_margin.end = height_of_containing_block - (top + margin_top + computed_height + bottom); } (None, Some(margin_bottom)) => { // If one of 'margin-top' or 'margin-bottom' is 'auto', solve the equation for that value - computed_margin.start = - height_of_containing_block - (top + height + margin_bottom + bottom + padding_border); + computed_margin.start = height_of_containing_block - (top + height + margin_bottom + bottom); } (Some(margin_top), Some(margin_bottom)) => { // If the values are over-constrained, ignore the value for 'bottom' and solve for that value. - computed_inset.end = - height_of_containing_block - (top + height + padding_border + margin_top + margin_bottom); + computed_inset.end = height_of_containing_block - (top + height + margin_top + margin_bottom); } } } @@ -1535,15 +1518,13 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_vertical( //computed_margin_bottom = 0.0; // TODO: HANDLE 10.6.7 computed_height = content_height; - computed_inset.start = - height_of_containing_block - (content_height + bottom + padding_border + computed_margin.sum()); + computed_inset.start = height_of_containing_block - (content_height + bottom + computed_margin.sum()); } (None, Some(height), None) => { // 2. 'top' and 'bottom' are 'auto' and 'height' is not 'auto', then set 'top' to the // static position, set 'auto' values for 'margin-top' and 'margin-bottom' to 0, and solve for 'bottom' computed_inset.start = static_position; - computed_inset.end = - height_of_containing_block - (computed_inset.start + height + padding_border + computed_margin.sum()); + computed_inset.end = height_of_containing_block - (computed_inset.start + height + computed_margin.sum()); } (Some(top), None, None) => { // 3. 'height' and 'bottom' are 'auto' and 'top' is not 'auto', @@ -1551,24 +1532,22 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_vertical( // 'margin-top' and 'margin-bottom' to 0, and solve for 'bottom' // TODO: HANDLE 10.6.7 computed_height = content_height; - computed_inset.end = - height_of_containing_block - (top + computed_height + padding_border + computed_margin.sum()) + computed_inset.end = height_of_containing_block - (top + computed_height + computed_margin.sum()) } (None, Some(height), Some(bottom)) => { // 4. 'top' is 'auto', 'height' and 'bottom' are not 'auto', then set 'auto' values for // 'margin-top' and 'margin-bottom' to 0, and solve for 'top' - computed_inset.start = - height_of_containing_block - (height + bottom + padding_border + computed_margin.sum()); + computed_inset.start = height_of_containing_block - (height + bottom + computed_margin.sum()); } (Some(top), None, Some(bottom)) => { // 5. 'height' is 'auto', 'top' and 'bottom' are not 'auto', then 'auto' values for // 'margin-top' and 'margin-bottom' are set to 0 and solve for 'height' - computed_height = height_of_containing_block - (top + bottom + padding_border + computed_margin.sum()); + computed_height = height_of_containing_block - (top + bottom + computed_margin.sum()); } (Some(top), Some(height), None) => { // 6. 'bottom' is 'auto', 'top' and 'height' are not 'auto', then set 'auto' values for // 'margin-top' and 'margin-bottom' to 0 and solve for 'bottom' - computed_inset.end = height_of_containing_block - (top + height + padding_border + computed_margin.sum()); + computed_inset.end = height_of_containing_block - (top + height + computed_margin.sum()); } } @@ -1583,7 +1562,6 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_vertical( inset, content_height, margin, - padding_border, static_position, min_height, None, @@ -1598,7 +1576,6 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_vertical( inset, content_height, margin, - padding_border, static_position, min_height, max_height, From 34621f3f7b548e3d87a32134f66a6058333f7deb Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Sun, 12 Apr 2026 00:03:45 -0400 Subject: [PATCH 12/17] clippy --- src/compute/block.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/compute/block.rs b/src/compute/block.rs index 282bf163f..6fee20924 100644 --- a/src/compute/block.rs +++ b/src/compute/block.rs @@ -74,9 +74,13 @@ pub struct BlockContext<'bfc> { is_root: bool, } +/// Stores the results of a resolved block. struct ResolvedBoxProperties { + /// The resolved size. size: f32, + /// The resolved insets. inset: Line, + /// The resolved margin. margin: Line, } @@ -1264,6 +1268,7 @@ fn perform_absolute_layout_on_absolute_children( } /// Compute the left, margin-left, width, margin-right, and right for non-replaced absolutely positioned boxes. #[inline] +#[allow(clippy::too_many_arguments)] fn resolve_absolutely_positioned_non_replaced_box_properties_horizontal( width: Option, width_of_containing_block: f32, @@ -1452,6 +1457,7 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_horizontal( /// Compute the top, margin-top, height, margin-bottom, and bottom for non-replaced absolutely positioned boxes. #[inline] +#[allow(clippy::too_many_arguments)] fn resolve_absolutely_positioned_non_replaced_box_properties_vertical( height: Option, height_of_containing_block: f32, From cf3188160ffd93eb033c1a48e851bd1785cb1b83 Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Sun, 12 Apr 2026 02:46:39 -0400 Subject: [PATCH 13/17] Move layout_output down --- src/compute/block.rs | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/compute/block.rs b/src/compute/block.rs index 6fee20924..a3c2ba37f 100644 --- a/src/compute/block.rs +++ b/src/compute/block.rs @@ -1172,8 +1172,6 @@ fn perform_absolute_layout_on_absolute_children( Line::FALSE, ); - let mut final_size = known_dimensions.unwrap_or(measured_size).maybe_clamp(min_size, max_size); - let resolved_box_properties_horizontal = resolve_absolutely_positioned_non_replaced_box_properties_horizontal( known_dimensions.width, area_width, @@ -1186,7 +1184,19 @@ fn perform_absolute_layout_on_absolute_children( max_size.width, ); - final_size.width = resolved_box_properties_horizontal.size; + let resolved_box_properties_vertical = resolve_absolutely_positioned_non_replaced_box_properties_vertical( + known_dimensions.height, + area_height, + resolved_inset.vertical_components(), + measured_size.height, + margin.vertical_components(), + item.static_position.y, + min_size.height.unwrap_or(0.0), + max_size.height, + ); + + let final_size = Size::new(resolved_box_properties_horizontal.size, resolved_box_properties_vertical.size) + .map(Option::unwrap_or_default); let layout_output = tree.perform_child_layout( item.node_id, @@ -1200,18 +1210,6 @@ fn perform_absolute_layout_on_absolute_children( Line::FALSE, ); - let resolved_box_properties_vertical = resolve_absolutely_positioned_non_replaced_box_properties_vertical( - known_dimensions.height, - area_height, - resolved_inset.vertical_components(), - measured_size.height, - margin.vertical_components(), - item.static_position.y, - min_size.height.unwrap_or(0.0), - max_size.height, - ); - final_size.height = resolved_box_properties_vertical.size; - let resolved_margin = Rect::from_lines(resolved_box_properties_horizontal.margin, resolved_box_properties_vertical.margin); let is_static_x = resolved_inset.left.is_none() && resolved_inset.right.is_none(); From fd481e87aa6578a2edddf8b9979eabcef5ab8c56 Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Sun, 12 Apr 2026 13:20:33 -0400 Subject: [PATCH 14/17] Remove generated. --- .../block/block_absolute_auto_margin.rs | 125 --------------- .../block_absolute_auto_margins_and_insets.rs | 151 ------------------ ...ntal_left_and_right_auto_width_not_auto.rs | 125 --------------- ...ntal_left_and_width_auto_right_not_auto.rs | 125 --------------- ...ntal_left_auto_width_and_right_not_auto.rs | 125 --------------- ...ntal_right_auto_left_and_width_not_auto.rs | 125 --------------- ...ntal_width_and_right_auto_left_not_auto.rs | 125 --------------- ...ntal_width_auto_left_and_right_not_auto.rs | 125 --------------- tests/generated/block/mod.rs | 0 9 files changed, 1026 deletions(-) delete mode 100644 tests/generated/block/block_absolute_auto_margin.rs delete mode 100644 tests/generated/block/block_absolute_auto_margins_and_insets.rs delete mode 100644 tests/generated/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.rs delete mode 100644 tests/generated/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.rs delete mode 100644 tests/generated/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.rs delete mode 100644 tests/generated/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.rs delete mode 100644 tests/generated/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.rs delete mode 100644 tests/generated/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.rs delete mode 100644 tests/generated/block/mod.rs diff --git a/tests/generated/block/block_absolute_auto_margin.rs b/tests/generated/block/block_absolute_auto_margin.rs deleted file mode 100644 index 00c6f94a8..000000000 --- a/tests/generated/block/block_absolute_auto_margin.rs +++ /dev/null @@ -1,125 +0,0 @@ -#[test] -#[allow(non_snake_case)] -fn block_absolute_auto_margin__border_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(100f32), - height: taffy::style::Dimension::from_length(100f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(100f32), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: length(50f32), - right: length(0f32), - top: length(0f32), - bottom: auto(), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(200f32), - height: taffy::style::Dimension::from_length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node0, 75f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); -} - -#[test] -#[allow(non_snake_case)] -fn block_absolute_auto_margin__content_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - box_sizing: taffy::style::BoxSizing::ContentBox, - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(100f32), - height: taffy::style::Dimension::from_length(100f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(100f32), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: length(50f32), - right: length(0f32), - top: length(0f32), - bottom: auto(), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - box_sizing: taffy::style::BoxSizing::ContentBox, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(200f32), - height: taffy::style::Dimension::from_length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 75f32, "x of node {:?}. Expected {}. Actual {}", node0, 75f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); -} diff --git a/tests/generated/block/block_absolute_auto_margins_and_insets.rs b/tests/generated/block/block_absolute_auto_margins_and_insets.rs deleted file mode 100644 index 869ec3135..000000000 --- a/tests/generated/block/block_absolute_auto_margins_and_insets.rs +++ /dev/null @@ -1,151 +0,0 @@ -#[test] -#[allow(non_snake_case)] -fn block_absolute_auto_margins_and_insets__border_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(60f32), - height: taffy::style::Dimension::from_length(60f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: zero(), - bottom: zero(), - }, - inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), top: auto(), bottom: auto() }, - border: taffy::geometry::Rect { - left: length(10f32), - right: length(10f32), - top: length(10f32), - bottom: length(10f32), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(120f32), - height: taffy::style::Dimension::from_length(120f32), - }, - padding: taffy::geometry::Rect { - left: length(20f32), - right: length(20f32), - top: length(20f32), - bottom: length(20f32), - }, - border: taffy::geometry::Rect { - left: length(20f32), - right: length(20f32), - top: length(20f32), - bottom: length(20f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node, 120f32, size.width); - assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node, 120f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width); - assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height); - assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node0, 30f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); -} - -#[test] -#[allow(non_snake_case)] -fn block_absolute_auto_margins_and_insets__content_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - box_sizing: taffy::style::BoxSizing::ContentBox, - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(60f32), - height: taffy::style::Dimension::from_length(60f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: zero(), - bottom: zero(), - }, - inset: taffy::geometry::Rect { left: length(0f32), right: length(0f32), top: auto(), bottom: auto() }, - border: taffy::geometry::Rect { - left: length(10f32), - right: length(10f32), - top: length(10f32), - bottom: length(10f32), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - box_sizing: taffy::style::BoxSizing::ContentBox, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(120f32), - height: taffy::style::Dimension::from_length(120f32), - }, - padding: taffy::geometry::Rect { - left: length(20f32), - right: length(20f32), - top: length(20f32), - bottom: length(20f32), - }, - border: taffy::geometry::Rect { - left: length(20f32), - right: length(20f32), - top: length(20f32), - bottom: length(20f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width); - assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height); - assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x); - assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node0, 40f32, location.y); -} diff --git a/tests/generated/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.rs b/tests/generated/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.rs deleted file mode 100644 index 90f4482f8..000000000 --- a/tests/generated/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.rs +++ /dev/null @@ -1,125 +0,0 @@ -#[test] -#[allow(non_snake_case)] -fn block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(100f32), - height: taffy::style::Dimension::from_length(100f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(100f32), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(0f32), - bottom: auto(), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(200f32), - height: taffy::style::Dimension::from_length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); -} - -#[test] -#[allow(non_snake_case)] -fn block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - box_sizing: taffy::style::BoxSizing::ContentBox, - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(100f32), - height: taffy::style::Dimension::from_length(100f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(100f32), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(0f32), - bottom: auto(), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - box_sizing: taffy::style::BoxSizing::ContentBox, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(200f32), - height: taffy::style::Dimension::from_length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); -} diff --git a/tests/generated/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.rs b/tests/generated/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.rs deleted file mode 100644 index 2aa83ef6c..000000000 --- a/tests/generated/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.rs +++ /dev/null @@ -1,125 +0,0 @@ -#[test] -#[allow(non_snake_case)] -fn block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::AUTO, - height: taffy::style::Dimension::from_length(100f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(100f32), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: length(20f32), - top: length(0f32), - bottom: auto(), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(200f32), - height: taffy::style::Dimension::from_length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 180f32, "x of node {:?}. Expected {}. Actual {}", node0, 180f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); -} - -#[test] -#[allow(non_snake_case)] -fn block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - box_sizing: taffy::style::BoxSizing::ContentBox, - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::AUTO, - height: taffy::style::Dimension::from_length(100f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(100f32), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: length(20f32), - top: length(0f32), - bottom: auto(), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - box_sizing: taffy::style::BoxSizing::ContentBox, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(200f32), - height: taffy::style::Dimension::from_length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 180f32, "x of node {:?}. Expected {}. Actual {}", node0, 180f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); -} diff --git a/tests/generated/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.rs b/tests/generated/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.rs deleted file mode 100644 index 65a7a3eb5..000000000 --- a/tests/generated/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.rs +++ /dev/null @@ -1,125 +0,0 @@ -#[test] -#[allow(non_snake_case)] -fn block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(100f32), - height: taffy::style::Dimension::from_length(100f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(100f32), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: length(20f32), - top: length(0f32), - bottom: auto(), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(200f32), - height: taffy::style::Dimension::from_length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); -} - -#[test] -#[allow(non_snake_case)] -fn block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - box_sizing: taffy::style::BoxSizing::ContentBox, - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(100f32), - height: taffy::style::Dimension::from_length(100f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(100f32), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: length(20f32), - top: length(0f32), - bottom: auto(), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - box_sizing: taffy::style::BoxSizing::ContentBox, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(200f32), - height: taffy::style::Dimension::from_length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); -} diff --git a/tests/generated/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.rs b/tests/generated/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.rs deleted file mode 100644 index f2ebe162a..000000000 --- a/tests/generated/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.rs +++ /dev/null @@ -1,125 +0,0 @@ -#[test] -#[allow(non_snake_case)] -fn block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(100f32), - height: taffy::style::Dimension::from_length(100f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(100f32), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: length(50f32), - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(0f32), - bottom: auto(), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(200f32), - height: taffy::style::Dimension::from_length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); -} - -#[test] -#[allow(non_snake_case)] -fn block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - box_sizing: taffy::style::BoxSizing::ContentBox, - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(100f32), - height: taffy::style::Dimension::from_length(100f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(100f32), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: length(50f32), - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(0f32), - bottom: auto(), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - box_sizing: taffy::style::BoxSizing::ContentBox, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(200f32), - height: taffy::style::Dimension::from_length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); -} diff --git a/tests/generated/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.rs b/tests/generated/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.rs deleted file mode 100644 index 8c976b961..000000000 --- a/tests/generated/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.rs +++ /dev/null @@ -1,125 +0,0 @@ -#[test] -#[allow(non_snake_case)] -fn block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::AUTO, - height: taffy::style::Dimension::from_length(100f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(100f32), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: length(20f32), - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(0f32), - bottom: auto(), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(200f32), - height: taffy::style::Dimension::from_length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); -} - -#[test] -#[allow(non_snake_case)] -fn block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - box_sizing: taffy::style::BoxSizing::ContentBox, - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::AUTO, - height: taffy::style::Dimension::from_length(100f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(100f32), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: length(20f32), - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(0f32), - bottom: auto(), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - box_sizing: taffy::style::BoxSizing::ContentBox, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(200f32), - height: taffy::style::Dimension::from_length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); -} diff --git a/tests/generated/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.rs b/tests/generated/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.rs deleted file mode 100644 index 2e0781476..000000000 --- a/tests/generated/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.rs +++ /dev/null @@ -1,125 +0,0 @@ -#[test] -#[allow(non_snake_case)] -fn block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::AUTO, - height: taffy::style::Dimension::from_length(100f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(100f32), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: length(50f32), - right: length(20f32), - top: length(0f32), - bottom: auto(), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(200f32), - height: taffy::style::Dimension::from_length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node0, 130f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); -} - -#[test] -#[allow(non_snake_case)] -fn block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box() { - #[allow(unused_imports)] - use taffy::{prelude::*, Layout}; - let mut taffy = crate::new_test_tree(); - let node0 = taffy - .new_leaf_with_context( - taffy::style::Style { - box_sizing: taffy::style::BoxSizing::ContentBox, - position: taffy::style::Position::Absolute, - size: taffy::geometry::Size { - width: taffy::style::Dimension::AUTO, - height: taffy::style::Dimension::from_length(100f32), - }, - margin: taffy::geometry::Rect { - left: taffy::style::LengthPercentageAuto::AUTO, - right: taffy::style::LengthPercentageAuto::AUTO, - top: length(100f32), - bottom: zero(), - }, - inset: taffy::geometry::Rect { - left: length(50f32), - right: length(20f32), - top: length(0f32), - bottom: auto(), - }, - ..Default::default() - }, - crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal), - ) - .unwrap(); - let node = taffy - .new_with_children( - taffy::style::Style { - display: taffy::style::Display::Block, - box_sizing: taffy::style::BoxSizing::ContentBox, - size: taffy::geometry::Size { - width: taffy::style::Dimension::from_length(200f32), - height: taffy::style::Dimension::from_length(200f32), - }, - ..Default::default() - }, - &[node0], - ) - .unwrap(); - taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap(); - println!("\nComputed tree:"); - taffy.print_tree(node); - println!(); - let layout = taffy.layout(node).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node, 200f32, size.width); - assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height); - assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x); - assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y); - let layout = taffy.layout(node0).unwrap(); - let Layout { size, location, .. } = layout; - assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node0, 130f32, size.width); - assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height); - assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x); - assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y); -} diff --git a/tests/generated/block/mod.rs b/tests/generated/block/mod.rs deleted file mode 100644 index e69de29bb..000000000 From 9e66a334c28a74ea38f91768cc04b7d03f5a3745 Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Sun, 12 Apr 2026 13:32:35 -0400 Subject: [PATCH 15/17] Remove redundant tests --- ...al_left_and_right_auto_width_not_auto.html | 22 ---- ...al_left_and_width_auto_right_not_auto.html | 22 ---- ...al_left_auto_width_and_right_not_auto.html | 22 ---- ...al_right_auto_left_and_width_not_auto.html | 22 ---- ...al_width_and_right_auto_left_not_auto.html | 22 ---- ...al_width_auto_left_and_right_not_auto.html | 22 ---- ...ht_auto_width_not_auto__border_box_ltr.xml | 15 --- ...ht_auto_width_not_auto__border_box_rtl.xml | 15 --- ...t_auto_width_not_auto__content_box_ltr.xml | 15 --- ...t_auto_width_not_auto__content_box_rtl.xml | 15 --- ...th_auto_right_not_auto__border_box_ltr.xml | 15 --- ...th_auto_right_not_auto__border_box_rtl.xml | 15 --- ...h_auto_right_not_auto__content_box_ltr.xml | 15 --- ...h_auto_right_not_auto__content_box_rtl.xml | 15 --- ...dth_and_right_not_auto__border_box_ltr.xml | 15 --- ...dth_and_right_not_auto__border_box_rtl.xml | 15 --- ...th_and_right_not_auto__content_box_ltr.xml | 15 --- ...th_and_right_not_auto__content_box_rtl.xml | 15 --- ...eft_and_width_not_auto__border_box_ltr.xml | 15 --- ...eft_and_width_not_auto__border_box_rtl.xml | 15 --- ...ft_and_width_not_auto__content_box_ltr.xml | 15 --- ...ft_and_width_not_auto__content_box_rtl.xml | 15 --- ...ght_auto_left_not_auto__border_box_ltr.xml | 15 --- ...ght_auto_left_not_auto__border_box_rtl.xml | 15 --- ...ht_auto_left_not_auto__content_box_ltr.xml | 15 --- ...ht_auto_left_not_auto__content_box_rtl.xml | 15 --- ...eft_and_right_not_auto__border_box_ltr.xml | 15 --- ...eft_and_right_not_auto__border_box_rtl.xml | 15 --- ...ft_and_right_not_auto__content_box_ltr.xml | 15 --- ...ft_and_right_not_auto__content_box_rtl.xml | 15 --- tests/xml/mod.rs | 120 ------------------ 31 files changed, 612 deletions(-) delete mode 100644 test_fixtures/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.html delete mode 100644 test_fixtures/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.html delete mode 100644 test_fixtures/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.html delete mode 100644 test_fixtures/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.html delete mode 100644 test_fixtures/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.html delete mode 100644 test_fixtures/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.html delete mode 100644 tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_ltr.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_rtl.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_ltr.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_rtl.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_ltr.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_rtl.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_ltr.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_rtl.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_ltr.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_rtl.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_ltr.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_rtl.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_ltr.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_rtl.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_ltr.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_rtl.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_ltr.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_rtl.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_ltr.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_rtl.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_ltr.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_rtl.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_ltr.xml delete mode 100644 tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_rtl.xml diff --git a/test_fixtures/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.html b/test_fixtures/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.html deleted file mode 100644 index 684eab37e..000000000 --- a/test_fixtures/block/block_absolute_horizontal_left_and_right_auto_width_not_auto.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - Absolute positioning: 'left' and 'right' are 'auto' and 'width' is not 'auto', then if the 'direction' property of the element establishing the static-position containing block is 'ltr' set 'left' to the static position, otherwise set 'right' to the static position. Then solve for 'left' (if 'direction is 'rtl') or 'right' (if 'direction' is 'ltr'). - - - - - -
-
-
-
- - - \ No newline at end of file diff --git a/test_fixtures/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.html b/test_fixtures/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.html deleted file mode 100644 index 1c11327da..000000000 --- a/test_fixtures/block/block_absolute_horizontal_left_and_width_auto_right_not_auto.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - Absolute positioning: 'left' and 'width' are 'auto' and 'right' is not 'auto', then the width is shrink-to-fit. Then solve for 'left' - - - - - -
-
-
-
- - - \ No newline at end of file diff --git a/test_fixtures/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.html b/test_fixtures/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.html deleted file mode 100644 index ad864fd8d..000000000 --- a/test_fixtures/block/block_absolute_horizontal_left_auto_width_and_right_not_auto.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - Absolute positioning: 'left' is 'auto', 'width' and 'right' are not 'auto', then solve for 'left' - - - - - -
-
-
-
- - - \ No newline at end of file diff --git a/test_fixtures/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.html b/test_fixtures/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.html deleted file mode 100644 index d1eaec779..000000000 --- a/test_fixtures/block/block_absolute_horizontal_right_auto_left_and_width_not_auto.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - Absolute positioning: 'right' is 'auto', 'left' and 'width' are not 'auto', then solve for 'right' - - - - - -
-
-
-
- - - \ No newline at end of file diff --git a/test_fixtures/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.html b/test_fixtures/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.html deleted file mode 100644 index cf890f6f5..000000000 --- a/test_fixtures/block/block_absolute_horizontal_width_and_right_auto_left_not_auto.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - Absolute positioning: 'width' and 'right' are 'auto' and 'left' is not 'auto', then the width is shrink-to-fit . Then solve for 'right' - - - - - -
-
-
-
- - - \ No newline at end of file diff --git a/test_fixtures/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.html b/test_fixtures/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.html deleted file mode 100644 index ee2e911aa..000000000 --- a/test_fixtures/block/block_absolute_horizontal_width_auto_left_and_right_not_auto.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - Absolute positioning: 'width' is 'auto', 'left' and 'right' are not 'auto', then solve for 'width' - - - - - -
-
-
-
- - - \ No newline at end of file diff --git a/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_ltr.xml deleted file mode 100644 index 44d453ed7..000000000 --- a/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_ltr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_rtl.xml deleted file mode 100644 index ea3e3e962..000000000 --- a/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_rtl.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_ltr.xml deleted file mode 100644 index ecdbcc384..000000000 --- a/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_ltr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_rtl.xml deleted file mode 100644 index a27273b11..000000000 --- a/tests/xml/block/block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_rtl.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_ltr.xml deleted file mode 100644 index e4748f3a7..000000000 --- a/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_ltr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_rtl.xml deleted file mode 100644 index ca7d0d12e..000000000 --- a/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_rtl.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_ltr.xml deleted file mode 100644 index aa30f324b..000000000 --- a/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_ltr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_rtl.xml deleted file mode 100644 index 2aa723abe..000000000 --- a/tests/xml/block/block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_rtl.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_ltr.xml deleted file mode 100644 index e5d426f1d..000000000 --- a/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_ltr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_rtl.xml deleted file mode 100644 index 45715d39b..000000000 --- a/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_rtl.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_ltr.xml deleted file mode 100644 index f3f351031..000000000 --- a/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_ltr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_rtl.xml deleted file mode 100644 index 8e56fe1ef..000000000 --- a/tests/xml/block/block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_rtl.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_ltr.xml deleted file mode 100644 index 7a3cc617f..000000000 --- a/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_ltr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_rtl.xml deleted file mode 100644 index 88c472dee..000000000 --- a/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_rtl.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_ltr.xml deleted file mode 100644 index 46264ec98..000000000 --- a/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_ltr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_rtl.xml deleted file mode 100644 index e51a065fd..000000000 --- a/tests/xml/block/block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_rtl.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_ltr.xml deleted file mode 100644 index 821a8482a..000000000 --- a/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_ltr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_rtl.xml deleted file mode 100644 index 7dfe2ce89..000000000 --- a/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_rtl.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_ltr.xml deleted file mode 100644 index e1cd6cc63..000000000 --- a/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_ltr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_rtl.xml deleted file mode 100644 index 026440203..000000000 --- a/tests/xml/block/block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_rtl.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_ltr.xml deleted file mode 100644 index 254cd8751..000000000 --- a/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_ltr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_rtl.xml deleted file mode 100644 index 4c41278af..000000000 --- a/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_rtl.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_ltr.xml b/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_ltr.xml deleted file mode 100644 index 01e21ce86..000000000 --- a/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_ltr.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_rtl.xml b/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_rtl.xml deleted file mode 100644 index 2a094587c..000000000 --- a/tests/xml/block/block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_rtl.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - -
- - - -
- - - - - - -
diff --git a/tests/xml/mod.rs b/tests/xml/mod.rs index 54cf0ff3b..f2c32ddc3 100644 --- a/tests/xml/mod.rs +++ b/tests/xml/mod.rs @@ -353,126 +353,6 @@ mod block { crate::run_xml_test("block", "block_absolute_child_with_max_height__content_box_rtl"); } - #[test] - fn block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_ltr() { - crate::run_xml_test("block", "block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_ltr"); - } - - #[test] - fn block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_ltr() { - crate::run_xml_test("block", "block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_ltr"); - } - - #[test] - fn block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_rtl() { - crate::run_xml_test("block", "block_absolute_horizontal_left_and_right_auto_width_not_auto__border_box_rtl"); - } - - #[test] - fn block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_rtl() { - crate::run_xml_test("block", "block_absolute_horizontal_left_and_right_auto_width_not_auto__content_box_rtl"); - } - - #[test] - fn block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_ltr() { - crate::run_xml_test("block", "block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_ltr"); - } - - #[test] - fn block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_ltr() { - crate::run_xml_test("block", "block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_ltr"); - } - - #[test] - fn block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_rtl() { - crate::run_xml_test("block", "block_absolute_horizontal_left_and_width_auto_right_not_auto__border_box_rtl"); - } - - #[test] - fn block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_rtl() { - crate::run_xml_test("block", "block_absolute_horizontal_left_and_width_auto_right_not_auto__content_box_rtl"); - } - - #[test] - fn block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_ltr() { - crate::run_xml_test("block", "block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_ltr"); - } - - #[test] - fn block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_ltr() { - crate::run_xml_test("block", "block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_ltr"); - } - - #[test] - fn block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_rtl() { - crate::run_xml_test("block", "block_absolute_horizontal_left_auto_width_and_right_not_auto__border_box_rtl"); - } - - #[test] - fn block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_rtl() { - crate::run_xml_test("block", "block_absolute_horizontal_left_auto_width_and_right_not_auto__content_box_rtl"); - } - - #[test] - fn block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_ltr() { - crate::run_xml_test("block", "block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_ltr"); - } - - #[test] - fn block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_ltr() { - crate::run_xml_test("block", "block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_ltr"); - } - - #[test] - fn block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_rtl() { - crate::run_xml_test("block", "block_absolute_horizontal_right_auto_left_and_width_not_auto__border_box_rtl"); - } - - #[test] - fn block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_rtl() { - crate::run_xml_test("block", "block_absolute_horizontal_right_auto_left_and_width_not_auto__content_box_rtl"); - } - - #[test] - fn block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_ltr() { - crate::run_xml_test("block", "block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_ltr"); - } - - #[test] - fn block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_ltr() { - crate::run_xml_test("block", "block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_ltr"); - } - - #[test] - fn block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_rtl() { - crate::run_xml_test("block", "block_absolute_horizontal_width_and_right_auto_left_not_auto__border_box_rtl"); - } - - #[test] - fn block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_rtl() { - crate::run_xml_test("block", "block_absolute_horizontal_width_and_right_auto_left_not_auto__content_box_rtl"); - } - - #[test] - fn block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_ltr() { - crate::run_xml_test("block", "block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_ltr"); - } - - #[test] - fn block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_ltr() { - crate::run_xml_test("block", "block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_ltr"); - } - - #[test] - fn block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_rtl() { - crate::run_xml_test("block", "block_absolute_horizontal_width_auto_left_and_right_not_auto__border_box_rtl"); - } - - #[test] - fn block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_rtl() { - crate::run_xml_test("block", "block_absolute_horizontal_width_auto_left_and_right_not_auto__content_box_rtl"); - } - #[test] fn block_absolute_layout_child_order__border_box_ltr() { crate::run_xml_test("block", "block_absolute_layout_child_order__border_box_ltr"); From 3c1b15a1ab9ae049a12222015515183141a421e8 Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Sun, 12 Apr 2026 20:32:26 -0400 Subject: [PATCH 16/17] Remove commented out code --- src/compute/block.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/compute/block.rs b/src/compute/block.rs index a3c2ba37f..15e03b300 100644 --- a/src/compute/block.rs +++ b/src/compute/block.rs @@ -1518,8 +1518,6 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_vertical( (None, None, Some(bottom)) => { // 1. 'top' and 'height' are 'auto' and 'bottom' is not 'auto', then the height is based // on the content per 10.6.7, set 'auto' values for 'margin-top' and 'margin-bottom' to 0, and solve for 'top' - //computed_margin_top = 0.0; - //computed_margin_bottom = 0.0; // TODO: HANDLE 10.6.7 computed_height = content_height; computed_inset.start = height_of_containing_block - (content_height + bottom + computed_margin.sum()); From 83a76c7c622ee9bcab5725c3f7f438ae7f486172 Mon Sep 17 00:00:00 2001 From: "Austin M. Reppert" Date: Sun, 12 Apr 2026 20:46:27 -0400 Subject: [PATCH 17/17] Fix spec comment --- src/compute/block.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compute/block.rs b/src/compute/block.rs index 15e03b300..de3348d67 100644 --- a/src/compute/block.rs +++ b/src/compute/block.rs @@ -1556,8 +1556,8 @@ fn resolve_absolutely_positioned_non_replaced_box_properties_vertical( // 10.7 Minimum and maximum heights: if max_height.is_some() && computed_height > max_height.unwrap() { // 2.0 - // If the tentative used width is greater than 'max-width', the rules above are applied again, - // but this time using the computed value of 'max-width' as the computed value for 'width'. + // If this tentative height is greater than 'max-height', the rules above are applied again, + // but this time using the value of 'max-height' as the computed value for 'height'. resolve_absolutely_positioned_non_replaced_box_properties_vertical( max_height, height_of_containing_block,