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:
1 parent
10ee6d1f21
commit
cca9a49c51
60 files changed
+46155
-27
No files matched your search
@@ -0,0 +1,987 @@
|
||||
// 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/flex_basis_flex_grow_row" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_flex_grow_row.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_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, 75.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, 25.0)
|
||||
assert_eq(l1.size.height, 100.0)
|
||||
assert_eq(l1.location.x, 75.0)
|
||||
assert_eq(l1.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_flex_shrink_column" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_flex_shrink_column.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node0 = taffy.new_leaf(Style::default().with_flex_basis(length(100.0)))
|
||||
let node1 = taffy.new_leaf(Style::default().with_flex_basis(length(50.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, 67.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, 33.0)
|
||||
assert_eq(l1.location.x, 0.0)
|
||||
assert_eq(l1.location.y, 67.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_flex_shrink_row" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_flex_shrink_row.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node0 = taffy.new_leaf(Style::default().with_flex_basis(length(100.0)))
|
||||
let node1 = taffy.new_leaf(Style::default().with_flex_basis(length(50.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, 67.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, 33.0)
|
||||
assert_eq(l1.size.height, 100.0)
|
||||
assert_eq(l1.location.x, 67.0)
|
||||
assert_eq(l1.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_larger_than_content_column" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_larger_than_content_column.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node00 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(100.0), height=length(10.0))),
|
||||
)
|
||||
let node0 = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_flex_basis(length(50.0)),
|
||||
[node00],
|
||||
)
|
||||
let node = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_size(Size(width=auto(), 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, 100.0)
|
||||
assert_eq(l0.size.height, 50.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, 100.0)
|
||||
assert_eq(l00.size.height, 10.0)
|
||||
assert_eq(l00.location.x, 0.0)
|
||||
assert_eq(l00.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_larger_than_content_row" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_larger_than_content_row.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node00 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(10.0), height=length(100.0))),
|
||||
)
|
||||
let node0 = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_flex_basis(length(50.0)),
|
||||
[node00],
|
||||
)
|
||||
let node = taffy.new_with_children(
|
||||
Style::default().with_size(Size(width=length(100.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, 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 l00 = taffy.layout(node00)
|
||||
assert_eq(l00.size.width, 10.0)
|
||||
assert_eq(l00.size.height, 100.0)
|
||||
assert_eq(l00.location.x, 0.0)
|
||||
assert_eq(l00.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_overrides_main_size" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_overrides_main_size.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node0 = taffy.new_leaf(
|
||||
Style::default()
|
||||
.with_flex_grow(1.0)
|
||||
.with_flex_basis(length(50.0))
|
||||
.with_size(Size(width=length(20.0), height=auto())),
|
||||
)
|
||||
let node1 = taffy.new_leaf(
|
||||
Style::default()
|
||||
.with_flex_grow(1.0)
|
||||
.with_size(Size(width=length(10.0), height=auto())),
|
||||
)
|
||||
let node2 = 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))),
|
||||
[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, 60.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, 20.0)
|
||||
assert_eq(l1.size.height, 100.0)
|
||||
assert_eq(l1.location.x, 60.0)
|
||||
assert_eq(l1.location.y, 0.0)
|
||||
let l2 = taffy.layout(node2)
|
||||
assert_eq(l2.size.width, 20.0)
|
||||
assert_eq(l2.size.height, 100.0)
|
||||
assert_eq(l2.location.x, 80.0)
|
||||
assert_eq(l2.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node00 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(70.0), height=length(100.0))),
|
||||
)
|
||||
let node0 = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_flex_grow(1.0)
|
||||
.with_flex_basis(length(60.0)),
|
||||
[node00],
|
||||
)
|
||||
let node10 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(20.0), height=length(100.0))),
|
||||
)
|
||||
let node1 = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_flex_grow(1.0)
|
||||
.with_flex_basis(length(0.0)),
|
||||
[node10],
|
||||
)
|
||||
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, 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, 100.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, 70.0)
|
||||
assert_eq(l00.size.height, 100.0)
|
||||
assert_eq(l00.location.x, 0.0)
|
||||
assert_eq(l00.location.y, 0.0)
|
||||
let l1 = taffy.layout(node1)
|
||||
assert_eq(l1.size.width, 20.0)
|
||||
assert_eq(l1.size.height, 100.0)
|
||||
assert_eq(l1.location.x, 80.0)
|
||||
assert_eq(l1.location.y, 0.0)
|
||||
let l10 = taffy.layout(node10)
|
||||
assert_eq(l10.size.width, 20.0)
|
||||
assert_eq(l10.size.height, 100.0)
|
||||
assert_eq(l10.location.x, 0.0)
|
||||
assert_eq(l10.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_smaller_than_content_column" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_than_content_column.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_flex_direction(flex_direction_column())
|
||||
.with_flex_basis(length(50.0)),
|
||||
[node00],
|
||||
)
|
||||
let node = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_size(Size(width=auto(), 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, 100.0)
|
||||
assert_eq(l0.size.height, 100.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, 100.0)
|
||||
assert_eq(l00.size.height, 100.0)
|
||||
assert_eq(l00.location.x, 0.0)
|
||||
assert_eq(l00.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_smaller_than_content_row" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_than_content_row.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_flex_direction(flex_direction_column())
|
||||
.with_flex_basis(length(50.0)),
|
||||
[node00],
|
||||
)
|
||||
let node = taffy.new_with_children(
|
||||
Style::default().with_size(Size(width=length(100.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, 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 l00 = taffy.layout(node00)
|
||||
assert_eq(l00.size.width, 100.0)
|
||||
assert_eq(l00.size.height, 100.0)
|
||||
assert_eq(l00.location.x, 0.0)
|
||||
assert_eq(l00.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_smaller_than_main_dimen_column" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_than_main_dimen_column.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node0 = taffy.new_leaf(
|
||||
Style::default()
|
||||
.with_flex_basis(length(10.0))
|
||||
.with_size(Size(width=length(50.0), height=length(50.0))),
|
||||
)
|
||||
let node = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_size(Size(width=auto(), 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, 50.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, 10.0)
|
||||
assert_eq(l0.location.x, 0.0)
|
||||
assert_eq(l0.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_smaller_than_main_dimen_row" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_than_main_dimen_row.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node0 = taffy.new_leaf(
|
||||
Style::default()
|
||||
.with_flex_basis(length(10.0))
|
||||
.with_size(Size(width=length(50.0), height=length(50.0))),
|
||||
)
|
||||
let node = taffy.new_with_children(
|
||||
Style::default().with_size(Size(width=length(100.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, 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, 10.0)
|
||||
assert_eq(l0.size.height, 50.0)
|
||||
assert_eq(l0.location.x, 0.0)
|
||||
assert_eq(l0.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_smaller_then_content_with_flex_grow_large_size" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_large_size.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node00 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(70.0), height=length(100.0))),
|
||||
)
|
||||
let node0 = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_flex_grow(1.0)
|
||||
.with_flex_basis(length(0.0)),
|
||||
[node00],
|
||||
)
|
||||
let node10 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(20.0), height=length(100.0))),
|
||||
)
|
||||
let node1 = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_flex_grow(1.0)
|
||||
.with_flex_basis(length(0.0)),
|
||||
[node10],
|
||||
)
|
||||
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, 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, 70.0)
|
||||
assert_eq(l0.size.height, 100.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, 70.0)
|
||||
assert_eq(l00.size.height, 100.0)
|
||||
assert_eq(l00.location.x, 0.0)
|
||||
assert_eq(l00.location.y, 0.0)
|
||||
let l1 = taffy.layout(node1)
|
||||
assert_eq(l1.size.width, 30.0)
|
||||
assert_eq(l1.size.height, 100.0)
|
||||
assert_eq(l1.location.x, 70.0)
|
||||
assert_eq(l1.location.y, 0.0)
|
||||
let l10 = taffy.layout(node10)
|
||||
assert_eq(l10.size.width, 20.0)
|
||||
assert_eq(l10.size.height, 100.0)
|
||||
assert_eq(l10.location.x, 0.0)
|
||||
assert_eq(l10.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_smaller_then_content_with_flex_grow_small_size" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_small_size.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node00 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(70.0), height=length(100.0))),
|
||||
)
|
||||
let node0 = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_flex_grow(1.0)
|
||||
.with_flex_basis(length(0.0)),
|
||||
[node00],
|
||||
)
|
||||
let node10 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(20.0), height=length(100.0))),
|
||||
)
|
||||
let node1 = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_flex_grow(1.0)
|
||||
.with_flex_basis(length(0.0)),
|
||||
[node10],
|
||||
)
|
||||
let node = taffy.new_with_children(
|
||||
Style::default().with_size(Size(width=length(10.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, 10.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, 70.0)
|
||||
assert_eq(l0.size.height, 100.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, 70.0)
|
||||
assert_eq(l00.size.height, 100.0)
|
||||
assert_eq(l00.location.x, 0.0)
|
||||
assert_eq(l00.location.y, 0.0)
|
||||
let l1 = taffy.layout(node1)
|
||||
assert_eq(l1.size.width, 20.0)
|
||||
assert_eq(l1.size.height, 100.0)
|
||||
assert_eq(l1.location.x, 70.0)
|
||||
assert_eq(l1.location.y, 0.0)
|
||||
let l10 = taffy.layout(node10)
|
||||
assert_eq(l10.size.width, 20.0)
|
||||
assert_eq(l10.size.height, 100.0)
|
||||
assert_eq(l10.location.x, 0.0)
|
||||
assert_eq(l10.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node00 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(70.0), height=length(100.0))),
|
||||
)
|
||||
let node0 = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_flex_grow(1.0)
|
||||
.with_flex_basis(length(0.0)),
|
||||
[node00],
|
||||
)
|
||||
let node10 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(20.0), height=length(100.0))),
|
||||
)
|
||||
let node1 = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_flex_grow(1.0)
|
||||
.with_flex_basis(length(0.0)),
|
||||
[node10],
|
||||
)
|
||||
let node = taffy.new_with_children(Style::default(), [node0, node1])
|
||||
taffy.compute_layout_with_measure(node, Size::max_content(), measure_text)
|
||||
let lnode = taffy.layout(node)
|
||||
assert_eq(lnode.size.width, 90.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, 70.0)
|
||||
assert_eq(l0.size.height, 100.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, 70.0)
|
||||
assert_eq(l00.size.height, 100.0)
|
||||
assert_eq(l00.location.x, 0.0)
|
||||
assert_eq(l00.location.y, 0.0)
|
||||
let l1 = taffy.layout(node1)
|
||||
assert_eq(l1.size.width, 20.0)
|
||||
assert_eq(l1.size.height, 100.0)
|
||||
assert_eq(l1.location.x, 70.0)
|
||||
assert_eq(l1.location.y, 0.0)
|
||||
let l10 = taffy.layout(node10)
|
||||
assert_eq(l10.size.width, 20.0)
|
||||
assert_eq(l10.size.height, 100.0)
|
||||
assert_eq(l10.location.x, 0.0)
|
||||
assert_eq(l10.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_smaller_then_content_with_flex_grow_very_large_size" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node00 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(70.0), height=length(100.0))),
|
||||
)
|
||||
let node0 = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_flex_grow(1.0)
|
||||
.with_flex_basis(length(0.0)),
|
||||
[node00],
|
||||
)
|
||||
let node10 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(20.0), height=length(100.0))),
|
||||
)
|
||||
let node1 = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_flex_grow(1.0)
|
||||
.with_flex_basis(length(0.0)),
|
||||
[node10],
|
||||
)
|
||||
let node = taffy.new_with_children(
|
||||
Style::default().with_size(Size(width=length(200.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, 200.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 l00 = taffy.layout(node00)
|
||||
assert_eq(l00.size.width, 70.0)
|
||||
assert_eq(l00.size.height, 100.0)
|
||||
assert_eq(l00.location.x, 0.0)
|
||||
assert_eq(l00.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, 100.0)
|
||||
assert_eq(l1.location.y, 0.0)
|
||||
let l10 = taffy.layout(node10)
|
||||
assert_eq(l10.size.width, 20.0)
|
||||
assert_eq(l10.size.height, 100.0)
|
||||
assert_eq(l10.location.x, 0.0)
|
||||
assert_eq(l10.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_unconstraint_column" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_unconstraint_column.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node0 = taffy.new_leaf(
|
||||
Style::default()
|
||||
.with_flex_basis(length(50.0))
|
||||
.with_size(Size(width=length(100.0), height=auto())),
|
||||
)
|
||||
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, 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, 100.0)
|
||||
assert_eq(l0.size.height, 50.0)
|
||||
assert_eq(l0.location.x, 0.0)
|
||||
assert_eq(l0.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_basis_unconstraint_row" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_unconstraint_row.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node0 = taffy.new_leaf(
|
||||
Style::default()
|
||||
.with_flex_basis(length(50.0))
|
||||
.with_size(Size(width=auto(), height=length(100.0))),
|
||||
)
|
||||
let node = taffy.new_with_children(Style::default(), [node0])
|
||||
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, 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/flex_basis_zero_undefined_main_size" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_basis_zero_undefined_main_size.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node00 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(100.0), height=length(50.0))),
|
||||
)
|
||||
let node0 = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_flex_basis(length(0.0)),
|
||||
[node00],
|
||||
)
|
||||
let node = taffy.new_with_children(Style::default(), [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, 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 l00 = taffy.layout(node00)
|
||||
assert_eq(l00.size.width, 100.0)
|
||||
assert_eq(l00.size.height, 50.0)
|
||||
assert_eq(l00.location.x, 0.0)
|
||||
assert_eq(l00.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_column_relative_all_sides" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_column_relative_all_sides.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node0 = taffy.new_leaf(
|
||||
Style::default()
|
||||
.with_size(Size(width=length(40.0), height=auto()))
|
||||
.with_inset(
|
||||
Rect(
|
||||
left=length(10.0),
|
||||
right=length(10.0),
|
||||
top=length(10.0),
|
||||
bottom=length(10.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],
|
||||
)
|
||||
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, 40.0)
|
||||
assert_eq(l0.size.height, 0.0)
|
||||
assert_eq(l0.location.x, 10.0)
|
||||
assert_eq(l0.location.y, 10.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_direction_column" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_direction_column.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node0 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=auto(), height=length(10.0))),
|
||||
)
|
||||
let node1 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=auto(), height=length(10.0))),
|
||||
)
|
||||
let node2 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=auto(), height=length(10.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, 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, 100.0)
|
||||
assert_eq(l0.size.height, 10.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, 10.0)
|
||||
assert_eq(l1.location.x, 0.0)
|
||||
assert_eq(l1.location.y, 10.0)
|
||||
let l2 = taffy.layout(node2)
|
||||
assert_eq(l2.size.width, 100.0)
|
||||
assert_eq(l2.size.height, 10.0)
|
||||
assert_eq(l2.location.x, 0.0)
|
||||
assert_eq(l2.location.y, 20.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_direction_column_no_height" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_direction_column_no_height.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node0 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=auto(), height=length(10.0))),
|
||||
)
|
||||
let node1 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=auto(), height=length(10.0))),
|
||||
)
|
||||
let node2 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=auto(), height=length(10.0))),
|
||||
)
|
||||
let node = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column())
|
||||
.with_size(Size(width=length(100.0), height=auto())),
|
||||
[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, 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, 100.0)
|
||||
assert_eq(l0.size.height, 10.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, 10.0)
|
||||
assert_eq(l1.location.x, 0.0)
|
||||
assert_eq(l1.location.y, 10.0)
|
||||
let l2 = taffy.layout(node2)
|
||||
assert_eq(l2.size.width, 100.0)
|
||||
assert_eq(l2.size.height, 10.0)
|
||||
assert_eq(l2.location.x, 0.0)
|
||||
assert_eq(l2.location.y, 20.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_direction_column_reverse" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_direction_column_reverse.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node0 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=auto(), height=length(10.0))),
|
||||
)
|
||||
let node1 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=auto(), height=length(10.0))),
|
||||
)
|
||||
let node2 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=auto(), height=length(10.0))),
|
||||
)
|
||||
let node = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column_reverse())
|
||||
.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, 100.0)
|
||||
assert_eq(l0.size.height, 10.0)
|
||||
assert_eq(l0.location.x, 0.0)
|
||||
assert_eq(l0.location.y, 90.0)
|
||||
let l1 = taffy.layout(node1)
|
||||
assert_eq(l1.size.width, 100.0)
|
||||
assert_eq(l1.size.height, 10.0)
|
||||
assert_eq(l1.location.x, 0.0)
|
||||
assert_eq(l1.location.y, 80.0)
|
||||
let l2 = taffy.layout(node2)
|
||||
assert_eq(l2.size.width, 100.0)
|
||||
assert_eq(l2.size.height, 10.0)
|
||||
assert_eq(l2.location.x, 0.0)
|
||||
assert_eq(l2.location.y, 70.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_direction_column_reverse_no_height" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_direction_column_reverse_no_height.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node0 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=auto(), height=length(10.0))),
|
||||
)
|
||||
let node1 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=auto(), height=length(10.0))),
|
||||
)
|
||||
let node2 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=auto(), height=length(10.0))),
|
||||
)
|
||||
let node = taffy.new_with_children(
|
||||
Style::default()
|
||||
.with_flex_direction(flex_direction_column_reverse())
|
||||
.with_size(Size(width=length(100.0), height=auto())),
|
||||
[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, 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, 100.0)
|
||||
assert_eq(l0.size.height, 10.0)
|
||||
assert_eq(l0.location.x, 0.0)
|
||||
assert_eq(l0.location.y, 20.0)
|
||||
let l1 = taffy.layout(node1)
|
||||
assert_eq(l1.size.width, 100.0)
|
||||
assert_eq(l1.size.height, 10.0)
|
||||
assert_eq(l1.location.x, 0.0)
|
||||
assert_eq(l1.location.y, 10.0)
|
||||
let l2 = taffy.layout(node2)
|
||||
assert_eq(l2.size.width, 100.0)
|
||||
assert_eq(l2.size.height, 10.0)
|
||||
assert_eq(l2.location.x, 0.0)
|
||||
assert_eq(l2.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_direction_row" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_direction_row.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node0 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(10.0), height=auto())),
|
||||
)
|
||||
let node1 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(10.0), height=auto())),
|
||||
)
|
||||
let node2 = 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))),
|
||||
[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, 10.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, 10.0)
|
||||
assert_eq(l1.size.height, 100.0)
|
||||
assert_eq(l1.location.x, 10.0)
|
||||
assert_eq(l1.location.y, 0.0)
|
||||
let l2 = taffy.layout(node2)
|
||||
assert_eq(l2.size.width, 10.0)
|
||||
assert_eq(l2.size.height, 100.0)
|
||||
assert_eq(l2.location.x, 20.0)
|
||||
assert_eq(l2.location.y, 0.0)
|
||||
}
|
||||
|
||||
///|
|
||||
test "upstream/generated/flex/flex_direction_row_no_width" {
|
||||
// Ported from taffy-reference/tests/generated/flex/flex_direction_row_no_width.rs
|
||||
let taffy : ChicleTree[TextMeasure] = ChicleTree()
|
||||
let node0 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(10.0), height=auto())),
|
||||
)
|
||||
let node1 = taffy.new_leaf(
|
||||
Style::default().with_size(Size(width=length(10.0), height=auto())),
|
||||
)
|
||||
let node2 = 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=auto(), 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, 30.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, 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, 10.0)
|
||||
assert_eq(l1.size.height, 100.0)
|
||||
assert_eq(l1.location.x, 10.0)
|
||||
assert_eq(l1.location.y, 0.0)
|
||||
let l2 = taffy.layout(node2)
|
||||
assert_eq(l2.size.width, 10.0)
|
||||
assert_eq(l2.size.height, 100.0)
|
||||
assert_eq(l2.location.x, 20.0)
|
||||
assert_eq(l2.location.y, 0.0)
|
||||
}
|
||||
Reference in new issue
Block a user