diff --git a/enums.py b/enums.py index d7002c47e3..dfc95dc771 100755 --- a/enums.py +++ b/enums.py @@ -69,9 +69,6 @@ # Fix flex basis computation to not apply FitContent constraint in the # main axis for non-measure container nodes "FixFlexBasisFitContent", - # Measure a leaf's min-content height at the width it is given instead - # of asking for a height of at most zero - "MinContentHeightAtGivenWidth", ], "Gutter": ["Column", "Row", "All"], "GridTrackType": ["Auto", "Points", "Percent", "Fr", "Minmax"], diff --git a/gentest/fixtures/YGAutoMinSizeTest.html b/gentest/fixtures/YGAutoMinSizeTest.html index a8da2addaa..a8bf3463a7 100644 --- a/gentest/fixtures/YGAutoMinSizeTest.html +++ b/gentest/fixtures/YGAutoMinSizeTest.html @@ -251,14 +251,12 @@
aaaa aaaa aaaa
aaaa aaaa aaaa
@@ -269,21 +267,18 @@
aaaa aaaa aaaa
aaaa aaaa aaaa
aaaa aaaa aaaa
@@ -292,7 +287,6 @@
aaaa aaaa aaaa
@@ -303,7 +297,6 @@
@@ -312,7 +305,6 @@
@@ -323,14 +315,12 @@
aaaa aaaa aaaa
aaaa aaaa aaaa
@@ -338,7 +328,6 @@
aaaa aaaa aaaa
@@ -349,7 +338,6 @@
@@ -365,7 +353,6 @@
aaaa aaaa aaaa
diff --git a/java/com/facebook/yoga/YogaExperimentalFeature.kt b/java/com/facebook/yoga/YogaExperimentalFeature.kt index bf122ae07f..aec70ac246 100644 --- a/java/com/facebook/yoga/YogaExperimentalFeature.kt +++ b/java/com/facebook/yoga/YogaExperimentalFeature.kt @@ -11,8 +11,7 @@ package com.facebook.yoga public enum class YogaExperimentalFeature(public val intValue: Int) { WEB_FLEX_BASIS(0), - FIX_FLEX_BASIS_FIT_CONTENT(1), - MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH(2); + FIX_FLEX_BASIS_FIT_CONTENT(1); public fun intValue(): Int = intValue @@ -22,7 +21,6 @@ public enum class YogaExperimentalFeature(public val intValue: Int) { when (value) { 0 -> WEB_FLEX_BASIS 1 -> FIX_FLEX_BASIS_FIT_CONTENT - 2 -> MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH else -> throw IllegalArgumentException("Unknown enum value: $value") } } diff --git a/java/tests/generated/com/facebook/yoga/YGAutoMinSizeTest.java b/java/tests/generated/com/facebook/yoga/YGAutoMinSizeTest.java index ec1fe3d8a1..1eaabba962 100644 --- a/java/tests/generated/com/facebook/yoga/YGAutoMinSizeTest.java +++ b/java/tests/generated/com/facebook/yoga/YGAutoMinSizeTest.java @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<21eb813d9af6d73d4e8f50df15963aa0>> + * @generated SignedSource<<965fc9a5d196883b28ce23727c268e24>> * generated by gentest/src/GentestDriver.ts from gentest/fixtures/YGAutoMinSizeTest.html */ @@ -2070,7 +2070,6 @@ public void test_auto_min_size_wrapping_column_counts_all_children() { @Test public void test_auto_min_size_text_keeps_wrapped_lines() { YogaConfig config = YogaConfigFactory.create(); - config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH, true); config.setErrata(YogaErrata.NONE); final YogaNode root = createNode(config); @@ -2127,7 +2126,6 @@ public void test_auto_min_size_text_keeps_wrapped_lines() { @Test public void test_auto_min_size_nested_text_keeps_wrapped_lines() { YogaConfig config = YogaConfigFactory.create(); - config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH, true); config.setErrata(YogaErrata.NONE); final YogaNode root = createNode(config); @@ -2198,7 +2196,6 @@ public void test_auto_min_size_nested_text_keeps_wrapped_lines() { @Test public void test_auto_min_size_text_wraps_inside_margin_and_padding() { YogaConfig config = YogaConfigFactory.create(); - config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH, true); config.setErrata(YogaErrata.NONE); final YogaNode root = createNode(config); @@ -2259,7 +2256,6 @@ public void test_auto_min_size_text_wraps_inside_margin_and_padding() { @Test public void test_auto_min_size_text_wraps_at_stated_width() { YogaConfig config = YogaConfigFactory.create(); - config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH, true); config.setErrata(YogaErrata.NONE); final YogaNode root = createNode(config); @@ -2319,7 +2315,6 @@ public void test_auto_min_size_text_wraps_at_stated_width() { @Test public void test_auto_min_size_text_wraps_at_stated_content_box_width() { YogaConfig config = YogaConfigFactory.create(); - config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH, true); config.setErrata(YogaErrata.NONE); final YogaNode root = createNode(config); @@ -2380,7 +2375,6 @@ public void test_auto_min_size_text_wraps_at_stated_content_box_width() { @Test public void test_auto_min_size_text_wraps_inside_padded_parent() { YogaConfig config = YogaConfigFactory.create(); - config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH, true); config.setErrata(YogaErrata.NONE); final YogaNode root = createNode(config); @@ -2452,7 +2446,6 @@ public void test_auto_min_size_text_wraps_inside_padded_parent() { @Test public void test_auto_min_size_percent_margin_resolves_against_parent_content_width() { YogaConfig config = YogaConfigFactory.create(); - config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH, true); config.setErrata(YogaErrata.NONE); final YogaNode root = createNode(config); @@ -2523,7 +2516,6 @@ public void test_auto_min_size_percent_margin_resolves_against_parent_content_wi @Test public void test_auto_min_size_text_fits_wider_parent() { YogaConfig config = YogaConfigFactory.create(); - config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH, true); config.setErrata(YogaErrata.NONE); final YogaNode root = createNode(config); @@ -2607,7 +2599,6 @@ public void test_auto_min_size_text_fits_wider_parent() { @Test public void test_auto_min_size_text_fits_min_width() { YogaConfig config = YogaConfigFactory.create(); - config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH, true); config.setErrata(YogaErrata.NONE); final YogaNode root = createNode(config); @@ -2665,7 +2656,6 @@ public void test_auto_min_size_text_fits_min_width() { @Test public void test_auto_min_size_text_wraps_at_max_width() { YogaConfig config = YogaConfigFactory.create(); - config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH, true); config.setErrata(YogaErrata.NONE); final YogaNode root = createNode(config); @@ -2723,7 +2713,6 @@ public void test_auto_min_size_text_wraps_at_max_width() { @Test public void test_auto_min_size_text_below_row_wraps_at_max_width() { YogaConfig config = YogaConfigFactory.create(); - config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH, true); config.setErrata(YogaErrata.NONE); final YogaNode root = createNode(config); @@ -2795,7 +2784,6 @@ public void test_auto_min_size_text_below_row_wraps_at_max_width() { @Test public void test_auto_min_size_text_below_row_is_not_wrapped() { YogaConfig config = YogaConfigFactory.create(); - config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH, true); config.setErrata(YogaErrata.NONE); final YogaNode root = createNode(config); @@ -2906,7 +2894,6 @@ public void test_auto_min_size_text_below_row_is_not_wrapped() { @Test public void test_auto_min_size_text_in_wrapping_column_keeps_wrapped_lines() { YogaConfig config = YogaConfigFactory.create(); - config.setExperimentalFeatureEnabled(YogaExperimentalFeature.MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH, true); config.setErrata(YogaErrata.NONE); final YogaNode root = createNode(config); diff --git a/javascript/src/generated/YGEnums.ts b/javascript/src/generated/YGEnums.ts index a3cbf47f7f..c0fa83dd1b 100644 --- a/javascript/src/generated/YGEnums.ts +++ b/javascript/src/generated/YGEnums.ts @@ -72,7 +72,6 @@ export enum Errata { export enum ExperimentalFeature { WebFlexBasis = 0, FixFlexBasisFitContent = 1, - MinContentHeightAtGivenWidth = 2, } export enum FlexDirection { @@ -202,7 +201,6 @@ const constants = { ERRATA_CLASSIC: Errata.Classic, EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS: ExperimentalFeature.WebFlexBasis, EXPERIMENTAL_FEATURE_FIX_FLEX_BASIS_FIT_CONTENT: ExperimentalFeature.FixFlexBasisFitContent, - EXPERIMENTAL_FEATURE_MIN_CONTENT_HEIGHT_AT_GIVEN_WIDTH: ExperimentalFeature.MinContentHeightAtGivenWidth, FLEX_DIRECTION_COLUMN: FlexDirection.Column, FLEX_DIRECTION_COLUMN_REVERSE: FlexDirection.ColumnReverse, FLEX_DIRECTION_ROW: FlexDirection.Row, diff --git a/javascript/tests/generated/YGAutoMinSizeTest.test.ts b/javascript/tests/generated/YGAutoMinSizeTest.test.ts index 62a9602310..53f3d18986 100644 --- a/javascript/tests/generated/YGAutoMinSizeTest.test.ts +++ b/javascript/tests/generated/YGAutoMinSizeTest.test.ts @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<020135c5d3f3b3a01d1136f77372bf2f>> + * @generated SignedSource<<5d267528d8e4a6067440bb0d80ab1d02>> * generated by gentest/src/GentestDriver.ts from gentest/fixtures/YGAutoMinSizeTest.html */ @@ -1999,8 +1999,6 @@ test('auto_min_size_wrapping_column_counts_all_children', () => { test('auto_min_size_text_keeps_wrapped_lines', () => { const config = Yoga.Config.create(); - config.setExperimentalFeatureEnabled(ExperimentalFeature.MinContentHeightAtGivenWidth, true); - config.setErrata(Errata.None); const root = Yoga.Node.create(config); @@ -2053,8 +2051,6 @@ test('auto_min_size_text_keeps_wrapped_lines', () => { test('auto_min_size_nested_text_keeps_wrapped_lines', () => { const config = Yoga.Config.create(); - config.setExperimentalFeatureEnabled(ExperimentalFeature.MinContentHeightAtGivenWidth, true); - config.setErrata(Errata.None); const root = Yoga.Node.create(config); @@ -2121,8 +2117,6 @@ test('auto_min_size_nested_text_keeps_wrapped_lines', () => { test('auto_min_size_text_wraps_inside_margin_and_padding', () => { const config = Yoga.Config.create(); - config.setExperimentalFeatureEnabled(ExperimentalFeature.MinContentHeightAtGivenWidth, true); - config.setErrata(Errata.None); const root = Yoga.Node.create(config); @@ -2179,8 +2173,6 @@ test('auto_min_size_text_wraps_inside_margin_and_padding', () => { test('auto_min_size_text_wraps_at_stated_width', () => { const config = Yoga.Config.create(); - config.setExperimentalFeatureEnabled(ExperimentalFeature.MinContentHeightAtGivenWidth, true); - config.setErrata(Errata.None); const root = Yoga.Node.create(config); @@ -2236,8 +2228,6 @@ test('auto_min_size_text_wraps_at_stated_width', () => { test('auto_min_size_text_wraps_at_stated_content_box_width', () => { const config = Yoga.Config.create(); - config.setExperimentalFeatureEnabled(ExperimentalFeature.MinContentHeightAtGivenWidth, true); - config.setErrata(Errata.None); const root = Yoga.Node.create(config); @@ -2294,8 +2284,6 @@ test('auto_min_size_text_wraps_at_stated_content_box_width', () => { test('auto_min_size_text_wraps_inside_padded_parent', () => { const config = Yoga.Config.create(); - config.setExperimentalFeatureEnabled(ExperimentalFeature.MinContentHeightAtGivenWidth, true); - config.setErrata(Errata.None); const root = Yoga.Node.create(config); @@ -2363,8 +2351,6 @@ test('auto_min_size_text_wraps_inside_padded_parent', () => { test('auto_min_size_percent_margin_resolves_against_parent_content_width', () => { const config = Yoga.Config.create(); - config.setExperimentalFeatureEnabled(ExperimentalFeature.MinContentHeightAtGivenWidth, true); - config.setErrata(Errata.None); const root = Yoga.Node.create(config); @@ -2432,8 +2418,6 @@ test('auto_min_size_percent_margin_resolves_against_parent_content_width', () => test('auto_min_size_text_fits_wider_parent', () => { const config = Yoga.Config.create(); - config.setExperimentalFeatureEnabled(ExperimentalFeature.MinContentHeightAtGivenWidth, true); - config.setErrata(Errata.None); const root = Yoga.Node.create(config); @@ -2513,8 +2497,6 @@ test('auto_min_size_text_fits_wider_parent', () => { test('auto_min_size_text_fits_min_width', () => { const config = Yoga.Config.create(); - config.setExperimentalFeatureEnabled(ExperimentalFeature.MinContentHeightAtGivenWidth, true); - config.setErrata(Errata.None); const root = Yoga.Node.create(config); @@ -2568,8 +2550,6 @@ test('auto_min_size_text_fits_min_width', () => { test('auto_min_size_text_wraps_at_max_width', () => { const config = Yoga.Config.create(); - config.setExperimentalFeatureEnabled(ExperimentalFeature.MinContentHeightAtGivenWidth, true); - config.setErrata(Errata.None); const root = Yoga.Node.create(config); @@ -2623,8 +2603,6 @@ test('auto_min_size_text_wraps_at_max_width', () => { test('auto_min_size_text_below_row_wraps_at_max_width', () => { const config = Yoga.Config.create(); - config.setExperimentalFeatureEnabled(ExperimentalFeature.MinContentHeightAtGivenWidth, true); - config.setErrata(Errata.None); const root = Yoga.Node.create(config); @@ -2692,8 +2670,6 @@ test('auto_min_size_text_below_row_wraps_at_max_width', () => { test('auto_min_size_text_below_row_is_not_wrapped', () => { const config = Yoga.Config.create(); - config.setExperimentalFeatureEnabled(ExperimentalFeature.MinContentHeightAtGivenWidth, true); - config.setErrata(Errata.None); const root = Yoga.Node.create(config); @@ -2800,8 +2776,6 @@ test('auto_min_size_text_below_row_is_not_wrapped', () => { test('auto_min_size_text_in_wrapping_column_keeps_wrapped_lines', () => { const config = Yoga.Config.create(); - config.setExperimentalFeatureEnabled(ExperimentalFeature.MinContentHeightAtGivenWidth, true); - config.setErrata(Errata.None); const root = Yoga.Node.create(config); diff --git a/tests/YGAutoMinSizeTest.cpp b/tests/YGAutoMinSizeTest.cpp index 0a6ce5d58c..bda626cf65 100644 --- a/tests/YGAutoMinSizeTest.cpp +++ b/tests/YGAutoMinSizeTest.cpp @@ -572,6 +572,7 @@ TEST(YogaAutoMinSize, nested_leaf_probed_at_most_once_per_axis_per_layout) { } struct Probe { int calls = 0; + float width = YGUndefined; YGMeasureMode widthMode = YGMeasureModeUndefined; YGMeasureMode heightMode = YGMeasureModeUndefined; } probe; @@ -581,12 +582,13 @@ TEST(YogaAutoMinSize, nested_leaf_probed_at_most_once_per_axis_per_layout) { YGNodeSetMinContentMeasureFunc( leaf, [](YGNodeConstRef node, - float /*width*/, + float width, YGMeasureMode widthMode, float /*height*/, YGMeasureMode heightMode) { auto* p = static_cast(YGNodeGetContext(node)); ++p->calls; + p->width = width; p->widthMode = widthMode; p->heightMode = heightMode; return YGSize{kWordWidth, kLineHeight}; @@ -601,6 +603,7 @@ TEST(YogaAutoMinSize, nested_leaf_probed_at_most_once_per_axis_per_layout) { YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); EXPECT_EQ(probe.calls, 1); + EXPECT_FLOAT_EQ(0.0f, probe.width); EXPECT_EQ(probe.widthMode, YGMeasureModeAtMost); EXPECT_EQ(probe.heightMode, YGMeasureModeUndefined); // The memoized floor still reaches the outermost item. @@ -814,28 +817,11 @@ static YGNodeRef makeTextColumn(YGConfigRef config, float width, bool nested) { return root; } -// Without the experimental feature, a height is probed as a width is: at most -// zero on the probed axis and no constraint on the other. -TEST(YogaAutoMinSize, min_content_height_probe_asks_for_at_most_zero) { - YGConfigRef config = makeWebConfig(/*useAutoMinSize=*/true); - YGNodeRef root = makeTextColumn(config, 70, /*nested=*/false); - - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - - EXPECT_EQ(YGMeasureModeUndefined, gLastHeightProbeWidthMode); - EXPECT_EQ(YGMeasureModeAtMost, gLastHeightProbeHeightMode); - EXPECT_FLOAT_EQ(0.0f, gLastHeightProbe.height); - - YGNodeFreeRecursive(root); - YGConfigFree(config); -} - -// With it, the leaf is measured at its content width, and measured again when -// the owner's width changes although the leaf, and a box around it, are clean. +// A height is probed at the leaf's content width with no limit on the height, +// and probed again when the owner's width changes although the leaf, and a box +// around it, are clean. TEST(YogaAutoMinSize, min_content_height_follows_given_width) { YGConfigRef config = makeWebConfig(/*useAutoMinSize=*/true); - YGConfigSetExperimentalFeatureEnabled( - config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); for (const bool nested : {false, true}) { YGNodeRef root = makeTextColumn(config, 70, nested); YGNodeRef item = YGNodeGetChild(root, 0); @@ -862,8 +848,6 @@ TEST(YogaAutoMinSize, min_content_height_follows_given_width) { // with no limit on either axis. TEST(YogaAutoMinSize, min_content_height_without_owner_width_is_unconstrained) { YGConfigRef config = makeWebConfig(/*useAutoMinSize=*/true); - YGConfigSetExperimentalFeatureEnabled( - config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); YGNodeRef root = makeTextColumn(config, YGUndefined, /*nested=*/false); YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); @@ -877,11 +861,9 @@ TEST(YogaAutoMinSize, min_content_height_without_owner_width_is_unconstrained) { } // A width probe does not depend on the owner's width, so the leaf's memo for -// it survives a new width with the feature on. +// it survives a new width. TEST(YogaAutoMinSize, min_content_width_memo_survives_new_owner_width) { ShrinkRow row(/*useAutoMinSize=*/true, /*containerWidth=*/20); - YGConfigSetExperimentalFeatureEnabled( - row.config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); YGNodeSetMinContentMeasureFunc(row.text, measureMinContentWord); row.layout(); diff --git a/tests/generated/YGAutoMinSizeTest.cpp b/tests/generated/YGAutoMinSizeTest.cpp index 2d77a8d48a..c9443ddba5 100644 --- a/tests/generated/YGAutoMinSizeTest.cpp +++ b/tests/generated/YGAutoMinSizeTest.cpp @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. * * clang-format off - * @generated SignedSource<<3dca6ee37b123e37612a36b22d03137d>> + * @generated SignedSource<<1bd9552d4b810b704a32f89fbb17afad>> * generated by gentest/src/GentestDriver.ts from gentest/fixtures/YGAutoMinSizeTest.html */ @@ -2079,7 +2079,6 @@ TEST(YogaTest, auto_min_size_wrapping_column_counts_all_children) { TEST(YogaTest, auto_min_size_text_keeps_wrapped_lines) { YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); YGConfigSetErrata(config, YGErrataNone); YGNodeRef root = YGNodeNewWithConfig(config); @@ -2137,7 +2136,6 @@ TEST(YogaTest, auto_min_size_text_keeps_wrapped_lines) { TEST(YogaTest, auto_min_size_nested_text_keeps_wrapped_lines) { YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); YGConfigSetErrata(config, YGErrataNone); YGNodeRef root = YGNodeNewWithConfig(config); @@ -2209,7 +2207,6 @@ TEST(YogaTest, auto_min_size_nested_text_keeps_wrapped_lines) { TEST(YogaTest, auto_min_size_text_wraps_inside_margin_and_padding) { YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); YGConfigSetErrata(config, YGErrataNone); YGNodeRef root = YGNodeNewWithConfig(config); @@ -2271,7 +2268,6 @@ TEST(YogaTest, auto_min_size_text_wraps_inside_margin_and_padding) { TEST(YogaTest, auto_min_size_text_wraps_at_stated_width) { YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); YGConfigSetErrata(config, YGErrataNone); YGNodeRef root = YGNodeNewWithConfig(config); @@ -2332,7 +2328,6 @@ TEST(YogaTest, auto_min_size_text_wraps_at_stated_width) { TEST(YogaTest, auto_min_size_text_wraps_at_stated_content_box_width) { YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); YGConfigSetErrata(config, YGErrataNone); YGNodeRef root = YGNodeNewWithConfig(config); @@ -2394,7 +2389,6 @@ TEST(YogaTest, auto_min_size_text_wraps_at_stated_content_box_width) { TEST(YogaTest, auto_min_size_text_wraps_inside_padded_parent) { YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); YGConfigSetErrata(config, YGErrataNone); YGNodeRef root = YGNodeNewWithConfig(config); @@ -2467,7 +2461,6 @@ TEST(YogaTest, auto_min_size_text_wraps_inside_padded_parent) { TEST(YogaTest, auto_min_size_percent_margin_resolves_against_parent_content_width) { YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); YGConfigSetErrata(config, YGErrataNone); YGNodeRef root = YGNodeNewWithConfig(config); @@ -2539,7 +2532,6 @@ TEST(YogaTest, auto_min_size_percent_margin_resolves_against_parent_content_widt TEST(YogaTest, auto_min_size_text_fits_wider_parent) { YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); YGConfigSetErrata(config, YGErrataNone); YGNodeRef root = YGNodeNewWithConfig(config); @@ -2624,7 +2616,6 @@ TEST(YogaTest, auto_min_size_text_fits_wider_parent) { TEST(YogaTest, auto_min_size_text_fits_min_width) { YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); YGConfigSetErrata(config, YGErrataNone); YGNodeRef root = YGNodeNewWithConfig(config); @@ -2683,7 +2674,6 @@ TEST(YogaTest, auto_min_size_text_fits_min_width) { TEST(YogaTest, auto_min_size_text_wraps_at_max_width) { YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); YGConfigSetErrata(config, YGErrataNone); YGNodeRef root = YGNodeNewWithConfig(config); @@ -2742,7 +2732,6 @@ TEST(YogaTest, auto_min_size_text_wraps_at_max_width) { TEST(YogaTest, auto_min_size_text_below_row_wraps_at_max_width) { YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); YGConfigSetErrata(config, YGErrataNone); YGNodeRef root = YGNodeNewWithConfig(config); @@ -2815,7 +2804,6 @@ TEST(YogaTest, auto_min_size_text_below_row_wraps_at_max_width) { TEST(YogaTest, auto_min_size_text_below_row_is_not_wrapped) { YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); YGConfigSetErrata(config, YGErrataNone); YGNodeRef root = YGNodeNewWithConfig(config); @@ -2927,7 +2915,6 @@ TEST(YogaTest, auto_min_size_text_below_row_is_not_wrapped) { TEST(YogaTest, auto_min_size_text_in_wrapping_column_keeps_wrapped_lines) { YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureMinContentHeightAtGivenWidth, true); YGConfigSetErrata(config, YGErrataNone); YGNodeRef root = YGNodeNewWithConfig(config); diff --git a/yoga/YGEnums.cpp b/yoga/YGEnums.cpp index 800b1ea800..8cde14f010 100644 --- a/yoga/YGEnums.cpp +++ b/yoga/YGEnums.cpp @@ -139,8 +139,6 @@ const char* YGExperimentalFeatureToString(const YGExperimentalFeature value) { return "web-flex-basis"; case YGExperimentalFeatureFixFlexBasisFitContent: return "fix-flex-basis-fit-content"; - case YGExperimentalFeatureMinContentHeightAtGivenWidth: - return "min-content-height-at-given-width"; } return "unknown"; } diff --git a/yoga/YGEnums.h b/yoga/YGEnums.h index ba8600b0cd..052504d9fc 100644 --- a/yoga/YGEnums.h +++ b/yoga/YGEnums.h @@ -78,8 +78,7 @@ YG_DEFINE_ENUM_FLAG_OPERATORS(YGErrata) YG_ENUM_DECL( YGExperimentalFeature, YGExperimentalFeatureWebFlexBasis, - YGExperimentalFeatureFixFlexBasisFitContent, - YGExperimentalFeatureMinContentHeightAtGivenWidth) + YGExperimentalFeatureFixFlexBasisFitContent) YG_ENUM_DECL( YGFlexDirection, diff --git a/yoga/YGNode.h b/yoga/YGNode.h index 89aa72b99d..a28a96381d 100644 --- a/yoga/YGNode.h +++ b/yoga/YGNode.h @@ -225,21 +225,23 @@ YG_EXPORT bool YGNodeHasMeasureFunc(YGNodeConstRef node); * automatic minimum sizing path when probing this node for its min-content * size along the main axis. * - * The signature mirrors `YGMeasureFunc`. The algorithm calls this with - * `AtMost 0` along the probed axis and `Undefined` on the other. With - * `YGExperimentalFeatureMinContentHeightAtGivenWidth`, it probes a height - * with the node's width as an `AtMost` width and an `Undefined` height. A - * min-content-aware Primitive can return its true minimum (e.g., `Image` - * and `Collection` along the scroll axis can return 0; text returns its - * longest-word width; etc.) without doing a full measure pass. + * The signature mirrors `YGMeasureFunc`. The algorithm always passes an + * `Undefined` height. It probes a width with an `AtMost 0` width, and a height + * with the node's content width as an `AtMost` width, or with an `Undefined` + * width when neither the node nor a box above it gives it one, as below a row + * or in a column sized by its content. It reads the width of the result for a + * width probe and the height for a height probe. A min-content-aware Primitive + * can return its true minimum (e.g., `Image` and `Collection` along the scroll + * axis can return 0; text returns its longest-word width, and the height of + * the lines it wraps to at the given width; etc.) without doing a full measure + * pass. * * When unset, the algorithm falls back to the regular `YGMeasureFunc` with * the same arguments. Setting this is a perf opt-in for Primitives whose * min-content size is cheap to compute or differs from what the regular * measure would return. Its results are kept, as a measure function's are, - * until the node is marked dirty. With - * `YGExperimentalFeatureMinContentHeightAtGivenWidth`, a height result is also - * measured again when the width it was measured at changes. + * until the node is marked dirty. A height result is also measured again when + * the content width of the box around the node changes. */ typedef YGSize (*YGMinContentMeasureFunc)( YGNodeConstRef node, @@ -276,7 +278,8 @@ YG_EXPORT bool YGNodeHasMinContentMeasureFunc(YGNodeConstRef node); * Precedence inside the probe is: * 1. Static value via `YGNodeSetMinContentWidth/Height` (this API) * 2. Dynamic callback via `YGNodeSetMinContentMeasureFunc` - * 3. Regular `YGMeasureFunc` with `AtMost 0` (today's default) + * 3. Regular `YGMeasureFunc`, called with the arguments + * `YGMinContentMeasureFunc` receives * 4. Container recursion (sum on main axis, max on cross) * * Static is preferred for known-constant values because it skips the JNI diff --git a/yoga/algorithm/CalculateLayout.cpp b/yoga/algorithm/CalculateLayout.cpp index 5ee9fcc7a1..305e1456cb 100644 --- a/yoga/algorithm/CalculateLayout.cpp +++ b/yoga/algorithm/CalculateLayout.cpp @@ -1069,30 +1069,22 @@ static MinContentSize measureOrWalkMinContentMainSize( // 2. Dynamic min-content callback if set (for Primitives whose // min-content depends on state). Otherwise fall back to the regular // measure function. A width is probed with `AtMost 0`, which text - // measurers naturally answer with longest-word width. A height is probed - // the same way unless `MinContentHeightAtGivenWidth` is on: a text - // measurer answers `AtMost 0` with no height at all, where a min-content + // measurers naturally answer with longest-word width. A min-content // height is the height the content takes at the box's width (css-sizing-3 // §2.1), so the leaf is measured at its width with no limit on its height. - const bool heightAtGivenWidth = !wantRow && - node->getConfig()->isExperimentalFeatureEnabled( - ExperimentalFeature::MinContentHeightAtGivenWidth); - float width = wantRow ? 0.0f : YGUndefined; - if (heightAtGivenWidth) { - width = contentWidthUnderOwner(node, ownerDirection, ownerWidth); - } + const float width = wantRow + ? 0.0f + : contentWidthUnderOwner(node, ownerDirection, ownerWidth); const MeasureMode widthMode = yoga::isDefined(width) ? MeasureMode::AtMost : MeasureMode::Undefined; - const float height = wantRow || heightAtGivenWidth ? YGUndefined : 0.0f; - const MeasureMode heightMode = - yoga::isDefined(height) ? MeasureMode::AtMost : MeasureMode::Undefined; const YGSize size = node->hasMinContentMeasureFunc() - ? node->measureMinContent(width, widthMode, height, heightMode) - : node->measure(width, widthMode, height, heightMode); + ? node->measureMinContent( + width, widthMode, YGUndefined, MeasureMode::Undefined) + : node->measure(width, widthMode, YGUndefined, MeasureMode::Undefined); layout.minContent[axisIndex] = wantRow ? size.width : size.height; layout.minContentOwnerWidth[axisIndex] = ownerWidth; layout.setMinContentResolvesAgainstOwnerWidth( - dimension(requestedAxis), heightAtGivenWidth); + dimension(requestedAxis), !wantRow); layout.minContentGeneration[axisIndex] = generationCount; return leafMinContentSize(node, requestedAxis, ownerDirection, ownerWidth); } @@ -1112,9 +1104,7 @@ static MinContentSize measureOrWalkMinContentMainSize( // which the walk does not know, so they are walked against no width and // their text is as tall as it is unwrapped, the least it can be. float childOwnerWidth = ownerWidth; - if (!wantRow && - node->getConfig()->isExperimentalFeatureEnabled( - ExperimentalFeature::MinContentHeightAtGivenWidth)) { + if (!wantRow) { childOwnerWidth = childrenAddUp ? contentWidthUnderOwner(node, ownerDirection, ownerWidth) : YGUndefined; @@ -1272,10 +1262,12 @@ static MinContentSize computeChildMinContentContribution( // directly into containers rather than going through a measure callback. // // Algorithm: -// * Leaf with measure function: invoke it with `AtMost 0` on the -// requested axis and `Undefined` on the other. Text measure-funcs -// respond with longest-word width; image/collection-like measures -// respond with 0 along their scroll axis. +// * Leaf with measure function: invoke it with no limit on its height, +// and with an `AtMost 0` width when probing a width or the leaf's +// content width when probing a height. Text measure-funcs respond with +// longest-word width and with the height of their wrapped lines; +// image/collection-like measures respond with 0 along their scroll +// axis. // * Empty leaf: return 0. // * Container: iterate in-flow children. For each, take its // min-content contribution along `requestedAxis` plus its margins: @@ -1295,9 +1287,10 @@ static MinContentSize computeChildMinContentContribution( // Results are memoized per node and axis (see `LayoutResults::minContent`) for // as long as the node's cached measurements hold, so a later layout walks only // the subtrees that changed: a leaf's measure callback runs again only once the -// leaf is marked dirty, and a container is walked again for a new `ownerWidth` -// only when its own percentage padding, or a percentage padding or margin -// below it, resolves against it. +// leaf is marked dirty or, for its height, given a new `ownerWidth`, and a +// container is walked again for a new `ownerWidth` only when a percentage +// padding or margin in it or below it resolves against it or, for its height, +// when a measured leaf below it is measured at it. static MinContentSize computeMinContentMainSize( yoga::Node* const node, const FlexDirection requestedAxis, diff --git a/yoga/enums/ExperimentalFeature.h b/yoga/enums/ExperimentalFeature.h index 26328d6abb..7e6c5eb8b6 100644 --- a/yoga/enums/ExperimentalFeature.h +++ b/yoga/enums/ExperimentalFeature.h @@ -18,12 +18,11 @@ namespace facebook::yoga { enum class ExperimentalFeature : uint8_t { WebFlexBasis = YGExperimentalFeatureWebFlexBasis, FixFlexBasisFitContent = YGExperimentalFeatureFixFlexBasisFitContent, - MinContentHeightAtGivenWidth = YGExperimentalFeatureMinContentHeightAtGivenWidth, }; template <> constexpr int32_t ordinalCount() { - return 3; + return 2; } constexpr ExperimentalFeature scopedEnum(YGExperimentalFeature unscoped) {