Compare commits
5 Commits
admirsahet
...
dependabot
Author | SHA1 | Date | |
---|---|---|---|
|
f443092278 | ||
|
dc4ab5ad57 | ||
|
6d6f69bee7 | ||
|
596f8dff3c | ||
|
ae8ede9b53 |
@@ -2,6 +2,18 @@
|
|||||||
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px;"></div>
|
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px;"></div>
|
||||||
</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 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 style="width:10px; height: 10px; position: absolute; end: 10px; bottom: 10px;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -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">
|
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>
|
</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>
|
||||||
|
@@ -451,6 +451,12 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
|
|||||||
|
|
||||||
YGNodeStyleSetPosition: {
|
YGNodeStyleSetPosition: {
|
||||||
value: function (nodeName, edge, value) {
|
value: function (nodeName, edge, value) {
|
||||||
|
let valueStr = toValueCpp(value);
|
||||||
|
if (valueStr != 'YGAuto') {
|
||||||
|
valueStr = ', ' + valueStr;
|
||||||
|
} else {
|
||||||
|
valueStr = '';
|
||||||
|
}
|
||||||
this.push(
|
this.push(
|
||||||
'YGNodeStyleSetPosition' +
|
'YGNodeStyleSetPosition' +
|
||||||
toFunctionName(value) +
|
toFunctionName(value) +
|
||||||
@@ -458,8 +464,7 @@ CPPEmitter.prototype = Object.create(Emitter.prototype, {
|
|||||||
nodeName +
|
nodeName +
|
||||||
', ' +
|
', ' +
|
||||||
edge +
|
edge +
|
||||||
', ' +
|
valueStr +
|
||||||
toValueCpp(value) +
|
|
||||||
');',
|
');',
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@@ -420,15 +420,21 @@ JavaEmitter.prototype = Object.create(Emitter.prototype, {
|
|||||||
|
|
||||||
YGNodeStyleSetPosition: {
|
YGNodeStyleSetPosition: {
|
||||||
value: function (nodeName, edge, value) {
|
value: function (nodeName, edge, value) {
|
||||||
|
let valueStr = toValueJava(value);
|
||||||
|
|
||||||
|
if (valueStr == 'YogaConstants.AUTO') {
|
||||||
|
valueStr = '';
|
||||||
|
} else {
|
||||||
|
valueStr = ', ' + valueStr + 'f';
|
||||||
|
}
|
||||||
this.push(
|
this.push(
|
||||||
nodeName +
|
nodeName +
|
||||||
'.setPosition' +
|
'.setPosition' +
|
||||||
toMethodName(value) +
|
toMethodName(value) +
|
||||||
'(' +
|
'(' +
|
||||||
edge +
|
edge +
|
||||||
', ' +
|
valueStr +
|
||||||
toValueJava(value) +
|
');',
|
||||||
'f);',
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@@ -364,14 +364,22 @@ JavascriptEmitter.prototype = Object.create(Emitter.prototype, {
|
|||||||
|
|
||||||
YGNodeStyleSetPosition: {
|
YGNodeStyleSetPosition: {
|
||||||
value: function (nodeName, edge, value) {
|
value: function (nodeName, edge, value) {
|
||||||
this.push(
|
const valueStr = toValueJavascript(value);
|
||||||
nodeName +
|
|
||||||
'.setPosition(' +
|
if (valueStr == "'auto'") {
|
||||||
toValueJavascript(edge) +
|
this.push(
|
||||||
', ' +
|
nodeName + '.setPositionAuto(' + toValueJavascript(edge) + ');',
|
||||||
toValueJavascript(value) +
|
);
|
||||||
');',
|
} else {
|
||||||
);
|
this.push(
|
||||||
|
nodeName +
|
||||||
|
'.setPosition(' +
|
||||||
|
toValueJavascript(edge) +
|
||||||
|
', ' +
|
||||||
|
valueStr +
|
||||||
|
');',
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -21,8 +21,8 @@ val ndkVersionProperty: String by rootProject.extra
|
|||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.facebook.yoga"
|
namespace = "com.facebook.yoga"
|
||||||
compileSdk = 34
|
compileSdk = 35
|
||||||
buildToolsVersion = "34.0.0"
|
buildToolsVersion = "35.0.0"
|
||||||
ndkVersion = "26.0.10792818"
|
ndkVersion = "26.0.10792818"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
|
@@ -84,6 +84,7 @@ public class YogaNative {
|
|||||||
static native long jni_YGNodeStyleGetPositionJNI(long nativePointer, int edge);
|
static native long jni_YGNodeStyleGetPositionJNI(long nativePointer, int edge);
|
||||||
static native void jni_YGNodeStyleSetPositionJNI(long nativePointer, int edge, float position);
|
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_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 long jni_YGNodeStyleGetWidthJNI(long nativePointer);
|
||||||
static native void jni_YGNodeStyleSetWidthJNI(long nativePointer, float width);
|
static native void jni_YGNodeStyleSetWidthJNI(long nativePointer, float width);
|
||||||
static native void jni_YGNodeStyleSetWidthPercentJNI(long nativePointer, float percent);
|
static native void jni_YGNodeStyleSetWidthPercentJNI(long nativePointer, float percent);
|
||||||
|
@@ -144,6 +144,8 @@ public abstract class YogaNode implements YogaProps {
|
|||||||
|
|
||||||
public abstract void setPositionPercent(YogaEdge edge, float percent);
|
public abstract void setPositionPercent(YogaEdge edge, float percent);
|
||||||
|
|
||||||
|
public abstract void setPositionAuto(YogaEdge edge);
|
||||||
|
|
||||||
public abstract YogaValue getWidth();
|
public abstract YogaValue getWidth();
|
||||||
|
|
||||||
public abstract void setWidth(float width);
|
public abstract void setWidth(float width);
|
||||||
|
@@ -411,6 +411,10 @@ public abstract class YogaNodeJNIBase extends YogaNode implements Cloneable {
|
|||||||
YogaNative.jni_YGNodeStyleSetPositionPercentJNI(mNativePointer, edge.intValue(), percent);
|
YogaNative.jni_YGNodeStyleSetPositionPercentJNI(mNativePointer, edge.intValue(), percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setPositionAuto(YogaEdge edge) {
|
||||||
|
YogaNative.jni_YGNodeStyleSetPositionAutoJNI(mNativePointer, edge.intValue());
|
||||||
|
}
|
||||||
|
|
||||||
public YogaValue getWidth() {
|
public YogaValue getWidth() {
|
||||||
return valueFromLong(YogaNative.jni_YGNodeStyleGetWidthJNI(mNativePointer));
|
return valueFromLong(YogaNative.jni_YGNodeStyleGetWidthJNI(mNativePointer));
|
||||||
}
|
}
|
||||||
|
@@ -460,6 +460,14 @@ static void jni_YGNodeCopyStyleJNI(
|
|||||||
static_cast<float>(value)); \
|
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, YGDirection, Direction);
|
||||||
YG_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection);
|
YG_NODE_JNI_STYLE_PROP(jint, YGFlexDirection, FlexDirection);
|
||||||
YG_NODE_JNI_STYLE_PROP(jint, YGJustify, JustifyContent);
|
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(MinHeight);
|
||||||
YG_NODE_JNI_STYLE_UNIT_PROP(MaxHeight);
|
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(
|
static jlong jni_YGNodeStyleGetMarginJNI(
|
||||||
JNIEnv* /*env*/,
|
JNIEnv* /*env*/,
|
||||||
@@ -891,6 +899,9 @@ static JNINativeMethod methods[] = {
|
|||||||
{"jni_YGNodeStyleSetPositionPercentJNI",
|
{"jni_YGNodeStyleSetPositionPercentJNI",
|
||||||
"(JIF)V",
|
"(JIF)V",
|
||||||
(void*)jni_YGNodeStyleSetPositionPercentJNI},
|
(void*)jni_YGNodeStyleSetPositionPercentJNI},
|
||||||
|
{"jni_YGNodeStyleSetPositionAutoJNI",
|
||||||
|
"(JI)V",
|
||||||
|
(void*)jni_YGNodeStyleSetPositionAutoJNI},
|
||||||
{"jni_YGNodeStyleGetWidthJNI", "(J)J", (void*)jni_YGNodeStyleGetWidthJNI},
|
{"jni_YGNodeStyleGetWidthJNI", "(J)J", (void*)jni_YGNodeStyleGetWidthJNI},
|
||||||
{"jni_YGNodeStyleSetWidthJNI", "(JF)V", (void*)jni_YGNodeStyleSetWidthJNI},
|
{"jni_YGNodeStyleSetWidthJNI", "(JF)V", (void*)jni_YGNodeStyleSetWidthJNI},
|
||||||
{"jni_YGNodeStyleSetWidthPercentJNI",
|
{"jni_YGNodeStyleSetWidthPercentJNI",
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* 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
|
* 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);
|
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
|
@Test
|
||||||
public void test_absolute_layout_width_height_end_bottom() {
|
public void test_absolute_layout_width_height_end_bottom() {
|
||||||
YogaConfig config = YogaConfigFactory.create();
|
YogaConfig config = YogaConfigFactory.create();
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* 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
|
* 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);
|
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) {
|
private YogaNode createNode(YogaConfig config) {
|
||||||
return mNodeFactory.create(config);
|
return mNodeFactory.create(config);
|
||||||
}
|
}
|
||||||
|
@@ -87,6 +87,10 @@ void Node::setPositionPercent(int edge, double position) {
|
|||||||
YGNodeStyleSetPositionPercent(m_node, static_cast<YGEdge>(edge), 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) {
|
void Node::setAlignContent(int alignContent) {
|
||||||
YGNodeStyleSetAlignContent(m_node, static_cast<YGAlign>(alignContent));
|
YGNodeStyleSetAlignContent(m_node, static_cast<YGAlign>(alignContent));
|
||||||
}
|
}
|
||||||
|
@@ -76,6 +76,7 @@ class Node {
|
|||||||
void setPositionType(int positionType);
|
void setPositionType(int positionType);
|
||||||
void setPosition(int edge, double position);
|
void setPosition(int edge, double position);
|
||||||
void setPositionPercent(int edge, double position);
|
void setPositionPercent(int edge, double position);
|
||||||
|
void setPositionAuto(int edge);
|
||||||
|
|
||||||
void setAlignContent(int alignContent);
|
void setAlignContent(int alignContent);
|
||||||
void setAlignItems(int alignItems);
|
void setAlignItems(int alignItems);
|
||||||
|
@@ -70,6 +70,7 @@ EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
|
|||||||
.function("setPositionType", &Node::setPositionType)
|
.function("setPositionType", &Node::setPositionType)
|
||||||
.function("setPosition", &Node::setPosition)
|
.function("setPosition", &Node::setPosition)
|
||||||
.function("setPositionPercent", &Node::setPositionPercent)
|
.function("setPositionPercent", &Node::setPositionPercent)
|
||||||
|
.function("setPositionAuto", &Node::setPositionAuto)
|
||||||
|
|
||||||
.function("setAlignContent", &Node::setAlignContent)
|
.function("setAlignContent", &Node::setAlignContent)
|
||||||
.function("setAlignItems", &Node::setAlignItems)
|
.function("setAlignItems", &Node::setAlignItems)
|
||||||
|
@@ -168,6 +168,7 @@ export type Node = {
|
|||||||
setPosition(edge: Edge, position: number | `${number}%` | undefined): void;
|
setPosition(edge: Edge, position: number | `${number}%` | undefined): void;
|
||||||
setPositionPercent(edge: Edge, position: number | undefined): void;
|
setPositionPercent(edge: Edge, position: number | undefined): void;
|
||||||
setPositionType(positionType: PositionType): void;
|
setPositionType(positionType: PositionType): void;
|
||||||
|
setPositionAuto(edge: Edge): void;
|
||||||
setWidth(width: number | 'auto' | `${number}%` | undefined): void;
|
setWidth(width: number | 'auto' | `${number}%` | undefined): void;
|
||||||
setWidthAuto(): void;
|
setWidthAuto(): void;
|
||||||
setWidthPercent(width: number | undefined): void;
|
setWidthPercent(width: number | undefined): void;
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* 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
|
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAbsolutePositionTest.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -75,6 +75,150 @@ test('absolute_layout_width_height_start_top', () => {
|
|||||||
config.free();
|
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', () => {
|
test('absolute_layout_width_height_end_bottom', () => {
|
||||||
const config = Yoga.Config.create();
|
const config = Yoga.Config.create();
|
||||||
let root;
|
let root;
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* 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
|
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -6192,3 +6192,146 @@ test('static_position_static_root', () => {
|
|||||||
config.free();
|
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);
|
YGNodeStyleSetHeight(root_child0, 10);
|
||||||
YGNodeInsertChild(root, root_child0, 0);
|
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();
|
YGNodeRef root_child0_child0 = YGNodeNew();
|
||||||
YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeStatic);
|
YGNodeStyleSetPositionType(root_child0_child0, YGPositionTypeStatic);
|
||||||
YGNodeStyleSetWidth(root_child0_child0, 5);
|
YGNodeStyleSetWidth(root_child0_child0, 5);
|
||||||
YGNodeStyleSetHeight(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();
|
YGNodeRef root_child0_child0_child0 = YGNodeNew();
|
||||||
YGNodeStyleSetPositionType(root_child0_child0_child0, YGPositionTypeAbsolute);
|
YGNodeStyleSetPositionType(root_child0_child0_child0, YGPositionTypeAbsolute);
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* clang-format off
|
* clang-format off
|
||||||
* @generated SignedSource<<425ef3591b2f5cf0bc6d9daa9c5db96c>>
|
* @generated SignedSource<<499316b3f7b7ec5c406abf5ac77837f1>>
|
||||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGAbsolutePositionTest.html
|
* 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);
|
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) {
|
TEST(YogaTest, absolute_layout_width_height_end_bottom) {
|
||||||
YGConfigRef config = YGConfigNew();
|
YGConfigRef config = YGConfigNew();
|
||||||
|
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*
|
*
|
||||||
* clang-format off
|
* clang-format off
|
||||||
* @generated SignedSource<<03c511300b41c81c3592dd5df34bc2b9>>
|
* @generated SignedSource<<83ad08d246e0d406b525b1b1d5290b35>>
|
||||||
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html
|
* generated by gentest/gentest-driver.ts from gentest/fixtures/YGStaticPositionTest.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -5933,3 +5933,142 @@ TEST(YogaTest, static_position_static_root) {
|
|||||||
|
|
||||||
YGConfigFree(config);
|
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);
|
||||||
|
}
|
||||||
|
41
yarn.lock
41
yarn.lock
@@ -3592,7 +3592,7 @@ brace-expansion@^2.0.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
balanced-match "^1.0.0"
|
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"
|
version "3.0.3"
|
||||||
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
|
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.3.tgz#490332f40919452272d55a8480adc0c441358789"
|
||||||
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
|
integrity sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==
|
||||||
@@ -8166,11 +8166,11 @@ micromark@^4.0.0:
|
|||||||
micromark-util-types "^2.0.0"
|
micromark-util-types "^2.0.0"
|
||||||
|
|
||||||
micromatch@^4.0.2, micromatch@^4.0.4, micromatch@^4.0.5:
|
micromatch@^4.0.2, micromatch@^4.0.4, micromatch@^4.0.5:
|
||||||
version "4.0.5"
|
version "4.0.8"
|
||||||
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6"
|
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202"
|
||||||
integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==
|
integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==
|
||||||
dependencies:
|
dependencies:
|
||||||
braces "^3.0.2"
|
braces "^3.0.3"
|
||||||
picomatch "^2.3.1"
|
picomatch "^2.3.1"
|
||||||
|
|
||||||
mime-db@1.52.0, "mime-db@>= 1.43.0 < 2":
|
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"
|
char-regex "^1.0.2"
|
||||||
strip-ansi "^6.0.0"
|
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"
|
version "4.2.3"
|
||||||
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
|
||||||
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
|
||||||
@@ -10383,7 +10392,14 @@ stringify-object@^3.3.0:
|
|||||||
is-obj "^1.0.1"
|
is-obj "^1.0.1"
|
||||||
is-regexp "^1.0.0"
|
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"
|
version "6.0.1"
|
||||||
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
|
||||||
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
|
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"
|
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
|
||||||
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==
|
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"
|
version "7.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
|
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
|
||||||
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
|
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
|
||||||
|
@@ -205,6 +205,11 @@ void YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float percent) {
|
|||||||
node, scopedEnum(edge), value::percent(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) {
|
YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge) {
|
||||||
return (YGValue)resolveRef(node)->style().position(scopedEnum(edge));
|
return (YGValue)resolveRef(node)->style().position(scopedEnum(edge));
|
||||||
}
|
}
|
||||||
|
@@ -71,8 +71,10 @@ YGNodeStyleSetPosition(YGNodeRef node, YGEdge edge, float position);
|
|||||||
YG_EXPORT void
|
YG_EXPORT void
|
||||||
YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float position);
|
YGNodeStyleSetPositionPercent(YGNodeRef node, YGEdge edge, float position);
|
||||||
YG_EXPORT YGValue YGNodeStyleGetPosition(YGNodeConstRef node, YGEdge edge);
|
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
|
YG_EXPORT void
|
||||||
YGNodeStyleSetMarginPercent(YGNodeRef node, YGEdge edge, float margin);
|
YGNodeStyleSetMarginPercent(YGNodeRef node, YGEdge edge, float margin);
|
||||||
YG_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge);
|
YG_EXPORT void YGNodeStyleSetMarginAuto(YGNodeRef node, YGEdge edge);
|
||||||
|
@@ -154,7 +154,8 @@ static void positionAbsoluteChildLegacy(
|
|||||||
(parent->style().flexWrap() == Wrap::WrapReverse));
|
(parent->style().flexWrap() == Wrap::WrapReverse));
|
||||||
|
|
||||||
if (child->style().isFlexEndPositionDefined(axis, direction) &&
|
if (child->style().isFlexEndPositionDefined(axis, direction) &&
|
||||||
!child->style().isFlexStartPositionDefined(axis, direction)) {
|
(!child->style().isFlexStartPositionDefined(axis, direction) ||
|
||||||
|
child->style().isFlexStartPositionAuto(axis, direction))) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
containingNode->getLayout().measuredDimension(dimension(axis)) -
|
containingNode->getLayout().measuredDimension(dimension(axis)) -
|
||||||
child->getLayout().measuredDimension(dimension(axis)) -
|
child->getLayout().measuredDimension(dimension(axis)) -
|
||||||
@@ -169,7 +170,8 @@ static void positionAbsoluteChildLegacy(
|
|||||||
isAxisRow ? containingBlockWidth : containingBlockHeight),
|
isAxisRow ? containingBlockWidth : containingBlockHeight),
|
||||||
flexStartEdge(axis));
|
flexStartEdge(axis));
|
||||||
} else if (
|
} else if (
|
||||||
!child->style().isFlexStartPositionDefined(axis, direction) &&
|
(!child->style().isFlexStartPositionDefined(axis, direction) ||
|
||||||
|
child->style().isFlexStartPositionAuto(axis, direction)) &&
|
||||||
shouldCenter) {
|
shouldCenter) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
(parent->getLayout().measuredDimension(dimension(axis)) -
|
(parent->getLayout().measuredDimension(dimension(axis)) -
|
||||||
@@ -177,7 +179,8 @@ static void positionAbsoluteChildLegacy(
|
|||||||
2.0f,
|
2.0f,
|
||||||
flexStartEdge(axis));
|
flexStartEdge(axis));
|
||||||
} else if (
|
} else if (
|
||||||
!child->style().isFlexStartPositionDefined(axis, direction) &&
|
(!child->style().isFlexStartPositionDefined(axis, direction) ||
|
||||||
|
child->style().isFlexStartPositionAuto(axis, direction)) &&
|
||||||
shouldFlexEnd) {
|
shouldFlexEnd) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
(parent->getLayout().measuredDimension(dimension(axis)) -
|
(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
|
// 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
|
// flex-start edge and then filling in the flex-end direction at the end if
|
||||||
// necessary.
|
// necessary.
|
||||||
if (child->style().isInlineStartPositionDefined(axis, direction)) {
|
if (child->style().isInlineStartPositionDefined(axis, direction) &&
|
||||||
|
!child->style().isInlineStartPositionAuto(axis, direction)) {
|
||||||
const float positionRelativeToInlineStart =
|
const float positionRelativeToInlineStart =
|
||||||
child->style().computeInlineStartPosition(
|
child->style().computeInlineStartPosition(
|
||||||
axis, direction, containingBlockSize) +
|
axis, direction, containingBlockSize) +
|
||||||
@@ -237,7 +241,9 @@ static void positionAbsoluteChildImpl(
|
|||||||
: positionRelativeToInlineStart;
|
: positionRelativeToInlineStart;
|
||||||
|
|
||||||
child->setLayoutPosition(positionRelativeToFlexStart, flexStartEdge(axis));
|
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 =
|
const float positionRelativeToInlineStart =
|
||||||
containingNode->getLayout().measuredDimension(dimension(axis)) -
|
containingNode->getLayout().measuredDimension(dimension(axis)) -
|
||||||
child->getLayout().measuredDimension(dimension(axis)) -
|
child->getLayout().measuredDimension(dimension(axis)) -
|
||||||
@@ -328,7 +334,10 @@ void layoutAbsoluteChild(
|
|||||||
if (child->style().isFlexStartPositionDefined(
|
if (child->style().isFlexStartPositionDefined(
|
||||||
FlexDirection::Row, direction) &&
|
FlexDirection::Row, direction) &&
|
||||||
child->style().isFlexEndPositionDefined(
|
child->style().isFlexEndPositionDefined(
|
||||||
FlexDirection::Row, direction)) {
|
FlexDirection::Row, direction) &&
|
||||||
|
!child->style().isFlexStartPositionAuto(
|
||||||
|
FlexDirection::Row, direction) &&
|
||||||
|
!child->style().isFlexEndPositionAuto(FlexDirection::Row, direction)) {
|
||||||
childWidth =
|
childWidth =
|
||||||
containingNode->getLayout().measuredDimension(Dimension::Width) -
|
containingNode->getLayout().measuredDimension(Dimension::Width) -
|
||||||
(containingNode->style().computeFlexStartBorder(
|
(containingNode->style().computeFlexStartBorder(
|
||||||
@@ -360,6 +369,10 @@ void layoutAbsoluteChild(
|
|||||||
if (child->style().isFlexStartPositionDefined(
|
if (child->style().isFlexStartPositionDefined(
|
||||||
FlexDirection::Column, direction) &&
|
FlexDirection::Column, direction) &&
|
||||||
child->style().isFlexEndPositionDefined(
|
child->style().isFlexEndPositionDefined(
|
||||||
|
FlexDirection::Column, direction) &&
|
||||||
|
!child->style().isFlexStartPositionAuto(
|
||||||
|
FlexDirection::Column, direction) &&
|
||||||
|
!child->style().isFlexEndPositionAuto(
|
||||||
FlexDirection::Column, direction)) {
|
FlexDirection::Column, direction)) {
|
||||||
childHeight =
|
childHeight =
|
||||||
containingNode->getLayout().measuredDimension(Dimension::Height) -
|
containingNode->getLayout().measuredDimension(Dimension::Height) -
|
||||||
@@ -592,8 +605,7 @@ bool layoutAbsoluteDescendants(
|
|||||||
currentNodeTopOffsetFromContainingBlock +
|
currentNodeTopOffsetFromContainingBlock +
|
||||||
child->getLayout().position(PhysicalEdge::Top);
|
child->getLayout().position(PhysicalEdge::Top);
|
||||||
|
|
||||||
hasNewLayout = hasNewLayout ||
|
hasNewLayout = layoutAbsoluteDescendants(
|
||||||
layoutAbsoluteDescendants(
|
|
||||||
containingNode,
|
containingNode,
|
||||||
child,
|
child,
|
||||||
widthSizingMode,
|
widthSizingMode,
|
||||||
@@ -604,7 +616,8 @@ bool layoutAbsoluteDescendants(
|
|||||||
childLeftOffsetFromContainingBlock,
|
childLeftOffsetFromContainingBlock,
|
||||||
childTopOffsetFromContainingBlock,
|
childTopOffsetFromContainingBlock,
|
||||||
containingNodeAvailableInnerWidth,
|
containingNodeAvailableInnerWidth,
|
||||||
containingNodeAvailableInnerHeight);
|
containingNodeAvailableInnerHeight) ||
|
||||||
|
hasNewLayout;
|
||||||
|
|
||||||
if (hasNewLayout) {
|
if (hasNewLayout) {
|
||||||
child->setHasNewLayout(hasNewLayout);
|
child->setHasNewLayout(hasNewLayout);
|
||||||
|
@@ -57,49 +57,63 @@ bool canUseCachedMeasurement(
|
|||||||
const float marginColumn,
|
const float marginColumn,
|
||||||
const yoga::Config* const config) {
|
const yoga::Config* const config) {
|
||||||
if ((yoga::isDefined(lastComputedHeight) && lastComputedHeight < 0) ||
|
if ((yoga::isDefined(lastComputedHeight) && lastComputedHeight < 0) ||
|
||||||
(yoga::isDefined(lastComputedWidth) && lastComputedWidth < 0)) {
|
((yoga::isDefined(lastComputedWidth)) && lastComputedWidth < 0)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const float pointScaleFactor = config->getPointScaleFactor();
|
const float pointScaleFactor = config->getPointScaleFactor();
|
||||||
|
|
||||||
bool useRoundedComparison = config != nullptr && pointScaleFactor != 0;
|
bool useRoundedComparison = config != nullptr && pointScaleFactor != 0;
|
||||||
|
const float effectiveWidth = useRoundedComparison
|
||||||
auto roundIfNeeded = [&](float value) {
|
? roundValueToPixelGrid(availableWidth, pointScaleFactor, false, false)
|
||||||
return useRoundedComparison
|
: availableWidth;
|
||||||
? roundValueToPixelGrid(value, pointScaleFactor, false, false)
|
const float effectiveHeight = useRoundedComparison
|
||||||
: value;
|
? roundValueToPixelGrid(availableHeight, pointScaleFactor, false, false)
|
||||||
};
|
: availableHeight;
|
||||||
|
const float effectiveLastWidth = useRoundedComparison
|
||||||
const float effectiveWidth = roundIfNeeded(availableWidth);
|
? roundValueToPixelGrid(
|
||||||
const float effectiveHeight = roundIfNeeded(availableHeight);
|
lastAvailableWidth, pointScaleFactor, false, false)
|
||||||
const float effectiveLastWidth = roundIfNeeded(lastAvailableWidth);
|
: lastAvailableWidth;
|
||||||
const float effectiveLastHeight = roundIfNeeded(lastAvailableHeight);
|
const float effectiveLastHeight = useRoundedComparison
|
||||||
|
? roundValueToPixelGrid(
|
||||||
|
lastAvailableHeight, pointScaleFactor, false, false)
|
||||||
|
: lastAvailableHeight;
|
||||||
|
|
||||||
const bool hasSameWidthSpec = lastWidthMode == widthMode &&
|
const bool hasSameWidthSpec = lastWidthMode == widthMode &&
|
||||||
yoga::inexactEquals(effectiveLastWidth, effectiveWidth);
|
yoga::inexactEquals(effectiveLastWidth, effectiveWidth);
|
||||||
const bool hasSameHeightSpec = lastHeightMode == heightMode &&
|
const bool hasSameHeightSpec = lastHeightMode == heightMode &&
|
||||||
yoga::inexactEquals(effectiveLastHeight, effectiveHeight);
|
yoga::inexactEquals(effectiveLastHeight, effectiveHeight);
|
||||||
|
|
||||||
const float adjustedWidth = availableWidth - marginRow;
|
|
||||||
const float adjustedHeight = availableHeight - marginColumn;
|
|
||||||
|
|
||||||
const bool widthIsCompatible =
|
const bool widthIsCompatible =
|
||||||
hasSameWidthSpec ||
|
hasSameWidthSpec ||
|
||||||
sizeIsExactAndMatchesOldMeasuredSize(
|
sizeIsExactAndMatchesOldMeasuredSize(
|
||||||
widthMode, adjustedWidth, lastComputedWidth) ||
|
widthMode, availableWidth - marginRow, lastComputedWidth) ||
|
||||||
oldSizeIsMaxContentAndStillFits(
|
oldSizeIsMaxContentAndStillFits(
|
||||||
widthMode, adjustedWidth, lastWidthMode, lastComputedWidth) ||
|
widthMode,
|
||||||
|
availableWidth - marginRow,
|
||||||
|
lastWidthMode,
|
||||||
|
lastComputedWidth) ||
|
||||||
newSizeIsStricterAndStillValid(
|
newSizeIsStricterAndStillValid(
|
||||||
widthMode, adjustedWidth, lastWidthMode, lastAvailableWidth, lastComputedWidth);
|
widthMode,
|
||||||
|
availableWidth - marginRow,
|
||||||
|
lastWidthMode,
|
||||||
|
lastAvailableWidth,
|
||||||
|
lastComputedWidth);
|
||||||
|
|
||||||
const bool heightIsCompatible =
|
const bool heightIsCompatible = hasSameHeightSpec ||
|
||||||
hasSameHeightSpec ||
|
|
||||||
sizeIsExactAndMatchesOldMeasuredSize(
|
sizeIsExactAndMatchesOldMeasuredSize(
|
||||||
heightMode, adjustedHeight, lastComputedHeight) ||
|
heightMode,
|
||||||
oldSizeIsMaxContentAndStillFits(
|
availableHeight - marginColumn,
|
||||||
heightMode, adjustedHeight, lastHeightMode, lastComputedHeight) ||
|
lastComputedHeight) ||
|
||||||
newSizeIsStricterAndStillValid(
|
oldSizeIsMaxContentAndStillFits(heightMode,
|
||||||
heightMode, adjustedHeight, lastHeightMode, lastAvailableHeight, lastComputedHeight);
|
availableHeight - marginColumn,
|
||||||
|
lastHeightMode,
|
||||||
|
lastComputedHeight) ||
|
||||||
|
newSizeIsStricterAndStillValid(heightMode,
|
||||||
|
availableHeight - marginColumn,
|
||||||
|
lastHeightMode,
|
||||||
|
lastAvailableHeight,
|
||||||
|
lastComputedHeight);
|
||||||
|
|
||||||
return widthIsCompatible && heightIsCompatible;
|
return widthIsCompatible && heightIsCompatible;
|
||||||
}
|
}
|
||||||
|
@@ -10,6 +10,7 @@
|
|||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <yoga/Yoga.h>
|
#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;
|
deltaFreeSpace += updatedMainSize - childFlexBasis;
|
||||||
|
|
||||||
const float marginMain = currentLineChild->style().computeMarginForAxis(
|
const float marginMain = currentLineChild->style().computeMarginForAxis(
|
||||||
@@ -749,6 +757,20 @@ static float distributeFreeSpaceSecondPass(
|
|||||||
const bool isLayoutPass = performLayout && !requiresStretchLayout;
|
const bool isLayoutPass = performLayout && !requiresStretchLayout;
|
||||||
// Recursively call the layout algorithm for this child with the updated
|
// Recursively call the layout algorithm for this child with the updated
|
||||||
// main size.
|
// 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(
|
calculateLayoutInternal(
|
||||||
currentLineChild,
|
currentLineChild,
|
||||||
childWidth,
|
childWidth,
|
||||||
@@ -1037,7 +1059,8 @@ static void justifyMainAxis(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (childStyle.positionType() == PositionType::Absolute &&
|
if (childStyle.positionType() == PositionType::Absolute &&
|
||||||
child->style().isFlexStartPositionDefined(mainAxis, direction)) {
|
child->style().isFlexStartPositionDefined(mainAxis, direction) &&
|
||||||
|
!child->style().isFlexStartPositionAuto(mainAxis, direction)) {
|
||||||
if (performLayout) {
|
if (performLayout) {
|
||||||
// In case the child is position absolute and has left/top being
|
// In case the child is position absolute and has left/top being
|
||||||
// defined, we override the position to whatever the user said (and
|
// 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
|
// top/left/bottom/right set, override all the previously computed
|
||||||
// positions to set it correctly.
|
// positions to set it correctly.
|
||||||
const bool isChildLeadingPosDefined =
|
const bool isChildLeadingPosDefined =
|
||||||
child->style().isFlexStartPositionDefined(crossAxis, direction);
|
child->style().isFlexStartPositionDefined(crossAxis, direction) &&
|
||||||
|
!child->style().isFlexStartPositionAuto(crossAxis, direction);
|
||||||
if (isChildLeadingPosDefined) {
|
if (isChildLeadingPosDefined) {
|
||||||
child->setLayoutPosition(
|
child->setLayoutPosition(
|
||||||
child->style().computeFlexStartPosition(
|
child->style().computeFlexStartPosition(
|
||||||
|
@@ -226,7 +226,8 @@ float Node::relativePosition(
|
|||||||
if (style_.positionType() == PositionType::Static) {
|
if (style_.positionType() == PositionType::Static) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (style_.isInlineStartPositionDefined(axis, direction)) {
|
if (style_.isInlineStartPositionDefined(axis, direction) &&
|
||||||
|
!style_.isInlineStartPositionAuto(axis, direction)) {
|
||||||
return style_.computeInlineStartPosition(axis, direction, axisSize);
|
return style_.computeInlineStartPosition(axis, direction, axisSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -223,22 +223,40 @@ class YG_EXPORT Style {
|
|||||||
return computePosition(flexStartEdge(axis), direction).isDefined();
|
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)
|
bool isInlineStartPositionDefined(FlexDirection axis, Direction direction)
|
||||||
const {
|
const {
|
||||||
return computePosition(inlineStartEdge(axis, direction), direction)
|
return computePosition(inlineStartEdge(axis, direction), direction)
|
||||||
.isDefined();
|
.isDefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isInlineStartPositionAuto(FlexDirection axis, Direction direction)
|
||||||
|
const {
|
||||||
|
return computePosition(inlineStartEdge(axis, direction), direction)
|
||||||
|
.isAuto();
|
||||||
|
}
|
||||||
|
|
||||||
bool isFlexEndPositionDefined(FlexDirection axis, Direction direction) const {
|
bool isFlexEndPositionDefined(FlexDirection axis, Direction direction) const {
|
||||||
return computePosition(flexEndEdge(axis), direction).isDefined();
|
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)
|
bool isInlineEndPositionDefined(FlexDirection axis, Direction direction)
|
||||||
const {
|
const {
|
||||||
return computePosition(inlineEndEdge(axis, direction), direction)
|
return computePosition(inlineEndEdge(axis, direction), direction)
|
||||||
.isDefined();
|
.isDefined();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isInlineEndPositionAuto(FlexDirection axis, Direction direction) const {
|
||||||
|
return computePosition(inlineEndEdge(axis, direction), direction).isAuto();
|
||||||
|
}
|
||||||
|
|
||||||
float computeFlexStartPosition(
|
float computeFlexStartPosition(
|
||||||
FlexDirection axis,
|
FlexDirection axis,
|
||||||
Direction direction,
|
Direction direction,
|
||||||
|
Reference in New Issue
Block a user