Remove row-reverse errata (#1547)

Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1547

X-link: https://github.com/facebook/react-native/pull/42251

Yoga has an odd behavior, where `start`/`end` edges under row-reverse are relative to flex-direction, instead of writing direction.

While Yoga doesn't actually document what this behavior is supposed to be, it goes against CK documentation, historic RN documentation, and the behavior valid on the web. It is also applied inconsistently (e.g. sometimes only on container, sometimes on child). It really is a bug, instead of an intended behavior.

We changed the default behavior for Yoga, but left the existing one behind an errata (so existing fbsource users got old behavior). We have previously seen this behavior show up in product code, including CK when running on FlexLayout.

`row-reverse` is surprisingly uncommon though:
1. Litho has <40 usages
2. RN has ~40 usages in `RKJSModules`,~30 in `arvr/js`, ~6 in `xplat/archon`
3. CK has ~80 usages
4. NT has ~40 usages

There are few enough, mostly simple components, that we can inspect through each of them, looking for signs they will hit the issue (at the potential chance of missing some).

CK accounts for 10/14 usages that I could tell would trigger the issue, since it only exposes start/end edge, and not left/right. It might make sense to make it preserve behavior instead, to reduce risk a bit.

FlexLayout is now separately powering Bloks, which wasn't surveyed, so I didn't touch CK behavior under Bloks.

There could also be other usages in other frameworks/bespoke usages, and this has implications for OSS users. But based on our own usage, of many, many components, this seems rare.

Changelog:
[General][Breaking] - Make `start/end` in styles always refer to writing direction

Reviewed By: pentiumao, joevilches

Differential Revision: D52698130

fbshipit-source-id: 2a9ac47e177469f30dc988d916b6c0ad95d53461
This commit is contained in:
Nick Gerleman
2024-01-12 13:49:53 -08:00
committed by Facebook GitHub Bot
parent 7e70656e46
commit 8c3e01166b
10 changed files with 52 additions and 895 deletions

View File

@@ -68,13 +68,11 @@ ENUMS = {
# Allows main-axis flex basis to be stretched without flexGrow being # Allows main-axis flex basis to be stretched without flexGrow being
# set (previously referred to as "UseLegacyStretchBehaviour") # set (previously referred to as "UseLegacyStretchBehaviour")
("StretchFlexBasis", 1 << 0), ("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 # Position: static behaves like position: relative within Yoga
("PositionStaticBehavesLikeRelative", 1 << 2), ("PositionStaticBehavesLikeRelative", 1 << 1),
# Positioning of absolute nodes will have various bugs related to # Positioning of absolute nodes will have various bugs related to
# justification, alignment, and insets # justification, alignment, and insets
("AbsolutePositioning", 1 << 3), ("AbsolutePositioning", 1 << 2),
# Enable all incorrect behavior (preserve compatibility) # Enable all incorrect behavior (preserve compatibility)
("All", 0x7FFFFFFF), ("All", 0x7FFFFFFF),
# Enable all errata except for "StretchFlexBasis" (Defaults behavior # Enable all errata except for "StretchFlexBasis" (Defaults behavior

View File

@@ -12,9 +12,8 @@ package com.facebook.yoga;
public enum YogaErrata { public enum YogaErrata {
NONE(0), NONE(0),
STRETCH_FLEX_BASIS(1), STRETCH_FLEX_BASIS(1),
STARTING_ENDING_EDGE_FROM_FLEX_DIRECTION(2), POSITION_STATIC_BEHAVES_LIKE_RELATIVE(2),
POSITION_STATIC_BEHAVES_LIKE_RELATIVE(4), ABSOLUTE_POSITIONING(4),
ABSOLUTE_POSITIONING(8),
ALL(2147483647), ALL(2147483647),
CLASSIC(2147483646); CLASSIC(2147483646);
@@ -32,9 +31,8 @@ public enum YogaErrata {
switch (value) { switch (value) {
case 0: return NONE; case 0: return NONE;
case 1: return STRETCH_FLEX_BASIS; case 1: return STRETCH_FLEX_BASIS;
case 2: return STARTING_ENDING_EDGE_FROM_FLEX_DIRECTION; case 2: return POSITION_STATIC_BEHAVES_LIKE_RELATIVE;
case 4: return POSITION_STATIC_BEHAVES_LIKE_RELATIVE; case 4: return ABSOLUTE_POSITIONING;
case 8: return ABSOLUTE_POSITIONING;
case 2147483647: return ALL; case 2147483647: return ALL;
case 2147483646: return CLASSIC; case 2147483646: return CLASSIC;
default: throw new IllegalArgumentException("Unknown enum value: " + value); default: throw new IllegalArgumentException("Unknown enum value: " + value);

View File

@@ -50,9 +50,8 @@ export enum Edge {
export enum Errata { export enum Errata {
None = 0, None = 0,
StretchFlexBasis = 1, StretchFlexBasis = 1,
StartingEndingEdgeFromFlexDirection = 2, PositionStaticBehavesLikeRelative = 2,
PositionStaticBehavesLikeRelative = 4, AbsolutePositioning = 4,
AbsolutePositioning = 8,
All = 2147483647, All = 2147483647,
Classic = 2147483646, Classic = 2147483646,
} }
@@ -163,7 +162,6 @@ const constants = {
EDGE_ALL: Edge.All, EDGE_ALL: Edge.All,
ERRATA_NONE: Errata.None, ERRATA_NONE: Errata.None,
ERRATA_STRETCH_FLEX_BASIS: Errata.StretchFlexBasis, ERRATA_STRETCH_FLEX_BASIS: Errata.StretchFlexBasis,
ERRATA_STARTING_ENDING_EDGE_FROM_FLEX_DIRECTION: Errata.StartingEndingEdgeFromFlexDirection,
ERRATA_POSITION_STATIC_BEHAVES_LIKE_RELATIVE: Errata.PositionStaticBehavesLikeRelative, ERRATA_POSITION_STATIC_BEHAVES_LIKE_RELATIVE: Errata.PositionStaticBehavesLikeRelative,
ERRATA_ABSOLUTE_POSITIONING: Errata.AbsolutePositioning, ERRATA_ABSOLUTE_POSITIONING: Errata.AbsolutePositioning,
ERRATA_ALL: Errata.All, ERRATA_ALL: Errata.All,

View File

@@ -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 <gtest/gtest.h>
#include <yoga/Yoga.h>
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);
}

View File

@@ -95,8 +95,6 @@ const char* YGErrataToString(const YGErrata value) {
return "none"; return "none";
case YGErrataStretchFlexBasis: case YGErrataStretchFlexBasis:
return "stretch-flex-basis"; return "stretch-flex-basis";
case YGErrataStartingEndingEdgeFromFlexDirection:
return "starting-ending-edge-from-flex-direction";
case YGErrataPositionStaticBehavesLikeRelative: case YGErrataPositionStaticBehavesLikeRelative:
return "position-static-behaves-like-relative"; return "position-static-behaves-like-relative";
case YGErrataAbsolutePositioning: case YGErrataAbsolutePositioning:

View File

@@ -56,9 +56,8 @@ YG_ENUM_DECL(
YGErrata, YGErrata,
YGErrataNone = 0, YGErrataNone = 0,
YGErrataStretchFlexBasis = 1, YGErrataStretchFlexBasis = 1,
YGErrataStartingEndingEdgeFromFlexDirection = 2, YGErrataPositionStaticBehavesLikeRelative = 2,
YGErrataPositionStaticBehavesLikeRelative = 4, YGErrataAbsolutePositioning = 4,
YGErrataAbsolutePositioning = 8,
YGErrataAll = 2147483647, YGErrataAll = 2147483647,
YGErrataClassic = 2147483646) YGErrataClassic = 2147483646)
YG_DEFINE_ENUM_FLAG_OPERATORS(YGErrata) YG_DEFINE_ENUM_FLAG_OPERATORS(YGErrata)

View File

@@ -920,13 +920,9 @@ static void justifyMainAxis(
const auto& style = node->getStyle(); const auto& style = node->getStyle();
const float leadingPaddingAndBorderMain = const float leadingPaddingAndBorderMain =
node->hasErrata(Errata::StartingEndingEdgeFromFlexDirection) node->getFlexStartPaddingAndBorder(mainAxis, direction, ownerWidth);
? node->getInlineStartPaddingAndBorder(mainAxis, direction, ownerWidth)
: node->getFlexStartPaddingAndBorder(mainAxis, direction, ownerWidth);
const float trailingPaddingAndBorderMain = const float trailingPaddingAndBorderMain =
node->hasErrata(Errata::StartingEndingEdgeFromFlexDirection) node->getFlexEndPaddingAndBorder(mainAxis, direction, ownerWidth);
? node->getInlineEndPaddingAndBorder(mainAxis, direction, ownerWidth)
: node->getFlexEndPaddingAndBorder(mainAxis, direction, ownerWidth);
const float gap = node->getGapForAxis(mainAxis); const float gap = node->getGapForAxis(mainAxis);
// If we are using "at most" rules in the main axis, make sure that // If we are using "at most" rules in the main axis, make sure that

View File

@@ -18,7 +18,6 @@ namespace facebook::yoga {
enum class Errata : uint32_t { enum class Errata : uint32_t {
None = YGErrataNone, None = YGErrataNone,
StretchFlexBasis = YGErrataStretchFlexBasis, StretchFlexBasis = YGErrataStretchFlexBasis,
StartingEndingEdgeFromFlexDirection = YGErrataStartingEndingEdgeFromFlexDirection,
PositionStaticBehavesLikeRelative = YGErrataPositionStaticBehavesLikeRelative, PositionStaticBehavesLikeRelative = YGErrataPositionStaticBehavesLikeRelative,
AbsolutePositioning = YGErrataAbsolutePositioning, AbsolutePositioning = YGErrataAbsolutePositioning,
All = YGErrataAll, All = YGErrataAll,

View File

@@ -81,44 +81,33 @@ Style::Length Node::computeEdgeValueForColumn(Edge edge) const {
} }
} }
Edge Node::getInlineStartEdgeUsingErrata( Edge Node::getInlineStartEdge(FlexDirection flexDirection, Direction direction)
FlexDirection flexDirection, const {
Direction direction) const { return inlineStartEdge(flexDirection, direction);
return hasErrata(Errata::StartingEndingEdgeFromFlexDirection)
? flexStartEdge(flexDirection)
: inlineStartEdge(flexDirection, direction);
} }
Edge Node::getInlineEndEdgeUsingErrata( Edge Node::getInlineEndEdge(FlexDirection flexDirection, Direction direction)
FlexDirection flexDirection, const {
Direction direction) const { return inlineEndEdge(flexDirection, direction);
return hasErrata(Errata::StartingEndingEdgeFromFlexDirection)
? flexEndEdge(flexDirection)
: inlineEndEdge(flexDirection, direction);
} }
Edge Node::getFlexStartRelativeEdgeUsingErrata( Edge Node::getFlexStartRelativeEdge(
FlexDirection flexDirection, FlexDirection flexDirection,
Direction direction) const { Direction direction) const {
return hasErrata(Errata::StartingEndingEdgeFromFlexDirection) return flexStartRelativeEdge(flexDirection, direction);
? Edge::Start
: flexStartRelativeEdge(flexDirection, direction);
} }
Edge Node::getFlexEndRelativeEdgeUsingErrata( Edge Node::getFlexEndRelativeEdge(
FlexDirection flexDirection, FlexDirection flexDirection,
Direction direction) const { Direction direction) const {
return hasErrata(Errata::StartingEndingEdgeFromFlexDirection) return flexEndRelativeEdge(flexDirection, direction);
? Edge::End
: flexEndRelativeEdge(flexDirection, direction);
} }
bool Node::isFlexStartPositionDefined(FlexDirection axis, Direction direction) bool Node::isFlexStartPositionDefined(FlexDirection axis, Direction direction)
const { const {
auto leadingPosition = isRow(axis) auto leadingPosition = isRow(axis)
? computeEdgeValueForRow<&Style::position>( ? computeEdgeValueForRow<&Style::position>(
getFlexStartRelativeEdgeUsingErrata(axis, direction), getFlexStartRelativeEdge(axis, direction), flexStartEdge(axis))
flexStartEdge(axis))
: computeEdgeValueForColumn<&Style::position>(flexStartEdge(axis)); : computeEdgeValueForColumn<&Style::position>(flexStartEdge(axis));
return leadingPosition.isDefined(); return leadingPosition.isDefined();
@@ -126,7 +115,7 @@ bool Node::isFlexStartPositionDefined(FlexDirection axis, Direction direction)
bool Node::isInlineStartPositionDefined(FlexDirection axis, Direction direction) bool Node::isInlineStartPositionDefined(FlexDirection axis, Direction direction)
const { const {
Edge startEdge = getInlineStartEdgeUsingErrata(axis, direction); Edge startEdge = getInlineStartEdge(axis, direction);
Style::Length leadingPosition = isRow(axis) Style::Length leadingPosition = isRow(axis)
? computeEdgeValueForRow<&Style::position>(Edge::Start, startEdge) ? computeEdgeValueForRow<&Style::position>(Edge::Start, startEdge)
: computeEdgeValueForColumn<&Style::position>(startEdge); : computeEdgeValueForColumn<&Style::position>(startEdge);
@@ -138,8 +127,7 @@ bool Node::isFlexEndPositionDefined(FlexDirection axis, Direction direction)
const { const {
auto trailingPosition = isRow(axis) auto trailingPosition = isRow(axis)
? computeEdgeValueForRow<&Style::position>( ? computeEdgeValueForRow<&Style::position>(
getFlexEndRelativeEdgeUsingErrata(axis, direction), getFlexEndRelativeEdge(axis, direction), flexEndEdge(axis))
flexEndEdge(axis))
: computeEdgeValueForColumn<&Style::position>(flexEndEdge(axis)); : computeEdgeValueForColumn<&Style::position>(flexEndEdge(axis));
return !trailingPosition.isUndefined(); return !trailingPosition.isUndefined();
@@ -147,7 +135,7 @@ bool Node::isFlexEndPositionDefined(FlexDirection axis, Direction direction)
bool Node::isInlineEndPositionDefined(FlexDirection axis, Direction direction) bool Node::isInlineEndPositionDefined(FlexDirection axis, Direction direction)
const { const {
Edge endEdge = getInlineEndEdgeUsingErrata(axis, direction); Edge endEdge = getInlineEndEdge(axis, direction);
Style::Length trailingPosition = isRow(axis) Style::Length trailingPosition = isRow(axis)
? computeEdgeValueForRow<&Style::position>(Edge::End, endEdge) ? computeEdgeValueForRow<&Style::position>(Edge::End, endEdge)
: computeEdgeValueForColumn<&Style::position>(endEdge); : computeEdgeValueForColumn<&Style::position>(endEdge);
@@ -161,8 +149,7 @@ float Node::getFlexStartPosition(
float axisSize) const { float axisSize) const {
auto leadingPosition = isRow(axis) auto leadingPosition = isRow(axis)
? computeEdgeValueForRow<&Style::position>( ? computeEdgeValueForRow<&Style::position>(
getFlexStartRelativeEdgeUsingErrata(axis, direction), getFlexStartRelativeEdge(axis, direction), flexStartEdge(axis))
flexStartEdge(axis))
: computeEdgeValueForColumn<&Style::position>(flexStartEdge(axis)); : computeEdgeValueForColumn<&Style::position>(flexStartEdge(axis));
return leadingPosition.resolve(axisSize).unwrapOrDefault(0.0f); return leadingPosition.resolve(axisSize).unwrapOrDefault(0.0f);
@@ -172,7 +159,7 @@ float Node::getInlineStartPosition(
FlexDirection axis, FlexDirection axis,
Direction direction, Direction direction,
float axisSize) const { float axisSize) const {
Edge startEdge = getInlineStartEdgeUsingErrata(axis, direction); Edge startEdge = getInlineStartEdge(axis, direction);
Style::Length leadingPosition = isRow(axis) Style::Length leadingPosition = isRow(axis)
? computeEdgeValueForRow<&Style::position>(Edge::Start, startEdge) ? computeEdgeValueForRow<&Style::position>(Edge::Start, startEdge)
: computeEdgeValueForColumn<&Style::position>(startEdge); : computeEdgeValueForColumn<&Style::position>(startEdge);
@@ -186,8 +173,7 @@ float Node::getFlexEndPosition(
float axisSize) const { float axisSize) const {
auto trailingPosition = isRow(axis) auto trailingPosition = isRow(axis)
? computeEdgeValueForRow<&Style::position>( ? computeEdgeValueForRow<&Style::position>(
getFlexEndRelativeEdgeUsingErrata(axis, direction), getFlexEndRelativeEdge(axis, direction), flexEndEdge(axis))
flexEndEdge(axis))
: computeEdgeValueForColumn<&Style::position>(flexEndEdge(axis)); : computeEdgeValueForColumn<&Style::position>(flexEndEdge(axis));
return trailingPosition.resolve(axisSize).unwrapOrDefault(0.0f); return trailingPosition.resolve(axisSize).unwrapOrDefault(0.0f);
@@ -197,7 +183,7 @@ float Node::getInlineEndPosition(
FlexDirection axis, FlexDirection axis,
Direction direction, Direction direction,
float axisSize) const { float axisSize) const {
Edge endEdge = getInlineEndEdgeUsingErrata(axis, direction); Edge endEdge = getInlineEndEdge(axis, direction);
Style::Length trailingPosition = isRow(axis) Style::Length trailingPosition = isRow(axis)
? computeEdgeValueForRow<&Style::position>(Edge::End, endEdge) ? computeEdgeValueForRow<&Style::position>(Edge::End, endEdge)
: computeEdgeValueForColumn<&Style::position>(endEdge); : computeEdgeValueForColumn<&Style::position>(endEdge);
@@ -211,8 +197,7 @@ float Node::getFlexStartMargin(
float widthSize) const { float widthSize) const {
auto leadingMargin = isRow(axis) auto leadingMargin = isRow(axis)
? computeEdgeValueForRow<&Style::margin>( ? computeEdgeValueForRow<&Style::margin>(
getFlexStartRelativeEdgeUsingErrata(axis, direction), getFlexStartRelativeEdge(axis, direction), flexStartEdge(axis))
flexStartEdge(axis))
: computeEdgeValueForColumn<&Style::margin>(flexStartEdge(axis)); : computeEdgeValueForColumn<&Style::margin>(flexStartEdge(axis));
return leadingMargin.resolve(widthSize).unwrapOrDefault(0.0f); return leadingMargin.resolve(widthSize).unwrapOrDefault(0.0f);
@@ -222,7 +207,7 @@ float Node::getInlineStartMargin(
FlexDirection axis, FlexDirection axis,
Direction direction, Direction direction,
float widthSize) const { float widthSize) const {
Edge startEdge = getInlineStartEdgeUsingErrata(axis, direction); Edge startEdge = getInlineStartEdge(axis, direction);
Style::Length leadingMargin = isRow(axis) Style::Length leadingMargin = isRow(axis)
? computeEdgeValueForRow<&Style::margin>(Edge::Start, startEdge) ? computeEdgeValueForRow<&Style::margin>(Edge::Start, startEdge)
: computeEdgeValueForColumn<&Style::margin>(startEdge); : computeEdgeValueForColumn<&Style::margin>(startEdge);
@@ -236,8 +221,7 @@ float Node::getFlexEndMargin(
float widthSize) const { float widthSize) const {
auto trailingMargin = isRow(axis) auto trailingMargin = isRow(axis)
? computeEdgeValueForRow<&Style::margin>( ? computeEdgeValueForRow<&Style::margin>(
getFlexEndRelativeEdgeUsingErrata(axis, direction), getFlexEndRelativeEdge(axis, direction), flexEndEdge(axis))
flexEndEdge(axis))
: computeEdgeValueForColumn<&Style::margin>(flexEndEdge(axis)); : computeEdgeValueForColumn<&Style::margin>(flexEndEdge(axis));
return trailingMargin.resolve(widthSize).unwrapOrDefault(0.0f); return trailingMargin.resolve(widthSize).unwrapOrDefault(0.0f);
@@ -247,7 +231,7 @@ float Node::getInlineEndMargin(
FlexDirection axis, FlexDirection axis,
Direction direction, Direction direction,
float widthSize) const { float widthSize) const {
Edge endEdge = getInlineEndEdgeUsingErrata(axis, direction); Edge endEdge = getInlineEndEdge(axis, direction);
Style::Length trailingMargin = isRow(axis) Style::Length trailingMargin = isRow(axis)
? computeEdgeValueForRow<&Style::margin>(Edge::End, endEdge) ? computeEdgeValueForRow<&Style::margin>(Edge::End, endEdge)
: computeEdgeValueForColumn<&Style::margin>(endEdge); : computeEdgeValueForColumn<&Style::margin>(endEdge);
@@ -257,7 +241,7 @@ float Node::getInlineEndMargin(
float Node::getInlineStartBorder(FlexDirection axis, Direction direction) float Node::getInlineStartBorder(FlexDirection axis, Direction direction)
const { const {
Edge startEdge = getInlineStartEdgeUsingErrata(axis, direction); Edge startEdge = getInlineStartEdge(axis, direction);
Style::Length leadingBorder = isRow(axis) Style::Length leadingBorder = isRow(axis)
? computeEdgeValueForRow<&Style::border>(Edge::Start, startEdge) ? computeEdgeValueForRow<&Style::border>(Edge::Start, startEdge)
: computeEdgeValueForColumn<&Style::border>(startEdge); : computeEdgeValueForColumn<&Style::border>(startEdge);
@@ -268,15 +252,14 @@ float Node::getInlineStartBorder(FlexDirection axis, Direction direction)
float Node::getFlexStartBorder(FlexDirection axis, Direction direction) const { float Node::getFlexStartBorder(FlexDirection axis, Direction direction) const {
Style::Length leadingBorder = isRow(axis) Style::Length leadingBorder = isRow(axis)
? computeEdgeValueForRow<&Style::border>( ? computeEdgeValueForRow<&Style::border>(
getFlexStartRelativeEdgeUsingErrata(axis, direction), getFlexStartRelativeEdge(axis, direction), flexStartEdge(axis))
flexStartEdge(axis))
: computeEdgeValueForColumn<&Style::border>(flexStartEdge(axis)); : computeEdgeValueForColumn<&Style::border>(flexStartEdge(axis));
return maxOrDefined(leadingBorder.value().unwrap(), 0.0f); return maxOrDefined(leadingBorder.value().unwrap(), 0.0f);
} }
float Node::getInlineEndBorder(FlexDirection axis, Direction direction) const { float Node::getInlineEndBorder(FlexDirection axis, Direction direction) const {
Edge endEdge = getInlineEndEdgeUsingErrata(axis, direction); Edge endEdge = getInlineEndEdge(axis, direction);
Style::Length trailingBorder = isRow(axis) Style::Length trailingBorder = isRow(axis)
? computeEdgeValueForRow<&Style::border>(Edge::End, endEdge) ? computeEdgeValueForRow<&Style::border>(Edge::End, endEdge)
: computeEdgeValueForColumn<&Style::border>(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 { float Node::getFlexEndBorder(FlexDirection axis, Direction direction) const {
Style::Length trailingBorder = isRow(axis) Style::Length trailingBorder = isRow(axis)
? computeEdgeValueForRow<&Style::border>( ? computeEdgeValueForRow<&Style::border>(
getFlexEndRelativeEdgeUsingErrata(axis, direction), getFlexEndRelativeEdge(axis, direction), flexEndEdge(axis))
flexEndEdge(axis))
: computeEdgeValueForColumn<&Style::border>(flexEndEdge(axis)); : computeEdgeValueForColumn<&Style::border>(flexEndEdge(axis));
return maxOrDefined(trailingBorder.value().unwrap(), 0.0f); return maxOrDefined(trailingBorder.value().unwrap(), 0.0f);
@@ -298,7 +280,7 @@ float Node::getInlineStartPadding(
FlexDirection axis, FlexDirection axis,
Direction direction, Direction direction,
float widthSize) const { float widthSize) const {
Edge startEdge = getInlineStartEdgeUsingErrata(axis, direction); Edge startEdge = getInlineStartEdge(axis, direction);
Style::Length leadingPadding = isRow(axis) Style::Length leadingPadding = isRow(axis)
? computeEdgeValueForRow<&Style::padding>(Edge::Start, startEdge) ? computeEdgeValueForRow<&Style::padding>(Edge::Start, startEdge)
: computeEdgeValueForColumn<&Style::padding>(startEdge); : computeEdgeValueForColumn<&Style::padding>(startEdge);
@@ -312,8 +294,7 @@ float Node::getFlexStartPadding(
float widthSize) const { float widthSize) const {
auto leadingPadding = isRow(axis) auto leadingPadding = isRow(axis)
? computeEdgeValueForRow<&Style::padding>( ? computeEdgeValueForRow<&Style::padding>(
getFlexStartRelativeEdgeUsingErrata(axis, direction), getFlexStartRelativeEdge(axis, direction), flexStartEdge(axis))
flexStartEdge(axis))
: computeEdgeValueForColumn<&Style::padding>(flexStartEdge(axis)); : computeEdgeValueForColumn<&Style::padding>(flexStartEdge(axis));
return maxOrDefined(leadingPadding.resolve(widthSize).unwrap(), 0.0f); return maxOrDefined(leadingPadding.resolve(widthSize).unwrap(), 0.0f);
@@ -323,7 +304,7 @@ float Node::getInlineEndPadding(
FlexDirection axis, FlexDirection axis,
Direction direction, Direction direction,
float widthSize) const { float widthSize) const {
Edge endEdge = getInlineEndEdgeUsingErrata(axis, direction); Edge endEdge = getInlineEndEdge(axis, direction);
Style::Length trailingPadding = isRow(axis) Style::Length trailingPadding = isRow(axis)
? computeEdgeValueForRow<&Style::padding>(Edge::End, endEdge) ? computeEdgeValueForRow<&Style::padding>(Edge::End, endEdge)
: computeEdgeValueForColumn<&Style::padding>(endEdge); : computeEdgeValueForColumn<&Style::padding>(endEdge);
@@ -337,8 +318,7 @@ float Node::getFlexEndPadding(
float widthSize) const { float widthSize) const {
auto trailingPadding = isRow(axis) auto trailingPadding = isRow(axis)
? computeEdgeValueForRow<&Style::padding>( ? computeEdgeValueForRow<&Style::padding>(
getFlexEndRelativeEdgeUsingErrata(axis, direction), getFlexEndRelativeEdge(axis, direction), flexEndEdge(axis))
flexEndEdge(axis))
: computeEdgeValueForColumn<&Style::padding>(flexEndEdge(axis)); : computeEdgeValueForColumn<&Style::padding>(flexEndEdge(axis));
return maxOrDefined(trailingPadding.resolve(widthSize).unwrap(), 0.0f); return maxOrDefined(trailingPadding.resolve(widthSize).unwrap(), 0.0f);
@@ -578,14 +558,10 @@ void Node::setPosition(
const float relativePositionCross = const float relativePositionCross =
relativePosition(crossAxis, directionRespectingRoot, crossSize); relativePosition(crossAxis, directionRespectingRoot, crossSize);
const Edge mainAxisLeadingEdge = const Edge mainAxisLeadingEdge = getInlineStartEdge(mainAxis, direction);
getInlineStartEdgeUsingErrata(mainAxis, direction); const Edge mainAxisTrailingEdge = getInlineEndEdge(mainAxis, direction);
const Edge mainAxisTrailingEdge = const Edge crossAxisLeadingEdge = getInlineStartEdge(crossAxis, direction);
getInlineEndEdgeUsingErrata(mainAxis, direction); const Edge crossAxisTrailingEdge = getInlineEndEdge(crossAxis, direction);
const Edge crossAxisLeadingEdge =
getInlineStartEdgeUsingErrata(crossAxis, direction);
const Edge crossAxisTrailingEdge =
getInlineEndEdgeUsingErrata(crossAxis, direction);
setLayoutPosition( setLayoutPosition(
(getInlineStartMargin(mainAxis, direction, ownerWidth) + (getInlineStartMargin(mainAxis, direction, ownerWidth) +

View File

@@ -350,18 +350,14 @@ class YG_EXPORT Node : public ::YGNode {
Direction direction, Direction direction,
const float axisSize) const; const float axisSize) const;
Edge getInlineStartEdgeUsingErrata( Edge getInlineStartEdge(FlexDirection flexDirection, Direction direction)
FlexDirection flexDirection, const;
Direction direction) const; Edge getInlineEndEdge(FlexDirection flexDirection, Direction direction) const;
Edge getInlineEndEdgeUsingErrata( Edge getFlexStartRelativeEdge(
FlexDirection flexDirection,
Direction direction) const;
Edge getFlexStartRelativeEdgeUsingErrata(
FlexDirection flexDirection,
Direction direction) const;
Edge getFlexEndRelativeEdgeUsingErrata(
FlexDirection flexDirection, FlexDirection flexDirection,
Direction direction) const; Direction direction) const;
Edge getFlexEndRelativeEdge(FlexDirection flexDirection, Direction direction)
const;
void useWebDefaults() { void useWebDefaults() {
style_.setFlexDirection(FlexDirection::Row); style_.setFlexDirection(FlexDirection::Row);