Compare commits

...

5 Commits

Author SHA1 Message Date
dependabot[bot]
f443092278 Bump micromatch from 4.0.5 to 4.0.8
Bumps [micromatch](https://github.com/micromatch/micromatch) from 4.0.5 to 4.0.8.
- [Release notes](https://github.com/micromatch/micromatch/releases)
- [Changelog](https://github.com/micromatch/micromatch/blob/master/CHANGELOG.md)
- [Commits](https://github.com/micromatch/micromatch/compare/4.0.5...4.0.8)

---
updated-dependencies:
- dependency-name: micromatch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-01 01:28:32 +00:00
Alan Lee
dc4ab5ad57 update compileSdk to 35 (#1692)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1692

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

Update compileSdk to 35 before adding relating work for Android 15

Changelog:
[Android][Added] - Update compileSdk to 35

Reviewed By: cortinico

Differential Revision: D61874541

fbshipit-source-id: f7c92dc15aa68a53bcd626450c515d2f24e9e40f
2024-08-29 09:17:42 -07:00
Dawid
6d6f69bee7 Fix handling 'auto' checks in absolute layout (#1689)
Summary:
X-link: https://github.com/facebook/react-native/pull/46216

Regarding [issue](https://github.com/facebook/react-native/issues/45817) with incorrect layout when `left` is set to `auto`. This PR introduces handling `auto` whenever inline or flex position is checked to be defined and it fixes above issue.

Changelog:
[General][Fixed] - Fix handling 'auto' checks in absolute layout

## Tests:
 I have run the provided unit tests and everything passes.

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

Reviewed By: cipolleschi

Differential Revision: D61737876

Pulled By: NickGerleman

fbshipit-source-id: 531199a91c5e122b930b49725ea567cbb1d592ce
2024-08-27 06:00:34 -07:00
Joe Vilches
596f8dff3c Extra log for case where availableHeight is undefined and sizing mode != max content (#1687)
Summary:
X-link: https://github.com/facebook/react-native/pull/45965

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

We are seeing some crashes that are hard to wrap our head around. Lets add more logs. I chose these values based on what could make the height/width undefined from looking at the code. We might need more but this should give us some more direction.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D61054392

fbshipit-source-id: 654ff96f94aa89605a603e2e36335bb48b61f4a2
2024-08-19 16:13:44 -07:00
Joe Vilches
ae8ede9b53 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
2024-08-08 22:41:29 -07:00
28 changed files with 1036 additions and 44 deletions

View File

@@ -2,6 +2,18 @@
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px;"></div>
</div>
<div id="absolute_layout_width_height_left_auto_right" style="width: 100px; height: 100px">
<div style="width: 10px; height: 10px; position: absolute; left: auto; right: 10px;"></div>
</div>
<div id="absolute_layout_width_height_left_right_auto" style="width: 100px; height: 100px">
<div style="width: 10px; height: 10px; position: absolute; left: 10px; right: auto;"></div>
</div>
<div id="absolute_layout_width_height_left_auto_right_auto" style="width: 100px; height: 100px">
<div style="width: 10px; height: 10px; position: absolute; left: auto; right: auto;"></div>
</div>
<div id="absolute_layout_width_height_end_bottom" style="width: 100px; height: 100px;">
<div style="width:10px; height: 10px; position: absolute; end: 10px; bottom: 10px;"></div>
</div>

View File

@@ -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>

View File

@@ -451,6 +451,12 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
YGNodeStyleSetPosition: {
value: function (nodeName, edge, value) {
let valueStr = toValueCpp(value);
if (valueStr != 'YGAuto') {
valueStr = ', ' + valueStr;
} else {
valueStr = '';
}
this.push(
'YGNodeStyleSetPosition' +
toFunctionName(value) +
@@ -458,8 +464,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
nodeName +
', ' +
edge +
', ' +
toValueCpp(value) +
valueStr +
');',
);
},

View File

@@ -420,15 +420,21 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
YGNodeStyleSetPosition: {
value: function (nodeName, edge, value) {
let valueStr = toValueJava(value);
if (valueStr == 'YogaConstants.AUTO') {
valueStr = '';
} else {
valueStr = ', ' + valueStr + 'f';
}
this.push(
nodeName +
'.setPosition' +
toMethodName(value) +
'(' +
edge +
', ' +
toValueJava(value) +
'f);',
valueStr +
');',
);
},
},

View File

@@ -364,14 +364,22 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
YGNodeStyleSetPosition: {
value: function (nodeName, edge, value) {
this.push(
nodeName +
'.setPosition(' +
toValueJavascript(edge) +
', ' +
toValueJavascript(value) +
');',
);
const valueStr = toValueJavascript(value);
if (valueStr == "'auto'") {
this.push(
nodeName + '.setPositionAuto(' + toValueJavascript(edge) + ');',
);
} else {
this.push(
nodeName +
'.setPosition(' +
toValueJavascript(edge) +
', ' +
valueStr +
');',
);
}
},
},

View File

@@ -21,8 +21,8 @@ val ndkVersionProperty: String by rootProject.extra
android {
namespace = "com.facebook.yoga"
compileSdk = 34
buildToolsVersion = "34.0.0"
compileSdk = 35
buildToolsVersion = "35.0.0"
ndkVersion = "26.0.10792818"
defaultConfig {

View File

@@ -84,6 +84,7 @@ public class YogaNative {
static native long jni_YGNodeStyleGetPositionJNI(long nativePointer, int edge);
static native void jni_YGNodeStyleSetPositionJNI(long nativePointer, int edge, float position);
static native void jni_YGNodeStyleSetPositionPercentJNI(long nativePointer, int edge, float percent);
static native void jni_YGNodeStyleSetPositionAutoJNI(long nativePointer, int edge);
static native long jni_YGNodeStyleGetWidthJNI(long nativePointer);
static native void jni_YGNodeStyleSetWidthJNI(long nativePointer, float width);
static native void jni_YGNodeStyleSetWidthPercentJNI(long nativePointer, float percent);

View File

@@ -144,6 +144,8 @@ public abstract class YogaNode implements YogaProps {
public abstract void setPositionPercent(YogaEdge edge, float percent);
public abstract void setPositionAuto(YogaEdge edge);
public abstract YogaValue getWidth();
public abstract void setWidth(float width);

View File

@@ -411,6 +411,10 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
YogaNative.jni_YGNodeStyleSetPositionPercentJNI(mNativePointer, edge.intValue(), percent);
}
public void setPositionAuto(YogaEdge edge) {
YogaNative.jni_YGNodeStyleSetPositionAutoJNI(mNativePointer, edge.intValue());
}
public YogaValue getWidth() {
return valueFromLong(YogaNative.jni_YGNodeStyleGetWidthJNI(mNativePointer));
}

View File

@@ -460,6 +460,14 @@ static void jni_YGNodeCopyStyleJNI(
static_cast<float>(value)); \
}
#define YG_NODE_JNI_STYLE_EDGE_UNIT_PROP_AUTO(name) \
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(name) \
static void jni_YGNodeStyleSet##name##AutoJNI( \
JNIEnv* /*env*/, jobject /*obj*/, jlong nativePointer, jint edge) { \
YGNodeStyleSet##name##Auto( \
_jlong2YGNodeRef(nativePointer), static_cast<YGEdge>(edge)); \
}
YG_NODE_JNI_STYLE_PROP(jint, YGDirection, Direction);
YG_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection);
YG_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent);
@@ -482,7 +490,7 @@ YG_NODE_JNI_STYLE_UNIT_PROP_AUTO(Height);
YG_NODE_JNI_STYLE_UNIT_PROP(MinHeight);
YG_NODE_JNI_STYLE_UNIT_PROP(MaxHeight);
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP(Position);
YG_NODE_JNI_STYLE_EDGE_UNIT_PROP_AUTO(Position);
static jlong jni_YGNodeStyleGetMarginJNI(
JNIEnv* /*env*/,
@@ -891,6 +899,9 @@ static JNINativeMethod methods[] = {
{"jni_YGNodeStyleSetPositionPercentJNI",
"(JIF)V",
(void*)jni_YGNodeStyleSetPositionPercentJNI},
{"jni_YGNodeStyleSetPositionAutoJNI",
"(JI)V",
(void*)jni_YGNodeStyleSetPositionAutoJNI},
{"jni_YGNodeStyleGetWidthJNI", "(J)J", (void*)jni_YGNodeStyleGetWidthJNI},
{"jni_YGNodeStyleSetWidthJNI", "(JF)V", (void*)jni_YGNodeStyleSetWidthJNI},
{"jni_YGNodeStyleSetWidthPercentJNI",

View File

@@ -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<<30a9046ab7f9c7bda2d4f3b2ae12afcd>>
* @generated SignedSource<<c4a613bef526a87ca88e3b28e1abc215>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAbsolutePositionTest.html
*/
@@ -70,6 +70,135 @@ public class YGAbsolutePositionTest {
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_absolute_layout_width_height_left_auto_right() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPositionAuto(YogaEdge.LEFT);
root_child0.setPosition(YogaEdge.RIGHT, 10f);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_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(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(80f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_absolute_layout_width_height_left_right_auto() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPosition(YogaEdge.LEFT, 10f);
root_child0.setPositionAuto(YogaEdge.RIGHT);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_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(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(10f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_absolute_layout_width_height_left_auto_right_auto() {
YogaConfig config = YogaConfigFactory.create();
final YogaNode root = createNode(config);
root.setPositionType(YogaPositionType.ABSOLUTE);
root.setWidth(100f);
root.setHeight(100f);
final YogaNode root_child0 = createNode(config);
root_child0.setPositionType(YogaPositionType.ABSOLUTE);
root_child0.setPositionAuto(YogaEdge.LEFT);
root_child0.setPositionAuto(YogaEdge.RIGHT);
root_child0.setWidth(10f);
root_child0.setHeight(10f);
root.addChildAt(root_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(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(0f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_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(100f, root.getLayoutWidth(), 0.0f);
assertEquals(100f, root.getLayoutHeight(), 0.0f);
assertEquals(90f, root_child0.getLayoutX(), 0.0f);
assertEquals(0f, root_child0.getLayoutY(), 0.0f);
assertEquals(10f, root_child0.getLayoutWidth(), 0.0f);
assertEquals(10f, root_child0.getLayoutHeight(), 0.0f);
}
@Test
public void test_absolute_layout_width_height_end_bottom() {
YogaConfig config = YogaConfigFactory.create();

View File

@@ -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);
}

View File

@@ -87,6 +87,10 @@ void Node::setPositionPercent(int edge, double position) {
YGNodeStyleSetPositionPercent(m_node, static_cast<YGEdge>(edge), position);
}
void Node::setPositionAuto(int edge) {
YGNodeStyleSetPositionAuto(m_node, static_cast<YGEdge>(edge));
}
void Node::setAlignContent(int alignContent) {
YGNodeStyleSetAlignContent(m_node, static_cast<YGAlign>(alignContent));
}

View File

@@ -76,6 +76,7 @@ class Node {
void setPositionType(int positionType);
void setPosition(int edge, double position);
void setPositionPercent(int edge, double position);
void setPositionAuto(int edge);
void setAlignContent(int alignContent);
void setAlignItems(int alignItems);

View File

@@ -70,6 +70,7 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
.function("setPositionType", &Node::setPositionType)
.function("setPosition", &Node::setPosition)
.function("setPositionPercent", &Node::setPositionPercent)
.function("setPositionAuto", &Node::setPositionAuto)
.function("setAlignContent", &Node::setAlignContent)
.function("setAlignItems", &Node::setAlignItems)

View File

@@ -168,6 +168,7 @@ export type Node = {
setPosition(edge: Edge, position: number | `${number}%` | undefined): void;
setPositionPercent(edge: Edge, position: number | undefined): void;
setPositionType(positionType: PositionType): void;
setPositionAuto(edge: Edge): void;
setWidth(width: number | 'auto' | `${number}%` | undefined): void;
setWidthAuto(): void;
setWidthPercent(width: number | undefined): void;

View File

@@ -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<<133e2d77cd6267d4bfb0fe992d437fd1>>
* @generated SignedSource<<3ac965030750351f007587f3ae1dec10>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAbsolutePositionTest.html
*/
@@ -75,6 +75,150 @@ test('absolute_layout_width_height_start_top', () => {
config.free();
}
});
test('absolute_layout_width_height_left_auto_right', () => {
const config = Yoga.Config.create();
let root;
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setWidth(100);
root.setHeight(100);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Absolute);
root_child0.setPositionAuto(Edge.Left);
root_child0.setPosition(Edge.Right, 10);
root_child0.setWidth(10);
root_child0.setHeight(10);
root.insertChild(root_child0, 0);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(80);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(10);
expect(root_child0.getComputedHeight()).toBe(10);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(80);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(10);
expect(root_child0.getComputedHeight()).toBe(10);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('absolute_layout_width_height_left_right_auto', () => {
const config = Yoga.Config.create();
let root;
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setWidth(100);
root.setHeight(100);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Absolute);
root_child0.setPosition(Edge.Left, 10);
root_child0.setPositionAuto(Edge.Right);
root_child0.setWidth(10);
root_child0.setHeight(10);
root.insertChild(root_child0, 0);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(10);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(10);
expect(root_child0.getComputedHeight()).toBe(10);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(10);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(10);
expect(root_child0.getComputedHeight()).toBe(10);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('absolute_layout_width_height_left_auto_right_auto', () => {
const config = Yoga.Config.create();
let root;
try {
root = Yoga.Node.create(config);
root.setPositionType(PositionType.Absolute);
root.setWidth(100);
root.setHeight(100);
const root_child0 = Yoga.Node.create(config);
root_child0.setPositionType(PositionType.Absolute);
root_child0.setPositionAuto(Edge.Left);
root_child0.setPositionAuto(Edge.Right);
root_child0.setWidth(10);
root_child0.setHeight(10);
root.insertChild(root_child0, 0);
root.calculateLayout(undefined, undefined, Direction.LTR);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(0);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(10);
expect(root_child0.getComputedHeight()).toBe(10);
root.calculateLayout(undefined, undefined, Direction.RTL);
expect(root.getComputedLeft()).toBe(0);
expect(root.getComputedTop()).toBe(0);
expect(root.getComputedWidth()).toBe(100);
expect(root.getComputedHeight()).toBe(100);
expect(root_child0.getComputedLeft()).toBe(90);
expect(root_child0.getComputedTop()).toBe(0);
expect(root_child0.getComputedWidth()).toBe(10);
expect(root_child0.getComputedHeight()).toBe(10);
} finally {
if (typeof root !== 'undefined') {
root.freeRecursive();
}
config.free();
}
});
test('absolute_layout_width_height_end_bottom', () => {
const config = Yoga.Config.create();
let root;

View File

@@ -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();
}
});

View File

@@ -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);

View File

@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*
* clang-format off
* @generated SignedSource<<425ef3591b2f5cf0bc6d9daa9c5db96c>>
* @generated SignedSource<<499316b3f7b7ec5c406abf5ac77837f1>>
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAbsolutePositionTest.html
*/
@@ -57,6 +57,138 @@ TEST(YogaTest, absolute_layout_width_height_start_top) {
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_width_height_left_auto_right) {
YGConfigRef config = YGConfigNew();
YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPositionAuto(root_child0, YGEdgeLeft);
YGNodeStyleSetPosition(root_child0, YGEdgeRight, 10);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
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(80, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
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(80, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_width_height_left_right_auto) {
YGConfigRef config = YGConfigNew();
YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeLeft, 10);
YGNodeStyleSetPositionAuto(root_child0, YGEdgeRight);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
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(10, YGNodeLayoutGetHeight(root_child0));
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(10, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_width_height_left_auto_right_auto) {
YGConfigRef config = YGConfigNew();
YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root, YGPositionTypeAbsolute);
YGNodeStyleSetWidth(root, 100);
YGNodeStyleSetHeight(root, 100);
YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPositionAuto(root_child0, YGEdgeLeft);
YGNodeStyleSetPositionAuto(root_child0, YGEdgeRight);
YGNodeStyleSetWidth(root_child0, 10);
YGNodeStyleSetHeight(root_child0, 10);
YGNodeInsertChild(root, root_child0, 0);
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(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
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(90, YGNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, YGNodeLayoutGetHeight(root_child0));
YGNodeFreeRecursive(root);
YGConfigFree(config);
}
TEST(YogaTest, absolute_layout_width_height_end_bottom) {
YGConfigRef config = YGConfigNew();

View File

@@ -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);
}

View File

@@ -3592,7 +3592,7 @@ brace-expansion@^2.0.1:
dependencies:
balanced-match "^1.0.0"
braces@^3.0.2, braces@~3.0.2:
braces@^3.0.3, braces@~3.0.2:
version "3.0.3"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
@@ -8166,11 +8166,11 @@ micromark@^4.0.0:
micromark-util-types "^2.0.0"
micromatch@^4.0.2, micromatch@^4.0.4, micromatch@^4.0.5:
version "4.0.5"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6"
integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==
version "4.0.8"
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202"
integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==
dependencies:
braces "^3.0.2"
braces "^3.0.3"
picomatch "^2.3.1"
mime-db@1.52.0, "mime-db@>= 1.43.0 < 2":
@@ -10292,7 +10292,16 @@ string-length@^4.0.1:
char-regex "^1.0.2"
strip-ansi "^6.0.0"
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"
string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@@ -10383,7 +10392,14 @@ stringify-object@^3.3.0:
is-obj "^1.0.1"
is-regexp "^1.0.0"
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@@ -11288,7 +11304,16 @@ word-wrap@^1.2.3:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@7.0.0, wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"
wrap-ansi@7.0.0, wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==

View File

@@ -205,6 +205,11 @@ void YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float percent) {
node, scopedEnum(edge), value::percent(percent));
}
void YGNodeStyleSetPositionAuto(YGNodeRef node, YGEdge edge) {
updateStyle<&Style::position, &Style::setPosition>(
node, scopedEnum(edge), value::ofAuto());
}
YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) {
return (YGValue)resolveRef(node)->style().position(scopedEnum(edge));
}

View File

@@ -71,8 +71,10 @@ YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float position);
YG_EXPORT void
YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float position);
YG_EXPORT YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge);
YG_EXPORT void YGNodeStyleSetPositionAuto(YGNodeRef node, YGEdge edge);
YG_EXPORT void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float margin);
YG_EXPORT
void YGNodeStyleSetMargin(YGNodeRef node, YGEdge edge, float margin);
YG_EXPORT void
YGNodeStyleSetMarginPercent(YGNodeRef node, YGEdge edge, float margin);
YG_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge);

View File

@@ -154,7 +154,8 @@ static void positionAbsoluteChildLegacy(
(parent->style().flexWrap() == Wrap::WrapReverse));
if (child->style().isFlexEndPositionDefined(axis, direction) &&
!child->style().isFlexStartPositionDefined(axis, direction)) {
(!child->style().isFlexStartPositionDefined(axis, direction) ||
child->style().isFlexStartPositionAuto(axis, direction))) {
child->setLayoutPosition(
containingNode->getLayout().measuredDimension(dimension(axis)) -
child->getLayout().measuredDimension(dimension(axis)) -
@@ -169,7 +170,8 @@ static void positionAbsoluteChildLegacy(
isAxisRow ? containingBlockWidth : containingBlockHeight),
flexStartEdge(axis));
} else if (
!child->style().isFlexStartPositionDefined(axis, direction) &&
(!child->style().isFlexStartPositionDefined(axis, direction) ||
child->style().isFlexStartPositionAuto(axis, direction)) &&
shouldCenter) {
child->setLayoutPosition(
(parent->getLayout().measuredDimension(dimension(axis)) -
@@ -177,7 +179,8 @@ static void positionAbsoluteChildLegacy(
2.0f,
flexStartEdge(axis));
} else if (
!child->style().isFlexStartPositionDefined(axis, direction) &&
(!child->style().isFlexStartPositionDefined(axis, direction) ||
child->style().isFlexStartPositionAuto(axis, direction)) &&
shouldFlexEnd) {
child->setLayoutPosition(
(parent->getLayout().measuredDimension(dimension(axis)) -
@@ -223,7 +226,8 @@ static void positionAbsoluteChildImpl(
// to the flex-start edge because this algorithm works by positioning on the
// flex-start edge and then filling in the flex-end direction at the end if
// necessary.
if (child->style().isInlineStartPositionDefined(axis, direction)) {
if (child->style().isInlineStartPositionDefined(axis, direction) &&
!child->style().isInlineStartPositionAuto(axis, direction)) {
const float positionRelativeToInlineStart =
child->style().computeInlineStartPosition(
axis, direction, containingBlockSize) +
@@ -237,7 +241,9 @@ static void positionAbsoluteChildImpl(
: positionRelativeToInlineStart;
child->setLayoutPosition(positionRelativeToFlexStart, flexStartEdge(axis));
} else if (child->style().isInlineEndPositionDefined(axis, direction)) {
} else if (
child->style().isInlineEndPositionDefined(axis, direction) &&
!child->style().isInlineEndPositionAuto(axis, direction)) {
const float positionRelativeToInlineStart =
containingNode->getLayout().measuredDimension(dimension(axis)) -
child->getLayout().measuredDimension(dimension(axis)) -
@@ -328,7 +334,10 @@ void layoutAbsoluteChild(
if (child->style().isFlexStartPositionDefined(
FlexDirection::Row, direction) &&
child->style().isFlexEndPositionDefined(
FlexDirection::Row, direction)) {
FlexDirection::Row, direction) &&
!child->style().isFlexStartPositionAuto(
FlexDirection::Row, direction) &&
!child->style().isFlexEndPositionAuto(FlexDirection::Row, direction)) {
childWidth =
containingNode->getLayout().measuredDimension(Dimension::Width) -
(containingNode->style().computeFlexStartBorder(
@@ -360,6 +369,10 @@ void layoutAbsoluteChild(
if (child->style().isFlexStartPositionDefined(
FlexDirection::Column, direction) &&
child->style().isFlexEndPositionDefined(
FlexDirection::Column, direction) &&
!child->style().isFlexStartPositionAuto(
FlexDirection::Column, direction) &&
!child->style().isFlexEndPositionAuto(
FlexDirection::Column, direction)) {
childHeight =
containingNode->getLayout().measuredDimension(Dimension::Height) -
@@ -592,8 +605,7 @@ bool layoutAbsoluteDescendants(
currentNodeTopOffsetFromContainingBlock +
child->getLayout().position(PhysicalEdge::Top);
hasNewLayout = hasNewLayout ||
layoutAbsoluteDescendants(
hasNewLayout = layoutAbsoluteDescendants(
containingNode,
child,
widthSizingMode,
@@ -604,7 +616,8 @@ bool layoutAbsoluteDescendants(
childLeftOffsetFromContainingBlock,
childTopOffsetFromContainingBlock,
containingNodeAvailableInnerWidth,
containingNodeAvailableInnerHeight);
containingNodeAvailableInnerHeight) ||
hasNewLayout;
if (hasNewLayout) {
child->setHasNewLayout(hasNewLayout);

View File

@@ -10,6 +10,7 @@
#include <cfloat>
#include <cmath>
#include <cstring>
#include <string>
#include <yoga/Yoga.h>
@@ -661,6 +662,13 @@ static float distributeFreeSpaceSecondPass(
}
}
yoga::assertFatalWithNode(
currentLineChild,
yoga::isDefined(updatedMainSize),
("updatedMainSize is undefined. mainAxisownerSize: " +
std::to_string(mainAxisownerSize))
.c_str());
deltaFreeSpace += updatedMainSize - childFlexBasis;
const float marginMain = currentLineChild->style().computeMarginForAxis(
@@ -749,6 +757,20 @@ static float distributeFreeSpaceSecondPass(
const bool isLayoutPass = performLayout && !requiresStretchLayout;
// Recursively call the layout algorithm for this child with the updated
// main size.
yoga::assertFatalWithNode(
currentLineChild,
yoga::isUndefined(childMainSize)
? childMainSizingMode == SizingMode::MaxContent
: true,
"childMainSize is undefined so childMainSizingMode must be MaxContent");
yoga::assertFatalWithNode(
currentLineChild,
yoga::isUndefined(childCrossSize)
? childCrossSizingMode == SizingMode::MaxContent
: true,
"childCrossSize is undefined so childCrossSizingMode must be MaxContent");
calculateLayoutInternal(
currentLineChild,
childWidth,
@@ -1037,7 +1059,8 @@ static void justifyMainAxis(
continue;
}
if (childStyle.positionType() == PositionType::Absolute &&
child->style().isFlexStartPositionDefined(mainAxis, direction)) {
child->style().isFlexStartPositionDefined(mainAxis, direction) &&
!child->style().isFlexStartPositionAuto(mainAxis, direction)) {
if (performLayout) {
// In case the child is position absolute and has left/top being
// defined, we override the position to whatever the user said (and
@@ -1607,7 +1630,8 @@ static void calculateLayoutImpl(
// top/left/bottom/right set, override all the previously computed
// positions to set it correctly.
const bool isChildLeadingPosDefined =
child->style().isFlexStartPositionDefined(crossAxis, direction);
child->style().isFlexStartPositionDefined(crossAxis, direction) &&
!child->style().isFlexStartPositionAuto(crossAxis, direction);
if (isChildLeadingPosDefined) {
child->setLayoutPosition(
child->style().computeFlexStartPosition(

View File

@@ -226,7 +226,8 @@ float Node::relativePosition(
if (style_.positionType() == PositionType::Static) {
return 0;
}
if (style_.isInlineStartPositionDefined(axis, direction)) {
if (style_.isInlineStartPositionDefined(axis, direction) &&
!style_.isInlineStartPositionAuto(axis, direction)) {
return style_.computeInlineStartPosition(axis, direction, axisSize);
}

View File

@@ -223,22 +223,40 @@ class YG_EXPORT Style {
return computePosition(flexStartEdge(axis), direction).isDefined();
}
bool isFlexStartPositionAuto(FlexDirection axis, Direction direction) const {
return computePosition(flexStartEdge(axis), direction).isAuto();
}
bool isInlineStartPositionDefined(FlexDirection axis, Direction direction)
const {
return computePosition(inlineStartEdge(axis, direction), direction)
.isDefined();
}
bool isInlineStartPositionAuto(FlexDirection axis, Direction direction)
const {
return computePosition(inlineStartEdge(axis, direction), direction)
.isAuto();
}
bool isFlexEndPositionDefined(FlexDirection axis, Direction direction) const {
return computePosition(flexEndEdge(axis), direction).isDefined();
}
bool isFlexEndPositionAuto(FlexDirection axis, Direction direction) const {
return computePosition(flexEndEdge(axis), direction).isAuto();
}
bool isInlineEndPositionDefined(FlexDirection axis, Direction direction)
const {
return computePosition(inlineEndEdge(axis, direction), direction)
.isDefined();
}
bool isInlineEndPositionAuto(FlexDirection axis, Direction direction) const {
return computePosition(inlineEndEdge(axis, direction), direction).isAuto();
}
float computeFlexStartPosition(
FlexDirection axis,
Direction direction,