Fix bug where we used border box for size of containing block in a certain case (#1486)

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

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

Somehow missed this case. We never want to measure the CB as that gets border box but we want padding box

Reviewed By: NickGerleman

Differential Revision: D51376309

fbshipit-source-id: 2b5119c421ef92fadb28a70254cb7fe02aeb8c28
This commit is contained in:
Joe Vilches
2023-12-07 21:25:45 -08:00
committed by Facebook GitHub Bot
parent d1dda2185e
commit f8d048bb1a
5 changed files with 820 additions and 4 deletions

View File

@@ -475,3 +475,31 @@
</div> </div>
</div> </div>
</div> </div>
<div id="static_position_no_definite_size_amalgamation">
<div style="position: relative; margin: 5px 9px 1px 4px; border-width: 6px 7px 8px 5px; padding: 9px 11px 13px 2px">
<div
style="position: static; margin: 6px 3px 9px 8px; border-width: 10px 2px 1px 8px; padding: 7px 9px 4px 1px">
<div
style="position: absolute; left: 23%; margin: 12px 4px 7px 9px; border-width: 1px 5px 9px 2px; padding: 3px 8px 10px 5px">
<div
style="width: 100px; height: 50px; position: relative; margin: 12px 4px 7px 9px; border-width: 1px 5px 9px 2px; padding: 3px 8px 10px 5px">
</div>
</div>
</div>
</div>
</div>
<div id="static_position_both_insets_set_amalgamation">
<div style="position: relative; margin: 5px 9px 1px 4px; border-width: 6px 7px 8px 5px; padding: 9px 11px 13px 2px">
<div
style="position: static; margin: 6px 3px 9px 8px; border-width: 10px 2px 1px 8px; padding: 7px 9px 4px 1px">
<div
style="position: absolute; left: 23%; right: 13px; margin: 12px 4px 7px 9px; border-width: 1px 5px 9px 2px; padding: 3px 8px 10px 5px">
<div
style="width: 100px; height: 50px; position: relative; margin: 12px 4px 7px 9px; border-width: 1px 5px 9px 2px; padding: 3px 8px 10px 5px">
</div>
</div>
</div>
</div>
</div>

View File

@@ -4003,6 +4003,265 @@ public class YGStaticPositionTest {
assertEquals(50f, root_child0_child0_child2_child0.getLayoutHeight(), 0.0f); assertEquals(50f, root_child0_child0_child2_child0.getLayoutHeight(), 0.0f);
} }
@Test
public void test_static_position_no_definite_size_amalgamation() {
YogaConfig config = YogaConfigFactory.create();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.LEFT, 4f);
root_child0.setMargin(YogaEdge.TOP, 5f);
root_child0.setMargin(YogaEdge.RIGHT, 9f);
root_child0.setMargin(YogaEdge.BOTTOM, 1f);
root_child0.setPadding(YogaEdge.LEFT, 2);
root_child0.setPadding(YogaEdge.TOP, 9);
root_child0.setPadding(YogaEdge.RIGHT, 11);
root_child0.setPadding(YogaEdge.BOTTOM, 13);
root_child0.setBorder(YogaEdge.LEFT, 5f);
root_child0.setBorder(YogaEdge.TOP, 6f);
root_child0.setBorder(YogaEdge.RIGHT, 7f);
root_child0.setBorder(YogaEdge.BOTTOM, 8f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setPositionType(YogaPositionType.STATIC);
root_child0_child0.setMargin(YogaEdge.LEFT, 8f);
root_child0_child0.setMargin(YogaEdge.TOP, 6f);
root_child0_child0.setMargin(YogaEdge.RIGHT, 3f);
root_child0_child0.setMargin(YogaEdge.BOTTOM, 9f);
root_child0_child0.setPadding(YogaEdge.LEFT, 1);
root_child0_child0.setPadding(YogaEdge.TOP, 7);
root_child0_child0.setPadding(YogaEdge.RIGHT, 9);
root_child0_child0.setPadding(YogaEdge.BOTTOM, 4);
root_child0_child0.setBorder(YogaEdge.LEFT, 8f);
root_child0_child0.setBorder(YogaEdge.TOP, 10f);
root_child0_child0.setBorder(YogaEdge.RIGHT, 2f);
root_child0_child0.setBorder(YogaEdge.BOTTOM, 1f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child0_child0 = createNode(config);
root_child0_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0_child0_child0.setPositionPercent(YogaEdge.LEFT, 23f);
root_child0_child0_child0.setMargin(YogaEdge.LEFT, 9f);
root_child0_child0_child0.setMargin(YogaEdge.TOP, 12f);
root_child0_child0_child0.setMargin(YogaEdge.RIGHT, 4f);
root_child0_child0_child0.setMargin(YogaEdge.BOTTOM, 7f);
root_child0_child0_child0.setPadding(YogaEdge.LEFT, 5);
root_child0_child0_child0.setPadding(YogaEdge.TOP, 3);
root_child0_child0_child0.setPadding(YogaEdge.RIGHT, 8);
root_child0_child0_child0.setPadding(YogaEdge.BOTTOM, 10);
root_child0_child0_child0.setBorder(YogaEdge.LEFT, 2f);
root_child0_child0_child0.setBorder(YogaEdge.TOP, 1f);
root_child0_child0_child0.setBorder(YogaEdge.RIGHT, 5f);
root_child0_child0_child0.setBorder(YogaEdge.BOTTOM, 9f);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
final YogaNode root_child0_child0_child0_child0 = createNode(config);
root_child0_child0_child0_child0.setMargin(YogaEdge.LEFT, 9f);
root_child0_child0_child0_child0.setMargin(YogaEdge.TOP, 12f);
root_child0_child0_child0_child0.setMargin(YogaEdge.RIGHT, 4f);
root_child0_child0_child0_child0.setMargin(YogaEdge.BOTTOM, 7f);
root_child0_child0_child0_child0.setPadding(YogaEdge.LEFT, 5);
root_child0_child0_child0_child0.setPadding(YogaEdge.TOP, 3);
root_child0_child0_child0_child0.setPadding(YogaEdge.RIGHT, 8);
root_child0_child0_child0_child0.setPadding(YogaEdge.BOTTOM, 10);
root_child0_child0_child0_child0.setBorder(YogaEdge.LEFT, 2f);
root_child0_child0_child0_child0.setBorder(YogaEdge.TOP, 1f);
root_child0_child0_child0_child0.setBorder(YogaEdge.RIGHT, 5f);
root_child0_child0_child0_child0.setBorder(YogaEdge.BOTTOM, 9f);
root_child0_child0_child0_child0.setWidth(100f);
root_child0_child0_child0_child0.setHeight(50f);
root_child0_child0_child0.addChildAt(root_child0_child0_child0_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(69f, root.getLayoutWidth(), 0.0f);
assertEquals(79f, root.getLayoutHeight(), 0.0f);
assertEquals(4f, root_child0.getLayoutX(), 0.0f);
assertEquals(5f, root_child0.getLayoutY(), 0.0f);
assertEquals(56f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(73f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(15f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(21f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(22f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(9f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(29f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(133f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(92f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(16f, root_child0_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(16f, root_child0_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child0_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(69f, root.getLayoutWidth(), 0.0f);
assertEquals(79f, root.getLayoutHeight(), 0.0f);
assertEquals(4f, root_child0.getLayoutX(), 0.0f);
assertEquals(5f, root_child0.getLayoutY(), 0.0f);
assertEquals(56f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(73f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(15f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(21f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(22f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(9f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(29f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(133f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(92f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(16f, root_child0_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(16f, root_child0_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child0_child0_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_static_position_both_insets_set_amalgamation() {
YogaConfig config = YogaConfigFactory.create();
config.setExperimentalFeatureEnabled(YogaExperimentalFeature.ABSOLUTE_PERCENTAGE_AGAINST_PADDING_EDGE, true);
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
final YogaNode root_child0 = createNode(config);
root_child0.setMargin(YogaEdge.LEFT, 4f);
root_child0.setMargin(YogaEdge.TOP, 5f);
root_child0.setMargin(YogaEdge.RIGHT, 9f);
root_child0.setMargin(YogaEdge.BOTTOM, 1f);
root_child0.setPadding(YogaEdge.LEFT, 2);
root_child0.setPadding(YogaEdge.TOP, 9);
root_child0.setPadding(YogaEdge.RIGHT, 11);
root_child0.setPadding(YogaEdge.BOTTOM, 13);
root_child0.setBorder(YogaEdge.LEFT, 5f);
root_child0.setBorder(YogaEdge.TOP, 6f);
root_child0.setBorder(YogaEdge.RIGHT, 7f);
root_child0.setBorder(YogaEdge.BOTTOM, 8f);
root.addChildAt(root_child0, 0);
final YogaNode root_child0_child0 = createNode(config);
root_child0_child0.setPositionType(YogaPositionType.STATIC);
root_child0_child0.setMargin(YogaEdge.LEFT, 8f);
root_child0_child0.setMargin(YogaEdge.TOP, 6f);
root_child0_child0.setMargin(YogaEdge.RIGHT, 3f);
root_child0_child0.setMargin(YogaEdge.BOTTOM, 9f);
root_child0_child0.setPadding(YogaEdge.LEFT, 1);
root_child0_child0.setPadding(YogaEdge.TOP, 7);
root_child0_child0.setPadding(YogaEdge.RIGHT, 9);
root_child0_child0.setPadding(YogaEdge.BOTTOM, 4);
root_child0_child0.setBorder(YogaEdge.LEFT, 8f);
root_child0_child0.setBorder(YogaEdge.TOP, 10f);
root_child0_child0.setBorder(YogaEdge.RIGHT, 2f);
root_child0_child0.setBorder(YogaEdge.BOTTOM, 1f);
root_child0.addChildAt(root_child0_child0, 0);
final YogaNode root_child0_child0_child0 = createNode(config);
root_child0_child0_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0_child0_child0.setPositionPercent(YogaEdge.LEFT, 23f);
root_child0_child0_child0.setPosition(YogaEdge.RIGHT, 13f);
root_child0_child0_child0.setMargin(YogaEdge.LEFT, 9f);
root_child0_child0_child0.setMargin(YogaEdge.TOP, 12f);
root_child0_child0_child0.setMargin(YogaEdge.RIGHT, 4f);
root_child0_child0_child0.setMargin(YogaEdge.BOTTOM, 7f);
root_child0_child0_child0.setPadding(YogaEdge.LEFT, 5);
root_child0_child0_child0.setPadding(YogaEdge.TOP, 3);
root_child0_child0_child0.setPadding(YogaEdge.RIGHT, 8);
root_child0_child0_child0.setPadding(YogaEdge.BOTTOM, 10);
root_child0_child0_child0.setBorder(YogaEdge.LEFT, 2f);
root_child0_child0_child0.setBorder(YogaEdge.TOP, 1f);
root_child0_child0_child0.setBorder(YogaEdge.RIGHT, 5f);
root_child0_child0_child0.setBorder(YogaEdge.BOTTOM, 9f);
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
final YogaNode root_child0_child0_child0_child0 = createNode(config);
root_child0_child0_child0_child0.setMargin(YogaEdge.LEFT, 9f);
root_child0_child0_child0_child0.setMargin(YogaEdge.TOP, 12f);
root_child0_child0_child0_child0.setMargin(YogaEdge.RIGHT, 4f);
root_child0_child0_child0_child0.setMargin(YogaEdge.BOTTOM, 7f);
root_child0_child0_child0_child0.setPadding(YogaEdge.LEFT, 5);
root_child0_child0_child0_child0.setPadding(YogaEdge.TOP, 3);
root_child0_child0_child0_child0.setPadding(YogaEdge.RIGHT, 8);
root_child0_child0_child0_child0.setPadding(YogaEdge.BOTTOM, 10);
root_child0_child0_child0_child0.setBorder(YogaEdge.LEFT, 2f);
root_child0_child0_child0_child0.setBorder(YogaEdge.TOP, 1f);
root_child0_child0_child0_child0.setBorder(YogaEdge.RIGHT, 5f);
root_child0_child0_child0_child0.setBorder(YogaEdge.BOTTOM, 9f);
root_child0_child0_child0_child0.setWidth(100f);
root_child0_child0_child0_child0.setHeight(50f);
root_child0_child0_child0.addChildAt(root_child0_child0_child0_child0, 0);
root.setDirection(YogaDirection.LTR);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(69f, root.getLayoutWidth(), 0.0f);
assertEquals(79f, root.getLayoutHeight(), 0.0f);
assertEquals(4f, root_child0.getLayoutX(), 0.0f);
assertEquals(5f, root_child0.getLayoutY(), 0.0f);
assertEquals(56f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(73f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(15f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(21f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(22f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(9f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(29f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(20f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(92f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(16f, root_child0_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(16f, root_child0_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child0_child0_child0.getLayoutHeight(), 0.0f);
root.setDirection(YogaDirection.RTL);
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
assertEquals(0f, root.getLayoutX(), 0.0f);
assertEquals(0f, root.getLayoutY(), 0.0f);
assertEquals(69f, root.getLayoutWidth(), 0.0f);
assertEquals(79f, root.getLayoutHeight(), 0.0f);
assertEquals(4f, root_child0.getLayoutX(), 0.0f);
assertEquals(5f, root_child0.getLayoutY(), 0.0f);
assertEquals(56f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(73f, root_child0.getLayoutHeight(), 0.0f);
assertEquals(15f, root_child0_child0.getLayoutX(), 0.0f);
assertEquals(21f, root_child0_child0.getLayoutY(), 0.0f);
assertEquals(20f, root_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(22f, root_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(-3f, root_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(29f, root_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(20f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(92f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
assertEquals(-97f, root_child0_child0_child0_child0.getLayoutX(), 0.0f);
assertEquals(16f, root_child0_child0_child0_child0.getLayoutY(), 0.0f);
assertEquals(100f, root_child0_child0_child0_child0.getLayoutWidth(), 0.0f);
assertEquals(50f, root_child0_child0_child0_child0.getLayoutHeight(), 0.0f);
}
private YogaNode createNode(YogaConfig config) { private YogaNode createNode(YogaConfig config) {
return mNodeFactory.create(config); return mNodeFactory.create(config);
} }

View File

@@ -4284,3 +4284,274 @@ test('static_position_justify_flex_start_position_set_amalgamation', () => {
config.free(); config.free();
} }
}); });
test('static_position_no_definite_size_amalgamation', () => {
const config = Yoga.Config.create();
let root;
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
const root_child0 = Yoga.Node.create(config);
root_child0.setMargin(Edge.Left, 4);
root_child0.setMargin(Edge.Top, 5);
root_child0.setMargin(Edge.Right, 9);
root_child0.setMargin(Edge.Bottom, 1);
root_child0.setPadding(Edge.Left, 2);
root_child0.setPadding(Edge.Top, 9);
root_child0.setPadding(Edge.Right, 11);
root_child0.setPadding(Edge.Bottom, 13);
root_child0.setBorder(Edge.Left, 5);
root_child0.setBorder(Edge.Top, 6);
root_child0.setBorder(Edge.Right, 7);
root_child0.setBorder(Edge.Bottom, 8);
root.insertChild(root_child0, 0);
const root_child0_child0 = Yoga.Node.create(config);
root_child0_child0.setPositionType(PositionType.Static);
root_child0_child0.setMargin(Edge.Left, 8);
root_child0_child0.setMargin(Edge.Top, 6);
root_child0_child0.setMargin(Edge.Right, 3);
root_child0_child0.setMargin(Edge.Bottom, 9);
root_child0_child0.setPadding(Edge.Left, 1);
root_child0_child0.setPadding(Edge.Top, 7);
root_child0_child0.setPadding(Edge.Right, 9);
root_child0_child0.setPadding(Edge.Bottom, 4);
root_child0_child0.setBorder(Edge.Left, 8);
root_child0_child0.setBorder(Edge.Top, 10);
root_child0_child0.setBorder(Edge.Right, 2);
root_child0_child0.setBorder(Edge.Bottom, 1);
root_child0.insertChild(root_child0_child0, 0);
const root_child0_child0_child0 = Yoga.Node.create(config);
root_child0_child0_child0.setPositionType(PositionType.Absolute);
root_child0_child0_child0.setPosition(Edge.Left, "23%");
root_child0_child0_child0.setMargin(Edge.Left, 9);
root_child0_child0_child0.setMargin(Edge.Top, 12);
root_child0_child0_child0.setMargin(Edge.Right, 4);
root_child0_child0_child0.setMargin(Edge.Bottom, 7);
root_child0_child0_child0.setPadding(Edge.Left, 5);
root_child0_child0_child0.setPadding(Edge.Top, 3);
root_child0_child0_child0.setPadding(Edge.Right, 8);
root_child0_child0_child0.setPadding(Edge.Bottom, 10);
root_child0_child0_child0.setBorder(Edge.Left, 2);
root_child0_child0_child0.setBorder(Edge.Top, 1);
root_child0_child0_child0.setBorder(Edge.Right, 5);
root_child0_child0_child0.setBorder(Edge.Bottom, 9);
root_child0_child0.insertChild(root_child0_child0_child0, 0);
const root_child0_child0_child0_child0 = Yoga.Node.create(config);
root_child0_child0_child0_child0.setMargin(Edge.Left, 9);
root_child0_child0_child0_child0.setMargin(Edge.Top, 12);
root_child0_child0_child0_child0.setMargin(Edge.Right, 4);
root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7);
root_child0_child0_child0_child0.setPadding(Edge.Left, 5);
root_child0_child0_child0_child0.setPadding(Edge.Top, 3);
root_child0_child0_child0_child0.setPadding(Edge.Right, 8);
root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10);
root_child0_child0_child0_child0.setBorder(Edge.Left, 2);
root_child0_child0_child0_child0.setBorder(Edge.Top, 1);
root_child0_child0_child0_child0.setBorder(Edge.Right, 5);
root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9);
root_child0_child0_child0_child0.setWidth(100);
root_child0_child0_child0_child0.setHeight(50);
root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(69);
expect(root.getComputedHeight()).toBe(79);
expect(root_child0.getComputedLeft()).toBe(4);
expect(root_child0.getComputedTop()).toBe(5);
expect(root_child0.getComputedWidth()).toBe(56);
expect(root_child0.getComputedHeight()).toBe(73);
expect(root_child0_child0.getComputedLeft()).toBe(15);
expect(root_child0_child0.getComputedTop()).toBe(21);
expect(root_child0_child0.getComputedWidth()).toBe(20);
expect(root_child0_child0.getComputedHeight()).toBe(22);
expect(root_child0_child0_child0.getComputedLeft()).toBe(9);
expect(root_child0_child0_child0.getComputedTop()).toBe(29);
expect(root_child0_child0_child0.getComputedWidth()).toBe(133);
expect(root_child0_child0_child0.getComputedHeight()).toBe(92);
expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16);
expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16);
expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100);
expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(69);
expect(root.getComputedHeight()).toBe(79);
expect(root_child0.getComputedLeft()).toBe(4);
expect(root_child0.getComputedTop()).toBe(5);
expect(root_child0.getComputedWidth()).toBe(56);
expect(root_child0.getComputedHeight()).toBe(73);
expect(root_child0_child0.getComputedLeft()).toBe(15);
expect(root_child0_child0.getComputedTop()).toBe(21);
expect(root_child0_child0.getComputedWidth()).toBe(20);
expect(root_child0_child0.getComputedHeight()).toBe(22);
expect(root_child0_child0_child0.getComputedLeft()).toBe(9);
expect(root_child0_child0_child0.getComputedTop()).toBe(29);
expect(root_child0_child0_child0.getComputedWidth()).toBe(133);
expect(root_child0_child0_child0.getComputedHeight()).toBe(92);
expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16);
expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16);
expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100);
expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('static_position_both_insets_set_amalgamation', () => {
const config = Yoga.Config.create();
let root;
config.setExperimentalFeatureEnabled(ExperimentalFeature.AbsolutePercentageAgainstPaddingEdge, true);
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
const root_child0 = Yoga.Node.create(config);
root_child0.setMargin(Edge.Left, 4);
root_child0.setMargin(Edge.Top, 5);
root_child0.setMargin(Edge.Right, 9);
root_child0.setMargin(Edge.Bottom, 1);
root_child0.setPadding(Edge.Left, 2);
root_child0.setPadding(Edge.Top, 9);
root_child0.setPadding(Edge.Right, 11);
root_child0.setPadding(Edge.Bottom, 13);
root_child0.setBorder(Edge.Left, 5);
root_child0.setBorder(Edge.Top, 6);
root_child0.setBorder(Edge.Right, 7);
root_child0.setBorder(Edge.Bottom, 8);
root.insertChild(root_child0, 0);
const root_child0_child0 = Yoga.Node.create(config);
root_child0_child0.setPositionType(PositionType.Static);
root_child0_child0.setMargin(Edge.Left, 8);
root_child0_child0.setMargin(Edge.Top, 6);
root_child0_child0.setMargin(Edge.Right, 3);
root_child0_child0.setMargin(Edge.Bottom, 9);
root_child0_child0.setPadding(Edge.Left, 1);
root_child0_child0.setPadding(Edge.Top, 7);
root_child0_child0.setPadding(Edge.Right, 9);
root_child0_child0.setPadding(Edge.Bottom, 4);
root_child0_child0.setBorder(Edge.Left, 8);
root_child0_child0.setBorder(Edge.Top, 10);
root_child0_child0.setBorder(Edge.Right, 2);
root_child0_child0.setBorder(Edge.Bottom, 1);
root_child0.insertChild(root_child0_child0, 0);
const root_child0_child0_child0 = Yoga.Node.create(config);
root_child0_child0_child0.setPositionType(PositionType.Absolute);
root_child0_child0_child0.setPosition(Edge.Left, "23%");
root_child0_child0_child0.setPosition(Edge.Right, 13);
root_child0_child0_child0.setMargin(Edge.Left, 9);
root_child0_child0_child0.setMargin(Edge.Top, 12);
root_child0_child0_child0.setMargin(Edge.Right, 4);
root_child0_child0_child0.setMargin(Edge.Bottom, 7);
root_child0_child0_child0.setPadding(Edge.Left, 5);
root_child0_child0_child0.setPadding(Edge.Top, 3);
root_child0_child0_child0.setPadding(Edge.Right, 8);
root_child0_child0_child0.setPadding(Edge.Bottom, 10);
root_child0_child0_child0.setBorder(Edge.Left, 2);
root_child0_child0_child0.setBorder(Edge.Top, 1);
root_child0_child0_child0.setBorder(Edge.Right, 5);
root_child0_child0_child0.setBorder(Edge.Bottom, 9);
root_child0_child0.insertChild(root_child0_child0_child0, 0);
const root_child0_child0_child0_child0 = Yoga.Node.create(config);
root_child0_child0_child0_child0.setMargin(Edge.Left, 9);
root_child0_child0_child0_child0.setMargin(Edge.Top, 12);
root_child0_child0_child0_child0.setMargin(Edge.Right, 4);
root_child0_child0_child0_child0.setMargin(Edge.Bottom, 7);
root_child0_child0_child0_child0.setPadding(Edge.Left, 5);
root_child0_child0_child0_child0.setPadding(Edge.Top, 3);
root_child0_child0_child0_child0.setPadding(Edge.Right, 8);
root_child0_child0_child0_child0.setPadding(Edge.Bottom, 10);
root_child0_child0_child0_child0.setBorder(Edge.Left, 2);
root_child0_child0_child0_child0.setBorder(Edge.Top, 1);
root_child0_child0_child0_child0.setBorder(Edge.Right, 5);
root_child0_child0_child0_child0.setBorder(Edge.Bottom, 9);
root_child0_child0_child0_child0.setWidth(100);
root_child0_child0_child0_child0.setHeight(50);
root_child0_child0_child0.insertChild(root_child0_child0_child0_child0, 0);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(69);
expect(root.getComputedHeight()).toBe(79);
expect(root_child0.getComputedLeft()).toBe(4);
expect(root_child0.getComputedTop()).toBe(5);
expect(root_child0.getComputedWidth()).toBe(56);
expect(root_child0.getComputedHeight()).toBe(73);
expect(root_child0_child0.getComputedLeft()).toBe(15);
expect(root_child0_child0.getComputedTop()).toBe(21);
expect(root_child0_child0.getComputedWidth()).toBe(20);
expect(root_child0_child0.getComputedHeight()).toBe(22);
expect(root_child0_child0_child0.getComputedLeft()).toBe(9);
expect(root_child0_child0_child0.getComputedTop()).toBe(29);
expect(root_child0_child0_child0.getComputedWidth()).toBe(20);
expect(root_child0_child0_child0.getComputedHeight()).toBe(92);
expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(16);
expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16);
expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100);
expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(69);
expect(root.getComputedHeight()).toBe(79);
expect(root_child0.getComputedLeft()).toBe(4);
expect(root_child0.getComputedTop()).toBe(5);
expect(root_child0.getComputedWidth()).toBe(56);
expect(root_child0.getComputedHeight()).toBe(73);
expect(root_child0_child0.getComputedLeft()).toBe(15);
expect(root_child0_child0.getComputedTop()).toBe(21);
expect(root_child0_child0.getComputedWidth()).toBe(20);
expect(root_child0_child0.getComputedHeight()).toBe(22);
expect(root_child0_child0_child0.getComputedLeft()).toBe(-3);
expect(root_child0_child0_child0.getComputedTop()).toBe(29);
expect(root_child0_child0_child0.getComputedWidth()).toBe(20);
expect(root_child0_child0_child0.getComputedHeight()).toBe(92);
expect(root_child0_child0_child0_child0.getComputedLeft()).toBe(-97);
expect(root_child0_child0_child0_child0.getComputedTop()).toBe(16);
expect(root_child0_child0_child0_child0.getComputedWidth()).toBe(100);
expect(root_child0_child0_child0_child0.getComputedHeight()).toBe(50);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});

View File

@@ -4036,3 +4036,264 @@ TEST(YogaTest, static_position_justify_flex_start_position_set_amalgamation) {
YGConfigFree(config); YGConfigFree(config);
} }
TEST(YogaTest, static_position_no_definite_size_amalgamation) {
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 4);
YGNodeStyleSetMargin(root_child0, YGEdgeTop, 5);
YGNodeStyleSetMargin(root_child0, YGEdgeRight, 9);
YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 1);
YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 2);
YGNodeStyleSetPadding(root_child0, YGEdgeTop, 9);
YGNodeStyleSetPadding(root_child0, YGEdgeRight, 11);
YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 13);
YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 5);
YGNodeStyleSetBorder(root_child0, YGEdgeTop, 6);
YGNodeStyleSetBorder(root_child0, YGEdgeRight, 7);
YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 8);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeStatic);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeLeft, 8);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeTop, 6);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeRight, 3);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeBottom, 9);
YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, 1);
YGNodeStyleSetPadding(root_child0_child0, YGEdgeTop, 7);
YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, 9);
YGNodeStyleSetPadding(root_child0_child0, YGEdgeBottom, 4);
YGNodeStyleSetBorder(root_child0_child0, YGEdgeLeft, 8);
YGNodeStyleSetBorder(root_child0_child0, YGEdgeTop, 10);
YGNodeStyleSetBorder(root_child0_child0, YGEdgeRight, 2);
YGNodeStyleSetBorder(root_child0_child0, YGEdgeBottom, 1);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0_child0_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPositionPercent(root_child0_child0_child0, YGEdgeLeft, 23);
YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeLeft, 9);
YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeTop, 12);
YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeRight, 4);
YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeBottom, 7);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeLeft, 5);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeTop, 3);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeRight, 8);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeBottom, 10);
YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeLeft, 2);
YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeTop, 1);
YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeRight, 5);
YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeBottom, 9);
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
const YGNodeRef root_child0_child0_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child0_child0_child0_child0, YGEdgeLeft, 9);
YGNodeStyleSetMargin(root_child0_child0_child0_child0, YGEdgeTop, 12);
YGNodeStyleSetMargin(root_child0_child0_child0_child0, YGEdgeRight, 4);
YGNodeStyleSetMargin(root_child0_child0_child0_child0, YGEdgeBottom, 7);
YGNodeStyleSetPadding(root_child0_child0_child0_child0, YGEdgeLeft, 5);
YGNodeStyleSetPadding(root_child0_child0_child0_child0, YGEdgeTop, 3);
YGNodeStyleSetPadding(root_child0_child0_child0_child0, YGEdgeRight, 8);
YGNodeStyleSetPadding(root_child0_child0_child0_child0, YGEdgeBottom, 10);
YGNodeStyleSetBorder(root_child0_child0_child0_child0, YGEdgeLeft, 2);
YGNodeStyleSetBorder(root_child0_child0_child0_child0, YGEdgeTop, 1);
YGNodeStyleSetBorder(root_child0_child0_child0_child0, YGEdgeRight, 5);
YGNodeStyleSetBorder(root_child0_child0_child0_child0, YGEdgeBottom, 9);
YGNodeStyleSetWidth(root_child0_child0_child0_child0, 100);
YGNodeStyleSetHeight(root_child0_child0_child0_child0, 50);
YGNodeInsertChild(root_child0_child0_child0, root_child0_child0_child0_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(69, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(79, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(4, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(56, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(73, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(21, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(22, YGNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(9, YGNodeLayoutGetLeft(root_child0_child0_child0));
ASSERT_FLOAT_EQ(29, YGNodeLayoutGetTop(root_child0_child0_child0));
ASSERT_FLOAT_EQ(133, YGNodeLayoutGetWidth(root_child0_child0_child0));
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetHeight(root_child0_child0_child0));
ASSERT_FLOAT_EQ(16, YGNodeLayoutGetLeft(root_child0_child0_child0_child0));
ASSERT_FLOAT_EQ(16, YGNodeLayoutGetTop(root_child0_child0_child0_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0_child0_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(69, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(79, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(4, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(56, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(73, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(21, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(22, YGNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(9, YGNodeLayoutGetLeft(root_child0_child0_child0));
ASSERT_FLOAT_EQ(29, YGNodeLayoutGetTop(root_child0_child0_child0));
ASSERT_FLOAT_EQ(133, YGNodeLayoutGetWidth(root_child0_child0_child0));
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetHeight(root_child0_child0_child0));
ASSERT_FLOAT_EQ(16, YGNodeLayoutGetLeft(root_child0_child0_child0_child0));
ASSERT_FLOAT_EQ(16, YGNodeLayoutGetTop(root_child0_child0_child0_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0_child0_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, static_position_both_insets_set_amalgamation) {
const YGConfigRef config = YGConfigNew();
YGConfigSetExperimentalFeatureEnabled(config, YGExperimentalFeatureAbsolutePercentageAgainstPaddingEdge, true);
const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child0, YGEdgeLeft, 4);
YGNodeStyleSetMargin(root_child0, YGEdgeTop, 5);
YGNodeStyleSetMargin(root_child0, YGEdgeRight, 9);
YGNodeStyleSetMargin(root_child0, YGEdgeBottom, 1);
YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 2);
YGNodeStyleSetPadding(root_child0, YGEdgeTop, 9);
YGNodeStyleSetPadding(root_child0, YGEdgeRight, 11);
YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 13);
YGNodeStyleSetBorder(root_child0, YGEdgeLeft, 5);
YGNodeStyleSetBorder(root_child0, YGEdgeTop, 6);
YGNodeStyleSetBorder(root_child0, YGEdgeRight, 7);
YGNodeStyleSetBorder(root_child0, YGEdgeBottom, 8);
YGNodeInsertChild(root, root_child0, 0);
const YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeStatic);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeLeft, 8);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeTop, 6);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeRight, 3);
YGNodeStyleSetMargin(root_child0_child0, YGEdgeBottom, 9);
YGNodeStyleSetPadding(root_child0_child0, YGEdgeLeft, 1);
YGNodeStyleSetPadding(root_child0_child0, YGEdgeTop, 7);
YGNodeStyleSetPadding(root_child0_child0, YGEdgeRight, 9);
YGNodeStyleSetPadding(root_child0_child0, YGEdgeBottom, 4);
YGNodeStyleSetBorder(root_child0_child0, YGEdgeLeft, 8);
YGNodeStyleSetBorder(root_child0_child0, YGEdgeTop, 10);
YGNodeStyleSetBorder(root_child0_child0, YGEdgeRight, 2);
YGNodeStyleSetBorder(root_child0_child0, YGEdgeBottom, 1);
YGNodeInsertChild(root_child0, root_child0_child0, 0);
const YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0_child0_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPositionPercent(root_child0_child0_child0, YGEdgeLeft, 23);
YGNodeStyleSetPosition(root_child0_child0_child0, YGEdgeRight, 13);
YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeLeft, 9);
YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeTop, 12);
YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeRight, 4);
YGNodeStyleSetMargin(root_child0_child0_child0, YGEdgeBottom, 7);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeLeft, 5);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeTop, 3);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeRight, 8);
YGNodeStyleSetPadding(root_child0_child0_child0, YGEdgeBottom, 10);
YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeLeft, 2);
YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeTop, 1);
YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeRight, 5);
YGNodeStyleSetBorder(root_child0_child0_child0, YGEdgeBottom, 9);
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
const YGNodeRef root_child0_child0_child0_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetMargin(root_child0_child0_child0_child0, YGEdgeLeft, 9);
YGNodeStyleSetMargin(root_child0_child0_child0_child0, YGEdgeTop, 12);
YGNodeStyleSetMargin(root_child0_child0_child0_child0, YGEdgeRight, 4);
YGNodeStyleSetMargin(root_child0_child0_child0_child0, YGEdgeBottom, 7);
YGNodeStyleSetPadding(root_child0_child0_child0_child0, YGEdgeLeft, 5);
YGNodeStyleSetPadding(root_child0_child0_child0_child0, YGEdgeTop, 3);
YGNodeStyleSetPadding(root_child0_child0_child0_child0, YGEdgeRight, 8);
YGNodeStyleSetPadding(root_child0_child0_child0_child0, YGEdgeBottom, 10);
YGNodeStyleSetBorder(root_child0_child0_child0_child0, YGEdgeLeft, 2);
YGNodeStyleSetBorder(root_child0_child0_child0_child0, YGEdgeTop, 1);
YGNodeStyleSetBorder(root_child0_child0_child0_child0, YGEdgeRight, 5);
YGNodeStyleSetBorder(root_child0_child0_child0_child0, YGEdgeBottom, 9);
YGNodeStyleSetWidth(root_child0_child0_child0_child0, 100);
YGNodeStyleSetHeight(root_child0_child0_child0_child0, 50);
YGNodeInsertChild(root_child0_child0_child0, root_child0_child0_child0_child0, 0);
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(69, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(79, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(4, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(56, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(73, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(21, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(22, YGNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(9, YGNodeLayoutGetLeft(root_child0_child0_child0));
ASSERT_FLOAT_EQ(29, YGNodeLayoutGetTop(root_child0_child0_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0_child0));
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetHeight(root_child0_child0_child0));
ASSERT_FLOAT_EQ(16, YGNodeLayoutGetLeft(root_child0_child0_child0_child0));
ASSERT_FLOAT_EQ(16, YGNodeLayoutGetTop(root_child0_child0_child0_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0_child0_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0_child0));
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(69, YGNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(79, YGNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(4, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(5, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(56, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(73, YGNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(15, YGNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(21, YGNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(22, YGNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(-3, YGNodeLayoutGetLeft(root_child0_child0_child0));
ASSERT_FLOAT_EQ(29, YGNodeLayoutGetTop(root_child0_child0_child0));
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetWidth(root_child0_child0_child0));
ASSERT_FLOAT_EQ(92, YGNodeLayoutGetHeight(root_child0_child0_child0));
ASSERT_FLOAT_EQ(-97, YGNodeLayoutGetLeft(root_child0_child0_child0_child0));
ASSERT_FLOAT_EQ(16, YGNodeLayoutGetTop(root_child0_child0_child0_child0));
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0_child0_child0));
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}

View File

@@ -199,10 +199,7 @@ static void positionAbsoluteChildImpl(
// necessary. // necessary.
if (child->isInlineStartPositionDefined(axis, direction)) { if (child->isInlineStartPositionDefined(axis, direction)) {
const float positionRelativeToInlineStart = const float positionRelativeToInlineStart =
child->getInlineStartPosition( child->getInlineStartPosition(axis, direction, containingBlockSize) +
axis,
direction,
containingNode->getLayout().measuredDimension(dimension(axis))) +
containingNode->getInlineStartBorder(axis, direction) + containingNode->getInlineStartBorder(axis, direction) +
child->getInlineStartMargin(axis, direction, containingBlockSize); child->getInlineStartMargin(axis, direction, containingBlockSize);
const float positionRelativeToFlexStart = const float positionRelativeToFlexStart =