Fix crash when you layout multiple absolute nodes in the same static subtree (#1686)
Summary: X-link: https://github.com/facebook/react-native/pull/45952 Pull Request resolved: https://github.com/facebook/yoga/pull/1686 https://en.wikipedia.org/wiki/Short-circuit_evaluation 🫠 Changelog: [Internal] Reviewed By: NickGerleman Differential Revision: D60997231 fbshipit-source-id: 11d70086eecfb5481c578477f288138370016a83
This commit is contained in:
committed by
Facebook GitHub Bot
parent
5009f5c1ac
commit
ae8ede9b53
@@ -693,3 +693,20 @@
|
||||
style="height: 50%; width: 50%; position: absolute; border-width: 3px 2px 1px 4px; padding: 7px 5px 4px 3px; margin: 11px 15px 1px 12px">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="static_position_absolute_child_multiple">
|
||||
<div style="width: 400px; height: 400px; padding: 100px; position: relative">
|
||||
<div style="height:100px; width: 100px; position: static">
|
||||
<div style="height: 50px; width: 10%; position: absolute">
|
||||
</div>
|
||||
</div>
|
||||
<div style="height:100px; width: 100px; position: static">
|
||||
<div style="height: 50px; width: 50%; position: absolute">
|
||||
</div>
|
||||
<div style="height: 50px; width: 50%; position: absolute">
|
||||
</div>
|
||||
</div>
|
||||
<div style="height: 50px; width: 25px; position: absolute">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<cc85b1a4863eb810093395adeee3fa44>>
|
||||
* @generated SignedSource<<997d12880828a3c2881898b769618b43>>
|
||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html
|
||||
*/
|
||||
|
||||
@@ -5887,6 +5887,144 @@ public class YGStaticPositionTest {
|
||||
assertEquals(100f, root_child0.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_static_position_absolute_child_multiple() {
|
||||
YogaConfig config = YogaConfigFactory.create();
|
||||
|
||||
final YogaNode root = createNode(config);
|
||||
root.setPositionType(YogaPositionType.ABSOLUTE);
|
||||
|
||||
final YogaNode root_child0 = createNode(config);
|
||||
root_child0.setPadding(YogaEdge.LEFT, 100);
|
||||
root_child0.setPadding(YogaEdge.TOP, 100);
|
||||
root_child0.setPadding(YogaEdge.RIGHT, 100);
|
||||
root_child0.setPadding(YogaEdge.BOTTOM, 100);
|
||||
root_child0.setWidth(400f);
|
||||
root_child0.setHeight(400f);
|
||||
root.addChildAt(root_child0, 0);
|
||||
|
||||
final YogaNode root_child0_child0 = createNode(config);
|
||||
root_child0_child0.setPositionType(YogaPositionType.STATIC);
|
||||
root_child0_child0.setWidth(100f);
|
||||
root_child0_child0.setHeight(100f);
|
||||
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.setWidthPercent(10f);
|
||||
root_child0_child0_child0.setHeight(50f);
|
||||
root_child0_child0.addChildAt(root_child0_child0_child0, 0);
|
||||
|
||||
final YogaNode root_child0_child1 = createNode(config);
|
||||
root_child0_child1.setPositionType(YogaPositionType.STATIC);
|
||||
root_child0_child1.setWidth(100f);
|
||||
root_child0_child1.setHeight(100f);
|
||||
root_child0.addChildAt(root_child0_child1, 1);
|
||||
|
||||
final YogaNode root_child0_child1_child0 = createNode(config);
|
||||
root_child0_child1_child0.setPositionType(YogaPositionType.ABSOLUTE);
|
||||
root_child0_child1_child0.setWidthPercent(50f);
|
||||
root_child0_child1_child0.setHeight(50f);
|
||||
root_child0_child1.addChildAt(root_child0_child1_child0, 0);
|
||||
|
||||
final YogaNode root_child0_child1_child1 = createNode(config);
|
||||
root_child0_child1_child1.setPositionType(YogaPositionType.ABSOLUTE);
|
||||
root_child0_child1_child1.setWidthPercent(50f);
|
||||
root_child0_child1_child1.setHeight(50f);
|
||||
root_child0_child1.addChildAt(root_child0_child1_child1, 1);
|
||||
|
||||
final YogaNode root_child0_child2 = createNode(config);
|
||||
root_child0_child2.setPositionType(YogaPositionType.ABSOLUTE);
|
||||
root_child0_child2.setWidth(25f);
|
||||
root_child0_child2.setHeight(50f);
|
||||
root_child0.addChildAt(root_child0_child2, 2);
|
||||
root.setDirection(YogaDirection.LTR);
|
||||
root.calculateLayout(YogaConstants.UNDEFINED, YogaConstants.UNDEFINED);
|
||||
|
||||
assertEquals(0f, root.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root.getLayoutY(), 0.0f);
|
||||
assertEquals(400f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(400f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(400f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(100f, root_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(100f, root_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(40f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(100f, root_child0_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(200f, root_child0_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0_child1_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0_child1_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child0_child1_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child0_child1_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0_child1_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0_child1_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child0_child1_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child0_child1_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(100f, root_child0_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(25f, root_child0_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child0_child2.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(400f, root.getLayoutWidth(), 0.0f);
|
||||
assertEquals(400f, root.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(400f, root_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(400f, root_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(200f, root_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(100f, root_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(60f, root_child0_child0_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0_child0_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(40f, root_child0_child0_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child0_child0_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(200f, root_child0_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(200f, root_child0_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(100f, root_child0_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(100f, root_child0_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(-100f, root_child0_child1_child0.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0_child1_child0.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child0_child1_child0.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child0_child1_child0.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(-100f, root_child0_child1_child1.getLayoutX(), 0.0f);
|
||||
assertEquals(0f, root_child0_child1_child1.getLayoutY(), 0.0f);
|
||||
assertEquals(200f, root_child0_child1_child1.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child0_child1_child1.getLayoutHeight(), 0.0f);
|
||||
|
||||
assertEquals(275f, root_child0_child2.getLayoutX(), 0.0f);
|
||||
assertEquals(100f, root_child0_child2.getLayoutY(), 0.0f);
|
||||
assertEquals(25f, root_child0_child2.getLayoutWidth(), 0.0f);
|
||||
assertEquals(50f, root_child0_child2.getLayoutHeight(), 0.0f);
|
||||
}
|
||||
|
||||
private YogaNode createNode(YogaConfig config) {
|
||||
return mNodeFactory.create(config);
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @generated SignedSource<<fd288594fce8fa8e2399df5f5d303440>>
|
||||
* @generated SignedSource<<ce99ac91b3467951bb539796415198ee>>
|
||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html
|
||||
*/
|
||||
|
||||
@@ -6192,3 +6192,146 @@ test('static_position_static_root', () => {
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
test('static_position_absolute_child_multiple', () => {
|
||||
const config = Yoga.Config.create();
|
||||
let root;
|
||||
|
||||
try {
|
||||
root = Yoga.Node.create(config);
|
||||
root.setPositionType(PositionType.Absolute);
|
||||
|
||||
const root_child0 = Yoga.Node.create(config);
|
||||
root_child0.setPadding(Edge.Left, 100);
|
||||
root_child0.setPadding(Edge.Top, 100);
|
||||
root_child0.setPadding(Edge.Right, 100);
|
||||
root_child0.setPadding(Edge.Bottom, 100);
|
||||
root_child0.setWidth(400);
|
||||
root_child0.setHeight(400);
|
||||
root.insertChild(root_child0, 0);
|
||||
|
||||
const root_child0_child0 = Yoga.Node.create(config);
|
||||
root_child0_child0.setPositionType(PositionType.Static);
|
||||
root_child0_child0.setWidth(100);
|
||||
root_child0_child0.setHeight(100);
|
||||
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.setWidth("10%");
|
||||
root_child0_child0_child0.setHeight(50);
|
||||
root_child0_child0.insertChild(root_child0_child0_child0, 0);
|
||||
|
||||
const root_child0_child1 = Yoga.Node.create(config);
|
||||
root_child0_child1.setPositionType(PositionType.Static);
|
||||
root_child0_child1.setWidth(100);
|
||||
root_child0_child1.setHeight(100);
|
||||
root_child0.insertChild(root_child0_child1, 1);
|
||||
|
||||
const root_child0_child1_child0 = Yoga.Node.create(config);
|
||||
root_child0_child1_child0.setPositionType(PositionType.Absolute);
|
||||
root_child0_child1_child0.setWidth("50%");
|
||||
root_child0_child1_child0.setHeight(50);
|
||||
root_child0_child1.insertChild(root_child0_child1_child0, 0);
|
||||
|
||||
const root_child0_child1_child1 = Yoga.Node.create(config);
|
||||
root_child0_child1_child1.setPositionType(PositionType.Absolute);
|
||||
root_child0_child1_child1.setWidth("50%");
|
||||
root_child0_child1_child1.setHeight(50);
|
||||
root_child0_child1.insertChild(root_child0_child1_child1, 1);
|
||||
|
||||
const root_child0_child2 = Yoga.Node.create(config);
|
||||
root_child0_child2.setPositionType(PositionType.Absolute);
|
||||
root_child0_child2.setWidth(25);
|
||||
root_child0_child2.setHeight(50);
|
||||
root_child0.insertChild(root_child0_child2, 2);
|
||||
root.calculateLayout(undefined, undefined, Direction.LTR);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(400);
|
||||
expect(root.getComputedHeight()).toBe(400);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(400);
|
||||
expect(root_child0.getComputedHeight()).toBe(400);
|
||||
|
||||
expect(root_child0_child0.getComputedLeft()).toBe(100);
|
||||
expect(root_child0_child0.getComputedTop()).toBe(100);
|
||||
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0_child0_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child0.getComputedWidth()).toBe(40);
|
||||
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
||||
|
||||
expect(root_child0_child1.getComputedLeft()).toBe(100);
|
||||
expect(root_child0_child1.getComputedTop()).toBe(200);
|
||||
expect(root_child0_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child0_child1.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0_child1_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child1_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child1_child0.getComputedWidth()).toBe(200);
|
||||
expect(root_child0_child1_child0.getComputedHeight()).toBe(50);
|
||||
|
||||
expect(root_child0_child1_child1.getComputedLeft()).toBe(0);
|
||||
expect(root_child0_child1_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child1_child1.getComputedWidth()).toBe(200);
|
||||
expect(root_child0_child1_child1.getComputedHeight()).toBe(50);
|
||||
|
||||
expect(root_child0_child2.getComputedLeft()).toBe(100);
|
||||
expect(root_child0_child2.getComputedTop()).toBe(100);
|
||||
expect(root_child0_child2.getComputedWidth()).toBe(25);
|
||||
expect(root_child0_child2.getComputedHeight()).toBe(50);
|
||||
|
||||
root.calculateLayout(undefined, undefined, Direction.RTL);
|
||||
|
||||
expect(root.getComputedLeft()).toBe(0);
|
||||
expect(root.getComputedTop()).toBe(0);
|
||||
expect(root.getComputedWidth()).toBe(400);
|
||||
expect(root.getComputedHeight()).toBe(400);
|
||||
|
||||
expect(root_child0.getComputedLeft()).toBe(0);
|
||||
expect(root_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0.getComputedWidth()).toBe(400);
|
||||
expect(root_child0.getComputedHeight()).toBe(400);
|
||||
|
||||
expect(root_child0_child0.getComputedLeft()).toBe(200);
|
||||
expect(root_child0_child0.getComputedTop()).toBe(100);
|
||||
expect(root_child0_child0.getComputedWidth()).toBe(100);
|
||||
expect(root_child0_child0.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0_child0_child0.getComputedLeft()).toBe(60);
|
||||
expect(root_child0_child0_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child0_child0.getComputedWidth()).toBe(40);
|
||||
expect(root_child0_child0_child0.getComputedHeight()).toBe(50);
|
||||
|
||||
expect(root_child0_child1.getComputedLeft()).toBe(200);
|
||||
expect(root_child0_child1.getComputedTop()).toBe(200);
|
||||
expect(root_child0_child1.getComputedWidth()).toBe(100);
|
||||
expect(root_child0_child1.getComputedHeight()).toBe(100);
|
||||
|
||||
expect(root_child0_child1_child0.getComputedLeft()).toBe(-100);
|
||||
expect(root_child0_child1_child0.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child1_child0.getComputedWidth()).toBe(200);
|
||||
expect(root_child0_child1_child0.getComputedHeight()).toBe(50);
|
||||
|
||||
expect(root_child0_child1_child1.getComputedLeft()).toBe(-100);
|
||||
expect(root_child0_child1_child1.getComputedTop()).toBe(0);
|
||||
expect(root_child0_child1_child1.getComputedWidth()).toBe(200);
|
||||
expect(root_child0_child1_child1.getComputedHeight()).toBe(50);
|
||||
|
||||
expect(root_child0_child2.getComputedLeft()).toBe(275);
|
||||
expect(root_child0_child2.getComputedTop()).toBe(100);
|
||||
expect(root_child0_child2.getComputedWidth()).toBe(25);
|
||||
expect(root_child0_child2.getComputedHeight()).toBe(50);
|
||||
} finally {
|
||||
if (typeof root !== 'undefined') {
|
||||
root.freeRecursive();
|
||||
}
|
||||
|
||||
config.free();
|
||||
}
|
||||
});
|
||||
|
@@ -219,11 +219,17 @@ TEST(YogaTest, has_new_layout_flag_set_static) {
|
||||
YGNodeStyleSetHeight(root_child0, 10);
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
YGNodeRef root_child0_child1 = YGNodeNew();
|
||||
YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeAbsolute);
|
||||
YGNodeStyleSetWidth(root_child0_child1, 5);
|
||||
YGNodeStyleSetHeight(root_child0_child1, 5);
|
||||
YGNodeInsertChild(root_child0, root_child0_child1, 0);
|
||||
|
||||
YGNodeRef root_child0_child0 = YGNodeNew();
|
||||
YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeStatic);
|
||||
YGNodeStyleSetWidth(root_child0_child0, 5);
|
||||
YGNodeStyleSetHeight(root_child0_child0, 5);
|
||||
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||
YGNodeInsertChild(root_child0, root_child0_child0, 1);
|
||||
|
||||
YGNodeRef root_child0_child0_child0 = YGNodeNew();
|
||||
YGNodeStyleSetPositionType(root_child0_child0_child0, YGPositionTypeAbsolute);
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* clang-format off
|
||||
* @generated SignedSource<<03c511300b41c81c3592dd5df34bc2b9>>
|
||||
* @generated SignedSource<<83ad08d246e0d406b525b1b1d5290b35>>
|
||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html
|
||||
*/
|
||||
|
||||
@@ -5933,3 +5933,142 @@ TEST(YogaTest, static_position_static_root) {
|
||||
|
||||
YGConfigFree(config);
|
||||
}
|
||||
|
||||
TEST(YogaTest, static_position_absolute_child_multiple) {
|
||||
YGConfigRef config = YGConfigNew();
|
||||
|
||||
YGNodeRef root = YGNodeNewWithConfig(config);
|
||||
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
|
||||
|
||||
YGNodeRef root_child0 = YGNodeNewWithConfig(config);
|
||||
YGNodeStyleSetPadding(root_child0, YGEdgeLeft, 100);
|
||||
YGNodeStyleSetPadding(root_child0, YGEdgeTop, 100);
|
||||
YGNodeStyleSetPadding(root_child0, YGEdgeRight, 100);
|
||||
YGNodeStyleSetPadding(root_child0, YGEdgeBottom, 100);
|
||||
YGNodeStyleSetWidth(root_child0, 400);
|
||||
YGNodeStyleSetHeight(root_child0, 400);
|
||||
YGNodeInsertChild(root, root_child0, 0);
|
||||
|
||||
YGNodeRef root_child0_child0 = YGNodeNewWithConfig(config);
|
||||
YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeStatic);
|
||||
YGNodeStyleSetWidth(root_child0_child0, 100);
|
||||
YGNodeStyleSetHeight(root_child0_child0, 100);
|
||||
YGNodeInsertChild(root_child0, root_child0_child0, 0);
|
||||
|
||||
YGNodeRef root_child0_child0_child0 = YGNodeNewWithConfig(config);
|
||||
YGNodeStyleSetPositionType(root_child0_child0_child0, YGPositionTypeAbsolute);
|
||||
YGNodeStyleSetWidthPercent(root_child0_child0_child0, 10);
|
||||
YGNodeStyleSetHeight(root_child0_child0_child0, 50);
|
||||
YGNodeInsertChild(root_child0_child0, root_child0_child0_child0, 0);
|
||||
|
||||
YGNodeRef root_child0_child1 = YGNodeNewWithConfig(config);
|
||||
YGNodeStyleSetPositionType(root_child0_child1, YGPositionTypeStatic);
|
||||
YGNodeStyleSetWidth(root_child0_child1, 100);
|
||||
YGNodeStyleSetHeight(root_child0_child1, 100);
|
||||
YGNodeInsertChild(root_child0, root_child0_child1, 1);
|
||||
|
||||
YGNodeRef root_child0_child1_child0 = YGNodeNewWithConfig(config);
|
||||
YGNodeStyleSetPositionType(root_child0_child1_child0, YGPositionTypeAbsolute);
|
||||
YGNodeStyleSetWidthPercent(root_child0_child1_child0, 50);
|
||||
YGNodeStyleSetHeight(root_child0_child1_child0, 50);
|
||||
YGNodeInsertChild(root_child0_child1, root_child0_child1_child0, 0);
|
||||
|
||||
YGNodeRef root_child0_child1_child1 = YGNodeNewWithConfig(config);
|
||||
YGNodeStyleSetPositionType(root_child0_child1_child1, YGPositionTypeAbsolute);
|
||||
YGNodeStyleSetWidthPercent(root_child0_child1_child1, 50);
|
||||
YGNodeStyleSetHeight(root_child0_child1_child1, 50);
|
||||
YGNodeInsertChild(root_child0_child1, root_child0_child1_child1, 1);
|
||||
|
||||
YGNodeRef root_child0_child2 = YGNodeNewWithConfig(config);
|
||||
YGNodeStyleSetPositionType(root_child0_child2, YGPositionTypeAbsolute);
|
||||
YGNodeStyleSetWidth(root_child0_child2, 25);
|
||||
YGNodeStyleSetHeight(root_child0_child2, 50);
|
||||
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(400, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child0));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child0));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child0_child1));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child1));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child1_child0));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child1_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0_child1_child1));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child1_child1));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child1_child1));
|
||||
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetLeft(root_child0_child2));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2));
|
||||
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0_child2));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child2));
|
||||
|
||||
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionRTL);
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root));
|
||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root));
|
||||
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetWidth(root_child0));
|
||||
ASSERT_FLOAT_EQ(400, YGNodeLayoutGetHeight(root_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0_child0));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child0));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child0));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(60, YGNodeLayoutGetLeft(root_child0_child0_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child0_child0));
|
||||
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetWidth(root_child0_child0_child0));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child0_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetLeft(root_child0_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetTop(root_child0_child1));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root_child0_child1));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root_child0_child1));
|
||||
|
||||
ASSERT_FLOAT_EQ(-100, YGNodeLayoutGetLeft(root_child0_child1_child0));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1_child0));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child1_child0));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child1_child0));
|
||||
|
||||
ASSERT_FLOAT_EQ(-100, YGNodeLayoutGetLeft(root_child0_child1_child1));
|
||||
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0_child1_child1));
|
||||
ASSERT_FLOAT_EQ(200, YGNodeLayoutGetWidth(root_child0_child1_child1));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child1_child1));
|
||||
|
||||
ASSERT_FLOAT_EQ(275, YGNodeLayoutGetLeft(root_child0_child2));
|
||||
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetTop(root_child0_child2));
|
||||
ASSERT_FLOAT_EQ(25, YGNodeLayoutGetWidth(root_child0_child2));
|
||||
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0_child2));
|
||||
|
||||
YGNodeFreeRecursive(root);
|
||||
|
||||
YGConfigFree(config);
|
||||
}
|
||||
|
@@ -592,8 +592,7 @@ bool layoutAbsoluteDescendants(
|
||||
currentNodeTopOffsetFromContainingBlock +
|
||||
child->getLayout().position(PhysicalEdge::Top);
|
||||
|
||||
hasNewLayout = hasNewLayout ||
|
||||
layoutAbsoluteDescendants(
|
||||
hasNewLayout = layoutAbsoluteDescendants(
|
||||
containingNode,
|
||||
child,
|
||||
widthSizingMode,
|
||||
@@ -604,7 +603,8 @@ bool layoutAbsoluteDescendants(
|
||||
childLeftOffsetFromContainingBlock,
|
||||
childTopOffsetFromContainingBlock,
|
||||
containingNodeAvailableInnerWidth,
|
||||
containingNodeAvailableInnerHeight);
|
||||
containingNodeAvailableInnerHeight) ||
|
||||
hasNewLayout;
|
||||
|
||||
if (hasNewLayout) {
|
||||
child->setHasNewLayout(hasNewLayout);
|
||||
|
Reference in New Issue
Block a user