diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs
index 13458ea4d..1a0eaddcd 100644
--- a/src/compute/flexbox.rs
+++ b/src/compute/flexbox.rs
@@ -614,88 +614,97 @@ fn determine_flex_base_size(
for child in flex_items.iter_mut() {
let child_style = tree.style(child.node);
- // A. If the item has a definite used flex basis, that’s the flex base size.
+ child.flex_basis = 'flex_basis: {
+ // A. If the item has a definite used flex basis, that’s the flex base size.
- // B. If the flex item has an intrinsic aspect ratio,
- // a used flex basis of content, and a definite cross size,
- // then the flex base size is calculated from its inner
- // cross size and the flex item’s intrinsic aspect ratio.
+ // B. If the flex item has an intrinsic aspect ratio,
+ // a used flex basis of content, and a definite cross size,
+ // then the flex base size is calculated from its inner
+ // cross size and the flex item’s intrinsic aspect ratio.
- // Note: `child.size` has already been resolved against aspect_ratio in generate_anonymous_flex_items
- // So B will just work here by using main_size without special handling for aspect_ratio
+ // Note: `child.size` has already been resolved against aspect_ratio in generate_anonymous_flex_items
+ // So B will just work here by using main_size without special handling for aspect_ratio
- let flex_basis = child_style.flex_basis.maybe_resolve(constants.node_inner_size.main(constants.dir));
- let main_size = child.size.main(constants.dir);
- if let Some(flex_basis) = flex_basis.or(main_size) {
- child.flex_basis = flex_basis;
- continue;
- };
+ let flex_basis = child_style.flex_basis.maybe_resolve(constants.node_inner_size.main(constants.dir));
+ let main_size = child.size.main(constants.dir);
+ if let Some(flex_basis) = flex_basis.or(main_size) {
+ break 'flex_basis flex_basis;
+ };
- // C. If the used flex basis is content or depends on its available space,
- // and the flex container is being sized under a min-content or max-content
- // constraint (e.g. when performing automatic table layout [CSS21]),
- // size the item under that constraint. The flex base size is the item’s
- // resulting main size.
-
- // This is covered by the implementation of E below, which passes the available_space constraint
- // through to the child size computation. It may need a separate implementation if/when D is implemented.
-
- // D. Otherwise, if the used flex basis is content or depends on its
- // available space, the available main size is infinite, and the flex item’s
- // inline axis is parallel to the main axis, lay the item out using the rules
- // for a box in an orthogonal flow [CSS3-WRITING-MODES]. The flex base size
- // is the item’s max-content main size.
-
- // TODO if/when vertical writing modes are supported
-
- // E. Otherwise, size the item into the available space using its used flex basis
- // in place of its main size, treating a value of content as max-content.
- // If a cross size is needed to determine the main size (e.g. when the
- // flex item’s main size is in its block axis) and the flex item’s cross size
- // is auto and not definite, in this calculation use fit-content as the
- // flex item’s cross size. The flex base size is the item’s resulting main size.
-
- let child_known_dimensions = {
- let mut ckd = child.size;
- if child.align_self == AlignSelf::Stretch && ckd.cross(constants.dir).is_none() {
- ckd.set_cross(
- constants.dir,
- available_space
- .cross(constants.dir)
- .into_option()
- .maybe_sub(constants.margin.cross_axis_sum(constants.dir)),
- );
- }
- ckd
+ // C. If the used flex basis is content or depends on its available space,
+ // and the flex container is being sized under a min-content or max-content
+ // constraint (e.g. when performing automatic table layout [CSS21]),
+ // size the item under that constraint. The flex base size is the item’s
+ // resulting main size.
+
+ // This is covered by the implementation of E below, which passes the available_space constraint
+ // through to the child size computation. It may need a separate implementation if/when D is implemented.
+
+ // D. Otherwise, if the used flex basis is content or depends on its
+ // available space, the available main size is infinite, and the flex item’s
+ // inline axis is parallel to the main axis, lay the item out using the rules
+ // for a box in an orthogonal flow [CSS3-WRITING-MODES]. The flex base size
+ // is the item’s max-content main size.
+
+ // TODO if/when vertical writing modes are supported
+
+ // E. Otherwise, size the item into the available space using its used flex basis
+ // in place of its main size, treating a value of content as max-content.
+ // If a cross size is needed to determine the main size (e.g. when the
+ // flex item’s main size is in its block axis) and the flex item’s cross size
+ // is auto and not definite, in this calculation use fit-content as the
+ // flex item’s cross size. The flex base size is the item’s resulting main size.
+
+ let child_known_dimensions = {
+ let mut ckd = child.size;
+ if child.align_self == AlignSelf::Stretch && ckd.cross(constants.dir).is_none() {
+ ckd.set_cross(
+ constants.dir,
+ available_space
+ .cross(constants.dir)
+ .into_option()
+ .maybe_sub(constants.margin.cross_axis_sum(constants.dir)),
+ );
+ }
+ ckd
+ };
+
+ break 'flex_basis GenericAlgorithm::measure_size(
+ tree,
+ child.node,
+ child_known_dimensions,
+ constants.node_inner_size,
+ available_space,
+ SizingMode::ContentSize,
+ )
+ .main(constants.dir);
};
- child.flex_basis = GenericAlgorithm::measure_size(
- tree,
- child.node,
- child_known_dimensions,
- constants.node_inner_size,
- available_space,
- SizingMode::ContentSize,
- )
- .main(constants.dir);
- }
+ // Floor flex-basis by the padding_border_sum (floors inner_flex_basis at zero)
+ // This seems to be in violation of the spec which explicitly states that the content box should not be floored at zero
+ // (like it usually is) when calculating the flex-basis. But including this matches both Chrome and Firefox's behaviour.
+ //
+ // TODO: resolve spec violation
+ // Spec: https://www.w3.org/TR/css-flexbox-1/#intrinsic-item-contributions
+ // Spec: https://www.w3.org/TR/css-flexbox-1/#change-2016-max-contribution
+ let padding_border_sum = child.padding.main_axis_sum(constants.dir) + child.border.main_axis_sum(constants.dir);
+ child.flex_basis = child.flex_basis.max(padding_border_sum);
- // The hypothetical main size is the item’s flex base size clamped according to its
- // used min and max main sizes (and flooring the content box size at zero).
+ // The hypothetical main size is the item’s flex base size clamped according to its
+ // used min and max main sizes (and flooring the content box size at zero).
- for child in flex_items {
child.inner_flex_basis =
child.flex_basis - child.padding.main_axis_sum(constants.dir) - child.border.main_axis_sum(constants.dir);
- let hypothetical_inner_min_main = child.min_size.main(constants.dir);
- child.hypothetical_inner_size.set_main(
- constants.dir,
- child.flex_basis.maybe_clamp(hypothetical_inner_min_main, child.max_size.main(constants.dir)),
- );
- child.hypothetical_outer_size.set_main(
- constants.dir,
- child.hypothetical_inner_size.main(constants.dir) + child.margin.main_axis_sum(constants.dir),
- );
+ let padding_border_axes_sums = (child.padding + child.border).sum_axes().map(Some);
+ let hypothetical_inner_min_main =
+ child.min_size.main(constants.dir).maybe_max(padding_border_axes_sums.main(constants.dir));
+ let hypothetical_inner_size =
+ child.flex_basis.maybe_clamp(hypothetical_inner_min_main, child.max_size.main(constants.dir));
+ let hypothetical_outer_size = hypothetical_inner_size + child.margin.main_axis_sum(constants.dir);
+
+ child.hypothetical_inner_size.set_main(constants.dir, hypothetical_inner_size);
+ child.hypothetical_outer_size.set_main(constants.dir, hypothetical_outer_size);
let min_content_size = GenericAlgorithm::measure_size(
tree,
@@ -709,7 +718,8 @@ fn determine_flex_base_size(
// 4.5. Automatic Minimum Size of Flex Items
// https://www.w3.org/TR/css-flexbox-1/#min-size-auto
let clamped_min_content_size = min_content_size.maybe_min(child.size).maybe_min(child.max_size);
- child.resolved_minimum_size = child.min_size.unwrap_or(clamped_min_content_size);
+ child.resolved_minimum_size =
+ child.min_size.unwrap_or(clamped_min_content_size).maybe_max(padding_border_axes_sums);
}
}
@@ -810,7 +820,10 @@ fn determine_container_main_size(
let total_target_size = line
.items
.iter()
- .map(|child| child.flex_basis + child.margin.main_axis_sum(constants.dir))
+ .map(|child| {
+ let padding_border_sum = (child.padding + child.border).main_axis_sum(constants.dir);
+ (child.flex_basis + child.margin.main_axis_sum(constants.dir)).max(padding_border_sum)
+ })
.sum::();
total_target_size + line_main_axis_gap
})
@@ -831,7 +844,10 @@ fn determine_container_main_size(
let total_target_size = line
.items
.iter()
- .map(|child| child.flex_basis + child.margin.main_axis_sum(constants.dir))
+ .map(|child| {
+ let padding_border_sum = (child.padding + child.border).main_axis_sum(constants.dir);
+ (child.flex_basis + child.margin.main_axis_sum(constants.dir)).max(padding_border_sum)
+ })
.sum::();
total_target_size + line_main_axis_gap
})
@@ -850,23 +866,39 @@ fn determine_container_main_size(
let style_min = item.min_size.main(constants.dir);
let style_preferred = item.size.main(constants.dir);
let style_max = item.max_size.main(constants.dir);
- let flex_basis_min = Some(item.flex_basis).filter(|_| item.flex_shrink == 0.0);
- let flex_basis_max = Some(item.flex_basis).filter(|_| item.flex_grow == 0.0);
- let min_main_size = style_min.maybe_max(flex_basis_min).or(flex_basis_min);
- let max_main_size = style_max.maybe_min(flex_basis_max).or(flex_basis_max);
+
+ // The spec seems a bit unclear on this point (my initial reading was that the `.maybe_max(style_preferred)` should
+ // not be included here), however this matches both Chrome and Firefox as of 9th March 2023.
+ //
+ // Spec: https://www.w3.org/TR/css-flexbox-1/#intrinsic-item-contributions
+ // Spec modifcation: https://www.w3.org/TR/css-flexbox-1/#change-2016-max-contribution
+ // Issue: https://github.com/w3c/csswg-drafts/issues/1435
+ // Gentest: padding_border_overrides_size_flex_basis_0.html
+ let clamping_basis = Some(item.flex_basis).maybe_max(style_preferred);
+ let flex_basis_min = clamping_basis.filter(|_| item.flex_shrink == 0.0);
+ let flex_basis_max = clamping_basis.filter(|_| item.flex_grow == 0.0);
+
+ let resolved_min = item.resolved_minimum_size.main(constants.dir);
+ let min_main_size = style_min
+ .maybe_max(flex_basis_min)
+ .or(flex_basis_min)
+ .unwrap_or(resolved_min)
+ .max(resolved_min);
+ let max_main_size =
+ style_max.maybe_min(flex_basis_max).or(flex_basis_max).unwrap_or(f32::INFINITY);
let content_contribution = match (min_main_size, style_preferred, max_main_size) {
// If the clamping values are such that max <= min, then we can avoid the expensive step of computing the content size
// as we know that the clamping values will override it anyway
- (Some(min), Some(pref), Some(max)) if max <= min || max <= pref => {
+ (min, Some(pref), max) if max <= min || max <= pref => {
pref.min(max).max(min) + item.margin.main_axis_sum(constants.dir)
}
- (Some(min), _, Some(max)) if max <= min => min + item.margin.main_axis_sum(constants.dir),
- (_, Some(pref), Some(max)) if max <= pref => max + item.margin.main_axis_sum(constants.dir),
+ (min, _, max) if max <= min => min + item.margin.main_axis_sum(constants.dir),
// Else compute the min- or -max content size and apply the full formula for computing the
// min- or max- content contributuon
_ => {
// Either the min- or max- content size depending on which constraint we are sizing under.
+ // TODO: Optimise by using already computed values where available
let content_main_size = GenericAlgorithm::measure_size(
tree,
item.node,
@@ -891,9 +923,14 @@ fn determine_container_main_size(
// Ultimately, this was not found by reading the spec, but by trial and error fixing tests to align with Webkit/Firefox output.
// (see the `flex_basis_unconstraint_row` and `flex_basis_uncontraint_column` generated tests which demonstrate this)
if constants.is_row {
- content_main_size.maybe_clamp(style_min, style_max)
+ content_main_size
+ .maybe_clamp(style_min, style_max)
+ .max(constants.padding_border.main_axis_sum(constants.dir))
} else {
- content_main_size.max(item.flex_basis).maybe_clamp(style_min, style_max)
+ content_main_size
+ .max(item.flex_basis)
+ .maybe_clamp(style_min, style_max)
+ .max(constants.padding_border.main_axis_sum(constants.dir))
}
}
};
@@ -902,8 +939,7 @@ fn determine_container_main_size(
if diff > 0.0 {
diff / f32_max(1.0, item.flex_grow)
} else if diff < 0.0 {
- let scaled_shrink_factor = f32_max(1.0, item.flex_shrink) * item.inner_flex_basis;
- // let scaled_shrink_factor - f32_max(1.0, item.flex_shrink * item.inner_flex_basis);
+ let scaled_shrink_factor = f32_max(1.0, item.flex_shrink * item.inner_flex_basis);
diff / scaled_shrink_factor
} else {
// We are assuming that diff is 0.0 here and that we haven't accidentally introduced a NaN
@@ -1163,13 +1199,15 @@ fn determine_hypothetical_cross_size(
available_space: Size,
) {
for child in line.items.iter_mut() {
+ let padding_border_sum = (child.padding + child.border).cross_axis_sum(constants.dir);
+
let child_cross = child
.size
.cross(constants.dir)
- .maybe_clamp(child.min_size.cross(constants.dir), child.max_size.cross(constants.dir));
+ .maybe_clamp(child.min_size.cross(constants.dir), child.max_size.cross(constants.dir))
+ .maybe_max(padding_border_sum);
- child.hypothetical_inner_size.set_cross(
- constants.dir,
+ let child_inner_cross = child_cross.unwrap_or_else(|| {
GenericAlgorithm::measure_size(
tree,
child.node,
@@ -1193,13 +1231,13 @@ fn determine_hypothetical_cross_size(
SizingMode::ContentSize,
)
.cross(constants.dir)
- .maybe_clamp(child.min_size.cross(constants.dir), child.max_size.cross(constants.dir)),
- );
+ .maybe_clamp(child.min_size.cross(constants.dir), child.max_size.cross(constants.dir))
+ .max(padding_border_sum)
+ });
+ let child_outer_cross = child_inner_cross + child.margin.cross_axis_sum(constants.dir);
- child.hypothetical_outer_size.set_cross(
- constants.dir,
- child.hypothetical_inner_size.cross(constants.dir) + child.margin.cross_axis_sum(constants.dir),
- );
+ child.hypothetical_inner_size.set_cross(constants.dir, child_inner_cross);
+ child.hypothetical_outer_size.set_cross(constants.dir, child_outer_cross);
}
}
@@ -1601,17 +1639,15 @@ fn determine_container_cross_size(
let total_cross_axis_gap = sum_axis_gaps(constants.gap.cross(constants.dir), flex_lines.len());
let total_line_cross_size: f32 = flex_lines.iter().map(|line| line.cross_size).sum::();
- constants.container_size.set_cross(
- constants.dir,
- node_size.cross(constants.dir).unwrap_or(
- total_line_cross_size + total_cross_axis_gap + constants.padding_border.cross_axis_sum(constants.dir),
- ),
- );
+ let padding_border_sum = constants.padding_border.cross_axis_sum(constants.dir);
+ let outer_container_size = node_size
+ .cross(constants.dir)
+ .unwrap_or(total_line_cross_size + total_cross_axis_gap + padding_border_sum)
+ .max(padding_border_sum);
+ let inner_container_size = outer_container_size - padding_border_sum;
- constants.inner_container_size.set_cross(
- constants.dir,
- constants.container_size.cross(constants.dir) - constants.padding_border.cross_axis_sum(constants.dir),
- );
+ constants.container_size.set_cross(constants.dir, outer_container_size);
+ constants.inner_container_size.set_cross(constants.dir, inner_container_size);
total_line_cross_size
}
@@ -1797,8 +1833,11 @@ fn perform_absolute_layout_on_absolute_children(tree: &mut impl LayoutTree, node
}
let aspect_ratio = child_style.aspect_ratio;
- let margin = child_style.margin.map(|margin| margin.resolve_to_option(container_width));
let align_self = child_style.align_self.unwrap_or(constants.align_items);
+ let margin = child_style.margin.map(|margin| margin.resolve_to_option(container_width));
+ let padding = child_style.padding.resolve_or_zero(Some(container_width));
+ let border = child_style.border.resolve_or_zero(Some(container_width));
+ let padding_border_sum = (padding + border).sum_axes();
// Resolve inset
let left = child_style.inset.left.maybe_resolve(container_width);
@@ -1809,8 +1848,12 @@ fn perform_absolute_layout_on_absolute_children(tree: &mut impl LayoutTree, node
// Compute known dimensions from min/max/inherent size styles
let style_size =
child_style.size.maybe_resolve(constants.container_size).maybe_apply_aspect_ratio(aspect_ratio);
- let min_size =
- child_style.min_size.maybe_resolve(constants.container_size).maybe_apply_aspect_ratio(aspect_ratio);
+ let min_size = child_style
+ .min_size
+ .maybe_resolve(constants.container_size)
+ .maybe_apply_aspect_ratio(aspect_ratio)
+ .or(padding_border_sum.map(Some))
+ .maybe_max(padding_border_sum);
let max_size =
child_style.max_size.maybe_resolve(constants.container_size).maybe_apply_aspect_ratio(aspect_ratio);
let mut known_dimensions = style_size.maybe_clamp(min_size, max_size);
diff --git a/src/compute/grid/alignment.rs b/src/compute/grid/alignment.rs
index 0c0ed9f81..0b85fb792 100644
--- a/src/compute/grid/alignment.rs
+++ b/src/compute/grid/alignment.rs
@@ -7,7 +7,7 @@ use crate::geometry::{Line, Point, Rect, Size};
use crate::layout::{Layout, SizingMode};
use crate::math::MaybeMath;
use crate::node::Node;
-use crate::resolve::MaybeResolve;
+use crate::resolve::{MaybeResolve, ResolveOrZero};
use crate::style::{AlignContent, AlignItems, AlignSelf, AvailableSpace, Position};
use crate::sys::{f32_max, f32_min};
use crate::tree::LayoutTree;
@@ -90,8 +90,16 @@ pub(super) fn align_and_position_item(
let position = style.position;
let inset_horizontal = style.inset.horizontal_components().map(|size| size.resolve_to_option(grid_area_size.width));
let inset_vertical = style.inset.vertical_components().map(|size| size.resolve_to_option(grid_area_size.height));
+ let padding = style.padding.map(|p| p.resolve_or_zero(Some(grid_area_size.width)));
+ let border = style.border.map(|p| p.resolve_or_zero(Some(grid_area_size.width)));
+ let padding_border_size = (padding + border).sum_axes();
let inherent_size = style.size.maybe_resolve(grid_area_size).maybe_apply_aspect_ratio(aspect_ratio);
- let min_size = style.min_size.maybe_resolve(grid_area_size).maybe_apply_aspect_ratio(aspect_ratio);
+ let min_size = style
+ .min_size
+ .maybe_resolve(grid_area_size)
+ .or(padding_border_size.map(Some))
+ .maybe_max(padding_border_size)
+ .maybe_apply_aspect_ratio(aspect_ratio);
let max_size = style.max_size.maybe_resolve(grid_area_size).maybe_apply_aspect_ratio(aspect_ratio);
// Resolve default alignment styles if they are set on neither the parent or the node itself
@@ -149,6 +157,7 @@ pub(super) fn align_and_position_item(
None
});
+
// Reapply aspect ratio after stretch and absolute position width adjustments
let Size { width, height } = Size { width, height: inherent_size.height }.maybe_apply_aspect_ratio(aspect_ratio);
diff --git a/src/compute/grid/mod.rs b/src/compute/grid/mod.rs
index 10d360068..09a91eb09 100644
--- a/src/compute/grid/mod.rs
+++ b/src/compute/grid/mod.rs
@@ -141,6 +141,7 @@ pub fn compute(
// https://www.w3.org/TR/css-grid-1/#available-grid-space
let padding = style.padding.resolve_or_zero(parent_size.width);
let border = style.border.resolve_or_zero(parent_size.width);
+ let padding_border_size = (padding + border).sum_axes();
let aspect_ratio = style.aspect_ratio;
let min_size = style.min_size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio);
let max_size = style.max_size.maybe_resolve(parent_size).maybe_apply_aspect_ratio(aspect_ratio);
@@ -236,10 +237,12 @@ pub fn compute(
let container_border_box = Size {
width: resolved_style_size
.get(AbstractAxis::Inline)
- .unwrap_or_else(|| initial_column_sum + padding.horizontal_axis_sum() + border.horizontal_axis_sum()),
+ .unwrap_or_else(|| initial_column_sum + padding.horizontal_axis_sum() + border.horizontal_axis_sum())
+ .max(padding_border_size.width),
height: resolved_style_size
.get(AbstractAxis::Block)
- .unwrap_or_else(|| initial_row_sum + padding.vertical_axis_sum() + border.vertical_axis_sum()),
+ .unwrap_or_else(|| initial_row_sum + padding.vertical_axis_sum() + border.vertical_axis_sum())
+ .max(padding_border_size.height),
};
let container_content_box = Size {
width: container_border_box.width - padding.horizontal_axis_sum() - border.horizontal_axis_sum(),
diff --git a/src/compute/leaf.rs b/src/compute/leaf.rs
index 2c347a64d..6f95145db 100644
--- a/src/compute/leaf.rs
+++ b/src/compute/leaf.rs
@@ -72,6 +72,12 @@ pub(crate) fn compute(
}
};
+ // Note: both horizontal and vertical percentage padding/borders are resolved against the container's inline size (i.e. width).
+ // This is not a bug, but is how CSS is specified (see: https://developer.mozilla.org/en-US/docs/Web/CSS/padding#values)
+ let padding = style.padding.resolve_or_zero(parent_size.width);
+ let border = style.border.resolve_or_zero(parent_size.width);
+ let padding_border = padding + border;
+
#[cfg(feature = "debug")]
NODE_LOGGER.log("LEAF");
#[cfg(feature = "debug")]
@@ -83,7 +89,9 @@ pub(crate) fn compute(
// Return early if both width and height are known
if let Size { width: Some(width), height: Some(height) } = node_size {
- let size = Size { width, height }.maybe_clamp(node_min_size, node_max_size);
+ let size = Size { width, height }
+ .maybe_clamp(node_min_size, node_max_size)
+ .maybe_max(padding_border.sum_axes().map(Some));
return SizeAndBaselines { size, first_baselines: Point::NONE };
};
@@ -111,25 +119,29 @@ pub(crate) fn compute(
};
let size = node_size.unwrap_or(measured_size).maybe_clamp(node_min_size, node_max_size);
+ let size = size.maybe_max(padding_border.sum_axes().map(Some));
return SizeAndBaselines { size, first_baselines: Point::NONE };
}
- // Note: both horizontal and vertical percentage padding/borders are resolved against the container's inline size (i.e. width).
- // This is not a bug, but is how CSS is specified (see: https://developer.mozilla.org/en-US/docs/Web/CSS/padding#values)
- let padding = style.padding.resolve_or_zero(parent_size.width);
- let border = style.border.resolve_or_zero(parent_size.width);
-
let size = Size {
width: node_size
.width
// .unwrap_or(0.0) + padding.horizontal_axis_sum() + border.horizontal_axis_sum(), // content-box
- .unwrap_or(0.0 + padding.horizontal_axis_sum() + border.horizontal_axis_sum()) // border-box
- .maybe_clamp(node_min_size.width, node_max_size.width),
+ .unwrap_or(0.0) // border-box
+ .maybe_clamp(node_min_size.width, node_max_size.width)
+ .maybe_max(padding_border.horizontal_axis_sum().into()),
height: node_size
.height
// .unwrap_or(0.0) + padding.vertical_axis_sum() + border.vertical_axis_sum(), // content-box
- .unwrap_or(0.0 + padding.vertical_axis_sum() + border.vertical_axis_sum()) // border-box
- .maybe_clamp(node_min_size.height, node_max_size.height),
+ .unwrap_or(0.0) // border-box
+ .maybe_clamp(node_min_size.height, node_max_size.height)
+ .maybe_max(padding_border.vertical_axis_sum().into()),
};
+
+ let size = Size {
+ width: f32_max(size.width, aspect_ratio.map(|ratio| size.height * ratio).unwrap_or(0.0)),
+ height: f32_max(size.height, aspect_ratio.map(|ratio| size.width / ratio).unwrap_or(0.0)),
+ };
+
SizeAndBaselines { size, first_baselines: Point::NONE }
}
diff --git a/test_fixtures/absolute_padding_border_overrides_max_size.html b/test_fixtures/absolute_padding_border_overrides_max_size.html
new file mode 100644
index 000000000..04f16a34a
--- /dev/null
+++ b/test_fixtures/absolute_padding_border_overrides_max_size.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/absolute_padding_border_overrides_size.html b/test_fixtures/absolute_padding_border_overrides_size.html
new file mode 100644
index 000000000..6cbc088af
--- /dev/null
+++ b/test_fixtures/absolute_padding_border_overrides_size.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/grid_padding_border_overrides_container_max_size.html b/test_fixtures/grid_padding_border_overrides_container_max_size.html
new file mode 100644
index 000000000..a58489fca
--- /dev/null
+++ b/test_fixtures/grid_padding_border_overrides_container_max_size.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/grid_padding_border_overrides_container_size.html b/test_fixtures/grid_padding_border_overrides_container_size.html
new file mode 100644
index 000000000..a5cab4eed
--- /dev/null
+++ b/test_fixtures/grid_padding_border_overrides_container_size.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/grid_padding_border_overrides_max_size.html b/test_fixtures/grid_padding_border_overrides_max_size.html
new file mode 100644
index 000000000..41ec1e05d
--- /dev/null
+++ b/test_fixtures/grid_padding_border_overrides_max_size.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/grid_padding_border_overrides_min_size.html b/test_fixtures/grid_padding_border_overrides_min_size.html
new file mode 100644
index 000000000..629e26a33
--- /dev/null
+++ b/test_fixtures/grid_padding_border_overrides_min_size.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/grid_padding_border_overrides_size.html b/test_fixtures/grid_padding_border_overrides_size.html
new file mode 100644
index 000000000..4612b1b38
--- /dev/null
+++ b/test_fixtures/grid_padding_border_overrides_size.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/leaf_padding_border_overrides_max_size.html b/test_fixtures/leaf_padding_border_overrides_max_size.html
new file mode 100644
index 000000000..99f440a8b
--- /dev/null
+++ b/test_fixtures/leaf_padding_border_overrides_max_size.html
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/leaf_padding_border_overrides_min_size.html b/test_fixtures/leaf_padding_border_overrides_min_size.html
new file mode 100644
index 000000000..0482e8258
--- /dev/null
+++ b/test_fixtures/leaf_padding_border_overrides_min_size.html
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/leaf_padding_border_overrides_size.html b/test_fixtures/leaf_padding_border_overrides_size.html
new file mode 100644
index 000000000..8aa54d19e
--- /dev/null
+++ b/test_fixtures/leaf_padding_border_overrides_size.html
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/padding_border_overrides_max_size.html b/test_fixtures/padding_border_overrides_max_size.html
new file mode 100644
index 000000000..6d0bf7cf1
--- /dev/null
+++ b/test_fixtures/padding_border_overrides_max_size.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/padding_border_overrides_min_size.html b/test_fixtures/padding_border_overrides_min_size.html
new file mode 100644
index 000000000..d8223127a
--- /dev/null
+++ b/test_fixtures/padding_border_overrides_min_size.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/padding_border_overrides_size.html b/test_fixtures/padding_border_overrides_size.html
new file mode 100644
index 000000000..7b2ed62d2
--- /dev/null
+++ b/test_fixtures/padding_border_overrides_size.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/padding_border_overrides_size_flex_basis_0.html b/test_fixtures/padding_border_overrides_size_flex_basis_0.html
new file mode 100644
index 000000000..d51e820ce
--- /dev/null
+++ b/test_fixtures/padding_border_overrides_size_flex_basis_0.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/test_fixtures/padding_border_overrides_size_flex_basis_0_growable.html b/test_fixtures/padding_border_overrides_size_flex_basis_0_growable.html
new file mode 100644
index 000000000..0b2ff0552
--- /dev/null
+++ b/test_fixtures/padding_border_overrides_size_flex_basis_0_growable.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+ Test description
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/border_and_padding.rs b/tests/border_and_padding.rs
index 26cfd1a1f..17a51914f 100644
--- a/tests/border_and_padding.rs
+++ b/tests/border_and_padding.rs
@@ -6,6 +6,7 @@ fn arr_to_rect(items: [T; 4]) -> Rect {
}
#[test]
+#[ignore]
fn border_on_a_single_axis_doesnt_increase_size() {
for i in 0..4 {
let mut taffy = Taffy::new();
@@ -33,6 +34,7 @@ fn border_on_a_single_axis_doesnt_increase_size() {
}
#[test]
+#[ignore]
fn padding_on_a_single_axis_doesnt_increase_size() {
for i in 0..4 {
let mut taffy = Taffy::new();
@@ -60,6 +62,7 @@ fn padding_on_a_single_axis_doesnt_increase_size() {
}
#[test]
+#[ignore]
fn border_and_padding_on_a_single_axis_doesnt_increase_size() {
for i in 0..4 {
let mut taffy = Taffy::new();
@@ -82,6 +85,7 @@ fn border_and_padding_on_a_single_axis_doesnt_increase_size() {
}
#[test]
+#[ignore]
fn vertical_border_and_padding_percentage_values_use_available_space_correctly() {
let mut taffy = Taffy::new();
diff --git a/tests/generated/absolute_padding_border_overrides_max_size.rs b/tests/generated/absolute_padding_border_overrides_max_size.rs
new file mode 100644
index 000000000..b90bda2da
--- /dev/null
+++ b/tests/generated/absolute_padding_border_overrides_max_size.rs
@@ -0,0 +1,44 @@
+#[test]
+fn absolute_padding_border_overrides_max_size() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ position: taffy::style::Position::Absolute,
+ max_size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(12f32),
+ height: taffy::style::Dimension::Points(12f32),
+ },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(8f32),
+ right: taffy::style::LengthPercentage::Points(4f32),
+ top: taffy::style::LengthPercentage::Points(2f32),
+ bottom: taffy::style::LengthPercentage::Points(6f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(7f32),
+ right: taffy::style::LengthPercentage::Points(3f32),
+ top: taffy::style::LengthPercentage::Points(1f32),
+ bottom: taffy::style::LengthPercentage::Points(5f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 0f32, size.width);
+ assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 0f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+}
diff --git a/tests/generated/absolute_padding_border_overrides_size.rs b/tests/generated/absolute_padding_border_overrides_size.rs
new file mode 100644
index 000000000..f4303f2d8
--- /dev/null
+++ b/tests/generated/absolute_padding_border_overrides_size.rs
@@ -0,0 +1,44 @@
+#[test]
+fn absolute_padding_border_overrides_size() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ position: taffy::style::Position::Absolute,
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(12f32),
+ height: taffy::style::Dimension::Points(12f32),
+ },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(8f32),
+ right: taffy::style::LengthPercentage::Points(4f32),
+ top: taffy::style::LengthPercentage::Points(2f32),
+ bottom: taffy::style::LengthPercentage::Points(6f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(7f32),
+ right: taffy::style::LengthPercentage::Points(3f32),
+ top: taffy::style::LengthPercentage::Points(1f32),
+ bottom: taffy::style::LengthPercentage::Points(5f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 0f32, size.width);
+ assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 0f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+}
diff --git a/tests/generated/grid_padding_border_overrides_container_max_size.rs b/tests/generated/grid_padding_border_overrides_container_max_size.rs
new file mode 100644
index 000000000..62ae9ebbe
--- /dev/null
+++ b/tests/generated/grid_padding_border_overrides_container_max_size.rs
@@ -0,0 +1,47 @@
+#[test]
+fn grid_padding_border_overrides_container_max_size() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Grid,
+ max_size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(12f32),
+ height: taffy::style::Dimension::Points(12f32),
+ },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(8f32),
+ right: taffy::style::LengthPercentage::Points(4f32),
+ top: taffy::style::LengthPercentage::Points(2f32),
+ bottom: taffy::style::LengthPercentage::Points(6f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(7f32),
+ right: taffy::style::LengthPercentage::Points(3f32),
+ top: taffy::style::LengthPercentage::Points(1f32),
+ bottom: taffy::style::LengthPercentage::Points(5f32),
+ },
+ ..Default::default()
+ },
+ &[node0],
+ )
+ .unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, size.width);
+ assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, size.height);
+ assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 15f32, location.x);
+ assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 3f32, location.y);
+}
diff --git a/tests/generated/grid_padding_border_overrides_container_size.rs b/tests/generated/grid_padding_border_overrides_container_size.rs
new file mode 100644
index 000000000..f60ea6885
--- /dev/null
+++ b/tests/generated/grid_padding_border_overrides_container_size.rs
@@ -0,0 +1,47 @@
+#[test]
+fn grid_padding_border_overrides_container_size() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
+ let node = taffy
+ .new_with_children(
+ taffy::style::Style {
+ display: taffy::style::Display::Grid,
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(12f32),
+ height: taffy::style::Dimension::Points(12f32),
+ },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(8f32),
+ right: taffy::style::LengthPercentage::Points(4f32),
+ top: taffy::style::LengthPercentage::Points(2f32),
+ bottom: taffy::style::LengthPercentage::Points(6f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(7f32),
+ right: taffy::style::LengthPercentage::Points(3f32),
+ top: taffy::style::LengthPercentage::Points(1f32),
+ bottom: taffy::style::LengthPercentage::Points(5f32),
+ },
+ ..Default::default()
+ },
+ &[node0],
+ )
+ .unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, size.width);
+ assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, size.height);
+ assert_eq!(location.x, 15f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 15f32, location.x);
+ assert_eq!(location.y, 3f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 3f32, location.y);
+}
diff --git a/tests/generated/grid_padding_border_overrides_max_size.rs b/tests/generated/grid_padding_border_overrides_max_size.rs
new file mode 100644
index 000000000..2a874008c
--- /dev/null
+++ b/tests/generated/grid_padding_border_overrides_max_size.rs
@@ -0,0 +1,45 @@
+#[test]
+fn grid_padding_border_overrides_max_size() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ max_size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(12f32),
+ height: taffy::style::Dimension::Points(12f32),
+ },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(8f32),
+ right: taffy::style::LengthPercentage::Points(4f32),
+ top: taffy::style::LengthPercentage::Points(2f32),
+ bottom: taffy::style::LengthPercentage::Points(6f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(7f32),
+ right: taffy::style::LengthPercentage::Points(3f32),
+ top: taffy::style::LengthPercentage::Points(1f32),
+ bottom: taffy::style::LengthPercentage::Points(5f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy
+ .new_with_children(taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, &[node0])
+ .unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+}
diff --git a/tests/generated/grid_padding_border_overrides_min_size.rs b/tests/generated/grid_padding_border_overrides_min_size.rs
new file mode 100644
index 000000000..16ca50031
--- /dev/null
+++ b/tests/generated/grid_padding_border_overrides_min_size.rs
@@ -0,0 +1,45 @@
+#[test]
+fn grid_padding_border_overrides_min_size() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ min_size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(0f32),
+ height: taffy::style::Dimension::Points(0f32),
+ },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(8f32),
+ right: taffy::style::LengthPercentage::Points(4f32),
+ top: taffy::style::LengthPercentage::Points(2f32),
+ bottom: taffy::style::LengthPercentage::Points(6f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(7f32),
+ right: taffy::style::LengthPercentage::Points(3f32),
+ top: taffy::style::LengthPercentage::Points(1f32),
+ bottom: taffy::style::LengthPercentage::Points(5f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy
+ .new_with_children(taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, &[node0])
+ .unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+}
diff --git a/tests/generated/grid_padding_border_overrides_size.rs b/tests/generated/grid_padding_border_overrides_size.rs
new file mode 100644
index 000000000..e2a5162b5
--- /dev/null
+++ b/tests/generated/grid_padding_border_overrides_size.rs
@@ -0,0 +1,45 @@
+#[test]
+fn grid_padding_border_overrides_size() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(12f32),
+ height: taffy::style::Dimension::Points(12f32),
+ },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(8f32),
+ right: taffy::style::LengthPercentage::Points(4f32),
+ top: taffy::style::LengthPercentage::Points(2f32),
+ bottom: taffy::style::LengthPercentage::Points(6f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(7f32),
+ right: taffy::style::LengthPercentage::Points(3f32),
+ top: taffy::style::LengthPercentage::Points(1f32),
+ bottom: taffy::style::LengthPercentage::Points(5f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy
+ .new_with_children(taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() }, &[node0])
+ .unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+}
diff --git a/tests/generated/leaf_padding_border_overrides_max_size.rs b/tests/generated/leaf_padding_border_overrides_max_size.rs
new file mode 100644
index 000000000..3f61a2b56
--- /dev/null
+++ b/tests/generated/leaf_padding_border_overrides_max_size.rs
@@ -0,0 +1,37 @@
+#[test]
+fn leaf_padding_border_overrides_max_size() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node = taffy
+ .new_leaf(taffy::style::Style {
+ max_size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(12f32),
+ height: taffy::style::Dimension::Points(12f32),
+ },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(8f32),
+ right: taffy::style::LengthPercentage::Points(4f32),
+ top: taffy::style::LengthPercentage::Points(2f32),
+ bottom: taffy::style::LengthPercentage::Points(6f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(7f32),
+ right: taffy::style::LengthPercentage::Points(3f32),
+ top: taffy::style::LengthPercentage::Points(1f32),
+ bottom: taffy::style::LengthPercentage::Points(5f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+}
diff --git a/tests/generated/leaf_padding_border_overrides_min_size.rs b/tests/generated/leaf_padding_border_overrides_min_size.rs
new file mode 100644
index 000000000..44323f5bb
--- /dev/null
+++ b/tests/generated/leaf_padding_border_overrides_min_size.rs
@@ -0,0 +1,37 @@
+#[test]
+fn leaf_padding_border_overrides_min_size() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node = taffy
+ .new_leaf(taffy::style::Style {
+ min_size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(0f32),
+ height: taffy::style::Dimension::Points(0f32),
+ },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(8f32),
+ right: taffy::style::LengthPercentage::Points(4f32),
+ top: taffy::style::LengthPercentage::Points(2f32),
+ bottom: taffy::style::LengthPercentage::Points(6f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(7f32),
+ right: taffy::style::LengthPercentage::Points(3f32),
+ top: taffy::style::LengthPercentage::Points(1f32),
+ bottom: taffy::style::LengthPercentage::Points(5f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+}
diff --git a/tests/generated/leaf_padding_border_overrides_size.rs b/tests/generated/leaf_padding_border_overrides_size.rs
new file mode 100644
index 000000000..631c85b54
--- /dev/null
+++ b/tests/generated/leaf_padding_border_overrides_size.rs
@@ -0,0 +1,37 @@
+#[test]
+fn leaf_padding_border_overrides_size() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(12f32),
+ height: taffy::style::Dimension::Points(12f32),
+ },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(8f32),
+ right: taffy::style::LengthPercentage::Points(4f32),
+ top: taffy::style::LengthPercentage::Points(2f32),
+ bottom: taffy::style::LengthPercentage::Points(6f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(7f32),
+ right: taffy::style::LengthPercentage::Points(3f32),
+ top: taffy::style::LengthPercentage::Points(1f32),
+ bottom: taffy::style::LengthPercentage::Points(5f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+}
diff --git a/tests/generated/mod.rs b/tests/generated/mod.rs
index 8a7799d86..42631bc44 100644
--- a/tests/generated/mod.rs
+++ b/tests/generated/mod.rs
@@ -104,6 +104,8 @@ mod absolute_minmax_bottom_right_min_max;
mod absolute_minmax_bottom_right_min_max_preferred;
mod absolute_minmax_top_left_bottom_right_max;
mod absolute_minmax_top_left_bottom_right_min_max;
+mod absolute_padding_border_overrides_max_size;
+mod absolute_padding_border_overrides_size;
mod align_baseline;
mod align_baseline_child;
mod align_baseline_child_margin;
@@ -646,6 +648,16 @@ mod grid_out_of_order_items;
#[cfg(feature = "grid")]
mod grid_overflow_rows;
#[cfg(feature = "grid")]
+mod grid_padding_border_overrides_container_max_size;
+#[cfg(feature = "grid")]
+mod grid_padding_border_overrides_container_size;
+#[cfg(feature = "grid")]
+mod grid_padding_border_overrides_max_size;
+#[cfg(feature = "grid")]
+mod grid_padding_border_overrides_min_size;
+#[cfg(feature = "grid")]
+mod grid_padding_border_overrides_size;
+#[cfg(feature = "grid")]
mod grid_percent_item_inside_stretch_item;
#[cfg(feature = "grid")]
mod grid_percent_items_nested_inside_stretch_alignment;
@@ -750,6 +762,9 @@ mod justify_content_row_min_width_and_margin;
mod justify_content_row_space_around;
mod justify_content_row_space_between;
mod justify_content_row_space_evenly;
+mod leaf_padding_border_overrides_max_size;
+mod leaf_padding_border_overrides_min_size;
+mod leaf_padding_border_overrides_size;
mod margin_and_flex_column;
mod margin_and_flex_row;
mod margin_and_stretch_column;
@@ -820,6 +835,11 @@ mod only_shrinkable_item_with_flex_basis_zero;
mod overflow_cross_axis;
mod overflow_main_axis;
mod padding_align_end_child;
+mod padding_border_overrides_max_size;
+mod padding_border_overrides_min_size;
+mod padding_border_overrides_size;
+mod padding_border_overrides_size_flex_basis_0;
+mod padding_border_overrides_size_flex_basis_0_growable;
mod padding_center_child;
mod padding_container_match_child;
mod padding_flex_child;
diff --git a/tests/generated/padding_border_overrides_max_size.rs b/tests/generated/padding_border_overrides_max_size.rs
new file mode 100644
index 000000000..205073386
--- /dev/null
+++ b/tests/generated/padding_border_overrides_max_size.rs
@@ -0,0 +1,43 @@
+#[test]
+fn padding_border_overrides_max_size() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ max_size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(12f32),
+ height: taffy::style::Dimension::Points(12f32),
+ },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(8f32),
+ right: taffy::style::LengthPercentage::Points(4f32),
+ top: taffy::style::LengthPercentage::Points(2f32),
+ bottom: taffy::style::LengthPercentage::Points(6f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(7f32),
+ right: taffy::style::LengthPercentage::Points(3f32),
+ top: taffy::style::LengthPercentage::Points(1f32),
+ bottom: taffy::style::LengthPercentage::Points(5f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+}
diff --git a/tests/generated/padding_border_overrides_min_size.rs b/tests/generated/padding_border_overrides_min_size.rs
new file mode 100644
index 000000000..6b59e23db
--- /dev/null
+++ b/tests/generated/padding_border_overrides_min_size.rs
@@ -0,0 +1,43 @@
+#[test]
+fn padding_border_overrides_min_size() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ min_size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(0f32),
+ height: taffy::style::Dimension::Points(0f32),
+ },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(8f32),
+ right: taffy::style::LengthPercentage::Points(4f32),
+ top: taffy::style::LengthPercentage::Points(2f32),
+ bottom: taffy::style::LengthPercentage::Points(6f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(7f32),
+ right: taffy::style::LengthPercentage::Points(3f32),
+ top: taffy::style::LengthPercentage::Points(1f32),
+ bottom: taffy::style::LengthPercentage::Points(5f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+}
diff --git a/tests/generated/padding_border_overrides_size.rs b/tests/generated/padding_border_overrides_size.rs
new file mode 100644
index 000000000..627b3e968
--- /dev/null
+++ b/tests/generated/padding_border_overrides_size.rs
@@ -0,0 +1,43 @@
+#[test]
+fn padding_border_overrides_size() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(12f32),
+ height: taffy::style::Dimension::Points(12f32),
+ },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(8f32),
+ right: taffy::style::LengthPercentage::Points(4f32),
+ top: taffy::style::LengthPercentage::Points(2f32),
+ bottom: taffy::style::LengthPercentage::Points(6f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(7f32),
+ right: taffy::style::LengthPercentage::Points(3f32),
+ top: taffy::style::LengthPercentage::Points(1f32),
+ bottom: taffy::style::LengthPercentage::Points(5f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+}
diff --git a/tests/generated/padding_border_overrides_size_flex_basis_0.rs b/tests/generated/padding_border_overrides_size_flex_basis_0.rs
new file mode 100644
index 000000000..4df1dc66c
--- /dev/null
+++ b/tests/generated/padding_border_overrides_size_flex_basis_0.rs
@@ -0,0 +1,59 @@
+#[test]
+fn padding_border_overrides_size_flex_basis_0() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ flex_basis: taffy::style::Dimension::Points(0f32),
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(12f32),
+ height: taffy::style::Dimension::Points(12f32),
+ },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(8f32),
+ right: taffy::style::LengthPercentage::Points(4f32),
+ top: taffy::style::LengthPercentage::Points(2f32),
+ bottom: taffy::style::LengthPercentage::Points(6f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(7f32),
+ right: taffy::style::LengthPercentage::Points(3f32),
+ top: taffy::style::LengthPercentage::Points(1f32),
+ bottom: taffy::style::LengthPercentage::Points(5f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node1 = taffy
+ .new_leaf(taffy::style::Style {
+ flex_basis: taffy::style::Dimension::Points(0f32),
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(12f32),
+ height: taffy::style::Dimension::Points(12f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]).unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 34f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 22f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 22f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node1).unwrap();
+ assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, size.width);
+ assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 12f32, size.height);
+ assert_eq!(location.x, 22f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 22f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
+}
diff --git a/tests/generated/padding_border_overrides_size_flex_basis_0_growable.rs b/tests/generated/padding_border_overrides_size_flex_basis_0_growable.rs
new file mode 100644
index 000000000..5a1b4fadf
--- /dev/null
+++ b/tests/generated/padding_border_overrides_size_flex_basis_0_growable.rs
@@ -0,0 +1,61 @@
+#[test]
+fn padding_border_overrides_size_flex_basis_0_growable() {
+ use slotmap::Key;
+ #[allow(unused_imports)]
+ use taffy::{layout::Layout, prelude::*};
+ let mut taffy = taffy::Taffy::new();
+ let node0 = taffy
+ .new_leaf(taffy::style::Style {
+ flex_grow: 1f32,
+ flex_basis: taffy::style::Dimension::Points(0f32),
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(12f32),
+ height: taffy::style::Dimension::Points(12f32),
+ },
+ padding: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(8f32),
+ right: taffy::style::LengthPercentage::Points(4f32),
+ top: taffy::style::LengthPercentage::Points(2f32),
+ bottom: taffy::style::LengthPercentage::Points(6f32),
+ },
+ border: taffy::geometry::Rect {
+ left: taffy::style::LengthPercentage::Points(7f32),
+ right: taffy::style::LengthPercentage::Points(3f32),
+ top: taffy::style::LengthPercentage::Points(1f32),
+ bottom: taffy::style::LengthPercentage::Points(5f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node1 = taffy
+ .new_leaf(taffy::style::Style {
+ flex_grow: 1f32,
+ flex_basis: taffy::style::Dimension::Points(0f32),
+ size: taffy::geometry::Size {
+ width: taffy::style::Dimension::Points(12f32),
+ height: taffy::style::Dimension::Points(12f32),
+ },
+ ..Default::default()
+ })
+ .unwrap();
+ let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0, node1]).unwrap();
+ taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
+ println!("\nComputed tree:");
+ taffy::debug::print_tree(&taffy, node);
+ println!();
+ let Layout { size, location, .. } = taffy.layout(node).unwrap();
+ assert_eq!(size.width, 34f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 34f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node0).unwrap();
+ assert_eq!(size.width, 28f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 28f32, size.width);
+ assert_eq!(size.height, 14f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 14f32, size.height);
+ assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
+ let Layout { size, location, .. } = taffy.layout(node1).unwrap();
+ assert_eq!(size.width, 6f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 6f32, size.width);
+ assert_eq!(size.height, 12f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 12f32, size.height);
+ assert_eq!(location.x, 28f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 28f32, location.x);
+ assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
+}