diff --git a/NOTICE b/NOTICE index 7b7ce42..7ad4e25 100644 --- a/NOTICE +++ b/NOTICE @@ -18,3 +18,12 @@ MoonBit packages. This port is distributed under the same license, the Apache License, Version 2.0 (see LICENSE). It is not affiliated with or endorsed by Zed Industries. + +Third-party material: + +- conformance/chicle/upstream contains layout fixture tests from + Milky2018/moon_taffy 0.5.3 (Apache-2.0, Copyright 2025 International + Digital Economy Academy), which are derived from taffy's generated tests + (https://github.com/DioxusLabs/taffy, MIT). +- The layout package depends on Milky2018/chicle (Apache-2.0), fetched from + mooncakes.io; it is not vendored here. diff --git a/README.md b/README.md index 7933214..a7dc707 100644 --- a/README.md +++ b/README.md @@ -15,33 +15,52 @@ roadmap. | `experiments/gpui/scene` | `scene.rs`, `bounds_tree.rs` | Ported (primitives, draw ordering, layers, batching, replay) | | `experiments/gpui/font` | font descriptors in `text_system.rs` | Ported (`Font`, weights, styles, features, fallbacks) | | `experiments/gpui/style` | `style.rs`, `styled.rs`, Refineable, gpui_macros style helpers | Ported (`Style`/`StyleRefinement`, the full `Styled` fluent API) | +| `experiments/gpui/app` | `app.rs`, `entity_map.rs`, `context.rs`, `subscription.rs` | Ported (entities, contexts, notify/observe, typed events and globals, effect flushing) | +| `experiments/gpui/executor` | `executor.rs`, `scheduler` crate | Ported (tasks, timers, cancellation, deterministic test dispatcher; single thread) | +| `experiments/gpui/input` | mouse/window input of `interactive.rs` | Ported (mouse events, modifiers, `PlatformInput`, `DispatchEventResult`) | +| `experiments/gpui/window` | `window.rs`, `element.rs`, `view.rs`, `app.rs` | Ported, headless (`Application`, `PlatformWindow` integration, frame lifecycle, views, hitboxes, mouse dispatch, painting) | +| `experiments/gpui/elements` | `elements/div.rs`, `elements/canvas.rs` | Ported (`div` with styles, hover, clicks and mouse listeners; `canvas`) | +| `experiments/gpui/layout` | `taffy.rs` | Ported on [`Milky2018/chicle`](https://mooncakes.io/docs/Milky2018/chicle) (flexbox, grid, block) | +| `experiments/gpui/platform` | `platform.rs` | Ported (core `Platform`/`PlatformWindow` traits, window options/params, clipboard) | +| `experiments/gpui/platform/test` | `platform/test/*`, `app/test_context.rs` | Ported (`TestPlatform`, `TestWindow`, `TestAppContext`, `VisualTestContext`) | ## Example -Nothing renders yet. `src/examples/card` resolves a style written with -GPUI's fluent API, paints it into a `Scene` by hand, and prints the draw -batches: +Nothing is shown on screen yet (the renderer comes with M8). `src/examples/card` +is a view rendering a `div()` card with GPUI's fluent API inside a +`TestPlatform` window; `VisualTestContext` simulates a hover and click while +pumping frames automatically, and prints the scene's draw batches and quads: ```sh moon run src/examples/card --target js ``` ```moonbit -@style.StyleRefinement::new() +@elements.div() + .id("card") .flex().flex_col().gap_2().p_4() .w(@geometry.px(320.0)) .rounded_lg().border_1().border_color(@color.rgb(0xd0d7de)) .bg(@color.rgb(0xffffff)).shadow_md() - .text_color(@color.rgb(0x1f2328)).text_sm() + .hover(fn(style) { style.border_color(@color.rgb(0x0969da)) }) + .on_click(@window.listener(cx, fn(card, _, _, cx) { + card.expanded = !card.expanded + cx.notify() + })) ``` +`src/examples/counter` shows the app model and executors: two entities +talking through notifications, a typed event and a global, and a task +ticking on a simulated clock (`moon run src/examples/counter --target js`). + The first example that renders in the browser comes with milestone M8; see the roadmap. ## Generated code -`src/style/style_generated.mbt`, `styled_generated.mbt` and -`styled_extend_generated.mbt` are generated by `tools/gen_style.py`, which +`src/style/style_generated.mbt`, `styled_generated.mbt`, +`styled_extend_generated.mbt`, and the `*_styled_generated.mbt` files in +`src/elements` are generated by `tools/gen_style.py`, which stands in for GPUI's Rust macros. Do not edit them by hand; change the script or `src/style/styled.mbt`, then run: @@ -49,6 +68,12 @@ script or `src/style/styled.mbt`, then run: python3 tools/gen_style.py && moon fmt ``` +## Layout conformance + +`conformance/chicle` is a standalone module with 1,038 taffy layout fixtures +for the layout engine dependency. Run it before changing the chicle version: +`cd conformance/chicle && moon test --target all`. + ## Testing All packages are pure MoonBit and are tested on every backend: diff --git a/conformance/chicle/README.md b/conformance/chicle/README.md new file mode 100644 index 0000000..bf046b1 --- /dev/null +++ b/conformance/chicle/README.md @@ -0,0 +1,25 @@ +# Layout conformance suite + +1,038 layout fixtures, run against `Milky2018/chicle`, the layout engine +behind `experiments/gpui/layout`. They are taffy's generated layout fixtures +(flexbox, grid, block, measured leaves), as ported to MoonBit in +`Milky2018/moon_taffy@0.5.3` (`src/tests/upstream`). That package no longer +compiles on the current MoonBit toolchain; its successor, chicle, does. + +Run this suite before raising the chicle version in the root `moon.mod`: + +```sh +cd conformance/chicle +moon test --target all +``` + +As of chicle 0.6.3 and moon 0.1.20261119, all 1,038 tests pass on wasm, +wasm-gc, js and native, in about 40 seconds. The suite is kept outside the +main module so that `moon test` at the repository root stays fast. + +The only changes from upstream are the renames `TaffyTree` → `ChicleTree` +and `TaffyError` → `ChicleError`, and the import paths in `moon.pkg`. + +License: Apache-2.0. Copyright 2025 International Digital Economy Academy +(see the file headers). The fixtures derive from taffy +(https://github.com/DioxusLabs/taffy, MIT). diff --git a/conformance/chicle/moon.mod b/conformance/chicle/moon.mod new file mode 100644 index 0000000..ab3dc43 --- /dev/null +++ b/conformance/chicle/moon.mod @@ -0,0 +1,11 @@ +// Layout conformance suite for the layout engine dependency. Not part of the +// main module; run on demand (see README.md). +name = "experiments/gpui-layout-conformance" + +version = "0.1.0" + +license = "Apache-2.0" + +import { + "Milky2018/chicle@0.6.3", +} diff --git a/conformance/chicle/upstream/measure_child_with_flex_grow_test.mbt b/conformance/chicle/upstream/measure_child_with_flex_grow_test.mbt new file mode 100644 index 0000000..846fdb7 --- /dev/null +++ b/conformance/chicle/upstream/measure_child_with_flex_grow_test.mbt @@ -0,0 +1,45 @@ +// 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 "measure_child_with_flex_grow (upstream: generated/flex/measure_child_with_flex_grow.rs)" { + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "H\u{200B}H\u{200B}H\u{200B}H\u{200B}H", + writing_mode: Horizontal, + }) + 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 layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 50.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.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) +} diff --git a/conformance/chicle/upstream/measure_fixtures_test.mbt b/conformance/chicle/upstream/measure_fixtures_test.mbt new file mode 100644 index 0000000..1d35382 --- /dev/null +++ b/conformance/chicle/upstream/measure_fixtures_test.mbt @@ -0,0 +1,170 @@ +// 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. + +///| +enum WritingMode { + Horizontal + Vertical +} + +///| +struct TextMeasure { + text_content : String + writing_mode : WritingMode +} + +///| +fn[T] unwrap_or_else(x : T?, fallback : () -> T) -> T { + match x { + Some(v) => v + None => fallback() + } +} + +///| +fn to_int_floor(x : Double) -> Int { + x.floor().to_int() +} + +///| +fn measure_text( + known_dimensions : Size[Double?], + available_space : Size[AvailableSpace], + _node_id : NodeId, + node_context : TextMeasure?, + _style : Style, +) -> Size[Double] { + let h_width = 10.0 + let h_height = 10.0 + // U+200B ZERO WIDTH SPACE + let zws = "\u{200B}" + match (known_dimensions.width, known_dimensions.height) { + (Some(w), Some(h)) => return Size(width=w, height=h) + _ => () + } + let ctx = match node_context { + Some(c) => c + None => return Size::zero() + } + let is_horizontal = match ctx.writing_mode { + Horizontal => true + Vertical => false + } + let mut saw_any = false + let mut min_line_length = 0 + let mut max_line_length = 0 + for seg in ctx.text_content.split(zws) { + saw_any = true + let len = seg.length() + if len > min_line_length { + min_line_length = len + } + max_line_length = max_line_length + len + } + if !saw_any { + return Size::zero() + } + let inline_known = if is_horizontal { + known_dimensions.width + } else { + known_dimensions.height + } + let block_known = if is_horizontal { + known_dimensions.height + } else { + known_dimensions.width + } + let inline_avail = if is_horizontal { + available_space.width + } else { + available_space.height + } + let min_inline = min_line_length.to_double() * h_width + let max_inline = max_line_length.to_double() * h_width + let inline_size = unwrap_or_else(inline_known, fn() { + match inline_avail { + AvailMinContent => min_inline + AvailMaxContent => max_inline + AvailDefinite(v) => if v < max_inline { v } else { max_inline } + } + }) + let inline_size = if inline_size > min_inline { + inline_size + } else { + min_inline + } + let block_size = unwrap_or_else(block_known, fn() { + match _style.aspect_ratio { + Some(ratio) => + if ratio > 0.0 { + if is_horizontal { + inline_size / ratio + } else { + inline_size * ratio + } + } else { + let inline_line_length = to_int_floor(inline_size / h_width) + let mut line_count = 1 + let mut current_line_length = 0 + for seg in ctx.text_content.split(zws) { + let len = seg.length() + if current_line_length + len > inline_line_length { + if current_line_length > 0 { + line_count = line_count + 1 + } + current_line_length = len + } else { + current_line_length = current_line_length + len + } + } + line_count.to_double() * h_height + } + None => { + let inline_line_length = to_int_floor(inline_size / h_width) + let mut line_count = 1 + let mut current_line_length = 0 + for seg in ctx.text_content.split(zws) { + let len = seg.length() + if current_line_length + len > inline_line_length { + if current_line_length > 0 { + line_count = line_count + 1 + } + current_line_length = len + } else { + current_line_length = current_line_length + len + } + } + line_count.to_double() * h_height + } + } + }) + if is_horizontal { + Size(width=inline_size, height=block_size) + } else { + Size(width=block_size, height=inline_size) + } +} + +///| +test "measure_text_vertical_smoke" { + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context(Style::default(), { + text_content: "H\u{200B}H\u{200B}H\u{200B}H\u{200B}H", + writing_mode: Vertical, + }) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 10.0) + assert_eq(layout.size.height, 50.0) +} diff --git a/conformance/chicle/upstream/moon.pkg b/conformance/chicle/upstream/moon.pkg new file mode 100644 index 0000000..b4017b2 --- /dev/null +++ b/conformance/chicle/upstream/moon.pkg @@ -0,0 +1,7 @@ +import { + "Milky2018/chicle/geometry" @geometry, + "Milky2018/chicle/style" @style, + "Milky2018/chicle/style_helpers" @style_helpers, + "Milky2018/chicle/tree" @tree, + "moonbitlang/core/json", +} diff --git a/conformance/chicle/upstream/prelude.mbt b/conformance/chicle/upstream/prelude.mbt new file mode 100644 index 0000000..7030519 --- /dev/null +++ b/conformance/chicle/upstream/prelude.mbt @@ -0,0 +1,159 @@ +// 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. + +///| +pub using @geometry { + abstract_axis_block, + abstract_axis_inline, + type AvailableSpace, + type AbsoluteAxis, + type AbstractAxis, + type Line, + type Point, + type Rect, + type Size, +} + +///| +pub using @style { + length_percentage_auto_auto, + length_percentage_auto_length, + length_percentage_auto_percent, + length_percentage_length, + length_percentage_percent, + type AlignContent, + type AlignItems, + type AlignSelf, + type BoxSizing, + type Dimension, + type Display, + type FlexDirection, + type FlexWrap, + type GridAutoFlow, + type GridPlacement, + type GridTrackRepetition, + type JustifyContent, + type JustifyItems, + type JustifySelf, + type LengthPercentage, + type LengthPercentageAuto, + type MaxTrackSizingFunction, + type MinTrackSizingFunction, + type NonRepeatedTrackSizingFunction, + type Overflow, + type Position, + type Style, + type TrackSizingFunction, +} + +///| +pub using @style_helpers { + align_content_center, + align_content_end, + align_content_flex_end, + align_content_flex_start, + align_content_space_around, + align_content_space_between, + align_content_space_evenly, + align_content_start, + align_content_stretch, + align_items_baseline, + align_items_center, + align_items_end, + align_items_flex_end, + align_items_flex_start, + align_items_start, + align_items_stretch, + auto, + available_space_definite, + box_sizing_border_box, + box_sizing_content_box, + display_block, + display_flex, + display_grid, + display_none, + evenly_sized_tracks, + fit_content, + flex, + flex_direction_column, + flex_direction_column_reverse, + flex_direction_row, + flex_direction_row_reverse, + flex_wrap_no_wrap, + flex_wrap_wrap, + flex_wrap_wrap_reverse, + fr, + grid_auto_flow_column, + grid_auto_flow_column_dense, + grid_auto_flow_row, + grid_auto_flow_row_dense, + grid_max_content, + grid_min_content, + justify_content_center, + justify_content_end, + justify_content_flex_end, + justify_content_flex_start, + justify_content_space_around, + justify_content_space_between, + justify_content_space_evenly, + justify_content_start, + justify_content_stretch, + length, + line, + max_content, + max_track_auto, + max_track_fit_content, + max_track_fixed, + max_track_fraction, + max_track_max_content, + max_track_min_content, + min_content, + min_track_auto, + min_track_fixed, + min_track_max_content, + min_track_min_content, + minmax, + overflow_clip, + overflow_hidden, + overflow_scroll, + overflow_visible, + percent, + place_auto, + position_absolute, + position_relative, + repeat, + repeat_auto_fill, + repeat_auto_fit, + repeat_count, + repeated_track_sizing_function, + span, + track_sizing_function, + zero, +} + +///| +pub using @tree { + layout_input_for_compute_size, + layout_input_for_perform_layout, + requested_axis_from_absolute, + type Layout, + type LayoutInput, + type LayoutOutput, + type NodeId, + type RequestedAxis, + type RunMode, + type SizingMode, + type ChicleError, + type ChicleTree, +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part01_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part01_test.mbt new file mode 100644 index 0000000..5db04a0 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part01_test.mbt @@ -0,0 +1,1001 @@ +// 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/block/block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_aspect_ratio(3.0) + .with_inset( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 360.0) + assert_eq(c.size.height, 120.0) + assert_eq(c.location.x, 20.0) + assert_eq(c.location.y, 15.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_height" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=percent(0.5), height=auto())) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=percent(0.05), right=auto(), top=percent(0.05), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 200.0) + assert_eq(c.size.height, 67.0) + assert_eq(c.location.x, 20.0) + assert_eq(c.location.y, 15.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_height_from_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_height_from_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_aspect_ratio(3.0) + .with_inset( + Rect( + left=percent(0.1), + right=percent(0.1), + top=percent(0.05), + bottom=auto(), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 320.0) + assert_eq(c.size.height, 107.0) + assert_eq(c.location.x, 40.0) + assert_eq(c.location.y, 15.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_max_height" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context( + Style::default() + .with_position(position_absolute()) + .with_max_size(Size(width=length(50.0), height=auto())) + .with_aspect_ratio(3.0), + { + text_content: "HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH", + writing_mode: Horizontal, + }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 17.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_max_width" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context( + Style::default() + .with_position(position_absolute()) + .with_max_size(Size(width=auto(), height=length(50.0))) + .with_aspect_ratio(0.5), + { + text_content: "HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH", + writing_mode: Horizontal, + }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 25.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_min_height" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_min_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_min_size(Size(width=length(50.0), height=auto())) + .with_aspect_ratio(3.0), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 17.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_min_width" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_min_width.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_min_size(Size(width=auto(), height=length(50.0))) + .with_aspect_ratio(0.5), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 25.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_width" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_width.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=auto(), height=percent(0.2))) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=percent(0.05), right=auto(), top=percent(0.05), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 180.0) + assert_eq(c.size.height, 60.0) + assert_eq(c.location.x, 20.0) + assert_eq(c.location.y, 15.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_fill_width_from_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_fill_width_from_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.3), bottom=percent(0.5)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 180.0) + assert_eq(c.size.height, 60.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 90.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_height_overrides_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_height_overrides_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=auto(), height=percent(0.1))) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.3), bottom=percent(0.5)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 90.0) + assert_eq(c.size.height, 30.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 90.0) +} + +///| +test "upstream/generated/block/block_absolute_aspect_ratio_width_overrides_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_aspect_ratio_width_overrides_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=percent(0.4), height=auto())) + .with_aspect_ratio(3.0) + .with_inset( + Rect( + left=percent(0.1), + right=percent(0.1), + top=percent(0.05), + bottom=auto(), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 400.0) + assert_eq(root_layout.size.height, 300.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 160.0) + assert_eq(c.size.height, 53.0) + assert_eq(c.location.x, 40.0) + assert_eq(c.location.y, 15.0) +} + +///| +test "upstream/generated/block/block_absolute_child_with_margin_x" { + // Ported from taffy-reference/tests/generated/block/block_absolute_child_with_margin_x.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(9.0), height=length(9.0))) + .with_margin( + Rect( + left=length(7.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(9.0), height=length(9.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(7.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(9.0), height=length(9.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(5.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(20.0), height=length(37.0))), + [node0, node1, node2], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 20.0) + assert_eq(root_layout.size.height, 37.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 9.0) + assert_eq(l0.size.height, 9.0) + assert_eq(l0.location.x, 7.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 9.0) + assert_eq(l1.size.height, 9.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 9.0) + assert_eq(l2.size.height, 9.0) + assert_eq(l2.location.x, 10.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_child_with_margin_y" { + // Ported from taffy-reference/tests/generated/block/block_absolute_child_with_margin_y.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(9.0), height=length(9.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(7.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(9.0), height=length(9.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(7.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(9.0), height=length(9.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(5.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(20.0), height=length(37.0))), + [node0, node1, node2], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 20.0) + assert_eq(root_layout.size.height, 37.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 9.0) + assert_eq(l0.size.height, 9.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 7.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 9.0) + assert_eq(l1.size.height, 9.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 9.0) + assert_eq(l2.size.height, 9.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_child_with_max_height" { + // Ported from taffy-reference/tests/generated/block/block_absolute_child_with_max_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(150.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_max_size(Size(width=auto(), height=length(100.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=auto(), bottom=length(20.0)), + ), + [node00], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 200.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, 80.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 150.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_child_order" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_child_order.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(110.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 110.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.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, 60.0) + assert_eq(l1.size.height, 40.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 40.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 60.0) + assert_eq(l2.size.height, 40.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 40.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_no_size" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_no_size.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default().with_position(position_absolute()), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 0.0) + assert_eq(c.size.height, 0.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_percentage_bottom_based_on_parent_height" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_percentage_bottom_based_on_parent_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.5), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=auto(), bottom=percent(0.5)), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=auto())) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.1), bottom=percent(0.1)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(200.0))), + [node0, node1, node2], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 200.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, 0.0) + assert_eq(l0.location.y, 100.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 90.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 10.0) + assert_eq(l2.size.height, 160.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 20.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_percentage_height" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_percentage_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=percent(0.5))) + .with_inset( + Rect(left=length(10.0), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 10.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_row_width_height_end_bottom" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_row_width_height_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 10.0) + assert_eq(c.size.height, 10.0) + assert_eq(c.location.x, 80.0) + assert_eq(c.location.y, 80.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_start_top_end_bottom" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_start_top_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_inset( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 80.0) + assert_eq(c.size.height, 80.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_width_height_end_bottom" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_width_height_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 10.0) + assert_eq(c.size.height, 10.0) + assert_eq(c.location.x, 80.0) + assert_eq(c.location.y, 80.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_width_height_start_top" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_width_height_start_top.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=length(10.0), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 10.0) + assert_eq(c.size.height, 10.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_width_height_start_top_end_bottom" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_width_height_start_top_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 10.0) + assert_eq(c.size.height, 10.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_layout_within_border" { + // Ported from taffy-reference/tests/generated/block/block_absolute_layout_within_border.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=auto(), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_inset( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=auto()), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_inset( + Rect(left=auto(), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0, node1, node2, node3], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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, 10.0) + assert_eq(l0.location.y, 10.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, 40.0) + assert_eq(l1.location.y, 40.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 20.0) + assert_eq(l2.location.y, 20.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 30.0) + assert_eq(l3.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_bottom_and_top_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_bottom_and_top_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=auto()), + ) + .with_inset( + Rect(left=auto(), right=auto(), top=length(10.0), bottom=length(20.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 70.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part02_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part02_test.mbt new file mode 100644 index 0000000..3579621 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part02_test.mbt @@ -0,0 +1,894 @@ +// 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/block/block_absolute_margin_auto_bottom_and_top_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_bottom_and_top_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_bottom_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_bottom_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=length(0.0), bottom=auto()), + ) + .with_inset( + Rect(left=auto(), right=auto(), top=length(10.0), bottom=length(20.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_bottom_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_bottom_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_and_right_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_and_right_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(10.0), right=length(20.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 70.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_and_right_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_and_right_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(10.0), right=length(20.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, -40.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_child_bigger_than_parent_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(10.0), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(10.0), right=length(20.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, -50.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_fix_right_child_bigger_than_parent_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(10.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(10.0), right=length(20.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_right_child_bigger_than_parent_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(10.0), right=length(20.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 130.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_left_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_left_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_multiple_children_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_multiple_children_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(100.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(10.0), right=length(20.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(20.0), right=length(10.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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, 10.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, 20.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_multiple_children_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_multiple_children_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(100.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_right_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_right_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ) + .with_inset( + Rect(left=length(10.0), right=length(20.0), top=auto(), bottom=auto()), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_right_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_right_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_top_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_top_with_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ) + .with_inset( + Rect(left=auto(), right=auto(), top=length(20.0), bottom=length(10.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 140.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_auto_top_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_auto_top_without_inset.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_bottom_left_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_bottom_left_with_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ) + .with_inset( + Rect( + left=length(20.0), + right=length(10.0), + top=length(10.0), + bottom=length(20.0), + ), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 10.0) + assert_eq(c.size.height, 10.0) + assert_eq(c.location.x, 30.0) + assert_eq(c.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_margin_bottom_left_without_inset" { + // Ported from taffy-reference/tests/generated/block/block_absolute_margin_bottom_left_without_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 10.0) + assert_eq(c.size.height, 10.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_minmax_bottom_right_max" { + // Ported from taffy-reference/tests/generated/block/block_absolute_minmax_bottom_right_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 40.0) + assert_eq(c.size.height, 30.0) + assert_eq(c.location.x, 50.0) + assert_eq(c.location.y, 60.0) +} + +///| +test "upstream/generated/block/block_absolute_minmax_bottom_right_min_max" { + // Ported from taffy-reference/tests/generated/block/block_absolute_minmax_bottom_right_min_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_min_size(Size(width=length(50.0), height=length(60.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 60.0) + assert_eq(c.location.x, 40.0) + assert_eq(c.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_absolute_minmax_bottom_right_min_max_preferred" { + // Ported from taffy-reference/tests/generated/block/block_absolute_minmax_bottom_right_min_max_preferred.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_min_size(Size(width=length(50.0), height=length(60.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 60.0) + assert_eq(c.location.x, 40.0) + assert_eq(c.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_absolute_minmax_top_left_bottom_right_max" { + // Ported from taffy-reference/tests/generated/block/block_absolute_minmax_top_left_bottom_right_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 40.0) + assert_eq(c.size.height, 30.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 10.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part03_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part03_test.mbt new file mode 100644 index 0000000..de8fd20 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part03_test.mbt @@ -0,0 +1,1086 @@ +// 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/block/block_absolute_minmax_top_left_bottom_right_min_max" { + // Ported from taffy-reference/tests/generated/block/block_absolute_minmax_top_left_bottom_right_min_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_min_size(Size(width=length(50.0), height=length(60.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 50.0) + assert_eq(c.size.height, 60.0) + assert_eq(c.location.x, 10.0) + assert_eq(c.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_no_styles" { + // Ported from taffy-reference/tests/generated/block/block_absolute_no_styles.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 10.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + 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, 10.0) +} + +///| +test "upstream/generated/block/block_absolute_padding_border_overrides_max_size" { + // Ported from taffy-reference/tests/generated/block/block_absolute_padding_border_overrides_max_size.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_max_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 0.0) + assert_eq(root_layout.size.height, 0.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 22.0) + assert_eq(c.size.height, 14.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_absolute_padding_border_overrides_size" { + // Ported from taffy-reference/tests/generated/block/block_absolute_padding_border_overrides_size.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_position(position_absolute()) + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [child], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 0.0) + assert_eq(root_layout.size.height, 0.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(child) + assert_eq(c.size.width, 22.0) + assert_eq(c.size.height, 14.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_align_baseline_child" { + // Ported from taffy-reference/tests/generated/block/block_align_baseline_child.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let root = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 30.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_align_baseline_child_margin" { + // Ported from taffy-reference/tests/generated/block/block_align_baseline_child_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(10.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let root = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 35.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 5.0) + assert_eq(l10.location.y, 5.0) +} + +///| +test "upstream/generated/block/block_align_baseline_child_margin_percent" { + // Ported from taffy-reference/tests/generated/block/block_align_baseline_child_margin_percent.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(10.0))) + .with_margin( + Rect( + left=percent(0.01), + right=percent(0.01), + top=percent(0.01), + bottom=percent(0.01), + ), + ), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let root = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 35.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 1.0) + assert_eq(l10.location.y, 1.0) +} + +///| +test "upstream/generated/block/block_align_baseline_child_padding" { + // Ported from taffy-reference/tests/generated/block/block_align_baseline_child_padding.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node10], + ) + let root = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 45.0) + assert_eq(l1.location.y, 35.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 5.0) + assert_eq(l10.location.y, 5.0) +} + +///| +test "upstream/generated/block/block_align_baseline_child_top" { + // Ported from taffy-reference/tests/generated/block/block_align_baseline_child_top.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let root = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 30.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_align_baseline_child_top2" { + // Ported from taffy-reference/tests/generated/block/block_align_baseline_child_top2.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))) + .with_inset(Rect(left=auto(), right=auto(), top=length(5.0), bottom=auto())), + [node10], + ) + let root = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 35.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_align_baseline_double_nested_child" { + // Ported from taffy-reference/tests/generated/block/block_align_baseline_double_nested_child.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node00], + ) + let node10 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(15.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let root = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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 l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 20.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, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 30.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 15.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_aspect_ratio_fill_height" { + // Ported from taffy-reference/tests/generated/block/block_aspect_ratio_fill_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 40.0) + assert_eq(c.size.height, 20.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_aspect_ratio_fill_max_height" { + // Ported from taffy-reference/tests/generated/block/block_aspect_ratio_fill_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_max_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.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\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 40.0) + assert_eq(c.size.height, 20.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_aspect_ratio_fill_max_width" { + // Ported from taffy-reference/tests/generated/block/block_aspect_ratio_fill_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_max_size(Size(width=auto(), height=length(20.0))) + .with_aspect_ratio(2.0), + { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 40.0) + assert_eq(c.size.height, 20.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_aspect_ratio_fill_min_height" { + // Ported from taffy-reference/tests/generated/block/block_aspect_ratio_fill_min_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_min_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 100.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_aspect_ratio_fill_min_width" { + // Ported from taffy-reference/tests/generated/block/block_aspect_ratio_fill_min_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_min_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + { text_content: "", writing_mode: Horizontal }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 100.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_aspect_ratio_fill_width" { + // Ported from taffy-reference/tests/generated/block/block_aspect_ratio_fill_width.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 80.0) + assert_eq(c.size.height, 40.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_basic" { + // Ported from taffy-reference/tests/generated/block/block_basic.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 50.0) + assert_eq(layout.size.height, 20.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 50.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 50.0) + assert_eq(c1.size.height, 10.0) + assert_eq(c1.location.x, 0.0) + assert_eq(c1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_border_fixed_size" { + // Ported from taffy-reference/tests/generated/block/block_border_fixed_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_border( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 50.0) + assert_eq(layout.size.height, 50.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 38.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 8.0) + assert_eq(c0.location.y, 2.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 38.0) + assert_eq(c1.size.height, 10.0) + assert_eq(c1.location.x, 8.0) + assert_eq(c1.location.y, 12.0) +} + +///| +test "upstream/generated/block/block_border_intrinsic_size" { + // Ported from taffy-reference/tests/generated/block/block_border_intrinsic_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_border( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 62.0) + assert_eq(layout.size.height, 28.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 50.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 8.0) + assert_eq(c0.location.y, 2.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 50.0) + assert_eq(c1.size.height, 10.0) + assert_eq(c1.location.x, 8.0) + assert_eq(c1.location.y, 12.0) +} + +///| +test "upstream/generated/block/block_border_percentage_fixed_size" { + // Ported from taffy-reference/tests/generated/block/block_border_percentage_fixed_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_block()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 50.0) + assert_eq(layout.size.height, 50.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 50.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c00 = taffy.layout(node00) + assert_eq(c00.size.width, 50.0) + assert_eq(c00.size.height, 10.0) + assert_eq(c00.location.x, 0.0) + assert_eq(c00.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_border_percentage_intrinsic_size" { + // Ported from taffy-reference/tests/generated/block/block_border_percentage_intrinsic_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_block()), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 0.0) + assert_eq(layout.size.height, 10.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 0.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c00 = taffy.layout(node00) + assert_eq(c00.size.width, 0.0) + assert_eq(c00.size.height, 10.0) + assert_eq(c00.location.x, 0.0) + assert_eq(c00.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_display_none" { + // Ported from taffy-reference/tests/generated/block/block_display_none.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_none()) + .with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 50.0) + assert_eq(layout.size.height, 20.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 50.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 0.0) + assert_eq(c1.size.height, 0.0) + assert_eq(c1.location.x, 0.0) + assert_eq(c1.location.y, 0.0) + let c2 = taffy.layout(node2) + assert_eq(c2.size.width, 50.0) + assert_eq(c2.size.height, 10.0) + assert_eq(c2.location.x, 0.0) + assert_eq(c2.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_display_none_with_child" { + // Ported from taffy-reference/tests/generated/block/block_display_none_with_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node10 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=length(20.0), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_with_children( + Style::default().with_display(display_none()), + [node10], + ) + let node2 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .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 layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 100.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 0.0) + assert_eq(c1.size.height, 0.0) + assert_eq(c1.location.x, 0.0) + assert_eq(c1.location.y, 0.0) + let c10 = taffy.layout(node10) + assert_eq(c10.size.width, 0.0) + assert_eq(c10.size.height, 0.0) + assert_eq(c10.location.x, 0.0) + assert_eq(c10.location.y, 0.0) + let c2 = taffy.layout(node2) + assert_eq(c2.size.width, 100.0) + assert_eq(c2.size.height, 10.0) + assert_eq(c2.location.x, 0.0) + assert_eq(c2.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_display_none_with_inset" { + // Ported from taffy-reference/tests/generated/block/block_display_none_with_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_none()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(10.0), bottom=auto()), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .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 layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 100.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 0.0) + assert_eq(c1.size.height, 0.0) + assert_eq(c1.location.x, 0.0) + assert_eq(c1.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part04_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part04_test.mbt new file mode 100644 index 0000000..011ca01 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part04_test.mbt @@ -0,0 +1,986 @@ +// 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/block/block_display_none_with_margin" { + // Ported from taffy-reference/tests/generated/block/block_display_none_with_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + 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), + ), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .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 layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 0.0) + assert_eq(c0.size.height, 0.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 100.0) + assert_eq(c1.size.height, 10.0) + assert_eq(c1.location.x, 0.0) + assert_eq(c1.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_display_none_with_position_absolute" { + // Ported from taffy-reference/tests/generated/block/block_display_none_with_position_absolute.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_none()) + .with_position(position_absolute()) + .with_size(Size(width=length(100.0), height=length(100.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 0.0) + assert_eq(c0.size.height, 0.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_inset_fixed" { + // Ported from taffy-reference/tests/generated/block/block_inset_fixed.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=length(2.0), right=auto(), top=length(4.0), bottom=auto()), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=length(6.0), top=auto(), bottom=length(8.0)), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect( + left=length(2.0), + right=length(6.0), + top=length(4.0), + bottom=length(8.0), + ), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 50.0) + assert_eq(layout.size.height, 30.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 50.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 2.0) + assert_eq(c0.location.y, 4.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 50.0) + assert_eq(c1.size.height, 10.0) + assert_eq(c1.location.x, -6.0) + assert_eq(c1.location.y, 2.0) + let c2 = taffy.layout(node2) + assert_eq(c2.size.width, 50.0) + assert_eq(c2.size.height, 10.0) + assert_eq(c2.location.x, 2.0) + assert_eq(c2.location.y, 24.0) +} + +///| +test "upstream/generated/block/block_inset_percentage" { + // Ported from taffy-reference/tests/generated/block/block_inset_percentage.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=percent(0.02), right=auto(), top=percent(0.04), bottom=auto()), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=percent(0.06), top=auto(), bottom=percent(0.08)), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect( + left=percent(0.02), + right=percent(0.06), + top=percent(0.04), + bottom=percent(0.08), + ), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 50.0) + assert_eq(layout.size.height, 30.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 50.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 1.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 50.0) + assert_eq(c1.size.height, 10.0) + assert_eq(c1.location.x, -3.0) + assert_eq(c1.location.y, 10.0) + let c2 = taffy.layout(node2) + assert_eq(c2.size.width, 50.0) + assert_eq(c2.size.height, 10.0) + assert_eq(c2.location.x, 1.0) + assert_eq(c2.location.y, 20.0) +} + +///| +test "upstream/generated/block/block_intrinsic_width" { + // Ported from taffy-reference/tests/generated/block/block_intrinsic_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 50.0) + assert_eq(layout.size.height, 20.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 50.0) + assert_eq(c0.size.height, 10.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 50.0) + assert_eq(c1.size.height, 10.0) + assert_eq(c1.location.x, 0.0) + assert_eq(c1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_item_max_width" { + // Ported from taffy-reference/tests/generated/block/block_item_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_max_size(Size(width=length(100.0), height=auto())), + { text_content: "", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_max_size(Size(width=length(300.0), height=auto())), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 200.0) + assert_eq(layout.size.height, 200.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 100.0) + assert_eq(c0.size.height, 50.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) + let c1 = taffy.layout(node1) + assert_eq(c1.size.width, 200.0) + assert_eq(c1.size.height, 50.0) + assert_eq(c1.location.x, 0.0) + assert_eq(c1.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_item_min_width_overrides_max_width" { + // Ported from taffy-reference/tests/generated/block/block_item_min_width_overrides_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_min_size(Size(width=length(200.0), height=auto())) + .with_max_size(Size(width=length(50.0), height=auto())), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let layout = taffy.layout(node) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) + assert_eq(layout.location.x, 0.0) + assert_eq(layout.location.y, 0.0) + let c0 = taffy.layout(node0) + assert_eq(c0.size.width, 200.0) + assert_eq(c0.size.height, 50.0) + assert_eq(c0.location.x, 0.0) + assert_eq(c0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_auto_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_margin_auto_bottom_and_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_bottom_and_top.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_margin_auto_left" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_left.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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, 150.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_margin_auto_left_and_right" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_left_and_right.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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, 75.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_margin_auto_left_and_right_with_auto_width" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_left_and_right_with_auto_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_max_size(Size(width=length(100.0), height=auto())) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 100.0) + assert_eq(c.size.height, 50.0) + assert_eq(c.location.x, 50.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_auto_left_child_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_left_child_bigger_than_parent.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_auto_left_fix_right_child_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_left_fix_right_child_bigger_than_parent.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(10.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_auto_left_right_child_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_left_right_child_bigger_than_parent.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 52.0) + assert_eq(root_layout.size.height, 52.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let c = taffy.layout(node0) + assert_eq(c.size.width, 72.0) + assert_eq(c.size.height, 72.0) + assert_eq(c.location.x, 0.0) + assert_eq(c.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_auto_multiple_children" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_multiple_children.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(100.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1, node2], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 100.0) +} + +///| +test "upstream/generated/block/block_margin_auto_right" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_right.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_margin_auto_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_auto_top.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_margin_x_fixed_auto_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_fixed_auto_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(10.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.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, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_fixed_auto_left" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_fixed_auto_left.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(10.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 30.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, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_fixed_auto_left_and_right" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_fixed_auto_left_and_right.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(10.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 15.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, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_fixed_auto_right" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_fixed_auto_right.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(10.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.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, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_fixed_auto_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_fixed_auto_top.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(10.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.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, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_fixed_size_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_fixed_size_negative.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(-10.0), + right=length(-5.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 65.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, -10.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, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_fixed_size_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_fixed_size_positive.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(5.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 35.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 10.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, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part05_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part05_test.mbt new file mode 100644 index 0000000..4fa8fdb --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part05_test.mbt @@ -0,0 +1,1631 @@ +// 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/block/block_margin_x_intrinsic_size_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_intrinsic_size_negative.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(-10.0), + right=length(-5.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 0.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 15.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, -10.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, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_intrinsic_size_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_intrinsic_size_positive.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(5.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 15.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 0.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 15.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_percentage_fixed_size_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_percentage_fixed_size_negative.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=percent(-0.2), + right=percent(-0.1), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 65.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, -10.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, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_percentage_fixed_size_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_percentage_fixed_size_positive.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 35.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 10.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, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_x_percentage_intrinsic_size_other_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_percentage_intrinsic_size_other_negative.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=percent(-0.2), + right=percent(-0.1), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 130.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, -20.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) +} + +///| +test "upstream/generated/block/block_margin_x_percentage_intrinsic_size_other_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_percentage_intrinsic_size_other_positive.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(10.0))), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 20.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 70.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 20.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) +} + +///| +test "upstream/generated/block/block_margin_x_percentage_intrinsic_size_self_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_percentage_intrinsic_size_self_negative.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(100.0), height=length(10.0))) + .with_margin( + Rect( + left=percent(-0.2), + right=percent(-0.1), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 10.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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, -20.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_x_percentage_intrinsic_size_self_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_x_percentage_intrinsic_size_self_positive.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(100.0), height=length(10.0))) + .with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 10.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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, 20.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_complex" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_complex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(-5.0), + ), + ), + ) + let node11 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(7.0), + bottom=length(3.0), + ), + ), + ) + let node12 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-6.0), + bottom=length(9.0), + ), + ), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + [node10, node11, node12], + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(-5.0), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 0.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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, -10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, -10.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 0.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, -5.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 0.0) + assert_eq(l11.size.height, 10.0) + assert_eq(l11.location.x, 0.0) + assert_eq(l11.location.y, 7.0) + let l12 = taffy.layout(node12) + assert_eq(l12.size.width, 0.0) + assert_eq(l12.size.height, 10.0) + assert_eq(l12.location.x, 0.0) + assert_eq(l12.location.y, -6.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, -10.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, -10.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_aspect_ratio" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_aspect_ratio.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_aspect_ratio(2.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 65.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 25.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 55.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_border_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_border_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 30.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.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/block/block_margin_y_collapse_through_blocked_by_border_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_border_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 30.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.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/block/block_margin_y_collapse_through_blocked_by_height" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(1.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 41.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 1.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 31.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_line_box" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + { text_content: "HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 50.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 40.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_height_zero" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_height_zero.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(0.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + { text_content: "HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 40.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_line_box_with_max_height_zero.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_max_size(Size(width=auto(), height=length(0.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + { text_content: "HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 40.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_min_height" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_min_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_min_size(Size(width=auto(), height=length(1.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 41.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 1.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 31.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_hidden" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_hidden(), y=overflow_visible())) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 40.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_scroll" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_x_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 40.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_hidden" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_visible(), y=overflow_hidden())) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 40.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_scroll" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_overflow_y_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 40.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_padding_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_padding_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(1.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 41.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 1.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 31.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_blocked_by_padding_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_blocked_by_padding_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=length(1.0), + bottom=length(0.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 41.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 1.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 31.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-5.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-7.0), + bottom=length(-3.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-2.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 13.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 3.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 3.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_positive.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 30.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 20.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part06_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part06_test.mbt new file mode 100644 index 0000000..9bd0eee --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part06_test.mbt @@ -0,0 +1,1880 @@ +// 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/block/block_margin_y_collapse_through_positive_and_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_positive_and_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(-4.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(7.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 17.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 5.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 7.0) +} + +///| +test "upstream/generated/block/block_margin_y_collapse_through_with_absolute_child" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_collapse_through_with_absolute_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node10 = taffy.new_leaf_with_context( + Style::default() + .with_position(position_absolute()) + .with_display(display_block()), + { text_content: "HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node10], + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 50.0) + assert_eq(root_layout.size.height, 30.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 20.0) + assert_eq(l10.size.height, 10.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, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 20.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_blocked_by_border_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_border_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ) + .with_overflow(Point(x=overflow_hidden(), y=overflow_visible())), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 10.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_x_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .with_scrollbar_width(15.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 45.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 35.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 10.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_visible(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 10.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_overflow_y_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 35.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 10.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 35.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_blocked_by_padding_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_blocked_by_padding_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=length(1.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 31.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 21.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 11.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_negative_equal" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_negative_equal.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_negative_parent_larger" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_negative_parent_larger.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_negative_parent_smaller" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_negative_parent_smaller.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_not_blocked_by_border_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_not_blocked_by_border_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_not_blocked_by_padding_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_not_blocked_by_padding_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(1.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 21.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 11.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_positive_and_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_positive_and_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node100 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node10 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(0.0), + ), + ), + [node100], + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node10], + ) + let node200 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node20 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node200], + ) + let node2 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(0.0), + ), + ), + [node20], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 5.0) + let l_node10 = taffy.layout(node10) + assert_eq(l_node10.size.width, 50.0) + assert_eq(l_node10.size.height, 10.0) + assert_eq(l_node10.location.x, 0.0) + assert_eq(l_node10.location.y, 0.0) + let l_node100 = taffy.layout(node100) + assert_eq(l_node100.size.width, 50.0) + assert_eq(l_node100.size.height, 10.0) + assert_eq(l_node100.location.x, 0.0) + assert_eq(l_node100.location.y, 0.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 20.0) + let l_node20 = taffy.layout(node20) + assert_eq(l_node20.size.width, 50.0) + assert_eq(l_node20.size.height, 10.0) + assert_eq(l_node20.location.x, 0.0) + assert_eq(l_node20.location.y, 0.0) + let l_node200 = taffy.layout(node200) + assert_eq(l_node200.size.width, 50.0) + assert_eq(l_node200.size.height, 10.0) + assert_eq(l_node200.location.x, 0.0) + assert_eq(l_node200.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_positive_equal" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_positive_equal.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_positive_parent_larger" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_positive_parent_larger.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_child_collapse_positive_parent_smaller" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_child_collapse_positive_parent_smaller.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_granchild_collapse_positive_and_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_granchild_collapse_positive_and_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node000 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node0000], + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node1000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node100 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-2.0), + bottom=length(0.0), + ), + ), + [node1000], + ) + let node10 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(0.0), + ), + ), + [node100], + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node10], + ) + let node2000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node200 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(15.0), + bottom=length(0.0), + ), + ), + [node2000], + ) + let node20 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(0.0), + ), + ), + [node200], + ) + let node2 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(0.0), + ), + ), + [node20], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) + let l_node0000 = taffy.layout(node0000) + assert_eq(l_node0000.size.width, 50.0) + assert_eq(l_node0000.size.height, 10.0) + assert_eq(l_node0000.location.x, 0.0) + assert_eq(l_node0000.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 5.0) + let l_node10 = taffy.layout(node10) + assert_eq(l_node10.size.width, 50.0) + assert_eq(l_node10.size.height, 10.0) + assert_eq(l_node10.location.x, 0.0) + assert_eq(l_node10.location.y, 0.0) + let l_node100 = taffy.layout(node100) + assert_eq(l_node100.size.width, 50.0) + assert_eq(l_node100.size.height, 10.0) + assert_eq(l_node100.location.x, 0.0) + assert_eq(l_node100.location.y, 0.0) + let l_node1000 = taffy.layout(node1000) + assert_eq(l_node1000.size.width, 50.0) + assert_eq(l_node1000.size.height, 10.0) + assert_eq(l_node1000.location.x, 0.0) + assert_eq(l_node1000.location.y, 0.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 20.0) + let l_node20 = taffy.layout(node20) + assert_eq(l_node20.size.width, 50.0) + assert_eq(l_node20.size.height, 10.0) + assert_eq(l_node20.location.x, 0.0) + assert_eq(l_node20.location.y, 0.0) + let l_node200 = taffy.layout(node200) + assert_eq(l_node200.size.width, 50.0) + assert_eq(l_node200.size.height, 10.0) + assert_eq(l_node200.location.x, 0.0) + assert_eq(l_node200.location.y, 0.0) + let l_node2000 = taffy.layout(node2000) + assert_eq(l_node2000.size.width, 50.0) + assert_eq(l_node2000.size.height, 10.0) + assert_eq(l_node2000.location.x, 0.0) + assert_eq(l_node2000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_first_granchild_collapse_positive_equal" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_first_granchild_collapse_positive_equal.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node000 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node0000], + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) + let l_node0000 = taffy.layout(node0000) + assert_eq(l_node0000.size.width, 50.0) + assert_eq(l_node0000.size.height, 10.0) + assert_eq(l_node0000.location.x, 0.0) + assert_eq(l_node0000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_blocked_by_border_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_border_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_hidden(), y=overflow_visible())) + .with_scrollbar_width(15.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_x_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .with_scrollbar_width(15.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 45.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 35.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_visible(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_overflow_y_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 35.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 35.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_blocked_by_padding_bottom" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_blocked_by_padding_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(1.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 31.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 21.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part07_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part07_test.mbt new file mode 100644 index 0000000..ddb5d55 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part07_test.mbt @@ -0,0 +1,1894 @@ +// 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/block/block_margin_y_last_child_collapse_negative_equal" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_negative_equal.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_negative_parent_larger" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_negative_parent_larger.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-5.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_negative_parent_smaller" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_negative_parent_smaller.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-5.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_not_blocked_by_border_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_not_blocked_by_border_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_not_blocked_by_padding_top" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_not_blocked_by_padding_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=length(1.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 21.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 11.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 1.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_positive_and_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_positive_and_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-10.0), + ), + ), + [node00], + ) + let node100 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node10 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(5.0), + ), + ), + [node100], + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-10.0), + ), + ), + [node10], + ) + let node200 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node20 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node200], + ) + let node2 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(-5.0), + ), + ), + [node20], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 10.0) + let l_node10 = taffy.layout(node10) + assert_eq(l_node10.size.width, 50.0) + assert_eq(l_node10.size.height, 10.0) + assert_eq(l_node10.location.x, 0.0) + assert_eq(l_node10.location.y, 0.0) + let l_node100 = taffy.layout(node100) + assert_eq(l_node100.size.width, 50.0) + assert_eq(l_node100.size.height, 10.0) + assert_eq(l_node100.location.x, 0.0) + assert_eq(l_node100.location.y, 0.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 15.0) + let l_node20 = taffy.layout(node20) + assert_eq(l_node20.size.width, 50.0) + assert_eq(l_node20.size.height, 10.0) + assert_eq(l_node20.location.x, 0.0) + assert_eq(l_node20.location.y, 0.0) + let l_node200 = taffy.layout(node200) + assert_eq(l_node200.size.width, 50.0) + assert_eq(l_node200.size.height, 10.0) + assert_eq(l_node200.location.x, 0.0) + assert_eq(l_node200.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_positive_equal" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_positive_equal.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_positive_parent_larger" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_positive_parent_larger.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(5.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_child_collapse_positive_parent_smaller" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_child_collapse_positive_parent_smaller.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(5.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_last_granchild_collapse_positive_equal" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_last_granchild_collapse_positive_equal.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node000 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node0000], + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node000 = taffy.layout(node000) + assert_eq(l_node000.size.width, 50.0) + assert_eq(l_node000.size.height, 10.0) + assert_eq(l_node000.location.x, 0.0) + assert_eq(l_node000.location.y, 0.0) + let l_node0000 = taffy.layout(node0000) + assert_eq(l_node0000.size.width, 50.0) + assert_eq(l_node0000.size.height, 10.0) + assert_eq(l_node0000.location.x, 0.0) + assert_eq(l_node0000.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_sibling_collapse_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_sibling_collapse_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(-5.0), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -10.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, -10.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, -10.0) + let l_node3 = taffy.layout(node3) + assert_eq(l_node3.size.width, 50.0) + assert_eq(l_node3.size.height, 10.0) + assert_eq(l_node3.location.x, 0.0) + assert_eq(l_node3.location.y, -10.0) +} + +///| +test "upstream/generated/block/block_margin_y_sibling_collapse_negative_percentage" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_sibling_collapse_negative_percentage.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.1), + bottom=percent(-0.1), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.1), + bottom=percent(-0.1), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.05), + bottom=percent(-0.05), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.1), + bottom=percent(-0.1), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 15.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -5.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 0.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 5.0) + let l_node3 = taffy.layout(node3) + assert_eq(l_node3.size.width, 50.0) + assert_eq(l_node3.size.height, 10.0) + assert_eq(l_node3.location.x, 0.0) + assert_eq(l_node3.location.y, 10.0) +} + +///| +test "upstream/generated/block/block_margin_y_sibling_collapse_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_sibling_collapse_positive.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 90.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 30.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 50.0) + let l_node3 = taffy.layout(node3) + assert_eq(l_node3.size.width, 50.0) + assert_eq(l_node3.size.height, 10.0) + assert_eq(l_node3.location.x, 0.0) + assert_eq(l_node3.location.y, 70.0) +} + +///| +test "upstream/generated/block/block_margin_y_sibling_collapse_positive_and_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_sibling_collapse_positive_and_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(5.0), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node4 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(-10.0), + ), + ), + ) + let node5 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(5.0), + bottom=length(-5.0), + ), + ), + ) + let node6 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3, node4, node5, node6], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 90.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 35.0) + let l_node3 = taffy.layout(node3) + assert_eq(l_node3.size.width, 50.0) + assert_eq(l_node3.size.height, 10.0) + assert_eq(l_node3.location.x, 0.0) + assert_eq(l_node3.location.y, 40.0) + let l_node4 = taffy.layout(node4) + assert_eq(l_node4.size.width, 50.0) + assert_eq(l_node4.size.height, 10.0) + assert_eq(l_node4.location.x, 0.0) + assert_eq(l_node4.location.y, 50.0) + let l_node5 = taffy.layout(node5) + assert_eq(l_node5.size.width, 50.0) + assert_eq(l_node5.size.height, 10.0) + assert_eq(l_node5.location.x, 0.0) + assert_eq(l_node5.location.y, 55.0) + let l_node6 = taffy.layout(node6) + assert_eq(l_node6.size.width, 50.0) + assert_eq(l_node6.size.height, 10.0) + assert_eq(l_node6.location.x, 0.0) + assert_eq(l_node6.location.y, 70.0) +} + +///| +test "upstream/generated/block/block_margin_y_sibling_collapse_positive_and_negative_percentage" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_sibling_collapse_positive_and_negative_percentage.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.1), + bottom=percent(0.1), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.05), + bottom=percent(0.05), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.1), + bottom=percent(-0.1), + ), + ), + ) + let node4 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(-0.1), + ), + ), + ) + let node5 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.05), + bottom=percent(-0.05), + ), + ), + ) + let node6 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3, node4, node5, node6], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 80.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 5.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 15.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 28.0) + let l_node3 = taffy.layout(node3) + assert_eq(l_node3.size.width, 50.0) + assert_eq(l_node3.size.height, 10.0) + assert_eq(l_node3.location.x, 0.0) + assert_eq(l_node3.location.y, 35.0) + let l_node4 = taffy.layout(node4) + assert_eq(l_node4.size.width, 50.0) + assert_eq(l_node4.size.height, 10.0) + assert_eq(l_node4.location.x, 0.0) + assert_eq(l_node4.location.y, 45.0) + let l_node5 = taffy.layout(node5) + assert_eq(l_node5.size.width, 50.0) + assert_eq(l_node5.size.height, 10.0) + assert_eq(l_node5.location.x, 0.0) + assert_eq(l_node5.location.y, 53.0) + let l_node6 = taffy.layout(node6) + assert_eq(l_node6.size.width, 50.0) + assert_eq(l_node6.size.height, 10.0) + assert_eq(l_node6.location.x, 0.0) + assert_eq(l_node6.location.y, 65.0) +} + +///| +test "upstream/generated/block/block_margin_y_sibling_collapse_positive_percentage" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_sibling_collapse_positive_percentage.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.05), + bottom=percent(0.05), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 65.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 5.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, 35.0) + let l_node3 = taffy.layout(node3) + assert_eq(l_node3.size.width, 50.0) + assert_eq(l_node3.size.height, 10.0) + assert_eq(l_node3.location.x, 0.0) + assert_eq(l_node3.location.y, 50.0) +} + +///| +test "upstream/generated/block/block_margin_y_simple_negative" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_simple_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -10.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, -10.0) +} + +///| +test "upstream/generated/block/block_margin_y_simple_negative_percentage_other" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_simple_negative_percentage_other.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.1), + bottom=percent(-0.1), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -5.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_simple_negative_percentage_self" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_simple_negative_percentage_self.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(-0.1), + bottom=percent(-0.1), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -5.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_margin_y_simple_positive" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_simple_positive.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 40.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 30.0) +} + +///| +test "upstream/generated/block/block_margin_y_simple_positive_percentage_other" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_simple_positive_percentage_other.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 5.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/block/block_margin_y_simple_positive_percentage_self" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_simple_positive_percentage_self.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 5.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/block/block_margin_y_total_collapse" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_total_collapse.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 10.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node01 = taffy.layout(node01) + assert_eq(l_node01.size.width, 50.0) + assert_eq(l_node01.size.height, 0.0) + assert_eq(l_node01.location.x, 0.0) + assert_eq(l_node01.location.y, 20.0) + let l_node02 = taffy.layout(node02) + assert_eq(l_node02.size.width, 50.0) + assert_eq(l_node02.size.height, 10.0) + assert_eq(l_node02.location.x, 0.0) + assert_eq(l_node02.location.y, 20.0) +} + +///| +test "upstream/generated/block/block_margin_y_total_collapse_complex" { + // Ported from taffy-reference/tests/generated/block/block_margin_y_total_collapse_complex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(-5.0), + ), + ), + ) + let node11 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(7.0), + bottom=length(3.0), + ), + ), + ) + let node12 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-6.0), + bottom=length(9.0), + ), + ), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + [node10, node11, node12], + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-5.0), + bottom=length(-5.0), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(-10.0), + bottom=length(-10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, -10.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, -10.0) + let l_node10 = taffy.layout(node10) + assert_eq(l_node10.size.width, 0.0) + assert_eq(l_node10.size.height, 10.0) + assert_eq(l_node10.location.x, 0.0) + assert_eq(l_node10.location.y, -5.0) + let l_node11 = taffy.layout(node11) + assert_eq(l_node11.size.width, 0.0) + assert_eq(l_node11.size.height, 10.0) + assert_eq(l_node11.location.x, 0.0) + assert_eq(l_node11.location.y, 7.0) + let l_node12 = taffy.layout(node12) + assert_eq(l_node12.size.width, 0.0) + assert_eq(l_node12.size.height, 10.0) + assert_eq(l_node12.location.x, 0.0) + assert_eq(l_node12.location.y, -6.0) + let l_node2 = taffy.layout(node2) + assert_eq(l_node2.size.width, 50.0) + assert_eq(l_node2.size.height, 10.0) + assert_eq(l_node2.location.x, 0.0) + assert_eq(l_node2.location.y, -10.0) + let l_node3 = taffy.layout(node3) + assert_eq(l_node3.size.width, 50.0) + assert_eq(l_node3.size.height, 10.0) + assert_eq(l_node3.location.x, 0.0) + assert_eq(l_node3.location.y, -10.0) +} + +///| +test "upstream/generated/block/block_overflow_scrollbars_overridden_by_available_space" { + // Ported from taffy-reference/tests/generated/block/block_overflow_scrollbars_overridden_by_available_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 2.0) + assert_eq(l_node.size.height, 4.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 2.0) + assert_eq(l_node0.size.height, 15.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 0.0) + assert_eq(l_node00.size.height, 0.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part08_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part08_test.mbt new file mode 100644 index 0000000..3fd2e87 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part08_test.mbt @@ -0,0 +1,1068 @@ +// 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/block/block_overflow_scrollbars_overridden_by_max_size" { + // Ported from taffy-reference/tests/generated/block/block_overflow_scrollbars_overridden_by_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_max_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 2.0) + assert_eq(l_node.size.height, 4.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 0.0) + assert_eq(l_node0.size.height, 0.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_overflow_scrollbars_overridden_by_size" { + // Ported from taffy-reference/tests/generated/block/block_overflow_scrollbars_overridden_by_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 2.0) + assert_eq(l_node.size.height, 4.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 0.0) + assert_eq(l_node0.size.height, 0.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_overflow_scrollbars_take_up_space_both_axis" { + // Ported from taffy-reference/tests/generated/block/block_overflow_scrollbars_take_up_space_both_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .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) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 35.0) + assert_eq(l_node0.size.height, 35.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_overflow_scrollbars_take_up_space_cross_axis" { + // Ported from taffy-reference/tests/generated/block/block_overflow_scrollbars_take_up_space_cross_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .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) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 35.0) + assert_eq(l_node0.size.height, 50.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_overflow_scrollbars_take_up_space_main_axis" { + // Ported from taffy-reference/tests/generated/block/block_overflow_scrollbars_take_up_space_main_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .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) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 35.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_padding_border_fixed_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_border_fixed_size.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 node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_padding( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ) + .with_border( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 28.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 15.0) + assert_eq(l_node0.location.y, 3.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 28.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 15.0) + assert_eq(l_node1.location.y, 13.0) +} + +///| +test "upstream/generated/block/block_padding_border_intrinsic_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_border_intrinsic_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_padding( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ) + .with_border( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 72.0) + assert_eq(l_node.size.height, 34.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 15.0) + assert_eq(l_node0.location.y, 3.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 15.0) + assert_eq(l_node1.location.y, 13.0) +} + +///| +test "upstream/generated/block/block_padding_border_overrides_max_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_border_overrides_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_max_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 22.0) + assert_eq(l_node.size.height, 14.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 22.0) + assert_eq(l_node0.size.height, 14.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 0.0) + assert_eq(l_node00.size.height, 0.0) + assert_eq(l_node00.location.x, 15.0) + assert_eq(l_node00.location.y, 3.0) +} + +///| +test "upstream/generated/block/block_padding_border_overrides_min_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_border_overrides_min_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_min_size(Size(width=length(0.0), height=length(0.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 22.0) + assert_eq(l_node.size.height, 14.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 22.0) + assert_eq(l_node0.size.height, 14.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 0.0) + assert_eq(l_node00.size.height, 0.0) + assert_eq(l_node00.location.x, 15.0) + assert_eq(l_node00.location.y, 3.0) +} + +///| +test "upstream/generated/block/block_padding_border_overrides_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_border_overrides_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 22.0) + assert_eq(l_node.size.height, 14.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 22.0) + assert_eq(l_node0.size.height, 14.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 0.0) + assert_eq(l_node00.size.height, 0.0) + assert_eq(l_node00.location.x, 15.0) + assert_eq(l_node00.location.y, 3.0) +} + +///| +test "upstream/generated/block/block_padding_border_percentage_fixed_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_border_percentage_fixed_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_padding( + Rect( + left=percent(0.04), + right=percent(0.02), + top=percent(0.01), + bottom=percent(0.03), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 12.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 47.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 2.0) + assert_eq(l_node00.location.y, 1.0) +} + +///| +test "upstream/generated/block/block_padding_border_percentage_intrinsic_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_border_percentage_intrinsic_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_padding( + Rect( + left=percent(0.04), + right=percent(0.02), + top=percent(0.01), + bottom=percent(0.03), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 0.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 0.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 0.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) +} + +///| +test "upstream/generated/block/block_padding_fixed_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_fixed_size.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 node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 38.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 8.0) + assert_eq(l_node0.location.y, 2.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 38.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 8.0) + assert_eq(l_node1.location.y, 12.0) +} + +///| +test "upstream/generated/block/block_padding_intrinsic_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_intrinsic_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 62.0) + assert_eq(l_node.size.height, 28.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 8.0) + assert_eq(l_node0.location.y, 2.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 10.0) + assert_eq(l_node1.location.x, 8.0) + assert_eq(l_node1.location.y, 12.0) +} + +///| +test "upstream/generated/block/block_padding_percentage_fixed_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_percentage_fixed_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_padding( + Rect( + left=percent(0.04), + right=percent(0.02), + top=percent(0.01), + bottom=percent(0.03), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 12.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 47.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 2.0) + assert_eq(l_node00.location.y, 1.0) +} + +///| +test "upstream/generated/block/block_padding_percentage_intrinsic_size" { + // Ported from taffy-reference/tests/generated/block/block_padding_percentage_intrinsic_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_padding( + Rect( + left=percent(0.04), + right=percent(0.02), + top=percent(0.01), + bottom=percent(0.03), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 0.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 0.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 0.0) + assert_eq(l_node00.size.height, 10.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) +} + +///| +test "upstream/generated/block/mod" { + // Upstream module declaration file; no runnable test vectors. + () +} + +///| +test "upstream/generated/blockflex/blockflex_block_in_flex_column" { + // Ported from taffy-reference/tests/generated/blockflex/blockflex_block_in_flex_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_display(display_block())) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(50.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 200.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 200.0) + assert_eq(l_node0.size.height, 0.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 0.0) +} + +///| +test "upstream/generated/blockflex/blockflex_block_in_flex_row" { + // Ported from taffy-reference/tests/generated/blockflex/blockflex_block_in_flex_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_display(display_block())) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(200.0), height=length(50.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 200.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 0.0) + assert_eq(l_node0.size.height, 50.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 50.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 0.0) +} + +///| +test "upstream/generated/blockflex/blockflex_flex_in_block" { + // Ported from taffy-reference/tests/generated/blockflex/blockflex_flex_in_block.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_flex()), + [node00], + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 200.0) + assert_eq(l_node.size.height, 70.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 200.0) + assert_eq(l_node0.size.height, 50.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node00 = taffy.layout(node00) + assert_eq(l_node00.size.width, 50.0) + assert_eq(l_node00.size.height, 50.0) + assert_eq(l_node00.location.x, 0.0) + assert_eq(l_node00.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 20.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 50.0) +} + +///| +test "upstream/generated/blockflex/blockflex_margin_y_collapse_through_blocked_by_flex" { + // Ported from taffy-reference/tests/generated/blockflex/blockflex_margin_y_collapse_through_blocked_by_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_flex()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 40.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/blockflex/blockflex_margin_y_first_child_collapse_blocked_by_flex" { + // Ported from taffy-reference/tests/generated/blockflex/blockflex_margin_y_first_child_collapse_blocked_by_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 0.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 10.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 0.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/blockflex/blockflex_margin_y_last_child_collapse_blocked_by_flex" { + // Ported from taffy-reference/tests/generated/blockflex/blockflex_margin_y_last_child_collapse_blocked_by_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 20.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, 0.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, 0.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/blockflex/blockflex_overflow_hidden" { + // Ported from taffy-reference/tests/generated/blockflex/blockflex_overflow_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_display(display_block()) + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_flex_grow(1.0), + { text_content: "HHHH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()).with_flex_grow(1.0), + { text_content: "HHHH\u{200B}HH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(20.0), height=length(50.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 20.0) + assert_eq(l_node.size.height, 50.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 0.0) + assert_eq(l_node0.size.height, 50.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 40.0) + assert_eq(l_node1.size.height, 50.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 0.0) +} + +///| +test "upstream/generated/blockflex/mod" { + // Upstream module declaration file; no runnable test vectors. + () +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part09_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part09_test.mbt new file mode 100644 index 0000000..9cfe885 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part09_test.mbt @@ -0,0 +1,912 @@ +// 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/blockgrid/blockgrid_block_in_grid_auto" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_auto.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([auto()]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 40.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 40.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 40.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 10.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_larger" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_larger.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([fit_content(length(50.0))]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 40.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 40.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 40.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 10.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_middle" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_middle.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([fit_content(length(30.0))]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 30.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 30.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 30.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_smaller" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_fit_content_smaller.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([fit_content(length(10.0))]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 20.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 20.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 20.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_fixed_larger" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_larger.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([length(50.0)]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 50.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 50.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 10.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_fixed_middle" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_middle.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([length(30.0)]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 30.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 30.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 30.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_fixed_smaller" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_fixed_smaller.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([length(10.0)]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 10.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 10.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 10.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_fr" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_fr.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([fr(1.0)]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 40.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 40.0) + assert_eq(l_node0.size.height, 10.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 40.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 10.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_max_content" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_max_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([grid_min_content()]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 20.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 20.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 20.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_block_in_grid_min_content" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_block_in_grid_min_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_display(display_block()), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default().with_display(display_block())) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([grid_min_content()]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 20.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l_node0 = taffy.layout(node0) + assert_eq(l_node0.size.width, 20.0) + assert_eq(l_node0.size.height, 20.0) + assert_eq(l_node0.location.x, 0.0) + assert_eq(l_node0.location.y, 0.0) + let l_node1 = taffy.layout(node1) + assert_eq(l_node1.size.width, 20.0) + assert_eq(l_node1.size.height, 0.0) + assert_eq(l_node1.location.x, 0.0) + assert_eq(l_node1.location.y, 20.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_grid_in_block" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_grid_in_block.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_grid()), + [node00], + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 200.0) + assert_eq(l_node.size.height, 70.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.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, 50.0) + assert_eq(l00.size.height, 50.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, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_margin_y_collapse_through_blocked_by_grid" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_margin_y_collapse_through_blocked_by_grid.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_display(display_grid()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_display(display_block()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 40.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/blockgrid/blockgrid_margin_y_first_child_collapse_blocked_by_grid" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_margin_y_first_child_collapse_blocked_by_grid.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 10.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 50.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/blockgrid/blockgrid_margin_y_last_child_collapse_blocked_by_grid" { + // Ported from taffy-reference/tests/generated/blockgrid/blockgrid_margin_y_last_child_collapse_blocked_by_grid.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 30.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 20.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, 50.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, 50.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/blockgrid/mod" { + // Upstream mod.rs only declares submodules; no standalone runnable vector. + () +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_aspect_ratio_overrides_height_of_full_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_aspect_ratio(3.0) + .with_inset( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 360.0) + assert_eq(l0.size.height, 120.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 15.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_fill_height" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=percent(0.5), height=auto())) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=percent(0.05), right=auto(), top=percent(0.05), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 200.0) + assert_eq(l0.size.height, 67.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 15.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_fill_height_from_inset" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_height_from_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_aspect_ratio(3.0) + .with_inset( + Rect( + left=percent(0.1), + right=percent(0.1), + top=percent(0.05), + bottom=auto(), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 320.0) + assert_eq(l0.size.height, 107.0) + assert_eq(l0.location.x, 40.0) + assert_eq(l0.location.y, 15.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_fill_max_height" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_position(position_absolute()) + .with_max_size(Size(width=length(50.0), height=auto())) + .with_aspect_ratio(3.0), + { + text_content: "HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 17.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_fill_max_width" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_position(position_absolute()) + .with_max_size(Size(width=auto(), height=length(50.0))) + .with_aspect_ratio(0.5), + { + text_content: "HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH\u{200B}HHHH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 25.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/absolute_aspect_ratio_fill_min_height" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_min_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_min_size(Size(width=length(50.0), height=auto())) + .with_aspect_ratio(3.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 17.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_fill_min_width" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_min_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_min_size(Size(width=auto(), height=length(50.0))) + .with_aspect_ratio(0.5), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 25.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/absolute_aspect_ratio_fill_width" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=auto(), height=percent(0.2))) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=percent(0.05), right=auto(), top=percent(0.05), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 180.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 15.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_fill_width_from_inset" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_fill_width_from_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.3), bottom=percent(0.5)), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 180.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 90.0) +} + +///| +test "upstream/generated/flex/absolute_aspect_ratio_height_overrides_inset" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_height_overrides_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=auto(), height=percent(0.1))) + .with_aspect_ratio(3.0) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.3), bottom=percent(0.5)), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 90.0) + assert_eq(l0.size.height, 30.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 90.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part10_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part10_test.mbt new file mode 100644 index 0000000..780a1a0 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part10_test.mbt @@ -0,0 +1,857 @@ +// 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/absolute_aspect_ratio_width_overrides_inset" { + // Ported from taffy-reference/tests/generated/flex/absolute_aspect_ratio_width_overrides_inset.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=percent(0.4), height=auto())) + .with_aspect_ratio(3.0) + .with_inset( + Rect( + left=percent(0.1), + right=percent(0.1), + top=percent(0.05), + bottom=auto(), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(400.0), height=length(300.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 400.0) + assert_eq(l_node.size.height, 300.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 160.0) + assert_eq(l0.size.height, 53.0) + assert_eq(l0.location.x, 40.0) + assert_eq(l0.location.y, 15.0) +} + +///| +test "upstream/generated/flex/absolute_child_with_cross_margin" { + // Ported from taffy-reference/tests/generated/flex/absolute_child_with_cross_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(28.0), height=length(27.0))), + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_position(position_absolute()) + .with_align_content(align_content_stretch()) + .with_flex_grow(0.0) + .with_flex_shrink(1.0) + .with_size(Size(width=percent(1.0), height=length(15.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(4.0), + bottom=length(0.0), + ), + ), + { text_content: "", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(25.0), height=length(27.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_space_between()) + .with_min_size(Size(width=length(311.0), height=length(0.0))) + .with_max_size( + Size(width=length(311.0), height=length(36893500000000000000.0)), + ), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 311.0) + assert_eq(l_node.size.height, 27.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 28.0) + assert_eq(l0.size.height, 27.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, 311.0) + assert_eq(l1.size.height, 15.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 4.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 25.0) + assert_eq(l2.size.height, 27.0) + assert_eq(l2.location.x, 286.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_child_with_main_margin" { + // Ported from taffy-reference/tests/generated/flex/absolute_child_with_main_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(9.0), height=length(9.0))) + .with_margin( + Rect( + left=length(7.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(20.0), height=length(37.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 20.0) + assert_eq(l_node.size.height, 37.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 9.0) + assert_eq(l0.size.height, 9.0) + assert_eq(l0.location.x, 7.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_child_with_max_height" { + // Ported from taffy-reference/tests/generated/flex/absolute_child_with_max_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(30.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_position(position_absolute()) + .with_flex_direction(flex_direction_column()) + .with_max_size(Size(width=auto(), height=length(100.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=auto(), bottom=length(20.0)), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 200.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 30.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 150.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 100.0) + assert_eq(l00.size.height, 30.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_child_with_max_height_larger_shrinkable_grandchild" { + // Ported from taffy-reference/tests/generated/flex/absolute_child_with_max_height_larger_shrinkable_grandchild.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(1.0) + .with_flex_basis(length(150.0)) + .with_size(Size(width=length(100.0), height=auto())), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_position(position_absolute()) + .with_flex_direction(flex_direction_column()) + .with_max_size(Size(width=auto(), height=length(100.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=auto(), bottom=length(20.0)), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(200.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 200.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.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, 80.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/absolute_layout_align_items_and_justify_content_center" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_and_justify_content_center.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.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(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 25.0) + assert_eq(l0.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_layout_align_items_and_justify_content_center_and_bottom_position" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=auto(), bottom=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(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 25.0) + assert_eq(l0.location.y, 50.0) +} + +///| +test "upstream/generated/flex/absolute_layout_align_items_and_justify_content_center_and_left_position" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_left_position.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))) + .with_inset(Rect(left=length(5.0), right=auto(), top=auto(), bottom=auto())), + ) + 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(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_layout_align_items_and_justify_content_center_and_right_position" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_right_position.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))) + .with_inset(Rect(left=auto(), right=length(5.0), top=auto(), bottom=auto())), + ) + 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(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 45.0) + assert_eq(l0.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_layout_align_items_and_justify_content_center_and_top_position" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_and_justify_content_center_and_top_position.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + 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(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 25.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/absolute_layout_align_items_and_justify_content_flex_end" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_and_justify_content_flex_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_flex_end()) + .with_justify_content(justify_content_flex_end()) + .with_size(Size(width=length(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 60.0) +} + +///| +test "upstream/generated/flex/absolute_layout_align_items_center" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_center.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_layout_align_items_center_on_child_only" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_align_items_center_on_child_only.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_center()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_layout_child_order" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_child_order.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(60.0), height=length(40.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(110.0), height=length(100.0))), + [node0, node1, node2], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 55.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 30.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 60.0) + assert_eq(l1.size.height, 40.0) + assert_eq(l1.location.x, 25.0) + assert_eq(l1.location.y, 30.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 55.0) + assert_eq(l2.size.height, 40.0) + assert_eq(l2.location.x, 55.0) + assert_eq(l2.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_layout_in_wrap_reverse_column_container" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_in_wrap_reverse_column_container.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 80.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_layout_in_wrap_reverse_column_container_flex_end" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_in_wrap_reverse_column_container_flex_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_flex_end()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_layout_in_wrap_reverse_row_container" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_in_wrap_reverse_row_container.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 80.0) +} + +///| +test "upstream/generated/flex/absolute_layout_in_wrap_reverse_row_container_flex_end" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_in_wrap_reverse_row_container_flex_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_flex_end()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_layout_justify_content_center" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_justify_content_center.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(60.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(110.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 110.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 60.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 25.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_layout_no_size" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_no_size.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_position(position_absolute()), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.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/absolute_layout_percentage_bottom_based_on_parent_height" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_percentage_bottom_based_on_parent_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.5), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=auto(), bottom=percent(0.5)), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=auto())) + .with_inset( + Rect(left=auto(), right=auto(), top=percent(0.1), bottom=percent(0.1)), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(200.0))), + [node0, node1, node2], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 200.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.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, 0.0) + assert_eq(l0.location.y, 100.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 90.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 10.0) + assert_eq(l2.size.height, 160.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 20.0) +} + +///| +test "upstream/generated/flex/absolute_layout_percentage_height" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_percentage_height.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=percent(0.5))) + .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(200.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 200.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.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, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/absolute_layout_row_width_height_end_bottom" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_row_width_height_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.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, 80.0) + assert_eq(l0.location.y, 80.0) +} + +///| +test "upstream/generated/flex/absolute_layout_start_top_end_bottom" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_start_top_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .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_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.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/absolute_layout_width_height_end_bottom" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_width_height_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.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, 80.0) + assert_eq(l0.location.y, 80.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part11_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part11_test.mbt new file mode 100644 index 0000000..b3433af --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part11_test.mbt @@ -0,0 +1,1255 @@ +// 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/absolute_layout_width_height_start_top" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_width_height_start_top.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.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], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.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/absolute_layout_width_height_start_top_end_bottom" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_width_height_start_top_end_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .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_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.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/absolute_layout_within_border" { + // Ported from taffy-reference/tests/generated/flex/absolute_layout_within_border.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=auto(), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_inset( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=auto()), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_inset( + Rect(left=auto(), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0, node1, node2, node3], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.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, 10.0) + assert_eq(l0.location.y, 10.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, 40.0) + assert_eq(l1.location.y, 40.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 20.0) + assert_eq(l2.location.y, 20.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 30.0) + assert_eq(l3.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_margin_bottom_left" { + // Ported from taffy-reference/tests/generated/flex/absolute_margin_bottom_left.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_flex_end()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.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, 80.0) +} + +///| +test "upstream/generated/flex/absolute_minmax_bottom_right_max" { + // Ported from taffy-reference/tests/generated/flex/absolute_minmax_bottom_right_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 30.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 60.0) +} + +///| +test "upstream/generated/flex/absolute_minmax_bottom_right_min_max" { + // Ported from taffy-reference/tests/generated/flex/absolute_minmax_bottom_right_min_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_min_size(Size(width=length(50.0), height=length(60.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 40.0) + assert_eq(l0.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_minmax_bottom_right_min_max_preferred" { + // Ported from taffy-reference/tests/generated/flex/absolute_minmax_bottom_right_min_max_preferred.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_min_size(Size(width=length(50.0), height=length(60.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .with_inset( + Rect(left=auto(), right=length(10.0), top=auto(), bottom=length(10.0)), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 40.0) + assert_eq(l0.location.y, 30.0) +} + +///| +test "upstream/generated/flex/absolute_minmax_top_left_bottom_right_max" { + // Ported from taffy-reference/tests/generated/flex/absolute_minmax_top_left_bottom_right_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .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_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 30.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/absolute_minmax_top_left_bottom_right_min_max" { + // Ported from taffy-reference/tests/generated/flex/absolute_minmax_top_left_bottom_right_min_max.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_min_size(Size(width=length(50.0), height=length(60.0))) + .with_max_size(Size(width=length(40.0), height=length(30.0))) + .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_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 50.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/absolute_padding_border_overrides_max_size" { + // Ported from taffy-reference/tests/generated/flex/absolute_padding_border_overrides_max_size.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_max_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 0.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 22.0) + assert_eq(l0.size.height, 14.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/absolute_padding_border_overrides_size" { + // Ported from taffy-reference/tests/generated/flex/absolute_padding_border_overrides_size.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 0.0) + assert_eq(l_node.size.height, 0.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 22.0) + assert_eq(l0.size.height, 14.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_baseline" { + // Ported from taffy-reference/tests/generated/flex/align_baseline.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 30.0) +} + +///| +test "upstream/generated/flex/align_baseline_child" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .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, 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, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_margin" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(10.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .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, 40.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 5.0) + assert_eq(l10.location.y, 5.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_margin_percent" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_margin_percent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(10.0))) + .with_margin( + Rect( + left=percent(0.01), + right=percent(0.01), + top=percent(0.01), + bottom=percent(0.01), + ), + ), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .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, 40.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 45.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 1.0) + assert_eq(l10.location.y, 1.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_multiline" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_multiline.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(60.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(20.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(10.0))), + ) + let node12 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(20.0))), + ) + let node13 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(50.0), height=auto())), + [node10, node11, node12, node13], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .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, 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, 50.0) + assert_eq(l0.size.height, 60.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, 40.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 25.0) + assert_eq(l10.size.height, 20.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 25.0) + assert_eq(l11.size.height, 10.0) + assert_eq(l11.location.x, 25.0) + assert_eq(l11.location.y, 0.0) + let l12 = taffy.layout(node12) + assert_eq(l12.size.width, 25.0) + assert_eq(l12.size.height, 20.0) + assert_eq(l12.location.x, 0.0) + assert_eq(l12.location.y, 20.0) + let l13 = taffy.layout(node13) + assert_eq(l13.size.width, 25.0) + assert_eq(l13.size.height, 10.0) + assert_eq(l13.location.x, 25.0) + assert_eq(l13.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_multiline_no_override_on_secondline" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_multiline_no_override_on_secondline.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(60.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(20.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(10.0))), + ) + let node12 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(20.0))), + ) + let node13 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_baseline()) + .with_size(Size(width=length(25.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(50.0), height=length(25.0))), + [node10, node11, node12, node13], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .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, 50.0) + assert_eq(l0.size.height, 60.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, 25.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 25.0) + assert_eq(l10.size.height, 20.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 25.0) + assert_eq(l11.size.height, 10.0) + assert_eq(l11.location.x, 25.0) + assert_eq(l11.location.y, 0.0) + let l12 = taffy.layout(node12) + assert_eq(l12.size.width, 25.0) + assert_eq(l12.size.height, 20.0) + assert_eq(l12.location.x, 0.0) + assert_eq(l12.location.y, 20.0) + let l13 = taffy.layout(node13) + assert_eq(l13.size.width, 25.0) + assert_eq(l13.size.height, 10.0) + assert_eq(l13.location.x, 25.0) + assert_eq(l13.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_multiline_override" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_multiline_override.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(60.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(20.0))), + ) + let node11 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_baseline()) + .with_size(Size(width=length(25.0), height=length(10.0))), + ) + let node12 = taffy.new_leaf( + Style::default().with_size(Size(width=length(25.0), height=length(20.0))), + ) + let node13 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_baseline()) + .with_size(Size(width=length(25.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(50.0), height=length(25.0))), + [node10, node11, node12, node13], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .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, 50.0) + assert_eq(l0.size.height, 60.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, 25.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 50.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 25.0) + assert_eq(l10.size.height, 20.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 25.0) + assert_eq(l11.size.height, 10.0) + assert_eq(l11.location.x, 25.0) + assert_eq(l11.location.y, 0.0) + let l12 = taffy.layout(node12) + assert_eq(l12.size.width, 25.0) + assert_eq(l12.size.height, 20.0) + assert_eq(l12.location.x, 0.0) + assert_eq(l12.location.y, 20.0) + let l13 = taffy.layout(node13) + assert_eq(l13.size.width, 25.0) + assert_eq(l13.size.height, 10.0) + assert_eq(l13.location.x, 25.0) + assert_eq(l13.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_padding" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_padding.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.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, 40.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 45.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 5.0) + assert_eq(l10.location.y, 5.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_top" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .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, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_baseline_child_top2" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_child_top2.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(50.0), height=length(20.0))) + .with_inset(Rect(left=auto(), right=auto(), top=length(5.0), bottom=auto())), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .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, 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, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 45.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_baseline_column" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_baseline()) + .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, 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, 20.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/flex/align_baseline_double_nested_child" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_double_nested_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + [node00], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(15.0))), + ) + let node1 = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .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, 50.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, 50.0) + assert_eq(l00.size.height, 20.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, 50.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 5.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 15.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_baseline_multiline" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_multiline.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let node20 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node20], + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3], + ) + 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, 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, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.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, 20.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 100.0) + let l20 = taffy.layout(node20) + assert_eq(l20.size.width, 50.0) + assert_eq(l20.size.height, 10.0) + assert_eq(l20.location.x, 0.0) + assert_eq(l20.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 60.0) +} + +///| +test "upstream/generated/flex/align_baseline_multiline_column" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_multiline_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(30.0), height=length(50.0))), + [node10], + ) + let node20 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node2 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(40.0), height=length(70.0))), + [node20], + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3], + ) + 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, 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, 30.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 20.0) + assert_eq(l10.size.height, 20.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, 40.0) + assert_eq(l2.size.height, 70.0) + assert_eq(l2.location.x, 50.0) + assert_eq(l2.location.y, 0.0) + let l20 = taffy.layout(node20) + assert_eq(l20.size.width, 10.0) + assert_eq(l20.size.height, 10.0) + assert_eq(l20.location.x, 0.0) + assert_eq(l20.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 70.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part12_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part12_test.mbt new file mode 100644 index 0000000..6fb34c9 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part12_test.mbt @@ -0,0 +1,1526 @@ +// 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/align_baseline_multiline_column2" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_multiline_column2.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(30.0), height=length(50.0))), + [node10], + ) + let node20 = taffy.new_leaf( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node2 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(40.0), height=length(70.0))), + [node20], + ) + let node3 = taffy.new_leaf( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3], + ) + 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, 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, 30.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 20.0) + assert_eq(l10.size.height, 20.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, 40.0) + assert_eq(l2.size.height, 70.0) + assert_eq(l2.location.x, 50.0) + assert_eq(l2.location.y, 0.0) + let l20 = taffy.layout(node20) + assert_eq(l20.size.width, 10.0) + assert_eq(l20.size.height, 10.0) + assert_eq(l20.location.x, 0.0) + assert_eq(l20.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 70.0) +} + +///| +test "upstream/generated/flex/align_baseline_multiline_row_and_column" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_multiline_row_and_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node10], + ) + let node20 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node20], + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_baseline()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3], + ) + 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, 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, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.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, 20.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 100.0) + let l20 = taffy.layout(node20) + assert_eq(l20.size.width, 50.0) + assert_eq(l20.size.height, 10.0) + assert_eq(l20.location.x, 0.0) + assert_eq(l20.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 90.0) +} + +///| +test "upstream/generated/flex/align_baseline_nested_child" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_nested_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .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, 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, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_baseline_nested_column" { + // Ported from taffy-reference/tests/generated/flex/align_baseline_nested_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(60.0))), + ) + let node100 = taffy.new_leaf( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(30.0))), + ) + let node101 = taffy.new_leaf( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(40.0))), + ) + let node10 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=length(80.0))), + [node100, node101], + ) + let node1 = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_baseline()) + .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, 50.0) + assert_eq(l0.size.height, 60.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, 80.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 30.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 80.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l100 = taffy.layout(node100) + assert_eq(l100.size.width, 50.0) + assert_eq(l100.size.height, 30.0) + assert_eq(l100.location.x, 0.0) + assert_eq(l100.location.y, 0.0) + let l101 = taffy.layout(node101) + assert_eq(l101.size.width, 50.0) + assert_eq(l101.size.height, 40.0) + assert_eq(l101.location.x, 0.0) + assert_eq(l101.location.y, 30.0) +} + +///| +test "upstream/generated/flex/align_center_should_size_based_on_content" { + // Ported from taffy-reference/tests/generated/flex/align_center_should_size_based_on_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node00 = taffy.new_with_children( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_flex_grow(0.0) + .with_flex_shrink(1.0), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .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, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 40.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 20.0) + assert_eq(l00.size.height, 20.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, 20.0) + assert_eq(l000.size.height, 20.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_center_single_line" { + // Ported from taffy-reference/tests/generated/flex/align_content_center_single_line.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_content(align_content_center()) + .with_size(Size(width=length(120.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + 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, 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, 20.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, 20.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 20.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, 10.0) + assert_eq(l2.location.x, 40.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 60.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 80.0) + assert_eq(l4.location.y, 0.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 10.0) + assert_eq(l5.location.x, 100.0) + assert_eq(l5.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_center_single_line_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_center_single_line_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_center_single_line_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_center_single_line_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_center_wrapped" { + // Ported from taffy-reference/tests/generated/flex/align_content_center_wrapped.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let mk = fn() { + taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + } + let node0 = mk() + let node1 = mk() + let node2 = mk() + let node3 = mk() + let node4 = mk() + let node5 = mk() + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_center()) + .with_size(Size(width=length(120.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 120.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 35.0) + let l1 = taffy.layout(node1) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 35.0) + let l2 = taffy.layout(node2) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 45.0) + let l3 = taffy.layout(node3) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 45.0) + let l4 = taffy.layout(node4) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 55.0) + let l5 = taffy.layout(node5) + assert_eq(l5.location.x, 50.0) + assert_eq(l5.location.y, 55.0) +} + +///| +test "upstream/generated/flex/align_content_center_wrapped_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_center_wrapped_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -25.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -5.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 15.0) +} + +///| +test "upstream/generated/flex/align_content_center_wrapped_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_center_wrapped_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -35.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -5.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 25.0) +} + +///| +test "upstream/generated/flex/align_content_end" { + // Ported from taffy-reference/tests/generated/flex/align_content_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_end()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + 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, 10.0) + assert_eq(l0.location.x, 50.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, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 50.0) + assert_eq(l2.location.y, 20.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 30.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_content_end_single_line_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_end_single_line_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_end()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_end_single_line_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_end_single_line_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_end()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_end_wrapped_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_end_wrapped_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_end()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -50.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, -10.0) +} + +///| +test "upstream/generated/flex/align_content_end_wrapped_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_end_wrapped_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_end()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -70.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -40.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, -10.0) +} + +///| +test "upstream/generated/flex/align_content_flex_end" { + // Ported from taffy-reference/tests/generated/flex/align_content_flex_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_flex_end()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + 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, 10.0) + assert_eq(l0.location.x, 50.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, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 50.0) + assert_eq(l2.location.y, 20.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 30.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_content_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_content_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(130.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 130.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 10.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_content_flex_start_with_flex" { + // Ported from taffy-reference/tests/generated/flex/align_content_flex_start_with_flex.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(percent(0.0)) + .with_size(Size(width=length(50.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.0)) + .with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = 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(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=length(120.0))), + [node0, node1, node2, node3, node4], + ) + 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, 120.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, 40.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, 40.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 40.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 0.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 80.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 80.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 0.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 120.0) +} + +///| +test "upstream/generated/flex/align_content_flex_start_without_height_on_children" { + // Ported from taffy-reference/tests/generated/flex/align_content_flex_start_without_height_on_children.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + 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, 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, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 0.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 10.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 0.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_content_not_stretch_with_align_items_stretch" { + // Ported from taffy-reference/tests/generated/flex/align_content_not_stretch_with_align_items_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(272.0), height=length(44.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node00], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(56.0), height=length(44.0))), + ) + let node1 = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(328.0), height=length(52.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 328.0) + assert_eq(lnode.size.height, 52.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, 272.0) + assert_eq(l0.size.height, 44.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, 272.0) + assert_eq(l00.size.height, 44.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, 56.0) + assert_eq(l1.size.height, 44.0) + assert_eq(l1.location.x, 272.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 56.0) + assert_eq(l10.size.height, 44.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_around_single_line" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_around_single_line.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_content(align_content_space_around()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + 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, 17.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, 16.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 17.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 17.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 33.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 17.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 16.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 67.0) + assert_eq(l4.location.y, 0.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 17.0) + assert_eq(l5.size.height, 10.0) + assert_eq(l5.location.x, 83.0) + assert_eq(l5.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_around_single_line_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_around_single_line_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_space_around()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_around_single_line_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_around_single_line_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_space_around()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_around_wrapped" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_around_wrapped.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_around()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + 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, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 12.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 12.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 45.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 45.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 78.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 50.0) + assert_eq(l5.size.height, 10.0) + assert_eq(l5.location.x, 50.0) + assert_eq(l5.location.y, 78.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part13_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part13_test.mbt new file mode 100644 index 0000000..82ad83c --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part13_test.mbt @@ -0,0 +1,1548 @@ +// 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/align_content_space_around_wrapped_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_around_wrapped_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_around()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_content_space_around_wrapped_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_around_wrapped_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_around()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 60.0) +} + +///| +test "upstream/generated/flex/align_content_space_between_single_line" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_between_single_line.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 node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node5 = 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_content(align_content_space_between()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + 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, 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, 10.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, 10.0) + assert_eq(l2.location.x, 20.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 10.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 30.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 10.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 40.0) + assert_eq(l4.location.y, 0.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 10.0) + assert_eq(l5.size.height, 10.0) + assert_eq(l5.location.x, 50.0) + assert_eq(l5.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_between_single_line_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_between_single_line_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_space_between()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_between_single_line_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_between_single_line_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_space_between()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_between_wrapped" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_between_wrapped.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let mk = fn() { + taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + } + let node0 = mk() + let node1 = mk() + let node2 = mk() + let node3 = mk() + let node4 = mk() + let node5 = mk() + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_between()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(node, Size::max_content()) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 100.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 45.0) + let l3 = taffy.layout(node3) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 45.0) + let l4 = taffy.layout(node4) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 90.0) + let l5 = taffy.layout(node5) + assert_eq(l5.location.x, 50.0) + assert_eq(l5.location.y, 90.0) +} + +///| +test "upstream/generated/flex/align_content_space_between_wrapped_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_between_wrapped_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_between()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_content_space_between_wrapped_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_between_wrapped_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_between()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 60.0) +} + +///| +test "upstream/generated/flex/align_content_space_evenly_single_line" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_evenly_single_line.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 node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node5 = 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_content(align_content_space_evenly()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + 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, 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, 10.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, 10.0) + assert_eq(l2.location.x, 20.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 10.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 30.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 10.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 40.0) + assert_eq(l4.location.y, 0.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 10.0) + assert_eq(l5.size.height, 10.0) + assert_eq(l5.location.x, 50.0) + assert_eq(l5.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_evenly_single_line_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_evenly_single_line_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_space_evenly()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_evenly_single_line_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_evenly_single_line_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_space_evenly()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_space_evenly_wrapped" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_evenly_wrapped.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_evenly()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + 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, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 18.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 18.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 45.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 45.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 73.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 50.0) + assert_eq(l5.size.height, 10.0) + assert_eq(l5.location.x, 50.0) + assert_eq(l5.location.y, 73.0) +} + +///| +test "upstream/generated/flex/align_content_space_evenly_wrapped_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_evenly_wrapped_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_evenly()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_content_space_evenly_wrapped_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_space_evenly_wrapped_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_evenly()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 60.0) +} + +///| +test "upstream/generated/flex/align_content_spacearound" { + // Ported from taffy-reference/tests/generated/flex/align_content_spacearound.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_around()) + .with_size(Size(width=length(140.0), height=length(120.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 140.0) + assert_eq(lnode.size.height, 120.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, 15.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 15.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 55.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 55.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 95.0) +} + +///| +test "upstream/generated/flex/align_content_spacebetween" { + // Ported from taffy-reference/tests/generated/flex/align_content_spacebetween.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_between()) + .with_size(Size(width=length(130.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 130.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 45.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 45.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 90.0) +} + +///| +test "upstream/generated/flex/align_content_start" { + // Ported from taffy-reference/tests/generated/flex/align_content_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_start()) + .with_size(Size(width=length(130.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 130.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 50.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 10.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_content_start_single_line_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_start_single_line_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_start()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_start_single_line_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/align_content_start_single_line_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(60.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_content(align_content_start()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 60.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_start_wrapped_negative_space" { + // Ported from taffy-reference/tests/generated/flex/align_content_start_wrapped_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_start()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_content_stretch" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.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, 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, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 0.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 0.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 0.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_column" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=auto(), height=length(50.0))), + [node00], + ) + let node1 = 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=auto(), height=length(50.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(50.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(50.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(100.0), height=length(150.0))), + [node0, node1, node2, node3, node4], + ) + 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, 150.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 l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 50.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, 50.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 50.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 100.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_is_not_overriding_align_items" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_is_not_overriding_align_items.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_align_content(align_content_stretch()), + [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, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 45.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.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, 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) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 100.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 50.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 50.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_children" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_children.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(50.0), height=auto())), + [node00], + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.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, 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, 50.0) + assert_eq(l00.size.height, 50.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, 50.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 100.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 50.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 50.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part14_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part14_test.mbt new file mode 100644 index 0000000..43728b4 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part14_test.mbt @@ -0,0 +1,1394 @@ +// 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/align_content_stretch_row_with_fixed_height" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_fixed_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(60.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.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, 80.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, 60.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 80.0) + assert_eq(l2.location.x, 100.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 80.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 80.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_flex" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = 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(50.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = 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(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.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, 100.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.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) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 0.0) + assert_eq(l3.size.height, 100.0) + assert_eq(l3.location.x, 100.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 100.0) + assert_eq(l4.location.x, 100.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_flex_no_shrink" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_flex_no_shrink.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = 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(50.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(0.0) + .with_flex_basis(percent(0.0)) + .with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.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, 100.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.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) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 0.0) + assert_eq(l3.size.height, 100.0) + assert_eq(l3.location.x, 100.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 100.0) + assert_eq(l4.location.x, 100.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_margin" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.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, 40.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, 20.0) + assert_eq(l1.location.x, 60.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 40.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 40.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 60.0) + assert_eq(l3.location.y, 50.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 80.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_max_height" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_max_size(Size(width=auto(), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.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, 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, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 100.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 50.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 50.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_min_height" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_min_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(80.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.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, 90.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, 90.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 90.0) + assert_eq(l2.location.x, 100.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 10.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 90.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 10.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 90.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_padding" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_padding.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 150.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, 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) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 100.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 50.0) + assert_eq(l3.size.height, 50.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 50.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 50.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 50.0) +} + +///| +test "upstream/generated/flex/align_content_stretch_row_with_single_row" { + // Ported from taffy-reference/tests/generated/flex/align_content_stretch_row_with_single_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(150.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, 150.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, 50.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_flex_start_with_shrinking_children" { + // Ported from taffy-reference/tests/generated/flex/align_flex_start_with_shrinking_children.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + ) + let node00 = taffy.new_with_children( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_align_items(align_items_flex_start()), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(500.0), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.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, 500.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, 0.0) + assert_eq(l00.size.height, 0.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, 0.0) + assert_eq(l000.size.height, 0.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_flex_start_with_shrinking_children_with_stretch" { + // Ported from taffy-reference/tests/generated/flex/align_flex_start_with_shrinking_children_with_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_align_items(align_items_stretch()) + .with_flex_grow(1.0) + .with_flex_shrink(1.0), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_align_items(align_items_flex_start()), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(500.0), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.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, 500.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, 0.0) + assert_eq(l00.size.height, 0.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, 0.0) + assert_eq(l000.size.height, 0.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_flex_start_with_stretching_children" { + // Ported from taffy-reference/tests/generated/flex/align_flex_start_with_stretching_children.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + ) + let node00 = taffy.new_with_children( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_align_items(align_items_stretch()), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(500.0), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.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, 500.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, 0.0) + assert_eq(l00.size.height, 500.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, 0.0) + assert_eq(l000.size.height, 500.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_items_center" { + // Ported from taffy-reference/tests/generated/flex/align_items_center.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_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, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 45.0) +} + +///| +test "upstream/generated/flex/align_items_center_child_with_margin_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_child_with_margin_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default().with_align_items(align_items_center()), + [node00], + ) + 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(50.0), height=length(50.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, 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, 70.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, -10.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 10.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_items_center_child_without_margin_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_child_without_margin_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(70.0), height=length(70.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_align_items(align_items_center()), + [node00], + ) + 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(50.0), height=length(50.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, 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, 70.0) + assert_eq(l0.size.height, 70.0) + assert_eq(l0.location.x, -10.0) + assert_eq(l0.location.y, -10.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 70.0) + assert_eq(l00.size.height, 70.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_items_center_justify_content_center" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_justify_content_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + { text_content: "", writing_mode: Horizontal }, + ) + let node00 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=percent(1.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(50.0))), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(500.0), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.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, 500.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, 10.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 245.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 10.0) + assert_eq(l000.size.height, 10.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_items_center_min_max_with_padding" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_min_max_with_padding.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(62.0), height=length(62.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_min_size(Size(width=length(320.0), height=length(72.0))) + .with_max_size(Size(width=length(320.0), height=length(504.0))) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=length(8.0), + bottom=length(8.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 78.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, 62.0) + assert_eq(l0.size.height, 62.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 8.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_child_margin" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_child_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .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, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 50.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_child_top" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_child_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(10.0), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .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, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 55.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_height_with_padding_border_with_wrap" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_height_with_padding_border_with_wrap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node00, node01], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node10, node11], + ) + 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, 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, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 5.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 10.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 10.0) + assert_eq(l01.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, 10.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 45.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 10.0) + assert_eq(l11.size.height, 20.0) + assert_eq(l11.location.x, 10.0) + assert_eq(l11.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_max_height_percentage_with_align_content_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_max_height_percentage_with_align_content_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_max_size(Size(width=auto(), height=percent(0.5))), + [node00, node01], + ) + 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, 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, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 20.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 10.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 10.0) + assert_eq(l01.location.y, 15.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_max_height_with_align_content_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_max_height_with_align_content_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(150.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_max_size(Size(width=auto(), 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, 10.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 25.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 150.0) + assert_eq(l1.location.x, 10.0) + assert_eq(l1.location.y, -25.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_max_height_with_padding_border" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_max_height_with_padding_border.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(150.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_max_size(Size(width=auto(), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node00, node01], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(150.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_max_size(Size(width=auto(), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node10, node11], + ) + let node = taffy.new_with_children( + Style::default().with_display(display_block()), + [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, 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, 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, 10.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 45.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 10.0) + assert_eq(l01.size.height, 150.0) + assert_eq(l01.location.x, 30.0) + assert_eq(l01.location.y, -25.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, 100.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 10.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 20.0) + assert_eq(l10.location.y, 90.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 10.0) + assert_eq(l11.size.height, 150.0) + assert_eq(l11.location.x, 30.0) + assert_eq(l11.location.y, 20.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_min_height_percentage_with_align_content_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_min_height_percentage_with_align_content_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=percent(1.0))), + [node00, node01], + ) + 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, 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, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 45.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 10.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 10.0) + assert_eq(l01.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_min_height_with_align_content_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start.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 node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), 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, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 45.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 10.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 10.0) + assert_eq(l1.location.y, 40.0) +} + +///| +test "upstream/generated/flex/align_items_center_with_min_height_with_align_content_flex_start_with_wrap" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_min_height_with_align_content_flex_start_with_wrap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))), + [node00, node01], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))), + [node10, node11], + ) + let node20 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node21 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node2 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))), + [node20, node21], + ) + let node30 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node31 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node3 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))), + [node30, node31], + ) + let node = taffy.new_with_children(Style::default(), [ + node0, node1, node2, node3, + ]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 400.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, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 5.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 10.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 10.0) + assert_eq(l01.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, 10.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 45.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 10.0) + assert_eq(l11.size.height, 20.0) + assert_eq(l11.location.x, 10.0) + assert_eq(l11.location.y, 40.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 200.0) + assert_eq(l2.location.y, 0.0) + let l20 = taffy.layout(node20) + assert_eq(l20.size.width, 10.0) + assert_eq(l20.size.height, 10.0) + assert_eq(l20.location.x, 0.0) + assert_eq(l20.location.y, 45.0) + let l21 = taffy.layout(node21) + assert_eq(l21.size.width, 10.0) + assert_eq(l21.size.height, 20.0) + assert_eq(l21.location.x, 10.0) + assert_eq(l21.location.y, 40.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 100.0) + assert_eq(l3.size.height, 100.0) + assert_eq(l3.location.x, 300.0) + assert_eq(l3.location.y, 0.0) + let l30 = taffy.layout(node30) + assert_eq(l30.size.width, 10.0) + assert_eq(l30.size.height, 10.0) + assert_eq(l30.location.x, 0.0) + assert_eq(l30.location.y, 45.0) + let l31 = taffy.layout(node31) + assert_eq(l31.size.width, 10.0) + assert_eq(l31.size.height, 20.0) + assert_eq(l31.location.x, 10.0) + assert_eq(l31.location.y, 40.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part15_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part15_test.mbt new file mode 100644 index 0000000..65842af --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part15_test.mbt @@ -0,0 +1,1087 @@ +// 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/align_items_center_with_min_height_with_padding_border" { + // Ported from taffy-reference/tests/generated/flex/align_items_center_with_min_height_with_padding_border.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(8.0), + top=length(8.0), + bottom=length(8.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(7.0), + top=length(7.0), + bottom=length(7.0), + ), + ), + [node00, node01], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(20.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(8.0), + top=length(8.0), + bottom=length(8.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(7.0), + top=length(7.0), + bottom=length(7.0), + ), + ), + [node10, node11], + ) + 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, 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, 10.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 15.0) + assert_eq(l00.location.y, 45.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 10.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 25.0) + assert_eq(l01.location.y, 40.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, 10.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 15.0) + assert_eq(l10.location.y, 20.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 10.0) + assert_eq(l11.size.height, 20.0) + assert_eq(l11.location.x, 25.0) + assert_eq(l11.location.y, 15.0) +} + +///| +test "upstream/generated/flex/align_items_flex_end" { + // Ported from taffy-reference/tests/generated/flex/align_items_flex_end.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_flex_end()) + .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, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 90.0) +} + +///| +test "upstream/generated/flex/align_items_flex_end_child_with_margin_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/align_items_flex_end_child_with_margin_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default().with_align_items(align_items_flex_end()), + [node00], + ) + 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(50.0), height=length(50.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, 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, 70.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, -10.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 50.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 10.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_items_flex_end_child_without_margin_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/align_items_flex_end_child_without_margin_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(70.0), height=length(70.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_align_items(align_items_flex_end()), + [node00], + ) + 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(50.0), height=length(50.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, 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, 70.0) + assert_eq(l0.size.height, 70.0) + assert_eq(l0.location.x, -10.0) + assert_eq(l0.location.y, -10.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 70.0) + assert_eq(l00.size.height, 70.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_items_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_items_flex_start.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_flex_start()) + .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, 10.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/align_items_min_max" { + // Ported from taffy-reference/tests/generated/flex/align_items_min_max.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_size(Size(width=auto(), height=length(100.0))) + .with_min_size(Size(width=length(100.0), height=auto())) + .with_max_size(Size(width=length(200.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, 60.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_items_stretch" { + // Ported from taffy-reference/tests/generated/flex/align_items_stretch.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))), + [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, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_items_stretch_min_cross" { + // Ported from taffy-reference/tests/generated/flex/align_items_stretch_min_cross.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=auto(), height=length(36.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_min_size(Size(width=length(400.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 400.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, 400.0) + assert_eq(l0.size.height, 36.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_self_baseline" { + // Ported from taffy-reference/tests/generated/flex/align_self_baseline.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_baseline()) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_align_self(align_items_baseline()) + .with_size(Size(width=length(50.0), height=length(20.0))), + [node10], + ) + 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, 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, 20.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 40.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 50.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_self_center" { + // Ported from taffy-reference/tests/generated/flex/align_self_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_center()) + .with_size(Size(width=length(10.0), height=length(10.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, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 45.0) +} + +///| +test "upstream/generated/flex/align_self_center_undefined_max_height" { + // Ported from taffy-reference/tests/generated/flex/align_self_center_undefined_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(240.0), height=length(44.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_center()) + .with_size(Size(width=length(40.0), height=length(56.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(280.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(52.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 280.0) + assert_eq(lnode.size.height, 56.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, 240.0) + assert_eq(l0.size.height, 44.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, 40.0) + assert_eq(l1.size.height, 56.0) + assert_eq(l1.location.x, 240.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/align_self_flex_end" { + // Ported from taffy-reference/tests/generated/flex/align_self_flex_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_flex_end()) + .with_size(Size(width=length(10.0), height=length(10.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, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 90.0) +} + +///| +test "upstream/generated/flex/align_self_flex_end_override_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_self_flex_end_override_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_flex_end()) + .with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_flex_start()) + .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, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 90.0) +} + +///| +test "upstream/generated/flex/align_self_flex_start" { + // Ported from taffy-reference/tests/generated/flex/align_self_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_flex_start()) + .with_size(Size(width=length(10.0), height=length(10.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, 10.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/align_stretch_should_size_based_on_parent" { + // Ported from taffy-reference/tests/generated/flex/align_stretch_should_size_based_on_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node00 = taffy.new_with_children( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_flex_grow(0.0) + .with_flex_shrink(1.0), + [node00], + ) + 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, 20.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, 20.0) + assert_eq(l00.size.height, 100.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, 20.0) + assert_eq(l000.size.height, 20.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/android_news_feed" { + // Ported from taffy-reference/tests/generated/flex/android_news_feed.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000000 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(0.0) + .with_size(Size(width=length(120.0), height=length(120.0))), + ) + let node00000 = taffy.new_with_children( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(0.0), + [node000000], + ) + let node000010 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(1.0), + ) + let node000011 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(1.0), + ) + let node00001 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()) + .with_flex_shrink(1.0) + .with_margin( + Rect( + left=length(0.0), + right=length(36.0), + top=length(0.0), + bottom=length(0.0), + ), + ) + .with_padding( + Rect( + left=length(36.0), + right=length(36.0), + top=length(21.0), + bottom=length(18.0), + ), + ), + [node000010, node000011], + ) + let node0000 = taffy.new_with_children( + Style::default() + .with_align_items(align_items_flex_start()) + .with_align_content(align_content_stretch()) + .with_margin( + Rect( + left=length(36.0), + right=length(0.0), + top=length(24.0), + bottom=length(0.0), + ), + ), + [node00000, node00001], + ) + let node000 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()), + [node0000], + ) + let node001000 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(0.0) + .with_size(Size(width=length(72.0), height=length(72.0))), + ) + let node00100 = taffy.new_with_children( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(0.0), + [node001000], + ) + let node001010 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(1.0), + ) + let node001011 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_flex_shrink(1.0), + ) + let node00101 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()) + .with_flex_shrink(1.0) + .with_margin( + Rect( + left=length(0.0), + right=length(36.0), + top=length(0.0), + bottom=length(0.0), + ), + ) + .with_padding( + Rect( + left=length(36.0), + right=length(36.0), + top=length(21.0), + bottom=length(18.0), + ), + ), + [node001010, node001011], + ) + let node0010 = taffy.new_with_children( + Style::default() + .with_align_items(align_items_flex_start()) + .with_align_content(align_content_stretch()) + .with_margin( + Rect( + left=length(174.0), + right=length(0.0), + top=length(24.0), + bottom=length(0.0), + ), + ), + [node00100, node00101], + ) + let node001 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()), + [node0010], + ) + let node00 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()), + [node000, node001], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_shrink(0.0), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()) + .with_flex_shrink(0.0) + .with_size(Size(width=length(1080.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, 1080.0) + assert_eq(lnode.size.height, 240.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, 1080.0) + assert_eq(l0.size.height, 240.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, 1080.0) + assert_eq(l00.size.height, 240.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, 1080.0) + assert_eq(l000.size.height, 144.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) + let l0000 = taffy.layout(node0000) + assert_eq(l0000.size.width, 1044.0) + assert_eq(l0000.size.height, 120.0) + assert_eq(l0000.location.x, 36.0) + assert_eq(l0000.location.y, 24.0) + let l00000 = taffy.layout(node00000) + assert_eq(l00000.size.width, 120.0) + assert_eq(l00000.size.height, 120.0) + assert_eq(l00000.location.x, 0.0) + assert_eq(l00000.location.y, 0.0) + let l000000 = taffy.layout(node000000) + assert_eq(l000000.size.width, 120.0) + assert_eq(l000000.size.height, 120.0) + assert_eq(l000000.location.x, 0.0) + assert_eq(l000000.location.y, 0.0) + let l00001 = taffy.layout(node00001) + assert_eq(l00001.size.width, 72.0) + assert_eq(l00001.size.height, 39.0) + assert_eq(l00001.location.x, 120.0) + assert_eq(l00001.location.y, 0.0) + let l000010 = taffy.layout(node000010) + assert_eq(l000010.size.width, 0.0) + assert_eq(l000010.size.height, 0.0) + assert_eq(l000010.location.x, 36.0) + assert_eq(l000010.location.y, 21.0) + let l000011 = taffy.layout(node000011) + assert_eq(l000011.size.width, 0.0) + assert_eq(l000011.size.height, 0.0) + assert_eq(l000011.location.x, 36.0) + assert_eq(l000011.location.y, 21.0) + let l001 = taffy.layout(node001) + assert_eq(l001.size.width, 1080.0) + assert_eq(l001.size.height, 96.0) + assert_eq(l001.location.x, 0.0) + assert_eq(l001.location.y, 144.0) + let l0010 = taffy.layout(node0010) + assert_eq(l0010.size.width, 906.0) + assert_eq(l0010.size.height, 72.0) + assert_eq(l0010.location.x, 174.0) + assert_eq(l0010.location.y, 24.0) + let l00100 = taffy.layout(node00100) + assert_eq(l00100.size.width, 72.0) + assert_eq(l00100.size.height, 72.0) + assert_eq(l00100.location.x, 0.0) + assert_eq(l00100.location.y, 0.0) + let l001000 = taffy.layout(node001000) + assert_eq(l001000.size.width, 72.0) + assert_eq(l001000.size.height, 72.0) + assert_eq(l001000.location.x, 0.0) + assert_eq(l001000.location.y, 0.0) + let l00101 = taffy.layout(node00101) + assert_eq(l00101.size.width, 72.0) + assert_eq(l00101.size.height, 39.0) + assert_eq(l00101.location.x, 72.0) + assert_eq(l00101.location.y, 0.0) + let l001010 = taffy.layout(node001010) + assert_eq(l001010.size.width, 0.0) + assert_eq(l001010.size.height, 0.0) + assert_eq(l001010.location.x, 36.0) + assert_eq(l001010.location.y, 21.0) + let l001011 = taffy.layout(node001011) + assert_eq(l001011.size.width, 0.0) + assert_eq(l001011.size.height, 0.0) + assert_eq(l001011.location.x, 36.0) + assert_eq(l001011.location.y, 21.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_fill_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_fill_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_start()) + .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, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_fill_max_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_fill_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.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\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_start()) + .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, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_fill_max_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_fill_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=auto(), height=length(20.0))) + .with_aspect_ratio(2.0), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_start()) + .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, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_fill_min_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_fill_min_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_start()) + .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, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_fill_min_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_fill_min_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_min_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_start()) + .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, 80.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_fill_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_fill_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_start()) + .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, 80.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_fill_width_flex" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_fill_width_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .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, 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/aspect_ratio_flex_column_stretch_fill_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .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, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_stretch_fill_max_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.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\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .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, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part16_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part16_test.mbt new file mode 100644 index 0000000..5bfd592 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part16_test.mbt @@ -0,0 +1,1166 @@ +// 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/aspect_ratio_flex_column_stretch_fill_max_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=auto(), height=length(20.0))) + .with_aspect_ratio(2.0), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .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, 100.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_column_stretch_fill_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_column_stretch_fill_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .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, 100.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_fill_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_fill_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_start()) + .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, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_fill_max_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_fill_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.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\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_start()) + .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, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_fill_max_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_fill_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=auto(), height=length(20.0))) + .with_aspect_ratio(2.0), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_start()) + .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, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_fill_min_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_fill_min_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_start()) + .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, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_fill_min_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_fill_min_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_min_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_start()) + .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, 80.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_fill_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_fill_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_align_items(align_items_start()) + .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, 80.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_fill_width_flex" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_fill_width_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_align_items(align_items_start()) + .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, 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/aspect_ratio_flex_row_stretch_fill_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .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, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_stretch_fill_max_height" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=length(40.0), height=auto())) + .with_aspect_ratio(2.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\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .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, 100.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_stretch_fill_max_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_max_size(Size(width=auto(), height=length(20.0))) + .with_aspect_ratio(2.0), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .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, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/aspect_ratio_flex_row_stretch_fill_width" { + // Ported from taffy-reference/tests/generated/flex/aspect_ratio_flex_row_stretch_fill_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(40.0))) + .with_aspect_ratio(2.0), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .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, 80.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_10343_block" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_10343_block.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf(Style::default()) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_block()) + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_flex()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_space_around()) + .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, 100.0) + assert_eq(l0.size.height, 210.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, 90.0) + assert_eq(l00.size.height, 200.0) + assert_eq(l00.location.x, 5.0) + assert_eq(l00.location.y, 5.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 90.0) + assert_eq(l000.size.height, 0.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_10343_flex" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_10343_flex.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf(Style::default()) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_flex()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_space_around()) + .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, 100.0) + assert_eq(l0.size.height, 210.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, 90.0) + assert_eq(l00.size.height, 200.0) + assert_eq(l00.location.x, 5.0) + assert_eq(l00.location.y, 5.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 0.0) + assert_eq(l000.size.height, 200.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_10343_grid" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_10343_grid.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf(Style::default()) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_flex()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_space_around()) + .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, 100.0) + assert_eq(l0.size.height, 210.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, 90.0) + assert_eq(l00.size.height, 200.0) + assert_eq(l00.location.x, 5.0) + assert_eq(l00.location.y, 5.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 90.0) + assert_eq(l000.size.height, 200.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_7976_3_level" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_7976_3_level.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(1.0), height=percent(1.0))) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_min_size(Size(width=length(40.0), height=length(40.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_content(align_content_start()) + .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, 40.0) + assert_eq(l0.size.height, 190.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 30.0) + assert_eq(l00.size.height, 180.0) + assert_eq(l00.location.x, 5.0) + assert_eq(l00.location.y, 5.0) +} + +///| +test "upstream/generated/flex/bevy_issue_7976_4_level" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_7976_4_level.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf(Style::default()) + let node00 = taffy.new_with_children( + Style::default() + .with_size(Size(width=percent(1.0), height=percent(1.0))) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_min_size(Size(width=length(40.0), height=length(40.0))) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_align_content(align_content_start()) + .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, 40.0) + assert_eq(l0.size.height, 190.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 30.0) + assert_eq(l00.size.height, 180.0) + assert_eq(l00.location.x, 5.0) + assert_eq(l00.location.y, 5.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 0.0) + assert_eq(l000.size.height, 170.0) + assert_eq(l000.location.x, 5.0) + assert_eq(l000.location.y, 5.0) +} + +///| +test "upstream/generated/flex/bevy_issue_7976_reduced" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_7976_reduced.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(40.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_content(align_content_start()) + .with_size(Size(width=auto(), 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, 40.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, 40.0) + assert_eq(l0.size.height, 200.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_8017" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_8017.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=percent(1.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=percent(1.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_gap(Size(width=length(8.0), height=length(8.0))) + .with_size(Size(width=percent(1.0), height=percent(0.5))), + [node00, node01], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=percent(1.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=percent(1.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_gap(Size(width=length(8.0), height=length(8.0))) + .with_size(Size(width=percent(1.0), height=percent(0.5))), + [node10, node11], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_gap(Size(width=length(8.0), height=length(8.0))) + .with_size(Size(width=length(400.0), height=length(400.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(8.0), + top=length(8.0), + bottom=length(8.0), + ), + ), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 400.0) + assert_eq(lnode.size.height, 400.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, 384.0) + assert_eq(l0.size.height, 188.0) + assert_eq(l0.location.x, 8.0) + assert_eq(l0.location.y, 8.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 188.0) + assert_eq(l00.size.height, 188.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 188.0) + assert_eq(l01.size.height, 188.0) + assert_eq(l01.location.x, 196.0) + assert_eq(l01.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 384.0) + assert_eq(l1.size.height, 188.0) + assert_eq(l1.location.x, 8.0) + assert_eq(l1.location.y, 204.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 188.0) + assert_eq(l10.size.height, 188.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 188.0) + assert_eq(l11.size.height, 188.0) + assert_eq(l11.location.x, 196.0) + assert_eq(l11.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_8017_reduced" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_8017_reduced.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default().with_size(Size(width=auto(), height=percent(0.5))), + [node00], + ) + let node10 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_with_children( + Style::default().with_size(Size(width=auto(), height=percent(0.5))), + [node10], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_gap(Size(width=length(8.0), height=length(8.0))) + .with_size(Size(width=length(200.0), height=length(400.0))), + [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, 400.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, 200.0) + assert_eq(l0.size.height, 196.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, 0.0) + assert_eq(l00.size.height, 196.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, 200.0) + assert_eq(l1.size.height, 196.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 204.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 0.0) + assert_eq(l10.size.height, 196.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) +} + +///| +test "upstream/generated/flex/bevy_issue_8082" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_8082.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node03 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_flex_start()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()), + [node00, node01, node02, node03], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_stretch()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_flex_start()) + .with_size(Size(width=length(200.0), height=length(400.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, 400.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, 200.0) + assert_eq(l0.size.height, 140.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, 50.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 40.0) + assert_eq(l00.location.y, 10.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 50.0) + assert_eq(l01.size.height, 50.0) + assert_eq(l01.location.x, 110.0) + assert_eq(l01.location.y, 10.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 50.0) + assert_eq(l02.size.height, 50.0) + assert_eq(l02.location.x, 40.0) + assert_eq(l02.location.y, 80.0) + let l03 = taffy.layout(node03) + assert_eq(l03.size.width, 50.0) + assert_eq(l03.size.height, 50.0) + assert_eq(l03.location.x, 110.0) + assert_eq(l03.location.y, 80.0) +} + +///| +test "upstream/generated/flex/bevy_issue_8082_percent" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_8082_percent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node02 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node03 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_flex_start()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=percent(0.5), height=auto())), + [node00, node01, node02, node03], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_stretch()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_flex_start()) + .with_size(Size(width=length(200.0), height=length(400.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, 400.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, 50.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 50.0) + assert_eq(l01.size.height, 50.0) + assert_eq(l01.location.x, 50.0) + assert_eq(l01.location.y, 0.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 50.0) + assert_eq(l02.size.height, 50.0) + assert_eq(l02.location.x, 0.0) + assert_eq(l02.location.y, 50.0) + let l03 = taffy.layout(node03) + assert_eq(l03.size.width, 50.0) + assert_eq(l03.size.height, 50.0) + assert_eq(l03.location.x, 50.0) + assert_eq(l03.location.y, 50.0) +} + +///| +test "upstream/generated/flex/bevy_issue_9530" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_9530.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=percent(1.0), height=length(20.0))), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=length(50.0))), + ) + let node11 = taffy.new_leaf_with_context( + Style::default() + .with_align_items(align_items_center()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_flex_grow(1.0) + .with_margin( + Rect( + left=length(20.0), + right=length(20.0), + top=length(20.0), + bottom=length(20.0), + ), + ), + { + text_content: "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH", + writing_mode: Horizontal, + }, + ) + let node12 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=length(50.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=percent(1.0), height=auto())) + .with_margin( + Rect( + left=length(20.0), + right=length(20.0), + top=length(20.0), + bottom=length(20.0), + ), + ) + .with_padding( + Rect( + left=length(20.0), + right=length(20.0), + top=length(20.0), + bottom=length(20.0), + ), + ), + [node10, node11, node12], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_align_content(align_content_center()) + .with_size(Size(width=length(300.0), height=length(300.0))) + .with_margin(Rect(left=auto(), right=auto(), top=auto(), bottom=auto())), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 300.0) + assert_eq(lnode.size.height, 300.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, 300.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, 300.0) + assert_eq(l1.size.height, 420.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 260.0) + assert_eq(l10.size.height, 50.0) + assert_eq(l10.location.x, 20.0) + assert_eq(l10.location.y, 20.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 220.0) + assert_eq(l11.size.height, 240.0) + assert_eq(l11.location.x, 40.0) + assert_eq(l11.location.y, 90.0) + let l12 = taffy.layout(node12) + assert_eq(l12.size.width, 260.0) + assert_eq(l12.size.height, 50.0) + assert_eq(l12.location.x, 20.0) + assert_eq(l12.location.y, 350.0) +} + +///| +test "upstream/generated/flex/bevy_issue_9530_reduced" { + // Ported from taffy-reference/tests/generated/flex/bevy_issue_9530_reduced.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", + writing_mode: Horizontal, + }, + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(40.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, 40.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, 40.0) + assert_eq(l0.size.height, 20.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, 40.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part17_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part17_test.mbt new file mode 100644 index 0000000..225ec04 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part17_test.mbt @@ -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) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part18_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part18_test.mbt new file mode 100644 index 0000000..71c9a1e --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part18_test.mbt @@ -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) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part19_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part19_test.mbt new file mode 100644 index 0000000..f506386 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part19_test.mbt @@ -0,0 +1,1003 @@ +// 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_direction_row_reverse" { + // Ported from taffy-reference/tests/generated/flex/flex_direction_row_reverse.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_flex_direction(flex_direction_row_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, 10.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 90.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, 80.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, 70.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_grow_child" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(0.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_grow_flex_basis_percent_min_max" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_flex_basis_percent_min_max.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_size(Size(width=auto(), height=length(20.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_size(Size(width=length(20.0), height=length(20.0))) + .with_max_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(120.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, 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, 100.0) + assert_eq(l0.size.height, 20.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, 20.0) + assert_eq(l1.location.x, 100.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_grow_height_maximized" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_height_maximized.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(length(200.0)), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(500.0))), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=length(500.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, 500.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, 500.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, 400.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 100.0) + assert_eq(l01.size.height, 100.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 400.0) +} + +///| +test "upstream/generated/flex/flex_grow_in_at_most_container" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_in_at_most_container.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(length(0.0)), + ) + let node0 = taffy.new_with_children(Style::default(), [node00]) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_flex_start()) + .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) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 0.0) + assert_eq(l00.size.height, 0.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_grow_less_than_factor_one" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_less_than_factor_one.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(0.2) + .with_flex_shrink(0.0) + .with_flex_basis(length(40.0)), + ) + let node1 = taffy.new_leaf( + Style::default().with_flex_grow(0.2).with_flex_shrink(0.0), + ) + let node2 = taffy.new_leaf( + Style::default().with_flex_grow(0.4).with_flex_shrink(0.0), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(500.0), height=length(200.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, 500.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, 132.0) + assert_eq(l0.size.height, 200.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, 92.0) + assert_eq(l1.size.height, 200.0) + assert_eq(l1.location.x, 132.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 184.0) + assert_eq(l2.size.height, 200.0) + assert_eq(l2.location.x, 224.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_grow_root_minimized" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_root_minimized.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(length(200.0)), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(500.0))), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(500.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, 300.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, 300.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, 200.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 100.0) + assert_eq(l01.size.height, 100.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 200.0) +} + +///| +test "upstream/generated/flex/flex_grow_shrink_at_most" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_shrink_at_most.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + ) + let node0 = taffy.new_with_children(Style::default(), [node00]) + 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) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 0.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_grow_to_min" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_to_min.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=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=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(500.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, 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, 100.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/flex/flex_grow_within_constrained_max_column" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_within_constrained_max_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_shrink(1.0).with_flex_basis(length(100.0)), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=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=auto())) + .with_max_size(Size(width=auto(), 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_grow_within_constrained_max_row" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_within_constrained_max_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_flex_shrink(1.0).with_flex_basis(length(100.0)), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=length(100.0), height=auto())), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.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, 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, 67.0) + assert_eq(l00.size.height, 100.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 33.0) + assert_eq(l01.size.height, 100.0) + assert_eq(l01.location.x, 67.0) + assert_eq(l01.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_grow_within_constrained_max_width" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_within_constrained_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_max_size(Size(width=length(300.0), height=auto())), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.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, 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, 200.0) + assert_eq(l0.size.height, 20.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, 200.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/flex_grow_within_constrained_min_column" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_within_constrained_min_column.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_size(Size(width=auto(), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_min_size(Size(width=auto(), 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, 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, 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, 0.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/flex/flex_grow_within_constrained_min_max_column" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_within_constrained_min_max_column.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_size(Size(width=auto(), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(200.0))), + [node0, node1], + ) + 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, 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, 0.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/flex/flex_grow_within_constrained_min_row" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_within_constrained_min_row.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_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=auto(), height=length(100.0))) + .with_min_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, 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, 50.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_grow_within_max_width" { + // Ported from taffy-reference/tests/generated/flex/flex_grow_within_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_max_size(Size(width=length(100.0), height=auto())), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.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, 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, 20.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, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_row_relative_all_sides" { + // Ported from taffy-reference/tests/generated/flex/flex_row_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_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, 100.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/flex_shrink_by_outer_margin_with_max_size" { + // Ported from taffy-reference/tests/generated/flex/flex_shrink_by_outer_margin_with_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(100.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(80.0))), + [node0], + ) + 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, 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, 20.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 100.0) +} + +///| +test "upstream/generated/flex/flex_shrink_flex_grow_child_flex_shrink_other_child" { + // Ported from taffy-reference/tests/generated/flex/flex_shrink_flex_grow_child_flex_shrink_other_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(0.0) + .with_flex_shrink(1.0) + .with_size(Size(width=length(500.0), height=length(100.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_size(Size(width=length(500.0), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(500.0), height=length(500.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.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, 250.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, 250.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 250.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_shrink_flex_grow_row" { + // Ported from taffy-reference/tests/generated/flex/flex_shrink_flex_grow_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(0.0) + .with_flex_shrink(1.0) + .with_size(Size(width=length(500.0), height=length(100.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(0.0) + .with_flex_shrink(1.0) + .with_size(Size(width=length(500.0), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(500.0), height=length(500.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.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, 250.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, 250.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 250.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_shrink_to_zero" { + // Ported from taffy-reference/tests/generated/flex/flex_shrink_to_zero.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_shrink(1.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.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(75.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, 75.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, 0.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 50.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_wrap_align_stretch_fits_one_row" { + // Ported from taffy-reference/tests/generated/flex/flex_wrap_align_stretch_fits_one_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(150.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, 150.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, 50.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/flex_wrap_children_with_min_main_overriding_flex_basis" { + // Ported from taffy-reference/tests/generated/flex/flex_wrap_children_with_min_main_overriding_flex_basis.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(50.0))) + .with_min_size(Size(width=length(55.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_basis(length(50.0)) + .with_size(Size(width=auto(), height=length(50.0))) + .with_min_size(Size(width=length(55.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .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, 55.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, 55.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 50.0) +} + +///| +test "upstream/generated/flex/flex_wrap_wrap_to_child_height" { + // Ported from taffy-reference/tests/generated/flex/flex_wrap_wrap_to_child_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(100.0), height=auto())), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_flex_start()), + [node00], + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [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, 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, 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) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 100.0) + assert_eq(l000.size.height, 100.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.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, 100.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_child_margins" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_child_margins.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)) + .with_margin( + Rect( + left=length(2.0), + right=length(2.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_margin( + Rect( + left=length(15.0), + right=length(15.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_gap(Size(width=length(10.0), height=length(0.0))) + .with_size(Size(width=length(80.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, 80.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, 2.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 2.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 2.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 26.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 2.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 63.0) + assert_eq(l2.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part20_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part20_test.mbt new file mode 100644 index 0000000..252382e --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part20_test.mbt @@ -0,0 +1,1311 @@ +// 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/gap_column_gap_determines_parent_width" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_determines_parent_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(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_stretch()) + .with_gap(Size(width=length(10.0), height=length(0.0))) + .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, 80.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, 20.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 20.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.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/gap_column_gap_flexible" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_flexible.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 node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + 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_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(80.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, 80.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, 20.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, 30.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, 60.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_flexible_undefined_parent" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_flexible_undefined_parent.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 node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + 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_gap(Size(width=length(10.0), height=length(20.0))) + .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, 20.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) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 0.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, 0.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/gap_column_gap_inflexible" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_inflexible.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_gap(Size(width=length(10.0), height=length(0.0))) + .with_size(Size(width=length(80.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, 80.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, 20.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, 30.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, 60.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_inflexible_undefined_parent" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_inflexible_undefined_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_gap(Size(width=length(10.0), height=length(0.0))) + .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, 80.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, 20.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, 30.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, 60.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_justify_center" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_justify_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(0.0))) + .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, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 10.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, 40.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, 70.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_justify_flex_end" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_justify_flex_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_flex_end()) + .with_gap(Size(width=length(10.0), height=length(0.0))) + .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, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 20.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, 50.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/gap_column_gap_justify_flex_start" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_justify_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_flex_start()) + .with_gap(Size(width=length(10.0), height=length(0.0))) + .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, 20.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, 30.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, 60.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_justify_space_around" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_justify_space_around.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_space_around()) + .with_gap(Size(width=length(10.0), height=length(0.0))) + .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, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 3.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, 40.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, 77.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_justify_space_between" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_justify_space_between.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_space_between()) + .with_gap(Size(width=length(10.0), height=length(0.0))) + .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, 20.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, 40.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/gap_column_gap_justify_space_evenly" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_justify_space_evenly.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_space_evenly()) + .with_gap(Size(width=length(10.0), height=length(0.0))) + .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, 20.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 5.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, 40.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, 75.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_mixed_flexible" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_mixed_flexible.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_gap(Size(width=length(10.0), height=length(0.0))) + .with_size(Size(width=length(80.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, 80.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, 20.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, 30.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, 60.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_percentage_cyclic_partially_shrinkable" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_percentage_cyclic_partially_shrinkable.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default().with_gap(Size(width=percent(0.5), height=length(0.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, 60.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, 20.0) + assert_eq(l0.size.height, 40.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, 40.0) + assert_eq(l1.location.x, 50.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, 40.0) + assert_eq(l2.location.x, 80.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_percentage_cyclic_shrinkable" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_percentage_cyclic_shrinkable.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default().with_gap(Size(width=percent(0.2), height=length(0.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, 60.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, 12.0) + assert_eq(l0.size.height, 40.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, 12.0) + assert_eq(l1.size.height, 40.0) + assert_eq(l1.location.x, 24.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 12.0) + assert_eq(l2.size.height, 40.0) + assert_eq(l2.location.x, 48.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_percentage_cyclic_unshrinkable" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_percentage_cyclic_unshrinkable.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(20.0), height=length(40.0))), + ) + let node = taffy.new_with_children( + Style::default().with_gap(Size(width=percent(0.2), height=length(0.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, 60.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, 20.0) + assert_eq(l0.size.height, 40.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, 40.0) + assert_eq(l1.location.x, 32.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, 40.0) + assert_eq(l2.location.x, 64.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_percentage_flexible" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_percentage_flexible.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 node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + 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_gap(Size(width=percent(0.1), height=length(20.0))) + .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, 27.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, 26.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 37.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 27.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 73.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_percentage_flexible_with_padding" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_percentage_flexible_with_padding.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 node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)), + ) + 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_gap(Size(width=percent(0.1), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.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, 21.0) + assert_eq(l0.size.height, 80.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 22.0) + assert_eq(l1.size.height, 80.0) + assert_eq(l1.location.x, 39.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 21.0) + assert_eq(l2.size.height, 80.0) + assert_eq(l2.location.x, 69.0) + assert_eq(l2.location.y, 10.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_percentage_inflexible" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_percentage_inflexible.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_gap(Size(width=percent(0.2), height=length(0.0))) + .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, 20.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, 40.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/gap_column_gap_row_gap_wrapping" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_row_gap_wrapping.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node6 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node7 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node8 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(80.0), height=auto())), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + 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, 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, 20.0) + assert_eq(l0.size.height, 20.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, 20.0) + assert_eq(l1.location.x, 30.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, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 40.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 40.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 40.0) + let l6 = taffy.layout(node6) + assert_eq(l6.size.width, 20.0) + assert_eq(l6.size.height, 20.0) + assert_eq(l6.location.x, 0.0) + assert_eq(l6.location.y, 80.0) + let l7 = taffy.layout(node7) + assert_eq(l7.size.width, 20.0) + assert_eq(l7.size.height, 20.0) + assert_eq(l7.location.x, 30.0) + assert_eq(l7.location.y, 80.0) + let l8 = taffy.layout(node8) + assert_eq(l8.size.width, 20.0) + assert_eq(l8.size.height, 20.0) + assert_eq(l8.location.x, 60.0) + assert_eq(l8.location.y, 80.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_start_index" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_start_index.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(80.0), height=auto())), + [node0, node1, node2, node3], + ) + 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, 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, 20.0) + assert_eq(l0.size.height, 20.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, 20.0) + assert_eq(l1.location.x, 0.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, 20.0) + assert_eq(l2.location.x, 30.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 60.0) + assert_eq(l3.location.y, 0.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_wrap_align_center" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_wrap_align_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_center()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + 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, 20.0) + assert_eq(l0.size.height, 20.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, 20.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 20.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 60.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 60.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 60.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_wrap_align_flex_end" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_wrap_align_flex_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_flex_end()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + 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, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 40.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 40.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 40.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 80.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 80.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 80.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_wrap_align_flex_start" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_wrap_align_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_flex_start()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + 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, 20.0) + assert_eq(l0.size.height, 20.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, 20.0) + assert_eq(l1.location.x, 30.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, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 40.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 40.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 40.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_wrap_align_space_around" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_wrap_align_space_around.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_around()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + 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, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 20.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 10.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 70.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 70.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 70.0) +} + +///| +test "upstream/generated/flex/gap_column_gap_wrap_align_space_between" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_wrap_align_space_between.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_space_between()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3, node4, node5], + ) + 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, 20.0) + assert_eq(l0.size.height, 20.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, 20.0) + assert_eq(l1.location.x, 30.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, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 80.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 80.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 80.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part21_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part21_test.mbt new file mode 100644 index 0000000..65b8dc9 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part21_test.mbt @@ -0,0 +1,1301 @@ +// 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/gap_column_gap_wrap_align_stretch" { + // Ported from taffy-reference/tests/generated/flex/gap_column_gap_wrap_align_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=length(60.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=length(60.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=length(60.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=length(60.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=length(60.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_content(align_content_stretch()) + .with_gap(Size(width=length(5.0), height=length(0.0))) + .with_size(Size(width=length(300.0), height=length(300.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 300.0) + assert_eq(lnode.size.height, 300.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, 71.0) + assert_eq(l0.size.height, 150.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, 72.0) + assert_eq(l1.size.height, 150.0) + assert_eq(l1.location.x, 76.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 71.0) + assert_eq(l2.size.height, 150.0) + assert_eq(l2.location.x, 153.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 71.0) + assert_eq(l3.size.height, 150.0) + assert_eq(l3.location.x, 229.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 300.0) + assert_eq(l4.size.height, 150.0) + assert_eq(l4.location.x, 0.0) + assert_eq(l4.location.y, 150.0) +} + +///| +test "upstream/generated/flex/gap_column_row_gap_wrapping" { + // Ported from taffy-reference/tests/generated/flex/gap_column_row_gap_wrapping.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node6 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node7 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node8 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(80.0), height=auto())), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + 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, 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, 20.0) + assert_eq(l0.size.height, 20.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, 20.0) + assert_eq(l1.location.x, 30.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, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 40.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 40.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 40.0) + let l6 = taffy.layout(node6) + assert_eq(l6.size.width, 20.0) + assert_eq(l6.size.height, 20.0) + assert_eq(l6.location.x, 0.0) + assert_eq(l6.location.y, 80.0) + let l7 = taffy.layout(node7) + assert_eq(l7.size.width, 20.0) + assert_eq(l7.size.height, 20.0) + assert_eq(l7.location.x, 30.0) + assert_eq(l7.location.y, 80.0) + let l8 = taffy.layout(node8) + assert_eq(l8.size.width, 20.0) + assert_eq(l8.size.height, 20.0) + assert_eq(l8.location.x, 60.0) + assert_eq(l8.location.y, 80.0) +} + +///| +test "upstream/generated/flex/gap_row_gap_align_items_end" { + // Ported from taffy-reference/tests/generated/flex/gap_row_gap_align_items_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_flex_end()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(200.0))), + [node0, node1, node2, node3, node4, node5], + ) + 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, 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, 20.0) + assert_eq(l0.size.height, 0.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, 20.0) + assert_eq(l1.size.height, 0.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 90.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 20.0) + assert_eq(l2.size.height, 0.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 90.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 0.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 200.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 0.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 200.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 0.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 200.0) +} + +///| +test "upstream/generated/flex/gap_row_gap_align_items_stretch" { + // Ported from taffy-reference/tests/generated/flex/gap_row_gap_align_items_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_stretch()) + .with_align_content(align_content_stretch()) + .with_gap(Size(width=length(10.0), height=length(20.0))) + .with_size(Size(width=length(100.0), height=length(200.0))), + [node0, node1, node2, node3, node4, node5], + ) + 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, 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, 20.0) + assert_eq(l0.size.height, 90.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, 90.0) + assert_eq(l1.location.x, 30.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, 90.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 90.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 110.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 90.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 110.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 90.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 110.0) +} + +///| +test "upstream/generated/flex/gap_row_gap_column_child_margins" { + // Ported from taffy-reference/tests/generated/flex/gap_row_gap_column_child_margins.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)) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(2.0), + bottom=length(2.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_shrink(1.0) + .with_flex_basis(percent(0.0)) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(15.0), + bottom=length(15.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_gap(Size(width=length(0.0), height=length(10.0))) + .with_size(Size(width=length(100.0), height=length(200.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, 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, 42.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 2.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 100.0) + assert_eq(l1.size.height, 42.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 66.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 42.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 143.0) +} + +///| +test "upstream/generated/flex/gap_row_gap_determines_parent_height" { + // Ported from taffy-reference/tests/generated/flex/gap_row_gap_determines_parent_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(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(30.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_stretch()) + .with_gap(Size(width=length(0.0), height=length(10.0))) + .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, 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, 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, 20.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 20.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 50.0) +} + +///| +test "upstream/generated/flex/gap_row_gap_percentage_wrapping" { + // Ported from taffy-reference/tests/generated/flex/gap_row_gap_percentage_wrapping.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node6 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node7 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node8 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_gap(Size(width=length(10.0), height=percent(0.1))) + .with_size(Size(width=length(80.0), height=auto())), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + 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, 60.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, 20.0) + assert_eq(l0.size.height, 20.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, 20.0) + assert_eq(l1.location.x, 30.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, 20.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 20.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 20.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 20.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 60.0) + assert_eq(l5.location.y, 20.0) + let l6 = taffy.layout(node6) + assert_eq(l6.size.width, 20.0) + assert_eq(l6.size.height, 20.0) + assert_eq(l6.location.x, 0.0) + assert_eq(l6.location.y, 40.0) + let l7 = taffy.layout(node7) + assert_eq(l7.size.width, 20.0) + assert_eq(l7.size.height, 20.0) + assert_eq(l7.location.x, 30.0) + assert_eq(l7.location.y, 40.0) + let l8 = taffy.layout(node8) + assert_eq(l8.size.width, 20.0) + assert_eq(l8.size.height, 20.0) + assert_eq(l8.location.x, 60.0) + assert_eq(l8.location.y, 40.0) +} + +///| +test "upstream/generated/flex/gap_row_gap_row_wrap_child_margins" { + // Ported from taffy-reference/tests/generated/flex/gap_row_gap_row_wrap_child_margins.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(60.0), height=auto())) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(2.0), + bottom=length(2.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(60.0), height=auto())) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(60.0), height=auto())) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(15.0), + bottom=length(15.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_gap(Size(width=length(0.0), height=length(10.0))) + .with_size(Size(width=length(100.0), height=length(200.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, 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, 60.0) + assert_eq(l0.size.height, 42.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 2.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 60.0) + assert_eq(l1.size.height, 42.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 66.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 60.0) + assert_eq(l2.size.height, 42.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 143.0) +} + +///| +test "upstream/generated/flex/intrinsic_sizing_cross_size_column" { + // Ported from taffy-reference/tests/generated/flex/intrinsic_sizing_cross_size_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default().with_flex_direction(flex_direction_column()), + { text_content: "HH\u{200b}HH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 40.0) + assert_eq(lnode.size.height, 10.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/intrinsic_sizing_main_size_column" { + // Ported from taffy-reference/tests/generated/flex/intrinsic_sizing_main_size_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default().with_flex_direction(flex_direction_column()), + { text_content: "HH\u{200b}HH", writing_mode: Vertical }, + ) + 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, 40.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/intrinsic_sizing_main_size_column_nested" { + // Ported from taffy-reference/tests/generated/flex/intrinsic_sizing_main_size_column_nested.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_flex_direction(flex_direction_column()), + { text_content: "HH\u{200b}HH", writing_mode: Vertical }, + ) + 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, 10.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, 10.0) + assert_eq(l0.size.height, 40.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/intrinsic_sizing_main_size_column_wrap" { + // Ported from taffy-reference/tests/generated/flex/intrinsic_sizing_main_size_column_wrap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_flex_direction(flex_direction_column()), + { text_content: "HH\u{200b}HH", writing_mode: Vertical }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_flex_direction(flex_direction_column()), + { text_content: "HH\u{200b}HH", writing_mode: Vertical }, + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()), + [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, 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, 10.0) + assert_eq(l0.size.height, 40.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, 40.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 40.0) +} + +///| +test "upstream/generated/flex/intrinsic_sizing_main_size_row" { + // Ported from taffy-reference/tests/generated/flex/intrinsic_sizing_main_size_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200b}HH", + writing_mode: Horizontal, + }) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 40.0) + assert_eq(lnode.size.height, 10.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/intrinsic_sizing_main_size_row_nested" { + // Ported from taffy-reference/tests/generated/flex/intrinsic_sizing_main_size_row_nested.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200b}HH", + writing_mode: Horizontal, + }) + 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, 40.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, 40.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/intrinsic_sizing_main_size_row_wrap" { + // Ported from taffy-reference/tests/generated/flex/intrinsic_sizing_main_size_row_wrap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200b}HH", + writing_mode: Horizontal, + }) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200b}HH", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default().with_flex_wrap(flex_wrap_wrap()), + [node0, node1], + ) + 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, 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, 40.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, 40.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 40.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_column_center" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_center.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_justify_content(justify_content_center()) + .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, 35.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, 45.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, 55.0) +} + +///| +test "upstream/generated/flex/justify_content_column_center_negative_space" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_center_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -25.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -5.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 15.0) +} + +///| +test "upstream/generated/flex/justify_content_column_center_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_center_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -35.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -5.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 25.0) +} + +///| +test "upstream/generated/flex/justify_content_column_end" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_end.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_justify_content(justify_content_flex_end()) + .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, 70.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, 90.0) +} + +///| +test "upstream/generated/flex/justify_content_column_end_negative_space" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_end_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_end()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -50.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, -10.0) +} + +///| +test "upstream/generated/flex/justify_content_column_end_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_end_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_end()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, -70.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, -40.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, -10.0) +} + +///| +test "upstream/generated/flex/justify_content_column_end_reverse" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_end_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()) + .with_justify_content(justify_content_flex_end()) + .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, 70.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, 90.0) +} + +///| +test "upstream/generated/flex/justify_content_column_flex_end" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_flex_end.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_justify_content(justify_content_flex_end()) + .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, 70.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, 90.0) +} + +///| +test "upstream/generated/flex/justify_content_column_flex_end_reverse" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_flex_end_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_justify_content(justify_content_flex_end()) + .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, 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/justify_content_column_flex_start" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_flex_start.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_justify_content(justify_content_flex_start()) + .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) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part22_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part22_test.mbt new file mode 100644 index 0000000..af6793b --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part22_test.mbt @@ -0,0 +1,1319 @@ +// 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/justify_content_column_flex_start_reverse" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_flex_start_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_justify_content(justify_content_flex_start()) + .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/justify_content_column_max_height_and_margin" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_max_height_and_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(80.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(100.0), + bottom=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, 20.0) + assert_eq(lnode.size.height, 180.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, 20.0) + assert_eq(l0.size.height, 80.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 100.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 20.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 30.0) +} + +///| +test "upstream/generated/flex/justify_content_column_min_height_and_margin" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_min_height_and_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_center()) + .with_min_size(Size(width=auto(), height=length(50.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(100.0), + bottom=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, 20.0) + assert_eq(lnode.size.height, 150.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, 20.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 100.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 20.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 15.0) +} + +///| +test "upstream/generated/flex/justify_content_column_min_height_and_margin_bottom" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_min_height_and_margin_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_center()) + .with_min_size(Size(width=auto(), height=length(50.0))), + [node0], + ) + 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, 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, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/justify_content_column_min_height_and_margin_top" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_min_height_and_margin_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_center()) + .with_min_size(Size(width=auto(), height=length(50.0))), + [node0], + ) + 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, 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, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 20.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_around" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_around.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_justify_content(justify_content_space_around()) + .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, 12.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, 45.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, 78.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_around_negative_space" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_around_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_space_around()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_around_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_around_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_space_around()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 60.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_between" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_between.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_justify_content(justify_content_space_between()) + .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, 45.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, 90.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_between_negative_space" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_between_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_space_between()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_between_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_between_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_space_between()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 60.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_evenly" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_evenly.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_justify_content(justify_content_space_evenly()) + .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, 18.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, 45.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, 73.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_evenly_negative_space" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_evenly_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_space_evenly()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/justify_content_column_space_evenly_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_space_evenly_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_space_evenly()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 60.0) +} + +///| +test "upstream/generated/flex/justify_content_column_start" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_start.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_justify_content(justify_content_start()) + .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/justify_content_column_start_negative_space" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_start_negative_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_start()) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 20.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 40.0) +} + +///| +test "upstream/generated/flex/justify_content_column_start_negative_space_gap" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_start_negative_space_gap.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node02 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=percent(0.8), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_start()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_size(Size(width=auto(), height=length(10.0))), + [node00, node01, node02], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=length(320.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 320.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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 60.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 160.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 160.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 30.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 160.0) + assert_eq(l02.size.height, 20.0) + assert_eq(l02.location.x, 20.0) + assert_eq(l02.location.y, 60.0) +} + +///| +test "upstream/generated/flex/justify_content_column_start_reverse" { + // Ported from taffy-reference/tests/generated/flex/justify_content_column_start_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_justify_content(justify_content_start()) + .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, 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/justify_content_min_max" { + // Ported from taffy-reference/tests/generated/flex/justify_content_min_max.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(100.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), 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, 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, 60.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 20.0) +} + +///| +test "upstream/generated/flex/justify_content_min_width_with_padding_child_width_greater_than_parent" { + // Ported from taffy-reference/tests/generated/flex/justify_content_min_width_with_padding_child_width_greater_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(300.0), height=length(100.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_align_content(align_content_stretch()) + .with_justify_content(justify_content_center()) + .with_min_size(Size(width=length(400.0), height=auto())) + .with_padding( + Rect( + left=length(100.0), + right=length(100.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_align_content(align_content_stretch()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(1000.0), height=length(1584.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 1000.0) + assert_eq(lnode.size.height, 1584.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, 1000.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, 500.0) + assert_eq(l00.size.height, 100.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, 300.0) + assert_eq(l000.size.height, 100.0) + assert_eq(l000.location.x, 100.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_min_width_with_padding_child_width_lower_than_parent" { + // Ported from taffy-reference/tests/generated/flex/justify_content_min_width_with_padding_child_width_lower_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default() + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(199.0), height=length(100.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_align_content(align_content_stretch()) + .with_justify_content(justify_content_center()) + .with_min_size(Size(width=length(400.0), height=auto())) + .with_padding( + Rect( + left=length(100.0), + right=length(100.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default().with_align_content(align_content_stretch()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(1080.0), height=length(1584.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 1080.0) + assert_eq(lnode.size.height, 1584.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, 1080.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, 400.0) + assert_eq(l00.size.height, 100.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, 199.0) + assert_eq(l000.size.height, 100.0) + assert_eq(l000.location.x, 101.0) + assert_eq(l000.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_overflow_min_max" { + // Ported from taffy-reference/tests/generated/flex/justify_content_overflow_min_max.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.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_justify_content(justify_content_center()) + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(110.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, 50.0) + assert_eq(lnode.size.height, 110.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, -20.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, 0.0) + assert_eq(l1.location.y, 30.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 80.0) +} + +///| +test "upstream/generated/flex/justify_content_row_center" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_center.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_justify_content(justify_content_center()) + .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, 35.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, 45.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, 55.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_row_flex_end" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_flex_end.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_justify_content(justify_content_flex_end()) + .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, 70.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, 80.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, 90.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_row_flex_start" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_flex_start.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_justify_content(justify_content_flex_start()) + .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) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part23_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part23_test.mbt new file mode 100644 index 0000000..b279040 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part23_test.mbt @@ -0,0 +1,955 @@ +// 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/justify_content_row_max_width_and_margin" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_max_width_and_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(100.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(100.0), height=auto())) + .with_max_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, 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, 0.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 90.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_row_min_width_and_margin" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_min_width_and_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_min_size(Size(width=length(50.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, 50.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, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_row_space_around" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_space_around.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_justify_content(justify_content_space_around()) + .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, 12.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, 45.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, 78.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_row_space_between" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_space_between.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_justify_content(justify_content_space_between()) + .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, 45.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, 90.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/justify_content_row_space_evenly" { + // Ported from taffy-reference/tests/generated/flex/justify_content_row_space_evenly.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_justify_content(justify_content_space_evenly()) + .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, 0.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 25.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, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 0.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 75.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_and_flex_column" { + // Ported from taffy-reference/tests/generated/flex/margin_and_flex_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.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, 100.0) + assert_eq(l0.size.height, 80.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/margin_and_flex_row" { + // Ported from taffy-reference/tests/generated/flex/margin_and_flex_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.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, 80.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_and_stretch_column" { + // Ported from taffy-reference/tests/generated/flex/margin_and_stretch_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.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, 80.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_and_stretch_row" { + // Ported from taffy-reference/tests/generated/flex/margin_and_stretch_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(10.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, 100.0) + assert_eq(l0.size.height, 80.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/margin_auto_bottom" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [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, 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, 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, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_bottom_and_top" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_bottom_and_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [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, 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, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 75.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, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_bottom_and_top_justify_center" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_bottom_and_top_justify_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [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, 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, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 75.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, 100.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_auto_left" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [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, 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, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 100.0) + assert_eq(l0.location.y, 75.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, 150.0) + assert_eq(l1.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_and_right" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_and_right.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(200.0))), + [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, 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, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 50.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, 150.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_and_right_column" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_and_right_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [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, 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, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 75.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, 150.0) + assert_eq(l1.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_and_right_column_and_center" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_and_right_column_and_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [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, 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, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 75.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, 150.0) + assert_eq(l1.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_and_right_stretch" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_and_right_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_stretch()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [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, 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, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 50.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, 150.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_child_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_child_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 52.0) + assert_eq(lnode.size.height, 52.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, 52.0) + assert_eq(l0.size.height, 72.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_fix_right_child_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_fix_right_child_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=length(10.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 52.0) + assert_eq(lnode.size.height, 52.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, 42.0) + assert_eq(l0.size.height, 72.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_right_child_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_right_child_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 52.0) + assert_eq(lnode.size.height, 52.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, 52.0) + assert_eq(l0.size.height, 72.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_auto_left_stretching_child" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_left_stretching_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)) + .with_margin( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [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, 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, 150.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 100.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, 150.0) + assert_eq(l1.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_multiple_children_column" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_multiple_children_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node2 = taffy.new_leaf( + Style::default().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_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.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, 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, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 75.0) + assert_eq(l0.location.y, 25.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, 75.0) + assert_eq(l1.location.y, 100.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 75.0) + assert_eq(l2.location.y, 150.0) +} + +///| +test "upstream/generated/flex/margin_auto_multiple_children_row" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_multiple_children_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.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, 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, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 75.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, 75.0) + assert_eq(l1.location.y, 75.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 50.0) + assert_eq(l2.size.height, 50.0) + assert_eq(l2.location.x, 150.0) + assert_eq(l2.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_right" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_right.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [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, 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, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 75.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, 150.0) + assert_eq(l1.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_auto_top" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [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, 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, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 150.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, 75.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part24_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part24_test.mbt new file mode 100644 index 0000000..59fcdd0 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part24_test.mbt @@ -0,0 +1,769 @@ +// 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/margin_auto_top_and_bottom_stretch" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_top_and_bottom_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default().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_align_items(align_items_stretch()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [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, 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, 50.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 50.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, 0.0) + assert_eq(l1.location.y, 150.0) +} + +///| +test "upstream/generated/flex/margin_auto_top_stretching_child" { + // Ported from taffy-reference/tests/generated/flex/margin_auto_top_stretching_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)) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [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, 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, 150.0) + assert_eq(l0.size.height, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 200.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, 150.0) + assert_eq(l1.location.y, 75.0) +} + +///| +test "upstream/generated/flex/margin_bottom" { + // Ported from taffy-reference/tests/generated/flex/margin_bottom.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(10.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_justify_content(justify_content_flex_end()) + .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, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 80.0) +} + +///| +test "upstream/generated/flex/margin_fix_left_auto_right_child_bigger_than_parent" { + // Ported from taffy-reference/tests/generated/flex/margin_fix_left_auto_right_child_bigger_than_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(72.0), height=length(72.0))) + .with_margin( + Rect(left=length(10.0), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(52.0), height=length(52.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 52.0) + assert_eq(lnode.size.height, 52.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, 42.0) + assert_eq(l0.size.height, 72.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_left" { + // Ported from taffy-reference/tests/generated/flex/margin_left.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(10.0), height=auto())) + .with_margin( + Rect( + left=length(10.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.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, 10.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_right" { + // Ported from taffy-reference/tests/generated/flex/margin_right.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(10.0), height=auto())) + .with_margin( + Rect( + left=length(0.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_flex_end()) + .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, 10.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 80.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_should_not_be_part_of_max_height" { + // Ported from taffy-reference/tests/generated/flex/margin_should_not_be_part_of_max_height.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_max_size(Size(width=auto(), height=length(100.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(20.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(250.0), height=length(250.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 250.0) + assert_eq(lnode.size.height, 250.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, 20.0) +} + +///| +test "upstream/generated/flex/margin_should_not_be_part_of_max_width" { + // Ported from taffy-reference/tests/generated/flex/margin_should_not_be_part_of_max_width.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_max_size(Size(width=length(100.0), height=auto())) + .with_margin( + Rect( + left=length(20.0), + right=length(0.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(250.0), height=length(250.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 250.0) + assert_eq(lnode.size.height, 250.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, 20.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/margin_top" { + // Ported from taffy-reference/tests/generated/flex/margin_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.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, 100.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/margin_with_sibling_column" { + // Ported from taffy-reference/tests/generated/flex/margin_with_sibling_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.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_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, 45.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, 45.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 55.0) +} + +///| +test "upstream/generated/flex/margin_with_sibling_row" { + // Ported from taffy-reference/tests/generated/flex/margin_with_sibling_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_margin( + Rect( + left=length(0.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.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, 45.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, 45.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 55.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/max_height" { + // Ported from taffy-reference/tests/generated/flex/max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(10.0), height=auto())) + .with_max_size(Size(width=auto(), height=length(50.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, 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/max_height_overrides_height" { + // Ported from taffy-reference/tests/generated/flex/max_height_overrides_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(200.0))) + .with_max_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/max_height_overrides_height_on_root" { + // Ported from taffy-reference/tests/generated/flex/max_height_overrides_height_on_root.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(200.0))) + .with_max_size(Size(width=auto(), 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, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/max_width" { + // Ported from taffy-reference/tests/generated/flex/max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_max_size(Size(width=length(50.0), height=auto())), + ) + 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, 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/max_width_overrides_width" { + // Ported from taffy-reference/tests/generated/flex/max_width_overrides_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(200.0), height=auto())) + .with_max_size(Size(width=length(100.0), height=auto())), + ) + 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, 0.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, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/max_width_overrides_width_on_root" { + // Ported from taffy-reference/tests/generated/flex/max_width_overrides_width_on_root.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(200.0), height=auto())) + .with_max_size(Size(width=length(100.0), height=auto())), + ) + 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, 0.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_child" { + // Ported from taffy-reference/tests/generated/flex/measure_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHHHH", + writing_mode: Horizontal, + }) + 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, 60.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, 60.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/measure_child_absolute" { + // Ported from taffy-reference/tests/generated/flex/measure_child_absolute.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_position(position_absolute()), + { text_content: "HHHHHH", writing_mode: Horizontal }, + ) + 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, 60.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/measure_child_constraint" { + // Ported from taffy-reference/tests/generated/flex/measure_child_constraint.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.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, 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, 100.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/measure_child_constraint_padding_parent" { + // Ported from taffy-reference/tests/generated/flex/measure_child_constraint_padding_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_padding( + 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, 50.0) + assert_eq(lnode.size.height, 120.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, 10.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/measure_child_with_flex_grow" { + // Ported from taffy-reference/tests/generated/flex/measure_child_with_flex_grow.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "H\u{200b}H\u{200b}H\u{200b}H\u{200b}H", + writing_mode: Horizontal, + }) + 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/measure_child_with_flex_shrink" { + // Ported from taffy-reference/tests/generated/flex/measure_child_with_flex_shrink.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH", + writing_mode: Horizontal, + }) + 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, 0.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, 100.0) + assert_eq(l1.size.height, 50.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_child_with_flex_shrink_hidden" { + // Ported from taffy-reference/tests/generated/flex/measure_child_with_flex_shrink_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0), + { + text_content: "HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH\u{200b}HHHHHHHHHH", + writing_mode: Horizontal, + }, + ) + 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) + assert_layout_xywh(taffy, node, 100.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 9.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 91.0, 50.0, 9.0, 0.0) +} + +///| +test "upstream/generated/flex/measure_child_with_min_size_greater_than_available_space" { + // Ported from taffy-reference/tests/generated/flex/measure_child_with_min_size_greater_than_available_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_min_size(Size(width=length(200.0), height=auto())), + { text_content: "HHHHHHHH\u{200b}HHHHHHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .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, 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, 200.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part25_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part25_test.mbt new file mode 100644 index 0000000..5c2c946 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part25_test.mbt @@ -0,0 +1,710 @@ +// 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/measure_flex_basis_overrides_measure" { + // Ported from taffy-reference/tests/generated/flex/measure_flex_basis_overrides_measure.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "H", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.0), height=length(50.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, 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/measure_height_overrides_measure" { + // Ported from taffy-reference/tests/generated/flex/measure_height_overrides_measure.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(5.0))), + { text_content: "H", writing_mode: Horizontal }, + ) + 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, 10.0) + assert_eq(lnode.size.height, 5.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, 5.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_remeasure_child_after_growing" { + // Ported from taffy-reference/tests/generated/flex/measure_remeasure_child_after_growing.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_start()) + .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, 20.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_remeasure_child_after_shrinking" { + // Ported from taffy-reference/tests/generated/flex/measure_remeasure_child_after_shrinking.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node = taffy.new_with_children( + Style::default() + .with_align_items(align_items_start()) + .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, 20.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 50.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_remeasure_child_after_stretching" { + // Ported from taffy-reference/tests/generated/flex/measure_remeasure_child_after_stretching.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + 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, 20.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/measure_root" { + // Ported from taffy-reference/tests/generated/flex/measure_root.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHHHH", + writing_mode: Horizontal, + }) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 60.0) + assert_eq(lnode.size.height, 10.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_stretch_overrides_measure" { + // Ported from taffy-reference/tests/generated/flex/measure_stretch_overrides_measure.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(length(5.0)), + ) + let node1 = taffy.new_leaf_with_context( + Style::default().with_flex_grow(1.0).with_flex_basis(length(5.0)), + { text_content: "H", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(20.0), height=length(10.0))), + [node0, node1], + ) + 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, 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, 10.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, 10.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 10.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/measure_width_overrides_measure" { + // Ported from taffy-reference/tests/generated/flex/measure_width_overrides_measure.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=length(50.0), height=auto())), + { text_content: "HHHHHHHHHH", writing_mode: Horizontal }, + ) + 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, 50.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, 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/min_height" { + // Ported from taffy-reference/tests/generated/flex/min_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=auto(), height=length(60.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, 60.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, 40.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 60.0) +} + +///| +test "upstream/generated/flex/min_height_larger_than_height" { + // Ported from taffy-reference/tests/generated/flex/min_height_larger_than_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(25.0))) + .with_min_size(Size(width=auto(), height=length(50.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, 50.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_height_overrides_height" { + // Ported from taffy-reference/tests/generated/flex/min_height_overrides_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_min_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/min_height_overrides_height_on_root" { + // Ported from taffy-reference/tests/generated/flex/min_height_overrides_height_on_root.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(50.0))) + .with_min_size(Size(width=auto(), 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, 100.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_height_overrides_max_height" { + // Ported from taffy-reference/tests/generated/flex/min_height_overrides_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=auto(), height=length(100.0))) + .with_max_size(Size(width=auto(), height=length(50.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/min_height_with_nested_fixed_height" { + // Ported from taffy-reference/tests/generated/flex/min_height_with_nested_fixed_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(40.0), height=length(40.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_self(align_items_flex_start()) + .with_flex_shrink(0.0) + .with_min_size(Size(width=auto(), height=length(28.0))) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(8.0), + bottom=length(9.0), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(320.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(44.0))) + .with_padding( + Rect( + left=length(16.0), + right=length(16.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 57.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, 16.0) + assert_eq(l0.location.y, 8.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 40.0) + assert_eq(l00.size.height, 40.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_max_percent_different_width_height" { + // Ported from taffy-reference/tests/generated/flex/min_max_percent_different_width_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_min_size(Size(width=percent(0.1), height=percent(0.1))) + .with_max_size(Size(width=percent(0.1), height=percent(0.1))), + { text_content: "", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_flex_start()) + .with_size(Size(width=length(100.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, 100.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, 10.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_max_percent_no_width_height" { + // Ported from taffy-reference/tests/generated/flex/min_max_percent_no_width_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=percent(0.1), height=percent(0.1))) + .with_max_size(Size(width=percent(0.1), height=percent(0.1))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_flex_start()) + .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, 10.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/min_width" { + // Ported from taffy-reference/tests/generated/flex/min_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=length(60.0), height=auto())), + ) + 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, 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, 40.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 60.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_width_larger_than_width" { + // Ported from taffy-reference/tests/generated/flex/min_width_larger_than_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(25.0), height=auto())) + .with_min_size(Size(width=length(50.0), height=auto())), + ) + 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, 50.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/min_width_overrides_max_width" { + // Ported from taffy-reference/tests/generated/flex/min_width_overrides_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(100.0), height=auto())) + .with_max_size(Size(width=length(50.0), height=auto())), + ) + 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, 0.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, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_width_overrides_width" { + // Ported from taffy-reference/tests/generated/flex/min_width_overrides_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_min_size(Size(width=length(100.0), height=auto())), + ) + 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, 0.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, 0.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/min_width_overrides_width_on_root" { + // Ported from taffy-reference/tests/generated/flex/min_width_overrides_width_on_root.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_min_size(Size(width=length(100.0), height=auto())), + ) + 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, 0.0) + assert_eq(lnode.location.x, 0.0) + assert_eq(lnode.location.y, 0.0) +} + +///| +test "upstream/generated/flex/mod" { + // Ported from taffy-reference/tests/generated/flex/mod.rs + () +} + +///| +test "upstream/generated/flex/nested_overflowing_child" { + // Ported from taffy-reference/tests/generated/flex/nested_overflowing_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(200.0), height=length(200.0))), + ) + let node0 = taffy.new_with_children(Style::default(), [node00]) + 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, 200.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, 200.0) + assert_eq(l00.size.height, 200.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/nested_overflowing_child_in_constraint_parent" { + // Ported from taffy-reference/tests/generated/flex/nested_overflowing_child_in_constraint_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(200.0), height=length(200.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [node00], + ) + 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, 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, 200.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/only_shrinkable_item_with_flex_basis_zero" { + // Ported from taffy-reference/tests/generated/flex/only_shrinkable_item_with_flex_basis_zero.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_shrink(1.0).with_flex_basis(length(0.0)), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_flex_basis(length(93.0)) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(0.0), + bottom=length(6.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default().with_flex_shrink(0.0).with_flex_basis(length(764.0)), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(480.0), height=auto())) + .with_max_size(Size(width=auto(), height=length(764.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, 480.0) + assert_eq(lnode.size.height, 764.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, 480.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, 480.0) + assert_eq(l1.size.height, 93.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 480.0) + assert_eq(l2.size.height, 764.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 99.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part26_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part26_test.mbt new file mode 100644 index 0000000..98fe620 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part26_test.mbt @@ -0,0 +1,732 @@ +// 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/overflow_cross_axis" { + // Ported from taffy-reference/tests/generated/flex/overflow_cross_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(200.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, 100.0) + assert_eq(l0.size.height, 200.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/overflow_main_axis" { + // Ported from taffy-reference/tests/generated/flex/overflow_main_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(200.0), height=auto())), + ) + 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, 200.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/overflow_main_axis_shrink_hidden" { + // Ported from taffy-reference/tests/generated/flex/overflow_main_axis_shrink_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_flex_shrink(1.0), + { text_content: "HHHHHHHHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default().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, 50.0, 50.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/overflow_main_axis_shrink_scroll" { + // Ported from taffy-reference/tests/generated/flex/overflow_main_axis_shrink_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_flex_shrink(1.0), + { text_content: "HHHHHHHHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default().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, 50.0, 50.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/overflow_main_axis_shrink_visible" { + // Ported from taffy-reference/tests/generated/flex/overflow_main_axis_shrink_visible.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_flex_shrink(1.0), + { text_content: "HHHHHHHHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.0), height=length(50.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, 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/overflow_scroll_main_axis_justify_content_end" { + // Ported from taffy-reference/tests/generated/flex/overflow_scroll_main_axis_justify_content_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(200.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_end()) + .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, 200.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, -100.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/overflow_scrollbars_overridden_by_available_space" { + // Ported from taffy-reference/tests/generated/flex/overflow_scrollbars_overridden_by_available_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node0 = taffy.new_with_children( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_flex_grow(1.0), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/overflow_scrollbars_overridden_by_max_size" { + // Ported from taffy-reference/tests/generated/flex/overflow_scrollbars_overridden_by_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_max_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/overflow_scrollbars_overridden_by_size" { + // Ported from taffy-reference/tests/generated/flex/overflow_scrollbars_overridden_by_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/overflow_scrollbars_take_up_space_both_axis" { + // Ported from taffy-reference/tests/generated/flex/overflow_scrollbars_take_up_space_both_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .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, 35.0, 35.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/overflow_scrollbars_take_up_space_cross_axis" { + // Ported from taffy-reference/tests/generated/flex/overflow_scrollbars_take_up_space_cross_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default() + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .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, 35.0, 50.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/overflow_scrollbars_take_up_space_main_axis" { + // Ported from taffy-reference/tests/generated/flex/overflow_scrollbars_take_up_space_main_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .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, 50.0, 35.0, 0.0, 0.0) +} + +///| +test "upstream/generated/flex/padding_align_end_child" { + // Ported from taffy-reference/tests/generated/flex/padding_align_end_child.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_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/padding_border_overrides_max_size" { + // Ported from taffy-reference/tests/generated/flex/padding_border_overrides_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_max_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.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, 22.0) + assert_eq(lnode.size.height, 14.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, 22.0) + assert_eq(l0.size.height, 14.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/padding_border_overrides_min_size" { + // Ported from taffy-reference/tests/generated/flex/padding_border_overrides_min_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(0.0), height=length(0.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.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, 22.0) + assert_eq(lnode.size.height, 14.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, 22.0) + assert_eq(l0.size.height, 14.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/padding_border_overrides_size" { + // Ported from taffy-reference/tests/generated/flex/padding_border_overrides_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.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, 22.0) + assert_eq(lnode.size.height, 14.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, 22.0) + assert_eq(l0.size.height, 14.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/padding_border_overrides_size_flex_basis_0" { + // Ported from taffy-reference/tests/generated/flex/padding_border_overrides_size_flex_basis_0.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_basis(length(0.0)) + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_basis(length(0.0)) + .with_size(Size(width=length(12.0), height=length(12.0))), + ) + 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, 34.0) + assert_eq(lnode.size.height, 14.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, 22.0) + assert_eq(l0.size.height, 14.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, 12.0) + assert_eq(l1.location.x, 22.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/padding_border_overrides_size_flex_basis_0_growable" { + // Ported from taffy-reference/tests/generated/flex/padding_border_overrides_size_flex_basis_0_growable.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(0.0)) + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(0.0)) + .with_size(Size(width=length(12.0), height=length(12.0))), + ) + 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, 34.0) + assert_eq(lnode.size.height, 14.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, 28.0) + assert_eq(l0.size.height, 14.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, 6.0) + assert_eq(l1.size.height, 12.0) + assert_eq(l1.location.x, 28.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/padding_border_overrides_size_root" { + // Ported from taffy-reference/tests/generated/flex/padding_border_overrides_size_root.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(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 22.0) + assert_eq(lnode.size.height, 14.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, 15.0) + assert_eq(l0.location.y, 3.0) +} + +///| +test "upstream/generated/flex/padding_center_child" { + // Ported from taffy-reference/tests/generated/flex/padding_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_padding( + Rect( + left=length(10.0), + right=length(20.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, 40.0) + assert_eq(l0.location.y, 40.0) +} + +///| +test "upstream/generated/flex/padding_container_match_child" { + // Ported from taffy-reference/tests/generated/flex/padding_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_padding( + 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/padding_flex_child" { + // Ported from taffy-reference/tests/generated/flex/padding_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_padding( + 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/padding_no_child" { + // Ported from taffy-reference/tests/generated/flex/padding_no_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default().with_padding( + 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/padding_no_size" { + // Ported from taffy-reference/tests/generated/flex/padding_no_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default().with_padding( + 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/padding_stretch_child" { + // Ported from taffy-reference/tests/generated/flex/padding_stretch_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + 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, 0.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 10.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part27_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part27_test.mbt new file mode 100644 index 0000000..15df8b2 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part27_test.mbt @@ -0,0 +1,1082 @@ +// 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/parent_wrap_child_size_overflowing_parent" { + // Ported from taffy-reference/tests/generated/flex/parent_wrap_child_size_overflowing_parent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(200.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [node00], + ) + 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, 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, 200.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percent_absolute_position" { + // Ported from taffy-reference/tests/generated/flex/percent_absolute_position.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=auto())), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=auto())), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=percent(1.0), height=length(50.0))) + .with_inset( + Rect(left=percent(0.5), right=auto(), top=auto(), bottom=auto()), + ), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(60.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 60.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, 60.0) + assert_eq(l0.size.height, 50.0) + assert_eq(l0.location.x, 30.0) + assert_eq(l0.location.y, 0.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 30.0) + assert_eq(l00.size.height, 50.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 30.0) + assert_eq(l01.size.height, 50.0) + assert_eq(l01.location.x, 30.0) + assert_eq(l01.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percent_within_flex_grow" { + // Ported from taffy-reference/tests/generated/flex/percent_within_flex_grow.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=auto())), + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=auto())), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0), + [node10], + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(350.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, 350.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, 150.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, 150.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, 100.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 250.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_absolute_position" { + // Ported from taffy-reference/tests/generated/flex/percentage_absolute_position.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_inset( + Rect(left=percent(0.3), right=auto(), top=percent(0.1), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.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, 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, 10.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 60.0) + assert_eq(l0.location.y, 10.0) +} + +///| +test "upstream/generated/flex/percentage_container_in_wrapping_container" { + // Ported from taffy-reference/tests/generated/flex/percentage_container_in_wrapping_container.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node001 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=percent(1.0), height=auto())), + [node000, node001], + ) + let node0 = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .with_justify_content(justify_content_center()) + .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, 50.0) + assert_eq(l0.location.x, 50.0) + assert_eq(l0.location.y, 75.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) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 50.0) + assert_eq(l000.size.height, 50.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) + let l001 = taffy.layout(node001) + assert_eq(l001.size.width, 50.0) + assert_eq(l001.size.height, 50.0) + assert_eq(l001.location.x, 50.0) + assert_eq(l001.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_different_width_height" { + // Ported from taffy-reference/tests/generated/flex/percentage_different_width_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=percent(0.3))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=auto(), height=percent(0.3))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(300.0))), + [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, 300.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, 200.0) + assert_eq(l0.size.height, 90.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, 90.0) + assert_eq(l1.location.x, 200.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_different_width_height_column" { + // Ported from taffy-reference/tests/generated/flex/percentage_different_width_height_column.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_size(Size(width=auto(), height=percent(0.3))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(300.0))), + [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, 300.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, 200.0) + assert_eq(l0.size.height, 210.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, 200.0) + assert_eq(l1.size.height, 90.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 210.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(percent(0.5)), + ) + let node1 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(percent(0.25)), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(200.0))), + [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, 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, 125.0) + assert_eq(l0.size.height, 200.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, 75.0) + assert_eq(l1.size.height, 200.0) + assert_eq(l1.location.x, 125.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_cross" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_cross.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(percent(0.5)), + ) + let node1 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_basis(percent(0.25)), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(400.0))), + [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, 400.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, 200.0) + assert_eq(l0.size.height, 250.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, 200.0) + assert_eq(l1.size.height, 150.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 250.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_cross_max_height" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_cross_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(percent(0.1)) + .with_max_size(Size(width=auto(), height=percent(0.6))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(percent(0.1)) + .with_max_size(Size(width=auto(), height=percent(0.2))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(400.0))), + [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, 400.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, 200.0) + assert_eq(l0.size.height, 240.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, 200.0) + assert_eq(l1.size.height, 80.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 240.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_cross_max_width" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_cross_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(percent(0.1)) + .with_max_size(Size(width=percent(0.6), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(percent(0.15)) + .with_max_size(Size(width=percent(0.2), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(400.0))), + [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, 400.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, 120.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, 40.0) + assert_eq(l1.size.height, 300.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 100.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_cross_min_height" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_cross_min_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_min_size(Size(width=auto(), height=percent(0.6))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(2.0) + .with_min_size(Size(width=auto(), height=percent(0.1))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(400.0))), + [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, 400.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, 200.0) + assert_eq(l0.size.height, 240.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, 200.0) + assert_eq(l1.size.height, 160.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 240.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_cross_min_width" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_cross_min_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(percent(0.1)) + .with_min_size(Size(width=percent(0.6), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(percent(0.15)) + .with_min_size(Size(width=percent(0.2), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(400.0))), + [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, 400.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, 200.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, 200.0) + assert_eq(l1.size.height, 300.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 100.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_main_max_height" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_main_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(percent(0.1)) + .with_max_size(Size(width=auto(), height=percent(0.6))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(percent(0.1)) + .with_max_size(Size(width=auto(), height=percent(0.2))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(400.0))), + [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, 400.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, 52.0) + assert_eq(l0.size.height, 240.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, 148.0) + assert_eq(l1.size.height, 80.0) + assert_eq(l1.location.x, 52.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_main_max_width" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_main_max_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(percent(0.15)) + .with_max_size(Size(width=percent(0.6), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(percent(0.1)) + .with_max_size(Size(width=percent(0.2), height=auto())), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(400.0))), + [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, 400.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, 120.0) + assert_eq(l0.size.height, 400.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, 40.0) + assert_eq(l1.size.height, 400.0) + assert_eq(l1.location.x, 120.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_flex_basis_main_min_width" { + // Ported from taffy-reference/tests/generated/flex/percentage_flex_basis_main_min_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(percent(0.15)) + .with_min_size(Size(width=percent(0.6), height=auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(percent(0.1)) + .with_min_size(Size(width=percent(0.2), height=auto())), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(400.0))), + [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, 400.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, 120.0) + assert_eq(l0.size.height, 400.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, 80.0) + assert_eq(l1.size.height, 400.0) + assert_eq(l1.location.x, 120.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_main_max_height" { + // Ported from taffy-reference/tests/generated/flex/percentage_main_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default().with_flex_basis(length(15.0))) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_basis(length(48.0)) + .with_max_size(Size(width=auto(), height=percent(0.33))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_flex_start()) + .with_size(Size(width=auto(), height=length(151.0))), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(71.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, 71.0) + assert_eq(lnode.size.height, 151.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, 71.0) + assert_eq(l0.size.height, 151.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, 0.0) + assert_eq(l00.size.height, 15.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 0.0) + assert_eq(l01.size.height, 48.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 15.0) +} + +///| +test "upstream/generated/flex/percentage_margin_should_calculate_based_only_on_width" { + // Ported from taffy-reference/tests/generated/flex/percentage_margin_should_calculate_based_only_on_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_margin( + Rect( + left=percent(0.1), + right=percent(0.1), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.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, 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, 160.0) + assert_eq(l0.size.height, 60.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 20.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 10.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/percentage_moderate_complexity" { + // Ported from taffy-reference/tests/generated/flex/percentage_moderate_complexity.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.45), height=auto())) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=percent(0.5), height=auto())) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=percent(0.03), + right=percent(0.03), + top=percent(0.03), + bottom=percent(0.03), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=auto())) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) +} + +///| +test "upstream/generated/flex/percentage_moderate_complexity2" { + // Ported from taffy-reference/tests/generated/flex/percentage_moderate_complexity2.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=percent(0.5), height=auto())) + .with_padding( + Rect( + left=percent(0.1), + right=percent(0.1), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .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, 60.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, 20.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 20.0) +} + +///| +test "upstream/generated/flex/percentage_multiple_nested_with_padding_margin_and_percentage_values" { + // Ported from taffy-reference/tests/generated/flex/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.45), height=auto())) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=percent(0.5), height=auto())) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=percent(0.03), + right=percent(0.03), + top=percent(0.03), + bottom=percent(0.03), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_flex_basis(percent(0.1)) + .with_min_size(Size(width=percent(0.6), height=auto())) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + [node00], + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(percent(0.15)) + .with_min_size(Size(width=percent(0.2), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(200.0))), + [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, 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, 190.0) + assert_eq(l0.size.height, 48.0) + assert_eq(l0.location.x, 5.0) + assert_eq(l0.location.y, 5.0) + let l00 = taffy.layout(node00) + assert_eq(l00.size.width, 92.0) + assert_eq(l00.size.height, 25.0) + assert_eq(l00.location.x, 8.0) + assert_eq(l00.location.y, 8.0) + let l000 = taffy.layout(node000) + assert_eq(l000.size.width, 36.0) + assert_eq(l000.size.height, 6.0) + assert_eq(l000.location.x, 10.0) + assert_eq(l000.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 200.0) + assert_eq(l1.size.height, 142.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 58.0) +} + +///| +test "upstream/generated/flex/percentage_padding_should_calculate_based_only_on_width" { + // Ported from taffy-reference/tests/generated/flex/percentage_padding_should_calculate_based_only_on_width.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_padding( + Rect( + left=percent(0.1), + right=percent(0.1), + top=percent(0.1), + bottom=percent(0.1), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.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, 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, 200.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, 10.0) + assert_eq(l00.location.x, 20.0) + assert_eq(l00.location.y, 20.0) +} + +///| +test "upstream/generated/flex/percentage_position_bottom_right" { + // Ported from taffy-reference/tests/generated/flex/percentage_position_bottom_right.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.55), height=percent(0.15))) + .with_inset( + Rect(left=auto(), right=percent(0.2), top=auto(), bottom=percent(0.1)), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(500.0), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.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, 275.0) + assert_eq(l0.size.height, 75.0) + assert_eq(l0.location.x, -100.0) + assert_eq(l0.location.y, -50.0) +} + +///| +test "upstream/generated/flex/percentage_position_left_top" { + // Ported from taffy-reference/tests/generated/flex/percentage_position_left_top.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.45), height=percent(0.55))) + .with_inset( + Rect(left=percent(0.1), right=auto(), top=percent(0.2), bottom=auto()), + ), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(400.0), height=length(400.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 400.0) + assert_eq(lnode.size.height, 400.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, 180.0) + assert_eq(l0.size.height, 220.0) + assert_eq(l0.location.x, 40.0) + assert_eq(l0.location.y, 80.0) +} + +///| +test "upstream/generated/flex/percentage_size_based_on_parent_inner_size" { + // Ported from taffy-reference/tests/generated/flex/percentage_size_based_on_parent_inner_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(0.5), height=percent(0.5))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(200.0), height=length(400.0))) + .with_padding( + Rect( + left=length(20.0), + right=length(20.0), + top=length(20.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, 200.0) + assert_eq(lnode.size.height, 400.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, 180.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 20.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part28_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part28_test.mbt new file mode 100644 index 0000000..cfaf0a0 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part28_test.mbt @@ -0,0 +1,1252 @@ +// 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/percentage_size_of_flex_basis" { + // Ported from taffy-reference/tests/generated/flex/percentage_size_of_flex_basis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(1.0), height=length(100.0))), + ) + let node0 = taffy.new_with_children( + Style::default().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, 50.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/percentage_sizes_should_not_prevent_flex_shrinking" { + // Ported from taffy-reference/tests/generated/flex/percentage_sizes_should_not_prevent_flex_shrinking.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default().with_size(Size(width=percent(1.2), height=auto())), + [node00], + ) + let node = taffy.new_with_children( + Style::default().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, 200.0) + assert_eq(l0.size.height, 200.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, 0.0) + assert_eq(l00.size.height, 200.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_width_height" { + // Ported from taffy-reference/tests/generated/flex/percentage_width_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(0.3), height=percent(0.3))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(400.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, 400.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, 120.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/percentage_width_height_undefined_parent_size" { + // Ported from taffy-reference/tests/generated/flex/percentage_width_height_undefined_parent_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=percent(0.5), height=percent(0.5))), + ) + 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, 0.0) + assert_eq(lnode.size.height, 0.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/position_root_with_rtl_should_position_withoutdirection" { + // Ported from taffy-reference/tests/generated/flex/position_root_with_rtl_should_position_withoutdirection.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(52.0), height=length(52.0))) + .with_inset( + Rect(left=length(72.0), right=auto(), top=auto(), bottom=auto()), + ), + ) + 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, 52.0) + assert_eq(lnode.size.height, 52.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, 52.0) + assert_eq(l0.size.height, 52.0) + assert_eq(l0.location.x, 72.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/flex/relative_position_should_not_nudge_siblings" { + // Ported from taffy-reference/tests/generated/flex/relative_position_should_not_nudge_siblings.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(15.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(15.0), bottom=auto()), + ), + ) + 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, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 15.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, 25.0) +} + +///| +test "upstream/generated/flex/rounding_flex_basis_flex_grow_row_prime_number_width" { + // Ported from taffy-reference/tests/generated/flex/rounding_flex_basis_flex_grow_row_prime_number_width.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_flex_grow(1.0)) + let node2 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node3 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node4 = taffy.new_leaf(Style::default().with_flex_grow(1.0)) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(113.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 113.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, 23.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, 22.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 23.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 23.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 45.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 22.0) + assert_eq(l3.size.height, 100.0) + assert_eq(l3.location.x, 68.0) + assert_eq(l3.location.y, 0.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 23.0) + assert_eq(l4.size.height, 100.0) + assert_eq(l4.location.x, 90.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/rounding_flex_basis_flex_grow_row_width_of_100" { + // Ported from taffy-reference/tests/generated/flex/rounding_flex_basis_flex_grow_row_width_of_100.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_flex_grow(1.0)) + let node2 = 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, 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, 33.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, 34.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 33.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 33.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 67.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/rounding_flex_basis_flex_shrink_row" { + // Ported from taffy-reference/tests/generated/flex/rounding_flex_basis_flex_shrink_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_flex_shrink(1.0).with_flex_basis(length(100.0)), + ) + let node1 = taffy.new_leaf(Style::default().with_flex_basis(length(25.0))) + let node2 = taffy.new_leaf(Style::default().with_flex_basis(length(25.0))) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(101.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, 101.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, 17.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 67.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 17.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 84.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/rounding_flex_basis_overrides_main_size" { + // Ported from taffy-reference/tests/generated/flex/rounding_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=auto(), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .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(113.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, 113.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, 64.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, 64.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 24.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 89.0) +} + +///| +test "upstream/generated/flex/rounding_fractial_input_1" { + // Ported from taffy-reference/tests/generated/flex/rounding_fractial_input_1.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=auto(), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .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(113.4))), + [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, 113.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, 64.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, 64.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 24.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 89.0) +} + +///| +test "upstream/generated/flex/rounding_fractial_input_2" { + // Ported from taffy-reference/tests/generated/flex/rounding_fractial_input_2.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=auto(), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .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(113.6))), + [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, 114.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, 65.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, 24.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 65.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 25.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 89.0) +} + +///| +test "upstream/generated/flex/rounding_fractial_input_3" { + // Ported from taffy-reference/tests/generated/flex/rounding_fractial_input_3.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=auto(), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .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(113.4))), + [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, 113.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, 64.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, 64.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 24.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 89.0) +} + +///| +test "upstream/generated/flex/rounding_fractial_input_4" { + // Ported from taffy-reference/tests/generated/flex/rounding_fractial_input_4.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=auto(), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .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(113.4))), + [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, 113.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, 64.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, 64.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 24.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 89.0) +} + +///| +test "upstream/generated/flex/rounding_fractial_input_5" { + // Ported from taffy-reference/tests/generated/flex/rounding_fractial_input_5.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.3), height=length(100.3))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.3), height=length(100.3))), + ) + let node = taffy.new_with_children( + Style::default() + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(963.333), 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, 963.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, 101.0) + assert_eq(l0.size.height, 100.0) + assert_eq(l0.location.x, 381.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, 482.0) + assert_eq(l1.location.y, 0.0) +} + +///| +test "upstream/generated/flex/rounding_fractial_input_6" { + // Ported from taffy-reference/tests/generated/flex/rounding_fractial_input_6.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(2.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(2.0), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=percent(0.5), height=auto())), + [node00, node01], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(2.0), height=length(10.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(2.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=percent(0.5), height=auto())), + [node10, node11], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(7.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, 7.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, 4.0) + assert_eq(l0.size.height, 20.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, 2.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 2.0) + assert_eq(l01.size.height, 10.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 3.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 4.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 2.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 2.0) + assert_eq(l11.size.height, 10.0) + assert_eq(l11.location.x, 0.0) + assert_eq(l11.location.y, 10.0) +} + +///| +test "upstream/generated/flex/rounding_fractial_input_7" { + // Ported from taffy-reference/tests/generated/flex/rounding_fractial_input_7.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=percent(0.25), height=auto())), + [node00, node01], + ) + let node10 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node11 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=percent(0.25), height=auto())), + [node10, node11], + ) + let node20 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node21 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node2 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=percent(0.25), height=auto())), + [node20, node21], + ) + let node30 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node31 = taffy.new_leaf( + Style::default().with_size(Size(width=length(1.0), height=length(10.0))), + ) + let node3 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=percent(0.25), height=auto())), + [node30, node31], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(7.0), height=auto())), + [node0, node1, node2, node3], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 7.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, 2.0) + assert_eq(l0.size.height, 20.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, 1.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 1.0) + assert_eq(l01.size.height, 10.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 2.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 2.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 1.0) + assert_eq(l10.size.height, 10.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 1.0) + assert_eq(l11.size.height, 10.0) + assert_eq(l11.location.x, 0.0) + assert_eq(l11.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 1.0) + assert_eq(l2.size.height, 20.0) + assert_eq(l2.location.x, 4.0) + assert_eq(l2.location.y, 0.0) + let l20 = taffy.layout(node20) + assert_eq(l20.size.width, 1.0) + assert_eq(l20.size.height, 10.0) + assert_eq(l20.location.x, 0.0) + assert_eq(l20.location.y, 0.0) + let l21 = taffy.layout(node21) + assert_eq(l21.size.width, 1.0) + assert_eq(l21.size.height, 10.0) + assert_eq(l21.location.x, 0.0) + assert_eq(l21.location.y, 10.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 2.0) + assert_eq(l3.size.height, 20.0) + assert_eq(l3.location.x, 5.0) + assert_eq(l3.location.y, 0.0) + let l30 = taffy.layout(node30) + assert_eq(l30.size.width, 1.0) + assert_eq(l30.size.height, 10.0) + assert_eq(l30.location.x, 0.0) + assert_eq(l30.location.y, 0.0) + let l31 = taffy.layout(node31) + assert_eq(l31.size.width, 1.0) + assert_eq(l31.size.height, 10.0) + assert_eq(l31.location.x, 0.0) + assert_eq(l31.location.y, 10.0) +} + +///| +test "upstream/generated/flex/rounding_inner_node_controversy_combined" { + // Ported from taffy-reference/tests/generated/flex/rounding_inner_node_controversy_combined.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=percent(1.0))), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=percent(1.0), height=auto())), + ) + let node110 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=percent(1.0), height=auto())), + ) + let node11 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=percent(1.0), height=auto())), + [node110], + ) + let node12 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=percent(1.0), height=auto())), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=percent(1.0))), + [node10, node11, node12], + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=percent(1.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(640.0), height=length(320.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, 640.0) + assert_eq(lnode.size.height, 320.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, 213.0) + assert_eq(l0.size.height, 320.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, 214.0) + assert_eq(l1.size.height, 320.0) + assert_eq(l1.location.x, 213.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 214.0) + assert_eq(l10.size.height, 107.0) + assert_eq(l10.location.x, 0.0) + assert_eq(l10.location.y, 0.0) + let l11 = taffy.layout(node11) + assert_eq(l11.size.width, 214.0) + assert_eq(l11.size.height, 106.0) + assert_eq(l11.location.x, 0.0) + assert_eq(l11.location.y, 107.0) + let l110 = taffy.layout(node110) + assert_eq(l110.size.width, 214.0) + assert_eq(l110.size.height, 106.0) + assert_eq(l110.location.x, 0.0) + assert_eq(l110.location.y, 0.0) + let l12 = taffy.layout(node12) + assert_eq(l12.size.width, 214.0) + assert_eq(l12.size.height, 107.0) + assert_eq(l12.location.x, 0.0) + assert_eq(l12.location.y, 213.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 213.0) + assert_eq(l2.size.height, 320.0) + assert_eq(l2.location.x, 427.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/rounding_inner_node_controversy_horizontal" { + // Ported from taffy-reference/tests/generated/flex/rounding_inner_node_controversy_horizontal.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node10 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + [node10], + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(320.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, 320.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, 107.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, 106.0) + assert_eq(l1.size.height, 10.0) + assert_eq(l1.location.x, 107.0) + assert_eq(l1.location.y, 0.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 106.0) + assert_eq(l10.size.height, 10.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, 107.0) + assert_eq(l2.size.height, 10.0) + assert_eq(l2.location.x, 213.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/flex/rounding_inner_node_controversy_vertical" { + // Ported from taffy-reference/tests/generated/flex/rounding_inner_node_controversy_vertical.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 node10 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=length(10.0), height=auto())), + ) + let node1 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(1.0) + .with_size(Size(width=length(10.0), height=auto())), + [node10], + ) + 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_flex_direction(flex_direction_column()) + .with_size(Size(width=auto(), height=length(320.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, 10.0) + assert_eq(lnode.size.height, 320.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, 107.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, 106.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 107.0) + let l10 = taffy.layout(node10) + assert_eq(l10.size.width, 10.0) + assert_eq(l10.size.height, 106.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, 10.0) + assert_eq(l2.size.height, 107.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 213.0) +} + +///| +test "upstream/generated/flex/rounding_total_fractial" { + // Ported from taffy-reference/tests/generated/flex/rounding_total_fractial.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_grow(0.7) + .with_flex_basis(length(50.3)) + .with_size(Size(width=auto(), height=length(20.3))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.6) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.1) + .with_size(Size(width=auto(), height=length(10.7))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(87.4), height=length(113.4))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 87.0) + assert_eq(lnode.size.height, 113.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, 87.0) + assert_eq(l0.size.height, 59.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, 87.0) + assert_eq(l1.size.height, 30.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 59.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 87.0) + assert_eq(l2.size.height, 24.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 89.0) +} + +///| +test "upstream/generated/flex/rounding_total_fractial_nested" { + // Ported from taffy-reference/tests/generated/flex/rounding_total_fractial_nested.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.0) + .with_flex_basis(length(0.3)) + .with_size(Size(width=auto(), height=length(9.9))) + .with_inset( + Rect(left=auto(), right=auto(), top=auto(), bottom=length(13.3)), + ), + ) + let node01 = taffy.new_leaf( + Style::default() + .with_flex_grow(4.0) + .with_flex_basis(length(0.3)) + .with_size(Size(width=auto(), height=length(1.1))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(13.3), bottom=auto()), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_grow(0.7) + .with_flex_basis(length(50.3)) + .with_size(Size(width=auto(), height=length(20.3))), + [node00, node01], + ) + let node1 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.6) + .with_size(Size(width=auto(), height=length(10.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_flex_grow(1.1) + .with_size(Size(width=auto(), height=length(10.7))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(87.4), height=length(113.4))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 87.0) + assert_eq(lnode.size.height, 113.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, 87.0) + assert_eq(l0.size.height, 59.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, 87.0) + assert_eq(l00.size.height, 12.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, -13.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 87.0) + assert_eq(l01.size.height, 47.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 25.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 87.0) + assert_eq(l1.size.height, 30.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 59.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 87.0) + assert_eq(l2.size.height, 24.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 89.0) +} + +///| +test "upstream/generated/flex/scroll_size" { + // Ported from taffy-reference/tests/generated/flex/scroll_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_flex_shrink(0.0) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_align_items(align_items_start()) + .with_justify_content(justify_content_start()) + .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) +} + +///| +test "upstream/generated/flex/simple_child" { + // Ported from taffy-reference/tests/generated/flex/simple_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node00 = taffy.new_with_children( + Style::default().with_size(Size(width=length(10.0), height=length(10.0))), + [node000], + ) + let node010 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_center()) + .with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node011 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_center()) + .with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node01 = taffy.new_with_children(Style::default(), [node010, node011]) + let node0 = taffy.new_with_children( + Style::default().with_size(Size(width=percent(1.0), height=percent(1.0))), + [node00, node01], + ) + 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, 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, 10.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, 10.0) + assert_eq(l000.size.height, 10.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 20.0) + assert_eq(l01.size.height, 100.0) + assert_eq(l01.location.x, 10.0) + assert_eq(l01.location.y, 0.0) + let l010 = taffy.layout(node010) + assert_eq(l010.size.width, 10.0) + assert_eq(l010.size.height, 10.0) + assert_eq(l010.location.x, 0.0) + assert_eq(l010.location.y, 45.0) + let l011 = taffy.layout(node011) + assert_eq(l011.size.width, 10.0) + assert_eq(l011.size.height, 10.0) + assert_eq(l011.location.x, 10.0) + assert_eq(l011.location.y, 45.0) +} + +///| +test "upstream/generated/flex/single_flex_child_after_absolute_child" { + // Ported from taffy-reference/tests/generated/flex/single_flex_child_after_absolute_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=percent(1.0), height=percent(1.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_flex_grow(1.0).with_flex_shrink(1.0), + ) + let node2 = taffy.new_leaf( + Style::default().with_flex_shrink(0.0).with_flex_basis(length(174.0)), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(428.0), height=length(845.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, 428.0) + assert_eq(lnode.size.height, 845.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, 428.0) + assert_eq(l0.size.height, 845.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, 428.0) + assert_eq(l1.size.height, 671.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 428.0) + assert_eq(l2.size.height, 174.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 671.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part29_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part29_test.mbt new file mode 100644 index 0000000..e146264 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part29_test.mbt @@ -0,0 +1,1188 @@ +// 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/size_defined_by_child" { + // Ported from taffy-reference/tests/generated/flex/size_defined_by_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), 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, 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) +} + +///| +test "upstream/generated/flex/size_defined_by_child_with_border" { + // Ported from taffy-reference/tests/generated/flex/size_defined_by_child_with_border.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_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/size_defined_by_child_with_padding" { + // Ported from taffy-reference/tests/generated/flex/size_defined_by_child_with_padding.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_padding( + 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/size_defined_by_grand_child" { + // Ported from taffy-reference/tests/generated/flex/size_defined_by_grand_child.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(), [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, 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/undefined_height_with_min_max" { + // Ported from taffy-reference/tests/generated/flex/undefined_height_with_min_max.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=auto(), height=length(0.0))) + .with_max_size(Size(width=auto(), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(320.0), height=auto())) + .with_min_size(Size(width=auto(), height=length(0.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 320.0) + assert_eq(lnode.size.height, 0.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, 320.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/undefined_width_with_min_max" { + // Ported from taffy-reference/tests/generated/flex/undefined_width_with_min_max.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(0.0), height=auto())) + .with_max_size(Size(width=length(100.0), height=auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=auto(), height=length(50.0))), + [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, 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, 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/undefined_width_with_min_max_row" { + // Ported from taffy-reference/tests/generated/flex/undefined_width_with_min_max_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_min_size(Size(width=length(60.0), height=auto())) + .with_max_size(Size(width=length(300.0), height=auto())), + [node00], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=auto(), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 60.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, 60.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, 30.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/width_smaller_then_content_with_flex_grow_large_size" { + // Ported from taffy-reference/tests/generated/flex/width_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_size(Size(width=length(0.0), height=auto())), + [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_size(Size(width=length(0.0), height=auto())), + [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, 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, 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, 50.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 50.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/width_smaller_then_content_with_flex_grow_small_size" { + // Ported from taffy-reference/tests/generated/flex/width_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_size(Size(width=length(0.0), height=auto())), + [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_size(Size(width=length(0.0), height=auto())), + [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, 5.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, 5.0) + assert_eq(l1.size.height, 100.0) + assert_eq(l1.location.x, 5.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/width_smaller_then_content_with_flex_grow_unconstraint_size" { + // Ported from taffy-reference/tests/generated/flex/width_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_size(Size(width=length(0.0), height=auto())), + [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_size(Size(width=length(0.0), height=auto())), + [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, 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) + 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, 0.0) + assert_eq(l1.size.height, 100.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, 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/width_smaller_then_content_with_flex_grow_very_large_size" { + // Ported from taffy-reference/tests/generated/flex/width_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_size(Size(width=length(0.0), height=auto())), + [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_size(Size(width=length(0.0), height=auto())), + [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/wrap_child" { + // Ported from taffy-reference/tests/generated/flex/wrap_child.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + 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, 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) +} + +///| +test "upstream/generated/flex/wrap_column" { + // Ported from taffy-reference/tests/generated/flex/wrap_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(31.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(32.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(33.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(34.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3], + ) + 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, 30.0) + assert_eq(l0.size.height, 31.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, 30.0) + assert_eq(l1.size.height, 32.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 31.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 33.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 63.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 34.0) + assert_eq(l3.location.x, 50.0) + assert_eq(l3.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_grandchild" { + // Ported from taffy-reference/tests/generated/flex/wrap_grandchild.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(), [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, 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/wrap_nodes_with_content_sizing_margin_cross" { + // Ported from taffy-reference/tests/generated/flex/wrap_nodes_with_content_sizing_margin_cross.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(40.0), height=length(40.0))), + ) + let node00 = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node000], + ) + let node010 = taffy.new_leaf( + Style::default().with_size(Size(width=length(40.0), height=length(40.0))), + ) + let node01 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_margin( + Rect( + left=length(0.0), + right=length(0.0), + top=length(10.0), + bottom=length(0.0), + ), + ), + [node010], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(70.0), height=auto())), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(500.0), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.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, 90.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, 40.0) + assert_eq(l00.size.height, 40.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, 40.0) + assert_eq(l000.size.height, 40.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 40.0) + assert_eq(l01.size.height, 40.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 50.0) + let l010 = taffy.layout(node010) + assert_eq(l010.size.width, 40.0) + assert_eq(l010.size.height, 40.0) + assert_eq(l010.location.x, 0.0) + assert_eq(l010.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_nodes_with_content_sizing_overflowing_margin" { + // Ported from taffy-reference/tests/generated/flex/wrap_nodes_with_content_sizing_overflowing_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(40.0), height=length(40.0))), + ) + let node00 = taffy.new_with_children( + Style::default().with_flex_direction(flex_direction_column()), + [node000], + ) + let node010 = taffy.new_leaf( + Style::default().with_size(Size(width=length(40.0), height=length(40.0))), + ) + let node01 = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_margin( + Rect( + left=length(0.0), + right=length(10.0), + top=length(0.0), + bottom=length(0.0), + ), + ), + [node010], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(85.0), height=auto())), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_size(Size(width=length(500.0), height=length(500.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 500.0) + assert_eq(lnode.size.height, 500.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, 85.0) + assert_eq(l0.size.height, 80.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, 40.0) + assert_eq(l00.size.height, 40.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, 40.0) + assert_eq(l000.size.height, 40.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 40.0) + assert_eq(l01.size.height, 40.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 40.0) + let l010 = taffy.layout(node010) + assert_eq(l010.size.width, 40.0) + assert_eq(l010.size.height, 40.0) + assert_eq(l010.location.x, 0.0) + assert_eq(l010.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_column" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(31.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(32.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(33.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(34.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0, node1, node2, node3], + ) + 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, 30.0) + assert_eq(l0.size.height, 31.0) + assert_eq(l0.location.x, 70.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 32.0) + assert_eq(l1.location.x, 70.0) + assert_eq(l1.location.y, 31.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 33.0) + assert_eq(l2.location.x, 70.0) + assert_eq(l2.location.y, 63.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 34.0) + assert_eq(l3.location.x, 20.0) + assert_eq(l3.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_column_fixed_size" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_column_fixed_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(40.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(200.0), height=length(100.0))), + [node0, node1, node2, node3, node4], + ) + 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, 30.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 135.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 135.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 135.0) + assert_eq(l2.location.y, 30.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 135.0) + assert_eq(l3.location.y, 60.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 30.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 35.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_row" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(31.0), height=length(30.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(32.0), height=length(30.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(33.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(34.0), height=length(30.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3], + ) + 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, 60.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, 31.0) + assert_eq(l0.size.height, 30.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 30.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 32.0) + assert_eq(l1.size.height, 30.0) + assert_eq(l1.location.x, 31.0) + assert_eq(l1.location.y, 30.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 33.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 63.0) + assert_eq(l2.location.y, 30.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 34.0) + assert_eq(l3.size.height, 30.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_row_align_content_center" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_row_align_content_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(40.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_align_content(align_content_center()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3, node4], + ) + 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, 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, 30.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 70.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 60.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 50.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 30.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_row_align_content_flex_start" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_row_align_content_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(40.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3, node4], + ) + 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, 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, 30.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 70.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 60.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 50.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 30.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_row_align_content_space_around" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_row_align_content_space_around.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(40.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_align_content(align_content_space_around()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3, node4], + ) + 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, 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, 30.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 70.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 60.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 50.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 30.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_row_align_content_stretch" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_row_align_content_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(40.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_align_content(align_content_stretch()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3, node4], + ) + 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, 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, 30.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 70.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 60.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 50.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 30.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 30.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_reverse_row_single_line_different_size" { + // Ported from taffy-reference/tests/generated/flex/wrap_reverse_row_single_line_different_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(40.0))), + ) + let node4 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(50.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap_reverse()) + .with_align_content(align_content_flex_start()) + .with_size(Size(width=length(300.0), height=auto())), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let lnode = taffy.layout(node) + assert_eq(lnode.size.width, 300.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, 30.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 40.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 30.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 20.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 90.0) + assert_eq(l3.location.y, 10.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 30.0) + assert_eq(l4.size.height, 50.0) + assert_eq(l4.location.x, 120.0) + assert_eq(l4.location.y, 0.0) +} + +///| +test "upstream/generated/flex/wrap_row" { + // Ported from taffy-reference/tests/generated/flex/wrap_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(31.0), height=length(30.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(32.0), height=length(30.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(33.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(34.0), height=length(30.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3], + ) + 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, 60.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, 31.0) + assert_eq(l0.size.height, 30.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, 32.0) + assert_eq(l1.size.height, 30.0) + assert_eq(l1.location.x, 31.0) + assert_eq(l1.location.y, 0.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 33.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 63.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 34.0) + assert_eq(l3.size.height, 30.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 30.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part30_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part30_test.mbt new file mode 100644 index 0000000..12d706d --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part30_test.mbt @@ -0,0 +1,1483 @@ +// 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/wrap_row_align_items_center" { + // Ported from taffy-reference/tests/generated/flex/wrap_row_align_items_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3], + ) + 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, 60.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, 30.0) + assert_eq(l0.size.height, 10.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 10.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 5.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 30.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 30.0) +} + +///| +test "upstream/generated/flex/wrap_row_align_items_flex_end" { + // Ported from taffy-reference/tests/generated/flex/wrap_row_align_items_flex_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(10.0))), + ) + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(20.0))), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node3 = taffy.new_leaf( + Style::default().with_size(Size(width=length(30.0), height=length(30.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_flex_end()) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3], + ) + 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, 60.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, 30.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, 30.0) + assert_eq(l1.size.height, 20.0) + assert_eq(l1.location.x, 30.0) + assert_eq(l1.location.y, 10.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 30.0) + assert_eq(l2.size.height, 30.0) + assert_eq(l2.location.x, 60.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 30.0) + assert_eq(l3.size.height, 30.0) + assert_eq(l3.location.x, 0.0) + assert_eq(l3.location.y, 30.0) +} + +///| +test "upstream/generated/flex/wrapped_column_max_height" { + // Ported from taffy-reference/tests/generated/flex/wrapped_column_max_height.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(100.0), height=length(500.0))) + .with_max_size(Size(width=auto(), height=length(200.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_margin( + Rect( + left=length(20.0), + right=length(20.0), + top=length(20.0), + bottom=length(20.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(700.0), height=length(500.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, 700.0) + assert_eq(lnode.size.height, 500.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, 200.0) + assert_eq(l0.location.x, 250.0) + assert_eq(l0.location.y, 30.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 200.0) + assert_eq(l1.size.height, 200.0) + assert_eq(l1.location.x, 200.0) + assert_eq(l1.location.y, 250.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 420.0) + assert_eq(l2.location.y, 200.0) +} + +///| +test "upstream/generated/flex/wrapped_column_max_height_flex" { + // Ported from taffy-reference/tests/generated/flex/wrapped_column_max_height_flex.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)) + .with_size(Size(width=length(100.0), height=length(500.0))) + .with_max_size(Size(width=auto(), height=length(200.0))), + ) + let node1 = 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(200.0), height=length(200.0))) + .with_margin( + Rect( + left=length(20.0), + right=length(20.0), + top=length(20.0), + bottom=length(20.0), + ), + ), + ) + let node2 = taffy.new_leaf( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_flex_wrap(flex_wrap_wrap()) + .with_align_items(align_items_center()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content_center()) + .with_size(Size(width=length(700.0), height=length(500.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, 700.0) + assert_eq(lnode.size.height, 500.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, 180.0) + assert_eq(l0.location.x, 300.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 200.0) + assert_eq(l1.size.height, 180.0) + assert_eq(l1.location.x, 250.0) + assert_eq(l1.location.y, 200.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 100.0) + assert_eq(l2.size.height, 100.0) + assert_eq(l2.location.x, 300.0) + assert_eq(l2.location.y, 400.0) +} + +///| +test "upstream/generated/flex/wrapped_row_within_align_items_center" { + // Ported from taffy-reference/tests/generated/flex/wrapped_row_within_align_items_center.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(150.0), height=length(80.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(80.0), height=length(80.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_flex_wrap(flex_wrap_wrap()), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_center()) + .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, 200.0) + assert_eq(l0.size.height, 160.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, 150.0) + assert_eq(l00.size.height, 80.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 80.0) + assert_eq(l01.size.height, 80.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 80.0) +} + +///| +test "upstream/generated/flex/wrapped_row_within_align_items_flex_end" { + // Ported from taffy-reference/tests/generated/flex/wrapped_row_within_align_items_flex_end.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(150.0), height=length(80.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(80.0), height=length(80.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_flex_wrap(flex_wrap_wrap()), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_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, 200.0) + assert_eq(l0.size.height, 160.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, 150.0) + assert_eq(l00.size.height, 80.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 80.0) + assert_eq(l01.size.height, 80.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 80.0) +} + +///| +test "upstream/generated/flex/wrapped_row_within_align_items_flex_start" { + // Ported from taffy-reference/tests/generated/flex/wrapped_row_within_align_items_flex_start.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(150.0), height=length(80.0))), + ) + let node01 = taffy.new_leaf( + Style::default().with_size(Size(width=length(80.0), height=length(80.0))), + ) + let node0 = taffy.new_with_children( + Style::default().with_flex_wrap(flex_wrap_wrap()), + [node00, node01], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_direction(flex_direction_column()) + .with_align_items(align_items_flex_start()) + .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, 200.0) + assert_eq(l0.size.height, 160.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, 150.0) + assert_eq(l00.size.height, 80.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 80.0) + assert_eq(l01.size.height, 80.0) + assert_eq(l01.location.x, 0.0) + assert_eq(l01.location.y, 80.0) +} + +///| +test "upstream/generated/grid/chrome_issue_325928327" { + // Ported from taffy-reference/tests/generated/grid/chrome_issue_325928327.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=auto(), height=percent(1.0))) + .with_aspect_ratio(1.0), + ) + let node0 = taffy.new_with_children( + Style::default().with_size(Size(width=auto(), height=percent(1.0))), + [node00], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_items(align_items_center()) + .with_size(Size(width=percent(1.0), height=length(40.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_absolute_align_self_sized_all" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_align_self_sized_all.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_start()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_start()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_end()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_end()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node4 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_center()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_center()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node6 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_stretch()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node7 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_stretch()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1, node2, node3, node4, node5, node6, node7], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7] + let expected_w = [20.0, 60.0, 20.0, 60.0, 20.0, 60.0, 20.0, 60.0] + let expected_h = [20.0, 60.0, 20.0, 60.0, 20.0, 60.0, 20.0, 60.0] + let expected_x = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] + let expected_y = [0.0, 0.0, 100.0, 60.0, 50.0, 30.0, 0.0, 0.0] + for i in 0..<8 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_column_end" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_column_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_grid_column(Line(start=place_auto(), end=line(1))) + .with_inset( + Rect( + left=length(4.0), + right=length(3.0), + top=length(1.0), + bottom=length(2.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let n = taffy.layout(node0) + assert_eq(n.size.width, 33.0) + assert_eq(n.size.height, 157.0) + assert_eq(n.location.x, 4.0) + assert_eq(n.location.y, 1.0) +} + +///| +test "upstream/generated/grid/grid_absolute_column_start" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_column_start.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_grid_column(Line(start=line(1), end=place_auto())) + .with_inset( + Rect( + left=length(4.0), + right=length(3.0), + top=length(1.0), + bottom=length(2.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let n = taffy.layout(node0) + assert_eq(n.size.width, 133.0) + assert_eq(n.size.height, 157.0) + assert_eq(n.location.x, 44.0) + assert_eq(n.location.y, 1.0) +} + +///| +test "upstream/generated/grid/grid_absolute_container_bottom_left" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_bottom_left.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=length(0.0), right=auto(), top=auto(), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [160.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_bottom_left_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_bottom_left_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=length(10.0))) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=length(0.0), right=auto(), top=auto(), bottom=length(0.0)), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [10.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [10.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [4.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [147.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_left_overrides_right" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_left_overrides_right.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(10.0), height=auto())) + .with_inset( + Rect(left=length(5.0), right=length(2.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [10.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [5.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [0.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_left_right" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_left_right.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=length(5.0), right=length(2.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [173.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [5.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [0.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_left_right_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_left_right_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=length(5.0), right=length(2.0), top=auto(), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [167.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [9.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [1.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_negative_position" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_negative_position.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=auto(), right=length(-15.0), top=length(-5.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=length(-35.0), right=auto(), top=auto(), bottom=length(-25.0)), + ), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [195.0, -35.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0] + let expected_y = [-5.0, 185.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_negative_position_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_negative_position_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=auto(), right=length(-15.0), top=length(-5.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=length(-35.0), right=auto(), top=auto(), bottom=length(-25.0)), + ), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [193.0, -31.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0] + let expected_y = [-4.0, 182.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_top_bottom" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_top_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=auto(), right=auto(), top=length(2.0), bottom=length(5.0)), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [153.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [2.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_top_bottom_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_top_bottom_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=auto(), right=auto(), top=length(2.0), bottom=length(5.0)), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [149.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [4.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [3.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_top_right" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_top_right.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [180.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [0.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_container_top_right_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_container_top_right_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [178.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [1.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_justify_self_sized_all" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_justify_self_sized_all.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_end()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_end()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node4 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_center()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_center()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node6 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_stretch()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node7 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_justify_self(align_items_stretch()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1, node2, node3, node4, node5, node6, node7], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7] + let expected_w = [20.0, 60.0, 20.0, 60.0, 20.0, 60.0, 20.0, 60.0] + let expected_h = [20.0, 60.0, 20.0, 60.0, 20.0, 60.0, 20.0, 60.0] + let expected_x = [0.0, 0.0, 100.0, 60.0, 50.0, 30.0, 0.0, 0.0] + let expected_y = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] + for i in 0..<8 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_layout_within_border" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_layout_within_border.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_inset( + Rect(left=auto(), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_inset( + Rect(left=length(0.0), right=auto(), top=length(0.0), bottom=auto()), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_inset( + Rect(left=auto(), right=length(0.0), top=auto(), bottom=length(0.0)), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0, node1, node2, node3], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3] + let expected_w = [50.0, 50.0, 50.0, 50.0] + let expected_h = [50.0, 50.0, 50.0, 50.0] + let expected_x = [10.0, 40.0, 20.0, 30.0] + let expected_y = [10.0, 40.0, 20.0, 30.0] + for i in 0..<4 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_layout_within_border_static" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_layout_within_border_static.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_end()) + .with_justify_self(align_items_end()) + .with_size(Size(width=length(50.0), height=length(50.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_align_self(align_items_end()) + .with_justify_self(align_items_end()) + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_margin( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(100.0), height=length(100.0))) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ) + .with_border( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [node0, node1, node2, node3], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 100.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3] + let expected_w = [50.0, 50.0, 50.0, 50.0] + let expected_h = [50.0, 50.0, 50.0, 50.0] + let expected_x = [10.0, 40.0, 20.0, 30.0] + let expected_y = [10.0, 40.0, 20.0, 30.0] + for i in 0..<4 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part31_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part31_test.mbt new file mode 100644 index 0000000..71b6b1f --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part31_test.mbt @@ -0,0 +1,486 @@ +// 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/grid/grid_absolute_row_end" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_row_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_grid_row(Line(start=place_auto(), end=line(1))) + .with_inset( + Rect( + left=length(4.0), + right=length(3.0), + top=length(1.0), + bottom=length(2.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let n = taffy.layout(node0) + assert_eq(n.size.width, 173.0) + assert_eq(n.size.height, 7.0) + assert_eq(n.location.x, 4.0) + assert_eq(n.location.y, 1.0) +} + +///| +test "upstream/generated/grid/grid_absolute_row_start" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_row_start.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_inset( + Rect( + left=length(4.0), + right=length(3.0), + top=length(1.0), + bottom=length(2.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let n = taffy.layout(node0) + assert_eq(n.size.width, 173.0) + assert_eq(n.size.height, 147.0) + assert_eq(n.location.x, 4.0) + assert_eq(n.location.y, 11.0) +} + +///| +test "upstream/generated/grid/grid_absolute_top_overrides_bottom" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_top_overrides_bottom.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_size(Size(width=auto(), height=length(10.0))) + .with_inset( + Rect(left=auto(), right=auto(), top=length(2.0), bottom=length(5.0)), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [10.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0] + let expected_y = [2.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_with_padding" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_with_padding.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_inset( + Rect(left=length(10.0), right=auto(), top=auto(), bottom=length(10.0)), + ), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [180.0, 10.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0] + let expected_y = [0.0, 150.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_absolute_with_padding_and_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_absolute_with_padding_and_margin.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=auto(), right=length(0.0), top=length(0.0), bottom=auto()), + ), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_position(position_absolute()) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ) + .with_inset( + Rect(left=length(10.0), right=auto(), top=auto(), bottom=length(10.0)), + ), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [0.0, 0.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [178.0, 14.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0] + let expected_y = [1.0, 147.0, 10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_align_content_center" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_center.rs + run_grid_align_content_test(align_content_center(), [40.0, 80.0, 120.0]) +} + +///| +test "upstream/generated/grid/grid_align_content_center_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_center_negative_space_gap.rs + run_grid_align_content_negative_space_gap_test(align_content_center(), [ + -10.0, 40.0, 90.0, + ]) +} + +///| +test "upstream/generated/grid/grid_align_content_end" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_end.rs + run_grid_align_content_test(align_content_end(), [80.0, 120.0, 160.0]) +} + +///| +test "upstream/generated/grid/grid_align_content_end_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_end_negative_space_gap.rs + run_grid_align_content_negative_space_gap_test(align_content_end(), [ + -20.0, 30.0, 80.0, + ]) +} + +///| +test "upstream/generated/grid/grid_align_content_end_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_end_with_padding_border.rs + run_grid_align_content_with_padding_border_test(align_content_end(), [ + 44.0, 84.0, 124.0, + ]) +} + +///| +test "upstream/generated/grid/grid_align_content_space_around" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_around.rs + run_grid_align_content_test(align_content_space_around(), [13.0, 80.0, 147.0]) +} + +///| +test "upstream/generated/grid/grid_align_content_space_around_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_around_negative_space_gap.rs + run_grid_align_content_negative_space_gap_test(align_content_space_around(), [ + 0.0, 50.0, 100.0, + ]) +} + +///| +test "upstream/generated/grid/grid_align_content_space_around_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_around_with_padding_border.rs + run_grid_align_content_with_padding_border_test( + align_content_space_around(), + [17.0, 68.0, 119.0], + ) +} + +///| +test "upstream/generated/grid/grid_align_content_space_between" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_between.rs + run_grid_align_content_test(align_content_space_between(), [0.0, 80.0, 160.0]) +} + +///| +test "upstream/generated/grid/grid_align_content_space_between_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_between_negative_space_gap.rs + run_grid_align_content_negative_space_gap_test( + align_content_space_between(), + [0.0, 50.0, 100.0], + ) +} + +///| +test "upstream/generated/grid/grid_align_content_space_between_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_between_with_padding_border.rs + run_grid_align_content_with_padding_border_test( + align_content_space_between(), + [12.0, 68.0, 124.0], + ) +} + +///| +test "upstream/generated/grid/grid_align_content_space_evenly" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_evenly.rs + run_grid_align_content_test(align_content_space_evenly(), [20.0, 80.0, 140.0]) +} + +///| +test "upstream/generated/grid/grid_align_content_space_evenly_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_evenly_negative_space_gap.rs + run_grid_align_content_negative_space_gap_test(align_content_space_evenly(), [ + 0.0, 50.0, 100.0, + ]) +} + +///| +test "upstream/generated/grid/grid_align_content_space_evenly_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_space_evenly_with_padding_border.rs + run_grid_align_content_with_padding_border_test( + align_content_space_evenly(), + [20.0, 68.0, 116.0], + ) +} + +///| +test "upstream/generated/grid/grid_align_content_start" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_start.rs + run_grid_align_content_test(align_content_start(), [0.0, 40.0, 80.0]) +} + +///| +test "upstream/generated/grid/grid_align_content_start_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_start_negative_space_gap.rs + run_grid_align_content_negative_space_gap_test(align_content_start(), [ + 0.0, 50.0, 100.0, + ]) +} + +///| +test "upstream/generated/grid/grid_align_content_start_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_align_content_start_with_padding_border.rs + run_grid_align_content_with_padding_border_test(align_content_start(), [ + 12.0, 52.0, 92.0, + ]) +} + +///| +fn[C] assert_layout_xywh( + taffy : ChicleTree[C], + node : NodeId, + width : Double, + height : Double, + x : Double, + y : Double, +) -> Unit raise Error { + let layout = taffy.layout(node) + assert_eq(layout.size.width, width) + assert_eq(layout.size.height, height) + assert_eq(layout.location.x, x) + assert_eq(layout.location.y, y) +} + +///| +fn[C] assert_nodes_layout_xywh( + taffy : ChicleTree[C], + nodes : Array[NodeId], + expected_w : Array[Double], + expected_h : Array[Double], + expected_x : Array[Double], + expected_y : Array[Double], +) -> Unit raise Error { + for i in 0.. Array[NodeId] { + [ + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + taffy.new_leaf(Style::default()), + ] +} + +///| +fn assert_grid_positions( + taffy : ChicleTree[Unit], + nodes : Array[NodeId], + expected_x : Array[Double], + expected_y : Array[Double], + item_width : Double, + item_height : Double, +) -> Unit raise Error { + for row in 0..<3 { + for col in 0..<3 { + let idx = row * 3 + col + let layout = taffy.layout(nodes[idx]) + assert_eq(layout.size.width, item_width) + assert_eq(layout.size.height, item_height) + assert_eq(layout.location.x, expected_x[col]) + assert_eq(layout.location.y, expected_y[row]) + } + } +} + +///| +fn run_grid_align_content_test( + align_content : AlignContent, + expected_y : Array[Double], +) -> Unit raise Error { + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes = make_nine_default_grid_children(taffy) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_align_content(align_content) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(200.0), height=length(200.0))), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + assert_grid_positions(taffy, nodes, [0.0, 40.0, 80.0], expected_y, 40.0, 40.0) +} + +///| +fn run_grid_align_content_with_padding_border_test( + align_content : AlignContent, + expected_y : Array[Double], +) -> Unit raise Error { + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes = make_nine_default_grid_children(taffy) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_align_content(align_content) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ) + .with_border( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + assert_grid_positions( + taffy, + nodes, + [48.0, 88.0, 128.0], + expected_y, + 40.0, + 40.0, + ) +} + +///| +fn run_grid_align_content_negative_space_gap_test( + align_content : AlignContent, + expected_y : Array[Double], +) -> Unit raise Error { + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes = make_nine_default_grid_children(taffy) + let inner = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_align_content(align_content) + .with_justify_content(justify_content_center()) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(20.0), length(20.0), length(20.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + nodes, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(240.0), height=length(240.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [inner], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 240.0) + assert_eq(root_layout.size.height, 240.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let inner_layout = taffy.layout(inner) + assert_eq(inner_layout.size.width, 120.0) + assert_eq(inner_layout.size.height, 120.0) + assert_eq(inner_layout.location.x, 60.0) + assert_eq(inner_layout.location.y, 60.0) + assert_grid_positions( + taffy, + nodes, + [20.0, 50.0, 80.0], + expected_y, + 20.0, + 40.0, + ) +} + +///| +fn run_grid_justify_content_test( + justify_content : JustifyContent, + expected_x : Array[Double], +) -> Unit raise Error { + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes = make_nine_default_grid_children(taffy) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_content(justify_content) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(200.0), height=length(200.0))), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + assert_grid_positions(taffy, nodes, expected_x, [0.0, 40.0, 80.0], 40.0, 40.0) +} + +///| +fn run_grid_justify_content_with_padding_border_test( + justify_content : JustifyContent, + expected_x : Array[Double], +) -> Unit raise Error { + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes = make_nine_default_grid_children(taffy) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_content(justify_content) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(200.0), height=length(200.0))) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ) + .with_border( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 200.0) + assert_eq(root_layout.size.height, 200.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + assert_grid_positions( + taffy, + nodes, + expected_x, + [12.0, 52.0, 92.0], + 40.0, + 40.0, + ) +} + +///| +fn run_grid_justify_content_negative_space_gap_test( + justify_content : JustifyContent, + expected_x : Array[Double], +) -> Unit raise Error { + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes = make_nine_default_grid_children(taffy) + let inner = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_align_content(align_content_center()) + .with_justify_content(justify_content) + .with_gap(Size(width=length(10.0), height=length(10.0))) + .with_grid_template_rows([length(20.0), length(20.0), length(20.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + nodes, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(240.0), height=length(240.0))) + .with_border( + Rect( + left=length(60.0), + right=length(60.0), + top=length(60.0), + bottom=length(60.0), + ), + ), + [inner], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 240.0) + assert_eq(root_layout.size.height, 240.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let inner_layout = taffy.layout(inner) + assert_eq(inner_layout.size.width, 120.0) + assert_eq(inner_layout.size.height, 120.0) + assert_eq(inner_layout.location.x, 60.0) + assert_eq(inner_layout.location.y, 60.0) + assert_grid_positions( + taffy, + nodes, + expected_x, + [20.0, 50.0, 80.0], + 40.0, + 20.0, + ) +} + +///| +test "upstream/generated/grid/grid_justify_content_center" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_center.rs + run_grid_justify_content_test(justify_content_center(), [40.0, 80.0, 120.0]) +} + +///| +test "upstream/generated/grid/grid_justify_content_center_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_center_negative_space_gap.rs + run_grid_justify_content_negative_space_gap_test(justify_content_center(), [ + -10.0, 40.0, 90.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_center_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_center_with_padding_border.rs + run_grid_justify_content_with_padding_border_test(justify_content_center(), [ + 52.0, 92.0, 132.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_end" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_end.rs + run_grid_justify_content_test(justify_content_end(), [80.0, 120.0, 160.0]) +} + +///| +test "upstream/generated/grid/grid_justify_content_end_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_end_negative_space_gap.rs + run_grid_justify_content_negative_space_gap_test(justify_content_end(), [ + -20.0, 30.0, 80.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_end_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_end_with_padding_border.rs + run_grid_justify_content_with_padding_border_test(justify_content_end(), [ + 56.0, 96.0, 136.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_around" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_around.rs + run_grid_justify_content_test(justify_content_space_around(), [ + 13.0, 80.0, 147.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_around_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_around_negative_space_gap.rs + run_grid_justify_content_negative_space_gap_test( + justify_content_space_around(), + [0.0, 50.0, 100.0], + ) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_around_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_around_with_padding_border.rs + run_grid_justify_content_with_padding_border_test( + justify_content_space_around(), + [49.0, 92.0, 135.0], + ) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_between" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_between.rs + run_grid_justify_content_test(justify_content_space_between(), [ + 0.0, 80.0, 160.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_between_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_between_negative_space_gap.rs + run_grid_justify_content_negative_space_gap_test( + justify_content_space_between(), + [0.0, 50.0, 100.0], + ) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_between_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_between_with_padding_border.rs + run_grid_justify_content_with_padding_border_test( + justify_content_space_between(), + [48.0, 92.0, 136.0], + ) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_evenly" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_evenly.rs + run_grid_justify_content_test(justify_content_space_evenly(), [ + 20.0, 80.0, 140.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_evenly_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_evenly_negative_space_gap.rs + run_grid_justify_content_negative_space_gap_test( + justify_content_space_evenly(), + [0.0, 50.0, 100.0], + ) +} + +///| +test "upstream/generated/grid/grid_justify_content_space_evenly_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_space_evenly_with_padding_border.rs + run_grid_justify_content_with_padding_border_test( + justify_content_space_evenly(), + [50.0, 92.0, 134.0], + ) +} + +///| +test "upstream/generated/grid/grid_justify_content_start" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_start.rs + run_grid_justify_content_test(justify_content_start(), [0.0, 40.0, 80.0]) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part36_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part36_test.mbt new file mode 100644 index 0000000..e020f1c --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part36_test.mbt @@ -0,0 +1,1228 @@ +// 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/grid/grid_justify_content_start_negative_space_gap" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_start_negative_space_gap.rs + run_grid_justify_content_negative_space_gap_test(justify_content_start(), [ + 0.0, 50.0, 100.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_content_start_with_padding_border" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_content_start_with_padding_border.rs + run_grid_justify_content_with_padding_border_test(justify_content_start(), [ + 48.0, 88.0, 128.0, + ]) +} + +///| +test "upstream/generated/grid/grid_justify_items_sized_center" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_items_sized_center.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row_start(1) + .with_grid_column_start(1) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row_start(3) + .with_grid_column_start(3) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_items(align_items_center()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 10.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 60.0) + assert_eq(l1.size.height, 60.0) + assert_eq(l1.location.x, 70.0) + assert_eq(l1.location.y, 80.0) +} + +///| +test "upstream/generated/grid/grid_justify_items_sized_end" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_items_sized_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row_start(1) + .with_grid_column_start(1) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row_start(3) + .with_grid_column_start(3) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_items(align_items_end()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.0) + assert_eq(l0.location.x, 20.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 60.0) + assert_eq(l1.size.height, 60.0) + assert_eq(l1.location.x, 60.0) + assert_eq(l1.location.y, 80.0) +} + +///| +test "upstream/generated/grid/grid_justify_items_sized_start" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_items_sized_start.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row_start(1) + .with_grid_column_start(1) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row_start(3) + .with_grid_column_start(3) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_items(align_items_start()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.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, 60.0) + assert_eq(l1.size.height, 60.0) + assert_eq(l1.location.x, 80.0) + assert_eq(l1.location.y, 80.0) +} + +///| +test "upstream/generated/grid/grid_justify_items_sized_stretch" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_items_sized_stretch.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row_start(1) + .with_grid_column_start(1) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row_start(3) + .with_grid_column_start(3) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_items(align_items_stretch()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.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, 60.0) + assert_eq(l1.size.height, 60.0) + assert_eq(l1.location.x, 80.0) + assert_eq(l1.location.y, 80.0) +} + +///| +test "upstream/generated/grid/grid_justify_self_sized_all" { + // Ported from taffy-reference/tests/generated/grid/grid_justify_self_sized_all.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_start()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_start()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_end()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node3 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_end()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node4 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_center()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node5 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_center()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let node6 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_stretch()) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node7 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_stretch()) + .with_size(Size(width=length(60.0), height=length(60.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1, node2, node3, node4, node5, node6, node7], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.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, 60.0) + assert_eq(l1.size.height, 60.0) + assert_eq(l1.location.x, 40.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, 20.0) + assert_eq(l2.location.x, 100.0) + assert_eq(l2.location.y, 0.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 60.0) + assert_eq(l3.size.height, 60.0) + assert_eq(l3.location.x, -20.0) + assert_eq(l3.location.y, 40.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 20.0) + assert_eq(l4.size.height, 20.0) + assert_eq(l4.location.x, 50.0) + assert_eq(l4.location.y, 40.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 60.0) + assert_eq(l5.size.height, 60.0) + assert_eq(l5.location.x, 70.0) + assert_eq(l5.location.y, 40.0) + let l6 = taffy.layout(node6) + assert_eq(l6.size.width, 20.0) + assert_eq(l6.size.height, 20.0) + assert_eq(l6.location.x, 0.0) + assert_eq(l6.location.y, 80.0) + let l7 = taffy.layout(node7) + assert_eq(l7.size.width, 60.0) + assert_eq(l7.size.height, 60.0) + assert_eq(l7.location.x, 40.0) + assert_eq(l7.location.y, 80.0) +} + +///| +test "upstream/generated/grid/grid_margins_auto_margins" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_auto_margins.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf( + Style::default() + .with_justify_self(align_items_start()) + .with_size(Size(width=length(20.0), height=auto())) + .with_margin( + Rect(left=auto(), right=auto(), top=length(0.0), bottom=length(0.0)), + ), + ) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_start()) + .with_size(Size(width=auto(), height=length(20.0))) + .with_margin( + Rect(left=length(0.0), right=length(0.0), top=auto(), bottom=auto()), + ), + ) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin(Rect(left=auto(), right=auto(), top=auto(), bottom=auto())), + ) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 40.0, 20.0, 40.0, 40.0, 40.0, 20.0, 40.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 20.0, 40.0, 20.0, 40.0, 40.0] + let expected_x = [40.0, 80.0, 130.0, 40.0, 80.0, 120.0, 50.0, 80.0, 120.0] + let expected_y = [10.0, 10.0, 10.0, 50.0, 60.0, 50.0, 100.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_auto_margins_override_stretch" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_auto_margins_override_stretch.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf_with_context( + Style::default() + .with_align_self(align_items_stretch()) + .with_justify_self(align_items_stretch()) + .with_margin(Rect(left=auto(), right=auto(), top=auto(), bottom=auto())), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 10.0, 40.0, 40.0] + let expected_x = [40.0, 80.0, 120.0, 40.0, 80.0, 120.0, 40.0, 80.0, 120.0] + let expected_y = [10.0, 10.0, 10.0, 50.0, 50.0, 50.0, 105.0, 90.0, 90.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_fixed_center" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_fixed_center.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_center()) + .with_justify_self(align_items_center()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [52.0, 80.0, 120.0, 40.0, 80.0, 120.0] + let expected_y = [18.0, 10.0, 10.0, 50.0, 50.0, 50.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_fixed_end" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_fixed_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_end()) + .with_justify_self(align_items_end()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [58.0, 80.0, 120.0, 40.0, 80.0, 120.0] + let expected_y = [27.0, 10.0, 10.0, 50.0, 50.0, 50.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_fixed_start" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_fixed_start.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [44.0, 80.0, 120.0, 40.0, 80.0, 120.0] + let expected_y = [11.0, 10.0, 10.0, 50.0, 50.0, 50.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_fixed_stretch" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_fixed_stretch.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_stretch()) + .with_justify_self(align_items_stretch()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=length(4.0), + right=length(2.0), + top=length(1.0), + bottom=length(3.0), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_padding( + Rect( + left=length(40.0), + right=length(20.0), + top=length(10.0), + bottom=length(30.0), + ), + ), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 180.0) + assert_eq(root_layout.size.height, 160.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [44.0, 80.0, 120.0, 40.0, 80.0, 120.0] + let expected_y = [11.0, 10.0, 10.0, 50.0, 50.0, 50.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_percent_center" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_percent_center.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_center()) + .with_justify_self(align_items_center()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=percent(0.05), + bottom=percent(0.15), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(20.0), length(20.0), length(20.0)]), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 60.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 20.0, 20.0, 20.0, 20.0, 20.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [1.0, 20.0, 40.0, 0.0, 20.0, 40.0] + let expected_y = [9.0, 0.0, 0.0, 40.0, 40.0, 40.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_percent_end" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_percent_end.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_end()) + .with_justify_self(align_items_end()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=percent(0.05), + bottom=percent(0.15), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(20.0), length(20.0), length(20.0)]), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 60.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 20.0, 20.0, 20.0, 20.0, 20.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [-2.0, 20.0, 40.0, 0.0, 20.0, 40.0] + let expected_y = [17.0, 0.0, 0.0, 40.0, 40.0, 40.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_percent_start" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_percent_start.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=percent(0.05), + bottom=percent(0.15), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(20.0), length(20.0), length(20.0)]), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 60.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 20.0, 20.0, 20.0, 20.0, 20.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [4.0, 20.0, 40.0, 0.0, 20.0, 40.0] + let expected_y = [1.0, 0.0, 0.0, 40.0, 40.0, 40.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_margins_percent_stretch" { + // Ported from taffy-reference/tests/generated/grid/grid_margins_percent_stretch.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_align_self(align_items_stretch()) + .with_justify_self(align_items_stretch()) + .with_size(Size(width=length(20.0), height=length(20.0))) + .with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=percent(0.05), + bottom=percent(0.15), + ), + ), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(20.0), length(20.0), length(20.0)]), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 60.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5] + let expected_w = [20.0, 20.0, 20.0, 20.0, 20.0, 20.0] + let expected_h = [20.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [4.0, 20.0, 40.0, 0.0, 20.0, 40.0] + let expected_y = [1.0, 0.0, 0.0, 40.0, 40.0, 40.0] + for i in 0..<6 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_maximum_single_item" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_maximum_single_item.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + minmax(length(0.0), grid_max_content()), + length(40.0), + ]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 40.0, 80.0, 0.0, 40.0, 80.0, 0.0, 40.0, 80.0] + let expected_y = [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_single_item" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_max_content(), length(40.0)]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 40.0, 80.0, 0.0, 40.0, 80.0, 0.0, 40.0, 80.0] + let expected_y = [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_single_item_margin_auto" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item_margin_auto.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context( + Style::default().with_margin( + Rect(left=auto(), right=auto(), top=auto(), bottom=auto()), + ), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_max_content(), length(40.0)]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [40.0, 10.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 40.0, 80.0, 0.0, 40.0, 80.0, 0.0, 40.0, 80.0] + let expected_y = [0.0, 15.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_single_item_margin_fixed" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item_margin_fixed.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context( + Style::default().with_margin( + Rect( + left=length(20.0), + right=length(10.0), + top=length(5.0), + bottom=length(15.0), + ), + ), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_max_content(), length(40.0)]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 150.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 40.0, 40.0, 40.0, 70.0, 40.0, 40.0, 70.0, 40.0] + let expected_h = [40.0, 20.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 60.0, 110.0, 0.0, 40.0, 110.0, 0.0, 40.0, 110.0] + let expected_y = [0.0, 5.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_single_item_margin_percent" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item_margin_percent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context( + Style::default().with_margin( + Rect( + left=percent(0.2), + right=percent(0.1), + top=percent(0.05), + bottom=percent(0.15), + ), + ), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_max_content(), length(40.0)]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 28.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_h = [40.0, 32.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0] + let expected_x = [0.0, 48.0, 80.0, 0.0, 40.0, 80.0, 0.0, 40.0, 80.0] + let expected_y = [0.0, 2.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_single_item_span_2" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item_span_2.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=span(2), end=place_auto())), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + grid_max_content(), + grid_max_content(), + ]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 80.0) + assert_eq(root_layout.size.height, 120.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 40.0, 40.0, 20.0, 20.0, 40.0, 20.0, 20.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 0.0] + let expected_x = [0.0, 40.0, 0.0, 40.0, 60.0, 0.0, 40.0, 60.0, 0.0] + let expected_y = [0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0, 120.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_single_item_span_2_gap_fixed" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item_span_2_gap_fixed.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=span(2), end=place_auto())), + { text_content: "HH\u{200B}HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_gap(Size(width=length(20.0), height=length(0.0))) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + grid_max_content(), + grid_max_content(), + ]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 60.0, 40.0, 20.0, 20.0, 40.0, 20.0, 20.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 0.0] + let expected_x = [0.0, 60.0, 0.0, 60.0, 100.0, 0.0, 60.0, 100.0, 0.0] + let expected_y = [0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0, 120.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_content_single_item_span_2_gap_percent_definite" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item_span_2_gap_percent_definite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=span(2), end=place_auto())), + { text_content: "HH\u{200B}HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_gap(Size(width=percent(0.2), height=length(0.0))) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + grid_max_content(), + grid_max_content(), + ]) + .with_size(Size(width=length(100.0), height=auto())), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 120.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 60.0, 40.0, 20.0, 20.0, 40.0, 20.0, 20.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 0.0] + let expected_x = [0.0, 60.0, 0.0, 60.0, 100.0, 0.0, 60.0, 100.0, 0.0] + let expected_y = [0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0, 120.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part37_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part37_test.mbt new file mode 100644 index 0000000..7706c40 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part37_test.mbt @@ -0,0 +1,811 @@ +// 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/grid/grid_max_content_single_item_span_2_gap_percent_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_max_content_single_item_span_2_gap_percent_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=span(2), end=place_auto())), + { text_content: "HH\u{200B}HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_gap(Size(width=percent(0.2), height=length(0.0))) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + grid_max_content(), + grid_max_content(), + ]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 100.0) + assert_eq(root_layout.size.height, 120.0) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let expected_w = [40.0, 60.0, 40.0, 20.0, 20.0, 40.0, 20.0, 20.0, 40.0] + let expected_h = [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 0.0] + let expected_x = [0.0, 60.0, 0.0, 60.0, 100.0, 0.0, 60.0, 100.0, 0.0] + let expected_y = [0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0, 120.0] + for i in 0..<9 { + let layout = taffy.layout(nodes[i]) + assert_eq(layout.size.width, expected_w[i]) + assert_eq(layout.size.height, expected_h[i]) + assert_eq(layout.location.x, expected_x[i]) + assert_eq(layout.location.y, expected_y[i]) + } +} + +///| +test "upstream/generated/grid/grid_max_width_greater_than_max_content" { + // Ported from taffy-reference/tests/generated/grid/grid_max_width_greater_than_max_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([auto(), auto()]) + .with_max_size(Size(width=length(400.0), height=auto())), + [node00, node01], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([grid_max_content()]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 160.0, 10.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 160.0, 10.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 80.0, 10.0, 0.0, 0.0) + assert_layout_xywh(taffy, node01, 80.0, 10.0, 80.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_max_width_less_than_max_content_with_min_content" { + // Ported from taffy-reference/tests/generated/grid/grid_max_width_less_than_max_content_with_min_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([auto(), auto()]) + .with_max_size(Size(width=length(80.0), height=auto())), + [node00, node01], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([grid_min_content()]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node01, 20.0, 40.0, 20.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_max_width_smaller_than_max_content" { + // Ported from taffy-reference/tests/generated/grid/grid_max_width_smaller_than_max_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([auto(), auto()]) + .with_max_size(Size(width=length(80.0), height=auto())), + [node00, node01], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([grid_max_content()]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 80.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 80.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 40.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node01, 40.0, 20.0, 40.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_max_width_smaller_than_min_content" { + // Ported from taffy-reference/tests/generated/grid/grid_max_width_smaller_than_min_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHH\u{200B}HHHH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHH\u{200B}HHHH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([auto(), auto()]) + .with_max_size(Size(width=length(60.0), height=auto())), + [node00, node01], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_columns([grid_max_content()]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 60.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 60.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 40.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node01, 40.0, 20.0, 40.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_min_content_flex_column" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_flex_column.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node02 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_flex()) + .with_flex_direction(flex_direction_column()), + [node00, node01, node02], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content()]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 20.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node01, 20.0, 20.0, 0.0, 20.0) + assert_layout_xywh(taffy, node02, 20.0, 20.0, 0.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_min_content_flex_row" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_flex_row.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node02 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default().with_display(display_flex()), + [node00, node01, node02], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content()]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 60.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 60.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node01, 20.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node02, 20.0, 40.0, 40.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_min_content_flex_single_item" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_flex_single_item.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf( + Style::default().with_min_size(Size(width=length(10.0), height=auto())), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=span(2), end=place_auto())), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7] + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_min_content(), fr(1.0)]), + nodes, + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 80.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 10.0, 30.0, 40.0, 40.0, 40.0, 10.0, 30.0], + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 50.0, 0.0, 40.0, 0.0, 40.0, 50.0], + [0.0, 0.0, 0.0, 40.0, 40.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_min_content_flex_single_item_margin_auto" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_flex_single_item_margin_auto.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let all_auto_margin : Rect[Dimension] = Rect( + left=auto(), + right=auto(), + top=auto(), + bottom=auto(), + ) + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(10.0), height=auto())) + .with_margin(all_auto_margin), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf_with_context( + Style::default() + .with_grid_column(Line(start=span(2), end=place_auto())) + .with_margin(all_auto_margin), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7] + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_min_content(), fr(1.0)]), + nodes, + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 80.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 10.0, 30.0, 40.0, 40.0, 40.0, 10.0, 30.0], + [40.0, 0.0, 40.0, 40.0, 10.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 50.0, 0.0, 40.0, 0.0, 40.0, 50.0], + [0.0, 20.0, 0.0, 40.0, 55.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_min_content_flex_single_item_margin_fixed" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_flex_single_item_margin_fixed.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let fixed_margin : Rect[Dimension] = Rect( + left=length(20.0), + right=length(10.0), + top=length(5.0), + bottom=length(15.0), + ) + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(10.0), height=auto())) + .with_margin(fixed_margin), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf_with_context( + Style::default() + .with_grid_column(Line(start=span(2), end=place_auto())) + .with_margin(fixed_margin), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7] + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_min_content(), fr(1.0)]), + nodes, + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 110.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 10.0, 30.0, 40.0, 40.0, 40.0, 40.0, 30.0], + [40.0, 20.0, 40.0, 40.0, 20.0, 40.0, 40.0, 40.0], + [0.0, 60.0, 80.0, 0.0, 60.0, 0.0, 40.0, 80.0], + [0.0, 5.0, 0.0, 40.0, 45.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_min_content_flex_single_item_margin_percent" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_flex_single_item_margin_percent.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let percent_margin : Rect[Dimension] = Rect( + left=percent(0.2), + right=percent(0.1), + top=percent(0.05), + bottom=percent(0.15), + ) + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(10.0), height=auto())) + .with_margin(percent_margin), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf_with_context( + Style::default() + .with_grid_column(Line(start=span(2), end=place_auto())) + .with_margin(percent_margin), + { text_content: "HH\u{200B}HH", writing_mode: Horizontal }, + ) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7] + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_min_content(), fr(1.0)]), + nodes, + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 80.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 10.0, 30.0, 40.0, 28.0, 40.0, 10.0, 30.0], + [40.0, 38.0, 40.0, 40.0, 32.0, 40.0, 40.0, 40.0], + [0.0, 42.0, 50.0, 0.0, 48.0, 0.0, 40.0, 50.0], + [0.0, 1.0, 0.0, 40.0, 42.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_min_content_maximum_single_item" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_maximum_single_item.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + minmax(length(0.0), grid_min_content()), + length(40.0), + ]), + nodes, + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 20.0, 40.0, 40.0, 20.0, 40.0, 40.0, 20.0, 40.0], + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 60.0, 0.0, 40.0, 60.0, 0.0, 40.0, 60.0], + [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_min_content_single_item" { + // Ported from taffy-reference/tests/generated/grid/grid_min_content_single_item.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let nodes = [node0, node1, node2, node3, node4, node5, node6, node7, node8] + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), grid_min_content(), length(40.0)]), + nodes, + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 20.0, 40.0, 40.0, 20.0, 40.0, 40.0, 20.0, 40.0], + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 60.0, 0.0, 40.0, 60.0, 0.0, 40.0, 60.0], + [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_minmax_auto_fixed_10px" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_auto_fixed_10px.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(auto(), length(10.0))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 10.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 10.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_auto_max_content" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_auto_max_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(auto(), grid_max_content())]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_auto_min_content" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_auto_min_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(auto(), grid_min_content())]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_auto_percent_definite" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_auto_percent_definite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(auto(), percent(0.2))]) + .with_size(Size(width=length(100.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_auto_percent_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_auto_percent_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(auto(), percent(0.2))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 8.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_column_fixed_width_above_range" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_column_fixed_width_above_range.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes : Array[NodeId] = [] + for _i in 0..<9 { + nodes.push(taffy.new_leaf(Style::default())) + } + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + minmax(length(20.0), length(40.0)), + length(40.0), + ]) + .with_size(Size(width=length(140.0), height=auto())), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + assert_layout_xywh(taffy, root, 140.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 80.0, 0.0, 40.0, 80.0, 0.0, 40.0, 80.0], + [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_minmax_column_fixed_width_below_range" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_column_fixed_width_below_range.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes : Array[NodeId] = [] + for _i in 0..<9 { + nodes.push(taffy.new_leaf(Style::default())) + } + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + minmax(length(20.0), length(40.0)), + length(40.0), + ]) + .with_size(Size(width=length(90.0), height=auto())), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + assert_layout_xywh(taffy, root, 90.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 20.0, 40.0, 40.0, 20.0, 40.0, 40.0, 20.0, 40.0], + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 60.0, 0.0, 40.0, 60.0, 0.0, 40.0, 60.0], + [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_minmax_column_fixed_width_within_range" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_column_fixed_width_within_range.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes : Array[NodeId] = [] + for _i in 0..<9 { + nodes.push(taffy.new_leaf(Style::default())) + } + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + minmax(length(20.0), length(40.0)), + length(40.0), + ]) + .with_size(Size(width=length(110.0), height=auto())), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 110.0) + assert_eq(root_layout.size.height, 120.0) + assert_eq(root_layout.location.x, 0.0) + assert_eq(root_layout.location.y, 0.0) + // Spot-check a representative item in the second column (should be 30px wide). + let item = nodes[1] + let l = taffy.layout(item) + assert_eq(l.size.width, 30.0) + assert_eq(l.size.height, 40.0) + assert_eq(l.location.x, 40.0) + assert_eq(l.location.y, 0.0) + // Spot-check a representative item in the third column (fixed 40px). + let item2 = nodes[2] + let l2 = taffy.layout(item2) + assert_eq(l2.size.width, 40.0) + assert_eq(l2.size.height, 40.0) + assert_eq(l2.location.x, 70.0) + assert_eq(l2.location.y, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_column_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_column_indefinite.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes : Array[NodeId] = [] + for _i in 0..<9 { + nodes.push(taffy.new_leaf(Style::default())) + } + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([ + length(40.0), + minmax(length(20.0), length(40.0)), + length(40.0), + ]), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + assert_layout_xywh(taffy, root, 120.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 80.0, 0.0, 40.0, 80.0, 0.0, 40.0, 80.0], + [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_minmax_column_with_auto_fixed" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_column_with_auto_fixed.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(length(20.0), length(40.0)), auto()]) + .with_size(Size(width=length(60.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + assert_layout_xywh(taffy, root, 60.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 40.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_column_with_fr_fixed" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_column_with_fr_fixed.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(length(20.0), length(40.0)), fr(1.0)]) + .with_size(Size(width=length(60.0), height=auto())), + [node0, node1], + ) + taffy.compute_layout(root, Size::max_content()) + assert_layout_xywh(taffy, root, 60.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 40.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_max_content_1fr" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_max_content_1fr.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_max_content(), fr(1.0))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part38_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part38_test.mbt new file mode 100644 index 0000000..a524fbb --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part38_test.mbt @@ -0,0 +1,631 @@ +// 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/grid/grid_minmax_max_content_auto" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_max_content_auto.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_max_content(), auto())]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_max_content_fixed_10px" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_max_content_fixed_10px.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_max_content(), length(10.0))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_max_content_min_content" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_max_content_min_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_max_content(), grid_min_content())]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_max_content_percent_definite" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_max_content_percent_definite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_max_content(), percent(0.2))]) + .with_size(Size(width=length(100.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_max_content_percent_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_max_content_percent_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_max_content(), percent(0.2))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_min_content_1fr" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_min_content_1fr.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_min_content(), fr(1.0))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_min_content_auto" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_min_content_auto.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_min_content(), auto())]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_min_content_fixed_10px" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_min_content_fixed_10px.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_min_content(), length(10.0))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_min_content_max_content" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_min_content_max_content.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_min_content(), grid_max_content())]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_min_content_percent_definite" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_min_content_percent_definite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_min_content(), percent(0.2))]) + .with_size(Size(width=length(100.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_minmax_min_content_percent_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_minmax_min_content_percent_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([minmax(grid_min_content(), percent(0.2))]), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_out_of_order_items" { + // Ported from taffy-reference/tests/generated/grid/grid_out_of_order_items.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf( + Style::default() + .with_grid_column(Line(start=line(1), end=place_auto())) + .with_size(Size(width=length(35.0), height=length(35.0))), + ) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())) + .with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_size(Size(width=length(10.0), height=length(10.0))), + ) + let node8 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_grid_auto_flow(grid_auto_flow_row_dense()) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.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, 80.0) + assert_eq(l0.location.y, 0.0) + let l1 = taffy.layout(node1) + assert_eq(l1.size.width, 40.0) + assert_eq(l1.size.height, 40.0) + assert_eq(l1.location.x, 0.0) + assert_eq(l1.location.y, 40.0) + let l2 = taffy.layout(node2) + assert_eq(l2.size.width, 35.0) + assert_eq(l2.size.height, 35.0) + assert_eq(l2.location.x, 0.0) + assert_eq(l2.location.y, 80.0) + let l3 = taffy.layout(node3) + assert_eq(l3.size.width, 40.0) + assert_eq(l3.size.height, 40.0) + assert_eq(l3.location.x, 40.0) + assert_eq(l3.location.y, 40.0) + let l4 = taffy.layout(node4) + assert_eq(l4.size.width, 40.0) + assert_eq(l4.size.height, 40.0) + assert_eq(l4.location.x, 80.0) + assert_eq(l4.location.y, 40.0) + let l5 = taffy.layout(node5) + assert_eq(l5.size.width, 20.0) + assert_eq(l5.size.height, 20.0) + assert_eq(l5.location.x, 0.0) + assert_eq(l5.location.y, 0.0) + let l6 = taffy.layout(node6) + assert_eq(l6.size.width, 40.0) + assert_eq(l6.size.height, 40.0) + assert_eq(l6.location.x, 40.0) + assert_eq(l6.location.y, 80.0) + let l7 = taffy.layout(node7) + assert_eq(l7.size.width, 10.0) + assert_eq(l7.size.height, 10.0) + assert_eq(l7.location.x, 40.0) + assert_eq(l7.location.y, 0.0) + let l8 = taffy.layout(node8) + assert_eq(l8.size.width, 40.0) + assert_eq(l8.size.height, 40.0) + assert_eq(l8.location.x, 80.0) + assert_eq(l8.location.y, 80.0) +} + +///| +test "upstream/generated/grid/grid_overflow_inline_axis_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_inline_axis_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0), + { text_content: "HHHHHHHHHH", writing_mode: Horizontal }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 50.0, 50.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_inline_axis_scroll" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_inline_axis_scroll.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0), + { text_content: "HHHHHHHHHH", writing_mode: Horizontal }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 50.0, 50.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_inline_axis_visible" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_inline_axis_visible.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HHHHHHHHHH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 50.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_rows" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_rows.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=line(1), end=span(4))), + { + text_content: "HHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHH", + writing_mode: Horizontal, + }, + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([ + grid_min_content(), + grid_max_content(), + length(10.0), + percent(0.2), + ]), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 320.0, 80.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 320.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 43.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node2, 203.0, 40.0, 43.0, 40.0) + assert_layout_xywh(taffy, node3, 10.0, 40.0, 246.0, 40.0) + assert_layout_xywh(taffy, node4, 64.0, 40.0, 256.0, 40.0) + assert_layout_xywh(taffy, node5, 43.0, 0.0, 0.0, 80.0) +} + +///| +test "upstream/generated/grid/grid_overflow_scrollbars_overridden_by_available_space" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_scrollbars_overridden_by_available_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0), + [node00], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_scrollbars_overridden_by_max_size" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_scrollbars_overridden_by_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_max_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_scrollbars_overridden_by_size" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_scrollbars_overridden_by_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 2.0, 4.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_scrollbars_take_up_space_both_axis" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_scrollbars_take_up_space_both_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 35.0, 35.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_scrollbars_take_up_space_x_axis" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_scrollbars_take_up_space_x_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 50.0, 35.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_overflow_scrollbars_take_up_space_y_axis" { + // Ported from taffy-reference/tests/generated/grid/grid_overflow_scrollbars_take_up_space_y_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(50.0), height=length(50.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 50.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 35.0, 50.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_padding_border_overrides_container_max_size" { + // Ported from taffy-reference/tests/generated/grid/grid_padding_border_overrides_container_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_max_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 22.0, 14.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 0.0, 15.0, 3.0) +} + +///| +test "upstream/generated/grid/grid_padding_border_overrides_container_size" { + // Ported from taffy-reference/tests/generated/grid/grid_padding_border_overrides_container_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 22.0, 14.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 0.0, 15.0, 3.0) +} + +///| +test "upstream/generated/grid/grid_padding_border_overrides_max_size" { + // Ported from taffy-reference/tests/generated/grid/grid_padding_border_overrides_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_max_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_grid()), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 22.0, 14.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 22.0, 14.0, 0.0, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part39_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part39_test.mbt new file mode 100644 index 0000000..039b844 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part39_test.mbt @@ -0,0 +1,981 @@ +// 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/grid/grid_padding_border_overrides_min_size" { + // Ported from taffy-reference/tests/generated/grid/grid_padding_border_overrides_min_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(0.0), height=length(0.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_grid()), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 22.0, 14.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 22.0, 14.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_padding_border_overrides_size" { + // Ported from taffy-reference/tests/generated/grid/grid_padding_border_overrides_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default().with_display(display_grid()), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 22.0, 14.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 22.0, 14.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_percent_item_inside_stretch_item" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_item_inside_stretch_item.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=percent(0.5), height=auto())), + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_grid()), + [node00], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 50.0, 100.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_percent_items_nested_inside_stretch_alignment" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_items_nested_inside_stretch_alignment.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_display(display_grid()) + .with_padding( + Rect( + left=length(0.0), + right=length(0.0), + top=percent(0.2), + bottom=length(0.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default().with_display(display_grid()), + [node00], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(200.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 200.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 200.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node00, 200.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_percent_items_nested_moderate" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_items_nested_moderate.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.45), height=auto())) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=percent(0.5), height=auto())) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=percent(0.03), + right=percent(0.03), + top=percent(0.03), + bottom=percent(0.03), + ), + ), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(200.0), height=auto())) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) +} + +///| +test "upstream/generated/grid/grid_percent_items_nested_with_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_items_nested_with_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.45), height=auto())) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=percent(0.5), height=auto())), + [node00], + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(200.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + let l00 = taffy.layout(node00) + assert_eq(l00.location.x, 5.0) + assert_eq(l00.location.y, 5.0) + assert_eq(l00.size.width, 45.0) + assert_eq(l00.size.height, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 10.0, 0.0, 0.0) + assert_layout_xywh(taffy, root, 200.0, 10.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_percent_items_nested_with_padding_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_items_nested_with_padding_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.45), height=auto())) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + ) + let node00 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=percent(0.5), height=auto())) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=percent(0.03), + right=percent(0.03), + top=percent(0.03), + bottom=percent(0.03), + ), + ), + [node000], + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_min_size(Size(width=percent(0.6), height=auto())) + .with_margin( + Rect( + left=length(5.0), + right=length(5.0), + top=length(5.0), + bottom=length(5.0), + ), + ) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + [node00], + ) + let node1 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([fr(1.0), fr(4.0)]) + .with_size(Size(width=length(200.0), height=length(200.0))), + [node0, node1], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node0, 190.0, 41.0, 5.0, 5.0) + assert_layout_xywh(taffy, node00, 92.0, 25.0, 8.0, 8.0) + assert_layout_xywh(taffy, node000, 36.0, 6.0, 10.0, 10.0) + assert_layout_xywh(taffy, node1, 200.0, 149.0, 0.0, 51.0) + assert_layout_xywh(taffy, root, 200.0, 200.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_percent_items_width_and_margin" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_items_width_and_margin.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.45), height=auto())) + .with_margin( + Rect( + left=percent(0.05), + right=percent(0.05), + top=percent(0.05), + bottom=percent(0.05), + ), + ) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(200.0), height=auto())) + .with_padding( + Rect( + left=length(3.0), + right=length(3.0), + top=length(3.0), + bottom=length(3.0), + ), + ), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 200.0, 31.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 87.0, 6.0, 13.0, 13.0) +} + +///| +test "upstream/generated/grid/grid_percent_items_width_and_padding" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_items_width_and_padding.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=percent(0.5), height=auto())) + .with_padding( + Rect( + left=percent(0.03), + right=percent(0.03), + top=percent(0.03), + bottom=percent(0.03), + ), + ), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(200.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 200.0, 12.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 12.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_percent_tracks_definite_overflow" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_tracks_definite_overflow.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([percent(0.5), percent(0.8)]) + .with_grid_template_columns([percent(0.4), percent(0.4), percent(0.4)]) + .with_size(Size(width=length(120.0), height=length(60.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 120.0, 60.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 48.0, 30.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 48.0, 30.0, 48.0, 0.0) + assert_layout_xywh(taffy, node2, 48.0, 30.0, 96.0, 0.0) + assert_layout_xywh(taffy, node3, 48.0, 48.0, 0.0, 30.0) + assert_layout_xywh(taffy, node4, 48.0, 48.0, 48.0, 30.0) + assert_layout_xywh(taffy, node5, 48.0, 48.0, 96.0, 30.0) +} + +///| +test "upstream/generated/grid/grid_percent_tracks_definite_underflow" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_tracks_definite_underflow.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([percent(0.3), percent(0.6)]) + .with_grid_template_columns([percent(0.1), percent(0.2), percent(0.3)]) + .with_size(Size(width=length(120.0), height=length(60.0))), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 120.0, 60.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 12.0, 18.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 24.0, 18.0, 12.0, 0.0) + assert_layout_xywh(taffy, node2, 36.0, 18.0, 36.0, 0.0) + assert_layout_xywh(taffy, node3, 12.0, 36.0, 0.0, 18.0) + assert_layout_xywh(taffy, node4, 24.0, 36.0, 12.0, 18.0) + assert_layout_xywh(taffy, node5, 36.0, 36.0, 36.0, 18.0) +} + +///| +test "upstream/generated/grid/grid_percent_tracks_indefinite_only" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_tracks_indefinite_only.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([percent(0.3), percent(0.6)]) + .with_grid_template_columns([percent(0.1), percent(0.2), percent(0.3)]), + [node0, node1, node2, node3, node4, node5], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 0.0, 0.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 0.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 0.0, 0.0, 0.0, 0.0) + assert_layout_xywh(taffy, node2, 0.0, 0.0, 0.0, 0.0) + assert_layout_xywh(taffy, node3, 0.0, 0.0, 0.0, 0.0) + assert_layout_xywh(taffy, node4, 0.0, 0.0, 0.0, 0.0) + assert_layout_xywh(taffy, node5, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_percent_tracks_indefinite_with_content_overflow" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_tracks_indefinite_with_content_overflow.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([percent(0.5), percent(0.8)]) + .with_grid_template_columns([percent(0.4), percent(0.4), percent(0.4)]), + [node0, node1, node2, node3, node4, node5, node6], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 40.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node2, 40.0, 50.0, 40.0, 0.0) + assert_layout_xywh(taffy, node3, 40.0, 50.0, 80.0, 0.0) + assert_layout_xywh(taffy, node4, 40.0, 80.0, 0.0, 50.0) + assert_layout_xywh(taffy, node5, 40.0, 80.0, 40.0, 50.0) + assert_layout_xywh(taffy, node6, 40.0, 80.0, 80.0, 50.0) +} + +///| +test "upstream/generated/grid/grid_percent_tracks_indefinite_with_content_underflow" { + // Ported from taffy-reference/tests/generated/grid/grid_percent_tracks_indefinite_with_content_underflow.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([percent(0.3), percent(0.6)]) + .with_grid_template_columns([percent(0.1), percent(0.2), percent(0.3)]), + [node0, node1, node2, node3, node4, node5, node6], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 10.0, 30.0, 0.0, 0.0) + assert_layout_xywh(taffy, node2, 20.0, 30.0, 10.0, 0.0) + assert_layout_xywh(taffy, node3, 30.0, 30.0, 30.0, 0.0) + assert_layout_xywh(taffy, node4, 10.0, 60.0, 0.0, 30.0) + assert_layout_xywh(taffy, node5, 20.0, 60.0, 10.0, 30.0) + assert_layout_xywh(taffy, node6, 30.0, 60.0, 30.0, 30.0) +} + +///| +test "upstream/generated/grid/grid_placement_auto_negative" { + // Ported from taffy-reference/tests/generated/grid/grid_placement_auto_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(-5), end=place_auto())), + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf( + Style::default().with_grid_row(Line(start=line(2), end=place_auto())), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 120.0, 120.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node2, 20.0, 40.0, 0.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_placement_definite_in_secondary_axis_with_fully_definite_negative" { + // Ported from taffy-reference/tests/generated/grid/grid_placement_definite_in_secondary_axis_with_fully_definite_negative.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default().with_grid_row(Line(start=line(2), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(2), end=place_auto())) + .with_grid_column(Line(start=line(-4), end=place_auto())), + ) + let node2 = taffy.new_leaf( + Style::default().with_grid_row(Line(start=line(1), end=place_auto())), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 120.0, 120.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 40.0, 40.0) + assert_layout_xywh(taffy, node1, 40.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node2, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_relative_all_sides" { + // Ported from taffy-reference/tests/generated/grid/grid_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 root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(100.0), height=length(100.0))), + [node0], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 100.0, 100.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 100.0, 10.0, 10.0) +} + +///| +test "upstream/generated/grid/grid_relayout_vertical_text" { + // Ported from taffy-reference/tests/generated/grid/grid_relayout_vertical_text.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH\u{200B}HH\u{200B}HH\u{200B}HH\u{200B}HH", + writing_mode: Vertical, + }) + let node1 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH\u{200B}HH\u{200B}HH", + writing_mode: Horizontal, + }) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content()]), + [node0, node1], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 40.0, 60.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 40.0, 20.0, 0.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_repeat_integer" { + // Ported from taffy-reference/tests/generated/grid/grid_repeat_integer.rs + let taffy : ChicleTree[Unit] = ChicleTree() + let nodes : Array[NodeId] = [] + for _i in 0..<9 { + nodes.push(taffy.new_leaf(Style::default())) + } + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([repeat(repeat_count(3), [length(40.0)])]) + .with_grid_template_columns([repeat(repeat_count(3), [length(40.0)])]) + .with_size(Size(width=length(120.0), height=length(120.0))), + nodes, + ) + taffy.compute_layout(root, Size::max_content()) + let root_layout = taffy.layout(root) + assert_eq(root_layout.size.width, 120.0) + assert_eq(root_layout.size.height, 120.0) + let l8 = taffy.layout(nodes[8]) + assert_eq(l8.location.x, 80.0) + assert_eq(l8.location.y, 80.0) +} + +///| +test "upstream/generated/grid/grid_repeat_mixed" { + // Ported from taffy-reference/tests/generated/grid/grid_repeat_mixed.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let nodes : Array[NodeId] = [] + for _i in 0..<9 { + nodes.push(taffy.new_leaf(Style::default())) + } + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([ + length(40.0), + repeat(repeat_count(1), [length(40.0)]), + repeat(repeat_auto_fill(), [length(40.0)]), + ]) + .with_grid_template_columns([ + length(40.0), + repeat(repeat_count(1), [length(40.0)]), + repeat(repeat_auto_fill(), [length(40.0)]), + ]) + .with_size(Size(width=length(120.0), height=length(120.0))), + nodes, + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 120.0, 120.0, 0.0, 0.0) + assert_nodes_layout_xywh( + taffy, + nodes, + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0, 40.0], + [0.0, 40.0, 80.0, 0.0, 40.0, 80.0, 0.0, 40.0, 80.0], + [0.0, 0.0, 0.0, 40.0, 40.0, 40.0, 80.0, 80.0, 80.0], + ) +} + +///| +test "upstream/generated/grid/grid_size_child_fixed_tracks" { + // Ported from taffy-reference/tests/generated/grid/grid_size_child_fixed_tracks.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node1 = taffy.new_leaf_with_context( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()), + { text_content: "HHH\u{200b}HHH", writing_mode: Horizontal }, + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()), + { text_content: "HH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node3 = taffy.new_leaf_with_context( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()) + .with_size(Size(width=length(20.0), height=auto())), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let node4 = taffy.new_leaf_with_context( + Style::default() + .with_align_self(align_items_start()) + .with_justify_self(align_items_start()) + .with_max_size(Size(width=length(30.0), height=auto())), + { + text_content: "HH\u{200b}HH\u{200b}HH\u{200b}HH", + writing_mode: Horizontal, + }, + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0), length(40.0)]) + .with_grid_template_columns([length(40.0), length(40.0), length(40.0)]) + .with_size(Size(width=length(120.0), height=length(120.0))), + [node0, node1, node2, node3, node4], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 120.0, 120.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 20.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 40.0, 20.0, 40.0, 0.0) + assert_layout_xywh(taffy, node2, 40.0, 20.0, 80.0, 0.0) + assert_layout_xywh(taffy, node3, 20.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node4, 30.0, 40.0, 40.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=line(1), end=span(13))), + { + text_content: "HHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHH", + writing_mode: Horizontal, + }, + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let node9 = taffy.new_leaf(Style::default()) + let node10 = taffy.new_leaf(Style::default()) + let node11 = taffy.new_leaf(Style::default()) + let node12 = taffy.new_leaf(Style::default()) + let node13 = taffy.new_leaf(Style::default()) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([ + grid_min_content(), + grid_max_content(), + fit_content(length(20.0)), + auto(), + length(10.0), + percent(0.2), + minmax(length(2.0), auto()), + minmax(length(2.0), length(4.0)), + minmax(length(2.0), grid_min_content()), + minmax(length(2.0), grid_max_content()), + minmax(grid_min_content(), grid_max_content()), + minmax(grid_min_content(), auto()), + minmax(grid_max_content(), auto()), + ]), + [ + node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, + node11, node12, node13, + ], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 322.0, 80.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 322.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 11.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node2, 91.0, 40.0, 11.0, 40.0) + assert_layout_xywh(taffy, node3, 11.0, 40.0, 102.0, 40.0) + assert_layout_xywh(taffy, node4, 11.0, 40.0, 113.0, 40.0) + assert_layout_xywh(taffy, node5, 10.0, 40.0, 124.0, 40.0) + assert_layout_xywh(taffy, node6, 65.0, 40.0, 134.0, 40.0) + assert_layout_xywh(taffy, node7, 2.0, 40.0, 199.0, 40.0) + assert_layout_xywh(taffy, node8, 4.0, 40.0, 201.0, 40.0) + assert_layout_xywh(taffy, node9, 2.0, 40.0, 205.0, 40.0) + assert_layout_xywh(taffy, node10, 2.0, 40.0, 207.0, 40.0) + assert_layout_xywh(taffy, node11, 11.0, 40.0, 209.0, 40.0) + assert_layout_xywh(taffy, node12, 11.0, 40.0, 220.0, 40.0) + assert_layout_xywh(taffy, node13, 91.0, 40.0, 231.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_13_most_non_flex_with_minmax_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_column(Line(start=line(1), end=span(13))), + { + text_content: "HHHHHHHHHHHHHHHH\u{200b}HHHHHHHHHHHHHHHH", + writing_mode: Horizontal, + }, + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let node9 = taffy.new_leaf(Style::default()) + let node10 = taffy.new_leaf(Style::default()) + let node11 = taffy.new_leaf(Style::default()) + let node12 = taffy.new_leaf(Style::default()) + let node13 = taffy.new_leaf(Style::default()) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([ + grid_min_content(), + grid_max_content(), + fit_content(length(20.0)), + auto(), + length(10.0), + percent(0.2), + minmax(length(2.0), auto()), + minmax(length(2.0), length(4.0)), + minmax(length(2.0), grid_min_content()), + minmax(length(2.0), grid_max_content()), + minmax(grid_min_content(), grid_max_content()), + minmax(grid_min_content(), auto()), + minmax(grid_max_content(), auto()), + ]), + [ + node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, + node11, node12, node13, + ], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 322.0, 80.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 322.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 16.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node2, 95.0, 40.0, 16.0, 40.0) + assert_layout_xywh(taffy, node3, 0.0, 40.0, 111.0, 40.0) + assert_layout_xywh(taffy, node4, 0.0, 40.0, 111.0, 40.0) + assert_layout_xywh(taffy, node5, 10.0, 40.0, 111.0, 40.0) + assert_layout_xywh(taffy, node6, 64.0, 40.0, 121.0, 40.0) + assert_layout_xywh(taffy, node7, 2.0, 40.0, 185.0, 40.0) + assert_layout_xywh(taffy, node8, 4.0, 40.0, 187.0, 40.0) + assert_layout_xywh(taffy, node9, 2.0, 40.0, 191.0, 40.0) + assert_layout_xywh(taffy, node10, 2.0, 40.0, 193.0, 40.0) + assert_layout_xywh(taffy, node11, 16.0, 40.0, 195.0, 40.0) + assert_layout_xywh(taffy, node12, 15.0, 40.0, 211.0, 40.0) + assert_layout_xywh(taffy, node13, 96.0, 40.0, 226.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_span_2_max_content_auto_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_max_content_auto_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_max_content(), auto()]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 60.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 60.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_max_content_auto_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_max_content_auto_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_max_content(), auto()]), + [node0, node1], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 0.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 0.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 0.0, 40.0, 0.0, 0.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part40_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part40_test.mbt new file mode 100644 index 0000000..95bc25e --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part40_test.mbt @@ -0,0 +1,997 @@ +// 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/grid/grid_span_2_max_content_fit_content_10px_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_max_content_fit_content_10px_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_max_content(), fit_content(length(10.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 60.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 60.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_max_content_fit_content_10px_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_max_content_fit_content_10px_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_max_content(), fit_content(length(10.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 0.0, 40.0, 80.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_max_content(), fit_content(length(80.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 60.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 60.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_max_content_fit_content_80px_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_max_content(), fit_content(length(80.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 0.0, 40.0, 80.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_max_content_max_content_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_max_content_max_content_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_max_content(), grid_max_content()]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 40.0, 40.0, 40.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_auto_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_auto_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), auto()]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 60.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 10.0, 0.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_auto_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_auto_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf(Style::default()) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), auto()]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 40.0, 40.0, 40.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 10.0, 0.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), fit_content(length(10.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node2, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_fit_content_10px_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), fit_content(length(10.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 50.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 10.0, 40.0, 40.0, 0.0) + assert_layout_xywh(taffy, node2, 50.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), fit_content(length(30.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 50.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 30.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node2, 50.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_fit_content_30px_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), fit_content(length(30.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 70.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 30.0, 40.0, 40.0, 0.0) + assert_layout_xywh(taffy, node2, 70.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), fit_content(length(80.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 60.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_fit_content_80px_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), fit_content(length(80.0))]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 40.0, 40.0, 40.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_max_content_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_max_content_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), grid_max_content()]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 80.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 60.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node2, 80.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_2_min_content_min_content_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_2_min_content_min_content_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=place_auto())), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(2), end=place_auto())), + ) + let node2 = taffy.new_leaf_with_context( + Style::default() + .with_grid_row(Line(start=line(1), end=place_auto())) + .with_grid_column(Line(start=line(1), end=span(2))), + { text_content: "HHHH\u{200b}HHHH", writing_mode: Horizontal }, + ) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0)]) + .with_grid_template_columns([grid_min_content(), grid_min_content()]), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 40.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 20.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 20.0, 40.0, 20.0, 0.0) + assert_layout_xywh(taffy, node2, 40.0, 40.0, 0.0, 0.0) +} + +///| +test "upstream/generated/grid/grid_span_6_all_non_flex_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_6_all_non_flex_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=line(1), end=span(6))), + { text_content: "HHHHHHHH\u{200b}HHHHHHHH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([ + grid_min_content(), + grid_max_content(), + fit_content(length(20.0)), + auto(), + length(10.0), + percent(0.2), + ]), + [node0, node1, node2, node3, node4, node5, node6], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 160.0, 80.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 160.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 10.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node2, 89.0, 40.0, 10.0, 40.0) + assert_layout_xywh(taffy, node3, 10.0, 40.0, 99.0, 40.0) + assert_layout_xywh(taffy, node4, 9.0, 40.0, 109.0, 40.0) + assert_layout_xywh(taffy, node5, 10.0, 40.0, 118.0, 40.0) + assert_layout_xywh(taffy, node6, 32.0, 40.0, 128.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_span_6_all_non_flex_indefinite_hidden" { + // Ported from taffy-reference/tests/generated/grid/grid_span_6_all_non_flex_indefinite_hidden.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_hidden(), y=overflow_hidden())) + .with_scrollbar_width(15.0) + .with_grid_column(Line(start=line(1), end=span(6))), + { text_content: "HHHHHHHH\u{200b}HHHHHHHH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([ + grid_min_content(), + grid_max_content(), + fit_content(length(20.0)), + auto(), + length(10.0), + percent(0.2), + ]), + [node0, node1, node2, node3, node4, node5, node6], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 160.0, 80.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 160.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 19.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node2, 99.0, 40.0, 19.0, 40.0) + assert_layout_xywh(taffy, node3, 0.0, 40.0, 118.0, 40.0) + assert_layout_xywh(taffy, node4, 0.0, 40.0, 118.0, 40.0) + assert_layout_xywh(taffy, node5, 10.0, 40.0, 118.0, 40.0) + assert_layout_xywh(taffy, node6, 32.0, 40.0, 128.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_span_8_all_track_types_indefinite" { + // Ported from taffy-reference/tests/generated/grid/grid_span_8_all_track_types_indefinite.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf_with_context( + Style::default().with_grid_column(Line(start=line(1), end=span(8))), + { text_content: "HHHHHHHH\u{200b}HHHHHHHH", writing_mode: Horizontal }, + ) + let node1 = taffy.new_leaf(Style::default()) + let node2 = taffy.new_leaf(Style::default()) + let node3 = taffy.new_leaf(Style::default()) + let node4 = taffy.new_leaf(Style::default()) + let node5 = taffy.new_leaf(Style::default()) + let node6 = taffy.new_leaf(Style::default()) + let node7 = taffy.new_leaf(Style::default()) + let node8 = taffy.new_leaf(Style::default()) + let node = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(40.0), length(40.0)]) + .with_grid_template_columns([ + grid_min_content(), + grid_max_content(), + fit_content(length(20.0)), + auto(), + length(10.0), + percent(0.2), + fr(1.0), + fr(2.0), + ]), + [node0, node1, node2, node3, node4, node5, node6, node7, node8], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + assert_layout_xywh(taffy, node, 160.0, 80.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 160.0, 40.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 0.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node2, 0.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node3, 0.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node4, 0.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node5, 10.0, 40.0, 0.0, 40.0) + assert_layout_xywh(taffy, node6, 32.0, 40.0, 10.0, 40.0) + assert_layout_xywh(taffy, node7, 39.0, 40.0, 42.0, 40.0) + assert_layout_xywh(taffy, node8, 79.0, 40.0, 81.0, 40.0) +} + +///| +test "upstream/generated/grid/grid_taffy_issue_624" { + // Ported from taffy-reference/tests/generated/grid/grid_taffy_issue_624.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=span(2))) + .with_grid_column(Line(start=line(1), end=place_auto())) + .with_size(Size(width=length(100.0), height=length(50.0))), + ) + let node1 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(1), end=span(2))) + .with_grid_column(Line(start=line(2), end=span(2))) + .with_size(Size(width=length(40.0), height=length(30.0))), + ) + let node2 = taffy.new_leaf( + Style::default() + .with_grid_row(Line(start=line(3), end=span(1))) + .with_grid_column(Line(start=line(1), end=span(2))) + .with_size(Size(width=length(120.0), height=length(20.0))), + ) + let root = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_justify_items(align_items_start()) + .with_justify_content(justify_content_start()) + .with_grid_template_rows([auto(), auto(), auto(), fr(1.0)]) + .with_grid_template_columns([auto(), auto(), fr(1.0)]) + .with_size(Size(width=length(320.0), height=length(640.0))), + [node0, node1, node2], + ) + taffy.compute_layout_with_measure(root, Size::max_content(), measure_text) + assert_layout_xywh(taffy, root, 320.0, 640.0, 0.0, 0.0) + assert_layout_xywh(taffy, node0, 100.0, 50.0, 0.0, 0.0) + assert_layout_xywh(taffy, node1, 40.0, 30.0, 100.0, 0.0) + assert_layout_xywh(taffy, node2, 120.0, 20.0, 0.0, 50.0) +} + +///| +test "upstream/generated/grid/mod" { + // Ported from taffy-reference/tests/generated/grid/mod.rs + () +} + +///| +test "upstream/generated/gridflex/gridflex_column_integration" { + // Ported from taffy-reference/tests/generated/gridflex/gridflex_column_integration.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node02 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node03 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([fr(1.0), fr(1.0)]) + .with_grid_template_columns([fr(1.0), fr(1.0)]), + [node00, node01, node02, node03], + ) + 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 l_node = taffy.layout(node) + assert_eq(l_node.size.width, 40.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.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, 20.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 20.0) + assert_eq(l01.size.height, 10.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 0.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 20.0) + assert_eq(l02.size.height, 10.0) + assert_eq(l02.location.x, 0.0) + assert_eq(l02.location.y, 10.0) + let l03 = taffy.layout(node03) + assert_eq(l03.size.width, 20.0) + assert_eq(l03.size.height, 10.0) + assert_eq(l03.location.x, 20.0) + assert_eq(l03.location.y, 10.0) +} + +///| +test "upstream/generated/gridflex/gridflex_kitchen_sink" { + // Ported from taffy-reference/tests/generated/gridflex/gridflex_kitchen_sink.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node000 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node00100 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=auto())), + ) + let node00101 = taffy.new_leaf(Style::default()) + let node00102 = taffy.new_leaf(Style::default()) + let node00103 = taffy.new_leaf(Style::default()) + let node0010 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([percent(0.3), percent(0.1)]) + .with_grid_template_columns([auto(), percent(0.1)]), + [node00100, node00101, node00102, node00103], + ) + let node001 = taffy.new_with_children( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=length(50.0), height=auto())), + [node0010], + ) + let node00 = taffy.new_with_children(Style::default(), [node000, node001]) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node02 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node03 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([fr(1.0), fr(1.0)]) + .with_grid_template_columns([fr(1.0), fr(1.0)]), + [node00, node01, node02, node03], + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 140.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 140.0) + assert_eq(l0.size.height, 20.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, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l000 = taffy.layout(node000) + let l001 = taffy.layout(node001) + assert_eq(l000.size.width, 20.0) + assert_eq(l000.size.height, 10.0) + assert_eq(l000.location.x, 0.0) + assert_eq(l000.location.y, 0.0) + assert_eq(l001.size.width, 50.0) + assert_eq(l001.size.height, 10.0) + assert_eq(l001.location.x, 20.0) + assert_eq(l001.location.y, 0.0) + let l0010 = taffy.layout(node0010) + assert_eq(l0010.size.width, 20.0) + assert_eq(l0010.size.height, 10.0) + assert_eq(l0010.location.x, 0.0) + assert_eq(l0010.location.y, 0.0) + let l00100 = taffy.layout(node00100) + assert_eq(l00100.size.width, 20.0) + assert_eq(l00100.size.height, 3.0) + assert_eq(l00100.location.x, 0.0) + assert_eq(l00100.location.y, 0.0) + let l00101 = taffy.layout(node00101) + assert_eq(l00101.size.width, 2.0) + assert_eq(l00101.size.height, 3.0) + assert_eq(l00101.location.x, 20.0) + assert_eq(l00101.location.y, 0.0) + let l00102 = taffy.layout(node00102) + assert_eq(l00102.size.width, 20.0) + assert_eq(l00102.size.height, 1.0) + assert_eq(l00102.location.x, 0.0) + assert_eq(l00102.location.y, 3.0) + let l00103 = taffy.layout(node00103) + assert_eq(l00103.size.width, 2.0) + assert_eq(l00103.size.height, 1.0) + assert_eq(l00103.location.x, 20.0) + assert_eq(l00103.location.y, 3.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 70.0) + assert_eq(l01.size.height, 10.0) + assert_eq(l01.location.x, 70.0) + assert_eq(l01.location.y, 0.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 70.0) + assert_eq(l02.size.height, 10.0) + assert_eq(l02.location.x, 0.0) + assert_eq(l02.location.y, 10.0) + let l03 = taffy.layout(node03) + assert_eq(l03.size.width, 70.0) + assert_eq(l03.size.height, 10.0) + assert_eq(l03.location.x, 70.0) + assert_eq(l03.location.y, 10.0) +} + +///| +test "upstream/generated/gridflex/gridflex_kitchen_sink_minimise" { + // Ported from taffy-reference/tests/generated/gridflex/gridflex_kitchen_sink_minimise.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=auto())), + ) + let node01 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([length(20.0)]) + .with_grid_template_columns([fr(1.0), fr(1.0)]), + [node00, node01], + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 100.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 100.0) + assert_eq(l0.size.height, 20.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, 50.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 50.0) + assert_eq(l01.size.height, 20.0) + assert_eq(l01.location.x, 50.0) + assert_eq(l01.location.y, 0.0) +} + +///| +test "upstream/generated/gridflex/gridflex_kitchen_sink_minimise2" { + // Ported from taffy-reference/tests/generated/gridflex/gridflex_kitchen_sink_minimise2.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([auto()]) + .with_grid_template_columns([auto()]), + [node00], + ) + let node = taffy.new_with_children( + Style::default() + .with_flex_grow(1.0) + .with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.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, 20.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/gridflex/gridflex_kitchen_sink_minimise3" { + // Ported from taffy-reference/tests/generated/gridflex/gridflex_kitchen_sink_minimise3.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf( + Style::default().with_size(Size(width=length(20.0), height=length(20.0))), + ) + let node01 = taffy.new_leaf(Style::default()) + let node02 = taffy.new_leaf(Style::default()) + let node03 = taffy.new_leaf(Style::default()) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([percent(0.3), percent(0.1)]) + .with_grid_template_columns([auto(), percent(0.1)]), + [node00, node01, node02, node03], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.0), height=auto())), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 50.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 20.0) + assert_eq(l0.size.height, 20.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, 20.0) + assert_eq(l00.size.height, 20.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 2.0) + assert_eq(l01.size.height, 6.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 0.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 20.0) + assert_eq(l02.size.height, 2.0) + assert_eq(l02.location.x, 0.0) + assert_eq(l02.location.y, 6.0) + let l03 = taffy.layout(node03) + assert_eq(l03.size.width, 2.0) + assert_eq(l03.size.height, 2.0) + assert_eq(l03.location.x, 20.0) + assert_eq(l03.location.y, 6.0) +} diff --git a/conformance/chicle/upstream/upstream_generated_stub_part41_test.mbt b/conformance/chicle/upstream/upstream_generated_stub_part41_test.mbt new file mode 100644 index 0000000..f979c95 --- /dev/null +++ b/conformance/chicle/upstream/upstream_generated_stub_part41_test.mbt @@ -0,0 +1,421 @@ +// 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/gridflex/gridflex_row_integration" { + // Ported from taffy-reference/tests/generated/gridflex/gridflex_row_integration.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node00 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node01 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node02 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node03 = taffy.new_leaf_with_context(Style::default(), { + text_content: "HH", + writing_mode: Horizontal, + }) + let node0 = taffy.new_with_children( + Style::default() + .with_display(display_grid()) + .with_grid_template_rows([fr(1.0), fr(1.0)]) + .with_grid_template_columns([fr(1.0), fr(1.0)]), + [node00, node01, node02, node03], + ) + let node = taffy.new_with_children(Style::default(), [node0]) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 40.0) + assert_eq(l_node.size.height, 20.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 40.0) + assert_eq(l0.size.height, 20.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, 20.0) + assert_eq(l00.size.height, 10.0) + assert_eq(l00.location.x, 0.0) + assert_eq(l00.location.y, 0.0) + let l01 = taffy.layout(node01) + assert_eq(l01.size.width, 20.0) + assert_eq(l01.size.height, 10.0) + assert_eq(l01.location.x, 20.0) + assert_eq(l01.location.y, 0.0) + let l02 = taffy.layout(node02) + assert_eq(l02.size.width, 20.0) + assert_eq(l02.size.height, 10.0) + assert_eq(l02.location.x, 0.0) + assert_eq(l02.location.y, 10.0) + let l03 = taffy.layout(node03) + assert_eq(l03.size.width, 20.0) + assert_eq(l03.size.height, 10.0) + assert_eq(l03.location.x, 20.0) + assert_eq(l03.location.y, 10.0) +} + +///| +test "upstream/generated/gridflex/mod" { + // Upstream mod.rs only declares submodules; no standalone runnable vector. + () +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_affect_available_space_x_axis" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_affect_available_space_x_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(45.0), height=length(45.0))), + { text_content: "HHHHHHHHHHHHHHHHHHHHH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 45.0) + assert_eq(l_node.size.height, 45.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_affect_available_space_y_axis" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_affect_available_space_y_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(45.0), height=length(45.0))), + { text_content: "HHHHHHHHHHHHHHHHHHHHH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 45.0) + assert_eq(l_node.size.height, 45.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_overridden_by_available_space" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_available_space.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node0 = taffy.new_leaf( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_flex_grow(1.0), + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(2.0), height=length(4.0))), + [node0], + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 2.0) + assert_eq(l_node.size.height, 4.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) + let l0 = taffy.layout(node0) + assert_eq(l0.size.width, 2.0) + assert_eq(l0.size.height, 4.0) + assert_eq(l0.location.x, 0.0) + assert_eq(l0.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_overridden_by_max_size" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_max_size(Size(width=length(2.0), height=length(4.0))), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 2.0) + assert_eq(l_node.size.height, 4.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_overridden_by_size" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0) + .with_size(Size(width=length(2.0), height=length(4.0))), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 2.0) + assert_eq(l_node.size.height, 4.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_take_up_space_both_axis" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_both_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_scroll())) + .with_scrollbar_width(15.0), + { text_content: "HH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 35.0) + assert_eq(l_node.size.height, 25.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_take_up_space_x_axis" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_x_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_scroll(), y=overflow_visible())) + .with_scrollbar_width(15.0), + { text_content: "HH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 20.0) + assert_eq(l_node.size.height, 25.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_overflow_scrollbars_take_up_space_y_axis" { + // Ported from taffy-reference/tests/generated/leaf/leaf_overflow_scrollbars_take_up_space_y_axis.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default() + .with_overflow(Point(x=overflow_visible(), y=overflow_scroll())) + .with_scrollbar_width(15.0), + { text_content: "HH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 35.0) + assert_eq(l_node.size.height, 10.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_padding_border_overrides_max_size" { + // Ported from taffy-reference/tests/generated/leaf/leaf_padding_border_overrides_max_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_max_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 22.0) + assert_eq(l_node.size.height, 14.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_padding_border_overrides_min_size" { + // Ported from taffy-reference/tests/generated/leaf/leaf_padding_border_overrides_min_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_min_size(Size(width=length(0.0), height=length(0.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 22.0) + assert_eq(l_node.size.height, 14.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_padding_border_overrides_size" { + // Ported from taffy-reference/tests/generated/leaf/leaf_padding_border_overrides_size.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(12.0), height=length(12.0))) + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 22.0) + assert_eq(l_node.size.height, 14.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_with_content_and_border" { + // Ported from taffy-reference/tests/generated/leaf/leaf_with_content_and_border.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default().with_border( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + { text_content: "HHHH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 52.0) + assert_eq(l_node.size.height, 18.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_with_content_and_padding" { + // Ported from taffy-reference/tests/generated/leaf/leaf_with_content_and_padding.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default().with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ), + { text_content: "HHHH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 52.0) + assert_eq(l_node.size.height, 18.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/leaf_with_content_and_padding_border" { + // Ported from taffy-reference/tests/generated/leaf/leaf_with_content_and_padding_border.rs + let taffy : ChicleTree[TextMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context( + Style::default() + .with_padding( + Rect( + left=length(8.0), + right=length(4.0), + top=length(2.0), + bottom=length(6.0), + ), + ) + .with_border( + Rect( + left=length(7.0), + right=length(3.0), + top=length(1.0), + bottom=length(5.0), + ), + ), + { text_content: "HHHH", writing_mode: Horizontal }, + ) + taffy.compute_layout_with_measure(node, Size::max_content(), measure_text) + let l_node = taffy.layout(node) + assert_eq(l_node.size.width, 62.0) + assert_eq(l_node.size.height, 24.0) + assert_eq(l_node.location.x, 0.0) + assert_eq(l_node.location.y, 0.0) +} + +///| +test "upstream/generated/leaf/mod" { + // Upstream mod.rs only declares submodules; no standalone runnable vector. + () +} + +///| +test "upstream/generated/./mod" { + // Upstream mod.rs only declares submodules; no standalone runnable vector. + () +} diff --git a/conformance/chicle/upstream/upstream_misc_stub_test.mbt b/conformance/chicle/upstream/upstream_misc_stub_test.mbt new file mode 100644 index 0000000..e371e92 --- /dev/null +++ b/conformance/chicle/upstream/upstream_misc_stub_test.mbt @@ -0,0 +1,827 @@ +// 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. + +///| +struct MiscFixedMeasure { + width : Double + height : Double +} + +///| +struct MiscAspectRatioMeasure { + width : Double + height_ratio : Double +} + +///| +fn[T] misc_unwrap_or(value : T?, fallback : T) -> T { + match value { + Some(v) => v + None => fallback + } +} + +///| +fn misc_fixed_measure( + known_dimensions : Size[Double?], + _available_space : Size[AvailableSpace], + _node_id : NodeId, + node_context : MiscFixedMeasure?, + _style : Style, +) -> Size[Double] { + let ctx = match node_context { + Some(v) => v + None => { width: 0.0, height: 0.0 } + } + Size( + width=misc_unwrap_or(known_dimensions.width, ctx.width), + height=misc_unwrap_or(known_dimensions.height, ctx.height), + ) +} + +///| +fn misc_aspect_ratio_measure( + known_dimensions : Size[Double?], + _available_space : Size[AvailableSpace], + _node_id : NodeId, + node_context : MiscAspectRatioMeasure?, + _style : Style, +) -> Size[Double] { + let ctx = match node_context { + Some(v) => v + None => return Size::zero() + } + let width = misc_unwrap_or(known_dimensions.width, ctx.width) + let height = misc_unwrap_or(known_dimensions.height, width * ctx.height_ratio) + Size(width~, height~) +} + +///| +fn misc_square_measure( + known_dimensions : Size[Double?], + _available_space : Size[AvailableSpace], + _node_id : NodeId, + _node_context : Unit?, + _style : Style, +) -> Size[Double] { + let height = misc_unwrap_or(known_dimensions.height, 50.0) + let width = misc_unwrap_or(known_dimensions.width, height) + Size(width~, height~) +} + +///| +fn misc_count_measure( + known_dimensions : Size[Double?], + _available_space : Size[AvailableSpace], + _node_id : NodeId, + node_context : Array[Int]?, + _style : Style, +) -> Size[Double] { + match node_context { + Some(ctx) => ctx[0] = ctx[0] + 1 + None => () + } + Size( + width=misc_unwrap_or(known_dimensions.width, 50.0), + height=misc_unwrap_or(known_dimensions.height, 50.0), + ) +} + +///| +fn[C] misc_assert_layout_xywh( + taffy : ChicleTree[C], + node : NodeId, + x : Double, + y : Double, + width : Double, + height : Double, +) -> Unit raise Error { + let layout = taffy.layout(node) + assert_eq(layout.location.x, x) + assert_eq(layout.location.y, y) + assert_eq(layout.size.width, width) + assert_eq(layout.size.height, height) +} + +///| +test "upstream/caching/measure_count_flexbox" { + let taffy : ChicleTree[Array[Int]] = ChicleTree() + let leaf_counter = [0] + let leaf = taffy.new_leaf_with_context(Style::default(), leaf_counter) + let mut node = taffy.new_with_children(Style::default(), [leaf]) + for _ in 0..<100 { + node = taffy.new_with_children(Style::default(), [node]) + } + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_count_measure, + ) + match taffy.node_context(leaf) { + Some(ctx) => assert_eq(ctx[0], 4) + None => panic() + } +} + +///| +test "upstream/caching/measure_count_grid" { + let taffy : ChicleTree[Array[Int]] = ChicleTree() + let leaf_counter = [0] + let leaf = taffy.new_leaf_with_context( + Style::default().with_display(display_grid()), + leaf_counter, + ) + let mut node = taffy.new_with_children(Style::default(), [leaf]) + for _ in 0..<100 { + node = taffy.new_with_children(Style::default(), [node]) + } + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_count_measure, + ) + match taffy.node_context(leaf) { + Some(ctx) => assert_eq(ctx[0], 4) + None => panic() + } +} + +///| +test "upstream/measure/measure_root" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let node = taffy.new_leaf_with_context(Style::default(), { + width: 100.0, + height: 100.0, + }) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(node).size.width, 100.0) + assert_eq(taffy.layout(node).size.height, 100.0) +} + +///| +test "upstream/measure/measure_child" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context(Style::default(), { + width: 100.0, + height: 100.0, + }) + let node = taffy.new_with_children(Style::default(), [child]) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(node).size.width, 100.0) + assert_eq(taffy.layout(node).size.height, 100.0) + assert_eq(taffy.layout(child).size.width, 100.0) + assert_eq(taffy.layout(child).size.height, 100.0) +} + +///| +test "upstream/measure/measure_child_constraint" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context(Style::default(), { + width: 100.0, + height: 100.0, + }) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(50.0), height=auto())), + [child], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(node).size.width, 50.0) + assert_eq(taffy.layout(node).size.height, 100.0) + assert_eq(taffy.layout(child).size.width, 100.0) + assert_eq(taffy.layout(child).size.height, 100.0) +} + +///| +test "upstream/measure/measure_child_constraint_padding_parent" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context(Style::default(), { + width: 100.0, + height: 100.0, + }) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(50.0), height=auto())) + .with_padding( + Rect( + left=length(10.0), + right=length(10.0), + top=length(10.0), + bottom=length(10.0), + ), + ), + [child], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + misc_assert_layout_xywh(taffy, node, 0.0, 0.0, 50.0, 120.0) + misc_assert_layout_xywh(taffy, child, 10.0, 10.0, 100.0, 100.0) +} + +///| +test "upstream/measure/measure_child_with_flex_grow" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let child1 = taffy.new_leaf_with_context( + Style::default().with_flex_grow(1.0), + { width: 10.0, height: 50.0 }, + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [child0, child1], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child1).size.width, 50.0) + assert_eq(taffy.layout(child1).size.height, 50.0) +} + +///| +test "upstream/measure/measure_child_with_flex_shrink" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_flex_shrink(0.0), + ) + let child1 = taffy.new_leaf_with_context(Style::default(), { + width: 100.0, + height: 50.0, + }) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=auto())), + [child0, child1], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child1).size.width, 100.0) + assert_eq(taffy.layout(child1).size.height, 50.0) +} + +///| +test "upstream/measure/remeasure_child_after_growing" { + let taffy : ChicleTree[MiscAspectRatioMeasure] = ChicleTree() + let child0 = taffy.new_leaf( + Style::default().with_size(Size(width=length(50.0), height=length(50.0))), + ) + let child1 = taffy.new_leaf_with_context( + Style::default().with_flex_grow(1.0), + { width: 10.0, height_ratio: 2.0 }, + ) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(100.0), height=auto())) + .with_align_items(align_items_start()), + [child0, child1], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_aspect_ratio_measure, + ) + assert_eq(taffy.layout(child1).size.width, 50.0) + assert_eq(taffy.layout(child1).size.height, 100.0) +} + +///| +test "upstream/measure/remeasure_child_after_shrinking" { + let taffy : ChicleTree[MiscAspectRatioMeasure] = ChicleTree() + let child0 = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_flex_shrink(0.0), + ) + let child1 = taffy.new_leaf_with_context(Style::default(), { + width: 100.0, + height_ratio: 2.0, + }) + let node = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(100.0), height=auto())) + .with_align_items(align_items_start()), + [child0, child1], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_aspect_ratio_measure, + ) + assert_eq(taffy.layout(child1).size.width, 100.0) + assert_eq(taffy.layout(child1).size.height, 200.0) +} + +///| +test "upstream/measure/remeasure_child_after_stretching" { + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf_with_context(Style::default(), ()) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_square_measure, + ) + assert_eq(taffy.layout(child).size.width, 100.0) + assert_eq(taffy.layout(child).size.height, 100.0) +} + +///| +test "upstream/measure/width_overrides_measure" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=length(50.0), height=auto())), + { width: 100.0, height: 100.0 }, + ) + let node = taffy.new_with_children(Style::default(), [child]) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child).size.width, 50.0) + assert_eq(taffy.layout(child).size.height, 100.0) +} + +///| +test "upstream/measure/height_overrides_measure" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context( + Style::default().with_size(Size(width=auto(), height=length(50.0))), + { width: 100.0, height: 100.0 }, + ) + let node = taffy.new_with_children(Style::default(), [child]) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child).size.width, 100.0) + assert_eq(taffy.layout(child).size.height, 50.0) +} + +///| +test "upstream/measure/flex_basis_overrides_measure" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child0 = taffy.new_leaf( + Style::default().with_flex_basis(length(50.0)).with_flex_grow(1.0), + ) + let child1 = taffy.new_leaf_with_context( + Style::default().with_flex_basis(length(50.0)).with_flex_grow(1.0), + { width: 100.0, height: 100.0 }, + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(200.0), height=length(100.0))), + [child0, child1], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child0).size.width, 100.0) + assert_eq(taffy.layout(child0).size.height, 100.0) + assert_eq(taffy.layout(child1).size.width, 100.0) + assert_eq(taffy.layout(child1).size.height, 100.0) +} + +///| +test "upstream/measure/stretch_overrides_measure" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context(Style::default(), { + width: 50.0, + height: 50.0, + }) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child).size.width, 50.0) + assert_eq(taffy.layout(child).size.height, 100.0) +} + +///| +test "upstream/measure/measure_absolute_child" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = taffy.new_leaf_with_context( + Style::default().with_position(position_absolute()), + { width: 50.0, height: 50.0 }, + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=length(100.0), height=length(100.0))), + [child], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child).size.width, 50.0) + assert_eq(taffy.layout(child).size.height, 50.0) +} + +///| +test "upstream/measure/ignore_invalid_measure" { + let taffy : ChicleTree[MiscFixedMeasure] = ChicleTree() + let child = 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))), + [child], + ) + taffy.compute_layout_with_measure( + node, + Size::max_content(), + misc_fixed_measure, + ) + assert_eq(taffy.layout(child).size.width, 100.0) + assert_eq(taffy.layout(child).size.height, 100.0) +} + +///| +test "upstream/min_max_overrides/min_overrides_max" { + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_min_size(Size(width=length(100.0), height=length(100.0))) + .with_max_size(Size(width=length(10.0), height=length(10.0))), + ) + taffy.compute_layout( + child, + Size( + width=available_space_definite(100.0), + height=available_space_definite(100.0), + ), + ) + let layout = taffy.layout(child) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) +} + +///| +test "upstream/min_max_overrides/max_overrides_size" { + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_max_size(Size(width=length(10.0), height=length(10.0))), + ) + taffy.compute_layout( + child, + Size( + width=available_space_definite(100.0), + height=available_space_definite(100.0), + ), + ) + let layout = taffy.layout(child) + assert_eq(layout.size.width, 10.0) + assert_eq(layout.size.height, 10.0) +} + +///| +test "upstream/min_max_overrides/min_overrides_size" { + let taffy : ChicleTree[Unit] = ChicleTree() + let child = taffy.new_leaf( + Style::default() + .with_size(Size(width=length(50.0), height=length(50.0))) + .with_min_size(Size(width=length(100.0), height=length(100.0))), + ) + taffy.compute_layout( + child, + Size( + width=available_space_definite(100.0), + height=available_space_definite(100.0), + ), + ) + let layout = taffy.layout(child) + assert_eq(layout.size.width, 100.0) + assert_eq(layout.size.height, 100.0) +} + +///| +test "upstream/relayout/relayout" { + let taffy : ChicleTree[Unit] = ChicleTree() + let node1 = taffy.new_leaf( + Style::default().with_size(Size(width=length(8.0), height=length(80.0))), + ) + let node0 = taffy.new_with_children( + Style::default() + .with_align_self(align_items_center()) + .with_size(Size(width=auto(), height=auto())), + [node1], + ) + let node = taffy.new_with_children( + Style::default().with_size(Size(width=percent(1.0), height=percent(1.0))), + [node0], + ) + let available : Size[AvailableSpace] = Size( + width=available_space_definite(100.0), + height=available_space_definite(100.0), + ) + taffy.compute_layout(node, available) + let initial = taffy.layout(node).location + let initial0 = taffy.layout(node0).location + let initial1 = taffy.layout(node1).location + for _ in 1..<10 { + taffy.compute_layout(node, available) + let l = taffy.layout(node).location + let l0 = taffy.layout(node0).location + let l1 = taffy.layout(node1).location + assert_eq(l.x, initial.x) + assert_eq(l.y, initial.y) + assert_eq(l0.x, initial0.x) + assert_eq(l0.y, initial0.y) + assert_eq(l1.x, initial1.x) + assert_eq(l1.y, initial1.y) + } +} + +///| +test "upstream/relayout/toggle_flex_child_display_none" { + let hidden_style = Style::default() + .with_display(display_none()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let flex_style = Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let taffy : ChicleTree[Unit] = ChicleTree() + let node = taffy.new_leaf(hidden_style) + let root = taffy.new_with_children(flex_style, [node]) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, node, 0.0, 0.0, 0.0, 0.0) + taffy.set_style( + node, + Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, node, 0.0, 0.0, 100.0, 100.0) + taffy.set_style( + node, + Style::default() + .with_display(display_none()) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, node, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/relayout/toggle_flex_container_display_none" { + let hidden_style = Style::default() + .with_display(display_none()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let flex_style = Style::default() + .with_display(display_flex()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let taffy : ChicleTree[Unit] = ChicleTree() + let node = taffy.new_leaf(hidden_style) + let root = taffy.new_with_children(hidden_style, [node]) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, root, 0.0, 0.0, 0.0, 0.0) + taffy.set_style(root, flex_style) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, root, 0.0, 0.0, 100.0, 100.0) + taffy.set_style(root, hidden_style) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, root, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/relayout/toggle_grid_child_display_none" { + let hidden_style = Style::default() + .with_display(display_none()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let grid_style = Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let taffy : ChicleTree[Unit] = ChicleTree() + let node = taffy.new_leaf(hidden_style) + let root = taffy.new_with_children(grid_style, [node]) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, node, 0.0, 0.0, 0.0, 0.0) + taffy.set_style( + node, + Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, node, 0.0, 0.0, 100.0, 100.0) + taffy.set_style( + node, + Style::default() + .with_display(display_none()) + .with_size(Size(width=length(100.0), height=length(100.0))), + ) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, node, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/relayout/toggle_grid_container_display_none" { + let hidden_style = Style::default() + .with_display(display_none()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let grid_style = Style::default() + .with_display(display_grid()) + .with_size(Size(width=length(100.0), height=length(100.0))) + let taffy : ChicleTree[Unit] = ChicleTree() + let node = taffy.new_leaf(hidden_style) + let root = taffy.new_with_children(hidden_style, [node]) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, root, 0.0, 0.0, 0.0, 0.0) + taffy.set_style(root, grid_style) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, root, 0.0, 0.0, 100.0, 100.0) + taffy.set_style(root, hidden_style) + taffy.compute_layout(root, Size::max_content()) + misc_assert_layout_xywh(taffy, root, 0.0, 0.0, 0.0, 0.0) +} + +///| +test "upstream/relayout/relayout_is_stable_with_rounding" { + let taffy : ChicleTree[Unit] = ChicleTree() + let inner = taffy.new_leaf( + Style::default().with_min_size(Size(width=length(300.0), height=auto())), + ) + let wrapper = taffy.new_with_children( + Style::default() + .with_size(Size(width=length(150.0), height=auto())) + .with_justify_content(justify_content_end()), + [inner], + ) + let outer = taffy.new_with_children( + Style::default() + .with_size(Size(width=percent(1.0), height=auto())) + .with_inset(Rect(left=length(1.5), right=auto(), top=auto(), bottom=auto())), + [wrapper], + ) + let root = taffy.new_with_children( + Style::default().with_size( + Size(width=length(1920.0), height=length(1080.0)), + ), + [outer], + ) + taffy.mark_dirty(root) + taffy.compute_layout(root, Size::max_content()) + let root0 = taffy.layout(root) + let outer0 = taffy.layout(outer) + let wrapper0 = taffy.layout(wrapper) + let inner0 = taffy.layout(inner) + for _ in 0..<5 { + taffy.mark_dirty(root) + taffy.compute_layout(root, Size::max_content()) + let r = taffy.layout(root) + let o = taffy.layout(outer) + let w = taffy.layout(wrapper) + let i = taffy.layout(inner) + assert_eq(r.location.x, root0.location.x) + assert_eq(r.location.y, root0.location.y) + assert_eq(r.size.width, root0.size.width) + assert_eq(r.size.height, root0.size.height) + assert_eq(o.location.x, outer0.location.x) + assert_eq(o.location.y, outer0.location.y) + assert_eq(o.size.width, outer0.size.width) + assert_eq(o.size.height, outer0.size.height) + assert_eq(w.location.x, wrapper0.location.x) + assert_eq(w.location.y, wrapper0.location.y) + assert_eq(w.size.width, wrapper0.size.width) + assert_eq(w.size.height, wrapper0.size.height) + assert_eq(i.location.x, inner0.location.x) + assert_eq(i.location.y, inner0.location.y) + assert_eq(i.size.width, inner0.size.width) + assert_eq(i.size.height, inner0.size.height) + } +} + +///| +test "upstream/serde/serde_can_serialize" { + let style = Style::default() + let _ = style.to_json().stringify() +} + +///| +test "upstream/serde/serde_can_deserialize_partial_values" { + let json_str = + #|{ + #| "inset": { + #| "left": { "Length": 22 }, + #| "right": "Auto" + #| }, + #| "size": { + #| "width": { "Percent": 50 } + #| }, + #| "min_size": { + #| "height": { "Length": 10 } + #| }, + #| "max_size": { + #| "width": "Auto" + #| }, + #| "margin": { + #| "right": { "Length": 99.0 }, + #| "bottom": { "Length": 99.0 } + #| }, + #| "padding": { + #| "left": { "Length": 99.0 } + #| }, + #| "border": { + #| "bottom": { "Length": 99.0 } + #| }, + #| "gap": { + #| "width": { "Length": 99.0 } + #| }, + #| "grid_row": { "start": "Auto" }, + #| "grid_column": { "end": "Auto" } + #|} + let json = @json.parse(json_str) + let style : Style = @json.from_json(json) + match style.inset.left { + DimLength(v) => assert_eq(v, 22.0) + _ => panic() + } + match style.inset.right { + DimAuto => () + _ => panic() + } + match style.size.width { + DimPercent(v) => assert_eq(v, 50.0) + _ => panic() + } + match style.min_size.height { + DimLength(v) => assert_eq(v, 10.0) + _ => panic() + } + match style.max_size.width { + DimAuto => () + _ => panic() + } + match style.margin.right { + DimLength(v) => assert_eq(v, 99.0) + _ => panic() + } + match style.margin.bottom { + DimLength(v) => assert_eq(v, 99.0) + _ => panic() + } + match style.padding.left { + DimLength(v) => assert_eq(v, 99.0) + _ => panic() + } + match style.border.bottom { + DimLength(v) => assert_eq(v, 99.0) + _ => panic() + } + match style.gap.width { + DimLength(v) => assert_eq(v, 99.0) + _ => panic() + } + match style.grid_row.start { + PlaceAuto => () + _ => panic() + } + match style.grid_column.end { + PlaceAuto => () + _ => panic() + } +} diff --git a/docs/PORTING.md b/docs/PORTING.md index af83eae..f7e0c91 100644 --- a/docs/PORTING.md +++ b/docs/PORTING.md @@ -132,23 +132,24 @@ stays isolated. | `scene` | `scene.rs`, `bounds_tree.rs`, `AtlasTile` (platform.rs) | pure | **done** (see deviations) | | `font` | `Font`, `FontWeight`, `FontStyle`, `FontFeatures`, `FontFallbacks` (text_system.rs) | pure | **done** (descriptors only) | | `style` | `style.rs`, `styled.rs`, Refineable, gpui_macros style helpers | pure | **done** (generated by `tools/gen_style.py`) | -| `layout` | `taffy.rs` (+ a taffy port) | pure | next | +| `layout` | `taffy.rs` (engine on `Milky2018/chicle`, a taffy port) | pure | **done** (no cross-frame node cache yet) | | `keymap` | `keymap.rs`, `keymap/*`, `platform/keystroke.rs` | pure | planned | | `action` | `action.rs` | pure | planned | -| `app` | `app.rs`, `app/*`, `subscription.rs`, `global.rs`, `gpui.rs` traits | pure | planned | -| `executor` | `executor.rs`, `platform_scheduler.rs`, `scheduler` crate | pure core + platform hooks | planned | -| `element` | `element.rs`, `view.rs`, `elements/div.rs`, `interactive.rs` | pure | planned | -| `window` | `window.rs`, `key_dispatch.rs`, `tab_stop.rs` | pure (talks to platform traits) | planned | +| `app` | `app.rs`, `app/entity_map.rs`, `app/context.rs`, `subscription.rs`, `global.rs` | pure | **done** (no windows, executors or actions yet) | +| `executor` | `executor.rs`, `scheduler` crate (`executor.rs`, `test_scheduler.rs`) | pure core + `Dispatcher` platform hook | **done** (single thread) | +| `input` | mouse/window input of `interactive.rs`, `Modifiers`, `PlatformInput`, `DispatchEventResult` | pure | **done** (mouse/modifiers; keys in M5) | +| `window` | `window.rs`, `element.rs`, `view.rs`, `Style::paint`, `Application`, window handles | pure | **done** (`PlatformWindow`-backed + standalone headless; no focus/keys/caching yet) | +| `elements` | `elements/div.rs` (+ `Interactivity`), `elements/canvas.rs` | pure | **done** (`div`, `canvas`) | | `text` | `text_system.rs`, `text_system/*` | mixed: wrapping/caching pure, shaping platform | planned | -| `platform` | `platform.rs` (traits only), `interactive.rs` input types | pure (interfaces) | planned | -| `platform/test` | `platform/test/*` | pure | planned: headless platform for tests | +| `platform` | `platform.rs` (core traits, `WindowId`, `WindowOptions`, `WindowParams`, `ClipboardItem`) | pure (interfaces) | **done** (core subset; text/atlas/IME/displays later) | +| `platform/test` | `platform/test/*`, `app/test_context.rs` (`TestAppContext`, `VisualTestContext`) | pure | **done** | | `platform/web` | `gpui_web` | **js only** | planned | | `renderer/canvas2d` | (new) | **js only** | planned | | `renderer/software` | (new; optional) | pure | candidate | | `renderer/wgpu` | `gpui_wgpu` | native (+ js WebGPU) | later | | `platform/native/*` | `gpui_macos`, `gpui_linux`, `gpui_windows` | native only | later | -| `examples/*` | `examples/*` | executables | `card` (headless, prints a scene report) | -| `elements/*` | `elements/{text,img,svg,list,uniform_list,anchored,deferred,canvas,animation}.rs` | pure | later | +| `examples/*` | `examples/*` | executables | `counter` (M3–M4), `card` (headless on `TestPlatform`, prints a scene report) | +| `elements/*` | `elements/{text,img,svg,list,uniform_list,anchored,deferred,animation}.rs` | pure | later | A facade package (`experiments/gpui` re-exporting the common API, similar to GPUI's `prelude.rs`) should come once there are enough packages to make @@ -209,6 +210,7 @@ records what I verified with toolchain `moon 0.1.20261119`. | Need | Package | Backends | Notes | | --- | --- | --- | --- | | Flexbox/grid layout | `Milky2018/moon_taffy@0.5.3` | all (pure) | Port of taffy 0.5.2 (GPUI uses 0.15). **Does not compile on the current toolchain**: 32 errors in `style/style_json.mbt` from the new explicit trait-method `extend` rule. Needs an upstream fix or a vendored patch. | +| Flexbox/grid layout (used) | `Milky2018/chicle@0.6.3` | all (pure) | Successor of `moon_taffy` from the same upstream repository; builds on the current toolchain. **All 1,038 of `moon_taffy`'s taffy fixtures pass against it on all four backends** (`conformance/chicle`). | | Flexbox (alt.) | `NoahLiu/yoga-mbt@0.1.1` | pure | Yoga-style flexbox only, with no grid. | | Text shaping/layout | `Milky2018/moon_cosmic@0.3.9` | all (pure) | Port of cosmic-text on `moon_swash`, `moon_skrifa`, and `moon_zeno`. **Checks on js and native.** It is what `gpui_web`/`gpui_wgpu` use upstream (cosmic-text), so it fits well. | | Font parsing | `Milky2018/moon_skrifa`, `mizchi/font`, `bikallem/freetype` | pure | | @@ -217,11 +219,11 @@ records what I verified with toolchain `moon 0.1.20261119`. | Browser APIs | `mizchi/js_browser@0.13.0` (MIT), `dijdzv/websys`, `peter-jerry-ye/canvas` | **js only** | DOM, Canvas2D, events, and rAF. | | WebGPU | `Milky2018/wgpu_mbt@0.16.2` | **native only** | wgpu-native C API bindings; macOS is supported, Linux and Windows are experimental. `tonyfettes/webgpu` and `emadurandal/rhodonite_webgpu` cover browser WebGPU. | | Windowing | `Milky2018/window@0.6.2` (winit port, **native, macOS only**), `mizchi/glfw`, `klaseca/sdl`, `laplaceliu/tycho_window` (Xlib) | native only | | -| Async | `moonbitlang/async@0.22.10` | **native** (some wasm) | Not usable on js. Core has a `moonbitlang/core/async` package; its js story needs checking before the executor milestone. | +| Async | `moonbitlang/async@0.22.10`, `moonbitlang/core/async` | native, wasm; js partly; **not wasm-gc** | Not used. Both own the event loop (`async fn main`, task groups), which conflicts with a platform-driven executor, and neither supports wasm-gc. `executor` uses the same compiler intrinsics (`%async.suspend`/`%async.run`) directly; see M4. | | Taffy-free layout ref | `Frank-III/onebit-tui` | native | Uses Yoga through FFI. Not useful here. | Recommendation: depend on `moon_cosmic` for text when that milestone -arrives. For layout, **fork/vendor `moon_taffy`** (Apache-2.0) and fix it for +arrives. For layout, the original plan was to **fork/vendor `moon_taffy`** (Apache-2.0) and fix it for the toolchain, or send the fix upstream. Writing flexbox from scratch would be the costlier path. @@ -342,24 +344,34 @@ gantt `rounded_md`, `shadow_lg`, ...). - Tests: refinement cascade semantics, and helper values matching GPUI's (for example `p_2 == rems(0.5)`). -- **M2: layout.** - - Vendor and fix `moon_taffy`, or port the taffy flexbox, block, and grid - algorithms needed. +- **M2: layout (done).** + - Depends on `Milky2018/chicle` (see decision 3). - `LayoutEngine` with `request_layout`, `request_measured_layout`, - `compute_layout`, and `layout_bounds`, plus `Style` → taffy conversion - with rem and scale resolution. - - Tests: a corpus of flexbox cases (taffy's generated tests). -- **M3: app model.** - - `App`, `Entity[T]`/`WeakEntity[T]`, and `Context[T]`. - - `notify`, `observe`, `subscribe`/`emit` with typed event keys, globals, - and observers. - - The effect queue and `flush_effects` semantics: deferral, and dedup of - notifications. - - Tests ported from GPUI's `app` tests. -- **M4: executor.** - - Foreground executor, timers, and `Task[T]` (cancel and detach). - - `TestScheduler` with a virtual clock and `run_until_parked`. - - `spawn` from `Context`. + `compute_layout`, `layout_bounds`, and `stretch_auto_size_to_fill`. + - `Style` → engine conversion with rem resolution and device-pixel + snapping. + - Tests: GPUI's rounding and stroke-snapping tests, plus layout + scenarios. The engine is checked separately by the 1,038-fixture + conformance suite in `conformance/chicle`. +- **M3: app model (done).** + - `App`, `Entity[T]`/`WeakEntity[T]`/`Reservation[T]`, and `Context[T]`. + - `notify`, `observe`, `subscribe`/`emit` with typed `EventKey`s, + globals with `GlobalKey`s, release listeners, and `defer_call`. + - The effect queue and `flush_effects` semantics: deferred activation of + new subscriptions, dedup of notifications, and cascading effects. + - Tests: GPUI's subscription tests are ported, plus app-model tests, + including the aborts expected on misuse. + - `src/examples/counter` shows the model end to end. +- **M4: executor (done).** + - `Executor` (spawn, timer, sleep, yield_now, now), and `Task[T]` (wait, + cancel with unwinding, try_result, ready, detach). + - A `Dispatcher` trait as the platform hook, plus `TestDispatcher`, a + deterministic dispatcher with a virtual clock (`tick`, + `run_until_parked`, `advance_clock`, with GPUI's timer semantics). + - `AsyncApp`, `App::spawn`, `Context::spawn` (weak entity), and the + app's `foreground_executor`/`background_executor`. + - `App::new()` uses its own `TestDispatcher` (like GPUI's + `TestAppContext`); a platform passes its own dispatcher. - **M5: input model.** - `Keystroke::parse`, `Modifiers`. - `KeyContext` and the predicate parser and evaluator. @@ -367,18 +379,49 @@ gantt multi-stroke matching. - `ActionRegistry`. - Tests ported from `keymap.rs` and `keymap/context.rs`. -- **M6: elements and window.** - - `Element`/`AnyElement`/`IntoElement`/`ParentElement`, `Render`, and - views. - - `div` with styles, hover and active styles, mouse listeners, and - scrolling. - - `Window::draw` (request_layout → prepaint → paint), element ids and - state, hitboxes, the content-mask stack, and the dispatch tree. - - Tests: build a tree, draw against the test platform, assert on the - Scene. -- **M7: test platform.** A headless `Platform`/`PlatformWindow` that records - scenes and injects input events, mirroring GPUI's `TestPlatform` and - `VisualTestContext`. This is the base for most later tests. +- **M6: elements and window (done).** + - `Element`/`AnyElement`/`IntoElement`, `Render`, `AnyView`, views as + elements, `listener`, and `empty`. + - `Window`: + - `draw` (render, then layout to fill the viewport, prepaint, paint, + `Scene::finish`) with phase checks, and `draw_if_dirty`. + - The content-mask, element-offset, opacity, and element-id stacks. + - Element state across frames (`ElementStateKey`), hitboxes and hit + testing, occlusion, and mouse dispatch (capture and bubble, + `stop_propagation`). + - Hover-driven and notify-driven invalidation, with only rendered views + invalidating the window, plus `resize`. + - Painting: `paint_quad` with device-pixel snapping, drop and inset + shadows, `paint_path`, and `paint_style` (a port of `Style::paint`). + - `div()`: + - Styles through the generated `Styled` list, plus children and hover + styles. + - Mouse down, up, move and scroll listeners, and clicks (with element + state). + - `occlude`, overflow clipping, and opacity. + - `canvas()`. + - Tests: end-to-end views to scene, clicks, hover, invalidation, nested + views, bubbling, occlusion, shadows and borders, clipping, canvas, + resize, and the aborts expected on misuse. +- **M7: test platform (done).** + - `input`: `MouseExitEvent`, `ModifiersChangedEvent`, `PlatformInput`, and + `DispatchEventResult`. + - `platform`: core `Platform` and `PlatformWindow` traits plus `WindowId`, + `WindowBounds`, `WindowOptions`, `WindowParams`, and `ClipboardItem` + (text subset). + - `window`: `Application`, `AnyWindowHandle`, `WindowHandle[V]`, + `Window::dispatch_input`, `prevent_default`, close/activation hooks, + `replace_root_view`, and `PlatformWindow` callback/frame wiring (keeping + standalone `Window::new`). Closing a window releases its root view. + - `platform/test`: `TestPlatform` and `TestWindow` (recording presented + `Scene`s and simulating frames, input, resize, scale factor, active/hover + status, and close requests), plus `TestAppContext` and `VisualTestContext` + which pump tasks and scheduled frames together with a runaway-redraw + guard. + - Tests: platform types, `TestPlatform`/`TestWindow`/`TestAppContext` unit + tests, `elements` visual integration tests (`VisualTestContext`), panic + tests on closed-window misuse and runaway redraws, and `src/examples/card` + updated to run on `TestPlatform`/`VisualTestContext`. - **M8: web platform + Canvas2D renderer (first pixels).** - A `` window, rAF-driven frames, resize, and DPR. - DOM pointer, wheel, and key events → `PlatformInput`. @@ -430,7 +473,7 @@ gantt `Style::refined` returns a new style. Only `StyleRefinement` (what `Styled::style()` returns) is mutable, because it is the builder. Nested updates are written as `style.text = { ..style.text, color: ... }`. -- `Styled` is one trait with 3,213 methods: about 140 hand-written in +- `Styled` is one trait with 3,213 methods: 132 hand-written in `src/style/styled.mbt`, the rest generated as GPUI's macros would generate them. GPUI's `text_style()` accessor (`&mut TextStyleRefinement`) is omitted. @@ -444,6 +487,130 @@ gantt - The refinement `Cascade` and `Style::paint` (which needs `Window`) wait for M6. The conversion to taffy styles waits for M2. +### Deviations taken in M2 (layout) +- There is no cross-frame node cache yet. GPUI reuses taffy nodes keyed by + element path, and reuses measure closures by key. That cache depends on + element ids from the Window, so it comes in M6. Until then the engine is + rebuilt on `clear()`, as older GPUI versions did. +- `compute_layout` takes the scale factor instead of `&mut Window`. +- Measure functions are `(known, available) -> Size[Pixels]` closures. They + do not receive GPUI's `final_layout` flag, because chicle's measure + callback does not report the run mode. +- The engine keeps its own parent/child maps, because chicle has no + `parent`/`children` queries. Misuse fails loudly: an unknown or stale + `LayoutId`, or a child given two parents, aborts. + +### Deviations taken in M3 (app model) +- **Type keys replace `TypeId`.** Events and globals are identified by + `EventKey[E]` and `GlobalKey[G]` values, created once per type (usually a + top-level `let`). The app stores values under the key's id as closures + that write into the key's typed slot. Reading one back through the same + key is type-safe and needs no downcast. + - `EventEmitter` (a compile-time check that `T` may emit `E`) has no + equivalent: any entity may emit any `EventKey`. +- **Entities are not reference counted.** A handle points at a typed cell. + `App::release(entity)` plays the role of the last handle being dropped: + - Weak handles stop upgrading at once. + - At the next flush, observers and subscriptions are removed and release + listeners run. + - Double release is a no-op. + - Use after release, re-entrant updates, reads during an update, and using + an entity with another `App` all abort, as GPUI panics. +- **Subscriptions do not end when dropped.** A `Subscription` stays active + until `unsubscribe()` is called, or until the entity it belongs to is + released. GPUI unsubscribes on drop; `detach()` is kept for parity. +- **Entity state is passed by reference.** Update callbacks receive the + state; entity types should be structs with `mut` fields (GPUI's `&mut T`). +- **Renames.** + - Entity creation is `App::new_entity`, because `App::new` creates the app. + - `cx.defer` is `defer_call`, because `defer` is a MoonBit keyword. + - `Context` does not deref to `App`; use `cx.app`. +- **Top-level `App` methods open an update.** Methods such as `notify`, + `set_global`, `release` and `defer_call` flush their effects when called + outside an update. + - `global_mut` and `default_global` return the global to be mutated, so + they must be called inside `App::update`; outside one they abort. +- **Not yet ported:** + - `observe_new` (needs a per-type key for entities). + - Accessed-entity tracking and window invalidation (M6). + - `spawn` and `AsyncApp` (M4). + - Actions (M5). + - Leak detection. + +### Deviations taken in M4 (executor) +- **Coroutines come from MoonBit's experimental async intrinsics.** + `%async.suspend`, `%async.run`, `%async.capture_cancellation`, and + `%async.raise_cancellation_signal` are scheduled by our own `Dispatcher`. + This is what `moonbitlang/core/async` is built on, minus its event loop. + It works on all four backends, including wasm-gc. + - The package must set `experimental: true`, and packages importing it + need `"allow-experimental-packages": true`. + - Risk: the intrinsics may change with the toolchain. They are wrapped in + `src/executor/coroutine.mbt`. +- **One thread.** Background and foreground executors are the same executor + on the main thread, as in GPUI's single-threaded web backend. There are no + priorities, dedicated threads, `block_on`, or `scoped`. +- **Tasks are not cancelled on drop.** A GPUI `Task` cancels its future when + dropped. Here a task runs to completion unless `cancel()` is called. + - Cancellation resumes the task with a cancellation signal at its next + suspension point, running its `defer` blocks. + - Waiters get `TaskCancelled`; errors raised by a task are re-raised by + `wait`. +- **Durations are integer milliseconds.** `now()` returns `Int64` + milliseconds. +- **The test dispatcher is FIFO and deterministic.** GPUI's `TestScheduler` + can randomize the interleaving of sessions with a seed. That is not ported. + There is also no parking detection. +- **`AsyncApp` methods return values, not `Result`s.** An app is never + dropped while a task references it. + +### Deviations taken in M6 (elements and window) +- **Element state lives in the element.** `Element` has no associated state + types. Elements keep per-frame state in their own fields and are rebuilt + every frame. `render` returns `AnyElement`. +- **Element ids are strings, and state is keyed by `ElementStateKey[S]`** + (the same key pattern as globals). `Div::id` makes a div stateful, and + `on_click` aborts without an id. There is no separate `Stateful
` type. +- **Hover styles apply at paint time only.** Hovering cannot change layout. + Any change in the hovered hitboxes marks the window dirty, not only for + elements with hover styles. +- **The window is headless.** It is created directly with a viewport size, + scale factor, and rem size, and `draw` returns the `Scene`. There is no + platform window or frame scheduling yet (M7/M8). +- **Invalidation without accessed-entity tracking.** A window re-renders when + a view it rendered in the last frame is notified, through + `App::observe_notifications`. There is no view caching or `Scene::replay` + reuse yet; every frame renders everything. +- **Quads are not split.** GPUI splits bordered quads into a fill and border + strips; that renderer optimization is not ported. +- **Not yet ported:** + - Focus and the key dispatch tree (M5/M10). + - Active and group styles. + - Drag and drop, tooltips, scroll state, and deferred draws. + - Text (M9). + +### Deviations taken in M7 (test platform) +- **Core platform subset.** `Platform` and `PlatformWindow` include window + lifecycle, frame scheduling/drawing, input/resize/focus/hover callbacks, + executor dispatcher, cursor style, clipboard, and `open_url`. Text + system, glyph atlas, IME, displays, menus, and screen capture come in + later milestones. +- **Explicit `PlatformWindow::close`.** MoonBit has no `Drop`, so + app-driven window teardown calls `PlatformWindow::close` explicitly (without + re-invoking `on_close`). Closing a `Window` releases its root view + (Design Decision 1). +- **`TestWindow` defaults to `scale_factor = 1.0`.** Matches M6's + `Window::new` (GPUI historically defaults to `2.0`), configurable via + `TestPlatform::new(default_scale_factor=...)` or `WindowOptions`. +- **`Application` lives in `window`.** `Application` owns the `App`, + `Platform`, and open windows so `app` stays independent of `platform`, + `scene`, and `style`; `application_for(app)` looks it up via a private + `GlobalKey`. +- **Automatic frame pumping in tests.** `TestAppContext::run_until_parked()` + alternates draining ready tasks on `TestDispatcher` with pumping scheduled + frames, aborting after 100 consecutive redraws to catch runaway redraw + loops. + ## 7. Design decisions Decided on 2026-11-24, following the recommendations below. @@ -454,8 +621,12 @@ Decided on 2026-11-24, following the recommendations below. 2. **Text shaping on the web.** Shape with `moon_cosmic`, which is pure, the same on every backend, and matches upstream `gpui_web`, using bundled fonts. Canvas text is used only as an emoji/CJK fallback, as upstream does. -3. **Layout engine.** Vendor `moon_taffy`, fix it for the current toolchain, - and send the fixes upstream. +3. **Layout engine.** The decision was to vendor `moon_taffy`, fix it, and + upstream the fixes. Revised in M2: upstream had already moved on and + published the fixed successor `Milky2018/chicle` 0.6.3. We depend on it + instead of forking. `moon_taffy`'s 1,038 taffy fixtures, which chicle no + longer ships, all pass against it. They are kept in `conformance/chicle` + and must be rerun before any chicle upgrade. 4. **First renderer.** Canvas2D on js first, then WebGPU reusing GPUI's WGSL shaders. 5. **API surface naming.** Keep GPUI names verbatim (`div()`, `px()`, @@ -477,4 +648,21 @@ Decided on 2026-11-24, following the recommendations below. Always run `python3 tools/gen_style.py && moon fmt` together. - A value converts implicitly to a trait object (`&IntoLength`) at a call site. That is how GPUI's `impl Into` parameters are expressed. +- `defer` is a keyword (GPUI's `cx.defer` became `defer_call`). +- Closures are not allowed to raise implicitly: `assert_*` cannot be called + inside a callback in a test. Record values and assert afterwards. A test + whose name starts with `panic` passes only if it aborts; use this to test + the fail-loudly paths. +- `test` is a keyword, so a binding cannot be named `test`. Trait-object + coercion does not reach inside tuples: build `(&Trait, ...)` values + separately. +- Async code: `async fn` bodies that never suspend get an "unused async" + warning; a plain `fn` closure is accepted where an `async` one is + expected. Closures that raise must say so (`fn() raise { ... }`). +- `Ref(x)` builds a `Ref`; `{ val: x }` needs a type annotation. - Test-only imports go in `import { ... } for "test"` in `moon.pkg`. +- Package import aliases in `moon.pkg` write `"path/to/pkg" @alias,` (without + `as`). +- Tuple destructuring cannot annotate element types inside the pattern + (`let (a : T, b)`); annotate the whole tuple or bind afterwards + (`let a : T = a`). diff --git a/moon.mod b/moon.mod index a8ca10a..37e9207 100644 --- a/moon.mod +++ b/moon.mod @@ -16,3 +16,7 @@ description = "A MoonBit port of GPUI, Zed's GPU-accelerated UI framework" source = "src" preferred_target = "js" + +import { + "Milky2018/chicle@0.6.3", +} diff --git a/src/app/app.mbt b/src/app/app.mbt new file mode 100644 index 0000000..0071ec5 --- /dev/null +++ b/src/app/app.mbt @@ -0,0 +1,521 @@ +// The application state and effect cycle, ported from gpui/src/app.rs. +// +// All state lives in entities owned by the `App`. Updates run inside +// `App::update`; side effects (notifications, events, global changes, +// deferred callbacks, releases) are queued and flushed when the outermost +// update returns, exactly like GPUI's `flush_effects`. +// +// Not ported yet: windows and view invalidation (M6), executors and `spawn` +// (M4), actions and keymaps (M5), `observe_new` (needs a per-type key for +// entities), and the platform services. + +///| +let next_app_id : Ref[Int32] = { val: 0, } + +///| +priv enum Effect { + Notify(EntityId) + Emit(emitter~ : EntityId, event_key~ : Int32, payload~ : () -> Unit) + NotifyGlobalObservers(Int32) + Defer((App) -> Unit) +} + +///| +/// A typed event listener stored without its type: `handler` reads the +/// payload back through the listener's own `EventKey`. +priv struct EventListener { + event_key : Int32 + handler : (() -> Unit, App) -> Bool +} + +///| +priv struct EntityRecord { + /// Drops the state once release listeners have run. + free : () -> Unit +} + +///| +/// The application: owner of all entities and globals (GPUI: `App`). +pub struct App { + priv id : Int32 + priv mut next_entity_id : Int32 + priv entities : Map[EntityId, EntityRecord] + priv mut pending_updates : Int32 + priv mut flushing_effects : Bool + priv pending_effects : @deque.Deque[Effect] + priv pending_notifications : @hashset.HashSet[EntityId] + priv pending_global_notifications : @hashset.HashSet[Int32] + priv dropped_entities : Array[EntityId] + priv observers : SubscriberSet[EntityId, (App) -> Bool] + priv event_listeners : SubscriberSet[EntityId, EventListener] + priv release_listeners : SubscriberSet[EntityId, (App) -> Unit] + priv global_observers : SubscriberSet[Int32, (App) -> Bool] + priv globals : Map[Int32, () -> Unit] + /// Called synchronously by `notify` (windows invalidate views with it). + priv notify_hooks : SubscriberSet[Unit, (EntityId) -> Unit] + priv executor : @executor.Executor + /// Set when the app drives its own deterministic dispatcher (tests). + priv test_dispatcher : @executor.TestDispatcher? +} + +///| +/// A new, empty application. GPUI creates its `App` through `Application` +/// with a platform; there is no platform layer yet (M7/M8). +/// +/// Async work runs on `dispatcher`. Without one, the app gets a +/// deterministic `TestDispatcher` that runs nothing until driven with +/// `run_until_parked` or `advance_clock` (like GPUI's `TestAppContext`). +pub fn App::new(dispatcher? : &@executor.Dispatcher) -> App { + let id = next_app_id.val + next_app_id.val = id + 1 + let test_dispatcher = match dispatcher { + Some(_) => None + None => Some(@executor.TestDispatcher::new()) + } + let executor = match (dispatcher, test_dispatcher) { + (Some(dispatcher), _) => @executor.Executor::new(dispatcher) + (None, Some(own)) => @executor.Executor::new(own) + (None, None) => abort("unreachable") + } + { + executor, + test_dispatcher, + id, + next_entity_id: 1, + entities: {}, + pending_updates: 0, + flushing_effects: false, + pending_effects: @deque.Deque([]), + pending_notifications: @hashset.HashSet([]), + pending_global_notifications: @hashset.HashSet([]), + dropped_entities: [], + observers: SubscriberSet::new(), + event_listeners: SubscriberSet::new(), + release_listeners: SubscriberSet::new(), + global_observers: SubscriberSet::new(), + globals: {}, + notify_hooks: SubscriberSet::new(), + } +} + +///| +/// Runs `f`; queued effects are flushed when the outermost update returns. +pub fn[R] App::update(self : App, f : (App) -> R) -> R { + self.pending_updates = self.pending_updates + 1 + let result = f(self) + if self.pending_updates == 1 && !self.flushing_effects { + self.flush_effects() + } + self.pending_updates = self.pending_updates - 1 + result +} + +///| +fn App::push_effect(self : App, effect : Effect) -> Unit { + match effect { + Notify(emitter) => + if !self.pending_notifications.add_and_check(emitter) { + return + } + NotifyGlobalObservers(key) => + if !self.pending_global_notifications.add_and_check(key) { + return + } + _ => () + } + self.pending_effects.push_back(effect) +} + +///| +/// Applies queued effects until none remain (GPUI: `flush_effects`). +fn App::flush_effects(self : App) -> Unit { + self.flushing_effects = true + while true { + self.release_dropped_entities() + match self.pending_effects.pop_front() { + Some(Notify(emitter)) => { + self.pending_notifications.remove(emitter) + self.observers.retain(emitter, fn(handler) { handler(self) }) + } + Some(Emit(emitter~, event_key~, payload~)) => + self.event_listeners.retain(emitter, fn(listener) { + if listener.event_key == event_key { + (listener.handler)(payload, self) + } else { + true + } + }) + Some(NotifyGlobalObservers(key)) => { + self.pending_global_notifications.remove(key) + self.global_observers.retain(key, fn(observer) { observer(self) }) + } + Some(Defer(callback)) => callback(self) + None => if self.dropped_entities.is_empty() { break } + } + } + self.flushing_effects = false +} + +///| +/// Removes released entities' observers and subscriptions, then runs their +/// release listeners (GPUI: `release_dropped_entities`). +fn App::release_dropped_entities(self : App) -> Unit { + while !self.dropped_entities.is_empty() { + let dropped = self.dropped_entities.copy() + self.dropped_entities.clear() + for entity_id in dropped { + ignore(self.observers.remove(entity_id)) + ignore(self.event_listeners.remove(entity_id)) + for callback in self.release_listeners.remove(entity_id) { + callback(self) + } + if self.entities.get(entity_id) is Some(record) { + (record.free)() + self.entities.remove(entity_id) + } + } + } +} + +///| +/// Queues `f` to run after the current effects (GPUI: `App::defer`; +/// renamed because `defer` is a MoonBit keyword). +pub fn App::defer_call(self : App, f : (App) -> Unit) -> Unit { + self.update(fn(app) { app.push_effect(Defer(f)) }) +} + +// --------------------------------------------------------------------------- +// Entities +// --------------------------------------------------------------------------- + +///| +/// Hands out an id for an entity whose state is created later with +/// `insert_entity` (GPUI: `reserve_entity`). +pub fn[T] App::reserve_entity(self : App) -> Reservation[T] { + let id = EntityId(self.next_entity_id) + self.next_entity_id = self.next_entity_id + 1 + { + cell: { app_id: self.id, id, value: None, leased: false, released: false, }, + } +} + +///| +/// Builds the state of a reserved entity (GPUI: `insert_entity`). +pub fn[T] App::insert_entity( + self : App, + reservation : Reservation[T], + build : (Context[T]) -> T, +) -> Entity[T] { + let cell = reservation.cell + cell.check_app(self, "insert") + guard cell.value is None && !self.entities.contains(cell.id) else { + abort("cannot insert \{cell.id}: the reservation was already used") + } + self.update(fn(app) { + let value = build({ app, weak: { cell, }, }) + cell.value = Some(value) + app.entities[cell.id] = { free: fn() { cell.value = None }, } + { cell, } + }) +} + +///| +/// Creates an entity whose state is built by `build` (GPUI: `App::new`; +/// renamed because `App::new` is the app's constructor here). +pub fn[T] App::new_entity(self : App, build : (Context[T]) -> T) -> Entity[T] { + self.insert_entity(self.reserve_entity(), build) +} + +///| +/// Updates an entity's state; effects flush afterwards +/// (GPUI: `update_entity`). Fails loudly if the entity is already being +/// updated or has been released. +pub fn[T, R] App::update_entity( + self : App, + entity : Entity[T], + f : (T, Context[T]) -> R, +) -> R { + let cell = entity.cell + cell.check_app(self, "update") + self.update(fn(app) { + let value = cell.lease("update") + let result = f(value, { app, weak: { cell, }, }) + cell.end_lease() + result + }) +} + +///| +/// Reads an entity's state (GPUI: `read_entity`). The state must not be +/// mutated through the returned value. +pub fn[T] App::read_entity(self : App, entity : Entity[T]) -> T { + entity.cell.check_app(self, "read") + entity.cell.read() +} + +///| +/// Releases an entity: its observers and subscriptions are removed and its +/// release listeners run during the next effect flush. Weak handles stop +/// upgrading immediately. Releasing twice is a no-op. +pub fn[T] App::release(self : App, entity : Entity[T]) -> Unit { + let cell = entity.cell + cell.check_app(self, "release") + guard !cell.released else { return } + guard !cell.leased else { + abort("cannot release \{cell.id} while it is being updated") + } + cell.released = true + self.update(fn(app) { app.dropped_entities.push(cell.id) }) +} + +///| +/// Number of live (inserted, not yet released) entities. +pub fn App::entity_count(self : App) -> Int32 { + self.entities.length() +} + +///| +/// Marks an entity as changed: its observers run during the next flush +/// (GPUI: `App::notify`). Repeated notifications before the flush coalesce. +/// Notification hooks (windows rendering the entity) run immediately. +pub fn App::notify(self : App, entity_id : EntityId) -> Unit { + self.notify_hooks.retain((), fn(hook) { + hook(entity_id) + true + }) + self.update(fn(app) { app.push_effect(Notify(entity_id)) }) +} + +///| +/// Calls `hook` synchronously whenever any entity is notified. Used by +/// windows to invalidate the views they rendered (GPUI keeps per-window +/// invalidators for this). +pub fn App::observe_notifications( + self : App, + hook : (EntityId) -> Unit, +) -> Subscription { + self.notify_hooks.insert((), hook) +} + +///| +fn[T] App::emit_event( + self : App, + emitter : EntityId, + key : EventKey[T], + event : T, +) -> Unit { + self.update(fn(app) { + app.push_effect(Emit(emitter~, event_key=key.id, payload=key.erase(event))) + }) +} + +///| +fn App::new_observer( + self : App, + entity_id : EntityId, + handler : (App) -> Bool, +) -> Subscription { + let (subscription, activate) = self.observers.insert_pending( + entity_id, handler, + ) + // New observers start after the effects already queued (GPUI semantics). + self.defer_call(fn(_) { activate() }) + subscription +} + +///| +fn[T] App::observe_internal( + self : App, + entity : Entity[T], + on_notify : (Entity[T], App) -> Bool, +) -> Subscription { + let weak = entity.downgrade() + self.new_observer(entity.entity_id(), fn(app) { + match weak.upgrade() { + Some(entity) => on_notify(entity, app) + None => false + } + }) +} + +///| +/// Calls `on_notify` whenever `entity` is notified. +pub fn[T] App::observe( + self : App, + entity : Entity[T], + on_notify : (Entity[T], App) -> Unit, +) -> Subscription { + self.observe_internal(entity, fn(entity, app) { + on_notify(entity, app) + true + }) +} + +///| +fn[T, E] App::subscribe_internal( + self : App, + entity : Entity[T], + key : EventKey[E], + on_event : (Entity[T], E, App) -> Bool, +) -> Subscription { + let weak = entity.downgrade() + let listener : EventListener = { + event_key: key.id, + handler: fn(payload, app) { + let event = key.unerase(payload) + match weak.upgrade() { + Some(entity) => on_event(entity, event, app) + None => false + } + }, + } + let (subscription, activate) = self.event_listeners.insert_pending( + entity.entity_id(), + listener, + ) + self.defer_call(fn(_) { activate() }) + subscription +} + +///| +/// Calls `on_event` for every event of kind `key` that `entity` emits. +pub fn[T, E] App::subscribe( + self : App, + entity : Entity[T], + key : EventKey[E], + on_event : (Entity[T], E, App) -> Unit, +) -> Subscription { + self.subscribe_internal(entity, key, fn(entity, event, app) { + on_event(entity, event, app) + true + }) +} + +///| +/// Calls `on_release` with the entity's state when it is released +/// (GPUI: `observe_release`). +pub fn[T] App::observe_release( + self : App, + entity : Entity[T], + on_release : (T, App) -> Unit, +) -> Subscription { + let cell = entity.cell + self.release_listeners.insert(cell.id, fn(app) { + guard cell.value is Some(value) else { return } + on_release(value, app) + }) +} + +// --------------------------------------------------------------------------- +// Globals +// --------------------------------------------------------------------------- + +///| +pub fn[G] App::has_global(self : App, key : GlobalKey[G]) -> Bool { + self.globals.contains(key.id) +} + +///| +/// The global for `key`; fails loudly if it is not set (GPUI: `global`). +pub fn[G] App::global(self : App, key : GlobalKey[G]) -> G { + match self.globals.get(key.id) { + Some(erased) => key.unerase(erased) + None => abort("no global of type \{key.name} exists") + } +} + +///| +pub fn[G] App::try_global(self : App, key : GlobalKey[G]) -> G? { + match self.globals.get(key.id) { + Some(erased) => Some(key.unerase(erased)) + None => None + } +} + +///| +/// The global for `key`, to be mutated by the caller; its observers run when +/// the enclosing update finishes (GPUI: `global_mut`). Must be called inside +/// `App::update` (or an entity update), so that the mutation happens before +/// observers run; fails loudly otherwise. +pub fn[G] App::global_mut(self : App, key : GlobalKey[G]) -> G { + guard self.pending_updates > 0 else { + abort( + "global_mut(\{key.name}) must be called inside App::update; use update_global or set_global outside", + ) + } + let value = self.global(key) + self.push_effect(NotifyGlobalObservers(key.id)) + value +} + +///| +/// The global for `key`, created with `init` if missing (GPUI: +/// `default_global`). Like `global_mut`, must be called inside an update. +pub fn[G] App::default_global( + self : App, + key : GlobalKey[G], + init : () -> G, +) -> G { + if !self.has_global(key) { + self.globals[key.id] = key.erase(init()) + } + self.global_mut(key) +} + +///| +/// Sets the global for `key` and notifies its observers. +pub fn[G] App::set_global(self : App, key : GlobalKey[G], value : G) -> Unit { + self.update(fn(app) { + app.push_effect(NotifyGlobalObservers(key.id)) + app.globals[key.id] = key.erase(value) + }) +} + +///| +/// Removes and returns the global for `key`; fails loudly if missing. +pub fn[G] App::remove_global(self : App, key : GlobalKey[G]) -> G { + let value = self.global(key) + self.update(fn(app) { + app.push_effect(NotifyGlobalObservers(key.id)) + app.globals.remove(key.id) + }) + value +} + +///| +/// Updates the global for `key` (GPUI: `update_global`). The global is +/// leased: reading it inside `f` fails loudly, as in GPUI. +pub fn[G, R] App::update_global( + self : App, + key : GlobalKey[G], + f : (G, App) -> R, +) -> R { + self.update(fn(app) { + guard app.globals.get(key.id) is Some(erased) else { + abort("no global of type \{key.name} exists") + } + let value = key.unerase(erased) + app.globals.remove(key.id) + let result = f(value, app) + app.globals[key.id] = key.erase(value) + app.push_effect(NotifyGlobalObservers(key.id)) + result + }) +} + +///| +/// Calls `f` whenever the global for `key` changes. +pub fn[G] App::observe_global( + self : App, + key : GlobalKey[G], + f : (App) -> Unit, +) -> Subscription { + let (subscription, activate) = self.global_observers.insert_pending(key.id, fn( + app, + ) { + f(app) + true + }) + self.defer_call(fn(_) { activate() }) + subscription +} diff --git a/src/app/app_test.mbt b/src/app/app_test.mbt new file mode 100644 index 0000000..819683b --- /dev/null +++ b/src/app/app_test.mbt @@ -0,0 +1,461 @@ +///| +struct Counter { + mut count : Int32 +} + +///| +struct Log { + entries : Array[String] +} + +///| +let changed : @app.EventKey[Int32] = @app.EventKey::new("Changed") + +///| +let renamed : @app.EventKey[String] = @app.EventKey::new("Renamed") + +///| +struct Settings { + mut theme : String +} + +///| +let settings_key : @app.GlobalKey[Settings] = @app.GlobalKey::new("Settings") + +///| +let marker_key : @app.GlobalKey[Int32] = @app.GlobalKey::new("Marker") + +///| +fn new_counter(app : @app.App, count~ : Int32 = 0) -> @app.Entity[Counter] { + app.new_entity(fn(_) { { count, } }) +} + +///| +test "entities are created, read and updated" { + let app = @app.App::new() + let counter = new_counter(app, count=1) + assert_eq(counter.read(app).count, 1) + let context_ok = Ref(false) + let result = counter.update(app, fn(state, cx) { + state.count += 1 + context_ok.val = cx.entity_id() == counter.entity_id() && + cx.entity() == counter + state.count * 10 + }) + assert_eq(result, 20) + assert_true(context_ok.val) + assert_eq(app.read_entity(counter).count, 2) + assert_eq(app.entity_count(), 1) + let other = new_counter(app) + assert_not_eq(other.entity_id(), counter.entity_id()) + assert_false(other == counter) +} + +///| +test "reserve then insert" { + let app = @app.App::new() + let reservation : @app.Reservation[Counter] = app.reserve_entity() + let id = reservation.entity_id() + let seen_id : Ref[@app.EntityId?] = Ref(None) + let entity = app.insert_entity(reservation, fn(cx) { + seen_id.val = Some(cx.entity_id()) + { count: 7, } + }) + assert_eq(seen_id.val, Some(id)) + assert_eq(entity.entity_id(), id) + assert_eq(entity.read(app).count, 7) +} + +///| +test "observers run after the update and notifications coalesce" { + let app = @app.App::new() + let counter = new_counter(app) + let seen = [] + let during = Ref(-1) + let subscription = app.observe(counter, fn(entity, app) { + seen.push(entity.read(app).count) + }) + counter.update(app, fn(state, cx) { + state.count = 1 + cx.notify() + state.count = 2 + cx.notify() + // Nothing runs until the outermost update returns. + during.val = seen.length() + }) + assert_eq(during.val, 0) + assert_eq(seen, [2]) + subscription.unsubscribe() + counter.update(app, fn(_, cx) { cx.notify() }) + assert_eq(seen, [2]) +} + +///| +test "nested updates flush once at the end" { + let app = @app.App::new() + let counter = new_counter(app) + let seen = [] + app.observe(counter, fn(_, _) { seen.push("notified") }).detach() + let during = Ref(-1) + app.update(fn(app) { + counter.update(app, fn(_, cx) { cx.notify() }) + during.val = seen.length() + counter.update(app, fn(_, cx) { cx.notify() }) + }) + assert_eq(during.val, 0) + assert_eq(seen, ["notified"]) +} + +///| +test "observers registered during an update see effects queued after them" { + let app = @app.App::new() + let counter = new_counter(app) + let seen = [] + app.update(fn(app) { + // Notified before the observer exists: not delivered to it. + app.notify(counter.entity_id()) + app.observe(counter, fn(_, _) { seen.push("first") }).detach() + }) + assert_eq(seen, []) + app.update(fn(app) { + app.observe(counter, fn(_, _) { seen.push("second") }).detach() + // Queued after the observer's activation: delivered. + app.notify(counter.entity_id()) + }) + assert_eq(seen, ["first", "second"]) +} + +///| +test "events are delivered by kind" { + let app = @app.App::new() + let counter = new_counter(app) + let ints = [] + let strings = [] + app.subscribe(counter, changed, fn(_, value, _) { ints.push(value) }).detach() + app + .subscribe(counter, renamed, fn(_, value, _) { strings.push(value) }) + .detach() + counter.update(app, fn(state, cx) { + state.count = 5 + cx.emit(changed, state.count) + cx.emit(renamed, "five") + cx.emit(changed, 6) + }) + assert_eq(ints, [5, 6]) + assert_eq(strings, ["five"]) +} + +///| +test "entities observe and subscribe to each other" { + let app = @app.App::new() + let source = new_counter(app) + let log : @app.Entity[Log] = app.new_entity(fn(cx) { + cx + .observe(source, fn(log, source, cx) { + log.entries.push("notified \{source.read(cx.app).count}") + }) + .detach() + cx + .subscribe(source, changed, fn(log, _, value, _) { + log.entries.push("changed \{value}") + }) + .detach() + { entries: [], } + }) + source.update(app, fn(state, cx) { + state.count = 3 + cx.emit(changed, 3) + cx.notify() + }) + assert_eq(log.read(app).entries, ["changed 3", "notified 3"]) +} + +///| +test "self observation and self subscription" { + let app = @app.App::new() + let counter : @app.Entity[Counter] = app.new_entity(fn(cx) { + cx.observe_self(fn(state, _) { state.count += 100 }).detach() + cx + .subscribe_self(changed, fn(state, value, _) { state.count += value }) + .detach() + { count: 0, } + }) + counter.update(app, fn(_, cx) { + cx.emit(changed, 2) + cx.notify() + }) + assert_eq(counter.read(app).count, 102) +} + +///| +test "observers cascade within one flush" { + let app = @app.App::new() + let a = new_counter(app) + let b = new_counter(app) + let order = [] + app + .observe(a, fn(_, app) { + order.push("a") + b.update(app, fn(_, cx) { cx.notify() }) + }) + .detach() + app.observe(b, fn(_, _) { order.push("b") }).detach() + a.update(app, fn(_, cx) { cx.notify() }) + assert_eq(order, ["a", "b"]) +} + +///| +test "release removes observers, runs release listeners, stops weak handles" { + let app = @app.App::new() + let counter : @app.Entity[Counter] = app.new_entity(fn(cx) { + cx.on_release(fn(state, _) { state.count = -1 }).detach() + { count: 4, } + }) + let released = [] + app + .observe_release(counter, fn(state, _) { released.push(state.count) }) + .detach() + let notified = [] + app.observe(counter, fn(_, _) { notified.push(1) }).detach() + let weak = counter.downgrade() + assert_true(weak.upgrade() is Some(_)) + let upgraded_during = Ref(true) + let released_during = Ref(-1) + app.update(fn(app) { + app.release(counter) + // Weak handles stop upgrading immediately, listeners run at the flush. + upgraded_during.val = weak.upgrade() is Some(_) + released_during.val = released.length() + }) + assert_false(upgraded_during.val) + assert_eq(released_during.val, 0) + // Listeners run in registration order: on_release first. + assert_eq(released, [-1]) + assert_true(counter.is_released()) + assert_eq(app.entity_count(), 0) + assert_eq(weak.update(app, fn(_, _) { 1 }), None) + // Releasing again is a no-op. + app.release(counter) + assert_eq(released, [-1]) +} + +///| +test "observer entities stop observing when released" { + let app = @app.App::new() + let source = new_counter(app) + let seen = [] + let watcher : @app.Entity[Log] = app.new_entity(fn(cx) { + cx.observe(source, fn(_, _, _) { seen.push("seen") }).detach() + { entries: [], } + }) + source.update(app, fn(_, cx) { cx.notify() }) + assert_eq(seen, ["seen"]) + app.release(watcher) + source.update(app, fn(_, cx) { cx.notify() }) + assert_eq(seen, ["seen"]) +} + +///| +test "observe_release between entities" { + let app = @app.App::new() + let child = new_counter(app, count=9) + let parent : @app.Entity[Log] = app.new_entity(fn(cx) { + cx + .observe_release(child, fn(log, child_state, _) { + log.entries.push("child released with \{child_state.count}") + }) + .detach() + { entries: [], } + }) + app.release(child) + assert_eq(parent.read(app).entries, ["child released with 9"]) +} + +///| +test "globals" { + let app = @app.App::new() + assert_false(app.has_global(settings_key)) + assert_true(app.try_global(settings_key) is None) + app.set_global(settings_key, { theme: "light", }) + assert_eq(app.global(settings_key).theme, "light") + let changes = [] + app + .observe_global(settings_key, fn(app) { + changes.push(app.global(settings_key).theme) + }) + .detach() + app.update_global(settings_key, fn(settings, _) { settings.theme = "dark" }) + assert_eq(changes, ["dark"]) + app.update(fn(app) { app.global_mut(settings_key).theme = "solarized" }) + assert_eq(changes, ["dark", "solarized"]) + // Different keys hold different types independently. + app.set_global(marker_key, 42) + assert_eq(app.global(marker_key), 42) + assert_eq( + app.update(fn(app) { app.default_global(marker_key, fn() { 0 }) }), + 42, + ) + let removed = app.remove_global(marker_key) + assert_eq(removed, 42) + assert_false(app.has_global(marker_key)) + assert_eq( + app.update(fn(app) { app.default_global(marker_key, fn() { 7 }) }), + 7, + ) + // Globals are per app. + assert_false(@app.App::new().has_global(settings_key)) +} + +///| +test "entities observe globals until released" { + let app = @app.App::new() + app.set_global(marker_key, 0) + let counter : @app.Entity[Counter] = app.new_entity(fn(cx) { + cx.observe_global(marker_key, fn(state, _) { state.count += 1 }).detach() + { count: 0, } + }) + app.set_global(marker_key, 1) + app.set_global(marker_key, 2) + assert_eq(counter.read(app).count, 2) + let weak = counter.downgrade() + app.release(counter) + app.set_global(marker_key, 3) + assert_true(weak.upgrade() is None) +} + +///| +/// Port of GPUI's `test_unsubscribe_during_callback_with_insert`. +test "unsubscribe during callback with insert" { + let app = @app.App::new() + app.set_global(marker_key, 0) + let a_count = Ref(0) + let b_count = Ref(0) + let sub_a : Ref[@app.Subscription?] = Ref(None) + let sub_b : Ref[@app.Subscription?] = Ref(None) + sub_a.val = Some( + app.observe_global(marker_key, fn(app) { + a_count.val += 1 + sub_a.val.unwrap().unsubscribe() + app.observe_global(marker_key, fn(_) { }).detach() + }), + ) + sub_b.val = Some( + app.observe_global(marker_key, fn(_) { + b_count.val += 1 + sub_b.val.unwrap().unsubscribe() + }), + ) + app.set_global(marker_key, 1) + assert_eq(a_count.val, 1) + assert_eq(b_count.val, 1) + app.set_global(marker_key, 2) + assert_eq(a_count.val, 1) + assert_eq(b_count.val, 1) +} + +///| +/// Port of GPUI's `test_callback_dropped_by_earlier_callback_does_not_fire`. +test "callback unsubscribed by an earlier callback does not fire" { + let app = @app.App::new() + app.set_global(marker_key, 0) + let b_count = Ref(0) + let sub_b : Ref[@app.Subscription?] = Ref(None) + app + .observe_global(marker_key, fn(_) { + if sub_b.val is Some(sub) { + sub.unsubscribe() + } + }) + .detach() + sub_b.val = Some(app.observe_global(marker_key, fn(_) { b_count.val += 1 })) + app.set_global(marker_key, 1) + assert_eq(b_count.val, 0) +} + +///| +/// Port of GPUI's `test_self_drop_during_callback` and +/// `test_subscription_drop`. +test "self unsubscribe and unsubscribe before firing" { + let app = @app.App::new() + app.set_global(marker_key, 0) + let count = Ref(0) + let sub : Ref[@app.Subscription?] = Ref(None) + sub.val = Some( + app.observe_global(marker_key, fn(_) { + count.val += 1 + sub.val.unwrap().unsubscribe() + }), + ) + app.set_global(marker_key, 1) + app.set_global(marker_key, 2) + assert_eq(count.val, 1) + let other = Ref(0) + let subscription = app.observe_global(marker_key, fn(_) { other.val += 1 }) + subscription.unsubscribe() + app.set_global(marker_key, 3) + assert_eq(other.val, 0) +} + +///| +test "defer_call runs after current effects" { + let app = @app.App::new() + let order = [] + app.update(fn(app) { + app.defer_call(fn(_) { order.push("deferred") }) + order.push("update") + }) + assert_eq(order, ["update", "deferred"]) + let counter = new_counter(app) + counter.update(app, fn(_, cx) { + cx.defer_call(fn(app) { order.push("count \{counter.read(app).count}") }) + }) + assert_eq(order, ["update", "deferred", "count 0"]) +} + +///| +test "panic on re-entrant update" { + let app = @app.App::new() + let counter = new_counter(app) + counter.update(app, fn(_, cx) { counter.update(cx.app, fn(_, _) { }) }) +} + +///| +test "panic on reading an entity while it is updated" { + let app = @app.App::new() + let counter = new_counter(app) + counter.update(app, fn(_, cx) { ignore(counter.read(cx.app)) }) +} + +///| +test "panic on updating a released entity" { + let app = @app.App::new() + let counter = new_counter(app) + app.release(counter) + counter.update(app, fn(_, _) { }) +} + +///| +test "panic on using an entity with another app" { + let app = @app.App::new() + let counter = new_counter(app) + ignore(counter.read(@app.App::new())) +} + +///| +test "panic on reading a missing global" { + ignore(@app.App::new().global(settings_key)) +} + +///| +test "panic on reading a global while it is being updated" { + let app = @app.App::new() + app.set_global(marker_key, 1) + app.update_global(marker_key, fn(_, app) { ignore(app.global(marker_key)) }) +} + +///| +test "panic on global_mut outside an update" { + let app = @app.App::new() + app.set_global(marker_key, 1) + ignore(app.global_mut(marker_key)) +} diff --git a/src/app/async_app.mbt b/src/app/async_app.mbt new file mode 100644 index 0000000..bd2f8ed --- /dev/null +++ b/src/app/async_app.mbt @@ -0,0 +1,121 @@ +// Async integration, ported from gpui/src/app/async_context.rs and the +// `spawn` methods of App and Context. +// +// Deviation from GPUI: `AsyncApp` methods return plain values. GPUI's return +// `Result`s because the app may have been dropped while a task was +// suspended; a MoonBit `App` is never dropped while referenced. + +///| +/// A handle to the app that async tasks hold across suspension points +/// (GPUI: `AsyncApp`). Each call runs as its own update and flushes effects. +pub struct AsyncApp { + app : App +} + +///| +pub fn App::to_async(self : App) -> AsyncApp { + { app: self, } +} + +///| +/// The executor for work that must run on the main thread (GPUI: +/// `ForegroundExecutor`). There is one thread, so it is the same executor as +/// `background_executor`. +pub fn App::foreground_executor(self : App) -> @executor.Executor { + self.executor +} + +///| +/// The executor for work off the main thread (GPUI: `BackgroundExecutor`). +/// Shares the main thread here; see `foreground_executor`. +pub fn App::background_executor(self : App) -> @executor.Executor { + self.executor +} + +///| +/// Runs `f` as a task with an `AsyncApp` (GPUI: `cx.spawn`). +pub fn[R] App::spawn( + self : App, + f : async (AsyncApp) -> R, +) -> @executor.Task[R] { + let cx = self.to_async() + self.executor.spawn(async fn() { f(cx) }) +} + +///| +fn App::expect_test_dispatcher( + self : App, + operation : String, +) -> @executor.TestDispatcher { + match self.test_dispatcher { + Some(dispatcher) => dispatcher + None => + abort( + "App::\{operation} needs the app's own TestDispatcher (App::new() without a dispatcher)", + ) + } +} + +///| +/// Runs ready tasks until none is left (tests; GPUI: +/// `TestAppContext::run_until_parked`). +pub fn App::run_until_parked(self : App) -> Unit { + self.expect_test_dispatcher("run_until_parked").run_until_parked() +} + +///| +/// Advances the virtual clock, running timers and tasks (tests; GPUI: +/// `BackgroundExecutor::advance_clock`). +pub fn App::advance_clock(self : App, ms : Int32) -> Unit { + self.expect_test_dispatcher("advance_clock").advance_clock(ms) +} + +///| +/// Runs `f` as an update (GPUI: `AsyncApp::update`). +pub fn[R] AsyncApp::update(self : AsyncApp, f : (App) -> R) -> R { + self.app.update(f) +} + +///| +pub fn[T, R] AsyncApp::update_entity( + self : AsyncApp, + entity : Entity[T], + f : (T, Context[T]) -> R, +) -> R { + self.app.update_entity(entity, f) +} + +///| +pub fn[T] AsyncApp::read_entity(self : AsyncApp, entity : Entity[T]) -> T { + self.app.read_entity(entity) +} + +///| +pub fn[R] AsyncApp::spawn( + self : AsyncApp, + f : async (AsyncApp) -> R, +) -> @executor.Task[R] { + self.app.spawn(f) +} + +///| +pub fn AsyncApp::foreground_executor(self : AsyncApp) -> @executor.Executor { + self.app.executor +} + +///| +pub fn AsyncApp::background_executor(self : AsyncApp) -> @executor.Executor { + self.app.executor +} + +///| +/// Runs `f` as a task with a weak handle to this entity (GPUI: `cx.spawn`). +/// The task does not keep the entity alive: update it through the weak +/// handle, which yields `None` once the entity is released. +pub fn[T, R] Context::spawn( + self : Context[T], + f : async (WeakEntity[T], AsyncApp) -> R, +) -> @executor.Task[R] { + let weak = self.weak + self.app.spawn(async fn(cx) { f(weak, cx) }) +} diff --git a/src/app/async_test.mbt b/src/app/async_test.mbt new file mode 100644 index 0000000..809d906 --- /dev/null +++ b/src/app/async_test.mbt @@ -0,0 +1,118 @@ +///| +struct Status { + mut text : String + mut loads : Int32 +} + +///| +fn new_status(app : @app.App) -> @app.Entity[Status] { + app.new_entity(fn(_) { { text: "idle", loads: 0, } }) +} + +///| +test "app tasks update entities and flush effects per update" { + let app = @app.App::new() + let status = new_status(app) + let seen = [] + app + .observe(status, fn(status, app) { seen.push(status.read(app).text) }) + .detach() + let task = app.spawn(async fn(cx) { + cx.update_entity(status, fn(status, cx) { + status.text = "loading" + cx.notify() + }) + cx.background_executor().sleep(100) + cx.update_entity(status, fn(status, cx) { + status.text = "done" + status.loads += 1 + cx.notify() + }) + cx.read_entity(status).loads + }) + // Nothing runs until the test drives the app's dispatcher. + assert_eq(seen, []) + app.run_until_parked() + assert_eq(seen, ["loading"]) + app.advance_clock(99) + assert_eq(seen, ["loading"]) + app.advance_clock(1) + assert_eq(seen, ["loading", "done"]) + assert_eq(task.try_result(), Some(1)) +} + +///| +test "entity tasks hold weak handles" { + let app = @app.App::new() + let results = [] + let status : @app.Entity[Status] = app.new_entity(fn(cx) { + cx + .spawn(async fn(weak, cx) { + cx.foreground_executor().sleep(10) + let first = weak.update(cx.app, fn(status, _) { status.loads += 1 }) + results.push(first is Some(_)) + cx.foreground_executor().sleep(10) + // Released in between: the weak handle no longer upgrades. + let second = weak.update(cx.app, fn(status, _) { status.loads += 1 }) + results.push(second is Some(_)) + }) + .detach() + { text: "", loads: 0, } + }) + app.advance_clock(10) + assert_eq(results, [true]) + assert_eq(status.read(app).loads, 1) + app.release(status) + app.advance_clock(10) + assert_eq(results, [true, false]) +} + +///| +test "cancelling a spawned task stops it" { + let app = @app.App::new() + let status = new_status(app) + let task = app.spawn(async fn(cx) { + cx.background_executor().sleep(50) + cx.update_entity(status, fn(status, _) { status.text = "should not happen" }) + }) + app.run_until_parked() + task.cancel() + app.advance_clock(100) + assert_true(task.is_cancelled()) + assert_eq(status.read(app).text, "idle") +} + +///| +test "tasks spawned from AsyncApp and executor clock" { + let app = @app.App::new() + let order = [] + app + .spawn(async fn(cx) { + let child = cx.spawn(async fn(cx) { + cx.background_executor().sleep(5) + order.push("child") + 7 + }) + order.push("parent waits") + let value = child.wait() + order.push("parent got \{value} at \{cx.background_executor().now()}") + }) + .detach() + app.advance_clock(5) + assert_eq(order, ["parent waits", "child", "parent got 7 at 5"]) +} + +///| +test "apps can run on a caller-provided dispatcher" { + let dispatcher = @executor.TestDispatcher::new() + let app = @app.App::new(dispatcher~) + let task = app.spawn(fn(_) { "ran" }) + dispatcher.run_until_parked() + assert_eq(task.try_result(), Some("ran")) +} + +///| +test "panic on run_until_parked without the app's own dispatcher" { + let app = @app.App::new(dispatcher=@executor.TestDispatcher::new()) + app.run_until_parked() +} diff --git a/src/app/context.mbt b/src/app/context.mbt new file mode 100644 index 0000000..89fe945 --- /dev/null +++ b/src/app/context.mbt @@ -0,0 +1,199 @@ +// Port of gpui/src/app/context.rs: the context passed to entity callbacks. +// +// GPUI's `Context` derefs to `App`; here the app is the public `app` +// field (`cx.app.set_global(...)`). Window-related methods (`listener`, +// `observe_in`, focus) come with the Window (M6), `spawn` with the executors +// (M4). + +///| +/// The context of an update to entity `T` (GPUI: `Context<'_, T>`). +pub struct Context[T] { + app : App + priv weak : WeakEntity[T] +} + +///| +pub fn[T] Context::entity_id(self : Context[T]) -> EntityId { + self.weak.entity_id() +} + +///| +/// The entity being updated. +pub fn[T] Context::entity(self : Context[T]) -> Entity[T] { + match self.weak.upgrade() { + Some(entity) => entity + None => abort("the entity must be alive if we have an entity context") + } +} + +///| +pub fn[T] Context::weak_entity(self : Context[T]) -> WeakEntity[T] { + self.weak +} + +///| +/// Marks this entity as changed (GPUI: `cx.notify()`). +pub fn[T] Context::notify(self : Context[T]) -> Unit { + self.app.notify(self.weak.entity_id()) +} + +///| +/// Emits `event` to subscribers of this entity's `key` events +/// (GPUI: `cx.emit(event)`). +pub fn[T, E] Context::emit( + self : Context[T], + key : EventKey[E], + event : E, +) -> Unit { + self.app.emit_event(self.weak.entity_id(), key, event) +} + +///| +/// Queues `f` to run after the current effects. +pub fn[T] Context::defer_call(self : Context[T], f : (App) -> Unit) -> Unit { + self.app.defer_call(f) +} + +///| +/// Runs `f` on this entity's state, if it is still alive. +fn[T] invoke_on( + weak : WeakEntity[T], + app : App, + f : (T, Context[T]) -> Unit, +) -> Bool { + match weak.upgrade() { + Some(entity) => { + app.update_entity(entity, f) + true + } + None => false + } +} + +///| +/// Calls `on_notify` on this entity whenever `entity` is notified. Stops when +/// either entity is released (GPUI: `cx.observe`). +pub fn[T, W] Context::observe( + self : Context[T], + entity : Entity[W], + on_notify : (T, Entity[W], Context[T]) -> Unit, +) -> Subscription { + let observer = self.weak + self.app.observe_internal(entity, fn(entity, app) { + invoke_on(observer, app, fn(this, cx) { on_notify(this, entity, cx) }) + }) +} + +///| +/// Calls `on_notify` whenever this entity is notified. +pub fn[T] Context::observe_self( + self : Context[T], + on_notify : (T, Context[T]) -> Unit, +) -> Subscription { + let observer = self.weak + self.app.observe_internal(self.entity(), fn(_, app) { + invoke_on(observer, app, on_notify) + }) +} + +///| +/// Calls `on_event` on this entity for every `key` event `entity` emits. +/// Stops when either entity is released (GPUI: `cx.subscribe`). +pub fn[T, W, E] Context::subscribe( + self : Context[T], + entity : Entity[W], + key : EventKey[E], + on_event : (T, Entity[W], E, Context[T]) -> Unit, +) -> Subscription { + let subscriber = self.weak + self.app.subscribe_internal(entity, key, fn(entity, event, app) { + invoke_on(subscriber, app, fn(this, cx) { + on_event(this, entity, event, cx) + }) + }) +} + +///| +/// Calls `on_event` for every `key` event this entity emits. +pub fn[T, E] Context::subscribe_self( + self : Context[T], + key : EventKey[E], + on_event : (T, E, Context[T]) -> Unit, +) -> Subscription { + let subscriber = self.weak + self.app.subscribe_internal(self.entity(), key, fn(_, event, app) { + invoke_on(subscriber, app, fn(this, cx) { on_event(this, event, cx) }) + }) +} + +///| +/// Calls `on_release` with this entity's state when it is released +/// (GPUI: `cx.on_release`). +pub fn[T] Context::on_release( + self : Context[T], + on_release : (T, App) -> Unit, +) -> Subscription { + self.app.observe_release({ cell: self.weak.cell, }, on_release) +} + +///| +/// Calls `on_release` on this entity when `entity` is released +/// (GPUI: `cx.observe_release`). +pub fn[T, W] Context::observe_release( + self : Context[T], + entity : Entity[W], + on_release : (T, W, Context[T]) -> Unit, +) -> Subscription { + let observer = self.weak + self.app.observe_release(entity, fn(released, app) { + ignore( + invoke_on(observer, app, fn(this, cx) { on_release(this, released, cx) }), + ) + }) +} + +///| +/// Calls `f` on this entity whenever the global for `key` changes. Stops when +/// this entity is released (GPUI: `cx.observe_global`). +pub fn[T, G] Context::observe_global( + self : Context[T], + key : GlobalKey[G], + f : (T, Context[T]) -> Unit, +) -> Subscription { + let observer = self.weak + let (subscription, activate) = self.app.global_observers.insert_pending( + key.id, + fn(app) { invoke_on(observer, app, f) }, + ) + self.app.defer_call(fn(_) { activate() }) + subscription +} + +///| +/// Updates this entity's state from a weak handle, if it is still alive. +pub fn[T, R] WeakEntity::update( + self : WeakEntity[T], + app : App, + f : (T, Context[T]) -> R, +) -> R? { + match self.upgrade() { + Some(entity) => Some(app.update_entity(entity, f)) + None => None + } +} + +///| +/// `app.update_entity(self, f)`. +pub fn[T, R] Entity::update( + self : Entity[T], + app : App, + f : (T, Context[T]) -> R, +) -> R { + app.update_entity(self, f) +} + +///| +/// `app.read_entity(self)`. +pub fn[T] Entity::read(self : Entity[T], app : App) -> T { + app.read_entity(self) +} diff --git a/src/app/entity.mbt b/src/app/entity.mbt new file mode 100644 index 0000000..d33ddd1 --- /dev/null +++ b/src/app/entity.mbt @@ -0,0 +1,152 @@ +// Entities, ported from gpui/src/app/entity_map.rs. +// +// Deviations from GPUI: +// - A handle points directly at a typed cell holding the state; there is no +// `Box` map to downcast from. +// - Handles are not reference counted (no `Drop`). An entity lives until +// `App::release` is called; then its observers and event subscriptions are +// removed and its release listeners run, as when the last GPUI handle +// drops. `WeakEntity::upgrade` returns `None` from the moment of release. +// - State is passed to update callbacks by reference (MoonBit structs with +// `mut` fields), playing the role of GPUI's `&mut T`. + +///| +/// Identifies an entity within its app. +#derive(Eq, Hash, Compare, Debug) +pub(all) struct EntityId(Int32) + +///| +pub impl Show for EntityId with fn output(self, logger) { + logger.write_string("EntityId(\{self.0})") +} + +///| +priv struct EntityCell[T] { + app_id : Int32 + id : EntityId + mut value : T? + /// True while an update callback holds the state. + mut leased : Bool + mut released : Bool +} + +///| +/// A strong handle to state owned by the app (GPUI: `Entity`). +pub struct Entity[T] { + priv cell : EntityCell[T] +} + +///| +/// A handle that does not keep the entity alive (GPUI: `WeakEntity`). +pub struct WeakEntity[T] { + priv cell : EntityCell[T] +} + +///| +/// An entity id handed out before the entity's state exists +/// (GPUI: `Reservation`). +pub struct Reservation[T] { + priv cell : EntityCell[T] +} + +///| +pub fn[T] Entity::entity_id(self : Entity[T]) -> EntityId { + self.cell.id +} + +///| +pub fn[T] Entity::downgrade(self : Entity[T]) -> WeakEntity[T] { + { cell: self.cell, } +} + +///| +/// Whether `App::release` has been called for this entity. +pub fn[T] Entity::is_released(self : Entity[T]) -> Bool { + self.cell.released +} + +///| +pub impl[T] Eq for Entity[T] with fn equal(self, other) { + physical_equal(self.cell, other.cell) +} + +///| +pub impl[T] Hash for Entity[T] with fn hash_combine(self, hasher) { + hasher.combine(self.cell.id) +} + +///| +pub impl[T] Show for Entity[T] with fn output(self, logger) { + logger.write_string("Entity(\{self.cell.id.0})") +} + +///| +pub fn[T] WeakEntity::entity_id(self : WeakEntity[T]) -> EntityId { + self.cell.id +} + +///| +/// The strong handle, unless the entity has been released. +pub fn[T] WeakEntity::upgrade(self : WeakEntity[T]) -> Entity[T]? { + if self.cell.released { + None + } else { + Some({ cell: self.cell, }) + } +} + +///| +pub fn[T] Reservation::entity_id(self : Reservation[T]) -> EntityId { + self.cell.id +} + +///| +fn[T] EntityCell::check_app( + self : EntityCell[T], + app : App, + operation : String, +) -> Unit { + guard self.app_id == app.id else { + abort("cannot \{operation} \{self.id}: it belongs to a different App") + } +} + +///| +/// Takes the state for an update, failing loudly on re-entrancy or use after +/// release (GPUI: `EntityMap::lease`). +fn[T] EntityCell::lease(self : EntityCell[T], operation : String) -> T { + guard !self.released else { + abort("cannot \{operation} \{self.id}: the entity has been released") + } + guard !self.leased else { + abort("cannot \{operation} \{self.id} while it is already being updated") + } + guard self.value is Some(value) else { + abort( + "cannot \{operation} \{self.id}: the entity has not been inserted yet", + ) + } + self.leased = true + value +} + +///| +fn[T] EntityCell::end_lease(self : EntityCell[T]) -> Unit { + self.leased = false +} + +///| +/// Reads the state. Fails if the entity is being updated or was released +/// (GPUI: `EntityMap::read`). +fn[T] EntityCell::read(self : EntityCell[T]) -> T { + guard !self.released else { + abort("cannot read \{self.id}: the entity has been released") + } + guard !self.leased else { + abort("cannot read \{self.id} while it is already being updated") + } + guard self.value is Some(value) else { + abort("cannot read \{self.id}: the entity has not been inserted yet") + } + value +} diff --git a/src/app/keys.mbt b/src/app/keys.mbt new file mode 100644 index 0000000..dc4f1f9 --- /dev/null +++ b/src/app/keys.mbt @@ -0,0 +1,81 @@ +// Type keys: MoonBit's replacement for GPUI's `TypeId`-keyed maps of +// `Box` (globals, events). +// +// A key is created once per type, usually as a top-level `let`: +// +// let theme_key : @app.GlobalKey[Theme] = @app.GlobalKey::new("Theme") +// +// The app stores values under the key's id without knowing their type. A +// stored value is a closure that writes the value into its key's typed slot, +// so reading it back through the same key is type-safe without downcasts. + +///| +let next_key_id : Ref[Int32] = { val: 0, } + +///| +fn fresh_key_id() -> Int32 { + let id = next_key_id.val + next_key_id.val = id + 1 + id +} + +///| +/// Identifies one kind of global state (GPUI: `TypeId::of::()` for a +/// `G: Global`). +pub struct GlobalKey[G] { + id : Int32 + name : String + priv slot : Ref[G?] +} + +///| +pub fn[G] GlobalKey::new(name : String) -> GlobalKey[G] { + { id: fresh_key_id(), name, slot: { val: None, }, } +} + +///| +/// A type-erased value that can only be read back through `key`. +fn[G] GlobalKey::erase(self : GlobalKey[G], value : G) -> () -> Unit { + fn() { self.slot.val = Some(value) } +} + +///| +fn[G] GlobalKey::unerase(self : GlobalKey[G], erased : () -> Unit) -> G { + self.slot.val = None + erased() + guard self.slot.val is Some(value) else { + abort("global \{self.name}: stored value has the wrong key") + } + self.slot.val = None + value +} + +///| +/// Identifies one kind of event (GPUI: `TypeId::of::()` for events +/// declared with `impl EventEmitter for T`). +pub struct EventKey[E] { + id : Int32 + name : String + priv slot : Ref[E?] +} + +///| +pub fn[E] EventKey::new(name : String) -> EventKey[E] { + { id: fresh_key_id(), name, slot: { val: None, }, } +} + +///| +fn[E] EventKey::erase(self : EventKey[E], event : E) -> () -> Unit { + fn() { self.slot.val = Some(event) } +} + +///| +fn[E] EventKey::unerase(self : EventKey[E], erased : () -> Unit) -> E { + self.slot.val = None + erased() + guard self.slot.val is Some(event) else { + abort("event \{self.name}: payload has the wrong key") + } + self.slot.val = None + event +} diff --git a/src/app/moon.pkg b/src/app/moon.pkg new file mode 100644 index 0000000..4082d6d --- /dev/null +++ b/src/app/moon.pkg @@ -0,0 +1,11 @@ +import { + "experiments/gpui/executor", + "moonbitlang/core/deque", + "moonbitlang/core/hashset", +} + +// experiments/gpui/executor uses MoonBit's experimental async intrinsics. + +options( + "allow-experimental-packages": true, +) diff --git a/src/app/pkg.generated.mbti b/src/app/pkg.generated.mbti new file mode 100644 index 0000000..6f8cfad --- /dev/null +++ b/src/app/pkg.generated.mbti @@ -0,0 +1,132 @@ +// Generated using `moon info`, DON'T EDIT IT +package "experiments/gpui/app" + +import { + "experiments/gpui/executor", + "moonbitlang/core/debug", +} + +// Values + +// Errors + +// Types and methods +pub struct App { + // private fields +} +pub fn App::advance_clock(Self, Int32) -> Unit +pub fn App::background_executor(Self) -> @executor.Executor +pub fn[G] App::default_global(Self, GlobalKey[G], () -> G) -> G +pub fn App::defer_call(Self, (Self) -> Unit) -> Unit +pub fn App::entity_count(Self) -> Int32 +pub fn App::foreground_executor(Self) -> @executor.Executor +pub fn[G] App::global(Self, GlobalKey[G]) -> G +pub fn[G] App::global_mut(Self, GlobalKey[G]) -> G +pub fn[G] App::has_global(Self, GlobalKey[G]) -> Bool +pub fn[T] App::insert_entity(Self, Reservation[T], (Context[T]) -> T) -> Entity[T] +pub fn App::new(dispatcher? : &@executor.Dispatcher) -> Self +pub fn[T] App::new_entity(Self, (Context[T]) -> T) -> Entity[T] +pub fn App::notify(Self, EntityId) -> Unit +pub fn[T] App::observe(Self, Entity[T], (Entity[T], Self) -> Unit) -> Subscription +pub fn[G] App::observe_global(Self, GlobalKey[G], (Self) -> Unit) -> Subscription +pub fn App::observe_notifications(Self, (EntityId) -> Unit) -> Subscription +pub fn[T] App::observe_release(Self, Entity[T], (T, Self) -> Unit) -> Subscription +pub fn[T] App::read_entity(Self, Entity[T]) -> T +pub fn[T] App::release(Self, Entity[T]) -> Unit +pub fn[G] App::remove_global(Self, GlobalKey[G]) -> G +pub fn[T] App::reserve_entity(Self) -> Reservation[T] +pub fn App::run_until_parked(Self) -> Unit +pub fn[G] App::set_global(Self, GlobalKey[G], G) -> Unit +pub fn[R] App::spawn(Self, async (AsyncApp) -> R) -> @executor.Task[R] +pub fn[T, E] App::subscribe(Self, Entity[T], EventKey[E], (Entity[T], E, Self) -> Unit) -> Subscription +pub fn App::to_async(Self) -> AsyncApp +pub fn[G] App::try_global(Self, GlobalKey[G]) -> G? +pub fn[R] App::update(Self, (Self) -> R) -> R +pub fn[T, R] App::update_entity(Self, Entity[T], (T, Context[T]) -> R) -> R +pub fn[G, R] App::update_global(Self, GlobalKey[G], (G, Self) -> R) -> R + +pub struct AsyncApp { + app : App +} +pub fn AsyncApp::background_executor(Self) -> @executor.Executor +pub fn AsyncApp::foreground_executor(Self) -> @executor.Executor +pub fn[T] AsyncApp::read_entity(Self, Entity[T]) -> T +pub fn[R] AsyncApp::spawn(Self, async (Self) -> R) -> @executor.Task[R] +pub fn[R] AsyncApp::update(Self, (App) -> R) -> R +pub fn[T, R] AsyncApp::update_entity(Self, Entity[T], (T, Context[T]) -> R) -> R + +pub struct Context[T] { + app : App + // private fields +} +pub fn[T] Context::defer_call(Self[T], (App) -> Unit) -> Unit +pub fn[T, E] Context::emit(Self[T], EventKey[E], E) -> Unit +pub fn[T] Context::entity(Self[T]) -> Entity[T] +pub fn[T] Context::entity_id(Self[T]) -> EntityId +pub fn[T] Context::notify(Self[T]) -> Unit +pub fn[T, W] Context::observe(Self[T], Entity[W], (T, Entity[W], Self[T]) -> Unit) -> Subscription +pub fn[T, G] Context::observe_global(Self[T], GlobalKey[G], (T, Self[T]) -> Unit) -> Subscription +pub fn[T, W] Context::observe_release(Self[T], Entity[W], (T, W, Self[T]) -> Unit) -> Subscription +pub fn[T] Context::observe_self(Self[T], (T, Self[T]) -> Unit) -> Subscription +pub fn[T] Context::on_release(Self[T], (T, App) -> Unit) -> Subscription +pub fn[T, R] Context::spawn(Self[T], async (WeakEntity[T], AsyncApp) -> R) -> @executor.Task[R] +pub fn[T, W, E] Context::subscribe(Self[T], Entity[W], EventKey[E], (T, Entity[W], E, Self[T]) -> Unit) -> Subscription +pub fn[T, E] Context::subscribe_self(Self[T], EventKey[E], (T, E, Self[T]) -> Unit) -> Subscription +pub fn[T] Context::weak_entity(Self[T]) -> WeakEntity[T] + +pub struct Entity[T] { + // private fields +} +pub fn[T] Entity::downgrade(Self[T]) -> WeakEntity[T] +pub fn[T] Entity::entity_id(Self[T]) -> EntityId +pub fn[T] Entity::is_released(Self[T]) -> Bool +pub fn[T] Entity::read(Self[T], App) -> T +pub fn[T, R] Entity::update(Self[T], App, (T, Context[T]) -> R) -> R +pub impl[T] Eq for Entity[T] +pub impl[T] Hash for Entity[T] +pub impl[T] Show for Entity[T] + +#derive(Compare, Eq, Hash, @debug.Debug) +pub(all) struct EntityId(Int32) +pub impl Show for EntityId + +pub struct EventKey[E] { + id : Int32 + name : String + // private fields +} +pub fn[E] EventKey::new(String) -> Self[E] + +pub struct GlobalKey[G] { + id : Int32 + name : String + // private fields +} +pub fn[G] GlobalKey::new(String) -> Self[G] + +pub struct Reservation[T] { + // private fields +} +pub fn[T] Reservation::entity_id(Self[T]) -> EntityId + +type SubscriberSet[K, C] + +pub struct Subscription { + // private fields +} +pub fn Subscription::detach(Self) -> Unit +pub fn Subscription::is_active(Self) -> Bool +pub fn Subscription::join(Self, Self) -> Self +pub fn Subscription::new(() -> Unit) -> Self +pub fn Subscription::unsubscribe(Self) -> Unit + +pub struct WeakEntity[T] { + // private fields +} +pub fn[T] WeakEntity::entity_id(Self[T]) -> EntityId +pub fn[T, R] WeakEntity::update(Self[T], App, (T, Context[T]) -> R) -> R? +pub fn[T] WeakEntity::upgrade(Self[T]) -> Entity[T]? + +// Type aliases + +// Traits diff --git a/src/app/subscription.mbt b/src/app/subscription.mbt new file mode 100644 index 0000000..530939f --- /dev/null +++ b/src/app/subscription.mbt @@ -0,0 +1,179 @@ +// Port of gpui/src/subscription.rs. +// +// Deviation from GPUI: a Rust `Subscription` unsubscribes when dropped. There +// is no `Drop` in MoonBit, so a `Subscription` stays active until +// `unsubscribe()` is called, or until the entity it belongs to is released. +// `detach()` is kept for API parity; it only documents intent. + +///| +#derive(Eq) +priv enum SubscriberState { + Pending + Active + Dropped +} + +///| +priv struct Subscriber[C] { + id : Int32 + mut state : SubscriberState + callback : C +} + +///| +/// A set of callbacks keyed by emitter. Callbacks run in subscription order; +/// subscriptions created while callbacks run are pending until activated. +struct SubscriberSet[K, C] { + subscribers : Map[K, Array[Subscriber[C]]] + mut next_subscriber_id : Int32 +} + +///| +fn[K : Hash + Eq, C] SubscriberSet::new() -> SubscriberSet[K, C] { + { subscribers: {}, next_subscriber_id: 0, } +} + +///| +/// Inserts an active subscriber. +fn[K : Hash + Eq, C] SubscriberSet::insert( + self : SubscriberSet[K, C], + key : K, + callback : C, +) -> Subscription { + let (subscription, activate) = self.insert_pending(key, callback) + activate() + subscription +} + +///| +/// Inserts a subscriber that does not run until `activate` is called. +fn[K : Hash + Eq, C] SubscriberSet::insert_pending( + self : SubscriberSet[K, C], + key : K, + callback : C, +) -> (Subscription, () -> Unit) { + let id = self.next_subscriber_id + self.next_subscriber_id = id + 1 + let subscriber = { id, state: Pending, callback, } + match self.subscribers.get(key) { + Some(list) => list.push(subscriber) + None => self.subscribers[key] = [subscriber] + } + let subscription = Subscription::new(fn() { + subscriber.state = Dropped + if self.subscribers.get(key) is Some(list) { + let remaining = list.filter(fn(s) { s.id != id }) + if remaining.is_empty() { + self.subscribers.remove(key) + } else { + self.subscribers[key] = remaining + } + } + }) + let activate = fn() { + if subscriber.state == Pending { + subscriber.state = Active + } + } + (subscription, activate) +} + +///| +/// Removes every subscriber of `key`, returning the active callbacks. +fn[K : Hash + Eq, C] SubscriberSet::remove( + self : SubscriberSet[K, C], + key : K, +) -> Array[C] { + match self.subscribers.get(key) { + None => [] + Some(list) => { + self.subscribers.remove(key) + list.filter(fn(s) { s.state == Active }).map(fn(s) { s.callback }) + } + } +} + +///| +/// Calls `f` on every active subscriber of `key`, in order; a subscriber is +/// removed when `f` returns false or when it was unsubscribed meanwhile. +/// Subscribers added during the iteration are kept but not visited. +fn[K : Hash + Eq, C] SubscriberSet::retain( + self : SubscriberSet[K, C], + key : K, + f : (C) -> Bool, +) -> Unit { + guard self.subscribers.get(key) is Some(list) else { return } + // Detach the list so that insertions during callbacks go to a fresh list. + self.subscribers.remove(key) + let kept : Array[Subscriber[C]] = [] + for subscriber in list { + let keep = match subscriber.state { + Pending => true + Dropped => false + Active => f(subscriber.callback) && subscriber.state != Dropped + } + if keep && subscriber.state != Dropped { + kept.push(subscriber) + } + } + match self.subscribers.get(key) { + Some(added) => + // Ids only grow, so newly added subscribers come after the kept ones. + self.subscribers[key] = [ + ..kept, + ..added.filter(fn(s) { s.state != Dropped }), + ] + None => if !kept.is_empty() { self.subscribers[key] = kept } + } +} + +///| +/// A handle to a registered callback. Call `unsubscribe` to stop it. +pub struct Subscription { + priv mut unsubscribe_fn : (() -> Unit)? +} + +///| +/// A subscription that runs `unsubscribe` once when unsubscribed. +pub fn Subscription::new(unsubscribe : () -> Unit) -> Subscription { + { unsubscribe_fn: Some(unsubscribe), } +} + +///| +/// Stops the callback. Idempotent. +pub fn Subscription::unsubscribe(self : Subscription) -> Unit { + if self.unsubscribe_fn is Some(f) { + self.unsubscribe_fn = None + f() + } +} + +///| +/// Keeps the callback registered for as long as its entities live. In +/// MoonBit this is the default (there is no drop); kept for GPUI parity. +pub fn Subscription::detach(self : Subscription) -> Unit { + self.unsubscribe_fn = None +} + +///| +/// Whether `unsubscribe` has not been called (and `detach` neither). +pub fn Subscription::is_active(self : Subscription) -> Bool { + self.unsubscribe_fn is Some(_) +} + +///| +/// One subscription that unsubscribes both. +pub fn Subscription::join(a : Subscription, b : Subscription) -> Subscription { + let a_fn = a.unsubscribe_fn + let b_fn = b.unsubscribe_fn + a.unsubscribe_fn = None + b.unsubscribe_fn = None + Subscription::new(fn() { + if a_fn is Some(f) { + f() + } + if b_fn is Some(f) { + f() + } + }) +} diff --git a/src/app/subscription_wbtest.mbt b/src/app/subscription_wbtest.mbt new file mode 100644 index 0000000..a651cb4 --- /dev/null +++ b/src/app/subscription_wbtest.mbt @@ -0,0 +1,98 @@ +///| +/// Number of subscribers (pending or active) of `key`. +fn[K : Hash + Eq, C] SubscriberSet::count( + self : SubscriberSet[K, C], + key : K, +) -> Int32 { + match self.subscribers.get(key) { + Some(list) => list.length() + None => 0 + } +} + +///| +/// Port of GPUI's `test_immediate_and_pending_insertions`. +test "immediate and pending insertions" { + let subscribers : SubscriberSet[Int32, Int32] = SubscriberSet::new() + let first = subscribers.insert(1, 10) + let (second, activate_second) = subscribers.insert_pending(1, 20) + let visited = [] + subscribers.retain(1, fn(callback) { + visited.push(callback) + subscribers.insert(1, 30).detach() + true + }) + // Pending (20) and newly inserted (30) subscribers are not visited. + assert_eq(visited, [10]) + activate_second() + assert_eq(subscribers.remove(1), [10, 20, 30]) + first.unsubscribe() + second.unsubscribe() + let (pending, _activate) = subscribers.insert_pending(1, 40) + assert_eq(subscribers.remove(1).length(), 0) + pending.unsubscribe() +} + +///| +/// Port of GPUI's `test_activation_after_drop_during_retain`. +test "activation after unsubscribe during retain" { + let subscribers : SubscriberSet[Int32, Int32] = SubscriberSet::new() + let (first, activate_first) = subscribers.insert_pending(1, 10) + let (second, activate_second) = subscribers.insert_pending(1, 20) + subscribers.retain(1, fn(_) { abort("pending subscriber invoked") }) + activate_first() + let mut second_taken = false + let visited = [] + subscribers.retain(1, fn(callback) { + visited.push(callback) + guard !second_taken else { abort("only the first callback runs") } + second_taken = true + // Unsubscribing then activating must not revive the subscriber. + second.unsubscribe() + activate_second() + true + }) + assert_eq(visited, [10]) + assert_eq(subscribers.remove(1), [10]) + first.unsubscribe() +} + +///| +test "retain removes callbacks returning false and keeps order" { + let subscribers : SubscriberSet[String, Int32] = SubscriberSet::new() + for i in 0..<5 { + subscribers.insert("k", i).detach() + } + subscribers.retain("k", fn(i) { i % 2 == 0 }) + let seen = [] + subscribers.retain("k", fn(i) { + seen.push(i) + true + }) + assert_eq(seen, [0, 2, 4]) + // A subscriber unsubscribed by an earlier callback does not run. + let later = subscribers.insert("k", 9) + let seen = [] + subscribers.retain("k", fn(i) { + seen.push(i) + later.unsubscribe() + true + }) + assert_eq(seen, [0, 2, 4]) + assert_eq(subscribers.count("k"), 3) + assert_eq(subscribers.count("none"), 0) +} + +///| +test "subscription join and is_active" { + let log = [] + let a = Subscription::new(fn() { log.push("a") }) + let b = Subscription::new(fn() { log.push("b") }) + let joined = Subscription::join(a, b) + assert_false(a.is_active()) + assert_true(joined.is_active()) + joined.unsubscribe() + joined.unsubscribe() + assert_eq(log, ["a", "b"]) + assert_false(joined.is_active()) +} diff --git a/src/elements/canvas.mbt b/src/elements/canvas.mbt new file mode 100644 index 0000000..8de0610 --- /dev/null +++ b/src/elements/canvas.mbt @@ -0,0 +1,72 @@ +// `canvas()`, ported from gpui/src/elements/canvas.rs: an element laid out by +// its style that paints with a closure. + +///| +/// An element that paints itself with a closure (GPUI: `Canvas`). +pub struct Canvas { + priv base_style : @style.StyleRefinement + priv prepaint_fn : ( + @geometry.Bounds[@geometry.Pixels], + @window.Window, + @app.App, + ) -> Unit + priv paint_fn : (@geometry.Bounds[@geometry.Pixels], @window.Window, @app.App) -> Unit + priv mut layout_style : @style.Style? +} + +///| +/// A canvas that runs `paint` with its bounds during the paint phase, and +/// `prepaint` (if given) during prepaint. Size it with style methods, e.g. +/// `canvas(paint).size_full()`. +pub fn canvas( + paint : (@geometry.Bounds[@geometry.Pixels], @window.Window, @app.App) -> Unit, + prepaint~ : (@geometry.Bounds[@geometry.Pixels], @window.Window, @app.App) -> Unit = fn( + _, + _, + _, + ) { + + }, +) -> Canvas { + { + base_style: @style.StyleRefinement::new(), + prepaint_fn: prepaint, + paint_fn: paint, + layout_style: None, + } +} + +///| +pub impl @style.Styled for Canvas with fn style(self) { + self.base_style +} + +///| +pub impl @window.IntoElement for Canvas with fn into_any_element(self) { + @window.AnyElement::new(self) +} + +///| +pub extend Canvas with @window.IntoElement::{into_any_element} + +///| +impl @window.Element for Canvas with fn request_layout(self, window, _app) { + let style = (Default::default() : @style.Style).refined(self.base_style) + self.layout_style = Some(style) + window.request_layout(style, []) +} + +///| +impl @window.Element for Canvas with fn prepaint(self, bounds, window, app) { + (self.prepaint_fn)(bounds, window, app) +} + +///| +impl @window.Element for Canvas with fn paint(self, bounds, window, app) { + guard self.layout_style is Some(style) else { + abort("canvas painted before layout") + } + window.paint_style(style, bounds, fn() { + (self.paint_fn)(bounds, window, app) + }) +} diff --git a/src/elements/canvas_styled_generated.mbt b/src/elements/canvas_styled_generated.mbt new file mode 100644 index 0000000..e1c2e55 --- /dev/null +++ b/src/elements/canvas_styled_generated.mbt @@ -0,0 +1,3219 @@ +// GENERATED by tools/gen_style.py. DO NOT EDIT. +// Port of GPUI's derive(Refineable) / gpui_macros style helpers. + +///| +pub extend Canvas with @style.Styled::{ + visible, + invisible, + block, + flex, + grid, + hidden, + relative, + absolute, + overflow_hidden, + overflow_x_hidden, + overflow_y_hidden, + scrollbar_width, + cursor, + border_color, + border_dashed, + shadow, + shadow_none, + shadow_2xs, + shadow_xs, + shadow_sm, + shadow_md, + shadow_lg, + shadow_xl, + shadow_2xl, + flex_col, + flex_col_reverse, + flex_row, + flex_row_reverse, + flex_1, + flex_auto, + flex_initial, + flex_none, + flex_basis, + flex_grow, + flex_grow_0, + flex_grow_1, + flex_shrink, + flex_shrink_0, + flex_shrink_1, + flex_wrap, + flex_wrap_reverse, + flex_nowrap, + items_start, + items_end, + items_center, + items_baseline, + items_stretch, + self_start, + self_end, + self_flex_start, + self_flex_end, + self_center, + self_baseline, + self_stretch, + justify_start, + justify_end, + justify_center, + justify_between, + justify_around, + justify_evenly, + content_normal, + content_center, + content_start, + content_end, + content_between, + content_around, + content_evenly, + content_stretch, + aspect_ratio, + aspect_square, + bg, + opacity, + whitespace_normal, + whitespace_nowrap, + text_ellipsis, + text_ellipsis_start, + text_ellipsis_middle, + text_overflow, + text_align, + text_left, + text_center, + text_right, + truncate, + line_clamp, + text_color, + text_bg, + font_weight, + text_size, + text_xs, + text_sm, + text_base, + text_lg, + text_xl, + text_2xl, + text_3xl, + italic, + not_italic, + underline, + line_through, + text_decoration_none, + text_decoration_color, + text_decoration_solid, + text_decoration_wavy, + text_decoration_0, + text_decoration_1, + text_decoration_2, + text_decoration_4, + text_decoration_8, + font_family, + font_features, + font, + line_height, + grid_cols, + grid_cols_min_content, + grid_cols_max_content, + grid_rows, + grid_rows_min_content, + grid_rows_max_content, + col_start, + col_start_auto, + col_end, + col_end_auto, + col_span, + col_span_full, + row_start, + row_start_auto, + row_end, + row_end_auto, + row_span, + row_span_full, + debug, + debug_below, + w, + w_0, + w_neg_0, + w_0p5, + w_neg_0p5, + w_1, + w_neg_1, + w_1p5, + w_neg_1p5, + w_2, + w_neg_2, + w_2p5, + w_neg_2p5, + w_3, + w_neg_3, + w_3p5, + w_neg_3p5, + w_4, + w_neg_4, + w_5, + w_neg_5, + w_6, + w_neg_6, + w_7, + w_neg_7, + w_8, + w_neg_8, + w_9, + w_neg_9, + w_10, + w_neg_10, + w_11, + w_neg_11, + w_12, + w_neg_12, + w_16, + w_neg_16, + w_20, + w_neg_20, + w_24, + w_neg_24, + w_32, + w_neg_32, + w_40, + w_neg_40, + w_48, + w_neg_48, + w_56, + w_neg_56, + w_64, + w_neg_64, + w_72, + w_neg_72, + w_80, + w_neg_80, + w_96, + w_neg_96, + w_112, + w_neg_112, + w_128, + w_neg_128, + w_auto, + w_px, + w_neg_px, + w_full, + w_neg_full, + w_1_2, + w_neg_1_2, + w_1_3, + w_neg_1_3, + w_2_3, + w_neg_2_3, + w_1_4, + w_neg_1_4, + w_2_4, + w_neg_2_4, + w_3_4, + w_neg_3_4, + w_1_5, + w_neg_1_5, + w_2_5, + w_neg_2_5, + w_3_5, + w_neg_3_5, + w_4_5, + w_neg_4_5, + w_1_6, + w_neg_1_6, + w_5_6, + w_neg_5_6, + w_1_12, + w_neg_1_12, + h, + h_0, + h_neg_0, + h_0p5, + h_neg_0p5, + h_1, + h_neg_1, + h_1p5, + h_neg_1p5, + h_2, + h_neg_2, + h_2p5, + h_neg_2p5, + h_3, + h_neg_3, + h_3p5, + h_neg_3p5, + h_4, + h_neg_4, + h_5, + h_neg_5, + h_6, + h_neg_6, + h_7, + h_neg_7, + h_8, + h_neg_8, + h_9, + h_neg_9, + h_10, + h_neg_10, + h_11, + h_neg_11, + h_12, + h_neg_12, + h_16, + h_neg_16, + h_20, + h_neg_20, + h_24, + h_neg_24, + h_32, + h_neg_32, + h_40, + h_neg_40, + h_48, + h_neg_48, + h_56, + h_neg_56, + h_64, + h_neg_64, + h_72, + h_neg_72, + h_80, + h_neg_80, + h_96, + h_neg_96, + h_112, + h_neg_112, + h_128, + h_neg_128, + h_auto, + h_px, + h_neg_px, + h_full, + h_neg_full, + h_1_2, + h_neg_1_2, + h_1_3, + h_neg_1_3, + h_2_3, + h_neg_2_3, + h_1_4, + h_neg_1_4, + h_2_4, + h_neg_2_4, + h_3_4, + h_neg_3_4, + h_1_5, + h_neg_1_5, + h_2_5, + h_neg_2_5, + h_3_5, + h_neg_3_5, + h_4_5, + h_neg_4_5, + h_1_6, + h_neg_1_6, + h_5_6, + h_neg_5_6, + h_1_12, + h_neg_1_12, + size, + size_0, + size_neg_0, + size_0p5, + size_neg_0p5, + size_1, + size_neg_1, + size_1p5, + size_neg_1p5, + size_2, + size_neg_2, + size_2p5, + size_neg_2p5, + size_3, + size_neg_3, + size_3p5, + size_neg_3p5, + size_4, + size_neg_4, + size_5, + size_neg_5, + size_6, + size_neg_6, + size_7, + size_neg_7, + size_8, + size_neg_8, + size_9, + size_neg_9, + size_10, + size_neg_10, + size_11, + size_neg_11, + size_12, + size_neg_12, + size_16, + size_neg_16, + size_20, + size_neg_20, + size_24, + size_neg_24, + size_32, + size_neg_32, + size_40, + size_neg_40, + size_48, + size_neg_48, + size_56, + size_neg_56, + size_64, + size_neg_64, + size_72, + size_neg_72, + size_80, + size_neg_80, + size_96, + size_neg_96, + size_112, + size_neg_112, + size_128, + size_neg_128, + size_auto, + size_px, + size_neg_px, + size_full, + size_neg_full, + size_1_2, + size_neg_1_2, + size_1_3, + size_neg_1_3, + size_2_3, + size_neg_2_3, + size_1_4, + size_neg_1_4, + size_2_4, + size_neg_2_4, + size_3_4, + size_neg_3_4, + size_1_5, + size_neg_1_5, + size_2_5, + size_neg_2_5, + size_3_5, + size_neg_3_5, + size_4_5, + size_neg_4_5, + size_1_6, + size_neg_1_6, + size_5_6, + size_neg_5_6, + size_1_12, + size_neg_1_12, + min_size, + min_size_0, + min_size_neg_0, + min_size_0p5, + min_size_neg_0p5, + min_size_1, + min_size_neg_1, + min_size_1p5, + min_size_neg_1p5, + min_size_2, + min_size_neg_2, + min_size_2p5, + min_size_neg_2p5, + min_size_3, + min_size_neg_3, + min_size_3p5, + min_size_neg_3p5, + min_size_4, + min_size_neg_4, + min_size_5, + min_size_neg_5, + min_size_6, + min_size_neg_6, + min_size_7, + min_size_neg_7, + min_size_8, + min_size_neg_8, + min_size_9, + min_size_neg_9, + min_size_10, + min_size_neg_10, + min_size_11, + min_size_neg_11, + min_size_12, + min_size_neg_12, + min_size_16, + min_size_neg_16, + min_size_20, + min_size_neg_20, + min_size_24, + min_size_neg_24, + min_size_32, + min_size_neg_32, + min_size_40, + min_size_neg_40, + min_size_48, + min_size_neg_48, + min_size_56, + min_size_neg_56, + min_size_64, + min_size_neg_64, + min_size_72, + min_size_neg_72, + min_size_80, + min_size_neg_80, + min_size_96, + min_size_neg_96, + min_size_112, + min_size_neg_112, + min_size_128, + min_size_neg_128, + min_size_auto, + min_size_px, + min_size_neg_px, + min_size_full, + min_size_neg_full, + min_size_1_2, + min_size_neg_1_2, + min_size_1_3, + min_size_neg_1_3, + min_size_2_3, + min_size_neg_2_3, + min_size_1_4, + min_size_neg_1_4, + min_size_2_4, + min_size_neg_2_4, + min_size_3_4, + min_size_neg_3_4, + min_size_1_5, + min_size_neg_1_5, + min_size_2_5, + min_size_neg_2_5, + min_size_3_5, + min_size_neg_3_5, + min_size_4_5, + min_size_neg_4_5, + min_size_1_6, + min_size_neg_1_6, + min_size_5_6, + min_size_neg_5_6, + min_size_1_12, + min_size_neg_1_12, + min_w, + min_w_0, + min_w_neg_0, + min_w_0p5, + min_w_neg_0p5, + min_w_1, + min_w_neg_1, + min_w_1p5, + min_w_neg_1p5, + min_w_2, + min_w_neg_2, + min_w_2p5, + min_w_neg_2p5, + min_w_3, + min_w_neg_3, + min_w_3p5, + min_w_neg_3p5, + min_w_4, + min_w_neg_4, + min_w_5, + min_w_neg_5, + min_w_6, + min_w_neg_6, + min_w_7, + min_w_neg_7, + min_w_8, + min_w_neg_8, + min_w_9, + min_w_neg_9, + min_w_10, + min_w_neg_10, + min_w_11, + min_w_neg_11, + min_w_12, + min_w_neg_12, + min_w_16, + min_w_neg_16, + min_w_20, + min_w_neg_20, + min_w_24, + min_w_neg_24, + min_w_32, + min_w_neg_32, + min_w_40, + min_w_neg_40, + min_w_48, + min_w_neg_48, + min_w_56, + min_w_neg_56, + min_w_64, + min_w_neg_64, + min_w_72, + min_w_neg_72, + min_w_80, + min_w_neg_80, + min_w_96, + min_w_neg_96, + min_w_112, + min_w_neg_112, + min_w_128, + min_w_neg_128, + min_w_auto, + min_w_px, + min_w_neg_px, + min_w_full, + min_w_neg_full, + min_w_1_2, + min_w_neg_1_2, + min_w_1_3, + min_w_neg_1_3, + min_w_2_3, + min_w_neg_2_3, + min_w_1_4, + min_w_neg_1_4, + min_w_2_4, + min_w_neg_2_4, + min_w_3_4, + min_w_neg_3_4, + min_w_1_5, + min_w_neg_1_5, + min_w_2_5, + min_w_neg_2_5, + min_w_3_5, + min_w_neg_3_5, + min_w_4_5, + min_w_neg_4_5, + min_w_1_6, + min_w_neg_1_6, + min_w_5_6, + min_w_neg_5_6, + min_w_1_12, + min_w_neg_1_12, + min_h, + min_h_0, + min_h_neg_0, + min_h_0p5, + min_h_neg_0p5, + min_h_1, + min_h_neg_1, + min_h_1p5, + min_h_neg_1p5, + min_h_2, + min_h_neg_2, + min_h_2p5, + min_h_neg_2p5, + min_h_3, + min_h_neg_3, + min_h_3p5, + min_h_neg_3p5, + min_h_4, + min_h_neg_4, + min_h_5, + min_h_neg_5, + min_h_6, + min_h_neg_6, + min_h_7, + min_h_neg_7, + min_h_8, + min_h_neg_8, + min_h_9, + min_h_neg_9, + min_h_10, + min_h_neg_10, + min_h_11, + min_h_neg_11, + min_h_12, + min_h_neg_12, + min_h_16, + min_h_neg_16, + min_h_20, + min_h_neg_20, + min_h_24, + min_h_neg_24, + min_h_32, + min_h_neg_32, + min_h_40, + min_h_neg_40, + min_h_48, + min_h_neg_48, + min_h_56, + min_h_neg_56, + min_h_64, + min_h_neg_64, + min_h_72, + min_h_neg_72, + min_h_80, + min_h_neg_80, + min_h_96, + min_h_neg_96, + min_h_112, + min_h_neg_112, + min_h_128, + min_h_neg_128, + min_h_auto, + min_h_px, + min_h_neg_px, + min_h_full, + min_h_neg_full, + min_h_1_2, + min_h_neg_1_2, + min_h_1_3, + min_h_neg_1_3, + min_h_2_3, + min_h_neg_2_3, + min_h_1_4, + min_h_neg_1_4, + min_h_2_4, + min_h_neg_2_4, + min_h_3_4, + min_h_neg_3_4, + min_h_1_5, + min_h_neg_1_5, + min_h_2_5, + min_h_neg_2_5, + min_h_3_5, + min_h_neg_3_5, + min_h_4_5, + min_h_neg_4_5, + min_h_1_6, + min_h_neg_1_6, + min_h_5_6, + min_h_neg_5_6, + min_h_1_12, + min_h_neg_1_12, + max_size, + max_size_0, + max_size_neg_0, + max_size_0p5, + max_size_neg_0p5, + max_size_1, + max_size_neg_1, + max_size_1p5, + max_size_neg_1p5, + max_size_2, + max_size_neg_2, + max_size_2p5, + max_size_neg_2p5, + max_size_3, + max_size_neg_3, + max_size_3p5, + max_size_neg_3p5, + max_size_4, + max_size_neg_4, + max_size_5, + max_size_neg_5, + max_size_6, + max_size_neg_6, + max_size_7, + max_size_neg_7, + max_size_8, + max_size_neg_8, + max_size_9, + max_size_neg_9, + max_size_10, + max_size_neg_10, + max_size_11, + max_size_neg_11, + max_size_12, + max_size_neg_12, + max_size_16, + max_size_neg_16, + max_size_20, + max_size_neg_20, + max_size_24, + max_size_neg_24, + max_size_32, + max_size_neg_32, + max_size_40, + max_size_neg_40, + max_size_48, + max_size_neg_48, + max_size_56, + max_size_neg_56, + max_size_64, + max_size_neg_64, + max_size_72, + max_size_neg_72, + max_size_80, + max_size_neg_80, + max_size_96, + max_size_neg_96, + max_size_112, + max_size_neg_112, + max_size_128, + max_size_neg_128, + max_size_auto, + max_size_px, + max_size_neg_px, + max_size_full, + max_size_neg_full, + max_size_1_2, + max_size_neg_1_2, + max_size_1_3, + max_size_neg_1_3, + max_size_2_3, + max_size_neg_2_3, + max_size_1_4, + max_size_neg_1_4, + max_size_2_4, + max_size_neg_2_4, + max_size_3_4, + max_size_neg_3_4, + max_size_1_5, + max_size_neg_1_5, + max_size_2_5, + max_size_neg_2_5, + max_size_3_5, + max_size_neg_3_5, + max_size_4_5, + max_size_neg_4_5, + max_size_1_6, + max_size_neg_1_6, + max_size_5_6, + max_size_neg_5_6, + max_size_1_12, + max_size_neg_1_12, + max_w, + max_w_0, + max_w_neg_0, + max_w_0p5, + max_w_neg_0p5, + max_w_1, + max_w_neg_1, + max_w_1p5, + max_w_neg_1p5, + max_w_2, + max_w_neg_2, + max_w_2p5, + max_w_neg_2p5, + max_w_3, + max_w_neg_3, + max_w_3p5, + max_w_neg_3p5, + max_w_4, + max_w_neg_4, + max_w_5, + max_w_neg_5, + max_w_6, + max_w_neg_6, + max_w_7, + max_w_neg_7, + max_w_8, + max_w_neg_8, + max_w_9, + max_w_neg_9, + max_w_10, + max_w_neg_10, + max_w_11, + max_w_neg_11, + max_w_12, + max_w_neg_12, + max_w_16, + max_w_neg_16, + max_w_20, + max_w_neg_20, + max_w_24, + max_w_neg_24, + max_w_32, + max_w_neg_32, + max_w_40, + max_w_neg_40, + max_w_48, + max_w_neg_48, + max_w_56, + max_w_neg_56, + max_w_64, + max_w_neg_64, + max_w_72, + max_w_neg_72, + max_w_80, + max_w_neg_80, + max_w_96, + max_w_neg_96, + max_w_112, + max_w_neg_112, + max_w_128, + max_w_neg_128, + max_w_auto, + max_w_px, + max_w_neg_px, + max_w_full, + max_w_neg_full, + max_w_1_2, + max_w_neg_1_2, + max_w_1_3, + max_w_neg_1_3, + max_w_2_3, + max_w_neg_2_3, + max_w_1_4, + max_w_neg_1_4, + max_w_2_4, + max_w_neg_2_4, + max_w_3_4, + max_w_neg_3_4, + max_w_1_5, + max_w_neg_1_5, + max_w_2_5, + max_w_neg_2_5, + max_w_3_5, + max_w_neg_3_5, + max_w_4_5, + max_w_neg_4_5, + max_w_1_6, + max_w_neg_1_6, + max_w_5_6, + max_w_neg_5_6, + max_w_1_12, + max_w_neg_1_12, + max_h, + max_h_0, + max_h_neg_0, + max_h_0p5, + max_h_neg_0p5, + max_h_1, + max_h_neg_1, + max_h_1p5, + max_h_neg_1p5, + max_h_2, + max_h_neg_2, + max_h_2p5, + max_h_neg_2p5, + max_h_3, + max_h_neg_3, + max_h_3p5, + max_h_neg_3p5, + max_h_4, + max_h_neg_4, + max_h_5, + max_h_neg_5, + max_h_6, + max_h_neg_6, + max_h_7, + max_h_neg_7, + max_h_8, + max_h_neg_8, + max_h_9, + max_h_neg_9, + max_h_10, + max_h_neg_10, + max_h_11, + max_h_neg_11, + max_h_12, + max_h_neg_12, + max_h_16, + max_h_neg_16, + max_h_20, + max_h_neg_20, + max_h_24, + max_h_neg_24, + max_h_32, + max_h_neg_32, + max_h_40, + max_h_neg_40, + max_h_48, + max_h_neg_48, + max_h_56, + max_h_neg_56, + max_h_64, + max_h_neg_64, + max_h_72, + max_h_neg_72, + max_h_80, + max_h_neg_80, + max_h_96, + max_h_neg_96, + max_h_112, + max_h_neg_112, + max_h_128, + max_h_neg_128, + max_h_auto, + max_h_px, + max_h_neg_px, + max_h_full, + max_h_neg_full, + max_h_1_2, + max_h_neg_1_2, + max_h_1_3, + max_h_neg_1_3, + max_h_2_3, + max_h_neg_2_3, + max_h_1_4, + max_h_neg_1_4, + max_h_2_4, + max_h_neg_2_4, + max_h_3_4, + max_h_neg_3_4, + max_h_1_5, + max_h_neg_1_5, + max_h_2_5, + max_h_neg_2_5, + max_h_3_5, + max_h_neg_3_5, + max_h_4_5, + max_h_neg_4_5, + max_h_1_6, + max_h_neg_1_6, + max_h_5_6, + max_h_neg_5_6, + max_h_1_12, + max_h_neg_1_12, + gap, + gap_0, + gap_neg_0, + gap_0p5, + gap_neg_0p5, + gap_1, + gap_neg_1, + gap_1p5, + gap_neg_1p5, + gap_2, + gap_neg_2, + gap_2p5, + gap_neg_2p5, + gap_3, + gap_neg_3, + gap_3p5, + gap_neg_3p5, + gap_4, + gap_neg_4, + gap_5, + gap_neg_5, + gap_6, + gap_neg_6, + gap_7, + gap_neg_7, + gap_8, + gap_neg_8, + gap_9, + gap_neg_9, + gap_10, + gap_neg_10, + gap_11, + gap_neg_11, + gap_12, + gap_neg_12, + gap_16, + gap_neg_16, + gap_20, + gap_neg_20, + gap_24, + gap_neg_24, + gap_32, + gap_neg_32, + gap_40, + gap_neg_40, + gap_48, + gap_neg_48, + gap_56, + gap_neg_56, + gap_64, + gap_neg_64, + gap_72, + gap_neg_72, + gap_80, + gap_neg_80, + gap_96, + gap_neg_96, + gap_112, + gap_neg_112, + gap_128, + gap_neg_128, + gap_px, + gap_neg_px, + gap_full, + gap_neg_full, + gap_1_2, + gap_neg_1_2, + gap_1_3, + gap_neg_1_3, + gap_2_3, + gap_neg_2_3, + gap_1_4, + gap_neg_1_4, + gap_2_4, + gap_neg_2_4, + gap_3_4, + gap_neg_3_4, + gap_1_5, + gap_neg_1_5, + gap_2_5, + gap_neg_2_5, + gap_3_5, + gap_neg_3_5, + gap_4_5, + gap_neg_4_5, + gap_1_6, + gap_neg_1_6, + gap_5_6, + gap_neg_5_6, + gap_1_12, + gap_neg_1_12, + gap_x, + gap_x_0, + gap_x_neg_0, + gap_x_0p5, + gap_x_neg_0p5, + gap_x_1, + gap_x_neg_1, + gap_x_1p5, + gap_x_neg_1p5, + gap_x_2, + gap_x_neg_2, + gap_x_2p5, + gap_x_neg_2p5, + gap_x_3, + gap_x_neg_3, + gap_x_3p5, + gap_x_neg_3p5, + gap_x_4, + gap_x_neg_4, + gap_x_5, + gap_x_neg_5, + gap_x_6, + gap_x_neg_6, + gap_x_7, + gap_x_neg_7, + gap_x_8, + gap_x_neg_8, + gap_x_9, + gap_x_neg_9, + gap_x_10, + gap_x_neg_10, + gap_x_11, + gap_x_neg_11, + gap_x_12, + gap_x_neg_12, + gap_x_16, + gap_x_neg_16, + gap_x_20, + gap_x_neg_20, + gap_x_24, + gap_x_neg_24, + gap_x_32, + gap_x_neg_32, + gap_x_40, + gap_x_neg_40, + gap_x_48, + gap_x_neg_48, + gap_x_56, + gap_x_neg_56, + gap_x_64, + gap_x_neg_64, + gap_x_72, + gap_x_neg_72, + gap_x_80, + gap_x_neg_80, + gap_x_96, + gap_x_neg_96, + gap_x_112, + gap_x_neg_112, + gap_x_128, + gap_x_neg_128, + gap_x_px, + gap_x_neg_px, + gap_x_full, + gap_x_neg_full, + gap_x_1_2, + gap_x_neg_1_2, + gap_x_1_3, + gap_x_neg_1_3, + gap_x_2_3, + gap_x_neg_2_3, + gap_x_1_4, + gap_x_neg_1_4, + gap_x_2_4, + gap_x_neg_2_4, + gap_x_3_4, + gap_x_neg_3_4, + gap_x_1_5, + gap_x_neg_1_5, + gap_x_2_5, + gap_x_neg_2_5, + gap_x_3_5, + gap_x_neg_3_5, + gap_x_4_5, + gap_x_neg_4_5, + gap_x_1_6, + gap_x_neg_1_6, + gap_x_5_6, + gap_x_neg_5_6, + gap_x_1_12, + gap_x_neg_1_12, + gap_y, + gap_y_0, + gap_y_neg_0, + gap_y_0p5, + gap_y_neg_0p5, + gap_y_1, + gap_y_neg_1, + gap_y_1p5, + gap_y_neg_1p5, + gap_y_2, + gap_y_neg_2, + gap_y_2p5, + gap_y_neg_2p5, + gap_y_3, + gap_y_neg_3, + gap_y_3p5, + gap_y_neg_3p5, + gap_y_4, + gap_y_neg_4, + gap_y_5, + gap_y_neg_5, + gap_y_6, + gap_y_neg_6, + gap_y_7, + gap_y_neg_7, + gap_y_8, + gap_y_neg_8, + gap_y_9, + gap_y_neg_9, + gap_y_10, + gap_y_neg_10, + gap_y_11, + gap_y_neg_11, + gap_y_12, + gap_y_neg_12, + gap_y_16, + gap_y_neg_16, + gap_y_20, + gap_y_neg_20, + gap_y_24, + gap_y_neg_24, + gap_y_32, + gap_y_neg_32, + gap_y_40, + gap_y_neg_40, + gap_y_48, + gap_y_neg_48, + gap_y_56, + gap_y_neg_56, + gap_y_64, + gap_y_neg_64, + gap_y_72, + gap_y_neg_72, + gap_y_80, + gap_y_neg_80, + gap_y_96, + gap_y_neg_96, + gap_y_112, + gap_y_neg_112, + gap_y_128, + gap_y_neg_128, + gap_y_px, + gap_y_neg_px, + gap_y_full, + gap_y_neg_full, + gap_y_1_2, + gap_y_neg_1_2, + gap_y_1_3, + gap_y_neg_1_3, + gap_y_2_3, + gap_y_neg_2_3, + gap_y_1_4, + gap_y_neg_1_4, + gap_y_2_4, + gap_y_neg_2_4, + gap_y_3_4, + gap_y_neg_3_4, + gap_y_1_5, + gap_y_neg_1_5, + gap_y_2_5, + gap_y_neg_2_5, + gap_y_3_5, + gap_y_neg_3_5, + gap_y_4_5, + gap_y_neg_4_5, + gap_y_1_6, + gap_y_neg_1_6, + gap_y_5_6, + gap_y_neg_5_6, + gap_y_1_12, + gap_y_neg_1_12, + m, + m_0, + m_neg_0, + m_0p5, + m_neg_0p5, + m_1, + m_neg_1, + m_1p5, + m_neg_1p5, + m_2, + m_neg_2, + m_2p5, + m_neg_2p5, + m_3, + m_neg_3, + m_3p5, + m_neg_3p5, + m_4, + m_neg_4, + m_5, + m_neg_5, + m_6, + m_neg_6, + m_7, + m_neg_7, + m_8, + m_neg_8, + m_9, + m_neg_9, + m_10, + m_neg_10, + m_11, + m_neg_11, + m_12, + m_neg_12, + m_16, + m_neg_16, + m_20, + m_neg_20, + m_24, + m_neg_24, + m_32, + m_neg_32, + m_40, + m_neg_40, + m_48, + m_neg_48, + m_56, + m_neg_56, + m_64, + m_neg_64, + m_72, + m_neg_72, + m_80, + m_neg_80, + m_96, + m_neg_96, + m_112, + m_neg_112, + m_128, + m_neg_128, + m_auto, + m_px, + m_neg_px, + m_full, + m_neg_full, + m_1_2, + m_neg_1_2, + m_1_3, + m_neg_1_3, + m_2_3, + m_neg_2_3, + m_1_4, + m_neg_1_4, + m_2_4, + m_neg_2_4, + m_3_4, + m_neg_3_4, + m_1_5, + m_neg_1_5, + m_2_5, + m_neg_2_5, + m_3_5, + m_neg_3_5, + m_4_5, + m_neg_4_5, + m_1_6, + m_neg_1_6, + m_5_6, + m_neg_5_6, + m_1_12, + m_neg_1_12, + mt, + mt_0, + mt_neg_0, + mt_0p5, + mt_neg_0p5, + mt_1, + mt_neg_1, + mt_1p5, + mt_neg_1p5, + mt_2, + mt_neg_2, + mt_2p5, + mt_neg_2p5, + mt_3, + mt_neg_3, + mt_3p5, + mt_neg_3p5, + mt_4, + mt_neg_4, + mt_5, + mt_neg_5, + mt_6, + mt_neg_6, + mt_7, + mt_neg_7, + mt_8, + mt_neg_8, + mt_9, + mt_neg_9, + mt_10, + mt_neg_10, + mt_11, + mt_neg_11, + mt_12, + mt_neg_12, + mt_16, + mt_neg_16, + mt_20, + mt_neg_20, + mt_24, + mt_neg_24, + mt_32, + mt_neg_32, + mt_40, + mt_neg_40, + mt_48, + mt_neg_48, + mt_56, + mt_neg_56, + mt_64, + mt_neg_64, + mt_72, + mt_neg_72, + mt_80, + mt_neg_80, + mt_96, + mt_neg_96, + mt_112, + mt_neg_112, + mt_128, + mt_neg_128, + mt_auto, + mt_px, + mt_neg_px, + mt_full, + mt_neg_full, + mt_1_2, + mt_neg_1_2, + mt_1_3, + mt_neg_1_3, + mt_2_3, + mt_neg_2_3, + mt_1_4, + mt_neg_1_4, + mt_2_4, + mt_neg_2_4, + mt_3_4, + mt_neg_3_4, + mt_1_5, + mt_neg_1_5, + mt_2_5, + mt_neg_2_5, + mt_3_5, + mt_neg_3_5, + mt_4_5, + mt_neg_4_5, + mt_1_6, + mt_neg_1_6, + mt_5_6, + mt_neg_5_6, + mt_1_12, + mt_neg_1_12, + mb, + mb_0, + mb_neg_0, + mb_0p5, + mb_neg_0p5, + mb_1, + mb_neg_1, + mb_1p5, + mb_neg_1p5, + mb_2, + mb_neg_2, + mb_2p5, + mb_neg_2p5, + mb_3, + mb_neg_3, + mb_3p5, + mb_neg_3p5, + mb_4, + mb_neg_4, + mb_5, + mb_neg_5, + mb_6, + mb_neg_6, + mb_7, + mb_neg_7, + mb_8, + mb_neg_8, + mb_9, + mb_neg_9, + mb_10, + mb_neg_10, + mb_11, + mb_neg_11, + mb_12, + mb_neg_12, + mb_16, + mb_neg_16, + mb_20, + mb_neg_20, + mb_24, + mb_neg_24, + mb_32, + mb_neg_32, + mb_40, + mb_neg_40, + mb_48, + mb_neg_48, + mb_56, + mb_neg_56, + mb_64, + mb_neg_64, + mb_72, + mb_neg_72, + mb_80, + mb_neg_80, + mb_96, + mb_neg_96, + mb_112, + mb_neg_112, + mb_128, + mb_neg_128, + mb_auto, + mb_px, + mb_neg_px, + mb_full, + mb_neg_full, + mb_1_2, + mb_neg_1_2, + mb_1_3, + mb_neg_1_3, + mb_2_3, + mb_neg_2_3, + mb_1_4, + mb_neg_1_4, + mb_2_4, + mb_neg_2_4, + mb_3_4, + mb_neg_3_4, + mb_1_5, + mb_neg_1_5, + mb_2_5, + mb_neg_2_5, + mb_3_5, + mb_neg_3_5, + mb_4_5, + mb_neg_4_5, + mb_1_6, + mb_neg_1_6, + mb_5_6, + mb_neg_5_6, + mb_1_12, + mb_neg_1_12, + my, + my_0, + my_neg_0, + my_0p5, + my_neg_0p5, + my_1, + my_neg_1, + my_1p5, + my_neg_1p5, + my_2, + my_neg_2, + my_2p5, + my_neg_2p5, + my_3, + my_neg_3, + my_3p5, + my_neg_3p5, + my_4, + my_neg_4, + my_5, + my_neg_5, + my_6, + my_neg_6, + my_7, + my_neg_7, + my_8, + my_neg_8, + my_9, + my_neg_9, + my_10, + my_neg_10, + my_11, + my_neg_11, + my_12, + my_neg_12, + my_16, + my_neg_16, + my_20, + my_neg_20, + my_24, + my_neg_24, + my_32, + my_neg_32, + my_40, + my_neg_40, + my_48, + my_neg_48, + my_56, + my_neg_56, + my_64, + my_neg_64, + my_72, + my_neg_72, + my_80, + my_neg_80, + my_96, + my_neg_96, + my_112, + my_neg_112, + my_128, + my_neg_128, + my_auto, + my_px, + my_neg_px, + my_full, + my_neg_full, + my_1_2, + my_neg_1_2, + my_1_3, + my_neg_1_3, + my_2_3, + my_neg_2_3, + my_1_4, + my_neg_1_4, + my_2_4, + my_neg_2_4, + my_3_4, + my_neg_3_4, + my_1_5, + my_neg_1_5, + my_2_5, + my_neg_2_5, + my_3_5, + my_neg_3_5, + my_4_5, + my_neg_4_5, + my_1_6, + my_neg_1_6, + my_5_6, + my_neg_5_6, + my_1_12, + my_neg_1_12, + mx, + mx_0, + mx_neg_0, + mx_0p5, + mx_neg_0p5, + mx_1, + mx_neg_1, + mx_1p5, + mx_neg_1p5, + mx_2, + mx_neg_2, + mx_2p5, + mx_neg_2p5, + mx_3, + mx_neg_3, + mx_3p5, + mx_neg_3p5, + mx_4, + mx_neg_4, + mx_5, + mx_neg_5, + mx_6, + mx_neg_6, + mx_7, + mx_neg_7, + mx_8, + mx_neg_8, + mx_9, + mx_neg_9, + mx_10, + mx_neg_10, + mx_11, + mx_neg_11, + mx_12, + mx_neg_12, + mx_16, + mx_neg_16, + mx_20, + mx_neg_20, + mx_24, + mx_neg_24, + mx_32, + mx_neg_32, + mx_40, + mx_neg_40, + mx_48, + mx_neg_48, + mx_56, + mx_neg_56, + mx_64, + mx_neg_64, + mx_72, + mx_neg_72, + mx_80, + mx_neg_80, + mx_96, + mx_neg_96, + mx_112, + mx_neg_112, + mx_128, + mx_neg_128, + mx_auto, + mx_px, + mx_neg_px, + mx_full, + mx_neg_full, + mx_1_2, + mx_neg_1_2, + mx_1_3, + mx_neg_1_3, + mx_2_3, + mx_neg_2_3, + mx_1_4, + mx_neg_1_4, + mx_2_4, + mx_neg_2_4, + mx_3_4, + mx_neg_3_4, + mx_1_5, + mx_neg_1_5, + mx_2_5, + mx_neg_2_5, + mx_3_5, + mx_neg_3_5, + mx_4_5, + mx_neg_4_5, + mx_1_6, + mx_neg_1_6, + mx_5_6, + mx_neg_5_6, + mx_1_12, + mx_neg_1_12, + ml, + ml_0, + ml_neg_0, + ml_0p5, + ml_neg_0p5, + ml_1, + ml_neg_1, + ml_1p5, + ml_neg_1p5, + ml_2, + ml_neg_2, + ml_2p5, + ml_neg_2p5, + ml_3, + ml_neg_3, + ml_3p5, + ml_neg_3p5, + ml_4, + ml_neg_4, + ml_5, + ml_neg_5, + ml_6, + ml_neg_6, + ml_7, + ml_neg_7, + ml_8, + ml_neg_8, + ml_9, + ml_neg_9, + ml_10, + ml_neg_10, + ml_11, + ml_neg_11, + ml_12, + ml_neg_12, + ml_16, + ml_neg_16, + ml_20, + ml_neg_20, + ml_24, + ml_neg_24, + ml_32, + ml_neg_32, + ml_40, + ml_neg_40, + ml_48, + ml_neg_48, + ml_56, + ml_neg_56, + ml_64, + ml_neg_64, + ml_72, + ml_neg_72, + ml_80, + ml_neg_80, + ml_96, + ml_neg_96, + ml_112, + ml_neg_112, + ml_128, + ml_neg_128, + ml_auto, + ml_px, + ml_neg_px, + ml_full, + ml_neg_full, + ml_1_2, + ml_neg_1_2, + ml_1_3, + ml_neg_1_3, + ml_2_3, + ml_neg_2_3, + ml_1_4, + ml_neg_1_4, + ml_2_4, + ml_neg_2_4, + ml_3_4, + ml_neg_3_4, + ml_1_5, + ml_neg_1_5, + ml_2_5, + ml_neg_2_5, + ml_3_5, + ml_neg_3_5, + ml_4_5, + ml_neg_4_5, + ml_1_6, + ml_neg_1_6, + ml_5_6, + ml_neg_5_6, + ml_1_12, + ml_neg_1_12, + mr, + mr_0, + mr_neg_0, + mr_0p5, + mr_neg_0p5, + mr_1, + mr_neg_1, + mr_1p5, + mr_neg_1p5, + mr_2, + mr_neg_2, + mr_2p5, + mr_neg_2p5, + mr_3, + mr_neg_3, + mr_3p5, + mr_neg_3p5, + mr_4, + mr_neg_4, + mr_5, + mr_neg_5, + mr_6, + mr_neg_6, + mr_7, + mr_neg_7, + mr_8, + mr_neg_8, + mr_9, + mr_neg_9, + mr_10, + mr_neg_10, + mr_11, + mr_neg_11, + mr_12, + mr_neg_12, + mr_16, + mr_neg_16, + mr_20, + mr_neg_20, + mr_24, + mr_neg_24, + mr_32, + mr_neg_32, + mr_40, + mr_neg_40, + mr_48, + mr_neg_48, + mr_56, + mr_neg_56, + mr_64, + mr_neg_64, + mr_72, + mr_neg_72, + mr_80, + mr_neg_80, + mr_96, + mr_neg_96, + mr_112, + mr_neg_112, + mr_128, + mr_neg_128, + mr_auto, + mr_px, + mr_neg_px, + mr_full, + mr_neg_full, + mr_1_2, + mr_neg_1_2, + mr_1_3, + mr_neg_1_3, + mr_2_3, + mr_neg_2_3, + mr_1_4, + mr_neg_1_4, + mr_2_4, + mr_neg_2_4, + mr_3_4, + mr_neg_3_4, + mr_1_5, + mr_neg_1_5, + mr_2_5, + mr_neg_2_5, + mr_3_5, + mr_neg_3_5, + mr_4_5, + mr_neg_4_5, + mr_1_6, + mr_neg_1_6, + mr_5_6, + mr_neg_5_6, + mr_1_12, + mr_neg_1_12, + p, + p_0, + p_neg_0, + p_0p5, + p_neg_0p5, + p_1, + p_neg_1, + p_1p5, + p_neg_1p5, + p_2, + p_neg_2, + p_2p5, + p_neg_2p5, + p_3, + p_neg_3, + p_3p5, + p_neg_3p5, + p_4, + p_neg_4, + p_5, + p_neg_5, + p_6, + p_neg_6, + p_7, + p_neg_7, + p_8, + p_neg_8, + p_9, + p_neg_9, + p_10, + p_neg_10, + p_11, + p_neg_11, + p_12, + p_neg_12, + p_16, + p_neg_16, + p_20, + p_neg_20, + p_24, + p_neg_24, + p_32, + p_neg_32, + p_40, + p_neg_40, + p_48, + p_neg_48, + p_56, + p_neg_56, + p_64, + p_neg_64, + p_72, + p_neg_72, + p_80, + p_neg_80, + p_96, + p_neg_96, + p_112, + p_neg_112, + p_128, + p_neg_128, + p_px, + p_neg_px, + p_full, + p_neg_full, + p_1_2, + p_neg_1_2, + p_1_3, + p_neg_1_3, + p_2_3, + p_neg_2_3, + p_1_4, + p_neg_1_4, + p_2_4, + p_neg_2_4, + p_3_4, + p_neg_3_4, + p_1_5, + p_neg_1_5, + p_2_5, + p_neg_2_5, + p_3_5, + p_neg_3_5, + p_4_5, + p_neg_4_5, + p_1_6, + p_neg_1_6, + p_5_6, + p_neg_5_6, + p_1_12, + p_neg_1_12, + pt, + pt_0, + pt_neg_0, + pt_0p5, + pt_neg_0p5, + pt_1, + pt_neg_1, + pt_1p5, + pt_neg_1p5, + pt_2, + pt_neg_2, + pt_2p5, + pt_neg_2p5, + pt_3, + pt_neg_3, + pt_3p5, + pt_neg_3p5, + pt_4, + pt_neg_4, + pt_5, + pt_neg_5, + pt_6, + pt_neg_6, + pt_7, + pt_neg_7, + pt_8, + pt_neg_8, + pt_9, + pt_neg_9, + pt_10, + pt_neg_10, + pt_11, + pt_neg_11, + pt_12, + pt_neg_12, + pt_16, + pt_neg_16, + pt_20, + pt_neg_20, + pt_24, + pt_neg_24, + pt_32, + pt_neg_32, + pt_40, + pt_neg_40, + pt_48, + pt_neg_48, + pt_56, + pt_neg_56, + pt_64, + pt_neg_64, + pt_72, + pt_neg_72, + pt_80, + pt_neg_80, + pt_96, + pt_neg_96, + pt_112, + pt_neg_112, + pt_128, + pt_neg_128, + pt_px, + pt_neg_px, + pt_full, + pt_neg_full, + pt_1_2, + pt_neg_1_2, + pt_1_3, + pt_neg_1_3, + pt_2_3, + pt_neg_2_3, + pt_1_4, + pt_neg_1_4, + pt_2_4, + pt_neg_2_4, + pt_3_4, + pt_neg_3_4, + pt_1_5, + pt_neg_1_5, + pt_2_5, + pt_neg_2_5, + pt_3_5, + pt_neg_3_5, + pt_4_5, + pt_neg_4_5, + pt_1_6, + pt_neg_1_6, + pt_5_6, + pt_neg_5_6, + pt_1_12, + pt_neg_1_12, + pb, + pb_0, + pb_neg_0, + pb_0p5, + pb_neg_0p5, + pb_1, + pb_neg_1, + pb_1p5, + pb_neg_1p5, + pb_2, + pb_neg_2, + pb_2p5, + pb_neg_2p5, + pb_3, + pb_neg_3, + pb_3p5, + pb_neg_3p5, + pb_4, + pb_neg_4, + pb_5, + pb_neg_5, + pb_6, + pb_neg_6, + pb_7, + pb_neg_7, + pb_8, + pb_neg_8, + pb_9, + pb_neg_9, + pb_10, + pb_neg_10, + pb_11, + pb_neg_11, + pb_12, + pb_neg_12, + pb_16, + pb_neg_16, + pb_20, + pb_neg_20, + pb_24, + pb_neg_24, + pb_32, + pb_neg_32, + pb_40, + pb_neg_40, + pb_48, + pb_neg_48, + pb_56, + pb_neg_56, + pb_64, + pb_neg_64, + pb_72, + pb_neg_72, + pb_80, + pb_neg_80, + pb_96, + pb_neg_96, + pb_112, + pb_neg_112, + pb_128, + pb_neg_128, + pb_px, + pb_neg_px, + pb_full, + pb_neg_full, + pb_1_2, + pb_neg_1_2, + pb_1_3, + pb_neg_1_3, + pb_2_3, + pb_neg_2_3, + pb_1_4, + pb_neg_1_4, + pb_2_4, + pb_neg_2_4, + pb_3_4, + pb_neg_3_4, + pb_1_5, + pb_neg_1_5, + pb_2_5, + pb_neg_2_5, + pb_3_5, + pb_neg_3_5, + pb_4_5, + pb_neg_4_5, + pb_1_6, + pb_neg_1_6, + pb_5_6, + pb_neg_5_6, + pb_1_12, + pb_neg_1_12, + px, + px_0, + px_neg_0, + px_0p5, + px_neg_0p5, + px_1, + px_neg_1, + px_1p5, + px_neg_1p5, + px_2, + px_neg_2, + px_2p5, + px_neg_2p5, + px_3, + px_neg_3, + px_3p5, + px_neg_3p5, + px_4, + px_neg_4, + px_5, + px_neg_5, + px_6, + px_neg_6, + px_7, + px_neg_7, + px_8, + px_neg_8, + px_9, + px_neg_9, + px_10, + px_neg_10, + px_11, + px_neg_11, + px_12, + px_neg_12, + px_16, + px_neg_16, + px_20, + px_neg_20, + px_24, + px_neg_24, + px_32, + px_neg_32, + px_40, + px_neg_40, + px_48, + px_neg_48, + px_56, + px_neg_56, + px_64, + px_neg_64, + px_72, + px_neg_72, + px_80, + px_neg_80, + px_96, + px_neg_96, + px_112, + px_neg_112, + px_128, + px_neg_128, + px_px, + px_neg_px, + px_full, + px_neg_full, + px_1_2, + px_neg_1_2, + px_1_3, + px_neg_1_3, + px_2_3, + px_neg_2_3, + px_1_4, + px_neg_1_4, + px_2_4, + px_neg_2_4, + px_3_4, + px_neg_3_4, + px_1_5, + px_neg_1_5, + px_2_5, + px_neg_2_5, + px_3_5, + px_neg_3_5, + px_4_5, + px_neg_4_5, + px_1_6, + px_neg_1_6, + px_5_6, + px_neg_5_6, + px_1_12, + px_neg_1_12, + py, + py_0, + py_neg_0, + py_0p5, + py_neg_0p5, + py_1, + py_neg_1, + py_1p5, + py_neg_1p5, + py_2, + py_neg_2, + py_2p5, + py_neg_2p5, + py_3, + py_neg_3, + py_3p5, + py_neg_3p5, + py_4, + py_neg_4, + py_5, + py_neg_5, + py_6, + py_neg_6, + py_7, + py_neg_7, + py_8, + py_neg_8, + py_9, + py_neg_9, + py_10, + py_neg_10, + py_11, + py_neg_11, + py_12, + py_neg_12, + py_16, + py_neg_16, + py_20, + py_neg_20, + py_24, + py_neg_24, + py_32, + py_neg_32, + py_40, + py_neg_40, + py_48, + py_neg_48, + py_56, + py_neg_56, + py_64, + py_neg_64, + py_72, + py_neg_72, + py_80, + py_neg_80, + py_96, + py_neg_96, + py_112, + py_neg_112, + py_128, + py_neg_128, + py_px, + py_neg_px, + py_full, + py_neg_full, + py_1_2, + py_neg_1_2, + py_1_3, + py_neg_1_3, + py_2_3, + py_neg_2_3, + py_1_4, + py_neg_1_4, + py_2_4, + py_neg_2_4, + py_3_4, + py_neg_3_4, + py_1_5, + py_neg_1_5, + py_2_5, + py_neg_2_5, + py_3_5, + py_neg_3_5, + py_4_5, + py_neg_4_5, + py_1_6, + py_neg_1_6, + py_5_6, + py_neg_5_6, + py_1_12, + py_neg_1_12, + pl, + pl_0, + pl_neg_0, + pl_0p5, + pl_neg_0p5, + pl_1, + pl_neg_1, + pl_1p5, + pl_neg_1p5, + pl_2, + pl_neg_2, + pl_2p5, + pl_neg_2p5, + pl_3, + pl_neg_3, + pl_3p5, + pl_neg_3p5, + pl_4, + pl_neg_4, + pl_5, + pl_neg_5, + pl_6, + pl_neg_6, + pl_7, + pl_neg_7, + pl_8, + pl_neg_8, + pl_9, + pl_neg_9, + pl_10, + pl_neg_10, + pl_11, + pl_neg_11, + pl_12, + pl_neg_12, + pl_16, + pl_neg_16, + pl_20, + pl_neg_20, + pl_24, + pl_neg_24, + pl_32, + pl_neg_32, + pl_40, + pl_neg_40, + pl_48, + pl_neg_48, + pl_56, + pl_neg_56, + pl_64, + pl_neg_64, + pl_72, + pl_neg_72, + pl_80, + pl_neg_80, + pl_96, + pl_neg_96, + pl_112, + pl_neg_112, + pl_128, + pl_neg_128, + pl_px, + pl_neg_px, + pl_full, + pl_neg_full, + pl_1_2, + pl_neg_1_2, + pl_1_3, + pl_neg_1_3, + pl_2_3, + pl_neg_2_3, + pl_1_4, + pl_neg_1_4, + pl_2_4, + pl_neg_2_4, + pl_3_4, + pl_neg_3_4, + pl_1_5, + pl_neg_1_5, + pl_2_5, + pl_neg_2_5, + pl_3_5, + pl_neg_3_5, + pl_4_5, + pl_neg_4_5, + pl_1_6, + pl_neg_1_6, + pl_5_6, + pl_neg_5_6, + pl_1_12, + pl_neg_1_12, + pr, + pr_0, + pr_neg_0, + pr_0p5, + pr_neg_0p5, + pr_1, + pr_neg_1, + pr_1p5, + pr_neg_1p5, + pr_2, + pr_neg_2, + pr_2p5, + pr_neg_2p5, + pr_3, + pr_neg_3, + pr_3p5, + pr_neg_3p5, + pr_4, + pr_neg_4, + pr_5, + pr_neg_5, + pr_6, + pr_neg_6, + pr_7, + pr_neg_7, + pr_8, + pr_neg_8, + pr_9, + pr_neg_9, + pr_10, + pr_neg_10, + pr_11, + pr_neg_11, + pr_12, + pr_neg_12, + pr_16, + pr_neg_16, + pr_20, + pr_neg_20, + pr_24, + pr_neg_24, + pr_32, + pr_neg_32, + pr_40, + pr_neg_40, + pr_48, + pr_neg_48, + pr_56, + pr_neg_56, + pr_64, + pr_neg_64, + pr_72, + pr_neg_72, + pr_80, + pr_neg_80, + pr_96, + pr_neg_96, + pr_112, + pr_neg_112, + pr_128, + pr_neg_128, + pr_px, + pr_neg_px, + pr_full, + pr_neg_full, + pr_1_2, + pr_neg_1_2, + pr_1_3, + pr_neg_1_3, + pr_2_3, + pr_neg_2_3, + pr_1_4, + pr_neg_1_4, + pr_2_4, + pr_neg_2_4, + pr_3_4, + pr_neg_3_4, + pr_1_5, + pr_neg_1_5, + pr_2_5, + pr_neg_2_5, + pr_3_5, + pr_neg_3_5, + pr_4_5, + pr_neg_4_5, + pr_1_6, + pr_neg_1_6, + pr_5_6, + pr_neg_5_6, + pr_1_12, + pr_neg_1_12, + inset, + inset_0, + inset_neg_0, + inset_0p5, + inset_neg_0p5, + inset_1, + inset_neg_1, + inset_1p5, + inset_neg_1p5, + inset_2, + inset_neg_2, + inset_2p5, + inset_neg_2p5, + inset_3, + inset_neg_3, + inset_3p5, + inset_neg_3p5, + inset_4, + inset_neg_4, + inset_5, + inset_neg_5, + inset_6, + inset_neg_6, + inset_7, + inset_neg_7, + inset_8, + inset_neg_8, + inset_9, + inset_neg_9, + inset_10, + inset_neg_10, + inset_11, + inset_neg_11, + inset_12, + inset_neg_12, + inset_16, + inset_neg_16, + inset_20, + inset_neg_20, + inset_24, + inset_neg_24, + inset_32, + inset_neg_32, + inset_40, + inset_neg_40, + inset_48, + inset_neg_48, + inset_56, + inset_neg_56, + inset_64, + inset_neg_64, + inset_72, + inset_neg_72, + inset_80, + inset_neg_80, + inset_96, + inset_neg_96, + inset_112, + inset_neg_112, + inset_128, + inset_neg_128, + inset_auto, + inset_px, + inset_neg_px, + inset_full, + inset_neg_full, + inset_1_2, + inset_neg_1_2, + inset_1_3, + inset_neg_1_3, + inset_2_3, + inset_neg_2_3, + inset_1_4, + inset_neg_1_4, + inset_2_4, + inset_neg_2_4, + inset_3_4, + inset_neg_3_4, + inset_1_5, + inset_neg_1_5, + inset_2_5, + inset_neg_2_5, + inset_3_5, + inset_neg_3_5, + inset_4_5, + inset_neg_4_5, + inset_1_6, + inset_neg_1_6, + inset_5_6, + inset_neg_5_6, + inset_1_12, + inset_neg_1_12, + top, + top_0, + top_neg_0, + top_0p5, + top_neg_0p5, + top_1, + top_neg_1, + top_1p5, + top_neg_1p5, + top_2, + top_neg_2, + top_2p5, + top_neg_2p5, + top_3, + top_neg_3, + top_3p5, + top_neg_3p5, + top_4, + top_neg_4, + top_5, + top_neg_5, + top_6, + top_neg_6, + top_7, + top_neg_7, + top_8, + top_neg_8, + top_9, + top_neg_9, + top_10, + top_neg_10, + top_11, + top_neg_11, + top_12, + top_neg_12, + top_16, + top_neg_16, + top_20, + top_neg_20, + top_24, + top_neg_24, + top_32, + top_neg_32, + top_40, + top_neg_40, + top_48, + top_neg_48, + top_56, + top_neg_56, + top_64, + top_neg_64, + top_72, + top_neg_72, + top_80, + top_neg_80, + top_96, + top_neg_96, + top_112, + top_neg_112, + top_128, + top_neg_128, + top_auto, + top_px, + top_neg_px, + top_full, + top_neg_full, + top_1_2, + top_neg_1_2, + top_1_3, + top_neg_1_3, + top_2_3, + top_neg_2_3, + top_1_4, + top_neg_1_4, + top_2_4, + top_neg_2_4, + top_3_4, + top_neg_3_4, + top_1_5, + top_neg_1_5, + top_2_5, + top_neg_2_5, + top_3_5, + top_neg_3_5, + top_4_5, + top_neg_4_5, + top_1_6, + top_neg_1_6, + top_5_6, + top_neg_5_6, + top_1_12, + top_neg_1_12, + bottom, + bottom_0, + bottom_neg_0, + bottom_0p5, + bottom_neg_0p5, + bottom_1, + bottom_neg_1, + bottom_1p5, + bottom_neg_1p5, + bottom_2, + bottom_neg_2, + bottom_2p5, + bottom_neg_2p5, + bottom_3, + bottom_neg_3, + bottom_3p5, + bottom_neg_3p5, + bottom_4, + bottom_neg_4, + bottom_5, + bottom_neg_5, + bottom_6, + bottom_neg_6, + bottom_7, + bottom_neg_7, + bottom_8, + bottom_neg_8, + bottom_9, + bottom_neg_9, + bottom_10, + bottom_neg_10, + bottom_11, + bottom_neg_11, + bottom_12, + bottom_neg_12, + bottom_16, + bottom_neg_16, + bottom_20, + bottom_neg_20, + bottom_24, + bottom_neg_24, + bottom_32, + bottom_neg_32, + bottom_40, + bottom_neg_40, + bottom_48, + bottom_neg_48, + bottom_56, + bottom_neg_56, + bottom_64, + bottom_neg_64, + bottom_72, + bottom_neg_72, + bottom_80, + bottom_neg_80, + bottom_96, + bottom_neg_96, + bottom_112, + bottom_neg_112, + bottom_128, + bottom_neg_128, + bottom_auto, + bottom_px, + bottom_neg_px, + bottom_full, + bottom_neg_full, + bottom_1_2, + bottom_neg_1_2, + bottom_1_3, + bottom_neg_1_3, + bottom_2_3, + bottom_neg_2_3, + bottom_1_4, + bottom_neg_1_4, + bottom_2_4, + bottom_neg_2_4, + bottom_3_4, + bottom_neg_3_4, + bottom_1_5, + bottom_neg_1_5, + bottom_2_5, + bottom_neg_2_5, + bottom_3_5, + bottom_neg_3_5, + bottom_4_5, + bottom_neg_4_5, + bottom_1_6, + bottom_neg_1_6, + bottom_5_6, + bottom_neg_5_6, + bottom_1_12, + bottom_neg_1_12, + left, + left_0, + left_neg_0, + left_0p5, + left_neg_0p5, + left_1, + left_neg_1, + left_1p5, + left_neg_1p5, + left_2, + left_neg_2, + left_2p5, + left_neg_2p5, + left_3, + left_neg_3, + left_3p5, + left_neg_3p5, + left_4, + left_neg_4, + left_5, + left_neg_5, + left_6, + left_neg_6, + left_7, + left_neg_7, + left_8, + left_neg_8, + left_9, + left_neg_9, + left_10, + left_neg_10, + left_11, + left_neg_11, + left_12, + left_neg_12, + left_16, + left_neg_16, + left_20, + left_neg_20, + left_24, + left_neg_24, + left_32, + left_neg_32, + left_40, + left_neg_40, + left_48, + left_neg_48, + left_56, + left_neg_56, + left_64, + left_neg_64, + left_72, + left_neg_72, + left_80, + left_neg_80, + left_96, + left_neg_96, + left_112, + left_neg_112, + left_128, + left_neg_128, + left_auto, + left_px, + left_neg_px, + left_full, + left_neg_full, + left_1_2, + left_neg_1_2, + left_1_3, + left_neg_1_3, + left_2_3, + left_neg_2_3, + left_1_4, + left_neg_1_4, + left_2_4, + left_neg_2_4, + left_3_4, + left_neg_3_4, + left_1_5, + left_neg_1_5, + left_2_5, + left_neg_2_5, + left_3_5, + left_neg_3_5, + left_4_5, + left_neg_4_5, + left_1_6, + left_neg_1_6, + left_5_6, + left_neg_5_6, + left_1_12, + left_neg_1_12, + right, + right_0, + right_neg_0, + right_0p5, + right_neg_0p5, + right_1, + right_neg_1, + right_1p5, + right_neg_1p5, + right_2, + right_neg_2, + right_2p5, + right_neg_2p5, + right_3, + right_neg_3, + right_3p5, + right_neg_3p5, + right_4, + right_neg_4, + right_5, + right_neg_5, + right_6, + right_neg_6, + right_7, + right_neg_7, + right_8, + right_neg_8, + right_9, + right_neg_9, + right_10, + right_neg_10, + right_11, + right_neg_11, + right_12, + right_neg_12, + right_16, + right_neg_16, + right_20, + right_neg_20, + right_24, + right_neg_24, + right_32, + right_neg_32, + right_40, + right_neg_40, + right_48, + right_neg_48, + right_56, + right_neg_56, + right_64, + right_neg_64, + right_72, + right_neg_72, + right_80, + right_neg_80, + right_96, + right_neg_96, + right_112, + right_neg_112, + right_128, + right_neg_128, + right_auto, + right_px, + right_neg_px, + right_full, + right_neg_full, + right_1_2, + right_neg_1_2, + right_1_3, + right_neg_1_3, + right_2_3, + right_neg_2_3, + right_1_4, + right_neg_1_4, + right_2_4, + right_neg_2_4, + right_3_4, + right_neg_3_4, + right_1_5, + right_neg_1_5, + right_2_5, + right_neg_2_5, + right_3_5, + right_neg_3_5, + right_4_5, + right_neg_4_5, + right_1_6, + right_neg_1_6, + right_5_6, + right_neg_5_6, + right_1_12, + right_neg_1_12, + rounded, + rounded_none, + rounded_xs, + rounded_sm, + rounded_md, + rounded_lg, + rounded_xl, + rounded_2xl, + rounded_3xl, + rounded_full, + rounded_t, + rounded_t_none, + rounded_t_xs, + rounded_t_sm, + rounded_t_md, + rounded_t_lg, + rounded_t_xl, + rounded_t_2xl, + rounded_t_3xl, + rounded_t_full, + rounded_b, + rounded_b_none, + rounded_b_xs, + rounded_b_sm, + rounded_b_md, + rounded_b_lg, + rounded_b_xl, + rounded_b_2xl, + rounded_b_3xl, + rounded_b_full, + rounded_r, + rounded_r_none, + rounded_r_xs, + rounded_r_sm, + rounded_r_md, + rounded_r_lg, + rounded_r_xl, + rounded_r_2xl, + rounded_r_3xl, + rounded_r_full, + rounded_l, + rounded_l_none, + rounded_l_xs, + rounded_l_sm, + rounded_l_md, + rounded_l_lg, + rounded_l_xl, + rounded_l_2xl, + rounded_l_3xl, + rounded_l_full, + rounded_tl, + rounded_tl_none, + rounded_tl_xs, + rounded_tl_sm, + rounded_tl_md, + rounded_tl_lg, + rounded_tl_xl, + rounded_tl_2xl, + rounded_tl_3xl, + rounded_tl_full, + rounded_tr, + rounded_tr_none, + rounded_tr_xs, + rounded_tr_sm, + rounded_tr_md, + rounded_tr_lg, + rounded_tr_xl, + rounded_tr_2xl, + rounded_tr_3xl, + rounded_tr_full, + rounded_bl, + rounded_bl_none, + rounded_bl_xs, + rounded_bl_sm, + rounded_bl_md, + rounded_bl_lg, + rounded_bl_xl, + rounded_bl_2xl, + rounded_bl_3xl, + rounded_bl_full, + rounded_br, + rounded_br_none, + rounded_br_xs, + rounded_br_sm, + rounded_br_md, + rounded_br_lg, + rounded_br_xl, + rounded_br_2xl, + rounded_br_3xl, + rounded_br_full, + border, + border_0, + border_1, + border_2, + border_3, + border_4, + border_5, + border_6, + border_7, + border_8, + border_9, + border_10, + border_11, + border_12, + border_16, + border_20, + border_24, + border_32, + border_t, + border_t_0, + border_t_1, + border_t_2, + border_t_3, + border_t_4, + border_t_5, + border_t_6, + border_t_7, + border_t_8, + border_t_9, + border_t_10, + border_t_11, + border_t_12, + border_t_16, + border_t_20, + border_t_24, + border_t_32, + border_b, + border_b_0, + border_b_1, + border_b_2, + border_b_3, + border_b_4, + border_b_5, + border_b_6, + border_b_7, + border_b_8, + border_b_9, + border_b_10, + border_b_11, + border_b_12, + border_b_16, + border_b_20, + border_b_24, + border_b_32, + border_r, + border_r_0, + border_r_1, + border_r_2, + border_r_3, + border_r_4, + border_r_5, + border_r_6, + border_r_7, + border_r_8, + border_r_9, + border_r_10, + border_r_11, + border_r_12, + border_r_16, + border_r_20, + border_r_24, + border_r_32, + border_l, + border_l_0, + border_l_1, + border_l_2, + border_l_3, + border_l_4, + border_l_5, + border_l_6, + border_l_7, + border_l_8, + border_l_9, + border_l_10, + border_l_11, + border_l_12, + border_l_16, + border_l_20, + border_l_24, + border_l_32, + border_x, + border_x_0, + border_x_1, + border_x_2, + border_x_3, + border_x_4, + border_x_5, + border_x_6, + border_x_7, + border_x_8, + border_x_9, + border_x_10, + border_x_11, + border_x_12, + border_x_16, + border_x_20, + border_x_24, + border_x_32, + border_y, + border_y_0, + border_y_1, + border_y_2, + border_y_3, + border_y_4, + border_y_5, + border_y_6, + border_y_7, + border_y_8, + border_y_9, + border_y_10, + border_y_11, + border_y_12, + border_y_16, + border_y_20, + border_y_24, + border_y_32, + cursor_default, + cursor_pointer, + cursor_text, + cursor_move, + cursor_not_allowed, + cursor_context_menu, + cursor_crosshair, + cursor_vertical_text, + cursor_alias, + cursor_copy, + cursor_no_drop, + cursor_grab, + cursor_grabbing, + cursor_ew_resize, + cursor_ns_resize, + cursor_nesw_resize, + cursor_nwse_resize, + cursor_col_resize, + cursor_row_resize, + cursor_n_resize, + cursor_e_resize, + cursor_s_resize, + cursor_w_resize, +} diff --git a/src/elements/div.mbt b/src/elements/div.mbt new file mode 100644 index 0000000..d4911f3 --- /dev/null +++ b/src/elements/div.mbt @@ -0,0 +1,355 @@ +// `div()`, ported from gpui/src/elements/div.rs (`Div` and the parts of +// `Interactivity` that need neither focus nor actions). +// +// Ported: styles (via `Styled`), children, hover styles, mouse down/up/move +// and scroll listeners, clicks (which need an element id), hitbox +// occlusion, overflow clipping and opacity. +// +// Not ported yet: focus and key listeners and actions (M5/M10), active and +// group styles, drag and drop, tooltips, scrolling state, and the +// `Stateful
` split (an id is set with `.id(...)` on `Div` itself, and +// `on_click` fails loudly without one). +// +// Deviation: hover styles apply at paint time only. GPUI also lays out with +// them (using the previous frame's hover state); here hovering cannot change +// an element's layout. + +///| +/// A flexible container: GPUI's workhorse element (`div()`). +pub struct Div { + priv base_style : @style.StyleRefinement + priv mut hover_style : @style.StyleRefinement? + priv mut element_id : String? + priv mut occlude_mouse : Bool + priv children : Array[@window.AnyElement] + priv mouse_down_listeners : Array[ + ( + @input.MouseButton, + (@input.MouseDownEvent, @window.Window, @app.App) -> Unit, + ), + ] + priv mouse_up_listeners : Array[ + ( + @input.MouseButton, + (@input.MouseUpEvent, @window.Window, @app.App) -> Unit, + ), + ] + priv mouse_move_listeners : Array[ + (@input.MouseMoveEvent, @window.Window, @app.App) -> Unit, + ] + priv scroll_listeners : Array[ + (@input.ScrollWheelEvent, @window.Window, @app.App) -> Unit, + ] + priv click_listeners : Array[ + (@input.ClickEvent, @window.Window, @app.App) -> Unit, + ] + // Per-frame state. + priv mut layout_style : @style.Style? + priv mut hitbox : @window.Hitbox? +} + +///| +/// A new, empty `div`. +pub fn div() -> Div { + { + base_style: @style.StyleRefinement::new(), + hover_style: None, + element_id: None, + occlude_mouse: false, + children: [], + mouse_down_listeners: [], + mouse_up_listeners: [], + mouse_move_listeners: [], + scroll_listeners: [], + click_listeners: [], + layout_style: None, + hitbox: None, + } +} + +///| +pub impl @style.Styled for Div with fn style(self) { + self.base_style +} + +///| +pub impl @window.IntoElement for Div with fn into_any_element(self) { + @window.AnyElement::new(self) +} + +///| +pub extend Div with @window.IntoElement::{into_any_element} + +///| +/// Gives the element an id, which makes it stateful (needed for clicks). +/// Ids are scoped to the parent's id (GPUI: `.id(...)`). +pub fn Div::id(self : Div, id : String) -> Div { + self.element_id = Some(id) + self +} + +///| +/// Adds a child (GPUI: `ParentElement::child`). +pub fn[E : @window.IntoElement] Div::child(self : Div, child : E) -> Div { + self.children.push(child.into_any_element()) + self +} + +///| +/// Adds children (GPUI: `ParentElement::children`). +pub fn[E : @window.IntoElement] Div::children( + self : Div, + children : Array[E], +) -> Div { + for child in children { + self.children.push(child.into_any_element()) + } + self +} + +///| +/// Styles applied while the mouse is over the element (GPUI: `.hover(...)`). +pub fn Div::hover( + self : Div, + f : (@style.StyleRefinement) -> @style.StyleRefinement, +) -> Div { + let current = match self.hover_style { + Some(style) => style + None => @style.StyleRefinement::new() + } + self.hover_style = Some(f(current)) + self +} + +///| +/// Hitboxes painted below this element are not hovered (GPUI: +/// `.occlude()`). +pub fn Div::occlude(self : Div) -> Div { + self.occlude_mouse = true + self +} + +///| +/// Called when `button` is pressed over the element (bubble phase). +pub fn Div::on_mouse_down( + self : Div, + button : @input.MouseButton, + listener : (@input.MouseDownEvent, @window.Window, @app.App) -> Unit, +) -> Div { + self.mouse_down_listeners.push((button, listener)) + self +} + +///| +/// Called when `button` is released over the element (bubble phase). +pub fn Div::on_mouse_up( + self : Div, + button : @input.MouseButton, + listener : (@input.MouseUpEvent, @window.Window, @app.App) -> Unit, +) -> Div { + self.mouse_up_listeners.push((button, listener)) + self +} + +///| +/// Called when the mouse moves over the element (bubble phase). +pub fn Div::on_mouse_move( + self : Div, + listener : (@input.MouseMoveEvent, @window.Window, @app.App) -> Unit, +) -> Div { + self.mouse_move_listeners.push(listener) + self +} + +///| +/// Called on scroll-wheel events over the element (bubble phase). +pub fn Div::on_scroll_wheel( + self : Div, + listener : (@input.ScrollWheelEvent, @window.Window, @app.App) -> Unit, +) -> Div { + self.scroll_listeners.push(listener) + self +} + +///| +/// Called when the left button is pressed and released over the element. +/// The element needs an id (GPUI: `StatefulInteractiveElement::on_click`). +pub fn Div::on_click( + self : Div, + listener : (@input.ClickEvent, @window.Window, @app.App) -> Unit, +) -> Div { + self.click_listeners.push(listener) + self +} + +///| +fn Div::is_interactive(self : Div) -> Bool { + self.hover_style is Some(_) || + self.occlude_mouse || + !self.mouse_down_listeners.is_empty() || + !self.mouse_up_listeners.is_empty() || + !self.mouse_move_listeners.is_empty() || + !self.scroll_listeners.is_empty() || + !self.click_listeners.is_empty() +} + +///| +/// The pending press of a click, kept across frames. +priv struct ClickState { + mut pending : @input.MouseDownEvent? +} + +///| +let click_state_key : @window.ElementStateKey[ClickState] = @window.ElementStateKey::new( + "ClickState", +) + +///| +impl @window.Element for Div with fn request_layout(self, window, app) { + let style = (Default::default() : @style.Style).refined(self.base_style) + self.layout_style = Some(style) + window.with_element_id(self.element_id, fn() { + let child_ids = self.children.map(fn(child) { + child.request_layout(window, app) + }) + window.request_layout(style, child_ids) + }) +} + +///| +impl @window.Element for Div with fn prepaint(self, bounds, window, app) { + guard self.layout_style is Some(style) else { + abort("div prepainted before layout") + } + window.with_element_id(self.element_id, fn() { + if self.is_interactive() { + let behavior : @window.HitboxBehavior = if self.occlude_mouse { + BlockMouse + } else { + Normal + } + self.hitbox = Some(window.insert_hitbox(bounds, behavior)) + } + window.with_content_mask(style.overflow_mask(bounds, window.rem_size()), fn() { + for child in self.children { + child.prepaint(window, app) + } + }) + }) +} + +///| +impl @window.Element for Div with fn paint(self, bounds, window, app) { + guard self.layout_style is Some(layout_style) else { + abort("div painted before layout") + } + let hovered = match self.hitbox { + Some(hitbox) => hitbox.is_hovered(window) + None => false + } + let style = match (self.hover_style, hovered) { + (Some(hover), true) => layout_style.refined(hover) + _ => layout_style + } + window.with_element_id(self.element_id, fn() { + if self.hitbox is Some(hitbox) { + self.register_listeners(hitbox, window) + } + window.with_element_opacity(style.opacity, fn() { + window.paint_style(style, bounds, fn() { + window.with_content_mask( + style.overflow_mask(bounds, window.rem_size()), + fn() { + for child in self.children { + child.paint(window, app) + } + }, + ) + }) + }) + }) +} + +///| +fn Div::register_listeners( + self : Div, + hitbox : @window.Hitbox, + window : @window.Window, +) -> Unit { + for entry in self.mouse_down_listeners { + let (button, listener) = entry + window.on_mouse_event(fn(event, phase, window, app) { + if phase == Bubble && + event is MouseDown(down) && + down.button == button && + hitbox.is_hovered(window) { + listener(down, window, app) + } + }) + } + for entry in self.mouse_up_listeners { + let (button, listener) = entry + window.on_mouse_event(fn(event, phase, window, app) { + if phase == Bubble && + event is MouseUp(up) && + up.button == button && + hitbox.is_hovered(window) { + listener(up, window, app) + } + }) + } + for listener in self.mouse_move_listeners { + window.on_mouse_event(fn(event, phase, window, app) { + if phase == Bubble && + event is MouseMove(moved) && + hitbox.is_hovered(window) { + listener(moved, window, app) + } + }) + } + for listener in self.scroll_listeners { + window.on_mouse_event(fn(event, phase, window, app) { + if phase == Bubble && + event is ScrollWheel(scroll) && + hitbox.is_hovered(window) { + listener(scroll, window, app) + } + }) + } + if !self.click_listeners.is_empty() { + guard window.global_element_id() is Some(_) else { + abort("on_click requires an element id: call .id(...) on the div") + } + // The pending press lives in element state so it survives redraws + // between mouse down and mouse up. + let state = window.with_element_state(click_state_key, fn(previous) { + let state = match previous { + Some(state) => state + None => { pending: None, } + } + (state, state) + }) + let listeners = self.click_listeners + window.on_mouse_event(fn(event, phase, window, app) { + match (event, phase) { + (MouseDown(down), Bubble) => + if down.button == Left && hitbox.is_hovered(window) { + state.pending = Some(down) + } + (MouseUp(up), Capture) => + if up.button == Left { + match state.pending { + Some(down) if hitbox.is_hovered(window) => { + state.pending = None + for listener in listeners { + listener({ down, up, }, window, app) + } + } + _ => state.pending = None + } + } + _ => () + } + }) + } +} diff --git a/src/elements/div_styled_generated.mbt b/src/elements/div_styled_generated.mbt new file mode 100644 index 0000000..4ef3f8a --- /dev/null +++ b/src/elements/div_styled_generated.mbt @@ -0,0 +1,3219 @@ +// GENERATED by tools/gen_style.py. DO NOT EDIT. +// Port of GPUI's derive(Refineable) / gpui_macros style helpers. + +///| +pub extend Div with @style.Styled::{ + visible, + invisible, + block, + flex, + grid, + hidden, + relative, + absolute, + overflow_hidden, + overflow_x_hidden, + overflow_y_hidden, + scrollbar_width, + cursor, + border_color, + border_dashed, + shadow, + shadow_none, + shadow_2xs, + shadow_xs, + shadow_sm, + shadow_md, + shadow_lg, + shadow_xl, + shadow_2xl, + flex_col, + flex_col_reverse, + flex_row, + flex_row_reverse, + flex_1, + flex_auto, + flex_initial, + flex_none, + flex_basis, + flex_grow, + flex_grow_0, + flex_grow_1, + flex_shrink, + flex_shrink_0, + flex_shrink_1, + flex_wrap, + flex_wrap_reverse, + flex_nowrap, + items_start, + items_end, + items_center, + items_baseline, + items_stretch, + self_start, + self_end, + self_flex_start, + self_flex_end, + self_center, + self_baseline, + self_stretch, + justify_start, + justify_end, + justify_center, + justify_between, + justify_around, + justify_evenly, + content_normal, + content_center, + content_start, + content_end, + content_between, + content_around, + content_evenly, + content_stretch, + aspect_ratio, + aspect_square, + bg, + opacity, + whitespace_normal, + whitespace_nowrap, + text_ellipsis, + text_ellipsis_start, + text_ellipsis_middle, + text_overflow, + text_align, + text_left, + text_center, + text_right, + truncate, + line_clamp, + text_color, + text_bg, + font_weight, + text_size, + text_xs, + text_sm, + text_base, + text_lg, + text_xl, + text_2xl, + text_3xl, + italic, + not_italic, + underline, + line_through, + text_decoration_none, + text_decoration_color, + text_decoration_solid, + text_decoration_wavy, + text_decoration_0, + text_decoration_1, + text_decoration_2, + text_decoration_4, + text_decoration_8, + font_family, + font_features, + font, + line_height, + grid_cols, + grid_cols_min_content, + grid_cols_max_content, + grid_rows, + grid_rows_min_content, + grid_rows_max_content, + col_start, + col_start_auto, + col_end, + col_end_auto, + col_span, + col_span_full, + row_start, + row_start_auto, + row_end, + row_end_auto, + row_span, + row_span_full, + debug, + debug_below, + w, + w_0, + w_neg_0, + w_0p5, + w_neg_0p5, + w_1, + w_neg_1, + w_1p5, + w_neg_1p5, + w_2, + w_neg_2, + w_2p5, + w_neg_2p5, + w_3, + w_neg_3, + w_3p5, + w_neg_3p5, + w_4, + w_neg_4, + w_5, + w_neg_5, + w_6, + w_neg_6, + w_7, + w_neg_7, + w_8, + w_neg_8, + w_9, + w_neg_9, + w_10, + w_neg_10, + w_11, + w_neg_11, + w_12, + w_neg_12, + w_16, + w_neg_16, + w_20, + w_neg_20, + w_24, + w_neg_24, + w_32, + w_neg_32, + w_40, + w_neg_40, + w_48, + w_neg_48, + w_56, + w_neg_56, + w_64, + w_neg_64, + w_72, + w_neg_72, + w_80, + w_neg_80, + w_96, + w_neg_96, + w_112, + w_neg_112, + w_128, + w_neg_128, + w_auto, + w_px, + w_neg_px, + w_full, + w_neg_full, + w_1_2, + w_neg_1_2, + w_1_3, + w_neg_1_3, + w_2_3, + w_neg_2_3, + w_1_4, + w_neg_1_4, + w_2_4, + w_neg_2_4, + w_3_4, + w_neg_3_4, + w_1_5, + w_neg_1_5, + w_2_5, + w_neg_2_5, + w_3_5, + w_neg_3_5, + w_4_5, + w_neg_4_5, + w_1_6, + w_neg_1_6, + w_5_6, + w_neg_5_6, + w_1_12, + w_neg_1_12, + h, + h_0, + h_neg_0, + h_0p5, + h_neg_0p5, + h_1, + h_neg_1, + h_1p5, + h_neg_1p5, + h_2, + h_neg_2, + h_2p5, + h_neg_2p5, + h_3, + h_neg_3, + h_3p5, + h_neg_3p5, + h_4, + h_neg_4, + h_5, + h_neg_5, + h_6, + h_neg_6, + h_7, + h_neg_7, + h_8, + h_neg_8, + h_9, + h_neg_9, + h_10, + h_neg_10, + h_11, + h_neg_11, + h_12, + h_neg_12, + h_16, + h_neg_16, + h_20, + h_neg_20, + h_24, + h_neg_24, + h_32, + h_neg_32, + h_40, + h_neg_40, + h_48, + h_neg_48, + h_56, + h_neg_56, + h_64, + h_neg_64, + h_72, + h_neg_72, + h_80, + h_neg_80, + h_96, + h_neg_96, + h_112, + h_neg_112, + h_128, + h_neg_128, + h_auto, + h_px, + h_neg_px, + h_full, + h_neg_full, + h_1_2, + h_neg_1_2, + h_1_3, + h_neg_1_3, + h_2_3, + h_neg_2_3, + h_1_4, + h_neg_1_4, + h_2_4, + h_neg_2_4, + h_3_4, + h_neg_3_4, + h_1_5, + h_neg_1_5, + h_2_5, + h_neg_2_5, + h_3_5, + h_neg_3_5, + h_4_5, + h_neg_4_5, + h_1_6, + h_neg_1_6, + h_5_6, + h_neg_5_6, + h_1_12, + h_neg_1_12, + size, + size_0, + size_neg_0, + size_0p5, + size_neg_0p5, + size_1, + size_neg_1, + size_1p5, + size_neg_1p5, + size_2, + size_neg_2, + size_2p5, + size_neg_2p5, + size_3, + size_neg_3, + size_3p5, + size_neg_3p5, + size_4, + size_neg_4, + size_5, + size_neg_5, + size_6, + size_neg_6, + size_7, + size_neg_7, + size_8, + size_neg_8, + size_9, + size_neg_9, + size_10, + size_neg_10, + size_11, + size_neg_11, + size_12, + size_neg_12, + size_16, + size_neg_16, + size_20, + size_neg_20, + size_24, + size_neg_24, + size_32, + size_neg_32, + size_40, + size_neg_40, + size_48, + size_neg_48, + size_56, + size_neg_56, + size_64, + size_neg_64, + size_72, + size_neg_72, + size_80, + size_neg_80, + size_96, + size_neg_96, + size_112, + size_neg_112, + size_128, + size_neg_128, + size_auto, + size_px, + size_neg_px, + size_full, + size_neg_full, + size_1_2, + size_neg_1_2, + size_1_3, + size_neg_1_3, + size_2_3, + size_neg_2_3, + size_1_4, + size_neg_1_4, + size_2_4, + size_neg_2_4, + size_3_4, + size_neg_3_4, + size_1_5, + size_neg_1_5, + size_2_5, + size_neg_2_5, + size_3_5, + size_neg_3_5, + size_4_5, + size_neg_4_5, + size_1_6, + size_neg_1_6, + size_5_6, + size_neg_5_6, + size_1_12, + size_neg_1_12, + min_size, + min_size_0, + min_size_neg_0, + min_size_0p5, + min_size_neg_0p5, + min_size_1, + min_size_neg_1, + min_size_1p5, + min_size_neg_1p5, + min_size_2, + min_size_neg_2, + min_size_2p5, + min_size_neg_2p5, + min_size_3, + min_size_neg_3, + min_size_3p5, + min_size_neg_3p5, + min_size_4, + min_size_neg_4, + min_size_5, + min_size_neg_5, + min_size_6, + min_size_neg_6, + min_size_7, + min_size_neg_7, + min_size_8, + min_size_neg_8, + min_size_9, + min_size_neg_9, + min_size_10, + min_size_neg_10, + min_size_11, + min_size_neg_11, + min_size_12, + min_size_neg_12, + min_size_16, + min_size_neg_16, + min_size_20, + min_size_neg_20, + min_size_24, + min_size_neg_24, + min_size_32, + min_size_neg_32, + min_size_40, + min_size_neg_40, + min_size_48, + min_size_neg_48, + min_size_56, + min_size_neg_56, + min_size_64, + min_size_neg_64, + min_size_72, + min_size_neg_72, + min_size_80, + min_size_neg_80, + min_size_96, + min_size_neg_96, + min_size_112, + min_size_neg_112, + min_size_128, + min_size_neg_128, + min_size_auto, + min_size_px, + min_size_neg_px, + min_size_full, + min_size_neg_full, + min_size_1_2, + min_size_neg_1_2, + min_size_1_3, + min_size_neg_1_3, + min_size_2_3, + min_size_neg_2_3, + min_size_1_4, + min_size_neg_1_4, + min_size_2_4, + min_size_neg_2_4, + min_size_3_4, + min_size_neg_3_4, + min_size_1_5, + min_size_neg_1_5, + min_size_2_5, + min_size_neg_2_5, + min_size_3_5, + min_size_neg_3_5, + min_size_4_5, + min_size_neg_4_5, + min_size_1_6, + min_size_neg_1_6, + min_size_5_6, + min_size_neg_5_6, + min_size_1_12, + min_size_neg_1_12, + min_w, + min_w_0, + min_w_neg_0, + min_w_0p5, + min_w_neg_0p5, + min_w_1, + min_w_neg_1, + min_w_1p5, + min_w_neg_1p5, + min_w_2, + min_w_neg_2, + min_w_2p5, + min_w_neg_2p5, + min_w_3, + min_w_neg_3, + min_w_3p5, + min_w_neg_3p5, + min_w_4, + min_w_neg_4, + min_w_5, + min_w_neg_5, + min_w_6, + min_w_neg_6, + min_w_7, + min_w_neg_7, + min_w_8, + min_w_neg_8, + min_w_9, + min_w_neg_9, + min_w_10, + min_w_neg_10, + min_w_11, + min_w_neg_11, + min_w_12, + min_w_neg_12, + min_w_16, + min_w_neg_16, + min_w_20, + min_w_neg_20, + min_w_24, + min_w_neg_24, + min_w_32, + min_w_neg_32, + min_w_40, + min_w_neg_40, + min_w_48, + min_w_neg_48, + min_w_56, + min_w_neg_56, + min_w_64, + min_w_neg_64, + min_w_72, + min_w_neg_72, + min_w_80, + min_w_neg_80, + min_w_96, + min_w_neg_96, + min_w_112, + min_w_neg_112, + min_w_128, + min_w_neg_128, + min_w_auto, + min_w_px, + min_w_neg_px, + min_w_full, + min_w_neg_full, + min_w_1_2, + min_w_neg_1_2, + min_w_1_3, + min_w_neg_1_3, + min_w_2_3, + min_w_neg_2_3, + min_w_1_4, + min_w_neg_1_4, + min_w_2_4, + min_w_neg_2_4, + min_w_3_4, + min_w_neg_3_4, + min_w_1_5, + min_w_neg_1_5, + min_w_2_5, + min_w_neg_2_5, + min_w_3_5, + min_w_neg_3_5, + min_w_4_5, + min_w_neg_4_5, + min_w_1_6, + min_w_neg_1_6, + min_w_5_6, + min_w_neg_5_6, + min_w_1_12, + min_w_neg_1_12, + min_h, + min_h_0, + min_h_neg_0, + min_h_0p5, + min_h_neg_0p5, + min_h_1, + min_h_neg_1, + min_h_1p5, + min_h_neg_1p5, + min_h_2, + min_h_neg_2, + min_h_2p5, + min_h_neg_2p5, + min_h_3, + min_h_neg_3, + min_h_3p5, + min_h_neg_3p5, + min_h_4, + min_h_neg_4, + min_h_5, + min_h_neg_5, + min_h_6, + min_h_neg_6, + min_h_7, + min_h_neg_7, + min_h_8, + min_h_neg_8, + min_h_9, + min_h_neg_9, + min_h_10, + min_h_neg_10, + min_h_11, + min_h_neg_11, + min_h_12, + min_h_neg_12, + min_h_16, + min_h_neg_16, + min_h_20, + min_h_neg_20, + min_h_24, + min_h_neg_24, + min_h_32, + min_h_neg_32, + min_h_40, + min_h_neg_40, + min_h_48, + min_h_neg_48, + min_h_56, + min_h_neg_56, + min_h_64, + min_h_neg_64, + min_h_72, + min_h_neg_72, + min_h_80, + min_h_neg_80, + min_h_96, + min_h_neg_96, + min_h_112, + min_h_neg_112, + min_h_128, + min_h_neg_128, + min_h_auto, + min_h_px, + min_h_neg_px, + min_h_full, + min_h_neg_full, + min_h_1_2, + min_h_neg_1_2, + min_h_1_3, + min_h_neg_1_3, + min_h_2_3, + min_h_neg_2_3, + min_h_1_4, + min_h_neg_1_4, + min_h_2_4, + min_h_neg_2_4, + min_h_3_4, + min_h_neg_3_4, + min_h_1_5, + min_h_neg_1_5, + min_h_2_5, + min_h_neg_2_5, + min_h_3_5, + min_h_neg_3_5, + min_h_4_5, + min_h_neg_4_5, + min_h_1_6, + min_h_neg_1_6, + min_h_5_6, + min_h_neg_5_6, + min_h_1_12, + min_h_neg_1_12, + max_size, + max_size_0, + max_size_neg_0, + max_size_0p5, + max_size_neg_0p5, + max_size_1, + max_size_neg_1, + max_size_1p5, + max_size_neg_1p5, + max_size_2, + max_size_neg_2, + max_size_2p5, + max_size_neg_2p5, + max_size_3, + max_size_neg_3, + max_size_3p5, + max_size_neg_3p5, + max_size_4, + max_size_neg_4, + max_size_5, + max_size_neg_5, + max_size_6, + max_size_neg_6, + max_size_7, + max_size_neg_7, + max_size_8, + max_size_neg_8, + max_size_9, + max_size_neg_9, + max_size_10, + max_size_neg_10, + max_size_11, + max_size_neg_11, + max_size_12, + max_size_neg_12, + max_size_16, + max_size_neg_16, + max_size_20, + max_size_neg_20, + max_size_24, + max_size_neg_24, + max_size_32, + max_size_neg_32, + max_size_40, + max_size_neg_40, + max_size_48, + max_size_neg_48, + max_size_56, + max_size_neg_56, + max_size_64, + max_size_neg_64, + max_size_72, + max_size_neg_72, + max_size_80, + max_size_neg_80, + max_size_96, + max_size_neg_96, + max_size_112, + max_size_neg_112, + max_size_128, + max_size_neg_128, + max_size_auto, + max_size_px, + max_size_neg_px, + max_size_full, + max_size_neg_full, + max_size_1_2, + max_size_neg_1_2, + max_size_1_3, + max_size_neg_1_3, + max_size_2_3, + max_size_neg_2_3, + max_size_1_4, + max_size_neg_1_4, + max_size_2_4, + max_size_neg_2_4, + max_size_3_4, + max_size_neg_3_4, + max_size_1_5, + max_size_neg_1_5, + max_size_2_5, + max_size_neg_2_5, + max_size_3_5, + max_size_neg_3_5, + max_size_4_5, + max_size_neg_4_5, + max_size_1_6, + max_size_neg_1_6, + max_size_5_6, + max_size_neg_5_6, + max_size_1_12, + max_size_neg_1_12, + max_w, + max_w_0, + max_w_neg_0, + max_w_0p5, + max_w_neg_0p5, + max_w_1, + max_w_neg_1, + max_w_1p5, + max_w_neg_1p5, + max_w_2, + max_w_neg_2, + max_w_2p5, + max_w_neg_2p5, + max_w_3, + max_w_neg_3, + max_w_3p5, + max_w_neg_3p5, + max_w_4, + max_w_neg_4, + max_w_5, + max_w_neg_5, + max_w_6, + max_w_neg_6, + max_w_7, + max_w_neg_7, + max_w_8, + max_w_neg_8, + max_w_9, + max_w_neg_9, + max_w_10, + max_w_neg_10, + max_w_11, + max_w_neg_11, + max_w_12, + max_w_neg_12, + max_w_16, + max_w_neg_16, + max_w_20, + max_w_neg_20, + max_w_24, + max_w_neg_24, + max_w_32, + max_w_neg_32, + max_w_40, + max_w_neg_40, + max_w_48, + max_w_neg_48, + max_w_56, + max_w_neg_56, + max_w_64, + max_w_neg_64, + max_w_72, + max_w_neg_72, + max_w_80, + max_w_neg_80, + max_w_96, + max_w_neg_96, + max_w_112, + max_w_neg_112, + max_w_128, + max_w_neg_128, + max_w_auto, + max_w_px, + max_w_neg_px, + max_w_full, + max_w_neg_full, + max_w_1_2, + max_w_neg_1_2, + max_w_1_3, + max_w_neg_1_3, + max_w_2_3, + max_w_neg_2_3, + max_w_1_4, + max_w_neg_1_4, + max_w_2_4, + max_w_neg_2_4, + max_w_3_4, + max_w_neg_3_4, + max_w_1_5, + max_w_neg_1_5, + max_w_2_5, + max_w_neg_2_5, + max_w_3_5, + max_w_neg_3_5, + max_w_4_5, + max_w_neg_4_5, + max_w_1_6, + max_w_neg_1_6, + max_w_5_6, + max_w_neg_5_6, + max_w_1_12, + max_w_neg_1_12, + max_h, + max_h_0, + max_h_neg_0, + max_h_0p5, + max_h_neg_0p5, + max_h_1, + max_h_neg_1, + max_h_1p5, + max_h_neg_1p5, + max_h_2, + max_h_neg_2, + max_h_2p5, + max_h_neg_2p5, + max_h_3, + max_h_neg_3, + max_h_3p5, + max_h_neg_3p5, + max_h_4, + max_h_neg_4, + max_h_5, + max_h_neg_5, + max_h_6, + max_h_neg_6, + max_h_7, + max_h_neg_7, + max_h_8, + max_h_neg_8, + max_h_9, + max_h_neg_9, + max_h_10, + max_h_neg_10, + max_h_11, + max_h_neg_11, + max_h_12, + max_h_neg_12, + max_h_16, + max_h_neg_16, + max_h_20, + max_h_neg_20, + max_h_24, + max_h_neg_24, + max_h_32, + max_h_neg_32, + max_h_40, + max_h_neg_40, + max_h_48, + max_h_neg_48, + max_h_56, + max_h_neg_56, + max_h_64, + max_h_neg_64, + max_h_72, + max_h_neg_72, + max_h_80, + max_h_neg_80, + max_h_96, + max_h_neg_96, + max_h_112, + max_h_neg_112, + max_h_128, + max_h_neg_128, + max_h_auto, + max_h_px, + max_h_neg_px, + max_h_full, + max_h_neg_full, + max_h_1_2, + max_h_neg_1_2, + max_h_1_3, + max_h_neg_1_3, + max_h_2_3, + max_h_neg_2_3, + max_h_1_4, + max_h_neg_1_4, + max_h_2_4, + max_h_neg_2_4, + max_h_3_4, + max_h_neg_3_4, + max_h_1_5, + max_h_neg_1_5, + max_h_2_5, + max_h_neg_2_5, + max_h_3_5, + max_h_neg_3_5, + max_h_4_5, + max_h_neg_4_5, + max_h_1_6, + max_h_neg_1_6, + max_h_5_6, + max_h_neg_5_6, + max_h_1_12, + max_h_neg_1_12, + gap, + gap_0, + gap_neg_0, + gap_0p5, + gap_neg_0p5, + gap_1, + gap_neg_1, + gap_1p5, + gap_neg_1p5, + gap_2, + gap_neg_2, + gap_2p5, + gap_neg_2p5, + gap_3, + gap_neg_3, + gap_3p5, + gap_neg_3p5, + gap_4, + gap_neg_4, + gap_5, + gap_neg_5, + gap_6, + gap_neg_6, + gap_7, + gap_neg_7, + gap_8, + gap_neg_8, + gap_9, + gap_neg_9, + gap_10, + gap_neg_10, + gap_11, + gap_neg_11, + gap_12, + gap_neg_12, + gap_16, + gap_neg_16, + gap_20, + gap_neg_20, + gap_24, + gap_neg_24, + gap_32, + gap_neg_32, + gap_40, + gap_neg_40, + gap_48, + gap_neg_48, + gap_56, + gap_neg_56, + gap_64, + gap_neg_64, + gap_72, + gap_neg_72, + gap_80, + gap_neg_80, + gap_96, + gap_neg_96, + gap_112, + gap_neg_112, + gap_128, + gap_neg_128, + gap_px, + gap_neg_px, + gap_full, + gap_neg_full, + gap_1_2, + gap_neg_1_2, + gap_1_3, + gap_neg_1_3, + gap_2_3, + gap_neg_2_3, + gap_1_4, + gap_neg_1_4, + gap_2_4, + gap_neg_2_4, + gap_3_4, + gap_neg_3_4, + gap_1_5, + gap_neg_1_5, + gap_2_5, + gap_neg_2_5, + gap_3_5, + gap_neg_3_5, + gap_4_5, + gap_neg_4_5, + gap_1_6, + gap_neg_1_6, + gap_5_6, + gap_neg_5_6, + gap_1_12, + gap_neg_1_12, + gap_x, + gap_x_0, + gap_x_neg_0, + gap_x_0p5, + gap_x_neg_0p5, + gap_x_1, + gap_x_neg_1, + gap_x_1p5, + gap_x_neg_1p5, + gap_x_2, + gap_x_neg_2, + gap_x_2p5, + gap_x_neg_2p5, + gap_x_3, + gap_x_neg_3, + gap_x_3p5, + gap_x_neg_3p5, + gap_x_4, + gap_x_neg_4, + gap_x_5, + gap_x_neg_5, + gap_x_6, + gap_x_neg_6, + gap_x_7, + gap_x_neg_7, + gap_x_8, + gap_x_neg_8, + gap_x_9, + gap_x_neg_9, + gap_x_10, + gap_x_neg_10, + gap_x_11, + gap_x_neg_11, + gap_x_12, + gap_x_neg_12, + gap_x_16, + gap_x_neg_16, + gap_x_20, + gap_x_neg_20, + gap_x_24, + gap_x_neg_24, + gap_x_32, + gap_x_neg_32, + gap_x_40, + gap_x_neg_40, + gap_x_48, + gap_x_neg_48, + gap_x_56, + gap_x_neg_56, + gap_x_64, + gap_x_neg_64, + gap_x_72, + gap_x_neg_72, + gap_x_80, + gap_x_neg_80, + gap_x_96, + gap_x_neg_96, + gap_x_112, + gap_x_neg_112, + gap_x_128, + gap_x_neg_128, + gap_x_px, + gap_x_neg_px, + gap_x_full, + gap_x_neg_full, + gap_x_1_2, + gap_x_neg_1_2, + gap_x_1_3, + gap_x_neg_1_3, + gap_x_2_3, + gap_x_neg_2_3, + gap_x_1_4, + gap_x_neg_1_4, + gap_x_2_4, + gap_x_neg_2_4, + gap_x_3_4, + gap_x_neg_3_4, + gap_x_1_5, + gap_x_neg_1_5, + gap_x_2_5, + gap_x_neg_2_5, + gap_x_3_5, + gap_x_neg_3_5, + gap_x_4_5, + gap_x_neg_4_5, + gap_x_1_6, + gap_x_neg_1_6, + gap_x_5_6, + gap_x_neg_5_6, + gap_x_1_12, + gap_x_neg_1_12, + gap_y, + gap_y_0, + gap_y_neg_0, + gap_y_0p5, + gap_y_neg_0p5, + gap_y_1, + gap_y_neg_1, + gap_y_1p5, + gap_y_neg_1p5, + gap_y_2, + gap_y_neg_2, + gap_y_2p5, + gap_y_neg_2p5, + gap_y_3, + gap_y_neg_3, + gap_y_3p5, + gap_y_neg_3p5, + gap_y_4, + gap_y_neg_4, + gap_y_5, + gap_y_neg_5, + gap_y_6, + gap_y_neg_6, + gap_y_7, + gap_y_neg_7, + gap_y_8, + gap_y_neg_8, + gap_y_9, + gap_y_neg_9, + gap_y_10, + gap_y_neg_10, + gap_y_11, + gap_y_neg_11, + gap_y_12, + gap_y_neg_12, + gap_y_16, + gap_y_neg_16, + gap_y_20, + gap_y_neg_20, + gap_y_24, + gap_y_neg_24, + gap_y_32, + gap_y_neg_32, + gap_y_40, + gap_y_neg_40, + gap_y_48, + gap_y_neg_48, + gap_y_56, + gap_y_neg_56, + gap_y_64, + gap_y_neg_64, + gap_y_72, + gap_y_neg_72, + gap_y_80, + gap_y_neg_80, + gap_y_96, + gap_y_neg_96, + gap_y_112, + gap_y_neg_112, + gap_y_128, + gap_y_neg_128, + gap_y_px, + gap_y_neg_px, + gap_y_full, + gap_y_neg_full, + gap_y_1_2, + gap_y_neg_1_2, + gap_y_1_3, + gap_y_neg_1_3, + gap_y_2_3, + gap_y_neg_2_3, + gap_y_1_4, + gap_y_neg_1_4, + gap_y_2_4, + gap_y_neg_2_4, + gap_y_3_4, + gap_y_neg_3_4, + gap_y_1_5, + gap_y_neg_1_5, + gap_y_2_5, + gap_y_neg_2_5, + gap_y_3_5, + gap_y_neg_3_5, + gap_y_4_5, + gap_y_neg_4_5, + gap_y_1_6, + gap_y_neg_1_6, + gap_y_5_6, + gap_y_neg_5_6, + gap_y_1_12, + gap_y_neg_1_12, + m, + m_0, + m_neg_0, + m_0p5, + m_neg_0p5, + m_1, + m_neg_1, + m_1p5, + m_neg_1p5, + m_2, + m_neg_2, + m_2p5, + m_neg_2p5, + m_3, + m_neg_3, + m_3p5, + m_neg_3p5, + m_4, + m_neg_4, + m_5, + m_neg_5, + m_6, + m_neg_6, + m_7, + m_neg_7, + m_8, + m_neg_8, + m_9, + m_neg_9, + m_10, + m_neg_10, + m_11, + m_neg_11, + m_12, + m_neg_12, + m_16, + m_neg_16, + m_20, + m_neg_20, + m_24, + m_neg_24, + m_32, + m_neg_32, + m_40, + m_neg_40, + m_48, + m_neg_48, + m_56, + m_neg_56, + m_64, + m_neg_64, + m_72, + m_neg_72, + m_80, + m_neg_80, + m_96, + m_neg_96, + m_112, + m_neg_112, + m_128, + m_neg_128, + m_auto, + m_px, + m_neg_px, + m_full, + m_neg_full, + m_1_2, + m_neg_1_2, + m_1_3, + m_neg_1_3, + m_2_3, + m_neg_2_3, + m_1_4, + m_neg_1_4, + m_2_4, + m_neg_2_4, + m_3_4, + m_neg_3_4, + m_1_5, + m_neg_1_5, + m_2_5, + m_neg_2_5, + m_3_5, + m_neg_3_5, + m_4_5, + m_neg_4_5, + m_1_6, + m_neg_1_6, + m_5_6, + m_neg_5_6, + m_1_12, + m_neg_1_12, + mt, + mt_0, + mt_neg_0, + mt_0p5, + mt_neg_0p5, + mt_1, + mt_neg_1, + mt_1p5, + mt_neg_1p5, + mt_2, + mt_neg_2, + mt_2p5, + mt_neg_2p5, + mt_3, + mt_neg_3, + mt_3p5, + mt_neg_3p5, + mt_4, + mt_neg_4, + mt_5, + mt_neg_5, + mt_6, + mt_neg_6, + mt_7, + mt_neg_7, + mt_8, + mt_neg_8, + mt_9, + mt_neg_9, + mt_10, + mt_neg_10, + mt_11, + mt_neg_11, + mt_12, + mt_neg_12, + mt_16, + mt_neg_16, + mt_20, + mt_neg_20, + mt_24, + mt_neg_24, + mt_32, + mt_neg_32, + mt_40, + mt_neg_40, + mt_48, + mt_neg_48, + mt_56, + mt_neg_56, + mt_64, + mt_neg_64, + mt_72, + mt_neg_72, + mt_80, + mt_neg_80, + mt_96, + mt_neg_96, + mt_112, + mt_neg_112, + mt_128, + mt_neg_128, + mt_auto, + mt_px, + mt_neg_px, + mt_full, + mt_neg_full, + mt_1_2, + mt_neg_1_2, + mt_1_3, + mt_neg_1_3, + mt_2_3, + mt_neg_2_3, + mt_1_4, + mt_neg_1_4, + mt_2_4, + mt_neg_2_4, + mt_3_4, + mt_neg_3_4, + mt_1_5, + mt_neg_1_5, + mt_2_5, + mt_neg_2_5, + mt_3_5, + mt_neg_3_5, + mt_4_5, + mt_neg_4_5, + mt_1_6, + mt_neg_1_6, + mt_5_6, + mt_neg_5_6, + mt_1_12, + mt_neg_1_12, + mb, + mb_0, + mb_neg_0, + mb_0p5, + mb_neg_0p5, + mb_1, + mb_neg_1, + mb_1p5, + mb_neg_1p5, + mb_2, + mb_neg_2, + mb_2p5, + mb_neg_2p5, + mb_3, + mb_neg_3, + mb_3p5, + mb_neg_3p5, + mb_4, + mb_neg_4, + mb_5, + mb_neg_5, + mb_6, + mb_neg_6, + mb_7, + mb_neg_7, + mb_8, + mb_neg_8, + mb_9, + mb_neg_9, + mb_10, + mb_neg_10, + mb_11, + mb_neg_11, + mb_12, + mb_neg_12, + mb_16, + mb_neg_16, + mb_20, + mb_neg_20, + mb_24, + mb_neg_24, + mb_32, + mb_neg_32, + mb_40, + mb_neg_40, + mb_48, + mb_neg_48, + mb_56, + mb_neg_56, + mb_64, + mb_neg_64, + mb_72, + mb_neg_72, + mb_80, + mb_neg_80, + mb_96, + mb_neg_96, + mb_112, + mb_neg_112, + mb_128, + mb_neg_128, + mb_auto, + mb_px, + mb_neg_px, + mb_full, + mb_neg_full, + mb_1_2, + mb_neg_1_2, + mb_1_3, + mb_neg_1_3, + mb_2_3, + mb_neg_2_3, + mb_1_4, + mb_neg_1_4, + mb_2_4, + mb_neg_2_4, + mb_3_4, + mb_neg_3_4, + mb_1_5, + mb_neg_1_5, + mb_2_5, + mb_neg_2_5, + mb_3_5, + mb_neg_3_5, + mb_4_5, + mb_neg_4_5, + mb_1_6, + mb_neg_1_6, + mb_5_6, + mb_neg_5_6, + mb_1_12, + mb_neg_1_12, + my, + my_0, + my_neg_0, + my_0p5, + my_neg_0p5, + my_1, + my_neg_1, + my_1p5, + my_neg_1p5, + my_2, + my_neg_2, + my_2p5, + my_neg_2p5, + my_3, + my_neg_3, + my_3p5, + my_neg_3p5, + my_4, + my_neg_4, + my_5, + my_neg_5, + my_6, + my_neg_6, + my_7, + my_neg_7, + my_8, + my_neg_8, + my_9, + my_neg_9, + my_10, + my_neg_10, + my_11, + my_neg_11, + my_12, + my_neg_12, + my_16, + my_neg_16, + my_20, + my_neg_20, + my_24, + my_neg_24, + my_32, + my_neg_32, + my_40, + my_neg_40, + my_48, + my_neg_48, + my_56, + my_neg_56, + my_64, + my_neg_64, + my_72, + my_neg_72, + my_80, + my_neg_80, + my_96, + my_neg_96, + my_112, + my_neg_112, + my_128, + my_neg_128, + my_auto, + my_px, + my_neg_px, + my_full, + my_neg_full, + my_1_2, + my_neg_1_2, + my_1_3, + my_neg_1_3, + my_2_3, + my_neg_2_3, + my_1_4, + my_neg_1_4, + my_2_4, + my_neg_2_4, + my_3_4, + my_neg_3_4, + my_1_5, + my_neg_1_5, + my_2_5, + my_neg_2_5, + my_3_5, + my_neg_3_5, + my_4_5, + my_neg_4_5, + my_1_6, + my_neg_1_6, + my_5_6, + my_neg_5_6, + my_1_12, + my_neg_1_12, + mx, + mx_0, + mx_neg_0, + mx_0p5, + mx_neg_0p5, + mx_1, + mx_neg_1, + mx_1p5, + mx_neg_1p5, + mx_2, + mx_neg_2, + mx_2p5, + mx_neg_2p5, + mx_3, + mx_neg_3, + mx_3p5, + mx_neg_3p5, + mx_4, + mx_neg_4, + mx_5, + mx_neg_5, + mx_6, + mx_neg_6, + mx_7, + mx_neg_7, + mx_8, + mx_neg_8, + mx_9, + mx_neg_9, + mx_10, + mx_neg_10, + mx_11, + mx_neg_11, + mx_12, + mx_neg_12, + mx_16, + mx_neg_16, + mx_20, + mx_neg_20, + mx_24, + mx_neg_24, + mx_32, + mx_neg_32, + mx_40, + mx_neg_40, + mx_48, + mx_neg_48, + mx_56, + mx_neg_56, + mx_64, + mx_neg_64, + mx_72, + mx_neg_72, + mx_80, + mx_neg_80, + mx_96, + mx_neg_96, + mx_112, + mx_neg_112, + mx_128, + mx_neg_128, + mx_auto, + mx_px, + mx_neg_px, + mx_full, + mx_neg_full, + mx_1_2, + mx_neg_1_2, + mx_1_3, + mx_neg_1_3, + mx_2_3, + mx_neg_2_3, + mx_1_4, + mx_neg_1_4, + mx_2_4, + mx_neg_2_4, + mx_3_4, + mx_neg_3_4, + mx_1_5, + mx_neg_1_5, + mx_2_5, + mx_neg_2_5, + mx_3_5, + mx_neg_3_5, + mx_4_5, + mx_neg_4_5, + mx_1_6, + mx_neg_1_6, + mx_5_6, + mx_neg_5_6, + mx_1_12, + mx_neg_1_12, + ml, + ml_0, + ml_neg_0, + ml_0p5, + ml_neg_0p5, + ml_1, + ml_neg_1, + ml_1p5, + ml_neg_1p5, + ml_2, + ml_neg_2, + ml_2p5, + ml_neg_2p5, + ml_3, + ml_neg_3, + ml_3p5, + ml_neg_3p5, + ml_4, + ml_neg_4, + ml_5, + ml_neg_5, + ml_6, + ml_neg_6, + ml_7, + ml_neg_7, + ml_8, + ml_neg_8, + ml_9, + ml_neg_9, + ml_10, + ml_neg_10, + ml_11, + ml_neg_11, + ml_12, + ml_neg_12, + ml_16, + ml_neg_16, + ml_20, + ml_neg_20, + ml_24, + ml_neg_24, + ml_32, + ml_neg_32, + ml_40, + ml_neg_40, + ml_48, + ml_neg_48, + ml_56, + ml_neg_56, + ml_64, + ml_neg_64, + ml_72, + ml_neg_72, + ml_80, + ml_neg_80, + ml_96, + ml_neg_96, + ml_112, + ml_neg_112, + ml_128, + ml_neg_128, + ml_auto, + ml_px, + ml_neg_px, + ml_full, + ml_neg_full, + ml_1_2, + ml_neg_1_2, + ml_1_3, + ml_neg_1_3, + ml_2_3, + ml_neg_2_3, + ml_1_4, + ml_neg_1_4, + ml_2_4, + ml_neg_2_4, + ml_3_4, + ml_neg_3_4, + ml_1_5, + ml_neg_1_5, + ml_2_5, + ml_neg_2_5, + ml_3_5, + ml_neg_3_5, + ml_4_5, + ml_neg_4_5, + ml_1_6, + ml_neg_1_6, + ml_5_6, + ml_neg_5_6, + ml_1_12, + ml_neg_1_12, + mr, + mr_0, + mr_neg_0, + mr_0p5, + mr_neg_0p5, + mr_1, + mr_neg_1, + mr_1p5, + mr_neg_1p5, + mr_2, + mr_neg_2, + mr_2p5, + mr_neg_2p5, + mr_3, + mr_neg_3, + mr_3p5, + mr_neg_3p5, + mr_4, + mr_neg_4, + mr_5, + mr_neg_5, + mr_6, + mr_neg_6, + mr_7, + mr_neg_7, + mr_8, + mr_neg_8, + mr_9, + mr_neg_9, + mr_10, + mr_neg_10, + mr_11, + mr_neg_11, + mr_12, + mr_neg_12, + mr_16, + mr_neg_16, + mr_20, + mr_neg_20, + mr_24, + mr_neg_24, + mr_32, + mr_neg_32, + mr_40, + mr_neg_40, + mr_48, + mr_neg_48, + mr_56, + mr_neg_56, + mr_64, + mr_neg_64, + mr_72, + mr_neg_72, + mr_80, + mr_neg_80, + mr_96, + mr_neg_96, + mr_112, + mr_neg_112, + mr_128, + mr_neg_128, + mr_auto, + mr_px, + mr_neg_px, + mr_full, + mr_neg_full, + mr_1_2, + mr_neg_1_2, + mr_1_3, + mr_neg_1_3, + mr_2_3, + mr_neg_2_3, + mr_1_4, + mr_neg_1_4, + mr_2_4, + mr_neg_2_4, + mr_3_4, + mr_neg_3_4, + mr_1_5, + mr_neg_1_5, + mr_2_5, + mr_neg_2_5, + mr_3_5, + mr_neg_3_5, + mr_4_5, + mr_neg_4_5, + mr_1_6, + mr_neg_1_6, + mr_5_6, + mr_neg_5_6, + mr_1_12, + mr_neg_1_12, + p, + p_0, + p_neg_0, + p_0p5, + p_neg_0p5, + p_1, + p_neg_1, + p_1p5, + p_neg_1p5, + p_2, + p_neg_2, + p_2p5, + p_neg_2p5, + p_3, + p_neg_3, + p_3p5, + p_neg_3p5, + p_4, + p_neg_4, + p_5, + p_neg_5, + p_6, + p_neg_6, + p_7, + p_neg_7, + p_8, + p_neg_8, + p_9, + p_neg_9, + p_10, + p_neg_10, + p_11, + p_neg_11, + p_12, + p_neg_12, + p_16, + p_neg_16, + p_20, + p_neg_20, + p_24, + p_neg_24, + p_32, + p_neg_32, + p_40, + p_neg_40, + p_48, + p_neg_48, + p_56, + p_neg_56, + p_64, + p_neg_64, + p_72, + p_neg_72, + p_80, + p_neg_80, + p_96, + p_neg_96, + p_112, + p_neg_112, + p_128, + p_neg_128, + p_px, + p_neg_px, + p_full, + p_neg_full, + p_1_2, + p_neg_1_2, + p_1_3, + p_neg_1_3, + p_2_3, + p_neg_2_3, + p_1_4, + p_neg_1_4, + p_2_4, + p_neg_2_4, + p_3_4, + p_neg_3_4, + p_1_5, + p_neg_1_5, + p_2_5, + p_neg_2_5, + p_3_5, + p_neg_3_5, + p_4_5, + p_neg_4_5, + p_1_6, + p_neg_1_6, + p_5_6, + p_neg_5_6, + p_1_12, + p_neg_1_12, + pt, + pt_0, + pt_neg_0, + pt_0p5, + pt_neg_0p5, + pt_1, + pt_neg_1, + pt_1p5, + pt_neg_1p5, + pt_2, + pt_neg_2, + pt_2p5, + pt_neg_2p5, + pt_3, + pt_neg_3, + pt_3p5, + pt_neg_3p5, + pt_4, + pt_neg_4, + pt_5, + pt_neg_5, + pt_6, + pt_neg_6, + pt_7, + pt_neg_7, + pt_8, + pt_neg_8, + pt_9, + pt_neg_9, + pt_10, + pt_neg_10, + pt_11, + pt_neg_11, + pt_12, + pt_neg_12, + pt_16, + pt_neg_16, + pt_20, + pt_neg_20, + pt_24, + pt_neg_24, + pt_32, + pt_neg_32, + pt_40, + pt_neg_40, + pt_48, + pt_neg_48, + pt_56, + pt_neg_56, + pt_64, + pt_neg_64, + pt_72, + pt_neg_72, + pt_80, + pt_neg_80, + pt_96, + pt_neg_96, + pt_112, + pt_neg_112, + pt_128, + pt_neg_128, + pt_px, + pt_neg_px, + pt_full, + pt_neg_full, + pt_1_2, + pt_neg_1_2, + pt_1_3, + pt_neg_1_3, + pt_2_3, + pt_neg_2_3, + pt_1_4, + pt_neg_1_4, + pt_2_4, + pt_neg_2_4, + pt_3_4, + pt_neg_3_4, + pt_1_5, + pt_neg_1_5, + pt_2_5, + pt_neg_2_5, + pt_3_5, + pt_neg_3_5, + pt_4_5, + pt_neg_4_5, + pt_1_6, + pt_neg_1_6, + pt_5_6, + pt_neg_5_6, + pt_1_12, + pt_neg_1_12, + pb, + pb_0, + pb_neg_0, + pb_0p5, + pb_neg_0p5, + pb_1, + pb_neg_1, + pb_1p5, + pb_neg_1p5, + pb_2, + pb_neg_2, + pb_2p5, + pb_neg_2p5, + pb_3, + pb_neg_3, + pb_3p5, + pb_neg_3p5, + pb_4, + pb_neg_4, + pb_5, + pb_neg_5, + pb_6, + pb_neg_6, + pb_7, + pb_neg_7, + pb_8, + pb_neg_8, + pb_9, + pb_neg_9, + pb_10, + pb_neg_10, + pb_11, + pb_neg_11, + pb_12, + pb_neg_12, + pb_16, + pb_neg_16, + pb_20, + pb_neg_20, + pb_24, + pb_neg_24, + pb_32, + pb_neg_32, + pb_40, + pb_neg_40, + pb_48, + pb_neg_48, + pb_56, + pb_neg_56, + pb_64, + pb_neg_64, + pb_72, + pb_neg_72, + pb_80, + pb_neg_80, + pb_96, + pb_neg_96, + pb_112, + pb_neg_112, + pb_128, + pb_neg_128, + pb_px, + pb_neg_px, + pb_full, + pb_neg_full, + pb_1_2, + pb_neg_1_2, + pb_1_3, + pb_neg_1_3, + pb_2_3, + pb_neg_2_3, + pb_1_4, + pb_neg_1_4, + pb_2_4, + pb_neg_2_4, + pb_3_4, + pb_neg_3_4, + pb_1_5, + pb_neg_1_5, + pb_2_5, + pb_neg_2_5, + pb_3_5, + pb_neg_3_5, + pb_4_5, + pb_neg_4_5, + pb_1_6, + pb_neg_1_6, + pb_5_6, + pb_neg_5_6, + pb_1_12, + pb_neg_1_12, + px, + px_0, + px_neg_0, + px_0p5, + px_neg_0p5, + px_1, + px_neg_1, + px_1p5, + px_neg_1p5, + px_2, + px_neg_2, + px_2p5, + px_neg_2p5, + px_3, + px_neg_3, + px_3p5, + px_neg_3p5, + px_4, + px_neg_4, + px_5, + px_neg_5, + px_6, + px_neg_6, + px_7, + px_neg_7, + px_8, + px_neg_8, + px_9, + px_neg_9, + px_10, + px_neg_10, + px_11, + px_neg_11, + px_12, + px_neg_12, + px_16, + px_neg_16, + px_20, + px_neg_20, + px_24, + px_neg_24, + px_32, + px_neg_32, + px_40, + px_neg_40, + px_48, + px_neg_48, + px_56, + px_neg_56, + px_64, + px_neg_64, + px_72, + px_neg_72, + px_80, + px_neg_80, + px_96, + px_neg_96, + px_112, + px_neg_112, + px_128, + px_neg_128, + px_px, + px_neg_px, + px_full, + px_neg_full, + px_1_2, + px_neg_1_2, + px_1_3, + px_neg_1_3, + px_2_3, + px_neg_2_3, + px_1_4, + px_neg_1_4, + px_2_4, + px_neg_2_4, + px_3_4, + px_neg_3_4, + px_1_5, + px_neg_1_5, + px_2_5, + px_neg_2_5, + px_3_5, + px_neg_3_5, + px_4_5, + px_neg_4_5, + px_1_6, + px_neg_1_6, + px_5_6, + px_neg_5_6, + px_1_12, + px_neg_1_12, + py, + py_0, + py_neg_0, + py_0p5, + py_neg_0p5, + py_1, + py_neg_1, + py_1p5, + py_neg_1p5, + py_2, + py_neg_2, + py_2p5, + py_neg_2p5, + py_3, + py_neg_3, + py_3p5, + py_neg_3p5, + py_4, + py_neg_4, + py_5, + py_neg_5, + py_6, + py_neg_6, + py_7, + py_neg_7, + py_8, + py_neg_8, + py_9, + py_neg_9, + py_10, + py_neg_10, + py_11, + py_neg_11, + py_12, + py_neg_12, + py_16, + py_neg_16, + py_20, + py_neg_20, + py_24, + py_neg_24, + py_32, + py_neg_32, + py_40, + py_neg_40, + py_48, + py_neg_48, + py_56, + py_neg_56, + py_64, + py_neg_64, + py_72, + py_neg_72, + py_80, + py_neg_80, + py_96, + py_neg_96, + py_112, + py_neg_112, + py_128, + py_neg_128, + py_px, + py_neg_px, + py_full, + py_neg_full, + py_1_2, + py_neg_1_2, + py_1_3, + py_neg_1_3, + py_2_3, + py_neg_2_3, + py_1_4, + py_neg_1_4, + py_2_4, + py_neg_2_4, + py_3_4, + py_neg_3_4, + py_1_5, + py_neg_1_5, + py_2_5, + py_neg_2_5, + py_3_5, + py_neg_3_5, + py_4_5, + py_neg_4_5, + py_1_6, + py_neg_1_6, + py_5_6, + py_neg_5_6, + py_1_12, + py_neg_1_12, + pl, + pl_0, + pl_neg_0, + pl_0p5, + pl_neg_0p5, + pl_1, + pl_neg_1, + pl_1p5, + pl_neg_1p5, + pl_2, + pl_neg_2, + pl_2p5, + pl_neg_2p5, + pl_3, + pl_neg_3, + pl_3p5, + pl_neg_3p5, + pl_4, + pl_neg_4, + pl_5, + pl_neg_5, + pl_6, + pl_neg_6, + pl_7, + pl_neg_7, + pl_8, + pl_neg_8, + pl_9, + pl_neg_9, + pl_10, + pl_neg_10, + pl_11, + pl_neg_11, + pl_12, + pl_neg_12, + pl_16, + pl_neg_16, + pl_20, + pl_neg_20, + pl_24, + pl_neg_24, + pl_32, + pl_neg_32, + pl_40, + pl_neg_40, + pl_48, + pl_neg_48, + pl_56, + pl_neg_56, + pl_64, + pl_neg_64, + pl_72, + pl_neg_72, + pl_80, + pl_neg_80, + pl_96, + pl_neg_96, + pl_112, + pl_neg_112, + pl_128, + pl_neg_128, + pl_px, + pl_neg_px, + pl_full, + pl_neg_full, + pl_1_2, + pl_neg_1_2, + pl_1_3, + pl_neg_1_3, + pl_2_3, + pl_neg_2_3, + pl_1_4, + pl_neg_1_4, + pl_2_4, + pl_neg_2_4, + pl_3_4, + pl_neg_3_4, + pl_1_5, + pl_neg_1_5, + pl_2_5, + pl_neg_2_5, + pl_3_5, + pl_neg_3_5, + pl_4_5, + pl_neg_4_5, + pl_1_6, + pl_neg_1_6, + pl_5_6, + pl_neg_5_6, + pl_1_12, + pl_neg_1_12, + pr, + pr_0, + pr_neg_0, + pr_0p5, + pr_neg_0p5, + pr_1, + pr_neg_1, + pr_1p5, + pr_neg_1p5, + pr_2, + pr_neg_2, + pr_2p5, + pr_neg_2p5, + pr_3, + pr_neg_3, + pr_3p5, + pr_neg_3p5, + pr_4, + pr_neg_4, + pr_5, + pr_neg_5, + pr_6, + pr_neg_6, + pr_7, + pr_neg_7, + pr_8, + pr_neg_8, + pr_9, + pr_neg_9, + pr_10, + pr_neg_10, + pr_11, + pr_neg_11, + pr_12, + pr_neg_12, + pr_16, + pr_neg_16, + pr_20, + pr_neg_20, + pr_24, + pr_neg_24, + pr_32, + pr_neg_32, + pr_40, + pr_neg_40, + pr_48, + pr_neg_48, + pr_56, + pr_neg_56, + pr_64, + pr_neg_64, + pr_72, + pr_neg_72, + pr_80, + pr_neg_80, + pr_96, + pr_neg_96, + pr_112, + pr_neg_112, + pr_128, + pr_neg_128, + pr_px, + pr_neg_px, + pr_full, + pr_neg_full, + pr_1_2, + pr_neg_1_2, + pr_1_3, + pr_neg_1_3, + pr_2_3, + pr_neg_2_3, + pr_1_4, + pr_neg_1_4, + pr_2_4, + pr_neg_2_4, + pr_3_4, + pr_neg_3_4, + pr_1_5, + pr_neg_1_5, + pr_2_5, + pr_neg_2_5, + pr_3_5, + pr_neg_3_5, + pr_4_5, + pr_neg_4_5, + pr_1_6, + pr_neg_1_6, + pr_5_6, + pr_neg_5_6, + pr_1_12, + pr_neg_1_12, + inset, + inset_0, + inset_neg_0, + inset_0p5, + inset_neg_0p5, + inset_1, + inset_neg_1, + inset_1p5, + inset_neg_1p5, + inset_2, + inset_neg_2, + inset_2p5, + inset_neg_2p5, + inset_3, + inset_neg_3, + inset_3p5, + inset_neg_3p5, + inset_4, + inset_neg_4, + inset_5, + inset_neg_5, + inset_6, + inset_neg_6, + inset_7, + inset_neg_7, + inset_8, + inset_neg_8, + inset_9, + inset_neg_9, + inset_10, + inset_neg_10, + inset_11, + inset_neg_11, + inset_12, + inset_neg_12, + inset_16, + inset_neg_16, + inset_20, + inset_neg_20, + inset_24, + inset_neg_24, + inset_32, + inset_neg_32, + inset_40, + inset_neg_40, + inset_48, + inset_neg_48, + inset_56, + inset_neg_56, + inset_64, + inset_neg_64, + inset_72, + inset_neg_72, + inset_80, + inset_neg_80, + inset_96, + inset_neg_96, + inset_112, + inset_neg_112, + inset_128, + inset_neg_128, + inset_auto, + inset_px, + inset_neg_px, + inset_full, + inset_neg_full, + inset_1_2, + inset_neg_1_2, + inset_1_3, + inset_neg_1_3, + inset_2_3, + inset_neg_2_3, + inset_1_4, + inset_neg_1_4, + inset_2_4, + inset_neg_2_4, + inset_3_4, + inset_neg_3_4, + inset_1_5, + inset_neg_1_5, + inset_2_5, + inset_neg_2_5, + inset_3_5, + inset_neg_3_5, + inset_4_5, + inset_neg_4_5, + inset_1_6, + inset_neg_1_6, + inset_5_6, + inset_neg_5_6, + inset_1_12, + inset_neg_1_12, + top, + top_0, + top_neg_0, + top_0p5, + top_neg_0p5, + top_1, + top_neg_1, + top_1p5, + top_neg_1p5, + top_2, + top_neg_2, + top_2p5, + top_neg_2p5, + top_3, + top_neg_3, + top_3p5, + top_neg_3p5, + top_4, + top_neg_4, + top_5, + top_neg_5, + top_6, + top_neg_6, + top_7, + top_neg_7, + top_8, + top_neg_8, + top_9, + top_neg_9, + top_10, + top_neg_10, + top_11, + top_neg_11, + top_12, + top_neg_12, + top_16, + top_neg_16, + top_20, + top_neg_20, + top_24, + top_neg_24, + top_32, + top_neg_32, + top_40, + top_neg_40, + top_48, + top_neg_48, + top_56, + top_neg_56, + top_64, + top_neg_64, + top_72, + top_neg_72, + top_80, + top_neg_80, + top_96, + top_neg_96, + top_112, + top_neg_112, + top_128, + top_neg_128, + top_auto, + top_px, + top_neg_px, + top_full, + top_neg_full, + top_1_2, + top_neg_1_2, + top_1_3, + top_neg_1_3, + top_2_3, + top_neg_2_3, + top_1_4, + top_neg_1_4, + top_2_4, + top_neg_2_4, + top_3_4, + top_neg_3_4, + top_1_5, + top_neg_1_5, + top_2_5, + top_neg_2_5, + top_3_5, + top_neg_3_5, + top_4_5, + top_neg_4_5, + top_1_6, + top_neg_1_6, + top_5_6, + top_neg_5_6, + top_1_12, + top_neg_1_12, + bottom, + bottom_0, + bottom_neg_0, + bottom_0p5, + bottom_neg_0p5, + bottom_1, + bottom_neg_1, + bottom_1p5, + bottom_neg_1p5, + bottom_2, + bottom_neg_2, + bottom_2p5, + bottom_neg_2p5, + bottom_3, + bottom_neg_3, + bottom_3p5, + bottom_neg_3p5, + bottom_4, + bottom_neg_4, + bottom_5, + bottom_neg_5, + bottom_6, + bottom_neg_6, + bottom_7, + bottom_neg_7, + bottom_8, + bottom_neg_8, + bottom_9, + bottom_neg_9, + bottom_10, + bottom_neg_10, + bottom_11, + bottom_neg_11, + bottom_12, + bottom_neg_12, + bottom_16, + bottom_neg_16, + bottom_20, + bottom_neg_20, + bottom_24, + bottom_neg_24, + bottom_32, + bottom_neg_32, + bottom_40, + bottom_neg_40, + bottom_48, + bottom_neg_48, + bottom_56, + bottom_neg_56, + bottom_64, + bottom_neg_64, + bottom_72, + bottom_neg_72, + bottom_80, + bottom_neg_80, + bottom_96, + bottom_neg_96, + bottom_112, + bottom_neg_112, + bottom_128, + bottom_neg_128, + bottom_auto, + bottom_px, + bottom_neg_px, + bottom_full, + bottom_neg_full, + bottom_1_2, + bottom_neg_1_2, + bottom_1_3, + bottom_neg_1_3, + bottom_2_3, + bottom_neg_2_3, + bottom_1_4, + bottom_neg_1_4, + bottom_2_4, + bottom_neg_2_4, + bottom_3_4, + bottom_neg_3_4, + bottom_1_5, + bottom_neg_1_5, + bottom_2_5, + bottom_neg_2_5, + bottom_3_5, + bottom_neg_3_5, + bottom_4_5, + bottom_neg_4_5, + bottom_1_6, + bottom_neg_1_6, + bottom_5_6, + bottom_neg_5_6, + bottom_1_12, + bottom_neg_1_12, + left, + left_0, + left_neg_0, + left_0p5, + left_neg_0p5, + left_1, + left_neg_1, + left_1p5, + left_neg_1p5, + left_2, + left_neg_2, + left_2p5, + left_neg_2p5, + left_3, + left_neg_3, + left_3p5, + left_neg_3p5, + left_4, + left_neg_4, + left_5, + left_neg_5, + left_6, + left_neg_6, + left_7, + left_neg_7, + left_8, + left_neg_8, + left_9, + left_neg_9, + left_10, + left_neg_10, + left_11, + left_neg_11, + left_12, + left_neg_12, + left_16, + left_neg_16, + left_20, + left_neg_20, + left_24, + left_neg_24, + left_32, + left_neg_32, + left_40, + left_neg_40, + left_48, + left_neg_48, + left_56, + left_neg_56, + left_64, + left_neg_64, + left_72, + left_neg_72, + left_80, + left_neg_80, + left_96, + left_neg_96, + left_112, + left_neg_112, + left_128, + left_neg_128, + left_auto, + left_px, + left_neg_px, + left_full, + left_neg_full, + left_1_2, + left_neg_1_2, + left_1_3, + left_neg_1_3, + left_2_3, + left_neg_2_3, + left_1_4, + left_neg_1_4, + left_2_4, + left_neg_2_4, + left_3_4, + left_neg_3_4, + left_1_5, + left_neg_1_5, + left_2_5, + left_neg_2_5, + left_3_5, + left_neg_3_5, + left_4_5, + left_neg_4_5, + left_1_6, + left_neg_1_6, + left_5_6, + left_neg_5_6, + left_1_12, + left_neg_1_12, + right, + right_0, + right_neg_0, + right_0p5, + right_neg_0p5, + right_1, + right_neg_1, + right_1p5, + right_neg_1p5, + right_2, + right_neg_2, + right_2p5, + right_neg_2p5, + right_3, + right_neg_3, + right_3p5, + right_neg_3p5, + right_4, + right_neg_4, + right_5, + right_neg_5, + right_6, + right_neg_6, + right_7, + right_neg_7, + right_8, + right_neg_8, + right_9, + right_neg_9, + right_10, + right_neg_10, + right_11, + right_neg_11, + right_12, + right_neg_12, + right_16, + right_neg_16, + right_20, + right_neg_20, + right_24, + right_neg_24, + right_32, + right_neg_32, + right_40, + right_neg_40, + right_48, + right_neg_48, + right_56, + right_neg_56, + right_64, + right_neg_64, + right_72, + right_neg_72, + right_80, + right_neg_80, + right_96, + right_neg_96, + right_112, + right_neg_112, + right_128, + right_neg_128, + right_auto, + right_px, + right_neg_px, + right_full, + right_neg_full, + right_1_2, + right_neg_1_2, + right_1_3, + right_neg_1_3, + right_2_3, + right_neg_2_3, + right_1_4, + right_neg_1_4, + right_2_4, + right_neg_2_4, + right_3_4, + right_neg_3_4, + right_1_5, + right_neg_1_5, + right_2_5, + right_neg_2_5, + right_3_5, + right_neg_3_5, + right_4_5, + right_neg_4_5, + right_1_6, + right_neg_1_6, + right_5_6, + right_neg_5_6, + right_1_12, + right_neg_1_12, + rounded, + rounded_none, + rounded_xs, + rounded_sm, + rounded_md, + rounded_lg, + rounded_xl, + rounded_2xl, + rounded_3xl, + rounded_full, + rounded_t, + rounded_t_none, + rounded_t_xs, + rounded_t_sm, + rounded_t_md, + rounded_t_lg, + rounded_t_xl, + rounded_t_2xl, + rounded_t_3xl, + rounded_t_full, + rounded_b, + rounded_b_none, + rounded_b_xs, + rounded_b_sm, + rounded_b_md, + rounded_b_lg, + rounded_b_xl, + rounded_b_2xl, + rounded_b_3xl, + rounded_b_full, + rounded_r, + rounded_r_none, + rounded_r_xs, + rounded_r_sm, + rounded_r_md, + rounded_r_lg, + rounded_r_xl, + rounded_r_2xl, + rounded_r_3xl, + rounded_r_full, + rounded_l, + rounded_l_none, + rounded_l_xs, + rounded_l_sm, + rounded_l_md, + rounded_l_lg, + rounded_l_xl, + rounded_l_2xl, + rounded_l_3xl, + rounded_l_full, + rounded_tl, + rounded_tl_none, + rounded_tl_xs, + rounded_tl_sm, + rounded_tl_md, + rounded_tl_lg, + rounded_tl_xl, + rounded_tl_2xl, + rounded_tl_3xl, + rounded_tl_full, + rounded_tr, + rounded_tr_none, + rounded_tr_xs, + rounded_tr_sm, + rounded_tr_md, + rounded_tr_lg, + rounded_tr_xl, + rounded_tr_2xl, + rounded_tr_3xl, + rounded_tr_full, + rounded_bl, + rounded_bl_none, + rounded_bl_xs, + rounded_bl_sm, + rounded_bl_md, + rounded_bl_lg, + rounded_bl_xl, + rounded_bl_2xl, + rounded_bl_3xl, + rounded_bl_full, + rounded_br, + rounded_br_none, + rounded_br_xs, + rounded_br_sm, + rounded_br_md, + rounded_br_lg, + rounded_br_xl, + rounded_br_2xl, + rounded_br_3xl, + rounded_br_full, + border, + border_0, + border_1, + border_2, + border_3, + border_4, + border_5, + border_6, + border_7, + border_8, + border_9, + border_10, + border_11, + border_12, + border_16, + border_20, + border_24, + border_32, + border_t, + border_t_0, + border_t_1, + border_t_2, + border_t_3, + border_t_4, + border_t_5, + border_t_6, + border_t_7, + border_t_8, + border_t_9, + border_t_10, + border_t_11, + border_t_12, + border_t_16, + border_t_20, + border_t_24, + border_t_32, + border_b, + border_b_0, + border_b_1, + border_b_2, + border_b_3, + border_b_4, + border_b_5, + border_b_6, + border_b_7, + border_b_8, + border_b_9, + border_b_10, + border_b_11, + border_b_12, + border_b_16, + border_b_20, + border_b_24, + border_b_32, + border_r, + border_r_0, + border_r_1, + border_r_2, + border_r_3, + border_r_4, + border_r_5, + border_r_6, + border_r_7, + border_r_8, + border_r_9, + border_r_10, + border_r_11, + border_r_12, + border_r_16, + border_r_20, + border_r_24, + border_r_32, + border_l, + border_l_0, + border_l_1, + border_l_2, + border_l_3, + border_l_4, + border_l_5, + border_l_6, + border_l_7, + border_l_8, + border_l_9, + border_l_10, + border_l_11, + border_l_12, + border_l_16, + border_l_20, + border_l_24, + border_l_32, + border_x, + border_x_0, + border_x_1, + border_x_2, + border_x_3, + border_x_4, + border_x_5, + border_x_6, + border_x_7, + border_x_8, + border_x_9, + border_x_10, + border_x_11, + border_x_12, + border_x_16, + border_x_20, + border_x_24, + border_x_32, + border_y, + border_y_0, + border_y_1, + border_y_2, + border_y_3, + border_y_4, + border_y_5, + border_y_6, + border_y_7, + border_y_8, + border_y_9, + border_y_10, + border_y_11, + border_y_12, + border_y_16, + border_y_20, + border_y_24, + border_y_32, + cursor_default, + cursor_pointer, + cursor_text, + cursor_move, + cursor_not_allowed, + cursor_context_menu, + cursor_crosshair, + cursor_vertical_text, + cursor_alias, + cursor_copy, + cursor_no_drop, + cursor_grab, + cursor_grabbing, + cursor_ew_resize, + cursor_ns_resize, + cursor_nesw_resize, + cursor_nwse_resize, + cursor_col_resize, + cursor_row_resize, + cursor_n_resize, + cursor_e_resize, + cursor_s_resize, + cursor_w_resize, +} diff --git a/src/elements/elements_test.mbt b/src/elements/elements_test.mbt new file mode 100644 index 0000000..70f0494 --- /dev/null +++ b/src/elements/elements_test.mbt @@ -0,0 +1,427 @@ +///| +fn px(v : Double) -> @geometry.Pixels { + @geometry.px(v) +} + +///| +fn pt(x : Double, y : Double) -> @geometry.Point[@geometry.Pixels] { + @geometry.point(px(x), px(y)) +} + +///| +fn mouse_down(x : Double, y : Double) -> @input.MouseEvent { + MouseDown({ ..Default::default(), position: pt(x, y), click_count: 1, }) +} + +///| +fn mouse_up(x : Double, y : Double) -> @input.MouseEvent { + MouseUp({ ..Default::default(), position: pt(x, y), click_count: 1, }) +} + +///| +fn mouse_move(x : Double, y : Double) -> @input.MouseEvent { + MouseMove({ ..Default::default(), position: pt(x, y), }) +} + +///| +fn sp(v : Double) -> @geometry.ScaledPixels { + @geometry.ScaledPixels(v) +} + +///| +fn sbounds( + x : Double, + y : Double, + w : Double, + h : Double, +) -> @geometry.Bounds[@geometry.ScaledPixels] { + @geometry.bounds(@geometry.point(sp(x), sp(y)), @geometry.size(sp(w), sp(h))) +} + +// A counter view: a row with a decrement button, a value bar and an +// increment button. + +///| +struct Counter { + mut count : Int32 + mut renders : Int32 +} + +///| +impl @window.Render for Counter with fn render(self, _window, cx) { + self.renders += 1 + @elements.div() + .flex() + .flex_row() + .gap(px(10.0)) + .p(px(10.0)) + .size_full() + .bg(@color.rgb(0xffffff)) + .child( + @elements.div() + .id("minus") + .size(px(20.0)) + .bg(@color.rgb(0xcc0000)) + .on_click( + @window.listener(cx, fn(counter, _, _, cx) { + counter.count -= 1 + cx.notify() + }), + ), + ) + .child( + @elements.div() + .w(px((self.count * 10).to_double())) + .h(px(20.0)) + .bg(@color.rgb(0x0000cc)), + ) + .child( + @elements.div() + .id("plus") + .size(px(20.0)) + .bg(@color.rgb(0x00cc00)) + .hover(fn(style) { style.bg(@color.rgb(0x00ff00)) }) + .on_click( + @window.listener(cx, fn(counter, _, _, cx) { + counter.count += 1 + cx.notify() + }), + ), + ) + .into_any_element() +} + +///| +fn setup_counter( + count~ : Int32 = 3, + scale_factor~ : Double = 1.0, +) -> (@app.App, @window.Window, @app.Entity[Counter]) { + let app = @app.App::new() + let window = @window.Window::new( + app, + @geometry.size(px(200.0), px(40.0)), + scale_factor~, + ) + let counter : @app.Entity[Counter] = app.new_entity(fn(_) { + { count, renders: 0, } + }) + window.set_root_view(counter) + (app, window, counter) +} + +///| +test "a view renders a laid-out div tree into the scene" { + let (_, window, _) = setup_counter() + let scene = window.draw() + // Root background, minus, value bar (3 * 10px) and plus. + assert_eq(scene.quads.length(), 4) + let bounds = scene.quads.map(fn(q) { q.bounds }) + assert_eq(bounds, [ + sbounds(0.0, 0.0, 200.0, 40.0), + sbounds(10.0, 10.0, 20.0, 20.0), + sbounds(40.0, 10.0, 30.0, 20.0), + sbounds(80.0, 10.0, 20.0, 20.0), + ]) + assert_eq(scene.quads[1].background, @color.rgb(0xcc0000).to_background()) + assert_eq(scene.batches().map(fn(b) { b.label() }), ["quads (4)"]) + assert_eq(window.frame_count(), 1) + assert_false(window.is_dirty()) +} + +///| +test "device pixels at 2x" { + let (_, window, _) = setup_counter(scale_factor=2.0) + let scene = window.draw() + assert_eq(scene.quads[3].bounds, sbounds(160.0, 20.0, 40.0, 40.0)) +} + +///| +test "clicks update the view and invalidate the window" { + let (app, window, counter) = setup_counter() + ignore(window.draw()) + // Click "plus" (80..100, 10..30). + ignore(window.dispatch_mouse_event(mouse_down(90.0, 20.0))) + ignore(window.dispatch_mouse_event(mouse_up(90.0, 20.0))) + assert_eq(counter.read(app).count, 4) + assert_true(window.is_dirty()) + let scene = window.draw() + // The value bar grew to 40px and pushed "plus" to the right. + assert_eq(scene.quads[2].bounds.size.width, sp(40.0)) + assert_eq(scene.quads[3].bounds.origin.x, sp(90.0)) + // Click "minus" twice. + for _ in 0..<2 { + ignore(window.dispatch_mouse_event(mouse_down(15.0, 15.0))) + ignore(window.dispatch_mouse_event(mouse_up(15.0, 15.0))) + ignore(window.draw()) + } + assert_eq(counter.read(app).count, 2) +} + +///| +test "a click needs press and release over the same element" { + let (app, window, counter) = setup_counter() + ignore(window.draw()) + // Press on "plus", release elsewhere: no click. + ignore(window.dispatch_mouse_event(mouse_down(90.0, 20.0))) + ignore(window.dispatch_mouse_event(mouse_up(150.0, 20.0))) + assert_eq(counter.read(app).count, 3) + // Press elsewhere, release on "plus": no click either. + ignore(window.dispatch_mouse_event(mouse_down(150.0, 20.0))) + ignore(window.dispatch_mouse_event(mouse_up(90.0, 20.0))) + assert_eq(counter.read(app).count, 3) +} + +///| +test "hover styles apply under the mouse" { + let (_, window, _) = setup_counter() + ignore(window.draw()) + ignore(window.dispatch_mouse_event(mouse_move(90.0, 20.0))) + // Entering a hitbox marks the window dirty. + assert_true(window.is_dirty()) + let scene = window.draw() + assert_eq(scene.quads[3].background, @color.rgb(0x00ff00).to_background()) + ignore(window.dispatch_mouse_event(mouse_move(150.0, 20.0))) + let scene = window.draw() + assert_eq(scene.quads[3].background, @color.rgb(0x00cc00).to_background()) + // Moving within nothing interactive does not dirty the window. + ignore(window.dispatch_mouse_event(mouse_move(151.0, 20.0))) + assert_false(window.is_dirty()) +} + +///| +test "only rendered views invalidate the window" { + let (app, window, counter) = setup_counter() + ignore(window.draw()) + let unrelated : @app.Entity[Counter] = app.new_entity(fn(_) { + { count: 0, renders: 0, } + }) + unrelated.update(app, fn(_, cx) { cx.notify() }) + assert_false(window.is_dirty()) + assert_false(window.draw_if_dirty()) + counter.update(app, fn(_, cx) { cx.notify() }) + assert_true(window.draw_if_dirty()) + assert_eq(counter.read(app).renders, 2) +} + +///| +struct Panel { + child : @app.Entity[Counter] + log : Array[String] +} + +///| +impl @window.Render for Panel with fn render(self, _window, _cx) { + let log = self.log + @elements.div() + .size_full() + .p(px(4.0)) + .on_mouse_down(Left, fn(_, _, _) { log.push("panel down") }) + .child(self.child) + .into_any_element() +} + +///| +test "nested views and event bubbling" { + let app = @app.App::new() + let window = @window.Window::new(app, @geometry.size(px(208.0), px(48.0))) + let child : @app.Entity[Counter] = app.new_entity(fn(_) { + { count: 0, renders: 0, } + }) + let panel : @app.Entity[Panel] = app.new_entity(fn(_) { { child, log: [], } }) + window.set_root_view(panel) + let scene = window.draw() + // The child view is laid out inside the panel's padding. + assert_eq(scene.quads[0].bounds.origin, @geometry.point(sp(4.0), sp(4.0))) + // With a count of 0 the value bar is empty: "plus" spans x 54..74. + // A press on it reaches the button first, then bubbles to the panel. + ignore(window.dispatch_mouse_event(mouse_down(64.0, 24.0))) + ignore(window.dispatch_mouse_event(mouse_up(64.0, 24.0))) + assert_eq(child.read(app).count, 1) + assert_eq(panel.read(app).log, ["panel down"]) + // Notifying the nested view invalidates the window too. + ignore(window.draw()) + child.update(app, fn(_, cx) { cx.notify() }) + assert_true(window.is_dirty()) +} + +///| +struct Layers { + log : Array[String] +} + +///| +impl @window.Render for Layers with fn render(self, _window, _cx) { + let log = self.log + @elements.div() + .size_full() + .relative() + .on_mouse_down(Left, fn(_, _, _) { log.push("background") }) + .child( + @elements.div() + .absolute() + .size(px(50.0)) + .occlude() + .on_mouse_down(Left, fn(_, window, _) { + log.push("overlay") + window.stop_propagation() + }), + ) + .into_any_element() +} + +///| +test "occlusion and stop_propagation" { + let app = @app.App::new() + let window = @window.Window::new(app, @geometry.size(px(100.0), px(100.0))) + let view : @app.Entity[Layers] = app.new_entity(fn(_) { { log: [], } }) + window.set_root_view(view) + ignore(window.draw()) + let propagated = window.dispatch_mouse_event(mouse_down(10.0, 10.0)) + assert_false(propagated) + ignore(window.dispatch_mouse_event(mouse_down(80.0, 80.0))) + assert_eq(view.read(app).log, ["overlay", "background"]) +} + +///| +struct Styled { + opacity : Double +} + +///| +impl @window.Render for Styled with fn render(self, _window, _cx) { + @elements.div() + .size_full() + .overflow_hidden() + .opacity(self.opacity) + .shadow_sm() + .rounded_md() + .border_2() + .border_color(@color.black()) + .bg(@color.rgb(0x336699)) + .child(@elements.div().w(px(500.0)).h(px(10.0)).bg(@color.red())) + .into_any_element() +} + +///| +test "shadows, borders, opacity and overflow clipping" { + let app = @app.App::new() + let window = @window.Window::new(app, @geometry.size(px(100.0), px(100.0))) + let view : @app.Entity[Styled] = app.new_entity(fn(_) { { opacity: 0.5, } }) + window.set_root_view(view) + let scene = window.draw() + assert_eq(scene.shadows.length(), 2) + // Background, child, border. + assert_eq(scene.quads.length(), 3) + let background = scene.quads[0] + assert_eq(background.background.solid.a, 0.5) + assert_eq(background.corner_radii.top_left, sp(6.0)) + let border = scene.quads.filter(fn(q) { q.border_widths.top == sp(2.0) }) + assert_eq(border.length(), 1) + assert_eq(border[0].border_color.a, 0.5) + // The wide child is clipped to the inside of the border. + let child = scene.quads.filter(fn(q) { q.bounds.size.width == sp(500.0) }) + assert_eq(child[0].content_mask.bounds, sbounds(2.0, 2.0, 96.0, 96.0)) + // Quads overlapping quads share a draw order and form one batch, drawn in + // insertion order: background, child, then the border on top. + assert_eq(scene.batches().map(fn(b) { b.label() }), [ + "shadows (2)", "quads (3)", + ]) + assert_eq(scene.quads[2].border_widths.top, sp(2.0)) +} + +///| +enum Drawing { + Drawing +} + +///| +impl @window.Render for Drawing with fn render(_self, _window, _cx) { + @elements.div() + .size_full() + .p(px(10.0)) + .child( + @elements.canvas(fn(bounds, window, _) { + window.paint_path( + [[bounds.origin, bounds.top_right(), bounds.bottom_left()]], + @color.blue().to_background(), + ) + }).size(px(30.0)), + ) + .into_any_element() +} + +///| +test "canvas paints with its bounds" { + let app = @app.App::new() + let window = @window.Window::new(app, @geometry.size(px(100.0), px(100.0))) + let view : @app.Entity[Drawing] = app.new_entity(fn(_) { Drawing }) + window.set_root_view(view) + let scene = window.draw() + assert_eq(scene.paths.length(), 1) + assert_eq(scene.paths[0].bounds, sbounds(10.0, 10.0, 30.0, 30.0)) +} + +///| +test "resizing relayouts" { + let (_, window, _) = setup_counter() + ignore(window.draw()) + window.resize(@geometry.size(px(300.0), px(60.0)), scale_factor=2.0) + assert_true(window.is_dirty()) + let scene = window.draw() + assert_eq(scene.quads[0].bounds, sbounds(0.0, 0.0, 600.0, 120.0)) +} + +///| +enum Broken { + Broken +} + +///| +impl @window.Render for Broken with fn render(_self, _window, _cx) { + @elements.div().on_click(fn(_, _, _) { }).into_any_element() +} + +///| +test "panic on on_click without an id" { + let app = @app.App::new() + let window = @window.Window::new(app, @geometry.size(px(10.0), px(10.0))) + let view : @app.Entity[Broken] = app.new_entity(fn(_) { Broken }) + window.set_root_view(view) + ignore(window.draw()) +} + +///| +test "panic on drawing without a root view" { + let window = @window.Window::new( + @app.App::new(), + @geometry.size(px(10.0), px(10.0)), + ) + ignore(window.draw()) +} + +///| +enum PaintsDuringLayout { + PaintsDuringLayout +} + +///| +impl @window.Render for PaintsDuringLayout with fn render(_self, window, _cx) { + window.paint_quad( + @window.fill( + @geometry.bounds(pt(0.0, 0.0), @geometry.size(px(1.0), px(1.0))), + @color.red().to_background(), + ), + ) + @window.empty() +} + +///| +test "panic on painting outside the paint phase" { + let app = @app.App::new() + let window = @window.Window::new(app, @geometry.size(px(10.0), px(10.0))) + let view : @app.Entity[PaintsDuringLayout] = app.new_entity(fn(_) { + PaintsDuringLayout + }) + window.set_root_view(view) + ignore(window.draw()) +} diff --git a/src/elements/moon.pkg b/src/elements/moon.pkg new file mode 100644 index 0000000..8949a5f --- /dev/null +++ b/src/elements/moon.pkg @@ -0,0 +1,16 @@ +import { + "experiments/gpui/geometry", + "experiments/gpui/style", + "experiments/gpui/input", + "experiments/gpui/app", + "experiments/gpui/window", +} + +options( + "allow-experimental-packages": true, +) + +import { + "experiments/gpui/color", + "experiments/gpui/platform/test" @test_platform, +} for "test" diff --git a/src/elements/pkg.generated.mbti b/src/elements/pkg.generated.mbti new file mode 100644 index 0000000..16a14e0 --- /dev/null +++ b/src/elements/pkg.generated.mbti @@ -0,0 +1,6474 @@ +// Generated using `moon info`, DON'T EDIT IT +package "experiments/gpui/elements" + +import { + "experiments/gpui/app", + "experiments/gpui/color", + "experiments/gpui/font", + "experiments/gpui/geometry", + "experiments/gpui/input", + "experiments/gpui/style", + "experiments/gpui/window", +} + +// Values +pub fn canvas((@geometry.Bounds[@geometry.Pixels], @window.Window, @app.App) -> Unit, prepaint? : (@geometry.Bounds[@geometry.Pixels], @window.Window, @app.App) -> Unit) -> Canvas + +pub fn div() -> Div + +// Errors + +// Types and methods +pub struct Canvas { + // private fields +} +pub fn Canvas::absolute(Self) -> Self +pub fn Canvas::aspect_ratio(Self, Double) -> Self +pub fn Canvas::aspect_square(Self) -> Self +pub fn Canvas::bg(Self, &@style.IntoFill) -> Self +pub fn Canvas::block(Self) -> Self +pub fn Canvas::border(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::border_0(Self) -> Self +pub fn Canvas::border_1(Self) -> Self +pub fn Canvas::border_10(Self) -> Self +pub fn Canvas::border_11(Self) -> Self +pub fn Canvas::border_12(Self) -> Self +pub fn Canvas::border_16(Self) -> Self +pub fn Canvas::border_2(Self) -> Self +pub fn Canvas::border_20(Self) -> Self +pub fn Canvas::border_24(Self) -> Self +pub fn Canvas::border_3(Self) -> Self +pub fn Canvas::border_32(Self) -> Self +pub fn Canvas::border_4(Self) -> Self +pub fn Canvas::border_5(Self) -> Self +pub fn Canvas::border_6(Self) -> Self +pub fn Canvas::border_7(Self) -> Self +pub fn Canvas::border_8(Self) -> Self +pub fn Canvas::border_9(Self) -> Self +pub fn Canvas::border_b(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::border_b_0(Self) -> Self +pub fn Canvas::border_b_1(Self) -> Self +pub fn Canvas::border_b_10(Self) -> Self +pub fn Canvas::border_b_11(Self) -> Self +pub fn Canvas::border_b_12(Self) -> Self +pub fn Canvas::border_b_16(Self) -> Self +pub fn Canvas::border_b_2(Self) -> Self +pub fn Canvas::border_b_20(Self) -> Self +pub fn Canvas::border_b_24(Self) -> Self +pub fn Canvas::border_b_3(Self) -> Self +pub fn Canvas::border_b_32(Self) -> Self +pub fn Canvas::border_b_4(Self) -> Self +pub fn Canvas::border_b_5(Self) -> Self +pub fn Canvas::border_b_6(Self) -> Self +pub fn Canvas::border_b_7(Self) -> Self +pub fn Canvas::border_b_8(Self) -> Self +pub fn Canvas::border_b_9(Self) -> Self +pub fn Canvas::border_color(Self, &@color.IntoHsla) -> Self +pub fn Canvas::border_dashed(Self) -> Self +pub fn Canvas::border_l(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::border_l_0(Self) -> Self +pub fn Canvas::border_l_1(Self) -> Self +pub fn Canvas::border_l_10(Self) -> Self +pub fn Canvas::border_l_11(Self) -> Self +pub fn Canvas::border_l_12(Self) -> Self +pub fn Canvas::border_l_16(Self) -> Self +pub fn Canvas::border_l_2(Self) -> Self +pub fn Canvas::border_l_20(Self) -> Self +pub fn Canvas::border_l_24(Self) -> Self +pub fn Canvas::border_l_3(Self) -> Self +pub fn Canvas::border_l_32(Self) -> Self +pub fn Canvas::border_l_4(Self) -> Self +pub fn Canvas::border_l_5(Self) -> Self +pub fn Canvas::border_l_6(Self) -> Self +pub fn Canvas::border_l_7(Self) -> Self +pub fn Canvas::border_l_8(Self) -> Self +pub fn Canvas::border_l_9(Self) -> Self +pub fn Canvas::border_r(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::border_r_0(Self) -> Self +pub fn Canvas::border_r_1(Self) -> Self +pub fn Canvas::border_r_10(Self) -> Self +pub fn Canvas::border_r_11(Self) -> Self +pub fn Canvas::border_r_12(Self) -> Self +pub fn Canvas::border_r_16(Self) -> Self +pub fn Canvas::border_r_2(Self) -> Self +pub fn Canvas::border_r_20(Self) -> Self +pub fn Canvas::border_r_24(Self) -> Self +pub fn Canvas::border_r_3(Self) -> Self +pub fn Canvas::border_r_32(Self) -> Self +pub fn Canvas::border_r_4(Self) -> Self +pub fn Canvas::border_r_5(Self) -> Self +pub fn Canvas::border_r_6(Self) -> Self +pub fn Canvas::border_r_7(Self) -> Self +pub fn Canvas::border_r_8(Self) -> Self +pub fn Canvas::border_r_9(Self) -> Self +pub fn Canvas::border_t(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::border_t_0(Self) -> Self +pub fn Canvas::border_t_1(Self) -> Self +pub fn Canvas::border_t_10(Self) -> Self +pub fn Canvas::border_t_11(Self) -> Self +pub fn Canvas::border_t_12(Self) -> Self +pub fn Canvas::border_t_16(Self) -> Self +pub fn Canvas::border_t_2(Self) -> Self +pub fn Canvas::border_t_20(Self) -> Self +pub fn Canvas::border_t_24(Self) -> Self +pub fn Canvas::border_t_3(Self) -> Self +pub fn Canvas::border_t_32(Self) -> Self +pub fn Canvas::border_t_4(Self) -> Self +pub fn Canvas::border_t_5(Self) -> Self +pub fn Canvas::border_t_6(Self) -> Self +pub fn Canvas::border_t_7(Self) -> Self +pub fn Canvas::border_t_8(Self) -> Self +pub fn Canvas::border_t_9(Self) -> Self +pub fn Canvas::border_x(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::border_x_0(Self) -> Self +pub fn Canvas::border_x_1(Self) -> Self +pub fn Canvas::border_x_10(Self) -> Self +pub fn Canvas::border_x_11(Self) -> Self +pub fn Canvas::border_x_12(Self) -> Self +pub fn Canvas::border_x_16(Self) -> Self +pub fn Canvas::border_x_2(Self) -> Self +pub fn Canvas::border_x_20(Self) -> Self +pub fn Canvas::border_x_24(Self) -> Self +pub fn Canvas::border_x_3(Self) -> Self +pub fn Canvas::border_x_32(Self) -> Self +pub fn Canvas::border_x_4(Self) -> Self +pub fn Canvas::border_x_5(Self) -> Self +pub fn Canvas::border_x_6(Self) -> Self +pub fn Canvas::border_x_7(Self) -> Self +pub fn Canvas::border_x_8(Self) -> Self +pub fn Canvas::border_x_9(Self) -> Self +pub fn Canvas::border_y(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::border_y_0(Self) -> Self +pub fn Canvas::border_y_1(Self) -> Self +pub fn Canvas::border_y_10(Self) -> Self +pub fn Canvas::border_y_11(Self) -> Self +pub fn Canvas::border_y_12(Self) -> Self +pub fn Canvas::border_y_16(Self) -> Self +pub fn Canvas::border_y_2(Self) -> Self +pub fn Canvas::border_y_20(Self) -> Self +pub fn Canvas::border_y_24(Self) -> Self +pub fn Canvas::border_y_3(Self) -> Self +pub fn Canvas::border_y_32(Self) -> Self +pub fn Canvas::border_y_4(Self) -> Self +pub fn Canvas::border_y_5(Self) -> Self +pub fn Canvas::border_y_6(Self) -> Self +pub fn Canvas::border_y_7(Self) -> Self +pub fn Canvas::border_y_8(Self) -> Self +pub fn Canvas::border_y_9(Self) -> Self +pub fn Canvas::bottom(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::bottom_0(Self) -> Self +pub fn Canvas::bottom_0p5(Self) -> Self +pub fn Canvas::bottom_1(Self) -> Self +pub fn Canvas::bottom_10(Self) -> Self +pub fn Canvas::bottom_11(Self) -> Self +pub fn Canvas::bottom_112(Self) -> Self +pub fn Canvas::bottom_12(Self) -> Self +pub fn Canvas::bottom_128(Self) -> Self +pub fn Canvas::bottom_16(Self) -> Self +pub fn Canvas::bottom_1_12(Self) -> Self +pub fn Canvas::bottom_1_2(Self) -> Self +pub fn Canvas::bottom_1_3(Self) -> Self +pub fn Canvas::bottom_1_4(Self) -> Self +pub fn Canvas::bottom_1_5(Self) -> Self +pub fn Canvas::bottom_1_6(Self) -> Self +pub fn Canvas::bottom_1p5(Self) -> Self +pub fn Canvas::bottom_2(Self) -> Self +pub fn Canvas::bottom_20(Self) -> Self +pub fn Canvas::bottom_24(Self) -> Self +pub fn Canvas::bottom_2_3(Self) -> Self +pub fn Canvas::bottom_2_4(Self) -> Self +pub fn Canvas::bottom_2_5(Self) -> Self +pub fn Canvas::bottom_2p5(Self) -> Self +pub fn Canvas::bottom_3(Self) -> Self +pub fn Canvas::bottom_32(Self) -> Self +pub fn Canvas::bottom_3_4(Self) -> Self +pub fn Canvas::bottom_3_5(Self) -> Self +pub fn Canvas::bottom_3p5(Self) -> Self +pub fn Canvas::bottom_4(Self) -> Self +pub fn Canvas::bottom_40(Self) -> Self +pub fn Canvas::bottom_48(Self) -> Self +pub fn Canvas::bottom_4_5(Self) -> Self +pub fn Canvas::bottom_5(Self) -> Self +pub fn Canvas::bottom_56(Self) -> Self +pub fn Canvas::bottom_5_6(Self) -> Self +pub fn Canvas::bottom_6(Self) -> Self +pub fn Canvas::bottom_64(Self) -> Self +pub fn Canvas::bottom_7(Self) -> Self +pub fn Canvas::bottom_72(Self) -> Self +pub fn Canvas::bottom_8(Self) -> Self +pub fn Canvas::bottom_80(Self) -> Self +pub fn Canvas::bottom_9(Self) -> Self +pub fn Canvas::bottom_96(Self) -> Self +pub fn Canvas::bottom_auto(Self) -> Self +pub fn Canvas::bottom_full(Self) -> Self +pub fn Canvas::bottom_neg_0(Self) -> Self +pub fn Canvas::bottom_neg_0p5(Self) -> Self +pub fn Canvas::bottom_neg_1(Self) -> Self +pub fn Canvas::bottom_neg_10(Self) -> Self +pub fn Canvas::bottom_neg_11(Self) -> Self +pub fn Canvas::bottom_neg_112(Self) -> Self +pub fn Canvas::bottom_neg_12(Self) -> Self +pub fn Canvas::bottom_neg_128(Self) -> Self +pub fn Canvas::bottom_neg_16(Self) -> Self +pub fn Canvas::bottom_neg_1_12(Self) -> Self +pub fn Canvas::bottom_neg_1_2(Self) -> Self +pub fn Canvas::bottom_neg_1_3(Self) -> Self +pub fn Canvas::bottom_neg_1_4(Self) -> Self +pub fn Canvas::bottom_neg_1_5(Self) -> Self +pub fn Canvas::bottom_neg_1_6(Self) -> Self +pub fn Canvas::bottom_neg_1p5(Self) -> Self +pub fn Canvas::bottom_neg_2(Self) -> Self +pub fn Canvas::bottom_neg_20(Self) -> Self +pub fn Canvas::bottom_neg_24(Self) -> Self +pub fn Canvas::bottom_neg_2_3(Self) -> Self +pub fn Canvas::bottom_neg_2_4(Self) -> Self +pub fn Canvas::bottom_neg_2_5(Self) -> Self +pub fn Canvas::bottom_neg_2p5(Self) -> Self +pub fn Canvas::bottom_neg_3(Self) -> Self +pub fn Canvas::bottom_neg_32(Self) -> Self +pub fn Canvas::bottom_neg_3_4(Self) -> Self +pub fn Canvas::bottom_neg_3_5(Self) -> Self +pub fn Canvas::bottom_neg_3p5(Self) -> Self +pub fn Canvas::bottom_neg_4(Self) -> Self +pub fn Canvas::bottom_neg_40(Self) -> Self +pub fn Canvas::bottom_neg_48(Self) -> Self +pub fn Canvas::bottom_neg_4_5(Self) -> Self +pub fn Canvas::bottom_neg_5(Self) -> Self +pub fn Canvas::bottom_neg_56(Self) -> Self +pub fn Canvas::bottom_neg_5_6(Self) -> Self +pub fn Canvas::bottom_neg_6(Self) -> Self +pub fn Canvas::bottom_neg_64(Self) -> Self +pub fn Canvas::bottom_neg_7(Self) -> Self +pub fn Canvas::bottom_neg_72(Self) -> Self +pub fn Canvas::bottom_neg_8(Self) -> Self +pub fn Canvas::bottom_neg_80(Self) -> Self +pub fn Canvas::bottom_neg_9(Self) -> Self +pub fn Canvas::bottom_neg_96(Self) -> Self +pub fn Canvas::bottom_neg_full(Self) -> Self +pub fn Canvas::bottom_neg_px(Self) -> Self +pub fn Canvas::bottom_px(Self) -> Self +pub fn Canvas::col_end(Self, Int32) -> Self +pub fn Canvas::col_end_auto(Self) -> Self +pub fn Canvas::col_span(Self, Int32) -> Self +pub fn Canvas::col_span_full(Self) -> Self +pub fn Canvas::col_start(Self, Int32) -> Self +pub fn Canvas::col_start_auto(Self) -> Self +pub fn Canvas::content_around(Self) -> Self +pub fn Canvas::content_between(Self) -> Self +pub fn Canvas::content_center(Self) -> Self +pub fn Canvas::content_end(Self) -> Self +pub fn Canvas::content_evenly(Self) -> Self +pub fn Canvas::content_normal(Self) -> Self +pub fn Canvas::content_start(Self) -> Self +pub fn Canvas::content_stretch(Self) -> Self +pub fn Canvas::cursor(Self, @style.CursorStyle) -> Self +pub fn Canvas::cursor_alias(Self) -> Self +pub fn Canvas::cursor_col_resize(Self) -> Self +pub fn Canvas::cursor_context_menu(Self) -> Self +pub fn Canvas::cursor_copy(Self) -> Self +pub fn Canvas::cursor_crosshair(Self) -> Self +pub fn Canvas::cursor_default(Self) -> Self +pub fn Canvas::cursor_e_resize(Self) -> Self +pub fn Canvas::cursor_ew_resize(Self) -> Self +pub fn Canvas::cursor_grab(Self) -> Self +pub fn Canvas::cursor_grabbing(Self) -> Self +pub fn Canvas::cursor_move(Self) -> Self +pub fn Canvas::cursor_n_resize(Self) -> Self +pub fn Canvas::cursor_nesw_resize(Self) -> Self +pub fn Canvas::cursor_no_drop(Self) -> Self +pub fn Canvas::cursor_not_allowed(Self) -> Self +pub fn Canvas::cursor_ns_resize(Self) -> Self +pub fn Canvas::cursor_nwse_resize(Self) -> Self +pub fn Canvas::cursor_pointer(Self) -> Self +pub fn Canvas::cursor_row_resize(Self) -> Self +pub fn Canvas::cursor_s_resize(Self) -> Self +pub fn Canvas::cursor_text(Self) -> Self +pub fn Canvas::cursor_vertical_text(Self) -> Self +pub fn Canvas::cursor_w_resize(Self) -> Self +pub fn Canvas::debug(Self) -> Self +pub fn Canvas::debug_below(Self) -> Self +pub fn Canvas::flex(Self) -> Self +pub fn Canvas::flex_1(Self) -> Self +pub fn Canvas::flex_auto(Self) -> Self +pub fn Canvas::flex_basis(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::flex_col(Self) -> Self +pub fn Canvas::flex_col_reverse(Self) -> Self +pub fn Canvas::flex_grow(Self, Double) -> Self +pub fn Canvas::flex_grow_0(Self) -> Self +pub fn Canvas::flex_grow_1(Self) -> Self +pub fn Canvas::flex_initial(Self) -> Self +pub fn Canvas::flex_none(Self) -> Self +pub fn Canvas::flex_nowrap(Self) -> Self +pub fn Canvas::flex_row(Self) -> Self +pub fn Canvas::flex_row_reverse(Self) -> Self +pub fn Canvas::flex_shrink(Self, Double) -> Self +pub fn Canvas::flex_shrink_0(Self) -> Self +pub fn Canvas::flex_shrink_1(Self) -> Self +pub fn Canvas::flex_wrap(Self) -> Self +pub fn Canvas::flex_wrap_reverse(Self) -> Self +pub fn Canvas::font(Self, @font.Font) -> Self +pub fn Canvas::font_family(Self, String) -> Self +pub fn Canvas::font_features(Self, @font.FontFeatures) -> Self +pub fn Canvas::font_weight(Self, @font.FontWeight) -> Self +pub fn Canvas::gap(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Canvas::gap_0(Self) -> Self +pub fn Canvas::gap_0p5(Self) -> Self +pub fn Canvas::gap_1(Self) -> Self +pub fn Canvas::gap_10(Self) -> Self +pub fn Canvas::gap_11(Self) -> Self +pub fn Canvas::gap_112(Self) -> Self +pub fn Canvas::gap_12(Self) -> Self +pub fn Canvas::gap_128(Self) -> Self +pub fn Canvas::gap_16(Self) -> Self +pub fn Canvas::gap_1_12(Self) -> Self +pub fn Canvas::gap_1_2(Self) -> Self +pub fn Canvas::gap_1_3(Self) -> Self +pub fn Canvas::gap_1_4(Self) -> Self +pub fn Canvas::gap_1_5(Self) -> Self +pub fn Canvas::gap_1_6(Self) -> Self +pub fn Canvas::gap_1p5(Self) -> Self +pub fn Canvas::gap_2(Self) -> Self +pub fn Canvas::gap_20(Self) -> Self +pub fn Canvas::gap_24(Self) -> Self +pub fn Canvas::gap_2_3(Self) -> Self +pub fn Canvas::gap_2_4(Self) -> Self +pub fn Canvas::gap_2_5(Self) -> Self +pub fn Canvas::gap_2p5(Self) -> Self +pub fn Canvas::gap_3(Self) -> Self +pub fn Canvas::gap_32(Self) -> Self +pub fn Canvas::gap_3_4(Self) -> Self +pub fn Canvas::gap_3_5(Self) -> Self +pub fn Canvas::gap_3p5(Self) -> Self +pub fn Canvas::gap_4(Self) -> Self +pub fn Canvas::gap_40(Self) -> Self +pub fn Canvas::gap_48(Self) -> Self +pub fn Canvas::gap_4_5(Self) -> Self +pub fn Canvas::gap_5(Self) -> Self +pub fn Canvas::gap_56(Self) -> Self +pub fn Canvas::gap_5_6(Self) -> Self +pub fn Canvas::gap_6(Self) -> Self +pub fn Canvas::gap_64(Self) -> Self +pub fn Canvas::gap_7(Self) -> Self +pub fn Canvas::gap_72(Self) -> Self +pub fn Canvas::gap_8(Self) -> Self +pub fn Canvas::gap_80(Self) -> Self +pub fn Canvas::gap_9(Self) -> Self +pub fn Canvas::gap_96(Self) -> Self +pub fn Canvas::gap_full(Self) -> Self +pub fn Canvas::gap_neg_0(Self) -> Self +pub fn Canvas::gap_neg_0p5(Self) -> Self +pub fn Canvas::gap_neg_1(Self) -> Self +pub fn Canvas::gap_neg_10(Self) -> Self +pub fn Canvas::gap_neg_11(Self) -> Self +pub fn Canvas::gap_neg_112(Self) -> Self +pub fn Canvas::gap_neg_12(Self) -> Self +pub fn Canvas::gap_neg_128(Self) -> Self +pub fn Canvas::gap_neg_16(Self) -> Self +pub fn Canvas::gap_neg_1_12(Self) -> Self +pub fn Canvas::gap_neg_1_2(Self) -> Self +pub fn Canvas::gap_neg_1_3(Self) -> Self +pub fn Canvas::gap_neg_1_4(Self) -> Self +pub fn Canvas::gap_neg_1_5(Self) -> Self +pub fn Canvas::gap_neg_1_6(Self) -> Self +pub fn Canvas::gap_neg_1p5(Self) -> Self +pub fn Canvas::gap_neg_2(Self) -> Self +pub fn Canvas::gap_neg_20(Self) -> Self +pub fn Canvas::gap_neg_24(Self) -> Self +pub fn Canvas::gap_neg_2_3(Self) -> Self +pub fn Canvas::gap_neg_2_4(Self) -> Self +pub fn Canvas::gap_neg_2_5(Self) -> Self +pub fn Canvas::gap_neg_2p5(Self) -> Self +pub fn Canvas::gap_neg_3(Self) -> Self +pub fn Canvas::gap_neg_32(Self) -> Self +pub fn Canvas::gap_neg_3_4(Self) -> Self +pub fn Canvas::gap_neg_3_5(Self) -> Self +pub fn Canvas::gap_neg_3p5(Self) -> Self +pub fn Canvas::gap_neg_4(Self) -> Self +pub fn Canvas::gap_neg_40(Self) -> Self +pub fn Canvas::gap_neg_48(Self) -> Self +pub fn Canvas::gap_neg_4_5(Self) -> Self +pub fn Canvas::gap_neg_5(Self) -> Self +pub fn Canvas::gap_neg_56(Self) -> Self +pub fn Canvas::gap_neg_5_6(Self) -> Self +pub fn Canvas::gap_neg_6(Self) -> Self +pub fn Canvas::gap_neg_64(Self) -> Self +pub fn Canvas::gap_neg_7(Self) -> Self +pub fn Canvas::gap_neg_72(Self) -> Self +pub fn Canvas::gap_neg_8(Self) -> Self +pub fn Canvas::gap_neg_80(Self) -> Self +pub fn Canvas::gap_neg_9(Self) -> Self +pub fn Canvas::gap_neg_96(Self) -> Self +pub fn Canvas::gap_neg_full(Self) -> Self +pub fn Canvas::gap_neg_px(Self) -> Self +pub fn Canvas::gap_px(Self) -> Self +pub fn Canvas::gap_x(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Canvas::gap_x_0(Self) -> Self +pub fn Canvas::gap_x_0p5(Self) -> Self +pub fn Canvas::gap_x_1(Self) -> Self +pub fn Canvas::gap_x_10(Self) -> Self +pub fn Canvas::gap_x_11(Self) -> Self +pub fn Canvas::gap_x_112(Self) -> Self +pub fn Canvas::gap_x_12(Self) -> Self +pub fn Canvas::gap_x_128(Self) -> Self +pub fn Canvas::gap_x_16(Self) -> Self +pub fn Canvas::gap_x_1_12(Self) -> Self +pub fn Canvas::gap_x_1_2(Self) -> Self +pub fn Canvas::gap_x_1_3(Self) -> Self +pub fn Canvas::gap_x_1_4(Self) -> Self +pub fn Canvas::gap_x_1_5(Self) -> Self +pub fn Canvas::gap_x_1_6(Self) -> Self +pub fn Canvas::gap_x_1p5(Self) -> Self +pub fn Canvas::gap_x_2(Self) -> Self +pub fn Canvas::gap_x_20(Self) -> Self +pub fn Canvas::gap_x_24(Self) -> Self +pub fn Canvas::gap_x_2_3(Self) -> Self +pub fn Canvas::gap_x_2_4(Self) -> Self +pub fn Canvas::gap_x_2_5(Self) -> Self +pub fn Canvas::gap_x_2p5(Self) -> Self +pub fn Canvas::gap_x_3(Self) -> Self +pub fn Canvas::gap_x_32(Self) -> Self +pub fn Canvas::gap_x_3_4(Self) -> Self +pub fn Canvas::gap_x_3_5(Self) -> Self +pub fn Canvas::gap_x_3p5(Self) -> Self +pub fn Canvas::gap_x_4(Self) -> Self +pub fn Canvas::gap_x_40(Self) -> Self +pub fn Canvas::gap_x_48(Self) -> Self +pub fn Canvas::gap_x_4_5(Self) -> Self +pub fn Canvas::gap_x_5(Self) -> Self +pub fn Canvas::gap_x_56(Self) -> Self +pub fn Canvas::gap_x_5_6(Self) -> Self +pub fn Canvas::gap_x_6(Self) -> Self +pub fn Canvas::gap_x_64(Self) -> Self +pub fn Canvas::gap_x_7(Self) -> Self +pub fn Canvas::gap_x_72(Self) -> Self +pub fn Canvas::gap_x_8(Self) -> Self +pub fn Canvas::gap_x_80(Self) -> Self +pub fn Canvas::gap_x_9(Self) -> Self +pub fn Canvas::gap_x_96(Self) -> Self +pub fn Canvas::gap_x_full(Self) -> Self +pub fn Canvas::gap_x_neg_0(Self) -> Self +pub fn Canvas::gap_x_neg_0p5(Self) -> Self +pub fn Canvas::gap_x_neg_1(Self) -> Self +pub fn Canvas::gap_x_neg_10(Self) -> Self +pub fn Canvas::gap_x_neg_11(Self) -> Self +pub fn Canvas::gap_x_neg_112(Self) -> Self +pub fn Canvas::gap_x_neg_12(Self) -> Self +pub fn Canvas::gap_x_neg_128(Self) -> Self +pub fn Canvas::gap_x_neg_16(Self) -> Self +pub fn Canvas::gap_x_neg_1_12(Self) -> Self +pub fn Canvas::gap_x_neg_1_2(Self) -> Self +pub fn Canvas::gap_x_neg_1_3(Self) -> Self +pub fn Canvas::gap_x_neg_1_4(Self) -> Self +pub fn Canvas::gap_x_neg_1_5(Self) -> Self +pub fn Canvas::gap_x_neg_1_6(Self) -> Self +pub fn Canvas::gap_x_neg_1p5(Self) -> Self +pub fn Canvas::gap_x_neg_2(Self) -> Self +pub fn Canvas::gap_x_neg_20(Self) -> Self +pub fn Canvas::gap_x_neg_24(Self) -> Self +pub fn Canvas::gap_x_neg_2_3(Self) -> Self +pub fn Canvas::gap_x_neg_2_4(Self) -> Self +pub fn Canvas::gap_x_neg_2_5(Self) -> Self +pub fn Canvas::gap_x_neg_2p5(Self) -> Self +pub fn Canvas::gap_x_neg_3(Self) -> Self +pub fn Canvas::gap_x_neg_32(Self) -> Self +pub fn Canvas::gap_x_neg_3_4(Self) -> Self +pub fn Canvas::gap_x_neg_3_5(Self) -> Self +pub fn Canvas::gap_x_neg_3p5(Self) -> Self +pub fn Canvas::gap_x_neg_4(Self) -> Self +pub fn Canvas::gap_x_neg_40(Self) -> Self +pub fn Canvas::gap_x_neg_48(Self) -> Self +pub fn Canvas::gap_x_neg_4_5(Self) -> Self +pub fn Canvas::gap_x_neg_5(Self) -> Self +pub fn Canvas::gap_x_neg_56(Self) -> Self +pub fn Canvas::gap_x_neg_5_6(Self) -> Self +pub fn Canvas::gap_x_neg_6(Self) -> Self +pub fn Canvas::gap_x_neg_64(Self) -> Self +pub fn Canvas::gap_x_neg_7(Self) -> Self +pub fn Canvas::gap_x_neg_72(Self) -> Self +pub fn Canvas::gap_x_neg_8(Self) -> Self +pub fn Canvas::gap_x_neg_80(Self) -> Self +pub fn Canvas::gap_x_neg_9(Self) -> Self +pub fn Canvas::gap_x_neg_96(Self) -> Self +pub fn Canvas::gap_x_neg_full(Self) -> Self +pub fn Canvas::gap_x_neg_px(Self) -> Self +pub fn Canvas::gap_x_px(Self) -> Self +pub fn Canvas::gap_y(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Canvas::gap_y_0(Self) -> Self +pub fn Canvas::gap_y_0p5(Self) -> Self +pub fn Canvas::gap_y_1(Self) -> Self +pub fn Canvas::gap_y_10(Self) -> Self +pub fn Canvas::gap_y_11(Self) -> Self +pub fn Canvas::gap_y_112(Self) -> Self +pub fn Canvas::gap_y_12(Self) -> Self +pub fn Canvas::gap_y_128(Self) -> Self +pub fn Canvas::gap_y_16(Self) -> Self +pub fn Canvas::gap_y_1_12(Self) -> Self +pub fn Canvas::gap_y_1_2(Self) -> Self +pub fn Canvas::gap_y_1_3(Self) -> Self +pub fn Canvas::gap_y_1_4(Self) -> Self +pub fn Canvas::gap_y_1_5(Self) -> Self +pub fn Canvas::gap_y_1_6(Self) -> Self +pub fn Canvas::gap_y_1p5(Self) -> Self +pub fn Canvas::gap_y_2(Self) -> Self +pub fn Canvas::gap_y_20(Self) -> Self +pub fn Canvas::gap_y_24(Self) -> Self +pub fn Canvas::gap_y_2_3(Self) -> Self +pub fn Canvas::gap_y_2_4(Self) -> Self +pub fn Canvas::gap_y_2_5(Self) -> Self +pub fn Canvas::gap_y_2p5(Self) -> Self +pub fn Canvas::gap_y_3(Self) -> Self +pub fn Canvas::gap_y_32(Self) -> Self +pub fn Canvas::gap_y_3_4(Self) -> Self +pub fn Canvas::gap_y_3_5(Self) -> Self +pub fn Canvas::gap_y_3p5(Self) -> Self +pub fn Canvas::gap_y_4(Self) -> Self +pub fn Canvas::gap_y_40(Self) -> Self +pub fn Canvas::gap_y_48(Self) -> Self +pub fn Canvas::gap_y_4_5(Self) -> Self +pub fn Canvas::gap_y_5(Self) -> Self +pub fn Canvas::gap_y_56(Self) -> Self +pub fn Canvas::gap_y_5_6(Self) -> Self +pub fn Canvas::gap_y_6(Self) -> Self +pub fn Canvas::gap_y_64(Self) -> Self +pub fn Canvas::gap_y_7(Self) -> Self +pub fn Canvas::gap_y_72(Self) -> Self +pub fn Canvas::gap_y_8(Self) -> Self +pub fn Canvas::gap_y_80(Self) -> Self +pub fn Canvas::gap_y_9(Self) -> Self +pub fn Canvas::gap_y_96(Self) -> Self +pub fn Canvas::gap_y_full(Self) -> Self +pub fn Canvas::gap_y_neg_0(Self) -> Self +pub fn Canvas::gap_y_neg_0p5(Self) -> Self +pub fn Canvas::gap_y_neg_1(Self) -> Self +pub fn Canvas::gap_y_neg_10(Self) -> Self +pub fn Canvas::gap_y_neg_11(Self) -> Self +pub fn Canvas::gap_y_neg_112(Self) -> Self +pub fn Canvas::gap_y_neg_12(Self) -> Self +pub fn Canvas::gap_y_neg_128(Self) -> Self +pub fn Canvas::gap_y_neg_16(Self) -> Self +pub fn Canvas::gap_y_neg_1_12(Self) -> Self +pub fn Canvas::gap_y_neg_1_2(Self) -> Self +pub fn Canvas::gap_y_neg_1_3(Self) -> Self +pub fn Canvas::gap_y_neg_1_4(Self) -> Self +pub fn Canvas::gap_y_neg_1_5(Self) -> Self +pub fn Canvas::gap_y_neg_1_6(Self) -> Self +pub fn Canvas::gap_y_neg_1p5(Self) -> Self +pub fn Canvas::gap_y_neg_2(Self) -> Self +pub fn Canvas::gap_y_neg_20(Self) -> Self +pub fn Canvas::gap_y_neg_24(Self) -> Self +pub fn Canvas::gap_y_neg_2_3(Self) -> Self +pub fn Canvas::gap_y_neg_2_4(Self) -> Self +pub fn Canvas::gap_y_neg_2_5(Self) -> Self +pub fn Canvas::gap_y_neg_2p5(Self) -> Self +pub fn Canvas::gap_y_neg_3(Self) -> Self +pub fn Canvas::gap_y_neg_32(Self) -> Self +pub fn Canvas::gap_y_neg_3_4(Self) -> Self +pub fn Canvas::gap_y_neg_3_5(Self) -> Self +pub fn Canvas::gap_y_neg_3p5(Self) -> Self +pub fn Canvas::gap_y_neg_4(Self) -> Self +pub fn Canvas::gap_y_neg_40(Self) -> Self +pub fn Canvas::gap_y_neg_48(Self) -> Self +pub fn Canvas::gap_y_neg_4_5(Self) -> Self +pub fn Canvas::gap_y_neg_5(Self) -> Self +pub fn Canvas::gap_y_neg_56(Self) -> Self +pub fn Canvas::gap_y_neg_5_6(Self) -> Self +pub fn Canvas::gap_y_neg_6(Self) -> Self +pub fn Canvas::gap_y_neg_64(Self) -> Self +pub fn Canvas::gap_y_neg_7(Self) -> Self +pub fn Canvas::gap_y_neg_72(Self) -> Self +pub fn Canvas::gap_y_neg_8(Self) -> Self +pub fn Canvas::gap_y_neg_80(Self) -> Self +pub fn Canvas::gap_y_neg_9(Self) -> Self +pub fn Canvas::gap_y_neg_96(Self) -> Self +pub fn Canvas::gap_y_neg_full(Self) -> Self +pub fn Canvas::gap_y_neg_px(Self) -> Self +pub fn Canvas::gap_y_px(Self) -> Self +pub fn Canvas::grid(Self) -> Self +pub fn Canvas::grid_cols(Self, Int32) -> Self +pub fn Canvas::grid_cols_max_content(Self, Int32) -> Self +pub fn Canvas::grid_cols_min_content(Self, Int32) -> Self +pub fn Canvas::grid_rows(Self, Int32) -> Self +pub fn Canvas::grid_rows_max_content(Self, Int32) -> Self +pub fn Canvas::grid_rows_min_content(Self, Int32) -> Self +pub fn Canvas::h(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::h_0(Self) -> Self +pub fn Canvas::h_0p5(Self) -> Self +pub fn Canvas::h_1(Self) -> Self +pub fn Canvas::h_10(Self) -> Self +pub fn Canvas::h_11(Self) -> Self +pub fn Canvas::h_112(Self) -> Self +pub fn Canvas::h_12(Self) -> Self +pub fn Canvas::h_128(Self) -> Self +pub fn Canvas::h_16(Self) -> Self +pub fn Canvas::h_1_12(Self) -> Self +pub fn Canvas::h_1_2(Self) -> Self +pub fn Canvas::h_1_3(Self) -> Self +pub fn Canvas::h_1_4(Self) -> Self +pub fn Canvas::h_1_5(Self) -> Self +pub fn Canvas::h_1_6(Self) -> Self +pub fn Canvas::h_1p5(Self) -> Self +pub fn Canvas::h_2(Self) -> Self +pub fn Canvas::h_20(Self) -> Self +pub fn Canvas::h_24(Self) -> Self +pub fn Canvas::h_2_3(Self) -> Self +pub fn Canvas::h_2_4(Self) -> Self +pub fn Canvas::h_2_5(Self) -> Self +pub fn Canvas::h_2p5(Self) -> Self +pub fn Canvas::h_3(Self) -> Self +pub fn Canvas::h_32(Self) -> Self +pub fn Canvas::h_3_4(Self) -> Self +pub fn Canvas::h_3_5(Self) -> Self +pub fn Canvas::h_3p5(Self) -> Self +pub fn Canvas::h_4(Self) -> Self +pub fn Canvas::h_40(Self) -> Self +pub fn Canvas::h_48(Self) -> Self +pub fn Canvas::h_4_5(Self) -> Self +pub fn Canvas::h_5(Self) -> Self +pub fn Canvas::h_56(Self) -> Self +pub fn Canvas::h_5_6(Self) -> Self +pub fn Canvas::h_6(Self) -> Self +pub fn Canvas::h_64(Self) -> Self +pub fn Canvas::h_7(Self) -> Self +pub fn Canvas::h_72(Self) -> Self +pub fn Canvas::h_8(Self) -> Self +pub fn Canvas::h_80(Self) -> Self +pub fn Canvas::h_9(Self) -> Self +pub fn Canvas::h_96(Self) -> Self +pub fn Canvas::h_auto(Self) -> Self +pub fn Canvas::h_full(Self) -> Self +pub fn Canvas::h_neg_0(Self) -> Self +pub fn Canvas::h_neg_0p5(Self) -> Self +pub fn Canvas::h_neg_1(Self) -> Self +pub fn Canvas::h_neg_10(Self) -> Self +pub fn Canvas::h_neg_11(Self) -> Self +pub fn Canvas::h_neg_112(Self) -> Self +pub fn Canvas::h_neg_12(Self) -> Self +pub fn Canvas::h_neg_128(Self) -> Self +pub fn Canvas::h_neg_16(Self) -> Self +pub fn Canvas::h_neg_1_12(Self) -> Self +pub fn Canvas::h_neg_1_2(Self) -> Self +pub fn Canvas::h_neg_1_3(Self) -> Self +pub fn Canvas::h_neg_1_4(Self) -> Self +pub fn Canvas::h_neg_1_5(Self) -> Self +pub fn Canvas::h_neg_1_6(Self) -> Self +pub fn Canvas::h_neg_1p5(Self) -> Self +pub fn Canvas::h_neg_2(Self) -> Self +pub fn Canvas::h_neg_20(Self) -> Self +pub fn Canvas::h_neg_24(Self) -> Self +pub fn Canvas::h_neg_2_3(Self) -> Self +pub fn Canvas::h_neg_2_4(Self) -> Self +pub fn Canvas::h_neg_2_5(Self) -> Self +pub fn Canvas::h_neg_2p5(Self) -> Self +pub fn Canvas::h_neg_3(Self) -> Self +pub fn Canvas::h_neg_32(Self) -> Self +pub fn Canvas::h_neg_3_4(Self) -> Self +pub fn Canvas::h_neg_3_5(Self) -> Self +pub fn Canvas::h_neg_3p5(Self) -> Self +pub fn Canvas::h_neg_4(Self) -> Self +pub fn Canvas::h_neg_40(Self) -> Self +pub fn Canvas::h_neg_48(Self) -> Self +pub fn Canvas::h_neg_4_5(Self) -> Self +pub fn Canvas::h_neg_5(Self) -> Self +pub fn Canvas::h_neg_56(Self) -> Self +pub fn Canvas::h_neg_5_6(Self) -> Self +pub fn Canvas::h_neg_6(Self) -> Self +pub fn Canvas::h_neg_64(Self) -> Self +pub fn Canvas::h_neg_7(Self) -> Self +pub fn Canvas::h_neg_72(Self) -> Self +pub fn Canvas::h_neg_8(Self) -> Self +pub fn Canvas::h_neg_80(Self) -> Self +pub fn Canvas::h_neg_9(Self) -> Self +pub fn Canvas::h_neg_96(Self) -> Self +pub fn Canvas::h_neg_full(Self) -> Self +pub fn Canvas::h_neg_px(Self) -> Self +pub fn Canvas::h_px(Self) -> Self +pub fn Canvas::hidden(Self) -> Self +pub fn Canvas::inset(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::inset_0(Self) -> Self +pub fn Canvas::inset_0p5(Self) -> Self +pub fn Canvas::inset_1(Self) -> Self +pub fn Canvas::inset_10(Self) -> Self +pub fn Canvas::inset_11(Self) -> Self +pub fn Canvas::inset_112(Self) -> Self +pub fn Canvas::inset_12(Self) -> Self +pub fn Canvas::inset_128(Self) -> Self +pub fn Canvas::inset_16(Self) -> Self +pub fn Canvas::inset_1_12(Self) -> Self +pub fn Canvas::inset_1_2(Self) -> Self +pub fn Canvas::inset_1_3(Self) -> Self +pub fn Canvas::inset_1_4(Self) -> Self +pub fn Canvas::inset_1_5(Self) -> Self +pub fn Canvas::inset_1_6(Self) -> Self +pub fn Canvas::inset_1p5(Self) -> Self +pub fn Canvas::inset_2(Self) -> Self +pub fn Canvas::inset_20(Self) -> Self +pub fn Canvas::inset_24(Self) -> Self +pub fn Canvas::inset_2_3(Self) -> Self +pub fn Canvas::inset_2_4(Self) -> Self +pub fn Canvas::inset_2_5(Self) -> Self +pub fn Canvas::inset_2p5(Self) -> Self +pub fn Canvas::inset_3(Self) -> Self +pub fn Canvas::inset_32(Self) -> Self +pub fn Canvas::inset_3_4(Self) -> Self +pub fn Canvas::inset_3_5(Self) -> Self +pub fn Canvas::inset_3p5(Self) -> Self +pub fn Canvas::inset_4(Self) -> Self +pub fn Canvas::inset_40(Self) -> Self +pub fn Canvas::inset_48(Self) -> Self +pub fn Canvas::inset_4_5(Self) -> Self +pub fn Canvas::inset_5(Self) -> Self +pub fn Canvas::inset_56(Self) -> Self +pub fn Canvas::inset_5_6(Self) -> Self +pub fn Canvas::inset_6(Self) -> Self +pub fn Canvas::inset_64(Self) -> Self +pub fn Canvas::inset_7(Self) -> Self +pub fn Canvas::inset_72(Self) -> Self +pub fn Canvas::inset_8(Self) -> Self +pub fn Canvas::inset_80(Self) -> Self +pub fn Canvas::inset_9(Self) -> Self +pub fn Canvas::inset_96(Self) -> Self +pub fn Canvas::inset_auto(Self) -> Self +pub fn Canvas::inset_full(Self) -> Self +pub fn Canvas::inset_neg_0(Self) -> Self +pub fn Canvas::inset_neg_0p5(Self) -> Self +pub fn Canvas::inset_neg_1(Self) -> Self +pub fn Canvas::inset_neg_10(Self) -> Self +pub fn Canvas::inset_neg_11(Self) -> Self +pub fn Canvas::inset_neg_112(Self) -> Self +pub fn Canvas::inset_neg_12(Self) -> Self +pub fn Canvas::inset_neg_128(Self) -> Self +pub fn Canvas::inset_neg_16(Self) -> Self +pub fn Canvas::inset_neg_1_12(Self) -> Self +pub fn Canvas::inset_neg_1_2(Self) -> Self +pub fn Canvas::inset_neg_1_3(Self) -> Self +pub fn Canvas::inset_neg_1_4(Self) -> Self +pub fn Canvas::inset_neg_1_5(Self) -> Self +pub fn Canvas::inset_neg_1_6(Self) -> Self +pub fn Canvas::inset_neg_1p5(Self) -> Self +pub fn Canvas::inset_neg_2(Self) -> Self +pub fn Canvas::inset_neg_20(Self) -> Self +pub fn Canvas::inset_neg_24(Self) -> Self +pub fn Canvas::inset_neg_2_3(Self) -> Self +pub fn Canvas::inset_neg_2_4(Self) -> Self +pub fn Canvas::inset_neg_2_5(Self) -> Self +pub fn Canvas::inset_neg_2p5(Self) -> Self +pub fn Canvas::inset_neg_3(Self) -> Self +pub fn Canvas::inset_neg_32(Self) -> Self +pub fn Canvas::inset_neg_3_4(Self) -> Self +pub fn Canvas::inset_neg_3_5(Self) -> Self +pub fn Canvas::inset_neg_3p5(Self) -> Self +pub fn Canvas::inset_neg_4(Self) -> Self +pub fn Canvas::inset_neg_40(Self) -> Self +pub fn Canvas::inset_neg_48(Self) -> Self +pub fn Canvas::inset_neg_4_5(Self) -> Self +pub fn Canvas::inset_neg_5(Self) -> Self +pub fn Canvas::inset_neg_56(Self) -> Self +pub fn Canvas::inset_neg_5_6(Self) -> Self +pub fn Canvas::inset_neg_6(Self) -> Self +pub fn Canvas::inset_neg_64(Self) -> Self +pub fn Canvas::inset_neg_7(Self) -> Self +pub fn Canvas::inset_neg_72(Self) -> Self +pub fn Canvas::inset_neg_8(Self) -> Self +pub fn Canvas::inset_neg_80(Self) -> Self +pub fn Canvas::inset_neg_9(Self) -> Self +pub fn Canvas::inset_neg_96(Self) -> Self +pub fn Canvas::inset_neg_full(Self) -> Self +pub fn Canvas::inset_neg_px(Self) -> Self +pub fn Canvas::inset_px(Self) -> Self +pub fn Canvas::into_any_element(Self) -> @window.AnyElement +pub fn Canvas::invisible(Self) -> Self +pub fn Canvas::italic(Self) -> Self +pub fn Canvas::items_baseline(Self) -> Self +pub fn Canvas::items_center(Self) -> Self +pub fn Canvas::items_end(Self) -> Self +pub fn Canvas::items_start(Self) -> Self +pub fn Canvas::items_stretch(Self) -> Self +pub fn Canvas::justify_around(Self) -> Self +pub fn Canvas::justify_between(Self) -> Self +pub fn Canvas::justify_center(Self) -> Self +pub fn Canvas::justify_end(Self) -> Self +pub fn Canvas::justify_evenly(Self) -> Self +pub fn Canvas::justify_start(Self) -> Self +pub fn Canvas::left(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::left_0(Self) -> Self +pub fn Canvas::left_0p5(Self) -> Self +pub fn Canvas::left_1(Self) -> Self +pub fn Canvas::left_10(Self) -> Self +pub fn Canvas::left_11(Self) -> Self +pub fn Canvas::left_112(Self) -> Self +pub fn Canvas::left_12(Self) -> Self +pub fn Canvas::left_128(Self) -> Self +pub fn Canvas::left_16(Self) -> Self +pub fn Canvas::left_1_12(Self) -> Self +pub fn Canvas::left_1_2(Self) -> Self +pub fn Canvas::left_1_3(Self) -> Self +pub fn Canvas::left_1_4(Self) -> Self +pub fn Canvas::left_1_5(Self) -> Self +pub fn Canvas::left_1_6(Self) -> Self +pub fn Canvas::left_1p5(Self) -> Self +pub fn Canvas::left_2(Self) -> Self +pub fn Canvas::left_20(Self) -> Self +pub fn Canvas::left_24(Self) -> Self +pub fn Canvas::left_2_3(Self) -> Self +pub fn Canvas::left_2_4(Self) -> Self +pub fn Canvas::left_2_5(Self) -> Self +pub fn Canvas::left_2p5(Self) -> Self +pub fn Canvas::left_3(Self) -> Self +pub fn Canvas::left_32(Self) -> Self +pub fn Canvas::left_3_4(Self) -> Self +pub fn Canvas::left_3_5(Self) -> Self +pub fn Canvas::left_3p5(Self) -> Self +pub fn Canvas::left_4(Self) -> Self +pub fn Canvas::left_40(Self) -> Self +pub fn Canvas::left_48(Self) -> Self +pub fn Canvas::left_4_5(Self) -> Self +pub fn Canvas::left_5(Self) -> Self +pub fn Canvas::left_56(Self) -> Self +pub fn Canvas::left_5_6(Self) -> Self +pub fn Canvas::left_6(Self) -> Self +pub fn Canvas::left_64(Self) -> Self +pub fn Canvas::left_7(Self) -> Self +pub fn Canvas::left_72(Self) -> Self +pub fn Canvas::left_8(Self) -> Self +pub fn Canvas::left_80(Self) -> Self +pub fn Canvas::left_9(Self) -> Self +pub fn Canvas::left_96(Self) -> Self +pub fn Canvas::left_auto(Self) -> Self +pub fn Canvas::left_full(Self) -> Self +pub fn Canvas::left_neg_0(Self) -> Self +pub fn Canvas::left_neg_0p5(Self) -> Self +pub fn Canvas::left_neg_1(Self) -> Self +pub fn Canvas::left_neg_10(Self) -> Self +pub fn Canvas::left_neg_11(Self) -> Self +pub fn Canvas::left_neg_112(Self) -> Self +pub fn Canvas::left_neg_12(Self) -> Self +pub fn Canvas::left_neg_128(Self) -> Self +pub fn Canvas::left_neg_16(Self) -> Self +pub fn Canvas::left_neg_1_12(Self) -> Self +pub fn Canvas::left_neg_1_2(Self) -> Self +pub fn Canvas::left_neg_1_3(Self) -> Self +pub fn Canvas::left_neg_1_4(Self) -> Self +pub fn Canvas::left_neg_1_5(Self) -> Self +pub fn Canvas::left_neg_1_6(Self) -> Self +pub fn Canvas::left_neg_1p5(Self) -> Self +pub fn Canvas::left_neg_2(Self) -> Self +pub fn Canvas::left_neg_20(Self) -> Self +pub fn Canvas::left_neg_24(Self) -> Self +pub fn Canvas::left_neg_2_3(Self) -> Self +pub fn Canvas::left_neg_2_4(Self) -> Self +pub fn Canvas::left_neg_2_5(Self) -> Self +pub fn Canvas::left_neg_2p5(Self) -> Self +pub fn Canvas::left_neg_3(Self) -> Self +pub fn Canvas::left_neg_32(Self) -> Self +pub fn Canvas::left_neg_3_4(Self) -> Self +pub fn Canvas::left_neg_3_5(Self) -> Self +pub fn Canvas::left_neg_3p5(Self) -> Self +pub fn Canvas::left_neg_4(Self) -> Self +pub fn Canvas::left_neg_40(Self) -> Self +pub fn Canvas::left_neg_48(Self) -> Self +pub fn Canvas::left_neg_4_5(Self) -> Self +pub fn Canvas::left_neg_5(Self) -> Self +pub fn Canvas::left_neg_56(Self) -> Self +pub fn Canvas::left_neg_5_6(Self) -> Self +pub fn Canvas::left_neg_6(Self) -> Self +pub fn Canvas::left_neg_64(Self) -> Self +pub fn Canvas::left_neg_7(Self) -> Self +pub fn Canvas::left_neg_72(Self) -> Self +pub fn Canvas::left_neg_8(Self) -> Self +pub fn Canvas::left_neg_80(Self) -> Self +pub fn Canvas::left_neg_9(Self) -> Self +pub fn Canvas::left_neg_96(Self) -> Self +pub fn Canvas::left_neg_full(Self) -> Self +pub fn Canvas::left_neg_px(Self) -> Self +pub fn Canvas::left_px(Self) -> Self +pub fn Canvas::line_clamp(Self, Int32) -> Self +pub fn Canvas::line_height(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Canvas::line_through(Self) -> Self +pub fn Canvas::m(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::m_0(Self) -> Self +pub fn Canvas::m_0p5(Self) -> Self +pub fn Canvas::m_1(Self) -> Self +pub fn Canvas::m_10(Self) -> Self +pub fn Canvas::m_11(Self) -> Self +pub fn Canvas::m_112(Self) -> Self +pub fn Canvas::m_12(Self) -> Self +pub fn Canvas::m_128(Self) -> Self +pub fn Canvas::m_16(Self) -> Self +pub fn Canvas::m_1_12(Self) -> Self +pub fn Canvas::m_1_2(Self) -> Self +pub fn Canvas::m_1_3(Self) -> Self +pub fn Canvas::m_1_4(Self) -> Self +pub fn Canvas::m_1_5(Self) -> Self +pub fn Canvas::m_1_6(Self) -> Self +pub fn Canvas::m_1p5(Self) -> Self +pub fn Canvas::m_2(Self) -> Self +pub fn Canvas::m_20(Self) -> Self +pub fn Canvas::m_24(Self) -> Self +pub fn Canvas::m_2_3(Self) -> Self +pub fn Canvas::m_2_4(Self) -> Self +pub fn Canvas::m_2_5(Self) -> Self +pub fn Canvas::m_2p5(Self) -> Self +pub fn Canvas::m_3(Self) -> Self +pub fn Canvas::m_32(Self) -> Self +pub fn Canvas::m_3_4(Self) -> Self +pub fn Canvas::m_3_5(Self) -> Self +pub fn Canvas::m_3p5(Self) -> Self +pub fn Canvas::m_4(Self) -> Self +pub fn Canvas::m_40(Self) -> Self +pub fn Canvas::m_48(Self) -> Self +pub fn Canvas::m_4_5(Self) -> Self +pub fn Canvas::m_5(Self) -> Self +pub fn Canvas::m_56(Self) -> Self +pub fn Canvas::m_5_6(Self) -> Self +pub fn Canvas::m_6(Self) -> Self +pub fn Canvas::m_64(Self) -> Self +pub fn Canvas::m_7(Self) -> Self +pub fn Canvas::m_72(Self) -> Self +pub fn Canvas::m_8(Self) -> Self +pub fn Canvas::m_80(Self) -> Self +pub fn Canvas::m_9(Self) -> Self +pub fn Canvas::m_96(Self) -> Self +pub fn Canvas::m_auto(Self) -> Self +pub fn Canvas::m_full(Self) -> Self +pub fn Canvas::m_neg_0(Self) -> Self +pub fn Canvas::m_neg_0p5(Self) -> Self +pub fn Canvas::m_neg_1(Self) -> Self +pub fn Canvas::m_neg_10(Self) -> Self +pub fn Canvas::m_neg_11(Self) -> Self +pub fn Canvas::m_neg_112(Self) -> Self +pub fn Canvas::m_neg_12(Self) -> Self +pub fn Canvas::m_neg_128(Self) -> Self +pub fn Canvas::m_neg_16(Self) -> Self +pub fn Canvas::m_neg_1_12(Self) -> Self +pub fn Canvas::m_neg_1_2(Self) -> Self +pub fn Canvas::m_neg_1_3(Self) -> Self +pub fn Canvas::m_neg_1_4(Self) -> Self +pub fn Canvas::m_neg_1_5(Self) -> Self +pub fn Canvas::m_neg_1_6(Self) -> Self +pub fn Canvas::m_neg_1p5(Self) -> Self +pub fn Canvas::m_neg_2(Self) -> Self +pub fn Canvas::m_neg_20(Self) -> Self +pub fn Canvas::m_neg_24(Self) -> Self +pub fn Canvas::m_neg_2_3(Self) -> Self +pub fn Canvas::m_neg_2_4(Self) -> Self +pub fn Canvas::m_neg_2_5(Self) -> Self +pub fn Canvas::m_neg_2p5(Self) -> Self +pub fn Canvas::m_neg_3(Self) -> Self +pub fn Canvas::m_neg_32(Self) -> Self +pub fn Canvas::m_neg_3_4(Self) -> Self +pub fn Canvas::m_neg_3_5(Self) -> Self +pub fn Canvas::m_neg_3p5(Self) -> Self +pub fn Canvas::m_neg_4(Self) -> Self +pub fn Canvas::m_neg_40(Self) -> Self +pub fn Canvas::m_neg_48(Self) -> Self +pub fn Canvas::m_neg_4_5(Self) -> Self +pub fn Canvas::m_neg_5(Self) -> Self +pub fn Canvas::m_neg_56(Self) -> Self +pub fn Canvas::m_neg_5_6(Self) -> Self +pub fn Canvas::m_neg_6(Self) -> Self +pub fn Canvas::m_neg_64(Self) -> Self +pub fn Canvas::m_neg_7(Self) -> Self +pub fn Canvas::m_neg_72(Self) -> Self +pub fn Canvas::m_neg_8(Self) -> Self +pub fn Canvas::m_neg_80(Self) -> Self +pub fn Canvas::m_neg_9(Self) -> Self +pub fn Canvas::m_neg_96(Self) -> Self +pub fn Canvas::m_neg_full(Self) -> Self +pub fn Canvas::m_neg_px(Self) -> Self +pub fn Canvas::m_px(Self) -> Self +pub fn Canvas::max_h(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::max_h_0(Self) -> Self +pub fn Canvas::max_h_0p5(Self) -> Self +pub fn Canvas::max_h_1(Self) -> Self +pub fn Canvas::max_h_10(Self) -> Self +pub fn Canvas::max_h_11(Self) -> Self +pub fn Canvas::max_h_112(Self) -> Self +pub fn Canvas::max_h_12(Self) -> Self +pub fn Canvas::max_h_128(Self) -> Self +pub fn Canvas::max_h_16(Self) -> Self +pub fn Canvas::max_h_1_12(Self) -> Self +pub fn Canvas::max_h_1_2(Self) -> Self +pub fn Canvas::max_h_1_3(Self) -> Self +pub fn Canvas::max_h_1_4(Self) -> Self +pub fn Canvas::max_h_1_5(Self) -> Self +pub fn Canvas::max_h_1_6(Self) -> Self +pub fn Canvas::max_h_1p5(Self) -> Self +pub fn Canvas::max_h_2(Self) -> Self +pub fn Canvas::max_h_20(Self) -> Self +pub fn Canvas::max_h_24(Self) -> Self +pub fn Canvas::max_h_2_3(Self) -> Self +pub fn Canvas::max_h_2_4(Self) -> Self +pub fn Canvas::max_h_2_5(Self) -> Self +pub fn Canvas::max_h_2p5(Self) -> Self +pub fn Canvas::max_h_3(Self) -> Self +pub fn Canvas::max_h_32(Self) -> Self +pub fn Canvas::max_h_3_4(Self) -> Self +pub fn Canvas::max_h_3_5(Self) -> Self +pub fn Canvas::max_h_3p5(Self) -> Self +pub fn Canvas::max_h_4(Self) -> Self +pub fn Canvas::max_h_40(Self) -> Self +pub fn Canvas::max_h_48(Self) -> Self +pub fn Canvas::max_h_4_5(Self) -> Self +pub fn Canvas::max_h_5(Self) -> Self +pub fn Canvas::max_h_56(Self) -> Self +pub fn Canvas::max_h_5_6(Self) -> Self +pub fn Canvas::max_h_6(Self) -> Self +pub fn Canvas::max_h_64(Self) -> Self +pub fn Canvas::max_h_7(Self) -> Self +pub fn Canvas::max_h_72(Self) -> Self +pub fn Canvas::max_h_8(Self) -> Self +pub fn Canvas::max_h_80(Self) -> Self +pub fn Canvas::max_h_9(Self) -> Self +pub fn Canvas::max_h_96(Self) -> Self +pub fn Canvas::max_h_auto(Self) -> Self +pub fn Canvas::max_h_full(Self) -> Self +pub fn Canvas::max_h_neg_0(Self) -> Self +pub fn Canvas::max_h_neg_0p5(Self) -> Self +pub fn Canvas::max_h_neg_1(Self) -> Self +pub fn Canvas::max_h_neg_10(Self) -> Self +pub fn Canvas::max_h_neg_11(Self) -> Self +pub fn Canvas::max_h_neg_112(Self) -> Self +pub fn Canvas::max_h_neg_12(Self) -> Self +pub fn Canvas::max_h_neg_128(Self) -> Self +pub fn Canvas::max_h_neg_16(Self) -> Self +pub fn Canvas::max_h_neg_1_12(Self) -> Self +pub fn Canvas::max_h_neg_1_2(Self) -> Self +pub fn Canvas::max_h_neg_1_3(Self) -> Self +pub fn Canvas::max_h_neg_1_4(Self) -> Self +pub fn Canvas::max_h_neg_1_5(Self) -> Self +pub fn Canvas::max_h_neg_1_6(Self) -> Self +pub fn Canvas::max_h_neg_1p5(Self) -> Self +pub fn Canvas::max_h_neg_2(Self) -> Self +pub fn Canvas::max_h_neg_20(Self) -> Self +pub fn Canvas::max_h_neg_24(Self) -> Self +pub fn Canvas::max_h_neg_2_3(Self) -> Self +pub fn Canvas::max_h_neg_2_4(Self) -> Self +pub fn Canvas::max_h_neg_2_5(Self) -> Self +pub fn Canvas::max_h_neg_2p5(Self) -> Self +pub fn Canvas::max_h_neg_3(Self) -> Self +pub fn Canvas::max_h_neg_32(Self) -> Self +pub fn Canvas::max_h_neg_3_4(Self) -> Self +pub fn Canvas::max_h_neg_3_5(Self) -> Self +pub fn Canvas::max_h_neg_3p5(Self) -> Self +pub fn Canvas::max_h_neg_4(Self) -> Self +pub fn Canvas::max_h_neg_40(Self) -> Self +pub fn Canvas::max_h_neg_48(Self) -> Self +pub fn Canvas::max_h_neg_4_5(Self) -> Self +pub fn Canvas::max_h_neg_5(Self) -> Self +pub fn Canvas::max_h_neg_56(Self) -> Self +pub fn Canvas::max_h_neg_5_6(Self) -> Self +pub fn Canvas::max_h_neg_6(Self) -> Self +pub fn Canvas::max_h_neg_64(Self) -> Self +pub fn Canvas::max_h_neg_7(Self) -> Self +pub fn Canvas::max_h_neg_72(Self) -> Self +pub fn Canvas::max_h_neg_8(Self) -> Self +pub fn Canvas::max_h_neg_80(Self) -> Self +pub fn Canvas::max_h_neg_9(Self) -> Self +pub fn Canvas::max_h_neg_96(Self) -> Self +pub fn Canvas::max_h_neg_full(Self) -> Self +pub fn Canvas::max_h_neg_px(Self) -> Self +pub fn Canvas::max_h_px(Self) -> Self +pub fn Canvas::max_size(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::max_size_0(Self) -> Self +pub fn Canvas::max_size_0p5(Self) -> Self +pub fn Canvas::max_size_1(Self) -> Self +pub fn Canvas::max_size_10(Self) -> Self +pub fn Canvas::max_size_11(Self) -> Self +pub fn Canvas::max_size_112(Self) -> Self +pub fn Canvas::max_size_12(Self) -> Self +pub fn Canvas::max_size_128(Self) -> Self +pub fn Canvas::max_size_16(Self) -> Self +pub fn Canvas::max_size_1_12(Self) -> Self +pub fn Canvas::max_size_1_2(Self) -> Self +pub fn Canvas::max_size_1_3(Self) -> Self +pub fn Canvas::max_size_1_4(Self) -> Self +pub fn Canvas::max_size_1_5(Self) -> Self +pub fn Canvas::max_size_1_6(Self) -> Self +pub fn Canvas::max_size_1p5(Self) -> Self +pub fn Canvas::max_size_2(Self) -> Self +pub fn Canvas::max_size_20(Self) -> Self +pub fn Canvas::max_size_24(Self) -> Self +pub fn Canvas::max_size_2_3(Self) -> Self +pub fn Canvas::max_size_2_4(Self) -> Self +pub fn Canvas::max_size_2_5(Self) -> Self +pub fn Canvas::max_size_2p5(Self) -> Self +pub fn Canvas::max_size_3(Self) -> Self +pub fn Canvas::max_size_32(Self) -> Self +pub fn Canvas::max_size_3_4(Self) -> Self +pub fn Canvas::max_size_3_5(Self) -> Self +pub fn Canvas::max_size_3p5(Self) -> Self +pub fn Canvas::max_size_4(Self) -> Self +pub fn Canvas::max_size_40(Self) -> Self +pub fn Canvas::max_size_48(Self) -> Self +pub fn Canvas::max_size_4_5(Self) -> Self +pub fn Canvas::max_size_5(Self) -> Self +pub fn Canvas::max_size_56(Self) -> Self +pub fn Canvas::max_size_5_6(Self) -> Self +pub fn Canvas::max_size_6(Self) -> Self +pub fn Canvas::max_size_64(Self) -> Self +pub fn Canvas::max_size_7(Self) -> Self +pub fn Canvas::max_size_72(Self) -> Self +pub fn Canvas::max_size_8(Self) -> Self +pub fn Canvas::max_size_80(Self) -> Self +pub fn Canvas::max_size_9(Self) -> Self +pub fn Canvas::max_size_96(Self) -> Self +pub fn Canvas::max_size_auto(Self) -> Self +pub fn Canvas::max_size_full(Self) -> Self +pub fn Canvas::max_size_neg_0(Self) -> Self +pub fn Canvas::max_size_neg_0p5(Self) -> Self +pub fn Canvas::max_size_neg_1(Self) -> Self +pub fn Canvas::max_size_neg_10(Self) -> Self +pub fn Canvas::max_size_neg_11(Self) -> Self +pub fn Canvas::max_size_neg_112(Self) -> Self +pub fn Canvas::max_size_neg_12(Self) -> Self +pub fn Canvas::max_size_neg_128(Self) -> Self +pub fn Canvas::max_size_neg_16(Self) -> Self +pub fn Canvas::max_size_neg_1_12(Self) -> Self +pub fn Canvas::max_size_neg_1_2(Self) -> Self +pub fn Canvas::max_size_neg_1_3(Self) -> Self +pub fn Canvas::max_size_neg_1_4(Self) -> Self +pub fn Canvas::max_size_neg_1_5(Self) -> Self +pub fn Canvas::max_size_neg_1_6(Self) -> Self +pub fn Canvas::max_size_neg_1p5(Self) -> Self +pub fn Canvas::max_size_neg_2(Self) -> Self +pub fn Canvas::max_size_neg_20(Self) -> Self +pub fn Canvas::max_size_neg_24(Self) -> Self +pub fn Canvas::max_size_neg_2_3(Self) -> Self +pub fn Canvas::max_size_neg_2_4(Self) -> Self +pub fn Canvas::max_size_neg_2_5(Self) -> Self +pub fn Canvas::max_size_neg_2p5(Self) -> Self +pub fn Canvas::max_size_neg_3(Self) -> Self +pub fn Canvas::max_size_neg_32(Self) -> Self +pub fn Canvas::max_size_neg_3_4(Self) -> Self +pub fn Canvas::max_size_neg_3_5(Self) -> Self +pub fn Canvas::max_size_neg_3p5(Self) -> Self +pub fn Canvas::max_size_neg_4(Self) -> Self +pub fn Canvas::max_size_neg_40(Self) -> Self +pub fn Canvas::max_size_neg_48(Self) -> Self +pub fn Canvas::max_size_neg_4_5(Self) -> Self +pub fn Canvas::max_size_neg_5(Self) -> Self +pub fn Canvas::max_size_neg_56(Self) -> Self +pub fn Canvas::max_size_neg_5_6(Self) -> Self +pub fn Canvas::max_size_neg_6(Self) -> Self +pub fn Canvas::max_size_neg_64(Self) -> Self +pub fn Canvas::max_size_neg_7(Self) -> Self +pub fn Canvas::max_size_neg_72(Self) -> Self +pub fn Canvas::max_size_neg_8(Self) -> Self +pub fn Canvas::max_size_neg_80(Self) -> Self +pub fn Canvas::max_size_neg_9(Self) -> Self +pub fn Canvas::max_size_neg_96(Self) -> Self +pub fn Canvas::max_size_neg_full(Self) -> Self +pub fn Canvas::max_size_neg_px(Self) -> Self +pub fn Canvas::max_size_px(Self) -> Self +pub fn Canvas::max_w(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::max_w_0(Self) -> Self +pub fn Canvas::max_w_0p5(Self) -> Self +pub fn Canvas::max_w_1(Self) -> Self +pub fn Canvas::max_w_10(Self) -> Self +pub fn Canvas::max_w_11(Self) -> Self +pub fn Canvas::max_w_112(Self) -> Self +pub fn Canvas::max_w_12(Self) -> Self +pub fn Canvas::max_w_128(Self) -> Self +pub fn Canvas::max_w_16(Self) -> Self +pub fn Canvas::max_w_1_12(Self) -> Self +pub fn Canvas::max_w_1_2(Self) -> Self +pub fn Canvas::max_w_1_3(Self) -> Self +pub fn Canvas::max_w_1_4(Self) -> Self +pub fn Canvas::max_w_1_5(Self) -> Self +pub fn Canvas::max_w_1_6(Self) -> Self +pub fn Canvas::max_w_1p5(Self) -> Self +pub fn Canvas::max_w_2(Self) -> Self +pub fn Canvas::max_w_20(Self) -> Self +pub fn Canvas::max_w_24(Self) -> Self +pub fn Canvas::max_w_2_3(Self) -> Self +pub fn Canvas::max_w_2_4(Self) -> Self +pub fn Canvas::max_w_2_5(Self) -> Self +pub fn Canvas::max_w_2p5(Self) -> Self +pub fn Canvas::max_w_3(Self) -> Self +pub fn Canvas::max_w_32(Self) -> Self +pub fn Canvas::max_w_3_4(Self) -> Self +pub fn Canvas::max_w_3_5(Self) -> Self +pub fn Canvas::max_w_3p5(Self) -> Self +pub fn Canvas::max_w_4(Self) -> Self +pub fn Canvas::max_w_40(Self) -> Self +pub fn Canvas::max_w_48(Self) -> Self +pub fn Canvas::max_w_4_5(Self) -> Self +pub fn Canvas::max_w_5(Self) -> Self +pub fn Canvas::max_w_56(Self) -> Self +pub fn Canvas::max_w_5_6(Self) -> Self +pub fn Canvas::max_w_6(Self) -> Self +pub fn Canvas::max_w_64(Self) -> Self +pub fn Canvas::max_w_7(Self) -> Self +pub fn Canvas::max_w_72(Self) -> Self +pub fn Canvas::max_w_8(Self) -> Self +pub fn Canvas::max_w_80(Self) -> Self +pub fn Canvas::max_w_9(Self) -> Self +pub fn Canvas::max_w_96(Self) -> Self +pub fn Canvas::max_w_auto(Self) -> Self +pub fn Canvas::max_w_full(Self) -> Self +pub fn Canvas::max_w_neg_0(Self) -> Self +pub fn Canvas::max_w_neg_0p5(Self) -> Self +pub fn Canvas::max_w_neg_1(Self) -> Self +pub fn Canvas::max_w_neg_10(Self) -> Self +pub fn Canvas::max_w_neg_11(Self) -> Self +pub fn Canvas::max_w_neg_112(Self) -> Self +pub fn Canvas::max_w_neg_12(Self) -> Self +pub fn Canvas::max_w_neg_128(Self) -> Self +pub fn Canvas::max_w_neg_16(Self) -> Self +pub fn Canvas::max_w_neg_1_12(Self) -> Self +pub fn Canvas::max_w_neg_1_2(Self) -> Self +pub fn Canvas::max_w_neg_1_3(Self) -> Self +pub fn Canvas::max_w_neg_1_4(Self) -> Self +pub fn Canvas::max_w_neg_1_5(Self) -> Self +pub fn Canvas::max_w_neg_1_6(Self) -> Self +pub fn Canvas::max_w_neg_1p5(Self) -> Self +pub fn Canvas::max_w_neg_2(Self) -> Self +pub fn Canvas::max_w_neg_20(Self) -> Self +pub fn Canvas::max_w_neg_24(Self) -> Self +pub fn Canvas::max_w_neg_2_3(Self) -> Self +pub fn Canvas::max_w_neg_2_4(Self) -> Self +pub fn Canvas::max_w_neg_2_5(Self) -> Self +pub fn Canvas::max_w_neg_2p5(Self) -> Self +pub fn Canvas::max_w_neg_3(Self) -> Self +pub fn Canvas::max_w_neg_32(Self) -> Self +pub fn Canvas::max_w_neg_3_4(Self) -> Self +pub fn Canvas::max_w_neg_3_5(Self) -> Self +pub fn Canvas::max_w_neg_3p5(Self) -> Self +pub fn Canvas::max_w_neg_4(Self) -> Self +pub fn Canvas::max_w_neg_40(Self) -> Self +pub fn Canvas::max_w_neg_48(Self) -> Self +pub fn Canvas::max_w_neg_4_5(Self) -> Self +pub fn Canvas::max_w_neg_5(Self) -> Self +pub fn Canvas::max_w_neg_56(Self) -> Self +pub fn Canvas::max_w_neg_5_6(Self) -> Self +pub fn Canvas::max_w_neg_6(Self) -> Self +pub fn Canvas::max_w_neg_64(Self) -> Self +pub fn Canvas::max_w_neg_7(Self) -> Self +pub fn Canvas::max_w_neg_72(Self) -> Self +pub fn Canvas::max_w_neg_8(Self) -> Self +pub fn Canvas::max_w_neg_80(Self) -> Self +pub fn Canvas::max_w_neg_9(Self) -> Self +pub fn Canvas::max_w_neg_96(Self) -> Self +pub fn Canvas::max_w_neg_full(Self) -> Self +pub fn Canvas::max_w_neg_px(Self) -> Self +pub fn Canvas::max_w_px(Self) -> Self +pub fn Canvas::mb(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::mb_0(Self) -> Self +pub fn Canvas::mb_0p5(Self) -> Self +pub fn Canvas::mb_1(Self) -> Self +pub fn Canvas::mb_10(Self) -> Self +pub fn Canvas::mb_11(Self) -> Self +pub fn Canvas::mb_112(Self) -> Self +pub fn Canvas::mb_12(Self) -> Self +pub fn Canvas::mb_128(Self) -> Self +pub fn Canvas::mb_16(Self) -> Self +pub fn Canvas::mb_1_12(Self) -> Self +pub fn Canvas::mb_1_2(Self) -> Self +pub fn Canvas::mb_1_3(Self) -> Self +pub fn Canvas::mb_1_4(Self) -> Self +pub fn Canvas::mb_1_5(Self) -> Self +pub fn Canvas::mb_1_6(Self) -> Self +pub fn Canvas::mb_1p5(Self) -> Self +pub fn Canvas::mb_2(Self) -> Self +pub fn Canvas::mb_20(Self) -> Self +pub fn Canvas::mb_24(Self) -> Self +pub fn Canvas::mb_2_3(Self) -> Self +pub fn Canvas::mb_2_4(Self) -> Self +pub fn Canvas::mb_2_5(Self) -> Self +pub fn Canvas::mb_2p5(Self) -> Self +pub fn Canvas::mb_3(Self) -> Self +pub fn Canvas::mb_32(Self) -> Self +pub fn Canvas::mb_3_4(Self) -> Self +pub fn Canvas::mb_3_5(Self) -> Self +pub fn Canvas::mb_3p5(Self) -> Self +pub fn Canvas::mb_4(Self) -> Self +pub fn Canvas::mb_40(Self) -> Self +pub fn Canvas::mb_48(Self) -> Self +pub fn Canvas::mb_4_5(Self) -> Self +pub fn Canvas::mb_5(Self) -> Self +pub fn Canvas::mb_56(Self) -> Self +pub fn Canvas::mb_5_6(Self) -> Self +pub fn Canvas::mb_6(Self) -> Self +pub fn Canvas::mb_64(Self) -> Self +pub fn Canvas::mb_7(Self) -> Self +pub fn Canvas::mb_72(Self) -> Self +pub fn Canvas::mb_8(Self) -> Self +pub fn Canvas::mb_80(Self) -> Self +pub fn Canvas::mb_9(Self) -> Self +pub fn Canvas::mb_96(Self) -> Self +pub fn Canvas::mb_auto(Self) -> Self +pub fn Canvas::mb_full(Self) -> Self +pub fn Canvas::mb_neg_0(Self) -> Self +pub fn Canvas::mb_neg_0p5(Self) -> Self +pub fn Canvas::mb_neg_1(Self) -> Self +pub fn Canvas::mb_neg_10(Self) -> Self +pub fn Canvas::mb_neg_11(Self) -> Self +pub fn Canvas::mb_neg_112(Self) -> Self +pub fn Canvas::mb_neg_12(Self) -> Self +pub fn Canvas::mb_neg_128(Self) -> Self +pub fn Canvas::mb_neg_16(Self) -> Self +pub fn Canvas::mb_neg_1_12(Self) -> Self +pub fn Canvas::mb_neg_1_2(Self) -> Self +pub fn Canvas::mb_neg_1_3(Self) -> Self +pub fn Canvas::mb_neg_1_4(Self) -> Self +pub fn Canvas::mb_neg_1_5(Self) -> Self +pub fn Canvas::mb_neg_1_6(Self) -> Self +pub fn Canvas::mb_neg_1p5(Self) -> Self +pub fn Canvas::mb_neg_2(Self) -> Self +pub fn Canvas::mb_neg_20(Self) -> Self +pub fn Canvas::mb_neg_24(Self) -> Self +pub fn Canvas::mb_neg_2_3(Self) -> Self +pub fn Canvas::mb_neg_2_4(Self) -> Self +pub fn Canvas::mb_neg_2_5(Self) -> Self +pub fn Canvas::mb_neg_2p5(Self) -> Self +pub fn Canvas::mb_neg_3(Self) -> Self +pub fn Canvas::mb_neg_32(Self) -> Self +pub fn Canvas::mb_neg_3_4(Self) -> Self +pub fn Canvas::mb_neg_3_5(Self) -> Self +pub fn Canvas::mb_neg_3p5(Self) -> Self +pub fn Canvas::mb_neg_4(Self) -> Self +pub fn Canvas::mb_neg_40(Self) -> Self +pub fn Canvas::mb_neg_48(Self) -> Self +pub fn Canvas::mb_neg_4_5(Self) -> Self +pub fn Canvas::mb_neg_5(Self) -> Self +pub fn Canvas::mb_neg_56(Self) -> Self +pub fn Canvas::mb_neg_5_6(Self) -> Self +pub fn Canvas::mb_neg_6(Self) -> Self +pub fn Canvas::mb_neg_64(Self) -> Self +pub fn Canvas::mb_neg_7(Self) -> Self +pub fn Canvas::mb_neg_72(Self) -> Self +pub fn Canvas::mb_neg_8(Self) -> Self +pub fn Canvas::mb_neg_80(Self) -> Self +pub fn Canvas::mb_neg_9(Self) -> Self +pub fn Canvas::mb_neg_96(Self) -> Self +pub fn Canvas::mb_neg_full(Self) -> Self +pub fn Canvas::mb_neg_px(Self) -> Self +pub fn Canvas::mb_px(Self) -> Self +pub fn Canvas::min_h(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::min_h_0(Self) -> Self +pub fn Canvas::min_h_0p5(Self) -> Self +pub fn Canvas::min_h_1(Self) -> Self +pub fn Canvas::min_h_10(Self) -> Self +pub fn Canvas::min_h_11(Self) -> Self +pub fn Canvas::min_h_112(Self) -> Self +pub fn Canvas::min_h_12(Self) -> Self +pub fn Canvas::min_h_128(Self) -> Self +pub fn Canvas::min_h_16(Self) -> Self +pub fn Canvas::min_h_1_12(Self) -> Self +pub fn Canvas::min_h_1_2(Self) -> Self +pub fn Canvas::min_h_1_3(Self) -> Self +pub fn Canvas::min_h_1_4(Self) -> Self +pub fn Canvas::min_h_1_5(Self) -> Self +pub fn Canvas::min_h_1_6(Self) -> Self +pub fn Canvas::min_h_1p5(Self) -> Self +pub fn Canvas::min_h_2(Self) -> Self +pub fn Canvas::min_h_20(Self) -> Self +pub fn Canvas::min_h_24(Self) -> Self +pub fn Canvas::min_h_2_3(Self) -> Self +pub fn Canvas::min_h_2_4(Self) -> Self +pub fn Canvas::min_h_2_5(Self) -> Self +pub fn Canvas::min_h_2p5(Self) -> Self +pub fn Canvas::min_h_3(Self) -> Self +pub fn Canvas::min_h_32(Self) -> Self +pub fn Canvas::min_h_3_4(Self) -> Self +pub fn Canvas::min_h_3_5(Self) -> Self +pub fn Canvas::min_h_3p5(Self) -> Self +pub fn Canvas::min_h_4(Self) -> Self +pub fn Canvas::min_h_40(Self) -> Self +pub fn Canvas::min_h_48(Self) -> Self +pub fn Canvas::min_h_4_5(Self) -> Self +pub fn Canvas::min_h_5(Self) -> Self +pub fn Canvas::min_h_56(Self) -> Self +pub fn Canvas::min_h_5_6(Self) -> Self +pub fn Canvas::min_h_6(Self) -> Self +pub fn Canvas::min_h_64(Self) -> Self +pub fn Canvas::min_h_7(Self) -> Self +pub fn Canvas::min_h_72(Self) -> Self +pub fn Canvas::min_h_8(Self) -> Self +pub fn Canvas::min_h_80(Self) -> Self +pub fn Canvas::min_h_9(Self) -> Self +pub fn Canvas::min_h_96(Self) -> Self +pub fn Canvas::min_h_auto(Self) -> Self +pub fn Canvas::min_h_full(Self) -> Self +pub fn Canvas::min_h_neg_0(Self) -> Self +pub fn Canvas::min_h_neg_0p5(Self) -> Self +pub fn Canvas::min_h_neg_1(Self) -> Self +pub fn Canvas::min_h_neg_10(Self) -> Self +pub fn Canvas::min_h_neg_11(Self) -> Self +pub fn Canvas::min_h_neg_112(Self) -> Self +pub fn Canvas::min_h_neg_12(Self) -> Self +pub fn Canvas::min_h_neg_128(Self) -> Self +pub fn Canvas::min_h_neg_16(Self) -> Self +pub fn Canvas::min_h_neg_1_12(Self) -> Self +pub fn Canvas::min_h_neg_1_2(Self) -> Self +pub fn Canvas::min_h_neg_1_3(Self) -> Self +pub fn Canvas::min_h_neg_1_4(Self) -> Self +pub fn Canvas::min_h_neg_1_5(Self) -> Self +pub fn Canvas::min_h_neg_1_6(Self) -> Self +pub fn Canvas::min_h_neg_1p5(Self) -> Self +pub fn Canvas::min_h_neg_2(Self) -> Self +pub fn Canvas::min_h_neg_20(Self) -> Self +pub fn Canvas::min_h_neg_24(Self) -> Self +pub fn Canvas::min_h_neg_2_3(Self) -> Self +pub fn Canvas::min_h_neg_2_4(Self) -> Self +pub fn Canvas::min_h_neg_2_5(Self) -> Self +pub fn Canvas::min_h_neg_2p5(Self) -> Self +pub fn Canvas::min_h_neg_3(Self) -> Self +pub fn Canvas::min_h_neg_32(Self) -> Self +pub fn Canvas::min_h_neg_3_4(Self) -> Self +pub fn Canvas::min_h_neg_3_5(Self) -> Self +pub fn Canvas::min_h_neg_3p5(Self) -> Self +pub fn Canvas::min_h_neg_4(Self) -> Self +pub fn Canvas::min_h_neg_40(Self) -> Self +pub fn Canvas::min_h_neg_48(Self) -> Self +pub fn Canvas::min_h_neg_4_5(Self) -> Self +pub fn Canvas::min_h_neg_5(Self) -> Self +pub fn Canvas::min_h_neg_56(Self) -> Self +pub fn Canvas::min_h_neg_5_6(Self) -> Self +pub fn Canvas::min_h_neg_6(Self) -> Self +pub fn Canvas::min_h_neg_64(Self) -> Self +pub fn Canvas::min_h_neg_7(Self) -> Self +pub fn Canvas::min_h_neg_72(Self) -> Self +pub fn Canvas::min_h_neg_8(Self) -> Self +pub fn Canvas::min_h_neg_80(Self) -> Self +pub fn Canvas::min_h_neg_9(Self) -> Self +pub fn Canvas::min_h_neg_96(Self) -> Self +pub fn Canvas::min_h_neg_full(Self) -> Self +pub fn Canvas::min_h_neg_px(Self) -> Self +pub fn Canvas::min_h_px(Self) -> Self +pub fn Canvas::min_size(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::min_size_0(Self) -> Self +pub fn Canvas::min_size_0p5(Self) -> Self +pub fn Canvas::min_size_1(Self) -> Self +pub fn Canvas::min_size_10(Self) -> Self +pub fn Canvas::min_size_11(Self) -> Self +pub fn Canvas::min_size_112(Self) -> Self +pub fn Canvas::min_size_12(Self) -> Self +pub fn Canvas::min_size_128(Self) -> Self +pub fn Canvas::min_size_16(Self) -> Self +pub fn Canvas::min_size_1_12(Self) -> Self +pub fn Canvas::min_size_1_2(Self) -> Self +pub fn Canvas::min_size_1_3(Self) -> Self +pub fn Canvas::min_size_1_4(Self) -> Self +pub fn Canvas::min_size_1_5(Self) -> Self +pub fn Canvas::min_size_1_6(Self) -> Self +pub fn Canvas::min_size_1p5(Self) -> Self +pub fn Canvas::min_size_2(Self) -> Self +pub fn Canvas::min_size_20(Self) -> Self +pub fn Canvas::min_size_24(Self) -> Self +pub fn Canvas::min_size_2_3(Self) -> Self +pub fn Canvas::min_size_2_4(Self) -> Self +pub fn Canvas::min_size_2_5(Self) -> Self +pub fn Canvas::min_size_2p5(Self) -> Self +pub fn Canvas::min_size_3(Self) -> Self +pub fn Canvas::min_size_32(Self) -> Self +pub fn Canvas::min_size_3_4(Self) -> Self +pub fn Canvas::min_size_3_5(Self) -> Self +pub fn Canvas::min_size_3p5(Self) -> Self +pub fn Canvas::min_size_4(Self) -> Self +pub fn Canvas::min_size_40(Self) -> Self +pub fn Canvas::min_size_48(Self) -> Self +pub fn Canvas::min_size_4_5(Self) -> Self +pub fn Canvas::min_size_5(Self) -> Self +pub fn Canvas::min_size_56(Self) -> Self +pub fn Canvas::min_size_5_6(Self) -> Self +pub fn Canvas::min_size_6(Self) -> Self +pub fn Canvas::min_size_64(Self) -> Self +pub fn Canvas::min_size_7(Self) -> Self +pub fn Canvas::min_size_72(Self) -> Self +pub fn Canvas::min_size_8(Self) -> Self +pub fn Canvas::min_size_80(Self) -> Self +pub fn Canvas::min_size_9(Self) -> Self +pub fn Canvas::min_size_96(Self) -> Self +pub fn Canvas::min_size_auto(Self) -> Self +pub fn Canvas::min_size_full(Self) -> Self +pub fn Canvas::min_size_neg_0(Self) -> Self +pub fn Canvas::min_size_neg_0p5(Self) -> Self +pub fn Canvas::min_size_neg_1(Self) -> Self +pub fn Canvas::min_size_neg_10(Self) -> Self +pub fn Canvas::min_size_neg_11(Self) -> Self +pub fn Canvas::min_size_neg_112(Self) -> Self +pub fn Canvas::min_size_neg_12(Self) -> Self +pub fn Canvas::min_size_neg_128(Self) -> Self +pub fn Canvas::min_size_neg_16(Self) -> Self +pub fn Canvas::min_size_neg_1_12(Self) -> Self +pub fn Canvas::min_size_neg_1_2(Self) -> Self +pub fn Canvas::min_size_neg_1_3(Self) -> Self +pub fn Canvas::min_size_neg_1_4(Self) -> Self +pub fn Canvas::min_size_neg_1_5(Self) -> Self +pub fn Canvas::min_size_neg_1_6(Self) -> Self +pub fn Canvas::min_size_neg_1p5(Self) -> Self +pub fn Canvas::min_size_neg_2(Self) -> Self +pub fn Canvas::min_size_neg_20(Self) -> Self +pub fn Canvas::min_size_neg_24(Self) -> Self +pub fn Canvas::min_size_neg_2_3(Self) -> Self +pub fn Canvas::min_size_neg_2_4(Self) -> Self +pub fn Canvas::min_size_neg_2_5(Self) -> Self +pub fn Canvas::min_size_neg_2p5(Self) -> Self +pub fn Canvas::min_size_neg_3(Self) -> Self +pub fn Canvas::min_size_neg_32(Self) -> Self +pub fn Canvas::min_size_neg_3_4(Self) -> Self +pub fn Canvas::min_size_neg_3_5(Self) -> Self +pub fn Canvas::min_size_neg_3p5(Self) -> Self +pub fn Canvas::min_size_neg_4(Self) -> Self +pub fn Canvas::min_size_neg_40(Self) -> Self +pub fn Canvas::min_size_neg_48(Self) -> Self +pub fn Canvas::min_size_neg_4_5(Self) -> Self +pub fn Canvas::min_size_neg_5(Self) -> Self +pub fn Canvas::min_size_neg_56(Self) -> Self +pub fn Canvas::min_size_neg_5_6(Self) -> Self +pub fn Canvas::min_size_neg_6(Self) -> Self +pub fn Canvas::min_size_neg_64(Self) -> Self +pub fn Canvas::min_size_neg_7(Self) -> Self +pub fn Canvas::min_size_neg_72(Self) -> Self +pub fn Canvas::min_size_neg_8(Self) -> Self +pub fn Canvas::min_size_neg_80(Self) -> Self +pub fn Canvas::min_size_neg_9(Self) -> Self +pub fn Canvas::min_size_neg_96(Self) -> Self +pub fn Canvas::min_size_neg_full(Self) -> Self +pub fn Canvas::min_size_neg_px(Self) -> Self +pub fn Canvas::min_size_px(Self) -> Self +pub fn Canvas::min_w(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::min_w_0(Self) -> Self +pub fn Canvas::min_w_0p5(Self) -> Self +pub fn Canvas::min_w_1(Self) -> Self +pub fn Canvas::min_w_10(Self) -> Self +pub fn Canvas::min_w_11(Self) -> Self +pub fn Canvas::min_w_112(Self) -> Self +pub fn Canvas::min_w_12(Self) -> Self +pub fn Canvas::min_w_128(Self) -> Self +pub fn Canvas::min_w_16(Self) -> Self +pub fn Canvas::min_w_1_12(Self) -> Self +pub fn Canvas::min_w_1_2(Self) -> Self +pub fn Canvas::min_w_1_3(Self) -> Self +pub fn Canvas::min_w_1_4(Self) -> Self +pub fn Canvas::min_w_1_5(Self) -> Self +pub fn Canvas::min_w_1_6(Self) -> Self +pub fn Canvas::min_w_1p5(Self) -> Self +pub fn Canvas::min_w_2(Self) -> Self +pub fn Canvas::min_w_20(Self) -> Self +pub fn Canvas::min_w_24(Self) -> Self +pub fn Canvas::min_w_2_3(Self) -> Self +pub fn Canvas::min_w_2_4(Self) -> Self +pub fn Canvas::min_w_2_5(Self) -> Self +pub fn Canvas::min_w_2p5(Self) -> Self +pub fn Canvas::min_w_3(Self) -> Self +pub fn Canvas::min_w_32(Self) -> Self +pub fn Canvas::min_w_3_4(Self) -> Self +pub fn Canvas::min_w_3_5(Self) -> Self +pub fn Canvas::min_w_3p5(Self) -> Self +pub fn Canvas::min_w_4(Self) -> Self +pub fn Canvas::min_w_40(Self) -> Self +pub fn Canvas::min_w_48(Self) -> Self +pub fn Canvas::min_w_4_5(Self) -> Self +pub fn Canvas::min_w_5(Self) -> Self +pub fn Canvas::min_w_56(Self) -> Self +pub fn Canvas::min_w_5_6(Self) -> Self +pub fn Canvas::min_w_6(Self) -> Self +pub fn Canvas::min_w_64(Self) -> Self +pub fn Canvas::min_w_7(Self) -> Self +pub fn Canvas::min_w_72(Self) -> Self +pub fn Canvas::min_w_8(Self) -> Self +pub fn Canvas::min_w_80(Self) -> Self +pub fn Canvas::min_w_9(Self) -> Self +pub fn Canvas::min_w_96(Self) -> Self +pub fn Canvas::min_w_auto(Self) -> Self +pub fn Canvas::min_w_full(Self) -> Self +pub fn Canvas::min_w_neg_0(Self) -> Self +pub fn Canvas::min_w_neg_0p5(Self) -> Self +pub fn Canvas::min_w_neg_1(Self) -> Self +pub fn Canvas::min_w_neg_10(Self) -> Self +pub fn Canvas::min_w_neg_11(Self) -> Self +pub fn Canvas::min_w_neg_112(Self) -> Self +pub fn Canvas::min_w_neg_12(Self) -> Self +pub fn Canvas::min_w_neg_128(Self) -> Self +pub fn Canvas::min_w_neg_16(Self) -> Self +pub fn Canvas::min_w_neg_1_12(Self) -> Self +pub fn Canvas::min_w_neg_1_2(Self) -> Self +pub fn Canvas::min_w_neg_1_3(Self) -> Self +pub fn Canvas::min_w_neg_1_4(Self) -> Self +pub fn Canvas::min_w_neg_1_5(Self) -> Self +pub fn Canvas::min_w_neg_1_6(Self) -> Self +pub fn Canvas::min_w_neg_1p5(Self) -> Self +pub fn Canvas::min_w_neg_2(Self) -> Self +pub fn Canvas::min_w_neg_20(Self) -> Self +pub fn Canvas::min_w_neg_24(Self) -> Self +pub fn Canvas::min_w_neg_2_3(Self) -> Self +pub fn Canvas::min_w_neg_2_4(Self) -> Self +pub fn Canvas::min_w_neg_2_5(Self) -> Self +pub fn Canvas::min_w_neg_2p5(Self) -> Self +pub fn Canvas::min_w_neg_3(Self) -> Self +pub fn Canvas::min_w_neg_32(Self) -> Self +pub fn Canvas::min_w_neg_3_4(Self) -> Self +pub fn Canvas::min_w_neg_3_5(Self) -> Self +pub fn Canvas::min_w_neg_3p5(Self) -> Self +pub fn Canvas::min_w_neg_4(Self) -> Self +pub fn Canvas::min_w_neg_40(Self) -> Self +pub fn Canvas::min_w_neg_48(Self) -> Self +pub fn Canvas::min_w_neg_4_5(Self) -> Self +pub fn Canvas::min_w_neg_5(Self) -> Self +pub fn Canvas::min_w_neg_56(Self) -> Self +pub fn Canvas::min_w_neg_5_6(Self) -> Self +pub fn Canvas::min_w_neg_6(Self) -> Self +pub fn Canvas::min_w_neg_64(Self) -> Self +pub fn Canvas::min_w_neg_7(Self) -> Self +pub fn Canvas::min_w_neg_72(Self) -> Self +pub fn Canvas::min_w_neg_8(Self) -> Self +pub fn Canvas::min_w_neg_80(Self) -> Self +pub fn Canvas::min_w_neg_9(Self) -> Self +pub fn Canvas::min_w_neg_96(Self) -> Self +pub fn Canvas::min_w_neg_full(Self) -> Self +pub fn Canvas::min_w_neg_px(Self) -> Self +pub fn Canvas::min_w_px(Self) -> Self +pub fn Canvas::ml(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::ml_0(Self) -> Self +pub fn Canvas::ml_0p5(Self) -> Self +pub fn Canvas::ml_1(Self) -> Self +pub fn Canvas::ml_10(Self) -> Self +pub fn Canvas::ml_11(Self) -> Self +pub fn Canvas::ml_112(Self) -> Self +pub fn Canvas::ml_12(Self) -> Self +pub fn Canvas::ml_128(Self) -> Self +pub fn Canvas::ml_16(Self) -> Self +pub fn Canvas::ml_1_12(Self) -> Self +pub fn Canvas::ml_1_2(Self) -> Self +pub fn Canvas::ml_1_3(Self) -> Self +pub fn Canvas::ml_1_4(Self) -> Self +pub fn Canvas::ml_1_5(Self) -> Self +pub fn Canvas::ml_1_6(Self) -> Self +pub fn Canvas::ml_1p5(Self) -> Self +pub fn Canvas::ml_2(Self) -> Self +pub fn Canvas::ml_20(Self) -> Self +pub fn Canvas::ml_24(Self) -> Self +pub fn Canvas::ml_2_3(Self) -> Self +pub fn Canvas::ml_2_4(Self) -> Self +pub fn Canvas::ml_2_5(Self) -> Self +pub fn Canvas::ml_2p5(Self) -> Self +pub fn Canvas::ml_3(Self) -> Self +pub fn Canvas::ml_32(Self) -> Self +pub fn Canvas::ml_3_4(Self) -> Self +pub fn Canvas::ml_3_5(Self) -> Self +pub fn Canvas::ml_3p5(Self) -> Self +pub fn Canvas::ml_4(Self) -> Self +pub fn Canvas::ml_40(Self) -> Self +pub fn Canvas::ml_48(Self) -> Self +pub fn Canvas::ml_4_5(Self) -> Self +pub fn Canvas::ml_5(Self) -> Self +pub fn Canvas::ml_56(Self) -> Self +pub fn Canvas::ml_5_6(Self) -> Self +pub fn Canvas::ml_6(Self) -> Self +pub fn Canvas::ml_64(Self) -> Self +pub fn Canvas::ml_7(Self) -> Self +pub fn Canvas::ml_72(Self) -> Self +pub fn Canvas::ml_8(Self) -> Self +pub fn Canvas::ml_80(Self) -> Self +pub fn Canvas::ml_9(Self) -> Self +pub fn Canvas::ml_96(Self) -> Self +pub fn Canvas::ml_auto(Self) -> Self +pub fn Canvas::ml_full(Self) -> Self +pub fn Canvas::ml_neg_0(Self) -> Self +pub fn Canvas::ml_neg_0p5(Self) -> Self +pub fn Canvas::ml_neg_1(Self) -> Self +pub fn Canvas::ml_neg_10(Self) -> Self +pub fn Canvas::ml_neg_11(Self) -> Self +pub fn Canvas::ml_neg_112(Self) -> Self +pub fn Canvas::ml_neg_12(Self) -> Self +pub fn Canvas::ml_neg_128(Self) -> Self +pub fn Canvas::ml_neg_16(Self) -> Self +pub fn Canvas::ml_neg_1_12(Self) -> Self +pub fn Canvas::ml_neg_1_2(Self) -> Self +pub fn Canvas::ml_neg_1_3(Self) -> Self +pub fn Canvas::ml_neg_1_4(Self) -> Self +pub fn Canvas::ml_neg_1_5(Self) -> Self +pub fn Canvas::ml_neg_1_6(Self) -> Self +pub fn Canvas::ml_neg_1p5(Self) -> Self +pub fn Canvas::ml_neg_2(Self) -> Self +pub fn Canvas::ml_neg_20(Self) -> Self +pub fn Canvas::ml_neg_24(Self) -> Self +pub fn Canvas::ml_neg_2_3(Self) -> Self +pub fn Canvas::ml_neg_2_4(Self) -> Self +pub fn Canvas::ml_neg_2_5(Self) -> Self +pub fn Canvas::ml_neg_2p5(Self) -> Self +pub fn Canvas::ml_neg_3(Self) -> Self +pub fn Canvas::ml_neg_32(Self) -> Self +pub fn Canvas::ml_neg_3_4(Self) -> Self +pub fn Canvas::ml_neg_3_5(Self) -> Self +pub fn Canvas::ml_neg_3p5(Self) -> Self +pub fn Canvas::ml_neg_4(Self) -> Self +pub fn Canvas::ml_neg_40(Self) -> Self +pub fn Canvas::ml_neg_48(Self) -> Self +pub fn Canvas::ml_neg_4_5(Self) -> Self +pub fn Canvas::ml_neg_5(Self) -> Self +pub fn Canvas::ml_neg_56(Self) -> Self +pub fn Canvas::ml_neg_5_6(Self) -> Self +pub fn Canvas::ml_neg_6(Self) -> Self +pub fn Canvas::ml_neg_64(Self) -> Self +pub fn Canvas::ml_neg_7(Self) -> Self +pub fn Canvas::ml_neg_72(Self) -> Self +pub fn Canvas::ml_neg_8(Self) -> Self +pub fn Canvas::ml_neg_80(Self) -> Self +pub fn Canvas::ml_neg_9(Self) -> Self +pub fn Canvas::ml_neg_96(Self) -> Self +pub fn Canvas::ml_neg_full(Self) -> Self +pub fn Canvas::ml_neg_px(Self) -> Self +pub fn Canvas::ml_px(Self) -> Self +pub fn Canvas::mr(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::mr_0(Self) -> Self +pub fn Canvas::mr_0p5(Self) -> Self +pub fn Canvas::mr_1(Self) -> Self +pub fn Canvas::mr_10(Self) -> Self +pub fn Canvas::mr_11(Self) -> Self +pub fn Canvas::mr_112(Self) -> Self +pub fn Canvas::mr_12(Self) -> Self +pub fn Canvas::mr_128(Self) -> Self +pub fn Canvas::mr_16(Self) -> Self +pub fn Canvas::mr_1_12(Self) -> Self +pub fn Canvas::mr_1_2(Self) -> Self +pub fn Canvas::mr_1_3(Self) -> Self +pub fn Canvas::mr_1_4(Self) -> Self +pub fn Canvas::mr_1_5(Self) -> Self +pub fn Canvas::mr_1_6(Self) -> Self +pub fn Canvas::mr_1p5(Self) -> Self +pub fn Canvas::mr_2(Self) -> Self +pub fn Canvas::mr_20(Self) -> Self +pub fn Canvas::mr_24(Self) -> Self +pub fn Canvas::mr_2_3(Self) -> Self +pub fn Canvas::mr_2_4(Self) -> Self +pub fn Canvas::mr_2_5(Self) -> Self +pub fn Canvas::mr_2p5(Self) -> Self +pub fn Canvas::mr_3(Self) -> Self +pub fn Canvas::mr_32(Self) -> Self +pub fn Canvas::mr_3_4(Self) -> Self +pub fn Canvas::mr_3_5(Self) -> Self +pub fn Canvas::mr_3p5(Self) -> Self +pub fn Canvas::mr_4(Self) -> Self +pub fn Canvas::mr_40(Self) -> Self +pub fn Canvas::mr_48(Self) -> Self +pub fn Canvas::mr_4_5(Self) -> Self +pub fn Canvas::mr_5(Self) -> Self +pub fn Canvas::mr_56(Self) -> Self +pub fn Canvas::mr_5_6(Self) -> Self +pub fn Canvas::mr_6(Self) -> Self +pub fn Canvas::mr_64(Self) -> Self +pub fn Canvas::mr_7(Self) -> Self +pub fn Canvas::mr_72(Self) -> Self +pub fn Canvas::mr_8(Self) -> Self +pub fn Canvas::mr_80(Self) -> Self +pub fn Canvas::mr_9(Self) -> Self +pub fn Canvas::mr_96(Self) -> Self +pub fn Canvas::mr_auto(Self) -> Self +pub fn Canvas::mr_full(Self) -> Self +pub fn Canvas::mr_neg_0(Self) -> Self +pub fn Canvas::mr_neg_0p5(Self) -> Self +pub fn Canvas::mr_neg_1(Self) -> Self +pub fn Canvas::mr_neg_10(Self) -> Self +pub fn Canvas::mr_neg_11(Self) -> Self +pub fn Canvas::mr_neg_112(Self) -> Self +pub fn Canvas::mr_neg_12(Self) -> Self +pub fn Canvas::mr_neg_128(Self) -> Self +pub fn Canvas::mr_neg_16(Self) -> Self +pub fn Canvas::mr_neg_1_12(Self) -> Self +pub fn Canvas::mr_neg_1_2(Self) -> Self +pub fn Canvas::mr_neg_1_3(Self) -> Self +pub fn Canvas::mr_neg_1_4(Self) -> Self +pub fn Canvas::mr_neg_1_5(Self) -> Self +pub fn Canvas::mr_neg_1_6(Self) -> Self +pub fn Canvas::mr_neg_1p5(Self) -> Self +pub fn Canvas::mr_neg_2(Self) -> Self +pub fn Canvas::mr_neg_20(Self) -> Self +pub fn Canvas::mr_neg_24(Self) -> Self +pub fn Canvas::mr_neg_2_3(Self) -> Self +pub fn Canvas::mr_neg_2_4(Self) -> Self +pub fn Canvas::mr_neg_2_5(Self) -> Self +pub fn Canvas::mr_neg_2p5(Self) -> Self +pub fn Canvas::mr_neg_3(Self) -> Self +pub fn Canvas::mr_neg_32(Self) -> Self +pub fn Canvas::mr_neg_3_4(Self) -> Self +pub fn Canvas::mr_neg_3_5(Self) -> Self +pub fn Canvas::mr_neg_3p5(Self) -> Self +pub fn Canvas::mr_neg_4(Self) -> Self +pub fn Canvas::mr_neg_40(Self) -> Self +pub fn Canvas::mr_neg_48(Self) -> Self +pub fn Canvas::mr_neg_4_5(Self) -> Self +pub fn Canvas::mr_neg_5(Self) -> Self +pub fn Canvas::mr_neg_56(Self) -> Self +pub fn Canvas::mr_neg_5_6(Self) -> Self +pub fn Canvas::mr_neg_6(Self) -> Self +pub fn Canvas::mr_neg_64(Self) -> Self +pub fn Canvas::mr_neg_7(Self) -> Self +pub fn Canvas::mr_neg_72(Self) -> Self +pub fn Canvas::mr_neg_8(Self) -> Self +pub fn Canvas::mr_neg_80(Self) -> Self +pub fn Canvas::mr_neg_9(Self) -> Self +pub fn Canvas::mr_neg_96(Self) -> Self +pub fn Canvas::mr_neg_full(Self) -> Self +pub fn Canvas::mr_neg_px(Self) -> Self +pub fn Canvas::mr_px(Self) -> Self +pub fn Canvas::mt(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::mt_0(Self) -> Self +pub fn Canvas::mt_0p5(Self) -> Self +pub fn Canvas::mt_1(Self) -> Self +pub fn Canvas::mt_10(Self) -> Self +pub fn Canvas::mt_11(Self) -> Self +pub fn Canvas::mt_112(Self) -> Self +pub fn Canvas::mt_12(Self) -> Self +pub fn Canvas::mt_128(Self) -> Self +pub fn Canvas::mt_16(Self) -> Self +pub fn Canvas::mt_1_12(Self) -> Self +pub fn Canvas::mt_1_2(Self) -> Self +pub fn Canvas::mt_1_3(Self) -> Self +pub fn Canvas::mt_1_4(Self) -> Self +pub fn Canvas::mt_1_5(Self) -> Self +pub fn Canvas::mt_1_6(Self) -> Self +pub fn Canvas::mt_1p5(Self) -> Self +pub fn Canvas::mt_2(Self) -> Self +pub fn Canvas::mt_20(Self) -> Self +pub fn Canvas::mt_24(Self) -> Self +pub fn Canvas::mt_2_3(Self) -> Self +pub fn Canvas::mt_2_4(Self) -> Self +pub fn Canvas::mt_2_5(Self) -> Self +pub fn Canvas::mt_2p5(Self) -> Self +pub fn Canvas::mt_3(Self) -> Self +pub fn Canvas::mt_32(Self) -> Self +pub fn Canvas::mt_3_4(Self) -> Self +pub fn Canvas::mt_3_5(Self) -> Self +pub fn Canvas::mt_3p5(Self) -> Self +pub fn Canvas::mt_4(Self) -> Self +pub fn Canvas::mt_40(Self) -> Self +pub fn Canvas::mt_48(Self) -> Self +pub fn Canvas::mt_4_5(Self) -> Self +pub fn Canvas::mt_5(Self) -> Self +pub fn Canvas::mt_56(Self) -> Self +pub fn Canvas::mt_5_6(Self) -> Self +pub fn Canvas::mt_6(Self) -> Self +pub fn Canvas::mt_64(Self) -> Self +pub fn Canvas::mt_7(Self) -> Self +pub fn Canvas::mt_72(Self) -> Self +pub fn Canvas::mt_8(Self) -> Self +pub fn Canvas::mt_80(Self) -> Self +pub fn Canvas::mt_9(Self) -> Self +pub fn Canvas::mt_96(Self) -> Self +pub fn Canvas::mt_auto(Self) -> Self +pub fn Canvas::mt_full(Self) -> Self +pub fn Canvas::mt_neg_0(Self) -> Self +pub fn Canvas::mt_neg_0p5(Self) -> Self +pub fn Canvas::mt_neg_1(Self) -> Self +pub fn Canvas::mt_neg_10(Self) -> Self +pub fn Canvas::mt_neg_11(Self) -> Self +pub fn Canvas::mt_neg_112(Self) -> Self +pub fn Canvas::mt_neg_12(Self) -> Self +pub fn Canvas::mt_neg_128(Self) -> Self +pub fn Canvas::mt_neg_16(Self) -> Self +pub fn Canvas::mt_neg_1_12(Self) -> Self +pub fn Canvas::mt_neg_1_2(Self) -> Self +pub fn Canvas::mt_neg_1_3(Self) -> Self +pub fn Canvas::mt_neg_1_4(Self) -> Self +pub fn Canvas::mt_neg_1_5(Self) -> Self +pub fn Canvas::mt_neg_1_6(Self) -> Self +pub fn Canvas::mt_neg_1p5(Self) -> Self +pub fn Canvas::mt_neg_2(Self) -> Self +pub fn Canvas::mt_neg_20(Self) -> Self +pub fn Canvas::mt_neg_24(Self) -> Self +pub fn Canvas::mt_neg_2_3(Self) -> Self +pub fn Canvas::mt_neg_2_4(Self) -> Self +pub fn Canvas::mt_neg_2_5(Self) -> Self +pub fn Canvas::mt_neg_2p5(Self) -> Self +pub fn Canvas::mt_neg_3(Self) -> Self +pub fn Canvas::mt_neg_32(Self) -> Self +pub fn Canvas::mt_neg_3_4(Self) -> Self +pub fn Canvas::mt_neg_3_5(Self) -> Self +pub fn Canvas::mt_neg_3p5(Self) -> Self +pub fn Canvas::mt_neg_4(Self) -> Self +pub fn Canvas::mt_neg_40(Self) -> Self +pub fn Canvas::mt_neg_48(Self) -> Self +pub fn Canvas::mt_neg_4_5(Self) -> Self +pub fn Canvas::mt_neg_5(Self) -> Self +pub fn Canvas::mt_neg_56(Self) -> Self +pub fn Canvas::mt_neg_5_6(Self) -> Self +pub fn Canvas::mt_neg_6(Self) -> Self +pub fn Canvas::mt_neg_64(Self) -> Self +pub fn Canvas::mt_neg_7(Self) -> Self +pub fn Canvas::mt_neg_72(Self) -> Self +pub fn Canvas::mt_neg_8(Self) -> Self +pub fn Canvas::mt_neg_80(Self) -> Self +pub fn Canvas::mt_neg_9(Self) -> Self +pub fn Canvas::mt_neg_96(Self) -> Self +pub fn Canvas::mt_neg_full(Self) -> Self +pub fn Canvas::mt_neg_px(Self) -> Self +pub fn Canvas::mt_px(Self) -> Self +pub fn Canvas::mx(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::mx_0(Self) -> Self +pub fn Canvas::mx_0p5(Self) -> Self +pub fn Canvas::mx_1(Self) -> Self +pub fn Canvas::mx_10(Self) -> Self +pub fn Canvas::mx_11(Self) -> Self +pub fn Canvas::mx_112(Self) -> Self +pub fn Canvas::mx_12(Self) -> Self +pub fn Canvas::mx_128(Self) -> Self +pub fn Canvas::mx_16(Self) -> Self +pub fn Canvas::mx_1_12(Self) -> Self +pub fn Canvas::mx_1_2(Self) -> Self +pub fn Canvas::mx_1_3(Self) -> Self +pub fn Canvas::mx_1_4(Self) -> Self +pub fn Canvas::mx_1_5(Self) -> Self +pub fn Canvas::mx_1_6(Self) -> Self +pub fn Canvas::mx_1p5(Self) -> Self +pub fn Canvas::mx_2(Self) -> Self +pub fn Canvas::mx_20(Self) -> Self +pub fn Canvas::mx_24(Self) -> Self +pub fn Canvas::mx_2_3(Self) -> Self +pub fn Canvas::mx_2_4(Self) -> Self +pub fn Canvas::mx_2_5(Self) -> Self +pub fn Canvas::mx_2p5(Self) -> Self +pub fn Canvas::mx_3(Self) -> Self +pub fn Canvas::mx_32(Self) -> Self +pub fn Canvas::mx_3_4(Self) -> Self +pub fn Canvas::mx_3_5(Self) -> Self +pub fn Canvas::mx_3p5(Self) -> Self +pub fn Canvas::mx_4(Self) -> Self +pub fn Canvas::mx_40(Self) -> Self +pub fn Canvas::mx_48(Self) -> Self +pub fn Canvas::mx_4_5(Self) -> Self +pub fn Canvas::mx_5(Self) -> Self +pub fn Canvas::mx_56(Self) -> Self +pub fn Canvas::mx_5_6(Self) -> Self +pub fn Canvas::mx_6(Self) -> Self +pub fn Canvas::mx_64(Self) -> Self +pub fn Canvas::mx_7(Self) -> Self +pub fn Canvas::mx_72(Self) -> Self +pub fn Canvas::mx_8(Self) -> Self +pub fn Canvas::mx_80(Self) -> Self +pub fn Canvas::mx_9(Self) -> Self +pub fn Canvas::mx_96(Self) -> Self +pub fn Canvas::mx_auto(Self) -> Self +pub fn Canvas::mx_full(Self) -> Self +pub fn Canvas::mx_neg_0(Self) -> Self +pub fn Canvas::mx_neg_0p5(Self) -> Self +pub fn Canvas::mx_neg_1(Self) -> Self +pub fn Canvas::mx_neg_10(Self) -> Self +pub fn Canvas::mx_neg_11(Self) -> Self +pub fn Canvas::mx_neg_112(Self) -> Self +pub fn Canvas::mx_neg_12(Self) -> Self +pub fn Canvas::mx_neg_128(Self) -> Self +pub fn Canvas::mx_neg_16(Self) -> Self +pub fn Canvas::mx_neg_1_12(Self) -> Self +pub fn Canvas::mx_neg_1_2(Self) -> Self +pub fn Canvas::mx_neg_1_3(Self) -> Self +pub fn Canvas::mx_neg_1_4(Self) -> Self +pub fn Canvas::mx_neg_1_5(Self) -> Self +pub fn Canvas::mx_neg_1_6(Self) -> Self +pub fn Canvas::mx_neg_1p5(Self) -> Self +pub fn Canvas::mx_neg_2(Self) -> Self +pub fn Canvas::mx_neg_20(Self) -> Self +pub fn Canvas::mx_neg_24(Self) -> Self +pub fn Canvas::mx_neg_2_3(Self) -> Self +pub fn Canvas::mx_neg_2_4(Self) -> Self +pub fn Canvas::mx_neg_2_5(Self) -> Self +pub fn Canvas::mx_neg_2p5(Self) -> Self +pub fn Canvas::mx_neg_3(Self) -> Self +pub fn Canvas::mx_neg_32(Self) -> Self +pub fn Canvas::mx_neg_3_4(Self) -> Self +pub fn Canvas::mx_neg_3_5(Self) -> Self +pub fn Canvas::mx_neg_3p5(Self) -> Self +pub fn Canvas::mx_neg_4(Self) -> Self +pub fn Canvas::mx_neg_40(Self) -> Self +pub fn Canvas::mx_neg_48(Self) -> Self +pub fn Canvas::mx_neg_4_5(Self) -> Self +pub fn Canvas::mx_neg_5(Self) -> Self +pub fn Canvas::mx_neg_56(Self) -> Self +pub fn Canvas::mx_neg_5_6(Self) -> Self +pub fn Canvas::mx_neg_6(Self) -> Self +pub fn Canvas::mx_neg_64(Self) -> Self +pub fn Canvas::mx_neg_7(Self) -> Self +pub fn Canvas::mx_neg_72(Self) -> Self +pub fn Canvas::mx_neg_8(Self) -> Self +pub fn Canvas::mx_neg_80(Self) -> Self +pub fn Canvas::mx_neg_9(Self) -> Self +pub fn Canvas::mx_neg_96(Self) -> Self +pub fn Canvas::mx_neg_full(Self) -> Self +pub fn Canvas::mx_neg_px(Self) -> Self +pub fn Canvas::mx_px(Self) -> Self +pub fn Canvas::my(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::my_0(Self) -> Self +pub fn Canvas::my_0p5(Self) -> Self +pub fn Canvas::my_1(Self) -> Self +pub fn Canvas::my_10(Self) -> Self +pub fn Canvas::my_11(Self) -> Self +pub fn Canvas::my_112(Self) -> Self +pub fn Canvas::my_12(Self) -> Self +pub fn Canvas::my_128(Self) -> Self +pub fn Canvas::my_16(Self) -> Self +pub fn Canvas::my_1_12(Self) -> Self +pub fn Canvas::my_1_2(Self) -> Self +pub fn Canvas::my_1_3(Self) -> Self +pub fn Canvas::my_1_4(Self) -> Self +pub fn Canvas::my_1_5(Self) -> Self +pub fn Canvas::my_1_6(Self) -> Self +pub fn Canvas::my_1p5(Self) -> Self +pub fn Canvas::my_2(Self) -> Self +pub fn Canvas::my_20(Self) -> Self +pub fn Canvas::my_24(Self) -> Self +pub fn Canvas::my_2_3(Self) -> Self +pub fn Canvas::my_2_4(Self) -> Self +pub fn Canvas::my_2_5(Self) -> Self +pub fn Canvas::my_2p5(Self) -> Self +pub fn Canvas::my_3(Self) -> Self +pub fn Canvas::my_32(Self) -> Self +pub fn Canvas::my_3_4(Self) -> Self +pub fn Canvas::my_3_5(Self) -> Self +pub fn Canvas::my_3p5(Self) -> Self +pub fn Canvas::my_4(Self) -> Self +pub fn Canvas::my_40(Self) -> Self +pub fn Canvas::my_48(Self) -> Self +pub fn Canvas::my_4_5(Self) -> Self +pub fn Canvas::my_5(Self) -> Self +pub fn Canvas::my_56(Self) -> Self +pub fn Canvas::my_5_6(Self) -> Self +pub fn Canvas::my_6(Self) -> Self +pub fn Canvas::my_64(Self) -> Self +pub fn Canvas::my_7(Self) -> Self +pub fn Canvas::my_72(Self) -> Self +pub fn Canvas::my_8(Self) -> Self +pub fn Canvas::my_80(Self) -> Self +pub fn Canvas::my_9(Self) -> Self +pub fn Canvas::my_96(Self) -> Self +pub fn Canvas::my_auto(Self) -> Self +pub fn Canvas::my_full(Self) -> Self +pub fn Canvas::my_neg_0(Self) -> Self +pub fn Canvas::my_neg_0p5(Self) -> Self +pub fn Canvas::my_neg_1(Self) -> Self +pub fn Canvas::my_neg_10(Self) -> Self +pub fn Canvas::my_neg_11(Self) -> Self +pub fn Canvas::my_neg_112(Self) -> Self +pub fn Canvas::my_neg_12(Self) -> Self +pub fn Canvas::my_neg_128(Self) -> Self +pub fn Canvas::my_neg_16(Self) -> Self +pub fn Canvas::my_neg_1_12(Self) -> Self +pub fn Canvas::my_neg_1_2(Self) -> Self +pub fn Canvas::my_neg_1_3(Self) -> Self +pub fn Canvas::my_neg_1_4(Self) -> Self +pub fn Canvas::my_neg_1_5(Self) -> Self +pub fn Canvas::my_neg_1_6(Self) -> Self +pub fn Canvas::my_neg_1p5(Self) -> Self +pub fn Canvas::my_neg_2(Self) -> Self +pub fn Canvas::my_neg_20(Self) -> Self +pub fn Canvas::my_neg_24(Self) -> Self +pub fn Canvas::my_neg_2_3(Self) -> Self +pub fn Canvas::my_neg_2_4(Self) -> Self +pub fn Canvas::my_neg_2_5(Self) -> Self +pub fn Canvas::my_neg_2p5(Self) -> Self +pub fn Canvas::my_neg_3(Self) -> Self +pub fn Canvas::my_neg_32(Self) -> Self +pub fn Canvas::my_neg_3_4(Self) -> Self +pub fn Canvas::my_neg_3_5(Self) -> Self +pub fn Canvas::my_neg_3p5(Self) -> Self +pub fn Canvas::my_neg_4(Self) -> Self +pub fn Canvas::my_neg_40(Self) -> Self +pub fn Canvas::my_neg_48(Self) -> Self +pub fn Canvas::my_neg_4_5(Self) -> Self +pub fn Canvas::my_neg_5(Self) -> Self +pub fn Canvas::my_neg_56(Self) -> Self +pub fn Canvas::my_neg_5_6(Self) -> Self +pub fn Canvas::my_neg_6(Self) -> Self +pub fn Canvas::my_neg_64(Self) -> Self +pub fn Canvas::my_neg_7(Self) -> Self +pub fn Canvas::my_neg_72(Self) -> Self +pub fn Canvas::my_neg_8(Self) -> Self +pub fn Canvas::my_neg_80(Self) -> Self +pub fn Canvas::my_neg_9(Self) -> Self +pub fn Canvas::my_neg_96(Self) -> Self +pub fn Canvas::my_neg_full(Self) -> Self +pub fn Canvas::my_neg_px(Self) -> Self +pub fn Canvas::my_px(Self) -> Self +pub fn Canvas::not_italic(Self) -> Self +pub fn Canvas::opacity(Self, Double) -> Self +pub fn Canvas::overflow_hidden(Self) -> Self +pub fn Canvas::overflow_x_hidden(Self) -> Self +pub fn Canvas::overflow_y_hidden(Self) -> Self +pub fn Canvas::p(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Canvas::p_0(Self) -> Self +pub fn Canvas::p_0p5(Self) -> Self +pub fn Canvas::p_1(Self) -> Self +pub fn Canvas::p_10(Self) -> Self +pub fn Canvas::p_11(Self) -> Self +pub fn Canvas::p_112(Self) -> Self +pub fn Canvas::p_12(Self) -> Self +pub fn Canvas::p_128(Self) -> Self +pub fn Canvas::p_16(Self) -> Self +pub fn Canvas::p_1_12(Self) -> Self +pub fn Canvas::p_1_2(Self) -> Self +pub fn Canvas::p_1_3(Self) -> Self +pub fn Canvas::p_1_4(Self) -> Self +pub fn Canvas::p_1_5(Self) -> Self +pub fn Canvas::p_1_6(Self) -> Self +pub fn Canvas::p_1p5(Self) -> Self +pub fn Canvas::p_2(Self) -> Self +pub fn Canvas::p_20(Self) -> Self +pub fn Canvas::p_24(Self) -> Self +pub fn Canvas::p_2_3(Self) -> Self +pub fn Canvas::p_2_4(Self) -> Self +pub fn Canvas::p_2_5(Self) -> Self +pub fn Canvas::p_2p5(Self) -> Self +pub fn Canvas::p_3(Self) -> Self +pub fn Canvas::p_32(Self) -> Self +pub fn Canvas::p_3_4(Self) -> Self +pub fn Canvas::p_3_5(Self) -> Self +pub fn Canvas::p_3p5(Self) -> Self +pub fn Canvas::p_4(Self) -> Self +pub fn Canvas::p_40(Self) -> Self +pub fn Canvas::p_48(Self) -> Self +pub fn Canvas::p_4_5(Self) -> Self +pub fn Canvas::p_5(Self) -> Self +pub fn Canvas::p_56(Self) -> Self +pub fn Canvas::p_5_6(Self) -> Self +pub fn Canvas::p_6(Self) -> Self +pub fn Canvas::p_64(Self) -> Self +pub fn Canvas::p_7(Self) -> Self +pub fn Canvas::p_72(Self) -> Self +pub fn Canvas::p_8(Self) -> Self +pub fn Canvas::p_80(Self) -> Self +pub fn Canvas::p_9(Self) -> Self +pub fn Canvas::p_96(Self) -> Self +pub fn Canvas::p_full(Self) -> Self +pub fn Canvas::p_neg_0(Self) -> Self +pub fn Canvas::p_neg_0p5(Self) -> Self +pub fn Canvas::p_neg_1(Self) -> Self +pub fn Canvas::p_neg_10(Self) -> Self +pub fn Canvas::p_neg_11(Self) -> Self +pub fn Canvas::p_neg_112(Self) -> Self +pub fn Canvas::p_neg_12(Self) -> Self +pub fn Canvas::p_neg_128(Self) -> Self +pub fn Canvas::p_neg_16(Self) -> Self +pub fn Canvas::p_neg_1_12(Self) -> Self +pub fn Canvas::p_neg_1_2(Self) -> Self +pub fn Canvas::p_neg_1_3(Self) -> Self +pub fn Canvas::p_neg_1_4(Self) -> Self +pub fn Canvas::p_neg_1_5(Self) -> Self +pub fn Canvas::p_neg_1_6(Self) -> Self +pub fn Canvas::p_neg_1p5(Self) -> Self +pub fn Canvas::p_neg_2(Self) -> Self +pub fn Canvas::p_neg_20(Self) -> Self +pub fn Canvas::p_neg_24(Self) -> Self +pub fn Canvas::p_neg_2_3(Self) -> Self +pub fn Canvas::p_neg_2_4(Self) -> Self +pub fn Canvas::p_neg_2_5(Self) -> Self +pub fn Canvas::p_neg_2p5(Self) -> Self +pub fn Canvas::p_neg_3(Self) -> Self +pub fn Canvas::p_neg_32(Self) -> Self +pub fn Canvas::p_neg_3_4(Self) -> Self +pub fn Canvas::p_neg_3_5(Self) -> Self +pub fn Canvas::p_neg_3p5(Self) -> Self +pub fn Canvas::p_neg_4(Self) -> Self +pub fn Canvas::p_neg_40(Self) -> Self +pub fn Canvas::p_neg_48(Self) -> Self +pub fn Canvas::p_neg_4_5(Self) -> Self +pub fn Canvas::p_neg_5(Self) -> Self +pub fn Canvas::p_neg_56(Self) -> Self +pub fn Canvas::p_neg_5_6(Self) -> Self +pub fn Canvas::p_neg_6(Self) -> Self +pub fn Canvas::p_neg_64(Self) -> Self +pub fn Canvas::p_neg_7(Self) -> Self +pub fn Canvas::p_neg_72(Self) -> Self +pub fn Canvas::p_neg_8(Self) -> Self +pub fn Canvas::p_neg_80(Self) -> Self +pub fn Canvas::p_neg_9(Self) -> Self +pub fn Canvas::p_neg_96(Self) -> Self +pub fn Canvas::p_neg_full(Self) -> Self +pub fn Canvas::p_neg_px(Self) -> Self +pub fn Canvas::p_px(Self) -> Self +pub fn Canvas::pb(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Canvas::pb_0(Self) -> Self +pub fn Canvas::pb_0p5(Self) -> Self +pub fn Canvas::pb_1(Self) -> Self +pub fn Canvas::pb_10(Self) -> Self +pub fn Canvas::pb_11(Self) -> Self +pub fn Canvas::pb_112(Self) -> Self +pub fn Canvas::pb_12(Self) -> Self +pub fn Canvas::pb_128(Self) -> Self +pub fn Canvas::pb_16(Self) -> Self +pub fn Canvas::pb_1_12(Self) -> Self +pub fn Canvas::pb_1_2(Self) -> Self +pub fn Canvas::pb_1_3(Self) -> Self +pub fn Canvas::pb_1_4(Self) -> Self +pub fn Canvas::pb_1_5(Self) -> Self +pub fn Canvas::pb_1_6(Self) -> Self +pub fn Canvas::pb_1p5(Self) -> Self +pub fn Canvas::pb_2(Self) -> Self +pub fn Canvas::pb_20(Self) -> Self +pub fn Canvas::pb_24(Self) -> Self +pub fn Canvas::pb_2_3(Self) -> Self +pub fn Canvas::pb_2_4(Self) -> Self +pub fn Canvas::pb_2_5(Self) -> Self +pub fn Canvas::pb_2p5(Self) -> Self +pub fn Canvas::pb_3(Self) -> Self +pub fn Canvas::pb_32(Self) -> Self +pub fn Canvas::pb_3_4(Self) -> Self +pub fn Canvas::pb_3_5(Self) -> Self +pub fn Canvas::pb_3p5(Self) -> Self +pub fn Canvas::pb_4(Self) -> Self +pub fn Canvas::pb_40(Self) -> Self +pub fn Canvas::pb_48(Self) -> Self +pub fn Canvas::pb_4_5(Self) -> Self +pub fn Canvas::pb_5(Self) -> Self +pub fn Canvas::pb_56(Self) -> Self +pub fn Canvas::pb_5_6(Self) -> Self +pub fn Canvas::pb_6(Self) -> Self +pub fn Canvas::pb_64(Self) -> Self +pub fn Canvas::pb_7(Self) -> Self +pub fn Canvas::pb_72(Self) -> Self +pub fn Canvas::pb_8(Self) -> Self +pub fn Canvas::pb_80(Self) -> Self +pub fn Canvas::pb_9(Self) -> Self +pub fn Canvas::pb_96(Self) -> Self +pub fn Canvas::pb_full(Self) -> Self +pub fn Canvas::pb_neg_0(Self) -> Self +pub fn Canvas::pb_neg_0p5(Self) -> Self +pub fn Canvas::pb_neg_1(Self) -> Self +pub fn Canvas::pb_neg_10(Self) -> Self +pub fn Canvas::pb_neg_11(Self) -> Self +pub fn Canvas::pb_neg_112(Self) -> Self +pub fn Canvas::pb_neg_12(Self) -> Self +pub fn Canvas::pb_neg_128(Self) -> Self +pub fn Canvas::pb_neg_16(Self) -> Self +pub fn Canvas::pb_neg_1_12(Self) -> Self +pub fn Canvas::pb_neg_1_2(Self) -> Self +pub fn Canvas::pb_neg_1_3(Self) -> Self +pub fn Canvas::pb_neg_1_4(Self) -> Self +pub fn Canvas::pb_neg_1_5(Self) -> Self +pub fn Canvas::pb_neg_1_6(Self) -> Self +pub fn Canvas::pb_neg_1p5(Self) -> Self +pub fn Canvas::pb_neg_2(Self) -> Self +pub fn Canvas::pb_neg_20(Self) -> Self +pub fn Canvas::pb_neg_24(Self) -> Self +pub fn Canvas::pb_neg_2_3(Self) -> Self +pub fn Canvas::pb_neg_2_4(Self) -> Self +pub fn Canvas::pb_neg_2_5(Self) -> Self +pub fn Canvas::pb_neg_2p5(Self) -> Self +pub fn Canvas::pb_neg_3(Self) -> Self +pub fn Canvas::pb_neg_32(Self) -> Self +pub fn Canvas::pb_neg_3_4(Self) -> Self +pub fn Canvas::pb_neg_3_5(Self) -> Self +pub fn Canvas::pb_neg_3p5(Self) -> Self +pub fn Canvas::pb_neg_4(Self) -> Self +pub fn Canvas::pb_neg_40(Self) -> Self +pub fn Canvas::pb_neg_48(Self) -> Self +pub fn Canvas::pb_neg_4_5(Self) -> Self +pub fn Canvas::pb_neg_5(Self) -> Self +pub fn Canvas::pb_neg_56(Self) -> Self +pub fn Canvas::pb_neg_5_6(Self) -> Self +pub fn Canvas::pb_neg_6(Self) -> Self +pub fn Canvas::pb_neg_64(Self) -> Self +pub fn Canvas::pb_neg_7(Self) -> Self +pub fn Canvas::pb_neg_72(Self) -> Self +pub fn Canvas::pb_neg_8(Self) -> Self +pub fn Canvas::pb_neg_80(Self) -> Self +pub fn Canvas::pb_neg_9(Self) -> Self +pub fn Canvas::pb_neg_96(Self) -> Self +pub fn Canvas::pb_neg_full(Self) -> Self +pub fn Canvas::pb_neg_px(Self) -> Self +pub fn Canvas::pb_px(Self) -> Self +pub fn Canvas::pl(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Canvas::pl_0(Self) -> Self +pub fn Canvas::pl_0p5(Self) -> Self +pub fn Canvas::pl_1(Self) -> Self +pub fn Canvas::pl_10(Self) -> Self +pub fn Canvas::pl_11(Self) -> Self +pub fn Canvas::pl_112(Self) -> Self +pub fn Canvas::pl_12(Self) -> Self +pub fn Canvas::pl_128(Self) -> Self +pub fn Canvas::pl_16(Self) -> Self +pub fn Canvas::pl_1_12(Self) -> Self +pub fn Canvas::pl_1_2(Self) -> Self +pub fn Canvas::pl_1_3(Self) -> Self +pub fn Canvas::pl_1_4(Self) -> Self +pub fn Canvas::pl_1_5(Self) -> Self +pub fn Canvas::pl_1_6(Self) -> Self +pub fn Canvas::pl_1p5(Self) -> Self +pub fn Canvas::pl_2(Self) -> Self +pub fn Canvas::pl_20(Self) -> Self +pub fn Canvas::pl_24(Self) -> Self +pub fn Canvas::pl_2_3(Self) -> Self +pub fn Canvas::pl_2_4(Self) -> Self +pub fn Canvas::pl_2_5(Self) -> Self +pub fn Canvas::pl_2p5(Self) -> Self +pub fn Canvas::pl_3(Self) -> Self +pub fn Canvas::pl_32(Self) -> Self +pub fn Canvas::pl_3_4(Self) -> Self +pub fn Canvas::pl_3_5(Self) -> Self +pub fn Canvas::pl_3p5(Self) -> Self +pub fn Canvas::pl_4(Self) -> Self +pub fn Canvas::pl_40(Self) -> Self +pub fn Canvas::pl_48(Self) -> Self +pub fn Canvas::pl_4_5(Self) -> Self +pub fn Canvas::pl_5(Self) -> Self +pub fn Canvas::pl_56(Self) -> Self +pub fn Canvas::pl_5_6(Self) -> Self +pub fn Canvas::pl_6(Self) -> Self +pub fn Canvas::pl_64(Self) -> Self +pub fn Canvas::pl_7(Self) -> Self +pub fn Canvas::pl_72(Self) -> Self +pub fn Canvas::pl_8(Self) -> Self +pub fn Canvas::pl_80(Self) -> Self +pub fn Canvas::pl_9(Self) -> Self +pub fn Canvas::pl_96(Self) -> Self +pub fn Canvas::pl_full(Self) -> Self +pub fn Canvas::pl_neg_0(Self) -> Self +pub fn Canvas::pl_neg_0p5(Self) -> Self +pub fn Canvas::pl_neg_1(Self) -> Self +pub fn Canvas::pl_neg_10(Self) -> Self +pub fn Canvas::pl_neg_11(Self) -> Self +pub fn Canvas::pl_neg_112(Self) -> Self +pub fn Canvas::pl_neg_12(Self) -> Self +pub fn Canvas::pl_neg_128(Self) -> Self +pub fn Canvas::pl_neg_16(Self) -> Self +pub fn Canvas::pl_neg_1_12(Self) -> Self +pub fn Canvas::pl_neg_1_2(Self) -> Self +pub fn Canvas::pl_neg_1_3(Self) -> Self +pub fn Canvas::pl_neg_1_4(Self) -> Self +pub fn Canvas::pl_neg_1_5(Self) -> Self +pub fn Canvas::pl_neg_1_6(Self) -> Self +pub fn Canvas::pl_neg_1p5(Self) -> Self +pub fn Canvas::pl_neg_2(Self) -> Self +pub fn Canvas::pl_neg_20(Self) -> Self +pub fn Canvas::pl_neg_24(Self) -> Self +pub fn Canvas::pl_neg_2_3(Self) -> Self +pub fn Canvas::pl_neg_2_4(Self) -> Self +pub fn Canvas::pl_neg_2_5(Self) -> Self +pub fn Canvas::pl_neg_2p5(Self) -> Self +pub fn Canvas::pl_neg_3(Self) -> Self +pub fn Canvas::pl_neg_32(Self) -> Self +pub fn Canvas::pl_neg_3_4(Self) -> Self +pub fn Canvas::pl_neg_3_5(Self) -> Self +pub fn Canvas::pl_neg_3p5(Self) -> Self +pub fn Canvas::pl_neg_4(Self) -> Self +pub fn Canvas::pl_neg_40(Self) -> Self +pub fn Canvas::pl_neg_48(Self) -> Self +pub fn Canvas::pl_neg_4_5(Self) -> Self +pub fn Canvas::pl_neg_5(Self) -> Self +pub fn Canvas::pl_neg_56(Self) -> Self +pub fn Canvas::pl_neg_5_6(Self) -> Self +pub fn Canvas::pl_neg_6(Self) -> Self +pub fn Canvas::pl_neg_64(Self) -> Self +pub fn Canvas::pl_neg_7(Self) -> Self +pub fn Canvas::pl_neg_72(Self) -> Self +pub fn Canvas::pl_neg_8(Self) -> Self +pub fn Canvas::pl_neg_80(Self) -> Self +pub fn Canvas::pl_neg_9(Self) -> Self +pub fn Canvas::pl_neg_96(Self) -> Self +pub fn Canvas::pl_neg_full(Self) -> Self +pub fn Canvas::pl_neg_px(Self) -> Self +pub fn Canvas::pl_px(Self) -> Self +pub fn Canvas::pr(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Canvas::pr_0(Self) -> Self +pub fn Canvas::pr_0p5(Self) -> Self +pub fn Canvas::pr_1(Self) -> Self +pub fn Canvas::pr_10(Self) -> Self +pub fn Canvas::pr_11(Self) -> Self +pub fn Canvas::pr_112(Self) -> Self +pub fn Canvas::pr_12(Self) -> Self +pub fn Canvas::pr_128(Self) -> Self +pub fn Canvas::pr_16(Self) -> Self +pub fn Canvas::pr_1_12(Self) -> Self +pub fn Canvas::pr_1_2(Self) -> Self +pub fn Canvas::pr_1_3(Self) -> Self +pub fn Canvas::pr_1_4(Self) -> Self +pub fn Canvas::pr_1_5(Self) -> Self +pub fn Canvas::pr_1_6(Self) -> Self +pub fn Canvas::pr_1p5(Self) -> Self +pub fn Canvas::pr_2(Self) -> Self +pub fn Canvas::pr_20(Self) -> Self +pub fn Canvas::pr_24(Self) -> Self +pub fn Canvas::pr_2_3(Self) -> Self +pub fn Canvas::pr_2_4(Self) -> Self +pub fn Canvas::pr_2_5(Self) -> Self +pub fn Canvas::pr_2p5(Self) -> Self +pub fn Canvas::pr_3(Self) -> Self +pub fn Canvas::pr_32(Self) -> Self +pub fn Canvas::pr_3_4(Self) -> Self +pub fn Canvas::pr_3_5(Self) -> Self +pub fn Canvas::pr_3p5(Self) -> Self +pub fn Canvas::pr_4(Self) -> Self +pub fn Canvas::pr_40(Self) -> Self +pub fn Canvas::pr_48(Self) -> Self +pub fn Canvas::pr_4_5(Self) -> Self +pub fn Canvas::pr_5(Self) -> Self +pub fn Canvas::pr_56(Self) -> Self +pub fn Canvas::pr_5_6(Self) -> Self +pub fn Canvas::pr_6(Self) -> Self +pub fn Canvas::pr_64(Self) -> Self +pub fn Canvas::pr_7(Self) -> Self +pub fn Canvas::pr_72(Self) -> Self +pub fn Canvas::pr_8(Self) -> Self +pub fn Canvas::pr_80(Self) -> Self +pub fn Canvas::pr_9(Self) -> Self +pub fn Canvas::pr_96(Self) -> Self +pub fn Canvas::pr_full(Self) -> Self +pub fn Canvas::pr_neg_0(Self) -> Self +pub fn Canvas::pr_neg_0p5(Self) -> Self +pub fn Canvas::pr_neg_1(Self) -> Self +pub fn Canvas::pr_neg_10(Self) -> Self +pub fn Canvas::pr_neg_11(Self) -> Self +pub fn Canvas::pr_neg_112(Self) -> Self +pub fn Canvas::pr_neg_12(Self) -> Self +pub fn Canvas::pr_neg_128(Self) -> Self +pub fn Canvas::pr_neg_16(Self) -> Self +pub fn Canvas::pr_neg_1_12(Self) -> Self +pub fn Canvas::pr_neg_1_2(Self) -> Self +pub fn Canvas::pr_neg_1_3(Self) -> Self +pub fn Canvas::pr_neg_1_4(Self) -> Self +pub fn Canvas::pr_neg_1_5(Self) -> Self +pub fn Canvas::pr_neg_1_6(Self) -> Self +pub fn Canvas::pr_neg_1p5(Self) -> Self +pub fn Canvas::pr_neg_2(Self) -> Self +pub fn Canvas::pr_neg_20(Self) -> Self +pub fn Canvas::pr_neg_24(Self) -> Self +pub fn Canvas::pr_neg_2_3(Self) -> Self +pub fn Canvas::pr_neg_2_4(Self) -> Self +pub fn Canvas::pr_neg_2_5(Self) -> Self +pub fn Canvas::pr_neg_2p5(Self) -> Self +pub fn Canvas::pr_neg_3(Self) -> Self +pub fn Canvas::pr_neg_32(Self) -> Self +pub fn Canvas::pr_neg_3_4(Self) -> Self +pub fn Canvas::pr_neg_3_5(Self) -> Self +pub fn Canvas::pr_neg_3p5(Self) -> Self +pub fn Canvas::pr_neg_4(Self) -> Self +pub fn Canvas::pr_neg_40(Self) -> Self +pub fn Canvas::pr_neg_48(Self) -> Self +pub fn Canvas::pr_neg_4_5(Self) -> Self +pub fn Canvas::pr_neg_5(Self) -> Self +pub fn Canvas::pr_neg_56(Self) -> Self +pub fn Canvas::pr_neg_5_6(Self) -> Self +pub fn Canvas::pr_neg_6(Self) -> Self +pub fn Canvas::pr_neg_64(Self) -> Self +pub fn Canvas::pr_neg_7(Self) -> Self +pub fn Canvas::pr_neg_72(Self) -> Self +pub fn Canvas::pr_neg_8(Self) -> Self +pub fn Canvas::pr_neg_80(Self) -> Self +pub fn Canvas::pr_neg_9(Self) -> Self +pub fn Canvas::pr_neg_96(Self) -> Self +pub fn Canvas::pr_neg_full(Self) -> Self +pub fn Canvas::pr_neg_px(Self) -> Self +pub fn Canvas::pr_px(Self) -> Self +pub fn Canvas::pt(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Canvas::pt_0(Self) -> Self +pub fn Canvas::pt_0p5(Self) -> Self +pub fn Canvas::pt_1(Self) -> Self +pub fn Canvas::pt_10(Self) -> Self +pub fn Canvas::pt_11(Self) -> Self +pub fn Canvas::pt_112(Self) -> Self +pub fn Canvas::pt_12(Self) -> Self +pub fn Canvas::pt_128(Self) -> Self +pub fn Canvas::pt_16(Self) -> Self +pub fn Canvas::pt_1_12(Self) -> Self +pub fn Canvas::pt_1_2(Self) -> Self +pub fn Canvas::pt_1_3(Self) -> Self +pub fn Canvas::pt_1_4(Self) -> Self +pub fn Canvas::pt_1_5(Self) -> Self +pub fn Canvas::pt_1_6(Self) -> Self +pub fn Canvas::pt_1p5(Self) -> Self +pub fn Canvas::pt_2(Self) -> Self +pub fn Canvas::pt_20(Self) -> Self +pub fn Canvas::pt_24(Self) -> Self +pub fn Canvas::pt_2_3(Self) -> Self +pub fn Canvas::pt_2_4(Self) -> Self +pub fn Canvas::pt_2_5(Self) -> Self +pub fn Canvas::pt_2p5(Self) -> Self +pub fn Canvas::pt_3(Self) -> Self +pub fn Canvas::pt_32(Self) -> Self +pub fn Canvas::pt_3_4(Self) -> Self +pub fn Canvas::pt_3_5(Self) -> Self +pub fn Canvas::pt_3p5(Self) -> Self +pub fn Canvas::pt_4(Self) -> Self +pub fn Canvas::pt_40(Self) -> Self +pub fn Canvas::pt_48(Self) -> Self +pub fn Canvas::pt_4_5(Self) -> Self +pub fn Canvas::pt_5(Self) -> Self +pub fn Canvas::pt_56(Self) -> Self +pub fn Canvas::pt_5_6(Self) -> Self +pub fn Canvas::pt_6(Self) -> Self +pub fn Canvas::pt_64(Self) -> Self +pub fn Canvas::pt_7(Self) -> Self +pub fn Canvas::pt_72(Self) -> Self +pub fn Canvas::pt_8(Self) -> Self +pub fn Canvas::pt_80(Self) -> Self +pub fn Canvas::pt_9(Self) -> Self +pub fn Canvas::pt_96(Self) -> Self +pub fn Canvas::pt_full(Self) -> Self +pub fn Canvas::pt_neg_0(Self) -> Self +pub fn Canvas::pt_neg_0p5(Self) -> Self +pub fn Canvas::pt_neg_1(Self) -> Self +pub fn Canvas::pt_neg_10(Self) -> Self +pub fn Canvas::pt_neg_11(Self) -> Self +pub fn Canvas::pt_neg_112(Self) -> Self +pub fn Canvas::pt_neg_12(Self) -> Self +pub fn Canvas::pt_neg_128(Self) -> Self +pub fn Canvas::pt_neg_16(Self) -> Self +pub fn Canvas::pt_neg_1_12(Self) -> Self +pub fn Canvas::pt_neg_1_2(Self) -> Self +pub fn Canvas::pt_neg_1_3(Self) -> Self +pub fn Canvas::pt_neg_1_4(Self) -> Self +pub fn Canvas::pt_neg_1_5(Self) -> Self +pub fn Canvas::pt_neg_1_6(Self) -> Self +pub fn Canvas::pt_neg_1p5(Self) -> Self +pub fn Canvas::pt_neg_2(Self) -> Self +pub fn Canvas::pt_neg_20(Self) -> Self +pub fn Canvas::pt_neg_24(Self) -> Self +pub fn Canvas::pt_neg_2_3(Self) -> Self +pub fn Canvas::pt_neg_2_4(Self) -> Self +pub fn Canvas::pt_neg_2_5(Self) -> Self +pub fn Canvas::pt_neg_2p5(Self) -> Self +pub fn Canvas::pt_neg_3(Self) -> Self +pub fn Canvas::pt_neg_32(Self) -> Self +pub fn Canvas::pt_neg_3_4(Self) -> Self +pub fn Canvas::pt_neg_3_5(Self) -> Self +pub fn Canvas::pt_neg_3p5(Self) -> Self +pub fn Canvas::pt_neg_4(Self) -> Self +pub fn Canvas::pt_neg_40(Self) -> Self +pub fn Canvas::pt_neg_48(Self) -> Self +pub fn Canvas::pt_neg_4_5(Self) -> Self +pub fn Canvas::pt_neg_5(Self) -> Self +pub fn Canvas::pt_neg_56(Self) -> Self +pub fn Canvas::pt_neg_5_6(Self) -> Self +pub fn Canvas::pt_neg_6(Self) -> Self +pub fn Canvas::pt_neg_64(Self) -> Self +pub fn Canvas::pt_neg_7(Self) -> Self +pub fn Canvas::pt_neg_72(Self) -> Self +pub fn Canvas::pt_neg_8(Self) -> Self +pub fn Canvas::pt_neg_80(Self) -> Self +pub fn Canvas::pt_neg_9(Self) -> Self +pub fn Canvas::pt_neg_96(Self) -> Self +pub fn Canvas::pt_neg_full(Self) -> Self +pub fn Canvas::pt_neg_px(Self) -> Self +pub fn Canvas::pt_px(Self) -> Self +pub fn Canvas::px(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Canvas::px_0(Self) -> Self +pub fn Canvas::px_0p5(Self) -> Self +pub fn Canvas::px_1(Self) -> Self +pub fn Canvas::px_10(Self) -> Self +pub fn Canvas::px_11(Self) -> Self +pub fn Canvas::px_112(Self) -> Self +pub fn Canvas::px_12(Self) -> Self +pub fn Canvas::px_128(Self) -> Self +pub fn Canvas::px_16(Self) -> Self +pub fn Canvas::px_1_12(Self) -> Self +pub fn Canvas::px_1_2(Self) -> Self +pub fn Canvas::px_1_3(Self) -> Self +pub fn Canvas::px_1_4(Self) -> Self +pub fn Canvas::px_1_5(Self) -> Self +pub fn Canvas::px_1_6(Self) -> Self +pub fn Canvas::px_1p5(Self) -> Self +pub fn Canvas::px_2(Self) -> Self +pub fn Canvas::px_20(Self) -> Self +pub fn Canvas::px_24(Self) -> Self +pub fn Canvas::px_2_3(Self) -> Self +pub fn Canvas::px_2_4(Self) -> Self +pub fn Canvas::px_2_5(Self) -> Self +pub fn Canvas::px_2p5(Self) -> Self +pub fn Canvas::px_3(Self) -> Self +pub fn Canvas::px_32(Self) -> Self +pub fn Canvas::px_3_4(Self) -> Self +pub fn Canvas::px_3_5(Self) -> Self +pub fn Canvas::px_3p5(Self) -> Self +pub fn Canvas::px_4(Self) -> Self +pub fn Canvas::px_40(Self) -> Self +pub fn Canvas::px_48(Self) -> Self +pub fn Canvas::px_4_5(Self) -> Self +pub fn Canvas::px_5(Self) -> Self +pub fn Canvas::px_56(Self) -> Self +pub fn Canvas::px_5_6(Self) -> Self +pub fn Canvas::px_6(Self) -> Self +pub fn Canvas::px_64(Self) -> Self +pub fn Canvas::px_7(Self) -> Self +pub fn Canvas::px_72(Self) -> Self +pub fn Canvas::px_8(Self) -> Self +pub fn Canvas::px_80(Self) -> Self +pub fn Canvas::px_9(Self) -> Self +pub fn Canvas::px_96(Self) -> Self +pub fn Canvas::px_full(Self) -> Self +pub fn Canvas::px_neg_0(Self) -> Self +pub fn Canvas::px_neg_0p5(Self) -> Self +pub fn Canvas::px_neg_1(Self) -> Self +pub fn Canvas::px_neg_10(Self) -> Self +pub fn Canvas::px_neg_11(Self) -> Self +pub fn Canvas::px_neg_112(Self) -> Self +pub fn Canvas::px_neg_12(Self) -> Self +pub fn Canvas::px_neg_128(Self) -> Self +pub fn Canvas::px_neg_16(Self) -> Self +pub fn Canvas::px_neg_1_12(Self) -> Self +pub fn Canvas::px_neg_1_2(Self) -> Self +pub fn Canvas::px_neg_1_3(Self) -> Self +pub fn Canvas::px_neg_1_4(Self) -> Self +pub fn Canvas::px_neg_1_5(Self) -> Self +pub fn Canvas::px_neg_1_6(Self) -> Self +pub fn Canvas::px_neg_1p5(Self) -> Self +pub fn Canvas::px_neg_2(Self) -> Self +pub fn Canvas::px_neg_20(Self) -> Self +pub fn Canvas::px_neg_24(Self) -> Self +pub fn Canvas::px_neg_2_3(Self) -> Self +pub fn Canvas::px_neg_2_4(Self) -> Self +pub fn Canvas::px_neg_2_5(Self) -> Self +pub fn Canvas::px_neg_2p5(Self) -> Self +pub fn Canvas::px_neg_3(Self) -> Self +pub fn Canvas::px_neg_32(Self) -> Self +pub fn Canvas::px_neg_3_4(Self) -> Self +pub fn Canvas::px_neg_3_5(Self) -> Self +pub fn Canvas::px_neg_3p5(Self) -> Self +pub fn Canvas::px_neg_4(Self) -> Self +pub fn Canvas::px_neg_40(Self) -> Self +pub fn Canvas::px_neg_48(Self) -> Self +pub fn Canvas::px_neg_4_5(Self) -> Self +pub fn Canvas::px_neg_5(Self) -> Self +pub fn Canvas::px_neg_56(Self) -> Self +pub fn Canvas::px_neg_5_6(Self) -> Self +pub fn Canvas::px_neg_6(Self) -> Self +pub fn Canvas::px_neg_64(Self) -> Self +pub fn Canvas::px_neg_7(Self) -> Self +pub fn Canvas::px_neg_72(Self) -> Self +pub fn Canvas::px_neg_8(Self) -> Self +pub fn Canvas::px_neg_80(Self) -> Self +pub fn Canvas::px_neg_9(Self) -> Self +pub fn Canvas::px_neg_96(Self) -> Self +pub fn Canvas::px_neg_full(Self) -> Self +pub fn Canvas::px_neg_px(Self) -> Self +pub fn Canvas::px_px(Self) -> Self +pub fn Canvas::py(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Canvas::py_0(Self) -> Self +pub fn Canvas::py_0p5(Self) -> Self +pub fn Canvas::py_1(Self) -> Self +pub fn Canvas::py_10(Self) -> Self +pub fn Canvas::py_11(Self) -> Self +pub fn Canvas::py_112(Self) -> Self +pub fn Canvas::py_12(Self) -> Self +pub fn Canvas::py_128(Self) -> Self +pub fn Canvas::py_16(Self) -> Self +pub fn Canvas::py_1_12(Self) -> Self +pub fn Canvas::py_1_2(Self) -> Self +pub fn Canvas::py_1_3(Self) -> Self +pub fn Canvas::py_1_4(Self) -> Self +pub fn Canvas::py_1_5(Self) -> Self +pub fn Canvas::py_1_6(Self) -> Self +pub fn Canvas::py_1p5(Self) -> Self +pub fn Canvas::py_2(Self) -> Self +pub fn Canvas::py_20(Self) -> Self +pub fn Canvas::py_24(Self) -> Self +pub fn Canvas::py_2_3(Self) -> Self +pub fn Canvas::py_2_4(Self) -> Self +pub fn Canvas::py_2_5(Self) -> Self +pub fn Canvas::py_2p5(Self) -> Self +pub fn Canvas::py_3(Self) -> Self +pub fn Canvas::py_32(Self) -> Self +pub fn Canvas::py_3_4(Self) -> Self +pub fn Canvas::py_3_5(Self) -> Self +pub fn Canvas::py_3p5(Self) -> Self +pub fn Canvas::py_4(Self) -> Self +pub fn Canvas::py_40(Self) -> Self +pub fn Canvas::py_48(Self) -> Self +pub fn Canvas::py_4_5(Self) -> Self +pub fn Canvas::py_5(Self) -> Self +pub fn Canvas::py_56(Self) -> Self +pub fn Canvas::py_5_6(Self) -> Self +pub fn Canvas::py_6(Self) -> Self +pub fn Canvas::py_64(Self) -> Self +pub fn Canvas::py_7(Self) -> Self +pub fn Canvas::py_72(Self) -> Self +pub fn Canvas::py_8(Self) -> Self +pub fn Canvas::py_80(Self) -> Self +pub fn Canvas::py_9(Self) -> Self +pub fn Canvas::py_96(Self) -> Self +pub fn Canvas::py_full(Self) -> Self +pub fn Canvas::py_neg_0(Self) -> Self +pub fn Canvas::py_neg_0p5(Self) -> Self +pub fn Canvas::py_neg_1(Self) -> Self +pub fn Canvas::py_neg_10(Self) -> Self +pub fn Canvas::py_neg_11(Self) -> Self +pub fn Canvas::py_neg_112(Self) -> Self +pub fn Canvas::py_neg_12(Self) -> Self +pub fn Canvas::py_neg_128(Self) -> Self +pub fn Canvas::py_neg_16(Self) -> Self +pub fn Canvas::py_neg_1_12(Self) -> Self +pub fn Canvas::py_neg_1_2(Self) -> Self +pub fn Canvas::py_neg_1_3(Self) -> Self +pub fn Canvas::py_neg_1_4(Self) -> Self +pub fn Canvas::py_neg_1_5(Self) -> Self +pub fn Canvas::py_neg_1_6(Self) -> Self +pub fn Canvas::py_neg_1p5(Self) -> Self +pub fn Canvas::py_neg_2(Self) -> Self +pub fn Canvas::py_neg_20(Self) -> Self +pub fn Canvas::py_neg_24(Self) -> Self +pub fn Canvas::py_neg_2_3(Self) -> Self +pub fn Canvas::py_neg_2_4(Self) -> Self +pub fn Canvas::py_neg_2_5(Self) -> Self +pub fn Canvas::py_neg_2p5(Self) -> Self +pub fn Canvas::py_neg_3(Self) -> Self +pub fn Canvas::py_neg_32(Self) -> Self +pub fn Canvas::py_neg_3_4(Self) -> Self +pub fn Canvas::py_neg_3_5(Self) -> Self +pub fn Canvas::py_neg_3p5(Self) -> Self +pub fn Canvas::py_neg_4(Self) -> Self +pub fn Canvas::py_neg_40(Self) -> Self +pub fn Canvas::py_neg_48(Self) -> Self +pub fn Canvas::py_neg_4_5(Self) -> Self +pub fn Canvas::py_neg_5(Self) -> Self +pub fn Canvas::py_neg_56(Self) -> Self +pub fn Canvas::py_neg_5_6(Self) -> Self +pub fn Canvas::py_neg_6(Self) -> Self +pub fn Canvas::py_neg_64(Self) -> Self +pub fn Canvas::py_neg_7(Self) -> Self +pub fn Canvas::py_neg_72(Self) -> Self +pub fn Canvas::py_neg_8(Self) -> Self +pub fn Canvas::py_neg_80(Self) -> Self +pub fn Canvas::py_neg_9(Self) -> Self +pub fn Canvas::py_neg_96(Self) -> Self +pub fn Canvas::py_neg_full(Self) -> Self +pub fn Canvas::py_neg_px(Self) -> Self +pub fn Canvas::py_px(Self) -> Self +pub fn Canvas::relative(Self) -> Self +pub fn Canvas::right(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::right_0(Self) -> Self +pub fn Canvas::right_0p5(Self) -> Self +pub fn Canvas::right_1(Self) -> Self +pub fn Canvas::right_10(Self) -> Self +pub fn Canvas::right_11(Self) -> Self +pub fn Canvas::right_112(Self) -> Self +pub fn Canvas::right_12(Self) -> Self +pub fn Canvas::right_128(Self) -> Self +pub fn Canvas::right_16(Self) -> Self +pub fn Canvas::right_1_12(Self) -> Self +pub fn Canvas::right_1_2(Self) -> Self +pub fn Canvas::right_1_3(Self) -> Self +pub fn Canvas::right_1_4(Self) -> Self +pub fn Canvas::right_1_5(Self) -> Self +pub fn Canvas::right_1_6(Self) -> Self +pub fn Canvas::right_1p5(Self) -> Self +pub fn Canvas::right_2(Self) -> Self +pub fn Canvas::right_20(Self) -> Self +pub fn Canvas::right_24(Self) -> Self +pub fn Canvas::right_2_3(Self) -> Self +pub fn Canvas::right_2_4(Self) -> Self +pub fn Canvas::right_2_5(Self) -> Self +pub fn Canvas::right_2p5(Self) -> Self +pub fn Canvas::right_3(Self) -> Self +pub fn Canvas::right_32(Self) -> Self +pub fn Canvas::right_3_4(Self) -> Self +pub fn Canvas::right_3_5(Self) -> Self +pub fn Canvas::right_3p5(Self) -> Self +pub fn Canvas::right_4(Self) -> Self +pub fn Canvas::right_40(Self) -> Self +pub fn Canvas::right_48(Self) -> Self +pub fn Canvas::right_4_5(Self) -> Self +pub fn Canvas::right_5(Self) -> Self +pub fn Canvas::right_56(Self) -> Self +pub fn Canvas::right_5_6(Self) -> Self +pub fn Canvas::right_6(Self) -> Self +pub fn Canvas::right_64(Self) -> Self +pub fn Canvas::right_7(Self) -> Self +pub fn Canvas::right_72(Self) -> Self +pub fn Canvas::right_8(Self) -> Self +pub fn Canvas::right_80(Self) -> Self +pub fn Canvas::right_9(Self) -> Self +pub fn Canvas::right_96(Self) -> Self +pub fn Canvas::right_auto(Self) -> Self +pub fn Canvas::right_full(Self) -> Self +pub fn Canvas::right_neg_0(Self) -> Self +pub fn Canvas::right_neg_0p5(Self) -> Self +pub fn Canvas::right_neg_1(Self) -> Self +pub fn Canvas::right_neg_10(Self) -> Self +pub fn Canvas::right_neg_11(Self) -> Self +pub fn Canvas::right_neg_112(Self) -> Self +pub fn Canvas::right_neg_12(Self) -> Self +pub fn Canvas::right_neg_128(Self) -> Self +pub fn Canvas::right_neg_16(Self) -> Self +pub fn Canvas::right_neg_1_12(Self) -> Self +pub fn Canvas::right_neg_1_2(Self) -> Self +pub fn Canvas::right_neg_1_3(Self) -> Self +pub fn Canvas::right_neg_1_4(Self) -> Self +pub fn Canvas::right_neg_1_5(Self) -> Self +pub fn Canvas::right_neg_1_6(Self) -> Self +pub fn Canvas::right_neg_1p5(Self) -> Self +pub fn Canvas::right_neg_2(Self) -> Self +pub fn Canvas::right_neg_20(Self) -> Self +pub fn Canvas::right_neg_24(Self) -> Self +pub fn Canvas::right_neg_2_3(Self) -> Self +pub fn Canvas::right_neg_2_4(Self) -> Self +pub fn Canvas::right_neg_2_5(Self) -> Self +pub fn Canvas::right_neg_2p5(Self) -> Self +pub fn Canvas::right_neg_3(Self) -> Self +pub fn Canvas::right_neg_32(Self) -> Self +pub fn Canvas::right_neg_3_4(Self) -> Self +pub fn Canvas::right_neg_3_5(Self) -> Self +pub fn Canvas::right_neg_3p5(Self) -> Self +pub fn Canvas::right_neg_4(Self) -> Self +pub fn Canvas::right_neg_40(Self) -> Self +pub fn Canvas::right_neg_48(Self) -> Self +pub fn Canvas::right_neg_4_5(Self) -> Self +pub fn Canvas::right_neg_5(Self) -> Self +pub fn Canvas::right_neg_56(Self) -> Self +pub fn Canvas::right_neg_5_6(Self) -> Self +pub fn Canvas::right_neg_6(Self) -> Self +pub fn Canvas::right_neg_64(Self) -> Self +pub fn Canvas::right_neg_7(Self) -> Self +pub fn Canvas::right_neg_72(Self) -> Self +pub fn Canvas::right_neg_8(Self) -> Self +pub fn Canvas::right_neg_80(Self) -> Self +pub fn Canvas::right_neg_9(Self) -> Self +pub fn Canvas::right_neg_96(Self) -> Self +pub fn Canvas::right_neg_full(Self) -> Self +pub fn Canvas::right_neg_px(Self) -> Self +pub fn Canvas::right_px(Self) -> Self +pub fn Canvas::rounded(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::rounded_2xl(Self) -> Self +pub fn Canvas::rounded_3xl(Self) -> Self +pub fn Canvas::rounded_b(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::rounded_b_2xl(Self) -> Self +pub fn Canvas::rounded_b_3xl(Self) -> Self +pub fn Canvas::rounded_b_full(Self) -> Self +pub fn Canvas::rounded_b_lg(Self) -> Self +pub fn Canvas::rounded_b_md(Self) -> Self +pub fn Canvas::rounded_b_none(Self) -> Self +pub fn Canvas::rounded_b_sm(Self) -> Self +pub fn Canvas::rounded_b_xl(Self) -> Self +pub fn Canvas::rounded_b_xs(Self) -> Self +pub fn Canvas::rounded_bl(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::rounded_bl_2xl(Self) -> Self +pub fn Canvas::rounded_bl_3xl(Self) -> Self +pub fn Canvas::rounded_bl_full(Self) -> Self +pub fn Canvas::rounded_bl_lg(Self) -> Self +pub fn Canvas::rounded_bl_md(Self) -> Self +pub fn Canvas::rounded_bl_none(Self) -> Self +pub fn Canvas::rounded_bl_sm(Self) -> Self +pub fn Canvas::rounded_bl_xl(Self) -> Self +pub fn Canvas::rounded_bl_xs(Self) -> Self +pub fn Canvas::rounded_br(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::rounded_br_2xl(Self) -> Self +pub fn Canvas::rounded_br_3xl(Self) -> Self +pub fn Canvas::rounded_br_full(Self) -> Self +pub fn Canvas::rounded_br_lg(Self) -> Self +pub fn Canvas::rounded_br_md(Self) -> Self +pub fn Canvas::rounded_br_none(Self) -> Self +pub fn Canvas::rounded_br_sm(Self) -> Self +pub fn Canvas::rounded_br_xl(Self) -> Self +pub fn Canvas::rounded_br_xs(Self) -> Self +pub fn Canvas::rounded_full(Self) -> Self +pub fn Canvas::rounded_l(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::rounded_l_2xl(Self) -> Self +pub fn Canvas::rounded_l_3xl(Self) -> Self +pub fn Canvas::rounded_l_full(Self) -> Self +pub fn Canvas::rounded_l_lg(Self) -> Self +pub fn Canvas::rounded_l_md(Self) -> Self +pub fn Canvas::rounded_l_none(Self) -> Self +pub fn Canvas::rounded_l_sm(Self) -> Self +pub fn Canvas::rounded_l_xl(Self) -> Self +pub fn Canvas::rounded_l_xs(Self) -> Self +pub fn Canvas::rounded_lg(Self) -> Self +pub fn Canvas::rounded_md(Self) -> Self +pub fn Canvas::rounded_none(Self) -> Self +pub fn Canvas::rounded_r(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::rounded_r_2xl(Self) -> Self +pub fn Canvas::rounded_r_3xl(Self) -> Self +pub fn Canvas::rounded_r_full(Self) -> Self +pub fn Canvas::rounded_r_lg(Self) -> Self +pub fn Canvas::rounded_r_md(Self) -> Self +pub fn Canvas::rounded_r_none(Self) -> Self +pub fn Canvas::rounded_r_sm(Self) -> Self +pub fn Canvas::rounded_r_xl(Self) -> Self +pub fn Canvas::rounded_r_xs(Self) -> Self +pub fn Canvas::rounded_sm(Self) -> Self +pub fn Canvas::rounded_t(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::rounded_t_2xl(Self) -> Self +pub fn Canvas::rounded_t_3xl(Self) -> Self +pub fn Canvas::rounded_t_full(Self) -> Self +pub fn Canvas::rounded_t_lg(Self) -> Self +pub fn Canvas::rounded_t_md(Self) -> Self +pub fn Canvas::rounded_t_none(Self) -> Self +pub fn Canvas::rounded_t_sm(Self) -> Self +pub fn Canvas::rounded_t_xl(Self) -> Self +pub fn Canvas::rounded_t_xs(Self) -> Self +pub fn Canvas::rounded_tl(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::rounded_tl_2xl(Self) -> Self +pub fn Canvas::rounded_tl_3xl(Self) -> Self +pub fn Canvas::rounded_tl_full(Self) -> Self +pub fn Canvas::rounded_tl_lg(Self) -> Self +pub fn Canvas::rounded_tl_md(Self) -> Self +pub fn Canvas::rounded_tl_none(Self) -> Self +pub fn Canvas::rounded_tl_sm(Self) -> Self +pub fn Canvas::rounded_tl_xl(Self) -> Self +pub fn Canvas::rounded_tl_xs(Self) -> Self +pub fn Canvas::rounded_tr(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::rounded_tr_2xl(Self) -> Self +pub fn Canvas::rounded_tr_3xl(Self) -> Self +pub fn Canvas::rounded_tr_full(Self) -> Self +pub fn Canvas::rounded_tr_lg(Self) -> Self +pub fn Canvas::rounded_tr_md(Self) -> Self +pub fn Canvas::rounded_tr_none(Self) -> Self +pub fn Canvas::rounded_tr_sm(Self) -> Self +pub fn Canvas::rounded_tr_xl(Self) -> Self +pub fn Canvas::rounded_tr_xs(Self) -> Self +pub fn Canvas::rounded_xl(Self) -> Self +pub fn Canvas::rounded_xs(Self) -> Self +pub fn Canvas::row_end(Self, Int32) -> Self +pub fn Canvas::row_end_auto(Self) -> Self +pub fn Canvas::row_span(Self, Int32) -> Self +pub fn Canvas::row_span_full(Self) -> Self +pub fn Canvas::row_start(Self, Int32) -> Self +pub fn Canvas::row_start_auto(Self) -> Self +pub fn Canvas::scrollbar_width(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::self_baseline(Self) -> Self +pub fn Canvas::self_center(Self) -> Self +pub fn Canvas::self_end(Self) -> Self +pub fn Canvas::self_flex_end(Self) -> Self +pub fn Canvas::self_flex_start(Self) -> Self +pub fn Canvas::self_start(Self) -> Self +pub fn Canvas::self_stretch(Self) -> Self +pub fn Canvas::shadow(Self, Array[@style.BoxShadow]) -> Self +pub fn Canvas::shadow_2xl(Self) -> Self +pub fn Canvas::shadow_2xs(Self) -> Self +pub fn Canvas::shadow_lg(Self) -> Self +pub fn Canvas::shadow_md(Self) -> Self +pub fn Canvas::shadow_none(Self) -> Self +pub fn Canvas::shadow_sm(Self) -> Self +pub fn Canvas::shadow_xl(Self) -> Self +pub fn Canvas::shadow_xs(Self) -> Self +pub fn Canvas::size(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::size_0(Self) -> Self +pub fn Canvas::size_0p5(Self) -> Self +pub fn Canvas::size_1(Self) -> Self +pub fn Canvas::size_10(Self) -> Self +pub fn Canvas::size_11(Self) -> Self +pub fn Canvas::size_112(Self) -> Self +pub fn Canvas::size_12(Self) -> Self +pub fn Canvas::size_128(Self) -> Self +pub fn Canvas::size_16(Self) -> Self +pub fn Canvas::size_1_12(Self) -> Self +pub fn Canvas::size_1_2(Self) -> Self +pub fn Canvas::size_1_3(Self) -> Self +pub fn Canvas::size_1_4(Self) -> Self +pub fn Canvas::size_1_5(Self) -> Self +pub fn Canvas::size_1_6(Self) -> Self +pub fn Canvas::size_1p5(Self) -> Self +pub fn Canvas::size_2(Self) -> Self +pub fn Canvas::size_20(Self) -> Self +pub fn Canvas::size_24(Self) -> Self +pub fn Canvas::size_2_3(Self) -> Self +pub fn Canvas::size_2_4(Self) -> Self +pub fn Canvas::size_2_5(Self) -> Self +pub fn Canvas::size_2p5(Self) -> Self +pub fn Canvas::size_3(Self) -> Self +pub fn Canvas::size_32(Self) -> Self +pub fn Canvas::size_3_4(Self) -> Self +pub fn Canvas::size_3_5(Self) -> Self +pub fn Canvas::size_3p5(Self) -> Self +pub fn Canvas::size_4(Self) -> Self +pub fn Canvas::size_40(Self) -> Self +pub fn Canvas::size_48(Self) -> Self +pub fn Canvas::size_4_5(Self) -> Self +pub fn Canvas::size_5(Self) -> Self +pub fn Canvas::size_56(Self) -> Self +pub fn Canvas::size_5_6(Self) -> Self +pub fn Canvas::size_6(Self) -> Self +pub fn Canvas::size_64(Self) -> Self +pub fn Canvas::size_7(Self) -> Self +pub fn Canvas::size_72(Self) -> Self +pub fn Canvas::size_8(Self) -> Self +pub fn Canvas::size_80(Self) -> Self +pub fn Canvas::size_9(Self) -> Self +pub fn Canvas::size_96(Self) -> Self +pub fn Canvas::size_auto(Self) -> Self +pub fn Canvas::size_full(Self) -> Self +pub fn Canvas::size_neg_0(Self) -> Self +pub fn Canvas::size_neg_0p5(Self) -> Self +pub fn Canvas::size_neg_1(Self) -> Self +pub fn Canvas::size_neg_10(Self) -> Self +pub fn Canvas::size_neg_11(Self) -> Self +pub fn Canvas::size_neg_112(Self) -> Self +pub fn Canvas::size_neg_12(Self) -> Self +pub fn Canvas::size_neg_128(Self) -> Self +pub fn Canvas::size_neg_16(Self) -> Self +pub fn Canvas::size_neg_1_12(Self) -> Self +pub fn Canvas::size_neg_1_2(Self) -> Self +pub fn Canvas::size_neg_1_3(Self) -> Self +pub fn Canvas::size_neg_1_4(Self) -> Self +pub fn Canvas::size_neg_1_5(Self) -> Self +pub fn Canvas::size_neg_1_6(Self) -> Self +pub fn Canvas::size_neg_1p5(Self) -> Self +pub fn Canvas::size_neg_2(Self) -> Self +pub fn Canvas::size_neg_20(Self) -> Self +pub fn Canvas::size_neg_24(Self) -> Self +pub fn Canvas::size_neg_2_3(Self) -> Self +pub fn Canvas::size_neg_2_4(Self) -> Self +pub fn Canvas::size_neg_2_5(Self) -> Self +pub fn Canvas::size_neg_2p5(Self) -> Self +pub fn Canvas::size_neg_3(Self) -> Self +pub fn Canvas::size_neg_32(Self) -> Self +pub fn Canvas::size_neg_3_4(Self) -> Self +pub fn Canvas::size_neg_3_5(Self) -> Self +pub fn Canvas::size_neg_3p5(Self) -> Self +pub fn Canvas::size_neg_4(Self) -> Self +pub fn Canvas::size_neg_40(Self) -> Self +pub fn Canvas::size_neg_48(Self) -> Self +pub fn Canvas::size_neg_4_5(Self) -> Self +pub fn Canvas::size_neg_5(Self) -> Self +pub fn Canvas::size_neg_56(Self) -> Self +pub fn Canvas::size_neg_5_6(Self) -> Self +pub fn Canvas::size_neg_6(Self) -> Self +pub fn Canvas::size_neg_64(Self) -> Self +pub fn Canvas::size_neg_7(Self) -> Self +pub fn Canvas::size_neg_72(Self) -> Self +pub fn Canvas::size_neg_8(Self) -> Self +pub fn Canvas::size_neg_80(Self) -> Self +pub fn Canvas::size_neg_9(Self) -> Self +pub fn Canvas::size_neg_96(Self) -> Self +pub fn Canvas::size_neg_full(Self) -> Self +pub fn Canvas::size_neg_px(Self) -> Self +pub fn Canvas::size_px(Self) -> Self +pub fn Canvas::text_2xl(Self) -> Self +pub fn Canvas::text_3xl(Self) -> Self +pub fn Canvas::text_align(Self, @style.TextAlign) -> Self +pub fn Canvas::text_base(Self) -> Self +pub fn Canvas::text_bg(Self, &@color.IntoHsla) -> Self +pub fn Canvas::text_center(Self) -> Self +pub fn Canvas::text_color(Self, &@color.IntoHsla) -> Self +pub fn Canvas::text_decoration_0(Self) -> Self +pub fn Canvas::text_decoration_1(Self) -> Self +pub fn Canvas::text_decoration_2(Self) -> Self +pub fn Canvas::text_decoration_4(Self) -> Self +pub fn Canvas::text_decoration_8(Self) -> Self +pub fn Canvas::text_decoration_color(Self, &@color.IntoHsla) -> Self +pub fn Canvas::text_decoration_none(Self) -> Self +pub fn Canvas::text_decoration_solid(Self) -> Self +pub fn Canvas::text_decoration_wavy(Self) -> Self +pub fn Canvas::text_ellipsis(Self) -> Self +pub fn Canvas::text_ellipsis_middle(Self) -> Self +pub fn Canvas::text_ellipsis_start(Self) -> Self +pub fn Canvas::text_left(Self) -> Self +pub fn Canvas::text_lg(Self) -> Self +pub fn Canvas::text_overflow(Self, @style.TextOverflow) -> Self +pub fn Canvas::text_right(Self) -> Self +pub fn Canvas::text_size(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Canvas::text_sm(Self) -> Self +pub fn Canvas::text_xl(Self) -> Self +pub fn Canvas::text_xs(Self) -> Self +pub fn Canvas::top(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::top_0(Self) -> Self +pub fn Canvas::top_0p5(Self) -> Self +pub fn Canvas::top_1(Self) -> Self +pub fn Canvas::top_10(Self) -> Self +pub fn Canvas::top_11(Self) -> Self +pub fn Canvas::top_112(Self) -> Self +pub fn Canvas::top_12(Self) -> Self +pub fn Canvas::top_128(Self) -> Self +pub fn Canvas::top_16(Self) -> Self +pub fn Canvas::top_1_12(Self) -> Self +pub fn Canvas::top_1_2(Self) -> Self +pub fn Canvas::top_1_3(Self) -> Self +pub fn Canvas::top_1_4(Self) -> Self +pub fn Canvas::top_1_5(Self) -> Self +pub fn Canvas::top_1_6(Self) -> Self +pub fn Canvas::top_1p5(Self) -> Self +pub fn Canvas::top_2(Self) -> Self +pub fn Canvas::top_20(Self) -> Self +pub fn Canvas::top_24(Self) -> Self +pub fn Canvas::top_2_3(Self) -> Self +pub fn Canvas::top_2_4(Self) -> Self +pub fn Canvas::top_2_5(Self) -> Self +pub fn Canvas::top_2p5(Self) -> Self +pub fn Canvas::top_3(Self) -> Self +pub fn Canvas::top_32(Self) -> Self +pub fn Canvas::top_3_4(Self) -> Self +pub fn Canvas::top_3_5(Self) -> Self +pub fn Canvas::top_3p5(Self) -> Self +pub fn Canvas::top_4(Self) -> Self +pub fn Canvas::top_40(Self) -> Self +pub fn Canvas::top_48(Self) -> Self +pub fn Canvas::top_4_5(Self) -> Self +pub fn Canvas::top_5(Self) -> Self +pub fn Canvas::top_56(Self) -> Self +pub fn Canvas::top_5_6(Self) -> Self +pub fn Canvas::top_6(Self) -> Self +pub fn Canvas::top_64(Self) -> Self +pub fn Canvas::top_7(Self) -> Self +pub fn Canvas::top_72(Self) -> Self +pub fn Canvas::top_8(Self) -> Self +pub fn Canvas::top_80(Self) -> Self +pub fn Canvas::top_9(Self) -> Self +pub fn Canvas::top_96(Self) -> Self +pub fn Canvas::top_auto(Self) -> Self +pub fn Canvas::top_full(Self) -> Self +pub fn Canvas::top_neg_0(Self) -> Self +pub fn Canvas::top_neg_0p5(Self) -> Self +pub fn Canvas::top_neg_1(Self) -> Self +pub fn Canvas::top_neg_10(Self) -> Self +pub fn Canvas::top_neg_11(Self) -> Self +pub fn Canvas::top_neg_112(Self) -> Self +pub fn Canvas::top_neg_12(Self) -> Self +pub fn Canvas::top_neg_128(Self) -> Self +pub fn Canvas::top_neg_16(Self) -> Self +pub fn Canvas::top_neg_1_12(Self) -> Self +pub fn Canvas::top_neg_1_2(Self) -> Self +pub fn Canvas::top_neg_1_3(Self) -> Self +pub fn Canvas::top_neg_1_4(Self) -> Self +pub fn Canvas::top_neg_1_5(Self) -> Self +pub fn Canvas::top_neg_1_6(Self) -> Self +pub fn Canvas::top_neg_1p5(Self) -> Self +pub fn Canvas::top_neg_2(Self) -> Self +pub fn Canvas::top_neg_20(Self) -> Self +pub fn Canvas::top_neg_24(Self) -> Self +pub fn Canvas::top_neg_2_3(Self) -> Self +pub fn Canvas::top_neg_2_4(Self) -> Self +pub fn Canvas::top_neg_2_5(Self) -> Self +pub fn Canvas::top_neg_2p5(Self) -> Self +pub fn Canvas::top_neg_3(Self) -> Self +pub fn Canvas::top_neg_32(Self) -> Self +pub fn Canvas::top_neg_3_4(Self) -> Self +pub fn Canvas::top_neg_3_5(Self) -> Self +pub fn Canvas::top_neg_3p5(Self) -> Self +pub fn Canvas::top_neg_4(Self) -> Self +pub fn Canvas::top_neg_40(Self) -> Self +pub fn Canvas::top_neg_48(Self) -> Self +pub fn Canvas::top_neg_4_5(Self) -> Self +pub fn Canvas::top_neg_5(Self) -> Self +pub fn Canvas::top_neg_56(Self) -> Self +pub fn Canvas::top_neg_5_6(Self) -> Self +pub fn Canvas::top_neg_6(Self) -> Self +pub fn Canvas::top_neg_64(Self) -> Self +pub fn Canvas::top_neg_7(Self) -> Self +pub fn Canvas::top_neg_72(Self) -> Self +pub fn Canvas::top_neg_8(Self) -> Self +pub fn Canvas::top_neg_80(Self) -> Self +pub fn Canvas::top_neg_9(Self) -> Self +pub fn Canvas::top_neg_96(Self) -> Self +pub fn Canvas::top_neg_full(Self) -> Self +pub fn Canvas::top_neg_px(Self) -> Self +pub fn Canvas::top_px(Self) -> Self +pub fn Canvas::truncate(Self) -> Self +pub fn Canvas::underline(Self) -> Self +pub fn Canvas::visible(Self) -> Self +pub fn Canvas::w(Self, &@geometry.IntoLength) -> Self +pub fn Canvas::w_0(Self) -> Self +pub fn Canvas::w_0p5(Self) -> Self +pub fn Canvas::w_1(Self) -> Self +pub fn Canvas::w_10(Self) -> Self +pub fn Canvas::w_11(Self) -> Self +pub fn Canvas::w_112(Self) -> Self +pub fn Canvas::w_12(Self) -> Self +pub fn Canvas::w_128(Self) -> Self +pub fn Canvas::w_16(Self) -> Self +pub fn Canvas::w_1_12(Self) -> Self +pub fn Canvas::w_1_2(Self) -> Self +pub fn Canvas::w_1_3(Self) -> Self +pub fn Canvas::w_1_4(Self) -> Self +pub fn Canvas::w_1_5(Self) -> Self +pub fn Canvas::w_1_6(Self) -> Self +pub fn Canvas::w_1p5(Self) -> Self +pub fn Canvas::w_2(Self) -> Self +pub fn Canvas::w_20(Self) -> Self +pub fn Canvas::w_24(Self) -> Self +pub fn Canvas::w_2_3(Self) -> Self +pub fn Canvas::w_2_4(Self) -> Self +pub fn Canvas::w_2_5(Self) -> Self +pub fn Canvas::w_2p5(Self) -> Self +pub fn Canvas::w_3(Self) -> Self +pub fn Canvas::w_32(Self) -> Self +pub fn Canvas::w_3_4(Self) -> Self +pub fn Canvas::w_3_5(Self) -> Self +pub fn Canvas::w_3p5(Self) -> Self +pub fn Canvas::w_4(Self) -> Self +pub fn Canvas::w_40(Self) -> Self +pub fn Canvas::w_48(Self) -> Self +pub fn Canvas::w_4_5(Self) -> Self +pub fn Canvas::w_5(Self) -> Self +pub fn Canvas::w_56(Self) -> Self +pub fn Canvas::w_5_6(Self) -> Self +pub fn Canvas::w_6(Self) -> Self +pub fn Canvas::w_64(Self) -> Self +pub fn Canvas::w_7(Self) -> Self +pub fn Canvas::w_72(Self) -> Self +pub fn Canvas::w_8(Self) -> Self +pub fn Canvas::w_80(Self) -> Self +pub fn Canvas::w_9(Self) -> Self +pub fn Canvas::w_96(Self) -> Self +pub fn Canvas::w_auto(Self) -> Self +pub fn Canvas::w_full(Self) -> Self +pub fn Canvas::w_neg_0(Self) -> Self +pub fn Canvas::w_neg_0p5(Self) -> Self +pub fn Canvas::w_neg_1(Self) -> Self +pub fn Canvas::w_neg_10(Self) -> Self +pub fn Canvas::w_neg_11(Self) -> Self +pub fn Canvas::w_neg_112(Self) -> Self +pub fn Canvas::w_neg_12(Self) -> Self +pub fn Canvas::w_neg_128(Self) -> Self +pub fn Canvas::w_neg_16(Self) -> Self +pub fn Canvas::w_neg_1_12(Self) -> Self +pub fn Canvas::w_neg_1_2(Self) -> Self +pub fn Canvas::w_neg_1_3(Self) -> Self +pub fn Canvas::w_neg_1_4(Self) -> Self +pub fn Canvas::w_neg_1_5(Self) -> Self +pub fn Canvas::w_neg_1_6(Self) -> Self +pub fn Canvas::w_neg_1p5(Self) -> Self +pub fn Canvas::w_neg_2(Self) -> Self +pub fn Canvas::w_neg_20(Self) -> Self +pub fn Canvas::w_neg_24(Self) -> Self +pub fn Canvas::w_neg_2_3(Self) -> Self +pub fn Canvas::w_neg_2_4(Self) -> Self +pub fn Canvas::w_neg_2_5(Self) -> Self +pub fn Canvas::w_neg_2p5(Self) -> Self +pub fn Canvas::w_neg_3(Self) -> Self +pub fn Canvas::w_neg_32(Self) -> Self +pub fn Canvas::w_neg_3_4(Self) -> Self +pub fn Canvas::w_neg_3_5(Self) -> Self +pub fn Canvas::w_neg_3p5(Self) -> Self +pub fn Canvas::w_neg_4(Self) -> Self +pub fn Canvas::w_neg_40(Self) -> Self +pub fn Canvas::w_neg_48(Self) -> Self +pub fn Canvas::w_neg_4_5(Self) -> Self +pub fn Canvas::w_neg_5(Self) -> Self +pub fn Canvas::w_neg_56(Self) -> Self +pub fn Canvas::w_neg_5_6(Self) -> Self +pub fn Canvas::w_neg_6(Self) -> Self +pub fn Canvas::w_neg_64(Self) -> Self +pub fn Canvas::w_neg_7(Self) -> Self +pub fn Canvas::w_neg_72(Self) -> Self +pub fn Canvas::w_neg_8(Self) -> Self +pub fn Canvas::w_neg_80(Self) -> Self +pub fn Canvas::w_neg_9(Self) -> Self +pub fn Canvas::w_neg_96(Self) -> Self +pub fn Canvas::w_neg_full(Self) -> Self +pub fn Canvas::w_neg_px(Self) -> Self +pub fn Canvas::w_px(Self) -> Self +pub fn Canvas::whitespace_normal(Self) -> Self +pub fn Canvas::whitespace_nowrap(Self) -> Self +pub impl @style.Styled for Canvas +pub impl @window.IntoElement for Canvas + +pub struct Div { + // private fields +} +pub fn Div::absolute(Self) -> Self +pub fn Div::aspect_ratio(Self, Double) -> Self +pub fn Div::aspect_square(Self) -> Self +pub fn Div::bg(Self, &@style.IntoFill) -> Self +pub fn Div::block(Self) -> Self +pub fn Div::border(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::border_0(Self) -> Self +pub fn Div::border_1(Self) -> Self +pub fn Div::border_10(Self) -> Self +pub fn Div::border_11(Self) -> Self +pub fn Div::border_12(Self) -> Self +pub fn Div::border_16(Self) -> Self +pub fn Div::border_2(Self) -> Self +pub fn Div::border_20(Self) -> Self +pub fn Div::border_24(Self) -> Self +pub fn Div::border_3(Self) -> Self +pub fn Div::border_32(Self) -> Self +pub fn Div::border_4(Self) -> Self +pub fn Div::border_5(Self) -> Self +pub fn Div::border_6(Self) -> Self +pub fn Div::border_7(Self) -> Self +pub fn Div::border_8(Self) -> Self +pub fn Div::border_9(Self) -> Self +pub fn Div::border_b(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::border_b_0(Self) -> Self +pub fn Div::border_b_1(Self) -> Self +pub fn Div::border_b_10(Self) -> Self +pub fn Div::border_b_11(Self) -> Self +pub fn Div::border_b_12(Self) -> Self +pub fn Div::border_b_16(Self) -> Self +pub fn Div::border_b_2(Self) -> Self +pub fn Div::border_b_20(Self) -> Self +pub fn Div::border_b_24(Self) -> Self +pub fn Div::border_b_3(Self) -> Self +pub fn Div::border_b_32(Self) -> Self +pub fn Div::border_b_4(Self) -> Self +pub fn Div::border_b_5(Self) -> Self +pub fn Div::border_b_6(Self) -> Self +pub fn Div::border_b_7(Self) -> Self +pub fn Div::border_b_8(Self) -> Self +pub fn Div::border_b_9(Self) -> Self +pub fn Div::border_color(Self, &@color.IntoHsla) -> Self +pub fn Div::border_dashed(Self) -> Self +pub fn Div::border_l(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::border_l_0(Self) -> Self +pub fn Div::border_l_1(Self) -> Self +pub fn Div::border_l_10(Self) -> Self +pub fn Div::border_l_11(Self) -> Self +pub fn Div::border_l_12(Self) -> Self +pub fn Div::border_l_16(Self) -> Self +pub fn Div::border_l_2(Self) -> Self +pub fn Div::border_l_20(Self) -> Self +pub fn Div::border_l_24(Self) -> Self +pub fn Div::border_l_3(Self) -> Self +pub fn Div::border_l_32(Self) -> Self +pub fn Div::border_l_4(Self) -> Self +pub fn Div::border_l_5(Self) -> Self +pub fn Div::border_l_6(Self) -> Self +pub fn Div::border_l_7(Self) -> Self +pub fn Div::border_l_8(Self) -> Self +pub fn Div::border_l_9(Self) -> Self +pub fn Div::border_r(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::border_r_0(Self) -> Self +pub fn Div::border_r_1(Self) -> Self +pub fn Div::border_r_10(Self) -> Self +pub fn Div::border_r_11(Self) -> Self +pub fn Div::border_r_12(Self) -> Self +pub fn Div::border_r_16(Self) -> Self +pub fn Div::border_r_2(Self) -> Self +pub fn Div::border_r_20(Self) -> Self +pub fn Div::border_r_24(Self) -> Self +pub fn Div::border_r_3(Self) -> Self +pub fn Div::border_r_32(Self) -> Self +pub fn Div::border_r_4(Self) -> Self +pub fn Div::border_r_5(Self) -> Self +pub fn Div::border_r_6(Self) -> Self +pub fn Div::border_r_7(Self) -> Self +pub fn Div::border_r_8(Self) -> Self +pub fn Div::border_r_9(Self) -> Self +pub fn Div::border_t(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::border_t_0(Self) -> Self +pub fn Div::border_t_1(Self) -> Self +pub fn Div::border_t_10(Self) -> Self +pub fn Div::border_t_11(Self) -> Self +pub fn Div::border_t_12(Self) -> Self +pub fn Div::border_t_16(Self) -> Self +pub fn Div::border_t_2(Self) -> Self +pub fn Div::border_t_20(Self) -> Self +pub fn Div::border_t_24(Self) -> Self +pub fn Div::border_t_3(Self) -> Self +pub fn Div::border_t_32(Self) -> Self +pub fn Div::border_t_4(Self) -> Self +pub fn Div::border_t_5(Self) -> Self +pub fn Div::border_t_6(Self) -> Self +pub fn Div::border_t_7(Self) -> Self +pub fn Div::border_t_8(Self) -> Self +pub fn Div::border_t_9(Self) -> Self +pub fn Div::border_x(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::border_x_0(Self) -> Self +pub fn Div::border_x_1(Self) -> Self +pub fn Div::border_x_10(Self) -> Self +pub fn Div::border_x_11(Self) -> Self +pub fn Div::border_x_12(Self) -> Self +pub fn Div::border_x_16(Self) -> Self +pub fn Div::border_x_2(Self) -> Self +pub fn Div::border_x_20(Self) -> Self +pub fn Div::border_x_24(Self) -> Self +pub fn Div::border_x_3(Self) -> Self +pub fn Div::border_x_32(Self) -> Self +pub fn Div::border_x_4(Self) -> Self +pub fn Div::border_x_5(Self) -> Self +pub fn Div::border_x_6(Self) -> Self +pub fn Div::border_x_7(Self) -> Self +pub fn Div::border_x_8(Self) -> Self +pub fn Div::border_x_9(Self) -> Self +pub fn Div::border_y(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::border_y_0(Self) -> Self +pub fn Div::border_y_1(Self) -> Self +pub fn Div::border_y_10(Self) -> Self +pub fn Div::border_y_11(Self) -> Self +pub fn Div::border_y_12(Self) -> Self +pub fn Div::border_y_16(Self) -> Self +pub fn Div::border_y_2(Self) -> Self +pub fn Div::border_y_20(Self) -> Self +pub fn Div::border_y_24(Self) -> Self +pub fn Div::border_y_3(Self) -> Self +pub fn Div::border_y_32(Self) -> Self +pub fn Div::border_y_4(Self) -> Self +pub fn Div::border_y_5(Self) -> Self +pub fn Div::border_y_6(Self) -> Self +pub fn Div::border_y_7(Self) -> Self +pub fn Div::border_y_8(Self) -> Self +pub fn Div::border_y_9(Self) -> Self +pub fn Div::bottom(Self, &@geometry.IntoLength) -> Self +pub fn Div::bottom_0(Self) -> Self +pub fn Div::bottom_0p5(Self) -> Self +pub fn Div::bottom_1(Self) -> Self +pub fn Div::bottom_10(Self) -> Self +pub fn Div::bottom_11(Self) -> Self +pub fn Div::bottom_112(Self) -> Self +pub fn Div::bottom_12(Self) -> Self +pub fn Div::bottom_128(Self) -> Self +pub fn Div::bottom_16(Self) -> Self +pub fn Div::bottom_1_12(Self) -> Self +pub fn Div::bottom_1_2(Self) -> Self +pub fn Div::bottom_1_3(Self) -> Self +pub fn Div::bottom_1_4(Self) -> Self +pub fn Div::bottom_1_5(Self) -> Self +pub fn Div::bottom_1_6(Self) -> Self +pub fn Div::bottom_1p5(Self) -> Self +pub fn Div::bottom_2(Self) -> Self +pub fn Div::bottom_20(Self) -> Self +pub fn Div::bottom_24(Self) -> Self +pub fn Div::bottom_2_3(Self) -> Self +pub fn Div::bottom_2_4(Self) -> Self +pub fn Div::bottom_2_5(Self) -> Self +pub fn Div::bottom_2p5(Self) -> Self +pub fn Div::bottom_3(Self) -> Self +pub fn Div::bottom_32(Self) -> Self +pub fn Div::bottom_3_4(Self) -> Self +pub fn Div::bottom_3_5(Self) -> Self +pub fn Div::bottom_3p5(Self) -> Self +pub fn Div::bottom_4(Self) -> Self +pub fn Div::bottom_40(Self) -> Self +pub fn Div::bottom_48(Self) -> Self +pub fn Div::bottom_4_5(Self) -> Self +pub fn Div::bottom_5(Self) -> Self +pub fn Div::bottom_56(Self) -> Self +pub fn Div::bottom_5_6(Self) -> Self +pub fn Div::bottom_6(Self) -> Self +pub fn Div::bottom_64(Self) -> Self +pub fn Div::bottom_7(Self) -> Self +pub fn Div::bottom_72(Self) -> Self +pub fn Div::bottom_8(Self) -> Self +pub fn Div::bottom_80(Self) -> Self +pub fn Div::bottom_9(Self) -> Self +pub fn Div::bottom_96(Self) -> Self +pub fn Div::bottom_auto(Self) -> Self +pub fn Div::bottom_full(Self) -> Self +pub fn Div::bottom_neg_0(Self) -> Self +pub fn Div::bottom_neg_0p5(Self) -> Self +pub fn Div::bottom_neg_1(Self) -> Self +pub fn Div::bottom_neg_10(Self) -> Self +pub fn Div::bottom_neg_11(Self) -> Self +pub fn Div::bottom_neg_112(Self) -> Self +pub fn Div::bottom_neg_12(Self) -> Self +pub fn Div::bottom_neg_128(Self) -> Self +pub fn Div::bottom_neg_16(Self) -> Self +pub fn Div::bottom_neg_1_12(Self) -> Self +pub fn Div::bottom_neg_1_2(Self) -> Self +pub fn Div::bottom_neg_1_3(Self) -> Self +pub fn Div::bottom_neg_1_4(Self) -> Self +pub fn Div::bottom_neg_1_5(Self) -> Self +pub fn Div::bottom_neg_1_6(Self) -> Self +pub fn Div::bottom_neg_1p5(Self) -> Self +pub fn Div::bottom_neg_2(Self) -> Self +pub fn Div::bottom_neg_20(Self) -> Self +pub fn Div::bottom_neg_24(Self) -> Self +pub fn Div::bottom_neg_2_3(Self) -> Self +pub fn Div::bottom_neg_2_4(Self) -> Self +pub fn Div::bottom_neg_2_5(Self) -> Self +pub fn Div::bottom_neg_2p5(Self) -> Self +pub fn Div::bottom_neg_3(Self) -> Self +pub fn Div::bottom_neg_32(Self) -> Self +pub fn Div::bottom_neg_3_4(Self) -> Self +pub fn Div::bottom_neg_3_5(Self) -> Self +pub fn Div::bottom_neg_3p5(Self) -> Self +pub fn Div::bottom_neg_4(Self) -> Self +pub fn Div::bottom_neg_40(Self) -> Self +pub fn Div::bottom_neg_48(Self) -> Self +pub fn Div::bottom_neg_4_5(Self) -> Self +pub fn Div::bottom_neg_5(Self) -> Self +pub fn Div::bottom_neg_56(Self) -> Self +pub fn Div::bottom_neg_5_6(Self) -> Self +pub fn Div::bottom_neg_6(Self) -> Self +pub fn Div::bottom_neg_64(Self) -> Self +pub fn Div::bottom_neg_7(Self) -> Self +pub fn Div::bottom_neg_72(Self) -> Self +pub fn Div::bottom_neg_8(Self) -> Self +pub fn Div::bottom_neg_80(Self) -> Self +pub fn Div::bottom_neg_9(Self) -> Self +pub fn Div::bottom_neg_96(Self) -> Self +pub fn Div::bottom_neg_full(Self) -> Self +pub fn Div::bottom_neg_px(Self) -> Self +pub fn Div::bottom_px(Self) -> Self +pub fn[E : @window.IntoElement] Div::child(Self, E) -> Self +pub fn[E : @window.IntoElement] Div::children(Self, Array[E]) -> Self +pub fn Div::col_end(Self, Int32) -> Self +pub fn Div::col_end_auto(Self) -> Self +pub fn Div::col_span(Self, Int32) -> Self +pub fn Div::col_span_full(Self) -> Self +pub fn Div::col_start(Self, Int32) -> Self +pub fn Div::col_start_auto(Self) -> Self +pub fn Div::content_around(Self) -> Self +pub fn Div::content_between(Self) -> Self +pub fn Div::content_center(Self) -> Self +pub fn Div::content_end(Self) -> Self +pub fn Div::content_evenly(Self) -> Self +pub fn Div::content_normal(Self) -> Self +pub fn Div::content_start(Self) -> Self +pub fn Div::content_stretch(Self) -> Self +pub fn Div::cursor(Self, @style.CursorStyle) -> Self +pub fn Div::cursor_alias(Self) -> Self +pub fn Div::cursor_col_resize(Self) -> Self +pub fn Div::cursor_context_menu(Self) -> Self +pub fn Div::cursor_copy(Self) -> Self +pub fn Div::cursor_crosshair(Self) -> Self +pub fn Div::cursor_default(Self) -> Self +pub fn Div::cursor_e_resize(Self) -> Self +pub fn Div::cursor_ew_resize(Self) -> Self +pub fn Div::cursor_grab(Self) -> Self +pub fn Div::cursor_grabbing(Self) -> Self +pub fn Div::cursor_move(Self) -> Self +pub fn Div::cursor_n_resize(Self) -> Self +pub fn Div::cursor_nesw_resize(Self) -> Self +pub fn Div::cursor_no_drop(Self) -> Self +pub fn Div::cursor_not_allowed(Self) -> Self +pub fn Div::cursor_ns_resize(Self) -> Self +pub fn Div::cursor_nwse_resize(Self) -> Self +pub fn Div::cursor_pointer(Self) -> Self +pub fn Div::cursor_row_resize(Self) -> Self +pub fn Div::cursor_s_resize(Self) -> Self +pub fn Div::cursor_text(Self) -> Self +pub fn Div::cursor_vertical_text(Self) -> Self +pub fn Div::cursor_w_resize(Self) -> Self +pub fn Div::debug(Self) -> Self +pub fn Div::debug_below(Self) -> Self +pub fn Div::flex(Self) -> Self +pub fn Div::flex_1(Self) -> Self +pub fn Div::flex_auto(Self) -> Self +pub fn Div::flex_basis(Self, &@geometry.IntoLength) -> Self +pub fn Div::flex_col(Self) -> Self +pub fn Div::flex_col_reverse(Self) -> Self +pub fn Div::flex_grow(Self, Double) -> Self +pub fn Div::flex_grow_0(Self) -> Self +pub fn Div::flex_grow_1(Self) -> Self +pub fn Div::flex_initial(Self) -> Self +pub fn Div::flex_none(Self) -> Self +pub fn Div::flex_nowrap(Self) -> Self +pub fn Div::flex_row(Self) -> Self +pub fn Div::flex_row_reverse(Self) -> Self +pub fn Div::flex_shrink(Self, Double) -> Self +pub fn Div::flex_shrink_0(Self) -> Self +pub fn Div::flex_shrink_1(Self) -> Self +pub fn Div::flex_wrap(Self) -> Self +pub fn Div::flex_wrap_reverse(Self) -> Self +pub fn Div::font(Self, @font.Font) -> Self +pub fn Div::font_family(Self, String) -> Self +pub fn Div::font_features(Self, @font.FontFeatures) -> Self +pub fn Div::font_weight(Self, @font.FontWeight) -> Self +pub fn Div::gap(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Div::gap_0(Self) -> Self +pub fn Div::gap_0p5(Self) -> Self +pub fn Div::gap_1(Self) -> Self +pub fn Div::gap_10(Self) -> Self +pub fn Div::gap_11(Self) -> Self +pub fn Div::gap_112(Self) -> Self +pub fn Div::gap_12(Self) -> Self +pub fn Div::gap_128(Self) -> Self +pub fn Div::gap_16(Self) -> Self +pub fn Div::gap_1_12(Self) -> Self +pub fn Div::gap_1_2(Self) -> Self +pub fn Div::gap_1_3(Self) -> Self +pub fn Div::gap_1_4(Self) -> Self +pub fn Div::gap_1_5(Self) -> Self +pub fn Div::gap_1_6(Self) -> Self +pub fn Div::gap_1p5(Self) -> Self +pub fn Div::gap_2(Self) -> Self +pub fn Div::gap_20(Self) -> Self +pub fn Div::gap_24(Self) -> Self +pub fn Div::gap_2_3(Self) -> Self +pub fn Div::gap_2_4(Self) -> Self +pub fn Div::gap_2_5(Self) -> Self +pub fn Div::gap_2p5(Self) -> Self +pub fn Div::gap_3(Self) -> Self +pub fn Div::gap_32(Self) -> Self +pub fn Div::gap_3_4(Self) -> Self +pub fn Div::gap_3_5(Self) -> Self +pub fn Div::gap_3p5(Self) -> Self +pub fn Div::gap_4(Self) -> Self +pub fn Div::gap_40(Self) -> Self +pub fn Div::gap_48(Self) -> Self +pub fn Div::gap_4_5(Self) -> Self +pub fn Div::gap_5(Self) -> Self +pub fn Div::gap_56(Self) -> Self +pub fn Div::gap_5_6(Self) -> Self +pub fn Div::gap_6(Self) -> Self +pub fn Div::gap_64(Self) -> Self +pub fn Div::gap_7(Self) -> Self +pub fn Div::gap_72(Self) -> Self +pub fn Div::gap_8(Self) -> Self +pub fn Div::gap_80(Self) -> Self +pub fn Div::gap_9(Self) -> Self +pub fn Div::gap_96(Self) -> Self +pub fn Div::gap_full(Self) -> Self +pub fn Div::gap_neg_0(Self) -> Self +pub fn Div::gap_neg_0p5(Self) -> Self +pub fn Div::gap_neg_1(Self) -> Self +pub fn Div::gap_neg_10(Self) -> Self +pub fn Div::gap_neg_11(Self) -> Self +pub fn Div::gap_neg_112(Self) -> Self +pub fn Div::gap_neg_12(Self) -> Self +pub fn Div::gap_neg_128(Self) -> Self +pub fn Div::gap_neg_16(Self) -> Self +pub fn Div::gap_neg_1_12(Self) -> Self +pub fn Div::gap_neg_1_2(Self) -> Self +pub fn Div::gap_neg_1_3(Self) -> Self +pub fn Div::gap_neg_1_4(Self) -> Self +pub fn Div::gap_neg_1_5(Self) -> Self +pub fn Div::gap_neg_1_6(Self) -> Self +pub fn Div::gap_neg_1p5(Self) -> Self +pub fn Div::gap_neg_2(Self) -> Self +pub fn Div::gap_neg_20(Self) -> Self +pub fn Div::gap_neg_24(Self) -> Self +pub fn Div::gap_neg_2_3(Self) -> Self +pub fn Div::gap_neg_2_4(Self) -> Self +pub fn Div::gap_neg_2_5(Self) -> Self +pub fn Div::gap_neg_2p5(Self) -> Self +pub fn Div::gap_neg_3(Self) -> Self +pub fn Div::gap_neg_32(Self) -> Self +pub fn Div::gap_neg_3_4(Self) -> Self +pub fn Div::gap_neg_3_5(Self) -> Self +pub fn Div::gap_neg_3p5(Self) -> Self +pub fn Div::gap_neg_4(Self) -> Self +pub fn Div::gap_neg_40(Self) -> Self +pub fn Div::gap_neg_48(Self) -> Self +pub fn Div::gap_neg_4_5(Self) -> Self +pub fn Div::gap_neg_5(Self) -> Self +pub fn Div::gap_neg_56(Self) -> Self +pub fn Div::gap_neg_5_6(Self) -> Self +pub fn Div::gap_neg_6(Self) -> Self +pub fn Div::gap_neg_64(Self) -> Self +pub fn Div::gap_neg_7(Self) -> Self +pub fn Div::gap_neg_72(Self) -> Self +pub fn Div::gap_neg_8(Self) -> Self +pub fn Div::gap_neg_80(Self) -> Self +pub fn Div::gap_neg_9(Self) -> Self +pub fn Div::gap_neg_96(Self) -> Self +pub fn Div::gap_neg_full(Self) -> Self +pub fn Div::gap_neg_px(Self) -> Self +pub fn Div::gap_px(Self) -> Self +pub fn Div::gap_x(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Div::gap_x_0(Self) -> Self +pub fn Div::gap_x_0p5(Self) -> Self +pub fn Div::gap_x_1(Self) -> Self +pub fn Div::gap_x_10(Self) -> Self +pub fn Div::gap_x_11(Self) -> Self +pub fn Div::gap_x_112(Self) -> Self +pub fn Div::gap_x_12(Self) -> Self +pub fn Div::gap_x_128(Self) -> Self +pub fn Div::gap_x_16(Self) -> Self +pub fn Div::gap_x_1_12(Self) -> Self +pub fn Div::gap_x_1_2(Self) -> Self +pub fn Div::gap_x_1_3(Self) -> Self +pub fn Div::gap_x_1_4(Self) -> Self +pub fn Div::gap_x_1_5(Self) -> Self +pub fn Div::gap_x_1_6(Self) -> Self +pub fn Div::gap_x_1p5(Self) -> Self +pub fn Div::gap_x_2(Self) -> Self +pub fn Div::gap_x_20(Self) -> Self +pub fn Div::gap_x_24(Self) -> Self +pub fn Div::gap_x_2_3(Self) -> Self +pub fn Div::gap_x_2_4(Self) -> Self +pub fn Div::gap_x_2_5(Self) -> Self +pub fn Div::gap_x_2p5(Self) -> Self +pub fn Div::gap_x_3(Self) -> Self +pub fn Div::gap_x_32(Self) -> Self +pub fn Div::gap_x_3_4(Self) -> Self +pub fn Div::gap_x_3_5(Self) -> Self +pub fn Div::gap_x_3p5(Self) -> Self +pub fn Div::gap_x_4(Self) -> Self +pub fn Div::gap_x_40(Self) -> Self +pub fn Div::gap_x_48(Self) -> Self +pub fn Div::gap_x_4_5(Self) -> Self +pub fn Div::gap_x_5(Self) -> Self +pub fn Div::gap_x_56(Self) -> Self +pub fn Div::gap_x_5_6(Self) -> Self +pub fn Div::gap_x_6(Self) -> Self +pub fn Div::gap_x_64(Self) -> Self +pub fn Div::gap_x_7(Self) -> Self +pub fn Div::gap_x_72(Self) -> Self +pub fn Div::gap_x_8(Self) -> Self +pub fn Div::gap_x_80(Self) -> Self +pub fn Div::gap_x_9(Self) -> Self +pub fn Div::gap_x_96(Self) -> Self +pub fn Div::gap_x_full(Self) -> Self +pub fn Div::gap_x_neg_0(Self) -> Self +pub fn Div::gap_x_neg_0p5(Self) -> Self +pub fn Div::gap_x_neg_1(Self) -> Self +pub fn Div::gap_x_neg_10(Self) -> Self +pub fn Div::gap_x_neg_11(Self) -> Self +pub fn Div::gap_x_neg_112(Self) -> Self +pub fn Div::gap_x_neg_12(Self) -> Self +pub fn Div::gap_x_neg_128(Self) -> Self +pub fn Div::gap_x_neg_16(Self) -> Self +pub fn Div::gap_x_neg_1_12(Self) -> Self +pub fn Div::gap_x_neg_1_2(Self) -> Self +pub fn Div::gap_x_neg_1_3(Self) -> Self +pub fn Div::gap_x_neg_1_4(Self) -> Self +pub fn Div::gap_x_neg_1_5(Self) -> Self +pub fn Div::gap_x_neg_1_6(Self) -> Self +pub fn Div::gap_x_neg_1p5(Self) -> Self +pub fn Div::gap_x_neg_2(Self) -> Self +pub fn Div::gap_x_neg_20(Self) -> Self +pub fn Div::gap_x_neg_24(Self) -> Self +pub fn Div::gap_x_neg_2_3(Self) -> Self +pub fn Div::gap_x_neg_2_4(Self) -> Self +pub fn Div::gap_x_neg_2_5(Self) -> Self +pub fn Div::gap_x_neg_2p5(Self) -> Self +pub fn Div::gap_x_neg_3(Self) -> Self +pub fn Div::gap_x_neg_32(Self) -> Self +pub fn Div::gap_x_neg_3_4(Self) -> Self +pub fn Div::gap_x_neg_3_5(Self) -> Self +pub fn Div::gap_x_neg_3p5(Self) -> Self +pub fn Div::gap_x_neg_4(Self) -> Self +pub fn Div::gap_x_neg_40(Self) -> Self +pub fn Div::gap_x_neg_48(Self) -> Self +pub fn Div::gap_x_neg_4_5(Self) -> Self +pub fn Div::gap_x_neg_5(Self) -> Self +pub fn Div::gap_x_neg_56(Self) -> Self +pub fn Div::gap_x_neg_5_6(Self) -> Self +pub fn Div::gap_x_neg_6(Self) -> Self +pub fn Div::gap_x_neg_64(Self) -> Self +pub fn Div::gap_x_neg_7(Self) -> Self +pub fn Div::gap_x_neg_72(Self) -> Self +pub fn Div::gap_x_neg_8(Self) -> Self +pub fn Div::gap_x_neg_80(Self) -> Self +pub fn Div::gap_x_neg_9(Self) -> Self +pub fn Div::gap_x_neg_96(Self) -> Self +pub fn Div::gap_x_neg_full(Self) -> Self +pub fn Div::gap_x_neg_px(Self) -> Self +pub fn Div::gap_x_px(Self) -> Self +pub fn Div::gap_y(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Div::gap_y_0(Self) -> Self +pub fn Div::gap_y_0p5(Self) -> Self +pub fn Div::gap_y_1(Self) -> Self +pub fn Div::gap_y_10(Self) -> Self +pub fn Div::gap_y_11(Self) -> Self +pub fn Div::gap_y_112(Self) -> Self +pub fn Div::gap_y_12(Self) -> Self +pub fn Div::gap_y_128(Self) -> Self +pub fn Div::gap_y_16(Self) -> Self +pub fn Div::gap_y_1_12(Self) -> Self +pub fn Div::gap_y_1_2(Self) -> Self +pub fn Div::gap_y_1_3(Self) -> Self +pub fn Div::gap_y_1_4(Self) -> Self +pub fn Div::gap_y_1_5(Self) -> Self +pub fn Div::gap_y_1_6(Self) -> Self +pub fn Div::gap_y_1p5(Self) -> Self +pub fn Div::gap_y_2(Self) -> Self +pub fn Div::gap_y_20(Self) -> Self +pub fn Div::gap_y_24(Self) -> Self +pub fn Div::gap_y_2_3(Self) -> Self +pub fn Div::gap_y_2_4(Self) -> Self +pub fn Div::gap_y_2_5(Self) -> Self +pub fn Div::gap_y_2p5(Self) -> Self +pub fn Div::gap_y_3(Self) -> Self +pub fn Div::gap_y_32(Self) -> Self +pub fn Div::gap_y_3_4(Self) -> Self +pub fn Div::gap_y_3_5(Self) -> Self +pub fn Div::gap_y_3p5(Self) -> Self +pub fn Div::gap_y_4(Self) -> Self +pub fn Div::gap_y_40(Self) -> Self +pub fn Div::gap_y_48(Self) -> Self +pub fn Div::gap_y_4_5(Self) -> Self +pub fn Div::gap_y_5(Self) -> Self +pub fn Div::gap_y_56(Self) -> Self +pub fn Div::gap_y_5_6(Self) -> Self +pub fn Div::gap_y_6(Self) -> Self +pub fn Div::gap_y_64(Self) -> Self +pub fn Div::gap_y_7(Self) -> Self +pub fn Div::gap_y_72(Self) -> Self +pub fn Div::gap_y_8(Self) -> Self +pub fn Div::gap_y_80(Self) -> Self +pub fn Div::gap_y_9(Self) -> Self +pub fn Div::gap_y_96(Self) -> Self +pub fn Div::gap_y_full(Self) -> Self +pub fn Div::gap_y_neg_0(Self) -> Self +pub fn Div::gap_y_neg_0p5(Self) -> Self +pub fn Div::gap_y_neg_1(Self) -> Self +pub fn Div::gap_y_neg_10(Self) -> Self +pub fn Div::gap_y_neg_11(Self) -> Self +pub fn Div::gap_y_neg_112(Self) -> Self +pub fn Div::gap_y_neg_12(Self) -> Self +pub fn Div::gap_y_neg_128(Self) -> Self +pub fn Div::gap_y_neg_16(Self) -> Self +pub fn Div::gap_y_neg_1_12(Self) -> Self +pub fn Div::gap_y_neg_1_2(Self) -> Self +pub fn Div::gap_y_neg_1_3(Self) -> Self +pub fn Div::gap_y_neg_1_4(Self) -> Self +pub fn Div::gap_y_neg_1_5(Self) -> Self +pub fn Div::gap_y_neg_1_6(Self) -> Self +pub fn Div::gap_y_neg_1p5(Self) -> Self +pub fn Div::gap_y_neg_2(Self) -> Self +pub fn Div::gap_y_neg_20(Self) -> Self +pub fn Div::gap_y_neg_24(Self) -> Self +pub fn Div::gap_y_neg_2_3(Self) -> Self +pub fn Div::gap_y_neg_2_4(Self) -> Self +pub fn Div::gap_y_neg_2_5(Self) -> Self +pub fn Div::gap_y_neg_2p5(Self) -> Self +pub fn Div::gap_y_neg_3(Self) -> Self +pub fn Div::gap_y_neg_32(Self) -> Self +pub fn Div::gap_y_neg_3_4(Self) -> Self +pub fn Div::gap_y_neg_3_5(Self) -> Self +pub fn Div::gap_y_neg_3p5(Self) -> Self +pub fn Div::gap_y_neg_4(Self) -> Self +pub fn Div::gap_y_neg_40(Self) -> Self +pub fn Div::gap_y_neg_48(Self) -> Self +pub fn Div::gap_y_neg_4_5(Self) -> Self +pub fn Div::gap_y_neg_5(Self) -> Self +pub fn Div::gap_y_neg_56(Self) -> Self +pub fn Div::gap_y_neg_5_6(Self) -> Self +pub fn Div::gap_y_neg_6(Self) -> Self +pub fn Div::gap_y_neg_64(Self) -> Self +pub fn Div::gap_y_neg_7(Self) -> Self +pub fn Div::gap_y_neg_72(Self) -> Self +pub fn Div::gap_y_neg_8(Self) -> Self +pub fn Div::gap_y_neg_80(Self) -> Self +pub fn Div::gap_y_neg_9(Self) -> Self +pub fn Div::gap_y_neg_96(Self) -> Self +pub fn Div::gap_y_neg_full(Self) -> Self +pub fn Div::gap_y_neg_px(Self) -> Self +pub fn Div::gap_y_px(Self) -> Self +pub fn Div::grid(Self) -> Self +pub fn Div::grid_cols(Self, Int32) -> Self +pub fn Div::grid_cols_max_content(Self, Int32) -> Self +pub fn Div::grid_cols_min_content(Self, Int32) -> Self +pub fn Div::grid_rows(Self, Int32) -> Self +pub fn Div::grid_rows_max_content(Self, Int32) -> Self +pub fn Div::grid_rows_min_content(Self, Int32) -> Self +pub fn Div::h(Self, &@geometry.IntoLength) -> Self +pub fn Div::h_0(Self) -> Self +pub fn Div::h_0p5(Self) -> Self +pub fn Div::h_1(Self) -> Self +pub fn Div::h_10(Self) -> Self +pub fn Div::h_11(Self) -> Self +pub fn Div::h_112(Self) -> Self +pub fn Div::h_12(Self) -> Self +pub fn Div::h_128(Self) -> Self +pub fn Div::h_16(Self) -> Self +pub fn Div::h_1_12(Self) -> Self +pub fn Div::h_1_2(Self) -> Self +pub fn Div::h_1_3(Self) -> Self +pub fn Div::h_1_4(Self) -> Self +pub fn Div::h_1_5(Self) -> Self +pub fn Div::h_1_6(Self) -> Self +pub fn Div::h_1p5(Self) -> Self +pub fn Div::h_2(Self) -> Self +pub fn Div::h_20(Self) -> Self +pub fn Div::h_24(Self) -> Self +pub fn Div::h_2_3(Self) -> Self +pub fn Div::h_2_4(Self) -> Self +pub fn Div::h_2_5(Self) -> Self +pub fn Div::h_2p5(Self) -> Self +pub fn Div::h_3(Self) -> Self +pub fn Div::h_32(Self) -> Self +pub fn Div::h_3_4(Self) -> Self +pub fn Div::h_3_5(Self) -> Self +pub fn Div::h_3p5(Self) -> Self +pub fn Div::h_4(Self) -> Self +pub fn Div::h_40(Self) -> Self +pub fn Div::h_48(Self) -> Self +pub fn Div::h_4_5(Self) -> Self +pub fn Div::h_5(Self) -> Self +pub fn Div::h_56(Self) -> Self +pub fn Div::h_5_6(Self) -> Self +pub fn Div::h_6(Self) -> Self +pub fn Div::h_64(Self) -> Self +pub fn Div::h_7(Self) -> Self +pub fn Div::h_72(Self) -> Self +pub fn Div::h_8(Self) -> Self +pub fn Div::h_80(Self) -> Self +pub fn Div::h_9(Self) -> Self +pub fn Div::h_96(Self) -> Self +pub fn Div::h_auto(Self) -> Self +pub fn Div::h_full(Self) -> Self +pub fn Div::h_neg_0(Self) -> Self +pub fn Div::h_neg_0p5(Self) -> Self +pub fn Div::h_neg_1(Self) -> Self +pub fn Div::h_neg_10(Self) -> Self +pub fn Div::h_neg_11(Self) -> Self +pub fn Div::h_neg_112(Self) -> Self +pub fn Div::h_neg_12(Self) -> Self +pub fn Div::h_neg_128(Self) -> Self +pub fn Div::h_neg_16(Self) -> Self +pub fn Div::h_neg_1_12(Self) -> Self +pub fn Div::h_neg_1_2(Self) -> Self +pub fn Div::h_neg_1_3(Self) -> Self +pub fn Div::h_neg_1_4(Self) -> Self +pub fn Div::h_neg_1_5(Self) -> Self +pub fn Div::h_neg_1_6(Self) -> Self +pub fn Div::h_neg_1p5(Self) -> Self +pub fn Div::h_neg_2(Self) -> Self +pub fn Div::h_neg_20(Self) -> Self +pub fn Div::h_neg_24(Self) -> Self +pub fn Div::h_neg_2_3(Self) -> Self +pub fn Div::h_neg_2_4(Self) -> Self +pub fn Div::h_neg_2_5(Self) -> Self +pub fn Div::h_neg_2p5(Self) -> Self +pub fn Div::h_neg_3(Self) -> Self +pub fn Div::h_neg_32(Self) -> Self +pub fn Div::h_neg_3_4(Self) -> Self +pub fn Div::h_neg_3_5(Self) -> Self +pub fn Div::h_neg_3p5(Self) -> Self +pub fn Div::h_neg_4(Self) -> Self +pub fn Div::h_neg_40(Self) -> Self +pub fn Div::h_neg_48(Self) -> Self +pub fn Div::h_neg_4_5(Self) -> Self +pub fn Div::h_neg_5(Self) -> Self +pub fn Div::h_neg_56(Self) -> Self +pub fn Div::h_neg_5_6(Self) -> Self +pub fn Div::h_neg_6(Self) -> Self +pub fn Div::h_neg_64(Self) -> Self +pub fn Div::h_neg_7(Self) -> Self +pub fn Div::h_neg_72(Self) -> Self +pub fn Div::h_neg_8(Self) -> Self +pub fn Div::h_neg_80(Self) -> Self +pub fn Div::h_neg_9(Self) -> Self +pub fn Div::h_neg_96(Self) -> Self +pub fn Div::h_neg_full(Self) -> Self +pub fn Div::h_neg_px(Self) -> Self +pub fn Div::h_px(Self) -> Self +pub fn Div::hidden(Self) -> Self +pub fn Div::hover(Self, (@style.StyleRefinement) -> @style.StyleRefinement) -> Self +pub fn Div::id(Self, String) -> Self +pub fn Div::inset(Self, &@geometry.IntoLength) -> Self +pub fn Div::inset_0(Self) -> Self +pub fn Div::inset_0p5(Self) -> Self +pub fn Div::inset_1(Self) -> Self +pub fn Div::inset_10(Self) -> Self +pub fn Div::inset_11(Self) -> Self +pub fn Div::inset_112(Self) -> Self +pub fn Div::inset_12(Self) -> Self +pub fn Div::inset_128(Self) -> Self +pub fn Div::inset_16(Self) -> Self +pub fn Div::inset_1_12(Self) -> Self +pub fn Div::inset_1_2(Self) -> Self +pub fn Div::inset_1_3(Self) -> Self +pub fn Div::inset_1_4(Self) -> Self +pub fn Div::inset_1_5(Self) -> Self +pub fn Div::inset_1_6(Self) -> Self +pub fn Div::inset_1p5(Self) -> Self +pub fn Div::inset_2(Self) -> Self +pub fn Div::inset_20(Self) -> Self +pub fn Div::inset_24(Self) -> Self +pub fn Div::inset_2_3(Self) -> Self +pub fn Div::inset_2_4(Self) -> Self +pub fn Div::inset_2_5(Self) -> Self +pub fn Div::inset_2p5(Self) -> Self +pub fn Div::inset_3(Self) -> Self +pub fn Div::inset_32(Self) -> Self +pub fn Div::inset_3_4(Self) -> Self +pub fn Div::inset_3_5(Self) -> Self +pub fn Div::inset_3p5(Self) -> Self +pub fn Div::inset_4(Self) -> Self +pub fn Div::inset_40(Self) -> Self +pub fn Div::inset_48(Self) -> Self +pub fn Div::inset_4_5(Self) -> Self +pub fn Div::inset_5(Self) -> Self +pub fn Div::inset_56(Self) -> Self +pub fn Div::inset_5_6(Self) -> Self +pub fn Div::inset_6(Self) -> Self +pub fn Div::inset_64(Self) -> Self +pub fn Div::inset_7(Self) -> Self +pub fn Div::inset_72(Self) -> Self +pub fn Div::inset_8(Self) -> Self +pub fn Div::inset_80(Self) -> Self +pub fn Div::inset_9(Self) -> Self +pub fn Div::inset_96(Self) -> Self +pub fn Div::inset_auto(Self) -> Self +pub fn Div::inset_full(Self) -> Self +pub fn Div::inset_neg_0(Self) -> Self +pub fn Div::inset_neg_0p5(Self) -> Self +pub fn Div::inset_neg_1(Self) -> Self +pub fn Div::inset_neg_10(Self) -> Self +pub fn Div::inset_neg_11(Self) -> Self +pub fn Div::inset_neg_112(Self) -> Self +pub fn Div::inset_neg_12(Self) -> Self +pub fn Div::inset_neg_128(Self) -> Self +pub fn Div::inset_neg_16(Self) -> Self +pub fn Div::inset_neg_1_12(Self) -> Self +pub fn Div::inset_neg_1_2(Self) -> Self +pub fn Div::inset_neg_1_3(Self) -> Self +pub fn Div::inset_neg_1_4(Self) -> Self +pub fn Div::inset_neg_1_5(Self) -> Self +pub fn Div::inset_neg_1_6(Self) -> Self +pub fn Div::inset_neg_1p5(Self) -> Self +pub fn Div::inset_neg_2(Self) -> Self +pub fn Div::inset_neg_20(Self) -> Self +pub fn Div::inset_neg_24(Self) -> Self +pub fn Div::inset_neg_2_3(Self) -> Self +pub fn Div::inset_neg_2_4(Self) -> Self +pub fn Div::inset_neg_2_5(Self) -> Self +pub fn Div::inset_neg_2p5(Self) -> Self +pub fn Div::inset_neg_3(Self) -> Self +pub fn Div::inset_neg_32(Self) -> Self +pub fn Div::inset_neg_3_4(Self) -> Self +pub fn Div::inset_neg_3_5(Self) -> Self +pub fn Div::inset_neg_3p5(Self) -> Self +pub fn Div::inset_neg_4(Self) -> Self +pub fn Div::inset_neg_40(Self) -> Self +pub fn Div::inset_neg_48(Self) -> Self +pub fn Div::inset_neg_4_5(Self) -> Self +pub fn Div::inset_neg_5(Self) -> Self +pub fn Div::inset_neg_56(Self) -> Self +pub fn Div::inset_neg_5_6(Self) -> Self +pub fn Div::inset_neg_6(Self) -> Self +pub fn Div::inset_neg_64(Self) -> Self +pub fn Div::inset_neg_7(Self) -> Self +pub fn Div::inset_neg_72(Self) -> Self +pub fn Div::inset_neg_8(Self) -> Self +pub fn Div::inset_neg_80(Self) -> Self +pub fn Div::inset_neg_9(Self) -> Self +pub fn Div::inset_neg_96(Self) -> Self +pub fn Div::inset_neg_full(Self) -> Self +pub fn Div::inset_neg_px(Self) -> Self +pub fn Div::inset_px(Self) -> Self +pub fn Div::into_any_element(Self) -> @window.AnyElement +pub fn Div::invisible(Self) -> Self +pub fn Div::italic(Self) -> Self +pub fn Div::items_baseline(Self) -> Self +pub fn Div::items_center(Self) -> Self +pub fn Div::items_end(Self) -> Self +pub fn Div::items_start(Self) -> Self +pub fn Div::items_stretch(Self) -> Self +pub fn Div::justify_around(Self) -> Self +pub fn Div::justify_between(Self) -> Self +pub fn Div::justify_center(Self) -> Self +pub fn Div::justify_end(Self) -> Self +pub fn Div::justify_evenly(Self) -> Self +pub fn Div::justify_start(Self) -> Self +pub fn Div::left(Self, &@geometry.IntoLength) -> Self +pub fn Div::left_0(Self) -> Self +pub fn Div::left_0p5(Self) -> Self +pub fn Div::left_1(Self) -> Self +pub fn Div::left_10(Self) -> Self +pub fn Div::left_11(Self) -> Self +pub fn Div::left_112(Self) -> Self +pub fn Div::left_12(Self) -> Self +pub fn Div::left_128(Self) -> Self +pub fn Div::left_16(Self) -> Self +pub fn Div::left_1_12(Self) -> Self +pub fn Div::left_1_2(Self) -> Self +pub fn Div::left_1_3(Self) -> Self +pub fn Div::left_1_4(Self) -> Self +pub fn Div::left_1_5(Self) -> Self +pub fn Div::left_1_6(Self) -> Self +pub fn Div::left_1p5(Self) -> Self +pub fn Div::left_2(Self) -> Self +pub fn Div::left_20(Self) -> Self +pub fn Div::left_24(Self) -> Self +pub fn Div::left_2_3(Self) -> Self +pub fn Div::left_2_4(Self) -> Self +pub fn Div::left_2_5(Self) -> Self +pub fn Div::left_2p5(Self) -> Self +pub fn Div::left_3(Self) -> Self +pub fn Div::left_32(Self) -> Self +pub fn Div::left_3_4(Self) -> Self +pub fn Div::left_3_5(Self) -> Self +pub fn Div::left_3p5(Self) -> Self +pub fn Div::left_4(Self) -> Self +pub fn Div::left_40(Self) -> Self +pub fn Div::left_48(Self) -> Self +pub fn Div::left_4_5(Self) -> Self +pub fn Div::left_5(Self) -> Self +pub fn Div::left_56(Self) -> Self +pub fn Div::left_5_6(Self) -> Self +pub fn Div::left_6(Self) -> Self +pub fn Div::left_64(Self) -> Self +pub fn Div::left_7(Self) -> Self +pub fn Div::left_72(Self) -> Self +pub fn Div::left_8(Self) -> Self +pub fn Div::left_80(Self) -> Self +pub fn Div::left_9(Self) -> Self +pub fn Div::left_96(Self) -> Self +pub fn Div::left_auto(Self) -> Self +pub fn Div::left_full(Self) -> Self +pub fn Div::left_neg_0(Self) -> Self +pub fn Div::left_neg_0p5(Self) -> Self +pub fn Div::left_neg_1(Self) -> Self +pub fn Div::left_neg_10(Self) -> Self +pub fn Div::left_neg_11(Self) -> Self +pub fn Div::left_neg_112(Self) -> Self +pub fn Div::left_neg_12(Self) -> Self +pub fn Div::left_neg_128(Self) -> Self +pub fn Div::left_neg_16(Self) -> Self +pub fn Div::left_neg_1_12(Self) -> Self +pub fn Div::left_neg_1_2(Self) -> Self +pub fn Div::left_neg_1_3(Self) -> Self +pub fn Div::left_neg_1_4(Self) -> Self +pub fn Div::left_neg_1_5(Self) -> Self +pub fn Div::left_neg_1_6(Self) -> Self +pub fn Div::left_neg_1p5(Self) -> Self +pub fn Div::left_neg_2(Self) -> Self +pub fn Div::left_neg_20(Self) -> Self +pub fn Div::left_neg_24(Self) -> Self +pub fn Div::left_neg_2_3(Self) -> Self +pub fn Div::left_neg_2_4(Self) -> Self +pub fn Div::left_neg_2_5(Self) -> Self +pub fn Div::left_neg_2p5(Self) -> Self +pub fn Div::left_neg_3(Self) -> Self +pub fn Div::left_neg_32(Self) -> Self +pub fn Div::left_neg_3_4(Self) -> Self +pub fn Div::left_neg_3_5(Self) -> Self +pub fn Div::left_neg_3p5(Self) -> Self +pub fn Div::left_neg_4(Self) -> Self +pub fn Div::left_neg_40(Self) -> Self +pub fn Div::left_neg_48(Self) -> Self +pub fn Div::left_neg_4_5(Self) -> Self +pub fn Div::left_neg_5(Self) -> Self +pub fn Div::left_neg_56(Self) -> Self +pub fn Div::left_neg_5_6(Self) -> Self +pub fn Div::left_neg_6(Self) -> Self +pub fn Div::left_neg_64(Self) -> Self +pub fn Div::left_neg_7(Self) -> Self +pub fn Div::left_neg_72(Self) -> Self +pub fn Div::left_neg_8(Self) -> Self +pub fn Div::left_neg_80(Self) -> Self +pub fn Div::left_neg_9(Self) -> Self +pub fn Div::left_neg_96(Self) -> Self +pub fn Div::left_neg_full(Self) -> Self +pub fn Div::left_neg_px(Self) -> Self +pub fn Div::left_px(Self) -> Self +pub fn Div::line_clamp(Self, Int32) -> Self +pub fn Div::line_height(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Div::line_through(Self) -> Self +pub fn Div::m(Self, &@geometry.IntoLength) -> Self +pub fn Div::m_0(Self) -> Self +pub fn Div::m_0p5(Self) -> Self +pub fn Div::m_1(Self) -> Self +pub fn Div::m_10(Self) -> Self +pub fn Div::m_11(Self) -> Self +pub fn Div::m_112(Self) -> Self +pub fn Div::m_12(Self) -> Self +pub fn Div::m_128(Self) -> Self +pub fn Div::m_16(Self) -> Self +pub fn Div::m_1_12(Self) -> Self +pub fn Div::m_1_2(Self) -> Self +pub fn Div::m_1_3(Self) -> Self +pub fn Div::m_1_4(Self) -> Self +pub fn Div::m_1_5(Self) -> Self +pub fn Div::m_1_6(Self) -> Self +pub fn Div::m_1p5(Self) -> Self +pub fn Div::m_2(Self) -> Self +pub fn Div::m_20(Self) -> Self +pub fn Div::m_24(Self) -> Self +pub fn Div::m_2_3(Self) -> Self +pub fn Div::m_2_4(Self) -> Self +pub fn Div::m_2_5(Self) -> Self +pub fn Div::m_2p5(Self) -> Self +pub fn Div::m_3(Self) -> Self +pub fn Div::m_32(Self) -> Self +pub fn Div::m_3_4(Self) -> Self +pub fn Div::m_3_5(Self) -> Self +pub fn Div::m_3p5(Self) -> Self +pub fn Div::m_4(Self) -> Self +pub fn Div::m_40(Self) -> Self +pub fn Div::m_48(Self) -> Self +pub fn Div::m_4_5(Self) -> Self +pub fn Div::m_5(Self) -> Self +pub fn Div::m_56(Self) -> Self +pub fn Div::m_5_6(Self) -> Self +pub fn Div::m_6(Self) -> Self +pub fn Div::m_64(Self) -> Self +pub fn Div::m_7(Self) -> Self +pub fn Div::m_72(Self) -> Self +pub fn Div::m_8(Self) -> Self +pub fn Div::m_80(Self) -> Self +pub fn Div::m_9(Self) -> Self +pub fn Div::m_96(Self) -> Self +pub fn Div::m_auto(Self) -> Self +pub fn Div::m_full(Self) -> Self +pub fn Div::m_neg_0(Self) -> Self +pub fn Div::m_neg_0p5(Self) -> Self +pub fn Div::m_neg_1(Self) -> Self +pub fn Div::m_neg_10(Self) -> Self +pub fn Div::m_neg_11(Self) -> Self +pub fn Div::m_neg_112(Self) -> Self +pub fn Div::m_neg_12(Self) -> Self +pub fn Div::m_neg_128(Self) -> Self +pub fn Div::m_neg_16(Self) -> Self +pub fn Div::m_neg_1_12(Self) -> Self +pub fn Div::m_neg_1_2(Self) -> Self +pub fn Div::m_neg_1_3(Self) -> Self +pub fn Div::m_neg_1_4(Self) -> Self +pub fn Div::m_neg_1_5(Self) -> Self +pub fn Div::m_neg_1_6(Self) -> Self +pub fn Div::m_neg_1p5(Self) -> Self +pub fn Div::m_neg_2(Self) -> Self +pub fn Div::m_neg_20(Self) -> Self +pub fn Div::m_neg_24(Self) -> Self +pub fn Div::m_neg_2_3(Self) -> Self +pub fn Div::m_neg_2_4(Self) -> Self +pub fn Div::m_neg_2_5(Self) -> Self +pub fn Div::m_neg_2p5(Self) -> Self +pub fn Div::m_neg_3(Self) -> Self +pub fn Div::m_neg_32(Self) -> Self +pub fn Div::m_neg_3_4(Self) -> Self +pub fn Div::m_neg_3_5(Self) -> Self +pub fn Div::m_neg_3p5(Self) -> Self +pub fn Div::m_neg_4(Self) -> Self +pub fn Div::m_neg_40(Self) -> Self +pub fn Div::m_neg_48(Self) -> Self +pub fn Div::m_neg_4_5(Self) -> Self +pub fn Div::m_neg_5(Self) -> Self +pub fn Div::m_neg_56(Self) -> Self +pub fn Div::m_neg_5_6(Self) -> Self +pub fn Div::m_neg_6(Self) -> Self +pub fn Div::m_neg_64(Self) -> Self +pub fn Div::m_neg_7(Self) -> Self +pub fn Div::m_neg_72(Self) -> Self +pub fn Div::m_neg_8(Self) -> Self +pub fn Div::m_neg_80(Self) -> Self +pub fn Div::m_neg_9(Self) -> Self +pub fn Div::m_neg_96(Self) -> Self +pub fn Div::m_neg_full(Self) -> Self +pub fn Div::m_neg_px(Self) -> Self +pub fn Div::m_px(Self) -> Self +pub fn Div::max_h(Self, &@geometry.IntoLength) -> Self +pub fn Div::max_h_0(Self) -> Self +pub fn Div::max_h_0p5(Self) -> Self +pub fn Div::max_h_1(Self) -> Self +pub fn Div::max_h_10(Self) -> Self +pub fn Div::max_h_11(Self) -> Self +pub fn Div::max_h_112(Self) -> Self +pub fn Div::max_h_12(Self) -> Self +pub fn Div::max_h_128(Self) -> Self +pub fn Div::max_h_16(Self) -> Self +pub fn Div::max_h_1_12(Self) -> Self +pub fn Div::max_h_1_2(Self) -> Self +pub fn Div::max_h_1_3(Self) -> Self +pub fn Div::max_h_1_4(Self) -> Self +pub fn Div::max_h_1_5(Self) -> Self +pub fn Div::max_h_1_6(Self) -> Self +pub fn Div::max_h_1p5(Self) -> Self +pub fn Div::max_h_2(Self) -> Self +pub fn Div::max_h_20(Self) -> Self +pub fn Div::max_h_24(Self) -> Self +pub fn Div::max_h_2_3(Self) -> Self +pub fn Div::max_h_2_4(Self) -> Self +pub fn Div::max_h_2_5(Self) -> Self +pub fn Div::max_h_2p5(Self) -> Self +pub fn Div::max_h_3(Self) -> Self +pub fn Div::max_h_32(Self) -> Self +pub fn Div::max_h_3_4(Self) -> Self +pub fn Div::max_h_3_5(Self) -> Self +pub fn Div::max_h_3p5(Self) -> Self +pub fn Div::max_h_4(Self) -> Self +pub fn Div::max_h_40(Self) -> Self +pub fn Div::max_h_48(Self) -> Self +pub fn Div::max_h_4_5(Self) -> Self +pub fn Div::max_h_5(Self) -> Self +pub fn Div::max_h_56(Self) -> Self +pub fn Div::max_h_5_6(Self) -> Self +pub fn Div::max_h_6(Self) -> Self +pub fn Div::max_h_64(Self) -> Self +pub fn Div::max_h_7(Self) -> Self +pub fn Div::max_h_72(Self) -> Self +pub fn Div::max_h_8(Self) -> Self +pub fn Div::max_h_80(Self) -> Self +pub fn Div::max_h_9(Self) -> Self +pub fn Div::max_h_96(Self) -> Self +pub fn Div::max_h_auto(Self) -> Self +pub fn Div::max_h_full(Self) -> Self +pub fn Div::max_h_neg_0(Self) -> Self +pub fn Div::max_h_neg_0p5(Self) -> Self +pub fn Div::max_h_neg_1(Self) -> Self +pub fn Div::max_h_neg_10(Self) -> Self +pub fn Div::max_h_neg_11(Self) -> Self +pub fn Div::max_h_neg_112(Self) -> Self +pub fn Div::max_h_neg_12(Self) -> Self +pub fn Div::max_h_neg_128(Self) -> Self +pub fn Div::max_h_neg_16(Self) -> Self +pub fn Div::max_h_neg_1_12(Self) -> Self +pub fn Div::max_h_neg_1_2(Self) -> Self +pub fn Div::max_h_neg_1_3(Self) -> Self +pub fn Div::max_h_neg_1_4(Self) -> Self +pub fn Div::max_h_neg_1_5(Self) -> Self +pub fn Div::max_h_neg_1_6(Self) -> Self +pub fn Div::max_h_neg_1p5(Self) -> Self +pub fn Div::max_h_neg_2(Self) -> Self +pub fn Div::max_h_neg_20(Self) -> Self +pub fn Div::max_h_neg_24(Self) -> Self +pub fn Div::max_h_neg_2_3(Self) -> Self +pub fn Div::max_h_neg_2_4(Self) -> Self +pub fn Div::max_h_neg_2_5(Self) -> Self +pub fn Div::max_h_neg_2p5(Self) -> Self +pub fn Div::max_h_neg_3(Self) -> Self +pub fn Div::max_h_neg_32(Self) -> Self +pub fn Div::max_h_neg_3_4(Self) -> Self +pub fn Div::max_h_neg_3_5(Self) -> Self +pub fn Div::max_h_neg_3p5(Self) -> Self +pub fn Div::max_h_neg_4(Self) -> Self +pub fn Div::max_h_neg_40(Self) -> Self +pub fn Div::max_h_neg_48(Self) -> Self +pub fn Div::max_h_neg_4_5(Self) -> Self +pub fn Div::max_h_neg_5(Self) -> Self +pub fn Div::max_h_neg_56(Self) -> Self +pub fn Div::max_h_neg_5_6(Self) -> Self +pub fn Div::max_h_neg_6(Self) -> Self +pub fn Div::max_h_neg_64(Self) -> Self +pub fn Div::max_h_neg_7(Self) -> Self +pub fn Div::max_h_neg_72(Self) -> Self +pub fn Div::max_h_neg_8(Self) -> Self +pub fn Div::max_h_neg_80(Self) -> Self +pub fn Div::max_h_neg_9(Self) -> Self +pub fn Div::max_h_neg_96(Self) -> Self +pub fn Div::max_h_neg_full(Self) -> Self +pub fn Div::max_h_neg_px(Self) -> Self +pub fn Div::max_h_px(Self) -> Self +pub fn Div::max_size(Self, &@geometry.IntoLength) -> Self +pub fn Div::max_size_0(Self) -> Self +pub fn Div::max_size_0p5(Self) -> Self +pub fn Div::max_size_1(Self) -> Self +pub fn Div::max_size_10(Self) -> Self +pub fn Div::max_size_11(Self) -> Self +pub fn Div::max_size_112(Self) -> Self +pub fn Div::max_size_12(Self) -> Self +pub fn Div::max_size_128(Self) -> Self +pub fn Div::max_size_16(Self) -> Self +pub fn Div::max_size_1_12(Self) -> Self +pub fn Div::max_size_1_2(Self) -> Self +pub fn Div::max_size_1_3(Self) -> Self +pub fn Div::max_size_1_4(Self) -> Self +pub fn Div::max_size_1_5(Self) -> Self +pub fn Div::max_size_1_6(Self) -> Self +pub fn Div::max_size_1p5(Self) -> Self +pub fn Div::max_size_2(Self) -> Self +pub fn Div::max_size_20(Self) -> Self +pub fn Div::max_size_24(Self) -> Self +pub fn Div::max_size_2_3(Self) -> Self +pub fn Div::max_size_2_4(Self) -> Self +pub fn Div::max_size_2_5(Self) -> Self +pub fn Div::max_size_2p5(Self) -> Self +pub fn Div::max_size_3(Self) -> Self +pub fn Div::max_size_32(Self) -> Self +pub fn Div::max_size_3_4(Self) -> Self +pub fn Div::max_size_3_5(Self) -> Self +pub fn Div::max_size_3p5(Self) -> Self +pub fn Div::max_size_4(Self) -> Self +pub fn Div::max_size_40(Self) -> Self +pub fn Div::max_size_48(Self) -> Self +pub fn Div::max_size_4_5(Self) -> Self +pub fn Div::max_size_5(Self) -> Self +pub fn Div::max_size_56(Self) -> Self +pub fn Div::max_size_5_6(Self) -> Self +pub fn Div::max_size_6(Self) -> Self +pub fn Div::max_size_64(Self) -> Self +pub fn Div::max_size_7(Self) -> Self +pub fn Div::max_size_72(Self) -> Self +pub fn Div::max_size_8(Self) -> Self +pub fn Div::max_size_80(Self) -> Self +pub fn Div::max_size_9(Self) -> Self +pub fn Div::max_size_96(Self) -> Self +pub fn Div::max_size_auto(Self) -> Self +pub fn Div::max_size_full(Self) -> Self +pub fn Div::max_size_neg_0(Self) -> Self +pub fn Div::max_size_neg_0p5(Self) -> Self +pub fn Div::max_size_neg_1(Self) -> Self +pub fn Div::max_size_neg_10(Self) -> Self +pub fn Div::max_size_neg_11(Self) -> Self +pub fn Div::max_size_neg_112(Self) -> Self +pub fn Div::max_size_neg_12(Self) -> Self +pub fn Div::max_size_neg_128(Self) -> Self +pub fn Div::max_size_neg_16(Self) -> Self +pub fn Div::max_size_neg_1_12(Self) -> Self +pub fn Div::max_size_neg_1_2(Self) -> Self +pub fn Div::max_size_neg_1_3(Self) -> Self +pub fn Div::max_size_neg_1_4(Self) -> Self +pub fn Div::max_size_neg_1_5(Self) -> Self +pub fn Div::max_size_neg_1_6(Self) -> Self +pub fn Div::max_size_neg_1p5(Self) -> Self +pub fn Div::max_size_neg_2(Self) -> Self +pub fn Div::max_size_neg_20(Self) -> Self +pub fn Div::max_size_neg_24(Self) -> Self +pub fn Div::max_size_neg_2_3(Self) -> Self +pub fn Div::max_size_neg_2_4(Self) -> Self +pub fn Div::max_size_neg_2_5(Self) -> Self +pub fn Div::max_size_neg_2p5(Self) -> Self +pub fn Div::max_size_neg_3(Self) -> Self +pub fn Div::max_size_neg_32(Self) -> Self +pub fn Div::max_size_neg_3_4(Self) -> Self +pub fn Div::max_size_neg_3_5(Self) -> Self +pub fn Div::max_size_neg_3p5(Self) -> Self +pub fn Div::max_size_neg_4(Self) -> Self +pub fn Div::max_size_neg_40(Self) -> Self +pub fn Div::max_size_neg_48(Self) -> Self +pub fn Div::max_size_neg_4_5(Self) -> Self +pub fn Div::max_size_neg_5(Self) -> Self +pub fn Div::max_size_neg_56(Self) -> Self +pub fn Div::max_size_neg_5_6(Self) -> Self +pub fn Div::max_size_neg_6(Self) -> Self +pub fn Div::max_size_neg_64(Self) -> Self +pub fn Div::max_size_neg_7(Self) -> Self +pub fn Div::max_size_neg_72(Self) -> Self +pub fn Div::max_size_neg_8(Self) -> Self +pub fn Div::max_size_neg_80(Self) -> Self +pub fn Div::max_size_neg_9(Self) -> Self +pub fn Div::max_size_neg_96(Self) -> Self +pub fn Div::max_size_neg_full(Self) -> Self +pub fn Div::max_size_neg_px(Self) -> Self +pub fn Div::max_size_px(Self) -> Self +pub fn Div::max_w(Self, &@geometry.IntoLength) -> Self +pub fn Div::max_w_0(Self) -> Self +pub fn Div::max_w_0p5(Self) -> Self +pub fn Div::max_w_1(Self) -> Self +pub fn Div::max_w_10(Self) -> Self +pub fn Div::max_w_11(Self) -> Self +pub fn Div::max_w_112(Self) -> Self +pub fn Div::max_w_12(Self) -> Self +pub fn Div::max_w_128(Self) -> Self +pub fn Div::max_w_16(Self) -> Self +pub fn Div::max_w_1_12(Self) -> Self +pub fn Div::max_w_1_2(Self) -> Self +pub fn Div::max_w_1_3(Self) -> Self +pub fn Div::max_w_1_4(Self) -> Self +pub fn Div::max_w_1_5(Self) -> Self +pub fn Div::max_w_1_6(Self) -> Self +pub fn Div::max_w_1p5(Self) -> Self +pub fn Div::max_w_2(Self) -> Self +pub fn Div::max_w_20(Self) -> Self +pub fn Div::max_w_24(Self) -> Self +pub fn Div::max_w_2_3(Self) -> Self +pub fn Div::max_w_2_4(Self) -> Self +pub fn Div::max_w_2_5(Self) -> Self +pub fn Div::max_w_2p5(Self) -> Self +pub fn Div::max_w_3(Self) -> Self +pub fn Div::max_w_32(Self) -> Self +pub fn Div::max_w_3_4(Self) -> Self +pub fn Div::max_w_3_5(Self) -> Self +pub fn Div::max_w_3p5(Self) -> Self +pub fn Div::max_w_4(Self) -> Self +pub fn Div::max_w_40(Self) -> Self +pub fn Div::max_w_48(Self) -> Self +pub fn Div::max_w_4_5(Self) -> Self +pub fn Div::max_w_5(Self) -> Self +pub fn Div::max_w_56(Self) -> Self +pub fn Div::max_w_5_6(Self) -> Self +pub fn Div::max_w_6(Self) -> Self +pub fn Div::max_w_64(Self) -> Self +pub fn Div::max_w_7(Self) -> Self +pub fn Div::max_w_72(Self) -> Self +pub fn Div::max_w_8(Self) -> Self +pub fn Div::max_w_80(Self) -> Self +pub fn Div::max_w_9(Self) -> Self +pub fn Div::max_w_96(Self) -> Self +pub fn Div::max_w_auto(Self) -> Self +pub fn Div::max_w_full(Self) -> Self +pub fn Div::max_w_neg_0(Self) -> Self +pub fn Div::max_w_neg_0p5(Self) -> Self +pub fn Div::max_w_neg_1(Self) -> Self +pub fn Div::max_w_neg_10(Self) -> Self +pub fn Div::max_w_neg_11(Self) -> Self +pub fn Div::max_w_neg_112(Self) -> Self +pub fn Div::max_w_neg_12(Self) -> Self +pub fn Div::max_w_neg_128(Self) -> Self +pub fn Div::max_w_neg_16(Self) -> Self +pub fn Div::max_w_neg_1_12(Self) -> Self +pub fn Div::max_w_neg_1_2(Self) -> Self +pub fn Div::max_w_neg_1_3(Self) -> Self +pub fn Div::max_w_neg_1_4(Self) -> Self +pub fn Div::max_w_neg_1_5(Self) -> Self +pub fn Div::max_w_neg_1_6(Self) -> Self +pub fn Div::max_w_neg_1p5(Self) -> Self +pub fn Div::max_w_neg_2(Self) -> Self +pub fn Div::max_w_neg_20(Self) -> Self +pub fn Div::max_w_neg_24(Self) -> Self +pub fn Div::max_w_neg_2_3(Self) -> Self +pub fn Div::max_w_neg_2_4(Self) -> Self +pub fn Div::max_w_neg_2_5(Self) -> Self +pub fn Div::max_w_neg_2p5(Self) -> Self +pub fn Div::max_w_neg_3(Self) -> Self +pub fn Div::max_w_neg_32(Self) -> Self +pub fn Div::max_w_neg_3_4(Self) -> Self +pub fn Div::max_w_neg_3_5(Self) -> Self +pub fn Div::max_w_neg_3p5(Self) -> Self +pub fn Div::max_w_neg_4(Self) -> Self +pub fn Div::max_w_neg_40(Self) -> Self +pub fn Div::max_w_neg_48(Self) -> Self +pub fn Div::max_w_neg_4_5(Self) -> Self +pub fn Div::max_w_neg_5(Self) -> Self +pub fn Div::max_w_neg_56(Self) -> Self +pub fn Div::max_w_neg_5_6(Self) -> Self +pub fn Div::max_w_neg_6(Self) -> Self +pub fn Div::max_w_neg_64(Self) -> Self +pub fn Div::max_w_neg_7(Self) -> Self +pub fn Div::max_w_neg_72(Self) -> Self +pub fn Div::max_w_neg_8(Self) -> Self +pub fn Div::max_w_neg_80(Self) -> Self +pub fn Div::max_w_neg_9(Self) -> Self +pub fn Div::max_w_neg_96(Self) -> Self +pub fn Div::max_w_neg_full(Self) -> Self +pub fn Div::max_w_neg_px(Self) -> Self +pub fn Div::max_w_px(Self) -> Self +pub fn Div::mb(Self, &@geometry.IntoLength) -> Self +pub fn Div::mb_0(Self) -> Self +pub fn Div::mb_0p5(Self) -> Self +pub fn Div::mb_1(Self) -> Self +pub fn Div::mb_10(Self) -> Self +pub fn Div::mb_11(Self) -> Self +pub fn Div::mb_112(Self) -> Self +pub fn Div::mb_12(Self) -> Self +pub fn Div::mb_128(Self) -> Self +pub fn Div::mb_16(Self) -> Self +pub fn Div::mb_1_12(Self) -> Self +pub fn Div::mb_1_2(Self) -> Self +pub fn Div::mb_1_3(Self) -> Self +pub fn Div::mb_1_4(Self) -> Self +pub fn Div::mb_1_5(Self) -> Self +pub fn Div::mb_1_6(Self) -> Self +pub fn Div::mb_1p5(Self) -> Self +pub fn Div::mb_2(Self) -> Self +pub fn Div::mb_20(Self) -> Self +pub fn Div::mb_24(Self) -> Self +pub fn Div::mb_2_3(Self) -> Self +pub fn Div::mb_2_4(Self) -> Self +pub fn Div::mb_2_5(Self) -> Self +pub fn Div::mb_2p5(Self) -> Self +pub fn Div::mb_3(Self) -> Self +pub fn Div::mb_32(Self) -> Self +pub fn Div::mb_3_4(Self) -> Self +pub fn Div::mb_3_5(Self) -> Self +pub fn Div::mb_3p5(Self) -> Self +pub fn Div::mb_4(Self) -> Self +pub fn Div::mb_40(Self) -> Self +pub fn Div::mb_48(Self) -> Self +pub fn Div::mb_4_5(Self) -> Self +pub fn Div::mb_5(Self) -> Self +pub fn Div::mb_56(Self) -> Self +pub fn Div::mb_5_6(Self) -> Self +pub fn Div::mb_6(Self) -> Self +pub fn Div::mb_64(Self) -> Self +pub fn Div::mb_7(Self) -> Self +pub fn Div::mb_72(Self) -> Self +pub fn Div::mb_8(Self) -> Self +pub fn Div::mb_80(Self) -> Self +pub fn Div::mb_9(Self) -> Self +pub fn Div::mb_96(Self) -> Self +pub fn Div::mb_auto(Self) -> Self +pub fn Div::mb_full(Self) -> Self +pub fn Div::mb_neg_0(Self) -> Self +pub fn Div::mb_neg_0p5(Self) -> Self +pub fn Div::mb_neg_1(Self) -> Self +pub fn Div::mb_neg_10(Self) -> Self +pub fn Div::mb_neg_11(Self) -> Self +pub fn Div::mb_neg_112(Self) -> Self +pub fn Div::mb_neg_12(Self) -> Self +pub fn Div::mb_neg_128(Self) -> Self +pub fn Div::mb_neg_16(Self) -> Self +pub fn Div::mb_neg_1_12(Self) -> Self +pub fn Div::mb_neg_1_2(Self) -> Self +pub fn Div::mb_neg_1_3(Self) -> Self +pub fn Div::mb_neg_1_4(Self) -> Self +pub fn Div::mb_neg_1_5(Self) -> Self +pub fn Div::mb_neg_1_6(Self) -> Self +pub fn Div::mb_neg_1p5(Self) -> Self +pub fn Div::mb_neg_2(Self) -> Self +pub fn Div::mb_neg_20(Self) -> Self +pub fn Div::mb_neg_24(Self) -> Self +pub fn Div::mb_neg_2_3(Self) -> Self +pub fn Div::mb_neg_2_4(Self) -> Self +pub fn Div::mb_neg_2_5(Self) -> Self +pub fn Div::mb_neg_2p5(Self) -> Self +pub fn Div::mb_neg_3(Self) -> Self +pub fn Div::mb_neg_32(Self) -> Self +pub fn Div::mb_neg_3_4(Self) -> Self +pub fn Div::mb_neg_3_5(Self) -> Self +pub fn Div::mb_neg_3p5(Self) -> Self +pub fn Div::mb_neg_4(Self) -> Self +pub fn Div::mb_neg_40(Self) -> Self +pub fn Div::mb_neg_48(Self) -> Self +pub fn Div::mb_neg_4_5(Self) -> Self +pub fn Div::mb_neg_5(Self) -> Self +pub fn Div::mb_neg_56(Self) -> Self +pub fn Div::mb_neg_5_6(Self) -> Self +pub fn Div::mb_neg_6(Self) -> Self +pub fn Div::mb_neg_64(Self) -> Self +pub fn Div::mb_neg_7(Self) -> Self +pub fn Div::mb_neg_72(Self) -> Self +pub fn Div::mb_neg_8(Self) -> Self +pub fn Div::mb_neg_80(Self) -> Self +pub fn Div::mb_neg_9(Self) -> Self +pub fn Div::mb_neg_96(Self) -> Self +pub fn Div::mb_neg_full(Self) -> Self +pub fn Div::mb_neg_px(Self) -> Self +pub fn Div::mb_px(Self) -> Self +pub fn Div::min_h(Self, &@geometry.IntoLength) -> Self +pub fn Div::min_h_0(Self) -> Self +pub fn Div::min_h_0p5(Self) -> Self +pub fn Div::min_h_1(Self) -> Self +pub fn Div::min_h_10(Self) -> Self +pub fn Div::min_h_11(Self) -> Self +pub fn Div::min_h_112(Self) -> Self +pub fn Div::min_h_12(Self) -> Self +pub fn Div::min_h_128(Self) -> Self +pub fn Div::min_h_16(Self) -> Self +pub fn Div::min_h_1_12(Self) -> Self +pub fn Div::min_h_1_2(Self) -> Self +pub fn Div::min_h_1_3(Self) -> Self +pub fn Div::min_h_1_4(Self) -> Self +pub fn Div::min_h_1_5(Self) -> Self +pub fn Div::min_h_1_6(Self) -> Self +pub fn Div::min_h_1p5(Self) -> Self +pub fn Div::min_h_2(Self) -> Self +pub fn Div::min_h_20(Self) -> Self +pub fn Div::min_h_24(Self) -> Self +pub fn Div::min_h_2_3(Self) -> Self +pub fn Div::min_h_2_4(Self) -> Self +pub fn Div::min_h_2_5(Self) -> Self +pub fn Div::min_h_2p5(Self) -> Self +pub fn Div::min_h_3(Self) -> Self +pub fn Div::min_h_32(Self) -> Self +pub fn Div::min_h_3_4(Self) -> Self +pub fn Div::min_h_3_5(Self) -> Self +pub fn Div::min_h_3p5(Self) -> Self +pub fn Div::min_h_4(Self) -> Self +pub fn Div::min_h_40(Self) -> Self +pub fn Div::min_h_48(Self) -> Self +pub fn Div::min_h_4_5(Self) -> Self +pub fn Div::min_h_5(Self) -> Self +pub fn Div::min_h_56(Self) -> Self +pub fn Div::min_h_5_6(Self) -> Self +pub fn Div::min_h_6(Self) -> Self +pub fn Div::min_h_64(Self) -> Self +pub fn Div::min_h_7(Self) -> Self +pub fn Div::min_h_72(Self) -> Self +pub fn Div::min_h_8(Self) -> Self +pub fn Div::min_h_80(Self) -> Self +pub fn Div::min_h_9(Self) -> Self +pub fn Div::min_h_96(Self) -> Self +pub fn Div::min_h_auto(Self) -> Self +pub fn Div::min_h_full(Self) -> Self +pub fn Div::min_h_neg_0(Self) -> Self +pub fn Div::min_h_neg_0p5(Self) -> Self +pub fn Div::min_h_neg_1(Self) -> Self +pub fn Div::min_h_neg_10(Self) -> Self +pub fn Div::min_h_neg_11(Self) -> Self +pub fn Div::min_h_neg_112(Self) -> Self +pub fn Div::min_h_neg_12(Self) -> Self +pub fn Div::min_h_neg_128(Self) -> Self +pub fn Div::min_h_neg_16(Self) -> Self +pub fn Div::min_h_neg_1_12(Self) -> Self +pub fn Div::min_h_neg_1_2(Self) -> Self +pub fn Div::min_h_neg_1_3(Self) -> Self +pub fn Div::min_h_neg_1_4(Self) -> Self +pub fn Div::min_h_neg_1_5(Self) -> Self +pub fn Div::min_h_neg_1_6(Self) -> Self +pub fn Div::min_h_neg_1p5(Self) -> Self +pub fn Div::min_h_neg_2(Self) -> Self +pub fn Div::min_h_neg_20(Self) -> Self +pub fn Div::min_h_neg_24(Self) -> Self +pub fn Div::min_h_neg_2_3(Self) -> Self +pub fn Div::min_h_neg_2_4(Self) -> Self +pub fn Div::min_h_neg_2_5(Self) -> Self +pub fn Div::min_h_neg_2p5(Self) -> Self +pub fn Div::min_h_neg_3(Self) -> Self +pub fn Div::min_h_neg_32(Self) -> Self +pub fn Div::min_h_neg_3_4(Self) -> Self +pub fn Div::min_h_neg_3_5(Self) -> Self +pub fn Div::min_h_neg_3p5(Self) -> Self +pub fn Div::min_h_neg_4(Self) -> Self +pub fn Div::min_h_neg_40(Self) -> Self +pub fn Div::min_h_neg_48(Self) -> Self +pub fn Div::min_h_neg_4_5(Self) -> Self +pub fn Div::min_h_neg_5(Self) -> Self +pub fn Div::min_h_neg_56(Self) -> Self +pub fn Div::min_h_neg_5_6(Self) -> Self +pub fn Div::min_h_neg_6(Self) -> Self +pub fn Div::min_h_neg_64(Self) -> Self +pub fn Div::min_h_neg_7(Self) -> Self +pub fn Div::min_h_neg_72(Self) -> Self +pub fn Div::min_h_neg_8(Self) -> Self +pub fn Div::min_h_neg_80(Self) -> Self +pub fn Div::min_h_neg_9(Self) -> Self +pub fn Div::min_h_neg_96(Self) -> Self +pub fn Div::min_h_neg_full(Self) -> Self +pub fn Div::min_h_neg_px(Self) -> Self +pub fn Div::min_h_px(Self) -> Self +pub fn Div::min_size(Self, &@geometry.IntoLength) -> Self +pub fn Div::min_size_0(Self) -> Self +pub fn Div::min_size_0p5(Self) -> Self +pub fn Div::min_size_1(Self) -> Self +pub fn Div::min_size_10(Self) -> Self +pub fn Div::min_size_11(Self) -> Self +pub fn Div::min_size_112(Self) -> Self +pub fn Div::min_size_12(Self) -> Self +pub fn Div::min_size_128(Self) -> Self +pub fn Div::min_size_16(Self) -> Self +pub fn Div::min_size_1_12(Self) -> Self +pub fn Div::min_size_1_2(Self) -> Self +pub fn Div::min_size_1_3(Self) -> Self +pub fn Div::min_size_1_4(Self) -> Self +pub fn Div::min_size_1_5(Self) -> Self +pub fn Div::min_size_1_6(Self) -> Self +pub fn Div::min_size_1p5(Self) -> Self +pub fn Div::min_size_2(Self) -> Self +pub fn Div::min_size_20(Self) -> Self +pub fn Div::min_size_24(Self) -> Self +pub fn Div::min_size_2_3(Self) -> Self +pub fn Div::min_size_2_4(Self) -> Self +pub fn Div::min_size_2_5(Self) -> Self +pub fn Div::min_size_2p5(Self) -> Self +pub fn Div::min_size_3(Self) -> Self +pub fn Div::min_size_32(Self) -> Self +pub fn Div::min_size_3_4(Self) -> Self +pub fn Div::min_size_3_5(Self) -> Self +pub fn Div::min_size_3p5(Self) -> Self +pub fn Div::min_size_4(Self) -> Self +pub fn Div::min_size_40(Self) -> Self +pub fn Div::min_size_48(Self) -> Self +pub fn Div::min_size_4_5(Self) -> Self +pub fn Div::min_size_5(Self) -> Self +pub fn Div::min_size_56(Self) -> Self +pub fn Div::min_size_5_6(Self) -> Self +pub fn Div::min_size_6(Self) -> Self +pub fn Div::min_size_64(Self) -> Self +pub fn Div::min_size_7(Self) -> Self +pub fn Div::min_size_72(Self) -> Self +pub fn Div::min_size_8(Self) -> Self +pub fn Div::min_size_80(Self) -> Self +pub fn Div::min_size_9(Self) -> Self +pub fn Div::min_size_96(Self) -> Self +pub fn Div::min_size_auto(Self) -> Self +pub fn Div::min_size_full(Self) -> Self +pub fn Div::min_size_neg_0(Self) -> Self +pub fn Div::min_size_neg_0p5(Self) -> Self +pub fn Div::min_size_neg_1(Self) -> Self +pub fn Div::min_size_neg_10(Self) -> Self +pub fn Div::min_size_neg_11(Self) -> Self +pub fn Div::min_size_neg_112(Self) -> Self +pub fn Div::min_size_neg_12(Self) -> Self +pub fn Div::min_size_neg_128(Self) -> Self +pub fn Div::min_size_neg_16(Self) -> Self +pub fn Div::min_size_neg_1_12(Self) -> Self +pub fn Div::min_size_neg_1_2(Self) -> Self +pub fn Div::min_size_neg_1_3(Self) -> Self +pub fn Div::min_size_neg_1_4(Self) -> Self +pub fn Div::min_size_neg_1_5(Self) -> Self +pub fn Div::min_size_neg_1_6(Self) -> Self +pub fn Div::min_size_neg_1p5(Self) -> Self +pub fn Div::min_size_neg_2(Self) -> Self +pub fn Div::min_size_neg_20(Self) -> Self +pub fn Div::min_size_neg_24(Self) -> Self +pub fn Div::min_size_neg_2_3(Self) -> Self +pub fn Div::min_size_neg_2_4(Self) -> Self +pub fn Div::min_size_neg_2_5(Self) -> Self +pub fn Div::min_size_neg_2p5(Self) -> Self +pub fn Div::min_size_neg_3(Self) -> Self +pub fn Div::min_size_neg_32(Self) -> Self +pub fn Div::min_size_neg_3_4(Self) -> Self +pub fn Div::min_size_neg_3_5(Self) -> Self +pub fn Div::min_size_neg_3p5(Self) -> Self +pub fn Div::min_size_neg_4(Self) -> Self +pub fn Div::min_size_neg_40(Self) -> Self +pub fn Div::min_size_neg_48(Self) -> Self +pub fn Div::min_size_neg_4_5(Self) -> Self +pub fn Div::min_size_neg_5(Self) -> Self +pub fn Div::min_size_neg_56(Self) -> Self +pub fn Div::min_size_neg_5_6(Self) -> Self +pub fn Div::min_size_neg_6(Self) -> Self +pub fn Div::min_size_neg_64(Self) -> Self +pub fn Div::min_size_neg_7(Self) -> Self +pub fn Div::min_size_neg_72(Self) -> Self +pub fn Div::min_size_neg_8(Self) -> Self +pub fn Div::min_size_neg_80(Self) -> Self +pub fn Div::min_size_neg_9(Self) -> Self +pub fn Div::min_size_neg_96(Self) -> Self +pub fn Div::min_size_neg_full(Self) -> Self +pub fn Div::min_size_neg_px(Self) -> Self +pub fn Div::min_size_px(Self) -> Self +pub fn Div::min_w(Self, &@geometry.IntoLength) -> Self +pub fn Div::min_w_0(Self) -> Self +pub fn Div::min_w_0p5(Self) -> Self +pub fn Div::min_w_1(Self) -> Self +pub fn Div::min_w_10(Self) -> Self +pub fn Div::min_w_11(Self) -> Self +pub fn Div::min_w_112(Self) -> Self +pub fn Div::min_w_12(Self) -> Self +pub fn Div::min_w_128(Self) -> Self +pub fn Div::min_w_16(Self) -> Self +pub fn Div::min_w_1_12(Self) -> Self +pub fn Div::min_w_1_2(Self) -> Self +pub fn Div::min_w_1_3(Self) -> Self +pub fn Div::min_w_1_4(Self) -> Self +pub fn Div::min_w_1_5(Self) -> Self +pub fn Div::min_w_1_6(Self) -> Self +pub fn Div::min_w_1p5(Self) -> Self +pub fn Div::min_w_2(Self) -> Self +pub fn Div::min_w_20(Self) -> Self +pub fn Div::min_w_24(Self) -> Self +pub fn Div::min_w_2_3(Self) -> Self +pub fn Div::min_w_2_4(Self) -> Self +pub fn Div::min_w_2_5(Self) -> Self +pub fn Div::min_w_2p5(Self) -> Self +pub fn Div::min_w_3(Self) -> Self +pub fn Div::min_w_32(Self) -> Self +pub fn Div::min_w_3_4(Self) -> Self +pub fn Div::min_w_3_5(Self) -> Self +pub fn Div::min_w_3p5(Self) -> Self +pub fn Div::min_w_4(Self) -> Self +pub fn Div::min_w_40(Self) -> Self +pub fn Div::min_w_48(Self) -> Self +pub fn Div::min_w_4_5(Self) -> Self +pub fn Div::min_w_5(Self) -> Self +pub fn Div::min_w_56(Self) -> Self +pub fn Div::min_w_5_6(Self) -> Self +pub fn Div::min_w_6(Self) -> Self +pub fn Div::min_w_64(Self) -> Self +pub fn Div::min_w_7(Self) -> Self +pub fn Div::min_w_72(Self) -> Self +pub fn Div::min_w_8(Self) -> Self +pub fn Div::min_w_80(Self) -> Self +pub fn Div::min_w_9(Self) -> Self +pub fn Div::min_w_96(Self) -> Self +pub fn Div::min_w_auto(Self) -> Self +pub fn Div::min_w_full(Self) -> Self +pub fn Div::min_w_neg_0(Self) -> Self +pub fn Div::min_w_neg_0p5(Self) -> Self +pub fn Div::min_w_neg_1(Self) -> Self +pub fn Div::min_w_neg_10(Self) -> Self +pub fn Div::min_w_neg_11(Self) -> Self +pub fn Div::min_w_neg_112(Self) -> Self +pub fn Div::min_w_neg_12(Self) -> Self +pub fn Div::min_w_neg_128(Self) -> Self +pub fn Div::min_w_neg_16(Self) -> Self +pub fn Div::min_w_neg_1_12(Self) -> Self +pub fn Div::min_w_neg_1_2(Self) -> Self +pub fn Div::min_w_neg_1_3(Self) -> Self +pub fn Div::min_w_neg_1_4(Self) -> Self +pub fn Div::min_w_neg_1_5(Self) -> Self +pub fn Div::min_w_neg_1_6(Self) -> Self +pub fn Div::min_w_neg_1p5(Self) -> Self +pub fn Div::min_w_neg_2(Self) -> Self +pub fn Div::min_w_neg_20(Self) -> Self +pub fn Div::min_w_neg_24(Self) -> Self +pub fn Div::min_w_neg_2_3(Self) -> Self +pub fn Div::min_w_neg_2_4(Self) -> Self +pub fn Div::min_w_neg_2_5(Self) -> Self +pub fn Div::min_w_neg_2p5(Self) -> Self +pub fn Div::min_w_neg_3(Self) -> Self +pub fn Div::min_w_neg_32(Self) -> Self +pub fn Div::min_w_neg_3_4(Self) -> Self +pub fn Div::min_w_neg_3_5(Self) -> Self +pub fn Div::min_w_neg_3p5(Self) -> Self +pub fn Div::min_w_neg_4(Self) -> Self +pub fn Div::min_w_neg_40(Self) -> Self +pub fn Div::min_w_neg_48(Self) -> Self +pub fn Div::min_w_neg_4_5(Self) -> Self +pub fn Div::min_w_neg_5(Self) -> Self +pub fn Div::min_w_neg_56(Self) -> Self +pub fn Div::min_w_neg_5_6(Self) -> Self +pub fn Div::min_w_neg_6(Self) -> Self +pub fn Div::min_w_neg_64(Self) -> Self +pub fn Div::min_w_neg_7(Self) -> Self +pub fn Div::min_w_neg_72(Self) -> Self +pub fn Div::min_w_neg_8(Self) -> Self +pub fn Div::min_w_neg_80(Self) -> Self +pub fn Div::min_w_neg_9(Self) -> Self +pub fn Div::min_w_neg_96(Self) -> Self +pub fn Div::min_w_neg_full(Self) -> Self +pub fn Div::min_w_neg_px(Self) -> Self +pub fn Div::min_w_px(Self) -> Self +pub fn Div::ml(Self, &@geometry.IntoLength) -> Self +pub fn Div::ml_0(Self) -> Self +pub fn Div::ml_0p5(Self) -> Self +pub fn Div::ml_1(Self) -> Self +pub fn Div::ml_10(Self) -> Self +pub fn Div::ml_11(Self) -> Self +pub fn Div::ml_112(Self) -> Self +pub fn Div::ml_12(Self) -> Self +pub fn Div::ml_128(Self) -> Self +pub fn Div::ml_16(Self) -> Self +pub fn Div::ml_1_12(Self) -> Self +pub fn Div::ml_1_2(Self) -> Self +pub fn Div::ml_1_3(Self) -> Self +pub fn Div::ml_1_4(Self) -> Self +pub fn Div::ml_1_5(Self) -> Self +pub fn Div::ml_1_6(Self) -> Self +pub fn Div::ml_1p5(Self) -> Self +pub fn Div::ml_2(Self) -> Self +pub fn Div::ml_20(Self) -> Self +pub fn Div::ml_24(Self) -> Self +pub fn Div::ml_2_3(Self) -> Self +pub fn Div::ml_2_4(Self) -> Self +pub fn Div::ml_2_5(Self) -> Self +pub fn Div::ml_2p5(Self) -> Self +pub fn Div::ml_3(Self) -> Self +pub fn Div::ml_32(Self) -> Self +pub fn Div::ml_3_4(Self) -> Self +pub fn Div::ml_3_5(Self) -> Self +pub fn Div::ml_3p5(Self) -> Self +pub fn Div::ml_4(Self) -> Self +pub fn Div::ml_40(Self) -> Self +pub fn Div::ml_48(Self) -> Self +pub fn Div::ml_4_5(Self) -> Self +pub fn Div::ml_5(Self) -> Self +pub fn Div::ml_56(Self) -> Self +pub fn Div::ml_5_6(Self) -> Self +pub fn Div::ml_6(Self) -> Self +pub fn Div::ml_64(Self) -> Self +pub fn Div::ml_7(Self) -> Self +pub fn Div::ml_72(Self) -> Self +pub fn Div::ml_8(Self) -> Self +pub fn Div::ml_80(Self) -> Self +pub fn Div::ml_9(Self) -> Self +pub fn Div::ml_96(Self) -> Self +pub fn Div::ml_auto(Self) -> Self +pub fn Div::ml_full(Self) -> Self +pub fn Div::ml_neg_0(Self) -> Self +pub fn Div::ml_neg_0p5(Self) -> Self +pub fn Div::ml_neg_1(Self) -> Self +pub fn Div::ml_neg_10(Self) -> Self +pub fn Div::ml_neg_11(Self) -> Self +pub fn Div::ml_neg_112(Self) -> Self +pub fn Div::ml_neg_12(Self) -> Self +pub fn Div::ml_neg_128(Self) -> Self +pub fn Div::ml_neg_16(Self) -> Self +pub fn Div::ml_neg_1_12(Self) -> Self +pub fn Div::ml_neg_1_2(Self) -> Self +pub fn Div::ml_neg_1_3(Self) -> Self +pub fn Div::ml_neg_1_4(Self) -> Self +pub fn Div::ml_neg_1_5(Self) -> Self +pub fn Div::ml_neg_1_6(Self) -> Self +pub fn Div::ml_neg_1p5(Self) -> Self +pub fn Div::ml_neg_2(Self) -> Self +pub fn Div::ml_neg_20(Self) -> Self +pub fn Div::ml_neg_24(Self) -> Self +pub fn Div::ml_neg_2_3(Self) -> Self +pub fn Div::ml_neg_2_4(Self) -> Self +pub fn Div::ml_neg_2_5(Self) -> Self +pub fn Div::ml_neg_2p5(Self) -> Self +pub fn Div::ml_neg_3(Self) -> Self +pub fn Div::ml_neg_32(Self) -> Self +pub fn Div::ml_neg_3_4(Self) -> Self +pub fn Div::ml_neg_3_5(Self) -> Self +pub fn Div::ml_neg_3p5(Self) -> Self +pub fn Div::ml_neg_4(Self) -> Self +pub fn Div::ml_neg_40(Self) -> Self +pub fn Div::ml_neg_48(Self) -> Self +pub fn Div::ml_neg_4_5(Self) -> Self +pub fn Div::ml_neg_5(Self) -> Self +pub fn Div::ml_neg_56(Self) -> Self +pub fn Div::ml_neg_5_6(Self) -> Self +pub fn Div::ml_neg_6(Self) -> Self +pub fn Div::ml_neg_64(Self) -> Self +pub fn Div::ml_neg_7(Self) -> Self +pub fn Div::ml_neg_72(Self) -> Self +pub fn Div::ml_neg_8(Self) -> Self +pub fn Div::ml_neg_80(Self) -> Self +pub fn Div::ml_neg_9(Self) -> Self +pub fn Div::ml_neg_96(Self) -> Self +pub fn Div::ml_neg_full(Self) -> Self +pub fn Div::ml_neg_px(Self) -> Self +pub fn Div::ml_px(Self) -> Self +pub fn Div::mr(Self, &@geometry.IntoLength) -> Self +pub fn Div::mr_0(Self) -> Self +pub fn Div::mr_0p5(Self) -> Self +pub fn Div::mr_1(Self) -> Self +pub fn Div::mr_10(Self) -> Self +pub fn Div::mr_11(Self) -> Self +pub fn Div::mr_112(Self) -> Self +pub fn Div::mr_12(Self) -> Self +pub fn Div::mr_128(Self) -> Self +pub fn Div::mr_16(Self) -> Self +pub fn Div::mr_1_12(Self) -> Self +pub fn Div::mr_1_2(Self) -> Self +pub fn Div::mr_1_3(Self) -> Self +pub fn Div::mr_1_4(Self) -> Self +pub fn Div::mr_1_5(Self) -> Self +pub fn Div::mr_1_6(Self) -> Self +pub fn Div::mr_1p5(Self) -> Self +pub fn Div::mr_2(Self) -> Self +pub fn Div::mr_20(Self) -> Self +pub fn Div::mr_24(Self) -> Self +pub fn Div::mr_2_3(Self) -> Self +pub fn Div::mr_2_4(Self) -> Self +pub fn Div::mr_2_5(Self) -> Self +pub fn Div::mr_2p5(Self) -> Self +pub fn Div::mr_3(Self) -> Self +pub fn Div::mr_32(Self) -> Self +pub fn Div::mr_3_4(Self) -> Self +pub fn Div::mr_3_5(Self) -> Self +pub fn Div::mr_3p5(Self) -> Self +pub fn Div::mr_4(Self) -> Self +pub fn Div::mr_40(Self) -> Self +pub fn Div::mr_48(Self) -> Self +pub fn Div::mr_4_5(Self) -> Self +pub fn Div::mr_5(Self) -> Self +pub fn Div::mr_56(Self) -> Self +pub fn Div::mr_5_6(Self) -> Self +pub fn Div::mr_6(Self) -> Self +pub fn Div::mr_64(Self) -> Self +pub fn Div::mr_7(Self) -> Self +pub fn Div::mr_72(Self) -> Self +pub fn Div::mr_8(Self) -> Self +pub fn Div::mr_80(Self) -> Self +pub fn Div::mr_9(Self) -> Self +pub fn Div::mr_96(Self) -> Self +pub fn Div::mr_auto(Self) -> Self +pub fn Div::mr_full(Self) -> Self +pub fn Div::mr_neg_0(Self) -> Self +pub fn Div::mr_neg_0p5(Self) -> Self +pub fn Div::mr_neg_1(Self) -> Self +pub fn Div::mr_neg_10(Self) -> Self +pub fn Div::mr_neg_11(Self) -> Self +pub fn Div::mr_neg_112(Self) -> Self +pub fn Div::mr_neg_12(Self) -> Self +pub fn Div::mr_neg_128(Self) -> Self +pub fn Div::mr_neg_16(Self) -> Self +pub fn Div::mr_neg_1_12(Self) -> Self +pub fn Div::mr_neg_1_2(Self) -> Self +pub fn Div::mr_neg_1_3(Self) -> Self +pub fn Div::mr_neg_1_4(Self) -> Self +pub fn Div::mr_neg_1_5(Self) -> Self +pub fn Div::mr_neg_1_6(Self) -> Self +pub fn Div::mr_neg_1p5(Self) -> Self +pub fn Div::mr_neg_2(Self) -> Self +pub fn Div::mr_neg_20(Self) -> Self +pub fn Div::mr_neg_24(Self) -> Self +pub fn Div::mr_neg_2_3(Self) -> Self +pub fn Div::mr_neg_2_4(Self) -> Self +pub fn Div::mr_neg_2_5(Self) -> Self +pub fn Div::mr_neg_2p5(Self) -> Self +pub fn Div::mr_neg_3(Self) -> Self +pub fn Div::mr_neg_32(Self) -> Self +pub fn Div::mr_neg_3_4(Self) -> Self +pub fn Div::mr_neg_3_5(Self) -> Self +pub fn Div::mr_neg_3p5(Self) -> Self +pub fn Div::mr_neg_4(Self) -> Self +pub fn Div::mr_neg_40(Self) -> Self +pub fn Div::mr_neg_48(Self) -> Self +pub fn Div::mr_neg_4_5(Self) -> Self +pub fn Div::mr_neg_5(Self) -> Self +pub fn Div::mr_neg_56(Self) -> Self +pub fn Div::mr_neg_5_6(Self) -> Self +pub fn Div::mr_neg_6(Self) -> Self +pub fn Div::mr_neg_64(Self) -> Self +pub fn Div::mr_neg_7(Self) -> Self +pub fn Div::mr_neg_72(Self) -> Self +pub fn Div::mr_neg_8(Self) -> Self +pub fn Div::mr_neg_80(Self) -> Self +pub fn Div::mr_neg_9(Self) -> Self +pub fn Div::mr_neg_96(Self) -> Self +pub fn Div::mr_neg_full(Self) -> Self +pub fn Div::mr_neg_px(Self) -> Self +pub fn Div::mr_px(Self) -> Self +pub fn Div::mt(Self, &@geometry.IntoLength) -> Self +pub fn Div::mt_0(Self) -> Self +pub fn Div::mt_0p5(Self) -> Self +pub fn Div::mt_1(Self) -> Self +pub fn Div::mt_10(Self) -> Self +pub fn Div::mt_11(Self) -> Self +pub fn Div::mt_112(Self) -> Self +pub fn Div::mt_12(Self) -> Self +pub fn Div::mt_128(Self) -> Self +pub fn Div::mt_16(Self) -> Self +pub fn Div::mt_1_12(Self) -> Self +pub fn Div::mt_1_2(Self) -> Self +pub fn Div::mt_1_3(Self) -> Self +pub fn Div::mt_1_4(Self) -> Self +pub fn Div::mt_1_5(Self) -> Self +pub fn Div::mt_1_6(Self) -> Self +pub fn Div::mt_1p5(Self) -> Self +pub fn Div::mt_2(Self) -> Self +pub fn Div::mt_20(Self) -> Self +pub fn Div::mt_24(Self) -> Self +pub fn Div::mt_2_3(Self) -> Self +pub fn Div::mt_2_4(Self) -> Self +pub fn Div::mt_2_5(Self) -> Self +pub fn Div::mt_2p5(Self) -> Self +pub fn Div::mt_3(Self) -> Self +pub fn Div::mt_32(Self) -> Self +pub fn Div::mt_3_4(Self) -> Self +pub fn Div::mt_3_5(Self) -> Self +pub fn Div::mt_3p5(Self) -> Self +pub fn Div::mt_4(Self) -> Self +pub fn Div::mt_40(Self) -> Self +pub fn Div::mt_48(Self) -> Self +pub fn Div::mt_4_5(Self) -> Self +pub fn Div::mt_5(Self) -> Self +pub fn Div::mt_56(Self) -> Self +pub fn Div::mt_5_6(Self) -> Self +pub fn Div::mt_6(Self) -> Self +pub fn Div::mt_64(Self) -> Self +pub fn Div::mt_7(Self) -> Self +pub fn Div::mt_72(Self) -> Self +pub fn Div::mt_8(Self) -> Self +pub fn Div::mt_80(Self) -> Self +pub fn Div::mt_9(Self) -> Self +pub fn Div::mt_96(Self) -> Self +pub fn Div::mt_auto(Self) -> Self +pub fn Div::mt_full(Self) -> Self +pub fn Div::mt_neg_0(Self) -> Self +pub fn Div::mt_neg_0p5(Self) -> Self +pub fn Div::mt_neg_1(Self) -> Self +pub fn Div::mt_neg_10(Self) -> Self +pub fn Div::mt_neg_11(Self) -> Self +pub fn Div::mt_neg_112(Self) -> Self +pub fn Div::mt_neg_12(Self) -> Self +pub fn Div::mt_neg_128(Self) -> Self +pub fn Div::mt_neg_16(Self) -> Self +pub fn Div::mt_neg_1_12(Self) -> Self +pub fn Div::mt_neg_1_2(Self) -> Self +pub fn Div::mt_neg_1_3(Self) -> Self +pub fn Div::mt_neg_1_4(Self) -> Self +pub fn Div::mt_neg_1_5(Self) -> Self +pub fn Div::mt_neg_1_6(Self) -> Self +pub fn Div::mt_neg_1p5(Self) -> Self +pub fn Div::mt_neg_2(Self) -> Self +pub fn Div::mt_neg_20(Self) -> Self +pub fn Div::mt_neg_24(Self) -> Self +pub fn Div::mt_neg_2_3(Self) -> Self +pub fn Div::mt_neg_2_4(Self) -> Self +pub fn Div::mt_neg_2_5(Self) -> Self +pub fn Div::mt_neg_2p5(Self) -> Self +pub fn Div::mt_neg_3(Self) -> Self +pub fn Div::mt_neg_32(Self) -> Self +pub fn Div::mt_neg_3_4(Self) -> Self +pub fn Div::mt_neg_3_5(Self) -> Self +pub fn Div::mt_neg_3p5(Self) -> Self +pub fn Div::mt_neg_4(Self) -> Self +pub fn Div::mt_neg_40(Self) -> Self +pub fn Div::mt_neg_48(Self) -> Self +pub fn Div::mt_neg_4_5(Self) -> Self +pub fn Div::mt_neg_5(Self) -> Self +pub fn Div::mt_neg_56(Self) -> Self +pub fn Div::mt_neg_5_6(Self) -> Self +pub fn Div::mt_neg_6(Self) -> Self +pub fn Div::mt_neg_64(Self) -> Self +pub fn Div::mt_neg_7(Self) -> Self +pub fn Div::mt_neg_72(Self) -> Self +pub fn Div::mt_neg_8(Self) -> Self +pub fn Div::mt_neg_80(Self) -> Self +pub fn Div::mt_neg_9(Self) -> Self +pub fn Div::mt_neg_96(Self) -> Self +pub fn Div::mt_neg_full(Self) -> Self +pub fn Div::mt_neg_px(Self) -> Self +pub fn Div::mt_px(Self) -> Self +pub fn Div::mx(Self, &@geometry.IntoLength) -> Self +pub fn Div::mx_0(Self) -> Self +pub fn Div::mx_0p5(Self) -> Self +pub fn Div::mx_1(Self) -> Self +pub fn Div::mx_10(Self) -> Self +pub fn Div::mx_11(Self) -> Self +pub fn Div::mx_112(Self) -> Self +pub fn Div::mx_12(Self) -> Self +pub fn Div::mx_128(Self) -> Self +pub fn Div::mx_16(Self) -> Self +pub fn Div::mx_1_12(Self) -> Self +pub fn Div::mx_1_2(Self) -> Self +pub fn Div::mx_1_3(Self) -> Self +pub fn Div::mx_1_4(Self) -> Self +pub fn Div::mx_1_5(Self) -> Self +pub fn Div::mx_1_6(Self) -> Self +pub fn Div::mx_1p5(Self) -> Self +pub fn Div::mx_2(Self) -> Self +pub fn Div::mx_20(Self) -> Self +pub fn Div::mx_24(Self) -> Self +pub fn Div::mx_2_3(Self) -> Self +pub fn Div::mx_2_4(Self) -> Self +pub fn Div::mx_2_5(Self) -> Self +pub fn Div::mx_2p5(Self) -> Self +pub fn Div::mx_3(Self) -> Self +pub fn Div::mx_32(Self) -> Self +pub fn Div::mx_3_4(Self) -> Self +pub fn Div::mx_3_5(Self) -> Self +pub fn Div::mx_3p5(Self) -> Self +pub fn Div::mx_4(Self) -> Self +pub fn Div::mx_40(Self) -> Self +pub fn Div::mx_48(Self) -> Self +pub fn Div::mx_4_5(Self) -> Self +pub fn Div::mx_5(Self) -> Self +pub fn Div::mx_56(Self) -> Self +pub fn Div::mx_5_6(Self) -> Self +pub fn Div::mx_6(Self) -> Self +pub fn Div::mx_64(Self) -> Self +pub fn Div::mx_7(Self) -> Self +pub fn Div::mx_72(Self) -> Self +pub fn Div::mx_8(Self) -> Self +pub fn Div::mx_80(Self) -> Self +pub fn Div::mx_9(Self) -> Self +pub fn Div::mx_96(Self) -> Self +pub fn Div::mx_auto(Self) -> Self +pub fn Div::mx_full(Self) -> Self +pub fn Div::mx_neg_0(Self) -> Self +pub fn Div::mx_neg_0p5(Self) -> Self +pub fn Div::mx_neg_1(Self) -> Self +pub fn Div::mx_neg_10(Self) -> Self +pub fn Div::mx_neg_11(Self) -> Self +pub fn Div::mx_neg_112(Self) -> Self +pub fn Div::mx_neg_12(Self) -> Self +pub fn Div::mx_neg_128(Self) -> Self +pub fn Div::mx_neg_16(Self) -> Self +pub fn Div::mx_neg_1_12(Self) -> Self +pub fn Div::mx_neg_1_2(Self) -> Self +pub fn Div::mx_neg_1_3(Self) -> Self +pub fn Div::mx_neg_1_4(Self) -> Self +pub fn Div::mx_neg_1_5(Self) -> Self +pub fn Div::mx_neg_1_6(Self) -> Self +pub fn Div::mx_neg_1p5(Self) -> Self +pub fn Div::mx_neg_2(Self) -> Self +pub fn Div::mx_neg_20(Self) -> Self +pub fn Div::mx_neg_24(Self) -> Self +pub fn Div::mx_neg_2_3(Self) -> Self +pub fn Div::mx_neg_2_4(Self) -> Self +pub fn Div::mx_neg_2_5(Self) -> Self +pub fn Div::mx_neg_2p5(Self) -> Self +pub fn Div::mx_neg_3(Self) -> Self +pub fn Div::mx_neg_32(Self) -> Self +pub fn Div::mx_neg_3_4(Self) -> Self +pub fn Div::mx_neg_3_5(Self) -> Self +pub fn Div::mx_neg_3p5(Self) -> Self +pub fn Div::mx_neg_4(Self) -> Self +pub fn Div::mx_neg_40(Self) -> Self +pub fn Div::mx_neg_48(Self) -> Self +pub fn Div::mx_neg_4_5(Self) -> Self +pub fn Div::mx_neg_5(Self) -> Self +pub fn Div::mx_neg_56(Self) -> Self +pub fn Div::mx_neg_5_6(Self) -> Self +pub fn Div::mx_neg_6(Self) -> Self +pub fn Div::mx_neg_64(Self) -> Self +pub fn Div::mx_neg_7(Self) -> Self +pub fn Div::mx_neg_72(Self) -> Self +pub fn Div::mx_neg_8(Self) -> Self +pub fn Div::mx_neg_80(Self) -> Self +pub fn Div::mx_neg_9(Self) -> Self +pub fn Div::mx_neg_96(Self) -> Self +pub fn Div::mx_neg_full(Self) -> Self +pub fn Div::mx_neg_px(Self) -> Self +pub fn Div::mx_px(Self) -> Self +pub fn Div::my(Self, &@geometry.IntoLength) -> Self +pub fn Div::my_0(Self) -> Self +pub fn Div::my_0p5(Self) -> Self +pub fn Div::my_1(Self) -> Self +pub fn Div::my_10(Self) -> Self +pub fn Div::my_11(Self) -> Self +pub fn Div::my_112(Self) -> Self +pub fn Div::my_12(Self) -> Self +pub fn Div::my_128(Self) -> Self +pub fn Div::my_16(Self) -> Self +pub fn Div::my_1_12(Self) -> Self +pub fn Div::my_1_2(Self) -> Self +pub fn Div::my_1_3(Self) -> Self +pub fn Div::my_1_4(Self) -> Self +pub fn Div::my_1_5(Self) -> Self +pub fn Div::my_1_6(Self) -> Self +pub fn Div::my_1p5(Self) -> Self +pub fn Div::my_2(Self) -> Self +pub fn Div::my_20(Self) -> Self +pub fn Div::my_24(Self) -> Self +pub fn Div::my_2_3(Self) -> Self +pub fn Div::my_2_4(Self) -> Self +pub fn Div::my_2_5(Self) -> Self +pub fn Div::my_2p5(Self) -> Self +pub fn Div::my_3(Self) -> Self +pub fn Div::my_32(Self) -> Self +pub fn Div::my_3_4(Self) -> Self +pub fn Div::my_3_5(Self) -> Self +pub fn Div::my_3p5(Self) -> Self +pub fn Div::my_4(Self) -> Self +pub fn Div::my_40(Self) -> Self +pub fn Div::my_48(Self) -> Self +pub fn Div::my_4_5(Self) -> Self +pub fn Div::my_5(Self) -> Self +pub fn Div::my_56(Self) -> Self +pub fn Div::my_5_6(Self) -> Self +pub fn Div::my_6(Self) -> Self +pub fn Div::my_64(Self) -> Self +pub fn Div::my_7(Self) -> Self +pub fn Div::my_72(Self) -> Self +pub fn Div::my_8(Self) -> Self +pub fn Div::my_80(Self) -> Self +pub fn Div::my_9(Self) -> Self +pub fn Div::my_96(Self) -> Self +pub fn Div::my_auto(Self) -> Self +pub fn Div::my_full(Self) -> Self +pub fn Div::my_neg_0(Self) -> Self +pub fn Div::my_neg_0p5(Self) -> Self +pub fn Div::my_neg_1(Self) -> Self +pub fn Div::my_neg_10(Self) -> Self +pub fn Div::my_neg_11(Self) -> Self +pub fn Div::my_neg_112(Self) -> Self +pub fn Div::my_neg_12(Self) -> Self +pub fn Div::my_neg_128(Self) -> Self +pub fn Div::my_neg_16(Self) -> Self +pub fn Div::my_neg_1_12(Self) -> Self +pub fn Div::my_neg_1_2(Self) -> Self +pub fn Div::my_neg_1_3(Self) -> Self +pub fn Div::my_neg_1_4(Self) -> Self +pub fn Div::my_neg_1_5(Self) -> Self +pub fn Div::my_neg_1_6(Self) -> Self +pub fn Div::my_neg_1p5(Self) -> Self +pub fn Div::my_neg_2(Self) -> Self +pub fn Div::my_neg_20(Self) -> Self +pub fn Div::my_neg_24(Self) -> Self +pub fn Div::my_neg_2_3(Self) -> Self +pub fn Div::my_neg_2_4(Self) -> Self +pub fn Div::my_neg_2_5(Self) -> Self +pub fn Div::my_neg_2p5(Self) -> Self +pub fn Div::my_neg_3(Self) -> Self +pub fn Div::my_neg_32(Self) -> Self +pub fn Div::my_neg_3_4(Self) -> Self +pub fn Div::my_neg_3_5(Self) -> Self +pub fn Div::my_neg_3p5(Self) -> Self +pub fn Div::my_neg_4(Self) -> Self +pub fn Div::my_neg_40(Self) -> Self +pub fn Div::my_neg_48(Self) -> Self +pub fn Div::my_neg_4_5(Self) -> Self +pub fn Div::my_neg_5(Self) -> Self +pub fn Div::my_neg_56(Self) -> Self +pub fn Div::my_neg_5_6(Self) -> Self +pub fn Div::my_neg_6(Self) -> Self +pub fn Div::my_neg_64(Self) -> Self +pub fn Div::my_neg_7(Self) -> Self +pub fn Div::my_neg_72(Self) -> Self +pub fn Div::my_neg_8(Self) -> Self +pub fn Div::my_neg_80(Self) -> Self +pub fn Div::my_neg_9(Self) -> Self +pub fn Div::my_neg_96(Self) -> Self +pub fn Div::my_neg_full(Self) -> Self +pub fn Div::my_neg_px(Self) -> Self +pub fn Div::my_px(Self) -> Self +pub fn Div::not_italic(Self) -> Self +pub fn Div::occlude(Self) -> Self +pub fn Div::on_click(Self, (@input.ClickEvent, @window.Window, @app.App) -> Unit) -> Self +pub fn Div::on_mouse_down(Self, @input.MouseButton, (@input.MouseDownEvent, @window.Window, @app.App) -> Unit) -> Self +pub fn Div::on_mouse_move(Self, (@input.MouseMoveEvent, @window.Window, @app.App) -> Unit) -> Self +pub fn Div::on_mouse_up(Self, @input.MouseButton, (@input.MouseUpEvent, @window.Window, @app.App) -> Unit) -> Self +pub fn Div::on_scroll_wheel(Self, (@input.ScrollWheelEvent, @window.Window, @app.App) -> Unit) -> Self +pub fn Div::opacity(Self, Double) -> Self +pub fn Div::overflow_hidden(Self) -> Self +pub fn Div::overflow_x_hidden(Self) -> Self +pub fn Div::overflow_y_hidden(Self) -> Self +pub fn Div::p(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Div::p_0(Self) -> Self +pub fn Div::p_0p5(Self) -> Self +pub fn Div::p_1(Self) -> Self +pub fn Div::p_10(Self) -> Self +pub fn Div::p_11(Self) -> Self +pub fn Div::p_112(Self) -> Self +pub fn Div::p_12(Self) -> Self +pub fn Div::p_128(Self) -> Self +pub fn Div::p_16(Self) -> Self +pub fn Div::p_1_12(Self) -> Self +pub fn Div::p_1_2(Self) -> Self +pub fn Div::p_1_3(Self) -> Self +pub fn Div::p_1_4(Self) -> Self +pub fn Div::p_1_5(Self) -> Self +pub fn Div::p_1_6(Self) -> Self +pub fn Div::p_1p5(Self) -> Self +pub fn Div::p_2(Self) -> Self +pub fn Div::p_20(Self) -> Self +pub fn Div::p_24(Self) -> Self +pub fn Div::p_2_3(Self) -> Self +pub fn Div::p_2_4(Self) -> Self +pub fn Div::p_2_5(Self) -> Self +pub fn Div::p_2p5(Self) -> Self +pub fn Div::p_3(Self) -> Self +pub fn Div::p_32(Self) -> Self +pub fn Div::p_3_4(Self) -> Self +pub fn Div::p_3_5(Self) -> Self +pub fn Div::p_3p5(Self) -> Self +pub fn Div::p_4(Self) -> Self +pub fn Div::p_40(Self) -> Self +pub fn Div::p_48(Self) -> Self +pub fn Div::p_4_5(Self) -> Self +pub fn Div::p_5(Self) -> Self +pub fn Div::p_56(Self) -> Self +pub fn Div::p_5_6(Self) -> Self +pub fn Div::p_6(Self) -> Self +pub fn Div::p_64(Self) -> Self +pub fn Div::p_7(Self) -> Self +pub fn Div::p_72(Self) -> Self +pub fn Div::p_8(Self) -> Self +pub fn Div::p_80(Self) -> Self +pub fn Div::p_9(Self) -> Self +pub fn Div::p_96(Self) -> Self +pub fn Div::p_full(Self) -> Self +pub fn Div::p_neg_0(Self) -> Self +pub fn Div::p_neg_0p5(Self) -> Self +pub fn Div::p_neg_1(Self) -> Self +pub fn Div::p_neg_10(Self) -> Self +pub fn Div::p_neg_11(Self) -> Self +pub fn Div::p_neg_112(Self) -> Self +pub fn Div::p_neg_12(Self) -> Self +pub fn Div::p_neg_128(Self) -> Self +pub fn Div::p_neg_16(Self) -> Self +pub fn Div::p_neg_1_12(Self) -> Self +pub fn Div::p_neg_1_2(Self) -> Self +pub fn Div::p_neg_1_3(Self) -> Self +pub fn Div::p_neg_1_4(Self) -> Self +pub fn Div::p_neg_1_5(Self) -> Self +pub fn Div::p_neg_1_6(Self) -> Self +pub fn Div::p_neg_1p5(Self) -> Self +pub fn Div::p_neg_2(Self) -> Self +pub fn Div::p_neg_20(Self) -> Self +pub fn Div::p_neg_24(Self) -> Self +pub fn Div::p_neg_2_3(Self) -> Self +pub fn Div::p_neg_2_4(Self) -> Self +pub fn Div::p_neg_2_5(Self) -> Self +pub fn Div::p_neg_2p5(Self) -> Self +pub fn Div::p_neg_3(Self) -> Self +pub fn Div::p_neg_32(Self) -> Self +pub fn Div::p_neg_3_4(Self) -> Self +pub fn Div::p_neg_3_5(Self) -> Self +pub fn Div::p_neg_3p5(Self) -> Self +pub fn Div::p_neg_4(Self) -> Self +pub fn Div::p_neg_40(Self) -> Self +pub fn Div::p_neg_48(Self) -> Self +pub fn Div::p_neg_4_5(Self) -> Self +pub fn Div::p_neg_5(Self) -> Self +pub fn Div::p_neg_56(Self) -> Self +pub fn Div::p_neg_5_6(Self) -> Self +pub fn Div::p_neg_6(Self) -> Self +pub fn Div::p_neg_64(Self) -> Self +pub fn Div::p_neg_7(Self) -> Self +pub fn Div::p_neg_72(Self) -> Self +pub fn Div::p_neg_8(Self) -> Self +pub fn Div::p_neg_80(Self) -> Self +pub fn Div::p_neg_9(Self) -> Self +pub fn Div::p_neg_96(Self) -> Self +pub fn Div::p_neg_full(Self) -> Self +pub fn Div::p_neg_px(Self) -> Self +pub fn Div::p_px(Self) -> Self +pub fn Div::pb(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Div::pb_0(Self) -> Self +pub fn Div::pb_0p5(Self) -> Self +pub fn Div::pb_1(Self) -> Self +pub fn Div::pb_10(Self) -> Self +pub fn Div::pb_11(Self) -> Self +pub fn Div::pb_112(Self) -> Self +pub fn Div::pb_12(Self) -> Self +pub fn Div::pb_128(Self) -> Self +pub fn Div::pb_16(Self) -> Self +pub fn Div::pb_1_12(Self) -> Self +pub fn Div::pb_1_2(Self) -> Self +pub fn Div::pb_1_3(Self) -> Self +pub fn Div::pb_1_4(Self) -> Self +pub fn Div::pb_1_5(Self) -> Self +pub fn Div::pb_1_6(Self) -> Self +pub fn Div::pb_1p5(Self) -> Self +pub fn Div::pb_2(Self) -> Self +pub fn Div::pb_20(Self) -> Self +pub fn Div::pb_24(Self) -> Self +pub fn Div::pb_2_3(Self) -> Self +pub fn Div::pb_2_4(Self) -> Self +pub fn Div::pb_2_5(Self) -> Self +pub fn Div::pb_2p5(Self) -> Self +pub fn Div::pb_3(Self) -> Self +pub fn Div::pb_32(Self) -> Self +pub fn Div::pb_3_4(Self) -> Self +pub fn Div::pb_3_5(Self) -> Self +pub fn Div::pb_3p5(Self) -> Self +pub fn Div::pb_4(Self) -> Self +pub fn Div::pb_40(Self) -> Self +pub fn Div::pb_48(Self) -> Self +pub fn Div::pb_4_5(Self) -> Self +pub fn Div::pb_5(Self) -> Self +pub fn Div::pb_56(Self) -> Self +pub fn Div::pb_5_6(Self) -> Self +pub fn Div::pb_6(Self) -> Self +pub fn Div::pb_64(Self) -> Self +pub fn Div::pb_7(Self) -> Self +pub fn Div::pb_72(Self) -> Self +pub fn Div::pb_8(Self) -> Self +pub fn Div::pb_80(Self) -> Self +pub fn Div::pb_9(Self) -> Self +pub fn Div::pb_96(Self) -> Self +pub fn Div::pb_full(Self) -> Self +pub fn Div::pb_neg_0(Self) -> Self +pub fn Div::pb_neg_0p5(Self) -> Self +pub fn Div::pb_neg_1(Self) -> Self +pub fn Div::pb_neg_10(Self) -> Self +pub fn Div::pb_neg_11(Self) -> Self +pub fn Div::pb_neg_112(Self) -> Self +pub fn Div::pb_neg_12(Self) -> Self +pub fn Div::pb_neg_128(Self) -> Self +pub fn Div::pb_neg_16(Self) -> Self +pub fn Div::pb_neg_1_12(Self) -> Self +pub fn Div::pb_neg_1_2(Self) -> Self +pub fn Div::pb_neg_1_3(Self) -> Self +pub fn Div::pb_neg_1_4(Self) -> Self +pub fn Div::pb_neg_1_5(Self) -> Self +pub fn Div::pb_neg_1_6(Self) -> Self +pub fn Div::pb_neg_1p5(Self) -> Self +pub fn Div::pb_neg_2(Self) -> Self +pub fn Div::pb_neg_20(Self) -> Self +pub fn Div::pb_neg_24(Self) -> Self +pub fn Div::pb_neg_2_3(Self) -> Self +pub fn Div::pb_neg_2_4(Self) -> Self +pub fn Div::pb_neg_2_5(Self) -> Self +pub fn Div::pb_neg_2p5(Self) -> Self +pub fn Div::pb_neg_3(Self) -> Self +pub fn Div::pb_neg_32(Self) -> Self +pub fn Div::pb_neg_3_4(Self) -> Self +pub fn Div::pb_neg_3_5(Self) -> Self +pub fn Div::pb_neg_3p5(Self) -> Self +pub fn Div::pb_neg_4(Self) -> Self +pub fn Div::pb_neg_40(Self) -> Self +pub fn Div::pb_neg_48(Self) -> Self +pub fn Div::pb_neg_4_5(Self) -> Self +pub fn Div::pb_neg_5(Self) -> Self +pub fn Div::pb_neg_56(Self) -> Self +pub fn Div::pb_neg_5_6(Self) -> Self +pub fn Div::pb_neg_6(Self) -> Self +pub fn Div::pb_neg_64(Self) -> Self +pub fn Div::pb_neg_7(Self) -> Self +pub fn Div::pb_neg_72(Self) -> Self +pub fn Div::pb_neg_8(Self) -> Self +pub fn Div::pb_neg_80(Self) -> Self +pub fn Div::pb_neg_9(Self) -> Self +pub fn Div::pb_neg_96(Self) -> Self +pub fn Div::pb_neg_full(Self) -> Self +pub fn Div::pb_neg_px(Self) -> Self +pub fn Div::pb_px(Self) -> Self +pub fn Div::pl(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Div::pl_0(Self) -> Self +pub fn Div::pl_0p5(Self) -> Self +pub fn Div::pl_1(Self) -> Self +pub fn Div::pl_10(Self) -> Self +pub fn Div::pl_11(Self) -> Self +pub fn Div::pl_112(Self) -> Self +pub fn Div::pl_12(Self) -> Self +pub fn Div::pl_128(Self) -> Self +pub fn Div::pl_16(Self) -> Self +pub fn Div::pl_1_12(Self) -> Self +pub fn Div::pl_1_2(Self) -> Self +pub fn Div::pl_1_3(Self) -> Self +pub fn Div::pl_1_4(Self) -> Self +pub fn Div::pl_1_5(Self) -> Self +pub fn Div::pl_1_6(Self) -> Self +pub fn Div::pl_1p5(Self) -> Self +pub fn Div::pl_2(Self) -> Self +pub fn Div::pl_20(Self) -> Self +pub fn Div::pl_24(Self) -> Self +pub fn Div::pl_2_3(Self) -> Self +pub fn Div::pl_2_4(Self) -> Self +pub fn Div::pl_2_5(Self) -> Self +pub fn Div::pl_2p5(Self) -> Self +pub fn Div::pl_3(Self) -> Self +pub fn Div::pl_32(Self) -> Self +pub fn Div::pl_3_4(Self) -> Self +pub fn Div::pl_3_5(Self) -> Self +pub fn Div::pl_3p5(Self) -> Self +pub fn Div::pl_4(Self) -> Self +pub fn Div::pl_40(Self) -> Self +pub fn Div::pl_48(Self) -> Self +pub fn Div::pl_4_5(Self) -> Self +pub fn Div::pl_5(Self) -> Self +pub fn Div::pl_56(Self) -> Self +pub fn Div::pl_5_6(Self) -> Self +pub fn Div::pl_6(Self) -> Self +pub fn Div::pl_64(Self) -> Self +pub fn Div::pl_7(Self) -> Self +pub fn Div::pl_72(Self) -> Self +pub fn Div::pl_8(Self) -> Self +pub fn Div::pl_80(Self) -> Self +pub fn Div::pl_9(Self) -> Self +pub fn Div::pl_96(Self) -> Self +pub fn Div::pl_full(Self) -> Self +pub fn Div::pl_neg_0(Self) -> Self +pub fn Div::pl_neg_0p5(Self) -> Self +pub fn Div::pl_neg_1(Self) -> Self +pub fn Div::pl_neg_10(Self) -> Self +pub fn Div::pl_neg_11(Self) -> Self +pub fn Div::pl_neg_112(Self) -> Self +pub fn Div::pl_neg_12(Self) -> Self +pub fn Div::pl_neg_128(Self) -> Self +pub fn Div::pl_neg_16(Self) -> Self +pub fn Div::pl_neg_1_12(Self) -> Self +pub fn Div::pl_neg_1_2(Self) -> Self +pub fn Div::pl_neg_1_3(Self) -> Self +pub fn Div::pl_neg_1_4(Self) -> Self +pub fn Div::pl_neg_1_5(Self) -> Self +pub fn Div::pl_neg_1_6(Self) -> Self +pub fn Div::pl_neg_1p5(Self) -> Self +pub fn Div::pl_neg_2(Self) -> Self +pub fn Div::pl_neg_20(Self) -> Self +pub fn Div::pl_neg_24(Self) -> Self +pub fn Div::pl_neg_2_3(Self) -> Self +pub fn Div::pl_neg_2_4(Self) -> Self +pub fn Div::pl_neg_2_5(Self) -> Self +pub fn Div::pl_neg_2p5(Self) -> Self +pub fn Div::pl_neg_3(Self) -> Self +pub fn Div::pl_neg_32(Self) -> Self +pub fn Div::pl_neg_3_4(Self) -> Self +pub fn Div::pl_neg_3_5(Self) -> Self +pub fn Div::pl_neg_3p5(Self) -> Self +pub fn Div::pl_neg_4(Self) -> Self +pub fn Div::pl_neg_40(Self) -> Self +pub fn Div::pl_neg_48(Self) -> Self +pub fn Div::pl_neg_4_5(Self) -> Self +pub fn Div::pl_neg_5(Self) -> Self +pub fn Div::pl_neg_56(Self) -> Self +pub fn Div::pl_neg_5_6(Self) -> Self +pub fn Div::pl_neg_6(Self) -> Self +pub fn Div::pl_neg_64(Self) -> Self +pub fn Div::pl_neg_7(Self) -> Self +pub fn Div::pl_neg_72(Self) -> Self +pub fn Div::pl_neg_8(Self) -> Self +pub fn Div::pl_neg_80(Self) -> Self +pub fn Div::pl_neg_9(Self) -> Self +pub fn Div::pl_neg_96(Self) -> Self +pub fn Div::pl_neg_full(Self) -> Self +pub fn Div::pl_neg_px(Self) -> Self +pub fn Div::pl_px(Self) -> Self +pub fn Div::pr(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Div::pr_0(Self) -> Self +pub fn Div::pr_0p5(Self) -> Self +pub fn Div::pr_1(Self) -> Self +pub fn Div::pr_10(Self) -> Self +pub fn Div::pr_11(Self) -> Self +pub fn Div::pr_112(Self) -> Self +pub fn Div::pr_12(Self) -> Self +pub fn Div::pr_128(Self) -> Self +pub fn Div::pr_16(Self) -> Self +pub fn Div::pr_1_12(Self) -> Self +pub fn Div::pr_1_2(Self) -> Self +pub fn Div::pr_1_3(Self) -> Self +pub fn Div::pr_1_4(Self) -> Self +pub fn Div::pr_1_5(Self) -> Self +pub fn Div::pr_1_6(Self) -> Self +pub fn Div::pr_1p5(Self) -> Self +pub fn Div::pr_2(Self) -> Self +pub fn Div::pr_20(Self) -> Self +pub fn Div::pr_24(Self) -> Self +pub fn Div::pr_2_3(Self) -> Self +pub fn Div::pr_2_4(Self) -> Self +pub fn Div::pr_2_5(Self) -> Self +pub fn Div::pr_2p5(Self) -> Self +pub fn Div::pr_3(Self) -> Self +pub fn Div::pr_32(Self) -> Self +pub fn Div::pr_3_4(Self) -> Self +pub fn Div::pr_3_5(Self) -> Self +pub fn Div::pr_3p5(Self) -> Self +pub fn Div::pr_4(Self) -> Self +pub fn Div::pr_40(Self) -> Self +pub fn Div::pr_48(Self) -> Self +pub fn Div::pr_4_5(Self) -> Self +pub fn Div::pr_5(Self) -> Self +pub fn Div::pr_56(Self) -> Self +pub fn Div::pr_5_6(Self) -> Self +pub fn Div::pr_6(Self) -> Self +pub fn Div::pr_64(Self) -> Self +pub fn Div::pr_7(Self) -> Self +pub fn Div::pr_72(Self) -> Self +pub fn Div::pr_8(Self) -> Self +pub fn Div::pr_80(Self) -> Self +pub fn Div::pr_9(Self) -> Self +pub fn Div::pr_96(Self) -> Self +pub fn Div::pr_full(Self) -> Self +pub fn Div::pr_neg_0(Self) -> Self +pub fn Div::pr_neg_0p5(Self) -> Self +pub fn Div::pr_neg_1(Self) -> Self +pub fn Div::pr_neg_10(Self) -> Self +pub fn Div::pr_neg_11(Self) -> Self +pub fn Div::pr_neg_112(Self) -> Self +pub fn Div::pr_neg_12(Self) -> Self +pub fn Div::pr_neg_128(Self) -> Self +pub fn Div::pr_neg_16(Self) -> Self +pub fn Div::pr_neg_1_12(Self) -> Self +pub fn Div::pr_neg_1_2(Self) -> Self +pub fn Div::pr_neg_1_3(Self) -> Self +pub fn Div::pr_neg_1_4(Self) -> Self +pub fn Div::pr_neg_1_5(Self) -> Self +pub fn Div::pr_neg_1_6(Self) -> Self +pub fn Div::pr_neg_1p5(Self) -> Self +pub fn Div::pr_neg_2(Self) -> Self +pub fn Div::pr_neg_20(Self) -> Self +pub fn Div::pr_neg_24(Self) -> Self +pub fn Div::pr_neg_2_3(Self) -> Self +pub fn Div::pr_neg_2_4(Self) -> Self +pub fn Div::pr_neg_2_5(Self) -> Self +pub fn Div::pr_neg_2p5(Self) -> Self +pub fn Div::pr_neg_3(Self) -> Self +pub fn Div::pr_neg_32(Self) -> Self +pub fn Div::pr_neg_3_4(Self) -> Self +pub fn Div::pr_neg_3_5(Self) -> Self +pub fn Div::pr_neg_3p5(Self) -> Self +pub fn Div::pr_neg_4(Self) -> Self +pub fn Div::pr_neg_40(Self) -> Self +pub fn Div::pr_neg_48(Self) -> Self +pub fn Div::pr_neg_4_5(Self) -> Self +pub fn Div::pr_neg_5(Self) -> Self +pub fn Div::pr_neg_56(Self) -> Self +pub fn Div::pr_neg_5_6(Self) -> Self +pub fn Div::pr_neg_6(Self) -> Self +pub fn Div::pr_neg_64(Self) -> Self +pub fn Div::pr_neg_7(Self) -> Self +pub fn Div::pr_neg_72(Self) -> Self +pub fn Div::pr_neg_8(Self) -> Self +pub fn Div::pr_neg_80(Self) -> Self +pub fn Div::pr_neg_9(Self) -> Self +pub fn Div::pr_neg_96(Self) -> Self +pub fn Div::pr_neg_full(Self) -> Self +pub fn Div::pr_neg_px(Self) -> Self +pub fn Div::pr_px(Self) -> Self +pub fn Div::pt(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Div::pt_0(Self) -> Self +pub fn Div::pt_0p5(Self) -> Self +pub fn Div::pt_1(Self) -> Self +pub fn Div::pt_10(Self) -> Self +pub fn Div::pt_11(Self) -> Self +pub fn Div::pt_112(Self) -> Self +pub fn Div::pt_12(Self) -> Self +pub fn Div::pt_128(Self) -> Self +pub fn Div::pt_16(Self) -> Self +pub fn Div::pt_1_12(Self) -> Self +pub fn Div::pt_1_2(Self) -> Self +pub fn Div::pt_1_3(Self) -> Self +pub fn Div::pt_1_4(Self) -> Self +pub fn Div::pt_1_5(Self) -> Self +pub fn Div::pt_1_6(Self) -> Self +pub fn Div::pt_1p5(Self) -> Self +pub fn Div::pt_2(Self) -> Self +pub fn Div::pt_20(Self) -> Self +pub fn Div::pt_24(Self) -> Self +pub fn Div::pt_2_3(Self) -> Self +pub fn Div::pt_2_4(Self) -> Self +pub fn Div::pt_2_5(Self) -> Self +pub fn Div::pt_2p5(Self) -> Self +pub fn Div::pt_3(Self) -> Self +pub fn Div::pt_32(Self) -> Self +pub fn Div::pt_3_4(Self) -> Self +pub fn Div::pt_3_5(Self) -> Self +pub fn Div::pt_3p5(Self) -> Self +pub fn Div::pt_4(Self) -> Self +pub fn Div::pt_40(Self) -> Self +pub fn Div::pt_48(Self) -> Self +pub fn Div::pt_4_5(Self) -> Self +pub fn Div::pt_5(Self) -> Self +pub fn Div::pt_56(Self) -> Self +pub fn Div::pt_5_6(Self) -> Self +pub fn Div::pt_6(Self) -> Self +pub fn Div::pt_64(Self) -> Self +pub fn Div::pt_7(Self) -> Self +pub fn Div::pt_72(Self) -> Self +pub fn Div::pt_8(Self) -> Self +pub fn Div::pt_80(Self) -> Self +pub fn Div::pt_9(Self) -> Self +pub fn Div::pt_96(Self) -> Self +pub fn Div::pt_full(Self) -> Self +pub fn Div::pt_neg_0(Self) -> Self +pub fn Div::pt_neg_0p5(Self) -> Self +pub fn Div::pt_neg_1(Self) -> Self +pub fn Div::pt_neg_10(Self) -> Self +pub fn Div::pt_neg_11(Self) -> Self +pub fn Div::pt_neg_112(Self) -> Self +pub fn Div::pt_neg_12(Self) -> Self +pub fn Div::pt_neg_128(Self) -> Self +pub fn Div::pt_neg_16(Self) -> Self +pub fn Div::pt_neg_1_12(Self) -> Self +pub fn Div::pt_neg_1_2(Self) -> Self +pub fn Div::pt_neg_1_3(Self) -> Self +pub fn Div::pt_neg_1_4(Self) -> Self +pub fn Div::pt_neg_1_5(Self) -> Self +pub fn Div::pt_neg_1_6(Self) -> Self +pub fn Div::pt_neg_1p5(Self) -> Self +pub fn Div::pt_neg_2(Self) -> Self +pub fn Div::pt_neg_20(Self) -> Self +pub fn Div::pt_neg_24(Self) -> Self +pub fn Div::pt_neg_2_3(Self) -> Self +pub fn Div::pt_neg_2_4(Self) -> Self +pub fn Div::pt_neg_2_5(Self) -> Self +pub fn Div::pt_neg_2p5(Self) -> Self +pub fn Div::pt_neg_3(Self) -> Self +pub fn Div::pt_neg_32(Self) -> Self +pub fn Div::pt_neg_3_4(Self) -> Self +pub fn Div::pt_neg_3_5(Self) -> Self +pub fn Div::pt_neg_3p5(Self) -> Self +pub fn Div::pt_neg_4(Self) -> Self +pub fn Div::pt_neg_40(Self) -> Self +pub fn Div::pt_neg_48(Self) -> Self +pub fn Div::pt_neg_4_5(Self) -> Self +pub fn Div::pt_neg_5(Self) -> Self +pub fn Div::pt_neg_56(Self) -> Self +pub fn Div::pt_neg_5_6(Self) -> Self +pub fn Div::pt_neg_6(Self) -> Self +pub fn Div::pt_neg_64(Self) -> Self +pub fn Div::pt_neg_7(Self) -> Self +pub fn Div::pt_neg_72(Self) -> Self +pub fn Div::pt_neg_8(Self) -> Self +pub fn Div::pt_neg_80(Self) -> Self +pub fn Div::pt_neg_9(Self) -> Self +pub fn Div::pt_neg_96(Self) -> Self +pub fn Div::pt_neg_full(Self) -> Self +pub fn Div::pt_neg_px(Self) -> Self +pub fn Div::pt_px(Self) -> Self +pub fn Div::px(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Div::px_0(Self) -> Self +pub fn Div::px_0p5(Self) -> Self +pub fn Div::px_1(Self) -> Self +pub fn Div::px_10(Self) -> Self +pub fn Div::px_11(Self) -> Self +pub fn Div::px_112(Self) -> Self +pub fn Div::px_12(Self) -> Self +pub fn Div::px_128(Self) -> Self +pub fn Div::px_16(Self) -> Self +pub fn Div::px_1_12(Self) -> Self +pub fn Div::px_1_2(Self) -> Self +pub fn Div::px_1_3(Self) -> Self +pub fn Div::px_1_4(Self) -> Self +pub fn Div::px_1_5(Self) -> Self +pub fn Div::px_1_6(Self) -> Self +pub fn Div::px_1p5(Self) -> Self +pub fn Div::px_2(Self) -> Self +pub fn Div::px_20(Self) -> Self +pub fn Div::px_24(Self) -> Self +pub fn Div::px_2_3(Self) -> Self +pub fn Div::px_2_4(Self) -> Self +pub fn Div::px_2_5(Self) -> Self +pub fn Div::px_2p5(Self) -> Self +pub fn Div::px_3(Self) -> Self +pub fn Div::px_32(Self) -> Self +pub fn Div::px_3_4(Self) -> Self +pub fn Div::px_3_5(Self) -> Self +pub fn Div::px_3p5(Self) -> Self +pub fn Div::px_4(Self) -> Self +pub fn Div::px_40(Self) -> Self +pub fn Div::px_48(Self) -> Self +pub fn Div::px_4_5(Self) -> Self +pub fn Div::px_5(Self) -> Self +pub fn Div::px_56(Self) -> Self +pub fn Div::px_5_6(Self) -> Self +pub fn Div::px_6(Self) -> Self +pub fn Div::px_64(Self) -> Self +pub fn Div::px_7(Self) -> Self +pub fn Div::px_72(Self) -> Self +pub fn Div::px_8(Self) -> Self +pub fn Div::px_80(Self) -> Self +pub fn Div::px_9(Self) -> Self +pub fn Div::px_96(Self) -> Self +pub fn Div::px_full(Self) -> Self +pub fn Div::px_neg_0(Self) -> Self +pub fn Div::px_neg_0p5(Self) -> Self +pub fn Div::px_neg_1(Self) -> Self +pub fn Div::px_neg_10(Self) -> Self +pub fn Div::px_neg_11(Self) -> Self +pub fn Div::px_neg_112(Self) -> Self +pub fn Div::px_neg_12(Self) -> Self +pub fn Div::px_neg_128(Self) -> Self +pub fn Div::px_neg_16(Self) -> Self +pub fn Div::px_neg_1_12(Self) -> Self +pub fn Div::px_neg_1_2(Self) -> Self +pub fn Div::px_neg_1_3(Self) -> Self +pub fn Div::px_neg_1_4(Self) -> Self +pub fn Div::px_neg_1_5(Self) -> Self +pub fn Div::px_neg_1_6(Self) -> Self +pub fn Div::px_neg_1p5(Self) -> Self +pub fn Div::px_neg_2(Self) -> Self +pub fn Div::px_neg_20(Self) -> Self +pub fn Div::px_neg_24(Self) -> Self +pub fn Div::px_neg_2_3(Self) -> Self +pub fn Div::px_neg_2_4(Self) -> Self +pub fn Div::px_neg_2_5(Self) -> Self +pub fn Div::px_neg_2p5(Self) -> Self +pub fn Div::px_neg_3(Self) -> Self +pub fn Div::px_neg_32(Self) -> Self +pub fn Div::px_neg_3_4(Self) -> Self +pub fn Div::px_neg_3_5(Self) -> Self +pub fn Div::px_neg_3p5(Self) -> Self +pub fn Div::px_neg_4(Self) -> Self +pub fn Div::px_neg_40(Self) -> Self +pub fn Div::px_neg_48(Self) -> Self +pub fn Div::px_neg_4_5(Self) -> Self +pub fn Div::px_neg_5(Self) -> Self +pub fn Div::px_neg_56(Self) -> Self +pub fn Div::px_neg_5_6(Self) -> Self +pub fn Div::px_neg_6(Self) -> Self +pub fn Div::px_neg_64(Self) -> Self +pub fn Div::px_neg_7(Self) -> Self +pub fn Div::px_neg_72(Self) -> Self +pub fn Div::px_neg_8(Self) -> Self +pub fn Div::px_neg_80(Self) -> Self +pub fn Div::px_neg_9(Self) -> Self +pub fn Div::px_neg_96(Self) -> Self +pub fn Div::px_neg_full(Self) -> Self +pub fn Div::px_neg_px(Self) -> Self +pub fn Div::px_px(Self) -> Self +pub fn Div::py(Self, &@geometry.IntoDefiniteLength) -> Self +pub fn Div::py_0(Self) -> Self +pub fn Div::py_0p5(Self) -> Self +pub fn Div::py_1(Self) -> Self +pub fn Div::py_10(Self) -> Self +pub fn Div::py_11(Self) -> Self +pub fn Div::py_112(Self) -> Self +pub fn Div::py_12(Self) -> Self +pub fn Div::py_128(Self) -> Self +pub fn Div::py_16(Self) -> Self +pub fn Div::py_1_12(Self) -> Self +pub fn Div::py_1_2(Self) -> Self +pub fn Div::py_1_3(Self) -> Self +pub fn Div::py_1_4(Self) -> Self +pub fn Div::py_1_5(Self) -> Self +pub fn Div::py_1_6(Self) -> Self +pub fn Div::py_1p5(Self) -> Self +pub fn Div::py_2(Self) -> Self +pub fn Div::py_20(Self) -> Self +pub fn Div::py_24(Self) -> Self +pub fn Div::py_2_3(Self) -> Self +pub fn Div::py_2_4(Self) -> Self +pub fn Div::py_2_5(Self) -> Self +pub fn Div::py_2p5(Self) -> Self +pub fn Div::py_3(Self) -> Self +pub fn Div::py_32(Self) -> Self +pub fn Div::py_3_4(Self) -> Self +pub fn Div::py_3_5(Self) -> Self +pub fn Div::py_3p5(Self) -> Self +pub fn Div::py_4(Self) -> Self +pub fn Div::py_40(Self) -> Self +pub fn Div::py_48(Self) -> Self +pub fn Div::py_4_5(Self) -> Self +pub fn Div::py_5(Self) -> Self +pub fn Div::py_56(Self) -> Self +pub fn Div::py_5_6(Self) -> Self +pub fn Div::py_6(Self) -> Self +pub fn Div::py_64(Self) -> Self +pub fn Div::py_7(Self) -> Self +pub fn Div::py_72(Self) -> Self +pub fn Div::py_8(Self) -> Self +pub fn Div::py_80(Self) -> Self +pub fn Div::py_9(Self) -> Self +pub fn Div::py_96(Self) -> Self +pub fn Div::py_full(Self) -> Self +pub fn Div::py_neg_0(Self) -> Self +pub fn Div::py_neg_0p5(Self) -> Self +pub fn Div::py_neg_1(Self) -> Self +pub fn Div::py_neg_10(Self) -> Self +pub fn Div::py_neg_11(Self) -> Self +pub fn Div::py_neg_112(Self) -> Self +pub fn Div::py_neg_12(Self) -> Self +pub fn Div::py_neg_128(Self) -> Self +pub fn Div::py_neg_16(Self) -> Self +pub fn Div::py_neg_1_12(Self) -> Self +pub fn Div::py_neg_1_2(Self) -> Self +pub fn Div::py_neg_1_3(Self) -> Self +pub fn Div::py_neg_1_4(Self) -> Self +pub fn Div::py_neg_1_5(Self) -> Self +pub fn Div::py_neg_1_6(Self) -> Self +pub fn Div::py_neg_1p5(Self) -> Self +pub fn Div::py_neg_2(Self) -> Self +pub fn Div::py_neg_20(Self) -> Self +pub fn Div::py_neg_24(Self) -> Self +pub fn Div::py_neg_2_3(Self) -> Self +pub fn Div::py_neg_2_4(Self) -> Self +pub fn Div::py_neg_2_5(Self) -> Self +pub fn Div::py_neg_2p5(Self) -> Self +pub fn Div::py_neg_3(Self) -> Self +pub fn Div::py_neg_32(Self) -> Self +pub fn Div::py_neg_3_4(Self) -> Self +pub fn Div::py_neg_3_5(Self) -> Self +pub fn Div::py_neg_3p5(Self) -> Self +pub fn Div::py_neg_4(Self) -> Self +pub fn Div::py_neg_40(Self) -> Self +pub fn Div::py_neg_48(Self) -> Self +pub fn Div::py_neg_4_5(Self) -> Self +pub fn Div::py_neg_5(Self) -> Self +pub fn Div::py_neg_56(Self) -> Self +pub fn Div::py_neg_5_6(Self) -> Self +pub fn Div::py_neg_6(Self) -> Self +pub fn Div::py_neg_64(Self) -> Self +pub fn Div::py_neg_7(Self) -> Self +pub fn Div::py_neg_72(Self) -> Self +pub fn Div::py_neg_8(Self) -> Self +pub fn Div::py_neg_80(Self) -> Self +pub fn Div::py_neg_9(Self) -> Self +pub fn Div::py_neg_96(Self) -> Self +pub fn Div::py_neg_full(Self) -> Self +pub fn Div::py_neg_px(Self) -> Self +pub fn Div::py_px(Self) -> Self +pub fn Div::relative(Self) -> Self +pub fn Div::right(Self, &@geometry.IntoLength) -> Self +pub fn Div::right_0(Self) -> Self +pub fn Div::right_0p5(Self) -> Self +pub fn Div::right_1(Self) -> Self +pub fn Div::right_10(Self) -> Self +pub fn Div::right_11(Self) -> Self +pub fn Div::right_112(Self) -> Self +pub fn Div::right_12(Self) -> Self +pub fn Div::right_128(Self) -> Self +pub fn Div::right_16(Self) -> Self +pub fn Div::right_1_12(Self) -> Self +pub fn Div::right_1_2(Self) -> Self +pub fn Div::right_1_3(Self) -> Self +pub fn Div::right_1_4(Self) -> Self +pub fn Div::right_1_5(Self) -> Self +pub fn Div::right_1_6(Self) -> Self +pub fn Div::right_1p5(Self) -> Self +pub fn Div::right_2(Self) -> Self +pub fn Div::right_20(Self) -> Self +pub fn Div::right_24(Self) -> Self +pub fn Div::right_2_3(Self) -> Self +pub fn Div::right_2_4(Self) -> Self +pub fn Div::right_2_5(Self) -> Self +pub fn Div::right_2p5(Self) -> Self +pub fn Div::right_3(Self) -> Self +pub fn Div::right_32(Self) -> Self +pub fn Div::right_3_4(Self) -> Self +pub fn Div::right_3_5(Self) -> Self +pub fn Div::right_3p5(Self) -> Self +pub fn Div::right_4(Self) -> Self +pub fn Div::right_40(Self) -> Self +pub fn Div::right_48(Self) -> Self +pub fn Div::right_4_5(Self) -> Self +pub fn Div::right_5(Self) -> Self +pub fn Div::right_56(Self) -> Self +pub fn Div::right_5_6(Self) -> Self +pub fn Div::right_6(Self) -> Self +pub fn Div::right_64(Self) -> Self +pub fn Div::right_7(Self) -> Self +pub fn Div::right_72(Self) -> Self +pub fn Div::right_8(Self) -> Self +pub fn Div::right_80(Self) -> Self +pub fn Div::right_9(Self) -> Self +pub fn Div::right_96(Self) -> Self +pub fn Div::right_auto(Self) -> Self +pub fn Div::right_full(Self) -> Self +pub fn Div::right_neg_0(Self) -> Self +pub fn Div::right_neg_0p5(Self) -> Self +pub fn Div::right_neg_1(Self) -> Self +pub fn Div::right_neg_10(Self) -> Self +pub fn Div::right_neg_11(Self) -> Self +pub fn Div::right_neg_112(Self) -> Self +pub fn Div::right_neg_12(Self) -> Self +pub fn Div::right_neg_128(Self) -> Self +pub fn Div::right_neg_16(Self) -> Self +pub fn Div::right_neg_1_12(Self) -> Self +pub fn Div::right_neg_1_2(Self) -> Self +pub fn Div::right_neg_1_3(Self) -> Self +pub fn Div::right_neg_1_4(Self) -> Self +pub fn Div::right_neg_1_5(Self) -> Self +pub fn Div::right_neg_1_6(Self) -> Self +pub fn Div::right_neg_1p5(Self) -> Self +pub fn Div::right_neg_2(Self) -> Self +pub fn Div::right_neg_20(Self) -> Self +pub fn Div::right_neg_24(Self) -> Self +pub fn Div::right_neg_2_3(Self) -> Self +pub fn Div::right_neg_2_4(Self) -> Self +pub fn Div::right_neg_2_5(Self) -> Self +pub fn Div::right_neg_2p5(Self) -> Self +pub fn Div::right_neg_3(Self) -> Self +pub fn Div::right_neg_32(Self) -> Self +pub fn Div::right_neg_3_4(Self) -> Self +pub fn Div::right_neg_3_5(Self) -> Self +pub fn Div::right_neg_3p5(Self) -> Self +pub fn Div::right_neg_4(Self) -> Self +pub fn Div::right_neg_40(Self) -> Self +pub fn Div::right_neg_48(Self) -> Self +pub fn Div::right_neg_4_5(Self) -> Self +pub fn Div::right_neg_5(Self) -> Self +pub fn Div::right_neg_56(Self) -> Self +pub fn Div::right_neg_5_6(Self) -> Self +pub fn Div::right_neg_6(Self) -> Self +pub fn Div::right_neg_64(Self) -> Self +pub fn Div::right_neg_7(Self) -> Self +pub fn Div::right_neg_72(Self) -> Self +pub fn Div::right_neg_8(Self) -> Self +pub fn Div::right_neg_80(Self) -> Self +pub fn Div::right_neg_9(Self) -> Self +pub fn Div::right_neg_96(Self) -> Self +pub fn Div::right_neg_full(Self) -> Self +pub fn Div::right_neg_px(Self) -> Self +pub fn Div::right_px(Self) -> Self +pub fn Div::rounded(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::rounded_2xl(Self) -> Self +pub fn Div::rounded_3xl(Self) -> Self +pub fn Div::rounded_b(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::rounded_b_2xl(Self) -> Self +pub fn Div::rounded_b_3xl(Self) -> Self +pub fn Div::rounded_b_full(Self) -> Self +pub fn Div::rounded_b_lg(Self) -> Self +pub fn Div::rounded_b_md(Self) -> Self +pub fn Div::rounded_b_none(Self) -> Self +pub fn Div::rounded_b_sm(Self) -> Self +pub fn Div::rounded_b_xl(Self) -> Self +pub fn Div::rounded_b_xs(Self) -> Self +pub fn Div::rounded_bl(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::rounded_bl_2xl(Self) -> Self +pub fn Div::rounded_bl_3xl(Self) -> Self +pub fn Div::rounded_bl_full(Self) -> Self +pub fn Div::rounded_bl_lg(Self) -> Self +pub fn Div::rounded_bl_md(Self) -> Self +pub fn Div::rounded_bl_none(Self) -> Self +pub fn Div::rounded_bl_sm(Self) -> Self +pub fn Div::rounded_bl_xl(Self) -> Self +pub fn Div::rounded_bl_xs(Self) -> Self +pub fn Div::rounded_br(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::rounded_br_2xl(Self) -> Self +pub fn Div::rounded_br_3xl(Self) -> Self +pub fn Div::rounded_br_full(Self) -> Self +pub fn Div::rounded_br_lg(Self) -> Self +pub fn Div::rounded_br_md(Self) -> Self +pub fn Div::rounded_br_none(Self) -> Self +pub fn Div::rounded_br_sm(Self) -> Self +pub fn Div::rounded_br_xl(Self) -> Self +pub fn Div::rounded_br_xs(Self) -> Self +pub fn Div::rounded_full(Self) -> Self +pub fn Div::rounded_l(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::rounded_l_2xl(Self) -> Self +pub fn Div::rounded_l_3xl(Self) -> Self +pub fn Div::rounded_l_full(Self) -> Self +pub fn Div::rounded_l_lg(Self) -> Self +pub fn Div::rounded_l_md(Self) -> Self +pub fn Div::rounded_l_none(Self) -> Self +pub fn Div::rounded_l_sm(Self) -> Self +pub fn Div::rounded_l_xl(Self) -> Self +pub fn Div::rounded_l_xs(Self) -> Self +pub fn Div::rounded_lg(Self) -> Self +pub fn Div::rounded_md(Self) -> Self +pub fn Div::rounded_none(Self) -> Self +pub fn Div::rounded_r(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::rounded_r_2xl(Self) -> Self +pub fn Div::rounded_r_3xl(Self) -> Self +pub fn Div::rounded_r_full(Self) -> Self +pub fn Div::rounded_r_lg(Self) -> Self +pub fn Div::rounded_r_md(Self) -> Self +pub fn Div::rounded_r_none(Self) -> Self +pub fn Div::rounded_r_sm(Self) -> Self +pub fn Div::rounded_r_xl(Self) -> Self +pub fn Div::rounded_r_xs(Self) -> Self +pub fn Div::rounded_sm(Self) -> Self +pub fn Div::rounded_t(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::rounded_t_2xl(Self) -> Self +pub fn Div::rounded_t_3xl(Self) -> Self +pub fn Div::rounded_t_full(Self) -> Self +pub fn Div::rounded_t_lg(Self) -> Self +pub fn Div::rounded_t_md(Self) -> Self +pub fn Div::rounded_t_none(Self) -> Self +pub fn Div::rounded_t_sm(Self) -> Self +pub fn Div::rounded_t_xl(Self) -> Self +pub fn Div::rounded_t_xs(Self) -> Self +pub fn Div::rounded_tl(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::rounded_tl_2xl(Self) -> Self +pub fn Div::rounded_tl_3xl(Self) -> Self +pub fn Div::rounded_tl_full(Self) -> Self +pub fn Div::rounded_tl_lg(Self) -> Self +pub fn Div::rounded_tl_md(Self) -> Self +pub fn Div::rounded_tl_none(Self) -> Self +pub fn Div::rounded_tl_sm(Self) -> Self +pub fn Div::rounded_tl_xl(Self) -> Self +pub fn Div::rounded_tl_xs(Self) -> Self +pub fn Div::rounded_tr(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::rounded_tr_2xl(Self) -> Self +pub fn Div::rounded_tr_3xl(Self) -> Self +pub fn Div::rounded_tr_full(Self) -> Self +pub fn Div::rounded_tr_lg(Self) -> Self +pub fn Div::rounded_tr_md(Self) -> Self +pub fn Div::rounded_tr_none(Self) -> Self +pub fn Div::rounded_tr_sm(Self) -> Self +pub fn Div::rounded_tr_xl(Self) -> Self +pub fn Div::rounded_tr_xs(Self) -> Self +pub fn Div::rounded_xl(Self) -> Self +pub fn Div::rounded_xs(Self) -> Self +pub fn Div::row_end(Self, Int32) -> Self +pub fn Div::row_end_auto(Self) -> Self +pub fn Div::row_span(Self, Int32) -> Self +pub fn Div::row_span_full(Self) -> Self +pub fn Div::row_start(Self, Int32) -> Self +pub fn Div::row_start_auto(Self) -> Self +pub fn Div::scrollbar_width(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::self_baseline(Self) -> Self +pub fn Div::self_center(Self) -> Self +pub fn Div::self_end(Self) -> Self +pub fn Div::self_flex_end(Self) -> Self +pub fn Div::self_flex_start(Self) -> Self +pub fn Div::self_start(Self) -> Self +pub fn Div::self_stretch(Self) -> Self +pub fn Div::shadow(Self, Array[@style.BoxShadow]) -> Self +pub fn Div::shadow_2xl(Self) -> Self +pub fn Div::shadow_2xs(Self) -> Self +pub fn Div::shadow_lg(Self) -> Self +pub fn Div::shadow_md(Self) -> Self +pub fn Div::shadow_none(Self) -> Self +pub fn Div::shadow_sm(Self) -> Self +pub fn Div::shadow_xl(Self) -> Self +pub fn Div::shadow_xs(Self) -> Self +pub fn Div::size(Self, &@geometry.IntoLength) -> Self +pub fn Div::size_0(Self) -> Self +pub fn Div::size_0p5(Self) -> Self +pub fn Div::size_1(Self) -> Self +pub fn Div::size_10(Self) -> Self +pub fn Div::size_11(Self) -> Self +pub fn Div::size_112(Self) -> Self +pub fn Div::size_12(Self) -> Self +pub fn Div::size_128(Self) -> Self +pub fn Div::size_16(Self) -> Self +pub fn Div::size_1_12(Self) -> Self +pub fn Div::size_1_2(Self) -> Self +pub fn Div::size_1_3(Self) -> Self +pub fn Div::size_1_4(Self) -> Self +pub fn Div::size_1_5(Self) -> Self +pub fn Div::size_1_6(Self) -> Self +pub fn Div::size_1p5(Self) -> Self +pub fn Div::size_2(Self) -> Self +pub fn Div::size_20(Self) -> Self +pub fn Div::size_24(Self) -> Self +pub fn Div::size_2_3(Self) -> Self +pub fn Div::size_2_4(Self) -> Self +pub fn Div::size_2_5(Self) -> Self +pub fn Div::size_2p5(Self) -> Self +pub fn Div::size_3(Self) -> Self +pub fn Div::size_32(Self) -> Self +pub fn Div::size_3_4(Self) -> Self +pub fn Div::size_3_5(Self) -> Self +pub fn Div::size_3p5(Self) -> Self +pub fn Div::size_4(Self) -> Self +pub fn Div::size_40(Self) -> Self +pub fn Div::size_48(Self) -> Self +pub fn Div::size_4_5(Self) -> Self +pub fn Div::size_5(Self) -> Self +pub fn Div::size_56(Self) -> Self +pub fn Div::size_5_6(Self) -> Self +pub fn Div::size_6(Self) -> Self +pub fn Div::size_64(Self) -> Self +pub fn Div::size_7(Self) -> Self +pub fn Div::size_72(Self) -> Self +pub fn Div::size_8(Self) -> Self +pub fn Div::size_80(Self) -> Self +pub fn Div::size_9(Self) -> Self +pub fn Div::size_96(Self) -> Self +pub fn Div::size_auto(Self) -> Self +pub fn Div::size_full(Self) -> Self +pub fn Div::size_neg_0(Self) -> Self +pub fn Div::size_neg_0p5(Self) -> Self +pub fn Div::size_neg_1(Self) -> Self +pub fn Div::size_neg_10(Self) -> Self +pub fn Div::size_neg_11(Self) -> Self +pub fn Div::size_neg_112(Self) -> Self +pub fn Div::size_neg_12(Self) -> Self +pub fn Div::size_neg_128(Self) -> Self +pub fn Div::size_neg_16(Self) -> Self +pub fn Div::size_neg_1_12(Self) -> Self +pub fn Div::size_neg_1_2(Self) -> Self +pub fn Div::size_neg_1_3(Self) -> Self +pub fn Div::size_neg_1_4(Self) -> Self +pub fn Div::size_neg_1_5(Self) -> Self +pub fn Div::size_neg_1_6(Self) -> Self +pub fn Div::size_neg_1p5(Self) -> Self +pub fn Div::size_neg_2(Self) -> Self +pub fn Div::size_neg_20(Self) -> Self +pub fn Div::size_neg_24(Self) -> Self +pub fn Div::size_neg_2_3(Self) -> Self +pub fn Div::size_neg_2_4(Self) -> Self +pub fn Div::size_neg_2_5(Self) -> Self +pub fn Div::size_neg_2p5(Self) -> Self +pub fn Div::size_neg_3(Self) -> Self +pub fn Div::size_neg_32(Self) -> Self +pub fn Div::size_neg_3_4(Self) -> Self +pub fn Div::size_neg_3_5(Self) -> Self +pub fn Div::size_neg_3p5(Self) -> Self +pub fn Div::size_neg_4(Self) -> Self +pub fn Div::size_neg_40(Self) -> Self +pub fn Div::size_neg_48(Self) -> Self +pub fn Div::size_neg_4_5(Self) -> Self +pub fn Div::size_neg_5(Self) -> Self +pub fn Div::size_neg_56(Self) -> Self +pub fn Div::size_neg_5_6(Self) -> Self +pub fn Div::size_neg_6(Self) -> Self +pub fn Div::size_neg_64(Self) -> Self +pub fn Div::size_neg_7(Self) -> Self +pub fn Div::size_neg_72(Self) -> Self +pub fn Div::size_neg_8(Self) -> Self +pub fn Div::size_neg_80(Self) -> Self +pub fn Div::size_neg_9(Self) -> Self +pub fn Div::size_neg_96(Self) -> Self +pub fn Div::size_neg_full(Self) -> Self +pub fn Div::size_neg_px(Self) -> Self +pub fn Div::size_px(Self) -> Self +pub fn Div::text_2xl(Self) -> Self +pub fn Div::text_3xl(Self) -> Self +pub fn Div::text_align(Self, @style.TextAlign) -> Self +pub fn Div::text_base(Self) -> Self +pub fn Div::text_bg(Self, &@color.IntoHsla) -> Self +pub fn Div::text_center(Self) -> Self +pub fn Div::text_color(Self, &@color.IntoHsla) -> Self +pub fn Div::text_decoration_0(Self) -> Self +pub fn Div::text_decoration_1(Self) -> Self +pub fn Div::text_decoration_2(Self) -> Self +pub fn Div::text_decoration_4(Self) -> Self +pub fn Div::text_decoration_8(Self) -> Self +pub fn Div::text_decoration_color(Self, &@color.IntoHsla) -> Self +pub fn Div::text_decoration_none(Self) -> Self +pub fn Div::text_decoration_solid(Self) -> Self +pub fn Div::text_decoration_wavy(Self) -> Self +pub fn Div::text_ellipsis(Self) -> Self +pub fn Div::text_ellipsis_middle(Self) -> Self +pub fn Div::text_ellipsis_start(Self) -> Self +pub fn Div::text_left(Self) -> Self +pub fn Div::text_lg(Self) -> Self +pub fn Div::text_overflow(Self, @style.TextOverflow) -> Self +pub fn Div::text_right(Self) -> Self +pub fn Div::text_size(Self, &@geometry.IntoAbsoluteLength) -> Self +pub fn Div::text_sm(Self) -> Self +pub fn Div::text_xl(Self) -> Self +pub fn Div::text_xs(Self) -> Self +pub fn Div::top(Self, &@geometry.IntoLength) -> Self +pub fn Div::top_0(Self) -> Self +pub fn Div::top_0p5(Self) -> Self +pub fn Div::top_1(Self) -> Self +pub fn Div::top_10(Self) -> Self +pub fn Div::top_11(Self) -> Self +pub fn Div::top_112(Self) -> Self +pub fn Div::top_12(Self) -> Self +pub fn Div::top_128(Self) -> Self +pub fn Div::top_16(Self) -> Self +pub fn Div::top_1_12(Self) -> Self +pub fn Div::top_1_2(Self) -> Self +pub fn Div::top_1_3(Self) -> Self +pub fn Div::top_1_4(Self) -> Self +pub fn Div::top_1_5(Self) -> Self +pub fn Div::top_1_6(Self) -> Self +pub fn Div::top_1p5(Self) -> Self +pub fn Div::top_2(Self) -> Self +pub fn Div::top_20(Self) -> Self +pub fn Div::top_24(Self) -> Self +pub fn Div::top_2_3(Self) -> Self +pub fn Div::top_2_4(Self) -> Self +pub fn Div::top_2_5(Self) -> Self +pub fn Div::top_2p5(Self) -> Self +pub fn Div::top_3(Self) -> Self +pub fn Div::top_32(Self) -> Self +pub fn Div::top_3_4(Self) -> Self +pub fn Div::top_3_5(Self) -> Self +pub fn Div::top_3p5(Self) -> Self +pub fn Div::top_4(Self) -> Self +pub fn Div::top_40(Self) -> Self +pub fn Div::top_48(Self) -> Self +pub fn Div::top_4_5(Self) -> Self +pub fn Div::top_5(Self) -> Self +pub fn Div::top_56(Self) -> Self +pub fn Div::top_5_6(Self) -> Self +pub fn Div::top_6(Self) -> Self +pub fn Div::top_64(Self) -> Self +pub fn Div::top_7(Self) -> Self +pub fn Div::top_72(Self) -> Self +pub fn Div::top_8(Self) -> Self +pub fn Div::top_80(Self) -> Self +pub fn Div::top_9(Self) -> Self +pub fn Div::top_96(Self) -> Self +pub fn Div::top_auto(Self) -> Self +pub fn Div::top_full(Self) -> Self +pub fn Div::top_neg_0(Self) -> Self +pub fn Div::top_neg_0p5(Self) -> Self +pub fn Div::top_neg_1(Self) -> Self +pub fn Div::top_neg_10(Self) -> Self +pub fn Div::top_neg_11(Self) -> Self +pub fn Div::top_neg_112(Self) -> Self +pub fn Div::top_neg_12(Self) -> Self +pub fn Div::top_neg_128(Self) -> Self +pub fn Div::top_neg_16(Self) -> Self +pub fn Div::top_neg_1_12(Self) -> Self +pub fn Div::top_neg_1_2(Self) -> Self +pub fn Div::top_neg_1_3(Self) -> Self +pub fn Div::top_neg_1_4(Self) -> Self +pub fn Div::top_neg_1_5(Self) -> Self +pub fn Div::top_neg_1_6(Self) -> Self +pub fn Div::top_neg_1p5(Self) -> Self +pub fn Div::top_neg_2(Self) -> Self +pub fn Div::top_neg_20(Self) -> Self +pub fn Div::top_neg_24(Self) -> Self +pub fn Div::top_neg_2_3(Self) -> Self +pub fn Div::top_neg_2_4(Self) -> Self +pub fn Div::top_neg_2_5(Self) -> Self +pub fn Div::top_neg_2p5(Self) -> Self +pub fn Div::top_neg_3(Self) -> Self +pub fn Div::top_neg_32(Self) -> Self +pub fn Div::top_neg_3_4(Self) -> Self +pub fn Div::top_neg_3_5(Self) -> Self +pub fn Div::top_neg_3p5(Self) -> Self +pub fn Div::top_neg_4(Self) -> Self +pub fn Div::top_neg_40(Self) -> Self +pub fn Div::top_neg_48(Self) -> Self +pub fn Div::top_neg_4_5(Self) -> Self +pub fn Div::top_neg_5(Self) -> Self +pub fn Div::top_neg_56(Self) -> Self +pub fn Div::top_neg_5_6(Self) -> Self +pub fn Div::top_neg_6(Self) -> Self +pub fn Div::top_neg_64(Self) -> Self +pub fn Div::top_neg_7(Self) -> Self +pub fn Div::top_neg_72(Self) -> Self +pub fn Div::top_neg_8(Self) -> Self +pub fn Div::top_neg_80(Self) -> Self +pub fn Div::top_neg_9(Self) -> Self +pub fn Div::top_neg_96(Self) -> Self +pub fn Div::top_neg_full(Self) -> Self +pub fn Div::top_neg_px(Self) -> Self +pub fn Div::top_px(Self) -> Self +pub fn Div::truncate(Self) -> Self +pub fn Div::underline(Self) -> Self +pub fn Div::visible(Self) -> Self +pub fn Div::w(Self, &@geometry.IntoLength) -> Self +pub fn Div::w_0(Self) -> Self +pub fn Div::w_0p5(Self) -> Self +pub fn Div::w_1(Self) -> Self +pub fn Div::w_10(Self) -> Self +pub fn Div::w_11(Self) -> Self +pub fn Div::w_112(Self) -> Self +pub fn Div::w_12(Self) -> Self +pub fn Div::w_128(Self) -> Self +pub fn Div::w_16(Self) -> Self +pub fn Div::w_1_12(Self) -> Self +pub fn Div::w_1_2(Self) -> Self +pub fn Div::w_1_3(Self) -> Self +pub fn Div::w_1_4(Self) -> Self +pub fn Div::w_1_5(Self) -> Self +pub fn Div::w_1_6(Self) -> Self +pub fn Div::w_1p5(Self) -> Self +pub fn Div::w_2(Self) -> Self +pub fn Div::w_20(Self) -> Self +pub fn Div::w_24(Self) -> Self +pub fn Div::w_2_3(Self) -> Self +pub fn Div::w_2_4(Self) -> Self +pub fn Div::w_2_5(Self) -> Self +pub fn Div::w_2p5(Self) -> Self +pub fn Div::w_3(Self) -> Self +pub fn Div::w_32(Self) -> Self +pub fn Div::w_3_4(Self) -> Self +pub fn Div::w_3_5(Self) -> Self +pub fn Div::w_3p5(Self) -> Self +pub fn Div::w_4(Self) -> Self +pub fn Div::w_40(Self) -> Self +pub fn Div::w_48(Self) -> Self +pub fn Div::w_4_5(Self) -> Self +pub fn Div::w_5(Self) -> Self +pub fn Div::w_56(Self) -> Self +pub fn Div::w_5_6(Self) -> Self +pub fn Div::w_6(Self) -> Self +pub fn Div::w_64(Self) -> Self +pub fn Div::w_7(Self) -> Self +pub fn Div::w_72(Self) -> Self +pub fn Div::w_8(Self) -> Self +pub fn Div::w_80(Self) -> Self +pub fn Div::w_9(Self) -> Self +pub fn Div::w_96(Self) -> Self +pub fn Div::w_auto(Self) -> Self +pub fn Div::w_full(Self) -> Self +pub fn Div::w_neg_0(Self) -> Self +pub fn Div::w_neg_0p5(Self) -> Self +pub fn Div::w_neg_1(Self) -> Self +pub fn Div::w_neg_10(Self) -> Self +pub fn Div::w_neg_11(Self) -> Self +pub fn Div::w_neg_112(Self) -> Self +pub fn Div::w_neg_12(Self) -> Self +pub fn Div::w_neg_128(Self) -> Self +pub fn Div::w_neg_16(Self) -> Self +pub fn Div::w_neg_1_12(Self) -> Self +pub fn Div::w_neg_1_2(Self) -> Self +pub fn Div::w_neg_1_3(Self) -> Self +pub fn Div::w_neg_1_4(Self) -> Self +pub fn Div::w_neg_1_5(Self) -> Self +pub fn Div::w_neg_1_6(Self) -> Self +pub fn Div::w_neg_1p5(Self) -> Self +pub fn Div::w_neg_2(Self) -> Self +pub fn Div::w_neg_20(Self) -> Self +pub fn Div::w_neg_24(Self) -> Self +pub fn Div::w_neg_2_3(Self) -> Self +pub fn Div::w_neg_2_4(Self) -> Self +pub fn Div::w_neg_2_5(Self) -> Self +pub fn Div::w_neg_2p5(Self) -> Self +pub fn Div::w_neg_3(Self) -> Self +pub fn Div::w_neg_32(Self) -> Self +pub fn Div::w_neg_3_4(Self) -> Self +pub fn Div::w_neg_3_5(Self) -> Self +pub fn Div::w_neg_3p5(Self) -> Self +pub fn Div::w_neg_4(Self) -> Self +pub fn Div::w_neg_40(Self) -> Self +pub fn Div::w_neg_48(Self) -> Self +pub fn Div::w_neg_4_5(Self) -> Self +pub fn Div::w_neg_5(Self) -> Self +pub fn Div::w_neg_56(Self) -> Self +pub fn Div::w_neg_5_6(Self) -> Self +pub fn Div::w_neg_6(Self) -> Self +pub fn Div::w_neg_64(Self) -> Self +pub fn Div::w_neg_7(Self) -> Self +pub fn Div::w_neg_72(Self) -> Self +pub fn Div::w_neg_8(Self) -> Self +pub fn Div::w_neg_80(Self) -> Self +pub fn Div::w_neg_9(Self) -> Self +pub fn Div::w_neg_96(Self) -> Self +pub fn Div::w_neg_full(Self) -> Self +pub fn Div::w_neg_px(Self) -> Self +pub fn Div::w_px(Self) -> Self +pub fn Div::whitespace_normal(Self) -> Self +pub fn Div::whitespace_nowrap(Self) -> Self +pub impl @style.Styled for Div +pub impl @window.IntoElement for Div + +// Type aliases + +// Traits diff --git a/src/elements/visual_test.mbt b/src/elements/visual_test.mbt new file mode 100644 index 0000000..a8ba43b --- /dev/null +++ b/src/elements/visual_test.mbt @@ -0,0 +1,187 @@ +///| +struct VisualCounter { + mut count : Int32 +} + +///| +impl @window.Render for VisualCounter with fn render(self, _window, cx) { + @elements.div() + .flex() + .flex_row() + .gap(px(10.0)) + .p(px(10.0)) + .size_full() + .bg(@color.rgb(0xffffff)) + .child( + @elements.div() + .id("minus") + .size(px(20.0)) + .bg(@color.rgb(0xcc0000)) + .on_click( + @window.listener(cx, fn(counter, _, _, cx) { + counter.count -= 1 + cx.notify() + }), + ), + ) + .child( + @elements.div() + .w(px((self.count * 10).to_double())) + .h(px(20.0)) + .bg(@color.rgb(0x0000cc)), + ) + .child( + @elements.div() + .id("plus") + .size(px(20.0)) + .bg(@color.rgb(0x00cc00)) + .hover(fn(style) { style.bg(@color.rgb(0x00ff00)) }) + .on_click( + @window.listener(cx, fn(counter, _, _, cx) { + counter.count += 1 + cx.notify() + }), + ), + ) + .into_any_element() +} + +///| +test "VisualTestContext renders div counter and tracks scene history" { + let cx = @test_platform.TestAppContext::new() + let (counter, vcx) = cx.add_window_view( + size=@geometry.size(px(200.0), px(40.0)), + fn(_, _) { { count: 3, } }, + ) + assert_eq(vcx.draw_count(), 1) + assert_eq(vcx.scene().quads.length(), 4) + assert_eq(vcx.scene().quads[2].bounds.size.width, sp(30.0)) + assert_eq( + vcx.scene().quads[3].background, + @color.rgb(0x00cc00).to_background(), + ) + + // Moving onto "plus" triggers hover redraw automatically. + ignore(vcx.simulate_mouse_move(pt(90.0, 20.0))) + assert_eq(vcx.draw_count(), 2) + assert_eq( + vcx.scene().quads[3].background, + @color.rgb(0x00ff00).to_background(), + ) + + // Clicking "plus" updates the view and draws the expanded value bar. + vcx.simulate_click(pt(90.0, 20.0)) + assert_eq(cx.read_entity(counter).count, 4) + assert_eq(vcx.draw_count(), 3) + assert_eq(vcx.drawn_scenes().length(), 3) + assert_eq(vcx.scene().quads[2].bounds.size.width, sp(40.0)) + assert_eq(vcx.scene().quads[3].bounds.origin.x, sp(90.0)) +} + +///| +enum VisualCanvasView { + VisualCanvasView +} + +///| +impl @window.Render for VisualCanvasView with fn render(_self, _window, _cx) { + @elements.div() + .flex() + .size_full() + .p(px(10.0)) + .child( + @elements.canvas(fn(bounds, window, _) { + window.paint_path( + [[bounds.origin, bounds.top_right(), bounds.bottom_left()]], + @color.blue().to_background(), + ) + }).size_full(), + ) + .into_any_element() +} + +///| +test "VisualTestContext resize, scale factor, and canvas view" { + let cx = @test_platform.TestAppContext::new() + let (_, vcx) = cx.add_window_view(size=@geometry.size(px(100.0), px(80.0)), fn( + _, + _, + ) { + VisualCanvasView + }) + assert_eq(vcx.scene().paths.length(), 1) + assert_eq(vcx.scene().paths[0].bounds, sbounds(10.0, 10.0, 80.0, 60.0)) + + vcx.simulate_resize(@geometry.size(px(150.0), px(100.0))) + vcx.simulate_scale_factor_change(2.0) + assert_eq(vcx.scene().paths[0].bounds, sbounds(20.0, 20.0, 260.0, 160.0)) +} + +///| +struct VisualTicker { + mut ticks : Int32 +} + +///| +impl @window.Render for VisualTicker with fn render(self, _window, _cx) { + @elements.div() + .size_full() + .child( + @elements.div() + .w(px((self.ticks * 20).to_double())) + .h(px(10.0)) + .bg(@color.red()), + ) + .into_any_element() +} + +///| +test "VisualTestContext async ticker updates div layout on virtual clock" { + let cx = @test_platform.TestAppContext::new() + let (ticker, vcx) = cx.add_window_view( + size=@geometry.size(px(200.0), px(40.0)), + fn(_, ctx) { + let weak : @app.WeakEntity[VisualTicker] = ctx.weak_entity() + ctx + .spawn(async fn(_, async_app) { + while true { + async_app.background_executor().sleep(100) + let alive = weak.update(async_app.app, fn(t : VisualTicker, cx) { + t.ticks = t.ticks + 1 + cx.notify() + }) + if alive is None { + break + } + } + }) + .detach() + { ticks: 0, } + }, + ) + assert_eq(vcx.draw_count(), 1) + assert_eq(vcx.scene().quads.length(), 0) + + cx.advance_clock(250) + assert_eq(cx.read_entity(ticker).ticks, 2) + assert_true(vcx.draw_count() >= 2) + assert_eq(vcx.scene().quads.length(), 1) + assert_eq(vcx.scene().quads[0].bounds.size.width, sp(40.0)) +} + +///| +test "closing VisualTestContext window releases rendered div view" { + let cx = @test_platform.TestAppContext::new() + let released = Ref(false) + let (counter, vcx) = cx.add_window_view( + size=@geometry.size(px(100.0), px(40.0)), + fn(_, ctx) { + ctx.on_release(fn(_, _) { released.val = true }).detach() + { count: 1, } + }, + ) + assert_false(released.val) + assert_true(vcx.simulate_close()) + assert_true(counter.is_released()) + assert_true(released.val) +} diff --git a/src/examples/card/main.mbt b/src/examples/card/main.mbt index 930fd88..1d1f9e2 100644 --- a/src/examples/card/main.mbt +++ b/src/examples/card/main.mbt @@ -1,128 +1,107 @@ -// A headless example of what exists so far (M0 + M1): describe a "card" with -// GPUI's fluent style API, resolve it, and paint it into a Scene by hand. -// There is no layout engine or renderer yet, so bounds are fixed and the -// output is a text report of the scene's draw batches. +// A headless example of what exists so far (M0-M7): a view renders a card +// with GPUI's `div()` and fluent styles inside a `TestPlatform` window, +// and `VisualTestContext` simulates a hover and click while pumping frames +// automatically. There is no renderer or text yet (text lines are +// placeholder bars), so the output is a report of the scene's draw batches +// and quads. // // Run with: moon run src/examples/card --target js ///| -/// The card's style, written exactly as in GPUI: -/// `div().flex().p_4().rounded_lg().border_1().shadow_md().bg(...)`. -fn card_style() -> @style.StyleRefinement { - @style.StyleRefinement::new() - .flex() - .flex_col() - .gap_2() - .p_4() - .w(@geometry.px(320.0)) - .rounded_lg() - .border_1() - .border_color(@color.rgb(0xd0d7de)) - .bg(@color.rgb(0xffffff)) - .shadow_md() - .text_color(@color.rgb(0x1f2328)) - .text_sm() +struct Card { + mut expanded : Bool + mut clicks : Int32 } ///| -/// Paints the resolved style's background, border and shadows, the way -/// GPUI's `Style::paint` will once the Window exists (M6). -fn paint_card( - scene : @scene.Scene, - style : @style.Style, - bounds : @geometry.Bounds[@geometry.Pixels], - rem_size : @geometry.Pixels, - scale_factor : Double, -) -> Unit { - let corner_radii = style.corner_radii - .absolute_to_pixels(rem_size) - .clamp_radii_for_quad_size(bounds.size) - let mask : @geometry.ContentMask[@geometry.Pixels] = { - bounds: bounds.dilate(@geometry.px(64.0)), - } - for shadow in style.box_shadow { - let shadow_bounds = bounds - .translate(shadow.offset) - .dilate(shadow.spread_radius) - scene.insert_primitive( - Shadow({ - order: 0, - blur_radius: shadow.blur_radius.scale(scale_factor), - bounds: shadow_bounds.scale(scale_factor), - corner_radii: corner_radii.scale(scale_factor), - content_mask: mask.scale(scale_factor), - color: shadow.color, - shape_bounds: bounds.scale(scale_factor), - shape_corner_radii: corner_radii.scale(scale_factor), - inset: false, +/// A placeholder for a line of text (the text system arrives in M9). +fn text_bar(width : Double, color : UInt32) -> @elements.Div { + @elements.div() + .w(@geometry.px(width)) + .h(@geometry.px(10.0)) + .rounded_sm() + .bg(@color.rgb(color)) +} + +///| +impl @window.Render for Card with fn render(self, _window, cx) { + let body_lines = if self.expanded { 4 } else { 1 } + let card = @elements.div() + .id("card") + .flex() + .flex_col() + .gap_2() + .p_4() + .w(@geometry.px(320.0)) + .rounded_lg() + .border_1() + .border_color(@color.rgb(0xd0d7de)) + .bg(@color.rgb(0xffffff)) + .shadow_md() + .hover(fn(style) { style.border_color(@color.rgb(0x0969da)) }) + .on_click( + @window.listener(cx, fn(card, _, _, cx) { + card.expanded = !card.expanded + card.clicks += 1 + cx.notify() }), ) + .child(text_bar(160.0, 0x1f2328)) + for _ in 0.. fill.color().unwrap() - None => Default::default() + @elements.div() + .size_full() + .flex() + .items_start() + .p(@geometry.px(40.0)) + .bg(@color.rgb(0xf6f8fa)) + .child(card) + .into_any_element() +} + +///| +fn describe( + label : String, + scene : @scene.Scene, + lines : Array[String], +) -> Unit { + lines.push(label) + let batches = scene.batches().map(fn(b) { b.label() }).join(", ") + lines.push(" batches: \{batches}") + for quad in scene.quads { + let b = quad.bounds + let extra = if quad.border_widths.top.to_double() > 0.0 { + " border \{quad.border_color.to_rgb()}" + } else { + "" + } + lines.push( + " quad (\{b.origin.x.to_double()}, \{b.origin.y.to_double()}) \{b.size.width.to_double()} x \{b.size.height.to_double()}\{extra}", + ) } - scene.insert_primitive( - Quad({ - order: 0, - border_style: style.border_style, - bounds: bounds.scale(scale_factor), - content_mask: mask.scale(scale_factor), - background, - border_color: style.border_color.unwrap_or(@color.transparent_black()), - corner_radii: corner_radii.scale(scale_factor), - border_widths: style.border_widths - .absolute_to_pixels(rem_size) - .scale(scale_factor), - }), - ) } ///| /// Builds the report printed by `main`. fn report() -> String { - let rem_size = @geometry.px(16.0) - let scale_factor = 2.0 - let style = (Default::default() : @style.Style).refined(card_style()) - let text = (Default::default() : @style.TextStyle).refined(style.text) - let bounds : @geometry.Bounds[@geometry.Pixels] = { - origin: @geometry.point(@geometry.px(40.0), @geometry.px(40.0)), - size: @geometry.size(@geometry.px(320.0), @geometry.px(120.0)), - } - let scene = @scene.Scene::new() - paint_card(scene, style, bounds, rem_size, scale_factor) - // A title underline, overlapping the card. - scene.insert_primitive( - Underline({ - order: 0, - bounds: @geometry.bounds( - @geometry.point(@geometry.px(56.0), @geometry.px(76.0)), - @geometry.size(@geometry.px(120.0), @geometry.px(1.0)), - ).scale(scale_factor), - content_mask: { bounds: bounds.scale(scale_factor), }, - color: text.color, - thickness: @geometry.ScaledPixels(2.0), - wavy: false, - }), + let cx = @test_platform.TestAppContext::new() + let (card, vcx) = cx.add_window_view( + size=@geometry.size(@geometry.px(400.0), @geometry.px(240.0)), + fn(_, _) { { expanded: false, clicks: 0, } }, ) - scene.finish() - let lines = [ - "card style", - " display: \{@debug.to_string(style.display)}, direction: \{@debug.to_string(style.flex_direction)}", - " width: \{style.size.width}, padding: \{style.padding.top}, gap: \{style.gap.width}", - " radius: \{style.corner_radii.top_left} = \{style.corner_radii.top_left.to_pixels(rem_size)}", - " shadows: \{style.box_shadow.length()}", - " text: \{text.font_size.to_pixels(rem_size)} \{text.font_family}, color \{text.color.to_rgb()}", - "scene at \{scale_factor}x", - ] - for batch in scene.batches() { - lines.push(" \{batch.label()}") - } - for quad in scene.quads { - lines.push( - " quad order \{quad.order}: \{quad.bounds.size.width.0} x \{quad.bounds.size.height.0} device px", - ) - } + let card : @app.Entity[Card] = card + let lines = [] + describe("first frame", vcx.scene(), lines) + // Hover the card, then click it: the view expands and the window redraws. + let inside = @geometry.point(@geometry.px(100.0), @geometry.px(60.0)) + ignore(vcx.simulate_mouse_move(inside)) + vcx.simulate_click(inside) + let state = cx.read_entity(card) + lines.push( + "clicked: expanded = \{state.expanded}, clicks = \{state.clicks}, frames = \{vcx.draw_count()}, dirty = \{vcx.window().is_dirty()}", + ) + describe("after click (hovered)", vcx.scene(), lines) lines.join("\n") } diff --git a/src/examples/card/main_wbtest.mbt b/src/examples/card/main_wbtest.mbt index 63b61b6..cfe4e97 100644 --- a/src/examples/card/main_wbtest.mbt +++ b/src/examples/card/main_wbtest.mbt @@ -3,17 +3,24 @@ test "card report" { inspect( report(), content=( - #|card style - #| display: Flex, direction: Column - #| width: 320px, padding: 1rem, gap: 0.5rem - #| radius: 0.5rem = 8px - #| shadows: 2 - #| text: 14px .SystemUIFont, color #1f2328ff - #|scene at 2x - #| shadows (2) - #| quads (1) - #| underlines (1) - #| quad order 1: 640 x 240 device px + #|first frame + #| batches: quads (1), shadows (2), quads (4) + #| quad (0, 0) 400 x 240 + #| quad (40, 40) 320 x 62 + #| quad (57, 57) 160 x 10 + #| quad (57, 75) 280 x 10 + #| quad (40, 40) 320 x 62 border #d0d7deff + #|clicked: expanded = true, clicks = 1, frames = 3, dirty = false + #|after click (hovered) + #| batches: quads (1), shadows (2), quads (7) + #| quad (0, 0) 400 x 240 + #| quad (40, 40) 320 x 116 + #| quad (57, 57) 160 x 10 + #| quad (57, 75) 280 x 10 + #| quad (57, 93) 280 x 10 + #| quad (57, 111) 280 x 10 + #| quad (57, 129) 280 x 10 + #| quad (40, 40) 320 x 116 border #0969daff ), ) } diff --git a/src/examples/card/moon.pkg b/src/examples/card/moon.pkg index e3e94a1..dd5dc3b 100644 --- a/src/examples/card/moon.pkg +++ b/src/examples/card/moon.pkg @@ -2,8 +2,14 @@ import { "experiments/gpui/geometry", "experiments/gpui/color", "experiments/gpui/scene", - "experiments/gpui/style", - "moonbitlang/core/debug", + "experiments/gpui/app", + "experiments/gpui/window", + "experiments/gpui/elements", + "experiments/gpui/platform/test" @test_platform, } pkgtype(kind: "executable") + +options( + "allow-experimental-packages": true, +) diff --git a/src/examples/card/pkg.generated.mbti b/src/examples/card/pkg.generated.mbti index e864326..d7f2749 100644 --- a/src/examples/card/pkg.generated.mbti +++ b/src/examples/card/pkg.generated.mbti @@ -6,6 +6,7 @@ package "experiments/gpui/examples/card" // Errors // Types and methods +type Card // Type aliases diff --git a/src/examples/counter/main.mbt b/src/examples/counter/main.mbt new file mode 100644 index 0000000..97196ce --- /dev/null +++ b/src/examples/counter/main.mbt @@ -0,0 +1,92 @@ +// The app model (M3) and executors (M4) without a window: two entities +// talking through notifications, typed events and a global, and a task +// ticking on the app's simulated clock. +// +// Run with: moon run src/examples/counter --target js + +///| +struct Counter { + mut count : Int32 +} + +///| +struct History { + entries : Array[String] +} + +///| +/// An event a counter emits when it passes a threshold. +let milestone : @app.EventKey[Int32] = @app.EventKey::new("Milestone") + +///| +/// App-wide configuration. +struct Config { + mut step : Int32 +} + +///| +let config_key : @app.GlobalKey[Config] = @app.GlobalKey::new("Config") + +///| +fn report() -> String { + let app = @app.App::new() + app.set_global(config_key, { step: 1, }) + let counter : @app.Entity[Counter] = app.new_entity(fn(_) { { count: 0, } }) + // The history observes the counter and subscribes to its milestones; both + // stop automatically when either entity is released. + let history : @app.Entity[History] = app.new_entity(fn(cx) { + cx + .observe(counter, fn(history, counter, cx) { + history.entries.push("count is \{counter.read(cx.app).count}") + }) + .detach() + cx + .subscribe(counter, milestone, fn(history, _, value, _) { + history.entries.push("milestone \{value}!") + }) + .detach() + cx + .observe_release(counter, fn(history, counter, _) { + history.entries.push("counter released at \{counter.count}") + }) + .detach() + { entries: [], } + }) + let increment = fn() { + counter.update(app, fn(counter, cx) { + counter.count += cx.app.global(config_key).step + if counter.count % 5 == 0 { + cx.emit(milestone, counter.count) + } + // Notifying twice in one update still runs observers once. + cx.notify() + cx.notify() + }) + } + increment() + increment() + app.update_global(config_key, fn(config, _) { config.step = 3 }) + increment() + // A task that increments every 100ms until cancelled. `App::new()` uses a + // deterministic test dispatcher, so time only moves when we advance it. + let ticker = app.spawn(async fn(cx) { + while true { + cx.background_executor().sleep(100) + cx.update_entity(counter, fn(counter, cx) { + counter.count += 1 + cx.notify() + }) + } + }) + app.advance_clock(250) + ticker.cancel() + app.advance_clock(1000) + app.release(counter) + // Updating a released entity would abort; the history keeps working. + history.read(app).entries.join("\n") +} + +///| +fn main { + println(report()) +} diff --git a/src/examples/counter/main_wbtest.mbt b/src/examples/counter/main_wbtest.mbt new file mode 100644 index 0000000..ed7a01d --- /dev/null +++ b/src/examples/counter/main_wbtest.mbt @@ -0,0 +1,15 @@ +///| +test "counter report" { + inspect( + report(), + content=( + #|count is 1 + #|count is 2 + #|milestone 5! + #|count is 5 + #|count is 6 + #|count is 7 + #|counter released at 7 + ), + ) +} diff --git a/src/examples/counter/moon.pkg b/src/examples/counter/moon.pkg new file mode 100644 index 0000000..b357fe3 --- /dev/null +++ b/src/examples/counter/moon.pkg @@ -0,0 +1,5 @@ +import { + "experiments/gpui/app", +} + +pkgtype(kind: "executable") diff --git a/src/examples/counter/pkg.generated.mbti b/src/examples/counter/pkg.generated.mbti new file mode 100644 index 0000000..211e357 --- /dev/null +++ b/src/examples/counter/pkg.generated.mbti @@ -0,0 +1,17 @@ +// Generated using `moon info`, DON'T EDIT IT +package "experiments/gpui/examples/counter" + +// Values + +// Errors + +// Types and methods +type Config + +type Counter + +type History + +// Type aliases + +// Traits diff --git a/src/executor/coroutine.mbt b/src/executor/coroutine.mbt new file mode 100644 index 0000000..7ac03cb --- /dev/null +++ b/src/executor/coroutine.mbt @@ -0,0 +1,157 @@ +// Coroutines on top of MoonBit's async intrinsics, scheduled by a +// `Dispatcher` instead of `moonbitlang/core/async`'s event loop. +// +// Why not `moonbitlang/core/async`: it owns the event loop (`async fn main`, +// `with_task_group`) and does not support the wasm-gc backend. GPUI's +// executors are driven by the platform (the browser's event loop, a native run +// loop, or a deterministic test scheduler), so we schedule coroutines +// ourselves with the same intrinsics `moonbitlang/core/async` is built on. +// They are experimental; see docs/PORTING.md. + +///| +async fn[T] async_suspend(cb : ((T) -> Unit) -> Unit) -> T noraise + nocancel = "%async.suspend" + +///| +fn run_async(f : async () -> Unit noraise + nocancel) = "%async.run" + +///| +async fn[X] raise_cancellation_signal() -> X noraise = "%async.raise_cancellation_signal" + +///| +async fn[X] capture_cancellation( + f : async () -> X, + handler~ : async () -> X nocancel, +) -> X nocancel = "%async.capture_cancellation" + +///| +priv enum Wake { + Continue + Cancelled +} + +///| +/// One running computation. While suspended, `continuation` resumes it. +priv struct Coroutine { + scheduler : Scheduler + mut continuation : ((Wake) -> Unit)? + mut cancelled : Bool + mut scheduled : Bool + mut finished : Bool + /// Woken while running: the next `suspend` returns immediately. + mut missed_wake : Bool +} + +///| +/// Runs coroutines one step at a time through a dispatcher. +priv struct Scheduler { + dispatcher : &Dispatcher +} + +///| +/// The coroutine running right now, across all schedulers (there is one +/// thread). +let current : Ref[Coroutine?] = { val: None, } + +///| +/// Schedules `coroutine` to continue on the dispatcher, once. +fn Coroutine::wake(self : Coroutine) -> Unit { + if self.scheduled || self.finished { + return + } + self.scheduled = true + self.scheduler.dispatcher.dispatch(fn() { self.step() }) +} + +///| +fn Coroutine::step(self : Coroutine) -> Unit { + self.scheduled = false + guard self.continuation is Some(continuation) else { + // Woken while running (it has not suspended yet). + if !self.finished { + self.missed_wake = true + } + return + } + self.continuation = None + let previous = current.val + current.val = Some(self) + continuation(if self.cancelled { Cancelled } else { Continue }) + current.val = previous +} + +///| +/// The coroutine running right now; fails loudly outside of a task. +fn current_coroutine(operation : String) -> Coroutine { + match current.val { + Some(coroutine) => coroutine + None => abort("\{operation} must be called from inside a task") + } +} + +///| +/// Suspends the current coroutine until it is woken. If the task is cancelled +/// (before or while suspended), raises the cancellation signal, which unwinds +/// the task and runs its `defer` blocks. +async fn suspend(coroutine : Coroutine) -> Unit noraise { + if coroutine.cancelled { + raise_cancellation_signal() + } + if coroutine.missed_wake { + coroutine.missed_wake = false + return + } + let wake : Wake = async_suspend(fn(k) { coroutine.continuation = Some(k) }) + match wake { + Continue => () + Cancelled => raise_cancellation_signal() + } +} + +///| +/// Starts `body` as a new coroutine on the next dispatcher turn. +fn Scheduler::spawn( + self : Scheduler, + body : async () -> Unit, + on_cancelled : () -> Unit, + on_error : (Error) -> Unit, + on_finished : () -> Unit, +) -> Coroutine { + let coroutine : Coroutine = { + scheduler: self, + continuation: None, + cancelled: false, + scheduled: false, + finished: false, + missed_wake: false, + } + coroutine.continuation = Some(fn(wake) { + match wake { + Cancelled => { + // Cancelled before it ever ran: the body never starts. + coroutine.finished = true + on_cancelled() + on_finished() + } + Continue => + run_async(() => { + capture_cancellation(body, handler=() => on_cancelled()) catch { + error => on_error(error) + } + coroutine.finished = true + on_finished() + }) + } + }) + coroutine.wake() + coroutine +} + +///| +fn Coroutine::cancel(self : Coroutine) -> Unit { + if self.finished || self.cancelled { + return + } + self.cancelled = true + // Resume it so that it observes the cancellation (and runs its `defer`s). + self.wake() +} diff --git a/src/executor/dispatcher.mbt b/src/executor/dispatcher.mbt new file mode 100644 index 0000000..fe57d15 --- /dev/null +++ b/src/executor/dispatcher.mbt @@ -0,0 +1,123 @@ +// The platform hook that runs executor work (GPUI: `PlatformDispatcher`, +// reduced to a single thread: GPUI's background threads are not available +// on the web and MoonBit has no threads; background tasks share the main +// thread, as in GPUI's single-threaded web backend). + +///| +/// Runs callbacks on the (only) thread, soon or after a delay. +pub(open) trait Dispatcher { + /// Run `runnable` soon, after the current callback returns. + fn dispatch(Self, runnable : () -> Unit) -> Unit + /// Run `runnable` after `delay_ms` milliseconds. + fn dispatch_after(Self, delay_ms : Int32, runnable : () -> Unit) -> Unit + /// Milliseconds since an arbitrary, fixed origin. + fn now(Self) -> Int64 +} + +///| +priv struct PendingTimer { + deadline : Int64 + runnable : () -> Unit +} + +///| +/// A deterministic dispatcher with a virtual clock, for tests (GPUI: +/// `TestScheduler`/`TestDispatcher`). Nothing runs until the test drives it +/// with `tick`, `run_until_parked` or `advance_clock`. +pub struct TestDispatcher { + priv queue : @deque.Deque[() -> Unit] + priv timers : Array[PendingTimer] + priv mut now_ms : Int64 +} + +///| +pub fn TestDispatcher::new() -> TestDispatcher { + { queue: @deque.Deque([]), timers: [], now_ms: 0, } +} + +///| +pub impl Dispatcher for TestDispatcher with fn dispatch(self, runnable) { + self.queue.push_back(runnable) +} + +///| +pub impl Dispatcher for TestDispatcher with fn dispatch_after( + self, + delay_ms, + runnable, +) { + guard delay_ms >= 0 else { + abort("dispatch_after: negative delay \{delay_ms}ms") + } + let timer = { deadline: self.now_ms + delay_ms.to_int64(), runnable, } + // Keep timers sorted by deadline; equal deadlines keep insertion order. + let mut index = self.timers.length() + while index > 0 && self.timers[index - 1].deadline > timer.deadline { + index = index - 1 + } + self.timers.insert(index, timer) +} + +///| +pub impl Dispatcher for TestDispatcher with fn now(self) { + self.now_ms +} + +///| +/// Moves timers whose deadline has passed into the run queue. +fn TestDispatcher::fire_due_timers(self : TestDispatcher) -> Unit { + while !self.timers.is_empty() && self.timers[0].deadline <= self.now_ms { + self.queue.push_back(self.timers.remove(0).runnable) + } +} + +///| +/// Runs one ready callback; false if none is ready. +pub fn TestDispatcher::tick(self : TestDispatcher) -> Bool { + self.fire_due_timers() + match self.queue.pop_front() { + Some(runnable) => { + runnable() + true + } + None => false + } +} + +///| +/// Runs callbacks until none is ready without advancing the clock (GPUI: +/// `run_until_parked`). +pub fn TestDispatcher::run_until_parked(self : TestDispatcher) -> Unit { + while self.tick() { + () + } +} + +///| +/// Advances the virtual clock by `ms`, firing timers in deadline order and +/// running everything they wake (GPUI: `advance_clock`). +pub fn TestDispatcher::advance_clock(self : TestDispatcher, ms : Int32) -> Unit { + guard ms >= 0 else { abort("advance_clock: negative duration \{ms}ms") } + let target = self.now_ms + ms.to_int64() + while true { + self.run_until_parked() + if !self.timers.is_empty() && self.timers[0].deadline <= target { + self.now_ms = self.timers[0].deadline + } else { + break + } + } + self.now_ms = target +} + +///| +/// Whether any callback is ready or any timer is pending. +pub fn TestDispatcher::has_pending_work(self : TestDispatcher) -> Bool { + !self.queue.is_empty() || !self.timers.is_empty() +} + +///| +/// Number of pending timers. +pub fn TestDispatcher::pending_timer_count(self : TestDispatcher) -> Int32 { + self.timers.length() +} diff --git a/src/executor/executor_test.mbt b/src/executor/executor_test.mbt new file mode 100644 index 0000000..fa6e135 --- /dev/null +++ b/src/executor/executor_test.mbt @@ -0,0 +1,216 @@ +///| +fn setup() -> (@executor.TestDispatcher, @executor.Executor) { + let dispatcher = @executor.TestDispatcher::new() + (dispatcher, @executor.Executor::new(dispatcher)) +} + +///| +fn[T] result_of(task : @executor.Task[T]) -> T? { + task.try_result() catch { + _ => None + } +} + +///| +suberror Boom { + Boom(String) +} + +///| +/// Port of the scheduler crate's `test_foreground_executor_spawn`. +test "spawn runs on the dispatcher" { + let (dispatcher, executor) = setup() + let task = executor.spawn(fn() { 42 }) + // Nothing runs until the dispatcher is driven. + assert_false(task.is_ready()) + dispatcher.run_until_parked() + assert_true(task.is_ready()) + assert_eq(result_of(task), Some(42)) + assert_eq(result_of(@executor.Task::ready("now")), Some("now")) +} + +///| +/// Like the scheduler crate's `test_foreground_ordering`: tasks start in +/// spawn order. +test "tasks run in spawn order" { + let (dispatcher, executor) = setup() + let trace = [] + for i in 0..<10 { + executor.spawn(fn() { trace.push(i) }).detach() + } + dispatcher.run_until_parked() + assert_eq(trace, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) +} + +///| +/// Port of the scheduler crate's `test_timer_ordering`. +test "timers fire in deadline order on the virtual clock" { + let (dispatcher, executor) = setup() + let order = [] + for delay in [100, 50, 150] { + executor + .spawn(async fn() { + executor.sleep(delay) + order.push((delay, executor.now())) + }) + .detach() + } + dispatcher.run_until_parked() + assert_eq(order, []) + dispatcher.advance_clock(60) + assert_eq(order, [(50, 50L)]) + assert_eq(executor.now(), 60L) + dispatcher.advance_clock(1000) + assert_eq(order, [(50, 50L), (100, 100L), (150, 150L)]) + assert_false(dispatcher.has_pending_work()) +} + +///| +test "tasks await tasks and errors propagate" { + let (dispatcher, executor) = setup() + let inner = executor.spawn(async fn() { + executor.sleep(10) + 20 + }) + let outer = executor.spawn(async fn() { inner.wait() + 1 }) + let failing : @executor.Task[Int32] = executor.spawn(fn() raise { + raise Boom("bad") + }) + let observer = executor.spawn(async fn() { + try failing.wait() catch { + Boom(message) => "caught \{message}" + _ => "other" + } noraise { + _ => "no error" + } + }) + dispatcher.advance_clock(10) + assert_eq(result_of(outer), Some(21)) + assert_eq(result_of(observer), Some("caught bad")) + let raised = try failing.try_result() catch { + Boom(_) => true + _ => false + } noraise { + _ => false + } + assert_true(raised) +} + +///| +test "cancel before start: the body never runs" { + let (dispatcher, executor) = setup() + let ran = Ref(false) + let task = executor.spawn(fn() { ran.val = true }) + task.cancel() + dispatcher.run_until_parked() + assert_false(ran.val) + assert_true(task.is_cancelled()) + let raised = try task.try_result() catch { + @executor.TaskCancelled => true + _ => false + } noraise { + _ => false + } + assert_true(raised) +} + +///| +test "cancel while suspended unwinds the task and notifies waiters" { + let (dispatcher, executor) = setup() + let log = [] + let sleeper = executor.spawn(async fn() { + defer log.push("cleanup") + log.push("sleeping") + executor.sleep(1000) + log.push("woke up") + }) + let waiter = executor.spawn(async fn() { + try sleeper.wait() catch { + @executor.TaskCancelled => "sleeper cancelled" + _ => "other error" + } noraise { + _ => "finished" + } + }) + dispatcher.run_until_parked() + assert_eq(log, ["sleeping"]) + sleeper.cancel() + dispatcher.run_until_parked() + assert_eq(log, ["sleeping", "cleanup"]) + assert_eq(result_of(waiter), Some("sleeper cancelled")) + // The timer still fires later, but nothing resumes. + dispatcher.advance_clock(2000) + assert_eq(log, ["sleeping", "cleanup"]) + // Cancelling a finished task does nothing. + waiter.cancel() + assert_false(waiter.is_cancelled()) +} + +///| +test "cancelled timers report cancellation" { + let (dispatcher, executor) = setup() + let timer = executor.timer(50) + timer.cancel() + assert_true(timer.is_cancelled()) + dispatcher.advance_clock(100) + assert_true(timer.is_cancelled()) +} + +///| +test "a task can cancel itself" { + let (dispatcher, executor) = setup() + let log = [] + let task_ref : Ref[@executor.Task[Unit]?] = Ref(None) + let task = executor.spawn(async fn() { + defer log.push("unwound") + task_ref.val.unwrap().cancel() + log.push("still running until the next suspension") + executor.yield_now() + log.push("never") + }) + task_ref.val = Some(task) + dispatcher.run_until_parked() + assert_eq(log, ["still running until the next suspension", "unwound"]) + assert_true(task.is_cancelled()) +} + +///| +test "yield_now interleaves tasks" { + let (dispatcher, executor) = setup() + let trace = [] + for name in ["a", "b"] { + executor + .spawn(async fn() { + for i in 0..<3 { + trace.push("\{name}\{i}") + executor.yield_now() + } + }) + .detach() + } + dispatcher.run_until_parked() + assert_eq(trace, ["a0", "b0", "a1", "b1", "a2", "b2"]) +} + +///| +test "tick runs one step at a time" { + let (dispatcher, executor) = setup() + let trace = [] + executor.spawn(fn() { trace.push(1) }).detach() + executor.spawn(fn() { trace.push(2) }).detach() + assert_true(dispatcher.tick()) + assert_eq(trace, [1]) + assert_true(dispatcher.tick()) + assert_false(dispatcher.tick()) + assert_eq(trace, [1, 2]) + assert_eq(dispatcher.pending_timer_count(), 0) +} + +///| +test "panic on a task waiting for itself" { + let (dispatcher, executor) = setup() + let task_ref : Ref[@executor.Task[Unit]?] = Ref(None) + let task = executor.spawn(async fn() { task_ref.val.unwrap().wait() }) + task_ref.val = Some(task) + dispatcher.run_until_parked() +} diff --git a/src/executor/executor_wbtest.mbt b/src/executor/executor_wbtest.mbt new file mode 100644 index 0000000..6977912 --- /dev/null +++ b/src/executor/executor_wbtest.mbt @@ -0,0 +1,11 @@ +///| +test "panic on waiting outside a task" { + let dispatcher = TestDispatcher::new() + let task = Executor::new(dispatcher).timer(1) + // A coroutine that is not a task: `wait` cannot suspend it. + run_async(() => { + capture_cancellation(() => task.wait(), handler=() => ()) catch { + _ => () + } + }) +} diff --git a/src/executor/moon.pkg b/src/executor/moon.pkg new file mode 100644 index 0000000..36a60b8 --- /dev/null +++ b/src/executor/moon.pkg @@ -0,0 +1,10 @@ +import { + "moonbitlang/core/deque", +} + +// The coroutine intrinsics (%async.*) are experimental. + +options( + "allow-experimental-packages": true, + experimental: true, +) diff --git a/src/executor/pkg.generated.mbti b/src/executor/pkg.generated.mbti new file mode 100644 index 0000000..2c632a7 --- /dev/null +++ b/src/executor/pkg.generated.mbti @@ -0,0 +1,54 @@ +// Generated using `moon info`, DON'T EDIT IT +package "experiments/gpui/executor" + +import { + "moonbitlang/core/debug", +} + +// Values + +// Errors +#derive(@debug.Debug) +pub suberror TaskCancelled + +// Types and methods +pub struct Executor { + // private fields +} +pub fn Executor::new(&Dispatcher) -> Self +pub fn Executor::now(Self) -> Int64 +pub async fn Executor::sleep(Self, Int32) -> Unit +pub fn[T] Executor::spawn(Self, async () -> T) -> Task[T] +pub fn Executor::timer(Self, Int32) -> Task[Unit] +pub async fn Executor::yield_now(Self) -> Unit + +pub struct Task[T] { + // private fields +} +pub fn[T] Task::cancel(Self[T]) -> Unit +pub fn[T] Task::detach(Self[T]) -> Unit +pub fn[T] Task::is_cancelled(Self[T]) -> Bool +pub fn[T] Task::is_ready(Self[T]) -> Bool +pub fn[T] Task::ready(T) -> Self[T] +pub fn[T] Task::try_result(Self[T]) -> T? raise +pub async fn[T] Task::wait(Self[T]) -> T + +pub struct TestDispatcher { + // private fields +} +pub fn TestDispatcher::advance_clock(Self, Int32) -> Unit +pub fn TestDispatcher::has_pending_work(Self) -> Bool +pub fn TestDispatcher::new() -> Self +pub fn TestDispatcher::pending_timer_count(Self) -> Int32 +pub fn TestDispatcher::run_until_parked(Self) -> Unit +pub fn TestDispatcher::tick(Self) -> Bool +pub impl Dispatcher for TestDispatcher + +// Type aliases + +// Traits +pub(open) trait Dispatcher { + fn dispatch(Self, () -> Unit) -> Unit + fn dispatch_after(Self, Int32, () -> Unit) -> Unit + fn now(Self) -> Int64 +} diff --git a/src/executor/task.mbt b/src/executor/task.mbt new file mode 100644 index 0000000..7bb5b6f --- /dev/null +++ b/src/executor/task.mbt @@ -0,0 +1,184 @@ +// Tasks and executors, ported from gpui/src/executor.rs and the `scheduler` +// crate (crates/scheduler/src/executor.rs). +// +// Deviations from GPUI: +// - Dropping a GPUI `Task` cancels it. There is no `Drop` in MoonBit: a task +// runs to completion unless `cancel()` is called. `detach()` is kept for +// parity. +// - There is one thread: background and foreground executors schedule on the +// same dispatcher (as GPUI's single-threaded web backend does). +// - Durations are milliseconds (`Int`); `now()` is milliseconds (`Int64`). + +///| +/// Raised by `Task::wait` when the task was cancelled. +#derive(Debug) +pub suberror TaskCancelled + +///| +priv enum Outcome[T] { + Pending + Done(T) + Failed(Error) + Cancelled +} + +///| +priv struct TaskState[T] { + mut outcome : Outcome[T] + waiters : Array[Coroutine] + mut coroutine : Coroutine? + /// Cancels work that is not a coroutine (timers). + mut on_cancel : (() -> Unit)? +} + +///| +/// The result of asynchronous work (GPUI: `Task`). Await it with `wait`. +pub struct Task[T] { + priv state : TaskState[T] +} + +///| +fn[T] TaskState::new() -> TaskState[T] { + { outcome: Pending, waiters: [], coroutine: None, on_cancel: None, } +} + +///| +fn[T] TaskState::complete(self : TaskState[T], outcome : Outcome[T]) -> Unit { + guard self.outcome is Pending else { return } + self.outcome = outcome + let waiters = self.waiters.copy() + self.waiters.clear() + for waiter in waiters { + waiter.wake() + } +} + +///| +/// A task that is already complete (GPUI: `Task::ready`). +pub fn[T] Task::ready(value : T) -> Task[T] { + { state: { ..TaskState::new(), outcome: Done(value), }, } +} + +///| +/// Whether the task has finished: completed, failed or cancelled. +pub fn[T] Task::is_ready(self : Task[T]) -> Bool { + !(self.state.outcome is Pending) +} + +///| +/// Whether the task was cancelled. +pub fn[T] Task::is_cancelled(self : Task[T]) -> Bool { + self.state.outcome is Cancelled +} + +///| +/// Lets the task run to completion without anyone awaiting it. In MoonBit +/// this is the default; kept for GPUI parity. +pub fn[T] Task::detach(self : Task[T]) -> Unit { + ignore(self) +} + +///| +/// Cancels the task. A running task is resumed with a cancellation signal at +/// its next suspension point, unwinding it (running `defer` blocks). Waiters +/// get `TaskCancelled`. No effect on finished tasks. +pub fn[T] Task::cancel(self : Task[T]) -> Unit { + guard self.state.outcome is Pending else { return } + match (self.state.coroutine, self.state.on_cancel) { + (Some(coroutine), _) => coroutine.cancel() + (None, Some(on_cancel)) => on_cancel() + (None, None) => self.state.complete(Cancelled) + } +} + +///| +/// The result if the task has finished: `Some(value)`, or raises the task's +/// error (or `TaskCancelled`); `None` while it is pending. +pub fn[T] Task::try_result(self : Task[T]) -> T? raise { + match self.state.outcome { + Pending => None + Done(value) => Some(value) + Failed(error) => raise error + Cancelled => raise TaskCancelled + } +} + +///| +/// Waits for the task from inside another task and returns its value. Raises +/// the task's error, or `TaskCancelled`. +pub async fn[T] Task::wait(self : Task[T]) -> T { + let state = self.state + while state.outcome is Pending { + let coroutine = current_coroutine("Task::wait") + if state.coroutine is Some(own) && physical_equal(own, coroutine) { + abort("a task cannot wait for itself") + } + state.waiters.push(coroutine) + suspend(coroutine) + } + match state.outcome { + Done(value) => value + Failed(error) => raise error + Cancelled => raise TaskCancelled + Pending => abort("unreachable: task still pending after wait") + } +} + +///| +/// Spawns tasks and timers on a dispatcher (GPUI: `ForegroundExecutor` and +/// `BackgroundExecutor`, which coincide on one thread). +pub struct Executor { + priv scheduler : Scheduler +} + +///| +pub fn Executor::new(dispatcher : &Dispatcher) -> Executor { + { scheduler: { dispatcher, }, } +} + +///| +/// Runs `f` as a task, starting on the next dispatcher turn. +pub fn[T] Executor::spawn(self : Executor, f : async () -> T) -> Task[T] { + let state : TaskState[T] = TaskState::new() + let coroutine = self.scheduler.spawn( + async fn() { + let value = f() + state.complete(Done(value)) + }, + fn() { state.complete(Cancelled) }, + fn(error) { state.complete(Failed(error)) }, + fn() { }, + ) + state.coroutine = Some(coroutine) + { state, } +} + +///| +/// A task that completes after `ms` milliseconds (GPUI: `timer`). +pub fn Executor::timer(self : Executor, ms : Int32) -> Task[Unit] { + let state : TaskState[Unit] = TaskState::new() + state.on_cancel = Some(fn() { state.complete(Cancelled) }) + self.scheduler.dispatcher.dispatch_after(ms, fn() { state.complete(Done(())) }) + { state, } +} + +///| +/// Suspends the current task for `ms` milliseconds. +pub async fn Executor::sleep(self : Executor, ms : Int32) -> Unit { + self.timer(ms).wait() +} + +///| +/// Lets other ready tasks run before continuing. +pub async fn Executor::yield_now(self : Executor) -> Unit { + let coroutine = current_coroutine("Executor::yield_now") + ignore(self) + coroutine.wake() + suspend(coroutine) +} + +///| +/// The dispatcher's clock, in milliseconds. +pub fn Executor::now(self : Executor) -> Int64 { + self.scheduler.dispatcher.now() +} diff --git a/src/input/input.mbt b/src/input/input.mbt new file mode 100644 index 0000000..67b2b67 --- /dev/null +++ b/src/input/input.mbt @@ -0,0 +1,212 @@ +// Input event types, ported from gpui/src/interactive.rs and the Modifiers of +// gpui/src/platform/keystroke.rs. Keyboard events and keystrokes come with +// the keymap milestone (M5). + +///| +/// Modifier keys held during an event. +#derive(Eq, Hash, Default, Debug) +pub(all) struct Modifiers { + control : Bool + alt : Bool + shift : Bool + /// Command on macOS, Windows/Super elsewhere. + platform : Bool + /// The function (fn) key. + function : Bool +} + +///| +/// Whether any modifier is held. +pub fn Modifiers::modified(self : Modifiers) -> Bool { + self.control || self.alt || self.shift || self.platform || self.function +} + +///| +#derive(Eq, Hash, Debug) +pub(all) enum NavigationDirection { + Back + Forward +} + +///| +#derive(Eq, Hash, Debug) +pub(all) enum MouseButton { + Left + Right + Middle + Navigate(NavigationDirection) +} + +///| +pub impl Default for MouseButton with fn default() { + Left +} + +///| +#derive(Eq, Default, Debug) +pub(all) struct MouseDownEvent { + button : MouseButton + position : @geometry.Point[@geometry.Pixels] + modifiers : Modifiers + click_count : Int32 + first_mouse : Bool +} + +///| +#derive(Eq, Default, Debug) +pub(all) struct MouseUpEvent { + button : MouseButton + position : @geometry.Point[@geometry.Pixels] + modifiers : Modifiers + click_count : Int32 +} + +///| +#derive(Eq, Default, Debug) +pub(all) struct MouseMoveEvent { + position : @geometry.Point[@geometry.Pixels] + /// The button held during the move, if any. + pressed_button : MouseButton? + modifiers : Modifiers +} + +///| +/// How a scroll delta is expressed. +#derive(Eq, Debug) +pub(all) enum ScrollDelta { + /// Precise pixels (trackpads). + Pixels(@geometry.Point[@geometry.Pixels]) + /// Lines (mouse wheels). + Lines(@geometry.Point[Double]) +} + +///| +#derive(Eq, Debug) +pub(all) struct ScrollWheelEvent { + position : @geometry.Point[@geometry.Pixels] + delta : ScrollDelta + modifiers : Modifiers +} + +///| +/// Fired when the pointer leaves the window (GPUI: `MouseExitEvent`). +#derive(Eq, Default, Debug) +pub(all) struct MouseExitEvent { + position : @geometry.Point[@geometry.Pixels] + pressed_button : MouseButton? + modifiers : Modifiers +} + +///| +/// Fired when the held modifier keys change (GPUI: `ModifiersChangedEvent`). +#derive(Eq, Default, Debug) +pub(all) struct ModifiersChangedEvent { + modifiers : Modifiers +} + +///| +/// A mouse click: the down and up events of one press (GPUI: +/// `MouseClickEvent`). +#derive(Eq, Default, Debug) +pub(all) struct ClickEvent { + down : MouseDownEvent + up : MouseUpEvent +} + +///| +/// Pointer input delivered to a window (GPUI: the mouse variants of +/// `PlatformInput`). +#derive(Eq, Debug) +pub(all) enum MouseEvent { + MouseDown(MouseDownEvent) + MouseUp(MouseUpEvent) + MouseMove(MouseMoveEvent) + ScrollWheel(ScrollWheelEvent) +} + +///| +pub fn MouseEvent::position( + self : MouseEvent, +) -> @geometry.Point[@geometry.Pixels] { + match self { + MouseDown(e) => e.position + MouseUp(e) => e.position + MouseMove(e) => e.position + ScrollWheel(e) => e.position + } +} + +///| +pub fn MouseEvent::modifiers(self : MouseEvent) -> Modifiers { + match self { + MouseDown(e) => e.modifiers + MouseUp(e) => e.modifiers + MouseMove(e) => e.modifiers + ScrollWheel(e) => e.modifiers + } +} + +///| +pub fn MouseEvent::to_platform_input(self : MouseEvent) -> PlatformInput { + match self { + MouseDown(e) => MouseDown(e) + MouseUp(e) => MouseUp(e) + MouseMove(e) => MouseMove(e) + ScrollWheel(e) => ScrollWheel(e) + } +} + +///| +/// Input events delivered by a platform window (GPUI: `PlatformInput`). +#derive(Eq, Debug) +pub(all) enum PlatformInput { + MouseDown(MouseDownEvent) + MouseUp(MouseUpEvent) + MouseMove(MouseMoveEvent) + MouseExited(MouseExitEvent) + ScrollWheel(ScrollWheelEvent) + ModifiersChanged(ModifiersChangedEvent) +} + +///| +pub fn PlatformInput::modifiers(self : PlatformInput) -> Modifiers { + match self { + MouseDown(e) => e.modifiers + MouseUp(e) => e.modifiers + MouseMove(e) => e.modifiers + MouseExited(e) => e.modifiers + ScrollWheel(e) => e.modifiers + ModifiersChanged(e) => e.modifiers + } +} + +///| +/// Extracts the mouse event if this input is one of the window-dispatched +/// pointer events (`MouseExited` and `ModifiersChanged` return `None`). +pub fn PlatformInput::mouse_event(self : PlatformInput) -> MouseEvent? { + match self { + MouseDown(e) => Some(MouseDown(e)) + MouseUp(e) => Some(MouseUp(e)) + MouseMove(e) => Some(MouseMove(e)) + ScrollWheel(e) => Some(ScrollWheel(e)) + MouseExited(_) | ModifiersChanged(_) => None + } +} + +///| +/// Result of dispatching a `PlatformInput` to a window (GPUI: +/// `DispatchEventResult`). +#derive(Eq, Default, Debug) +pub(all) struct DispatchEventResult { + propagate : Bool + default_prevented : Bool +} + +///| +/// Listeners run twice per event: capture (root to leaf), then bubble (leaf +/// to root) (GPUI: `DispatchPhase`). +#derive(Eq, Hash, Debug) +pub(all) enum DispatchPhase { + Capture + Bubble +} diff --git a/src/input/moon.pkg b/src/input/moon.pkg new file mode 100644 index 0000000..742fe15 --- /dev/null +++ b/src/input/moon.pkg @@ -0,0 +1,3 @@ +import { + "experiments/gpui/geometry", +} diff --git a/src/input/pkg.generated.mbti b/src/input/pkg.generated.mbti new file mode 100644 index 0000000..a2f63c2 --- /dev/null +++ b/src/input/pkg.generated.mbti @@ -0,0 +1,131 @@ +// Generated using `moon info`, DON'T EDIT IT +package "experiments/gpui/input" + +import { + "experiments/gpui/geometry", + "moonbitlang/core/debug", +} + +// Values + +// Errors + +// Types and methods +#derive(Default, Eq, @debug.Debug) +pub(all) struct ClickEvent { + down : MouseDownEvent + up : MouseUpEvent +} + +#derive(Default, Eq, @debug.Debug) +pub(all) struct DispatchEventResult { + propagate : Bool + default_prevented : Bool +} + +#derive(Eq, Hash, @debug.Debug) +pub(all) enum DispatchPhase { + Capture + Bubble +} + +#derive(Default, Eq, Hash, @debug.Debug) +pub(all) struct Modifiers { + control : Bool + alt : Bool + shift : Bool + platform : Bool + function : Bool +} +pub fn Modifiers::modified(Self) -> Bool + +#derive(Default, Eq, @debug.Debug) +pub(all) struct ModifiersChangedEvent { + modifiers : Modifiers +} + +#derive(Eq, Hash, @debug.Debug) +pub(all) enum MouseButton { + Left + Right + Middle + Navigate(NavigationDirection) +} +pub impl Default for MouseButton + +#derive(Default, Eq, @debug.Debug) +pub(all) struct MouseDownEvent { + button : MouseButton + position : @geometry.Point[@geometry.Pixels] + modifiers : Modifiers + click_count : Int32 + first_mouse : Bool +} + +#derive(Eq, @debug.Debug) +pub(all) enum MouseEvent { + MouseDown(MouseDownEvent) + MouseUp(MouseUpEvent) + MouseMove(MouseMoveEvent) + ScrollWheel(ScrollWheelEvent) +} +pub fn MouseEvent::modifiers(Self) -> Modifiers +pub fn MouseEvent::position(Self) -> @geometry.Point[@geometry.Pixels] +pub fn MouseEvent::to_platform_input(Self) -> PlatformInput + +#derive(Default, Eq, @debug.Debug) +pub(all) struct MouseExitEvent { + position : @geometry.Point[@geometry.Pixels] + pressed_button : MouseButton? + modifiers : Modifiers +} + +#derive(Default, Eq, @debug.Debug) +pub(all) struct MouseMoveEvent { + position : @geometry.Point[@geometry.Pixels] + pressed_button : MouseButton? + modifiers : Modifiers +} + +#derive(Default, Eq, @debug.Debug) +pub(all) struct MouseUpEvent { + button : MouseButton + position : @geometry.Point[@geometry.Pixels] + modifiers : Modifiers + click_count : Int32 +} + +#derive(Eq, Hash, @debug.Debug) +pub(all) enum NavigationDirection { + Back + Forward +} + +#derive(Eq, @debug.Debug) +pub(all) enum PlatformInput { + MouseDown(MouseDownEvent) + MouseUp(MouseUpEvent) + MouseMove(MouseMoveEvent) + MouseExited(MouseExitEvent) + ScrollWheel(ScrollWheelEvent) + ModifiersChanged(ModifiersChangedEvent) +} +pub fn PlatformInput::modifiers(Self) -> Modifiers +pub fn PlatformInput::mouse_event(Self) -> MouseEvent? + +#derive(Eq, @debug.Debug) +pub(all) enum ScrollDelta { + Pixels(@geometry.Point[@geometry.Pixels]) + Lines(@geometry.Point[Double]) +} + +#derive(Eq, @debug.Debug) +pub(all) struct ScrollWheelEvent { + position : @geometry.Point[@geometry.Pixels] + delta : ScrollDelta + modifiers : Modifiers +} + +// Type aliases + +// Traits diff --git a/src/layout/convert.mbt b/src/layout/convert.mbt new file mode 100644 index 0000000..5c73ae8 --- /dev/null +++ b/src/layout/convert.mbt @@ -0,0 +1,309 @@ +// Conversion from GPUI styles to the layout engine's styles, ported from +// gpui/src/taffy.rs (`LayoutStyle::to_taffy`, `ToTaffy`) and the rounding +// helpers in gpui/src/util.rs. +// +// GPUI lays out in *device* pixels: absolute lengths are resolved against the +// rem size, multiplied by the scale factor and rounded, so that layout results +// land on the pixel grid. `layout_bounds` divides back into logical pixels. + +///| +/// Rounds to the nearest integer, with ties going toward zero +/// (GPUI: `round_half_toward_zero`). +pub fn round_half_toward_zero(value : Double) -> Double { + let magnitude = (value.abs() - 0.5).ceil() + // `ceil(-0.5)` is -0.0; normalize so ties at ±0.5 give +0.0. + let magnitude = if magnitude == 0.0 { 0.0 } else { magnitude } + if value < 0.0 { + -magnitude + } else { + magnitude + } +} + +///| +/// Logical pixels to device pixels, rounded (GPUI: `round_to_device_pixel`). +pub fn round_to_device_pixel(logical : Double, scale_factor : Double) -> Double { + round_half_toward_zero(logical * scale_factor) +} + +///| +/// Like `round_to_device_pixel`, but a non-zero stroke is at least one device +/// pixel wide (GPUI: `round_stroke_to_device_pixel`). +pub fn round_stroke_to_device_pixel( + logical : Double, + scale_factor : Double, +) -> Double { + if logical == 0.0 { + 0.0 + } else { + let rounded = round_to_device_pixel( + if logical > 0.0 { + logical + } else { + 0.0 + }, + scale_factor, + ) + if rounded < 1.0 { + 1.0 + } else { + rounded + } + } +} + +///| +/// Logical pixels to device pixels, rounded up (GPUI: `ceil_to_device_pixel`). +pub fn ceil_to_device_pixel(logical : Double, scale_factor : Double) -> Double { + (logical * scale_factor).ceil() +} + +///| +fn absolute_to_device( + length : @geometry.AbsoluteLength, + rem_size : @geometry.Pixels, + scale_factor : Double, +) -> Double { + round_to_device_pixel(length.to_pixels(rem_size).to_double(), scale_factor) +} + +///| +fn definite_to_dimension( + length : @geometry.DefiniteLength, + rem_size : @geometry.Pixels, + scale_factor : Double, +) -> @cstyle.Dimension { + match length { + Absolute(absolute) => + DimLength(absolute_to_device(absolute, rem_size, scale_factor)) + Fraction(fraction) => DimPercent(fraction) + } +} + +///| +fn length_to_dimension( + length : @geometry.Length, + rem_size : @geometry.Pixels, + scale_factor : Double, +) -> @cstyle.Dimension { + match length { + Definite(definite) => + definite_to_dimension(definite, rem_size, scale_factor) + Auto => DimAuto + } +} + +///| +fn edges_to_rect( + edges : @geometry.Edges[@cstyle.Dimension], +) -> @cgeometry.Rect[@cstyle.Dimension] { + @cgeometry.Rect( + left=edges.left, + right=edges.right, + top=edges.top, + bottom=edges.bottom, + ) +} + +///| +fn size_to_engine( + size : @geometry.Size[@cstyle.Dimension], +) -> @cgeometry.Size[@cstyle.Dimension] { + @cgeometry.Size(width=size.width, height=size.height) +} + +///| +/// Border widths are snapped like strokes, so a hairline border stays +/// visible (GPUI: `border_widths_to_taffy`). +pub fn border_widths_to_engine( + widths : @geometry.Edges[@geometry.AbsoluteLength], + rem_size : @geometry.Pixels, + scale_factor : Double, +) -> @cgeometry.Rect[@cstyle.Dimension] { + edges_to_rect( + widths.map(fn(width) { + DimLength( + round_stroke_to_device_pixel( + width.to_pixels(rem_size).to_double(), + scale_factor, + ), + ) + }), + ) +} + +///| +fn display_to_engine(display : @style.Display) -> @cstyle.Display { + match display { + Block => DisplayBlock + Flex => DisplayFlex + Grid => DisplayGrid + @style.Display::None => DisplayNone + } +} + +///| +fn overflow_to_engine(overflow : @style.Overflow) -> @cstyle.Overflow { + match overflow { + Visible => OverflowVisible + Clip => OverflowClip + Hidden => OverflowHidden + Scroll => OverflowScroll + } +} + +///| +fn position_to_engine(position : @style.Position) -> @cstyle.Position { + match position { + Relative => PosRelative + Absolute => PosAbsolute + } +} + +///| +fn align_items_to_engine(align : @style.AlignItems) -> @cstyle.AlignItems { + match align { + Start => ItemsStart + End => ItemsEnd + FlexStart => ItemsFlexStart + FlexEnd => ItemsFlexEnd + Center => ItemsCenter + Baseline => ItemsBaseline + Stretch => ItemsStretch + } +} + +///| +fn align_content_to_engine(align : @style.AlignContent) -> @cstyle.AlignContent { + match align { + Start => AlignStart + End => AlignEnd + FlexStart => AlignFlexStart + FlexEnd => AlignFlexEnd + Center => AlignCenter + Stretch => AlignStretch + SpaceBetween => AlignSpaceBetween + SpaceEvenly => AlignSpaceEvenly + SpaceAround => AlignSpaceAround + } +} + +///| +fn flex_direction_to_engine( + direction : @style.FlexDirection, +) -> @cstyle.FlexDirection { + match direction { + Row => FlexRow + Column => FlexColumn + RowReverse => FlexRowReverse + ColumnReverse => FlexColumnReverse + } +} + +///| +fn flex_wrap_to_engine(wrap : @style.FlexWrap) -> @cstyle.FlexWrap { + match wrap { + NoWrap => FlexNoWrap + Wrap => @cstyle.FlexWrap::FlexWrap + WrapReverse => FlexWrapReverse + } +} + +///| +fn grid_placement_to_engine( + placement : @geometry.GridPlacement, +) -> @cstyle.GridPlacement { + match placement { + Line(line) => PlaceLine(line) + Span(span) => PlaceSpan(span) + Auto => PlaceAuto + } +} + +///| +fn grid_range_to_engine( + range : @geometry.GridRange, +) -> @cgeometry.Line[@cstyle.GridPlacement] { + @cgeometry.Line( + start=grid_placement_to_engine(range.start), + end=grid_placement_to_engine(range.end), + ) +} + +///| +/// `repeat(n, minmax(..))` tracks for GPUI's `grid_cols`/`grid_rows`. +fn grid_template_to_engine( + template : @style.GridTemplate?, +) -> Array[@cstyle.Dimension] { + match template { + Option::None => [] + Some(template) => { + let track : @cstyle.Dimension = match template.min_size { + Zero => DimMinMax(DimLength(0.0), DimFr(1.0)) + MinContent => DimMinMax(DimMinContent, DimFr(1.0)) + MaxContent => DimMinMax(DimLength(0.0), DimMaxContent) + } + [DimRepeat(RepeatCount(template.repeat), [track])] + } + } +} + +///| +/// Converts a resolved GPUI `Style` to the layout engine's style, resolving +/// rems and snapping absolute lengths to device pixels +/// (GPUI: `LayoutStyle::to_taffy`). +pub fn style_to_engine( + style : @style.Style, + rem_size : @geometry.Pixels, + scale_factor : Double, +) -> @cstyle.Style { + let length = fn(l : @geometry.Length) { + length_to_dimension(l, rem_size, scale_factor) + } + let definite = fn(l : @geometry.DefiniteLength) { + definite_to_dimension(l, rem_size, scale_factor) + } + let grid_location = style.grid_location + { + ..@cstyle.Style::default(), + display: display_to_engine(style.display), + overflow: @cgeometry.Point( + x=overflow_to_engine(style.overflow.x), + y=overflow_to_engine(style.overflow.y), + ), + scrollbar_width: absolute_to_device( + style.scrollbar_width, + rem_size, + scale_factor, + ), + position: position_to_engine(style.position), + inset: edges_to_rect(style.inset.map(length)), + size: size_to_engine(style.size.map(length)), + min_size: size_to_engine(style.min_size.map(length)), + max_size: size_to_engine(style.max_size.map(length)), + aspect_ratio: style.aspect_ratio, + margin: edges_to_rect(style.margin.map(length)), + padding: edges_to_rect(style.padding.map(definite)), + border: border_widths_to_engine(style.border_widths, rem_size, scale_factor), + align_items: style.align_items.map(align_items_to_engine), + align_self: style.align_self.map(align_items_to_engine), + align_content: style.align_content.map(align_content_to_engine), + justify_content: style.justify_content.map(align_content_to_engine), + gap: size_to_engine(style.gap.map(definite)), + flex_direction: flex_direction_to_engine(style.flex_direction), + flex_wrap: flex_wrap_to_engine(style.flex_wrap), + flex_basis: length(style.flex_basis), + flex_grow: style.flex_grow, + flex_shrink: style.flex_shrink, + grid_template_rows: grid_template_to_engine(style.grid_rows), + grid_template_columns: grid_template_to_engine(style.grid_cols), + grid_row: match grid_location { + Some(location) => grid_range_to_engine(location.row) + Option::None => @cgeometry.Line(start=PlaceAuto, end=PlaceAuto) + }, + grid_column: match grid_location { + Some(location) => grid_range_to_engine(location.column) + Option::None => @cgeometry.Line(start=PlaceAuto, end=PlaceAuto) + }, + } +} diff --git a/src/layout/engine.mbt b/src/layout/engine.mbt new file mode 100644 index 0000000..6e9215a --- /dev/null +++ b/src/layout/engine.mbt @@ -0,0 +1,335 @@ +// The layout engine, ported from `TaffyLayoutEngine` in gpui/src/taffy.rs, +// on top of `Milky2018/chicle` (a MoonBit port of taffy). +// +// Deviation from GPUI: there is no cross-frame node cache yet (GPUI reuses +// nodes keyed by element path and keeps measure closures alive across +// frames). The engine is rebuilt on `clear()`, as older GPUI versions did. +// The cache depends on element ids and arrives with the Window (M6). + +///| +/// Space available to a node along one axis (GPUI: `AvailableSpace`). +#derive(Eq, Hash, Debug) +pub(all) enum AvailableSpace { + /// A definite amount of space, in logical pixels. + Definite(@geometry.Pixels) + /// Size to the smallest size that fits the content. + MinContent + /// Size to the largest size the content wants. + MaxContent +} + +///| +pub impl Default for AvailableSpace with fn default() { + MinContent +} + +///| +pub fn AvailableSpace::min_size() -> @geometry.Size[AvailableSpace] { + { width: MinContent, height: MinContent, } +} + +///| +/// Definite space in both dimensions. +pub fn AvailableSpace::from_size( + size : @geometry.Size[@geometry.Pixels], +) -> @geometry.Size[AvailableSpace] { + { width: Definite(size.width), height: Definite(size.height), } +} + +///| +/// Identifies a node requested from the `LayoutEngine` during this frame. +#derive(Eq, Hash, Compare, Debug) +pub(all) struct LayoutId(Int32) + +///| +/// Measures a leaf (e.g. text): given the dimensions already known and the +/// available space, in logical pixels, returns the content size. +pub type MeasureFn = ( + @geometry.Size[@geometry.Pixels?], + @geometry.Size[AvailableSpace], +) -> @geometry.Size[@geometry.Pixels] + +///| +/// Computes flexbox/grid/block layout for a frame's element tree. +pub struct LayoutEngine { + priv mut tree : @ctree.ChicleTree[MeasureFn] + /// The engine style of each node (needed by `stretch_auto_size_to_fill`). + priv styles : Map[Int32, @cstyle.Style] + priv children : Map[Int32, Array[Int32]] + priv parents : Map[Int32, Int32] + priv absolute_layout_bounds : Map[Int32, @geometry.Bounds[@geometry.Pixels]] + /// Absolute outer origins in device pixels, unrounded. + priv absolute_outer_origins : Map[Int32, @geometry.Point[Double]] + priv computed_layouts : @hashset.HashSet[Int32] +} + +///| +fn new_tree() -> @ctree.ChicleTree[MeasureFn] { + let tree : @ctree.ChicleTree[MeasureFn] = @ctree.ChicleTree() + // GPUI snaps to device pixels itself; the engine must not round. + tree.disable_rounding() + tree +} + +///| +pub fn LayoutEngine::new() -> LayoutEngine { + { + tree: new_tree(), + styles: {}, + children: {}, + parents: {}, + absolute_layout_bounds: {}, + absolute_outer_origins: {}, + computed_layouts: @hashset.HashSet([]), + } +} + +///| +/// Forgets every node. Call between frames; `LayoutId`s from earlier frames +/// become invalid. +pub fn LayoutEngine::clear(self : LayoutEngine) -> Unit { + self.tree = new_tree() + self.styles.clear() + self.children.clear() + self.parents.clear() + self.absolute_layout_bounds.clear() + self.absolute_outer_origins.clear() + self.computed_layouts.clear() +} + +///| +/// Number of nodes requested since the last `clear`. +pub fn LayoutEngine::node_count(self : LayoutEngine) -> Int32 { + self.styles.length() +} + +///| +/// GPUI expects layout errors to be impossible by construction; fail loudly +/// if one happens anyway. +fn engine_failure(operation : String, error : @ctree.ChicleError) -> Unit { + ignore(error) + abort("layout engine: \{operation} failed (invalid LayoutId?)") +} + +///| +fn LayoutEngine::check_id( + self : LayoutEngine, + id : LayoutId, + operation : String, +) -> Unit { + guard self.styles.contains(id.0) else { + abort( + "layout engine: \{operation}: unknown LayoutId(\{id.0}) (requested in an earlier frame?)", + ) + } +} + +///| +/// Requests a node with the given children (GPUI: `request_layout`). +pub fn LayoutEngine::request_layout( + self : LayoutEngine, + style : @style.Style, + rem_size : @geometry.Pixels, + scale_factor : Double, + children : Array[LayoutId], +) -> LayoutId { + let engine_style = style_to_engine(style, rem_size, scale_factor) + let child_ids = children.map(fn(child) { + self.check_id(child, "request_layout") + guard !self.parents.contains(child.0) else { + abort("layout engine: LayoutId(\{child.0}) already has a parent") + } + child.0 + }) + let id = if child_ids.is_empty() { + self.tree.new_leaf(engine_style) + } else { + self.tree.new_with_children(engine_style, child_ids) + } + self.styles[id] = engine_style + self.children[id] = child_ids + for child in child_ids { + self.parents[child] = id + } + LayoutId(id) +} + +///| +/// Requests a leaf whose content size comes from `measure`, called during +/// `compute_layout` (GPUI: `request_measured_layout`). +pub fn LayoutEngine::request_measured_layout( + self : LayoutEngine, + style : @style.Style, + rem_size : @geometry.Pixels, + scale_factor : Double, + measure : MeasureFn, +) -> LayoutId { + let engine_style = style_to_engine(style, rem_size, scale_factor) + let id = self.tree.new_leaf_with_context(engine_style, measure) + self.styles[id] = engine_style + self.children[id] = [] + LayoutId(id) +} + +///| +/// Makes an `auto`-sized root fill `size` (GPUI: `stretch_auto_size_to_fill`, +/// used for the window's root element). +pub fn LayoutEngine::stretch_auto_size_to_fill( + self : LayoutEngine, + id : LayoutId, + size : @geometry.Size[@geometry.Pixels], + scale_factor : Double, +) -> Unit { + self.check_id(id, "stretch_auto_size_to_fill") + let style = self.styles[id.0] + let stretch_width = style.size.width is DimAuto + let stretch_height = style.size.height is DimAuto + if !stretch_width && !stretch_height { + return + } + let width : @cstyle.Dimension = if stretch_width { + DimLength(round_to_device_pixel(size.width.to_double(), scale_factor)) + } else { + style.size.width + } + let height : @cstyle.Dimension = if stretch_height { + DimLength(round_to_device_pixel(size.height.to_double(), scale_factor)) + } else { + style.size.height + } + let stretched = { ..style, size: @cgeometry.Size(width~, height~), } + self.styles[id.0] = stretched + self.tree.set_style(id.0, stretched) catch { + e => engine_failure("set_style", e) + } +} + +///| +fn available_to_engine( + space : AvailableSpace, + scale_factor : Double, +) -> @cgeometry.AvailableSpace { + match space { + Definite(pixels) => AvailDefinite(pixels.to_double() * scale_factor) + MinContent => AvailMinContent + MaxContent => AvailMaxContent + } +} + +///| +fn available_from_engine( + space : @cgeometry.AvailableSpace, + scale_factor : Double, +) -> AvailableSpace { + match space { + AvailDefinite(value) => Definite(@geometry.px(value / scale_factor)) + AvailMinContent => MinContent + AvailMaxContent => MaxContent + } +} + +///| +/// Computes the layout of the subtree rooted at `id` (GPUI: +/// `compute_layout`). Measure functions receive and return logical pixels; +/// measured sizes are rounded up to whole device pixels. +pub fn LayoutEngine::compute_layout( + self : LayoutEngine, + id : LayoutId, + available_space : @geometry.Size[AvailableSpace], + scale_factor : Double, +) -> Unit { + self.check_id(id, "compute_layout") + // Recomputing invalidates cached bounds of the whole subtree. + if self.computed_layouts.contains(id.0) { + let stack = [id.0] + while stack.pop() is Some(node) { + self.absolute_layout_bounds.remove(node) + self.absolute_outer_origins.remove(node) + for child in self.children.get(node).unwrap_or([]) { + stack.push(child) + } + } + } else { + self.computed_layouts.add(id.0) + } + let available = @cgeometry.Size( + width=available_to_engine(available_space.width, scale_factor), + height=available_to_engine(available_space.height, scale_factor), + ) + let measure_leaf = fn( + known : @cgeometry.Size[Double?], + available : @cgeometry.Size[@cgeometry.AvailableSpace], + _node : Int32, + context : MeasureFn?, + _style : @cstyle.Style, + ) -> @cgeometry.Size[Double] { + match context { + Option::None => @cgeometry.Size(width=0.0, height=0.0) + Some(measure) => { + let to_logical = fn(value : Double?) { + value.map(fn(v) { @geometry.px(v / scale_factor) }) + } + let measured = measure( + { width: to_logical(known.width), height: to_logical(known.height), }, + { + width: available_from_engine(available.width, scale_factor), + height: available_from_engine(available.height, scale_factor), + }, + ) + let snap = fn(d : @geometry.Pixels) { + let d = d.to_double() + ceil_to_device_pixel(if d > 0.0 { d } else { 0.0 }, scale_factor) + } + @cgeometry.Size( + width=snap(measured.width), + height=snap(measured.height), + ) + } + } + } + self.tree.compute_layout_with_measure(id.0, available, measure_leaf) catch { + e => engine_failure("compute_layout", e) + } +} + +///| +/// The bounds of a computed node, in logical pixels relative to the root's +/// origin (GPUI: `layout_bounds`). Corners are snapped to device pixels. +pub fn LayoutEngine::layout_bounds( + self : LayoutEngine, + id : LayoutId, + scale_factor : Double, +) -> @geometry.Bounds[@geometry.Pixels] { + self.check_id(id, "layout_bounds") + if self.absolute_layout_bounds.get(id.0) is Some(bounds) { + return bounds + } + let layout = self.tree.layout(id.0) catch { + e => { + engine_failure("layout", e) + panic() + } + } + let location : @geometry.Point[Double] = { + x: layout.location.x, + y: layout.location.y, + } + let origin = match self.parents.get(id.0) { + Some(parent) => { + ignore(self.layout_bounds(LayoutId(parent), scale_factor)) + guard self.absolute_outer_origins.get(parent) is Some(parent_origin) else { + abort("layout engine: parent origin should be cached") + } + parent_origin + location + } + Option::None => location + } + self.absolute_outer_origins[id.0] = origin + let far = origin + { x: layout.size.width, y: layout.size.height, } + let snap = fn(p : @geometry.Point[Double]) { + p.map(fn(v) { @geometry.px(round_half_toward_zero(v) / scale_factor) }) + } + let bounds = @geometry.Bounds::from_corners(snap(origin), snap(far)) + self.absolute_layout_bounds[id.0] = bounds + bounds +} diff --git a/src/layout/layout_test.mbt b/src/layout/layout_test.mbt new file mode 100644 index 0000000..9da9e8c --- /dev/null +++ b/src/layout/layout_test.mbt @@ -0,0 +1,359 @@ +///| +fn st(refinement : @style.StyleRefinement) -> @style.Style { + (Default::default() : @style.Style).refined(refinement) +} + +///| +fn r() -> @style.StyleRefinement { + @style.StyleRefinement::new() +} + +///| +let rem : @geometry.Pixels = @geometry.px(16.0) + +///| +fn bounds( + x : Double, + y : Double, + w : Double, + h : Double, +) -> @geometry.Bounds[@geometry.Pixels] { + @geometry.bounds( + @geometry.point(@geometry.px(x), @geometry.px(y)), + @geometry.size(@geometry.px(w), @geometry.px(h)), + ) +} + +///| +fn definite(w : Double, h : Double) -> @geometry.Size[@layout.AvailableSpace] { + @layout.AvailableSpace::from_size( + @geometry.size(@geometry.px(w), @geometry.px(h)), + ) +} + +///| +/// Port of GPUI's `test_round_half_toward_zero` (util.rs). +test "round half toward zero" { + let cases : Array[(Double, Double)] = [ + (0.5, 0.0), + (1.5, 1.0), + (2.5, 2.0), + (-0.5, 0.0), + (-1.5, -1.0), + (-2.5, -2.0), + (1.5001, 2.0), + (1.4999, 1.0), + (-1.5001, -2.0), + (-1.4999, -1.0), + (0.0, 0.0), + (3.0, 3.0), + (-3.0, -3.0), + (2.5001, 3.0), + ] + for case in cases { + let (input, expected) = case + assert_eq(@layout.round_half_toward_zero(input), expected) + } +} + +///| +/// Port of GPUI's `border_widths_to_taffy_use_stroke_snapping` (taffy.rs). +test "border widths use stroke snapping" { + let widths = @geometry.Edges::new( + top=@geometry.px(0.0).to_absolute(), + right=@geometry.px(0.4).to_absolute(), + bottom=@geometry.px(0.5).to_absolute(), + left=@geometry.px(1.6).to_absolute(), + ) + let border = @layout.border_widths_to_engine(widths, rem, 1.0) + assert_true(border.top is DimLength(0.0)) + assert_true(border.right is DimLength(1.0)) + assert_true(border.bottom is DimLength(1.0)) + assert_true(border.left is DimLength(2.0)) +} + +///| +test "flex row distributes free space" { + let engine = @layout.LayoutEngine::new() + let a = engine.request_layout( + st(r().w(@geometry.px(50.0)).h_full()), + rem, + 1.0, + [], + ) + let b = engine.request_layout(st(r().flex_1()), rem, 1.0, []) + let c = engine.request_layout( + st(r().w(@geometry.px(100.0)).h(@geometry.px(20.0))), + rem, + 1.0, + [], + ) + let root = engine.request_layout( + st(r().flex().w(@geometry.px(300.0)).h(@geometry.px(40.0))), + rem, + 1.0, + [a, b, c], + ) + engine.compute_layout(root, definite(1000.0, 1000.0), 1.0) + assert_eq(engine.layout_bounds(root, 1.0), bounds(0.0, 0.0, 300.0, 40.0)) + assert_eq(engine.layout_bounds(a, 1.0), bounds(0.0, 0.0, 50.0, 40.0)) + // flex_1 takes the remaining 150px; items stretch on the cross axis. + assert_eq(engine.layout_bounds(b, 1.0), bounds(50.0, 0.0, 150.0, 40.0)) + assert_eq(engine.layout_bounds(c, 1.0), bounds(200.0, 0.0, 100.0, 20.0)) + assert_eq(engine.node_count(), 4) +} + +///| +test "rems, padding, gap and percentages resolve" { + let engine = @layout.LayoutEngine::new() + let first = engine.request_layout(st(r().w_1_2().h_4()), rem, 1.0, []) + let second = engine.request_layout(st(r().w_full().h_8()), rem, 1.0, []) + let root = engine.request_layout( + st(r().flex().flex_col().p_4().gap_2().w(@geometry.px(232.0))), + rem, + 1.0, + [first, second], + ) + engine.compute_layout(root, definite(500.0, 500.0), 1.0) + // p_4 = 1rem = 16px, gap_2 = 0.5rem = 8px, h_4 = 16px, h_8 = 32px. + assert_eq(engine.layout_bounds(first, 1.0), bounds(16.0, 16.0, 100.0, 16.0)) + assert_eq(engine.layout_bounds(second, 1.0), bounds(16.0, 40.0, 200.0, 32.0)) + // Auto height: padding + children + gap. + assert_eq(engine.layout_bounds(root, 1.0), bounds(0.0, 0.0, 232.0, 88.0)) +} + +///| +test "borders take space inside the box" { + let engine = @layout.LayoutEngine::new() + let child = engine.request_layout(st(r().size_full()), rem, 1.0, []) + let root = engine.request_layout( + st(r().flex().border_2().size(@geometry.px(50.0))), + rem, + 1.0, + [child], + ) + engine.compute_layout(root, definite(100.0, 100.0), 1.0) + assert_eq(engine.layout_bounds(child, 1.0), bounds(2.0, 2.0, 46.0, 46.0)) +} + +///| +test "layout snaps to device pixels" { + let engine = @layout.LayoutEngine::new() + // 10.3px at 1.5x is 15.45 device px -> 15 -> 10px logical. + let child = engine.request_layout( + st(r().w(@geometry.px(10.3)).h(@geometry.px(10.0))), + rem, + 1.5, + [], + ) + let root = engine.request_layout(st(r().flex()), rem, 1.5, [child]) + engine.compute_layout(root, definite(100.0, 100.0), 1.5) + let b = engine.layout_bounds(child, 1.5) + assert_eq(b.size.width, @geometry.px(10.0)) + assert_eq(b.size.height, @geometry.px(10.0)) + // A 1px border at 0.5x is still one device pixel wide. + assert_eq(@layout.round_stroke_to_device_pixel(1.0, 0.5), 1.0) + assert_eq(@layout.round_stroke_to_device_pixel(0.0, 0.5), 0.0) +} + +///| +test "nested bounds are absolute" { + let engine = @layout.LayoutEngine::new() + let leaf = engine.request_layout(st(r().size(@geometry.px(10.0))), rem, 1.0, []) + let middle = engine.request_layout( + st(r().flex().p(@geometry.px(5.0))), + rem, + 1.0, + [leaf], + ) + let spacer = engine.request_layout(st(r().w(@geometry.px(30.0))), rem, 1.0, []) + let root = engine.request_layout( + st(r().flex().p(@geometry.px(7.0))), + rem, + 1.0, + [spacer, middle], + ) + engine.compute_layout(root, definite(200.0, 200.0), 1.0) + assert_eq(engine.layout_bounds(middle, 1.0), bounds(37.0, 7.0, 20.0, 20.0)) + assert_eq(engine.layout_bounds(leaf, 1.0), bounds(42.0, 12.0, 10.0, 10.0)) + // Recomputing with less space updates cached bounds. + engine.compute_layout(root, definite(20.0, 20.0), 1.0) + assert_eq(engine.layout_bounds(leaf, 1.0).origin.y, @geometry.px(12.0)) +} + +///| +test "measured leaves get logical pixels and are ceiled to device pixels" { + let engine = @layout.LayoutEngine::new() + let calls : Array[(@geometry.Pixels?, @layout.AvailableSpace)] = [] + // A fake paragraph: 7.25px per character, wrapping at the available width, + // 20px per line. + let measure = fn( + known : @geometry.Size[@geometry.Pixels?], + available : @geometry.Size[@layout.AvailableSpace], + ) -> @geometry.Size[@geometry.Pixels] { + calls.push((known.width, available.width)) + let text_width = 40.0 * 7.25 + let wrap = match (known.width, available.width) { + (Some(width), _) => width.to_double() + (None, Definite(width)) => width.to_double() + (None, _) => text_width + } + let width = if text_width < wrap { text_width } else { wrap } + let lines = (text_width / wrap).ceil() + @geometry.size(@geometry.px(width), @geometry.px(lines * 20.0)) + } + let text = engine.request_measured_layout(st(r()), rem, 2.0, measure) + let root = engine.request_layout( + st(r().flex().flex_col().w(@geometry.px(100.0))), + rem, + 2.0, + [text], + ) + engine.compute_layout(root, definite(800.0, 600.0), 2.0) + let b = engine.layout_bounds(text, 2.0) + assert_eq(b.size.width, @geometry.px(100.0)) + // 290px of text in 100px -> 3 lines. + assert_eq(b.size.height, @geometry.px(60.0)) + assert_true(calls.length() > 0) + // The measure function sees logical, not device, pixels. + for call in calls { + match call { + (Some(width), _) => assert_eq(width, @geometry.px(100.0)) + (None, Definite(width)) => assert_true(width.to_double() <= 800.0) + _ => () + } + } +} + +///| +test "measured sizes round up to whole device pixels" { + let engine = @layout.LayoutEngine::new() + let leaf = engine.request_measured_layout(st(r()), rem, 2.0, fn(_, _) { + @geometry.size(@geometry.px(10.2), @geometry.px(-5.0)) + }) + // items_start: keep the measured height instead of stretching. + let root = engine.request_layout(st(r().flex().items_start()), rem, 2.0, [ + leaf, + ]) + engine.compute_layout(root, definite(100.0, 100.0), 2.0) + let b = engine.layout_bounds(leaf, 2.0) + // ceil(10.2 * 2) = 21 device px = 10.5 logical; negative clamps to 0. + assert_eq(b.size.width, @geometry.px(10.5)) + assert_eq(b.size.height, @geometry.px(0.0)) +} + +///| +test "stretch auto size to fill" { + let engine = @layout.LayoutEngine::new() + let child = engine.request_layout(st(r().flex_1()), rem, 1.0, []) + let root = engine.request_layout(st(r().flex()), rem, 1.0, [child]) + engine.stretch_auto_size_to_fill( + root, + @geometry.size(@geometry.px(640.0), @geometry.px(480.0)), + 1.0, + ) + engine.compute_layout(root, @layout.AvailableSpace::min_size(), 1.0) + assert_eq(engine.layout_bounds(root, 1.0), bounds(0.0, 0.0, 640.0, 480.0)) + assert_eq(engine.layout_bounds(child, 1.0), bounds(0.0, 0.0, 640.0, 480.0)) + // A definite size is left alone. + let fixed = engine.request_layout( + st(r().size(@geometry.px(10.0))), + rem, + 1.0, + [], + ) + engine.stretch_auto_size_to_fill( + fixed, + @geometry.size(@geometry.px(640.0), @geometry.px(480.0)), + 1.0, + ) + engine.compute_layout(fixed, @layout.AvailableSpace::min_size(), 1.0) + assert_eq(engine.layout_bounds(fixed, 1.0).size.width, @geometry.px(10.0)) +} + +///| +test "grid columns and placement" { + let engine = @layout.LayoutEngine::new() + let cells = [ + engine.request_layout(st(r().h(@geometry.px(10.0))), rem, 1.0, []), + engine.request_layout(st(r().h(@geometry.px(10.0)).col_span(2)), rem, 1.0, []), + engine.request_layout(st(r().h(@geometry.px(10.0))), rem, 1.0, []), + ] + let root = engine.request_layout( + st(r().grid().grid_cols(3).w(@geometry.px(300.0))), + rem, + 1.0, + cells, + ) + engine.compute_layout(root, definite(1000.0, 1000.0), 1.0) + assert_eq(engine.layout_bounds(cells[0], 1.0), bounds(0.0, 0.0, 100.0, 10.0)) + assert_eq( + engine.layout_bounds(cells[1], 1.0), + bounds(100.0, 0.0, 200.0, 10.0), + ) + assert_eq(engine.layout_bounds(cells[2], 1.0), bounds(0.0, 10.0, 100.0, 10.0)) +} + +///| +test "absolute positioning and display none" { + let engine = @layout.LayoutEngine::new() + let overlay = engine.request_layout( + st( + r() + .absolute() + .top(@geometry.px(5.0)) + .right(@geometry.px(5.0)) + .size(@geometry.px(20.0)), + ), + rem, + 1.0, + [], + ) + let gone = engine.request_layout( + st(r().hidden().size(@geometry.px(50.0))), + rem, + 1.0, + [], + ) + let root = engine.request_layout( + st(r().flex().relative().size(@geometry.px(100.0))), + rem, + 1.0, + [overlay, gone], + ) + engine.compute_layout(root, definite(500.0, 500.0), 1.0) + assert_eq(engine.layout_bounds(overlay, 1.0), bounds(75.0, 5.0, 20.0, 20.0)) + assert_eq(engine.layout_bounds(gone, 1.0).size.width, @geometry.px(0.0)) +} + +///| +test "alignment and justification" { + let engine = @layout.LayoutEngine::new() + let child = engine.request_layout( + st(r().size(@geometry.px(20.0))), + rem, + 1.0, + [], + ) + let root = engine.request_layout( + st(r().flex().items_center().justify_center().size(@geometry.px(100.0))), + rem, + 1.0, + [child], + ) + engine.compute_layout(root, definite(500.0, 500.0), 1.0) + assert_eq(engine.layout_bounds(child, 1.0), bounds(40.0, 40.0, 20.0, 20.0)) +} + +///| +test "clear starts a new frame" { + let engine = @layout.LayoutEngine::new() + let a = engine.request_layout(st(r().size(@geometry.px(5.0))), rem, 1.0, []) + engine.compute_layout(a, @layout.AvailableSpace::min_size(), 1.0) + assert_eq(engine.node_count(), 1) + engine.clear() + assert_eq(engine.node_count(), 0) + let b = engine.request_layout(st(r().size(@geometry.px(7.0))), rem, 1.0, []) + engine.compute_layout(b, @layout.AvailableSpace::min_size(), 1.0) + assert_eq(engine.layout_bounds(b, 1.0).size.width, @geometry.px(7.0)) +} diff --git a/src/layout/moon.pkg b/src/layout/moon.pkg new file mode 100644 index 0000000..6fbde9b --- /dev/null +++ b/src/layout/moon.pkg @@ -0,0 +1,8 @@ +import { + "experiments/gpui/geometry", + "experiments/gpui/style", + "Milky2018/chicle/geometry" @cgeometry, + "Milky2018/chicle/style" @cstyle, + "Milky2018/chicle/tree" @ctree, + "moonbitlang/core/hashset", +} diff --git a/src/layout/pkg.generated.mbti b/src/layout/pkg.generated.mbti new file mode 100644 index 0000000..3395355 --- /dev/null +++ b/src/layout/pkg.generated.mbti @@ -0,0 +1,52 @@ +// Generated using `moon info`, DON'T EDIT IT +package "experiments/gpui/layout" + +import { + "moonbitlang/core/debug", +} + +// Values +pub fn border_widths_to_engine(@experiments/gpui/geometry.Edges[@experiments/gpui/geometry.AbsoluteLength], @experiments/gpui/geometry.Pixels, Double) -> @Milky2018/chicle/geometry.Rect[@Milky2018/chicle/style.Dimension] + +pub fn ceil_to_device_pixel(Double, Double) -> Double + +pub fn round_half_toward_zero(Double) -> Double + +pub fn round_stroke_to_device_pixel(Double, Double) -> Double + +pub fn round_to_device_pixel(Double, Double) -> Double + +pub fn style_to_engine(@experiments/gpui/style.Style, @experiments/gpui/geometry.Pixels, Double) -> @Milky2018/chicle/style.Style + +// Errors + +// Types and methods +#derive(Eq, Hash, @debug.Debug) +pub(all) enum AvailableSpace { + Definite(@experiments/gpui/geometry.Pixels) + MinContent + MaxContent +} +pub fn AvailableSpace::from_size(@experiments/gpui/geometry.Size[@experiments/gpui/geometry.Pixels]) -> @experiments/gpui/geometry.Size[Self] +pub fn AvailableSpace::min_size() -> @experiments/gpui/geometry.Size[Self] +pub impl Default for AvailableSpace + +pub struct LayoutEngine { + // private fields +} +pub fn LayoutEngine::clear(Self) -> Unit +pub fn LayoutEngine::compute_layout(Self, LayoutId, @experiments/gpui/geometry.Size[AvailableSpace], Double) -> Unit +pub fn LayoutEngine::layout_bounds(Self, LayoutId, Double) -> @experiments/gpui/geometry.Bounds[@experiments/gpui/geometry.Pixels] +pub fn LayoutEngine::new() -> Self +pub fn LayoutEngine::node_count(Self) -> Int32 +pub fn LayoutEngine::request_layout(Self, @experiments/gpui/style.Style, @experiments/gpui/geometry.Pixels, Double, Array[LayoutId]) -> LayoutId +pub fn LayoutEngine::request_measured_layout(Self, @experiments/gpui/style.Style, @experiments/gpui/geometry.Pixels, Double, (@experiments/gpui/geometry.Size[@experiments/gpui/geometry.Pixels?], @experiments/gpui/geometry.Size[AvailableSpace]) -> @experiments/gpui/geometry.Size[@experiments/gpui/geometry.Pixels]) -> LayoutId +pub fn LayoutEngine::stretch_auto_size_to_fill(Self, LayoutId, @experiments/gpui/geometry.Size[@experiments/gpui/geometry.Pixels], Double) -> Unit + +#derive(Compare, Eq, Hash, @debug.Debug) +pub(all) struct LayoutId(Int32) + +// Type aliases +pub type MeasureFn = (@experiments/gpui/geometry.Size[@experiments/gpui/geometry.Pixels?], @experiments/gpui/geometry.Size[AvailableSpace]) -> @experiments/gpui/geometry.Size[@experiments/gpui/geometry.Pixels] + +// Traits diff --git a/src/platform/moon.pkg b/src/platform/moon.pkg new file mode 100644 index 0000000..27b2906 --- /dev/null +++ b/src/platform/moon.pkg @@ -0,0 +1,13 @@ +import { + "experiments/gpui/geometry", + "experiments/gpui/scene", + "experiments/gpui/style", + "experiments/gpui/input", + "experiments/gpui/executor", +} + +// experiments/gpui/executor uses MoonBit's experimental async intrinsics. + +options( + "allow-experimental-packages": true, +) diff --git a/src/platform/pkg.generated.mbti b/src/platform/pkg.generated.mbti new file mode 100644 index 0000000..38c6647 --- /dev/null +++ b/src/platform/pkg.generated.mbti @@ -0,0 +1,111 @@ +// Generated using `moon info`, DON'T EDIT IT +package "experiments/gpui/platform" + +import { + "experiments/gpui/executor", + "experiments/gpui/geometry", + "experiments/gpui/input", + "experiments/gpui/scene", + "experiments/gpui/style", + "moonbitlang/core/debug", +} + +// Values + +// Errors + +// Types and methods +#derive(Eq, @debug.Debug) +pub(all) enum ClipboardEntry { + String(ClipboardString) +} + +#derive(Eq, @debug.Debug) +pub(all) struct ClipboardItem { + entries : Array[ClipboardEntry] +} +pub fn ClipboardItem::metadata(Self) -> String? +pub fn ClipboardItem::new_string(String) -> Self +pub fn ClipboardItem::new_string_with_metadata(String, String) -> Self +pub fn ClipboardItem::text(Self) -> String? + +#derive(Eq, @debug.Debug) +pub(all) struct ClipboardString { + text : String + metadata : String? +} +pub fn ClipboardString::new(String) -> Self +pub fn ClipboardString::new_with_metadata(String, String) -> Self + +#derive(Eq, @debug.Debug) +pub(all) enum WindowBounds { + Windowed(@geometry.Bounds[@geometry.Pixels]) + Maximized(@geometry.Bounds[@geometry.Pixels]) + Fullscreen(@geometry.Bounds[@geometry.Pixels]) +} +pub fn WindowBounds::get_bounds(Self) -> @geometry.Bounds[@geometry.Pixels] +pub impl Default for WindowBounds + +#derive(Compare, Eq, Hash, @debug.Debug) +pub(all) struct WindowId(Int32) +pub impl Show for WindowId + +#derive(Eq, @debug.Debug) +pub(all) struct WindowOptions { + window_bounds : WindowBounds? + title : String? + focus : Bool + show : Bool + scale_factor : Double? + rem_size : @geometry.Pixels +} +pub fn WindowOptions::with_size(@geometry.Size[@geometry.Pixels], scale_factor? : Double, title? : String, rem_size? : @geometry.Pixels) -> Self +pub impl Default for WindowOptions + +#derive(Eq, @debug.Debug) +pub(all) struct WindowParams { + bounds : @geometry.Bounds[@geometry.Pixels] + title : String? + focus : Bool + show : Bool + scale_factor : Double? +} + +// Type aliases + +// Traits +pub(open) trait Platform { + fn dispatcher(Self) -> &@executor.Dispatcher + fn default_window_bounds(Self) -> @geometry.Bounds[@geometry.Pixels] + fn open_window(Self, WindowId, WindowParams) -> &PlatformWindow + fn run(Self, () -> Unit) -> Unit + fn quit(Self) -> Unit + fn active_window(Self) -> WindowId? + fn set_cursor_style(Self, @style.CursorStyle) -> Unit + fn read_from_clipboard(Self) -> ClipboardItem? + fn write_to_clipboard(Self, ClipboardItem) -> Unit + fn open_url(Self, String) -> Unit +} + +pub(open) trait PlatformWindow { + fn bounds(Self) -> @geometry.Bounds[@geometry.Pixels] + fn content_size(Self) -> @geometry.Size[@geometry.Pixels] + fn scale_factor(Self) -> Double + fn mouse_position(Self) -> @geometry.Point[@geometry.Pixels] + fn modifiers(Self) -> @input.Modifiers + fn is_active(Self) -> Bool + fn is_hovered(Self) -> Bool + fn set_title(Self, String) -> Unit + fn activate(Self) -> Unit + fn resize(Self, @geometry.Size[@geometry.Pixels]) -> Unit + fn draw(Self, @scene.Scene) -> Unit + fn schedule_frame(Self) -> Unit + fn close(Self) -> Unit + fn on_request_frame(Self, () -> Unit) -> Unit + fn on_input(Self, (@input.PlatformInput) -> @input.DispatchEventResult) -> Unit + fn on_resize(Self, (@geometry.Size[@geometry.Pixels], Double) -> Unit) -> Unit + fn on_active_status_change(Self, (Bool) -> Unit) -> Unit + fn on_hover_status_change(Self, (Bool) -> Unit) -> Unit + fn on_should_close(Self, () -> Bool) -> Unit + fn on_close(Self, () -> Unit) -> Unit +} diff --git a/src/platform/platform.mbt b/src/platform/platform.mbt new file mode 100644 index 0000000..f6c9d77 --- /dev/null +++ b/src/platform/platform.mbt @@ -0,0 +1,83 @@ +// Platform interfaces, ported from gpui/src/platform.rs (the core subset: +// windows, event loop, executor dispatcher, cursor and clipboard; text +// system, glyph atlas, IME, menus and displays arrive in M9/M10). +// +// Pure trait definitions only; concrete backends live in `platform/test` +// (M7) and `platform/web` (M8). + +///| +/// A platform-backed window handle (GPUI: `PlatformWindow`). +pub(open) trait PlatformWindow { + /// Window bounds in logical pixels. + fn bounds(Self) -> @geometry.Bounds[@geometry.Pixels] + /// Size of the drawable content area in logical pixels. + fn content_size(Self) -> @geometry.Size[@geometry.Pixels] + /// Device-pixel scale factor. + fn scale_factor(Self) -> Double + /// Last known pointer position in logical pixels. + fn mouse_position(Self) -> @geometry.Point[@geometry.Pixels] + /// Currently held modifier keys. + fn modifiers(Self) -> @input.Modifiers + /// Whether this window is currently active/focused. + fn is_active(Self) -> Bool + /// Whether the pointer is currently over this window. + fn is_hovered(Self) -> Bool + /// Sets the window's title. + fn set_title(Self, String) -> Unit + /// Focuses/brings this window to the front. + fn activate(Self) -> Unit + /// Programmatically resizes the window to `size`. Must not re-enter + /// `on_resize`. + fn resize(Self, @geometry.Size[@geometry.Pixels]) -> Unit + /// Presents a finished `Scene`. + fn draw(Self, @scene.Scene) -> Unit + /// Requests that the platform invoke the `on_request_frame` callback on + /// the next frame. + fn schedule_frame(Self) -> Unit + /// App-driven teardown hook (MoonBit has no `Drop`). Must be idempotent + /// and must not re-invoke `on_close`. + fn close(Self) -> Unit + /// Registers the callback invoked when a scheduled frame should draw. + fn on_request_frame(Self, () -> Unit) -> Unit + /// Registers the callback invoked for platform input events. + fn on_input(Self, (@input.PlatformInput) -> @input.DispatchEventResult) -> Unit + /// Registers the callback invoked when the window size or scale factor + /// changes from the platform side. + fn on_resize(Self, (@geometry.Size[@geometry.Pixels], Double) -> Unit) -> Unit + /// Registers the callback invoked when active status changes. + fn on_active_status_change(Self, (Bool) -> Unit) -> Unit + /// Registers the callback invoked when pointer hover status changes. + fn on_hover_status_change(Self, (Bool) -> Unit) -> Unit + /// Registers the callback asked whether a user-initiated close should + /// proceed. + fn on_should_close(Self, () -> Bool) -> Unit + /// Registers the callback invoked when the platform closes the window. + fn on_close(Self, () -> Unit) -> Unit +} + +///| +/// Platform services (GPUI: `Platform`). +pub(open) trait Platform { + /// The dispatcher used by the app's executors. + fn dispatcher(Self) -> &@executor.Dispatcher + /// Default logical bounds for a new window when `WindowOptions.window_bounds` + /// is `None`. + fn default_window_bounds(Self) -> @geometry.Bounds[@geometry.Pixels] + /// Opens a new platform window with the given id and parameters. + fn open_window(Self, WindowId, WindowParams) -> &PlatformWindow + /// Starts the platform event loop, calling `on_finish_launching` once + /// ready. + fn run(Self, () -> Unit) -> Unit + /// Requests that the platform event loop exit. + fn quit(Self) -> Unit + /// The currently active window id, if any. + fn active_window(Self) -> WindowId? + /// Sets the pointer cursor style. + fn set_cursor_style(Self, @style.CursorStyle) -> Unit + /// Reads the current clipboard contents, if any. + fn read_from_clipboard(Self) -> ClipboardItem? + /// Replaces the clipboard contents. + fn write_to_clipboard(Self, ClipboardItem) -> Unit + /// Opens `url` in the system/browser handler. + fn open_url(Self, String) -> Unit +} diff --git a/src/platform/platform_test.mbt b/src/platform/platform_test.mbt new file mode 100644 index 0000000..e2b0759 --- /dev/null +++ b/src/platform/platform_test.mbt @@ -0,0 +1,70 @@ +///| +test "WindowBounds get_bounds extracts bounds across variants" { + let b = @geometry.bounds( + @geometry.point(@geometry.px(10.0), @geometry.px(20.0)), + @geometry.size(@geometry.px(800.0), @geometry.px(600.0)), + ) + assert_eq(@platform.WindowBounds::Windowed(b).get_bounds(), b) + assert_eq(@platform.WindowBounds::Maximized(b).get_bounds(), b) + assert_eq(@platform.WindowBounds::Fullscreen(b).get_bounds(), b) + assert_eq( + (Default::default() : @platform.WindowBounds), + @platform.WindowBounds::Windowed(Default::default()), + ) +} + +///| +test "WindowOptions default and with_size" { + let defaults : @platform.WindowOptions = Default::default() + assert_eq(defaults.window_bounds, None) + assert_eq(defaults.title, None) + assert_true(defaults.focus) + assert_true(defaults.show) + assert_eq(defaults.scale_factor, None) + assert_eq(defaults.rem_size, @geometry.px(16.0)) + let opts = @platform.WindowOptions::with_size( + @geometry.size(@geometry.px(640.0), @geometry.px(480.0)), + scale_factor=2.0, + title="Demo", + rem_size=@geometry.px(14.0), + ) + assert_eq( + opts.window_bounds, + Some( + @platform.WindowBounds::Windowed( + @geometry.bounds( + @geometry.point(@geometry.px(0.0), @geometry.px(0.0)), + @geometry.size(@geometry.px(640.0), @geometry.px(480.0)), + ), + ), + ), + ) + assert_eq(opts.scale_factor, Some(2.0)) + assert_eq(opts.title, Some("Demo")) + assert_eq(opts.rem_size, @geometry.px(14.0)) +} + +///| +test "ClipboardItem text and metadata" { + let plain = @platform.ClipboardItem::new_string("hello") + assert_eq(plain.text(), Some("hello")) + assert_eq(plain.metadata(), None) + let with_meta = @platform.ClipboardItem::new_string_with_metadata( + "code", "rust", + ) + assert_eq(with_meta.text(), Some("code")) + assert_eq(with_meta.metadata(), Some("rust")) + let multi : @platform.ClipboardItem = { + entries: [ + @platform.ClipboardEntry::String( + @platform.ClipboardString::new_with_metadata("first", "m1"), + ), + @platform.ClipboardEntry::String(@platform.ClipboardString::new("second")), + ], + } + assert_eq(multi.text(), Some("first\nsecond")) + assert_eq(multi.metadata(), Some("m1")) + let empty : @platform.ClipboardItem = { entries: [], } + assert_eq(empty.text(), None) + assert_eq(empty.metadata(), None) +} diff --git a/src/platform/test/moon.pkg b/src/platform/test/moon.pkg new file mode 100644 index 0000000..5c024f2 --- /dev/null +++ b/src/platform/test/moon.pkg @@ -0,0 +1,20 @@ +import { + "experiments/gpui/geometry", + "experiments/gpui/scene", + "experiments/gpui/style", + "experiments/gpui/input", + "experiments/gpui/executor", + "experiments/gpui/app", + "experiments/gpui/platform", + "experiments/gpui/window", +} + +// experiments/gpui/executor uses MoonBit's experimental async intrinsics. + +options( + "allow-experimental-packages": true, +) + +import { + "experiments/gpui/color", +} for "test" diff --git a/src/platform/test/pkg.generated.mbti b/src/platform/test/pkg.generated.mbti new file mode 100644 index 0000000..4feeb3f --- /dev/null +++ b/src/platform/test/pkg.generated.mbti @@ -0,0 +1,147 @@ +// Generated using `moon info`, DON'T EDIT IT +package "experiments/gpui/platform/test" + +import { + "experiments/gpui/app", + "experiments/gpui/executor", + "experiments/gpui/geometry", + "experiments/gpui/input", + "experiments/gpui/platform", + "experiments/gpui/scene", + "experiments/gpui/style", + "experiments/gpui/window", +} + +// Values + +// Errors + +// Types and methods +pub struct TestAppContext { + platform : TestPlatform + application : @window.Application + // private fields +} +pub fn TestAppContext::active_window(Self) -> @window.AnyWindowHandle? +pub fn TestAppContext::add_empty_window(Self, size? : @geometry.Size[@geometry.Pixels], scale_factor? : Double) -> VisualTestContext +pub fn[V : @window.Render] TestAppContext::add_window(Self, size? : @geometry.Size[@geometry.Pixels], scale_factor? : Double, title? : String, (@window.Window, @app.Context[V]) -> V) -> @window.WindowHandle[V] +pub fn[V : @window.Render] TestAppContext::add_window_view(Self, size? : @geometry.Size[@geometry.Pixels], scale_factor? : Double, title? : String, (@window.Window, @app.Context[V]) -> V) -> (@app.Entity[V], VisualTestContext) +pub fn TestAppContext::advance_clock(Self, Int32) -> Unit +pub fn TestAppContext::app(Self) -> @app.App +pub fn TestAppContext::application(Self) -> @window.Application +pub fn TestAppContext::background_executor(Self) -> @executor.Executor +pub fn TestAppContext::cursor_style(Self) -> @style.CursorStyle +pub fn TestAppContext::dispatcher(Self) -> @executor.TestDispatcher +pub fn TestAppContext::foreground_executor(Self) -> @executor.Executor +pub fn[G] TestAppContext::has_global(Self, @app.GlobalKey[G]) -> Bool +pub fn TestAppContext::new(default_bounds? : @geometry.Bounds[@geometry.Pixels], default_scale_factor? : Double) -> Self +pub fn[T] TestAppContext::new_entity(Self, (@app.Context[T]) -> T) -> @app.Entity[T] +pub fn[V : @window.Render] TestAppContext::open_window(Self, options? : @platform.WindowOptions, (@window.Window, @app.App) -> @app.Entity[V]) -> @window.WindowHandle[V] +pub fn TestAppContext::opened_url(Self) -> String? +pub fn TestAppContext::platform(Self) -> TestPlatform +pub fn TestAppContext::pump_frames(Self) -> Int32 +pub fn TestAppContext::quit(Self) -> Unit +pub fn[R] TestAppContext::read(Self, (@app.App) -> R) -> R +pub fn[T] TestAppContext::read_entity(Self, @app.Entity[T]) -> T +pub fn TestAppContext::read_from_clipboard(Self) -> @platform.ClipboardItem? +pub fn[G] TestAppContext::read_global(Self, @app.GlobalKey[G]) -> G +pub fn TestAppContext::refresh(Self) -> Unit +pub fn TestAppContext::run_until_parked(Self) -> Unit +pub fn[G] TestAppContext::set_global(Self, @app.GlobalKey[G], G) -> Unit +pub fn TestAppContext::skip_drawing(Self, skip? : Bool) -> Unit +pub fn[R] TestAppContext::spawn(Self, async (@app.AsyncApp) -> R) -> @executor.Task[R] +pub fn TestAppContext::test_window(Self, @window.AnyWindowHandle) -> TestWindow +pub fn[R] TestAppContext::update(Self, (@app.App) -> R) -> R +pub fn[T, R] TestAppContext::update_entity(Self, @app.Entity[T], (T, @app.Context[T]) -> R) -> R +pub fn[G, R] TestAppContext::update_global(Self, @app.GlobalKey[G], (G, @app.App) -> R) -> R +pub fn TestAppContext::windows(Self) -> Array[@window.AnyWindowHandle] +pub fn TestAppContext::with_platform(TestPlatform) -> Self +pub fn TestAppContext::write_to_clipboard(Self, @platform.ClipboardItem) -> Unit + +pub struct TestPlatform { + // private fields +} +pub fn TestPlatform::cursor_style(Self) -> @style.CursorStyle +pub fn TestPlatform::did_quit(Self) -> Bool +pub fn TestPlatform::did_run(Self) -> Bool +pub fn TestPlatform::new(dispatcher? : @executor.TestDispatcher, default_bounds? : @geometry.Bounds[@geometry.Pixels], default_scale_factor? : Double) -> Self +pub fn TestPlatform::opened_url(Self) -> String? +pub fn TestPlatform::opened_urls(Self) -> Array[String] +pub fn TestPlatform::pump_scheduled_frames(Self) -> Int32 +pub fn TestPlatform::set_active_window(Self, TestWindow?) -> Unit +pub fn TestPlatform::test_dispatcher(Self) -> @executor.TestDispatcher +pub fn TestPlatform::window(Self, @platform.WindowId) -> TestWindow? +pub fn TestPlatform::windows(Self) -> Array[TestWindow] +pub impl @platform.Platform for TestPlatform + +pub struct TestWindow { + // private fields +} +pub fn TestWindow::clear_drawn_scenes(Self) -> Unit +pub fn TestWindow::draw_count(Self) -> Int32 +pub fn TestWindow::drawn_scenes(Self) -> Array[@scene.Scene] +pub fn TestWindow::frame_schedule_count(Self) -> Int32 +pub fn TestWindow::frame_scheduled(Self) -> Bool +pub fn TestWindow::is_closed(Self) -> Bool +pub fn TestWindow::last_scene(Self) -> @scene.Scene? +pub fn TestWindow::simulate_active_status_change(Self, Bool) -> Unit +pub fn TestWindow::simulate_close(Self) -> Unit +pub fn TestWindow::simulate_close_requested(Self) -> Bool +pub fn TestWindow::simulate_frame_request(Self) -> Unit +pub fn TestWindow::simulate_hover_status_change(Self, Bool) -> Unit +pub fn TestWindow::simulate_input(Self, @input.PlatformInput) -> @input.DispatchEventResult +pub fn TestWindow::simulate_resize(Self, @geometry.Size[@geometry.Pixels]) -> Unit +pub fn TestWindow::simulate_scale_factor_change(Self, Double) -> Unit +pub fn TestWindow::simulate_scheduled_frame(Self) -> Bool +pub fn TestWindow::simulate_should_close(Self) -> Bool +pub fn TestWindow::title(Self) -> String? +pub fn TestWindow::window_id(Self) -> @platform.WindowId +pub impl @platform.PlatformWindow for TestWindow + +pub struct VisualTestContext { + cx : TestAppContext + window_handle : @window.AnyWindowHandle +} +pub fn VisualTestContext::advance_clock(Self, Int32) -> Unit +pub fn VisualTestContext::app(Self) -> @app.App +pub fn VisualTestContext::bounds(Self) -> @geometry.Bounds[@geometry.Pixels] +pub fn VisualTestContext::cursor_style(Self) -> @style.CursorStyle +pub fn VisualTestContext::draw(Self) -> @scene.Scene +pub fn VisualTestContext::draw_count(Self) -> Int32 +pub fn VisualTestContext::drawn_scenes(Self) -> Array[@scene.Scene] +pub fn VisualTestContext::from_window(@window.AnyWindowHandle, TestAppContext) -> Self +pub fn VisualTestContext::is_active(Self) -> Bool +pub fn VisualTestContext::is_closed(Self) -> Bool +pub fn VisualTestContext::is_hovered(Self) -> Bool +pub fn[T] VisualTestContext::new_entity(Self, (@app.Context[T]) -> T) -> @app.Entity[T] +pub fn[R] VisualTestContext::read(Self, (@app.App) -> R) -> R +pub fn VisualTestContext::read_from_clipboard(Self) -> @platform.ClipboardItem? +pub fn[V : @window.Render] VisualTestContext::replace_root_view(Self, (@window.Window, @app.Context[V]) -> V) -> @app.Entity[V] +pub fn VisualTestContext::run_until_parked(Self) -> Unit +pub fn VisualTestContext::scale_factor(Self) -> Double +pub fn VisualTestContext::scene(Self) -> @scene.Scene +pub fn VisualTestContext::simulate_active_status_change(Self, Bool) -> Unit +pub fn VisualTestContext::simulate_click(Self, @geometry.Point[@geometry.Pixels], button? : @input.MouseButton, modifiers? : @input.Modifiers) -> Unit +pub fn VisualTestContext::simulate_close(Self) -> Bool +pub fn VisualTestContext::simulate_hover_status_change(Self, Bool) -> Unit +pub fn VisualTestContext::simulate_input(Self, @input.PlatformInput) -> @input.DispatchEventResult +pub fn VisualTestContext::simulate_modifiers_change(Self, @input.Modifiers) -> @input.DispatchEventResult +pub fn VisualTestContext::simulate_mouse_down(Self, @geometry.Point[@geometry.Pixels], button? : @input.MouseButton, modifiers? : @input.Modifiers, click_count? : Int32) -> @input.DispatchEventResult +pub fn VisualTestContext::simulate_mouse_exit(Self, position? : @geometry.Point[@geometry.Pixels], modifiers? : @input.Modifiers) -> @input.DispatchEventResult +pub fn VisualTestContext::simulate_mouse_move(Self, @geometry.Point[@geometry.Pixels], button? : @input.MouseButton, modifiers? : @input.Modifiers) -> @input.DispatchEventResult +pub fn VisualTestContext::simulate_mouse_up(Self, @geometry.Point[@geometry.Pixels], button? : @input.MouseButton, modifiers? : @input.Modifiers, click_count? : Int32) -> @input.DispatchEventResult +pub fn VisualTestContext::simulate_resize(Self, @geometry.Size[@geometry.Pixels]) -> Unit +pub fn VisualTestContext::simulate_scale_factor_change(Self, Double) -> Unit +pub fn VisualTestContext::simulate_scroll_wheel(Self, @geometry.Point[@geometry.Pixels], @input.ScrollDelta, modifiers? : @input.Modifiers) -> @input.DispatchEventResult +pub fn VisualTestContext::test_window(Self) -> TestWindow +pub fn[R] VisualTestContext::update(Self, (@window.Window, @app.App) -> R) -> R +pub fn[T, R] VisualTestContext::update_entity(Self, @app.Entity[T], (T, @app.Context[T]) -> R) -> R +pub fn VisualTestContext::window(Self) -> @window.Window +pub fn VisualTestContext::window_handle(Self) -> @window.AnyWindowHandle +pub fn VisualTestContext::window_id(Self) -> @platform.WindowId +pub fn VisualTestContext::window_title(Self) -> String? +pub fn VisualTestContext::write_to_clipboard(Self, @platform.ClipboardItem) -> Unit + +// Type aliases + +// Traits diff --git a/src/platform/test/platform.mbt b/src/platform/test/platform.mbt new file mode 100644 index 0000000..fd3afca --- /dev/null +++ b/src/platform/test/platform.mbt @@ -0,0 +1,224 @@ +// Headless test platform, ported from gpui/src/platform/test/platform.rs. + +///| +let default_test_bounds : @geometry.Bounds[@geometry.Pixels] = @geometry.bounds( + @geometry.point(@geometry.px(0.0), @geometry.px(0.0)), + @geometry.size(@geometry.px(1024.0), @geometry.px(768.0)), +) + +///| +/// A headless `Platform` backed by `TestDispatcher` and `TestWindow`s +/// (GPUI: `TestPlatform`). +pub struct TestPlatform { + priv dispatcher : @executor.TestDispatcher + priv default_bounds : @geometry.Bounds[@geometry.Pixels] + priv default_scale_factor : Double + priv windows : Map[@platform.WindowId, TestWindow] + priv mut active_window : TestWindow? + priv mut active_cursor : @style.CursorStyle + priv mut clipboard : @platform.ClipboardItem? + priv opened_urls : Array[String] + priv mut run_called : Bool + priv mut quit_called : Bool +} + +///| +pub fn TestPlatform::new( + dispatcher? : @executor.TestDispatcher, + default_bounds? : @geometry.Bounds[@geometry.Pixels], + default_scale_factor~ : Double = 1.0, +) -> TestPlatform { + { + dispatcher: dispatcher.unwrap_or(@executor.TestDispatcher::new()), + default_bounds: default_bounds.unwrap_or(default_test_bounds), + default_scale_factor, + windows: {}, + active_window: None, + active_cursor: Arrow, + clipboard: None, + opened_urls: [], + run_called: false, + quit_called: false, + } +} + +///| +pub impl @platform.Platform for TestPlatform with fn dispatcher(self) { + let d : &@executor.Dispatcher = self.dispatcher + d +} + +///| +pub impl @platform.Platform for TestPlatform with fn default_window_bounds(self) { + self.default_bounds +} + +///| +pub impl @platform.Platform for TestPlatform with fn open_window( + self, + id, + params, +) { + let window = TestWindow::new(id, self, params, self.default_scale_factor) + self.windows[id] = window + if params.focus { + let previous = self.active_window + self.active_window = Some(window) + if previous is Some(prev) && prev.id != id { + @executor.Dispatcher::dispatch(self.dispatcher, fn() { + if !prev.closed { + prev.simulate_active_status_change(false) + } + }) + } + } + let pw : &@platform.PlatformWindow = window + pw +} + +///| +pub impl @platform.Platform for TestPlatform with fn run( + self, + on_finish_launching, +) { + self.run_called = true + on_finish_launching() +} + +///| +pub impl @platform.Platform for TestPlatform with fn quit(self) { + self.quit_called = true +} + +///| +pub impl @platform.Platform for TestPlatform with fn active_window(self) { + match self.active_window { + Some(win) if !win.closed => Some(win.id) + _ => None + } +} + +///| +pub impl @platform.Platform for TestPlatform with fn set_cursor_style( + self, + style, +) { + self.active_cursor = style +} + +///| +pub impl @platform.Platform for TestPlatform with fn read_from_clipboard(self) { + self.clipboard +} + +///| +pub impl @platform.Platform for TestPlatform with fn write_to_clipboard( + self, + item, +) { + self.clipboard = Some(item) +} + +///| +pub impl @platform.Platform for TestPlatform with fn open_url(self, url) { + self.opened_urls.push(url) +} + +// --------------------------------------------------------------------------- +// Inspection and simulation helpers +// --------------------------------------------------------------------------- + +///| +pub fn TestPlatform::test_dispatcher( + self : TestPlatform, +) -> @executor.TestDispatcher { + self.dispatcher +} + +///| +pub fn TestPlatform::window( + self : TestPlatform, + id : @platform.WindowId, +) -> TestWindow? { + self.windows.get(id) +} + +///| +pub fn TestPlatform::windows(self : TestPlatform) -> Array[TestWindow] { + let out = [] + for _, win in self.windows { + out.push(win) + } + out +} + +///| +pub fn TestPlatform::cursor_style(self : TestPlatform) -> @style.CursorStyle { + self.active_cursor +} + +///| +pub fn TestPlatform::opened_url(self : TestPlatform) -> String? { + self.opened_urls.last() +} + +///| +pub fn TestPlatform::opened_urls(self : TestPlatform) -> Array[String] { + self.opened_urls +} + +///| +pub fn TestPlatform::did_run(self : TestPlatform) -> Bool { + self.run_called +} + +///| +pub fn TestPlatform::did_quit(self : TestPlatform) -> Bool { + self.quit_called +} + +///| +/// Transfers active window status, notifying the previous and new windows on +/// the dispatcher (GPUI: `TestPlatform::set_active_window`). +pub fn TestPlatform::set_active_window( + self : TestPlatform, + window : TestWindow?, +) -> Unit { + let previous = self.active_window + self.active_window = window + let same = match (previous, window) { + (Some(prev), Some(curr)) => prev.id == curr.id + (None, None) => true + _ => false + } + if same { + return + } + @executor.Dispatcher::dispatch(self.dispatcher, fn() { + if previous is Some(prev) && !prev.closed { + prev.simulate_active_status_change(false) + } + if window is Some(win) && !win.closed { + win.simulate_active_status_change(true) + } + }) +} + +///| +/// Delivers one scheduled frame for every open window that currently has a +/// frame scheduled, returning how many frames ran. +pub fn TestPlatform::pump_scheduled_frames(self : TestPlatform) -> Int32 { + let open = [] + for _, win in self.windows { + if !win.closed && win.frame_scheduled { + open.push(win) + } + } + let mut pumped : Int32 = 0 + for win in open { + if win.simulate_scheduled_frame() { + pumped = pumped + 1 + } + } + pumped +} diff --git a/src/platform/test/test_context.mbt b/src/platform/test/test_context.mbt new file mode 100644 index 0000000..39289c3 --- /dev/null +++ b/src/platform/test/test_context.mbt @@ -0,0 +1,646 @@ +// High-level test harnesses, ported from gpui/src/app/test_context.rs +// (`TestAppContext` and `VisualTestContext`). + +///| +priv enum EmptyView { + EmptyView +} + +///| +impl @window.Render for EmptyView with fn render(_self, _window, _cx) { + @window.empty() +} + +///| +/// Owns a `TestPlatform` and `Application`, pumping tasks and scheduled +/// frames together for deterministic integration tests (GPUI: +/// `TestAppContext`). +pub struct TestAppContext { + platform : TestPlatform + application : @window.Application + priv mut skip_drawing : Bool +} + +///| +pub fn TestAppContext::new( + default_bounds? : @geometry.Bounds[@geometry.Pixels], + default_scale_factor~ : Double = 1.0, +) -> TestAppContext { + let platform = TestPlatform::new(default_bounds?, default_scale_factor~) + TestAppContext::with_platform(platform) +} + +///| +pub fn TestAppContext::with_platform(platform : TestPlatform) -> TestAppContext { + let p : &@platform.Platform = platform + let application = @window.Application::with_platform(p) + { platform, application, skip_drawing: false, } +} + +///| +pub fn TestAppContext::app(self : TestAppContext) -> @app.App { + self.application.app() +} + +///| +pub fn TestAppContext::application( + self : TestAppContext, +) -> @window.Application { + self.application +} + +///| +pub fn TestAppContext::platform(self : TestAppContext) -> TestPlatform { + self.platform +} + +///| +pub fn TestAppContext::dispatcher( + self : TestAppContext, +) -> @executor.TestDispatcher { + self.platform.test_dispatcher() +} + +///| +pub fn TestAppContext::foreground_executor( + self : TestAppContext, +) -> @executor.Executor { + self.application.app().foreground_executor() +} + +///| +pub fn TestAppContext::background_executor( + self : TestAppContext, +) -> @executor.Executor { + self.application.app().background_executor() +} + +///| +pub fn TestAppContext::windows( + self : TestAppContext, +) -> Array[@window.AnyWindowHandle] { + self.application.windows() +} + +///| +pub fn TestAppContext::active_window( + self : TestAppContext, +) -> @window.AnyWindowHandle? { + self.application.active_window() +} + +///| +pub fn TestAppContext::test_window( + self : TestAppContext, + handle : @window.AnyWindowHandle, +) -> TestWindow { + match self.platform.window(handle.window_id()) { + Some(win) => win + None => abort("no TestWindow for \{handle.window_id()}") + } +} + +///| +/// Disables (or re-enables) automatic frame pumping in `run_until_parked` +/// (GPUI: `TestAppContext::skip_drawing`). +pub fn TestAppContext::skip_drawing( + self : TestAppContext, + skip~ : Bool = true, +) -> Unit { + self.skip_drawing = skip +} + +///| +pub fn TestAppContext::pump_frames(self : TestAppContext) -> Int32 { + self.platform.pump_scheduled_frames() +} + +///| +/// Drains all ready tasks and pumps scheduled frames until neither tasks nor +/// scheduled frames remain (GPUI: `TestAppContext::run_until_parked`). Aborts +/// after 100 frame pump passes to catch runaway redraw loops. +pub fn TestAppContext::run_until_parked(self : TestAppContext) -> Unit { + let max_passes = 100 + let mut passes = 0 + while true { + self.platform.test_dispatcher().run_until_parked() + if self.skip_drawing { + break + } + let pumped = self.platform.pump_scheduled_frames() + if pumped == 0 { + break + } + passes = passes + 1 + if passes >= max_passes { + abort( + "TestAppContext::run_until_parked: runaway redraw loop (> \{max_passes} frame pumps)", + ) + } + } +} + +///| +/// Advances the virtual clock by `ms`, running timers, tasks and scheduled +/// frames (GPUI: `TestAppContext::advance_clock`). +pub fn TestAppContext::advance_clock(self : TestAppContext, ms : Int32) -> Unit { + self.run_until_parked() + self.platform.test_dispatcher().advance_clock(ms) + self.run_until_parked() +} + +///| +pub fn[R] TestAppContext::update( + self : TestAppContext, + f : (@app.App) -> R, +) -> R { + let result = self.application.app().update(f) + self.run_until_parked() + result +} + +///| +pub fn[R] TestAppContext::read(self : TestAppContext, f : (@app.App) -> R) -> R { + f(self.application.app()) +} + +///| +pub fn[T] TestAppContext::new_entity( + self : TestAppContext, + build : (@app.Context[T]) -> T, +) -> @app.Entity[T] { + self.update(fn(app) { app.new_entity(build) }) +} + +///| +pub fn[T, R] TestAppContext::update_entity( + self : TestAppContext, + entity : @app.Entity[T], + f : (T, @app.Context[T]) -> R, +) -> R { + self.update(fn(app) { app.update_entity(entity, f) }) +} + +///| +pub fn[T] TestAppContext::read_entity( + self : TestAppContext, + entity : @app.Entity[T], +) -> T { + self.application.app().read_entity(entity) +} + +///| +pub fn[R] TestAppContext::spawn( + self : TestAppContext, + f : async (@app.AsyncApp) -> R, +) -> @executor.Task[R] { + self.application.app().spawn(f) +} + +///| +pub fn[G] TestAppContext::set_global( + self : TestAppContext, + key : @app.GlobalKey[G], + value : G, +) -> Unit { + self.update(fn(app) { app.set_global(key, value) }) +} + +///| +pub fn[G] TestAppContext::read_global( + self : TestAppContext, + key : @app.GlobalKey[G], +) -> G { + self.application.app().global(key) +} + +///| +pub fn[G] TestAppContext::has_global( + self : TestAppContext, + key : @app.GlobalKey[G], +) -> Bool { + self.application.app().has_global(key) +} + +///| +pub fn[G, R] TestAppContext::update_global( + self : TestAppContext, + key : @app.GlobalKey[G], + f : (G, @app.App) -> R, +) -> R { + self.update(fn(app) { app.update_global(key, f) }) +} + +///| +pub fn TestAppContext::write_to_clipboard( + self : TestAppContext, + item : @platform.ClipboardItem, +) -> Unit { + self.application.write_to_clipboard(item) +} + +///| +pub fn TestAppContext::read_from_clipboard( + self : TestAppContext, +) -> @platform.ClipboardItem? { + self.application.read_from_clipboard() +} + +///| +pub fn TestAppContext::cursor_style( + self : TestAppContext, +) -> @style.CursorStyle { + self.platform.cursor_style() +} + +///| +pub fn TestAppContext::opened_url(self : TestAppContext) -> String? { + self.platform.opened_url() +} + +///| +pub fn TestAppContext::refresh(self : TestAppContext) -> Unit { + self.application.refresh_windows() + self.run_until_parked() +} + +///| +pub fn TestAppContext::quit(self : TestAppContext) -> Unit { + self.application.quit() +} + +///| +pub fn[V : @window.Render] TestAppContext::open_window( + self : TestAppContext, + options? : @platform.WindowOptions, + build_root : (@window.Window, @app.App) -> @app.Entity[V], +) -> @window.WindowHandle[V] { + let opts = options.unwrap_or(Default::default()) + let handle = self.application.open_window(opts, build_root) + self.run_until_parked() + handle +} + +///| +pub fn[V : @window.Render] TestAppContext::add_window( + self : TestAppContext, + size? : @geometry.Size[@geometry.Pixels], + scale_factor? : Double, + title? : String, + build_view : (@window.Window, @app.Context[V]) -> V, +) -> @window.WindowHandle[V] { + let options : @platform.WindowOptions = match size { + Some(s) => @platform.WindowOptions::with_size(s, scale_factor?, title?) + None => { ..Default::default(), scale_factor, title, } + } + self.open_window(options~, fn(window, app) { + app.new_entity(fn(cx) { build_view(window, cx) }) + }) +} + +///| +pub fn[V : @window.Render] TestAppContext::add_window_view( + self : TestAppContext, + size? : @geometry.Size[@geometry.Pixels], + scale_factor? : Double, + title? : String, + build_view : (@window.Window, @app.Context[V]) -> V, +) -> (@app.Entity[V], VisualTestContext) { + let handle = self.add_window(size?, scale_factor?, title?, build_view) + let vcx = VisualTestContext::from_window(handle.to_any(), self) + (handle.entity(), vcx) +} + +///| +pub fn TestAppContext::add_empty_window( + self : TestAppContext, + size? : @geometry.Size[@geometry.Pixels], + scale_factor? : Double, +) -> VisualTestContext { + let (_, vcx) = self.add_window_view(size?, scale_factor?, fn(_, _) { + EmptyView::EmptyView + }) + vcx +} + +// --------------------------------------------------------------------------- +// VisualTestContext +// --------------------------------------------------------------------------- + +///| +/// Window-scoped test driver combining a `TestAppContext` with one +/// `AnyWindowHandle` (GPUI: `VisualTestContext`). +pub struct VisualTestContext { + cx : TestAppContext + window_handle : @window.AnyWindowHandle +} + +///| +pub fn VisualTestContext::from_window( + window_handle : @window.AnyWindowHandle, + cx : TestAppContext, +) -> VisualTestContext { + { cx, window_handle, } +} + +///| +pub fn VisualTestContext::window_handle( + self : VisualTestContext, +) -> @window.AnyWindowHandle { + self.window_handle +} + +///| +pub fn VisualTestContext::window_id( + self : VisualTestContext, +) -> @platform.WindowId { + self.window_handle.window_id() +} + +///| +pub fn VisualTestContext::app(self : VisualTestContext) -> @app.App { + self.cx.app() +} + +///| +pub fn VisualTestContext::test_window(self : VisualTestContext) -> TestWindow { + self.cx.test_window(self.window_handle) +} + +///| +pub fn VisualTestContext::window(self : VisualTestContext) -> @window.Window { + match self.cx.application.window(self.window_id()) { + Some(win) => win + None => abort("window \{self.window_id()} is closed") + } +} + +///| +pub fn VisualTestContext::is_closed(self : VisualTestContext) -> Bool { + self.test_window().is_closed() +} + +///| +pub fn VisualTestContext::window_title(self : VisualTestContext) -> String? { + self.test_window().title() +} + +///| +pub fn VisualTestContext::is_active(self : VisualTestContext) -> Bool { + @platform.PlatformWindow::is_active(self.test_window()) +} + +///| +pub fn VisualTestContext::is_hovered(self : VisualTestContext) -> Bool { + @platform.PlatformWindow::is_hovered(self.test_window()) +} + +///| +pub fn VisualTestContext::bounds( + self : VisualTestContext, +) -> @geometry.Bounds[@geometry.Pixels] { + @platform.PlatformWindow::bounds(self.test_window()) +} + +///| +pub fn VisualTestContext::scale_factor(self : VisualTestContext) -> Double { + @platform.PlatformWindow::scale_factor(self.test_window()) +} + +///| +pub fn VisualTestContext::cursor_style( + self : VisualTestContext, +) -> @style.CursorStyle { + self.cx.cursor_style() +} + +///| +pub fn VisualTestContext::write_to_clipboard( + self : VisualTestContext, + item : @platform.ClipboardItem, +) -> Unit { + self.cx.write_to_clipboard(item) +} + +///| +pub fn VisualTestContext::read_from_clipboard( + self : VisualTestContext, +) -> @platform.ClipboardItem? { + self.cx.read_from_clipboard() +} + +///| +pub fn VisualTestContext::run_until_parked(self : VisualTestContext) -> Unit { + self.cx.run_until_parked() +} + +///| +pub fn VisualTestContext::advance_clock( + self : VisualTestContext, + ms : Int32, +) -> Unit { + self.cx.advance_clock(ms) +} + +///| +pub fn[R] VisualTestContext::update( + self : VisualTestContext, + f : (@window.Window, @app.App) -> R, +) -> R { + let window = self.window() + let result = self.app().update(fn(app) { f(window, app) }) + self.cx.run_until_parked() + result +} + +///| +pub fn[R] VisualTestContext::read( + self : VisualTestContext, + f : (@app.App) -> R, +) -> R { + self.cx.read(f) +} + +///| +pub fn[T, R] VisualTestContext::update_entity( + self : VisualTestContext, + entity : @app.Entity[T], + f : (T, @app.Context[T]) -> R, +) -> R { + self.cx.update_entity(entity, f) +} + +///| +pub fn[T] VisualTestContext::new_entity( + self : VisualTestContext, + build : (@app.Context[T]) -> T, +) -> @app.Entity[T] { + self.cx.new_entity(build) +} + +///| +pub fn[V : @window.Render] VisualTestContext::replace_root_view( + self : VisualTestContext, + build : (@window.Window, @app.Context[V]) -> V, +) -> @app.Entity[V] { + self.update(fn(window, _) { window.replace_root_view(build) }) +} + +///| +pub fn VisualTestContext::draw(self : VisualTestContext) -> @scene.Scene { + let scene = self.window().draw() + self.cx.run_until_parked() + scene +} + +///| +pub fn VisualTestContext::scene(self : VisualTestContext) -> @scene.Scene { + match self.test_window().last_scene() { + Some(scene) => scene + None => self.window().scene() + } +} + +///| +pub fn VisualTestContext::drawn_scenes( + self : VisualTestContext, +) -> Array[@scene.Scene] { + self.test_window().drawn_scenes() +} + +///| +pub fn VisualTestContext::draw_count(self : VisualTestContext) -> Int32 { + self.test_window().draw_count() +} + +///| +pub fn VisualTestContext::simulate_input( + self : VisualTestContext, + event : @input.PlatformInput, +) -> @input.DispatchEventResult { + let result = self.test_window().simulate_input(event) + self.cx.run_until_parked() + result +} + +///| +pub fn VisualTestContext::simulate_mouse_move( + self : VisualTestContext, + position : @geometry.Point[@geometry.Pixels], + button? : @input.MouseButton, + modifiers~ : @input.Modifiers = Default::default(), +) -> @input.DispatchEventResult { + self.simulate_input( + MouseMove({ position, pressed_button: button, modifiers, }), + ) +} + +///| +pub fn VisualTestContext::simulate_mouse_down( + self : VisualTestContext, + position : @geometry.Point[@geometry.Pixels], + button~ : @input.MouseButton = Left, + modifiers~ : @input.Modifiers = Default::default(), + click_count~ : Int32 = 1, +) -> @input.DispatchEventResult { + self.simulate_input( + MouseDown({ position, button, modifiers, click_count, first_mouse: false, }), + ) +} + +///| +pub fn VisualTestContext::simulate_mouse_up( + self : VisualTestContext, + position : @geometry.Point[@geometry.Pixels], + button~ : @input.MouseButton = Left, + modifiers~ : @input.Modifiers = Default::default(), + click_count~ : Int32 = 1, +) -> @input.DispatchEventResult { + self.simulate_input(MouseUp({ position, button, modifiers, click_count, })) +} + +///| +pub fn VisualTestContext::simulate_click( + self : VisualTestContext, + position : @geometry.Point[@geometry.Pixels], + button~ : @input.MouseButton = Left, + modifiers~ : @input.Modifiers = Default::default(), +) -> Unit { + ignore(self.simulate_mouse_down(position, button~, modifiers~)) + ignore(self.simulate_mouse_up(position, button~, modifiers~)) +} + +///| +pub fn VisualTestContext::simulate_scroll_wheel( + self : VisualTestContext, + position : @geometry.Point[@geometry.Pixels], + delta : @input.ScrollDelta, + modifiers~ : @input.Modifiers = Default::default(), +) -> @input.DispatchEventResult { + self.simulate_input(ScrollWheel({ position, delta, modifiers, })) +} + +///| +pub fn VisualTestContext::simulate_mouse_exit( + self : VisualTestContext, + position~ : @geometry.Point[@geometry.Pixels] = @geometry.point( + @geometry.px(0.0), + @geometry.px(0.0), + ), + modifiers~ : @input.Modifiers = Default::default(), +) -> @input.DispatchEventResult { + self.simulate_input( + MouseExited({ position, pressed_button: None, modifiers, }), + ) +} + +///| +pub fn VisualTestContext::simulate_modifiers_change( + self : VisualTestContext, + modifiers : @input.Modifiers, +) -> @input.DispatchEventResult { + self.simulate_input(ModifiersChanged({ modifiers, })) +} + +///| +pub fn VisualTestContext::simulate_resize( + self : VisualTestContext, + size : @geometry.Size[@geometry.Pixels], +) -> Unit { + self.test_window().simulate_resize(size) + self.cx.run_until_parked() +} + +///| +pub fn VisualTestContext::simulate_scale_factor_change( + self : VisualTestContext, + scale_factor : Double, +) -> Unit { + self.test_window().simulate_scale_factor_change(scale_factor) + self.cx.run_until_parked() +} + +///| +pub fn VisualTestContext::simulate_active_status_change( + self : VisualTestContext, + active : Bool, +) -> Unit { + self.test_window().simulate_active_status_change(active) + self.cx.run_until_parked() +} + +///| +pub fn VisualTestContext::simulate_hover_status_change( + self : VisualTestContext, + hovered : Bool, +) -> Unit { + self.test_window().simulate_hover_status_change(hovered) + self.cx.run_until_parked() +} + +///| +pub fn VisualTestContext::simulate_close(self : VisualTestContext) -> Bool { + let closed = self.test_window().simulate_close_requested() + self.cx.run_until_parked() + closed +} diff --git a/src/platform/test/test_platform_test.mbt b/src/platform/test/test_platform_test.mbt new file mode 100644 index 0000000..a62f2e1 --- /dev/null +++ b/src/platform/test/test_platform_test.mbt @@ -0,0 +1,498 @@ +///| +fn px(v : Double) -> @geometry.Pixels { + @geometry.px(v) +} + +///| +fn pt(x : Double, y : Double) -> @geometry.Point[@geometry.Pixels] { + @geometry.point(px(x), px(y)) +} + +///| +fn sz(w : Double, h : Double) -> @geometry.Size[@geometry.Pixels] { + @geometry.size(px(w), px(h)) +} + +///| +fn sp(v : Double) -> @geometry.ScaledPixels { + @geometry.ScaledPixels(v) +} + +///| +/// A minimal element that paints a solid quad across its layout bounds and +/// optionally handles mouse events and hover. +priv struct BoxElement { + color : @color.Rgba + hover_color : @color.Rgba? + on_down : ((@input.MouseDownEvent, @window.Window, @app.App) -> Unit)? + on_scroll : ((@input.ScrollWheelEvent, @window.Window, @app.App) -> Unit)? + mut hitbox : @window.Hitbox? +} + +///| +fn box_el( + color : @color.Rgba, + hover_color? : @color.Rgba, + on_down? : (@input.MouseDownEvent, @window.Window, @app.App) -> Unit, + on_scroll? : (@input.ScrollWheelEvent, @window.Window, @app.App) -> Unit, +) -> @window.AnyElement { + @window.AnyElement::new({ + color, + hover_color, + on_down, + on_scroll, + hitbox: None, + }) +} + +///| +impl @window.Element for BoxElement with fn request_layout(_self, window, _app) { + window.request_layout(Default::default(), []) +} + +///| +impl @window.Element for BoxElement with fn prepaint(self, bounds, window, _app) { + if self.hover_color is Some(_) || + self.on_down is Some(_) || + self.on_scroll is Some(_) { + self.hitbox = Some(window.insert_hitbox(bounds, Normal)) + } +} + +///| +impl @window.Element for BoxElement with fn paint(self, bounds, window, _app) { + let hovered = match self.hitbox { + Some(hitbox) => hitbox.is_hovered(window) + None => false + } + let bg = match (self.hover_color, hovered) { + (Some(hc), true) => hc + _ => self.color + } + if self.hitbox is Some(hitbox) { + if self.on_down is Some(cb) { + window.on_mouse_event(fn(event, phase, win, app) { + if phase == Bubble && event is MouseDown(down) && hitbox.is_hovered(win) { + cb(down, win, app) + } + }) + } + if self.on_scroll is Some(cb) { + window.on_mouse_event(fn(event, phase, win, app) { + if phase == Bubble && + event is ScrollWheel(scroll) && + hitbox.is_hovered(win) { + cb(scroll, win, app) + } + }) + } + } + window.paint_quad(@window.fill(bounds, bg.to_background())) +} + +///| +struct TestView { + mut count : Int32 + hover_bg : @color.Rgba? + prevent : Bool + stop : Bool + log : Array[String] +} + +///| +impl @window.Render for TestView with fn render(self, _window, cx) { + box_el( + @color.rgb(0x112233), + hover_color?=self.hover_bg, + on_down=@window.listener(cx, fn(view, down, window, cx) { + view.count = view.count + 1 + let btn = if down.button == Left { "Left" } else { "Other" } + view.log.push("down:\{btn}:\{down.modifiers.shift}") + if view.prevent { + window.prevent_default() + } + if view.stop { + window.stop_propagation() + } + cx.notify() + }), + on_scroll=@window.listener(cx, fn(view, scroll, _window, _cx) { + view.log.push("scroll:\{scroll.position.x.to_double()}") + }), + ) +} + +///| +enum PlainView { + PlainView +} + +///| +impl @window.Render for PlainView with fn render(_self, _window, _cx) { + box_el(@color.rgb(0xabcdef)) +} + +///| +enum RunawayView { + RunawayView +} + +///| +impl @window.Render for RunawayView with fn render(_self, window, _cx) { + window.refresh() + box_el(@color.rgb(0x000000)) +} + +///| +test "Application run, quit, and TestPlatform flags" { + let platform = @test.TestPlatform::new() + let app = @window.Application::with_platform(platform) + assert_false(platform.did_run()) + assert_false(platform.did_quit()) + let launched = Ref(false) + let found_app = Ref(false) + app.run(fn(a) { + launched.val = true + found_app.val = @window.application_for(a.app()) is Some(_) + a.quit() + }) + assert_true(launched.val) + assert_true(found_app.val) + assert_true(platform.did_run()) + assert_true(platform.did_quit()) +} + +///| +test "explicit frame scheduling on TestPlatform and TestWindow" { + let platform = @test.TestPlatform::new() + let app = @window.Application::with_platform(platform) + let view : Ref[@app.Entity[TestView]?] = Ref(None) + let unrelated : Ref[@app.Entity[PlainView]?] = Ref(None) + let handle = app.open_window( + @platform.WindowOptions::with_size(sz(300.0, 200.0), title="Manual"), + fn(_window, cx_app) { + unrelated.val = Some(cx_app.new_entity(fn(_) { PlainView })) + let v : @app.Entity[TestView] = cx_app.new_entity(fn(_) { + { count: 0, hover_bg: None, prevent: false, stop: false, log: [], } + }) + view.val = Some(v) + v + }, + ) + let tw = platform.window(handle.window_id()).unwrap() + assert_true(tw.frame_scheduled()) + assert_eq(tw.draw_count(), 0) + assert_true(tw.simulate_scheduled_frame()) + assert_false(tw.frame_scheduled()) + assert_eq(tw.draw_count(), 1) + assert_false(tw.simulate_scheduled_frame()) + + // Unrelated entity notification must not schedule a frame. + unrelated.val.unwrap().update(app.app(), fn(_, cx) { cx.notify() }) + assert_false(tw.frame_scheduled()) + + // Notifying rendered view re-schedules a frame. + view.val + .unwrap() + .update(app.app(), fn(v, cx) { + v.count = 1 + cx.notify() + }) + assert_true(tw.frame_scheduled()) + assert_true(tw.simulate_scheduled_frame()) + assert_eq(tw.draw_count(), 2) +} + +///| +test "resize, scale factor, and programmatic Window::resize avoid recursion" { + let cx = @test.TestAppContext::new() + let vcx = cx.add_empty_window(size=sz(200.0, 100.0)) + ignore(vcx.replace_root_view(fn(_, _) { PlainView })) + let before = vcx.draw_count() + vcx.simulate_resize(sz(320.0, 180.0)) + assert_eq(vcx.draw_count(), before + 1) + assert_eq(vcx.bounds().size, sz(320.0, 180.0)) + assert_eq( + vcx.scene().quads[0].bounds, + @geometry.bounds( + @geometry.point(sp(0.0), sp(0.0)), + @geometry.size(sp(320.0), sp(180.0)), + ), + ) + + vcx.simulate_scale_factor_change(2.0) + assert_eq(vcx.scale_factor(), 2.0) + assert_eq( + vcx.scene().quads[0].bounds, + @geometry.bounds( + @geometry.point(sp(0.0), sp(0.0)), + @geometry.size(sp(640.0), sp(360.0)), + ), + ) + + // Programmatic resize updates platform window bounds and schedules redraw without loop. + vcx.update(fn(win, _) { win.resize(sz(400.0, 200.0)) }) + assert_eq(vcx.bounds().size, sz(400.0, 200.0)) + assert_eq(vcx.scale_factor(), 2.0) + assert_eq( + vcx.scene().quads[0].bounds, + @geometry.bounds( + @geometry.point(sp(0.0), sp(0.0)), + @geometry.size(sp(800.0), sp(400.0)), + ), + ) + vcx.update(fn(win, _) { win.resize(sz(400.0, 200.0), scale_factor=1.5) }) + assert_eq(vcx.window().scale_factor(), 1.5) + assert_eq( + vcx.scene().quads[0].bounds, + @geometry.bounds( + @geometry.point(sp(0.0), sp(0.0)), + @geometry.size(sp(600.0), sp(300.0)), + ), + ) +} + +///| +test "title, cursor style, clipboard, and open_url" { + let cx = @test.TestAppContext::new() + let (_, vcx) = cx.add_window_view(size=sz(100.0, 100.0), title="Initial", fn( + _, + _, + ) { + PlainView + }) + assert_eq(vcx.window_title(), Some("Initial")) + vcx.update(fn(win, _) { + win.set_window_title("Updated") + win.set_cursor_style(PointingHand) + win.write_to_clipboard( + @platform.ClipboardItem::new_string_with_metadata("abc", "text"), + ) + }) + assert_eq(vcx.window_title(), Some("Updated")) + assert_eq(vcx.cursor_style(), @style.CursorStyle::PointingHand) + assert_eq(vcx.read_from_clipboard().unwrap().text(), Some("abc")) + assert_eq(cx.read_from_clipboard().unwrap().metadata(), Some("text")) + + cx.application().open_url("https://example.com") + assert_eq(cx.opened_url(), Some("https://example.com")) +} + +///| +test "multi-window activation and focus transfer" { + let cx = @test.TestAppContext::new() + let log : Array[String] = [] + let (_, vcx1) = cx.add_window_view(size=sz(100.0, 100.0), fn(win, _) { + win.on_window_active_change(fn(w, _) { + log.push("w1:\{w.is_window_active()}") + }) + PlainView + }) + assert_true(vcx1.is_active()) + assert_eq(cx.active_window(), Some(vcx1.window_handle())) + + let (_, vcx2) = cx.add_window_view(size=sz(100.0, 100.0), fn(win, _) { + win.on_window_active_change(fn(w, _) { + log.push("w2:\{w.is_window_active()}") + }) + PlainView + }) + assert_false(vcx1.is_active()) + assert_true(vcx2.is_active()) + assert_eq(cx.active_window(), Some(vcx2.window_handle())) + assert_eq(log, ["w1:false"]) + + vcx1.update(fn(win, _) { win.activate_window() }) + assert_true(vcx1.is_active()) + assert_false(vcx2.is_active()) + assert_eq(cx.active_window(), Some(vcx1.window_handle())) + assert_eq(log, ["w1:false", "w2:false", "w1:true"]) +} + +///| +test "MouseExited, hover status change, ModifiersChanged, and DispatchEventResult" { + let cx = @test.TestAppContext::new() + let (view, vcx) = cx.add_window_view(size=sz(100.0, 100.0), fn(_, _) { + { + count: 0, + hover_bg: Some(@color.rgb(0x00ff00)), + prevent: true, + stop: true, + log: [], + } + }) + assert_eq( + vcx.scene().quads[0].background, + @color.rgb(0x112233).to_background(), + ) + + ignore(vcx.simulate_mouse_move(pt(50.0, 50.0))) + assert_eq( + vcx.scene().quads[0].background, + @color.rgb(0x00ff00).to_background(), + ) + + // MouseExited clears hovered hitboxes and marks window dirty -> redraws unhovered. + ignore(vcx.simulate_mouse_exit(position=pt(200.0, 200.0))) + assert_eq( + vcx.scene().quads[0].background, + @color.rgb(0x112233).to_background(), + ) + + // Re-hover then lose window hover via platform hover status change. + ignore(vcx.simulate_mouse_move(pt(50.0, 50.0))) + assert_eq( + vcx.scene().quads[0].background, + @color.rgb(0x00ff00).to_background(), + ) + vcx.simulate_hover_status_change(false) + assert_false(vcx.is_hovered()) + assert_eq( + vcx.scene().quads[0].background, + @color.rgb(0x112233).to_background(), + ) + + // ModifiersChanged updates window modifiers and dirties/redraws on change. + let draws_before_mod = vcx.draw_count() + let shift_mods : @input.Modifiers = { ..Default::default(), shift: true, } + ignore(vcx.simulate_modifiers_change(shift_mods)) + assert_eq(vcx.window().modifiers(), shift_mods) + assert_eq(vcx.draw_count(), draws_before_mod + 1) + + // stop_propagation + prevent_default reflected in DispatchEventResult. + let result = vcx.simulate_mouse_down(pt(50.0, 50.0), modifiers=shift_mods) + assert_false(result.propagate) + assert_true(result.default_prevented) + assert_eq(cx.read_entity(view).log, ["down:Left:true"]) + + // ScrollWheel delivery. + ignore( + vcx.simulate_scroll_wheel( + pt(25.0, 25.0), + @input.ScrollDelta::Pixels(pt(0.0, -10.0)), + ), + ) + assert_eq(cx.read_entity(view).log, ["down:Left:true", "scroll:25"]) +} + +///| +test "window close veto, on_close, root release, and idempotence" { + let cx = @test.TestAppContext::new() + let can_close = Ref(false) + let events : Array[String] = [] + let handle = cx.add_window(size=sz(100.0, 100.0), fn(win, ctx) { + ctx.on_release(fn(_, _) { events.push("released") }).detach() + win.on_should_close(fn(_, _) { can_close.val }) + win.on_close(fn(_) { events.push("on_close") }) + PlainView + }) + let vcx = @test.VisualTestContext::from_window(handle.to_any(), cx) + assert_eq(cx.windows().length(), 1) + + // Vetoed close leaves window open and view alive. + assert_false(vcx.simulate_close()) + assert_false(vcx.is_closed()) + assert_false(handle.entity().is_released()) + assert_eq(events, []) + + // Allowed close runs on_close, releases root view, removes window from Application. + can_close.val = true + assert_true(vcx.simulate_close()) + assert_true(vcx.is_closed()) + assert_eq(cx.windows().length(), 0) + assert_true(handle.entity().is_released()) + assert_eq(events, ["on_close", "released"]) + assert_eq(handle.update(cx.application(), fn(_, _, _) { 1 }), None) + + // Idempotent repeat close calls do nothing extra. + vcx.test_window().simulate_close() + assert_eq(events, ["on_close", "released"]) +} + +///| +test "async task and virtual clock drive automatic redraws" { + let cx = @test.TestAppContext::new() + let (view, vcx) = cx.add_window_view(size=sz(120.0, 80.0), fn(_, ctx) { + let weak : @app.WeakEntity[TestView] = ctx.weak_entity() + ctx + .spawn(async fn(_, async_app) { + async_app.background_executor().sleep(50) + ignore( + weak.update(async_app.app, fn(v : TestView, cx) { + v.count = v.count + 10 + cx.notify() + }), + ) + }) + .detach() + { count: 1, hover_bg: None, prevent: false, stop: false, log: [], } + }) + assert_eq(vcx.draw_count(), 1) + assert_eq(cx.read_entity(view).count, 1) + + cx.advance_clock(50) + assert_eq(cx.read_entity(view).count, 11) + assert_eq(vcx.draw_count(), 2) +} + +///| +test "replace_root_view and skip_drawing" { + let cx = @test.TestAppContext::new() + let released = Ref(false) + let (first, vcx) = cx.add_window_view(size=sz(100.0, 100.0), fn(_, ctx) { + ctx.on_release(fn(_, _) { released.val = true }).detach() + PlainView + }) + assert_false(released.val) + let second = vcx.replace_root_view(fn(_, _) { + { count: 42, hover_bg: None, prevent: false, stop: false, log: [], } + }) + assert_true(first.is_released()) + assert_true(released.val) + assert_eq(cx.read_entity(second).count, 42) + assert_eq( + vcx.scene().quads[0].background, + @color.rgb(0x112233).to_background(), + ) + + // skip_drawing prevents automatic frame pumping until re-enabled. + cx.skip_drawing() + let count_before = vcx.draw_count() + cx.update_entity(second, fn(v, ctx) { + v.count = 43 + ctx.notify() + }) + assert_eq(vcx.draw_count(), count_before) + assert_true(vcx.test_window().frame_scheduled()) + cx.skip_drawing(skip=false) + cx.run_until_parked() + assert_eq(vcx.draw_count(), count_before + 1) +} + +///| +test "panic on drawing a closed window" { + let cx = @test.TestAppContext::new() + let vcx = cx.add_empty_window(size=sz(50.0, 50.0)) + let win = vcx.window() + win.close() + ignore(win.draw()) +} + +///| +test "panic on dispatching input on a closed window" { + let cx = @test.TestAppContext::new() + let vcx = cx.add_empty_window(size=sz(50.0, 50.0)) + let win = vcx.window() + win.close() + ignore( + win.dispatch_input( + MouseMove({ ..Default::default(), position: pt(5.0, 5.0), }), + ), + ) +} + +///| +test "panic on runaway redraw loop" { + let cx = @test.TestAppContext::new() + ignore(cx.add_window(size=sz(50.0, 50.0), fn(_, _) { RunawayView })) +} diff --git a/src/platform/test/window.mbt b/src/platform/test/window.mbt new file mode 100644 index 0000000..fda5592 --- /dev/null +++ b/src/platform/test/window.mbt @@ -0,0 +1,429 @@ +// Headless test window, ported from gpui/src/platform/test/window.rs. + +///| +/// A headless `PlatformWindow` for tests: records presented `Scene`s and +/// provides simulation hooks for frames, input, resizing, focus and closing +/// (GPUI: `TestWindow`). +pub struct TestWindow { + priv id : @platform.WindowId + priv platform : TestPlatform + priv mut bounds : @geometry.Bounds[@geometry.Pixels] + priv mut scale_factor : Double + priv mut title : String? + priv mut active : Bool + priv mut hovered : Bool + priv mut mouse_position : @geometry.Point[@geometry.Pixels] + priv mut modifiers : @input.Modifiers + priv mut closed : Bool + priv mut frame_scheduled : Bool + priv mut frame_schedule_count : Int32 + priv drawn_scenes : Array[@scene.Scene] + priv mut request_frame_callback : (() -> Unit)? + priv mut input_callback : ((@input.PlatformInput) -> @input.DispatchEventResult)? + priv mut resize_callback : ((@geometry.Size[@geometry.Pixels], Double) -> Unit)? + priv mut active_status_change_callback : ((Bool) -> Unit)? + priv mut hover_status_change_callback : ((Bool) -> Unit)? + priv mut should_close_callback : (() -> Bool)? + priv mut close_callback : (() -> Unit)? +} + +///| +fn TestWindow::new( + id : @platform.WindowId, + platform : TestPlatform, + params : @platform.WindowParams, + default_scale_factor : Double, +) -> TestWindow { + { + id, + platform, + bounds: params.bounds, + scale_factor: params.scale_factor.unwrap_or(default_scale_factor), + title: params.title, + active: params.focus, + hovered: false, + mouse_position: @geometry.point(@geometry.px(0.0), @geometry.px(0.0)), + modifiers: Default::default(), + closed: false, + frame_scheduled: false, + frame_schedule_count: 0, + drawn_scenes: [], + request_frame_callback: None, + input_callback: None, + resize_callback: None, + active_status_change_callback: None, + hover_status_change_callback: None, + should_close_callback: None, + close_callback: None, + } +} + +///| +fn TestWindow::clear_callbacks(self : TestWindow) -> Unit { + self.request_frame_callback = None + self.input_callback = None + self.resize_callback = None + self.active_status_change_callback = None + self.hover_status_change_callback = None + self.should_close_callback = None + self.close_callback = None +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn bounds(self) { + self.bounds +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn content_size(self) { + self.bounds.size +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn scale_factor(self) { + self.scale_factor +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn mouse_position(self) { + self.mouse_position +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn modifiers(self) { + self.modifiers +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn is_active(self) { + self.active +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn is_hovered(self) { + self.hovered +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn set_title(self, title) { + self.title = Some(title) +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn activate(self) { + if !self.closed { + self.platform.set_active_window(Some(self)) + } +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn resize(self, size) { + self.bounds = { ..self.bounds, size, } +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn draw(self, scene) { + self.drawn_scenes.push(scene) +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn schedule_frame(self) { + if !self.closed { + self.frame_scheduled = true + self.frame_schedule_count = self.frame_schedule_count + 1 + } +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn close(self) { + if self.closed { + return + } + self.closed = true + self.frame_scheduled = false + self.clear_callbacks() + if self.platform.active_window is Some(active) && active.id == self.id { + self.platform.active_window = None + } +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn on_request_frame( + self, + callback, +) { + self.request_frame_callback = Some(callback) +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn on_input( + self, + callback, +) { + self.input_callback = Some(callback) +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn on_resize( + self, + callback, +) { + self.resize_callback = Some(callback) +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn on_active_status_change( + self, + callback, +) { + self.active_status_change_callback = Some(callback) +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn on_hover_status_change( + self, + callback, +) { + self.hover_status_change_callback = Some(callback) +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn on_should_close( + self, + callback, +) { + self.should_close_callback = Some(callback) +} + +///| +pub impl @platform.PlatformWindow for TestWindow with fn on_close( + self, + callback, +) { + self.close_callback = Some(callback) +} + +// --------------------------------------------------------------------------- +// Inspection helpers +// --------------------------------------------------------------------------- + +///| +pub fn TestWindow::window_id(self : TestWindow) -> @platform.WindowId { + self.id +} + +///| +pub fn TestWindow::title(self : TestWindow) -> String? { + self.title +} + +///| +pub fn TestWindow::is_closed(self : TestWindow) -> Bool { + self.closed +} + +///| +pub fn TestWindow::frame_scheduled(self : TestWindow) -> Bool { + self.frame_scheduled +} + +///| +pub fn TestWindow::frame_schedule_count(self : TestWindow) -> Int32 { + self.frame_schedule_count +} + +///| +pub fn TestWindow::drawn_scenes(self : TestWindow) -> Array[@scene.Scene] { + self.drawn_scenes +} + +///| +pub fn TestWindow::draw_count(self : TestWindow) -> Int32 { + self.drawn_scenes.length() +} + +///| +pub fn TestWindow::last_scene(self : TestWindow) -> @scene.Scene? { + self.drawn_scenes.last() +} + +///| +pub fn TestWindow::clear_drawn_scenes(self : TestWindow) -> Unit { + self.drawn_scenes.clear() +} + +// --------------------------------------------------------------------------- +// Simulation hooks +// --------------------------------------------------------------------------- + +///| +/// Delivers one frame if one was scheduled; returns whether a frame ran +/// (GPUI: `TestWindow::simulate_scheduled_frame`). +pub fn TestWindow::simulate_scheduled_frame(self : TestWindow) -> Bool { + if self.closed || !self.frame_scheduled { + return false + } + self.frame_scheduled = false + match self.request_frame_callback { + Some(callback) => { + callback() + true + } + None => { + self.frame_scheduled = true + false + } + } +} + +///| +/// Unconditionally invokes the registered frame callback, as a display-link +/// tick would (GPUI: `TestWindow::simulate_frame_request`). +pub fn TestWindow::simulate_frame_request(self : TestWindow) -> Unit { + if self.closed { + return + } + self.frame_scheduled = false + if self.request_frame_callback is Some(callback) { + callback() + } +} + +///| +/// Simulates a `PlatformInput` event arriving from the OS/browser +/// (GPUI: `TestWindow::simulate_input`). +pub fn TestWindow::simulate_input( + self : TestWindow, + event : @input.PlatformInput, +) -> @input.DispatchEventResult { + if self.closed { + return { propagate: true, default_prevented: false, } + } + self.modifiers = event.modifiers() + match event { + MouseDown(e) => self.mouse_position = e.position + MouseUp(e) => self.mouse_position = e.position + MouseMove(e) => self.mouse_position = e.position + ScrollWheel(e) => self.mouse_position = e.position + MouseExited(e) => self.mouse_position = e.position + ModifiersChanged(_) => () + } + match self.input_callback { + Some(callback) => callback(event) + None => { propagate: true, default_prevented: false, } + } +} + +///| +/// Simulates a user/OS resize of the window (GPUI: `TestWindow::simulate_resize`). +pub fn TestWindow::simulate_resize( + self : TestWindow, + size : @geometry.Size[@geometry.Pixels], +) -> Unit { + if self.closed { + return + } + self.bounds = { ..self.bounds, size, } + if self.resize_callback is Some(callback) { + callback(size, self.scale_factor) + } +} + +///| +/// Simulates a display scale-factor change +/// (GPUI: `TestWindow::simulate_scale_factor_change`). +pub fn TestWindow::simulate_scale_factor_change( + self : TestWindow, + scale_factor : Double, +) -> Unit { + if self.closed { + return + } + self.scale_factor = scale_factor + if self.resize_callback is Some(callback) { + callback(self.bounds.size, scale_factor) + } +} + +///| +/// Simulates a window focus/activation change +/// (GPUI: `TestWindow::simulate_active_status_change`). +pub fn TestWindow::simulate_active_status_change( + self : TestWindow, + active : Bool, +) -> Unit { + if self.closed { + return + } + self.active = active + if active { + self.platform.active_window = Some(self) + } else if self.platform.active_window is Some(curr) && curr.id == self.id { + self.platform.active_window = None + } + if self.active_status_change_callback is Some(callback) { + callback(active) + } +} + +///| +/// Simulates the pointer entering or leaving the window surface. +pub fn TestWindow::simulate_hover_status_change( + self : TestWindow, + hovered : Bool, +) -> Unit { + if self.closed { + return + } + self.hovered = hovered + if self.hover_status_change_callback is Some(callback) { + callback(hovered) + } +} + +///| +/// Queries whether a close should proceed. Returns `true` if no handler is +/// registered. +pub fn TestWindow::simulate_should_close(self : TestWindow) -> Bool { + if self.closed { + return true + } + match self.should_close_callback { + Some(callback) => callback() + None => true + } +} + +///| +/// Simulates the OS closing this window unconditionally and invoking the +/// registered `on_close` callback (GPUI: `TestWindow::simulate_close`). +pub fn TestWindow::simulate_close(self : TestWindow) -> Unit { + if self.closed { + return + } + let callback = self.close_callback + self.closed = true + self.frame_scheduled = false + self.clear_callbacks() + if self.platform.active_window is Some(curr) && curr.id == self.id { + self.platform.active_window = None + } + if callback is Some(callback) { + callback() + } +} + +///| +/// Simulates a user-initiated close request: asks `on_should_close`, closes +/// if allowed, and returns whether the window closed. +pub fn TestWindow::simulate_close_requested(self : TestWindow) -> Bool { + if self.closed { + return false + } + if self.simulate_should_close() { + self.simulate_close() + true + } else { + false + } +} diff --git a/src/platform/types.mbt b/src/platform/types.mbt new file mode 100644 index 0000000..8519c46 --- /dev/null +++ b/src/platform/types.mbt @@ -0,0 +1,175 @@ +// Core value types shared between GPUI windows and platform implementations, +// ported from gpui/src/platform.rs. + +///| +/// Identifies an open window within an application (GPUI: `WindowId`). +#derive(Eq, Compare, Hash, Debug) +pub(all) struct WindowId(Int32) + +///| +pub impl Show for WindowId with fn output(self, logger) { + logger.write_string("WindowId(\{self.0})") +} + +///| +/// Requested window state and bounds (GPUI: `WindowBounds`). +#derive(Eq, Debug) +pub(all) enum WindowBounds { + Windowed(@geometry.Bounds[@geometry.Pixels]) + Maximized(@geometry.Bounds[@geometry.Pixels]) + Fullscreen(@geometry.Bounds[@geometry.Pixels]) +} + +///| +pub impl Default for WindowBounds with fn default() { + Windowed(Default::default()) +} + +///| +/// Returns the logical bounds stored in this `WindowBounds`. +pub fn WindowBounds::get_bounds( + self : WindowBounds, +) -> @geometry.Bounds[@geometry.Pixels] { + match self { + Windowed(bounds) | Maximized(bounds) | Fullscreen(bounds) => bounds + } +} + +///| +/// Configuration passed when opening a window (GPUI: `WindowOptions`). +#derive(Eq, Debug) +pub(all) struct WindowOptions { + window_bounds : WindowBounds? + title : String? + focus : Bool + show : Bool + scale_factor : Double? + rem_size : @geometry.Pixels +} + +///| +pub impl Default for WindowOptions with fn default() { + { + window_bounds: None, + title: None, + focus: true, + show: true, + scale_factor: None, + rem_size: @geometry.px(16.0), + } +} + +///| +/// Convenience constructor for a windowed `WindowOptions` of `size` at the +/// origin. +pub fn WindowOptions::with_size( + size : @geometry.Size[@geometry.Pixels], + scale_factor? : Double, + title? : String, + rem_size~ : @geometry.Pixels = @geometry.px(16.0), +) -> WindowOptions { + { + ..Default::default(), + window_bounds: Some( + Windowed( + @geometry.bounds( + @geometry.point(@geometry.px(0.0), @geometry.px(0.0)), + size, + ), + ), + ), + title, + scale_factor, + rem_size, + } +} + +///| +/// Resolved parameters handed to `Platform::open_window` (GPUI: +/// `WindowParams`). +#derive(Eq, Debug) +pub(all) struct WindowParams { + bounds : @geometry.Bounds[@geometry.Pixels] + title : String? + focus : Bool + show : Bool + scale_factor : Double? +} + +///| +/// A plain-text clipboard entry with optional metadata (GPUI: +/// `ClipboardString`). +#derive(Eq, Debug) +pub(all) struct ClipboardString { + text : String + metadata : String? +} + +///| +pub fn ClipboardString::new(text : String) -> ClipboardString { + { text, metadata: None, } +} + +///| +pub fn ClipboardString::new_with_metadata( + text : String, + metadata : String, +) -> ClipboardString { + { text, metadata: Some(metadata), } +} + +///| +/// One item inside a `ClipboardItem` (GPUI: `ClipboardEntry`, text subset). +#derive(Eq, Debug) +pub(all) enum ClipboardEntry { + String(ClipboardString) +} + +///| +/// Data placed on or read from the system clipboard (GPUI: `ClipboardItem`). +#derive(Eq, Debug) +pub(all) struct ClipboardItem { + entries : Array[ClipboardEntry] +} + +///| +/// Creates a `ClipboardItem` containing one plain-text entry. +pub fn ClipboardItem::new_string(text : String) -> ClipboardItem { + { entries: [String(ClipboardString::new(text))], } +} + +///| +/// Creates a `ClipboardItem` containing one plain-text entry with metadata. +pub fn ClipboardItem::new_string_with_metadata( + text : String, + metadata : String, +) -> ClipboardItem { + { entries: [String(ClipboardString::new_with_metadata(text, metadata))], } +} + +///| +/// Joins all text entries with `\n`, or returns `None` if there are none. +pub fn ClipboardItem::text(self : ClipboardItem) -> String? { + let texts = [] + for entry in self.entries { + match entry { + String(s) => texts.push(s.text) + } + } + if texts.is_empty() { + None + } else { + Some(texts.join("\n")) + } +} + +///| +/// Returns the metadata of the first text entry, if any. +pub fn ClipboardItem::metadata(self : ClipboardItem) -> String? { + for entry in self.entries { + match entry { + String(s) => return s.metadata + } + } + None +} diff --git a/src/window/application.mbt b/src/window/application.mbt new file mode 100644 index 0000000..26a346d --- /dev/null +++ b/src/window/application.mbt @@ -0,0 +1,294 @@ +// Platform-backed Application lifecycle and window handles, ported from +// gpui/src/app.rs (`Application`, `open_window`, `windows`, `quit`) and +// gpui/src/window.rs (`AnyWindowHandle`, `WindowHandle`). + +///| +/// An untyped handle to an open window (GPUI: `AnyWindowHandle`). +#derive(Eq, Compare, Hash, Debug) +pub struct AnyWindowHandle { + id : @platform.WindowId +} + +///| +pub fn AnyWindowHandle::window_id(self : AnyWindowHandle) -> @platform.WindowId { + self.id +} + +///| +pub fn[R] AnyWindowHandle::update( + self : AnyWindowHandle, + application : Application, + f : (AnyView, Window, @app.App) -> R, +) -> R? { + application.update_window(self, f) +} + +///| +/// A typed handle to an open window whose root view has type `V` (GPUI: +/// `WindowHandle`). +pub struct WindowHandle[V] { + id : @platform.WindowId + priv root : @app.Entity[V] +} + +///| +pub fn[V] WindowHandle::window_id(self : WindowHandle[V]) -> @platform.WindowId { + self.id +} + +///| +pub fn[V] WindowHandle::to_any(self : WindowHandle[V]) -> AnyWindowHandle { + { id: self.id, } +} + +///| +pub fn[V] WindowHandle::entity(self : WindowHandle[V]) -> @app.Entity[V] { + self.root +} + +///| +/// Updates the root view inside its window, returning `None` if the window +/// was closed or the view was released. +pub fn[V, R] WindowHandle::update( + self : WindowHandle[V], + application : Application, + f : (V, Window, @app.Context[V]) -> R, +) -> R? { + match application.window(self.id) { + Some(window) => + if window.is_closed() || self.root.is_released() { + None + } else { + Some( + application.app.update_entity(self.root, fn(view, cx) { + f(view, window, cx) + }), + ) + } + None => None + } +} + +///| +/// Reads the root view if the window is still open and the view is alive. +pub fn[V, R] WindowHandle::read_with( + self : WindowHandle[V], + application : Application, + f : (V, @app.App) -> R, +) -> R? { + match application.window(self.id) { + Some(window) => + if window.is_closed() || self.root.is_released() { + None + } else { + Some(f(self.root.read(application.app), application.app)) + } + None => None + } +} + +///| +/// An application wired to a `Platform`, owning its `App` and open windows +/// (GPUI: `Application`). +pub struct Application { + app : @app.App + platform : &@platform.Platform + priv mut next_window_id : Int32 + priv windows : Map[@platform.WindowId, Window] +} + +///| +let application_key : @app.GlobalKey[Application] = @app.GlobalKey::new( + "Application", +) + +///| +/// Looks up the `Application` owning `app`, if it was created via +/// `Application::with_platform`. +pub fn application_for(app : @app.App) -> Application? { + app.try_global(application_key) +} + +///| +/// Creates an `Application` backed by `platform` and registers it on the app. +pub fn Application::with_platform( + platform : &@platform.Platform, +) -> Application { + let app = @app.App::new(dispatcher=platform.dispatcher()) + let application : Application = { + app, + platform, + next_window_id: 1, + windows: {}, + } + app.set_global(application_key, application) + application +} + +///| +pub fn Application::app(self : Application) -> @app.App { + self.app +} + +///| +pub fn Application::platform(self : Application) -> &@platform.Platform { + self.platform +} + +///| +/// Launches the platform event loop, calling `on_finish_launching` once +/// ready (GPUI: `Application::run`). +pub fn Application::run( + self : Application, + on_finish_launching : (Application) -> Unit, +) -> Unit { + self.platform.run(fn() { on_finish_launching(self) }) +} + +///| +/// Closes all open windows and asks the platform to exit (GPUI: `App::quit`). +pub fn Application::quit(self : Application) -> Unit { + let open = [] + for _, win in self.windows { + open.push(win) + } + for win in open { + win.close() + } + self.platform.quit() +} + +///| +/// Opens a platform-backed window with `options` and a root view created by +/// `build_root` (GPUI: `App::open_window`). +pub fn[V : Render] Application::open_window( + self : Application, + options : @platform.WindowOptions, + build_root : (Window, @app.App) -> @app.Entity[V], +) -> WindowHandle[V] { + let id = @platform.WindowId(self.next_window_id) + self.next_window_id = self.next_window_id + 1 + let bounds = match options.window_bounds { + Some(wb) => wb.get_bounds() + None => self.platform.default_window_bounds() + } + let pw = self.platform.open_window(id, { + bounds, + title: options.title, + focus: options.focus, + show: options.show, + scale_factor: options.scale_factor, + }) + let window = Window::from_platform( + id, + self.app, + self.platform, + pw, + rem_size=options.rem_size, + title?=options.title, + on_closed=fn() { self.windows.remove(id) }, + ) + self.windows[id] = window + let root = self.app.update(fn(app) { build_root(window, app) }) + window.set_root_view(root) + { id, root, } +} + +///| +pub fn Application::windows(self : Application) -> Array[AnyWindowHandle] { + let handles : Array[AnyWindowHandle] = [] + for id, _ in self.windows { + handles.push({ id, }) + } + handles +} + +///| +pub fn Application::window_count(self : Application) -> Int32 { + self.windows.length() +} + +///| +pub fn Application::window( + self : Application, + id : @platform.WindowId, +) -> Window? { + self.windows.get(id) +} + +///| +pub fn Application::active_window(self : Application) -> AnyWindowHandle? { + match self.platform.active_window() { + Some(id) => + match self.windows.get(id) { + Some(win) if !win.is_closed() => Some({ id, }) + _ => None + } + None => None + } +} + +///| +pub fn[R] Application::update_window( + self : Application, + handle : AnyWindowHandle, + f : (AnyView, Window, @app.App) -> R, +) -> R? { + match self.windows.get(handle.id) { + Some(window) => + if window.is_closed() { + None + } else { + match window.root_view() { + Some(root) => Some(self.app.update(fn(app) { f(root, window, app) })) + None => None + } + } + None => None + } +} + +///| +pub fn Application::refresh_windows(self : Application) -> Unit { + for _, win in self.windows { + win.refresh() + } +} + +///| +pub fn Application::close_window( + self : Application, + id : @platform.WindowId, +) -> Unit { + if self.windows.get(id) is Some(win) { + win.close() + } +} + +///| +pub fn Application::read_from_clipboard( + self : Application, +) -> @platform.ClipboardItem? { + self.platform.read_from_clipboard() +} + +///| +pub fn Application::write_to_clipboard( + self : Application, + item : @platform.ClipboardItem, +) -> Unit { + self.platform.write_to_clipboard(item) +} + +///| +pub fn Application::set_cursor_style( + self : Application, + style : @style.CursorStyle, +) -> Unit { + self.platform.set_cursor_style(style) +} + +///| +pub fn Application::open_url(self : Application, url : String) -> Unit { + self.platform.open_url(url) +} diff --git a/src/window/element.mbt b/src/window/element.mbt new file mode 100644 index 0000000..b3b92ae --- /dev/null +++ b/src/window/element.mbt @@ -0,0 +1,208 @@ +// Elements and views, ported from gpui/src/element.rs and gpui/src/view.rs. +// +// Deviations from GPUI (see docs/PORTING.md): +// - `Element` has no associated `RequestLayoutState`/`PrepaintState` types: +// an element keeps per-frame state in its own mutable fields, set in +// `request_layout` and read in `prepaint` and `paint`. Elements are built +// fresh every frame, as in GPUI. +// - `render` returns `AnyElement` (no `impl IntoElement` return types). +// - Global element ids are paths of strings. + +///| +/// A node of the element tree, laid out and painted each frame (GPUI: +/// `Element`). +pub(open) trait Element { + /// Requests a layout node (and those of the children). + fn request_layout(Self, Window, @app.App) -> @layout.LayoutId + /// Runs after layout with the element's bounds: hitboxes, child offsets. + fn prepaint(Self, @geometry.Bounds[@geometry.Pixels], Window, @app.App) -> Unit + /// Emits primitives into the scene and registers event listeners. + fn paint(Self, @geometry.Bounds[@geometry.Pixels], Window, @app.App) -> Unit +} + +///| +/// Anything that can become an element (GPUI: `IntoElement`). +pub(open) trait IntoElement { + fn into_any_element(Self) -> AnyElement +} + +///| +/// A type-erased element plus its per-frame layout state (GPUI: +/// `AnyElement`, with `Drawable`'s phase tracking). +pub struct AnyElement { + priv element : &Element + priv mut layout_id : @layout.LayoutId? + priv mut bounds : @geometry.Bounds[@geometry.Pixels]? +} + +///| +pub fn AnyElement::new(element : &Element) -> AnyElement { + { element, layout_id: None, bounds: None, } +} + +///| +pub impl IntoElement for AnyElement with fn into_any_element(self) { + self +} + +///| +/// Requests layout; must be called once per frame, before `prepaint`. +pub fn AnyElement::request_layout( + self : AnyElement, + window : Window, + app : @app.App, +) -> @layout.LayoutId { + guard self.layout_id is None else { + abort("element layout requested twice in one frame") + } + let id = self.element.request_layout(window, app) + self.layout_id = Some(id) + id +} + +///| +/// Resolves the element's bounds from layout (plus the window's element +/// offset) and prepaints it. +pub fn AnyElement::prepaint( + self : AnyElement, + window : Window, + app : @app.App, +) -> Unit { + guard self.layout_id is Some(layout_id) else { + abort("element prepainted before its layout was requested") + } + let bounds = window.layout_bounds(layout_id) + self.bounds = Some(bounds) + self.element.prepaint(bounds, window, app) +} + +///| +/// Paints the element at the bounds computed in `prepaint`. +pub fn AnyElement::paint( + self : AnyElement, + window : Window, + app : @app.App, +) -> Unit { + guard self.bounds is Some(bounds) else { + abort("element painted before it was prepainted") + } + self.element.paint(bounds, window, app) +} + +///| +/// The bounds from the last `prepaint`, if any. +pub fn AnyElement::bounds( + self : AnyElement, +) -> @geometry.Bounds[@geometry.Pixels]? { + self.bounds +} + +///| +/// A view's state renders itself into an element tree each frame (GPUI: +/// `Render`). +pub(open) trait Render { + fn render(Self, Window, @app.Context[Self]) -> AnyElement +} + +///| +/// A type-erased view: an entity whose state implements `Render` (GPUI: +/// `AnyView`). +pub struct AnyView { + entity_id : @app.EntityId + priv render_fn : (Window, @app.App) -> AnyElement + priv release_fn : (@app.App) -> Unit +} + +///| +pub fn[V : Render] AnyView::from_entity(entity : @app.Entity[V]) -> AnyView { + { + entity_id: entity.entity_id(), + render_fn: fn(window, app) { + app.update_entity(entity, fn(state, cx) { + Render::render(state, window, cx) + }) + }, + release_fn: fn(app) { app.release(entity) }, + } +} + +///| +/// The element a view renders into for one frame. +priv struct ViewElement { + view : AnyView + mut rendered : AnyElement? +} + +///| +impl Element for ViewElement with fn request_layout(self, window, app) { + window.record_rendered_view(self.view.entity_id) + let element = (self.view.render_fn)(window, app) + self.rendered = Some(element) + element.request_layout(window, app) +} + +///| +impl Element for ViewElement with fn prepaint(self, _bounds, window, app) { + self.rendered.unwrap().prepaint(window, app) +} + +///| +impl Element for ViewElement with fn paint(self, _bounds, window, app) { + self.rendered.unwrap().paint(window, app) +} + +///| +pub impl IntoElement for AnyView with fn into_any_element(self) { + AnyElement::new(({ view: self, rendered: None, } : ViewElement)) +} + +///| +pub extend AnyView with IntoElement::{into_any_element} + +///| +/// Views are elements: `div().child(entity)` renders the entity. +pub impl[V : Render] IntoElement for @app.Entity[V] with fn into_any_element( + self, +) { + AnyView::from_entity(self).into_any_element() +} + +///| +/// Wraps a view method as an event listener that updates the view (GPUI: +/// `cx.listener`). The listener does nothing once the view is released. +pub fn[T, E] listener( + cx : @app.Context[T], + f : (T, E, Window, @app.Context[T]) -> Unit, +) -> (E, Window, @app.App) -> Unit { + let weak = cx.weak_entity() + fn(event, window, app) { + ignore(weak.update(app, fn(state, cx) { f(state, event, window, cx) })) + } +} + +///| +/// An element that takes no space and paints nothing (GPUI: `Empty`). +priv enum Empty { + Empty +} + +///| +impl Element for Empty with fn request_layout(_self, window, _app) { + window.request_layout(Default::default(), []) +} + +///| +impl Element for Empty with fn prepaint(_self, _bounds, _window, _app) { + () +} + +///| +impl Element for Empty with fn paint(_self, _bounds, _window, _app) { + () +} + +///| +/// An empty element. +pub fn empty() -> AnyElement { + AnyElement::new(Empty::Empty) +} diff --git a/src/window/moon.pkg b/src/window/moon.pkg new file mode 100644 index 0000000..8ff52c9 --- /dev/null +++ b/src/window/moon.pkg @@ -0,0 +1,17 @@ +import { + "experiments/gpui/geometry", + "experiments/gpui/color", + "experiments/gpui/scene", + "experiments/gpui/style", + "experiments/gpui/layout", + "experiments/gpui/input", + "experiments/gpui/app", + "experiments/gpui/platform", + "moonbitlang/core/hashset", + "moonbitlang/core/cmp", + "moonbitlang/core/debug", +} + +options( + "allow-experimental-packages": true, +) diff --git a/src/window/paint.mbt b/src/window/paint.mbt new file mode 100644 index 0000000..ad4632d --- /dev/null +++ b/src/window/paint.mbt @@ -0,0 +1,301 @@ +// Painting, ported from gpui/src/window.rs (`paint_quad`, `paint_drop_shadows`, +// `paint_inset_shadows`, the snapping helpers) and `Style::paint` from +// gpui/src/style.rs. +// +// Deviation: GPUI splits bordered quads into a background quad and border +// strips (`insert_quad`) as a renderer optimization; here a quad is inserted +// as is. + +///| +/// A quad to paint, in logical pixels (GPUI: `PaintQuad`). +#derive(Eq, Debug) +pub(all) struct PaintQuad { + bounds : @geometry.Bounds[@geometry.Pixels] + corner_radii : @geometry.Corners[@geometry.Pixels] + background : @color.Background + border_widths : @geometry.Edges[@geometry.Pixels] + border_color : @color.Hsla + border_style : @scene.BorderStyle +} + +///| +/// A filled quad without border (GPUI: `fill`). +pub fn fill( + bounds : @geometry.Bounds[@geometry.Pixels], + background : @color.Background, +) -> PaintQuad { + { + bounds, + corner_radii: Default::default(), + background, + border_widths: Default::default(), + border_color: @color.transparent_black(), + border_style: Solid, + } +} + +///| +/// A 1px outline (GPUI: `outline`). +pub fn outline( + bounds : @geometry.Bounds[@geometry.Pixels], + border_color : @color.Hsla, + border_style~ : @scene.BorderStyle = Solid, +) -> PaintQuad { + { + bounds, + corner_radii: Default::default(), + background: @color.transparent_black().to_background(), + border_widths: @geometry.Edges::all(@geometry.px(1.0)), + border_color, + border_style, + } +} + +///| +fn round_half_toward_zero(value : Double) -> Double { + @layout.round_half_toward_zero(value) +} + +///| +/// Logical bounds to device pixels, edges rounded (GPUI: `snap_bounds`). +fn Window::snap_bounds( + self : Window, + bounds : @geometry.Bounds[@geometry.Pixels], +) -> @geometry.Bounds[@geometry.ScaledPixels] { + let s = self.scale_factor + let left = round_half_toward_zero(bounds.left().to_double() * s) + let top = round_half_toward_zero(bounds.top().to_double() * s) + let right = @cmp.maximum( + round_half_toward_zero(bounds.right().to_double() * s), + left, + ) + let bottom = @cmp.maximum( + round_half_toward_zero(bounds.bottom().to_double() * s), + top, + ) + @geometry.Bounds::from_corners( + @geometry.point(@geometry.ScaledPixels(left), @geometry.ScaledPixels(top)), + @geometry.point( + @geometry.ScaledPixels(right), + @geometry.ScaledPixels(bottom), + ), + ) +} + +///| +/// Logical bounds to the device pixels they touch (GPUI: `cover_bounds`). +fn Window::cover_bounds( + self : Window, + bounds : @geometry.Bounds[@geometry.Pixels], +) -> @geometry.Bounds[@geometry.ScaledPixels] { + let s = self.scale_factor + let left = (bounds.left().to_double() * s).floor() + let top = (bounds.top().to_double() * s).floor() + if bounds.is_empty() { + return { + origin: @geometry.point( + @geometry.ScaledPixels(left), + @geometry.ScaledPixels(top), + ), + size: Default::default(), + } + } + let right = @cmp.maximum((bounds.right().to_double() * s).ceil(), left) + let bottom = @cmp.maximum((bounds.bottom().to_double() * s).ceil(), top) + @geometry.Bounds::from_corners( + @geometry.point(@geometry.ScaledPixels(left), @geometry.ScaledPixels(top)), + @geometry.point( + @geometry.ScaledPixels(right), + @geometry.ScaledPixels(bottom), + ), + ) +} + +///| +fn Window::snapped_content_mask( + self : Window, +) -> @geometry.ContentMask[@geometry.ScaledPixels] { + { bounds: self.cover_bounds(self.content_mask().bounds), } +} + +///| +/// Paints a quad, snapped to device pixels and faded by the element opacity +/// (GPUI: `paint_quad`). Only during paint. +pub fn Window::paint_quad(self : Window, quad : PaintQuad) -> Unit { + self.assert_phase("paint_quad", [Paint]) + let opacity = self.element_opacity + let scene_quad : @scene.Quad = { + order: 0, + bounds: self.snap_bounds(quad.bounds), + content_mask: self.snapped_content_mask(), + background: quad.background.opacity(opacity), + border_color: quad.border_color.opacity(opacity), + corner_radii: quad.corner_radii.scale(self.scale_factor), + border_widths: quad.border_widths.map(fn(width) { + @geometry.ScaledPixels( + @layout.round_stroke_to_device_pixel( + width.to_double(), + self.scale_factor, + ), + ) + }), + border_style: quad.border_style, + } + let has_background = !scene_quad.background.is_transparent() + let has_border = scene_quad.border_widths != Default::default() && + !scene_quad.border_color.is_transparent() + if has_background || has_border { + self.next_scene.insert_primitive(Quad(scene_quad)) + } +} + +///| +/// Paints the outer (non-inset) box shadows of a rounded rectangle (GPUI: +/// `paint_drop_shadows`). +pub fn Window::paint_drop_shadows( + self : Window, + bounds : @geometry.Bounds[@geometry.Pixels], + corner_radii : @geometry.Corners[@geometry.Pixels], + shadows : Array[@style.BoxShadow], +) -> Unit { + self.assert_phase("paint_drop_shadows", [Paint]) + let content_mask = self.snapped_content_mask() + for shadow in shadows { + if shadow.inset { + continue + } + let shape_bounds = self.cover_bounds( + bounds.translate(shadow.offset).dilate(shadow.spread_radius), + ) + if shape_bounds.is_empty() { + continue + } + let blur_radius = shadow.blur_radius.scale(self.scale_factor) + self.next_scene.insert_primitive( + Shadow({ + order: 0, + blur_radius, + bounds: shape_bounds.dilate(blur_radius.mul_scalar(3.0)), + content_mask, + corner_radii: Default::default(), + color: shadow.color.opacity(self.element_opacity), + shape_bounds, + shape_corner_radii: corner_radii.scale(self.scale_factor), + inset: false, + }), + ) + } +} + +///| +/// Paints the inset box shadows of a rounded rectangle (GPUI: +/// `paint_inset_shadows`). +pub fn Window::paint_inset_shadows( + self : Window, + bounds : @geometry.Bounds[@geometry.Pixels], + corner_radii : @geometry.Corners[@geometry.Pixels], + shadows : Array[@style.BoxShadow], +) -> Unit { + self.assert_phase("paint_inset_shadows", [Paint]) + let content_mask = self.snapped_content_mask() + let element_bounds = self.cover_bounds(bounds) + for shadow in shadows { + if !shadow.inset { + continue + } + let hole = bounds.translate(shadow.offset).dilate(-shadow.spread_radius) + let shrink = fn(radius : @geometry.Pixels) { + @cmp.maximum(radius - shadow.spread_radius, @geometry.px(0.0)) + } + self.next_scene.insert_primitive( + Shadow({ + order: 0, + blur_radius: shadow.blur_radius.scale(self.scale_factor), + bounds: element_bounds, + content_mask, + corner_radii: corner_radii.scale(self.scale_factor), + color: shadow.color.opacity(self.element_opacity), + shape_bounds: self.cover_bounds(hole), + shape_corner_radii: corner_radii.map(shrink).scale(self.scale_factor), + inset: true, + }), + ) + } +} + +///| +/// Paints an element's box (drop shadows, background, inset shadows), runs +/// `paint_children`, then paints the border on top (GPUI: `Style::paint`). +pub fn Window::paint_style( + self : Window, + style : @style.Style, + bounds : @geometry.Bounds[@geometry.Pixels], + paint_children : () -> Unit, +) -> Unit { + self.assert_phase("paint_style", [Paint]) + if style.debug { + self.paint_quad(outline(bounds, @color.red())) + } + let corner_radii = style.corner_radii + .absolute_to_pixels(self.rem_size) + .clamp_radii_for_quad_size(bounds.size) + self.paint_drop_shadows(bounds, corner_radii, style.box_shadow) + if style.background is Some(fill) && + fill.color() is Some(background) && + !background.is_transparent() { + let border_color = match background.tag { + LinearGradient => background.colors.0.color + _ => background.solid + } + self.paint_quad({ + bounds, + corner_radii, + background, + border_widths: Default::default(), + border_color: border_color.alpha(0.0), + border_style: style.border_style, + }) + } + self.paint_inset_shadows(bounds, corner_radii, style.box_shadow) + paint_children() + if style.is_border_visible() { + let border_color = style.border_color.unwrap() + self.paint_quad({ + bounds, + corner_radii, + background: border_color.alpha(0.0).to_background(), + border_widths: style.border_widths.absolute_to_pixels(self.rem_size), + border_color, + border_style: style.border_style, + }) + } +} + +///| +/// Paints an arbitrary primitive (escape hatch for custom elements such as +/// `canvas`). Only during paint. +pub fn Window::paint_primitive( + self : Window, + primitive : @scene.Primitive, +) -> Unit { + self.assert_phase("paint_primitive", [Paint]) + self.next_scene.insert_primitive(primitive) +} + +///| +/// Paints a filled path given by polygon contours in logical pixels (GPUI: +/// `paint_path`, simplified to polygons). +pub fn Window::paint_path( + self : Window, + contours : Array[Array[@geometry.Point[@geometry.Pixels]]], + color : @color.Background, +) -> Unit { + self.assert_phase("paint_path", [Paint]) + let path = @scene.PaintedPath::new( + contours, + self.scale_factor, + self.content_mask(), + color.opacity(self.element_opacity), + ) + self.next_scene.insert_primitive(Path(path)) +} diff --git a/src/window/pkg.generated.mbti b/src/window/pkg.generated.mbti new file mode 100644 index 0000000..d5edc1e --- /dev/null +++ b/src/window/pkg.generated.mbti @@ -0,0 +1,198 @@ +// Generated using `moon info`, DON'T EDIT IT +package "experiments/gpui/window" + +import { + "experiments/gpui/app", + "experiments/gpui/color", + "experiments/gpui/geometry", + "experiments/gpui/input", + "experiments/gpui/layout", + "experiments/gpui/platform", + "experiments/gpui/scene", + "experiments/gpui/style", + "moonbitlang/core/debug", +} + +// Values +pub fn application_for(@app.App) -> Application? + +pub fn empty() -> AnyElement + +pub fn fill(@geometry.Bounds[@geometry.Pixels], @color.Background) -> PaintQuad + +pub fn[T, E] listener(@app.Context[T], (T, E, Window, @app.Context[T]) -> Unit) -> (E, Window, @app.App) -> Unit + +pub fn outline(@geometry.Bounds[@geometry.Pixels], @color.Hsla, border_style? : @scene.BorderStyle) -> PaintQuad + +// Errors + +// Types and methods +pub struct AnyElement { + // private fields +} +pub fn AnyElement::bounds(Self) -> @geometry.Bounds[@geometry.Pixels]? +pub fn AnyElement::new(&Element) -> Self +pub fn AnyElement::paint(Self, Window, @app.App) -> Unit +pub fn AnyElement::prepaint(Self, Window, @app.App) -> Unit +pub fn AnyElement::request_layout(Self, Window, @app.App) -> @layout.LayoutId +pub impl IntoElement for AnyElement + +pub struct AnyView { + entity_id : @app.EntityId + // private fields +} +pub fn[V : Render] AnyView::from_entity(@app.Entity[V]) -> Self +pub fn AnyView::into_any_element(Self) -> AnyElement +pub impl IntoElement for AnyView + +#derive(Compare, Eq, Hash, @debug.Debug) +pub struct AnyWindowHandle { + id : @platform.WindowId +} +pub fn[R] AnyWindowHandle::update(Self, Application, (AnyView, Window, @app.App) -> R) -> R? +pub fn AnyWindowHandle::window_id(Self) -> @platform.WindowId + +pub struct Application { + app : @app.App + platform : &@platform.Platform + // private fields +} +pub fn Application::active_window(Self) -> AnyWindowHandle? +pub fn Application::app(Self) -> @app.App +pub fn Application::close_window(Self, @platform.WindowId) -> Unit +pub fn Application::open_url(Self, String) -> Unit +pub fn[V : Render] Application::open_window(Self, @platform.WindowOptions, (Window, @app.App) -> @app.Entity[V]) -> WindowHandle[V] +pub fn Application::platform(Self) -> &@platform.Platform +pub fn Application::quit(Self) -> Unit +pub fn Application::read_from_clipboard(Self) -> @platform.ClipboardItem? +pub fn Application::refresh_windows(Self) -> Unit +pub fn Application::run(Self, (Self) -> Unit) -> Unit +pub fn Application::set_cursor_style(Self, @style.CursorStyle) -> Unit +pub fn[R] Application::update_window(Self, AnyWindowHandle, (AnyView, Window, @app.App) -> R) -> R? +pub fn Application::window(Self, @platform.WindowId) -> Window? +pub fn Application::window_count(Self) -> Int32 +pub fn Application::windows(Self) -> Array[AnyWindowHandle] +pub fn Application::with_platform(&@platform.Platform) -> Self +pub fn Application::write_to_clipboard(Self, @platform.ClipboardItem) -> Unit + +pub struct ElementStateKey[S] { + id : Int32 + name : String + // private fields +} +pub fn[S] ElementStateKey::new(String) -> Self[S] + +#derive(Eq, @debug.Debug) +pub(all) struct Hitbox { + id : Int32 + bounds : @geometry.Bounds[@geometry.Pixels] + content_mask : @geometry.ContentMask[@geometry.Pixels] + behavior : HitboxBehavior +} +pub fn Hitbox::is_hovered(Self, Window) -> Bool + +#derive(Eq, Hash, @debug.Debug) +pub(all) enum HitboxBehavior { + Normal + BlockMouse +} + +#derive(Eq, @debug.Debug) +pub(all) struct PaintQuad { + bounds : @geometry.Bounds[@geometry.Pixels] + corner_radii : @geometry.Corners[@geometry.Pixels] + background : @color.Background + border_widths : @geometry.Edges[@geometry.Pixels] + border_color : @color.Hsla + border_style : @scene.BorderStyle +} + +pub struct Window { + // private fields +} +pub fn Window::activate_window(Self) -> Unit +pub fn Window::bounds(Self) -> @geometry.Bounds[@geometry.Pixels] +pub fn Window::close(Self) -> Unit +pub fn Window::content_mask(Self) -> @geometry.ContentMask[@geometry.Pixels] +pub fn Window::default_prevented(Self) -> Bool +pub fn Window::dispatch_input(Self, @input.PlatformInput) -> @input.DispatchEventResult +pub fn Window::dispatch_mouse_event(Self, @input.MouseEvent) -> Bool +pub fn Window::draw(Self) -> @scene.Scene +pub fn Window::draw_if_dirty(Self) -> Bool +pub fn Window::element_offset(Self) -> @geometry.Point[@geometry.Pixels] +pub fn Window::element_opacity(Self) -> Double +pub fn Window::frame_count(Self) -> Int32 +pub fn Window::global_element_id(Self) -> String? +pub fn Window::insert_hitbox(Self, @geometry.Bounds[@geometry.Pixels], HitboxBehavior) -> Hitbox +pub fn Window::is_closed(Self) -> Bool +pub fn Window::is_dirty(Self) -> Bool +pub fn Window::is_window_active(Self) -> Bool +pub fn Window::is_window_hovered(Self) -> Bool +pub fn Window::layout_bounds(Self, @layout.LayoutId) -> @geometry.Bounds[@geometry.Pixels] +pub fn Window::modifiers(Self) -> @input.Modifiers +pub fn Window::mouse_position(Self) -> @geometry.Point[@geometry.Pixels] +pub fn Window::new(@app.App, @geometry.Size[@geometry.Pixels], scale_factor? : Double, rem_size? : @geometry.Pixels) -> Self +pub fn Window::on_close(Self, (@app.App) -> Unit) -> Unit +pub fn Window::on_mouse_event(Self, (@input.MouseEvent, @input.DispatchPhase, Self, @app.App) -> Unit) -> Unit +pub fn Window::on_should_close(Self, (Self, @app.App) -> Bool) -> Unit +pub fn Window::on_window_active_change(Self, (Self, @app.App) -> Unit) -> Unit +pub fn Window::paint_drop_shadows(Self, @geometry.Bounds[@geometry.Pixels], @geometry.Corners[@geometry.Pixels], Array[@style.BoxShadow]) -> Unit +pub fn Window::paint_inset_shadows(Self, @geometry.Bounds[@geometry.Pixels], @geometry.Corners[@geometry.Pixels], Array[@style.BoxShadow]) -> Unit +pub fn Window::paint_path(Self, Array[Array[@geometry.Point[@geometry.Pixels]]], @color.Background) -> Unit +pub fn Window::paint_primitive(Self, @scene.Primitive) -> Unit +pub fn Window::paint_quad(Self, PaintQuad) -> Unit +pub fn Window::paint_style(Self, @style.Style, @geometry.Bounds[@geometry.Pixels], () -> Unit) -> Unit +pub fn Window::prevent_default(Self) -> Unit +pub fn Window::read_from_clipboard(Self) -> @platform.ClipboardItem? +pub fn Window::refresh(Self) -> Unit +pub fn Window::rem_size(Self) -> @geometry.Pixels +pub fn Window::remove_window(Self) -> Unit +pub fn[V : Render] Window::replace_root_view(Self, (Self, @app.Context[V]) -> V) -> @app.Entity[V] +pub fn Window::request_layout(Self, @style.Style, Array[@layout.LayoutId]) -> @layout.LayoutId +pub fn Window::request_measured_layout(Self, @style.Style, (@geometry.Size[@geometry.Pixels?], @geometry.Size[@layout.AvailableSpace]) -> @geometry.Size[@geometry.Pixels]) -> @layout.LayoutId +pub fn Window::resize(Self, @geometry.Size[@geometry.Pixels], scale_factor? : Double) -> Unit +pub fn Window::root_view(Self) -> AnyView? +pub fn Window::scale_factor(Self) -> Double +pub fn Window::scene(Self) -> @scene.Scene +pub fn Window::set_cursor_style(Self, @style.CursorStyle) -> Unit +pub fn Window::set_rem_size(Self, @geometry.Pixels) -> Unit +pub fn[V : Render] Window::set_root_view(Self, @app.Entity[V]) -> Unit +pub fn Window::set_window_title(Self, String) -> Unit +pub fn Window::stop_propagation(Self) -> Unit +pub fn Window::viewport_size(Self) -> @geometry.Size[@geometry.Pixels] +pub fn Window::window_id(Self) -> @platform.WindowId +pub fn Window::window_title(Self) -> String? +pub fn[R] Window::with_content_mask(Self, @geometry.ContentMask[@geometry.Pixels]?, () -> R) -> R +pub fn[R] Window::with_element_id(Self, String?, () -> R) -> R +pub fn[R] Window::with_element_offset(Self, @geometry.Point[@geometry.Pixels], () -> R) -> R +pub fn[R] Window::with_element_opacity(Self, Double?, () -> R) -> R +pub fn[S, R] Window::with_element_state(Self, ElementStateKey[S], (S?) -> (R, S)) -> R +pub fn Window::write_to_clipboard(Self, @platform.ClipboardItem) -> Unit + +pub struct WindowHandle[V] { + id : @platform.WindowId + // private fields +} +pub fn[V] WindowHandle::entity(Self[V]) -> @app.Entity[V] +pub fn[V, R] WindowHandle::read_with(Self[V], Application, (V, @app.App) -> R) -> R? +pub fn[V] WindowHandle::to_any(Self[V]) -> AnyWindowHandle +pub fn[V, R] WindowHandle::update(Self[V], Application, (V, Window, @app.Context[V]) -> R) -> R? +pub fn[V] WindowHandle::window_id(Self[V]) -> @platform.WindowId + +// Type aliases + +// Traits +pub(open) trait Element { + fn request_layout(Self, Window, @app.App) -> @layout.LayoutId + fn prepaint(Self, @geometry.Bounds[@geometry.Pixels], Window, @app.App) -> Unit + fn paint(Self, @geometry.Bounds[@geometry.Pixels], Window, @app.App) -> Unit +} + +pub(open) trait IntoElement { + fn into_any_element(Self) -> AnyElement +} +pub impl[V : Render] IntoElement for @app.Entity[V] + +pub(open) trait Render { + fn render(Self, Window, @app.Context[Self]) -> AnyElement +} diff --git a/src/window/window.mbt b/src/window/window.mbt new file mode 100644 index 0000000..b02c0c2 --- /dev/null +++ b/src/window/window.mbt @@ -0,0 +1,1033 @@ +// The window, ported from gpui/src/window.rs: the frame lifecycle (layout, +// prepaint, paint), the content-mask/offset/opacity stacks, hitboxes and +// hit-testing, element state, mouse dispatch, view invalidation, and +// PlatformWindow integration. +// +// Not ported yet (see docs/PORTING.md): focus, the key dispatch tree and +// actions (M5/M10), view caching and `Scene::replay`-based reuse, deferred +// draws, tooltips, drag and drop, and text (M9). + +///| +#derive(Eq, Debug) +priv enum DrawPhase { + Idle + Layout + Prepaint + Paint +} + +///| +/// How a hitbox affects the hitboxes painted below it (GPUI: +/// `HitboxBehavior`). +#derive(Eq, Hash, Debug) +pub(all) enum HitboxBehavior { + /// Hitboxes below are also hovered. + Normal + /// Hitboxes below are not hovered (GPUI: `BlockMouse`, used by `occlude`). + BlockMouse +} + +///| +/// A region that receives the mouse, inserted during prepaint (GPUI: +/// `Hitbox`). +#derive(Eq, Debug) +pub(all) struct Hitbox { + id : Int32 + bounds : @geometry.Bounds[@geometry.Pixels] + content_mask : @geometry.ContentMask[@geometry.Pixels] + behavior : HitboxBehavior +} + +///| +/// Whether the mouse is over this hitbox (as of the last mouse event, hit +/// tested against the last rendered frame). +pub fn Hitbox::is_hovered(self : Hitbox, window : Window) -> Bool { + window.hovered_hitboxes.contains(self.id) +} + +///| +/// Identifies one kind of per-element state kept across frames (GPUI keys +/// element state by `TypeId`). +pub struct ElementStateKey[S] { + id : Int32 + name : String + priv slot : Ref[S?] +} + +///| +let next_state_key_id : Ref[Int32] = { val: 0, } + +///| +pub fn[S] ElementStateKey::new(name : String) -> ElementStateKey[S] { + let id = next_state_key_id.val + next_state_key_id.val = id + 1 + { id, name, slot: { val: None, }, } +} + +///| +/// Negative ids for standalone headless `Window::new` so they never collide +/// with `Application::open_window` ids (1, 2, ...). +let next_standalone_window_id : Ref[Int32] = { val: -1, } + +///| +priv struct MouseListener { + callback : (@input.MouseEvent, @input.DispatchPhase, Window, @app.App) -> Unit +} + +///| +/// A window (GPUI: `Window`): either standalone headless (`Window::new`) or +/// backed by a `PlatformWindow` (`Application::open_window`). `draw` lays out +/// and paints the root view into a `Scene`; `dispatch_input` / +/// `dispatch_mouse_event` deliver input. +pub struct Window { + priv id : @platform.WindowId + priv app : @app.App + priv platform : &@platform.Platform? + priv platform_window : &@platform.PlatformWindow? + priv mut viewport_size : @geometry.Size[@geometry.Pixels] + priv mut scale_factor : Double + priv mut rem_size : @geometry.Pixels + priv mut title : String? + priv mut active : Bool + priv mut hovered : Bool + priv mut modifiers : @input.Modifiers + priv layout_engine : @layout.LayoutEngine + priv mut root : AnyView? + priv mut phase : DrawPhase + priv mut dirty : Bool + priv mut closed : Bool + priv mut drawn_frames : Int32 + priv content_mask_stack : Array[@geometry.ContentMask[@geometry.Pixels]] + priv element_offset_stack : Array[@geometry.Point[@geometry.Pixels]] + priv mut element_opacity : Double + priv element_id_stack : Array[String] + priv mut next_scene : @scene.Scene + priv mut rendered_scene : @scene.Scene + priv mut next_hitboxes : Array[Hitbox] + priv mut rendered_hitboxes : Array[Hitbox] + priv mut next_mouse_listeners : Array[MouseListener] + priv mut rendered_mouse_listeners : Array[MouseListener] + priv mut next_element_states : Map[String, () -> Unit] + priv mut rendered_element_states : Map[String, () -> Unit] + priv mut next_rendered_views : @hashset.HashSet[@app.EntityId] + priv mut rendered_views : @hashset.HashSet[@app.EntityId] + priv mut mouse_position : @geometry.Point[@geometry.Pixels] + priv mut pointer_inside : Bool + priv mut hovered_hitboxes : Array[Int32] + priv mut propagate_event : Bool + priv mut default_prevented : Bool + priv mut notify_subscription : @app.Subscription? + priv mut should_close_handler : ((Window, @app.App) -> Bool)? + priv close_callbacks : Array[(@app.App) -> Unit] + priv activation_observers : Array[(Window, @app.App) -> Unit] + priv mut on_closed_internal : (() -> Unit)? +} + +///| +fn Window::mark_dirty(self : Window) -> Unit { + self.dirty = true + if self.platform_window is Some(pw) && !self.closed { + pw.schedule_frame() + } +} + +///| +fn Window::create( + id : @platform.WindowId, + app : @app.App, + viewport_size : @geometry.Size[@geometry.Pixels], + scale_factor : Double, + rem_size : @geometry.Pixels, + platform : &@platform.Platform?, + platform_window : &@platform.PlatformWindow?, + title : String?, + active : Bool, + hovered : Bool, + mouse_position : @geometry.Point[@geometry.Pixels], + modifiers : @input.Modifiers, + on_closed_internal : (() -> Unit)?, +) -> Window { + let window : Window = { + id, + app, + platform, + platform_window, + viewport_size, + scale_factor, + rem_size, + title, + active, + hovered, + modifiers, + layout_engine: @layout.LayoutEngine::new(), + root: None, + phase: Idle, + dirty: true, + closed: false, + drawn_frames: 0, + content_mask_stack: [], + element_offset_stack: [], + element_opacity: 1.0, + element_id_stack: [], + next_scene: @scene.Scene::new(), + rendered_scene: @scene.Scene::new(), + next_hitboxes: [], + rendered_hitboxes: [], + next_mouse_listeners: [], + rendered_mouse_listeners: [], + next_element_states: {}, + rendered_element_states: {}, + next_rendered_views: @hashset.HashSet([]), + rendered_views: @hashset.HashSet([]), + mouse_position, + pointer_inside: hovered, + hovered_hitboxes: [], + propagate_event: true, + default_prevented: false, + notify_subscription: None, + should_close_handler: None, + close_callbacks: [], + activation_observers: [], + on_closed_internal, + } + // Invalidate when a view rendered in the last frame (or currently being + // rendered) is notified (GPUI: `WindowInvalidator::invalidate_view`). + window.notify_subscription = Some( + app.observe_notifications(fn(entity_id) { + if window.rendered_views.contains(entity_id) || + (window.phase != Idle && window.next_rendered_views.contains(entity_id)) { + window.mark_dirty() + } + }), + ) + window +} + +///| +/// A standalone headless window of `viewport_size` logical pixels showing +/// nothing yet. Set its content with `set_root_view`. +pub fn Window::new( + app : @app.App, + viewport_size : @geometry.Size[@geometry.Pixels], + scale_factor~ : Double = 1.0, + rem_size~ : @geometry.Pixels = @geometry.px(16.0), +) -> Window { + let id = @platform.WindowId(next_standalone_window_id.val) + next_standalone_window_id.val = next_standalone_window_id.val - 1 + Window::create( + id, + app, + viewport_size, + scale_factor, + rem_size, + None, + None, + None, + true, + false, + @geometry.point(@geometry.px(0.0), @geometry.px(0.0)), + Default::default(), + None, + ) +} + +///| +/// Constructs a window backed by `platform` and `platform_window` and wires +/// all platform callbacks (`Application::open_window`). +fn Window::from_platform( + id : @platform.WindowId, + app : @app.App, + platform : &@platform.Platform, + platform_window : &@platform.PlatformWindow, + rem_size~ : @geometry.Pixels = @geometry.px(16.0), + title? : String, + on_closed? : () -> Unit, +) -> Window { + let window = Window::create( + id, + app, + platform_window.content_size(), + platform_window.scale_factor(), + rem_size, + Some(platform), + Some(platform_window), + title, + platform_window.is_active(), + platform_window.is_hovered(), + platform_window.mouse_position(), + platform_window.modifiers(), + on_closed, + ) + if title is Some(t) { + platform_window.set_title(t) + } + platform_window.on_request_frame(fn() { + if !window.closed && window.phase == Idle { + ignore(window.draw_if_dirty()) + } + }) + platform_window.on_input(fn(input) { + if window.closed { + { propagate: true, default_prevented: false, } + } else { + window.dispatch_input(input) + } + }) + platform_window.on_resize(fn(size, factor) { + if !window.closed { + window.viewport_size = size + window.scale_factor = factor + window.mark_dirty() + } + }) + platform_window.on_active_status_change(fn(active) { + if !window.closed { + window.active = active + window.modifiers = platform_window.modifiers() + let observers = window.activation_observers.copy() + if !observers.is_empty() { + window.app.update(fn(app) { + for callback in observers { + callback(window, app) + } + }) + } + window.mark_dirty() + } + }) + platform_window.on_hover_status_change(fn(hovered) { + if !window.closed { + window.hovered = hovered + window.pointer_inside = hovered + if hovered { + window.hovered_hitboxes = hit_test_hitboxes( + window.rendered_hitboxes, + window.mouse_position, + ) + } else if !window.hovered_hitboxes.is_empty() { + window.hovered_hitboxes = [] + } + window.mark_dirty() + } + }) + platform_window.on_should_close(fn() { + if window.closed { + true + } else { + match window.should_close_handler { + Some(handler) => window.app.update(fn(app) { handler(window, app) }) + None => true + } + } + }) + platform_window.on_close(fn() { window.close() }) + window +} + +///| +/// Sets the view the window renders (GPUI: the root view of +/// `open_window`). +pub fn[V : Render] Window::set_root_view( + self : Window, + view : @app.Entity[V], +) -> Unit { + guard !self.closed else { abort("set_root_view called on a closed window") } + self.root = Some(AnyView::from_entity(view)) + self.mark_dirty() +} + +///| +/// Replaces the window's root view with a newly constructed view, releasing +/// the previous root view (GPUI: `replace_root`). +pub fn[V : Render] Window::replace_root_view( + self : Window, + build : (Window, @app.Context[V]) -> V, +) -> @app.Entity[V] { + guard !self.closed else { + abort("replace_root_view called on a closed window") + } + let previous = self.root + let view = self.app.new_entity(fn(cx) { build(self, cx) }) + self.set_root_view(view) + if previous is Some(prev) && prev.entity_id != view.entity_id() { + (prev.release_fn)(self.app) + } + view +} + +///| +pub fn Window::root_view(self : Window) -> AnyView? { + self.root +} + +///| +/// Stops listening to the app, runs `on_close` callbacks, releases the root +/// view, and tears down any backing `PlatformWindow`. Idempotent. +pub fn Window::close(self : Window) -> Unit { + if self.closed { + return + } + self.closed = true + if self.notify_subscription is Some(subscription) { + subscription.unsubscribe() + } + self.notify_subscription = None + let callbacks = self.close_callbacks.copy() + self.close_callbacks.clear() + if !callbacks.is_empty() { + self.app.update(fn(app) { + for callback in callbacks { + callback(app) + } + }) + } + self.activation_observers.clear() + self.should_close_handler = None + if self.root is Some(root) { + self.root = None + (root.release_fn)(self.app) + } + if self.on_closed_internal is Some(on_closed) { + self.on_closed_internal = None + on_closed() + } + if self.platform_window is Some(pw) { + pw.close() + } +} + +///| +/// Closes and removes this window (GPUI: `remove_window`). +pub fn Window::remove_window(self : Window) -> Unit { + self.close() +} + +///| +pub fn Window::window_id(self : Window) -> @platform.WindowId { + self.id +} + +///| +pub fn Window::bounds(self : Window) -> @geometry.Bounds[@geometry.Pixels] { + match self.platform_window { + Some(pw) => pw.bounds() + None => + @geometry.bounds( + @geometry.point(@geometry.px(0.0), @geometry.px(0.0)), + self.viewport_size, + ) + } +} + +///| +pub fn Window::viewport_size(self : Window) -> @geometry.Size[@geometry.Pixels] { + self.viewport_size +} + +///| +pub fn Window::scale_factor(self : Window) -> Double { + self.scale_factor +} + +///| +pub fn Window::rem_size(self : Window) -> @geometry.Pixels { + self.rem_size +} + +///| +pub fn Window::mouse_position( + self : Window, +) -> @geometry.Point[@geometry.Pixels] { + self.mouse_position +} + +///| +pub fn Window::modifiers(self : Window) -> @input.Modifiers { + self.modifiers +} + +///| +pub fn Window::is_window_active(self : Window) -> Bool { + self.active +} + +///| +pub fn Window::is_window_hovered(self : Window) -> Bool { + self.hovered +} + +///| +pub fn Window::is_closed(self : Window) -> Bool { + self.closed +} + +///| +pub fn Window::window_title(self : Window) -> String? { + self.title +} + +///| +pub fn Window::set_window_title(self : Window, title : String) -> Unit { + self.title = Some(title) + if self.platform_window is Some(pw) && !self.closed { + pw.set_title(title) + } +} + +///| +pub fn Window::activate_window(self : Window) -> Unit { + if self.platform_window is Some(pw) && !self.closed { + pw.activate() + } +} + +///| +pub fn Window::set_cursor_style( + self : Window, + style : @style.CursorStyle, +) -> Unit { + if self.platform is Some(platform) { + platform.set_cursor_style(style) + } +} + +///| +pub fn Window::read_from_clipboard(self : Window) -> @platform.ClipboardItem? { + match self.platform { + Some(platform) => platform.read_from_clipboard() + None => None + } +} + +///| +pub fn Window::write_to_clipboard( + self : Window, + item : @platform.ClipboardItem, +) -> Unit { + if self.platform is Some(platform) { + platform.write_to_clipboard(item) + } +} + +///| +/// Marks the current input event's default action as prevented (GPUI: +/// `prevent_default`). +pub fn Window::prevent_default(self : Window) -> Unit { + self.default_prevented = true +} + +///| +pub fn Window::default_prevented(self : Window) -> Bool { + self.default_prevented +} + +///| +pub fn Window::on_should_close( + self : Window, + handler : (Window, @app.App) -> Bool, +) -> Unit { + self.should_close_handler = Some(handler) +} + +///| +pub fn Window::on_close(self : Window, callback : (@app.App) -> Unit) -> Unit { + self.close_callbacks.push(callback) +} + +///| +pub fn Window::on_window_active_change( + self : Window, + callback : (Window, @app.App) -> Unit, +) -> Unit { + self.activation_observers.push(callback) +} + +///| +/// Resizes the viewport (and optionally changes the scale factor); the next +/// frame is laid out again. +pub fn Window::resize( + self : Window, + viewport_size : @geometry.Size[@geometry.Pixels], + scale_factor? : Double, +) -> Unit { + self.viewport_size = viewport_size + if scale_factor is Some(factor) { + self.scale_factor = factor + } + if self.platform_window is Some(pw) && !self.closed { + pw.resize(viewport_size) + } + self.mark_dirty() +} + +///| +pub fn Window::set_rem_size(self : Window, rem_size : @geometry.Pixels) -> Unit { + self.rem_size = rem_size + self.mark_dirty() +} + +///| +/// Marks the window for redraw (GPUI: `refresh`). +pub fn Window::refresh(self : Window) -> Unit { + self.mark_dirty() +} + +///| +/// Whether something changed since the last frame: a rendered view was +/// notified, the hovered hitboxes changed, or the window was resized. +pub fn Window::is_dirty(self : Window) -> Bool { + self.dirty +} + +///| +/// Number of frames drawn so far. +pub fn Window::frame_count(self : Window) -> Int32 { + self.drawn_frames +} + +///| +/// The scene of the last drawn frame. +pub fn Window::scene(self : Window) -> @scene.Scene { + self.rendered_scene +} + +// --------------------------------------------------------------------------- +// Frame lifecycle +// --------------------------------------------------------------------------- + +///| +fn Window::assert_phase( + self : Window, + operation : String, + allowed : Array[DrawPhase], +) -> Unit { + guard allowed.contains(self.phase) else { + abort( + "\{operation} is not allowed in the \{@debug.to_string(self.phase)} phase", + ) + } +} + +///| +/// Draws a frame: renders the root view, lays it out to fill the viewport, +/// prepaints and paints it. Returns the frame's scene and presents it to the +/// `PlatformWindow` if one is attached. Effects queued while drawing flush +/// afterwards (GPUI: `Window::draw`). +pub fn Window::draw(self : Window) -> @scene.Scene { + guard !self.closed else { abort("Window::draw called on a closed window") } + guard self.phase == Idle else { abort("Window::draw called while drawing") } + guard self.root is Some(root) else { + abort("Window::draw: no root view (call set_root_view first)") + } + self.app.update(fn(app) { + self.dirty = false + self.layout_engine.clear() + self.next_scene = @scene.Scene::new() + self.next_hitboxes = [] + self.next_mouse_listeners = [] + self.next_element_states = {} + self.next_rendered_views = @hashset.HashSet([]) + self.content_mask_stack.clear() + self.element_offset_stack.clear() + self.element_id_stack.clear() + self.element_opacity = 1.0 + let element = root.into_any_element() + self.phase = Layout + let layout_id = element.request_layout(self, app) + self.layout_engine.stretch_auto_size_to_fill( + layout_id, + self.viewport_size, + self.scale_factor, + ) + self.layout_engine.compute_layout( + layout_id, + @layout.AvailableSpace::from_size(self.viewport_size), + self.scale_factor, + ) + self.phase = Prepaint + element.prepaint(self, app) + self.hovered_hitboxes = if self.pointer_inside { + hit_test_hitboxes(self.next_hitboxes, self.mouse_position) + } else { + [] + } + self.phase = Paint + element.paint(self, app) + self.phase = Idle + self.next_scene.finish() + // Swap frames. + self.rendered_scene = self.next_scene + self.rendered_hitboxes = self.next_hitboxes + self.rendered_mouse_listeners = self.next_mouse_listeners + self.rendered_element_states = self.next_element_states + self.rendered_views = self.next_rendered_views + self.drawn_frames = self.drawn_frames + 1 + }) + if self.platform_window is Some(pw) && !self.closed { + pw.draw(self.rendered_scene) + } + self.rendered_scene +} + +///| +/// Draws a frame only if the window is dirty; returns whether it drew. +pub fn Window::draw_if_dirty(self : Window) -> Bool { + if self.dirty { + ignore(self.draw()) + true + } else { + false + } +} + +///| +fn Window::record_rendered_view( + self : Window, + entity_id : @app.EntityId, +) -> Unit { + self.next_rendered_views.add(entity_id) +} + +// --------------------------------------------------------------------------- +// Layout +// --------------------------------------------------------------------------- + +///| +/// Requests a layout node for `style` with `children` (GPUI: +/// `request_layout`). Only during the layout phase. +pub fn Window::request_layout( + self : Window, + style : @style.Style, + children : Array[@layout.LayoutId], +) -> @layout.LayoutId { + self.assert_phase("request_layout", [Layout]) + self.layout_engine.request_layout( + style, + self.rem_size, + self.scale_factor, + children, + ) +} + +///| +/// Requests a leaf measured by `measure` (GPUI: `request_measured_layout`). +pub fn Window::request_measured_layout( + self : Window, + style : @style.Style, + measure : @layout.MeasureFn, +) -> @layout.LayoutId { + self.assert_phase("request_measured_layout", [Layout]) + self.layout_engine.request_measured_layout( + style, + self.rem_size, + self.scale_factor, + measure, + ) +} + +///| +/// The bounds of a laid-out node, offset by the current element offset +/// (GPUI: `layout_bounds`). +pub fn Window::layout_bounds( + self : Window, + layout_id : @layout.LayoutId, +) -> @geometry.Bounds[@geometry.Pixels] { + self.assert_phase("layout_bounds", [Prepaint, Paint]) + self.layout_engine + .layout_bounds(layout_id, self.scale_factor) + .translate(self.element_offset()) +} + +// --------------------------------------------------------------------------- +// Stacks: content mask, element offset, opacity, element ids +// --------------------------------------------------------------------------- + +///| +/// The current clip region (the viewport if nothing is pushed). +pub fn Window::content_mask( + self : Window, +) -> @geometry.ContentMask[@geometry.Pixels] { + match self.content_mask_stack.last() { + Some(mask) => mask + None => + { + bounds: { + origin: @geometry.point(@geometry.px(0.0), @geometry.px(0.0)), + size: self.viewport_size, + }, + } + } +} + +///| +/// Runs `f` with painting clipped to `mask` intersected with the current +/// mask (GPUI: `with_content_mask`). `None` leaves the mask unchanged. +pub fn[R] Window::with_content_mask( + self : Window, + mask : @geometry.ContentMask[@geometry.Pixels]?, + f : () -> R, +) -> R { + self.assert_phase("with_content_mask", [Prepaint, Paint]) + match mask { + None => f() + Some(mask) => { + self.content_mask_stack.push(mask.intersect(self.content_mask())) + let result = f() + ignore(self.content_mask_stack.pop()) + result + } + } +} + +///| +pub fn Window::element_offset( + self : Window, +) -> @geometry.Point[@geometry.Pixels] { + match self.element_offset_stack.last() { + Some(offset) => offset + None => @geometry.point(@geometry.px(0.0), @geometry.px(0.0)) + } +} + +///| +/// Runs `f` with children offset by `offset` (GPUI: `with_element_offset`, +/// used for scrolling). Only during prepaint. +pub fn[R] Window::with_element_offset( + self : Window, + offset : @geometry.Point[@geometry.Pixels], + f : () -> R, +) -> R { + self.assert_phase("with_element_offset", [Prepaint]) + self.element_offset_stack.push(self.element_offset() + offset) + let result = f() + ignore(self.element_offset_stack.pop()) + result +} + +///| +pub fn Window::element_opacity(self : Window) -> Double { + self.element_opacity +} + +///| +/// Runs `f` with painting faded by `opacity` (multiplied with the current +/// opacity; GPUI: `with_element_opacity`). +pub fn[R] Window::with_element_opacity( + self : Window, + opacity : Double?, + f : () -> R, +) -> R { + match opacity { + None => f() + Some(opacity) => { + let previous = self.element_opacity + self.element_opacity = previous * opacity + let result = f() + self.element_opacity = previous + result + } + } +} + +///| +/// Runs `f` with `id` pushed onto the element id path (GPUI: +/// `with_element_id`). `None` leaves the path unchanged. +pub fn[R] Window::with_element_id( + self : Window, + id : String?, + f : () -> R, +) -> R { + match id { + None => f() + Some(id) => { + self.element_id_stack.push(id) + let result = f() + ignore(self.element_id_stack.pop()) + result + } + } +} + +///| +/// The current global element id (the path of pushed ids), if any. +pub fn Window::global_element_id(self : Window) -> String? { + if self.element_id_stack.is_empty() { + None + } else { + Some(self.element_id_stack.join("/")) + } +} + +///| +/// Gives `f` the state stored under the current element id from the +/// previous frame (or `None`) and stores the state it returns for the next +/// frame (GPUI: `with_element_state`). Fails loudly without an element id. +pub fn[S, R] Window::with_element_state( + self : Window, + key : ElementStateKey[S], + f : (S?) -> (R, S), +) -> R { + guard self.global_element_id() is Some(global_id) else { + abort("element state (\{key.name}) requires an element id (use .id(...))") + } + let storage_key = "\{global_id}#\{key.id}" + let erased = match self.next_element_states.get(storage_key) { + Some(erased) => Some(erased) + None => self.rendered_element_states.get(storage_key) + } + let previous = match erased { + Some(erased) => { + key.slot.val = None + erased() + let value = key.slot.val + key.slot.val = None + value + } + None => None + } + let (result, state) = f(previous) + self.next_element_states[storage_key] = fn() { key.slot.val = Some(state) } + result +} + +// --------------------------------------------------------------------------- +// Hitboxes and input dispatch +// --------------------------------------------------------------------------- + +///| +/// Inserts a hitbox for this frame (GPUI: `insert_hitbox`). Only during +/// prepaint. +pub fn Window::insert_hitbox( + self : Window, + bounds : @geometry.Bounds[@geometry.Pixels], + behavior : HitboxBehavior, +) -> Hitbox { + self.assert_phase("insert_hitbox", [Prepaint]) + let hitbox = { + id: self.next_hitboxes.length(), + bounds, + content_mask: self.content_mask(), + behavior, + } + self.next_hitboxes.push(hitbox) + hitbox +} + +///| +/// The ids of the hitboxes under `position`, topmost first, stopping below a +/// `BlockMouse` hitbox (GPUI: `Frame::hit_test`). +fn hit_test_hitboxes( + hitboxes : Array[Hitbox], + position : @geometry.Point[@geometry.Pixels], +) -> Array[Int32] { + let hits = [] + for i = hitboxes.length() - 1; i >= 0; i = i - 1 { + let hitbox = hitboxes[i] + let visible = hitbox.bounds.intersect(hitbox.content_mask.bounds) + if visible.contains(position) { + hits.push(hitbox.id) + if hitbox.behavior == BlockMouse { + break + } + } + } + hits +} + +///| +/// Registers a listener for mouse events of the next frame's dispatch +/// (GPUI: `on_mouse_event`). Only during paint. +pub fn Window::on_mouse_event( + self : Window, + callback : (@input.MouseEvent, @input.DispatchPhase, Window, @app.App) -> Unit, +) -> Unit { + self.assert_phase("on_mouse_event", [Paint]) + self.next_mouse_listeners.push({ callback, }) +} + +///| +/// Stops the current event from reaching further listeners (GPUI: +/// `stop_propagation`). +pub fn Window::stop_propagation(self : Window) -> Unit { + self.propagate_event = false +} + +///| +/// Delivers a mouse event to the listeners of the last frame: first in paint +/// order (capture), then in reverse paint order (bubble), until propagation +/// stops. Updates hover state; a change of hovered hitboxes marks the window +/// dirty. Returns whether the event propagated to the end. +pub fn Window::dispatch_mouse_event( + self : Window, + event : @input.MouseEvent, +) -> Bool { + guard !self.closed else { + abort("dispatch_mouse_event called on a closed window") + } + guard self.phase == Idle else { + abort("dispatch_mouse_event called while drawing") + } + self.mouse_position = event.position() + self.modifiers = event.modifiers() + self.pointer_inside = true + let hovered = hit_test_hitboxes(self.rendered_hitboxes, self.mouse_position) + if hovered != self.hovered_hitboxes { + self.hovered_hitboxes = hovered + self.mark_dirty() + } + self.propagate_event = true + self.default_prevented = false + let listeners = self.rendered_mouse_listeners + self.app.update(fn(app) { + for listener in listeners { + if !self.propagate_event { + break + } + (listener.callback)(event, Capture, self, app) + } + for i = listeners.length() - 1; i >= 0; i = i - 1 { + if !self.propagate_event { + break + } + (listeners[i].callback)(event, Bubble, self, app) + } + }) + self.propagate_event +} + +///| +/// Delivers a `PlatformInput` event to the window (GPUI: +/// `Window::dispatch_event`). +pub fn Window::dispatch_input( + self : Window, + event : @input.PlatformInput, +) -> @input.DispatchEventResult { + guard !self.closed else { abort("dispatch_input called on a closed window") } + guard self.phase == Idle else { abort("dispatch_input called while drawing") } + self.propagate_event = true + self.default_prevented = false + match event { + MouseDown(e) => ignore(self.dispatch_mouse_event(MouseDown(e))) + MouseUp(e) => ignore(self.dispatch_mouse_event(MouseUp(e))) + MouseMove(e) => ignore(self.dispatch_mouse_event(MouseMove(e))) + ScrollWheel(e) => ignore(self.dispatch_mouse_event(ScrollWheel(e))) + MouseExited(e) => { + self.mouse_position = e.position + self.modifiers = e.modifiers + self.pointer_inside = false + if !self.hovered_hitboxes.is_empty() { + self.hovered_hitboxes = [] + self.mark_dirty() + } + } + ModifiersChanged(e) => + if self.modifiers != e.modifiers { + self.modifiers = e.modifiers + self.mark_dirty() + } + } + { + propagate: self.propagate_event, + default_prevented: self.default_prevented, + } +} diff --git a/tools/gen_style.py b/tools/gen_style.py index 0f23fe7..fbec15b 100644 --- a/tools/gen_style.py +++ b/tools/gen_style.py @@ -16,8 +16,9 @@ Outputs (all in src/style/): styled_extend_generated.mbt promotes all `Styled` methods on StyleRefinement -Other packages that implement `Styled` (e.g. `Div`) need the same `extend` -list; pass `--extend Type=path/to/file.mbt` to emit it there. +Other packages that implement `Styled` need the same `extend` list. The +default run also emits it for the elements package (`Div`, `Canvas`); add +more with `--extend Type=path/to/file.mbt`. """ import argparse @@ -636,11 +637,11 @@ def gen_styled(): return "".join(out), names -def gen_extend(type_name, names): +def gen_extend(type_name, names, trait_ref="Styled"): body = ",\n ".join(names) return ( HEADER - + f"///|\npub extend {type_name} with Styled::{{\n {body},\n}}\n" + + f"///|\npub extend {type_name} with {trait_ref}::{{\n {body},\n}}\n" ) @@ -650,6 +651,13 @@ def write(path, content): print(f"wrote {os.path.relpath(path, ROOT)}") +# Styled types outside the style package, emitted on every run. +DEFAULT_EXTENDS = [ + "Div=src/elements/div_styled_generated.mbt", + "Canvas=src/elements/canvas_styled_generated.mbt", +] + + def main(): parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument( @@ -668,11 +676,15 @@ def main(): os.path.join(STYLE_DIR, "styled_extend_generated.mbt"), gen_extend("StyleRefinement", names), ) - for spec in args.extend: + for spec in DEFAULT_EXTENDS + args.extend: if "=" not in spec: sys.exit(f"gen_style: --extend expects TYPE=FILE, got {spec!r}") type_name, path = spec.split("=", 1) - write(os.path.join(ROOT, path), gen_extend(type_name, names)) + full = os.path.join(ROOT, path) + # Outside the style package the trait must be package-qualified. + inside = os.path.dirname(os.path.abspath(full)) == STYLE_DIR + trait_ref = "Styled" if inside else "@style.Styled" + write(full, gen_extend(type_name, names, trait_ref)) print(f"{len(names)} Styled methods")