diff --git a/enums.py b/enums.py index 7fe3732b..b494222a 100755 --- a/enums.py +++ b/enums.py @@ -68,13 +68,11 @@ ENUMS = { # Allows main-axis flex basis to be stretched without flexGrow being # set (previously referred to as "UseLegacyStretchBehaviour") ("StretchFlexBasis", 1 << 0), - # Solely uses the flex-direction to determine starting and ending edges - ("StartingEndingEdgeFromFlexDirection", 1 << 1), # Position: static behaves like position: relative within Yoga - ("PositionStaticBehavesLikeRelative", 1 << 2), + ("PositionStaticBehavesLikeRelative", 1 << 1), # Positioning of absolute nodes will have various bugs related to # justification, alignment, and insets - ("AbsolutePositioning", 1 << 3), + ("AbsolutePositioning", 1 << 2), # Enable all incorrect behavior (preserve compatibility) ("All", 0x7FFFFFFF), # Enable all errata except for "StretchFlexBasis" (Defaults behavior diff --git a/java/com/facebook/yoga/YogaErrata.java b/java/com/facebook/yoga/YogaErrata.java index 04307de4..6e74e640 100644 --- a/java/com/facebook/yoga/YogaErrata.java +++ b/java/com/facebook/yoga/YogaErrata.java @@ -12,9 +12,8 @@ package com.facebook.yoga; public enum YogaErrata { NONE(0), STRETCH_FLEX_BASIS(1), - STARTING_ENDING_EDGE_FROM_FLEX_DIRECTION(2), - POSITION_STATIC_BEHAVES_LIKE_RELATIVE(4), - ABSOLUTE_POSITIONING(8), + POSITION_STATIC_BEHAVES_LIKE_RELATIVE(2), + ABSOLUTE_POSITIONING(4), ALL(2147483647), CLASSIC(2147483646); @@ -32,9 +31,8 @@ public enum YogaErrata { switch (value) { case 0: return NONE; case 1: return STRETCH_FLEX_BASIS; - case 2: return STARTING_ENDING_EDGE_FROM_FLEX_DIRECTION; - case 4: return POSITION_STATIC_BEHAVES_LIKE_RELATIVE; - case 8: return ABSOLUTE_POSITIONING; + case 2: return POSITION_STATIC_BEHAVES_LIKE_RELATIVE; + case 4: return ABSOLUTE_POSITIONING; case 2147483647: return ALL; case 2147483646: return CLASSIC; default: throw new IllegalArgumentException("Unknown enum value: " + value); diff --git a/javascript/src/generated/YGEnums.ts b/javascript/src/generated/YGEnums.ts index 2c7a6a57..e5e7173d 100644 --- a/javascript/src/generated/YGEnums.ts +++ b/javascript/src/generated/YGEnums.ts @@ -50,9 +50,8 @@ export enum Edge { export enum Errata { None = 0, StretchFlexBasis = 1, - StartingEndingEdgeFromFlexDirection = 2, - PositionStaticBehavesLikeRelative = 4, - AbsolutePositioning = 8, + PositionStaticBehavesLikeRelative = 2, + AbsolutePositioning = 4, All = 2147483647, Classic = 2147483646, } @@ -163,7 +162,6 @@ const constants = { EDGE_ALL: Edge.All, ERRATA_NONE: Errata.None, ERRATA_STRETCH_FLEX_BASIS: Errata.StretchFlexBasis, - ERRATA_STARTING_ENDING_EDGE_FROM_FLEX_DIRECTION: Errata.StartingEndingEdgeFromFlexDirection, ERRATA_POSITION_STATIC_BEHAVES_LIKE_RELATIVE: Errata.PositionStaticBehavesLikeRelative, ERRATA_ABSOLUTE_POSITIONING: Errata.AbsolutePositioning, ERRATA_ALL: Errata.All, diff --git a/tests/YGFlexDirectionErrataTest.cpp b/tests/YGFlexDirectionErrataTest.cpp deleted file mode 100644 index 969c5177..00000000 --- a/tests/YGFlexDirectionErrataTest.cpp +++ /dev/null @@ -1,801 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -// clang-format off - -#include -#include - -TEST(YogaTest, flex_direction_row_reverse_margin_start_errata) { - const YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); - YGConfigSetErrata(config, YGErrata::YGErrataStartingEndingEdgeFromFlexDirection); - - const YGNodeRef root = YGNodeNewWithConfig(config); - YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse); - YGNodeStyleSetMargin(root, YGEdgeStart, 100); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); - - const YGNodeRef root_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeInsertChild(root, root_child0, 0); - - const YGNodeRef root_child1 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child1, 10); - YGNodeInsertChild(root, root_child1, 1); - - const YGNodeRef root_child2 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child2, 10); - YGNodeInsertChild(root, root_child2, 2); - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - - ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - - YGNodeFreeRecursive(root); - - YGConfigFree(config); -} - -TEST(YogaTest, flex_direction_row_reverse_margin_end_errata) { - const YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); - YGConfigSetErrata(config, YGErrata::YGErrataStartingEndingEdgeFromFlexDirection); - - const YGNodeRef root = YGNodeNewWithConfig(config); - YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse); - YGNodeStyleSetMargin(root, YGEdgeEnd, 100); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); - - const YGNodeRef root_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeInsertChild(root, root_child0, 0); - - const YGNodeRef root_child1 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child1, 10); - YGNodeInsertChild(root, root_child1, 1); - - const YGNodeRef root_child2 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child2, 10); - YGNodeInsertChild(root, root_child2, 2); - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - - ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - - YGNodeFreeRecursive(root); - - YGConfigFree(config); -} - -TEST(YogaTest, flex_direction_row_reverse_border_start_errata) { - const YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); - YGConfigSetErrata(config, YGErrata::YGErrataStartingEndingEdgeFromFlexDirection); - - const YGNodeRef root = YGNodeNewWithConfig(config); - YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse); - YGNodeStyleSetBorder(root, YGEdgeStart, 100); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); - - const YGNodeRef root_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeInsertChild(root, root_child0, 0); - - const YGNodeRef root_child1 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child1, 10); - YGNodeInsertChild(root, root_child1, 1); - - const YGNodeRef root_child2 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child2, 10); - YGNodeInsertChild(root, root_child2, 2); - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - - ASSERT_FLOAT_EQ(-30, YGNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(110, YGNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - - ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - - YGNodeFreeRecursive(root); - - YGConfigFree(config); -} - -TEST(YogaTest, flex_direction_row_reverse_border_end_errata) { - const YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); - YGConfigSetErrata(config, YGErrata::YGErrataStartingEndingEdgeFromFlexDirection); - - const YGNodeRef root = YGNodeNewWithConfig(config); - YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse); - YGNodeStyleSetBorder(root, YGEdgeEnd, 100); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); - - const YGNodeRef root_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeInsertChild(root, root_child0, 0); - - const YGNodeRef root_child1 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child1, 10); - YGNodeInsertChild(root, root_child1, 1); - - const YGNodeRef root_child2 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child2, 10); - YGNodeInsertChild(root, root_child2, 2); - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - - ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - - YGNodeFreeRecursive(root); - - YGConfigFree(config); -} - -TEST(YogaTest, flex_direction_row_reverse_padding_start_errata) { - const YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); - YGConfigSetErrata(config, YGErrata::YGErrataStartingEndingEdgeFromFlexDirection); - - const YGNodeRef root = YGNodeNewWithConfig(config); - YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse); - YGNodeStyleSetPadding(root, YGEdgeStart, 100); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); - - const YGNodeRef root_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeInsertChild(root, root_child0, 0); - - const YGNodeRef root_child1 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child1, 10); - YGNodeInsertChild(root, root_child1, 1); - - const YGNodeRef root_child2 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child2, 10); - YGNodeInsertChild(root, root_child2, 2); - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(-10, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(-20, YGNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - - ASSERT_FLOAT_EQ(-30, YGNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(110, YGNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - - ASSERT_FLOAT_EQ(120, YGNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - - YGNodeFreeRecursive(root); - - YGConfigFree(config); -} - -TEST(YogaTest, flex_direction_row_reverse_padding_end_errata) { - const YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); - YGConfigSetErrata(config, YGErrata::YGErrataStartingEndingEdgeFromFlexDirection); - - const YGNodeRef root = YGNodeNewWithConfig(config); - YGNodeStyleSetFlexDirection(root, YGFlexDirectionRowReverse); - YGNodeStyleSetPadding(root, YGEdgeEnd, 100); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); - - const YGNodeRef root_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child0, 10); - YGNodeInsertChild(root, root_child0, 0); - - const YGNodeRef root_child1 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child1, 10); - YGNodeInsertChild(root, root_child1, 1); - - const YGNodeRef root_child2 = YGNodeNewWithConfig(config); - YGNodeStyleSetWidth(root_child2, 10); - YGNodeInsertChild(root, root_child2, 2); - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - - ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child1)); - - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child2)); - - YGNodeFreeRecursive(root); - - YGConfigFree(config); -} - -TEST(YogaTest, flex_direction_row_reverse_pos_left_errata) { - const YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); - YGConfigSetErrata(config, YGErrata::YGErrataStartingEndingEdgeFromFlexDirection); - - const YGNodeRef root = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); - - const YGNodeRef root_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); - YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); - YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 100); - YGNodeStyleSetWidth(root_child0, 100); - YGNodeStyleSetHeight(root_child0, 100); - YGNodeInsertChild(root, root_child0, 0); - - const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeRelative); - YGNodeStyleSetWidth(root_child0_child0, 10); - YGNodeInsertChild(root_child0, root_child0_child0, 0); - - const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); - YGNodeStyleSetWidth(root_child0_child1, 10); - YGNodeInsertChild(root_child0, root_child0_child1, 1); - - const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); - YGNodeStyleSetWidth(root_child0_child2, 10); - YGNodeInsertChild(root_child0, root_child0_child2, 2); - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(-100, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0)); - - ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); - - ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child0_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); - - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(-100, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0)); - - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); - - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); - - YGNodeFreeRecursive(root); - - YGConfigFree(config); -} - -TEST(YogaTest, flex_direction_row_reverse_pos_right_errata) { - const YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); - YGConfigSetErrata(config, YGErrata::YGErrataStartingEndingEdgeFromFlexDirection); - - const YGNodeRef root = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); - - const YGNodeRef root_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); - YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRowReverse); - YGNodeStyleSetPosition(root_child0, YGEdgeRight, 100); - YGNodeStyleSetWidth(root_child0, 100); - YGNodeStyleSetHeight(root_child0, 100); - YGNodeInsertChild(root, root_child0, 0); - - const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeRelative); - YGNodeStyleSetWidth(root_child0_child0, 10); - YGNodeInsertChild(root_child0, root_child0_child0, 0); - - const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); - YGNodeStyleSetWidth(root_child0_child1, 10); - YGNodeInsertChild(root_child0, root_child0_child1, 1); - - const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); - YGNodeStyleSetWidth(root_child0_child2, 10); - YGNodeInsertChild(root_child0, root_child0_child2, 2); - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0)); - - ASSERT_FLOAT_EQ(80, YGNodeLayoutGetLeft(root_child0_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); - - ASSERT_FLOAT_EQ(70, YGNodeLayoutGetLeft(root_child0_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); - - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0)); - - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetLeft(root_child0_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1)); - - ASSERT_FLOAT_EQ(20, YGNodeLayoutGetLeft(root_child0_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child2)); - - YGNodeFreeRecursive(root); - - YGConfigFree(config); -} - -TEST(YogaTest, flex_direction_column_reverse_pos_top_errata) { - const YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); - YGConfigSetErrata(config, YGErrata::YGErrataStartingEndingEdgeFromFlexDirection); - - const YGNodeRef root = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); - - const YGNodeRef root_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); - YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionColumnReverse); - YGNodeStyleSetPosition(root_child0, YGEdgeTop, 100); - YGNodeStyleSetWidth(root_child0, 100); - YGNodeStyleSetHeight(root_child0, 100); - YGNodeInsertChild(root, root_child0, 0); - - const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeRelative); - YGNodeStyleSetWidth(root_child0_child0, 10); - YGNodeInsertChild(root_child0, root_child0_child0, 0); - - const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); - YGNodeStyleSetWidth(root_child0_child1, 10); - YGNodeInsertChild(root_child0, root_child0_child1, 1); - - const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); - YGNodeStyleSetWidth(root_child0_child2, 10); - YGNodeInsertChild(root_child0, root_child0_child2, 2); - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(-100, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); - - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(-100, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); - - ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); - - ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); - - YGNodeFreeRecursive(root); - - YGConfigFree(config); -} - -TEST(YogaTest, flex_direction_column_reverse_pos_bottom_errata) { - const YGConfigRef config = YGConfigNew(); - YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true); - YGConfigSetErrata(config, YGErrata::YGErrataStartingEndingEdgeFromFlexDirection); - - const YGNodeRef root = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute); - YGNodeStyleSetWidth(root, 100); - YGNodeStyleSetHeight(root, 100); - - const YGNodeRef root_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0, YGPositionTypeRelative); - YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionColumnReverse); - YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 100); - YGNodeStyleSetWidth(root_child0, 100); - YGNodeStyleSetHeight(root_child0, 100); - YGNodeInsertChild(root, root_child0, 0); - - const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeRelative); - YGNodeStyleSetWidth(root_child0_child0, 10); - YGNodeInsertChild(root_child0, root_child0_child0, 0); - - const YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeRelative); - YGNodeStyleSetWidth(root_child0_child1, 10); - YGNodeInsertChild(root_child0, root_child0_child1, 1); - - const YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config); - YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeRelative); - YGNodeStyleSetWidth(root_child0_child2, 10); - YGNodeInsertChild(root_child0, root_child0_child2, 2); - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); - - YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root)); - - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0)); - - ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child0)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child0)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child0)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child0)); - - ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child1)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child1)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child1)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child1)); - - ASSERT_FLOAT_EQ(90, YGNodeLayoutGetLeft(root_child0_child2)); - ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2)); - ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0_child2)); - ASSERT_FLOAT_EQ(0, YGNodeLayoutGetHeight(root_child0_child2)); - - YGNodeFreeRecursive(root); - - YGConfigFree(config); -} diff --git a/yoga/YGEnums.cpp b/yoga/YGEnums.cpp index d14db83c..fcc4e9af 100644 --- a/yoga/YGEnums.cpp +++ b/yoga/YGEnums.cpp @@ -95,8 +95,6 @@ const char* YGErrataToString(const YGErrata value) { return "none"; case YGErrataStretchFlexBasis: return "stretch-flex-basis"; - case YGErrataStartingEndingEdgeFromFlexDirection: - return "starting-ending-edge-from-flex-direction"; case YGErrataPositionStaticBehavesLikeRelative: return "position-static-behaves-like-relative"; case YGErrataAbsolutePositioning: diff --git a/yoga/YGEnums.h b/yoga/YGEnums.h index e6076dec..658744aa 100644 --- a/yoga/YGEnums.h +++ b/yoga/YGEnums.h @@ -56,9 +56,8 @@ YG_ENUM_DECL( YGErrata, YGErrataNone = 0, YGErrataStretchFlexBasis = 1, - YGErrataStartingEndingEdgeFromFlexDirection = 2, - YGErrataPositionStaticBehavesLikeRelative = 4, - YGErrataAbsolutePositioning = 8, + YGErrataPositionStaticBehavesLikeRelative = 2, + YGErrataAbsolutePositioning = 4, YGErrataAll = 2147483647, YGErrataClassic = 2147483646) YG_DEFINE_ENUM_FLAG_OPERATORS(YGErrata) diff --git a/yoga/algorithm/CalculateLayout.cpp b/yoga/algorithm/CalculateLayout.cpp index 6cf29621..9e181d5b 100644 --- a/yoga/algorithm/CalculateLayout.cpp +++ b/yoga/algorithm/CalculateLayout.cpp @@ -920,13 +920,9 @@ static void justifyMainAxis( const auto& style = node->getStyle(); const float leadingPaddingAndBorderMain = - node->hasErrata(Errata::StartingEndingEdgeFromFlexDirection) - ? node->getInlineStartPaddingAndBorder(mainAxis, direction, ownerWidth) - : node->getFlexStartPaddingAndBorder(mainAxis, direction, ownerWidth); + node->getFlexStartPaddingAndBorder(mainAxis, direction, ownerWidth); const float trailingPaddingAndBorderMain = - node->hasErrata(Errata::StartingEndingEdgeFromFlexDirection) - ? node->getInlineEndPaddingAndBorder(mainAxis, direction, ownerWidth) - : node->getFlexEndPaddingAndBorder(mainAxis, direction, ownerWidth); + node->getFlexEndPaddingAndBorder(mainAxis, direction, ownerWidth); const float gap = node->getGapForAxis(mainAxis); // If we are using "at most" rules in the main axis, make sure that diff --git a/yoga/enums/Errata.h b/yoga/enums/Errata.h index e97b66c3..e919d541 100644 --- a/yoga/enums/Errata.h +++ b/yoga/enums/Errata.h @@ -18,7 +18,6 @@ namespace facebook::yoga { enum class Errata : uint32_t { None = YGErrataNone, StretchFlexBasis = YGErrataStretchFlexBasis, - StartingEndingEdgeFromFlexDirection = YGErrataStartingEndingEdgeFromFlexDirection, PositionStaticBehavesLikeRelative = YGErrataPositionStaticBehavesLikeRelative, AbsolutePositioning = YGErrataAbsolutePositioning, All = YGErrataAll, diff --git a/yoga/node/Node.cpp b/yoga/node/Node.cpp index 1c838408..b8be2ca8 100644 --- a/yoga/node/Node.cpp +++ b/yoga/node/Node.cpp @@ -81,44 +81,33 @@ Style::Length Node::computeEdgeValueForColumn(Edge edge) const { } } -Edge Node::getInlineStartEdgeUsingErrata( - FlexDirection flexDirection, - Direction direction) const { - return hasErrata(Errata::StartingEndingEdgeFromFlexDirection) - ? flexStartEdge(flexDirection) - : inlineStartEdge(flexDirection, direction); +Edge Node::getInlineStartEdge(FlexDirection flexDirection, Direction direction) + const { + return inlineStartEdge(flexDirection, direction); } -Edge Node::getInlineEndEdgeUsingErrata( - FlexDirection flexDirection, - Direction direction) const { - return hasErrata(Errata::StartingEndingEdgeFromFlexDirection) - ? flexEndEdge(flexDirection) - : inlineEndEdge(flexDirection, direction); +Edge Node::getInlineEndEdge(FlexDirection flexDirection, Direction direction) + const { + return inlineEndEdge(flexDirection, direction); } -Edge Node::getFlexStartRelativeEdgeUsingErrata( +Edge Node::getFlexStartRelativeEdge( FlexDirection flexDirection, Direction direction) const { - return hasErrata(Errata::StartingEndingEdgeFromFlexDirection) - ? Edge::Start - : flexStartRelativeEdge(flexDirection, direction); + return flexStartRelativeEdge(flexDirection, direction); } -Edge Node::getFlexEndRelativeEdgeUsingErrata( +Edge Node::getFlexEndRelativeEdge( FlexDirection flexDirection, Direction direction) const { - return hasErrata(Errata::StartingEndingEdgeFromFlexDirection) - ? Edge::End - : flexEndRelativeEdge(flexDirection, direction); + return flexEndRelativeEdge(flexDirection, direction); } bool Node::isFlexStartPositionDefined(FlexDirection axis, Direction direction) const { auto leadingPosition = isRow(axis) ? computeEdgeValueForRow<&Style::position>( - getFlexStartRelativeEdgeUsingErrata(axis, direction), - flexStartEdge(axis)) + getFlexStartRelativeEdge(axis, direction), flexStartEdge(axis)) : computeEdgeValueForColumn<&Style::position>(flexStartEdge(axis)); return leadingPosition.isDefined(); @@ -126,7 +115,7 @@ bool Node::isFlexStartPositionDefined(FlexDirection axis, Direction direction) bool Node::isInlineStartPositionDefined(FlexDirection axis, Direction direction) const { - Edge startEdge = getInlineStartEdgeUsingErrata(axis, direction); + Edge startEdge = getInlineStartEdge(axis, direction); Style::Length leadingPosition = isRow(axis) ? computeEdgeValueForRow<&Style::position>(Edge::Start, startEdge) : computeEdgeValueForColumn<&Style::position>(startEdge); @@ -138,8 +127,7 @@ bool Node::isFlexEndPositionDefined(FlexDirection axis, Direction direction) const { auto trailingPosition = isRow(axis) ? computeEdgeValueForRow<&Style::position>( - getFlexEndRelativeEdgeUsingErrata(axis, direction), - flexEndEdge(axis)) + getFlexEndRelativeEdge(axis, direction), flexEndEdge(axis)) : computeEdgeValueForColumn<&Style::position>(flexEndEdge(axis)); return !trailingPosition.isUndefined(); @@ -147,7 +135,7 @@ bool Node::isFlexEndPositionDefined(FlexDirection axis, Direction direction) bool Node::isInlineEndPositionDefined(FlexDirection axis, Direction direction) const { - Edge endEdge = getInlineEndEdgeUsingErrata(axis, direction); + Edge endEdge = getInlineEndEdge(axis, direction); Style::Length trailingPosition = isRow(axis) ? computeEdgeValueForRow<&Style::position>(Edge::End, endEdge) : computeEdgeValueForColumn<&Style::position>(endEdge); @@ -161,8 +149,7 @@ float Node::getFlexStartPosition( float axisSize) const { auto leadingPosition = isRow(axis) ? computeEdgeValueForRow<&Style::position>( - getFlexStartRelativeEdgeUsingErrata(axis, direction), - flexStartEdge(axis)) + getFlexStartRelativeEdge(axis, direction), flexStartEdge(axis)) : computeEdgeValueForColumn<&Style::position>(flexStartEdge(axis)); return leadingPosition.resolve(axisSize).unwrapOrDefault(0.0f); @@ -172,7 +159,7 @@ float Node::getInlineStartPosition( FlexDirection axis, Direction direction, float axisSize) const { - Edge startEdge = getInlineStartEdgeUsingErrata(axis, direction); + Edge startEdge = getInlineStartEdge(axis, direction); Style::Length leadingPosition = isRow(axis) ? computeEdgeValueForRow<&Style::position>(Edge::Start, startEdge) : computeEdgeValueForColumn<&Style::position>(startEdge); @@ -186,8 +173,7 @@ float Node::getFlexEndPosition( float axisSize) const { auto trailingPosition = isRow(axis) ? computeEdgeValueForRow<&Style::position>( - getFlexEndRelativeEdgeUsingErrata(axis, direction), - flexEndEdge(axis)) + getFlexEndRelativeEdge(axis, direction), flexEndEdge(axis)) : computeEdgeValueForColumn<&Style::position>(flexEndEdge(axis)); return trailingPosition.resolve(axisSize).unwrapOrDefault(0.0f); @@ -197,7 +183,7 @@ float Node::getInlineEndPosition( FlexDirection axis, Direction direction, float axisSize) const { - Edge endEdge = getInlineEndEdgeUsingErrata(axis, direction); + Edge endEdge = getInlineEndEdge(axis, direction); Style::Length trailingPosition = isRow(axis) ? computeEdgeValueForRow<&Style::position>(Edge::End, endEdge) : computeEdgeValueForColumn<&Style::position>(endEdge); @@ -211,8 +197,7 @@ float Node::getFlexStartMargin( float widthSize) const { auto leadingMargin = isRow(axis) ? computeEdgeValueForRow<&Style::margin>( - getFlexStartRelativeEdgeUsingErrata(axis, direction), - flexStartEdge(axis)) + getFlexStartRelativeEdge(axis, direction), flexStartEdge(axis)) : computeEdgeValueForColumn<&Style::margin>(flexStartEdge(axis)); return leadingMargin.resolve(widthSize).unwrapOrDefault(0.0f); @@ -222,7 +207,7 @@ float Node::getInlineStartMargin( FlexDirection axis, Direction direction, float widthSize) const { - Edge startEdge = getInlineStartEdgeUsingErrata(axis, direction); + Edge startEdge = getInlineStartEdge(axis, direction); Style::Length leadingMargin = isRow(axis) ? computeEdgeValueForRow<&Style::margin>(Edge::Start, startEdge) : computeEdgeValueForColumn<&Style::margin>(startEdge); @@ -236,8 +221,7 @@ float Node::getFlexEndMargin( float widthSize) const { auto trailingMargin = isRow(axis) ? computeEdgeValueForRow<&Style::margin>( - getFlexEndRelativeEdgeUsingErrata(axis, direction), - flexEndEdge(axis)) + getFlexEndRelativeEdge(axis, direction), flexEndEdge(axis)) : computeEdgeValueForColumn<&Style::margin>(flexEndEdge(axis)); return trailingMargin.resolve(widthSize).unwrapOrDefault(0.0f); @@ -247,7 +231,7 @@ float Node::getInlineEndMargin( FlexDirection axis, Direction direction, float widthSize) const { - Edge endEdge = getInlineEndEdgeUsingErrata(axis, direction); + Edge endEdge = getInlineEndEdge(axis, direction); Style::Length trailingMargin = isRow(axis) ? computeEdgeValueForRow<&Style::margin>(Edge::End, endEdge) : computeEdgeValueForColumn<&Style::margin>(endEdge); @@ -257,7 +241,7 @@ float Node::getInlineEndMargin( float Node::getInlineStartBorder(FlexDirection axis, Direction direction) const { - Edge startEdge = getInlineStartEdgeUsingErrata(axis, direction); + Edge startEdge = getInlineStartEdge(axis, direction); Style::Length leadingBorder = isRow(axis) ? computeEdgeValueForRow<&Style::border>(Edge::Start, startEdge) : computeEdgeValueForColumn<&Style::border>(startEdge); @@ -268,15 +252,14 @@ float Node::getInlineStartBorder(FlexDirection axis, Direction direction) float Node::getFlexStartBorder(FlexDirection axis, Direction direction) const { Style::Length leadingBorder = isRow(axis) ? computeEdgeValueForRow<&Style::border>( - getFlexStartRelativeEdgeUsingErrata(axis, direction), - flexStartEdge(axis)) + getFlexStartRelativeEdge(axis, direction), flexStartEdge(axis)) : computeEdgeValueForColumn<&Style::border>(flexStartEdge(axis)); return maxOrDefined(leadingBorder.value().unwrap(), 0.0f); } float Node::getInlineEndBorder(FlexDirection axis, Direction direction) const { - Edge endEdge = getInlineEndEdgeUsingErrata(axis, direction); + Edge endEdge = getInlineEndEdge(axis, direction); Style::Length trailingBorder = isRow(axis) ? computeEdgeValueForRow<&Style::border>(Edge::End, endEdge) : computeEdgeValueForColumn<&Style::border>(endEdge); @@ -287,8 +270,7 @@ float Node::getInlineEndBorder(FlexDirection axis, Direction direction) const { float Node::getFlexEndBorder(FlexDirection axis, Direction direction) const { Style::Length trailingBorder = isRow(axis) ? computeEdgeValueForRow<&Style::border>( - getFlexEndRelativeEdgeUsingErrata(axis, direction), - flexEndEdge(axis)) + getFlexEndRelativeEdge(axis, direction), flexEndEdge(axis)) : computeEdgeValueForColumn<&Style::border>(flexEndEdge(axis)); return maxOrDefined(trailingBorder.value().unwrap(), 0.0f); @@ -298,7 +280,7 @@ float Node::getInlineStartPadding( FlexDirection axis, Direction direction, float widthSize) const { - Edge startEdge = getInlineStartEdgeUsingErrata(axis, direction); + Edge startEdge = getInlineStartEdge(axis, direction); Style::Length leadingPadding = isRow(axis) ? computeEdgeValueForRow<&Style::padding>(Edge::Start, startEdge) : computeEdgeValueForColumn<&Style::padding>(startEdge); @@ -312,8 +294,7 @@ float Node::getFlexStartPadding( float widthSize) const { auto leadingPadding = isRow(axis) ? computeEdgeValueForRow<&Style::padding>( - getFlexStartRelativeEdgeUsingErrata(axis, direction), - flexStartEdge(axis)) + getFlexStartRelativeEdge(axis, direction), flexStartEdge(axis)) : computeEdgeValueForColumn<&Style::padding>(flexStartEdge(axis)); return maxOrDefined(leadingPadding.resolve(widthSize).unwrap(), 0.0f); @@ -323,7 +304,7 @@ float Node::getInlineEndPadding( FlexDirection axis, Direction direction, float widthSize) const { - Edge endEdge = getInlineEndEdgeUsingErrata(axis, direction); + Edge endEdge = getInlineEndEdge(axis, direction); Style::Length trailingPadding = isRow(axis) ? computeEdgeValueForRow<&Style::padding>(Edge::End, endEdge) : computeEdgeValueForColumn<&Style::padding>(endEdge); @@ -337,8 +318,7 @@ float Node::getFlexEndPadding( float widthSize) const { auto trailingPadding = isRow(axis) ? computeEdgeValueForRow<&Style::padding>( - getFlexEndRelativeEdgeUsingErrata(axis, direction), - flexEndEdge(axis)) + getFlexEndRelativeEdge(axis, direction), flexEndEdge(axis)) : computeEdgeValueForColumn<&Style::padding>(flexEndEdge(axis)); return maxOrDefined(trailingPadding.resolve(widthSize).unwrap(), 0.0f); @@ -578,14 +558,10 @@ void Node::setPosition( const float relativePositionCross = relativePosition(crossAxis, directionRespectingRoot, crossSize); - const Edge mainAxisLeadingEdge = - getInlineStartEdgeUsingErrata(mainAxis, direction); - const Edge mainAxisTrailingEdge = - getInlineEndEdgeUsingErrata(mainAxis, direction); - const Edge crossAxisLeadingEdge = - getInlineStartEdgeUsingErrata(crossAxis, direction); - const Edge crossAxisTrailingEdge = - getInlineEndEdgeUsingErrata(crossAxis, direction); + const Edge mainAxisLeadingEdge = getInlineStartEdge(mainAxis, direction); + const Edge mainAxisTrailingEdge = getInlineEndEdge(mainAxis, direction); + const Edge crossAxisLeadingEdge = getInlineStartEdge(crossAxis, direction); + const Edge crossAxisTrailingEdge = getInlineEndEdge(crossAxis, direction); setLayoutPosition( (getInlineStartMargin(mainAxis, direction, ownerWidth) + diff --git a/yoga/node/Node.h b/yoga/node/Node.h index b1971a69..18e4ae67 100644 --- a/yoga/node/Node.h +++ b/yoga/node/Node.h @@ -350,18 +350,14 @@ class YG_EXPORT Node : public ::YGNode { Direction direction, const float axisSize) const; - Edge getInlineStartEdgeUsingErrata( - FlexDirection flexDirection, - Direction direction) const; - Edge getInlineEndEdgeUsingErrata( - FlexDirection flexDirection, - Direction direction) const; - Edge getFlexStartRelativeEdgeUsingErrata( - FlexDirection flexDirection, - Direction direction) const; - Edge getFlexEndRelativeEdgeUsingErrata( + Edge getInlineStartEdge(FlexDirection flexDirection, Direction direction) + const; + Edge getInlineEndEdge(FlexDirection flexDirection, Direction direction) const; + Edge getFlexStartRelativeEdge( FlexDirection flexDirection, Direction direction) const; + Edge getFlexEndRelativeEdge(FlexDirection flexDirection, Direction direction) + const; void useWebDefaults() { style_.setFlexDirection(FlexDirection::Row);