M2 layout: LayoutEngine on Milky2018/chicle, conformance suite

- layout: port of GPUI's TaffyLayoutEngine (request_layout,
  request_measured_layout, compute_layout, layout_bounds,
  stretch_auto_size_to_fill) and LayoutStyle::to_taffy, with rem resolution
  and device-pixel snapping (round_half_toward_zero, stroke snapping, ceiled
  measured sizes). No cross-frame node cache yet (needs element ids, M6).
- Depend on Milky2018/chicle 0.6.3, the maintained successor of
  moon_taffy (which no longer compiles), instead of vendoring.
- conformance/chicle: standalone module running moon_taffy's 1,038 taffy
  fixtures against chicle; all pass on wasm, wasm-gc, js and native.
- card example now lays out its content with the engine.
- Docs: PORTING.md M2 status, revised decision 3, M2 deviations; README;
  NOTICE attribution for the conformance fixtures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SpriteandClaude Opus 5.5 committed 2026-11-24 22:09:49 +00:00
1 parent 10ee6d1f21
commit cca9a49c51
60 files changed
+46155 -27

No files matched your search

@@ -0,0 +1,887 @@
// Copyright 2025 International Digital Economy Academy
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
///|
test "upstream/generated/flex/bevy_issue_9530_reduced2" {
// Ported from taffy-reference/tests/generated/flex/bevy_issue_9530_reduced2.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node00 = taffy.new_leaf_with_context(
Style::default().with_flex_grow(1.0),
{
text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH",
writing_mode: Horizontal,
},
)
let node0 = taffy.new_with_children(
Style::default()
.with_flex_direction(flex_direction_column())
.with_flex_grow(1.0)
.with_size(Size(width=length(80.0), height=auto()))
.with_margin(
Rect(
left=length(20.0),
right=length(20.0),
top=length(0.0),
bottom=length(0.0),
),
),
[node00],
)
let node = taffy.new_with_children(
Style::default().with_flex_direction(flex_direction_column()),
[node0],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 120.0)
assert_eq(lnode.size.height, 20.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 80.0)
assert_eq(l0.size.height, 20.0)
assert_eq(l0.location.x, 20.0)
assert_eq(l0.location.y, 0.0)
let l00 = taffy.layout(node00)
assert_eq(l00.size.width, 80.0)
assert_eq(l00.size.height, 20.0)
assert_eq(l00.location.x, 0.0)
assert_eq(l00.location.y, 0.0)
}
///|
test "upstream/generated/flex/bevy_issue_9530_reduced3" {
// Ported from taffy-reference/tests/generated/flex/bevy_issue_9530_reduced3.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf_with_context(
Style::default()
.with_flex_grow(1.0)
.with_margin(
Rect(
left=length(20.0),
right=length(20.0),
top=length(0.0),
bottom=length(0.0),
),
),
{
text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH",
writing_mode: Horizontal,
},
)
let node = taffy.new_with_children(
Style::default()
.with_flex_direction(flex_direction_column())
.with_size(Size(width=length(80.0), height=auto())),
[node0],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 80.0)
assert_eq(lnode.size.height, 40.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 40.0)
assert_eq(l0.size.height, 40.0)
assert_eq(l0.location.x, 20.0)
assert_eq(l0.location.y, 0.0)
}
///|
test "upstream/generated/flex/bevy_issue_9530_reduced4" {
// Ported from taffy-reference/tests/generated/flex/bevy_issue_9530_reduced4.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf_with_context(
Style::default().with_margin(
Rect(
left=length(20.0),
right=length(20.0),
top=length(20.0),
bottom=length(20.0),
),
),
{
text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH",
writing_mode: Horizontal,
},
)
let node = taffy.new_with_children(
Style::default()
.with_flex_direction(flex_direction_column())
.with_size(Size(width=length(80.0), height=auto())),
[node0],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 80.0)
assert_eq(lnode.size.height, 80.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 40.0)
assert_eq(l0.size.height, 40.0)
assert_eq(l0.location.x, 20.0)
assert_eq(l0.location.y, 20.0)
}
///|
test "upstream/generated/flex/blitz_issue_88" {
// Ported from taffy-reference/tests/generated/flex/blitz_issue_88.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node000 = taffy.new_leaf_with_context(
Style::default()
.with_display(display_block())
.with_flex_grow(1.0)
.with_flex_basis(length(0.0)),
{
text_content: "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH",
writing_mode: Horizontal,
},
)
let node00 = taffy.new_with_children(
Style::default().with_display(display_flex()).with_flex_grow(1.0),
[node000],
)
let node0 = taffy.new_with_children(
Style::default()
.with_display(display_flex())
.with_flex_direction(flex_direction_column())
.with_justify_content(justify_content_start()),
[node00],
)
let node = taffy.new_with_children(
Style::default()
.with_display(display_block())
.with_size(Size(width=length(600.0), height=auto())),
[node0],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 600.0)
assert_eq(lnode.size.height, 10.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 600.0)
assert_eq(l0.size.height, 10.0)
assert_eq(l0.location.x, 0.0)
assert_eq(l0.location.y, 0.0)
let l00 = taffy.layout(node00)
assert_eq(l00.size.width, 600.0)
assert_eq(l00.size.height, 10.0)
assert_eq(l00.location.x, 0.0)
assert_eq(l00.location.y, 0.0)
let l000 = taffy.layout(node000)
assert_eq(l000.size.width, 600.0)
assert_eq(l000.size.height, 10.0)
assert_eq(l000.location.x, 0.0)
assert_eq(l000.location.y, 0.0)
}
///|
test "upstream/generated/flex/border_center_child" {
// Ported from taffy-reference/tests/generated/flex/border_center_child.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(
Style::default().with_size(Size(width=length(10.0), height=length(10.0))),
)
let node = taffy.new_with_children(
Style::default()
.with_align_items(align_items_center())
.with_justify_content(justify_content_center())
.with_size(Size(width=length(100.0), height=length(100.0)))
.with_border(
Rect(
left=length(0.0),
right=length(0.0),
top=length(10.0),
bottom=length(20.0),
),
),
[node0],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 100.0)
assert_eq(lnode.size.height, 100.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 10.0)
assert_eq(l0.size.height, 10.0)
assert_eq(l0.location.x, 45.0)
assert_eq(l0.location.y, 40.0)
}
///|
test "upstream/generated/flex/border_container_match_child" {
// Ported from taffy-reference/tests/generated/flex/border_container_match_child.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(
Style::default().with_size(Size(width=length(10.0), height=length(10.0))),
)
let node = taffy.new_with_children(
Style::default()
.with_flex_direction(flex_direction_column())
.with_border(
Rect(
left=length(10.0),
right=length(10.0),
top=length(10.0),
bottom=length(10.0),
),
),
[node0],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 30.0)
assert_eq(lnode.size.height, 30.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 10.0)
assert_eq(l0.size.height, 10.0)
assert_eq(l0.location.x, 10.0)
assert_eq(l0.location.y, 10.0)
}
///|
test "upstream/generated/flex/border_flex_child" {
// Ported from taffy-reference/tests/generated/flex/border_flex_child.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(
Style::default()
.with_flex_grow(1.0)
.with_size(Size(width=length(10.0), height=auto())),
)
let node = taffy.new_with_children(
Style::default()
.with_size(Size(width=length(100.0), height=length(100.0)))
.with_border(
Rect(
left=length(10.0),
right=length(10.0),
top=length(10.0),
bottom=length(10.0),
),
),
[node0],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 100.0)
assert_eq(lnode.size.height, 100.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 80.0)
assert_eq(l0.size.height, 80.0)
assert_eq(l0.location.x, 10.0)
assert_eq(l0.location.y, 10.0)
}
///|
test "upstream/generated/flex/border_no_child" {
// Ported from taffy-reference/tests/generated/flex/border_no_child.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node = taffy.new_leaf(
Style::default().with_border(
Rect(
left=length(10.0),
right=length(10.0),
top=length(10.0),
bottom=length(10.0),
),
),
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 20.0)
assert_eq(lnode.size.height, 20.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
}
///|
test "upstream/generated/flex/border_no_size" {
// Ported from taffy-reference/tests/generated/flex/border_no_size.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node = taffy.new_leaf(
Style::default()
.with_flex_direction(flex_direction_column())
.with_border(
Rect(
left=length(10.0),
right=length(10.0),
top=length(10.0),
bottom=length(10.0),
),
),
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 20.0)
assert_eq(lnode.size.height, 20.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
}
///|
test "upstream/generated/flex/border_stretch_child" {
// Ported from taffy-reference/tests/generated/flex/border_stretch_child.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(
Style::default().with_size(Size(width=length(10.0), height=auto())),
)
let node = taffy.new_with_children(
Style::default()
.with_size(Size(width=length(100.0), height=length(100.0)))
.with_border(
Rect(
left=length(10.0),
right=length(10.0),
top=length(10.0),
bottom=length(10.0),
),
),
[node0],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 100.0)
assert_eq(lnode.size.height, 100.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 10.0)
assert_eq(l0.size.height, 80.0)
assert_eq(l0.location.x, 10.0)
assert_eq(l0.location.y, 10.0)
}
///|
test "upstream/generated/flex/child_min_max_width_flexing" {
// Ported from taffy-reference/tests/generated/flex/child_min_max_width_flexing.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(
Style::default()
.with_flex_grow(1.0)
.with_flex_shrink(0.0)
.with_flex_basis(length(0.0))
.with_min_size(Size(width=length(60.0), height=auto())),
)
let node1 = taffy.new_leaf(
Style::default()
.with_flex_grow(1.0)
.with_flex_shrink(0.0)
.with_flex_basis(percent(0.5))
.with_max_size(Size(width=length(20.0), height=auto())),
)
let node = taffy.new_with_children(
Style::default()
.with_align_items(align_items_stretch())
.with_size(Size(width=length(120.0), height=length(50.0))),
[node0, node1],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 120.0)
assert_eq(lnode.size.height, 50.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 100.0)
assert_eq(l0.size.height, 50.0)
assert_eq(l0.location.x, 0.0)
assert_eq(l0.location.y, 0.0)
let l1 = taffy.layout(node1)
assert_eq(l1.size.width, 20.0)
assert_eq(l1.size.height, 50.0)
assert_eq(l1.location.x, 100.0)
assert_eq(l1.location.y, 0.0)
}
///|
test "upstream/generated/flex/child_with_padding_align_end" {
// Ported from taffy-reference/tests/generated/flex/child_with_padding_align_end.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(
Style::default()
.with_size(Size(width=length(100.0), height=length(100.0)))
.with_padding(
Rect(
left=length(20.0),
right=length(20.0),
top=length(20.0),
bottom=length(20.0),
),
),
)
let node = taffy.new_with_children(
Style::default()
.with_flex_direction(flex_direction_column())
.with_align_items(align_items_flex_end())
.with_justify_content(justify_content_flex_end())
.with_size(Size(width=length(200.0), height=length(200.0))),
[node0],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 200.0)
assert_eq(lnode.size.height, 200.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 100.0)
assert_eq(l0.size.height, 100.0)
assert_eq(l0.location.x, 100.0)
assert_eq(l0.location.y, 100.0)
}
///|
test "upstream/generated/flex/container_with_unsized_child" {
// Ported from taffy-reference/tests/generated/flex/container_with_unsized_child.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(Style::default())
let node = taffy.new_with_children(
Style::default().with_size(Size(width=length(100.0), height=length(100.0))),
[node0],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 100.0)
assert_eq(lnode.size.height, 100.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 0.0)
assert_eq(l0.size.height, 100.0)
assert_eq(l0.location.x, 0.0)
assert_eq(l0.location.y, 0.0)
}
///|
test "upstream/generated/flex/content_size" {
// Ported from taffy-reference/tests/generated/flex/content_size.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node00 = taffy.new_leaf_with_context(
Style::default()
.with_position(position_absolute())
.with_flex_shrink(0.0)
.with_size(Size(width=percent(1.0), height=length(20.0)))
.with_inset(
Rect(left=auto(), right=auto(), top=length(-10.0), bottom=auto()),
),
{ text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal },
)
let node0 = taffy.new_with_children(
Style::default().with_size(Size(width=auto(), height=length(30.0))),
[node00],
)
let node = taffy.new_with_children(
Style::default()
.with_display(display_flex())
.with_flex_direction(flex_direction_column())
.with_overflow(Point(x=overflow_visible(), y=overflow_scroll()))
.with_scrollbar_width(15.0)
.with_size(Size(width=length(100.0), height=length(100.0))),
[node0],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
assert_layout_xywh(taffy, node, 100.0, 100.0, 0.0, 0.0)
assert_layout_xywh(taffy, node0, 85.0, 30.0, 0.0, 0.0)
assert_layout_xywh(taffy, node00, 85.0, 20.0, 0.0, -10.0)
}
///|
test "upstream/generated/flex/display_none" {
// Ported from taffy-reference/tests/generated/flex/display_none.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0))
let node1 = taffy.new_leaf(
Style::default().with_display(display_none()).with_flex_grow(1.0),
)
let node = taffy.new_with_children(
Style::default().with_size(Size(width=length(100.0), height=length(100.0))),
[node0, node1],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 100.0)
assert_eq(lnode.size.height, 100.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 100.0)
assert_eq(l0.size.height, 100.0)
assert_eq(l0.location.x, 0.0)
assert_eq(l0.location.y, 0.0)
let l1 = taffy.layout(node1)
assert_eq(l1.size.width, 0.0)
assert_eq(l1.size.height, 0.0)
assert_eq(l1.location.x, 0.0)
assert_eq(l1.location.y, 0.0)
}
///|
test "upstream/generated/flex/display_none_absolute_child" {
// Ported from taffy-reference/tests/generated/flex/display_none_absolute_child.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0))
let node1 = taffy.new_leaf(
Style::default()
.with_display(display_none())
.with_position(position_absolute())
.with_size(Size(width=length(20.0), height=length(20.0)))
.with_inset(
Rect(left=length(10.0), right=auto(), top=length(10.0), bottom=auto()),
),
)
let node = taffy.new_with_children(
Style::default().with_size(Size(width=length(100.0), height=length(100.0))),
[node0, node1],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 100.0)
assert_eq(lnode.size.height, 100.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 100.0)
assert_eq(l0.size.height, 100.0)
assert_eq(l0.location.x, 0.0)
assert_eq(l0.location.y, 0.0)
let l1 = taffy.layout(node1)
assert_eq(l1.size.width, 0.0)
assert_eq(l1.size.height, 0.0)
assert_eq(l1.location.x, 0.0)
assert_eq(l1.location.y, 0.0)
}
///|
test "upstream/generated/flex/display_none_fixed_size" {
// Ported from taffy-reference/tests/generated/flex/display_none_fixed_size.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0))
let node1 = taffy.new_leaf(
Style::default()
.with_display(display_none())
.with_size(Size(width=length(20.0), height=length(20.0))),
)
let node = taffy.new_with_children(
Style::default().with_size(Size(width=length(100.0), height=length(100.0))),
[node0, node1],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 100.0)
assert_eq(lnode.size.height, 100.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 100.0)
assert_eq(l0.size.height, 100.0)
assert_eq(l0.location.x, 0.0)
assert_eq(l0.location.y, 0.0)
let l1 = taffy.layout(node1)
assert_eq(l1.size.width, 0.0)
assert_eq(l1.size.height, 0.0)
assert_eq(l1.location.x, 0.0)
assert_eq(l1.location.y, 0.0)
}
///|
test "upstream/generated/flex/display_none_only_node" {
// Ported from taffy-reference/tests/generated/flex/display_none_only_node.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node = taffy.new_leaf(
Style::default()
.with_display(display_none())
.with_size(Size(width=length(100.0), height=length(100.0))),
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 0.0)
assert_eq(lnode.size.height, 0.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
}
///|
test "upstream/generated/flex/display_none_with_child" {
// Ported from taffy-reference/tests/generated/flex/display_none_with_child.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(
Style::default()
.with_flex_grow(1.0)
.with_flex_shrink(1.0)
.with_flex_basis(percent(0.0)),
)
let node10 = taffy.new_leaf(
Style::default()
.with_flex_grow(1.0)
.with_flex_shrink(1.0)
.with_flex_basis(percent(0.0))
.with_size(Size(width=length(20.0), height=auto())),
)
let node1 = taffy.new_with_children(
Style::default()
.with_display(display_none())
.with_flex_direction(flex_direction_column())
.with_flex_grow(1.0)
.with_flex_shrink(1.0)
.with_flex_basis(percent(0.0)),
[node10],
)
let node2 = taffy.new_leaf(
Style::default()
.with_flex_grow(1.0)
.with_flex_shrink(1.0)
.with_flex_basis(percent(0.0)),
)
let node = taffy.new_with_children(
Style::default().with_size(Size(width=length(100.0), height=length(100.0))),
[node0, node1, node2],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 100.0)
assert_eq(lnode.size.height, 100.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 50.0)
assert_eq(l0.size.height, 100.0)
assert_eq(l0.location.x, 0.0)
assert_eq(l0.location.y, 0.0)
let l1 = taffy.layout(node1)
assert_eq(l1.size.width, 0.0)
assert_eq(l1.size.height, 0.0)
assert_eq(l1.location.x, 0.0)
assert_eq(l1.location.y, 0.0)
let l10 = taffy.layout(node10)
assert_eq(l10.size.width, 0.0)
assert_eq(l10.size.height, 0.0)
assert_eq(l10.location.x, 0.0)
assert_eq(l10.location.y, 0.0)
let l2 = taffy.layout(node2)
assert_eq(l2.size.width, 50.0)
assert_eq(l2.size.height, 100.0)
assert_eq(l2.location.x, 50.0)
assert_eq(l2.location.y, 0.0)
}
///|
test "upstream/generated/flex/display_none_with_margin" {
// Ported from taffy-reference/tests/generated/flex/display_none_with_margin.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(
Style::default()
.with_display(display_none())
.with_size(Size(width=length(20.0), height=length(20.0)))
.with_margin(
Rect(
left=length(10.0),
right=length(10.0),
top=length(10.0),
bottom=length(10.0),
),
),
)
let node1 = taffy.new_leaf(Style::default().with_flex_grow(1.0))
let node = taffy.new_with_children(
Style::default().with_size(Size(width=length(100.0), height=length(100.0))),
[node0, node1],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 100.0)
assert_eq(lnode.size.height, 100.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 0.0)
assert_eq(l0.size.height, 0.0)
assert_eq(l0.location.x, 0.0)
assert_eq(l0.location.y, 0.0)
let l1 = taffy.layout(node1)
assert_eq(l1.size.width, 100.0)
assert_eq(l1.size.height, 100.0)
assert_eq(l1.location.x, 0.0)
assert_eq(l1.location.y, 0.0)
}
///|
test "upstream/generated/flex/display_none_with_position" {
// Ported from taffy-reference/tests/generated/flex/display_none_with_position.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0))
let node1 = taffy.new_leaf(
Style::default()
.with_display(display_none())
.with_flex_grow(1.0)
.with_inset(
Rect(left=auto(), right=auto(), top=length(10.0), bottom=auto()),
),
)
let node = taffy.new_with_children(
Style::default().with_size(Size(width=length(100.0), height=length(100.0))),
[node0, node1],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 100.0)
assert_eq(lnode.size.height, 100.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 100.0)
assert_eq(l0.size.height, 100.0)
assert_eq(l0.location.x, 0.0)
assert_eq(l0.location.y, 0.0)
let l1 = taffy.layout(node1)
assert_eq(l1.size.width, 0.0)
assert_eq(l1.size.height, 0.0)
assert_eq(l1.location.x, 0.0)
assert_eq(l1.location.y, 0.0)
}
///|
test "upstream/generated/flex/display_none_with_position_absolute" {
// Ported from taffy-reference/tests/generated/flex/display_none_with_position_absolute.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(
Style::default()
.with_display(display_none())
.with_position(position_absolute())
.with_size(Size(width=length(100.0), height=length(100.0))),
)
let node = taffy.new_with_children(
Style::default().with_size(Size(width=length(100.0), height=length(100.0))),
[node0],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 100.0)
assert_eq(lnode.size.height, 100.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 0.0)
assert_eq(l0.size.height, 0.0)
assert_eq(l0.location.x, 0.0)
assert_eq(l0.location.y, 0.0)
}
///|
test "upstream/generated/flex/do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" {
// Ported from taffy-reference/tests/generated/flex/do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node00 = taffy.new_leaf(
Style::default().with_size(Size(width=length(100.0), height=length(100.0))),
)
let node0 = taffy.new_with_children(
Style::default()
.with_position(position_absolute())
.with_flex_direction(flex_direction_column())
.with_inset(
Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=auto()),
),
[node00],
)
let node = taffy.new_with_children(
Style::default()
.with_overflow(Point(x=overflow_hidden(), y=overflow_hidden()))
.with_scrollbar_width(15.0)
.with_size(Size(width=length(50.0), height=length(50.0))),
[node0],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
assert_layout_xywh(taffy, node, 50.0, 50.0, 0.0, 0.0)
assert_layout_xywh(taffy, node0, 100.0, 100.0, 0.0, 0.0)
assert_layout_xywh(taffy, node00, 100.0, 100.0, 0.0, 0.0)
}
///|
test "upstream/generated/flex/flex_basis_and_main_dimen_set_when_flexing" {
// Ported from taffy-reference/tests/generated/flex/flex_basis_and_main_dimen_set_when_flexing.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(
Style::default()
.with_flex_grow(1.0)
.with_flex_basis(length(10.0))
.with_size(Size(width=length(50.0), height=length(50.0))),
)
let node1 = taffy.new_leaf(
Style::default()
.with_flex_grow(1.0)
.with_flex_basis(length(10.0))
.with_size(Size(width=length(0.0), height=length(50.0))),
)
let node = taffy.new_with_children(
Style::default().with_size(Size(width=length(100.0), height=auto())),
[node0, node1],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 100.0)
assert_eq(lnode.size.height, 50.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 50.0)
assert_eq(l0.size.height, 50.0)
assert_eq(l0.location.x, 0.0)
assert_eq(l0.location.y, 0.0)
let l1 = taffy.layout(node1)
assert_eq(l1.size.width, 50.0)
assert_eq(l1.size.height, 50.0)
assert_eq(l1.location.x, 50.0)
assert_eq(l1.location.y, 0.0)
}
///|
test "upstream/generated/flex/flex_basis_flex_grow_column" {
// Ported from taffy-reference/tests/generated/flex/flex_basis_flex_grow_column.rs
let taffy : ChicleTree[TextMeasure] = ChicleTree()
let node0 = taffy.new_leaf(
Style::default().with_flex_grow(1.0).with_flex_basis(length(50.0)),
)
let node1 = taffy.new_leaf(Style::default().with_flex_grow(1.0))
let node = taffy.new_with_children(
Style::default()
.with_flex_direction(flex_direction_column())
.with_size(Size(width=length(100.0), height=length(100.0))),
[node0, node1],
)
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
let lnode = taffy.layout(node)
assert_eq(lnode.size.width, 100.0)
assert_eq(lnode.size.height, 100.0)
assert_eq(lnode.location.x, 0.0)
assert_eq(lnode.location.y, 0.0)
let l0 = taffy.layout(node0)
assert_eq(l0.size.width, 100.0)
assert_eq(l0.size.height, 75.0)
assert_eq(l0.location.x, 0.0)
assert_eq(l0.location.y, 0.0)
let l1 = taffy.layout(node1)
assert_eq(l1.size.width, 100.0)
assert_eq(l1.size.height, 25.0)
assert_eq(l1.location.x, 0.0)
assert_eq(l1.location.y, 75.0)
}